@marimo-team/frontend 0.25.3-dev95 → 0.25.3-dev97
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{CellStatus-CplYFNTy.js → CellStatus-fK4n2NPc.js} +1 -1
- package/dist/assets/{ErrorBoundary-CdGuz4a_.js → ErrorBoundary-CAEGdoFW.js} +2 -2
- package/dist/assets/{JsonOutput-Csbov8Fx.js → JsonOutput-CyAKmZDD.js} +1 -1
- package/dist/assets/{MarimoErrorOutput-czclLlOn.js → MarimoErrorOutput-CgZvP0p0.js} +1 -1
- package/dist/assets/{RenderHTML-CNDedpS4.js → RenderHTML-DQvxDDNS.js} +1 -1
- package/dist/assets/{RunButton-CRfdOxVd.js → RunButton-BBDnDL6G.js} +1 -1
- package/dist/assets/{add-cell-with-ai-BAIX7r0P.js → add-cell-with-ai-Clg5FELx.js} +2 -2
- package/dist/assets/{add-connection-dialog-DrDuM-tI.js → add-connection-dialog-BqdWmD-7.js} +1 -1
- package/dist/assets/{agent-panel-CoXq_rlA.js → agent-panel-5RxG5Y82.js} +3 -3
- package/dist/assets/{ai-model-dropdown-COvWn46z.js → ai-model-dropdown-Bvl1ktQq.js} +2 -2
- package/dist/assets/{app-config-button-CtxoYG4F.js → app-config-button-0QTeQ2Mv.js} +1 -1
- package/dist/assets/{blob-DCjrjZKW.js → blob-5VcB8K_t.js} +1 -1
- package/dist/assets/{cache-panel-CbWZcBu0.js → cache-panel-BV-c7ed0.js} +1 -1
- package/dist/assets/{cell-editor-BnL0Sorl.js → cell-editor-Byw5y-oI.js} +2 -2
- package/dist/assets/{cell-link-BFbgKiRH.js → cell-link-C5yYyzuF.js} +1 -1
- package/dist/assets/{cells-yOs72eZm.js → cells-D_11MjVB.js} +13 -13
- package/dist/assets/{chat-display-DwRM41t_.js → chat-display-BCR_ySiV.js} +1 -1
- package/dist/assets/{chat-panel-DeTEdjxF.js → chat-panel-RPRvBsaU.js} +2 -2
- package/dist/assets/{chat-ui-D6XucD07.js → chat-ui-CGviVaRA.js} +3 -3
- package/dist/assets/column-preview-xe533-Cn.js +1 -0
- package/dist/assets/{command-palette-CA6yfNLb.js → command-palette-BB9bWdWp.js} +1 -1
- package/dist/assets/{common-B-ZYnO1x.js → common-CaeItbcI.js} +1 -1
- package/dist/assets/{components-vu2jLG08.js → components-G6frbw0c.js} +1 -1
- package/dist/assets/{datasource-BakEOWsf.js → datasource-deuXnlU-.js} +1 -1
- package/dist/assets/{dependency-graph-panel-DCGB3_id.js → dependency-graph-panel-CIykLnJe.js} +2 -2
- package/dist/assets/{documentation-panel-CpGZ2Dfn.js → documentation-panel-2PQ8kQLa.js} +1 -1
- package/dist/assets/{download-CV1k4XQ4.js → download-dK52bLxZ.js} +1 -1
- package/dist/assets/{edit-page-By7n2M84.js → edit-page-C2phWLKH.js} +6 -6
- package/dist/assets/{error-entries-JgrZYMbe.js → error-entries-3GVk2KjS.js} +1 -1
- package/dist/assets/{error-panel-DS7HWph-.js → error-panel-CzDRGPeC.js} +1 -1
- package/dist/assets/{feedback-button-eYsTCK-g.js → feedback-button-C5NgWpFg.js} +1 -1
- package/dist/assets/feedback-button-CONwLFpw.js +1 -0
- package/dist/assets/{file-explorer-panel-BTLwwwD4.js → file-explorer-panel-B50xDnTZ.js} +1 -1
- package/dist/assets/{file-name-input-BaR4h2Ud.js → file-name-input-DqwMSgGU.js} +1 -1
- package/dist/assets/{floating-outline-Drd73Quo.js → floating-outline-ChmAuvxz.js} +1 -1
- package/dist/assets/{gallery-page-DXUD11Rm.js → gallery-page-CiL8aMS1.js} +1 -1
- package/dist/assets/{glide-data-editor-DqBBoQBl.js → glide-data-editor-CqRclBkp.js} +1 -1
- package/dist/assets/{home-page-pgFFsmga.js → home-page-BgZVl4dP.js} +1 -1
- package/dist/assets/{hooks-D25kP4Sr.js → hooks-DM5n7Osw.js} +1 -1
- package/dist/assets/index-vCxv6WVQ.js +30 -0
- package/dist/assets/{layout-DLHIGZTK.js → layout-BpP8nTjb.js} +4 -4
- package/dist/assets/{logs-panel-D5AAD2s9.js → logs-panel-B5eVAZtH.js} +1 -1
- package/dist/assets/{markdown-renderer--CwVm4kJ.js → markdown-renderer-BWUzqkJM.js} +1 -1
- package/dist/assets/{name-cell-input-BFKZaNI5.js → name-cell-input-DXW68gRW.js} +1 -1
- package/dist/assets/{outline-panel-qcwRnl0R.js → outline-panel-DPxJhJ_A.js} +1 -1
- package/dist/assets/{packages-panel-DnSryNcz.js → packages-panel-gBE2FWQr.js} +1 -1
- package/dist/assets/{panel-accordion-state-BwJpDMVt.js → panel-accordion-state-CCF5Gxnc.js} +1 -1
- package/dist/assets/{panels-Aqzwb3UR.js → panels-BQYMF6p_.js} +1 -1
- package/dist/assets/{process-output-DuUfHYSr.js → process-output-Cw9IDcKQ.js} +1 -1
- package/dist/assets/{readonly-code-display-BY-9I_Yk.js → readonly-code-display-DYcZQ28T.js} +1 -1
- package/dist/assets/{readonly-python-code-DSyr-yE2.js → readonly-python-code-RFuQP50v.js} +1 -1
- package/dist/assets/{reveal-component-C_Lb7Mom.js → reveal-component-yRrDmCQz.js} +2 -2
- package/dist/assets/{run-page-ZTw-kCU-.js → run-page-CY65WUOu.js} +1 -1
- package/dist/assets/{runtime-details-state-B7gpnuXx.js → runtime-details-state-pobtu6TO.js} +1 -1
- package/dist/assets/scratchpad-panel-H44_pvb_.js +1 -0
- package/dist/assets/session-panel-Bnd1iXkO.js +1 -0
- package/dist/assets/{snippets-panel-BNadUJLU.js → snippets-panel-DKApxKx9.js} +1 -1
- package/dist/assets/{state-BaYudep3.js → state-Bl9BiY_s.js} +1 -1
- package/dist/assets/{state-_1LTGJQM.js → state-Dv059B3A.js} +1 -1
- package/dist/assets/{tracing-DbTgS4u9.js → tracing-Clwy4SlW.js} +1 -1
- package/dist/assets/{tracing-panel-CjlrpXPy.js → tracing-panel-BwjLG_aC.js} +2 -2
- package/dist/assets/{tree-actions-C_KYlaSv.js → tree-actions-BZNTQ12N.js} +1 -1
- package/dist/assets/{useAddCell-C0J8quGE.js → useAddCell-Cjuqk2YR.js} +1 -1
- package/dist/assets/{useCellActionButton-CbkOj6BE.js → useCellActionButton-MoWLvuGe.js} +1 -1
- package/dist/assets/{useDeleteCell-DHkF5wgS.js → useDeleteCell-BC-MW7d1.js} +1 -1
- package/dist/assets/{useDependencyPanelTab--yXJW6X5.js → useDependencyPanelTab-CZU7i-B3.js} +1 -1
- package/dist/assets/{useNotebookActions-dJQalORg.js → useNotebookActions-wFxVdRXQ.js} +1 -1
- package/dist/assets/{useRunCells-C_IwVJR_.js → useRunCells-ByaWxoIt.js} +1 -1
- package/dist/assets/{useSplitCell-Ci4MEUj8.js → useSplitCell-YJIystwv.js} +1 -1
- package/dist/index.html +20 -20
- package/package.json +1 -1
- package/src/components/app-config/ai-config.tsx +1 -0
- package/src/components/chat/acp/blocks.tsx +2 -2
- package/src/components/chat/chat-components.tsx +2 -0
- package/src/components/chat/chat-panel.tsx +6 -1
- package/src/components/data-table/__tests__/column-explorer.test.tsx +27 -1
- package/src/components/data-table/charts/__tests__/chart-panel.test.tsx +74 -1
- package/src/components/data-table/charts/__tests__/storage.test.ts +4 -1
- package/src/components/data-table/charts/charts.tsx +21 -6
- package/src/components/data-table/charts/storage.ts +16 -5
- package/src/components/data-table/column-explorer-panel/column-explorer.tsx +1 -1
- package/src/components/datasources/__tests__/column-actions.test.tsx +97 -0
- package/src/components/datasources/__tests__/column-preview.test.tsx +63 -2
- package/src/components/datasources/column-preview.tsx +8 -2
- package/src/components/datasources/datasources.tsx +12 -14
- package/src/components/debugger/debugger-code.tsx +5 -0
- package/src/components/dependency-graph/panels.tsx +2 -1
- package/src/components/editor/ai/ai-completion-editor.tsx +1 -0
- package/src/components/editor/alerts/startup-logs-alert.tsx +1 -0
- package/src/components/editor/cell/DeleteButton.tsx +1 -0
- package/src/components/editor/chrome/panels/cache-panel.tsx +1 -0
- package/src/components/editor/chrome/wrapper/__tests__/pending-ai-cells.test.tsx +58 -1
- package/src/components/editor/chrome/wrapper/pending-ai-cells.tsx +12 -2
- package/src/components/editor/notebook-banner.tsx +1 -0
- package/src/components/editor/output/ansi-reduce.ts +6 -0
- package/src/components/editor/output/console/ConsoleOutput.tsx +11 -7
- package/src/components/editor/package-alert.tsx +6 -4
- package/src/components/editor/renderers/vertical-layout/sidebar/toggle.tsx +7 -1
- package/src/components/mcp/mcp-status-indicator.tsx +1 -1
- package/src/components/scratchpad/scratchpad.tsx +2 -2
- package/src/components/slides/reveal-component.tsx +4 -2
- package/src/components/slides/slide-form.tsx +1 -0
- package/src/core/cells/__tests__/__snapshots__/cells.test.ts.snap +4 -0
- package/src/core/cells/__tests__/cell.test.ts +39 -0
- package/src/core/cells/__tests__/cells.test.ts +3 -1
- package/src/core/cells/__tests__/collapseConsoleOutputs.test.ts +54 -0
- package/src/core/cells/cell.ts +14 -3
- package/src/core/cells/cells.ts +1 -0
- package/src/core/cells/types.ts +10 -1
- package/src/core/codemirror/language/panel/panel.tsx +1 -0
- package/src/plugins/impl/RefreshPlugin.tsx +1 -0
- package/src/plugins/impl/chat/chat-ui.tsx +2 -1
- package/src/stories/button.stories.tsx +1 -0
- package/dist/assets/column-preview-DXM8SqGY.js +0 -1
- package/dist/assets/feedback-button-Dgs_HOOC.js +0 -1
- package/dist/assets/index-DNG4qQ-E.js +0 -30
- package/dist/assets/scratchpad-panel-D2IHkKoG.js +0 -1
- package/dist/assets/session-panel-cOSO3WCX.js +0 -1
|
@@ -32,7 +32,7 @@ Error generating stack: `+e.message+`
|
|
|
32
32
|
max-width: 300px;
|
|
33
33
|
box-shadow: 0 2px 8px rgba(0,0,0,.15);
|
|
34
34
|
`,n.textContent=t;let r=e.coordsAtPos(e.state.selection.main.head);r&&(n.style.left=`${r.left}px`,n.style.top=`${r.bottom+5}px`),document.body.appendChild(n),setTimeout(()=>{n.style.opacity=`0`,n.style.transition=`opacity 0.2s`,setTimeout(()=>n.remove(),200)},3e3)}function Ru(e){return zu(e,new WeakSet)}function zu(e,t){if(e==null)return!0;if(Array.isArray(e))return t.has(e)?!0:(t.add(e),e.length===0||e.every(e=>zu(e,t)));if(typeof e==`string`)return Bu(e);let n=e.value;return typeof n!=`string`||Bu(n)}function Bu(e){return e==null?!0:typeof e==`string`?e.trim()===``||/^[\s\n`]*$/.test(e):!1}function Vu(e,t){let n=[];return t.iterChanges((t,r,i,a,o)=>{let s=o.toString();if(t===0&&r===e.length){n.push({text:s});return}let c=gu(e,t),l=gu(e,r);n.push({range:{start:c,end:l},text:s})}),n.sort((e,t)=>{if(!e.range)return 1;if(!t.range)return-1;let n=e.range.start.line??-1,r=t.range.start.line??-1;if(n!==r)return r-n;let i=e.range.start.character??-1;return(t.range.start.character??-1)-i}),n}var Hu=Object.fromEntries(Object.entries(mu.CompletionItemKind).map(([e,t])=>[t,e]));function Uu(e){return!!(e.deprecated||e.tags?.includes(mu.CompletionItemTag.Deprecated))}function Wu(e){return e.deprecated?`cm-deprecated`:``}function Gu(e){return`insert`in e}function Ku(e,t){if(!t)return e;let n={...e};if(n.commitCharacters??=t.commitCharacters,n.insertTextFormat??=t.insertTextFormat,n.insertTextMode??=t.insertTextMode,n.data===void 0&&(n.data=t.data),n.textEdit==null&&t.editRange){let e=n.textEditText??n.insertText??n.label;n.textEdit=Gu(t.editRange)?{newText:e,insert:t.editRange.insert,replace:t.editRange.replace}:{newText:e,range:t.editRange}}return n}function qu(e,t,n,r){let{textEdit:i,insertText:a,label:o}=t,s=n,c=r,l=a||o;if(i){let t=ju(i)?i.range:Nu(i)?i.replace:void 0;if(t){l=i.newText;let n=hu(e,t.start),r=hu(e,t.end);n!=null&&r!=null&&n<=r&&(s=n,c=r)}}return{from:s,to:c,newText:l}}function Ju(e,t,n,r){let i=[];for(let a of t){let t=hu(e,a.range.start),o=hu(e,a.range.end);t==null||o==null||t>o||o>n&&t<r||i.push({from:t,to:o,insert:a.newText})}return i}function Yu(e,t,n){return r=>r<=e?r:r-(t-e)+n}function Xu(e){let{view:t,originalDoc:n,mainFrom:r,mainTo:i,insertedLength:a,resolveItem:o}=e,s=t.state.doc,c=Yu(r,i,a);o().then(e=>{let a=e?.additionalTextEdits;if(!a?.length||t.state.doc!==s)return;let o=Ju(n,a,r,i).map(e=>({...e,from:c(e.from),to:c(e.to)}));o.length!==0&&t.dispatch({changes:o,userEvent:`input.complete`})}).catch(e=>{console.error(`Failed to resolve completion item:`,e)})}var Zu;(function(e){e.PlainText=1,e.Snippet=2})(Zu||={});var Qu=/^\$\{(\d+)\|((?:\\.|[^\\}])*)\|\}/,$u=/^\$\{([A-Za-z_][A-Za-z0-9_]*)(?::([^}]*))?\}/,ed=/^\$[A-Za-z_][A-Za-z0-9_]*/,td=/^(?:\\.|[^,])*/,nd=/^\{0(?=[:}])/;function rd(e,t){let n=``,r=0;for(;r<e.length;){let i=e[r];if(i===`\\`&&r+1<e.length){n+=e.slice(r,r+2),r+=2;continue}if(i===`$`){let i=e.slice(r),a=Qu.exec(i);if(a){let e=td.exec(a[2]??``)?.[0]??``;n+=t(a[1]??``,e),r+=a[0].length;continue}let o=$u.exec(i);if(o){n+=o[2]??``,r+=o[0].length;continue}let s=ed.exec(i);if(s){r+=s[0].length;continue}}n+=i,r+=1}return n}function id(e){let t=0;for(let n of e.matchAll(/\$\{?(\d+)/g))t=Math.max(t,Number(n[1]));return String(t+1)}function ad(e){let t=rd(e,(e,t)=>`\${${e}:${t}}`),n=id(t),r=``,i=0;for(;i<t.length;){let e=t[i];if(e===`\\`&&i+1<t.length){let e=t[i+1];e===`$`?t[i+2]===`{`?(r+=`$\\{`,i+=3):(r+=`$`,i+=2):e===`{`||e===`}`?(r+=`\\${e}`,i+=2):e===`\\`?(r+=`\\`,i+=2):(r+=e,i+=2)}else if(e===`$`){let a=t.slice(i+1),o=nd.exec(a),s=/^\d+/.exec(a);if(o)r+=`\${${n}`,i+=1+o[0].length;else if(s){let e=s[0]===`0`?n:s[0];r+=`\${${e}}`,i+=1+s[0].length}else r+=e,i+=1}else e===`#`&&t[i+1]===`{`?(r+=`#\\{`,i+=2):(r+=e,i+=1)}return r}function od(e){let t=rd(e,(e,t)=>t),n=``,r=0;for(;r<t.length;){let e=t[r];if(e===`\\`&&r+1<t.length)n+=t[r+1],r+=2;else if(e===`$`){let i=/^\{(\d+)(?::([^}]*))?\}/.exec(t.slice(r+1));if(i)n+=i[2]??``,r+=1+i[0].length;else{let i=/^\d+/.exec(t.slice(r+1));i?r+=1+i[0].length:(n+=e,r+=1)}}else n+=e,r+=1}return n}function sd(e,t){let{detail:n,labelDetails:r,label:i,kind:a,documentation:o,additionalTextEdits:s,insertTextFormat:c,commitCharacters:l,filterText:u}=e,d=typeof i==`string`?i:``,f=null,p=()=>(f??=t.resolveItem(e),f),m={label:d,detail:r?.detail||n,apply(n,r,i,a){let o=n.state,{from:l,to:u,newText:d}=qu(o.doc,e,i,a);(l>a||u<a)&&(l=i,u=a);let f=d,m=Ju(o.doc,s??[],l,u),h=e=>{s||!t.hasResolveProvider||Xu({view:n,originalDoc:o.doc,mainFrom:l,mainTo:u,insertedLength:e,resolveItem:p})};if(c===Zu.Snippet&&t.useSnippetOnCompletion){let e=l,t=u;if(m.length>0){let r=o.changes(m);n.dispatch({changes:r}),e=r.mapPos(e,1),t=r.mapPos(t,1)}let r=n.state.doc.length;Pr(ad(f))(n,null,e,t),h(n.state.doc.length-r+(t-e));return}if(c===Zu.Snippet&&(f=od(f)),m.length===0){n.dispatch(Ar(o,f,l,u)),h(f.length);return}let g=o.changes([{from:l,to:u,insert:f},...m]);n.dispatch({changes:g,selection:{anchor:g.mapPos(l,-1)+f.length},userEvent:`input.complete`})},type:a?Hu[a]?.toLowerCase():void 0};u!=null&&u!==d&&(m.label=u,m.displayLabel=d),l?.length&&(m.commitCharacters=l),Uu(e)&&(m.deprecated=!0);let h=e=>{let n=document.createElement(`div`);return n.classList.add(`documentation`),Ou(n,e,{allowHTMLContent:t.allowHTMLContent,markdownRenderer:t.markdownRenderer}),n};return t.hasResolveProvider?m.info=async()=>{try{let e=(await p())?.documentation||o;return!e||Ru(e)?null:h(e)}catch(e){return console.error(`Failed to resolve completion item:`,e),!o||Ru(o)?null:h(o)}}:o&&(m.info=()=>h(o)),m}function cd(e,t,n,r=!0){let i=[t?ld(t):ud,n===`python`?dd:void 0].filter(Boolean),a=[...e];if(t&&r){let e=t.toLowerCase();/^\w+$/.test(e)&&(a=a.filter(({label:t,filterText:n})=>(typeof n==`string`?n:pd(t)).toLowerCase().startsWith(e)))}for(let e of i)a.sort(e);return a}function ld(e){return(t,n)=>{let r=fd(t).startsWith(e),i=fd(n).startsWith(e);if(r&&!i)return-1;if(!r&&i)return 1;let a=typeof t.sortText==`string`?t.sortText:pd(t.label),o=typeof n.sortText==`string`?n.sortText:pd(n.label);return a.localeCompare(o)}}function ud(e,t){let n=typeof e.sortText==`string`?e.sortText:pd(e.label),r=typeof t.sortText==`string`?t.sortText:pd(t.label);return n.localeCompare(r)}function dd(e,t){let n=pd(e.label).endsWith(`=`),r=pd(t.label).endsWith(`=`);return n&&!r?-1:!n&&r?1:0}function fd(e){return typeof e.filterText==`string`?e.filterText:pd(e.label)}function pd(e){return typeof e==`string`?e:``}function md(e){let t=new Proxy({},{get(){throw Error(e)}});return function(e){return e[0]??t}}var hd=md(`No document URI provided. Pass one to the extension or use documentUri.of().`),gd=md(`No language ID provided. Pass one to the extension or use languageId.of().`);function _d(e){if(e!==e.trim())return!1;try{return!!new URL(e).protocol}catch{return!1}}var vd=vn.define({combine(e){if(e.length===0)return hd(e);let t=hd(e);if(!(t&&_d(t)))throw Error(`Document URI must be a non-empty absolute URI`);return t}}),yd=vn.define({combine(e){if(e.length===0)return gd(e);let t=gd(e);if(!t.trim())throw Error(`Language ID must be a non-empty string`);return t}}),bd={ParseError:-32700,InvalidRequest:-32600,MethodNotFound:-32601,InvalidParams:-32602,InternalError:-32603,RequestTimeout:-32001},xd=class extends Error{code;data;constructor(e,t,n){super(t),this.name=`RPCError`,this.code=e,this.data=n}},Sd=1e4;function Cd(e){return e.id!=null}function wd(e){return e instanceof Error?e:new xd(bd.InternalError,String(e))}var Td=class{transport;pending=new Map;disconnect;disconnectClose;connected;nextId=0;closed=!1;isConnected=!1;closeError;notificationHandler;requestHandler;constructor(e){this.transport=e,this.disconnect=e.onMessage(e=>this.receive(e)),this.disconnectClose=e.onClose?.(e=>{this.closeError??=e;for(let t of[...this.pending.keys()])this.settle(t,t=>t.reject(e))}),this.connected=e.connect(),this.connected.then(()=>{this.isConnected=!0},()=>{}),this.connected.catch(()=>{})}onNotification(e){this.notificationHandler=e}onRequest(e){this.requestHandler=e}request(e,t,n=Sd,r){if(r?.aborted)return Promise.reject(new DOMException(`Request aborted`,`AbortError`));if(this.closed)return Promise.reject(new xd(bd.InternalError,`Client closed`));if(this.closeError)return Promise.reject(this.closeError);let i=this.nextId++;return new Promise((a,o)=>{let s=!1,c=e=>{this.pending.has(i)&&(this.settle(i,t=>t.reject(e)),s&&this.notify(`$/cancelRequest`,{id:i}).catch(()=>{}))},l=()=>c(new DOMException(`Request aborted`,`AbortError`));this.pending.set(i,{resolve:a,reject:o,cleanup:()=>r?.removeEventListener(`abort`,l)}),r?.addEventListener(`abort`,l,{once:!0});let u=()=>{let r=this.pending.get(i);if(r){r.timer=setTimeout(()=>{c(new xd(bd.RequestTimeout,`Request "${e}" timed out after ${n}ms`))},n);try{s=!0,this.transport.send({jsonrpc:`2.0`,id:i,method:e,params:t})}catch(e){this.settle(i,t=>t.reject(wd(e)))}}};if(this.isConnected){u();return}this.connected.then(u,e=>this.settle(i,t=>t.reject(wd(e))))})}notify(e,t){let n=this.dispatch({jsonrpc:`2.0`,method:e,params:t});return n.catch(()=>{}),n}respond(e){return this.dispatch(e)}close(){if(!this.closed){this.closed=!0;for(let e of[...this.pending.keys()])this.settle(e,e=>e.reject(new xd(bd.InternalError,`Client closed`)));this.disconnect(),this.disconnectClose?.(),this.transport.close()}}dispatch(e){if(this.closed)return Promise.resolve();if(this.isConnected)try{return this.transport.send(e),Promise.resolve()}catch(e){return Promise.reject(wd(e))}return this.connected.then(()=>{this.closed||this.transport.send(e)})}settle(e,t){let n=this.pending.get(e);n&&(n.timer!==void 0&&clearTimeout(n.timer),n.cleanup(),this.pending.delete(e),t(n))}receive(e){if(this.closed||typeof e!=`object`||!e||Array.isArray(e)||e.jsonrpc!==`2.0`)return;if(typeof e.method==`string`){Cd(e)?this.requestHandler?.(e):this.notificationHandler?.(e);return}if(!Cd(e))return;let t=e,n=t.id;if(typeof n==`string`&&!this.pending.has(n)&&/^\d+$/.test(n)){let e=Number(n);this.pending.has(e)&&(n=e)}this.settle(n,e=>{if(`error`in t){let n=t.error;if(typeof n!=`object`||!n||typeof n.code!=`number`||typeof n.message!=`string`){e.reject(new xd(bd.InvalidRequest,`Malformed JSON-RPC error response`,n));return}e.reject(new xd(n.code,n.message,n.data))}else`result`in t?e.resolve(t.result):e.reject(new xd(bd.InvalidRequest,`Malformed JSON-RPC response: missing result or error`))})}},Ed=1e4,Dd=`Language server: `,Od={"textDocument/hover":`hoverProvider`,"textDocument/completion":`completionProvider`,"textDocument/definition":`definitionProvider`,"textDocument/declaration":`declarationProvider`,"textDocument/typeDefinition":`typeDefinitionProvider`,"textDocument/implementation":`implementationProvider`,"textDocument/references":`referencesProvider`,"textDocument/documentHighlight":`documentHighlightProvider`,"textDocument/documentSymbol":`documentSymbolProvider`,"textDocument/codeAction":`codeActionProvider`,"textDocument/codeLens":`codeLensProvider`,"textDocument/documentLink":`documentLinkProvider`,"textDocument/formatting":`documentFormattingProvider`,"textDocument/rangeFormatting":`documentRangeFormattingProvider`,"textDocument/onTypeFormatting":`documentOnTypeFormattingProvider`,"textDocument/rename":`renameProvider`,"textDocument/prepareRename":`renameProvider`,"textDocument/signatureHelp":`signatureHelpProvider`,"textDocument/foldingRange":`foldingRangeProvider`,"textDocument/selectionRange":`selectionRangeProvider`,"workspace/symbol":`workspaceSymbolProvider`,"workspace/executeCommand":`executeCommandProvider`},kd=class{ready;capabilities;advertisedCapabilities;initializePromise;rootUri;workspaceFolders;timeout;client;initializationOptions;clientCapabilities;notificationListeners=new Set;documentOpenCounts=new Map;serverRequestHandlers=new Map;dynamicCapabilities=new Map;isClosed=!1;constructor({rootUri:e,workspaceFolders:t,transport:n,initializationOptions:r,capabilities:i,timeout:a=Ed,getWorkspaceConfiguration:o}){if(!e)throw Error(`rootUri must be a non-empty URI`);this.rootUri=e,this.workspaceFolders=t,this.initializationOptions=r,this.clientCapabilities=i,this.timeout=a,this.ready=!1,this.capabilities=null,this.client=new Td(n),this.client.onNotification(e=>{this.processNotification(e)}),this.client.onRequest(e=>{this.handleServerRequest(e)}),this.onRequest(`workspace/configuration`,e=>o?o(e):(e?.items??[]).map(()=>null)),this.onRequest(`client/registerCapability`,e=>{let t=e?.registrations;if(!Array.isArray(t))return null;for(let e of t)!e||typeof e.id!=`string`||e.id.length===0||typeof e.method!=`string`||this.dynamicCapabilities.has(e.id)||this.dynamicCapabilities.set(e.id,e);return null}),this.onRequest(`client/unregisterCapability`,e=>{let t=e?.unregisterations;if(!Array.isArray(t))return null;for(let e of t)this.dynamicCapabilities.delete(e.id);return null}),this.onRequest(`workspace/applyEdit`,()=>({applied:!1,failureReason:`workspace/applyEdit is not supported`})),this.onRequest(`window/showMessageRequest`,e=>{if(e?.message){let t=String(e.message).replace(/[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f]/g,``).slice(0,2031);console.info(`${Dd}${t}`)}return null}),this.onRequest(`window/workDoneProgress/create`,()=>null),this.initializePromise=this.initialize(),this.initializePromise.catch(e=>{console.error(`Language server initialization failed`,e)})}getInitializationOptions(){let e={textDocument:{hover:{dynamicRegistration:!0,contentFormat:[`markdown`,`plaintext`]},moniker:{},synchronization:{dynamicRegistration:!1,willSave:!0,didSave:!0,willSaveWaitUntil:!0},codeAction:{dynamicRegistration:!0,codeActionLiteralSupport:{codeActionKind:{valueSet:[``,`quickfix`,`refactor`,`refactor.extract`,`refactor.inline`,`refactor.rewrite`,`source`,`source.organizeImports`]}},resolveSupport:{properties:[`edit`]}},completion:{dynamicRegistration:!1,completionItem:{snippetSupport:!0,commitCharactersSupport:!0,documentationFormat:[`markdown`,`plaintext`],deprecatedSupport:!0,preselectSupport:!1,insertReplaceSupport:!0,tagSupport:{valueSet:[1]},resolveSupport:{properties:[`documentation`,`detail`,`additionalTextEdits`]}},completionList:{itemDefaults:[`commitCharacters`,`editRange`,`insertTextFormat`,`insertTextMode`,`data`]},contextSupport:!1},signatureHelp:{dynamicRegistration:!1,signatureInformation:{documentationFormat:[`markdown`,`plaintext`]}},declaration:{dynamicRegistration:!1,linkSupport:!0},definition:{dynamicRegistration:!0,linkSupport:!0},typeDefinition:{dynamicRegistration:!1,linkSupport:!0},implementation:{dynamicRegistration:!1,linkSupport:!0},rename:{dynamicRegistration:!0,prepareSupport:!0},publishDiagnostics:{relatedInformation:!0,tagSupport:{valueSet:[1,2]},versionSupport:!0,codeDescriptionSupport:!0,dataSupport:!0}},workspace:{didChangeConfiguration:{dynamicRegistration:!1}}};return{capabilities:this.clientCapabilities?typeof this.clientCapabilities==`function`?this.clientCapabilities(e):this.clientCapabilities:e,initializationOptions:this.initializationOptions,processId:null,rootUri:this.rootUri,workspaceFolders:this.workspaceFolders}}async initialize(){let e=this.getInitializationOptions();this.advertisedCapabilities=e?.capabilities;let t=await this.request(`initialize`,e,this.timeout*3);if(!t||typeof t!=`object`||!(`capabilities`in t)||typeof t.capabilities!=`object`||t.capabilities===null)throw Error(`Invalid initialize response: missing server capabilities`);this.isClosed||(this.capabilities=t.capabilities,this.notify(`initialized`,{}),this.ready=!0)}close(){if(!this.isClosed){if(this.isClosed=!0,this.ready=!1,this.notificationListeners.clear(),this.serverRequestHandlers.clear(),this.dynamicCapabilities.clear(),this.documentOpenCounts.clear(),this.capabilities){this.client.request(`shutdown`,null,this.timeout).catch(()=>{}).then(()=>{this.client.notify(`exit`,void 0).catch(()=>{}),this.client.close()});return}this.client.close()}}onRequest(e,t){return this.serverRequestHandlers.set(e,t),()=>{this.serverRequestHandlers.get(e)===t&&this.serverRequestHandlers.delete(e)}}mayRegisterDynamically(e){let[t,n]=e.split(`/`);return t!==`textDocument`||!n?!1:(this.advertisedCapabilities?.textDocument)?.[n]?.dynamicRegistration===!0}hasCapability(e){for(let t of this.dynamicCapabilities.values())if(t.method===e)return!0;let t=Od[e];return t?!!this.capabilities?.[t]:!1}async handleServerRequest(e){let t=this.serverRequestHandlers.get(e.method),n;if(!t)n={jsonrpc:`2.0`,id:e.id,error:{code:bd.MethodNotFound,message:`Method not found: ${e.method}`}};else try{let r=await t(e.params);n={jsonrpc:`2.0`,id:e.id,result:r===void 0?null:r}}catch(t){n={jsonrpc:`2.0`,id:e.id,error:{code:bd.InternalError,message:t instanceof Error?t.message:String(t)}}}this.isClosed||this.client.respond(n).catch(()=>{})}textDocumentDidOpen(e){let t=e.textDocument.uri,n=this.documentOpenCounts.get(t)??0;return this.documentOpenCounts.set(t,n+1),n>0?Promise.resolve(!1):this.notify(`textDocument/didOpen`,e).then(()=>!0)}textDocumentDidChange(e){return this.notify(`textDocument/didChange`,e)}textDocumentDidClose(e){let t=e.textDocument.uri,n=this.documentOpenCounts.get(t)??0;return n>1?(this.documentOpenCounts.set(t,n-1),Promise.resolve(void 0)):(this.documentOpenCounts.delete(t),this.notify(`textDocument/didClose`,e))}textDocumentWillSave(e){return this.notify(`textDocument/willSave`,e)}async textDocumentWillSaveWaitUntil(e){return await this.request(`textDocument/willSaveWaitUntil`,e,this.timeout)}textDocumentDidSave(e){return this.notify(`textDocument/didSave`,e)}async textDocumentHover(e){return await this.request(`textDocument/hover`,e,this.timeout)}async textDocumentCompletion(e){return await this.request(`textDocument/completion`,e,this.timeout)}async completionItemResolve(e){return await this.request(`completionItem/resolve`,e,this.timeout)}async textDocumentDefinition(e){return await this.request(`textDocument/definition`,e,this.timeout)}async textDocumentCodeAction(e){return await this.request(`textDocument/codeAction`,e,this.timeout)}async codeActionResolve(e){return await this.request(`codeAction/resolve`,e,this.timeout)}async textDocumentRename(e){return await this.request(`textDocument/rename`,e,this.timeout)}async textDocumentPrepareRename(e){return await this.request(`textDocument/prepareRename`,e,this.timeout)}async textDocumentSignatureHelp(e){return await this.request(`textDocument/signatureHelp`,e,this.timeout)}onNotification(e){return this.notificationListeners.add(e),()=>this.notificationListeners.delete(e)}waitForInitialization(e){if(!e)return this.initializePromise;if(e.aborted)return Promise.reject(new DOMException(`Request aborted`,`AbortError`));let t,n=new Promise((n,r)=>{t=()=>r(new DOMException(`Request aborted`,`AbortError`)),e.addEventListener(`abort`,t,{once:!0})});return Promise.race([this.initializePromise,n]).finally(()=>{e.removeEventListener(`abort`,t)})}request(e,t,n,r){if(e===`initialize`)return this.client.request(e,t,n,r);let i=this.hasCapability(e),a=!(this.ready||this.capabilities)&&this.mayRegisterDynamically(e);return this.waitForInitialization(r).then(()=>{if(this.isClosed)throw Error(`Language server client is closed`);if(Od[e]&&!a&&!(i||this.hasCapability(e)))throw Error(`Language server does not support method ${e}`);return this.client.request(e,t,n,r)})}notify(e,t){return this.client.notify(e,t)}processNotification(e){for(let t of this.notificationListeners)try{Promise.resolve(t(e)).catch(e=>{console.error(`Notification listener failed`,e)})}catch(e){console.error(`Notification listener failed`,e)}}},Ad=class e{static OUTBOX_LIMIT=1e3;url;protocols;socket;opened=!1;closed=!1;rejectConnect;handlers=new Set;closeHandlers=new Set;outbox=[];constructor(e,t){this.url=e,this.protocols=t}connect(){return/^wss?:\/\//i.test(this.url)?(this.url.toLowerCase().startsWith(`ws://`)&&typeof location<`u`&&location.protocol===`https:`&&console.warn(`Insecure WebSocket ${this.url} may be blocked from an HTTPS page`),this.rejectConnect?.(Error(`WebSocket connection to ${this.url} was replaced`)),this.rejectConnect=void 0,this.socket?.close(),this.opened=!1,this.closed=!1,new Promise((e,t)=>{let n=new WebSocket(this.url,this.protocols);this.socket=n,this.rejectConnect=t,n.addEventListener(`open`,()=>{if(this.socket===n){this.opened=!0,this.rejectConnect=void 0;for(let e of this.outbox)n.send(e);this.outbox=[],e()}}),n.addEventListener(`message`,e=>{this.socket===n&&this.receiveFrame(e.data,n)}),n.addEventListener(`error`,()=>{if(this.socket!==n)return;let e=Error(`WebSocket connection to ${this.url} failed`);this.opened?this.emitClose(e):t(e)}),n.addEventListener(`close`,()=>{this.socket===n&&(this.opened?this.closed||this.emitClose(Error(`WebSocket connection to ${this.url} closed`)):t(Error(`WebSocket to ${this.url} closed before opening`)))})})):Promise.reject(Error(`Invalid WebSocket URL: ${this.url||`(empty)`}`))}send(t){if(this.closed)return;let n=JSON.stringify(t);this.socket&&this.socket.readyState===WebSocket.OPEN?this.socket.send(n):this.outbox.length<e.OUTBOX_LIMIT&&this.outbox.push(n)}onMessage(e){return this.handlers.add(e),()=>{this.handlers.delete(e)}}onClose(e){return this.closeHandlers.add(e),()=>{this.closeHandlers.delete(e)}}close(){this.rejectConnect?.(Error(`WebSocket to ${this.url} closed`)),this.rejectConnect=void 0,this.closed=!0,this.opened=!1,this.handlers.clear(),this.closeHandlers.clear(),this.outbox=[],this.socket?.close(),this.socket=void 0}receiveFrame(e,t){if(e instanceof ArrayBuffer||Object.prototype.toString.call(e)===`[object ArrayBuffer]`){this.dispatchFrame(new TextDecoder().decode(e));return}if(typeof Blob<`u`&&e instanceof Blob){e.text().then(e=>{this.socket===t&&this.dispatchFrame(e)});return}this.dispatchFrame(String(e))}dispatchFrame(e){if(this.closed)return;let t;try{t=JSON.parse(e)}catch{return}if(typeof t!=`object`||!t||Array.isArray(t))return;let n=t;for(let e of this.handlers)try{e(n)}catch(e){console.error(`WebSocket message handler failed`,e)}}emitClose(e){this.opened=!1,this.closed=!0;for(let t of this.closeHandlers)try{t(e)}catch(e){console.error(`WebSocket close handler failed`,e)}}},jd=console.log,Md=2**31-1;function Nd(){return String(Date.now()+Math.random())}function Pd(e){return e!=null&&typeof e.command==`string`}function Fd(e,t){return e.line===t.line?e.character-t.character:e.line-t.line}function Id(e,t){let n=Fd(e.start,e.end)===0,r=Fd(t.start,t.end)===0;return n||r?Fd(e.start,t.end)<=0&&Fd(t.start,e.end)<=0:Fd(e.start,t.end)<0&&Fd(t.start,e.end)<0}function Ld(e,t){if(Pd(e))return!0;let n=e.diagnostics;return!n||n.length===0||n.some(e=>Id(e.range,t.range))}function Rd(e){let t;try{t=new URL(e)}catch{return!1}return t.protocol===`http:`||t.protocol===`https:`||t.protocol===`mailto:`}var zd=xn.define(),Bd=on.define({create:()=>new Map,update(e,t){let n=e;for(let r of t.effects)if(r.is(zd)){n===e&&(n=new Map(e));for(let e of[...n.keys()])e.startsWith(`${r.value.pluginId}:`)&&n.delete(e);for(let[e,t]of r.value.anchors)n.set(e,t)}if(t.docChanged&&n.size>0){n===e&&(n=new Map(e));for(let[e,r]of n)n.set(e,{from:t.changes.mapPos(r.from,1),to:t.changes.mapPos(r.to,r.from===r.to?1:-1)})}return n}}),Vd=xn.define(),Hd=on.define({create:()=>null,update(e,t){for(let e of t.effects)if(e.is(Vd))return e.value;if(e&&t.docChanged){let n=t.changes.mapPos(e.pos),r=e.end==null?void 0:t.changes.mapPos(e.end);return{...e,pos:n,end:r}}return e},provide:e=>fn.from(e)}),Ud=$n.define(),Wd=20,Gd=new WeakMap;function Kd(e,t){let n=Gd.get(e);n?n.push(t):Gd.set(e,[t])}function qd(e,t){let n=Gd.get(e);if(!n)return;let r=n.indexOf(t);r!==-1&&n.splice(r,1),n.length===0&&Gd.delete(e)}var Jd=class{documentVersion;pluginId;pendingDocumentChanges=new Set;client;documentUri;languageId;view;allowHTMLContent;useSnippetOnCompletion;clientSideFiltering;sendIncrementalChanges;featureOptions;onGoToDefinition;onShowLocation;markdownRenderer;codeActionsConfig;disposeListener;destroyed=!1;documentOpened=!1;documentTextSnapshotted=!1;documentOpenCarriedText=!0;documentReady;signatureHelpRequestId=0;closeCodeActionMenu;closeRenamePopup;constructor(e){let{client:t,documentUri:n,languageId:r,view:i,featureOptions:a,sendIncrementalChanges:o=!0,allowHTMLContent:s=!1,useSnippetOnCompletion:c=!1,clientSideFiltering:l=!1,onGoToDefinition:u,onShowLocation:d,markdownRenderer:f=yu,codeActionsConfig:p}=e;this.documentVersion=0,this.pluginId=Nd(),this.client=t,this.documentUri=n,this.languageId=r,this.view=i,this.allowHTMLContent=s,this.useSnippetOnCompletion=c,this.clientSideFiltering=l,this.sendIncrementalChanges=o,this.featureOptions=a,this.onGoToDefinition=u,this.onShowLocation=d,this.markdownRenderer=f,this.codeActionsConfig=p,Kd(i,this),this.disposeListener=t.onNotification(this.processNotification.bind(this)),this.documentReady=this.initialize().catch(e=>{console.error(`Language server initialization failed`,e)})}update({state:e,docChanged:t,startState:{doc:n},changes:r}){if(!t)return;let i=this.resolveTextDocumentSyncKind();i!==mu.TextDocumentSyncKind.None&&(this.sendIncrementalChanges&&i===mu.TextDocumentSyncKind.Incremental?this.trackDocumentChanges(Vu(n,r)):this.trackDocumentChanges([{text:e.doc.toString()}]))}trackDocumentChanges(e){let t=this.sendChanges(e);this.pendingDocumentChanges.add(t),t.finally(()=>this.pendingDocumentChanges.delete(t))}destroy(){this.destroyed=!0,this.disposeListener?.(),this.disposeListener=void 0,this.closeCodeActionMenu?.(),this.closeRenamePopup?.(),this.view.state.field(Bd,!1)&&this.view.dispatch({effects:zd.of({pluginId:this.pluginId,anchors:new Map})}),qd(this.view,this),this.closeDocument()}closeDocument(){this.documentOpened&&this.client.ready&&(this.documentOpened=!1,Promise.resolve(this.client.textDocumentDidClose({textDocument:{uri:this.documentUri}})).catch(e=>{console.error(`Failed to send didClose`,e)}))}async initialize({documentText:e}={}){if(this.client.initializePromise&&await this.client.initializePromise,this.destroyed)return;let t=e??this.view.state.doc.toString();this.documentTextSnapshotted=!0;let n=await this.client.textDocumentDidOpen({textDocument:{uri:this.documentUri,languageId:this.languageId,text:t,version:this.documentVersion}});this.documentOpenCarriedText=n!==!1,this.documentOpened=!0,this.destroyed&&this.closeDocument()}resolveTextDocumentSyncKind(){let e=this.client.capabilities?.textDocumentSync;return e==null?this.sendIncrementalChanges?mu.TextDocumentSyncKind.Incremental:mu.TextDocumentSyncKind.Full:typeof e==`number`?e:e.change??mu.TextDocumentSyncKind.None}async sendChanges(e){let t=this.documentTextSnapshotted;if(!(!this.documentOpened&&(await this.documentReady,!t&&this.documentOpenCarriedText))&&this.client.ready)try{await this.client.textDocumentDidChange({textDocument:{uri:this.documentUri,version:++this.documentVersion},contentChanges:e})}catch(e){console.error(e)}}async documentDidSave(e=mu.TextDocumentSaveReason.Manual){if(!this.client.ready||(await Promise.all(this.pendingDocumentChanges),this.destroyed||!this.client.ready))return;let t=this.client.capabilities?.textDocumentSync,n=typeof t==`object`&&t?t:void 0;if(n?.willSave){try{await this.client.textDocumentWillSave({textDocument:{uri:this.documentUri},reason:e})}catch(e){console.error(`Failed to send willSave`,e)}if(this.destroyed||!this.client.ready)return}if(n?.willSaveWaitUntil){try{let t=await this.client.textDocumentWillSaveWaitUntil({textDocument:{uri:this.documentUri},reason:e});t&&t.length>0&&!this.destroyed&&(this.applyEdits(this.view,t),await Promise.all(this.pendingDocumentChanges))}catch(e){console.error(`Failed during willSaveWaitUntil`,e)}if(this.destroyed||!this.client.ready)return}let r=n?.save;if(r==null||r===!1)return;let i=typeof r==`object`&&r.includeText;try{await this.client.textDocumentDidSave({textDocument:{uri:this.documentUri},text:i?this.view.state.doc.toString():void 0})}catch(e){console.error(`Failed to send didSave`,e)}}requestDiagnostics(e){this.sendChanges([{text:e.state.doc.toString()}])}async requestHoverTooltip(e,{line:t,character:n}){if(!this.featureOptions.hoverEnabled||!(this.client.ready&&this.client.hasCapability(`textDocument/hover`)))return null;let r;try{r=await this.client.textDocumentHover({textDocument:{uri:this.documentUri},position:{line:t,character:n}})}catch{return null}if(!r)return null;let{contents:i,range:a}=r,o=hu(e.state.doc,{line:t,character:n}),s;if(a&&(o=hu(e.state.doc,a.start),s=hu(e.state.doc,a.end)),o==null||Ru(i))return null;let c=document.createElement(`div`);return c.classList.add(`documentation`,`cm-lsp-hover-tooltip`),Ou(c,i,{allowHTMLContent:this.allowHTMLContent,markdownRenderer:this.markdownRenderer}),{pos:o,end:s,create:e=>({dom:c}),above:!0}}async requestCompletion(e,{line:t,character:n},{triggerKind:r,triggerCharacter:i}){if(!this.featureOptions.completionEnabled||(await Promise.all(this.pendingDocumentChanges),!(this.client.ready&&this.client.hasCapability(`textDocument/completion`))))return null;let a;try{a=await this.client.textDocumentCompletion({textDocument:{uri:this.documentUri},position:{line:t,character:n},context:{triggerKind:r,triggerCharacter:i}})}catch{return null}if(!a)return null;let o=Mu(a)?a:{isIncomplete:!1,items:a};if(!Array.isArray(o.items))return null;let s=o.items.map(e=>Ku(e,o.itemDefaults)),c=this.clientSideFiltering&&!o.isIncomplete,l=Au(s),u=l?e.matchBefore(l)??e.matchBefore(/[a-zA-Z0-9_]+/):e.matchBefore(/[a-zA-Z0-9_]+/),{pos:d}=e,f=cd(s,u?.text,this.languageId,!c);u&&(d=u.from);let p=f.map(e=>sd(e,{allowHTMLContent:this.allowHTMLContent,useSnippetOnCompletion:this.useSnippetOnCompletion,hasResolveProvider:this.client.capabilities?.completionProvider?.resolveProvider??!1,resolveItem:this.client.completionItemResolve.bind(this.client)}));return c?{from:d,options:p,validFor:/^\w*$/}:{from:d,options:p,filter:!1}}async requestDefinition(e,{line:t,character:n}){if(!this.featureOptions.definitionEnabled||!(this.client.ready&&this.client.hasCapability(`textDocument/definition`)))return;let r;try{r=await this.client.textDocumentDefinition({textDocument:{uri:this.documentUri},position:{line:t,character:n}})}catch{return}if(!r||this.destroyed)return;let i=Array.isArray(r)?r:[r];if(i.length===0)return;let a=i[0];if(!a||typeof a!=`object`)return;let o=`uri`in a&&typeof a.uri==`string`?a.uri:`targetUri`in a&&typeof a.targetUri==`string`?a.targetUri:void 0,s=`range`in a?a.range:`targetRange`in a?a.targetRange:void 0;if(!(o&&s?.start&&s.end))return;let c=o!==this.documentUri,l={uri:o,range:s,isExternalDocument:c};if(!c){let t=hu(e.state.doc,s.start),n=hu(e.state.doc,s.end);if(t==null||n==null||t>n)return;e.dispatch(e.state.update({selection:{anchor:t,head:n}}))}return this.onGoToDefinition&&this.onGoToDefinition(l),l}processNotification(e){try{e.method===`textDocument/publishDiagnostics`&&e.params&&this.processDiagnostics(e.params).catch(e=>jd(e))}catch(e){jd(e)}}lastSeenDiagnosticsVersion=null;async processDiagnostics(e){if(!e||e.uri!==this.documentUri||!Array.isArray(e.diagnostics))return;if(e.version!=null){if(typeof e.version!=`number`||!Number.isInteger(e.version)||e.version<0||e.version>Md||this.lastSeenDiagnosticsVersion!=null&&e.version<this.lastSeenDiagnosticsVersion)return;this.lastSeenDiagnosticsVersion=e.version}else if(this.lastSeenDiagnosticsVersion!=null)return;if(!this.featureOptions.diagnosticsEnabled){this.clearDiagnostics();return}let t={[mu.DiagnosticSeverity.Error]:`error`,[mu.DiagnosticSeverity.Warning]:`warning`,[mu.DiagnosticSeverity.Information]:`info`,[mu.DiagnosticSeverity.Hint]:`hint`},n=this.view.state.doc,r=e.diagnostics.filter(e=>{if(!e||typeof e!=`object`||!e.range||typeof e.message!=`string`&&(typeof e.message!=`object`||e.message===null||typeof e.message.value!=`string`))return!1;let t=hu(n,e.range.start),r=hu(n,e.range.end);return t!=null&&r!=null&&t<=r});if(e.diagnostics.length>0&&r.length===0)return;let i=[];try{i=await this.requestCodeActionsForDiagnostics(r)??[]}catch(e){console.error(`Failed to fetch code actions`,e)}if(this.destroyed||e.version!=null&&this.lastSeenDiagnosticsVersion!=null&&e.version<this.lastSeenDiagnosticsVersion||this.view.state.doc!==n)return;let a=new Map,o=r.map((e,r)=>{let{range:o,message:s,severity:c,code:l,source:u,tags:d}=e,f=hu(n,o.start),p=hu(n,o.end);if(f==null||p==null||f>p)return null;e.relatedInformation?.forEach((e,t)=>{if(e.location.uri!==this.documentUri)return;let i=hu(n,e.location.range.start),o=hu(n,e.location.range.end);i!=null&&o!=null&&a.set(`${this.pluginId}:${r}:${t}`,{from:i,to:o})});let m=i.filter(t=>Ld(t,e)).map(e=>({name:`command`in e&&typeof e.command==`object`&&e.command?.title||e.title,apply:()=>{this.applyCodeAction(e)}})),h=u||this.languageId,g=l!=null&&l!==``?`${h}(${l})`:h,_=[this.pluginId];return d?.includes(mu.DiagnosticTag.Unnecessary)&&_.push(`cm-lsp-unnecessary`),d?.includes(mu.DiagnosticTag.Deprecated)&&_.push(`cm-lsp-deprecated`),{from:f,to:p,severity:t[c??mu.DiagnosticSeverity.Error]??`error`,message:Fu(s),renderMessage:t=>this.renderDiagnosticMessage(t,e,r),source:g,markClass:_.join(` `),actions:m.length>0?m:void 0,lspDiagnostic:e}});this.setOwnDiagnostics(o.filter(e=>e!=null),a)}setOwnDiagnostics(e,t=new Map){let n=this.view.state,r=[];hr(n,(e,t,n)=>{this.ownsDiagnostic(e)||r.push({...e,from:t,to:n})});let i=cr(n,[...r,...e]),a=i.effects,o=Array.isArray(a)?[...a]:a?[a]:[];o.push(zd.of({pluginId:this.pluginId,anchors:t})),this.view.dispatch({...i,effects:o})}ownsDiagnostic(e){return e.markClass?.split(` `).includes(this.pluginId)??!1}renderDiagnosticMessage(e,t,n){let{message:r,code:i,source:a,codeDescription:o,relatedInformation:s}=t,c=document.createElement(`div`);c.classList.add(`cm-lsp-diagnostic-message`);let l=document.createElement(`div`);if(Ou(l,{kind:`markdown`,value:Fu(r)},{allowHTMLContent:this.allowHTMLContent,markdownRenderer:this.markdownRenderer}),c.appendChild(l),o?.href&&Rd(o.href)){let e=a||this.languageId,t=i!=null&&i!==``?`${e}(${i})`:e,n=document.createElement(`a`);n.className=`cm-diagnostic-code-link`,n.href=o.href,n.target=`_blank`,n.rel=`noopener noreferrer`,n.textContent=t,c.appendChild(n)}if(s&&s.length>0){let t=document.createElement(`div`);t.className=`cm-diagnostic-related`,s.forEach((r,i)=>{t.appendChild(this.renderRelatedInformation(e,r,`${this.pluginId}:${n}:${i}`))}),c.appendChild(t)}return c}renderRelatedInformation(e,t,n){let{location:r,message:i}=t,{uri:a,range:o}=r,s=a!==this.documentUri,c=()=>{if(s)return null;let t=e.state.field(Bd,!1)?.get(n);if(t)return t;let r=hu(e.state.doc,o.start);return r==null?null:{from:r,to:hu(e.state.doc,o.end)??r}},l=document.createElement(`div`);l.className=`cm-diagnostic-related-item`;let u=document.createElement(`span`);u.className=`cm-diagnostic-related-message`,u.textContent=i,l.appendChild(u);let d=c(),f=d&&!s?gu(e.state.doc,d.from):o.start,p=document.createElement(`span`);if(p.className=`cm-diagnostic-related-location`,p.textContent=` ${a}:${f.line+1}:${f.character+1}`,l.appendChild(p),!s||this.onShowLocation){l.classList.add(`cm-diagnostic-related-clickable`),l.setAttribute(`role`,`button`),l.tabIndex=0;let t=()=>{if(s){this.onShowLocation?.({uri:a,range:o,isExternalDocument:s});return}let t=c();t!=null&&e.dispatch({selection:{anchor:t.from,head:t.to},scrollIntoView:!0})};l.addEventListener(`click`,t),l.addEventListener(`keydown`,e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),t())})}return l}clearDiagnostics(){this.setOwnDiagnostics([])}async requestCodeActionsForDiagnostics(e){let t=e[0];if(!t||!this.featureOptions.codeActionsEnabled||!(this.client.ready&&this.client.hasCapability(`textDocument/codeAction`)))return null;let n=t.range.start,r=t.range.end;for(let t of e)Fd(t.range.start,n)<0&&(n=t.range.start),Fd(t.range.end,r)>0&&(r=t.range.end);return await this.client.textDocumentCodeAction({textDocument:{uri:this.documentUri},range:{start:n,end:r},context:{diagnostics:e}})}async requestCodeActions(e,t,n){return!this.featureOptions.codeActionsEnabled||!(this.client.ready&&this.client.hasCapability(`textDocument/codeAction`))?null:await this.client.textDocumentCodeAction({textDocument:{uri:this.documentUri},range:t,context:{diagnostics:this.diagnosticsInRange(e,t),...n?{only:n}:{}}})}async requestCodeActionsAtSelection(e){let{from:t,to:n}=e.state.selection.main;return await this.requestCodeActions(e,{start:gu(e.state.doc,t),end:gu(e.state.doc,n)})}diagnosticsInRange(e,t){let n=e.state.doc,r=hu(n,t.start),i=hu(n,t.end);if(r==null||i==null)return[];let a={error:mu.DiagnosticSeverity.Error,warning:mu.DiagnosticSeverity.Warning,info:mu.DiagnosticSeverity.Information,hint:mu.DiagnosticSeverity.Hint},o=[];return hr(e.state,(e,t,s)=>{if(t>i||s<r)return;let c={start:gu(n,t),end:gu(n,s)},l=e.lspDiagnostic;l?o.push({...l,range:c}):o.push({range:c,message:e.message,severity:a[e.severity],source:e.source})}),o}async applyCodeAction(e){let t=await this.resolveCodeAction(e);if(!this.destroyed){if(Pd(t)){jd(`Executing command:`,t);return}t.edit&&await this.applyWorkspaceEdit(this.view,t.edit),t.command?jd(`Executing command:`,t.command):t.edit||Lu(this.view,`Code action "${e.title}" has nothing to apply`)}}async resolveCodeAction(e){if(Pd(e)||e.edit||e.command||!this.serverSupportsCodeActionResolve())return e;try{return await this.client.codeActionResolve(e)??e}catch(t){return console.error(`Failed to resolve code action`,t),e}}serverSupportsCodeActionResolve(){let e=this.client.capabilities?.codeActionProvider;if(typeof e==`object`&&e.resolveProvider)return!0;for(let e of this.client.dynamicCapabilities.values())if(e.method===`textDocument/codeAction`&&e.registerOptions?.resolveProvider)return!0;return!1}async showCodeActionsMenu(e){let t=e.state,n=await this.requestCodeActionsAtSelection(e);if(this.destroyed||e.state.doc!==t.doc||!e.state.selection.main.eq(t.selection.main))return!1;if(!n||n.length===0)return Lu(e,`No code actions available`),!1;let r=async e=>{await this.applyCodeAction(e)};return this.codeActionsConfig?.renderMenu?(this.codeActionsConfig.renderMenu(n,r),!0):(this.showDefaultCodeActionsMenu(e,n,r),!0)}showDefaultCodeActionsMenu(e,t,n){this.closeCodeActionMenu?.();let r=document.createElement(`div`);r.className=`cm-code-action-menu`,r.setAttribute(`role`,`listbox`),r.style.cssText=`position: absolute; display: flex; flex-direction: column; padding: 2px; background: white; border: 1px solid #ddd; box-shadow: 0 2px 8px rgba(0,0,0,.15); z-index: 99;`;let i=e=>{r.contains(e.target)||a()},a=()=>{this.closeCodeActionMenu===a&&(this.closeCodeActionMenu=void 0),r.remove(),document.removeEventListener(`mousedown`,i)};this.closeCodeActionMenu=a;let o=t.map(t=>{let i=document.createElement(`button`);i.type=`button`,i.className=`cm-code-action-item`,i.style.cssText=`display: flex; gap: 8px; align-items: baseline; padding: 4px 8px; border: none; background: none; text-align: left; cursor: pointer; font: inherit;`;let o=document.createElement(`span`);if(o.textContent=t.title,i.appendChild(o),!Pd(t)&&t.kind){let e=document.createElement(`span`);e.className=`cm-code-action-kind`,e.style.cssText=`color: #888; font-size: 85%; margin-left: auto;`,e.textContent=t.kind,i.appendChild(e)}return!Pd(t)&&t.disabled&&(i.disabled=!0,i.title=t.disabled.reason,i.style.opacity=`0.5`,i.style.cursor=`default`),i.addEventListener(`click`,()=>{a(),e.focus(),n(t)}),r.appendChild(i),i}),s=o.findIndex(e=>!e.disabled),c=e=>{s=e,o[e]?.focus()},l=e=>{for(let t=s+e;t>=0&&t<o.length;t+=e)if(!o[t]?.disabled){c(t);return}};r.tabIndex=-1,r.addEventListener(`keydown`,t=>{if(t.key===`Escape`)a(),e.focus();else if(t.key===`ArrowDown`)l(1);else if(t.key===`ArrowUp`)l(-1);else if(t.key===`Enter`){let e=o[s];e&&!e.disabled&&e.click()}else return;t.preventDefault(),t.stopPropagation()});let u=e.coordsAtPos(e.state.selection.main.from);u&&(r.style.left=`${u.left+window.scrollX}px`,r.style.top=`${u.bottom+window.scrollY+5}px`),document.addEventListener(`mousedown`,i),document.body.appendChild(r),s===-1?r.focus():c(s)}async requestRename(e,{line:t,character:n}){if(this.featureOptions.renameEnabled){if(!this.client.ready){Lu(e,`Language server not ready`);return}if(!this.client.hasCapability(`textDocument/rename`)){Lu(e,`Rename not supported by language server`);return}try{let r=await this.client.textDocumentPrepareRename({textDocument:{uri:this.documentUri},position:{line:t,character:n}}).catch(()=>this.prepareRenameFallback(e,{line:t,character:n}));if(!r){Lu(e,`Cannot rename this symbol`);return}let i;if(`defaultBehavior`in r){if(!r.defaultBehavior){Lu(e,`Cannot rename this symbol`);return}let a=this.prepareRenameFallback(e,{line:t,character:n});if(!a){Lu(e,`Cannot rename this symbol`);return}i=a}else i=r;let a=document.createElement(`div`);a.className=`cm-rename-popup`,a.style.cssText=`position: absolute; padding: 4px; background: white; border: 1px solid #ddd; box-shadow: 0 2px 8px rgba(0,0,0,.15); z-index: 99;`;let o=document.createElement(`input`);o.type=`text`,o.style.cssText=`width: 200px; padding: 4px; border: 1px solid #ddd;`;let s=`range`in i?i.range:i,c=hu(e.state.doc,s.start);if(c==null)return;let l=hu(e.state.doc,s.end);o.value=`placeholder`in i?i.placeholder:l==null?``:e.state.doc.sliceString(c,l);let u=o.value;a.appendChild(o);let d=e.coordsAtPos(c);if(!d)return;a.style.left=`${d.left}px`,a.style.top=`${d.bottom+5}px`;let f=e=>{a.contains(e.target)||p()},p=()=>{a.remove(),document.removeEventListener(`mousedown`,f),this.closeRenamePopup===p&&(this.closeRenamePopup=void 0)},m=async()=>{let r=o.value.trim();if(!r){Lu(e,`New name cannot be empty`),p();return}if(/[\r\n]/.test(r)){Lu(e,`New name must be a single line`),p();return}if(r===u){p();return}try{let i=e.state.doc,a=await this.client.textDocumentRename({textDocument:{uri:this.documentUri},position:{line:t,character:n},newName:r});if(this.destroyed||e.state.doc!==i)return;await this.applyRenameEdit(e,a)}catch(t){Lu(e,`Rename failed: ${t instanceof Error?t.message:`Unknown error`}`)}finally{p()}};o.addEventListener(`keydown`,e=>{e.key===`Enter`?m():e.key===`Escape`&&p(),e.stopPropagation()}),this.closeRenamePopup?.(),this.closeRenamePopup=p,document.addEventListener(`mousedown`,f),document.body.appendChild(a),o.focus(),o.select()}catch(t){Lu(e,`Rename failed: ${t instanceof Error?t.message:`Unknown error`}`)}}}async requestSignatureHelp(e,{line:t,character:n},r=void 0){if(!(this.featureOptions.signatureHelpEnabled&&this.client.ready&&this.client.hasCapability(`textDocument/signatureHelp`)))return null;try{let i=await this.client.textDocumentSignatureHelp({textDocument:{uri:this.documentUri},position:{line:t,character:n},context:{isRetrigger:!1,triggerKind:1,triggerCharacter:r}});if(!i?.signatures||i.signatures.length===0)return null;let a=this.createTooltipContainer(),o=i.activeSignature??0,s=i.signatures[o]||i.signatures[0];if(!s)return null;let c=i.activeParameter??s.activeParameter??0,l=this.createSignatureElement(s,c);a.appendChild(l),s.documentation&&a.appendChild(this.createDocumentationElement(s.documentation));let u=s.parameters?.[c];u?.documentation&&a.appendChild(this.createParameterDocElement(u.documentation));let d=hu(e.state.doc,{line:t,character:n});return d==null?null:{pos:d,end:d,create:e=>({dom:a}),above:this.featureOptions.signatureHelpOptions?.position===`above`}}catch(e){return console.error(`Signature help error:`,e),null}}async showSignatureHelpTooltip(e,t,n){let r=++this.signatureHelpRequestId,i=await this.requestSignatureHelp(e,gu(e.state.doc,t),n);this.destroyed||r!==this.signatureHelpRequestId||e.dispatch({effects:Vd.of(i)})}createTooltipContainer(){let e=document.createElement(`div`);return e.classList.add(`cm-signature-help`),e.style.cssText=`padding: 6px; max-width: 400px;`,e}createSignatureElement(e,t){let n=document.createElement(`div`);if(n.classList.add(`cm-signature`),n.style.cssText=`font-family: monospace; margin-bottom: 4px;`,!e.label||typeof e.label!=`string`)return n.textContent=`Signature information unavailable`,n;let r=e.label,i=e.parameters||[];if(i.length===0||!i[t])return n.textContent=r,n;let a=i[t].label;if(typeof a==`string`){let e=r.indexOf(`(`)+1;for(let n=0;n<t;n++){let t=i[n]?.label;if(typeof t==`string`){let n=r.indexOf(t,e);n!==-1&&(e=n+t.length)}}let o=r.indexOf(a,e);o===-1?n.textContent=r:this.applyRangeHighlighting(n,r,o,o+a.length)}else Array.isArray(a)&&a.length===2?this.applyRangeHighlighting(n,r,a[0],a[1]):n.textContent=r;return n}applyRangeHighlighting(e,t,n,r){if(!(Number.isInteger(n)&&Number.isInteger(r))||n<0||r<0||n>t.length||r>t.length){e.textContent=t;return}let i=Math.min(n,r),a=Math.max(n,r);if(i===a){e.textContent=t;return}e.textContent=``;let o=t.substring(0,i),s=t.substring(i,a),c=t.substring(a);e.appendChild(document.createTextNode(o));let l=document.createElement(`span`);l.classList.add(`cm-signature-active-param`),l.style.cssText=`font-weight: bold; text-decoration: underline;`,l.textContent=s,e.appendChild(l),e.appendChild(document.createTextNode(c))}createDocumentationElement(e){let t=document.createElement(`div`);return t.classList.add(`cm-signature-docs`),t.style.cssText=`margin-top: 4px; color: #666;`,Ou(t,e,{allowHTMLContent:this.allowHTMLContent,markdownRenderer:this.markdownRenderer}),t}createParameterDocElement(e){let t=document.createElement(`div`);return t.classList.add(`cm-parameter-docs`),t.style.cssText=`margin-top: 4px; font-style: italic; border-top: 1px solid #eee; padding-top: 4px;`,Ou(t,e,{allowHTMLContent:this.allowHTMLContent,markdownRenderer:this.markdownRenderer}),t}prepareRenameFallback(e,{line:t,character:n}){let r=e.state.doc.line(t+1).text,i=/\w+/g,a,o=n,s=n;for(;(a=i.exec(r))!==null;){let e=a.index,t=a.index+a[0].length;if(n>=e&&n<=t){o=e,s=t;break}}return o===n&&s===n?null:{range:{start:{line:t,character:o},end:{line:t,character:s}},placeholder:r.slice(o,s)}}applyEdits(e,t){let n=e.state.doc,r=[];for(let e of t){if(!e||typeof e!=`object`||!e.range||typeof e.newText!=`string`)return!1;let t=hu(n,e.range.start),i=hu(n,e.range.end);if(t==null||i==null||t>i)return!1;r.push({from:t,to:i,insert:e.newText})}if(r.length===0)return!1;let i=[...r].sort((e,t)=>e.from-t.from||e.to-t.to);for(let t=1;t<i.length;t++){let n=i[t-1],r=i[t];if(n&&r&&(r.from<n.to||r.from===r.to&&n.from===n.to&&r.from===n.from))return Lu(e,`Workspace edit ranges overlap`),!1}return e.dispatch(e.state.update({changes:r})),!0}async applyWorkspaceEdit(e,t){if(!t)return Lu(e,`No edit returned from language server`),!1;let n=t.changes&&typeof t.changes==`object`?t.changes:{},r=Array.isArray(t.documentChanges)?t.documentChanges:[];if(Object.keys(n).length===0&&r.length===0)return Lu(e,`No changes to apply`),!1;if(r.length>0){let t=[];for(let n of r){if(typeof n!=`object`||!n||!(`textDocument`in n))return Lu(e,`File creation, deletion, or renaming operations not supported yet`),!1;if(typeof n.textDocument!=`object`||n.textDocument===null)return Lu(e,`Malformed workspace edit`),!1;if(n.textDocument.uri!==this.documentUri)return Lu(e,`Multi-file edits not supported yet`),!1;if(n.textDocument.version!=null&&n.textDocument.version!==this.documentVersion)return Lu(e,`Workspace edit is stale because the document changed`),!1;if(!Array.isArray(n.edits))return!1;for(let r of n.edits){if(typeof r!=`object`||!r||!(`newText`in r))return Lu(e,`Snippet edits not supported yet`),!1;t.push(r)}}return t.length!==0&&this.applyEdits(e,t)}let i=Object.entries(n);if(i.some(([e])=>e!==this.documentUri))return Lu(e,`Multi-file edits not supported yet`),!1;let a=i[0]?.[1];return Array.isArray(a)?this.applyEdits(e,a):!1}async applyRenameEdit(e,t){return this.applyWorkspaceEdit(e,t)}};function Yd(e){let t={rename:`F2`,goToDefinition:`F12`,signatureHelp:`Mod-Shift-Space`,codeActions:`Mod-.`,...e.keyboardShortcuts},n=e.client,r={diagnosticsEnabled:!0,hoverEnabled:!0,completionEnabled:!0,definitionEnabled:!0,renameEnabled:!0,codeActionsEnabled:!0,signatureHelpEnabled:!0,signatureActivateOnTyping:!1,signatureHelpOptions:{position:`below`},...e},i=Yn.define(t=>new Jd({client:n,documentUri:e.documentUri??t.state.facet(vd),languageId:e.languageId??t.state.facet(yd),view:t,featureOptions:r,sendIncrementalChanges:e.sendIncrementalChanges,allowHTMLContent:e.allowHTMLContent,useSnippetOnCompletion:e.useSnippetOnCompletion,clientSideFiltering:e.clientSideFiltering,onGoToDefinition:e.onGoToDefinition,onShowLocation:e.onShowLocation,markdownRenderer:e.markdownRenderer,codeActionsConfig:e.codeActionsConfig})),a=e=>e.plugin(i),o=[i];if(r.diagnosticsEnabled&&o.push(Bd,Kn.baseTheme({".cm-lsp-unnecessary":{opacity:`0.6`},".cm-lsp-deprecated":{textDecoration:`line-through`},".cm-diagnostic-related":{marginTop:`4px`,display:`flex`,flexDirection:`column`,gap:`2px`},".cm-diagnostic-related-clickable":{cursor:`pointer`},".cm-diagnostic-related-location":{opacity:`0.7`},".cm-diagnostic-code-link":{display:`inline-block`,marginTop:`4px`}})),o.push(dn.of([{key:t.signatureHelp,run:e=>{let t=a(e);if(!(t&&r.signatureHelpEnabled))return!1;let n=e.state.selection.main.head;return t.showSignatureHelpTooltip(e,n),!0}},{key:t.rename,run:e=>{let t=a(e);if(!(t&&r.renameEnabled))return!1;let n=e.state.selection.main.head;return t.requestRename(e,gu(e.state.doc,n)),!0}},{key:t.codeActions,run:e=>{let t=a(e);return t&&r.codeActionsEnabled?(t.showCodeActionsMenu(e).catch(t=>Lu(e,`Code actions failed: ${t instanceof Error?t.message:`Unknown error`}`)),!0):!1}},{key:t.goToDefinition,run:e=>{let t=a(e);if(!(t&&r.definitionEnabled))return!1;let n=e.state.selection.main.head;return t.requestDefinition(e,gu(e.state.doc,n)).catch(t=>Lu(e,`Go to definition failed: ${t instanceof Error?t.message:`Unknown error`}`)),!0}}])),r.hoverEnabled&&o.push(wn((e,t)=>{let n=a(e);return n==null?null:n.requestHoverTooltip(e,gu(e.state.doc,t))},e.hoverConfig)),r.signatureHelpEnabled){o.push(Hd);let e=e=>e.state.field(Hd)?(e.dispatch({effects:Vd.of(null)}),!0):!1;o.push(Kn.domEventHandlers({mousedown:(t,n)=>(e(n),!1)})),o.push(dn.of([{key:`)`,run:t=>(e(t),!1)},{key:`Escape`,run:t=>e(t)}])),o.push(Kn.updateListener.of(t=>{if(!(a(t.view)&&r.signatureActivateOnTyping)||!t.state.field(Hd)||!(t.selectionSet||t.docChanged))return;let n=t.state.selection.main.head;$d(t.state.doc,n)||queueMicrotask(()=>{e(t.view)})})),o.push(Kn.updateListener.of(async e=>{let t=a(e.view);if(!(t&&e.docChanged)||e.transactions.some(e=>e.annotation(Ud))||!t.client.hasCapability(`textDocument/signatureHelp`)||!r.signatureActivateOnTyping)return;let n=t.client.capabilities?.signatureHelpProvider?.triggerCharacters||[`(`,`,`],i=e.changes,o=-1,s;i.iterChanges((e,t,r,i,a)=>{if(o>=0)return;let c=Zd(a.toString(),r,n);c&&(o=c.triggerPos,s=c.triggerCharacter)}),o>=0&&t.showSignatureHelpTooltip(e.view,o,s)}))}if(r.completionEnabled){let t=e.completionConfig?.optionClass;o.push(Kn.baseTheme({".cm-tooltip-autocomplete li.cm-deprecated .cm-completionLabel":{textDecoration:`line-through`}}),Fr({...e.completionConfig,optionClass:e=>[Wu(e),t?.(e)??``].filter(Boolean).join(` `),override:[async t=>{let n=t.view?a(t.view):null;if(n==null)return null;let{state:r,pos:i}=t,o=Xd(t,n.client.capabilities?.completionProvider?.triggerCharacters??[],e.completionMatchBefore);return o==null?null:await n.requestCompletion(t,gu(r.doc,i),o)},...e.completionConfig?.override||[]]}))}return o.push(Kn.domEventHandlers({click:(e,n)=>{if(r.definitionEnabled&&t.goToDefinition===`ctrlcmd`&&(e.ctrlKey||e.metaKey)){let t=n.posAtCoords({x:e.clientX,y:e.clientY}),r=a(n);t&&r&&(r.requestDefinition(n,gu(n.state.doc,t)).catch(e=>Lu(n,`Go to definition failed: ${e instanceof Error?e.message:`Unknown error`}`)),e.preventDefault())}}})),o}function Xd(e,t,n){let{state:r,pos:i,explicit:a}=e,o=r.doc.lineAt(i),s=mu.CompletionTriggerKind.Invoked,c,l=o.text[i-o.from-1]||``,u=t?.includes(l);return!a&&u&&(s=mu.CompletionTriggerKind.TriggerCharacter,c=l),!a&&s===mu.CompletionTriggerKind.Invoked&&!e.matchBefore(n||/(\w+|\w+\.|\/|,)$/)?null:{triggerKind:s,triggerCharacter:c}}function Zd(e,t,n){if(!e)return null;for(let r of n){let n=e.indexOf(r);if(n!==-1)return{triggerPos:t+n+1,triggerCharacter:r}}return null}function Qd(e){let t=0;for(let n of e)n===`(`?t++:n===`)`&&t--;return t}function $d(e,t,n=Wd){let r=e.lineAt(t),i=Math.max(1,r.number-n),a=e.line(i).from;return Qd(e.sliceString(a,t))>0}function ef(e,t,n={}){let{preserveCursor:r=!0,effects:i,userEvent:a}=n,o=e.state.doc;if(o.toString()!==t){if(r&&e.hasFocus){let n=e.state.selection.main.head,r=o.lineAt(n),s=r.number,c=n-r.from,l=e.state.update({changes:{from:0,to:o.length,insert:t}}).state.doc,u;if(s<=l.lines){let e=l.line(s),t=e.length;u=e.from+Math.min(c,t)}else u=l.line(l.lines).to;e.dispatch({changes:{from:0,to:o.length,insert:t},annotations:Ud.of(!0),selection:{anchor:u},effects:i,userEvent:a})}else e.dispatch({changes:{from:0,to:o.length,insert:t},effects:i,userEvent:a})}}function tf(){return vn.define({combine:e=>e.find(e=>e!==void 0)})}var nf=tf(),rf=tf(),af=tf(),of=tf(),sf=tf();function cf({cellId:e,completionConfig:t,hotkeys:n,placeholderType:r,lspConfig:i,diagnosticsConfig:a}){return[of.of(e),nf.of(t),rf.of(n),af.of(r),sf.of({...i,diagnostics:a})]}var lf=new En;function uf(e){return e===`application/vnd.marimo+error`}function df(e){return e===`application/vnd.marimo+traceback`}function ff(e){return uf(e)||df(e)}function pf(e){return Object.values(e.cellRuntime).some(e=>e.status===`running`)}function mf(e){return Object.values(e.cellRuntime).filter(e=>e.status===`running`||e.status===`queued`).length}function hf(e){return Cf(e).length>0}function gf(e){return e.cellIds.inOrderIds.map(t=>e.cellData[t])}function _f({cellHandles:e}){let t={};for(let[n,r]of R.entries(e))r.current?.editorView&&(t[n]=r.current.editorView);return t}function vf(e){let{cellIds:t,cellData:n}=e,r=[];for(let e of t.inOrderIds)n[e].config.disabled&&r.push(e);return r}function yf(e){let{cellIds:t,cellData:n}=e,r=[];for(let e of t.inOrderIds)n[e].config.disabled||r.push(e);return r}function bf(e){return e.history.length>0}function xf(e){let t=e.history[e.history.length-1];return t&&t.type===`move`?`Undo move`:`Undo cell deletion`}function Sf(e,t){let n=e.cellIds.findWithId(t).getDescendants(t);return{stale:n.some(t=>e.cellRuntime[t]?.staleInputs||e.cellData[t]?.edited),errored:n.some(t=>e.cellRuntime[t]?.errored),runningOrQueued:n.some(t=>e.cellRuntime[t]?.status===`running`||e.cellRuntime[t]?.status===`queued`)}}function Cf(e){let{cellIds:t,cellData:n,cellRuntime:r}=e;return t.inOrderIds.filter(e=>wf({executionTime:r[e].runElapsedTimeMs??n[e].lastExecutionTime,status:r[e].status,errored:r[e].errored,interrupted:r[e].interrupted,stopped:r[e].stopped})||n[e].edited||r[e].interrupted||r[e].staleInputs&&!(r[e].status===`disabled-transitively`||n[e].config.disabled))}function wf({executionTime:e,status:t,errored:n,interrupted:r,stopped:i}){return e===null&&t!==`queued`&&t!==`running`&&!(n||r||i)}function Tf({edited:e,interrupted:t,staleInputs:n,disabled:r,status:i}){return e||t||n&&!(r||i===`disabled-transitively`)}function Ef({needsRun:e,errored:t,stopped:n,disabled:r,status:i}){return{"needs-run":e,"has-error":t,stopped:n,disabled:r??!1,stale:i===`disabled-transitively`}}function Df({errored:e,stopped:t}){return{published:!0,"has-error":e,stopped:t}}function Of({errored:e,interrupted:t,stopped:n,output:r,showErrorTracebacks:i}){let a=ff(r?.mimetype),o=i&&a&&Array.isArray(r?.data)&&r.data.some(e=>e.type===`exception`&&`traceback`in e&&e.traceback);return(e||t||n||a)&&!o}var kf=vn.define({combine:e=>e[0]}),Af=vn.define({combine:e=>e[0]}),jf={...Jr,caseInsensitiveIdentifiers:!0,identifierQuotes:"`"},Mf=Xr.define(jf),Nf=Xr.define({doubleQuotedStrings:!1,hashComments:!1,spaceAfterDashes:!1,identifierQuotes:`"`,caseInsensitiveIdentifiers:!0,keywords:`abs access acos aes_decrypt aggregate all allocate allow alter analyze and any approx_count_distinct approx_percentile are array array_avg array_cat array_compact array_contains array_generate_range array_max array_max_cardinality array_min array_position array_remove array_remove_at array_size array_sum array_to_string arrow as ascii asensitive asin assign asymmetric at atan atan2 atomic authorization auto avg avoid base64 batch begin begin_frame begin_partition between bigint bin bin_pack binary binary_string bit bit_and bit_length bit_or bitwise_and bitwise_not bitwise_or bitwise_xor blob bool_and bool_or boolean both branch bround btrim by cache call called cardinality cascaded case cast catalog cbrt ceil ceiling change char char_length character character_length check chr classifier clob close cloud coalesce col_like collate collect column columns commit commits_older_than compute concat concat_ws condition connect constraint contains convert convert_from convert_replaceutf8 convert_timezone convert_to copy corr corresponding cos cosh cot count covar_pop covar_samp crc32 create cross cube cume_dist current current_catalog current_date current_date_utc current_default_transform_group current_path current_role current_row current_schema current_time current_timestamp current_transform_group_for_type current_user cursor cycle data databases datasets date date_add date_diff date_format date_part date_sub date_trunc datediff datetype day dayofmonth dayofweek dayofyear deallocate dec decimal declare dedupe_lookback_period default define degrees delete dense_rank deref describe deterministic dimensions disallow disconnect display distinct double drop dynamic e each element else empty empty_as_null encode end end-exec end_frame end_partition ends_with engine equals escape escape_char every except exec execute exists exp expire explain extend external extract factorial false fetch field field_delimiter file_format files filter first_value flatten float floor folder for foreign frame_row free from from_hex full function fusion geo_beyond geo_distance geo_nearby get global grant grants greatest group grouping groups hash hash64 having hex history hold hour identity if ilike imindir import in include indicator initcap initial inner inout insensitive insert instr int integer intersect intersection interval into is is_bigint is_int is_member is_substr is_utf8 is_varchar isdate isnumeric job join json_array json_arrayagg json_exists json_object json_objectagg json_query json_value lag language large last_day last_query_id last_value lateral lazy lcase lead leading least left length levenshtein like like_regex limit listagg ln local localsort localtime localtimestamp locate log log10 logs lower lpad lshift ltrim manifests map_keys map_values mask mask_first_n mask_hash mask_last_n mask_show_first_n mask_show_last_n masking match match_number match_recognize matches max max_file_size_mb maxdir md5 measures median member merge metadata method min min_file_size_mb min_input_files mindir minus minute missing mod modifies module monitor month months_between more multiset national natural nchar nclob ndv new next next_day no none normalize normalize_string not notification_provider notification_queue_reference now nth_value ntile null null_if nullif numeric nvl occurrences_regex octet_length of offset old older_than omit on one only open operate optimize or order orphan out outer over overlaps overlay ownership parameter parse_url partition partitions pattern per percent percent_rank percentile_cont percentile_disc period permute pi pivot pmod policy portion position position_regex pow power precedes precision prepare prev primary procedure project promotion qualify quarter query query_user quote quote_char radians random range rank raw reads real record_delimiter recursive ref reference references referencing reflection reflections refresh regex regexp_col_like regexp_extract regexp_like regexp_matches regexp_replace regexp_split regr_avgx regr_avgy regr_count regr_intercept regr_r2 regr_slope regr_sxy regr_syy release remove rename repeat repeatstr replace reset result retain_last retain_last_commits retain_last_snapshots return returns reverse revoke rewrite right role rollback rollup round route row row_number rows rpad rshift rtrim running savepoint schemas scope scroll search second seek select sensitive session_user set sha sha1 sha256 sha512 show sign similar similar_to sin sinh size skip smallint snapshot snapshots snapshots_older_than some soundex specific specifictype split_part sql sqlexception sqlstate sqlwarning sqrt st_fromgeohash st_geohash start starts_with static statistics stddev stddev_pop stddev_samp stream string_binary strpos submultiset subset substr substring substring_index substring_regex succeeds sum symmetric system system_time system_user table tables tablesample tag tan tanh target_file_size_mb tblproperties then time time_format timestamp timestamp_format timestampadd timestampdiff timestamptype timezone_hour timezone_minute tinyint to to_char to_date to_hex to_number to_time to_timestamp toascii trailing transaction_timestamp translate translate_regex translation treat trigger trim trim_array trim_space true truncate typeof ucase uescape unbase64 unhex union unique unix_timestamp unknown unnest unpivot unset update upper upsert usage use user using vacuum value value_of values var_pop var_samp varbinary varchar varying versioning view views week weekofyear when whenever where width_bucket window with within without write xor year`,types:`array bigint binary boolean char character date dec decimal double float int integer interval map numeric struct time timestamp uuid varbinary varchar variant`}),Pf=Xr.define({charSetCasts:!0,doubleQuotedStrings:!1,unquotedBitLiterals:!0,hashComments:!1,spaceAfterDashes:!1,specialVar:`@?`,identifierQuotes:`"`,caseInsensitiveIdentifiers:!0,keywords:`percentile_cont row_number rank dense_rank rank_dense percent_rank cume_dist ntile lag lead first_value last_value nth_value !__postfix !~~ !~~* % & && * ** + - ->> / // <-> << <=> <@ >> @ @> Calendar JSON TimeZone ^ ^@ abort abs absolute access access_mode acos acosh action add add_parquet_key admin after age aggregate alias all all_profiling_output allow_community_extensions allow_extensions_metadata_mismatch allow_persistent_secrets allow_unredacted_secrets allow_unsigned_extensions allowed_directories allowed_paths also alter always analyse analyze and anti any any_value apply approx_count_distinct approx_quantile approx_top_k arbitrary arg_max arg_max_null arg_min arg_min_null argmax argmin array array_agg array_aggr array_aggregate array_append array_apply array_cat array_concat array_contains array_cosine_distance array_cosine_similarity array_cross_product array_distance array_distinct array_dot_product array_extract array_filter array_grade_up array_has array_has_all array_has_any array_indexof array_inner_product array_intersect array_length array_negative_dot_product array_negative_inner_product array_pop_back array_pop_front array_position array_prepend array_push_back array_push_front array_reduce array_resize array_reverse array_reverse_sort array_select array_slice array_sort array_to_json array_to_string array_to_string_comma_default array_transform array_unique array_value array_where array_zip arrow_large_buffer_size arrow_lossless_conversion arrow_output_list_view arrow_output_version arrow_scan arrow_scan_dumb as asc ascii asin asinh asof asof_loop_join_threshold assertion assignment asymmetric at atan atan2 atanh attach attribute authorization autoinstall_extension_repository autoinstall_known_extensions autoload_known_extensions avg backward bar base64 before begin between bigint bin binary binary_as_string bit bit_and bit_count bit_length bit_or bit_position bit_xor bitstring bitstring_agg blob bool bool_and bool_or boolean both bpchar by bytea cache call called can_cast_implicitly cardinality cascade cascaded case cast cast_to_type catalog catalog_error_max_schemas cbrt ceil ceiling centuries century chain char char_length character character_length characteristics check checkpoint checkpoint_threshold chr class close cluster coalesce col_description collate collation collations column columns combine comment comments commit committed compression concat concat_ws concurrently configuration conflict connection constant_or_null constraint constraints contains content continue conversion copy copy_database corr cos cosh cost cot count count_if count_star countif covar_pop covar_samp create create_sort_key cross csv cube current current_catalog current_connection_id current_database current_date current_localtime current_localtimestamp current_query current_query_id current_role current_schema current_schemas current_setting current_transaction_id current_user currval cursor custom_extension_repository custom_profiling_settings custom_user_agent cycle damerau_levenshtein data database database_list database_size date date_add date_diff date_part date_sub date_trunc datediff datepart datesub datetime datetrunc day dayname dayofmonth dayofweek dayofyear days deallocate debug_asof_iejoin debug_checkpoint_abort debug_force_external debug_force_no_cross_product debug_skip_checkpoint_on_commit debug_verify_vector debug_window_mode dec decade decades decimal declare decode default default_block_size default_collation default_null_order default_order default_secret_storage defaults deferrable deferred definer degrees delete delimiter delimiters depends desc describe detach dictionary disable disable_checkpoint_on_shutdown disable_logging disable_object_cache disable_optimizer disable_parquet_prefetching disable_print_progress_bar disable_profile disable_profiling disable_progress_bar disable_timestamptz_casts disable_verification disable_verify_external disable_verify_fetch_row disable_verify_parallelism disable_verify_serializer disabled_compression_methods disabled_filesystems disabled_log_types disabled_optimizers discard distinct divide do document domain double drop duckdb_api duckdb_columns duckdb_constraints duckdb_databases duckdb_dependencies duckdb_extensions duckdb_external_file_cache duckdb_functions duckdb_indexes duckdb_keywords duckdb_log_contexts duckdb_logs duckdb_logs_parsed duckdb_memory duckdb_optimizers duckdb_prepared_statements duckdb_schemas duckdb_secret_types duckdb_secrets duckdb_sequences duckdb_settings duckdb_table_sample duckdb_tables duckdb_temporary_files duckdb_types duckdb_variables duckdb_views dynamic_or_filter_threshold each editdist3 element_at else enable enable_checkpoint_on_shutdown enable_external_access enable_external_file_cache enable_fsst_vectors enable_geoparquet_conversion enable_http_logging enable_http_metadata_cache enable_logging enable_macro_dependencies enable_object_cache enable_optimizer enable_print_progress_bar enable_profile enable_profiling enable_progress_bar enable_progress_bar_print enable_verification enable_view_dependencies enabled_log_types encode encoding encrypted end ends_with entropy enum enum_code enum_first enum_last enum_range enum_range_boundary epoch epoch_ms epoch_ns epoch_us equi_width_bins era error errors_as_json escape even event except exclude excluding exclusive execute exists exp explain explain_output export export_state extension extension_directory extension_versions extensions external external_threads extract factorial false family favg fdiv fetch file_search_path filter finalize first flatten float float4 float8 floor fmod following for force force_bitpacking_mode force_checkpoint force_compression foreign format formatReadableDecimalSize formatReadableSize format_bytes format_pg_type format_type forward freeze from from_base64 from_binary from_hex from_json from_json_strict fsum full function functions gamma gcd gen_random_uuid generate_series generate_subscripts generated geomean geometric_mean get_bit get_block_size get_current_time get_current_timestamp getvariable glob global grade_up grant granted greatest greatest_common_divisor group group_concat grouping grouping_id groups guid hamming handler having header hex histogram histogram_exact histogram_values hold home_directory hour hours http_logging_output http_proxy http_proxy_password http_proxy_username hugeint identity ieee_floating_point_ops if ignore ilike ilike_escape immediate immediate_transaction_mode immutable implicit import import_database in in_search_path include including increment index index_scan_max_count index_scan_percentage indexes inet_client_addr inet_client_port inet_server_addr inet_server_port inherit inherits initially inline inner inout input insensitive insert install instead instr int int1 int128 int16 int2 int32 int4 int64 int8 integer integer_division integral intersect interval into invoker is is_histogram_other_bin isfinite isinf isnan isnull isodow isolation isoyear jaccard jaro_similarity jaro_winkler_similarity join json json_array json_array_length json_contains json_deserialize_sql json_each json_execute_serialized_sql json_exists json_extract json_extract_path json_extract_path_text json_extract_string json_group_array json_group_object json_group_structure json_keys json_merge_patch json_object json_pretty json_quote json_serialize_plan json_serialize_sql json_structure json_transform json_transform_strict json_tree json_type json_valid json_value julian kahan_sum key kurtosis kurtosis_pop label lambda lambda_syntax language large last last_day late_materialization_max_rows lateral lcase lcm leading leakproof least least_common_multiple left left_grapheme len length length_grapheme level levenshtein lgamma like like_escape limit list list_aggr list_aggregate list_any_value list_append list_apply list_approx_count_distinct list_avg list_bit_and list_bit_or list_bit_xor list_bool_and list_bool_or list_cat list_concat list_contains list_cosine_distance list_cosine_similarity list_count list_distance list_distinct list_dot_product list_element list_entropy list_extract list_filter list_first list_grade_up list_has list_has_all list_has_any list_histogram list_indexof list_inner_product list_intersect list_kurtosis list_kurtosis_pop list_last list_mad list_max list_median list_min list_mode list_negative_dot_product list_negative_inner_product list_pack list_position list_prepend list_product list_reduce list_resize list_reverse list_reverse_sort list_select list_sem list_skewness list_slice list_sort list_stddev_pop list_stddev_samp list_string_agg list_sum list_transform list_unique list_value list_var_pop list_var_samp list_where list_zip listagg listen ln load local location lock lock_configuration locked log log10 log2 log_query_path logged logging_level logging_mode logging_storage logical long lower lpad ltrim macro mad make_date make_time make_timestamp make_timestamp_ns make_timestamptz map map_concat map_contains map_contains_entry map_contains_value map_entries map_extract map_extract_value map_from_entries map_keys map_to_pg_oid map_values mapping match materialized max max_by max_expression_depth max_memory max_temp_directory_size max_vacuum_tasks maxvalue md5 md5_number md5_number_lower md5_number_upper mean median memory_limit merge_join_threshold metadata_info method microsecond microseconds millennia millennium millisecond milliseconds min min_by minute minutes minvalue mismatches mod mode month monthname months move multiply name names nanosecond national natural nchar nested_loop_join_threshold new next nextafter nextval nfc_normalize no none normalized_interval not not_ilike_escape not_like_escape nothing notify notnull now nowait null null_order nullif nulls numeric nvarchar obj_description object octet_length of off offset oid oids old old_implicit_casting on only operator option options or ord order order_by_non_integer_literal ordered_aggregate_threshold ordinality others out outer over overlaps overlay overriding owned owner pandas_analyze_sample pandas_scan parallel parquet_bloom_probe parquet_file_metadata parquet_kv_metadata parquet_metadata parquet_metadata_cache parquet_scan parquet_schema parse_dirname parse_dirpath parse_duckdb_log_message parse_filename parse_path parser partial partition partitioned partitioned_write_flush_threshold partitioned_write_max_open_files passing password percent perfect_ht_threshold persistent pi pivot pivot_filter_threshold pivot_limit pivot_longer pivot_wider placing plans platform policy position positional pow power pragma pragma_collations pragma_database_size pragma_metadata_info pragma_platform pragma_show pragma_storage_info pragma_table_info pragma_user_agent pragma_version preceding precision prefer_range_joins prefetch_all_parquet_files prefix prepare prepared preserve preserve_identifier_case preserve_insertion_order primary printf prior privileges procedural procedure produce_arrow_string_view product profile_output profiling_mode profiling_output program progress_bar_time publication python_enable_replacements python_map_function python_scan_all_frames qualify quantile quantile_cont quantile_disc quarter quarters query query_table quote radians random range read read_blob read_csv read_csv_auto read_json read_json_auto read_json_objects read_json_objects_auto read_ndjson read_ndjson_auto read_ndjson_objects read_parquet read_text real reassign recheck recursive reduce ref references referencing refresh regexp_escape regexp_extract regexp_extract_all regexp_full_match regexp_matches regexp_replace regexp_split_to_array regexp_split_to_table regr_avgx regr_avgy regr_count regr_intercept regr_r2 regr_slope regr_sxx regr_sxy regr_syy reindex relative release remap_struct rename repeat repeat_row repeatable replace replica reservoir_quantile reset respect restart restrict returning returns reverse revoke right right_grapheme role rollback rollup round round_even roundbankers row row_to_json rows rpad rtrim rule sample savepoint scalar_subquery_error_on_multiple_rows scheduler_process_partial schema schemas scope scroll search search_path second seconds secret secret_directory security select sem semi seq_scan sequence sequences serializable server session session_user set set_bit setof sets setseed sha1 sha256 share shobj_description short show show_databases show_tables show_tables_expanded sign signbit signed similar simple sin sinh skewness skip smallint snapshot sniff_csv some sorted split split_part sql sqrt stable standalone start starts_with statement statistics stats stddev stddev_pop stddev_samp stdin stdout storage storage_compatibility_version storage_info stored str_split str_split_regex streaming_buffer_size strftime strict string string_agg string_split string_split_regex string_to_array strip strip_accents strlen strpos strptime struct struct_concat struct_extract struct_extract_at struct_insert struct_pack subscription substr substring substring_grapheme subtract suffix sum sum_no_overflow sumkahan summarize summary symmetric sysid system table table_info tables tablesample tablespace tan tanh temp temp_directory template temporary test_all_types test_vector_types text then threads ties time time_bucket timestamp timestamp_ms timestamp_ns timestamp_s timestamp_us timestamptz timetz timetz_byte_comparable timezone timezone_hour timezone_minute tinyint to to_base to_base64 to_binary to_centuries to_days to_decades to_hex to_hours to_json to_microseconds to_millennia to_milliseconds to_minutes to_months to_quarters to_seconds to_timestamp to_weeks to_years today trailing transaction transaction_timestamp transform translate treat trigger trim true trunc truncate truncate_duckdb_logs trusted try_cast try_strptime txid_current type typeof types ubigint ucase uhugeint uint128 uint16 uint32 uint64 uint8 uinteger unbin unbounded uncommitted unencrypted unhex unicode union union_extract union_tag union_value unique unknown unlisten unlogged unnest unpack unpivot unpivot_list until update upper url_decode url_encode use user user_agent username using usmallint utinyint uuid uuid_extract_timestamp uuid_extract_version uuidv4 uuidv7 vacuum valid validate validator value values var_pop var_samp varbinary varchar variable variadic variance varint varying vector_type verbose verify_external verify_fetch_row verify_parallelism verify_serializer version view views virtual volatile wal_autocheckpoint wavg week weekday weekofyear weeks weighted_avg when where which_secret whitespace window with within without work worker_threads wrapper write write_log xml xmlattributes xmlconcat xmlelement xmlexists xmlforest xmlnamespaces xmlparse xmlpi xmlroot xmlserialize xmltable xor year years yearweek yes zone zstd_min_string_length | || ~ ~~ ~~* ~~~`,types:`JSON bigint binary bit bitstring blob bool boolean bpchar bytea char date datetime dec decimal double enum float float4 float8 guid hugeint int int1 int128 int16 int2 int32 int4 int64 int8 integer integral interval list logical long map null numeric nvarchar oid real row short signed smallint string struct text time timestamp timestamp_ms timestamp_ns timestamp_s timestamp_us timestamptz timetz tinyint ubigint uhugeint uint128 uint16 uint32 uint64 uint8 uinteger union usmallint utinyint uuid varbinary varchar varint`}),Ff=new Set(`postgresql.postgres.couchbase.db2.db2i.tidb.mysql.sqlite.mssql.sqlserver.duckdb.mariadb.cassandra.noql.spark.awsathena.athena.bigquery.hive.redshift.snowflake.flink.mongodb.trino.oracle.oracledb.singlestoredb.timescaledb.databricks.datafusion.microsoft sql server.dremio`.split(`.`));function If(e){return Ff.has(e)}function Lf(e){let t=e.dialect;if(!If(t))return L.debug(`Unknown dialect`,{dialect:t}),zf;switch(t){case`postgresql`:case`postgres`:return Jr;case`mysql`:return Gr;case`sqlite`:return Hr;case`mssql`:case`sqlserver`:case`microsoft sql server`:return qr;case`duckdb`:return Pf;case`mariadb`:return Yr;case`cassandra`:return Zr;case`oracledb`:case`oracle`:return Vr;case`bigquery`:return Mf;case`dremio`:return Nf;case`timescaledb`:return Jr;case`awsathena`:case`athena`:case`db2i`:case`db2`:case`hive`:case`redshift`:case`snowflake`:case`flink`:case`mongodb`:case`noql`:case`couchbase`:case`trino`:case`tidb`:case`singlestoredb`:case`spark`:case`databricks`:case`datafusion`:return L.debug(`Unsupported dialect`,{dialect:t}),zf;default:return Lr(t),zf}}var Rf={...Kr,caseInsensitiveIdentifiers:!0,identifierQuotes:`'`},zf=Xr.define(Rf),Bf=`__marimo_duckdb`,Vf=new Set([Bf]);function Hf(e,t){if(!e)return t;let n=(e.schemaPath?.length?e.schemaPath:[e.schema]).filter(Boolean);return[e.database,...n,t].join(`.`)}function Uf(e){return e===``}function Wf(e){return e.schemas_resolved!==!1}function Gf(e){return e.tables_resolved!==!1}function Kf(e){return e.child_schemas_resolved!==!1}function qf(e,t){let n=t?.trim().toLowerCase();return n?Gf(e)&&e.tables.some(e=>e.name.toLowerCase().includes(n))?!0:Kf(e)?(e.child_schemas??[]).some(e=>qf(e,n)):!1:!1}function Jf(e,t){return!t?.trim()||!Wf(e)?!1:e.schemas.some(e=>qf(e,t))}var Yf={formatTablePath:e=>e.join(`.`),formatSelectClause:(e,t)=>`SELECT ${e} FROM ${t} LIMIT 100`};function Xf(e){if(e=e.toLowerCase(),!If(e))return Yf;switch(e){case`bigquery`:{let e=Mf.spec.identifierQuotes;return{formatTablePath:t=>`${e}${t.join(`.`)}${e}`,formatSelectClause:Yf.formatSelectClause}}case`mssql`:case`sqlserver`:case`microsoft sql server`:return{formatTablePath:Yf.formatTablePath,formatSelectClause:(e,t)=>`SELECT TOP 100 ${e} FROM ${t}`};case`timescaledb`:case`postgres`:case`postgresql`:case`duckdb`:case`dremio`:return{formatTablePath:e=>e.map(e=>`"${e}"`).join(`.`),formatSelectClause:(e,t)=>`SELECT ${e===`*`?`*`:`"${e}"`} FROM ${t} LIMIT 100`};case`db2`:case`db2i`:case`mysql`:case`sqlite`:case`mariadb`:case`cassandra`:case`noql`:case`awsathena`:case`athena`:case`hive`:case`redshift`:case`snowflake`:case`flink`:case`mongodb`:case`oracle`:case`oracledb`:case`couchbase`:case`tidb`:case`spark`:case`trino`:case`singlestoredb`:case`databricks`:case`datafusion`:return Yf;default:return Lr(e),Yf}}function Zf({table:e,columnName:t,sqlTableContext:n}){if(n){let{engine:r,schema:i,defaultSchema:a,defaultDatabase:o,database:s,dialect:c}=n,l=[e.name];Uf(i)||i!==a&&l.unshift(i),s!==o&&l.unshift(s);let u=Xf(c),d=u.formatTablePath(l),f=u.formatSelectClause(t,d);return r===`__marimo_duckdb`?`_df = mo.sql(f"""\n${f}\n""")`:`_df = mo.sql(f"""\n${f}\n""", engine=${r})`}return`_df = mo.sql(f'SELECT "${t}" FROM ${e.name} LIMIT 100')`}function Qf(e,t){if(t===`date`||t===`datetime`||t===`time`){if(e===`min`)return`Earliest`;if(e===`max`)return`Latest`}return e}function $f(){return{tables:[],expandedTables:new Set,expandedColumns:new Set,columnsPreviews:new Map}}var{reducer:ep,createActions:tp,valueAtom:np,useActions:rp}=kr($f,{addDatasets:(e,t)=>{let{previewDatasetColumn:n}=Br();for(let r of t.tables)for(let t of r.columns){let i=`${r.name}:${t.name}`;e.expandedColumns.has(i)&&n({tableName:r.name,columnName:t.name,source:r.source,sourceType:r.source_type})}let r=e.tables;t.clear_channel&&(r=r.filter(e=>e.source!==t.clear_channel));let i=[...t.tables,...r],a=new Set,o=i.filter(e=>{let t=`${e.name}:${e.source}`;return!a.has(t)&&(a.add(t),!0)}).toSorted((e,t)=>e.name.localeCompare(t.name));return{...e,tables:o}},filterDatasetsFromVariables:(e,t)=>{let n=new Set(t),r=e.tables.filter(e=>!e.variable_name||n.has(e.variable_name));return{...e,tables:r}},toggleTable:(e,t)=>{let n=new Set(e.expandedTables);return n.has(t)?n.delete(t):n.add(t),{...e,expandedTables:n}},toggleColumn:(e,t)=>{let n=`${t.table}:${t.column}`,r=new Set(e.expandedColumns);return r.has(n)?r.delete(n):r.add(n),{...e,expandedColumns:r}},closeAllColumns:e=>({...e,expandedColumns:new Set}),addColumnPreview:(e,t)=>{let n=`${t.table_name}:${t.column_name}`,r=new Map(e.columnsPreviews);return r.set(n,t),{...e,columnsPreviews:r}}}),ip=()=>s(np),ap=o(e=>e(np).tables),op=o(new Set),sp=o(!1);function cp(){return rp()}var lp=new Map([[Bf,{name:Bf,dialect:`duckdb`,source:`duckdb`,display_name:`DuckDB (In-Memory)`,databases:[]}]]);function up(e,t,n){if(t.length===0)return e;let[r,...i]=t;return e.map(e=>e.name===r?i.length===0?n(e):{...e,child_schemas:up(e.child_schemas??[],i,n)}:e)}function dp(e){let{schemaPath:t,schema:n}=e;return t&&t.length>0?t:[n]}function fp(){return{latestEngineSelected:null,connectionsMap:lp}}var{reducer:pp,createActions:mp,valueAtom:hp,useActions:gp}=kr(fp,{addDataSourceConnection:(e,t)=>{if(t.connections.length===0)return e;let{latestEngineSelected:n,connectionsMap:r}=e,i=new Map(r);for(let e of t.connections)i.delete(e.name),i.set(e.name,e);return{latestEngineSelected:n,connectionsMap:i}},filterDataSourcesFromVariables:(e,t)=>{let{latestEngineSelected:n,connectionsMap:r}=e,i=new Set(t),a=new Map([...r].filter(([e])=>Vf.has(e)?!0:i.has(e)));return{latestEngineSelected:n&&a.has(n)?n:null,connectionsMap:a}},clearDataSourceConnections:()=>({latestEngineSelected:null,connectionsMap:new Map}),removeDataSourceConnection:(e,t)=>{let{latestEngineSelected:n,connectionsMap:r}=e,i=new Map(r);return i.delete(t),{latestEngineSelected:n&&i.has(n)?n:null,connectionsMap:i}},addSchemaList:(e,t)=>{let{schemas:n,sqlSchemaContext:r}=t,{connectionsMap:i,latestEngineSelected:a}=e,o=r.engine,s=i.get(o);if(!s)return e;let c=r.schemaPath??[],l=new Map(i),u={...s,databases:s.databases.map(e=>e.name===r.database?c.length===0?{...e,schemas:n,schemas_resolved:!0}:{...e,schemas:up(e.schemas,c,e=>({...e,child_schemas:n,child_schemas_resolved:!0}))}:e)};return l.set(o,u),{latestEngineSelected:a,connectionsMap:l}},addTableList:(e,t)=>{let{tables:n,sqlTableContext:r}=t,{connectionsMap:i,latestEngineSelected:a}=e,o=r.engine,s=i.get(o);if(!s)return e;let c=dp(r),l=new Map(i),u={...s,databases:s.databases.map(e=>e.name===r.database?{...e,schemas:up(e.schemas,c,e=>({...e,tables:n,tables_resolved:!0}))}:e)};return l.set(o,u),{latestEngineSelected:a,connectionsMap:l}},addTable:(e,t)=>{let{table:n,sqlTableContext:r}=t,{connectionsMap:i,latestEngineSelected:a}=e,o=r.engine,s=n.name,c=i.get(o);if(!c)return e;let l=dp(r),u=new Map(i),d={...c,databases:c.databases.map(e=>e.name===r.database?{...e,schemas:up(e.schemas,l,e=>{let t=e.tables.length===0?[n]:e.tables.map(e=>e.name===s?n:e);return{...e,tables:t}})}:e)};return u.set(o,d),{latestEngineSelected:a,connectionsMap:u}}}),_p=o(e=>e(hp).connectionsMap),vp=o(e=>{let t=new Map(e(_p));for(let e of Vf){let n=t.get(e);n&&(n.databases.length===0&&t.delete(e),n.databases.length===1&&n.databases[0].name===`memory`&&n.databases[0].schemas.length===0&&t.delete(e))}return Sr([...t.values()],e=>+!!Vf.has(e.name))});function yp(e){let t=u.get(hp);t.connectionsMap.has(e)&&u.set(hp,{...t,latestEngineSelected:e})}var bp=o(e=>{let t=u.get(ap),n=e(hp).connectionsMap,r=new Map;for(let e of t)r.set(e.name,e);for(let e of n.values())for(let t of e.databases){let n=t.name===e.default_database||e.databases.length===1,i=(a,o)=>{let s=o.length===0,c=o.length===1&&o[0]===e.default_schema,l=o.join(`.`);for(let e of a.tables){let i;if(i=e.name,s){i=n?e.name:`${t.name}.${e.name}`,r.has(i)?L.warn(`Table name collision for ${i}. Skipping.`):r.set(i,e);continue}if(n&&c&&!r.has(i)){r.set(i,e);continue}if(i=`${l}.${e.name}`,n&&!r.has(i)){r.set(i,e);continue}i=`${t.name}.${l}.${e.name}`,r.has(i)?L.warn(`Table name collision for ${i}. Skipping.`):r.set(i,e)}for(let e of a.child_schemas??[])i(e,[...o,e.name])};for(let e of t.schemas)i(e,Uf(e.name)?[]:[e.name])}return r});function xp(e){return e.variable_name?`dataframe`:`table`}var Sp=class{maxSize;cache=new Map;options;constructor(e,t={}){this.maxSize=e,this.options=t}getOrCreate(e){z(this.options.create,`create function is required`);let t=this.cache.get(e);if(t!==void 0)return t;let n=this.options.create(e);return this.cache.set(e,n),n}get(e){let t=this.cache.get(e);return t!==void 0&&(this.cache.delete(e),this.cache.set(e,t)),t}set(e,t){if(this.cache.has(e)&&this.cache.delete(e),this.cache.set(e,t),this.cache.size>this.maxSize){let e=this.cache.keys().next().value;e!==void 0&&this.cache.delete(e)}}keys(){return this.cache.keys()}values(){return this.cache.values()}entries(){return this.cache.entries()}delete(e){this.cache.delete(e)}};function Cp(e){switch(e){case`duckdb`:return`DuckDB`;case`motherduck`:return`MotherDuck`;case`sqlite`:return`SQLite`;case`postgres`:case`postgresql`:return`PostgreSQL`;case`mysql`:return`MySQL`;case`mariadb`:return`MariaDB`;case`mssql`:case`microsoft sql server`:return`Microsoft SQL Server`;case`oracle`:return`Oracle`;case`redshift`:return`Amazon Redshift`;case`snowflake`:return`Snowflake`;case`bigquery`:return`Google BigQuery`;case`clickhouse`:return`ClickHouse`;case`timeplus`:return`Timeplus`;case`databricks`:return`Databricks`;case`db2`:return`IBM Db2`;case`hive`:return`Apache Hive`;case`impala`:return`Apache Impala`;case`presto`:return`Presto`;case`trino`:return`Trino`;case`cockroachdb`:return`CockroachDB`;case`timescaledb`:return`TimescaleDB`;case`singlestore`:return`SingleStore`;case`cassandra`:return`Apache Cassandra`;case`mongodb`:return`MongoDB`;case`iceberg`:return`Apache Iceberg`;case`dremio`:return`Dremio`;default:return e}}function wp(e){let[t,n]=e.split(` `);return n?`${Cp(t)} ${n}`:Cp(e)}var Tp={boolean:Ot,date:kt,time:ko,datetime:To,temporal:To,number:Dt,string:At,integer:Dt,geometry:Io,unknown:wo};function Ep(e){return Object.hasOwn(Tp,e)?e:`unknown`}function Dp(e){switch(e){case`boolean`:return`bg-(--orange-4)`;case`date`:case`time`:case`datetime`:case`temporal`:return`bg-(--grass-4) dark:bg-(--grass-5)`;case`number`:case`integer`:return`bg-(--purple-4)`;case`string`:return`bg-(--blue-4)`;case`geometry`:return`bg-(--cyan-4) dark:bg-(--cyan-5)`;case`unknown`:return`bg-(--slate-4) dark:bg-(--slate-6)`;default:return Lr(e),`bg-(--slate-4) dark:bg-(--slate-6)`}}var Op=class{singular;_plural;constructor(e,t){this.singular=e,this._plural=t}pluralize(e){return e===1?this.singular:this.plural}get plural(){return this._plural??`${this.singular}s`}},kp=class e{words;constructor(e){this.words=e}static of(...t){return new e(t.map(e=>typeof e==`string`?new Op(e):e))}join(e,t){return this.words.map(e=>e.pluralize(t)).join(e)}},X=ne(),Ap=5,jp={boolean:`bg-(--orange-4) text-(--orange-11)`,date:`bg-(--grass-4) text-(--grass-11)`,time:`bg-(--grass-4) text-(--grass-11)`,datetime:`bg-(--grass-4) text-(--grass-11)`,number:`bg-(--purple-4) text-(--purple-11)`,integer:`bg-(--purple-4) text-(--purple-11)`,string:`bg-(--blue-4) text-(--blue-11)`,geometry:`bg-(--cyan-4) text-(--cyan-11)`,unknown:`bg-(--slate-4) text-(--slate-11)`},Mp={local:`bg-(--blue-4) text-(--blue-11)`,duckdb:`bg-(--amber-4) text-(--amber-11)`,connection:`bg-(--green-4) text-(--green-11)`,catalog:`bg-(--purple-4) text-(--purple-11)`},Np=`p-3 min-w-[250px] flex flex-col divide-y`,Pp=new Op(`column`,`columns`),Fp=new Op(`row`,`rows`),Ip=new Op(`schema`,`schemas`),Lp=new Op(`table`,`tables`),Rp=new Op(`database`,`databases`),zp=e=>{let t=(0,X.c)(6),{icon:n,title:r,badge:i}=e,a;t[0]===r?a=t[1]:(a=(0,K.jsx)(`h3`,{className:`font-semibold text-sm`,children:r}),t[0]=r,t[1]=a);let o;return t[2]!==i||t[3]!==n||t[4]!==a?(o=(0,K.jsxs)(`div`,{className:`flex items-center gap-2 pb-2`,children:[n,a,i]}),t[2]=i,t[3]=n,t[4]=a,t[5]=o):o=t[5],o},Bp=e=>{let t=(0,X.c)(5),{label:n,value:r}=e,i;t[0]===n?i=t[1]:(i=(0,K.jsxs)(`span`,{className:`text-(--slate-11)`,children:[n,`:`]}),t[0]=n,t[1]=i);let a;return t[2]!==i||t[3]!==r?(a=(0,K.jsxs)(`div`,{className:`flex items-center justify-between text-xs`,children:[i,r]}),t[2]=i,t[3]=r,t[4]=a):a=t[4],a},Vp=e=>{let t=(0,X.c)(5),{icon:n,text:r}=e,i;t[0]===r?i=t[1]:(i=(0,K.jsx)(`span`,{className:`text-xs text-(--slate-11)`,children:r}),t[0]=r,t[1]=i);let a;return t[2]!==n||t[3]!==i?(a=(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[n,i]}),t[2]=n,t[3]=i,t[4]=a):a=t[4],a},Hp=e=>{let t=(0,X.c)(15),{title:n,items:r,totalCount:i,limit:a}=e,o=n===void 0?``:n,s=a===void 0?Ap:a;if(r.length===0)return null;let c;t[0]!==r||t[1]!==s?(c=r.slice(0,s),t[0]=r,t[1]=s,t[2]=c):c=t[2];let l=c,u=i>s,d;t[3]===o?d=t[4]:(d=o&&(0,K.jsxs)(`h4`,{className:`text-xs font-medium text-(--slate-11) mb-2`,children:[o,`:`]}),t[3]=o,t[4]=d);let f;t[5]!==u||t[6]!==s||t[7]!==i?(f=u&&(0,K.jsxs)(`div`,{className:`text-xs text-(--slate-10) text-center py-1`,children:[`... and `,i-s,` more`]}),t[5]=u,t[6]=s,t[7]=i,t[8]=f):f=t[8];let p;t[9]!==f||t[10]!==l?(p=(0,K.jsxs)(`div`,{className:`flex flex-col gap-1 overflow-y-auto`,children:[l,f]}),t[9]=f,t[10]=l,t[11]=p):p=t[11];let m;return t[12]!==d||t[13]!==p?(m=(0,K.jsxs)(`div`,{className:`py-2`,children:[d,p]}),t[12]=d,t[13]=p,t[14]=m):m=t[14],m},Up=e=>jp[e]||jp.unknown,Wp=e=>{let t=e.type===`view`?(0,K.jsx)(Mo,{className:`w-4 h-4 text-(--blue-9)`}):(0,K.jsx)(Jo,{className:`w-4 h-4 text-(--green-9)`}),n=(0,K.jsx)($r,{variant:`secondary`,className:`text-xs ${e.type===`view`?`bg-(--blue-4) text-(--blue-11)`:`bg-(--green-4) text-(--green-11)`}`,children:e.type}),r=e.columns.map(e=>{let t=Tp[Ep(e.type)];return(0,K.jsxs)(`div`,{className:`flex items-center justify-between text-xs rounded`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(t,{className:`w-3 h-3 text-(--slate-9)`}),(0,K.jsx)(`span`,{className:`font-mono`,children:e.name})]}),(0,K.jsx)($r,{variant:`outline`,className:`text-xs ${Up(e.type)}`,children:e.type})]},e.name)}),i=e.primary_keys&&e.primary_keys.length>0,a=e.indexes&&e.indexes.length>0;return(0,K.jsxs)(`div`,{className:`${Np} min-w-[300px]`,children:[(0,K.jsx)(zp,{icon:t,title:e.name,badge:n}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-2 py-2`,children:[(0,K.jsx)(Bp,{label:`Source`,value:(0,K.jsx)($r,{variant:`outline`,className:`text-xs ${Mp[e.source_type]}`,children:e.source})}),e.variable_name&&(0,K.jsx)(Bp,{label:`Variable`,value:(0,K.jsx)(`code`,{className:`text-xs bg-(--slate-4) px-1 rounded`,children:e.variable_name})}),e.engine&&(0,K.jsx)(Bp,{label:`Engine`,value:(0,K.jsx)(`code`,{className:`text-xs bg-(--slate-4) px-1 rounded`,children:e.engine})})]}),(e.num_columns!=null||e.num_rows!=null)&&(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 py-2`,children:[e.num_columns!=null&&(0,K.jsx)(Vp,{icon:(0,K.jsx)(jo,{className:`w-3 h-3 text-(--slate-9)`}),text:`${e.num_columns} ${Pp.pluralize(e.num_columns)}`}),e.num_rows!=null&&(0,K.jsx)(Vp,{icon:(0,K.jsx)(Dt,{className:`w-3 h-3 text-(--slate-9)`}),text:`${e.num_rows} ${Fp.pluralize(e.num_rows)}`})]}),e.columns.length===0&&Qp(`column`),(i||a)&&(0,K.jsxs)(`div`,{className:`flex flex-col gap-2 py-2`,children:[i&&(0,K.jsxs)(`div`,{className:`flex flex-row gap-1`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(Rt,{className:`w-3 h-3 text-(--amber-9)`}),(0,K.jsx)(`span`,{className:`text-xs font-medium text-(--slate-11)`,children:`Primary Keys:`})]}),e.primary_keys?.map(e=>(0,K.jsx)($r,{variant:`outline`,className:`text-xs text-(--slate-11)`,children:e},e))]}),a&&(0,K.jsxs)(`div`,{className:`flex flex-row gap-1`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-1 mb-1`,children:[(0,K.jsx)(St,{className:`w-3 h-3 text-(--purple-9)`}),(0,K.jsx)(`span`,{className:`text-xs font-medium text-(--slate-11)`,children:`Indexes:`})]}),e.indexes?.map(e=>(0,K.jsx)($r,{variant:`outline`,className:`text-xs text-(--slate-11)`,children:e},e))]})]}),e.columns.length>0&&(0,K.jsx)(Hp,{items:r,totalCount:e.columns.length})]})},Gp=e=>{let t=Tp[Ep(e.type)],n=(0,K.jsx)($r,{variant:`outline`,className:`text-xs ${Up(e.type)}`,children:e.type}),r=e.sample_values?.map((e,t)=>(0,K.jsx)(`div`,{className:`text-xs bg-(--slate-3) rounded font-mono`,children:e==null?`null`:String(e)},t))||[];return(0,K.jsxs)(`div`,{className:Np,children:[(0,K.jsx)(zp,{icon:(0,K.jsx)(t,{className:`w-4 h-4 text-(--slate-9)`}),title:e.name,badge:n}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-2 mt-2`,children:[(0,K.jsx)(Bp,{label:`Type`,value:(0,K.jsx)(`span`,{className:`font-medium`,children:e.type})}),(0,K.jsx)(Bp,{label:`External Type`,value:(0,K.jsx)(`code`,{className:`text-xs bg-(--slate-4) px-1 rounded`,children:e.external_type})})]}),e.sample_values&&e.sample_values.length>0&&(0,K.jsx)(Hp,{title:`Sample Values`,items:r,totalCount:e.sample_values.length})]})},Kp=e=>{let t=(0,K.jsx)($r,{variant:`outline`,className:`text-xs bg-(--blue-4) text-(--blue-11)`,children:e.dialect}),n=e.schemas.map(e=>(0,K.jsxs)(`div`,{className:`flex items-center justify-between text-xs rounded hover:bg-(--slate-3)`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(J,{className:`w-3 h-3 text-(--slate-9)`}),(0,K.jsx)(`span`,{children:e.name})]}),(0,K.jsxs)($r,{variant:`outline`,className:`text-xs`,children:[e.tables.length,` `,Lp.pluralize(e.tables.length)]})]},e.name));return(0,K.jsxs)(`div`,{className:Np,children:[(0,K.jsx)(zp,{icon:(0,K.jsx)(Ct,{className:`w-4 h-4 text-(--blue-9)`}),title:e.name,badge:t}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-2 py-2`,children:[(0,K.jsx)(Bp,{label:`Dialect`,value:(0,K.jsx)(`span`,{className:`font-medium`,children:e.dialect})}),e.engine&&(0,K.jsx)(Bp,{label:`Engine`,value:(0,K.jsx)(`code`,{className:`text-xs bg-(--slate-4) px-1 rounded`,children:e.engine})})]}),(0,K.jsx)(`div`,{className:`py-2`,children:(0,K.jsx)(Vp,{icon:(0,K.jsx)(J,{className:`w-3 h-3 text-(--slate-9)`}),text:`${e.schemas.length} schema${e.schemas.length===1?``:`s`}`})}),e.schemas.length===0&&Qp(`schema`),e.schemas.length>0&&(0,K.jsx)(Hp,{title:`Schemas`,items:n,totalCount:e.schemas.length})]})},qp=e=>{let t=(0,K.jsx)($r,{variant:`outline`,className:`text-xs bg-(--green-4) text-(--green-11)`,children:`Schema`}),n=e.tables.map(e=>(0,K.jsxs)(`div`,{className:`flex items-center justify-between text-xs rounded hover:bg-(--slate-3)`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.type===`view`?(0,K.jsx)(Mo,{className:`w-3 h-3 text-(--blue-9)`}):(0,K.jsx)(Jo,{className:`w-3 h-3 text-(--green-9)`}),(0,K.jsx)(`span`,{children:e.name})]}),(0,K.jsx)($r,{variant:`outline`,className:`text-xs ${e.type===`view`?`bg-(--blue-4) text-(--blue-11)`:`bg-(--green-4) text-(--green-11)`}`,children:e.type})]},e.name));return(0,K.jsxs)(`div`,{className:Np,children:[(0,K.jsx)(zp,{icon:(0,K.jsx)(J,{className:`w-4 h-4 text-(--green-9)`}),title:e.name,badge:t}),(0,K.jsx)(`div`,{className:`py-2`,children:(0,K.jsx)(Vp,{icon:(0,K.jsx)(Jo,{className:`w-3 h-3 text-(--slate-9)`}),text:`${e.tables.length} table${e.tables.length===1?``:`s`}`})}),e.tables.length===0&&Qp(`table`),e.tables.length>0&&(0,K.jsx)(Hp,{title:`Tables`,items:n,totalCount:e.tables.length})]})},Jp=(0,K.jsx)($r,{variant:`outline`,children:`default`}),Yp=8,Xp=3,Zp=(e,t)=>{let n=e.databases.length,r=e.databases.reduce((e,t)=>e+t.schemas.length,0),i=(t,n)=>{if(t.tables.length===0)return null;let i=t.name===e.default_schema&&n,a=[];return r<Yp&&(a=t.tables.slice(0,4).map(e=>(0,K.jsxs)(`div`,{className:`flex items-center gap-2 ml-4`,children:[(0,K.jsx)(Jo,{className:`w-3 h-3 text-(--green-9)`}),(0,K.jsx)(`span`,{className:`text-xs`,children:e.name})]},e.name))),(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-xs rounded hover:bg-(--slate-3) ml-2`,children:[(0,K.jsx)(J,{className:`w-3 h-3 text-(--slate-9)`}),(0,K.jsx)(`span`,{children:t.name}),i&&Jp,(0,K.jsxs)($r,{variant:`outline`,className:`text-xs ml-auto`,children:[t.tables.length,` tables`]})]}),(0,K.jsx)(Hp,{items:a,totalCount:t.tables.length,limit:Xp})]},t.name)},a=e.databases.map(t=>{let n=t.name===e.default_database||e.databases.length===1,r=t.schemas.map(e=>i(e,n));return(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(Ct,{className:`w-3 h-3 text-(--blue-9)`}),(0,K.jsx)(`span`,{className:`text-xs`,children:t.name}),n&&Jp]}),r&&(0,K.jsx)(Hp,{items:r,totalCount:t.schemas.length})]},t.name)}),o=e.name;Vf.has(e.name)&&(o=`In-Memory`);let s=t?.map(e=>(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(Jo,{className:`w-3 h-3 text-(--blue-9)`}),(0,K.jsx)(`span`,{className:`text-xs`,children:e.name})]},e.name));return(0,K.jsxs)(`div`,{className:`${Np} px-1`,children:[(0,K.jsx)(zp,{icon:(0,K.jsx)(Ao,{className:`w-4 h-4 text-(--purple-9)`}),title:o}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-2 py-2`,children:[(0,K.jsx)(Bp,{label:`Dialect`,value:(0,K.jsx)(`span`,{className:`font-medium`,children:Cp(e.dialect)})}),(0,K.jsx)(Bp,{label:`Source`,value:(0,K.jsx)($r,{variant:`outline`,className:`text-xs bg-(--green-4) text-(--green-11)`,children:e.source})})]}),(0,K.jsxs)(`div`,{className:`flex flex-row justify-between py-2`,children:[(0,K.jsx)(Vp,{icon:(0,K.jsx)(Ct,{className:`w-3 h-3 text-(--slate-9)`}),text:`${n} ${Rp.pluralize(n)}`}),(0,K.jsx)(Vp,{icon:(0,K.jsx)(J,{className:`w-3 h-3 text-(--slate-9)`}),text:`${r} ${Ip.pluralize(r)}`})]}),n>0&&(0,K.jsx)(Hp,{items:a,totalCount:n}),s&&s.length>0&&(0,K.jsx)(Hp,{title:`Dataframes`,items:s,totalCount:s.length})]})},Qp=e=>(0,K.jsxs)(`div`,{className:`flex items-start gap-2 mt-3`,children:[(0,K.jsx)(Po,{size:10,className:`mt-1 text-(--slate-10) shrink-0`}),(0,K.jsxs)(`span`,{className:`text-xs text-(--slate-11)`,children:[`No `,e,` information available.`,`
|
|
35
|
-
`,(0,K.jsx)(`span`,{className:`text-(--blue-10)`,children:`Introspect to see more details.`})]})]}),$p=e(hi(),1),em=class{schema={};addTable(e,t){let n={self:nm({table:t}),children:t.columns.map(e=>tm({column:e}))};return this.setAt([...e,t.name],n),this}addSchema(e,t){let n={self:rm({namespace:t,path:e}),children:{}};return this.setAt(e,n),this}addDatabase(e,t){let n={self:im({namespace:t,path:e}),children:{}};return this.setAt(e,n),this}setAt(e,t){let n=this.schema;for(let t of e.slice(0,-1))n[t]||(n[t]={children:{}}),n=n[t].children;n[e[e.length-1]]=t}build(){return this.schema}reset(){return this.schema={},this}};function tm(e){return{label:e.column.name,type:`column`,info:()=>{let t=document.createElement(`div`);return(0,$p.createRoot)(t).render(Gp(e.column)),{dom:t}}}}function nm(e){return{label:e.table.name,type:`table`,info:()=>{let t=document.createElement(`div`);return(0,$p.createRoot)(t).render(Wp(e.table)),{dom:t}}}}function rm(e){return{label:e.namespace.name,detail:e.path.join(`.`),type:`schema`,info:()=>{let t=document.createElement(`div`);return(0,$p.createRoot)(t).render(qp(e.namespace)),{dom:t}}}}function im(e){return{label:e.namespace.name,detail:e.path.join(`.`),type:`database`,info:()=>{let t=document.createElement(`div`);return(0,$p.createRoot)(t).render(Kp(e.namespace)),{dom:t}}}}var am=o(e=>{let t=e(ap),n=new em;for(let e of t)n.addTable([],e);return n.build()}),om=class{cache;constructor(){this.cache=new Sp(10,{create:e=>this.getConnectionSchema(e)})}getConnection(e){return u.get(_p).get(e)}getConnectionSchema(e){let{default_database:t,databases:n,default_schema:r}=e,i=new em,a=n.find(e=>e.name===t||n.length===1);if((a??n[0])?.schemas.some(e=>Uf(e.name))??!1){for(let e of n){let t=e.name===a?.name,n=e.schemas.flatMap(e=>e.tables);i.addDatabase([e.name],e);for(let r of n)t?i.addTable([],r):i.addTable([e.name],r)}return{shouldAddLocalTables:!1,schema:i.build(),defaultSchema:a?.name}}if(a)for(let e of a.schemas){i.addSchema([e.name],e);for(let t of e.tables)i.addTable([e.name],t)}for(let e of n){i.addDatabase([e.name],e);for(let t of e.schemas){i.addSchema([e.name,t.name],t);for(let n of t.tables)i.addTable([e.name,t.name],n)}}return{shouldAddLocalTables:!0,schema:i.build(),defaultSchema:r??(a?.schemas.length===1?a.schemas[0]?.name:void 0)}}getInternalDialect(e){let t=this.getConnection(e);return t?t.dialect.toLowerCase():null}getDialect(e){let t=this.getConnection(e);return t?Lf(t):zf}getCompletionSource(e){let t=this.getConnection(e);if(!t)return null;let n=()=>u.get(am),r=this.cache.getOrCreate(t);return{dialect:Lf(t),schema:r.shouldAddLocalTables?{...r.schema,...n()}:r.schema,defaultSchema:r.defaultSchema,defaultTable:sm(t)}}};function sm(e){if(e.databases.length!==1)return;let t=e.databases[0];if(t.schemas.length!==1)return;let n=t.schemas[0];if(n.tables.length===1)return n.tables[0].name}var cm=new om,lm=xn.define();async function um(e){let{sendFormat:t}=Br(),n=R.mapValues(e,e=>AA(e)),r=await t({codes:n,lineLength:ae().formatting.line_length});for(let[t,i]of R.entries(r.codes)){let r=t,a=n[r],o=e[r];o&&i!==a&&(o.state.facet(kf).updateCellCode({cellId:r,code:i,formattingChange:!0}),jA(o,i))}}function dm(){return um(_f(GM()))}async function fm(e,t){let{formatDialect:n}=await U(async()=>{let{formatDialect:e}=await import(`./esm-D-owkyO9.js`);return{formatDialect:e}},__vite__mapDeps([0,1]),import.meta.url),r=await pm(cm.getInternalDialect(t)),i=e.state.field(SA),a=sn(e.state);if(i.type!==`sql`){L.error(`Language adapter is not SQL`);return}let o=e.state.doc.toString(),s;try{s=n(o,{dialect:r,tabWidth:a,useTabs:!1})}catch(e){L.error(`Error formatting SQL`,{error:e});return}let c=i.transformIn(s)[0],l=e.state.facet(kf),u=e.state.facet(of);l.updateCellCode({cellId:u,code:c,formattingChange:!0}),ef(e,s,{effects:[lm.of(!0)]})}async function pm(e){let{bigquery:t,db2:n,db2i:r,duckdb:i,hive:a,mariadb:o,mysql:s,tidb:c,n1ql:l,plsql:u,postgresql:d,redshift:f,spark:p,sqlite:m,sql:h,trino:g,transactsql:_,singlestoredb:v,snowflake:y}=await U(async()=>{let{bigquery:e,db2:t,db2i:n,duckdb:r,hive:i,mariadb:a,mysql:o,tidb:s,n1ql:c,plsql:l,postgresql:u,redshift:d,spark:f,sqlite:p,sql:m,trino:h,transactsql:g,singlestoredb:_,snowflake:v}=await import(`./esm-D-owkyO9.js`);return{bigquery:e,db2:t,db2i:n,duckdb:r,hive:i,mariadb:a,mysql:o,tidb:s,n1ql:c,plsql:l,postgresql:u,redshift:d,spark:f,sqlite:p,sql:m,trino:h,transactsql:g,singlestoredb:_,snowflake:v}},__vite__mapDeps([0,1]),import.meta.url),b=h;if(!e||!If(e))return b;switch(e){case`mysql`:return s;case`mariadb`:return o;case`postgres`:case`postgresql`:return d;case`sqlite`:return m;case`db2`:return n;case`db2i`:return r;case`hive`:return a;case`redshift`:return f;case`snowflake`:return y;case`trino`:return g;case`tidb`:return c;case`oracle`:case`oracledb`:return u;case`spark`:return p;case`singlestoredb`:return v;case`couchbase`:return l;case`bigquery`:return t;case`duckdb`:return i;case`mssql`:case`sqlserver`:case`microsoft sql server`:return _;case`athena`:case`awsathena`:case`cassandra`:case`noql`:case`flink`:case`mongodb`:case`timescaledb`:case`datafusion`:case`dremio`:return h;case`databricks`:return p;default:return Lr(e),b}}function mm(e,t){let n=document.createElement(`div`),r;return{dom:n,mount(){r=(0,$p.createRoot)(n),r.render((0,K.jsx)(d,{store:u,children:(0,K.jsx)(t,{view:e})}))},update(){r?.render((0,K.jsx)(d,{store:u,children:(0,K.jsx)(t,{view:e})}))},destroy(){r?.unmount()}}}function Z(e){return new Jn(Rn.define(e))}function hm(e){return U(()=>import(`./dist-CibNXpH2.js`).then(t=>t.sql({dialect:t[e]})),__vite__mapDeps([2,3,4,5]),import.meta.url)}var gm=[W.of({name:`C`,extensions:[`c`,`h`,`ino`],load(){return U(()=>import(`./dist-DcvY27K9.js`).then(e=>e.cpp()),__vite__mapDeps([6,7,4]),import.meta.url)}}),W.of({name:`C++`,alias:[`cpp`],extensions:[`cpp`,`c++`,`cc`,`cxx`,`hpp`,`h++`,`hh`,`hxx`],load(){return U(()=>import(`./dist-DcvY27K9.js`).then(e=>e.cpp()),__vite__mapDeps([6,7,4]),import.meta.url)}}),W.of({name:`CQL`,alias:[`cassandra`],extensions:[`cql`],load(){return hm(`Cassandra`)}}),W.of({name:`CSS`,extensions:[`css`],load(){return U(()=>import(`./dist-C43s7KMp.js`).then(e=>e.css()),__vite__mapDeps([8,9,4]),import.meta.url)}}),W.of({name:`Go`,extensions:[`go`],load(){return U(()=>import(`./dist-DfGC5qxC.js`).then(e=>e.go()),__vite__mapDeps([10,11,4,5]),import.meta.url)}}),W.of({name:`HTML`,alias:[`xhtml`],extensions:[`html`,`htm`,`handlebars`,`hbs`],load(){return U(()=>import(`./dist-BxKJ9CUC.js`).then(e=>e.html()),__vite__mapDeps([12,13,4,9,14,5]),import.meta.url)}}),W.of({name:`Java`,extensions:[`java`],load(){return U(()=>import(`./dist-DewjJKIE.js`).then(e=>e.java()),__vite__mapDeps([15,16,4]),import.meta.url)}}),W.of({name:`JavaScript`,alias:[`ecmascript`,`js`,`node`],extensions:[`js`,`mjs`,`cjs`],load(){return U(()=>import(`./dist-DoYtnejk.js`).then(e=>e.javascript()),__vite__mapDeps([17,14,4,5]),import.meta.url)}}),W.of({name:`Jinja`,extensions:[`j2`,`jinja`,`jinja2`],load(){return U(()=>import(`./dist-BZAAgYK3.js`).then(e=>e.jinja()),__vite__mapDeps([18,19,4,13,9,14,5]),import.meta.url)}}),W.of({name:`JSON`,alias:[`json5`],extensions:[`json`,`map`],load(){return U(()=>import(`./dist-4SpsNdg9.js`).then(e=>e.json()),__vite__mapDeps([20,21,4]),import.meta.url)}}),W.of({name:`JSX`,extensions:[`jsx`],load(){return U(()=>import(`./dist-DoYtnejk.js`).then(e=>e.javascript({jsx:!0})),__vite__mapDeps([17,14,4,5]),import.meta.url)}}),W.of({name:`LESS`,extensions:[`less`],load(){return U(()=>import(`./dist-DfRK-QAy.js`).then(e=>e.less()),__vite__mapDeps([22,23,4,9]),import.meta.url)}}),W.of({name:`Liquid`,extensions:[`liquid`],load(){return U(()=>import(`./dist-Cw0_qzU5.js`).then(e=>e.liquid()),__vite__mapDeps([24,25,4,13,9,14,5]),import.meta.url)}}),W.of({name:`MariaDB SQL`,load(){return hm(`MariaSQL`)}}),W.of({name:`Markdown`,extensions:[`md`,`markdown`,`mkd`],load(){return U(()=>import(`./dist-Cllq-3AX.js`).then(e=>e.markdown()),__vite__mapDeps([26,27,4,5,13,9,14]),import.meta.url)}}),W.of({name:`MS SQL`,load(){return hm(`MSSQL`)}}),W.of({name:`MySQL`,load(){return hm(`MySQL`)}}),W.of({name:`PHP`,extensions:[`php`,`php3`,`php4`,`php5`,`php7`,`phtml`],load(){return U(()=>import(`./dist-D0Fg9FgU.js`).then(e=>e.php()),__vite__mapDeps([28,29,4,13,9,14,5]),import.meta.url)}}),W.of({name:`PLSQL`,extensions:[`pls`],load(){return hm(`PLSQL`)}}),W.of({name:`PostgreSQL`,load(){return hm(`PostgreSQL`)}}),W.of({name:`Python`,extensions:[`BUILD`,`bzl`,`py`,`pyw`],filename:/^(BUCK|BUILD)$/,load(){return U(()=>import(`./dist-BXTY2Z6u.js`).then(e=>e.python()),__vite__mapDeps([30,31,4,5]),import.meta.url)}}),W.of({name:`Rust`,extensions:[`rs`],load(){return U(()=>import(`./dist-DG2TCPkT.js`).then(e=>e.rust()),__vite__mapDeps([32,33,4]),import.meta.url)}}),W.of({name:`Sass`,extensions:[`sass`],load(){return U(()=>import(`./dist-BeKmSRy3.js`).then(e=>e.sass({indented:!0})),__vite__mapDeps([34,35,4,9]),import.meta.url)}}),W.of({name:`SCSS`,extensions:[`scss`],load(){return U(()=>import(`./dist-BeKmSRy3.js`).then(e=>e.sass()),__vite__mapDeps([34,35,4,9]),import.meta.url)}}),W.of({name:`SQL`,extensions:[`sql`],load(){return hm(`StandardSQL`)}}),W.of({name:`SQLite`,load(){return hm(`SQLite`)}}),W.of({name:`TSX`,extensions:[`tsx`],load(){return U(()=>import(`./dist-DoYtnejk.js`).then(e=>e.javascript({jsx:!0,typescript:!0})),__vite__mapDeps([17,14,4,5]),import.meta.url)}}),W.of({name:`TypeScript`,alias:[`ts`],extensions:[`ts`,`mts`,`cts`],load(){return U(()=>import(`./dist-DoYtnejk.js`).then(e=>e.javascript({typescript:!0})),__vite__mapDeps([17,14,4,5]),import.meta.url)}}),W.of({name:`WebAssembly`,extensions:[`wat`,`wast`],load(){return U(()=>import(`./dist-C1ZMbzEY.js`).then(e=>e.wast()),__vite__mapDeps([36,37,4]),import.meta.url)}}),W.of({name:`XML`,alias:[`rss`,`wsdl`,`xsd`],extensions:[`xml`,`xsl`,`xsd`,`svg`],load(){return U(()=>import(`./dist-PsHgCCpB.js`).then(e=>e.xml()),__vite__mapDeps([38,39,4]),import.meta.url)}}),W.of({name:`YAML`,alias:[`yml`],extensions:[`yaml`,`yml`],load(){return U(()=>import(`./dist-CcKu0kT5.js`).then(e=>e.yaml()),__vite__mapDeps([40,41,4]),import.meta.url)}}),W.of({name:`APL`,extensions:[`dyalog`,`apl`],load(){return U(()=>import(`./apl-gw27yJ2n.js`).then(e=>Z(e.apl)),__vite__mapDeps([42,43]),import.meta.url)}}),W.of({name:`PGP`,alias:[`asciiarmor`],extensions:[`asc`,`pgp`,`sig`],load(){return U(()=>import(`./asciiarmor-Cor5STs8.js`).then(e=>Z(e.asciiArmor)),__vite__mapDeps([44,45]),import.meta.url)}}),W.of({name:`ASN.1`,extensions:[`asn`,`asn1`],load(){return U(()=>import(`./asn1-CPEENLyz.js`).then(e=>Z(e.asn1({}))),__vite__mapDeps([46,47]),import.meta.url)}}),W.of({name:`Asterisk`,filename:/^extensions\.conf$/i,load(){return U(()=>import(`./asterisk-BEn0Cwpx.js`).then(e=>Z(e.asterisk)),[],import.meta.url)}}),W.of({name:`Brainfuck`,extensions:[`b`,`bf`],load(){return U(()=>import(`./brainfuck-a_fzgFtj.js`).then(e=>Z(e.brainfuck)),__vite__mapDeps([48,49]),import.meta.url)}}),W.of({name:`Cobol`,extensions:[`cob`,`cpy`],load(){return U(()=>import(`./cobol-BYACvGhO.js`).then(e=>Z(e.cobol)),__vite__mapDeps([50,51]),import.meta.url)}}),W.of({name:`C#`,alias:[`csharp`,`cs`],extensions:[`cs`],load(){return U(()=>import(`./clike-DZROJv43.js`).then(e=>Z(e.csharp)),__vite__mapDeps([52,53]),import.meta.url)}}),W.of({name:`Clojure`,extensions:[`clj`,`cljc`,`cljx`],load(){return U(()=>import(`./clojure-sW2N62b5.js`).then(e=>Z(e.clojure)),__vite__mapDeps([54,55]),import.meta.url)}}),W.of({name:`ClojureScript`,extensions:[`cljs`],load(){return U(()=>import(`./clojure-sW2N62b5.js`).then(e=>Z(e.clojure)),__vite__mapDeps([54,55]),import.meta.url)}}),W.of({name:`Closure Stylesheets (GSS)`,extensions:[`gss`],load(){return U(()=>import(`./css-CbZNFbVv.js`).then(e=>Z(e.gss)),__vite__mapDeps([56,57]),import.meta.url)}}),W.of({name:`CMake`,extensions:[`cmake`,`cmake.in`],filename:/^CMakeLists\.txt$/,load(){return U(()=>import(`./cmake-DA9yMhzJ.js`).then(e=>Z(e.cmake)),__vite__mapDeps([58,59]),import.meta.url)}}),W.of({name:`CoffeeScript`,alias:[`coffee`,`coffee-script`],extensions:[`coffee`],load(){return U(()=>import(`./coffeescript-73GxLNLH.js`).then(e=>Z(e.coffeeScript)),__vite__mapDeps([60,61]),import.meta.url)}}),W.of({name:`Common Lisp`,alias:[`lisp`],extensions:[`cl`,`lisp`,`el`],load(){return U(()=>import(`./commonlisp-BAY0IMda.js`).then(e=>Z(e.commonLisp)),__vite__mapDeps([62,63]),import.meta.url)}}),W.of({name:`Cypher`,extensions:[`cyp`,`cypher`],load(){return U(()=>import(`./cypher-CpQ0ACJl.js`).then(e=>Z(e.cypher)),__vite__mapDeps([64,65]),import.meta.url)}}),W.of({name:`Cython`,extensions:[`pyx`,`pxd`,`pxi`],load(){return U(()=>import(`./python-xiYauDc4.js`).then(e=>Z(e.cython)),__vite__mapDeps([66,67]),import.meta.url)}}),W.of({name:`Crystal`,extensions:[`cr`],load(){return U(()=>import(`./crystal-DLlr59il.js`).then(e=>Z(e.crystal)),__vite__mapDeps([68,69]),import.meta.url)}}),W.of({name:`D`,extensions:[`d`],load(){return U(()=>import(`./d-BFwRCF-p.js`).then(e=>Z(e.d)),__vite__mapDeps([70,71]),import.meta.url)}}),W.of({name:`Dart`,extensions:[`dart`],load(){return U(()=>import(`./clike-DZROJv43.js`).then(e=>Z(e.dart)),__vite__mapDeps([52,53]),import.meta.url)}}),W.of({name:`diff`,extensions:[`diff`,`patch`],load(){return U(()=>import(`./diff-Ib_BKd8h.js`).then(e=>Z(e.diff)),__vite__mapDeps([72,73]),import.meta.url)}}),W.of({name:`Dockerfile`,filename:/^Dockerfile$/,load(){return U(()=>import(`./dockerfile-DJkHQgkl.js`).then(e=>Z(e.dockerFile)),__vite__mapDeps([74,75]),import.meta.url)}}),W.of({name:`DTD`,extensions:[`dtd`],load(){return U(()=>import(`./dtd-DgBHwr-e.js`).then(e=>Z(e.dtd)),__vite__mapDeps([76,77]),import.meta.url)}}),W.of({name:`Dylan`,extensions:[`dylan`,`dyl`,`intr`],load(){return U(()=>import(`./dylan-fdbf6J3T.js`).then(e=>Z(e.dylan)),__vite__mapDeps([78,79]),import.meta.url)}}),W.of({name:`EBNF`,load(){return U(()=>import(`./ebnf-D4c0_ac3.js`).then(e=>Z(e.ebnf)),[],import.meta.url)}}),W.of({name:`ECL`,extensions:[`ecl`],load(){return U(()=>import(`./ecl-K_KNI3_u.js`).then(e=>Z(e.ecl)),__vite__mapDeps([80,81]),import.meta.url)}}),W.of({name:`edn`,extensions:[`edn`],load(){return U(()=>import(`./clojure-sW2N62b5.js`).then(e=>Z(e.clojure)),__vite__mapDeps([54,55]),import.meta.url)}}),W.of({name:`Eiffel`,extensions:[`e`],load(){return U(()=>import(`./eiffel-DatcW1fL.js`).then(e=>Z(e.eiffel)),__vite__mapDeps([82,83]),import.meta.url)}}),W.of({name:`Elm`,extensions:[`elm`],load(){return U(()=>import(`./elm-DbcUgz-o.js`).then(e=>Z(e.elm)),__vite__mapDeps([84,85]),import.meta.url)}}),W.of({name:`Erlang`,extensions:[`erl`],load(){return U(()=>import(`./erlang-BistxQAs.js`).then(e=>Z(e.erlang)),__vite__mapDeps([86,87]),import.meta.url)}}),W.of({name:`Esper`,load(){return U(()=>import(`./sql-DuQMFDvy.js`).then(e=>Z(e.esper)),[],import.meta.url)}}),W.of({name:`Factor`,extensions:[`factor`],load(){return U(()=>import(`./factor-DwQNJbiW.js`).then(e=>Z(e.factor)),__vite__mapDeps([88,89,75]),import.meta.url)}}),W.of({name:`FCL`,load(){return U(()=>import(`./fcl-ClOhbFR7.js`).then(e=>Z(e.fcl)),[],import.meta.url)}}),W.of({name:`Forth`,extensions:[`forth`,`fth`,`4th`],load(){return U(()=>import(`./forth-B-tqi4f_.js`).then(e=>Z(e.forth)),__vite__mapDeps([90,91]),import.meta.url)}}),W.of({name:`Fortran`,extensions:[`f`,`for`,`f77`,`f90`,`f95`],load(){return U(()=>import(`./fortran-C9M6nI39.js`).then(e=>Z(e.fortran)),__vite__mapDeps([92,93]),import.meta.url)}}),W.of({name:`F#`,alias:[`fsharp`],extensions:[`fs`],load(){return U(()=>import(`./mllike-DHDLWZl9.js`).then(e=>Z(e.fSharp)),__vite__mapDeps([94,95]),import.meta.url)}}),W.of({name:`Gas`,extensions:[`s`],load(){return U(()=>import(`./gas-DJ-ntEw0.js`).then(e=>Z(e.gas)),__vite__mapDeps([96,97]),import.meta.url)}}),W.of({name:`Gherkin`,extensions:[`feature`],load(){return U(()=>import(`./gherkin-Co7qm0Mt.js`).then(e=>Z(e.gherkin)),__vite__mapDeps([98,99]),import.meta.url)}}),W.of({name:`Groovy`,extensions:[`groovy`,`gradle`],filename:/^Jenkinsfile$/,load(){return U(()=>import(`./groovy-DkYAhc5g.js`).then(e=>Z(e.groovy)),__vite__mapDeps([100,101]),import.meta.url)}}),W.of({name:`Haskell`,extensions:[`hs`],load(){return U(()=>import(`./haskell-QbTWCmtk.js`).then(e=>Z(e.haskell)),__vite__mapDeps([102,103]),import.meta.url)}}),W.of({name:`Haxe`,extensions:[`hx`],load(){return U(()=>import(`./haxe-CmR2u-6B.js`).then(e=>Z(e.haxe)),__vite__mapDeps([104,105]),import.meta.url)}}),W.of({name:`HXML`,extensions:[`hxml`],load(){return U(()=>import(`./haxe-CmR2u-6B.js`).then(e=>Z(e.hxml)),__vite__mapDeps([104,105]),import.meta.url)}}),W.of({name:`HTTP`,load(){return U(()=>import(`./http-CLVgA2GD.js`).then(e=>Z(e.http)),[],import.meta.url)}}),W.of({name:`IDL`,extensions:[`pro`],load(){return U(()=>import(`./idl-DY5VfUGL.js`).then(e=>Z(e.idl)),__vite__mapDeps([106,107]),import.meta.url)}}),W.of({name:`JSON-LD`,alias:[`jsonld`],extensions:[`jsonld`],load(){return U(()=>import(`./javascript-BWjar7HY.js`).then(e=>Z(e.jsonld)),__vite__mapDeps([108,109]),import.meta.url)}}),W.of({name:`Julia`,extensions:[`jl`],load(){return U(()=>import(`./julia-CBfVM-ng.js`).then(e=>Z(e.julia)),__vite__mapDeps([110,111]),import.meta.url)}}),W.of({name:`Kotlin`,extensions:[`kt`,`kts`],load(){return U(()=>import(`./clike-DZROJv43.js`).then(e=>Z(e.kotlin)),__vite__mapDeps([52,53]),import.meta.url)}}),W.of({name:`LiveScript`,alias:[`ls`],extensions:[`ls`],load(){return U(()=>import(`./livescript-CC7i4CEo.js`).then(e=>Z(e.liveScript)),__vite__mapDeps([112,113]),import.meta.url)}}),W.of({name:`Lua`,extensions:[`lua`],load(){return U(()=>import(`./lua-1tNpM92n.js`).then(e=>Z(e.lua)),__vite__mapDeps([114,115]),import.meta.url)}}),W.of({name:`mIRC`,extensions:[`mrc`],load(){return U(()=>import(`./mirc-BASUkO3C.js`).then(e=>Z(e.mirc)),__vite__mapDeps([116,117]),import.meta.url)}}),W.of({name:`Mathematica`,extensions:[`m`,`nb`,`wl`,`wls`],load(){return U(()=>import(`./mathematica-DWMBVyLs.js`).then(e=>Z(e.mathematica)),__vite__mapDeps([118,119]),import.meta.url)}}),W.of({name:`Modelica`,extensions:[`mo`],load(){return U(()=>import(`./modelica-C2NfUrdY.js`).then(e=>Z(e.modelica)),__vite__mapDeps([120,121]),import.meta.url)}}),W.of({name:`MUMPS`,extensions:[`mps`],load(){return U(()=>import(`./mumps-DwVYUX8b.js`).then(e=>Z(e.mumps)),__vite__mapDeps([122,123]),import.meta.url)}}),W.of({name:`Mbox`,extensions:[`mbox`],load(){return U(()=>import(`./mbox-DvNfx9hX.js`).then(e=>Z(e.mbox)),__vite__mapDeps([124,125]),import.meta.url)}}),W.of({name:`Nginx`,filename:/nginx.*\.conf$/i,load(){return U(()=>import(`./nginx-BMaDbqW3.js`).then(e=>Z(e.nginx)),[],import.meta.url)}}),W.of({name:`NSIS`,extensions:[`nsh`,`nsi`],load(){return U(()=>import(`./nsis-B6H_Q9YJ.js`).then(e=>Z(e.nsis)),__vite__mapDeps([126,127,75]),import.meta.url)}}),W.of({name:`NTriples`,extensions:[`nt`,`nq`],load(){return U(()=>import(`./ntriples-CSqEHNgf.js`).then(e=>Z(e.ntriples)),__vite__mapDeps([128,129]),import.meta.url)}}),W.of({name:`Objective-C`,alias:[`objective-c`,`objc`],extensions:[`m`],load(){return U(()=>import(`./clike-DZROJv43.js`).then(e=>Z(e.objectiveC)),__vite__mapDeps([52,53]),import.meta.url)}}),W.of({name:`Objective-C++`,alias:[`objective-c++`,`objc++`],extensions:[`mm`],load(){return U(()=>import(`./clike-DZROJv43.js`).then(e=>Z(e.objectiveCpp)),__vite__mapDeps([52,53]),import.meta.url)}}),W.of({name:`OCaml`,extensions:[`ml`,`mli`,`mll`,`mly`],load(){return U(()=>import(`./mllike-DHDLWZl9.js`).then(e=>Z(e.oCaml)),__vite__mapDeps([94,95]),import.meta.url)}}),W.of({name:`Octave`,extensions:[`m`],load(){return U(()=>import(`./octave-ImTMIie9.js`).then(e=>Z(e.octave)),__vite__mapDeps([130,131]),import.meta.url)}}),W.of({name:`Oz`,extensions:[`oz`],load(){return U(()=>import(`./oz-BuYcBdKy.js`).then(e=>Z(e.oz)),__vite__mapDeps([132,133]),import.meta.url)}}),W.of({name:`Pascal`,extensions:[`p`,`pas`],load(){return U(()=>import(`./pascal-B50DmceL.js`).then(e=>Z(e.pascal)),__vite__mapDeps([134,135]),import.meta.url)}}),W.of({name:`Perl`,extensions:[`pl`,`pm`],load(){return U(()=>import(`./perl-DmFVAwdF.js`).then(e=>Z(e.perl)),__vite__mapDeps([136,137]),import.meta.url)}}),W.of({name:`Pig`,extensions:[`pig`],load(){return U(()=>import(`./pig-BnQuru9N.js`).then(e=>Z(e.pig)),__vite__mapDeps([138,139]),import.meta.url)}}),W.of({name:`PowerShell`,extensions:[`ps1`,`psd1`,`psm1`],load(){return U(()=>import(`./powershell-B1pJyAAD.js`).then(e=>Z(e.powerShell)),__vite__mapDeps([140,141]),import.meta.url)}}),W.of({name:`Properties files`,alias:[`ini`,`properties`],extensions:[`properties`,`ini`,`in`],load(){return U(()=>import(`./properties-Ci7guRqV.js`).then(e=>Z(e.properties)),__vite__mapDeps([142,143]),import.meta.url)}}),W.of({name:`ProtoBuf`,extensions:[`proto`],load(){return U(()=>import(`./protobuf-CoqP8wM5.js`).then(e=>Z(e.protobuf)),__vite__mapDeps([144,145]),import.meta.url)}}),W.of({name:`Pug`,alias:[`jade`],extensions:[`pug`,`jade`],load(){return U(()=>import(`./pug-CJsoo9v0.js`).then(e=>Z(e.pug)),__vite__mapDeps([146,147,109]),import.meta.url)}}),W.of({name:`Puppet`,extensions:[`pp`],load(){return U(()=>import(`./puppet-C9UYpvtZ.js`).then(e=>Z(e.puppet)),__vite__mapDeps([148,149]),import.meta.url)}}),W.of({name:`Q`,extensions:[`q`],load(){return U(()=>import(`./q-CKkOe1xA.js`).then(e=>Z(e.q)),__vite__mapDeps([150,151]),import.meta.url)}}),W.of({name:`R`,alias:[`rscript`],extensions:[`r`,`R`],load(){return U(()=>import(`./r-Bwc-y-iL.js`).then(e=>Z(e.r)),__vite__mapDeps([152,153]),import.meta.url)}}),W.of({name:`RPM Changes`,load(){return U(()=>import(`./rpm-UQSdNQr2.js`).then(e=>Z(e.rpmChanges)),__vite__mapDeps([154,155]),import.meta.url)}}),W.of({name:`RPM Spec`,extensions:[`spec`],load(){return U(()=>import(`./rpm-UQSdNQr2.js`).then(e=>Z(e.rpmSpec)),__vite__mapDeps([154,155]),import.meta.url)}}),W.of({name:`Ruby`,alias:[`jruby`,`macruby`,`rake`,`rb`,`rbx`],extensions:[`rb`],filename:/^(Gemfile|Rakefile)$/,load(){return U(()=>import(`./ruby-CrY8zrT8.js`).then(e=>Z(e.ruby)),__vite__mapDeps([156,157]),import.meta.url)}}),W.of({name:`SAS`,extensions:[`sas`],load(){return U(()=>import(`./sas-CssadkTB.js`).then(e=>Z(e.sas)),__vite__mapDeps([158,159]),import.meta.url)}}),W.of({name:`Scala`,extensions:[`scala`],load(){return U(()=>import(`./clike-DZROJv43.js`).then(e=>Z(e.scala)),__vite__mapDeps([52,53]),import.meta.url)}}),W.of({name:`Scheme`,extensions:[`scm`,`ss`],load(){return U(()=>import(`./scheme-CkJWoRmu.js`).then(e=>Z(e.scheme)),__vite__mapDeps([160,161]),import.meta.url)}}),W.of({name:`Shell`,alias:[`bash`,`sh`,`zsh`],extensions:[`sh`,`ksh`,`bash`],filename:/^PKGBUILD$/,load(){return U(()=>import(`./shell-FgUEpLdy.js`).then(e=>Z(e.shell)),__vite__mapDeps([162,163]),import.meta.url)}}),W.of({name:`Sieve`,extensions:[`siv`,`sieve`],load(){return U(()=>import(`./sieve-BLxcNk7A.js`).then(e=>Z(e.sieve)),__vite__mapDeps([164,165]),import.meta.url)}}),W.of({name:`Smalltalk`,extensions:[`st`],load(){return U(()=>import(`./smalltalk-d1Dbk6V4.js`).then(e=>Z(e.smalltalk)),__vite__mapDeps([166,167]),import.meta.url)}}),W.of({name:`Solr`,load(){return U(()=>import(`./solr-BBopId9w.js`).then(e=>Z(e.solr)),[],import.meta.url)}}),W.of({name:`SML`,extensions:[`sml`,`sig`,`fun`,`smackspec`],load(){return U(()=>import(`./mllike-DHDLWZl9.js`).then(e=>Z(e.sml)),__vite__mapDeps([94,95]),import.meta.url)}}),W.of({name:`SPARQL`,alias:[`sparul`],extensions:[`rq`,`sparql`],load(){return U(()=>import(`./sparql-CUZhKeRb.js`).then(e=>Z(e.sparql)),__vite__mapDeps([168,169]),import.meta.url)}}),W.of({name:`Spreadsheet`,alias:[`excel`,`formula`],load(){return U(()=>import(`./spreadsheet-CTIncYxj.js`).then(e=>Z(e.spreadsheet)),[],import.meta.url)}}),W.of({name:`Squirrel`,extensions:[`nut`],load(){return U(()=>import(`./clike-DZROJv43.js`).then(e=>Z(e.squirrel)),__vite__mapDeps([52,53]),import.meta.url)}}),W.of({name:`Stylus`,extensions:[`styl`],load(){return U(()=>import(`./stylus-BvudHrj4.js`).then(e=>Z(e.stylus)),__vite__mapDeps([170,171]),import.meta.url)}}),W.of({name:`Swift`,extensions:[`swift`],load(){return U(()=>import(`./swift-CUIczYYb.js`).then(e=>Z(e.swift)),__vite__mapDeps([172,173]),import.meta.url)}}),W.of({name:`sTeX`,load(){return U(()=>import(`./stex-3SJlFZg3.js`).then(e=>Z(e.stex)),__vite__mapDeps([174,175]),import.meta.url)}}),W.of({name:`LaTeX`,alias:[`tex`],extensions:[`text`,`ltx`,`tex`],load(){return U(()=>import(`./stex-3SJlFZg3.js`).then(e=>Z(e.stex)),__vite__mapDeps([174,175]),import.meta.url)}}),W.of({name:`SystemVerilog`,extensions:[`v`,`sv`,`svh`],load(){return U(()=>import(`./verilog-DH7aBYt7.js`).then(e=>Z(e.verilog)),__vite__mapDeps([176,177]),import.meta.url)}}),W.of({name:`Tcl`,extensions:[`tcl`],load(){return U(()=>import(`./tcl-SjROh4xB.js`).then(e=>Z(e.tcl)),__vite__mapDeps([178,179]),import.meta.url)}}),W.of({name:`Textile`,extensions:[`textile`],load(){return U(()=>import(`./textile-DgW6fC9R.js`).then(e=>Z(e.textile)),__vite__mapDeps([180,181]),import.meta.url)}}),W.of({name:`TiddlyWiki`,load(){return U(()=>import(`./tiddlywiki-VlUiK86J.js`).then(e=>Z(e.tiddlyWiki)),[],import.meta.url)}}),W.of({name:`Tiki wiki`,load(){return U(()=>import(`./tiki-AK6FwT8q.js`).then(e=>Z(e.tiki)),[],import.meta.url)}}),W.of({name:`TOML`,extensions:[`toml`],load(){return U(()=>import(`./toml-BcC_uO4q.js`).then(e=>Z(e.toml)),__vite__mapDeps([182,183]),import.meta.url)}}),W.of({name:`Troff`,extensions:[`1`,`2`,`3`,`4`,`5`,`6`,`7`,`8`,`9`],load(){return U(()=>import(`./troff-BMlKH74u.js`).then(e=>Z(e.troff)),__vite__mapDeps([184,185]),import.meta.url)}}),W.of({name:`TTCN`,extensions:[`ttcn`,`ttcn3`,`ttcnpp`],load(){return U(()=>import(`./ttcn-P2iYmK_j.js`).then(e=>Z(e.ttcn)),__vite__mapDeps([186,187]),import.meta.url)}}),W.of({name:`TTCN_CFG`,extensions:[`cfg`],load(){return U(()=>import(`./ttcn-cfg-2bl9aE98.js`).then(e=>Z(e.ttcnCfg)),__vite__mapDeps([188,189]),import.meta.url)}}),W.of({name:`Turtle`,extensions:[`ttl`],load(){return U(()=>import(`./turtle-DDf6uD3p.js`).then(e=>Z(e.turtle)),__vite__mapDeps([190,191]),import.meta.url)}}),W.of({name:`Web IDL`,extensions:[`webidl`],load(){return U(()=>import(`./webidl-dw5if_Lv.js`).then(e=>Z(e.webIDL)),__vite__mapDeps([192,193]),import.meta.url)}}),W.of({name:`VB.NET`,extensions:[`vb`],load(){return U(()=>import(`./vb-CrfmF706.js`).then(e=>Z(e.vb)),__vite__mapDeps([194,195]),import.meta.url)}}),W.of({name:`VBScript`,extensions:[`vbs`],load(){return U(()=>import(`./vbscript-Cpiv2llq.js`).then(e=>Z(e.vbScript)),__vite__mapDeps([196,197]),import.meta.url)}}),W.of({name:`Velocity`,extensions:[`vtl`],load(){return U(()=>import(`./velocity-5N54agTA.js`).then(e=>Z(e.velocity)),__vite__mapDeps([198,199]),import.meta.url)}}),W.of({name:`Verilog`,extensions:[`v`],load(){return U(()=>import(`./verilog-DH7aBYt7.js`).then(e=>Z(e.verilog)),__vite__mapDeps([176,177]),import.meta.url)}}),W.of({name:`VHDL`,extensions:[`vhd`,`vhdl`],load(){return U(()=>import(`./vhdl-BmegRbqn.js`).then(e=>Z(e.vhdl)),__vite__mapDeps([200,201]),import.meta.url)}}),W.of({name:`XQuery`,extensions:[`xy`,`xquery`,`xq`,`xqm`,`xqy`],load(){return U(()=>import(`./xquery-CuDTgW6S.js`).then(e=>Z(e.xQuery)),__vite__mapDeps([202,203]),import.meta.url)}}),W.of({name:`Yacas`,extensions:[`ys`],load(){return U(()=>import(`./yacas-Dn2coKff.js`).then(e=>Z(e.yacas)),__vite__mapDeps([204,205]),import.meta.url)}}),W.of({name:`Z80`,extensions:[`z80`],load(){return U(()=>import(`./z80-ByJO5ysu.js`).then(e=>Z(e.z80)),__vite__mapDeps([206,207]),import.meta.url)}}),W.of({name:`MscGen`,extensions:[`mscgen`,`mscin`,`msc`],load(){return U(()=>import(`./mscgen-C7woTLsY.js`).then(e=>Z(e.mscgen)),__vite__mapDeps([208,209]),import.meta.url)}}),W.of({name:`Xù`,extensions:[`xu`],load(){return U(()=>import(`./mscgen-C7woTLsY.js`).then(e=>Z(e.xu)),__vite__mapDeps([208,209]),import.meta.url)}}),W.of({name:`MsGenny`,extensions:[`msgenny`],load(){return U(()=>import(`./mscgen-C7woTLsY.js`).then(e=>Z(e.msgenny)),__vite__mapDeps([208,209]),import.meta.url)}}),W.of({name:`Vue`,extensions:[`vue`],load(){return U(()=>import(`./dist-DH7Tm1i8.js`).then(e=>e.vue()),__vite__mapDeps([210,211,4,13,9,14,5]),import.meta.url)}}),W.of({name:`Angular Template`,load(){return U(()=>import(`./dist-DLwSLd_v.js`).then(e=>e.angular()),__vite__mapDeps([212,4,13,9,14,5]),import.meta.url)}})],_m=new WeakMap,vm=/(\n|\r\n?|\u2028|\u2029)/g,ym=/^\s*/,bm=/\S/,xm=Array.prototype.slice,Sm=48,Cm=57,wm=97,Tm=102,Em=65,Dm=70;function Om(e){if(typeof e==`string`)return jm([e])[0];if(typeof e==`function`)return function(){let t=xm.call(arguments);return t[0]=Am(t[0]),e.apply(this,t)};let t=Am(e),n=km(t,0);for(let e=1;e<t.length;e++)n+=arguments[e]+km(t,e);return n}function km(e,t){let n=e[t];if(n===void 0)throw TypeError(`invalid cooked string at index ${t}`);return n}function Am(e){let t=_m.get(e);if(t)return t;let n=jm(e.raw),r=n.map(Nm);return Object.defineProperty(r,"raw",{value:Object.freeze(n)}),Object.freeze(r),_m.set(e,r),r}function jm(e){let t=e.map(e=>e.split(vm)),n;for(let e=0;e<t.length;e++){let r=t[e],i=e===0,a=e+1===t.length;if(i){if(r.length===1||r[0].length>0)throw Error(`invalid content on opening line`);r[1]=``}if(a){if(r.length===1||bm.test(r[r.length-1]))throw Error(`invalid content on closing line`);r[r.length-2]=``,r[r.length-1]=``}for(let e=2;e<r.length;e+=2){let t=r[e],i=e+1===r.length&&!a,o=ym.exec(t)[0];if(!i&&o.length===t.length){r[e]=``;continue}n=Mm(o,n)}}let r=n?n.length:0;return t.map(e=>{let t=e[0];for(let n=1;n<e.length;n+=2){let i=e[n],a=e[n+1];t+=i+a.slice(r)}return t})}function Mm(e,t){if(t===void 0||e===t)return e;let n=0;for(let r=Math.min(e.length,t.length);n<r&&e[n]===t[n];n++);return e.slice(0,n)}function Nm(e){let t=``,n=0,r=0;for(;(r=e.indexOf(`\\`,r))>-1;){if(t+=e.slice(n,r),++r===e.length)return;let i=e[r++];switch(i){case`b`:t+=`\b`;break;case`t`:t+=` `;break;case`n`:t+=`
|
|
35
|
+
`,(0,K.jsx)(`span`,{className:`text-(--blue-10)`,children:`Introspect to see more details.`})]})]}),$p=e(hi(),1),em=class{schema={};addTable(e,t){let n={self:nm({table:t}),children:t.columns.map(e=>tm({column:e}))};return this.setAt([...e,t.name],n),this}addSchema(e,t){let n={self:rm({namespace:t,path:e}),children:{}};return this.setAt(e,n),this}addDatabase(e,t){let n={self:im({namespace:t,path:e}),children:{}};return this.setAt(e,n),this}setAt(e,t){let n=this.schema;for(let t of e.slice(0,-1))n[t]||(n[t]={children:{}}),n=n[t].children;n[e[e.length-1]]=t}build(){return this.schema}reset(){return this.schema={},this}};function tm(e){return{label:e.column.name,type:`column`,info:()=>{let t=document.createElement(`div`);return(0,$p.createRoot)(t).render(Gp(e.column)),{dom:t}}}}function nm(e){return{label:e.table.name,type:`table`,info:()=>{let t=document.createElement(`div`);return(0,$p.createRoot)(t).render(Wp(e.table)),{dom:t}}}}function rm(e){return{label:e.namespace.name,detail:e.path.join(`.`),type:`schema`,info:()=>{let t=document.createElement(`div`);return(0,$p.createRoot)(t).render(qp(e.namespace)),{dom:t}}}}function im(e){return{label:e.namespace.name,detail:e.path.join(`.`),type:`database`,info:()=>{let t=document.createElement(`div`);return(0,$p.createRoot)(t).render(Kp(e.namespace)),{dom:t}}}}var am=o(e=>{let t=e(ap),n=new em;for(let e of t)n.addTable([],e);return n.build()}),om=class{cache;constructor(){this.cache=new Sp(10,{create:e=>this.getConnectionSchema(e)})}getConnection(e){return u.get(_p).get(e)}getConnectionSchema(e){let{default_database:t,databases:n,default_schema:r}=e,i=new em,a=n.find(e=>e.name===t||n.length===1);if((a??n[0])?.schemas.some(e=>Uf(e.name))??!1){for(let e of n){let t=e.name===a?.name,n=e.schemas.flatMap(e=>e.tables);i.addDatabase([e.name],e);for(let r of n)t?i.addTable([],r):i.addTable([e.name],r)}return{shouldAddLocalTables:!1,schema:i.build(),defaultSchema:a?.name}}if(a)for(let e of a.schemas){i.addSchema([e.name],e);for(let t of e.tables)i.addTable([e.name],t)}for(let e of n){i.addDatabase([e.name],e);for(let t of e.schemas){i.addSchema([e.name,t.name],t);for(let n of t.tables)i.addTable([e.name,t.name],n)}}return{shouldAddLocalTables:!0,schema:i.build(),defaultSchema:r??(a?.schemas.length===1?a.schemas[0]?.name:void 0)}}getInternalDialect(e){let t=this.getConnection(e);return t?t.dialect.toLowerCase():null}getDialect(e){let t=this.getConnection(e);return t?Lf(t):zf}getCompletionSource(e){let t=this.getConnection(e);if(!t)return null;let n=()=>u.get(am),r=this.cache.getOrCreate(t);return{dialect:Lf(t),schema:r.shouldAddLocalTables?{...r.schema,...n()}:r.schema,defaultSchema:r.defaultSchema,defaultTable:sm(t)}}};function sm(e){if(e.databases.length!==1)return;let t=e.databases[0];if(t.schemas.length!==1)return;let n=t.schemas[0];if(n.tables.length===1)return n.tables[0].name}var cm=new om,lm=xn.define();async function um(e){let{sendFormat:t}=Br(),n=R.mapValues(e,e=>AA(e)),r=await t({codes:n,lineLength:ae().formatting.line_length});for(let[t,i]of R.entries(r.codes)){let r=t,a=n[r],o=e[r];o&&i!==a&&(o.state.facet(kf).updateCellCode({cellId:r,code:i,formattingChange:!0}),jA(o,i))}}function dm(){return um(_f(KM()))}async function fm(e,t){let{formatDialect:n}=await U(async()=>{let{formatDialect:e}=await import(`./esm-D-owkyO9.js`);return{formatDialect:e}},__vite__mapDeps([0,1]),import.meta.url),r=await pm(cm.getInternalDialect(t)),i=e.state.field(SA),a=sn(e.state);if(i.type!==`sql`){L.error(`Language adapter is not SQL`);return}let o=e.state.doc.toString(),s;try{s=n(o,{dialect:r,tabWidth:a,useTabs:!1})}catch(e){L.error(`Error formatting SQL`,{error:e});return}let c=i.transformIn(s)[0],l=e.state.facet(kf),u=e.state.facet(of);l.updateCellCode({cellId:u,code:c,formattingChange:!0}),ef(e,s,{effects:[lm.of(!0)]})}async function pm(e){let{bigquery:t,db2:n,db2i:r,duckdb:i,hive:a,mariadb:o,mysql:s,tidb:c,n1ql:l,plsql:u,postgresql:d,redshift:f,spark:p,sqlite:m,sql:h,trino:g,transactsql:_,singlestoredb:v,snowflake:y}=await U(async()=>{let{bigquery:e,db2:t,db2i:n,duckdb:r,hive:i,mariadb:a,mysql:o,tidb:s,n1ql:c,plsql:l,postgresql:u,redshift:d,spark:f,sqlite:p,sql:m,trino:h,transactsql:g,singlestoredb:_,snowflake:v}=await import(`./esm-D-owkyO9.js`);return{bigquery:e,db2:t,db2i:n,duckdb:r,hive:i,mariadb:a,mysql:o,tidb:s,n1ql:c,plsql:l,postgresql:u,redshift:d,spark:f,sqlite:p,sql:m,trino:h,transactsql:g,singlestoredb:_,snowflake:v}},__vite__mapDeps([0,1]),import.meta.url),b=h;if(!e||!If(e))return b;switch(e){case`mysql`:return s;case`mariadb`:return o;case`postgres`:case`postgresql`:return d;case`sqlite`:return m;case`db2`:return n;case`db2i`:return r;case`hive`:return a;case`redshift`:return f;case`snowflake`:return y;case`trino`:return g;case`tidb`:return c;case`oracle`:case`oracledb`:return u;case`spark`:return p;case`singlestoredb`:return v;case`couchbase`:return l;case`bigquery`:return t;case`duckdb`:return i;case`mssql`:case`sqlserver`:case`microsoft sql server`:return _;case`athena`:case`awsathena`:case`cassandra`:case`noql`:case`flink`:case`mongodb`:case`timescaledb`:case`datafusion`:case`dremio`:return h;case`databricks`:return p;default:return Lr(e),b}}function mm(e,t){let n=document.createElement(`div`),r;return{dom:n,mount(){r=(0,$p.createRoot)(n),r.render((0,K.jsx)(d,{store:u,children:(0,K.jsx)(t,{view:e})}))},update(){r?.render((0,K.jsx)(d,{store:u,children:(0,K.jsx)(t,{view:e})}))},destroy(){r?.unmount()}}}function Z(e){return new Jn(Rn.define(e))}function hm(e){return U(()=>import(`./dist-CibNXpH2.js`).then(t=>t.sql({dialect:t[e]})),__vite__mapDeps([2,3,4,5]),import.meta.url)}var gm=[W.of({name:`C`,extensions:[`c`,`h`,`ino`],load(){return U(()=>import(`./dist-DcvY27K9.js`).then(e=>e.cpp()),__vite__mapDeps([6,7,4]),import.meta.url)}}),W.of({name:`C++`,alias:[`cpp`],extensions:[`cpp`,`c++`,`cc`,`cxx`,`hpp`,`h++`,`hh`,`hxx`],load(){return U(()=>import(`./dist-DcvY27K9.js`).then(e=>e.cpp()),__vite__mapDeps([6,7,4]),import.meta.url)}}),W.of({name:`CQL`,alias:[`cassandra`],extensions:[`cql`],load(){return hm(`Cassandra`)}}),W.of({name:`CSS`,extensions:[`css`],load(){return U(()=>import(`./dist-C43s7KMp.js`).then(e=>e.css()),__vite__mapDeps([8,9,4]),import.meta.url)}}),W.of({name:`Go`,extensions:[`go`],load(){return U(()=>import(`./dist-DfGC5qxC.js`).then(e=>e.go()),__vite__mapDeps([10,11,4,5]),import.meta.url)}}),W.of({name:`HTML`,alias:[`xhtml`],extensions:[`html`,`htm`,`handlebars`,`hbs`],load(){return U(()=>import(`./dist-BxKJ9CUC.js`).then(e=>e.html()),__vite__mapDeps([12,13,4,9,14,5]),import.meta.url)}}),W.of({name:`Java`,extensions:[`java`],load(){return U(()=>import(`./dist-DewjJKIE.js`).then(e=>e.java()),__vite__mapDeps([15,16,4]),import.meta.url)}}),W.of({name:`JavaScript`,alias:[`ecmascript`,`js`,`node`],extensions:[`js`,`mjs`,`cjs`],load(){return U(()=>import(`./dist-DoYtnejk.js`).then(e=>e.javascript()),__vite__mapDeps([17,14,4,5]),import.meta.url)}}),W.of({name:`Jinja`,extensions:[`j2`,`jinja`,`jinja2`],load(){return U(()=>import(`./dist-BZAAgYK3.js`).then(e=>e.jinja()),__vite__mapDeps([18,19,4,13,9,14,5]),import.meta.url)}}),W.of({name:`JSON`,alias:[`json5`],extensions:[`json`,`map`],load(){return U(()=>import(`./dist-4SpsNdg9.js`).then(e=>e.json()),__vite__mapDeps([20,21,4]),import.meta.url)}}),W.of({name:`JSX`,extensions:[`jsx`],load(){return U(()=>import(`./dist-DoYtnejk.js`).then(e=>e.javascript({jsx:!0})),__vite__mapDeps([17,14,4,5]),import.meta.url)}}),W.of({name:`LESS`,extensions:[`less`],load(){return U(()=>import(`./dist-DfRK-QAy.js`).then(e=>e.less()),__vite__mapDeps([22,23,4,9]),import.meta.url)}}),W.of({name:`Liquid`,extensions:[`liquid`],load(){return U(()=>import(`./dist-Cw0_qzU5.js`).then(e=>e.liquid()),__vite__mapDeps([24,25,4,13,9,14,5]),import.meta.url)}}),W.of({name:`MariaDB SQL`,load(){return hm(`MariaSQL`)}}),W.of({name:`Markdown`,extensions:[`md`,`markdown`,`mkd`],load(){return U(()=>import(`./dist-Cllq-3AX.js`).then(e=>e.markdown()),__vite__mapDeps([26,27,4,5,13,9,14]),import.meta.url)}}),W.of({name:`MS SQL`,load(){return hm(`MSSQL`)}}),W.of({name:`MySQL`,load(){return hm(`MySQL`)}}),W.of({name:`PHP`,extensions:[`php`,`php3`,`php4`,`php5`,`php7`,`phtml`],load(){return U(()=>import(`./dist-D0Fg9FgU.js`).then(e=>e.php()),__vite__mapDeps([28,29,4,13,9,14,5]),import.meta.url)}}),W.of({name:`PLSQL`,extensions:[`pls`],load(){return hm(`PLSQL`)}}),W.of({name:`PostgreSQL`,load(){return hm(`PostgreSQL`)}}),W.of({name:`Python`,extensions:[`BUILD`,`bzl`,`py`,`pyw`],filename:/^(BUCK|BUILD)$/,load(){return U(()=>import(`./dist-BXTY2Z6u.js`).then(e=>e.python()),__vite__mapDeps([30,31,4,5]),import.meta.url)}}),W.of({name:`Rust`,extensions:[`rs`],load(){return U(()=>import(`./dist-DG2TCPkT.js`).then(e=>e.rust()),__vite__mapDeps([32,33,4]),import.meta.url)}}),W.of({name:`Sass`,extensions:[`sass`],load(){return U(()=>import(`./dist-BeKmSRy3.js`).then(e=>e.sass({indented:!0})),__vite__mapDeps([34,35,4,9]),import.meta.url)}}),W.of({name:`SCSS`,extensions:[`scss`],load(){return U(()=>import(`./dist-BeKmSRy3.js`).then(e=>e.sass()),__vite__mapDeps([34,35,4,9]),import.meta.url)}}),W.of({name:`SQL`,extensions:[`sql`],load(){return hm(`StandardSQL`)}}),W.of({name:`SQLite`,load(){return hm(`SQLite`)}}),W.of({name:`TSX`,extensions:[`tsx`],load(){return U(()=>import(`./dist-DoYtnejk.js`).then(e=>e.javascript({jsx:!0,typescript:!0})),__vite__mapDeps([17,14,4,5]),import.meta.url)}}),W.of({name:`TypeScript`,alias:[`ts`],extensions:[`ts`,`mts`,`cts`],load(){return U(()=>import(`./dist-DoYtnejk.js`).then(e=>e.javascript({typescript:!0})),__vite__mapDeps([17,14,4,5]),import.meta.url)}}),W.of({name:`WebAssembly`,extensions:[`wat`,`wast`],load(){return U(()=>import(`./dist-C1ZMbzEY.js`).then(e=>e.wast()),__vite__mapDeps([36,37,4]),import.meta.url)}}),W.of({name:`XML`,alias:[`rss`,`wsdl`,`xsd`],extensions:[`xml`,`xsl`,`xsd`,`svg`],load(){return U(()=>import(`./dist-PsHgCCpB.js`).then(e=>e.xml()),__vite__mapDeps([38,39,4]),import.meta.url)}}),W.of({name:`YAML`,alias:[`yml`],extensions:[`yaml`,`yml`],load(){return U(()=>import(`./dist-CcKu0kT5.js`).then(e=>e.yaml()),__vite__mapDeps([40,41,4]),import.meta.url)}}),W.of({name:`APL`,extensions:[`dyalog`,`apl`],load(){return U(()=>import(`./apl-gw27yJ2n.js`).then(e=>Z(e.apl)),__vite__mapDeps([42,43]),import.meta.url)}}),W.of({name:`PGP`,alias:[`asciiarmor`],extensions:[`asc`,`pgp`,`sig`],load(){return U(()=>import(`./asciiarmor-Cor5STs8.js`).then(e=>Z(e.asciiArmor)),__vite__mapDeps([44,45]),import.meta.url)}}),W.of({name:`ASN.1`,extensions:[`asn`,`asn1`],load(){return U(()=>import(`./asn1-CPEENLyz.js`).then(e=>Z(e.asn1({}))),__vite__mapDeps([46,47]),import.meta.url)}}),W.of({name:`Asterisk`,filename:/^extensions\.conf$/i,load(){return U(()=>import(`./asterisk-BEn0Cwpx.js`).then(e=>Z(e.asterisk)),[],import.meta.url)}}),W.of({name:`Brainfuck`,extensions:[`b`,`bf`],load(){return U(()=>import(`./brainfuck-a_fzgFtj.js`).then(e=>Z(e.brainfuck)),__vite__mapDeps([48,49]),import.meta.url)}}),W.of({name:`Cobol`,extensions:[`cob`,`cpy`],load(){return U(()=>import(`./cobol-BYACvGhO.js`).then(e=>Z(e.cobol)),__vite__mapDeps([50,51]),import.meta.url)}}),W.of({name:`C#`,alias:[`csharp`,`cs`],extensions:[`cs`],load(){return U(()=>import(`./clike-DZROJv43.js`).then(e=>Z(e.csharp)),__vite__mapDeps([52,53]),import.meta.url)}}),W.of({name:`Clojure`,extensions:[`clj`,`cljc`,`cljx`],load(){return U(()=>import(`./clojure-sW2N62b5.js`).then(e=>Z(e.clojure)),__vite__mapDeps([54,55]),import.meta.url)}}),W.of({name:`ClojureScript`,extensions:[`cljs`],load(){return U(()=>import(`./clojure-sW2N62b5.js`).then(e=>Z(e.clojure)),__vite__mapDeps([54,55]),import.meta.url)}}),W.of({name:`Closure Stylesheets (GSS)`,extensions:[`gss`],load(){return U(()=>import(`./css-CbZNFbVv.js`).then(e=>Z(e.gss)),__vite__mapDeps([56,57]),import.meta.url)}}),W.of({name:`CMake`,extensions:[`cmake`,`cmake.in`],filename:/^CMakeLists\.txt$/,load(){return U(()=>import(`./cmake-DA9yMhzJ.js`).then(e=>Z(e.cmake)),__vite__mapDeps([58,59]),import.meta.url)}}),W.of({name:`CoffeeScript`,alias:[`coffee`,`coffee-script`],extensions:[`coffee`],load(){return U(()=>import(`./coffeescript-73GxLNLH.js`).then(e=>Z(e.coffeeScript)),__vite__mapDeps([60,61]),import.meta.url)}}),W.of({name:`Common Lisp`,alias:[`lisp`],extensions:[`cl`,`lisp`,`el`],load(){return U(()=>import(`./commonlisp-BAY0IMda.js`).then(e=>Z(e.commonLisp)),__vite__mapDeps([62,63]),import.meta.url)}}),W.of({name:`Cypher`,extensions:[`cyp`,`cypher`],load(){return U(()=>import(`./cypher-CpQ0ACJl.js`).then(e=>Z(e.cypher)),__vite__mapDeps([64,65]),import.meta.url)}}),W.of({name:`Cython`,extensions:[`pyx`,`pxd`,`pxi`],load(){return U(()=>import(`./python-xiYauDc4.js`).then(e=>Z(e.cython)),__vite__mapDeps([66,67]),import.meta.url)}}),W.of({name:`Crystal`,extensions:[`cr`],load(){return U(()=>import(`./crystal-DLlr59il.js`).then(e=>Z(e.crystal)),__vite__mapDeps([68,69]),import.meta.url)}}),W.of({name:`D`,extensions:[`d`],load(){return U(()=>import(`./d-BFwRCF-p.js`).then(e=>Z(e.d)),__vite__mapDeps([70,71]),import.meta.url)}}),W.of({name:`Dart`,extensions:[`dart`],load(){return U(()=>import(`./clike-DZROJv43.js`).then(e=>Z(e.dart)),__vite__mapDeps([52,53]),import.meta.url)}}),W.of({name:`diff`,extensions:[`diff`,`patch`],load(){return U(()=>import(`./diff-Ib_BKd8h.js`).then(e=>Z(e.diff)),__vite__mapDeps([72,73]),import.meta.url)}}),W.of({name:`Dockerfile`,filename:/^Dockerfile$/,load(){return U(()=>import(`./dockerfile-DJkHQgkl.js`).then(e=>Z(e.dockerFile)),__vite__mapDeps([74,75]),import.meta.url)}}),W.of({name:`DTD`,extensions:[`dtd`],load(){return U(()=>import(`./dtd-DgBHwr-e.js`).then(e=>Z(e.dtd)),__vite__mapDeps([76,77]),import.meta.url)}}),W.of({name:`Dylan`,extensions:[`dylan`,`dyl`,`intr`],load(){return U(()=>import(`./dylan-fdbf6J3T.js`).then(e=>Z(e.dylan)),__vite__mapDeps([78,79]),import.meta.url)}}),W.of({name:`EBNF`,load(){return U(()=>import(`./ebnf-D4c0_ac3.js`).then(e=>Z(e.ebnf)),[],import.meta.url)}}),W.of({name:`ECL`,extensions:[`ecl`],load(){return U(()=>import(`./ecl-K_KNI3_u.js`).then(e=>Z(e.ecl)),__vite__mapDeps([80,81]),import.meta.url)}}),W.of({name:`edn`,extensions:[`edn`],load(){return U(()=>import(`./clojure-sW2N62b5.js`).then(e=>Z(e.clojure)),__vite__mapDeps([54,55]),import.meta.url)}}),W.of({name:`Eiffel`,extensions:[`e`],load(){return U(()=>import(`./eiffel-DatcW1fL.js`).then(e=>Z(e.eiffel)),__vite__mapDeps([82,83]),import.meta.url)}}),W.of({name:`Elm`,extensions:[`elm`],load(){return U(()=>import(`./elm-DbcUgz-o.js`).then(e=>Z(e.elm)),__vite__mapDeps([84,85]),import.meta.url)}}),W.of({name:`Erlang`,extensions:[`erl`],load(){return U(()=>import(`./erlang-BistxQAs.js`).then(e=>Z(e.erlang)),__vite__mapDeps([86,87]),import.meta.url)}}),W.of({name:`Esper`,load(){return U(()=>import(`./sql-DuQMFDvy.js`).then(e=>Z(e.esper)),[],import.meta.url)}}),W.of({name:`Factor`,extensions:[`factor`],load(){return U(()=>import(`./factor-DwQNJbiW.js`).then(e=>Z(e.factor)),__vite__mapDeps([88,89,75]),import.meta.url)}}),W.of({name:`FCL`,load(){return U(()=>import(`./fcl-ClOhbFR7.js`).then(e=>Z(e.fcl)),[],import.meta.url)}}),W.of({name:`Forth`,extensions:[`forth`,`fth`,`4th`],load(){return U(()=>import(`./forth-B-tqi4f_.js`).then(e=>Z(e.forth)),__vite__mapDeps([90,91]),import.meta.url)}}),W.of({name:`Fortran`,extensions:[`f`,`for`,`f77`,`f90`,`f95`],load(){return U(()=>import(`./fortran-C9M6nI39.js`).then(e=>Z(e.fortran)),__vite__mapDeps([92,93]),import.meta.url)}}),W.of({name:`F#`,alias:[`fsharp`],extensions:[`fs`],load(){return U(()=>import(`./mllike-DHDLWZl9.js`).then(e=>Z(e.fSharp)),__vite__mapDeps([94,95]),import.meta.url)}}),W.of({name:`Gas`,extensions:[`s`],load(){return U(()=>import(`./gas-DJ-ntEw0.js`).then(e=>Z(e.gas)),__vite__mapDeps([96,97]),import.meta.url)}}),W.of({name:`Gherkin`,extensions:[`feature`],load(){return U(()=>import(`./gherkin-Co7qm0Mt.js`).then(e=>Z(e.gherkin)),__vite__mapDeps([98,99]),import.meta.url)}}),W.of({name:`Groovy`,extensions:[`groovy`,`gradle`],filename:/^Jenkinsfile$/,load(){return U(()=>import(`./groovy-DkYAhc5g.js`).then(e=>Z(e.groovy)),__vite__mapDeps([100,101]),import.meta.url)}}),W.of({name:`Haskell`,extensions:[`hs`],load(){return U(()=>import(`./haskell-QbTWCmtk.js`).then(e=>Z(e.haskell)),__vite__mapDeps([102,103]),import.meta.url)}}),W.of({name:`Haxe`,extensions:[`hx`],load(){return U(()=>import(`./haxe-CmR2u-6B.js`).then(e=>Z(e.haxe)),__vite__mapDeps([104,105]),import.meta.url)}}),W.of({name:`HXML`,extensions:[`hxml`],load(){return U(()=>import(`./haxe-CmR2u-6B.js`).then(e=>Z(e.hxml)),__vite__mapDeps([104,105]),import.meta.url)}}),W.of({name:`HTTP`,load(){return U(()=>import(`./http-CLVgA2GD.js`).then(e=>Z(e.http)),[],import.meta.url)}}),W.of({name:`IDL`,extensions:[`pro`],load(){return U(()=>import(`./idl-DY5VfUGL.js`).then(e=>Z(e.idl)),__vite__mapDeps([106,107]),import.meta.url)}}),W.of({name:`JSON-LD`,alias:[`jsonld`],extensions:[`jsonld`],load(){return U(()=>import(`./javascript-BWjar7HY.js`).then(e=>Z(e.jsonld)),__vite__mapDeps([108,109]),import.meta.url)}}),W.of({name:`Julia`,extensions:[`jl`],load(){return U(()=>import(`./julia-CBfVM-ng.js`).then(e=>Z(e.julia)),__vite__mapDeps([110,111]),import.meta.url)}}),W.of({name:`Kotlin`,extensions:[`kt`,`kts`],load(){return U(()=>import(`./clike-DZROJv43.js`).then(e=>Z(e.kotlin)),__vite__mapDeps([52,53]),import.meta.url)}}),W.of({name:`LiveScript`,alias:[`ls`],extensions:[`ls`],load(){return U(()=>import(`./livescript-CC7i4CEo.js`).then(e=>Z(e.liveScript)),__vite__mapDeps([112,113]),import.meta.url)}}),W.of({name:`Lua`,extensions:[`lua`],load(){return U(()=>import(`./lua-1tNpM92n.js`).then(e=>Z(e.lua)),__vite__mapDeps([114,115]),import.meta.url)}}),W.of({name:`mIRC`,extensions:[`mrc`],load(){return U(()=>import(`./mirc-BASUkO3C.js`).then(e=>Z(e.mirc)),__vite__mapDeps([116,117]),import.meta.url)}}),W.of({name:`Mathematica`,extensions:[`m`,`nb`,`wl`,`wls`],load(){return U(()=>import(`./mathematica-DWMBVyLs.js`).then(e=>Z(e.mathematica)),__vite__mapDeps([118,119]),import.meta.url)}}),W.of({name:`Modelica`,extensions:[`mo`],load(){return U(()=>import(`./modelica-C2NfUrdY.js`).then(e=>Z(e.modelica)),__vite__mapDeps([120,121]),import.meta.url)}}),W.of({name:`MUMPS`,extensions:[`mps`],load(){return U(()=>import(`./mumps-DwVYUX8b.js`).then(e=>Z(e.mumps)),__vite__mapDeps([122,123]),import.meta.url)}}),W.of({name:`Mbox`,extensions:[`mbox`],load(){return U(()=>import(`./mbox-DvNfx9hX.js`).then(e=>Z(e.mbox)),__vite__mapDeps([124,125]),import.meta.url)}}),W.of({name:`Nginx`,filename:/nginx.*\.conf$/i,load(){return U(()=>import(`./nginx-BMaDbqW3.js`).then(e=>Z(e.nginx)),[],import.meta.url)}}),W.of({name:`NSIS`,extensions:[`nsh`,`nsi`],load(){return U(()=>import(`./nsis-B6H_Q9YJ.js`).then(e=>Z(e.nsis)),__vite__mapDeps([126,127,75]),import.meta.url)}}),W.of({name:`NTriples`,extensions:[`nt`,`nq`],load(){return U(()=>import(`./ntriples-CSqEHNgf.js`).then(e=>Z(e.ntriples)),__vite__mapDeps([128,129]),import.meta.url)}}),W.of({name:`Objective-C`,alias:[`objective-c`,`objc`],extensions:[`m`],load(){return U(()=>import(`./clike-DZROJv43.js`).then(e=>Z(e.objectiveC)),__vite__mapDeps([52,53]),import.meta.url)}}),W.of({name:`Objective-C++`,alias:[`objective-c++`,`objc++`],extensions:[`mm`],load(){return U(()=>import(`./clike-DZROJv43.js`).then(e=>Z(e.objectiveCpp)),__vite__mapDeps([52,53]),import.meta.url)}}),W.of({name:`OCaml`,extensions:[`ml`,`mli`,`mll`,`mly`],load(){return U(()=>import(`./mllike-DHDLWZl9.js`).then(e=>Z(e.oCaml)),__vite__mapDeps([94,95]),import.meta.url)}}),W.of({name:`Octave`,extensions:[`m`],load(){return U(()=>import(`./octave-ImTMIie9.js`).then(e=>Z(e.octave)),__vite__mapDeps([130,131]),import.meta.url)}}),W.of({name:`Oz`,extensions:[`oz`],load(){return U(()=>import(`./oz-BuYcBdKy.js`).then(e=>Z(e.oz)),__vite__mapDeps([132,133]),import.meta.url)}}),W.of({name:`Pascal`,extensions:[`p`,`pas`],load(){return U(()=>import(`./pascal-B50DmceL.js`).then(e=>Z(e.pascal)),__vite__mapDeps([134,135]),import.meta.url)}}),W.of({name:`Perl`,extensions:[`pl`,`pm`],load(){return U(()=>import(`./perl-DmFVAwdF.js`).then(e=>Z(e.perl)),__vite__mapDeps([136,137]),import.meta.url)}}),W.of({name:`Pig`,extensions:[`pig`],load(){return U(()=>import(`./pig-BnQuru9N.js`).then(e=>Z(e.pig)),__vite__mapDeps([138,139]),import.meta.url)}}),W.of({name:`PowerShell`,extensions:[`ps1`,`psd1`,`psm1`],load(){return U(()=>import(`./powershell-B1pJyAAD.js`).then(e=>Z(e.powerShell)),__vite__mapDeps([140,141]),import.meta.url)}}),W.of({name:`Properties files`,alias:[`ini`,`properties`],extensions:[`properties`,`ini`,`in`],load(){return U(()=>import(`./properties-Ci7guRqV.js`).then(e=>Z(e.properties)),__vite__mapDeps([142,143]),import.meta.url)}}),W.of({name:`ProtoBuf`,extensions:[`proto`],load(){return U(()=>import(`./protobuf-CoqP8wM5.js`).then(e=>Z(e.protobuf)),__vite__mapDeps([144,145]),import.meta.url)}}),W.of({name:`Pug`,alias:[`jade`],extensions:[`pug`,`jade`],load(){return U(()=>import(`./pug-CJsoo9v0.js`).then(e=>Z(e.pug)),__vite__mapDeps([146,147,109]),import.meta.url)}}),W.of({name:`Puppet`,extensions:[`pp`],load(){return U(()=>import(`./puppet-C9UYpvtZ.js`).then(e=>Z(e.puppet)),__vite__mapDeps([148,149]),import.meta.url)}}),W.of({name:`Q`,extensions:[`q`],load(){return U(()=>import(`./q-CKkOe1xA.js`).then(e=>Z(e.q)),__vite__mapDeps([150,151]),import.meta.url)}}),W.of({name:`R`,alias:[`rscript`],extensions:[`r`,`R`],load(){return U(()=>import(`./r-Bwc-y-iL.js`).then(e=>Z(e.r)),__vite__mapDeps([152,153]),import.meta.url)}}),W.of({name:`RPM Changes`,load(){return U(()=>import(`./rpm-UQSdNQr2.js`).then(e=>Z(e.rpmChanges)),__vite__mapDeps([154,155]),import.meta.url)}}),W.of({name:`RPM Spec`,extensions:[`spec`],load(){return U(()=>import(`./rpm-UQSdNQr2.js`).then(e=>Z(e.rpmSpec)),__vite__mapDeps([154,155]),import.meta.url)}}),W.of({name:`Ruby`,alias:[`jruby`,`macruby`,`rake`,`rb`,`rbx`],extensions:[`rb`],filename:/^(Gemfile|Rakefile)$/,load(){return U(()=>import(`./ruby-CrY8zrT8.js`).then(e=>Z(e.ruby)),__vite__mapDeps([156,157]),import.meta.url)}}),W.of({name:`SAS`,extensions:[`sas`],load(){return U(()=>import(`./sas-CssadkTB.js`).then(e=>Z(e.sas)),__vite__mapDeps([158,159]),import.meta.url)}}),W.of({name:`Scala`,extensions:[`scala`],load(){return U(()=>import(`./clike-DZROJv43.js`).then(e=>Z(e.scala)),__vite__mapDeps([52,53]),import.meta.url)}}),W.of({name:`Scheme`,extensions:[`scm`,`ss`],load(){return U(()=>import(`./scheme-CkJWoRmu.js`).then(e=>Z(e.scheme)),__vite__mapDeps([160,161]),import.meta.url)}}),W.of({name:`Shell`,alias:[`bash`,`sh`,`zsh`],extensions:[`sh`,`ksh`,`bash`],filename:/^PKGBUILD$/,load(){return U(()=>import(`./shell-FgUEpLdy.js`).then(e=>Z(e.shell)),__vite__mapDeps([162,163]),import.meta.url)}}),W.of({name:`Sieve`,extensions:[`siv`,`sieve`],load(){return U(()=>import(`./sieve-BLxcNk7A.js`).then(e=>Z(e.sieve)),__vite__mapDeps([164,165]),import.meta.url)}}),W.of({name:`Smalltalk`,extensions:[`st`],load(){return U(()=>import(`./smalltalk-d1Dbk6V4.js`).then(e=>Z(e.smalltalk)),__vite__mapDeps([166,167]),import.meta.url)}}),W.of({name:`Solr`,load(){return U(()=>import(`./solr-BBopId9w.js`).then(e=>Z(e.solr)),[],import.meta.url)}}),W.of({name:`SML`,extensions:[`sml`,`sig`,`fun`,`smackspec`],load(){return U(()=>import(`./mllike-DHDLWZl9.js`).then(e=>Z(e.sml)),__vite__mapDeps([94,95]),import.meta.url)}}),W.of({name:`SPARQL`,alias:[`sparul`],extensions:[`rq`,`sparql`],load(){return U(()=>import(`./sparql-CUZhKeRb.js`).then(e=>Z(e.sparql)),__vite__mapDeps([168,169]),import.meta.url)}}),W.of({name:`Spreadsheet`,alias:[`excel`,`formula`],load(){return U(()=>import(`./spreadsheet-CTIncYxj.js`).then(e=>Z(e.spreadsheet)),[],import.meta.url)}}),W.of({name:`Squirrel`,extensions:[`nut`],load(){return U(()=>import(`./clike-DZROJv43.js`).then(e=>Z(e.squirrel)),__vite__mapDeps([52,53]),import.meta.url)}}),W.of({name:`Stylus`,extensions:[`styl`],load(){return U(()=>import(`./stylus-BvudHrj4.js`).then(e=>Z(e.stylus)),__vite__mapDeps([170,171]),import.meta.url)}}),W.of({name:`Swift`,extensions:[`swift`],load(){return U(()=>import(`./swift-CUIczYYb.js`).then(e=>Z(e.swift)),__vite__mapDeps([172,173]),import.meta.url)}}),W.of({name:`sTeX`,load(){return U(()=>import(`./stex-3SJlFZg3.js`).then(e=>Z(e.stex)),__vite__mapDeps([174,175]),import.meta.url)}}),W.of({name:`LaTeX`,alias:[`tex`],extensions:[`text`,`ltx`,`tex`],load(){return U(()=>import(`./stex-3SJlFZg3.js`).then(e=>Z(e.stex)),__vite__mapDeps([174,175]),import.meta.url)}}),W.of({name:`SystemVerilog`,extensions:[`v`,`sv`,`svh`],load(){return U(()=>import(`./verilog-DH7aBYt7.js`).then(e=>Z(e.verilog)),__vite__mapDeps([176,177]),import.meta.url)}}),W.of({name:`Tcl`,extensions:[`tcl`],load(){return U(()=>import(`./tcl-SjROh4xB.js`).then(e=>Z(e.tcl)),__vite__mapDeps([178,179]),import.meta.url)}}),W.of({name:`Textile`,extensions:[`textile`],load(){return U(()=>import(`./textile-DgW6fC9R.js`).then(e=>Z(e.textile)),__vite__mapDeps([180,181]),import.meta.url)}}),W.of({name:`TiddlyWiki`,load(){return U(()=>import(`./tiddlywiki-VlUiK86J.js`).then(e=>Z(e.tiddlyWiki)),[],import.meta.url)}}),W.of({name:`Tiki wiki`,load(){return U(()=>import(`./tiki-AK6FwT8q.js`).then(e=>Z(e.tiki)),[],import.meta.url)}}),W.of({name:`TOML`,extensions:[`toml`],load(){return U(()=>import(`./toml-BcC_uO4q.js`).then(e=>Z(e.toml)),__vite__mapDeps([182,183]),import.meta.url)}}),W.of({name:`Troff`,extensions:[`1`,`2`,`3`,`4`,`5`,`6`,`7`,`8`,`9`],load(){return U(()=>import(`./troff-BMlKH74u.js`).then(e=>Z(e.troff)),__vite__mapDeps([184,185]),import.meta.url)}}),W.of({name:`TTCN`,extensions:[`ttcn`,`ttcn3`,`ttcnpp`],load(){return U(()=>import(`./ttcn-P2iYmK_j.js`).then(e=>Z(e.ttcn)),__vite__mapDeps([186,187]),import.meta.url)}}),W.of({name:`TTCN_CFG`,extensions:[`cfg`],load(){return U(()=>import(`./ttcn-cfg-2bl9aE98.js`).then(e=>Z(e.ttcnCfg)),__vite__mapDeps([188,189]),import.meta.url)}}),W.of({name:`Turtle`,extensions:[`ttl`],load(){return U(()=>import(`./turtle-DDf6uD3p.js`).then(e=>Z(e.turtle)),__vite__mapDeps([190,191]),import.meta.url)}}),W.of({name:`Web IDL`,extensions:[`webidl`],load(){return U(()=>import(`./webidl-dw5if_Lv.js`).then(e=>Z(e.webIDL)),__vite__mapDeps([192,193]),import.meta.url)}}),W.of({name:`VB.NET`,extensions:[`vb`],load(){return U(()=>import(`./vb-CrfmF706.js`).then(e=>Z(e.vb)),__vite__mapDeps([194,195]),import.meta.url)}}),W.of({name:`VBScript`,extensions:[`vbs`],load(){return U(()=>import(`./vbscript-Cpiv2llq.js`).then(e=>Z(e.vbScript)),__vite__mapDeps([196,197]),import.meta.url)}}),W.of({name:`Velocity`,extensions:[`vtl`],load(){return U(()=>import(`./velocity-5N54agTA.js`).then(e=>Z(e.velocity)),__vite__mapDeps([198,199]),import.meta.url)}}),W.of({name:`Verilog`,extensions:[`v`],load(){return U(()=>import(`./verilog-DH7aBYt7.js`).then(e=>Z(e.verilog)),__vite__mapDeps([176,177]),import.meta.url)}}),W.of({name:`VHDL`,extensions:[`vhd`,`vhdl`],load(){return U(()=>import(`./vhdl-BmegRbqn.js`).then(e=>Z(e.vhdl)),__vite__mapDeps([200,201]),import.meta.url)}}),W.of({name:`XQuery`,extensions:[`xy`,`xquery`,`xq`,`xqm`,`xqy`],load(){return U(()=>import(`./xquery-CuDTgW6S.js`).then(e=>Z(e.xQuery)),__vite__mapDeps([202,203]),import.meta.url)}}),W.of({name:`Yacas`,extensions:[`ys`],load(){return U(()=>import(`./yacas-Dn2coKff.js`).then(e=>Z(e.yacas)),__vite__mapDeps([204,205]),import.meta.url)}}),W.of({name:`Z80`,extensions:[`z80`],load(){return U(()=>import(`./z80-ByJO5ysu.js`).then(e=>Z(e.z80)),__vite__mapDeps([206,207]),import.meta.url)}}),W.of({name:`MscGen`,extensions:[`mscgen`,`mscin`,`msc`],load(){return U(()=>import(`./mscgen-C7woTLsY.js`).then(e=>Z(e.mscgen)),__vite__mapDeps([208,209]),import.meta.url)}}),W.of({name:`Xù`,extensions:[`xu`],load(){return U(()=>import(`./mscgen-C7woTLsY.js`).then(e=>Z(e.xu)),__vite__mapDeps([208,209]),import.meta.url)}}),W.of({name:`MsGenny`,extensions:[`msgenny`],load(){return U(()=>import(`./mscgen-C7woTLsY.js`).then(e=>Z(e.msgenny)),__vite__mapDeps([208,209]),import.meta.url)}}),W.of({name:`Vue`,extensions:[`vue`],load(){return U(()=>import(`./dist-DH7Tm1i8.js`).then(e=>e.vue()),__vite__mapDeps([210,211,4,13,9,14,5]),import.meta.url)}}),W.of({name:`Angular Template`,load(){return U(()=>import(`./dist-DLwSLd_v.js`).then(e=>e.angular()),__vite__mapDeps([212,4,13,9,14,5]),import.meta.url)}})],_m=new WeakMap,vm=/(\n|\r\n?|\u2028|\u2029)/g,ym=/^\s*/,bm=/\S/,xm=Array.prototype.slice,Sm=48,Cm=57,wm=97,Tm=102,Em=65,Dm=70;function Om(e){if(typeof e==`string`)return jm([e])[0];if(typeof e==`function`)return function(){let t=xm.call(arguments);return t[0]=Am(t[0]),e.apply(this,t)};let t=Am(e),n=km(t,0);for(let e=1;e<t.length;e++)n+=arguments[e]+km(t,e);return n}function km(e,t){let n=e[t];if(n===void 0)throw TypeError(`invalid cooked string at index ${t}`);return n}function Am(e){let t=_m.get(e);if(t)return t;let n=jm(e.raw),r=n.map(Nm);return Object.defineProperty(r,"raw",{value:Object.freeze(n)}),Object.freeze(r),_m.set(e,r),r}function jm(e){let t=e.map(e=>e.split(vm)),n;for(let e=0;e<t.length;e++){let r=t[e],i=e===0,a=e+1===t.length;if(i){if(r.length===1||r[0].length>0)throw Error(`invalid content on opening line`);r[1]=``}if(a){if(r.length===1||bm.test(r[r.length-1]))throw Error(`invalid content on closing line`);r[r.length-2]=``,r[r.length-1]=``}for(let e=2;e<r.length;e+=2){let t=r[e],i=e+1===r.length&&!a,o=ym.exec(t)[0];if(!i&&o.length===t.length){r[e]=``;continue}n=Mm(o,n)}}let r=n?n.length:0;return t.map(e=>{let t=e[0];for(let n=1;n<e.length;n+=2){let i=e[n],a=e[n+1];t+=i+a.slice(r)}return t})}function Mm(e,t){if(t===void 0||e===t)return e;let n=0;for(let r=Math.min(e.length,t.length);n<r&&e[n]===t[n];n++);return e.slice(0,n)}function Nm(e){let t=``,n=0,r=0;for(;(r=e.indexOf(`\\`,r))>-1;){if(t+=e.slice(n,r),++r===e.length)return;let i=e[r++];switch(i){case`b`:t+=`\b`;break;case`t`:t+=` `;break;case`n`:t+=`
|
|
36
36
|
`;break;case`v`:t+=`\v`;break;case`f`:t+=`\f`;break;case`r`:t+=`\r`;break;case`\r`:r<e.length&&e[r]===`
|
|
37
37
|
`&&++r;case`
|
|
38
38
|
`:case`\u2028`:case`\u2029`:break;case`0`:if(Pm(e,r))return;t+=`\0`;break;case`x`:{let n=Fm(e,r,r+2);if(n===-1)return;r+=2,t+=String.fromCharCode(n);break}case`u`:{let n;if(r<e.length&&e[r]===`{`){let t=e.indexOf(`}`,++r);if(t===-1)return;n=Fm(e,r,t),r=t+1}else n=Fm(e,r,r+4),r+=4;if(n===-1||n>1114111)return;t+=String.fromCodePoint(n);break}default:if(Pm(i,0))return;t+=i}n=r}return t+e.slice(n)}function Pm(e,t){let n=e.charCodeAt(t);return n>=Sm&&n<=Cm}function Fm(e,t,n){if(n>=e.length)return-1;let r=0;for(;t<n;t++){let n=Im(e.charCodeAt(t));if(n===-1)return-1;r=r*16+n}return r}function Im(e){return e>=Sm&&e<=Cm?e-Sm:e>=wm&&e<=Tm?e-wm+10:e>=Em&&e<=Dm?e-Em+10:-1}var Lm=[``,`f`,`r`,`fr`,`rf`];function Rm(e){try{return Om(`\n${e}\n`).trim()}catch{return e}}function zm(e){return ni.parse(e)}var Bm=new Set([`(`,`[`,`{`,`,`,`)`,`]`,`}`]);function Vm(e,t){return e.name===`ArgList`?{args:Hm(e),kwargs:Um(e,t)}:(console.warn(`Not an ArgList, name: ${e.name}`),{args:[],kwargs:[]})}function Hm(e){e.firstChild();let t=[],n=e.name;do if(n=e.name,!Bm.has(n)){if(n===`VariableName`&&e.node.nextSibling?.name===`AssignOp`){e.prev();break}t.push(e.node)}while(e.nextSibling());return t}function Um(e,t){let n=[],r=e.name;do if(r=e.name,r===`VariableName`){let r=t.slice(e.from,e.to),i=e.node.nextSibling;if(!i||i.name!==`AssignOp`)continue;let a=i.nextSibling;if(!a)continue;let o=t.slice(a.from,a.to).trim();n.push({key:r,value:o})}while(e.nextSibling());return n}function Wm(e,t){if(e.name===`String`){let n=t.slice(e.from,e.to);return n.startsWith(`r"""`)||n.startsWith(`r'''`)?n.slice(4,-3):n.startsWith(`"""`)||n.startsWith(`'''`)?n.slice(3,-3):n.startsWith(`r"`)||n.startsWith(`r'`)?n.slice(2,-1):n.slice(1,-1)}if(e.name===`FormatString`){let n=t.slice(e.from,e.to);return n.startsWith(`f"""`)||n.startsWith(`f'''`)?n.slice(4,-3):n.startsWith(`rf"""`)||n.startsWith(`rf'''`)||n.startsWith(`fr"""`)||n.startsWith(`fr'''`)?n.slice(5,-3):n.startsWith(`r"""`)||n.startsWith(`r'''`)?n.slice(4,-3):n.startsWith(`f"`)||n.startsWith(`f'`)?n.slice(2,-1):n.startsWith(`rf"`)||n.startsWith(`rf'`)||n.startsWith(`fr"`)||n.startsWith(`fr'`)?n.slice(3,-1):(n.startsWith(`r"`)||n.startsWith(`r'`),n.slice(2,-1))}return null}function Gm(e){return e===``?0:e.startsWith(`rf"""`)||e.startsWith(`rf'''`)||e.startsWith(`fr"""`)||e.startsWith(`fr'''`)?5:e.startsWith(`f"""`)||e.startsWith(`f'''`)||e.startsWith(`r"""`)||e.startsWith(`r'''`)?4:e.startsWith(`"""`)||e.startsWith(`'''`)||e.startsWith(`rf'`)||e.startsWith(`rf"`)||e.startsWith(`fr'`)||e.startsWith(`fr"`)?3:e.startsWith(`f'`)||e.startsWith(`f"`)||e.startsWith(`r'`)||e.startsWith(`r"`)?2:e.startsWith(`'`)||e.startsWith(`"`)?1:0}function Km(e){let t=[...Lm].sort((e,t)=>t.length-e.length);for(let n of t)if(e.startsWith(n))return[n,e.slice(n.length)];return[``,e]}function qm(e,t){return e.replaceAll(`\\${t}`,t)}var Jm=[[`"""`,`"""`],[`'''`,`'''`],[`"`,`"`],[`'`,`'`]],Ym=Lm.flatMap(e=>Jm.map(([t,n])=>[e+t,n])).map(([e,t])=>[e,RegExp(`^mo\\.md\\(\\s*${Xm(e)}(.*)${Xm(t)}\\s*\\)$`,`s`)]);function Xm(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}var Zm=class{type=`markdown`;defaultCode=`mo.md(r"""
|
|
@@ -81,11 +81,11 @@ mark line col
|
|
|
81
81
|
`&&fr(this.cm6)}else console.log(t+` is not implemented`)}setBookmark(e,t){var n=t?.insertLeft?1:-1,r=this.indexFromPos(e);return new t_(this,r,n)}addOverlay({query:e}){let t=new pr({regexp:!0,search:e.source,caseSensitive:!/i/.test(e.flags)});if(t.valid){t.forVim=!0,this.cm6Query=t;let e=mr.of(t);return this.cm6.dispatch({effects:e}),t}}removeOverlay(e){if(!this.cm6Query)return;this.cm6Query.forVim=!1;let t=mr.of(this.cm6Query);this.cm6.dispatch({effects:t})}getSearchCursor(e,t){var n=this,r=null,i=null,a=!1;t.ch??=Number.MAX_VALUE;var o=jg(n.cm6.state.doc,t),s=e.source.replace(/(\\.|{(?:\d+(?:,\d*)?|,\d+)})|[{}]/g,function(e,t){return t||`\\`+e});function c(t,n=0,r=t.length){return new gr(t,s,{ignoreCase:e.ignoreCase},n,r)}function l(e){var t=n.cm6.state.doc;if(e>t.length)return null;let r=c(t,e).next();return r.done?null:r.value}var u=1e4;function d(e,t){var r=n.cm6.state.doc;for(let n=1;;n++){let i=Math.max(e,t-n*u),a=c(r,i,t),o=null;for(;!a.next().done;)o=a.value;if(o&&(i==e||o.from>i+10))return o;if(i==e)return null}}return{findNext:function(){return this.find(!1)},findPrevious:function(){return this.find(!0)},find:function(e){var t=n.cm6.state.doc;return r=e?d(0,r?a?r.to-1:r.from:o):l(r?a?r.to+1:r.to:o),i=r&&{from:Mg(t,r.from),to:Mg(t,r.to),match:r.match},a=r?r.from==r.to:!1,r&&r.match},from:function(){return i?.from},to:function(){return i?.to},replace:function(e){r&&(zg(n,{changes:{from:r.from,to:r.to,insert:e}}),r.to=r.from+e.length,i&&(i.to=Mg(n.cm6.state.doc,r.to)))},get match(){return i&&i.match}}}findPosV(e,t,n,r){let{cm6:i}=this,a=i.state.doc,o=n==`page`?i.dom.clientHeight:0,s=jg(a,e),c=On.cursor(s,1,void 0,r),l=Math.round(Math.abs(t));for(let e=0;e<l;e++)n==`page`?c=i.moveVertically(c,t>0,o):n==`line`&&(c=i.moveVertically(c,t>0));let u=Mg(a,c.head);return(t<0&&c.head==0&&r!=0&&e.line==0&&e.ch!=0||t>0&&c.head==a.length&&u.ch!=r&&e.line==u.line)&&(u.hitSide=!0),u}charCoords(e,t){var n=this.cm6.contentDOM.getBoundingClientRect(),r=jg(this.cm6.state.doc,e),i=this.cm6.coordsAtPos(r),a=-n.top;return{left:(i?.left||0)-n.left,top:(i?.top||0)+a,bottom:(i?.bottom||0)+a}}coordsChar(e,t){var n=this.cm6.contentDOM.getBoundingClientRect(),r=this.cm6.posAtCoords({x:e.left+n.left,y:e.top+n.top})||0;return Mg(this.cm6.state.doc,r)}getScrollInfo(){var e=this.cm6.scrollDOM;return{left:e.scrollLeft,top:e.scrollTop,height:e.scrollHeight,width:e.scrollWidth,clientHeight:e.clientHeight,clientWidth:e.clientWidth}}scrollTo(e,t){e!=null&&(this.cm6.scrollDOM.scrollLeft=e),t!=null&&(this.cm6.scrollDOM.scrollTop=t)}scrollIntoView(e,t){if(e){var n=this.indexFromPos(e);this.cm6.dispatch({effects:Kn.scrollIntoView(n)})}else this.cm6.dispatch({scrollIntoView:!0,userEvent:`scroll`})}getWrapperElement(){return this.cm6.dom}getMode(){return{name:this.getOption(`mode`)}}setSize(e,t){this.cm6.dom.style.width=e+4+`px`,this.cm6.dom.style.height=t+`px`,this.refresh()}refresh(){this.cm6.measure()}destroy(){this.removeOverlay()}getLastEditEnd(){return this.posFromIndex(this.$lastChangeEndOffset)}onChange(e){this.$lineHandleChanges&&this.$lineHandleChanges.push(e);for(let t in this.marks)this.marks[t].update(e.changes);this.virtualSelection&&(this.virtualSelection.ranges=this.virtualSelection.ranges.map(t=>t.map(e.changes)));var t=this.curOp=this.curOp||{};e.changes.iterChanges((e,n,r,i,a)=>{(t.$changeStart==null||t.$changeStart>r)&&(t.$changeStart=r),this.$lastChangeEndOffset=i;var o={text:a.toJSON()};t.lastChange?t.lastChange.next=t.lastChange=o:t.lastChange=t.change=o},!0),t.changeHandlers||=this._handlers.change&&this._handlers.change.slice()}onSelectionChange(){var e=this.curOp=this.curOp||{};e.cursorActivityHandlers||=this._handlers.cursorActivity&&this._handlers.cursorActivity.slice(),this.curOp.cursorActivity=!0}operation(e,t){this.curOp||={$d:0},this.curOp.$d++;try{var n=e()}finally{this.curOp&&(this.curOp.$d--,this.curOp.$d||this.onBeforeEndOperation())}return n}onBeforeEndOperation(){var e=this.curOp,t=!1;e&&(e.change&&Lg(e.changeHandlers,this,e.change),e&&e.cursorActivity&&(Lg(e.cursorActivityHandlers,this,null),e.isVimOp&&(t=!0)),this.curOp=null),t&&this.scrollIntoView()}moveH(e,t){if(t==`char`){var n=this.getCursor();this.setCursor(n.line,n.ch+e)}}setOption(e,t){switch(e){case`keyMap`:this.state.keyMap=t;break;case`textwidth`:this.state.textwidth=t}}getOption(e){switch(e){case`firstLineNumber`:return 1;case`tabSize`:return this.cm6.state.tabSize||4;case`readOnly`:return this.cm6.state.readOnly;case`indentWithTabs`:return this.cm6.state.facet(hn)==` `;case`indentUnit`:return this.cm6.state.facet(hn).length||2;case`textwidth`:return this.state.textwidth;case`keyMap`:return this.state.keyMap||`vim`}}toggleOverwrite(e){this.state.overwrite=e}getTokenTypeAt(e){var t=this.indexFromPos(e),n=(Pn(this.cm6.state,t)?.resolve(t))?.type?.name||``;return/comment/i.test(n)?`comment`:/string/i.test(n)?`string`:``}overWriteSelection(e){var t=this.cm6.state.doc,n=this.cm6.state.selection,r=n.ranges.map(e=>{if(e.empty){var n=e.to<t.length?t.sliceString(e.from,e.to+1):``;if(n&&!/\n/.test(n))return On.range(e.from,e.to+1)}return e});this.cm6.dispatch({selection:On.create(r,n.mainIndex)}),this.replaceSelection(e)}isInMultiSelectMode(){return this.cm6.state.selection.ranges.length>1}virtualSelectionMode(){return!!this.virtualSelection}forEachSelection(e){var t=this.cm6.state.selection;this.virtualSelection=On.create(t.ranges,t.mainIndex);for(var n=0;n<this.virtualSelection.ranges.length;n++){var r=this.virtualSelection.ranges[n];r&&(this.cm6.dispatch({selection:On.create([r])}),e(),this.virtualSelection.ranges[n]=this.cm6.state.selection.ranges[0])}this.cm6.dispatch({selection:this.virtualSelection}),this.virtualSelection=null}hardWrap(e){return n_(this,e)}};Hg.isMac=typeof navigator<`u`&&/Mac/.test(navigator.platform),Hg.Pos=Ng,Hg.StringStream=Hn,Hg.commands={toggleLineComment:function(e){yr(e.cm6)},cursorCharLeft:function(e){lr(e.cm6)},redo:function(e){Bg(e,!1)},undo:function(e){Bg(e,!0)},newlineAndIndent:function(e){dr({state:e.cm6.state,dispatch:t=>zg(e,t)})},indentAuto:function(e){rr(e.cm6)},newlineAndIndentContinueComment:void 0,save:void 0},Hg.isWordChar=function(e){return Rg.test(e)},Hg.keys=Vg,Hg.addClass=function(e,t){},Hg.rmClass=function(e,t){},Hg.e_preventDefault=function(e){e.preventDefault()},Hg.e_stop=function(e){var t,n;(t=e?.stopPropagation)==null||t.call(e),(n=e?.preventDefault)==null||n.call(e)},Hg.lookupKey=function(e,t,n){var r=Hg.keys[e];!r&&/^Arrow/.test(e)&&(r=Hg.keys[e.slice(5)]),r&&n(r)},Hg.on=Pg,Hg.off=Fg,Hg.signal=Ig,Hg.findMatchingTag=Qg,Hg.findEnclosingTag=$g,Hg.keyName=void 0;function Ug(e,t,n){var r=document.createElement(`div`);return r.appendChild(t),r}function Wg(e,t){e.state.currentNotificationClose&&e.state.currentNotificationClose(),e.state.currentNotificationClose=t}function Gg(e,t,n){Wg(e,s);var r=Ug(e,t,n&&n.bottom),i=!1,a,o=n&&n.duration!==void 0?n.duration:5e3;function s(){i||(i=!0,clearTimeout(a),r.remove(),qg(e,r))}return r.onclick=function(e){e.preventDefault(),s()},Kg(e,r),o&&(a=setTimeout(s,o)),s}function Kg(e,t){var n=e.state.dialog;e.state.dialog=t,t.style.flex=`1`,t&&n!==t&&(n&&n.contains(document.activeElement)&&e.focus(),n&&n.parentElement?n.parentElement.replaceChild(t,n):n&&n.remove(),Hg.signal(e,`dialog`))}function qg(e,t){e.state.dialog==t&&(e.state.dialog=null,Hg.signal(e,`dialog`))}function Jg(e,t,n,r){r||={},Wg(e,void 0);var i=Ug(e,t,r.bottom),a=!1;Kg(e,i);function o(t){if(typeof t==`string`)s.value=t;else{if(a)return;a=!0,qg(e,i),e.state.dialog||e.focus(),r.onClose&&r.onClose(i)}}var s=i.getElementsByTagName(`input`)[0];return s&&(r.value&&(s.value=r.value,r.selectValueOnOpen!==!1&&s.select()),r.onInput&&Hg.on(s,`input`,function(e){r.onInput(e,s.value,o)}),r.onKeyUp&&Hg.on(s,`keyup`,function(e){r.onKeyUp(e,s.value,o)}),Hg.on(s,`keydown`,function(e){r&&r.onKeyDown&&r.onKeyDown(e,s.value,o)||(e.keyCode==13&&n&&n(s.value),(e.keyCode==27||r.closeOnEnter!==!1&&e.keyCode==13)&&(s.blur(),Hg.e_stop(e),o()))}),r.closeOnBlur!==!1&&Hg.on(s,`blur`,function(){setTimeout(function(){document.activeElement!==s&&o()})}),s.focus()),o}var Yg={"(":`)>`,")":`(<`,"[":`]>`,"]":`[<`,"{":`}>`,"}":`{<`,"<":`>>`,">":`<<`};function Xg(e){return e&&e.bracketRegex||/[(){}[\]]/}function Zg(e,t,n,r,i){for(var a=i&&i.maxScanLineLength||1e4,o=i&&i.maxScanLines||1e3,s=[],c=Xg(i),l=n>0?Math.min(t.line+o,e.lastLine()+1):Math.max(e.firstLine()-1,t.line-o),u=t.line;u!=l;u+=n){var d=e.getLine(u);if(d){var f=n>0?0:d.length-1,p=n>0?d.length:-1;if(!(d.length>a))for(u==t.line&&(f=t.ch-+(n<0));f!=p;f+=n){var m=d.charAt(f);if(c.test(m)){var h=Yg[m];if(h&&h.charAt(1)==`>`==n>0)s.push(m);else if(s.length)s.pop();else return{pos:new Ng(u,f),ch:m}}}}}return u-n!=(n>0?e.lastLine():e.firstLine())&&null}function Qg(e,t){return null}function $g(e,t){var n=e.cm6.state,r=e.indexFromPos(t);r<n.doc.length&&n.sliceDoc(r,r+1)==`<`&&r++;for(var i=Pn(n,r)?.resolve(r)||null;i;){if(i.firstChild?.type.name==`OpenTag`&&i.lastChild?.type.name==`CloseTag`)return{open:e_(n.doc,i.firstChild),close:e_(n.doc,i.lastChild)};i=i.parent}}function e_(e,t){return{from:Mg(e,t.from),to:Mg(e,t.to)}}var t_=class{constructor(e,t,n){this.cm=e,this.id=e.$mid++,this.offset=t,this.assoc=n,e.marks[this.id]=this}clear(){delete this.cm.marks[this.id]}find(){return this.offset==null?null:this.cm.posFromIndex(this.offset)}update(e){this.offset!=null&&(this.offset=e.mapPos(this.offset,this.assoc,Gn.TrackDel))}};function n_(e,t){for(var n=t.column||e.getOption(`textwidth`)||80,r=t.allowMerge!=0,i=Math.min(t.from,t.to),a=Math.max(t.from,t.to);i<=a;){var o=e.getLine(i);if(o.length>n){var s=p(o,n,5);if(s){var c=/^\s*/.exec(o)?.[0];e.replaceRange(`
|
|
82
82
|
`+c,new Ng(i,s.start),new Ng(i,s.end))}a++}else if(r&&/\S/.test(o)&&i!=a){var l=e.getLine(i+1);if(l&&/\S/.test(l)){var u=o.replace(/\s+$/,``),d=l.replace(/^\s+/,``),f=u+` `+d,s=p(f,n,5);s&&s.start>u.length||f.length<n?(e.replaceRange(` `,new Ng(i,u.length),new Ng(i+1,l.length-d.length)),i--,a--):u.length<o.length&&e.replaceRange(``,new Ng(i,u.length),new Ng(i,o.length))}}i++}return i;function p(e,t,n){if(!(e.length<t)){var r=e.slice(0,t),i=e.slice(t),a=/^(?:(\s+)|(\S+)(\s+))/.exec(i),o=/(?:(\s+)|(\s+)(\S+))$/.exec(r),s=0,c=0;if(o&&!o[2]&&(s=t-o[1].length,c=t),a&&!a[2]&&(s||=t,c=t+a[1].length),s)return{start:s,end:c};if(o&&o[2]&&o.index>n)return{start:o.index,end:o.index+o[2].length};if(a&&a[2])return s=t+a[2].length,{start:s,end:s+a[3].length}}}}var r_=Xn||function(){let e={cursorBlinkRate:1200};return function(){return e}}(),i_=class{constructor(e,t,n,r,i,a,o,s,c,l){this.left=e,this.top=t,this.height=n,this.fontFamily=r,this.fontSize=i,this.fontWeight=a,this.color=o,this.className=s,this.letter=c,this.partial=l}draw(){let e=document.createElement(`div`);return e.className=this.className,this.adjust(e),e}adjust(e){e.style.left=this.left+`px`,e.style.top=this.top+`px`,e.style.height=this.height+`px`,e.style.lineHeight=this.height+`px`,e.style.fontFamily=this.fontFamily,e.style.fontSize=this.fontSize,e.style.fontWeight=this.fontWeight,e.style.color=this.partial?`transparent`:this.color,e.className=this.className,e.textContent=this.letter}eq(e){return this.left==e.left&&this.top==e.top&&this.height==e.height&&this.fontFamily==e.fontFamily&&this.fontSize==e.fontSize&&this.fontWeight==e.fontWeight&&this.color==e.color&&this.className==e.className&&this.letter==e.letter}},a_=class{constructor(e,t){this.view=e,this.rangePieces=[],this.cursors=[],this.cm=t,this.measureReq={read:this.readPos.bind(this),write:this.drawSel.bind(this)},this.cursorLayer=e.scrollDOM.appendChild(document.createElement(`div`)),this.cursorLayer.className=`cm-cursorLayer cm-vimCursorLayer`,this.cursorLayer.setAttribute(`aria-hidden`,`true`),e.requestMeasure(this.measureReq),this.setBlinkRate()}setBlinkRate(){let e=r_(this.cm.cm6.state).cursorBlinkRate;this.cursorLayer.style.animationDuration=e+`ms`}update(e){(e.selectionSet||e.geometryChanged||e.viewportChanged)&&(this.view.requestMeasure(this.measureReq),this.cursorLayer.style.animationName=this.cursorLayer.style.animationName==`cm-blink`?`cm-blink2`:`cm-blink`),o_(e)&&this.setBlinkRate()}scheduleRedraw(){this.view.requestMeasure(this.measureReq)}readPos(){let{state:e}=this.view,t=[];for(let n of e.selection.ranges){let r=n==e.selection.main,i=l_(this.cm,this.view,n,r);i&&t.push(i)}return{cursors:t}}drawSel({cursors:e}){if(e.length!=this.cursors.length||e.some((e,t)=>!e.eq(this.cursors[t]))){let t=this.cursorLayer.children;if(t.length!==e.length){this.cursorLayer.textContent=``;for(let t of e)this.cursorLayer.appendChild(t.draw())}else e.forEach((e,n)=>e.adjust(t[n]));this.cursors=e}}destroy(){this.cursorLayer.remove()}};function o_(e){return r_(e.startState)!=r_(e.state)}var s_=gn.highest(Kn.theme({".cm-vimMode .cm-line":{"& ::selection":{backgroundColor:`transparent !important`},"&::selection":{backgroundColor:`transparent !important`},caretColor:`transparent !important`},".cm-fat-cursor":{position:`absolute`,background:`#ff9696`,border:`none`,whiteSpace:`pre`},"&:not(.cm-focused) .cm-fat-cursor":{background:`none`,outline:`solid 1px #ff9696`,color:`transparent !important`}}));function c_(e){let t=e.scrollDOM.getBoundingClientRect();return{left:(e.textDirection==Vn.LTR?t.left:t.right-e.scrollDOM.clientWidth)-e.scrollDOM.scrollLeft*e.scaleX,top:t.top-e.scrollDOM.scrollTop*e.scaleY}}function l_(e,t,n,r){var i;let a=n.head,o=!1,s=1,c=e.state.vim;if(c&&(!c.insertMode||e.state.overwrite)){if(o=!0,c.visualBlock&&!r)return null;n.anchor<n.head&&(a<t.state.doc.length&&t.state.sliceDoc(a,a+1))!=`
|
|
83
83
|
`&&a--,e.state.overwrite?s=.2:c.status&&(s=.5)}if(o){let e=a<t.state.doc.length&&t.state.sliceDoc(a,a+1);e&&/[\uDC00-\uDFFF]/.test(e)&&a>1&&(a--,e=t.state.sliceDoc(a,a+1));let n=t.coordsAtPos(a,1);if(!n)return null;let o=c_(t),c=t.domAtPos(a),u=c?c.node:t.contentDOM;for(u instanceof Text&&c.offset>=u.data.length&&u.parentElement?.nextSibling&&(u=u.parentElement?.nextSibling,c={node:u,offset:0});c&&c.node instanceof HTMLElement;)u=c.node,c={node:c.node.childNodes[c.offset],offset:0};if(!(u instanceof HTMLElement)){if(!u.parentNode)return null;u=u.parentNode}let d=getComputedStyle(u),f=n.left,p=(i=t).coordsForChar?.call(i,a);if(p&&(f=p.left),!e||e==`
|
|
84
|
-
`||e==`\r`)e=`\xA0`;else if(e==` `){e=`\xA0`;var l=t.coordsAtPos(a+1,-1);l&&(f=l.left-(l.left-n.left)/parseInt(d.tabSize))}else/[\uD800-\uDBFF]/.test(e)&&a<t.state.doc.length-1&&(e+=t.state.sliceDoc(a+1,a+2));let m=n.bottom-n.top;return new i_((f-o.left)/t.scaleX,(n.top-o.top+m*(1-s))/t.scaleY,m*s/t.scaleY,d.fontFamily,d.fontSize,d.fontWeight,d.color,r?`cm-fat-cursor cm-cursor-primary`:`cm-fat-cursor cm-cursor-secondary`,e,s!=1)}return null}var u_=typeof navigator<`u`&&/linux/i.test(navigator.platform)&&/ Gecko\/\d+/.exec(navigator.userAgent),d_=Ag(Hg),f_=Kn.baseTheme({".cm-vimMode .cm-cursorLayer:not(.cm-vimCursorLayer)":{display:`none`},".cm-vim-panel":{padding:`0px 10px`,fontFamily:`monospace`,minHeight:`1.3em`,display:`flex`},".cm-vim-panel input":{border:`none`,outline:`none`,backgroundColor:`inherit`},"&light .cm-searchMatch":{backgroundColor:`#ffff0054`},"&dark .cm-searchMatch":{backgroundColor:`#00ffff8a`}}),p_=Yn.fromClass(class{constructor(e){this.status=``,this.query=null,this.decorations=Nn.none,this.waitForCopy=!1,this.lastKeydown=``,this.useNextTextInput=!1,this.compositionText=``,this.view=e;let t=this.cm=new Hg(e);d_.enterVimMode(this.cm),this.view.cm=this.cm,this.cm.state.vimPlugin=this,this.blockCursor=new a_(e,t),this.updateClass(),this.cm.on(`vim-command-done`,()=>{t.state.vim&&(t.state.vim.status=``),this.blockCursor.scheduleRedraw(),this.updateStatus()}),this.cm.on(`vim-mode-change`,e=>{t.state.vim&&(t.state.vim.mode=e.mode,e.subMode&&(t.state.vim.mode+=e.subMode===`linewise`?` line`:` block`),t.state.vim.status=``,this.blockCursor.scheduleRedraw(),this.updateClass(),this.updateStatus())}),this.cm.on(`dialog`,()=>{this.cm.state.statusbar?this.updateStatus():e.dispatch({effects:g_.of(!!this.cm.state.dialog)})}),this.dom=document.createElement(`span`),this.spacer=document.createElement(`span`),this.spacer.style.flex=`1`,this.statusButton=document.createElement(`span`),this.statusButton.onclick=e=>{d_.handleKey(this.cm,`<Esc>`,`user`),this.cm.focus()},this.statusButton.style.cssText=`cursor: pointer`}update(e){if((e.viewportChanged||e.docChanged)&&this.query&&this.highlight(this.query),e.docChanged&&this.cm.onChange(e),e.selectionSet&&this.cm.onSelectionChange(),e.viewportChanged,this.cm.curOp&&!this.cm.curOp.isVimOp&&this.cm.onBeforeEndOperation(),e.transactions){for(let t of e.transactions)for(let e of t.effects)if(e.is(mr)){if(!e.value?.forVim)this.highlight(null);else{let t=e.value.create();this.highlight(t)}}}this.blockCursor.update(e)}updateClass(){let e=this.cm.state;!e.vim||e.vim.insertMode&&!e.overwrite?this.view.scrollDOM.classList.remove(`cm-vimMode`):this.view.scrollDOM.classList.add(`cm-vimMode`)}updateStatus(){let e=this.cm.state.statusbar,t=this.cm.state.vim;if(!e||!t)return;let n=this.cm.state.dialog;if(n)n.parentElement!=e&&(e.textContent=``,e.appendChild(n));else{e.textContent=``;var r=(t.mode||`normal`).toUpperCase();t.insertModeReturn&&(r+=`(C-O)`),this.statusButton.textContent=`--${r}--`,e.appendChild(this.statusButton),e.appendChild(this.spacer)}this.dom.textContent=t.status,e.appendChild(this.dom)}destroy(){d_.leaveVimMode(this.cm),this.updateClass(),this.blockCursor.destroy(),delete this.view.cm}highlight(e){if(this.query=e,!e)return this.decorations=Nn.none;let{view:t}=this,n=new An;for(let r=0,i=t.visibleRanges,a=i.length;r<a;r++){let{from:o,to:s}=i[r];for(;r<a-1&&s>i[r+1].from-500;)s=i[++r].to;e.highlight(t.state,o,s,(e,t)=>{n.add(e,t,h_)})}return this.decorations=n.finish()}handleKey(e,t){let n=this.cm,r=n.state.vim;if(!r)return;let i=d_.vimKeyFromEvent(e,r);if(Hg.signal(this.cm,`inputEvent`,{type:`handleKey`,key:i}),!i)return;if(i==`<Esc>`&&!r.insertMode&&!r.visualMode&&this.query){let e=r.searchState_;e&&(n.removeOverlay(e.getOverlay()),e.setOverlay(null))}if(i===`<C-c>`&&!Hg.isMac&&n.somethingSelected())return this.waitForCopy=!0,!0;r.status=(r.status||``)+i;let a=d_.multiSelectHandleKey(n,i,`user`);return r=d_.maybeInitVimState_(n),!a&&r.insertMode&&n.state.overwrite&&(e.key&&e.key.length==1&&!/\n/.test(e.key)?(a=!0,n.overWriteSelection(e.key)):e.key==`Backspace`&&(a=!0,Hg.commands.cursorCharLeft(n))),a&&(Hg.signal(this.cm,`vim-keypress`,i),e.preventDefault(),e.stopPropagation(),this.blockCursor.scheduleRedraw()),this.updateStatus(),!!a}},{eventHandlers:{copy:function(e,t){this.waitForCopy&&(this.waitForCopy=!1,Promise.resolve().then(()=>{var e=this.cm,t=e.state.vim;t&&(t.insertMode?e.setSelection(e.getCursor(),e.getCursor()):e.operation(()=>{e.curOp&&(e.curOp.isVimOp=!0),d_.handleKey(e,`<Esc>`,`user`)}))}))},compositionstart:function(e,t){this.useNextTextInput=!0,Hg.signal(this.cm,`inputEvent`,e)},compositionupdate:function(e,t){Hg.signal(this.cm,`inputEvent`,e)},compositionend:function(e,t){Hg.signal(this.cm,`inputEvent`,e)},keypress:function(e,t){Hg.signal(this.cm,`inputEvent`,e),this.lastKeydown==`Dead`&&this.handleKey(e,t)},keydown:function(e,t){Hg.signal(this.cm,`inputEvent`,e),this.lastKeydown=e.key,this.lastKeydown==`Unidentified`||this.lastKeydown==`Process`||this.lastKeydown==`Dead`?this.useNextTextInput=!0:(this.useNextTextInput=!1,this.handleKey(e,t))}},provide:()=>[Kn.inputHandler.of((e,t,n,r)=>{var i=x_(e);if(!i)return!1;var a=i.state?.vim,o=i.state.vimPlugin;if(a&&!a.insertMode&&!i.curOp?.isVimOp){if(r===`\0\0`)return!0;if(Hg.signal(i,`inputEvent`,{type:`text`,text:r,from:t,to:n}),r.length==1&&o.useNextTextInput){if(a.expectLiteralNext&&e.composing)return o.compositionText=r,!1;if(o.compositionText){var s=o.compositionText;o.compositionText=``;var c=e.state.selection.main.head;if(s===e.state.sliceDoc(c-s.length,c)){var l=i.getCursor();i.replaceRange(``,i.posFromIndex(c-s.length),l)}}return o.handleKey({key:r,preventDefault:()=>{},stopPropagation:()=>{}}),m_(e),!0}}return!1})],decorations:e=>e.decorations});function m_(e){var t=e.scrollDOM.parentElement;if(t){if(u_){e.contentDOM.textContent=`\0\0`,e.contentDOM.dispatchEvent(new CustomEvent(`compositionend`));return}var n=e.scrollDOM.nextSibling,r=window.getSelection(),i=r&&{anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset};e.scrollDOM.remove(),t.insertBefore(e.scrollDOM,n);try{i&&r&&(r.setPosition(i.anchorNode,i.anchorOffset),i.focusNode&&r.extend(i.focusNode,i.focusOffset))}catch(e){console.error(e)}e.focus(),e.contentDOM.dispatchEvent(new CustomEvent(`compositionend`))}}var h_=Nn.mark({class:`cm-searchMatch`}),g_=xn.define(),__=on.define({create:()=>!1,update(e,t){for(let n of t.effects)n.is(g_)&&(e=n.value);return e},provide:e=>bn.from(e,e=>e?v_:null)});function v_(e){let t=document.createElement(`div`);t.className=`cm-vim-panel`;let n=e.cm;return n.state.dialog&&t.appendChild(n.state.dialog),{top:!1,dom:t}}function y_(e){let t=document.createElement(`div`);t.className=`cm-vim-panel`;let n=e.cm;return n.state.statusbar=t,n.state.vimPlugin.updateStatus(),{dom:t}}function b_(e={}){return[f_,p_,s_,e.status?bn.of(y_):__]}function x_(e){return e.cm||null}function S_(e){let t=e.state.selection.main;return t.from===0&&t.to===0}function C_(e,t=!1){let n=e.state.selection.main,r=e.state.doc.length;return t&&n.from===r-1&&n.to===r-1?!0:n.from===r&&n.to===r}function w_(e){e&&e.dispatch({selection:{anchor:e.state.doc.length,head:e.state.doc.length}})}function T_(e){requestAnimationFrame(()=>{let t=e.current?.view;t&&(t.focus(),w_(t))})}function E_(e){let t=e.dom.closest(`.marimo-cell`);t&&requestAnimationFrame(()=>{t.scrollIntoView({behavior:`instant`,block:`nearest`,inline:`nearest`})})}function D_(e){return x_(e)?.state.vim!=null}function O_(e){let t=x_(e)?.state.vim;return t?!t.mode&&!t.insertMode&&!t.visualMode||t.mode===`normal`:!1}function k_(e){e&&e.dispatch({selection:{anchor:0,head:e.state.doc.length}})}var A_=new Set([Q.ClassDefinition]);function j_(e,t){requestAnimationFrame(()=>{e.focus(),e.dispatch({selection:{anchor:t,head:t},effects:Kn.scrollIntoView(t,{y:`center`})})}),E_(e)}function M_(e,t){let n=mn(e),r=null;return n.iterate({enter:n=>{if(r!==null)return!1;if(n.name===Q.VariableName&&e.doc.sliceString(n.from,n.to)===t)return r=n.from,!1;if(n.name===Q.Comment||n.name===Q.String)return!1}}),r}function N_(e,t){let n=[],r=e.resolveInner(t,0);for(;r;)ig.has(r.name)&&(n.some(e=>e.type===Q.FunctionDefinition||e.type===Q.LambdaExpression)&&r.name===Q.ClassDefinition||n.push({id:r.from,type:r.name})),r=r.parent;return n.push({id:-1,type:`global`}),n}function P_(e,t,n){e.push({scopeId:t,from:n})}function F_(e,t){if(e.firstChild())do t(e.node);while(e.nextSibling())}function I_(e,t){let{state:n,variableName:r,scopeId:i,declarations:a}=t;switch(e.name){case Q.VariableName:n.doc.sliceString(e.from,e.to)===r&&P_(a,i,e.from);break;case Q.TupleExpression:case Q.ArrayExpression:{let n=e.node.cursor();n.firstChild();do I_(n,t);while(n.nextSibling());break}}}function L_(e,t){let{state:n,variableName:r,scopeId:i,declarations:a}=t,o=e.cursor();o.firstChild();do{if(o.name!==Q.ParamList)continue;let e=o.node.cursor();e.firstChild();do e.name===Q.VariableName&&n.doc.sliceString(e.from,e.to)===r&&P_(a,i,e.from);while(e.nextSibling())}while(o.nextSibling())}function R_(e,t){let n=e.cursor();n.firstChild();let r=!1;do if(n.name===rg.For)r=!0;else if(r&&n.name===rg.In)break;else r&&I_(n,t);while(n.nextSibling())}function z_(e,t){let{state:n,variableName:r,scopeStack:i,declarations:a}=t,o=e.cursor(),s=o.name,c=o.from,l=ig.has(s)?[...i,c]:i,u=l[l.length-1]??-1;switch(s){case Q.FunctionDefinition:case Q.ClassDefinition:{let t=e.cursor();t.firstChild();do if(t.name===Q.VariableName&&n.doc.sliceString(t.from,t.to)===r){P_(a,i[i.length-1]??-1,t.from);break}while(t.nextSibling());s===Q.FunctionDefinition&&L_(e,{state:n,variableName:r,scopeId:c,declarations:a});break}case Q.LambdaExpression:L_(e,{state:n,variableName:r,scopeId:c,declarations:a});break;case Q.ArrayComprehensionExpression:case Q.DictionaryComprehensionExpression:case Q.SetComprehensionExpression:case Q.ComprehensionExpression:case Q.ForStatement:R_(e,{state:n,variableName:r,scopeId:u,declarations:a});break;case Q.AssignStatement:{let t=[],i=e.cursor();i.firstChild();do i.name===Q.AssignOp&&t.push(i.from);while(i.nextSibling());let o=t[t.length-1];if(o===void 0)break;let s=e.cursor();s.firstChild();do s.from<o&&I_(s,{state:n,variableName:r,scopeId:u,declarations:a});while(s.nextSibling());break}case Q.ImportStatement:{let t=e.cursor();t.firstChild();let i=!1,o=null,s=()=>{o?.matches&&P_(a,u,o.from),o=null};do{if(t.name===rg.Import){i=!0;continue}if(i){if(t.name===rg.As){o=null;continue}t.name===Q.VariableName?(s(),o={from:t.from,matches:n.doc.sliceString(t.from,t.to)===r}):t.name===`,`&&s()}}while(t.nextSibling());s();break}case Q.TryStatement:case Q.WithStatement:{let t=e.cursor();t.firstChild();let i=!1;do t.name===rg.As?i=!0:i&&t.name===Q.VariableName&&n.doc.sliceString(t.from,t.to)===r&&(P_(a,u,t.from),i=!1);while(t.nextSibling());break}}F_(o,e=>{z_(e,{state:n,variableName:r,scopeStack:l,declarations:a})})}function B_(e,t,n){let r=mn(e),i=[];z_(r,{state:e,variableName:t,scopeStack:[],declarations:i});let a=Math.max(0,Math.min(n,e.doc.length));for(let e of N_(r,a)){let t=i.filter(t=>t.scopeId===e.id).filter(t=>!A_.has(e.type)||t.from<=a).toSorted((e,t)=>e.from-t.from)[0];if(t)return t.from}return null}function V_(e,t,n){let{state:r}=e,i=n===void 0?M_(r,t):B_(r,t,n);return i!==null&&(j_(e,i),!0)}function H_(e,t){return j_(e,e.state.doc.line(t).from),!0}function U_(e,t){let n=u.get(ie);return(n===`mac`?e.mac??e.key:n===`windows`?e.win??e.key:e.linux??e.key)===t}function W_(e){let{from:t,to:n}=e.selection.main;if(t===n){let{startToken:n,endToken:r}=Eg(e.doc,t);return{position:n,word:e.doc.sliceString(n,r)}}return{position:t,word:e.doc.sliceString(t,n)}}function G_(e,t){if(!t)return null;let n=e[t];return!n||n.declaredBy.length===0?null:n.declaredBy[0]}function K_(e){return e.startsWith(`_`)}function q_(e){let{state:t}=e,{position:n,word:r}=W_(t);return r?(Nr(e),e.dispatch({effects:Un}),X_(e,r,n)):!1}function J_(e,t=u.get(P).getHotkey(`cell.goToDefinition`).key){for(let n of e.state.facet(dn).flat())if(U_(n,t)&&n.run?.(e))return!0;return!1}function Y_(e){return q_(e)?!0:J_(e)}function X_(e,t,n){if(n!==void 0&&V_(e,t,n))return!0;let r=Q_(e,t);return r?V_(r,t):!1}function Z_(e,t){let n=$_(e);return n?H_(n,t):!1}function Q_(e,t){if(K_(t))return e;let n=G_(u.get(Ah),t);return n?$_(n):null}function $_(e){return fN(e)??null}var ev=o(null);function tv(e){let t=u.get(ev);if(e===null){u.set(ev,null);return}(t?.cellId!==e.cellId||t.line!==e.line)&&u.set(ev,{...e,startedAtMs:Date.now()})}var nv=o(new Map),rv=new Set;function iv(e){return o(t=>{let n=t(ev);return n?.cellId===e?n.line:null})}function av(e){return o(t=>{let n=t(ev);return n?.cellId===e?{line:n.line,startedAtMs:n.startedAtMs}:null})}function ov(e){return o(t=>t(nv).get(e)??rv)}function sv(e){let t={};for(let[n,r]of e)r.size>0&&(t[n]=[...r].toSorted((e,t)=>e-t));Br().sendSetBreakpoints({breakpoints:t}).catch(e=>{L.debug(`Failed to sync breakpoints to kernel`,{error:e})})}function cv(e){let t=u.get(nv);if(!t.has(e))return;let n=new Map(t);n.delete(e),u.set(nv,n),sv(n)}function lv(){let e=u.get(nv);e.size>0&&sv(e)}function uv(e,t){let n=u.get(nv),r=new Map(n),i=new Set(r.get(e)??[]);i.has(t)?i.delete(t):i.add(t),i.size>0?r.set(e,i):r.delete(e),u.set(nv,r),sv(r)}function dv(e,t){if(t==null||t<1||t>e.doc.lines)return Nn.none;let n=new An;try{let r=e.doc.line(t);n.add(r.from,r.from,Nn.line({class:`cm-debugger-current-line`}))}catch(e){L.debug(`Invalid debugger line`,{error:e})}return n.finish()}var fv=class{unsubscribe;decorations;constructor(e,t){this.decorations=dv(e.state,t.get()),this.unsubscribe=t.sub(t=>{this.decorations=dv(e.state,t),e.dispatch({userEvent:`marimo.debugger-line-update`})})}update(e){this.decorations=this.decorations.map(e.changes)}destroy(){this.unsubscribe()}};function pv(e){return[Yn.define(t=>new fv(t,e),{decorations:e=>e.decorations}),Kn.theme({".cm-debugger-current-line":{backgroundColor:`color-mix(in srgb, var(--amber-4) 50%, transparent)`}})]}var mv=new class extends Fn{toDOM(){let e=document.createElement(`div`);return e.className=`cm-breakpoint-marker`,e}},hv=xn.define(),gv=on.define({create:()=>new Set,update(e,t){for(let e of t.effects)if(e.is(hv))return e.value;return e}});function _v(e){let t=e.field(gv);if(t.size===0)return jn.empty;let n=new An;for(let r of[...t].toSorted((e,t)=>e-t))if(r>=1&&r<=e.doc.lines){let t=e.doc.line(r);n.add(t.from,t.from,mv)}return n.finish()}var vv=class{unsubscribe;constructor(e,t){let n=t=>{e.dispatch({effects:hv.of(t)})};t.get().size>0&&queueMicrotask(()=>n(t.get())),this.unsubscribe=t.sub(n)}destroy(){this.unsubscribe()}};function yv(e,t){return[gv,Yn.define(e=>new vv(e,t)),Zn({class:`cm-breakpoint-gutter`,markers:e=>_v(e.state),initialSpacer:()=>mv,domEventHandlers:{mousedown:(t,n)=>{let r=t.state.doc.lineAt(n.from).number;return uv(e,r),!0}}}),Kn.theme({".cm-breakpoint-gutter":{width:`14px`,cursor:`pointer`},".cm-breakpoint-marker":{width:`8px`,height:`8px`,borderRadius:`50%`,backgroundColor:`var(--red-9)`,margin:`4px auto`}})]}var bv=class e{ms;static fromMilliseconds(t){return t==null?null:new e(t)}static fromSeconds(t){return t==null?null:new e(t*1e3)}static now(){return new e(Date.now())}constructor(e){this.ms=e}toMilliseconds(){return this.ms}toSeconds(){return this.ms/1e3}};function xv(e){if(e===null)return``;let t=e,n=t/1e3;return n>=60?`${Math.floor(n/60)}m${Math.floor(n%60)}s`:n>=1?`${n.toFixed(2).toString()}s`:`${t.toFixed(0).toString()}ms`}var Sv=500,Cv=250,wv=class e extends In{static intervals=new WeakMap;startedAtMs;constructor(e){super(),this.startedAtMs=e}eq(e){return e.startedAtMs===this.startedAtMs}toDOM(){let t=document.createElement(`span`);t.className=`cm-line-timer`,t.setAttribute(`aria-hidden`,`true`);let n=()=>{let e=Date.now()-this.startedAtMs;t.textContent=e>=Sv?xv(e):``};return n(),e.intervals.set(t,window.setInterval(n,Cv)),t}destroy(t){let n=e.intervals.get(t);n!==void 0&&(window.clearInterval(n),e.intervals.delete(t))}ignoreEvent(){return!0}};function Tv(e,t){if(t===null||t.line<1||t.line>e.doc.lines)return Nn.none;let n=new An;try{let r=e.doc.line(t.line);n.add(r.from,r.from,Nn.line({class:`cm-timing-current-line`})),n.add(r.to,r.to,Nn.widget({widget:new wv(t.startedAtMs),side:1}))}catch(e){L.debug(`Invalid timing line`,{error:e})}return n.finish()}var Ev=class{unsubscribe;decorations;constructor(e,t){this.decorations=Tv(e.state,t.get()),this.unsubscribe=t.sub(t=>{this.decorations=Tv(e.state,t),e.dispatch({userEvent:`marimo.timing-line-update`})})}update(e){this.decorations=this.decorations.map(e.changes)}destroy(){this.unsubscribe()}};function Dv(e){return[Yn.define(t=>new Ev(t,e),{decorations:e=>e.decorations}),Kn.theme({".cm-timing-current-line":{backgroundColor:`color-mix(in srgb, var(--grass-4) 50%, transparent)`},".cm-line-timer":{color:`var(--grass-11)`,fontSize:`0.85em`,marginLeft:`1.5ch`,pointerEvents:`none`}})]}function Ov(e,t){if(!t?.length)return Nn.none;let n=new An,r=e.facet(Af),i=t.filter(e=>e.kind===`cell`&&e.cellId===r).toSorted((e,t)=>e.lineNumber-t.lineNumber);for(let t of i)try{let r=e.doc.line(t.lineNumber),i=Nn.line({class:`cm-error-line`});n.add(r.from,r.from,i)}catch(e){L.debug(`Invalid line number in error decoration`,{error:e})}return n.finish()}function kv(e,t){if(!t?.length)return;let n=e.state.facet(Af),r=t.filter(e=>e.kind===`cell`&&e.cellId===n);if(r.length===0)return;let i=Bn(e.state),a=[];for(let t of r)try{let n=e.state.doc.line(t.lineNumber);i.between(n.from,n.to,(e,t)=>{a.push(Dn.of({from:e,to:t}))})}catch(e){L.debug(`Invalid line numbers`,{error:e})}a.length>0&&e.dispatch({effects:a})}var Av=class{unsubscribe;decorations;constructor(e,t){let n=t.get();this.decorations=Ov(e.state,n),kv(e,n),this.unsubscribe=t.sub(t=>{let n=this.decorations.size;this.decorations=Ov(e.state,t),kv(e,t),n!==this.decorations.size&&e.dispatch({userEvent:`marimo.error-decoration-update`})})}update(e){this.decorations=this.decorations.map(e.changes)}destroy(){this.unsubscribe()}};function jv(e){return Yn.define(t=>new Av(t,e),{decorations:e=>e.decorations})}function Mv(e){return[jv(e),Kn.theme({".cm-error-line":{backgroundColor:`color-mix(in srgb, var(--red-4) 40%, transparent)`},"&.cm-focused .cm-error-line.cm-activeLine":{backgroundColor:`color-mix(in srgb, var(--red-5) 40%, transparent)`}})]}function Nv({cellId:e,hotkeys:t}){let n=[];return n.push(...se({key:t.getHotkey(`cell.run`).key,preventDefault:!0,stopPropagation:!0,run:e=>(e.state.facet(kf).onRun(),!0)}),{key:t.getHotkey(`cell.runAndNewBelow`).key,preventDefault:!0,stopPropagation:!0,run:t=>{let n=t.state.facet(kf);return n.onRun(),e===`__scratch__`||(t.contentDOM.blur(),n.moveToNextCell({cellId:e,before:!1}),!0)}},...se({key:t.getHotkey(`cell.runAndNewAbove`).key,preventDefault:!0,stopPropagation:!0,run:t=>{let n=t.state.facet(kf);return n.onRun(),e===`__scratch__`||(t.contentDOM.blur(),n.moveToNextCell({cellId:e,before:!0}),!0)}}),{key:t.getHotkey(`cell.aiCompletion`).key,preventDefault:!0,stopPropagation:!0,run:e=>(e.state.facet(kf).aiCellCompletion()&&e.contentDOM.focus(),!0)}),e!==`__scratch__`&&n.push({key:t.getHotkey(`cell.goToDefinition`).key,run:e=>q_(e)},{key:t.getHotkey(`cell.delete`).key,preventDefault:!0,stopPropagation:!0,run:e=>(e.state.doc.length===0&&e.state.facet(kf).deleteCell(),!0)},{key:t.getHotkey(`cell.moveUp`).key,preventDefault:!0,stopPropagation:!0,run:t=>(t.state.facet(kf).moveCell({cellId:e,before:!0}),!0)},{key:t.getHotkey(`cell.moveDown`).key,preventDefault:!0,stopPropagation:!0,run:t=>(t.state.facet(kf).moveCell({cellId:e,before:!1}),!0)},{key:t.getHotkey(`cell.moveLeft`).key,preventDefault:!0,stopPropagation:!0,run:t=>(t.state.facet(kf).moveCell({cellId:e,before:!0,direction:`left`}),!0)},{key:t.getHotkey(`cell.moveRight`).key,preventDefault:!0,stopPropagation:!0,run:t=>(t.state.facet(kf).moveCell({cellId:e,before:!1,direction:`right`}),!0)},{key:`ArrowUp`,run:t=>jr(t.state)?!1:S_(t)?(t.state.facet(kf).moveToNextCell({cellId:e,before:!0,noCreate:!0}),!0):!1},{key:`ArrowDown`,run:t=>jr(t.state)?!1:C_(t)?(t.state.facet(kf).moveToNextCell({cellId:e,before:!1,noCreate:!0}),!0):!1},{key:t.getHotkey(`cell.focusDown`).key,preventDefault:!0,stopPropagation:!0,run:t=>(t.state.facet(kf).moveToNextCell({cellId:e,before:!1,noCreate:!0}),!0)},{key:t.getHotkey(`cell.focusUp`).key,preventDefault:!0,stopPropagation:!0,run:t=>(t.state.facet(kf).moveToNextCell({cellId:e,before:!0,noCreate:!0}),!0)},{key:t.getHotkey(`cell.sendToBottom`).key,preventDefault:!0,stopPropagation:!0,run:t=>(t.state.facet(kf).sendToBottom({cellId:e}),!0)},{key:t.getHotkey(`cell.sendToTop`).key,preventDefault:!0,stopPropagation:!0,run:t=>(t.state.facet(kf).sendToTop({cellId:e}),!0)},{key:t.getHotkey(`cell.createAbove`).key,preventDefault:!0,stopPropagation:!0,run:t=>(t.contentDOM.blur(),t.state.facet(kf).createNewCell({cellId:e,before:!0}),!0)},{key:t.getHotkey(`cell.createBelow`).key,preventDefault:!0,stopPropagation:!0,run:t=>(t.contentDOM.blur(),t.state.facet(kf).createNewCell({cellId:e,before:!1}),!0)},{key:t.getHotkey(`cell.hideCode`).key,preventDefault:!0,stopPropagation:!0,run:t=>{let n=t.state.facet(kf).toggleHideCode();return Nr(t),n?(t.contentDOM.blur(),document.getElementById(Fi.create(e))?.focus()):t.contentDOM.focus(),!0}},{key:t.getHotkey(`cell.splitCell`).key,preventDefault:!0,stopPropagation:!0,run:t=>{let n=t.state.facet(kf);return n.splitCell({cellId:e}),n.moveToNextCell&&requestAnimationFrame(()=>{t.contentDOM.blur(),n.moveToNextCell({cellId:e,before:!1})}),!0}}),[gn.high(dn.of(n))]}function Pv(e){return[Kn.updateListener.of(e=>{if(e.docChanged){let t=e.transactions.some(e=>e.effects.some(e=>e.is(lm))),n=AA(e.view),r=e.view.state.facet(kf),i=e.view.state.facet(Af);r.updateCellCode({cellId:i,code:n,formattingChange:t}),u.get(sh).has(i)&&u.set(ch)}}),wh(e)]}var Fv=[`input`,`delete`,`undo`,`redo`];function Iv({docChanged:e,transactions:t,predicate:n=()=>!0,hasFocus:r=!1}){return!e||!n()||t.some(e=>e.effects.some(e=>e.is(lm)))?!1:t.some(e=>e.annotation(ph)===void 0?Fv.some(t=>e.isUserEvent(t))||r:!1)}function Lv({predicate:e}){return Kn.updateListener.of(t=>{Iv({docChanged:t.docChanged,transactions:t.transactions,predicate:e,hasFocus:t.view.hasFocus})&&t.view.state.facet(kf).onRun()})}function Rv({cellId:e,hotkeys:t,cellActions:n}){let r=_h(`debugger`),i=_h(`line_timing`);return[kf.of(n),Af.of(e),Nv({cellId:e,hotkeys:t}),Pv(t),Mv(yh(hN(e),u)),r?yv(e,yh(ov(e),u)):[],i?Dv(yh(av(e),u)):r?pv(yh(iv(e),u)):[]]}var zv=xn.define(),Bv=20;function Vv(e){let{state:t,anchor:n,head:r}=e;if(r<n)return!1;let i=t.doc.lineAt(r).number,a=t.doc.lineAt(n).number,o=Math.max(a,i-Bv+1),s=Math.max(n,t.doc.line(o).from),c=s>n,l=+!!c,u=t.doc.iterRange(s,r);for(;;){let{value:e,done:t}=u.next();if(t)break;for(let t of e)if(t===`(`)l++;else if(t===`)`&&(l--,c?l<=0:l<0))return!1}return!0}function Hv(e){return{...e,create:t=>{let{dom:n,...r}=e.create(t),i=document.createElement(`div`);return i.classList.add(`mo-cm-tooltip`),i.append(n),{...r,dom:i}}}}var Uv=on.define({create:()=>null,update(e,t){for(let e of t.effects)if(e.is(zv))return e.value;if(!e||t.selection&&!t.docChanged)return null;if(t.docChanged){let n=t.changes.mapPos(e.pos);return Vv({state:t.state,anchor:n,head:t.state.selection.main.head})?{...e,pos:n}:null}return e},provide:e=>fn.from(e)});function Wv(e){return e.state.field(Uv,!1)?(e.dispatch({effects:zv.of(null)}),!0):!1}var Gv=async e=>{let t=e.state.doc.sliceString(0,e.pos),n=document.activeElement,r=null;if(n!==null){let e=Fi.findElement(n);e!==null&&(r=Fi.parse(e.id))}if(r===null)return L.error(`Failed to find active cell.`),null;let i=await bg.request({document:t,cellId:r});if(!i)return e.view?.dispatch({effects:zv.of(null)}),null;let a=Sg.asHoverTooltip({position:e.pos,message:i,limitToType:`tooltip`});return a&&u.set(ng,{documentation:a.html??null}),e.view?.dispatch({effects:zv.of(a?Hv(a):null)}),a?null:Sg.asCompletionResult(e.pos,i)};function Kv(e){return t=>e.predicate(t.state)?e.completion(t):null}var qv=async e=>{let t=e.matchBefore(/:\w*$/);if(!e.explicit&&!t)return null;let n=await Jv();return{from:t?.from??e.pos,options:n,validFor:/^[\w:]*$/}},Jv=Er(async()=>{let e=await fetch(`https://unpkg.com/emojilib@3.0.11/dist/emoji-en-US.json`).then(e=>{if(!e.ok)throw Error(`Failed to fetch emoji list`);return e.json()}).catch(()=>({}));return Object.entries(e).map(([e,t])=>({shortcode:t[0],label:t.map(e=>`:${e}`).join(` `),emoji:e,displayLabel:`${e} ${t[0].replaceAll(`_`,` `)}`,apply:e,type:`emoji`}))}),Yv=async e=>{let t=e.matchBefore(/::[\w-:]*$/);if(!e.explicit&&!t)return null;let n=await Xv();return{from:t?.from??e.pos,options:n,validFor:/^[\w-:]*$/}},Xv=Er(async()=>{let e=await fetch(`https://unpkg.com/lucide-static@0.452.0/tags.json`).then(e=>{if(!e.ok)throw Error(`Failed to fetch Lucide icon list`);return e.json()}).catch(()=>({})),t=e=>`https://cdn.jsdelivr.net/npm/lucide-static@0.452.0/icons/${e}.svg`;return Object.entries(e).map(([e,n])=>({label:`::${e}`,displayLabel:e,type:`lucide-icon`,boost:10,apply:`::lucide:${e}::`,detail:n.join(`, `),info:()=>{let n=document.createElement(`img`);return n.src=t(e),n.style.width=`24px`,n.style.height=`24px`,n}}))}),Zv=e=>{let t=e.matchBefore(/\\\w*$/);return!e.explicit&&!t?null:{from:t?.from??e.pos,options:Qv(),validFor:/^[\w\\]*$/}},Qv=Er(()=>[[`alpha`,`α`,`Greek small letter alpha`],[`beta`,`β`,`Greek small letter beta`],[`gamma`,`γ`,`Greek small letter gamma`],[`delta`,`δ`,`Greek small letter delta`],[`epsilon`,`ε`,`Greek small letter epsilon`],[`zeta`,`ζ`,`Greek small letter zeta`],[`eta`,`η`,`Greek small letter eta`],[`theta`,`θ`,`Greek small letter theta`],[`iota`,`ι`,`Greek small letter iota`],[`kappa`,`κ`,`Greek small letter kappa`],[`lambda`,`λ`,`Greek small letter lambda`],[`mu`,`μ`,`Greek small letter mu`],[`nu`,`ν`,`Greek small letter nu`],[`xi`,`ξ`,`Greek small letter xi`],[`omicron`,`ο`,`Greek small letter omicron`],[`pi`,`π`,`Greek small letter pi`],[`rho`,`ρ`,`Greek small letter rho`],[`sigma`,`σ`,`Greek small letter sigma`],[`tau`,`τ`,`Greek small letter tau`],[`upsilon`,`υ`,`Greek small letter upsilon`],[`phi`,`φ`,`Greek small letter phi`],[`chi`,`χ`,`Greek small letter chi`],[`psi`,`ψ`,`Greek small letter psi`],[`omega`,`ω`,`Greek small letter omega`],[`Gamma`,`Γ`,`Greek capital letter gamma`],[`Delta`,`Δ`,`Greek capital letter delta`],[`Theta`,`Θ`,`Greek capital letter theta`],[`Lambda`,`Λ`,`Greek capital letter lambda`],[`Xi`,`Ξ`,`Greek capital letter xi`],[`Pi`,`Π`,`Greek capital letter pi`],[`Sigma`,`Σ`,`Greek capital letter sigma`],[`Phi`,`Φ`,`Greek capital letter phi`],[`Psi`,`Ψ`,`Greek capital letter psi`],[`Omega`,`Ω`,`Greek capital letter omega`],[`pm`,`±`,`Plus-minus sign`],[`mp`,`∓`,`Minus-plus sign`],[`times`,`×`,`Multiplication sign`],[`div`,`÷`,`Division sign`],[`cdot`,`⋅`,`Dot operator`],[`ast`,`∗`,`Asterisk operator`],[`star`,`⋆`,`Star operator`],[`circ`,`∘`,`Ring operator`],[`bullet`,`•`,`Bullet`],[`cap`,`∩`,`Intersection`],[`cup`,`∪`,`Union`],[`uplus`,`⊎`,`Multiset union`],[`sqcap`,`⊓`,`Square cap`],[`sqcup`,`⊔`,`Square cup`],[`vee`,`∨`,`Logical or`],[`wedge`,`∧`,`Logical and`],[`setminus`,`∖`,`Set minus`],[`oplus`,`⊕`,`Circled plus`],[`ominus`,`⊖`,`Circled minus`],[`otimes`,`⊗`,`Circled times`],[`oslash`,`⊘`,`Circled division slash`],[`odot`,`⊙`,`Circled dot operator`],[`leq`,`≤`,`Less than or equal to`],[`geq`,`≥`,`Greater than or equal to`],[`equiv`,`≡`,`Identical to`],[`prec`,`≺`,`Precedes`],[`succ`,`≻`,`Succeeds`],[`sim`,`∼`,`Tilde operator`],[`perp`,`⊥`,`Up tack`],[`mid`,`∣`,`Divides`],[`parallel`,`∥`,`Parallel to`],[`subset`,`⊂`,`Subset of`],[`supset`,`⊃`,`Superset of`],[`subseteq`,`⊆`,`Subset of or equal to`],[`supseteq`,`⊇`,`Superset of or equal to`],[`cong`,`≅`,`Approximately equal to`],[`approx`,`≈`,`Almost equal to`],[`neq`,`≠`,`Not equal to`],[`ne`,`≠`,`Not equal to`],[`propto`,`∝`,`Proportional to`],[`leftarrow`,`←`,`Leftward arrow`],[`rightarrow`,`→`,`Rightward arrow`],[`Leftarrow`,`⇐`,`Leftward double arrow`],[`Rightarrow`,`⇒`,`Rightward double arrow`],[`leftrightarrow`,`↔`,`Left right arrow`],[`Leftrightarrow`,`⇔`,`Left right double arrow`],[`uparrow`,`↑`,`Upward arrow`],[`downarrow`,`↓`,`Downward arrow`],[`Uparrow`,`⇑`,`Upward double arrow`],[`Downarrow`,`⇓`,`Downward double arrow`],[`infty`,`∞`,`Infinity`],[`nabla`,`∇`,`Nabla`],[`partial`,`∂`,`Partial differential`],[`forall`,`∀`,`For all`],[`exists`,`∃`,`There exists`],[`nexists`,`∄`,`There does not exist`],[`emptyset`,`∅`,`Empty set`],[`in`,`∈`,`Element of`],[`notin`,`∉`,`Not an element of`],[`sum`,`∑`,`N-ary summation`],[`prod`,`∏`,`N-ary product`],[`int`,`∫`,`Integral`],[`oint`,`∮`,`Contour integral`],[`sqrt`,`√`,`Square root`],[`hbar`,`ℏ`,`Planck constant over 2pi`],[`ldots`,`…`,`Horizontal ellipsis`],[`cdots`,`⋯`,`Midline horizontal ellipsis`],[`vdots`,`⋮`,`Vertical ellipsis`],[`ddots`,`⋱`,`Down right diagonal ellipsis`]].map(([e,t,n])=>({label:`\\${e} ${n}`,displayLabel:e,type:`latex-symbol`,boost:10,apply:`\\${e}`,info:()=>{let e=document.createElement(`div`);return e.textContent=`${t} ${n}`,e},detail:t}))),$v=[qv,Yv,Zv],ey=100;function ty(e){return!e.state.selection.main.empty}function ny({view:e,selection:t,markup:n}){let r=[],i=!0;for(let r=t.from;r<=t.to;r++)if(!e.state.doc.lineAt(r).text.startsWith(n)){i=!1;break}for(let a=t.from;a<=t.to;){let t=e.state.doc.lineAt(a),o=t.text.startsWith(n);i?r.push({from:t.from,to:t.from+n.length,insert:Ln.of([``])}):(o&&r.push({from:t.from,to:t.from+n.length,insert:Ln.of([``])}),r.push({from:t.from,insert:Ln.of([n])})),a=t.to+1}return r}function ry({view:e,range:t,markupAfter:n,markupBefore:r}){if(t.empty){let n=e.state.wordAt(t.head);n&&(t=n)}let i=e.state.sliceDoc(t.from-r.length,t.from)===r,a=e.state.sliceDoc(t.to,t.to+n.length)===n,o=[];o.push(i?{from:t.from-r.length,to:t.from,insert:Ln.of([``])}:{from:t.from,insert:Ln.of(r.split(`
|
|
84
|
+
`||e==`\r`)e=`\xA0`;else if(e==` `){e=`\xA0`;var l=t.coordsAtPos(a+1,-1);l&&(f=l.left-(l.left-n.left)/parseInt(d.tabSize))}else/[\uD800-\uDBFF]/.test(e)&&a<t.state.doc.length-1&&(e+=t.state.sliceDoc(a+1,a+2));let m=n.bottom-n.top;return new i_((f-o.left)/t.scaleX,(n.top-o.top+m*(1-s))/t.scaleY,m*s/t.scaleY,d.fontFamily,d.fontSize,d.fontWeight,d.color,r?`cm-fat-cursor cm-cursor-primary`:`cm-fat-cursor cm-cursor-secondary`,e,s!=1)}return null}var u_=typeof navigator<`u`&&/linux/i.test(navigator.platform)&&/ Gecko\/\d+/.exec(navigator.userAgent),d_=Ag(Hg),f_=Kn.baseTheme({".cm-vimMode .cm-cursorLayer:not(.cm-vimCursorLayer)":{display:`none`},".cm-vim-panel":{padding:`0px 10px`,fontFamily:`monospace`,minHeight:`1.3em`,display:`flex`},".cm-vim-panel input":{border:`none`,outline:`none`,backgroundColor:`inherit`},"&light .cm-searchMatch":{backgroundColor:`#ffff0054`},"&dark .cm-searchMatch":{backgroundColor:`#00ffff8a`}}),p_=Yn.fromClass(class{constructor(e){this.status=``,this.query=null,this.decorations=Nn.none,this.waitForCopy=!1,this.lastKeydown=``,this.useNextTextInput=!1,this.compositionText=``,this.view=e;let t=this.cm=new Hg(e);d_.enterVimMode(this.cm),this.view.cm=this.cm,this.cm.state.vimPlugin=this,this.blockCursor=new a_(e,t),this.updateClass(),this.cm.on(`vim-command-done`,()=>{t.state.vim&&(t.state.vim.status=``),this.blockCursor.scheduleRedraw(),this.updateStatus()}),this.cm.on(`vim-mode-change`,e=>{t.state.vim&&(t.state.vim.mode=e.mode,e.subMode&&(t.state.vim.mode+=e.subMode===`linewise`?` line`:` block`),t.state.vim.status=``,this.blockCursor.scheduleRedraw(),this.updateClass(),this.updateStatus())}),this.cm.on(`dialog`,()=>{this.cm.state.statusbar?this.updateStatus():e.dispatch({effects:g_.of(!!this.cm.state.dialog)})}),this.dom=document.createElement(`span`),this.spacer=document.createElement(`span`),this.spacer.style.flex=`1`,this.statusButton=document.createElement(`span`),this.statusButton.onclick=e=>{d_.handleKey(this.cm,`<Esc>`,`user`),this.cm.focus()},this.statusButton.style.cssText=`cursor: pointer`}update(e){if((e.viewportChanged||e.docChanged)&&this.query&&this.highlight(this.query),e.docChanged&&this.cm.onChange(e),e.selectionSet&&this.cm.onSelectionChange(),e.viewportChanged,this.cm.curOp&&!this.cm.curOp.isVimOp&&this.cm.onBeforeEndOperation(),e.transactions){for(let t of e.transactions)for(let e of t.effects)if(e.is(mr)){if(!e.value?.forVim)this.highlight(null);else{let t=e.value.create();this.highlight(t)}}}this.blockCursor.update(e)}updateClass(){let e=this.cm.state;!e.vim||e.vim.insertMode&&!e.overwrite?this.view.scrollDOM.classList.remove(`cm-vimMode`):this.view.scrollDOM.classList.add(`cm-vimMode`)}updateStatus(){let e=this.cm.state.statusbar,t=this.cm.state.vim;if(!e||!t)return;let n=this.cm.state.dialog;if(n)n.parentElement!=e&&(e.textContent=``,e.appendChild(n));else{e.textContent=``;var r=(t.mode||`normal`).toUpperCase();t.insertModeReturn&&(r+=`(C-O)`),this.statusButton.textContent=`--${r}--`,e.appendChild(this.statusButton),e.appendChild(this.spacer)}this.dom.textContent=t.status,e.appendChild(this.dom)}destroy(){d_.leaveVimMode(this.cm),this.updateClass(),this.blockCursor.destroy(),delete this.view.cm}highlight(e){if(this.query=e,!e)return this.decorations=Nn.none;let{view:t}=this,n=new An;for(let r=0,i=t.visibleRanges,a=i.length;r<a;r++){let{from:o,to:s}=i[r];for(;r<a-1&&s>i[r+1].from-500;)s=i[++r].to;e.highlight(t.state,o,s,(e,t)=>{n.add(e,t,h_)})}return this.decorations=n.finish()}handleKey(e,t){let n=this.cm,r=n.state.vim;if(!r)return;let i=d_.vimKeyFromEvent(e,r);if(Hg.signal(this.cm,`inputEvent`,{type:`handleKey`,key:i}),!i)return;if(i==`<Esc>`&&!r.insertMode&&!r.visualMode&&this.query){let e=r.searchState_;e&&(n.removeOverlay(e.getOverlay()),e.setOverlay(null))}if(i===`<C-c>`&&!Hg.isMac&&n.somethingSelected())return this.waitForCopy=!0,!0;r.status=(r.status||``)+i;let a=d_.multiSelectHandleKey(n,i,`user`);return r=d_.maybeInitVimState_(n),!a&&r.insertMode&&n.state.overwrite&&(e.key&&e.key.length==1&&!/\n/.test(e.key)?(a=!0,n.overWriteSelection(e.key)):e.key==`Backspace`&&(a=!0,Hg.commands.cursorCharLeft(n))),a&&(Hg.signal(this.cm,`vim-keypress`,i),e.preventDefault(),e.stopPropagation(),this.blockCursor.scheduleRedraw()),this.updateStatus(),!!a}},{eventHandlers:{copy:function(e,t){this.waitForCopy&&(this.waitForCopy=!1,Promise.resolve().then(()=>{var e=this.cm,t=e.state.vim;t&&(t.insertMode?e.setSelection(e.getCursor(),e.getCursor()):e.operation(()=>{e.curOp&&(e.curOp.isVimOp=!0),d_.handleKey(e,`<Esc>`,`user`)}))}))},compositionstart:function(e,t){this.useNextTextInput=!0,Hg.signal(this.cm,`inputEvent`,e)},compositionupdate:function(e,t){Hg.signal(this.cm,`inputEvent`,e)},compositionend:function(e,t){Hg.signal(this.cm,`inputEvent`,e)},keypress:function(e,t){Hg.signal(this.cm,`inputEvent`,e),this.lastKeydown==`Dead`&&this.handleKey(e,t)},keydown:function(e,t){Hg.signal(this.cm,`inputEvent`,e),this.lastKeydown=e.key,this.lastKeydown==`Unidentified`||this.lastKeydown==`Process`||this.lastKeydown==`Dead`?this.useNextTextInput=!0:(this.useNextTextInput=!1,this.handleKey(e,t))}},provide:()=>[Kn.inputHandler.of((e,t,n,r)=>{var i=x_(e);if(!i)return!1;var a=i.state?.vim,o=i.state.vimPlugin;if(a&&!a.insertMode&&!i.curOp?.isVimOp){if(r===`\0\0`)return!0;if(Hg.signal(i,`inputEvent`,{type:`text`,text:r,from:t,to:n}),r.length==1&&o.useNextTextInput){if(a.expectLiteralNext&&e.composing)return o.compositionText=r,!1;if(o.compositionText){var s=o.compositionText;o.compositionText=``;var c=e.state.selection.main.head;if(s===e.state.sliceDoc(c-s.length,c)){var l=i.getCursor();i.replaceRange(``,i.posFromIndex(c-s.length),l)}}return o.handleKey({key:r,preventDefault:()=>{},stopPropagation:()=>{}}),m_(e),!0}}return!1})],decorations:e=>e.decorations});function m_(e){var t=e.scrollDOM.parentElement;if(t){if(u_){e.contentDOM.textContent=`\0\0`,e.contentDOM.dispatchEvent(new CustomEvent(`compositionend`));return}var n=e.scrollDOM.nextSibling,r=window.getSelection(),i=r&&{anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset};e.scrollDOM.remove(),t.insertBefore(e.scrollDOM,n);try{i&&r&&(r.setPosition(i.anchorNode,i.anchorOffset),i.focusNode&&r.extend(i.focusNode,i.focusOffset))}catch(e){console.error(e)}e.focus(),e.contentDOM.dispatchEvent(new CustomEvent(`compositionend`))}}var h_=Nn.mark({class:`cm-searchMatch`}),g_=xn.define(),__=on.define({create:()=>!1,update(e,t){for(let n of t.effects)n.is(g_)&&(e=n.value);return e},provide:e=>bn.from(e,e=>e?v_:null)});function v_(e){let t=document.createElement(`div`);t.className=`cm-vim-panel`;let n=e.cm;return n.state.dialog&&t.appendChild(n.state.dialog),{top:!1,dom:t}}function y_(e){let t=document.createElement(`div`);t.className=`cm-vim-panel`;let n=e.cm;return n.state.statusbar=t,n.state.vimPlugin.updateStatus(),{dom:t}}function b_(e={}){return[f_,p_,s_,e.status?bn.of(y_):__]}function x_(e){return e.cm||null}function S_(e){let t=e.state.selection.main;return t.from===0&&t.to===0}function C_(e,t=!1){let n=e.state.selection.main,r=e.state.doc.length;return t&&n.from===r-1&&n.to===r-1?!0:n.from===r&&n.to===r}function w_(e){e&&e.dispatch({selection:{anchor:e.state.doc.length,head:e.state.doc.length}})}function T_(e){requestAnimationFrame(()=>{let t=e.current?.view;t&&(t.focus(),w_(t))})}function E_(e){let t=e.dom.closest(`.marimo-cell`);t&&requestAnimationFrame(()=>{t.scrollIntoView({behavior:`instant`,block:`nearest`,inline:`nearest`})})}function D_(e){return x_(e)?.state.vim!=null}function O_(e){let t=x_(e)?.state.vim;return t?!t.mode&&!t.insertMode&&!t.visualMode||t.mode===`normal`:!1}function k_(e){e&&e.dispatch({selection:{anchor:0,head:e.state.doc.length}})}var A_=new Set([Q.ClassDefinition]);function j_(e,t){requestAnimationFrame(()=>{e.focus(),e.dispatch({selection:{anchor:t,head:t},effects:Kn.scrollIntoView(t,{y:`center`})})}),E_(e)}function M_(e,t){let n=mn(e),r=null;return n.iterate({enter:n=>{if(r!==null)return!1;if(n.name===Q.VariableName&&e.doc.sliceString(n.from,n.to)===t)return r=n.from,!1;if(n.name===Q.Comment||n.name===Q.String)return!1}}),r}function N_(e,t){let n=[],r=e.resolveInner(t,0);for(;r;)ig.has(r.name)&&(n.some(e=>e.type===Q.FunctionDefinition||e.type===Q.LambdaExpression)&&r.name===Q.ClassDefinition||n.push({id:r.from,type:r.name})),r=r.parent;return n.push({id:-1,type:`global`}),n}function P_(e,t,n){e.push({scopeId:t,from:n})}function F_(e,t){if(e.firstChild())do t(e.node);while(e.nextSibling())}function I_(e,t){let{state:n,variableName:r,scopeId:i,declarations:a}=t;switch(e.name){case Q.VariableName:n.doc.sliceString(e.from,e.to)===r&&P_(a,i,e.from);break;case Q.TupleExpression:case Q.ArrayExpression:{let n=e.node.cursor();n.firstChild();do I_(n,t);while(n.nextSibling());break}}}function L_(e,t){let{state:n,variableName:r,scopeId:i,declarations:a}=t,o=e.cursor();o.firstChild();do{if(o.name!==Q.ParamList)continue;let e=o.node.cursor();e.firstChild();do e.name===Q.VariableName&&n.doc.sliceString(e.from,e.to)===r&&P_(a,i,e.from);while(e.nextSibling())}while(o.nextSibling())}function R_(e,t){let n=e.cursor();n.firstChild();let r=!1;do if(n.name===rg.For)r=!0;else if(r&&n.name===rg.In)break;else r&&I_(n,t);while(n.nextSibling())}function z_(e,t){let{state:n,variableName:r,scopeStack:i,declarations:a}=t,o=e.cursor(),s=o.name,c=o.from,l=ig.has(s)?[...i,c]:i,u=l[l.length-1]??-1;switch(s){case Q.FunctionDefinition:case Q.ClassDefinition:{let t=e.cursor();t.firstChild();do if(t.name===Q.VariableName&&n.doc.sliceString(t.from,t.to)===r){P_(a,i[i.length-1]??-1,t.from);break}while(t.nextSibling());s===Q.FunctionDefinition&&L_(e,{state:n,variableName:r,scopeId:c,declarations:a});break}case Q.LambdaExpression:L_(e,{state:n,variableName:r,scopeId:c,declarations:a});break;case Q.ArrayComprehensionExpression:case Q.DictionaryComprehensionExpression:case Q.SetComprehensionExpression:case Q.ComprehensionExpression:case Q.ForStatement:R_(e,{state:n,variableName:r,scopeId:u,declarations:a});break;case Q.AssignStatement:{let t=[],i=e.cursor();i.firstChild();do i.name===Q.AssignOp&&t.push(i.from);while(i.nextSibling());let o=t[t.length-1];if(o===void 0)break;let s=e.cursor();s.firstChild();do s.from<o&&I_(s,{state:n,variableName:r,scopeId:u,declarations:a});while(s.nextSibling());break}case Q.ImportStatement:{let t=e.cursor();t.firstChild();let i=!1,o=null,s=()=>{o?.matches&&P_(a,u,o.from),o=null};do{if(t.name===rg.Import){i=!0;continue}if(i){if(t.name===rg.As){o=null;continue}t.name===Q.VariableName?(s(),o={from:t.from,matches:n.doc.sliceString(t.from,t.to)===r}):t.name===`,`&&s()}}while(t.nextSibling());s();break}case Q.TryStatement:case Q.WithStatement:{let t=e.cursor();t.firstChild();let i=!1;do t.name===rg.As?i=!0:i&&t.name===Q.VariableName&&n.doc.sliceString(t.from,t.to)===r&&(P_(a,u,t.from),i=!1);while(t.nextSibling());break}}F_(o,e=>{z_(e,{state:n,variableName:r,scopeStack:l,declarations:a})})}function B_(e,t,n){let r=mn(e),i=[];z_(r,{state:e,variableName:t,scopeStack:[],declarations:i});let a=Math.max(0,Math.min(n,e.doc.length));for(let e of N_(r,a)){let t=i.filter(t=>t.scopeId===e.id).filter(t=>!A_.has(e.type)||t.from<=a).toSorted((e,t)=>e.from-t.from)[0];if(t)return t.from}return null}function V_(e,t,n){let{state:r}=e,i=n===void 0?M_(r,t):B_(r,t,n);return i!==null&&(j_(e,i),!0)}function H_(e,t){return j_(e,e.state.doc.line(t).from),!0}function U_(e,t){let n=u.get(ie);return(n===`mac`?e.mac??e.key:n===`windows`?e.win??e.key:e.linux??e.key)===t}function W_(e){let{from:t,to:n}=e.selection.main;if(t===n){let{startToken:n,endToken:r}=Eg(e.doc,t);return{position:n,word:e.doc.sliceString(n,r)}}return{position:t,word:e.doc.sliceString(t,n)}}function G_(e,t){if(!t)return null;let n=e[t];return!n||n.declaredBy.length===0?null:n.declaredBy[0]}function K_(e){return e.startsWith(`_`)}function q_(e){let{state:t}=e,{position:n,word:r}=W_(t);return r?(Nr(e),e.dispatch({effects:Un}),X_(e,r,n)):!1}function J_(e,t=u.get(P).getHotkey(`cell.goToDefinition`).key){for(let n of e.state.facet(dn).flat())if(U_(n,t)&&n.run?.(e))return!0;return!1}function Y_(e){return q_(e)?!0:J_(e)}function X_(e,t,n){if(n!==void 0&&V_(e,t,n))return!0;let r=Q_(e,t);return r?V_(r,t):!1}function Z_(e,t){let n=$_(e);return n?H_(n,t):!1}function Q_(e,t){if(K_(t))return e;let n=G_(u.get(Ah),t);return n?$_(n):null}function $_(e){return pN(e)??null}var ev=o(null);function tv(e){let t=u.get(ev);if(e===null){u.set(ev,null);return}(t?.cellId!==e.cellId||t.line!==e.line)&&u.set(ev,{...e,startedAtMs:Date.now()})}var nv=o(new Map),rv=new Set;function iv(e){return o(t=>{let n=t(ev);return n?.cellId===e?n.line:null})}function av(e){return o(t=>{let n=t(ev);return n?.cellId===e?{line:n.line,startedAtMs:n.startedAtMs}:null})}function ov(e){return o(t=>t(nv).get(e)??rv)}function sv(e){let t={};for(let[n,r]of e)r.size>0&&(t[n]=[...r].toSorted((e,t)=>e-t));Br().sendSetBreakpoints({breakpoints:t}).catch(e=>{L.debug(`Failed to sync breakpoints to kernel`,{error:e})})}function cv(e){let t=u.get(nv);if(!t.has(e))return;let n=new Map(t);n.delete(e),u.set(nv,n),sv(n)}function lv(){let e=u.get(nv);e.size>0&&sv(e)}function uv(e,t){let n=u.get(nv),r=new Map(n),i=new Set(r.get(e)??[]);i.has(t)?i.delete(t):i.add(t),i.size>0?r.set(e,i):r.delete(e),u.set(nv,r),sv(r)}function dv(e,t){if(t==null||t<1||t>e.doc.lines)return Nn.none;let n=new An;try{let r=e.doc.line(t);n.add(r.from,r.from,Nn.line({class:`cm-debugger-current-line`}))}catch(e){L.debug(`Invalid debugger line`,{error:e})}return n.finish()}var fv=class{unsubscribe;decorations;constructor(e,t){this.decorations=dv(e.state,t.get()),this.unsubscribe=t.sub(t=>{this.decorations=dv(e.state,t),e.dispatch({userEvent:`marimo.debugger-line-update`})})}update(e){this.decorations=this.decorations.map(e.changes)}destroy(){this.unsubscribe()}};function pv(e){return[Yn.define(t=>new fv(t,e),{decorations:e=>e.decorations}),Kn.theme({".cm-debugger-current-line":{backgroundColor:`color-mix(in srgb, var(--amber-4) 50%, transparent)`}})]}var mv=new class extends Fn{toDOM(){let e=document.createElement(`div`);return e.className=`cm-breakpoint-marker`,e}},hv=xn.define(),gv=on.define({create:()=>new Set,update(e,t){for(let e of t.effects)if(e.is(hv))return e.value;return e}});function _v(e){let t=e.field(gv);if(t.size===0)return jn.empty;let n=new An;for(let r of[...t].toSorted((e,t)=>e-t))if(r>=1&&r<=e.doc.lines){let t=e.doc.line(r);n.add(t.from,t.from,mv)}return n.finish()}var vv=class{unsubscribe;constructor(e,t){let n=t=>{e.dispatch({effects:hv.of(t)})};t.get().size>0&&queueMicrotask(()=>n(t.get())),this.unsubscribe=t.sub(n)}destroy(){this.unsubscribe()}};function yv(e,t){return[gv,Yn.define(e=>new vv(e,t)),Zn({class:`cm-breakpoint-gutter`,markers:e=>_v(e.state),initialSpacer:()=>mv,domEventHandlers:{mousedown:(t,n)=>{let r=t.state.doc.lineAt(n.from).number;return uv(e,r),!0}}}),Kn.theme({".cm-breakpoint-gutter":{width:`14px`,cursor:`pointer`},".cm-breakpoint-marker":{width:`8px`,height:`8px`,borderRadius:`50%`,backgroundColor:`var(--red-9)`,margin:`4px auto`}})]}var bv=class e{ms;static fromMilliseconds(t){return t==null?null:new e(t)}static fromSeconds(t){return t==null?null:new e(t*1e3)}static now(){return new e(Date.now())}constructor(e){this.ms=e}toMilliseconds(){return this.ms}toSeconds(){return this.ms/1e3}};function xv(e){if(e===null)return``;let t=e,n=t/1e3;return n>=60?`${Math.floor(n/60)}m${Math.floor(n%60)}s`:n>=1?`${n.toFixed(2).toString()}s`:`${t.toFixed(0).toString()}ms`}var Sv=500,Cv=250,wv=class e extends In{static intervals=new WeakMap;startedAtMs;constructor(e){super(),this.startedAtMs=e}eq(e){return e.startedAtMs===this.startedAtMs}toDOM(){let t=document.createElement(`span`);t.className=`cm-line-timer`,t.setAttribute(`aria-hidden`,`true`);let n=()=>{let e=Date.now()-this.startedAtMs;t.textContent=e>=Sv?xv(e):``};return n(),e.intervals.set(t,window.setInterval(n,Cv)),t}destroy(t){let n=e.intervals.get(t);n!==void 0&&(window.clearInterval(n),e.intervals.delete(t))}ignoreEvent(){return!0}};function Tv(e,t){if(t===null||t.line<1||t.line>e.doc.lines)return Nn.none;let n=new An;try{let r=e.doc.line(t.line);n.add(r.from,r.from,Nn.line({class:`cm-timing-current-line`})),n.add(r.to,r.to,Nn.widget({widget:new wv(t.startedAtMs),side:1}))}catch(e){L.debug(`Invalid timing line`,{error:e})}return n.finish()}var Ev=class{unsubscribe;decorations;constructor(e,t){this.decorations=Tv(e.state,t.get()),this.unsubscribe=t.sub(t=>{this.decorations=Tv(e.state,t),e.dispatch({userEvent:`marimo.timing-line-update`})})}update(e){this.decorations=this.decorations.map(e.changes)}destroy(){this.unsubscribe()}};function Dv(e){return[Yn.define(t=>new Ev(t,e),{decorations:e=>e.decorations}),Kn.theme({".cm-timing-current-line":{backgroundColor:`color-mix(in srgb, var(--grass-4) 50%, transparent)`},".cm-line-timer":{color:`var(--grass-11)`,fontSize:`0.85em`,marginLeft:`1.5ch`,pointerEvents:`none`}})]}function Ov(e,t){if(!t?.length)return Nn.none;let n=new An,r=e.facet(Af),i=t.filter(e=>e.kind===`cell`&&e.cellId===r).toSorted((e,t)=>e.lineNumber-t.lineNumber);for(let t of i)try{let r=e.doc.line(t.lineNumber),i=Nn.line({class:`cm-error-line`});n.add(r.from,r.from,i)}catch(e){L.debug(`Invalid line number in error decoration`,{error:e})}return n.finish()}function kv(e,t){if(!t?.length)return;let n=e.state.facet(Af),r=t.filter(e=>e.kind===`cell`&&e.cellId===n);if(r.length===0)return;let i=Bn(e.state),a=[];for(let t of r)try{let n=e.state.doc.line(t.lineNumber);i.between(n.from,n.to,(e,t)=>{a.push(Dn.of({from:e,to:t}))})}catch(e){L.debug(`Invalid line numbers`,{error:e})}a.length>0&&e.dispatch({effects:a})}var Av=class{unsubscribe;decorations;constructor(e,t){let n=t.get();this.decorations=Ov(e.state,n),kv(e,n),this.unsubscribe=t.sub(t=>{let n=this.decorations.size;this.decorations=Ov(e.state,t),kv(e,t),n!==this.decorations.size&&e.dispatch({userEvent:`marimo.error-decoration-update`})})}update(e){this.decorations=this.decorations.map(e.changes)}destroy(){this.unsubscribe()}};function jv(e){return Yn.define(t=>new Av(t,e),{decorations:e=>e.decorations})}function Mv(e){return[jv(e),Kn.theme({".cm-error-line":{backgroundColor:`color-mix(in srgb, var(--red-4) 40%, transparent)`},"&.cm-focused .cm-error-line.cm-activeLine":{backgroundColor:`color-mix(in srgb, var(--red-5) 40%, transparent)`}})]}function Nv({cellId:e,hotkeys:t}){let n=[];return n.push(...se({key:t.getHotkey(`cell.run`).key,preventDefault:!0,stopPropagation:!0,run:e=>(e.state.facet(kf).onRun(),!0)}),{key:t.getHotkey(`cell.runAndNewBelow`).key,preventDefault:!0,stopPropagation:!0,run:t=>{let n=t.state.facet(kf);return n.onRun(),e===`__scratch__`||(t.contentDOM.blur(),n.moveToNextCell({cellId:e,before:!1}),!0)}},...se({key:t.getHotkey(`cell.runAndNewAbove`).key,preventDefault:!0,stopPropagation:!0,run:t=>{let n=t.state.facet(kf);return n.onRun(),e===`__scratch__`||(t.contentDOM.blur(),n.moveToNextCell({cellId:e,before:!0}),!0)}}),{key:t.getHotkey(`cell.aiCompletion`).key,preventDefault:!0,stopPropagation:!0,run:e=>(e.state.facet(kf).aiCellCompletion()&&e.contentDOM.focus(),!0)}),e!==`__scratch__`&&n.push({key:t.getHotkey(`cell.goToDefinition`).key,run:e=>q_(e)},{key:t.getHotkey(`cell.delete`).key,preventDefault:!0,stopPropagation:!0,run:e=>(e.state.doc.length===0&&e.state.facet(kf).deleteCell(),!0)},{key:t.getHotkey(`cell.moveUp`).key,preventDefault:!0,stopPropagation:!0,run:t=>(t.state.facet(kf).moveCell({cellId:e,before:!0}),!0)},{key:t.getHotkey(`cell.moveDown`).key,preventDefault:!0,stopPropagation:!0,run:t=>(t.state.facet(kf).moveCell({cellId:e,before:!1}),!0)},{key:t.getHotkey(`cell.moveLeft`).key,preventDefault:!0,stopPropagation:!0,run:t=>(t.state.facet(kf).moveCell({cellId:e,before:!0,direction:`left`}),!0)},{key:t.getHotkey(`cell.moveRight`).key,preventDefault:!0,stopPropagation:!0,run:t=>(t.state.facet(kf).moveCell({cellId:e,before:!1,direction:`right`}),!0)},{key:`ArrowUp`,run:t=>jr(t.state)?!1:S_(t)?(t.state.facet(kf).moveToNextCell({cellId:e,before:!0,noCreate:!0}),!0):!1},{key:`ArrowDown`,run:t=>jr(t.state)?!1:C_(t)?(t.state.facet(kf).moveToNextCell({cellId:e,before:!1,noCreate:!0}),!0):!1},{key:t.getHotkey(`cell.focusDown`).key,preventDefault:!0,stopPropagation:!0,run:t=>(t.state.facet(kf).moveToNextCell({cellId:e,before:!1,noCreate:!0}),!0)},{key:t.getHotkey(`cell.focusUp`).key,preventDefault:!0,stopPropagation:!0,run:t=>(t.state.facet(kf).moveToNextCell({cellId:e,before:!0,noCreate:!0}),!0)},{key:t.getHotkey(`cell.sendToBottom`).key,preventDefault:!0,stopPropagation:!0,run:t=>(t.state.facet(kf).sendToBottom({cellId:e}),!0)},{key:t.getHotkey(`cell.sendToTop`).key,preventDefault:!0,stopPropagation:!0,run:t=>(t.state.facet(kf).sendToTop({cellId:e}),!0)},{key:t.getHotkey(`cell.createAbove`).key,preventDefault:!0,stopPropagation:!0,run:t=>(t.contentDOM.blur(),t.state.facet(kf).createNewCell({cellId:e,before:!0}),!0)},{key:t.getHotkey(`cell.createBelow`).key,preventDefault:!0,stopPropagation:!0,run:t=>(t.contentDOM.blur(),t.state.facet(kf).createNewCell({cellId:e,before:!1}),!0)},{key:t.getHotkey(`cell.hideCode`).key,preventDefault:!0,stopPropagation:!0,run:t=>{let n=t.state.facet(kf).toggleHideCode();return Nr(t),n?(t.contentDOM.blur(),document.getElementById(Fi.create(e))?.focus()):t.contentDOM.focus(),!0}},{key:t.getHotkey(`cell.splitCell`).key,preventDefault:!0,stopPropagation:!0,run:t=>{let n=t.state.facet(kf);return n.splitCell({cellId:e}),n.moveToNextCell&&requestAnimationFrame(()=>{t.contentDOM.blur(),n.moveToNextCell({cellId:e,before:!1})}),!0}}),[gn.high(dn.of(n))]}function Pv(e){return[Kn.updateListener.of(e=>{if(e.docChanged){let t=e.transactions.some(e=>e.effects.some(e=>e.is(lm))),n=AA(e.view),r=e.view.state.facet(kf),i=e.view.state.facet(Af);r.updateCellCode({cellId:i,code:n,formattingChange:t}),u.get(sh).has(i)&&u.set(ch)}}),wh(e)]}var Fv=[`input`,`delete`,`undo`,`redo`];function Iv({docChanged:e,transactions:t,predicate:n=()=>!0,hasFocus:r=!1}){return!e||!n()||t.some(e=>e.effects.some(e=>e.is(lm)))?!1:t.some(e=>e.annotation(ph)===void 0?Fv.some(t=>e.isUserEvent(t))||r:!1)}function Lv({predicate:e}){return Kn.updateListener.of(t=>{Iv({docChanged:t.docChanged,transactions:t.transactions,predicate:e,hasFocus:t.view.hasFocus})&&t.view.state.facet(kf).onRun()})}function Rv({cellId:e,hotkeys:t,cellActions:n}){let r=_h(`debugger`),i=_h(`line_timing`);return[kf.of(n),Af.of(e),Nv({cellId:e,hotkeys:t}),Pv(t),Mv(yh(gN(e),u)),r?yv(e,yh(ov(e),u)):[],i?Dv(yh(av(e),u)):r?pv(yh(iv(e),u)):[]]}var zv=xn.define(),Bv=20;function Vv(e){let{state:t,anchor:n,head:r}=e;if(r<n)return!1;let i=t.doc.lineAt(r).number,a=t.doc.lineAt(n).number,o=Math.max(a,i-Bv+1),s=Math.max(n,t.doc.line(o).from),c=s>n,l=+!!c,u=t.doc.iterRange(s,r);for(;;){let{value:e,done:t}=u.next();if(t)break;for(let t of e)if(t===`(`)l++;else if(t===`)`&&(l--,c?l<=0:l<0))return!1}return!0}function Hv(e){return{...e,create:t=>{let{dom:n,...r}=e.create(t),i=document.createElement(`div`);return i.classList.add(`mo-cm-tooltip`),i.append(n),{...r,dom:i}}}}var Uv=on.define({create:()=>null,update(e,t){for(let e of t.effects)if(e.is(zv))return e.value;if(!e||t.selection&&!t.docChanged)return null;if(t.docChanged){let n=t.changes.mapPos(e.pos);return Vv({state:t.state,anchor:n,head:t.state.selection.main.head})?{...e,pos:n}:null}return e},provide:e=>fn.from(e)});function Wv(e){return e.state.field(Uv,!1)?(e.dispatch({effects:zv.of(null)}),!0):!1}var Gv=async e=>{let t=e.state.doc.sliceString(0,e.pos),n=document.activeElement,r=null;if(n!==null){let e=Fi.findElement(n);e!==null&&(r=Fi.parse(e.id))}if(r===null)return L.error(`Failed to find active cell.`),null;let i=await bg.request({document:t,cellId:r});if(!i)return e.view?.dispatch({effects:zv.of(null)}),null;let a=Sg.asHoverTooltip({position:e.pos,message:i,limitToType:`tooltip`});return a&&u.set(ng,{documentation:a.html??null}),e.view?.dispatch({effects:zv.of(a?Hv(a):null)}),a?null:Sg.asCompletionResult(e.pos,i)};function Kv(e){return t=>e.predicate(t.state)?e.completion(t):null}var qv=async e=>{let t=e.matchBefore(/:\w*$/);if(!e.explicit&&!t)return null;let n=await Jv();return{from:t?.from??e.pos,options:n,validFor:/^[\w:]*$/}},Jv=Er(async()=>{let e=await fetch(`https://unpkg.com/emojilib@3.0.11/dist/emoji-en-US.json`).then(e=>{if(!e.ok)throw Error(`Failed to fetch emoji list`);return e.json()}).catch(()=>({}));return Object.entries(e).map(([e,t])=>({shortcode:t[0],label:t.map(e=>`:${e}`).join(` `),emoji:e,displayLabel:`${e} ${t[0].replaceAll(`_`,` `)}`,apply:e,type:`emoji`}))}),Yv=async e=>{let t=e.matchBefore(/::[\w-:]*$/);if(!e.explicit&&!t)return null;let n=await Xv();return{from:t?.from??e.pos,options:n,validFor:/^[\w-:]*$/}},Xv=Er(async()=>{let e=await fetch(`https://unpkg.com/lucide-static@0.452.0/tags.json`).then(e=>{if(!e.ok)throw Error(`Failed to fetch Lucide icon list`);return e.json()}).catch(()=>({})),t=e=>`https://cdn.jsdelivr.net/npm/lucide-static@0.452.0/icons/${e}.svg`;return Object.entries(e).map(([e,n])=>({label:`::${e}`,displayLabel:e,type:`lucide-icon`,boost:10,apply:`::lucide:${e}::`,detail:n.join(`, `),info:()=>{let n=document.createElement(`img`);return n.src=t(e),n.style.width=`24px`,n.style.height=`24px`,n}}))}),Zv=e=>{let t=e.matchBefore(/\\\w*$/);return!e.explicit&&!t?null:{from:t?.from??e.pos,options:Qv(),validFor:/^[\w\\]*$/}},Qv=Er(()=>[[`alpha`,`α`,`Greek small letter alpha`],[`beta`,`β`,`Greek small letter beta`],[`gamma`,`γ`,`Greek small letter gamma`],[`delta`,`δ`,`Greek small letter delta`],[`epsilon`,`ε`,`Greek small letter epsilon`],[`zeta`,`ζ`,`Greek small letter zeta`],[`eta`,`η`,`Greek small letter eta`],[`theta`,`θ`,`Greek small letter theta`],[`iota`,`ι`,`Greek small letter iota`],[`kappa`,`κ`,`Greek small letter kappa`],[`lambda`,`λ`,`Greek small letter lambda`],[`mu`,`μ`,`Greek small letter mu`],[`nu`,`ν`,`Greek small letter nu`],[`xi`,`ξ`,`Greek small letter xi`],[`omicron`,`ο`,`Greek small letter omicron`],[`pi`,`π`,`Greek small letter pi`],[`rho`,`ρ`,`Greek small letter rho`],[`sigma`,`σ`,`Greek small letter sigma`],[`tau`,`τ`,`Greek small letter tau`],[`upsilon`,`υ`,`Greek small letter upsilon`],[`phi`,`φ`,`Greek small letter phi`],[`chi`,`χ`,`Greek small letter chi`],[`psi`,`ψ`,`Greek small letter psi`],[`omega`,`ω`,`Greek small letter omega`],[`Gamma`,`Γ`,`Greek capital letter gamma`],[`Delta`,`Δ`,`Greek capital letter delta`],[`Theta`,`Θ`,`Greek capital letter theta`],[`Lambda`,`Λ`,`Greek capital letter lambda`],[`Xi`,`Ξ`,`Greek capital letter xi`],[`Pi`,`Π`,`Greek capital letter pi`],[`Sigma`,`Σ`,`Greek capital letter sigma`],[`Phi`,`Φ`,`Greek capital letter phi`],[`Psi`,`Ψ`,`Greek capital letter psi`],[`Omega`,`Ω`,`Greek capital letter omega`],[`pm`,`±`,`Plus-minus sign`],[`mp`,`∓`,`Minus-plus sign`],[`times`,`×`,`Multiplication sign`],[`div`,`÷`,`Division sign`],[`cdot`,`⋅`,`Dot operator`],[`ast`,`∗`,`Asterisk operator`],[`star`,`⋆`,`Star operator`],[`circ`,`∘`,`Ring operator`],[`bullet`,`•`,`Bullet`],[`cap`,`∩`,`Intersection`],[`cup`,`∪`,`Union`],[`uplus`,`⊎`,`Multiset union`],[`sqcap`,`⊓`,`Square cap`],[`sqcup`,`⊔`,`Square cup`],[`vee`,`∨`,`Logical or`],[`wedge`,`∧`,`Logical and`],[`setminus`,`∖`,`Set minus`],[`oplus`,`⊕`,`Circled plus`],[`ominus`,`⊖`,`Circled minus`],[`otimes`,`⊗`,`Circled times`],[`oslash`,`⊘`,`Circled division slash`],[`odot`,`⊙`,`Circled dot operator`],[`leq`,`≤`,`Less than or equal to`],[`geq`,`≥`,`Greater than or equal to`],[`equiv`,`≡`,`Identical to`],[`prec`,`≺`,`Precedes`],[`succ`,`≻`,`Succeeds`],[`sim`,`∼`,`Tilde operator`],[`perp`,`⊥`,`Up tack`],[`mid`,`∣`,`Divides`],[`parallel`,`∥`,`Parallel to`],[`subset`,`⊂`,`Subset of`],[`supset`,`⊃`,`Superset of`],[`subseteq`,`⊆`,`Subset of or equal to`],[`supseteq`,`⊇`,`Superset of or equal to`],[`cong`,`≅`,`Approximately equal to`],[`approx`,`≈`,`Almost equal to`],[`neq`,`≠`,`Not equal to`],[`ne`,`≠`,`Not equal to`],[`propto`,`∝`,`Proportional to`],[`leftarrow`,`←`,`Leftward arrow`],[`rightarrow`,`→`,`Rightward arrow`],[`Leftarrow`,`⇐`,`Leftward double arrow`],[`Rightarrow`,`⇒`,`Rightward double arrow`],[`leftrightarrow`,`↔`,`Left right arrow`],[`Leftrightarrow`,`⇔`,`Left right double arrow`],[`uparrow`,`↑`,`Upward arrow`],[`downarrow`,`↓`,`Downward arrow`],[`Uparrow`,`⇑`,`Upward double arrow`],[`Downarrow`,`⇓`,`Downward double arrow`],[`infty`,`∞`,`Infinity`],[`nabla`,`∇`,`Nabla`],[`partial`,`∂`,`Partial differential`],[`forall`,`∀`,`For all`],[`exists`,`∃`,`There exists`],[`nexists`,`∄`,`There does not exist`],[`emptyset`,`∅`,`Empty set`],[`in`,`∈`,`Element of`],[`notin`,`∉`,`Not an element of`],[`sum`,`∑`,`N-ary summation`],[`prod`,`∏`,`N-ary product`],[`int`,`∫`,`Integral`],[`oint`,`∮`,`Contour integral`],[`sqrt`,`√`,`Square root`],[`hbar`,`ℏ`,`Planck constant over 2pi`],[`ldots`,`…`,`Horizontal ellipsis`],[`cdots`,`⋯`,`Midline horizontal ellipsis`],[`vdots`,`⋮`,`Vertical ellipsis`],[`ddots`,`⋱`,`Down right diagonal ellipsis`]].map(([e,t,n])=>({label:`\\${e} ${n}`,displayLabel:e,type:`latex-symbol`,boost:10,apply:`\\${e}`,info:()=>{let e=document.createElement(`div`);return e.textContent=`${t} ${n}`,e},detail:t}))),$v=[qv,Yv,Zv],ey=100;function ty(e){return!e.state.selection.main.empty}function ny({view:e,selection:t,markup:n}){let r=[],i=!0;for(let r=t.from;r<=t.to;r++)if(!e.state.doc.lineAt(r).text.startsWith(n)){i=!1;break}for(let a=t.from;a<=t.to;){let t=e.state.doc.lineAt(a),o=t.text.startsWith(n);i?r.push({from:t.from,to:t.from+n.length,insert:Ln.of([``])}):(o&&r.push({from:t.from,to:t.from+n.length,insert:Ln.of([``])}),r.push({from:t.from,insert:Ln.of([n])})),a=t.to+1}return r}function ry({view:e,range:t,markupAfter:n,markupBefore:r}){if(t.empty){let n=e.state.wordAt(t.head);n&&(t=n)}let i=e.state.sliceDoc(t.from-r.length,t.from)===r,a=e.state.sliceDoc(t.to,t.to+n.length)===n,o=[];o.push(i?{from:t.from-r.length,to:t.from,insert:Ln.of([``])}:{from:t.from,insert:Ln.of(r.split(`
|
|
85
85
|
`))},a?{from:t.to,to:t.to+n.length,insert:Ln.of([``])}:{from:t.to,insert:Ln.of(n.split(`
|
|
86
|
-
`))});let s=i?-r.length:r.length,c=a?-n.length:n.length;return{changes:o,range:On.range(t.from+s,t.to+c)}}function iy(e){if(!ty(e))return!1;let t=ny({view:e,selection:e.state.selection.main,markup:`> `});return t.length>0&&e.dispatch(e.state.update({changes:t,scrollIntoView:!0,userEvent:`input`})),e.focus(),!0}function ay(e){if(!ty(e))return!1;let t=e.state.changeByRange(t=>{if(t.empty){let n=e.state.wordAt(t.head);n&&(t=n)}return ry({view:e,range:t,markupBefore:`**`,markupAfter:`**`})});return e.dispatch(e.state.update(t,{scrollIntoView:!0,annotations:qn.userEvent.of(`input`)})),e.focus(),!0}function oy(e){if(!ty(e))return!1;let t=e.state.changeByRange(t=>{if(t.empty){let n=e.state.wordAt(t.head);n&&(t=n)}let n=e.state.doc.lineAt(t.from).number!==e.state.doc.lineAt(t.to).number;return ry({view:e,range:t,markupBefore:n?"```\n":"`",markupAfter:n?"\n```":"`"})});return e.dispatch(e.state.update(t,{scrollIntoView:!0,annotations:qn.userEvent.of(`input`)})),e.focus(),!0}function sy(e){let t=e.state.changeByRange(t=>{if(t.empty){let n=e.state.wordAt(t.head);n&&(t=n)}return ry({view:e,range:t,markupBefore:`_`,markupAfter:`_`})});return e.dispatch(e.state.update(t,{scrollIntoView:!0,annotations:qn.userEvent.of(`input`)})),e.focus(),!0}function cy(e,t=`http://`){if(!ty(e))return!1;let n=e.state.changeByRange(n=>{let r=e.state.sliceDoc(n.from,n.to);return{changes:[{from:n.from,to:n.to,insert:`[${r}](${t})`}],range:n}});e.dispatch(e.state.update(n,{scrollIntoView:!0,annotations:qn.userEvent.of(`input`)}));let{to:r}=n.selection.main;try{e.dispatch({selection:On.create([On.range(r+3,r+3+t.length),On.cursor(r+3+t.length)])})}catch{}return e.focus(),!0}async function ly(e,t){let n=new FileReader,r=await new Promise(e=>{n.onload=()=>e(n.result),n.readAsDataURL(t)}),i;try{if(r.startsWith(`data:`)){let e=prompt(`We can save your image as a file. Enter a filename.`,t.name),n=t.type.split(`/`)[1];if(e===null){let e=Math.round(r.length/1024);if(e>ey){an({title:`Content too large`,description:`The content size is ${e} KB, which is too large to paste directly into the document.`});return}}else{e.trim()===``?e=t.name:e.endsWith(`.${n}`)||(e=`${e}.${n}`);let r=u.get(es),a=r?wt.dirname(r):null,o=a?`${a}/public`:`public`,s=await Br().sendCreateFileOrFolder({path:o,type:`file`,name:e,file:t});s.success?(i=s.info?.path,i&&a&&i.startsWith(a)&&(i=wt.rest(i,a).replaceAll(`\\`,`/`)),an({title:`Image uploaded successfully`,description:`We've uploaded your image at ${i}`})):an({title:`Failed to upload image. Using raw base64 string.`})}}}catch{an({title:`Failed to upload image. Using raw base64 string.`})}let a=e.state.changeByRange(t=>{let n=e.state.sliceDoc(t.from,t.to);return n.trim()===``&&(n=`alt`),{changes:[{from:t.from,to:t.to,insert:``}],range:t}});e.dispatch(e.state.update(a,{scrollIntoView:!0,annotations:qn.userEvent.of(`input`)}));let{to:o}=a.selection.main;try{e.dispatch({selection:On.create([On.range(o+4,o+4+r.length),On.cursor(o+4+r.length)])})}catch{}return e.focus(),!0}async function uy(e,t){let n=await t.text(),r=e.state.changeByRange(e=>({changes:[{from:e.from,to:e.from,insert:n}],range:e}));return e.dispatch(e.state.update(r,{scrollIntoView:!0,annotations:qn.userEvent.of(`input`)})),e.focus(),!0}function dy(e){if(!ty(e))return!1;let{changes:t}=e.state.changeByRange(t=>({range:t,changes:ny({view:e,selection:t,markup:e.state.sliceDoc(t.from,t.to+2).startsWith(`* `)?`* `:`- `})}));return t.length>0&&e.dispatch(e.state.update({changes:t,scrollIntoView:!0,userEvent:`input`})),e.focus(),!0}function fy(e){if(!ty(e))return!1;let{changes:t}=e.state.changeByRange(t=>({range:t,changes:ny({view:e,selection:t,markup:`1. `})}));return t.length>0&&e.dispatch(e.state.update({changes:t,scrollIntoView:!0,userEvent:`input`})),e.focus(),!0}function py(e){return[gn.highest(dn.of([{key:e.getHotkey(`markdown.bold`).key,stopPropagation:!0,run:ay},{key:e.getHotkey(`markdown.italic`).key,stopPropagation:!0,run:sy},{key:e.getHotkey(`markdown.link`).key,stopPropagation:!0,run:e=>cy(e)},{key:e.getHotkey(`markdown.orderedList`).key,run:fy},{key:e.getHotkey(`markdown.unorderedList`).key,run:dy},{key:e.getHotkey(`markdown.blockquote`).key,run:iy},{key:e.getHotkey(`markdown.code`).key,run:oy},{key:"`",run:oy}])),Kn.domEventHandlers({paste:(e,t)=>{if(t.state.selection.main.empty)return!1;let n=e.clipboardData?.getData(`text/plain`);n?.startsWith(`http`)&&(e.preventDefault(),cy(t,n))}}),Kn.domEventHandlers({paste:(e,t)=>{let n=e.clipboardData?.files[0];if(!n)return!1;if(n.type.startsWith(`image/`))return e.preventDefault(),ly(t,n),!0;if(n.type.startsWith(`text/`))return e.preventDefault(),uy(t,n),!0}})]}function my(e,t,n=3,r=``){return Object.values(e).flatMap(e=>t.has(e.name)?[]:{label:`${r}${e.name}`,displayLabel:e.name,detail:e.dataType??``,boost:n,type:`variable`,apply:`${r}${e.name}`,section:`Variable`,info:()=>hy(e)})}function hy(e){let t=document.createElement(`div`);t.classList.add(`mo-cm-tooltip`,`docs-documentation`,`min-w-[200px]`,`flex`,`flex-col`,`gap-1`,`p-2`);let n=document.createElement(`div`);n.classList.add(`flex`,`items-center`,`gap-2`);let r=document.createElement(`span`);if(r.classList.add(`font-bold`,`text-base`),r.textContent=e.name,n.append(r),e.dataType){let t=document.createElement(`span`);t.classList.add(`text-xs`,`px-1.5`,`py-0.5`,`rounded-full`,`bg-purple-100`,`text-purple-800`,`dark:bg-purple-900`,`dark:text-purple-200`),t.textContent=e.dataType,n.append(t)}if(t.append(n),e.value){let n=document.createElement(`div`);n.classList.add(`flex`,`flex-col`,`gap-1`);let r=document.createElement(`div`);r.classList.add(`text-xs`,`text-muted-foreground`),r.textContent=`Value:`,n.append(r);let i=document.createElement(`div`);i.classList.add(`text-xs`,`font-mono`,`bg-muted`,`p-2`,`rounded`,`overflow-auto`,`max-h-40`),i.textContent=e.value,n.append(i),t.append(n)}return t}var gy=`Python`,_y=123,vy=1;function yy(e,t){let n=new WeakMap;return{defineNodes:[{name:gy,style:kn.emphasis},{name:`${gy}Mark`,style:kn.processingInstruction}],parseInline:[{name:gy,before:`Escape`,parse(r,i,a){if(!t())return-1;if(i===92&&r.char(a+1)===_y)return a+1;if(i!==_y)return-1;if(r.char(a+1)===_y)return a+2;let o=n.get(r);if(!o||a>=o.parsedTo){let t=e.parse(`rf"""${r.slice(a,r.end)}\n"""`).topNode.getChild(`ExpressionStatement`)?.getChild(`FormatString`),i=a-5,s=new Map;for(let e of t?.getChildren(`FormatReplacement`)??[])e.lastChild?.name===`}`&&s.set(i+e.from,i+e.to);o={ends:s,parsedTo:t?i+t.to:r.end},n.set(r,o)}let s=o.ends.get(a);return s===void 0?-1:r.addElement(r.elt(gy,a,s,[r.elt(`${gy}Mark`,a,a+1),r.elt(`${gy}Mark`,s-1,s)]))}}],wrap:zn(n=>{if(!t()||n.type.name!==gy)return null;let r=n.from+vy,i=n.to-vy;return r>=i||r<0||i<0?null:{parser:e,overlay:[{from:r,to:i}],extensions:[ai().support]}})}}var by=e=>{let t=e.state.doc.sliceString(0,e.pos),n=t.lastIndexOf(`{`);if(t.at(n-1)===`{`||n===-1||t.indexOf(`}`,n)>n)return null;let r=e.matchBefore(/\w*$/);if(!r)return null;let i=my(u.get(Ah),new Set,99);return{from:r.from,options:i,validFor:/^\w*$/}},xy=`InlineMathDollar`,Sy=`InlineMathBracket`,Cy=`BlockMathDollar`,wy=`BlockMathBracket`,Ty={[xy]:1,[Sy]:3,[Cy]:2,[wy]:3},Ey={DOLLAR:36,BACKSLASH:92,OPEN_PAREN:40,CLOSE_PAREN:41,OPEN_BRACKET:91,CLOSE_BRACKET:93},Dy=Object.keys(Ty).reduce((e,t)=>(e[t]={mark:`${t}Mark`,resolve:t},e),{});function Oy(e){let t=[];return Object.keys(Ty).forEach(e=>{t.push({name:e,style:kn.emphasis},{name:`${e}Mark`,style:kn.processingInstruction})}),{defineNodes:t,parseInline:[{name:Cy,parse(e,t,n){return t!==Ey.DOLLAR||e.char(n+1)!==Ey.DOLLAR?-1:e.addDelimiter(Dy[Cy],n,n+Ty[Cy],!0,!0)}},{name:xy,parse(e,t,n){return t!==Ey.DOLLAR||e.char(n+1)===Ey.DOLLAR?-1:e.addDelimiter(Dy[xy],n,n+Ty[xy],!0,!0)}},{name:Sy,before:`Escape`,parse(e,t,n){return t!==Ey.BACKSLASH||e.char(n+1)!==Ey.BACKSLASH||![Ey.OPEN_PAREN,Ey.CLOSE_PAREN].includes(e.char(n+2))?-1:e.addDelimiter(Dy[Sy],n,n+Ty[Sy],e.char(n+2)===Ey.OPEN_PAREN,e.char(n+2)===Ey.CLOSE_PAREN)}},{name:wy,before:`Escape`,parse(e,t,n){return t!==Ey.BACKSLASH||e.char(n+1)!==Ey.BACKSLASH||![Ey.OPEN_BRACKET,Ey.CLOSE_BRACKET].includes(e.char(n+2))?-1:e.addDelimiter(Dy[wy],n,n+Ty[wy],e.char(n+2)===Ey.OPEN_BRACKET,e.char(n+2)===Ey.CLOSE_BRACKET)}},{name:Sy,before:`Escape`,parse(e,t,n){return t!==Ey.BACKSLASH||![Ey.OPEN_PAREN,Ey.CLOSE_PAREN].includes(e.char(n+1))?-1:e.addDelimiter(Dy[Sy],n,n+2,e.char(n+1)===Ey.OPEN_PAREN,e.char(n+1)===Ey.CLOSE_PAREN)}},{name:wy,before:`Escape`,parse(e,t,n){return t!==Ey.BACKSLASH||![Ey.OPEN_BRACKET,Ey.CLOSE_BRACKET].includes(e.char(n+1))?-1:e.addDelimiter(Dy[wy],n,n+2,e.char(n+1)===Ey.OPEN_BRACKET,e.char(n+1)===Ey.CLOSE_BRACKET)}}],wrap:zn(t=>{let n=Ty[t.type.name];if(n){let r=t.node.firstChild?.to??t.from+n,i=t.node.lastChild?.from??t.to-n;if(r>=i||r<0||i<0)return null;let a=[],o=r;return t.node.cursor(Mn.IgnoreMounts).iterate(e=>{if(e.name===`Python`)return o<e.from&&a.push({from:o,to:e.from}),o=e.to,!1}),o<i&&a.push({from:o,to:i}),a.length?{parser:e,overlay:a}:null}return null})}}var ky=xn.define(),Ay=xn.define(),jy=on.define({create:()=>({}),update:(e,t)=>{for(let n of t.effects){if(n.is(ky))return n.value;if(n.is(Ay))return{...e,...n.value}}return e}}),My=class{parser=new Zm;type=`markdown`;defaultCode=this.parser.defaultCode;defaultMetadata=this.parser.defaultMetadata;static fromMarkdown(e){return Zm.fromMarkdown(e)}transformIn(e){let t=this.parser.transformIn(e);return[t.code,t.offset,t.metadata]}transformOut(e,t){let n=this.parser.transformOut(e,t);return[n.code,n.offset]}isSupported(e){return this.parser.isSupported(e)}getExtension(e,t,n,r){let i=ei().language.data,a,o=()=>{if(!a)return!0;let e=a?.state.field(jy);return e===void 0?!1:e.quotePrefix?.includes(`f`)??!1};return[Yn.define(e=>(a=e,{})),ei({base:ti,codeLanguages:gm,extensions:[Oy(Rn.define(si).parser),yy(ri.parser,o)]}),py(n),$v.map(e=>i.of({autocomplete:e})),ai().language.data.of({autocomplete:Kv({completion:Gv,predicate:o})}),Fr({defaultKeymap:!1,activateOnTyping:!0}),Lv({predicate:()=>!o()})]}},Ny={PREFIX:`file:///`,of(e){return`${this.PREFIX}${e}`},is(e){return e.startsWith(this.PREFIX)},parse(e){return z(this.is(e),`Invalid cell document URI: ${e}`),e.slice(this.PREFIX.length)}};function Py(e){return`notify`in e&&typeof e.notify==`function`}function Fy(e){return`processNotification`in e&&typeof e.processNotification==`function`}function Iy(e){return Ny.is(e)?u.get(OM).inOrderIds.includes(Ny.parse(e)):!1}function Ly(){return u.get(ns)?.rootUri??`file:///`}function Ry(){let e=u.get(ns)?.rootUri;return e?[{uri:e,name:`marimo`}]:[]}function zy(){return u.get(ns)?.documentUri??`file:///__marimo_notebook__.py`}function By(e){return R.filter(e,e=>e!==!1&&e!==null)}function Vy(e){let t=e.map(By);return Object.assign({},...t)}var Hy=class{clients=[];documentUri;constructor(e){this.clients=e,this.documentUri=zy()}onNotification(e){let t=[];for(let n of this.clients)t.push(n.onNotification(e));return()=>{for(let e of t)e();return!0}}get clientCapabilities(){return Vy(this.clients.map(e=>{if(e.clientCapabilities)return typeof e.clientCapabilities==`function`?e.clientCapabilities({}):e.clientCapabilities}).filter(e=>e!=null))}get ready(){return this.clients.some(e=>e.ready)}set ready(e){this.clients.forEach(t=>{t.ready=e})}get capabilities(){return Vy(this.clients.map(e=>e.capabilities).filter(e=>e!==null))}set capabilities(e){this.clients.forEach(t=>{t.capabilities=e})}get initializePromise(){return this.clients[0].initializePromise}set initializePromise(e){this.clients.forEach(t=>{t.initializePromise=e})}firstWithMethod(e){return this.clients.find(t=>t.hasCapability(e))}clientsWithMethod(e){return this.clients.filter(t=>t.hasCapability(e))}hasCapability(e){return this.clients.some(t=>t.hasCapability(e))}async initialize(){await Promise.all(this.clients.map(e=>e.initialize()))}async close(){await Promise.all(this.clients.map(e=>e.close()))}async textDocumentDidChange(e){await Promise.all(this.clients.map(t=>t.textDocumentDidChange(e)))}async completionItemResolve(e){let t=this.firstWithMethod(`textDocument/completion`);return t?t.completionItemResolve(e):e}async textDocumentCodeAction(e){let t=this.firstWithMethod(`textDocument/codeAction`);return t?t.textDocumentCodeAction(e):null}async codeActionResolve(e){let t=this.firstWithMethod(`textDocument/codeAction`);return t?t.codeActionResolve(e):e}async textDocumentRename(e){let t=this.firstWithMethod(`textDocument/rename`);return t?t.textDocumentRename(e):null}async textDocumentPrepareRename(e){let t=this.firstWithMethod(`textDocument/prepareRename`);return t?t.textDocumentPrepareRename(e):null}async textDocumentSignatureHelp(e){let t=this.firstWithMethod(`textDocument/signatureHelp`);return t?t.textDocumentSignatureHelp(e):null}async textDocumentCompletion(e){let t=this.clientsWithMethod(`textDocument/completion`);return Uy(await Promise.allSettled(t.map(t=>t.textDocumentCompletion(e))))}async textDocumentDefinition(e){let t=this.firstWithMethod(`textDocument/definition`);return t?t.textDocumentDefinition(e):null}async textDocumentDidOpen(e){return(await Promise.all(this.clients.map(t=>t.textDocumentDidOpen(e)))).some(e=>e!==!1)}async textDocumentDidClose(e){await Promise.all(this.clients.map(t=>t.textDocumentDidClose(e)))}async textDocumentWillSave(e){await Promise.all(this.clients.map(t=>t.textDocumentWillSave(e)))}async textDocumentWillSaveWaitUntil(e){let t=await Promise.allSettled(this.clients.map(t=>t.textDocumentWillSaveWaitUntil(e)));for(let e of t)if(e.status===`fulfilled`&&e.value?.length)return e.value;return null}async textDocumentDidSave(e){await Promise.all(this.clients.map(t=>t.textDocumentDidSave(e)))}async textDocumentHover(e){for(let t of this.clients){if(!t.hasCapability(`textDocument/hover`))continue;let n=await t.textDocumentHover(e);if(n)return n}return{contents:[]}}};function Uy(e){let t=[],n=!1;for(let r of e)if(r.status===`fulfilled`){let e=r.value;if(e==null)continue;Array.isArray(e)&&t.push(...e),`items`in e&&(t.push(...e.items),n||=e.isIncomplete)}return{items:t,isIncomplete:n}}function Wy(e){let t=ni.parse(e),n=``;return Wn(e,t,_n,(e,t)=>{let r=e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`);n+=t?`<span class="${t}">${r}</span>`:r},()=>{n+=`
|
|
87
|
-
`}),n}function Gy(){let e=new Ir.Renderer,t=e.code.bind(e);return e.code=e=>{let{text:n,lang:r}=e;return n.trim()?r===`python`||r===`py`?`<pre><code class="language-python">${Wy(n)}</code></pre>\n`:t(e):``},t=>Ir(t,{async:!1,gfm:!0,breaks:!0,renderer:e})}function Ky(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function qy(e,t){return typeof e[t]==`function`}var Jy=o(e=>{let t=e(
|
|
88
|
-
`)}function Xy(e){return Object.values(u.get(Jy)).filter(t=>t!==``&&t!==e).toSorted((e,t)=>e.startsWith(`import`)&&!t.startsWith(`import`)?-1:!e.startsWith(`import`)&&t.startsWith(`import`)?1:0)}var Zy=o(e=>e(
|
|
86
|
+
`))});let s=i?-r.length:r.length,c=a?-n.length:n.length;return{changes:o,range:On.range(t.from+s,t.to+c)}}function iy(e){if(!ty(e))return!1;let t=ny({view:e,selection:e.state.selection.main,markup:`> `});return t.length>0&&e.dispatch(e.state.update({changes:t,scrollIntoView:!0,userEvent:`input`})),e.focus(),!0}function ay(e){if(!ty(e))return!1;let t=e.state.changeByRange(t=>{if(t.empty){let n=e.state.wordAt(t.head);n&&(t=n)}return ry({view:e,range:t,markupBefore:`**`,markupAfter:`**`})});return e.dispatch(e.state.update(t,{scrollIntoView:!0,annotations:qn.userEvent.of(`input`)})),e.focus(),!0}function oy(e){if(!ty(e))return!1;let t=e.state.changeByRange(t=>{if(t.empty){let n=e.state.wordAt(t.head);n&&(t=n)}let n=e.state.doc.lineAt(t.from).number!==e.state.doc.lineAt(t.to).number;return ry({view:e,range:t,markupBefore:n?"```\n":"`",markupAfter:n?"\n```":"`"})});return e.dispatch(e.state.update(t,{scrollIntoView:!0,annotations:qn.userEvent.of(`input`)})),e.focus(),!0}function sy(e){let t=e.state.changeByRange(t=>{if(t.empty){let n=e.state.wordAt(t.head);n&&(t=n)}return ry({view:e,range:t,markupBefore:`_`,markupAfter:`_`})});return e.dispatch(e.state.update(t,{scrollIntoView:!0,annotations:qn.userEvent.of(`input`)})),e.focus(),!0}function cy(e,t=`http://`){if(!ty(e))return!1;let n=e.state.changeByRange(n=>{let r=e.state.sliceDoc(n.from,n.to);return{changes:[{from:n.from,to:n.to,insert:`[${r}](${t})`}],range:n}});e.dispatch(e.state.update(n,{scrollIntoView:!0,annotations:qn.userEvent.of(`input`)}));let{to:r}=n.selection.main;try{e.dispatch({selection:On.create([On.range(r+3,r+3+t.length),On.cursor(r+3+t.length)])})}catch{}return e.focus(),!0}async function ly(e,t){let n=new FileReader,r=await new Promise(e=>{n.onload=()=>e(n.result),n.readAsDataURL(t)}),i;try{if(r.startsWith(`data:`)){let e=prompt(`We can save your image as a file. Enter a filename.`,t.name),n=t.type.split(`/`)[1];if(e===null){let e=Math.round(r.length/1024);if(e>ey){an({title:`Content too large`,description:`The content size is ${e} KB, which is too large to paste directly into the document.`});return}}else{e.trim()===``?e=t.name:e.endsWith(`.${n}`)||(e=`${e}.${n}`);let r=u.get(es),a=r?wt.dirname(r):null,o=a?`${a}/public`:`public`,s=await Br().sendCreateFileOrFolder({path:o,type:`file`,name:e,file:t});s.success?(i=s.info?.path,i&&a&&i.startsWith(a)&&(i=wt.rest(i,a).replaceAll(`\\`,`/`)),an({title:`Image uploaded successfully`,description:`We've uploaded your image at ${i}`})):an({title:`Failed to upload image. Using raw base64 string.`})}}}catch{an({title:`Failed to upload image. Using raw base64 string.`})}let a=e.state.changeByRange(t=>{let n=e.state.sliceDoc(t.from,t.to);return n.trim()===``&&(n=`alt`),{changes:[{from:t.from,to:t.to,insert:``}],range:t}});e.dispatch(e.state.update(a,{scrollIntoView:!0,annotations:qn.userEvent.of(`input`)}));let{to:o}=a.selection.main;try{e.dispatch({selection:On.create([On.range(o+4,o+4+r.length),On.cursor(o+4+r.length)])})}catch{}return e.focus(),!0}async function uy(e,t){let n=await t.text(),r=e.state.changeByRange(e=>({changes:[{from:e.from,to:e.from,insert:n}],range:e}));return e.dispatch(e.state.update(r,{scrollIntoView:!0,annotations:qn.userEvent.of(`input`)})),e.focus(),!0}function dy(e){if(!ty(e))return!1;let{changes:t}=e.state.changeByRange(t=>({range:t,changes:ny({view:e,selection:t,markup:e.state.sliceDoc(t.from,t.to+2).startsWith(`* `)?`* `:`- `})}));return t.length>0&&e.dispatch(e.state.update({changes:t,scrollIntoView:!0,userEvent:`input`})),e.focus(),!0}function fy(e){if(!ty(e))return!1;let{changes:t}=e.state.changeByRange(t=>({range:t,changes:ny({view:e,selection:t,markup:`1. `})}));return t.length>0&&e.dispatch(e.state.update({changes:t,scrollIntoView:!0,userEvent:`input`})),e.focus(),!0}function py(e){return[gn.highest(dn.of([{key:e.getHotkey(`markdown.bold`).key,stopPropagation:!0,run:ay},{key:e.getHotkey(`markdown.italic`).key,stopPropagation:!0,run:sy},{key:e.getHotkey(`markdown.link`).key,stopPropagation:!0,run:e=>cy(e)},{key:e.getHotkey(`markdown.orderedList`).key,run:fy},{key:e.getHotkey(`markdown.unorderedList`).key,run:dy},{key:e.getHotkey(`markdown.blockquote`).key,run:iy},{key:e.getHotkey(`markdown.code`).key,run:oy},{key:"`",run:oy}])),Kn.domEventHandlers({paste:(e,t)=>{if(t.state.selection.main.empty)return!1;let n=e.clipboardData?.getData(`text/plain`);n?.startsWith(`http`)&&(e.preventDefault(),cy(t,n))}}),Kn.domEventHandlers({paste:(e,t)=>{let n=e.clipboardData?.files[0];if(!n)return!1;if(n.type.startsWith(`image/`))return e.preventDefault(),ly(t,n),!0;if(n.type.startsWith(`text/`))return e.preventDefault(),uy(t,n),!0}})]}function my(e,t,n=3,r=``){return Object.values(e).flatMap(e=>t.has(e.name)?[]:{label:`${r}${e.name}`,displayLabel:e.name,detail:e.dataType??``,boost:n,type:`variable`,apply:`${r}${e.name}`,section:`Variable`,info:()=>hy(e)})}function hy(e){let t=document.createElement(`div`);t.classList.add(`mo-cm-tooltip`,`docs-documentation`,`min-w-[200px]`,`flex`,`flex-col`,`gap-1`,`p-2`);let n=document.createElement(`div`);n.classList.add(`flex`,`items-center`,`gap-2`);let r=document.createElement(`span`);if(r.classList.add(`font-bold`,`text-base`),r.textContent=e.name,n.append(r),e.dataType){let t=document.createElement(`span`);t.classList.add(`text-xs`,`px-1.5`,`py-0.5`,`rounded-full`,`bg-purple-100`,`text-purple-800`,`dark:bg-purple-900`,`dark:text-purple-200`),t.textContent=e.dataType,n.append(t)}if(t.append(n),e.value){let n=document.createElement(`div`);n.classList.add(`flex`,`flex-col`,`gap-1`);let r=document.createElement(`div`);r.classList.add(`text-xs`,`text-muted-foreground`),r.textContent=`Value:`,n.append(r);let i=document.createElement(`div`);i.classList.add(`text-xs`,`font-mono`,`bg-muted`,`p-2`,`rounded`,`overflow-auto`,`max-h-40`),i.textContent=e.value,n.append(i),t.append(n)}return t}var gy=`Python`,_y=123,vy=1;function yy(e,t){let n=new WeakMap;return{defineNodes:[{name:gy,style:kn.emphasis},{name:`${gy}Mark`,style:kn.processingInstruction}],parseInline:[{name:gy,before:`Escape`,parse(r,i,a){if(!t())return-1;if(i===92&&r.char(a+1)===_y)return a+1;if(i!==_y)return-1;if(r.char(a+1)===_y)return a+2;let o=n.get(r);if(!o||a>=o.parsedTo){let t=e.parse(`rf"""${r.slice(a,r.end)}\n"""`).topNode.getChild(`ExpressionStatement`)?.getChild(`FormatString`),i=a-5,s=new Map;for(let e of t?.getChildren(`FormatReplacement`)??[])e.lastChild?.name===`}`&&s.set(i+e.from,i+e.to);o={ends:s,parsedTo:t?i+t.to:r.end},n.set(r,o)}let s=o.ends.get(a);return s===void 0?-1:r.addElement(r.elt(gy,a,s,[r.elt(`${gy}Mark`,a,a+1),r.elt(`${gy}Mark`,s-1,s)]))}}],wrap:zn(n=>{if(!t()||n.type.name!==gy)return null;let r=n.from+vy,i=n.to-vy;return r>=i||r<0||i<0?null:{parser:e,overlay:[{from:r,to:i}],extensions:[ai().support]}})}}var by=e=>{let t=e.state.doc.sliceString(0,e.pos),n=t.lastIndexOf(`{`);if(t.at(n-1)===`{`||n===-1||t.indexOf(`}`,n)>n)return null;let r=e.matchBefore(/\w*$/);if(!r)return null;let i=my(u.get(Ah),new Set,99);return{from:r.from,options:i,validFor:/^\w*$/}},xy=`InlineMathDollar`,Sy=`InlineMathBracket`,Cy=`BlockMathDollar`,wy=`BlockMathBracket`,Ty={[xy]:1,[Sy]:3,[Cy]:2,[wy]:3},Ey={DOLLAR:36,BACKSLASH:92,OPEN_PAREN:40,CLOSE_PAREN:41,OPEN_BRACKET:91,CLOSE_BRACKET:93},Dy=Object.keys(Ty).reduce((e,t)=>(e[t]={mark:`${t}Mark`,resolve:t},e),{});function Oy(e){let t=[];return Object.keys(Ty).forEach(e=>{t.push({name:e,style:kn.emphasis},{name:`${e}Mark`,style:kn.processingInstruction})}),{defineNodes:t,parseInline:[{name:Cy,parse(e,t,n){return t!==Ey.DOLLAR||e.char(n+1)!==Ey.DOLLAR?-1:e.addDelimiter(Dy[Cy],n,n+Ty[Cy],!0,!0)}},{name:xy,parse(e,t,n){return t!==Ey.DOLLAR||e.char(n+1)===Ey.DOLLAR?-1:e.addDelimiter(Dy[xy],n,n+Ty[xy],!0,!0)}},{name:Sy,before:`Escape`,parse(e,t,n){return t!==Ey.BACKSLASH||e.char(n+1)!==Ey.BACKSLASH||![Ey.OPEN_PAREN,Ey.CLOSE_PAREN].includes(e.char(n+2))?-1:e.addDelimiter(Dy[Sy],n,n+Ty[Sy],e.char(n+2)===Ey.OPEN_PAREN,e.char(n+2)===Ey.CLOSE_PAREN)}},{name:wy,before:`Escape`,parse(e,t,n){return t!==Ey.BACKSLASH||e.char(n+1)!==Ey.BACKSLASH||![Ey.OPEN_BRACKET,Ey.CLOSE_BRACKET].includes(e.char(n+2))?-1:e.addDelimiter(Dy[wy],n,n+Ty[wy],e.char(n+2)===Ey.OPEN_BRACKET,e.char(n+2)===Ey.CLOSE_BRACKET)}},{name:Sy,before:`Escape`,parse(e,t,n){return t!==Ey.BACKSLASH||![Ey.OPEN_PAREN,Ey.CLOSE_PAREN].includes(e.char(n+1))?-1:e.addDelimiter(Dy[Sy],n,n+2,e.char(n+1)===Ey.OPEN_PAREN,e.char(n+1)===Ey.CLOSE_PAREN)}},{name:wy,before:`Escape`,parse(e,t,n){return t!==Ey.BACKSLASH||![Ey.OPEN_BRACKET,Ey.CLOSE_BRACKET].includes(e.char(n+1))?-1:e.addDelimiter(Dy[wy],n,n+2,e.char(n+1)===Ey.OPEN_BRACKET,e.char(n+1)===Ey.CLOSE_BRACKET)}}],wrap:zn(t=>{let n=Ty[t.type.name];if(n){let r=t.node.firstChild?.to??t.from+n,i=t.node.lastChild?.from??t.to-n;if(r>=i||r<0||i<0)return null;let a=[],o=r;return t.node.cursor(Mn.IgnoreMounts).iterate(e=>{if(e.name===`Python`)return o<e.from&&a.push({from:o,to:e.from}),o=e.to,!1}),o<i&&a.push({from:o,to:i}),a.length?{parser:e,overlay:a}:null}return null})}}var ky=xn.define(),Ay=xn.define(),jy=on.define({create:()=>({}),update:(e,t)=>{for(let n of t.effects){if(n.is(ky))return n.value;if(n.is(Ay))return{...e,...n.value}}return e}}),My=class{parser=new Zm;type=`markdown`;defaultCode=this.parser.defaultCode;defaultMetadata=this.parser.defaultMetadata;static fromMarkdown(e){return Zm.fromMarkdown(e)}transformIn(e){let t=this.parser.transformIn(e);return[t.code,t.offset,t.metadata]}transformOut(e,t){let n=this.parser.transformOut(e,t);return[n.code,n.offset]}isSupported(e){return this.parser.isSupported(e)}getExtension(e,t,n,r){let i=ei().language.data,a,o=()=>{if(!a)return!0;let e=a?.state.field(jy);return e===void 0?!1:e.quotePrefix?.includes(`f`)??!1};return[Yn.define(e=>(a=e,{})),ei({base:ti,codeLanguages:gm,extensions:[Oy(Rn.define(si).parser),yy(ri.parser,o)]}),py(n),$v.map(e=>i.of({autocomplete:e})),ai().language.data.of({autocomplete:Kv({completion:Gv,predicate:o})}),Fr({defaultKeymap:!1,activateOnTyping:!0}),Lv({predicate:()=>!o()})]}},Ny={PREFIX:`file:///`,of(e){return`${this.PREFIX}${e}`},is(e){return e.startsWith(this.PREFIX)},parse(e){return z(this.is(e),`Invalid cell document URI: ${e}`),e.slice(this.PREFIX.length)}};function Py(e){return`notify`in e&&typeof e.notify==`function`}function Fy(e){return`processNotification`in e&&typeof e.processNotification==`function`}function Iy(e){return Ny.is(e)?u.get(kM).inOrderIds.includes(Ny.parse(e)):!1}function Ly(){return u.get(ns)?.rootUri??`file:///`}function Ry(){let e=u.get(ns)?.rootUri;return e?[{uri:e,name:`marimo`}]:[]}function zy(){return u.get(ns)?.documentUri??`file:///__marimo_notebook__.py`}function By(e){return R.filter(e,e=>e!==!1&&e!==null)}function Vy(e){let t=e.map(By);return Object.assign({},...t)}var Hy=class{clients=[];documentUri;constructor(e){this.clients=e,this.documentUri=zy()}onNotification(e){let t=[];for(let n of this.clients)t.push(n.onNotification(e));return()=>{for(let e of t)e();return!0}}get clientCapabilities(){return Vy(this.clients.map(e=>{if(e.clientCapabilities)return typeof e.clientCapabilities==`function`?e.clientCapabilities({}):e.clientCapabilities}).filter(e=>e!=null))}get ready(){return this.clients.some(e=>e.ready)}set ready(e){this.clients.forEach(t=>{t.ready=e})}get capabilities(){return Vy(this.clients.map(e=>e.capabilities).filter(e=>e!==null))}set capabilities(e){this.clients.forEach(t=>{t.capabilities=e})}get initializePromise(){return this.clients[0].initializePromise}set initializePromise(e){this.clients.forEach(t=>{t.initializePromise=e})}firstWithMethod(e){return this.clients.find(t=>t.hasCapability(e))}clientsWithMethod(e){return this.clients.filter(t=>t.hasCapability(e))}hasCapability(e){return this.clients.some(t=>t.hasCapability(e))}async initialize(){await Promise.all(this.clients.map(e=>e.initialize()))}async close(){await Promise.all(this.clients.map(e=>e.close()))}async textDocumentDidChange(e){await Promise.all(this.clients.map(t=>t.textDocumentDidChange(e)))}async completionItemResolve(e){let t=this.firstWithMethod(`textDocument/completion`);return t?t.completionItemResolve(e):e}async textDocumentCodeAction(e){let t=this.firstWithMethod(`textDocument/codeAction`);return t?t.textDocumentCodeAction(e):null}async codeActionResolve(e){let t=this.firstWithMethod(`textDocument/codeAction`);return t?t.codeActionResolve(e):e}async textDocumentRename(e){let t=this.firstWithMethod(`textDocument/rename`);return t?t.textDocumentRename(e):null}async textDocumentPrepareRename(e){let t=this.firstWithMethod(`textDocument/prepareRename`);return t?t.textDocumentPrepareRename(e):null}async textDocumentSignatureHelp(e){let t=this.firstWithMethod(`textDocument/signatureHelp`);return t?t.textDocumentSignatureHelp(e):null}async textDocumentCompletion(e){let t=this.clientsWithMethod(`textDocument/completion`);return Uy(await Promise.allSettled(t.map(t=>t.textDocumentCompletion(e))))}async textDocumentDefinition(e){let t=this.firstWithMethod(`textDocument/definition`);return t?t.textDocumentDefinition(e):null}async textDocumentDidOpen(e){return(await Promise.all(this.clients.map(t=>t.textDocumentDidOpen(e)))).some(e=>e!==!1)}async textDocumentDidClose(e){await Promise.all(this.clients.map(t=>t.textDocumentDidClose(e)))}async textDocumentWillSave(e){await Promise.all(this.clients.map(t=>t.textDocumentWillSave(e)))}async textDocumentWillSaveWaitUntil(e){let t=await Promise.allSettled(this.clients.map(t=>t.textDocumentWillSaveWaitUntil(e)));for(let e of t)if(e.status===`fulfilled`&&e.value?.length)return e.value;return null}async textDocumentDidSave(e){await Promise.all(this.clients.map(t=>t.textDocumentDidSave(e)))}async textDocumentHover(e){for(let t of this.clients){if(!t.hasCapability(`textDocument/hover`))continue;let n=await t.textDocumentHover(e);if(n)return n}return{contents:[]}}};function Uy(e){let t=[],n=!1;for(let r of e)if(r.status===`fulfilled`){let e=r.value;if(e==null)continue;Array.isArray(e)&&t.push(...e),`items`in e&&(t.push(...e.items),n||=e.isIncomplete)}return{items:t,isIncomplete:n}}function Wy(e){let t=ni.parse(e),n=``;return Wn(e,t,_n,(e,t)=>{let r=e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`);n+=t?`<span class="${t}">${r}</span>`:r},()=>{n+=`
|
|
87
|
+
`}),n}function Gy(){let e=new Ir.Renderer,t=e.code.bind(e);return e.code=e=>{let{text:n,lang:r}=e;return n.trim()?r===`python`||r===`py`?`<pre><code class="language-python">${Wy(n)}</code></pre>\n`:t(e):``},t=>Ir(t,{async:!1,gfm:!0,breaks:!0,renderer:e})}function Ky(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function qy(e,t){return typeof e[t]==`function`}var Jy=o(e=>{let t=e(CM);return R.fromEntries(t.cellIds.inOrderIds.map(e=>{let n=t.cellHandles[e]?.current?.editorViewOrNull;return[e,n?AA(n):t.cellData[e]?.code??``]}))});function Yy(e){return[...Xy(e),e].join(`
|
|
88
|
+
`)}function Xy(e){return Object.values(u.get(Jy)).filter(t=>t!==``&&t!==e).toSorted((e,t)=>e.startsWith(`import`)&&!t.startsWith(`import`)?-1:!e.startsWith(`import`)&&t.startsWith(`import`)?1:0)}var Zy=o(e=>e(CM).cellIds.inOrderIds),Qy=o(e=>eb(e(Zy),e(Ah))),$y=o(e=>({cellIds:e(Qy),codes:e(Jy)}));function eb(e,t){let n=new Map;e.forEach(e=>n.set(e,[]));let r=new Set(e),i=new Set(e);for(let{declaredBy:e,usedBy:a}of Object.values(t))for(let t of e){r.delete(t);for(let e of a)i.delete(e),e!==t&&n.get(t)?.push(e)}let a=new Map;e.forEach(e=>a.set(e,0)),n.forEach(e=>{e.forEach(e=>{a.set(e,(a.get(e)||0)+1)})});let o=[];a.forEach((e,t)=>{e===0&&o.push(t)});let s=[];for(;o.length>0;){let e=o.shift();if(!e)break;s.push(e),n.get(e)?.forEach(e=>{a.set(e,(a.get(e)||0)-1),a.get(e)===0&&o.push(e)})}return[...s.filter(e=>!r.has(e)),...r]}function tb(e,t){let n=new Map,r=0;e.forEach(e=>{n.set(e,r),r+=t[e].split(`
|
|
89
89
|
`).length});function i(e){return n.has(e)||L.warn(`[lsp] no cell line offsets for`,e),n.get(e)??0}let a=e.map(e=>t[e]).join(`
|
|
90
90
|
`);return{cellIds:e,mergedText:a,transformRange:(e,t)=>nb(e,i(t)),reverseRange:(e,t)=>nb(e,-i(t)),isInRange:(e,r)=>{let i=t[r].split(`
|
|
91
91
|
`).length,a=n.get(r)||0,o=e.start.line-a,s=e.end.line-a,c=o>=0&&o<i,l=s>=0&&s<i;return c&&!l&&L.warn(`[lsp] Cross-cell diagnostic detected: range starts in cell but ends outside`,{cellId:r,range:e,cellLines:i,offset:a}),c&&l},getEditsForNewText:e=>{let r=e.split(`
|
|
@@ -98,7 +98,7 @@ mark line col
|
|
|
98
98
|
`),isFenced:e}),r=[])};for(let e of t){let t=e.match(/^[\t ]*(`{3,}|~{3,})/);if(t){let n=t[1],c=n[0],l=n.length;if(!i){s(!1),i=!0,a=c,o=l,r.push(e);continue}if(c===a&&l>=o){r.push(e),s(!0),i=!1,a=``,o=0;continue}}r.push(e)}return s(i),n}function gb(e){let t=[],n=``,r=!1,i=``,a=0;for(;a<e.length;){if(e[a]==="`"){let o=a;for(;o<e.length&&e[o]==="`";)o+=1;let s=e.slice(a,o);if(r&&s===i){n+=s,t.push({text:n,isInlineCode:!0}),n=``,r=!1,i=``,a=o;continue}if(!r){n&&=(t.push({text:n,isInlineCode:!1}),``),r=!0,i=s,n+=s,a=o;continue}}n+=e[a],a+=1}return n&&t.push({text:n,isInlineCode:r}),t}function _b(e){let t=yb(e);return t=t.replaceAll(ob,(e,t)=>xb(t)),t=t.replaceAll(sb,(e,t)=>bb(t)),t=t.replaceAll(cb,(e,t)=>xb(t)),t=t.replaceAll(lb,(e,t)=>bb(t)),t}function vb(e){return e.match(/^[\t ]*/)?.[0].replaceAll(` `,` `).length??0}function yb(e){let t=e.split(`
|
|
99
99
|
`);if(t.length===0)return e;let n=[],r=0;for(;r<t.length;){let e=t[r],i=e.match(/^[\t ]*\.\.\s+math::(.*)$/);if(!i){n.push(e),r+=1;continue}let a=i[1]?.trim()??``,o=vb(e);r+=1;let s=[],c=a.includes(`\\begin`);if(a)s.push(a);else{for(;r<t.length;){let e=t[r];if(!e.trim()){r+=1;continue}if(!(vb(e)>o&&e.trim().startsWith(`:`)))break;r+=1}if(r<t.length){let e=t[r];c=!!e.trim()&&vb(e)<=o&&e.trimStart().startsWith(`\\`)}}if(c)for(;r<t.length&&t[r].trim();)s.push(t[r]),r+=1;else for(;r<t.length;){let e=t[r];if(!e.trim()){s.push(``),r+=1;continue}if(vb(e)<=o)break;s.push(e),r+=1}let l=s.filter(e=>!!e.trim());if(l.length===0){n.push(e);continue}let u=Math.min(...l.map(e=>vb(e))),d=s.map(e=>{if(!e)return``;let t=Math.min(u,vb(e));return e.slice(t)}).join(`
|
|
100
100
|
`).trim();n.push(xb(d))}return n.join(`
|
|
101
|
-
`)}function bb(e){return`<marimo-tex class="arithmatex">||(${e.trim()}||)</marimo-tex>`}function xb(e){return`<marimo-tex class="arithmatex">||[${e.trim()}||]</marimo-tex>`}function Sb(e){return e.startsWith(`_`)&&!e.startsWith(`__`)}var Cb=class{documentVersion=0;getNotebookCode;constructor(e){this.getNotebookCode=e}lastSnapshot=null;snapshot(){let e=this.getLens(),t=this.lastSnapshot?.mergedText!==e.mergedText;return t?(this.documentVersion++,this.lastSnapshot=e,{lens:e,didChange:t,version:this.documentVersion}):{lens:e,didChange:t,version:this.documentVersion}}getLatestSnapshot(){if(!this.lastSnapshot)throw Error(`No snapshots`);return{lens:this.lastSnapshot,version:this.documentVersion}}getLens(){let{cellIds:e,codes:t}=this.getNotebookCode();return tb(e,t)}},wb=()=>{let e=GM().cellHandles;return R.mapValues(e,e=>e.current?.editorViewOrNull)};function Tb(e){let t=db(e);return Array.isArray(t)?e:t}function Eb(e){return{...e,documentation:Tb(e.documentation)}}function Db(e){return e==null?null:Array.isArray(e)?e.map(e=>Eb(e)):{...e,items:e.items.map(e=>Eb(e))}}function Ob(e){return{...e,signatures:e.signatures.map(e=>({...e,documentation:Tb(e.documentation),parameters:e.parameters?.map(e=>({...e,documentation:Tb(e.documentation)}))}))}}function kb(e){return Ky(e)&&typeof e.line==`number`&&typeof e.character==`number`}function Ab(e){return Ky(e)&&kb(e.start)&&kb(e.end)}function jb(e){return Ky(e)&&typeof e.message==`string`&&Ab(e.range)}function Mb(e){if(e.method!==`textDocument/publishDiagnostics`||!Ky(e.params))return!1;let{uri:t,version:n,diagnostics:r}=e.params;return typeof t==`string`&&(n===void 0||typeof n==`number`)&&Array.isArray(r)&&r.every(jb)}var Nb=class{documentUri;client;snapshotter;getNotebookEditors;initialSettings;seenCellDocumentUris=new Set;pruneSeenCellUris(e){for(let t of this.seenCellDocumentUris){let n=Ny.parse(t);e.has(n)||this.seenCellDocumentUris.delete(t)}}completionItemCache=new Sp(10);openCellDocumentCounts=new Map;latestDiagnosticsVersion=null;forwardedDiagnosticsVersion=0;constructor(e,t,n=wb){this.documentUri=zy(),this.getNotebookEditors=n,this.initialSettings=t,this.client=e,this.patchProcessNotification(),this.initializePromise.then(()=>{z(Py(this.client),`notify is not a method on the client`),this.client.notify(`workspace/didChangeConfiguration`,{settings:t})}),this.snapshotter=new Cb(this.getNotebookCode.bind(this))}onNotification(e){return this.client.onNotification(e)}get ready(){return this.client.ready}set ready(e){this.client.ready=e}get capabilities(){return this.client.capabilities}set capabilities(e){this.client.capabilities=e}get initializePromise(){return this.client.initializePromise}set initializePromise(e){this.client.initializePromise=e}get clientCapabilities(){return this.client.clientCapabilities}async initialize(){await this.client.initialize()}close(){this.openCellDocumentCounts.clear(),this.client.close()}hasCapability(e){return this.client.hasCapability(e)}async resyncAllDocuments(){z(Py(this.client),`notify is not a method on the client`),await this.client.initialize(),await this.client.notify(`workspace/didChangeConfiguration`,{settings:this.initialSettings});let{lens:e,version:t}=this.snapshotter.snapshot();this.latestDiagnosticsVersion=null,this.forwardedDiagnosticsVersion=0,this.openCellDocumentCounts.size>0&&await this.client.notify(`textDocument/didOpen`,{textDocument:{languageId:`python`,text:e.mergedText,uri:this.documentUri,version:t}}),L.log(`[lsp] Document re-synchronization complete`)}getNotebookCode(){let{cellIds:e,codes:t}=u.get($y),n=this.getNotebookEditors();return{cellIds:e,codes:R.fromEntries(e.map(e=>{let r=n[e];return[e,r?AA(r):t[e]??``]}))}}assertCellDocumentUri(e){z(Ny.is(e),`Execpted URI to be CellDocumentUri`)}async textDocumentDidOpen(e){L.debug(`[lsp] textDocumentDidOpen`,e);let t=e.textDocument.uri;this.assertCellDocumentUri(t);let{lens:n,version:r}=this.snapshotter.snapshot(),i=this.openCellDocumentCounts.get(t)??0;this.openCellDocumentCounts.set(t,i+1);try{let i=await this.client.textDocumentDidOpen({textDocument:{languageId:e.textDocument.languageId,text:n.mergedText,uri:this.documentUri,version:r}});return this.seenCellDocumentUris.add(t),i!==!1}catch(e){let n=this.openCellDocumentCounts.get(t)??0;throw n<=1?this.openCellDocumentCounts.delete(t):this.openCellDocumentCounts.set(t,n-1),e}}async textDocumentDidClose(e){let t=e.textDocument.uri;this.assertCellDocumentUri(t);let n=this.openCellDocumentCounts.get(t)??0;if(n===0){L.warn(`[lsp] textDocumentDidClose with no tracked open`,t);return}n<=1?this.openCellDocumentCounts.delete(t):this.openCellDocumentCounts.set(t,n-1),await this.client.textDocumentDidClose({textDocument:{uri:this.documentUri}})}async sync(){let{lens:e,version:t,didChange:n}=this.snapshotter.snapshot(),r={textDocument:{uri:this.documentUri,version:t},contentChanges:[{text:e.mergedText}]};return n&&await this.client.textDocumentDidChange(r),{params:r,lens:e}}async textDocumentDidChange(e){if(L.debug(`[lsp] textDocumentDidChange`,e),e.contentChanges.length===1){await this.sync();return}L.warn(`[lsp] Unhandled textDocumentDidChange`,e),await this.client.textDocumentDidChange(e)}async textDocumentWillSave(e){this.assertCellDocumentUri(e.textDocument.uri),await this.client.textDocumentWillSave({...e,textDocument:{uri:this.documentUri}})}async textDocumentWillSaveWaitUntil(e){return this.assertCellDocumentUri(e.textDocument.uri),L.debug(`[lsp] willSaveWaitUntil edits are disabled for notebook documents`),null}async textDocumentDidSave(e){this.assertCellDocumentUri(e.textDocument.uri);let{lens:t}=this.snapshotter.snapshot();await this.client.textDocumentDidSave({textDocument:{uri:this.documentUri},text:e.text===void 0?void 0:t.mergedText})}async textDocumentDefinition(e){let t=e.textDocument.uri;if(!Ny.is(t))return L.warn(`Invalid cell document URI`,t),null;let{lens:n}=await this.sync(),r=Ny.parse(t);return this.client.textDocumentDefinition({...e,textDocument:{uri:this.documentUri},position:n.transformPosition(e.position,r)})}async textDocumentSignatureHelp(e){let t=e.textDocument.uri;if(!Ny.is(t))return L.warn(`Invalid cell document URI`,t),null;let{lens:n}=await this.sync(),r=Ny.parse(t),i=await this.client.textDocumentSignatureHelp({...e,textDocument:{uri:this.documentUri},position:n.transformPosition(e.position,r)});return i?Ob(i):null}textDocumentCodeAction(e){return Promise.resolve(null)}codeActionResolve(e){return Promise.resolve(e)}reverseRelatedInformation(e,t){if(e)return e.map(e=>{if(!Ky(e)||!Ky(e.location)||e.location.uri!==this.documentUri||!Ab(e.location.range))return e;let n=t.cellIds.find(n=>t.isInRange(e.location.range,n));return n===void 0?e:{...e,location:{uri:Ny.of(n),range:t.reverseRange(e.location.range,n)}}})}async textDocumentRename(e){let t=e.textDocument.uri;if(!Ny.is(t))return L.warn(`Invalid cell document URI`,t),null;let n=Ny.parse(t),{lens:r}=await this.sync(),i=r.transformPosition(e.position,n),a=await this.client.textDocumentRename({...e,textDocument:{uri:this.documentUri},position:i});if(!a)return null;let o=a.documentChanges?.flatMap(e=>`edits`in e?e.edits:[]);if(!o||o.length!==1)return L.warn(`Expected exactly one edit`,o),a;let s=o[0];if(!(`newText`in s))return L.warn(`Expected newText in edit`,s),a;let c=r.getEditsForNewText(s.newText),l=new Map(c.map(e=>[e.cellId,e.text])),u=this.getNotebookEditors(),d=u[n],f=!1;if(d){let t=d.state.doc.line(e.position.line+1).from+e.position.character,{startToken:n,endToken:r}=Eg(d.state.doc,t),i=d.state.doc.sliceString(n,r);f=Sb(i),f&&L.debug(`[lsp] Private variable rename detected, limiting to current cell`,i)}let p=[],m=0;for(let[e,t]of R.entries(u)){if(f&&e!==n)continue;let r=l.get(e);if(r==null){L.warn(`[lsp] No new code for cell during rename`,e),p.push(e);continue}if(!t){L.warn(`[lsp] No editor view for cell during rename`,e),p.push(e);continue}AA(t)!==r&&(jA(t,r),m++)}return p.length>0&&L.error(`[lsp] Rename partially failed: could not update ${p.length} cell(s)`,p),L.debug(`[lsp] Rename completed: updated ${m} cell(s)`),{...a,documentChanges:[{edits:[],textDocument:{uri:t,version:0}}]}}async completionItemResolve(e){let t=JSON.stringify(e),n=this.completionItemCache.get(t);if(n)return n;let r=this.client.completionItemResolve(e).then(e=>Eb(e));return this.completionItemCache.set(t,r),r}async textDocumentPrepareRename(e){let t=e.textDocument.uri;if(!Ny.is(t))return L.warn(`Invalid cell document URI`,t),null;let{lens:n}=await this.sync(),r=Ny.parse(t);return this.client.textDocumentPrepareRename({...e,textDocument:{uri:this.documentUri},position:n.transformPosition(e.position,r)})}async textDocumentHover(e){L.debug(`[lsp] textDocumentHover`,e);let{lens:t}=await this.sync(),n=Ny.parse(e.textDocument.uri),r=await this.client.textDocumentHover({...e,textDocument:{uri:this.documentUri},position:t.transformPosition(e.position,n)});return r?(typeof r.contents==`object`&&`kind`in r.contents&&(r.contents={kind:`markdown`,value:r.contents.value}),r.contents=db(r.contents)??r.contents,r.contents===``?null:(r.range&&=t.reverseRange(r.range,n),r)):(L.debug(`[lsp] no hover result`),r)}async textDocumentCompletion(e){let{lens:t}=await this.sync();if(!Ny.is(e.textDocument.uri))return L.error(`[lsp] Invalid cell document URI in completion request`,e.textDocument.uri),null;let n=Ny.parse(e.textDocument.uri);if(!n||n===`undefined`)return L.error(`[lsp] Invalid cellId 'undefined' in completion request`,{cellId:n,uri:e.textDocument.uri,availableCellIds:t.cellIds}),null;t.cellIds.includes(n)||L.warn(`[lsp] CellId in completion request not found in current lens`,{cellId:n,uri:e.textDocument.uri,availableCellIds:t.cellIds});let r=t.transformPosition(e.position,n);return Db(await this.client.textDocumentCompletion({...e,textDocument:{uri:this.documentUri},position:r}))}patchProcessNotification(){z(Fy(this.client),`processNotification is not a method on the client`);let e=this.client.processNotification.bind(this.client),t=t=>{if(Mb(t)){let n=t.params.version;if(n!=null){let e=this.latestDiagnosticsVersion;if(e!==null&&Number.isFinite(n)&&n<e){L.debug(`[lsp] dropping stale diagnostics notification`,t);return}this.latestDiagnosticsVersion=n}L.debug(`[lsp] handling diagnostics`,t);let r=this.snapshotter.getLatestSnapshot(),i=t.params.diagnostics,{lens:a}=r,o=++this.forwardedDiagnosticsVersion,s=new Map;for(let e of i)for(let t of a.cellIds)if(a.isInRange(e.range,t)){s.has(t)||s.set(t,[]);let n=this.reverseRelatedInformation(e.relatedInformation,a),r={...e,range:a.reverseRange(e.range,t),...n?{relatedInformation:n}:{}};s.get(t)?.push(r);break}let c=new Set(a.cellIds);this.pruneSeenCellUris(c);let l=new Set(this.seenCellDocumentUris);for(let[n,r]of s.entries()){L.debug(`[lsp] diagnostics for cell`,n,r);let i=Ny.of(n);l.delete(i),e({...t,params:{...t.params,uri:i,version:o,diagnostics:r}})}if(l.size>0){L.debug(`[lsp] clearing diagnostics`,l);for(let t of l)e({method:`textDocument/publishDiagnostics`,params:{uri:t,version:o,diagnostics:[]}})}return}return e(t)};this.client.processNotification=t}},Pb=1e3,Fb=new Set([`textDocument/didOpen`,`textDocument/didChange`,`textDocument/didClose`]),Ib=new Set([`initialize`,`initialized`,`workspace/didChangeConfiguration`,`textDocument/didOpen`]),Lb=class{delegate;connectionPromise;isDelegateConnected=!1;connectionGeneration=0;restoringGeneration;isClosed=!1;hasConnectedBefore=!1;messageHandlers=new Set;pendingMessages=[];inFlightBacklog;hasLoggedQueueOverflow=!1;disposeDelegateMessage;disposeDelegateClose;options;onReconnect;constructor(e){this.options={...e,retries:e.retries??1,retryDelayMs:e.retryDelayMs??1e3},this.onReconnect=e.onReconnect}async connect(){if(this.isClosed)throw Error(`Transport is closed`);if(this.isDelegateConnected)return;if(this.connectionPromise)return this.connectionPromise;let e=++this.connectionGeneration,t=this.connectWithRetries(e).finally(()=>{this.connectionPromise===t&&(this.connectionPromise=void 0)});return this.connectionPromise=t,t}isStale(e){return this.isClosed||e!==this.connectionGeneration}send(e){if(!this.isClosed){if(this.delegate&&this.isDelegateConnected&&(this.restoringGeneration===void 0||this.canSendWhileRestoring(e))){this.delegate.send(e);return}this.pendingMessages.length<Pb?this.pendingMessages.push(e):this.hasLoggedQueueOverflow||(this.hasLoggedQueueOverflow=!0,L.error(`LSP reconnect queue is full (${Pb}); dropping messages until it drains`)),this.reconnect()}}onMessage(e){return this.messageHandlers.add(e),()=>{this.messageHandlers.delete(e)}}close(){this.isClosed||(this.isClosed=!0,this.isDelegateConnected=!1,this.restoringGeneration=void 0,this.connectionGeneration++,this.connectionPromise=void 0,this.pendingMessages=[],this.inFlightBacklog=void 0,this.messageHandlers.clear(),this.disposeDelegate(),this.delegate?.close(),this.delegate=void 0)}async connectWithRetries(e){let t;for(let n=1;n<=this.options.retries;n++)try{await this.connectDelegate(e);return}catch(r){if(t=r instanceof Error?r:Error(String(r)),this.isStale(e))throw t;this.invalidateDelegate(),L.warn(`WebSocket connection attempt ${n}/${this.options.retries} failed`,t),n<this.options.retries&&await new Promise(e=>setTimeout(e,this.options.retryDelayMs))}let n=t??Error(`WebSocket connection failed`);throw this.options.onConnectionFailure?.(n),n}async connectDelegate(e){if(await this.options.waitForConnection?.(),this.isStale(e))throw Error(`Connection attempt abandoned`);let t=this.createDelegate();if(await t.connect(),this.isStale(e)||this.delegate!==t)throw t.close(),Error(`Transport closed while connecting`);this.isDelegateConnected=!0;let n=this.hasConnectedBefore;this.hasConnectedBefore=!0;let r=this.detachPendingMessages();this.inFlightBacklog=r;try{if(n){this.restoringGeneration=e;try{await this.onReconnect?.()}finally{this.restoringGeneration===e&&(this.restoringGeneration=void 0)}}if(this.isStale(e)||this.delegate!==t||!this.isDelegateConnected)throw Error(`WebSocket closed while restoring LSP state`)}catch(t){throw this.isStale(e)||this.reclaimInFlightBacklog(),t}let i=n&&this.onReconnect?r.filter(e=>!(`method`in e&&Fb.has(e.method))):r;this.inFlightBacklog=void 0;for(let e of[...i,...this.detachPendingMessages()])t.send(e);L.log(`WebSocket transport connected successfully`)}detachPendingMessages(){let e=this.pendingMessages;return this.pendingMessages=[],this.hasLoggedQueueOverflow=!1,e}reclaimInFlightBacklog(){this.inFlightBacklog&&=(this.pendingMessages=[...this.inFlightBacklog,...this.pendingMessages].slice(0,Pb),void 0)}canSendWhileRestoring(e){return!(`method`in e)||Ib.has(e.method)}createDelegate(){this.invalidateDelegate();let e=new Ad(this.options.getWsUrl());return this.delegate=e,this.disposeDelegateMessage=e.onMessage(e=>{for(let t of this.messageHandlers)try{t(e)}catch(e){L.error(`LSP message handler failed`,e)}}),this.disposeDelegateClose=e.onClose(t=>{this.delegate!==e||this.isClosed||(L.warn(`WebSocket transport connection closed`,t),this.isDelegateConnected=!1,this.disposeDelegate(),this.delegate=void 0,this.restoringGeneration=void 0,this.reclaimInFlightBacklog(),this.connectionPromise=void 0,queueMicrotask(()=>this.reconnect()))}),e}reconnect(){this.connect().catch(e=>{L.error(`WebSocket transport reconnection failed`,e)})}invalidateDelegate(){this.isDelegateConnected=!1,this.restoringGeneration=void 0,this.disposeDelegate(),this.delegate?.close(),this.delegate=void 0}disposeDelegate(){this.disposeDelegateMessage?.(),this.disposeDelegateMessage=void 0,this.disposeDelegateClose?.(),this.disposeDelegateClose=void 0}},Rb=new Set([1,2]);function zb(e,t){if(!(`method`in t)||t.method!==`window/logMessage`)return;let n=t.params;!Ky(n)||typeof n.message!=`string`||DM({logs:[{timestamp:Date.now()/1e3,level:Rb.has(n.type)?`stderr`:`stdout`,message:n.message,source:{type:`lsp`,name:e}}]})}function Bb(e,t){let n=Ce(),r=new Lb({getWsUrl:()=>n.getLSPURL(e).toString(),waitForConnection:async()=>{await be()},onReconnect:t});return r.onMessage(t=>zb(e,t)),r}xn.define(),new En;function Vb(e){return e.facet(pn.readOnly)}function Hb(e){return[cn(e),dn.of([{key:`ArrowRight`,preventDefault:!0,run:t=>Ub(t,e)},{key:`Tab`,preventDefault:!0,run:t=>Ub(t,e)}])]}function Ub(e,t){if(Vb(e.state))return!1;let n=e.state.doc.length;return n===0&&(e.dispatch({changes:{from:0,to:n,insert:t},selection:{head:t.length,anchor:t.length}}),!0)}function Wb(e){let{beforeText:t,linkText:n,afterText:r,onClick:i}=e;return[cn(e=>{let a=document.createElement(`span`);a.append(document.createTextNode(t));let o=document.createElement(`span`);return o.textContent=n,o.classList.add(`cm-clickable-placeholder`),o.onclick=t=>{t.stopPropagation(),i(e)},a.append(o),a.append(document.createTextNode(r)),a}),Kn.theme({".cm-placeholder":{color:`var(--slate-8)`},".cm-clickable-placeholder":{cursor:`pointer !important`,pointerEvents:`auto`,color:`var(--slate-9)`,textDecoration:`underline`,textUnderlineOffset:`0.2em`},".cm-clickable-placeholder:hover":{color:`var(--sky-11)`}})]}var Gb=Er(e=>{let t,n={transport:Bb(`pylsp`,async()=>{await t?.()}),rootUri:Ly(),workspaceFolders:Ry()},r=e?.pylsp,i=[`D100`,`D103`],a=[`W292`,`E402`,`E302`,`E305`],o=[`B018`,`I001`],s={pylsp:{plugins:{marimo_plugin:{enabled:!0},jedi:{auto_import_modules:[`numpy`]},jedi_completion:{include_params:!0,resolve_at_most:50},flake8:{enabled:r?.enable_flake8,extendIgnore:a},pydocstyle:{enabled:r?.enable_pydocstyle,ignore:i},pylint:{enabled:r?.enable_pylint},pyflakes:{enabled:r?.enable_pyflakes},pylsp_mypy:{enabled:r?.enable_mypy,live_mode:!0},ruff:{enabled:r?.enable_ruff,extendIgnore:[...a,...i,...o]},signature:{formatter:r?.enable_ruff?`ruff`:`black`,line_length:88}}}},c=new Nb(new kd({...n}),s);return t=()=>c.resyncAllDocuments(),c}),Kb=Er(e=>{let t,n=new Nb(new kd({transport:Bb(`ty`,async()=>{await t?.()}),rootUri:Ly(),workspaceFolders:Ry(),getWorkspaceConfiguration:()=>[{disableLanguageServices:!0}]}),{});return t=()=>n.resyncAllDocuments(),n}),qb=Er(e=>{let t,n=new Nb(new kd({transport:Bb(`pyrefly`,async()=>{await t?.()}),rootUri:Ly(),workspaceFolders:Ry(),initializationOptions:{pyrefly:{displayTypeErrors:e.diagnostics?.enabled??!1?`force-on`:`force-off`}}}),{});return t=()=>n.resyncAllDocuments(),n}),Jb=Er(e=>{let t,n=new Nb(new kd({transport:Bb(`basedpyright`,async()=>{await t?.()}),rootUri:Ly(),workspaceFolders:Ry()}),{});return t=()=>n.resyncAllDocuments(),n}),Yb=class{parser=new Qm;type=`python`;defaultCode=this.parser.defaultCode;defaultMetadata=this.parser.defaultMetadata;transformIn(e){let t=this.parser.transformIn(e);return[t.code,t.offset,t.metadata]}transformOut(e,t){let n=this.parser.transformOut(e,t);return[n.code,n.offset]}isSupported(e){return this.parser.isSupported(e)}getExtension(e,t,n,r,i){return[(()=>{let r={defaultKeymap:!1,activateOnTyping:t.activate_on_typing,closeOnBlur:!1},a={hideOnChange:!0},o=[];i?.pylsp?.enabled&&tg(`pylsp`)&&o.push(Gb(i)),i?.ty?.enabled&&tg(`ty`)&&o.push(Kb(i)),i?.pyrefly?.enabled&&tg(`pyrefly`)&&o.push(qb(i)),i?.basedpyright?.enabled&&tg(`basedpyright`)&&o.push(Jb(i));let s=t.signature_hint_on_typing,c=s?/(\w+|\w+\.|\/)$/:/(\w+|\w+\.|\(|\/|,)$/;if(o.length>0){let t=o.length===1?o[0]:new Hy(o),l=e=>{L.debug(`openExternalLocation`,e),!(t.documentUri===e.uri||Iy(e.uri))&&Br().openFile({path:e.uri.replace(`file://`,``)})};return[Yd({client:t,languageId:`python`,allowHTMLContent:!0,markdownRenderer:Gy(),useSnippetOnCompletion:!0,clientSideFiltering:!0,hoverConfig:a,completionConfig:r,diagnosticsEnabled:i.diagnostics?.enabled??!1,sendIncrementalChanges:!1,signatureHelpEnabled:!0,signatureActivateOnTyping:s,signatureHelpOptions:{position:`above`},keyboardShortcuts:{signatureHelp:n.getHotkey(`cell.signatureHelp`).key,goToDefinition:n.getHotkey(`cell.goToDefinition`).key,rename:n.getHotkey(`cell.renameSymbol`).key},completionMatchBefore:c,onGoToDefinition:l,onShowLocation:l}),vd.of(Ny.of(e))]}return[Fr({...r,override:[Gv]}),Uv]})(),Qb(),Xb(r)]}};function Xb(e){return e===`marimo-import`?gn.highest(Hb(`import marimo as mo`)):e===`ai`?Wb({beforeText:`Start coding or `,linkText:`generate`,afterText:` with AI.`,onClick:e=>{e.state.facet(kf).aiCellCompletion()}}):[]}var Zb=ri.configure({props:[un.add({ParenthesizedExpression:Cn,ArgList:Cn})]});function Qb(){return new Jn(Zb,[Zb.data.of({autocomplete:ii}),Zb.data.of({autocomplete:oi})])}function $b(e){return typeof e==`object`&&!Array.isArray(e)&&!ex(e)}function ex(e){if(typeof e!=`object`||Array.isArray(e)||!(`self`in e)||!(`children`in e))return!1;let t=e.self;return typeof t==`object`&&!!t&&!Array.isArray(t)&&typeof t.label==`string`}function tx(e){return Array.isArray(e)}function nx(e,t,n,r){let i=e.length;if(t===`string`||t===`completion`&&r&&tx(r))return`column`;if(t===`namespace`&&n){if(tx(n))return`table`;if($b(n))return Object.values(n).some(e=>tx(e)||ex(e)&&tx(e.children))?i<=1?`database`:`schema`:i===0?`database`:`namespace`}if(t===`completion`&&n)return tx(n)?`table`:($b(n)&&Object.values(n).some(e=>tx(e)||ex(e)&&tx(e.children)),i<=1?`database`:`schema`);switch(i){case 0:return`database`;case 1:return`schema`;default:return`namespace`}}function rx(e,t,n={}){let{maxDepth:r=10}=n;if((typeof t==`string`?t===``:t.length===0)&&ex(e)){let t=nx([],`completion`,e.children);return{completion:e.self,path:[],type:`completion`,semanticType:t,namespace:e.children}}let i=(typeof t==`string`?t.split(`.`):t).filter(e=>e.length>0);return i.length===0||i.length>r?null:ix(e,i,[],n)}function ix(e,t,n,r,i){if(t.length===0){if(ex(e)){let t=nx(n,`completion`,e.children,i);return{completion:e.self,path:n,type:`completion`,semanticType:t,namespace:e.children}}return{path:n,type:`namespace`,semanticType:nx(n,`namespace`,e,i),namespace:e}}let[a,...o]=t,{caseSensitive:s=!1}=r;if(!a)return null;if($b(e)){let t=s?Object.keys(e).find(e=>e===a):Object.keys(e).find(e=>e.toLowerCase()===a.toLowerCase());if(t){let i=e[t];if(i)return ix(i,o,[...n,t],r,e)}}else if(ex(e))return ix(e.children,t,n,r,e);else if(tx(e)){for(let t of e)if(typeof t==`string`){if((s?t===a:t.toLowerCase()===a.toLowerCase())&&o.length===0){let r=nx([...n,t],`string`,void 0,e);return{value:t,path:[...n,t],type:`string`,semanticType:r}}}else if((s?t.label===a:t.label.toLowerCase()===a.toLowerCase())&&o.length===0){let r=nx([...n,t.label],`completion`,void 0,e);return{completion:t,path:[...n,t.label],type:`completion`,semanticType:r}}}return null}function ax(e,t,n={}){let r=[];if(t.includes(`.`)){let r=t.lastIndexOf(`.`),i=t.substring(0,r),a=t.substring(r+1),o=rx(e,i,n);if(o?.namespace)return ox(o.namespace,a,o.path,n)}else return ox(e,t,[],n);return r}function ox(e,t,n,r){let i=[],{caseSensitive:a=!1,allowPartialMatch:o=!0}=r;if($b(e)){for(let[r,s]of Object.entries(e))if(o?a?r.startsWith(t):r.toLowerCase().startsWith(t.toLowerCase()):a?r===t:r.toLowerCase()===t.toLowerCase()){if(ex(s)){let t=nx([...n,r],`completion`,s.children,e);i.push({completion:s.self,path:[...n,r],type:`completion`,semanticType:t,namespace:s.children})}else{let t=nx([...n,r],`namespace`,s,e);i.push({path:[...n,r],type:`namespace`,semanticType:t,namespace:s})}}}else if(ex(e)){if(o?a?e.self.label.startsWith(t):e.self.label.toLowerCase().startsWith(t.toLowerCase()):a?e.self.label===t:e.self.label.toLowerCase()===t.toLowerCase()){let t=nx([...n,e.self.label],`completion`,e.children);i.push({completion:e.self,path:[...n,e.self.label],type:`completion`,semanticType:t,namespace:e.children})}i.push(...ox(e.children,t,n,r))}else if(tx(e)){for(let r of e)if(typeof r==`string`){if(o?a?r.startsWith(t):r.toLowerCase().startsWith(t.toLowerCase()):a?r===t:r.toLowerCase()===t.toLowerCase()){let t=nx([...n,r],`string`,void 0,e);i.push({value:r,path:[...n,r],type:`string`,semanticType:t})}}else if(o?a?r.label.startsWith(t):r.label.toLowerCase().startsWith(t.toLowerCase()):a?r.label===t:r.label.toLowerCase()===t.toLowerCase()){let t=nx([...n,r.label],`completion`,void 0,e);i.push({completion:r,path:[...n,r.label],type:`completion`,semanticType:t})}}return i}function sx(e,t,n={}){let r=[],{maxDepth:i=10}=n;cx(e,[],r,i);let{caseSensitive:a=!1}=n;return r.filter(e=>e.path.some(e=>a?e===t:e.toLowerCase()===t.toLowerCase())).sort((e,n)=>{let r=a?e.path[e.path.length-1]===t:e.path[e.path.length-1]?.toLowerCase()===t.toLowerCase(),i=a?n.path[n.path.length-1]===t:n.path[n.path.length-1]?.toLowerCase()===t.toLowerCase();return r&&!i?-1:!r&&i?1:e.path.length-n.path.length})}function cx(e,t,n,r){if(!(t.length>=r)){if($b(e))for(let[i,a]of Object.entries(e)){let o=[...t,i];if(ex(a)){let t=nx(o,`completion`,a.children,e);n.push({completion:a.self,path:o,type:`completion`,semanticType:t,namespace:a.children}),cx(a.children,o,n,r)}else{let t=nx(o,`namespace`,a,e);n.push({path:o,type:`namespace`,semanticType:t,namespace:a}),cx(a,o,n,r)}}else if(ex(e)){let i=nx(t,`completion`,e.children);n.push({completion:e.self,path:t,type:`completion`,semanticType:i,namespace:e.children}),cx(e.children,t,n,r)}else if(tx(e))for(let r of e)if(typeof r==`string`){let i=nx([...t,r],`string`,void 0,e);n.push({value:r,path:[...t,r],type:`string`,semanticType:i})}else{let i=nx([...t,r.label],`completion`,void 0,e);n.push({completion:r,path:[...t,r.label],type:`completion`,semanticType:i})}}}function lx(e,t,n={}){let{enableFuzzySearch:r=!1}=n,i=rx(e,t,n);if(i)return i;let a=ax(e,t,n);if(a.length>0)return a[0]||null;if(r){let r=sx(e,t,n);if(r.length>0)return r[0]||null}return null}var ux=vn.define({combine:e=>e[0]??null});function dx(e,t){let n=e??t.state.facet(ux);return n==null?null:typeof n==`function`?n(t):n}function fx(e,t){let n=e??t.state.facet(ux);return n==null?null:typeof n==`function`?t.view?n(t.view):null:n}function px(e){if(e==null)return null;let t=ex(e)?e.children:e;return tx(t)?t:null}function mx(e,t){let n=px(rx(e,t,{caseSensitive:!1})?.namespace);if(n)return n;let r=(typeof t==`string`?t.split(`.`):t).map(e=>e.toLowerCase()),i=r[r.length-1];if(!i)return null;let a=sx(e,i).filter(e=>{if(px(e.namespace)===null||e.path.length<r.length)return!1;let t=e.path.slice(-r.length).map(e=>e.toLowerCase());return r.every((e,n)=>t[n]===e)});return a.length===1?px(a[0]?.namespace):null}function hx(e,t,n){if(typeof e==`string`)return n===void 0?{label:e,type:`property`,detail:t}:{label:e,type:`property`,detail:t,boost:n};let r={...e,type:`property`,detail:e.detail??t};return n!==void 0&&r.boost===void 0&&(r.boost=n),r}var gx=e=>{let t;return async()=>(t||=e(),await t)},_x=class{opts;parser=null;offsetRecord={};constructor(e={}){this.opts=e}getParser=gx(async()=>{if(this.parser)return this.parser;let t=await U(()=>import(`./node-sql-parser-DDkYZCP2.js`).then(t=>e(t.default,1)),__vite__mapDeps([213,1]),import.meta.url),{Parser:n}=t.default||t;return this.parser=new n,this.parser});async parse(e,t){this.offsetRecord={};let n=this.opts.getParserOptions?.(t.state),r=await this.sanitizeSql(e,n);try{let e=await this.getParser();return n?.database===`DuckDB`?this.parseWithDuckDBSupport(r,n):{success:!0,errors:[],ast:e.astify(r,n)}}catch(e){return{success:!1,errors:[this.extractErrorInfo(e,r)]}}}async sanitizeSql(e,t){if(t?.ignoreBrackets){let{sql:t,offsetRecord:n}=bx(e);return this.offsetRecord=n,t}return e}async parseWithDuckDBSupport(e,t){let n=await this.getParser(),r=vx(e).trimStart().toLowerCase();if(r.startsWith(`from`)||r.includes(`macro`))return{success:!0,errors:[]};let i=e;r.includes(`create or replace table`)&&(this.offsetRecord[e.indexOf(`create or replace table`)]=-11,i=e.replace(/create or replace table/i,`create table`));try{let e={...t,database:`PostgreSQL`};return{success:!0,errors:[],ast:n.astify(i,e)}}catch(t){return{success:!1,errors:[this.extractErrorInfo(t,e)]}}}extractErrorInfo(e,t){let n=1,r=1,i=e?.message||`SQL parsing error`,a=e;if(a?.location)n=a.location.start?.line||1,r=a.location.start?.column||1;else if(a?.hash)n=a.hash.line||1,r=a.hash.loc?.first_column||1;else{let e=i.match(/line (\d+)/i),t=i.match(/column (\d+)/i);e?.[1]&&(n=parseInt(e[1],10)),t?.[1]&&(r=parseInt(t[1],10))}let o=Object.entries(this.offsetRecord).map(([e,t])=>({position:parseInt(e,10),offset:t})).sort((e,t)=>e.position-t.position),s=0;for(let{position:e,offset:i}of o){let a=e+s;s+=i;let o=t.slice(0,a),c=(o.match(/\n/g)?.length??0)+1,l=a-o.lastIndexOf(`
|
|
101
|
+
`)}function bb(e){return`<marimo-tex class="arithmatex">||(${e.trim()}||)</marimo-tex>`}function xb(e){return`<marimo-tex class="arithmatex">||[${e.trim()}||]</marimo-tex>`}function Sb(e){return e.startsWith(`_`)&&!e.startsWith(`__`)}var Cb=class{documentVersion=0;getNotebookCode;constructor(e){this.getNotebookCode=e}lastSnapshot=null;snapshot(){let e=this.getLens(),t=this.lastSnapshot?.mergedText!==e.mergedText;return t?(this.documentVersion++,this.lastSnapshot=e,{lens:e,didChange:t,version:this.documentVersion}):{lens:e,didChange:t,version:this.documentVersion}}getLatestSnapshot(){if(!this.lastSnapshot)throw Error(`No snapshots`);return{lens:this.lastSnapshot,version:this.documentVersion}}getLens(){let{cellIds:e,codes:t}=this.getNotebookCode();return tb(e,t)}},wb=()=>{let e=KM().cellHandles;return R.mapValues(e,e=>e.current?.editorViewOrNull)};function Tb(e){let t=db(e);return Array.isArray(t)?e:t}function Eb(e){return{...e,documentation:Tb(e.documentation)}}function Db(e){return e==null?null:Array.isArray(e)?e.map(e=>Eb(e)):{...e,items:e.items.map(e=>Eb(e))}}function Ob(e){return{...e,signatures:e.signatures.map(e=>({...e,documentation:Tb(e.documentation),parameters:e.parameters?.map(e=>({...e,documentation:Tb(e.documentation)}))}))}}function kb(e){return Ky(e)&&typeof e.line==`number`&&typeof e.character==`number`}function Ab(e){return Ky(e)&&kb(e.start)&&kb(e.end)}function jb(e){return Ky(e)&&typeof e.message==`string`&&Ab(e.range)}function Mb(e){if(e.method!==`textDocument/publishDiagnostics`||!Ky(e.params))return!1;let{uri:t,version:n,diagnostics:r}=e.params;return typeof t==`string`&&(n===void 0||typeof n==`number`)&&Array.isArray(r)&&r.every(jb)}var Nb=class{documentUri;client;snapshotter;getNotebookEditors;initialSettings;seenCellDocumentUris=new Set;pruneSeenCellUris(e){for(let t of this.seenCellDocumentUris){let n=Ny.parse(t);e.has(n)||this.seenCellDocumentUris.delete(t)}}completionItemCache=new Sp(10);openCellDocumentCounts=new Map;latestDiagnosticsVersion=null;forwardedDiagnosticsVersion=0;constructor(e,t,n=wb){this.documentUri=zy(),this.getNotebookEditors=n,this.initialSettings=t,this.client=e,this.patchProcessNotification(),this.initializePromise.then(()=>{z(Py(this.client),`notify is not a method on the client`),this.client.notify(`workspace/didChangeConfiguration`,{settings:t})}),this.snapshotter=new Cb(this.getNotebookCode.bind(this))}onNotification(e){return this.client.onNotification(e)}get ready(){return this.client.ready}set ready(e){this.client.ready=e}get capabilities(){return this.client.capabilities}set capabilities(e){this.client.capabilities=e}get initializePromise(){return this.client.initializePromise}set initializePromise(e){this.client.initializePromise=e}get clientCapabilities(){return this.client.clientCapabilities}async initialize(){await this.client.initialize()}close(){this.openCellDocumentCounts.clear(),this.client.close()}hasCapability(e){return this.client.hasCapability(e)}async resyncAllDocuments(){z(Py(this.client),`notify is not a method on the client`),await this.client.initialize(),await this.client.notify(`workspace/didChangeConfiguration`,{settings:this.initialSettings});let{lens:e,version:t}=this.snapshotter.snapshot();this.latestDiagnosticsVersion=null,this.forwardedDiagnosticsVersion=0,this.openCellDocumentCounts.size>0&&await this.client.notify(`textDocument/didOpen`,{textDocument:{languageId:`python`,text:e.mergedText,uri:this.documentUri,version:t}}),L.log(`[lsp] Document re-synchronization complete`)}getNotebookCode(){let{cellIds:e,codes:t}=u.get($y),n=this.getNotebookEditors();return{cellIds:e,codes:R.fromEntries(e.map(e=>{let r=n[e];return[e,r?AA(r):t[e]??``]}))}}assertCellDocumentUri(e){z(Ny.is(e),`Execpted URI to be CellDocumentUri`)}async textDocumentDidOpen(e){L.debug(`[lsp] textDocumentDidOpen`,e);let t=e.textDocument.uri;this.assertCellDocumentUri(t);let{lens:n,version:r}=this.snapshotter.snapshot(),i=this.openCellDocumentCounts.get(t)??0;this.openCellDocumentCounts.set(t,i+1);try{let i=await this.client.textDocumentDidOpen({textDocument:{languageId:e.textDocument.languageId,text:n.mergedText,uri:this.documentUri,version:r}});return this.seenCellDocumentUris.add(t),i!==!1}catch(e){let n=this.openCellDocumentCounts.get(t)??0;throw n<=1?this.openCellDocumentCounts.delete(t):this.openCellDocumentCounts.set(t,n-1),e}}async textDocumentDidClose(e){let t=e.textDocument.uri;this.assertCellDocumentUri(t);let n=this.openCellDocumentCounts.get(t)??0;if(n===0){L.warn(`[lsp] textDocumentDidClose with no tracked open`,t);return}n<=1?this.openCellDocumentCounts.delete(t):this.openCellDocumentCounts.set(t,n-1),await this.client.textDocumentDidClose({textDocument:{uri:this.documentUri}})}async sync(){let{lens:e,version:t,didChange:n}=this.snapshotter.snapshot(),r={textDocument:{uri:this.documentUri,version:t},contentChanges:[{text:e.mergedText}]};return n&&await this.client.textDocumentDidChange(r),{params:r,lens:e}}async textDocumentDidChange(e){if(L.debug(`[lsp] textDocumentDidChange`,e),e.contentChanges.length===1){await this.sync();return}L.warn(`[lsp] Unhandled textDocumentDidChange`,e),await this.client.textDocumentDidChange(e)}async textDocumentWillSave(e){this.assertCellDocumentUri(e.textDocument.uri),await this.client.textDocumentWillSave({...e,textDocument:{uri:this.documentUri}})}async textDocumentWillSaveWaitUntil(e){return this.assertCellDocumentUri(e.textDocument.uri),L.debug(`[lsp] willSaveWaitUntil edits are disabled for notebook documents`),null}async textDocumentDidSave(e){this.assertCellDocumentUri(e.textDocument.uri);let{lens:t}=this.snapshotter.snapshot();await this.client.textDocumentDidSave({textDocument:{uri:this.documentUri},text:e.text===void 0?void 0:t.mergedText})}async textDocumentDefinition(e){let t=e.textDocument.uri;if(!Ny.is(t))return L.warn(`Invalid cell document URI`,t),null;let{lens:n}=await this.sync(),r=Ny.parse(t);return this.client.textDocumentDefinition({...e,textDocument:{uri:this.documentUri},position:n.transformPosition(e.position,r)})}async textDocumentSignatureHelp(e){let t=e.textDocument.uri;if(!Ny.is(t))return L.warn(`Invalid cell document URI`,t),null;let{lens:n}=await this.sync(),r=Ny.parse(t),i=await this.client.textDocumentSignatureHelp({...e,textDocument:{uri:this.documentUri},position:n.transformPosition(e.position,r)});return i?Ob(i):null}textDocumentCodeAction(e){return Promise.resolve(null)}codeActionResolve(e){return Promise.resolve(e)}reverseRelatedInformation(e,t){if(e)return e.map(e=>{if(!Ky(e)||!Ky(e.location)||e.location.uri!==this.documentUri||!Ab(e.location.range))return e;let n=t.cellIds.find(n=>t.isInRange(e.location.range,n));return n===void 0?e:{...e,location:{uri:Ny.of(n),range:t.reverseRange(e.location.range,n)}}})}async textDocumentRename(e){let t=e.textDocument.uri;if(!Ny.is(t))return L.warn(`Invalid cell document URI`,t),null;let n=Ny.parse(t),{lens:r}=await this.sync(),i=r.transformPosition(e.position,n),a=await this.client.textDocumentRename({...e,textDocument:{uri:this.documentUri},position:i});if(!a)return null;let o=a.documentChanges?.flatMap(e=>`edits`in e?e.edits:[]);if(!o||o.length!==1)return L.warn(`Expected exactly one edit`,o),a;let s=o[0];if(!(`newText`in s))return L.warn(`Expected newText in edit`,s),a;let c=r.getEditsForNewText(s.newText),l=new Map(c.map(e=>[e.cellId,e.text])),u=this.getNotebookEditors(),d=u[n],f=!1;if(d){let t=d.state.doc.line(e.position.line+1).from+e.position.character,{startToken:n,endToken:r}=Eg(d.state.doc,t),i=d.state.doc.sliceString(n,r);f=Sb(i),f&&L.debug(`[lsp] Private variable rename detected, limiting to current cell`,i)}let p=[],m=0;for(let[e,t]of R.entries(u)){if(f&&e!==n)continue;let r=l.get(e);if(r==null){L.warn(`[lsp] No new code for cell during rename`,e),p.push(e);continue}if(!t){L.warn(`[lsp] No editor view for cell during rename`,e),p.push(e);continue}AA(t)!==r&&(jA(t,r),m++)}return p.length>0&&L.error(`[lsp] Rename partially failed: could not update ${p.length} cell(s)`,p),L.debug(`[lsp] Rename completed: updated ${m} cell(s)`),{...a,documentChanges:[{edits:[],textDocument:{uri:t,version:0}}]}}async completionItemResolve(e){let t=JSON.stringify(e),n=this.completionItemCache.get(t);if(n)return n;let r=this.client.completionItemResolve(e).then(e=>Eb(e));return this.completionItemCache.set(t,r),r}async textDocumentPrepareRename(e){let t=e.textDocument.uri;if(!Ny.is(t))return L.warn(`Invalid cell document URI`,t),null;let{lens:n}=await this.sync(),r=Ny.parse(t);return this.client.textDocumentPrepareRename({...e,textDocument:{uri:this.documentUri},position:n.transformPosition(e.position,r)})}async textDocumentHover(e){L.debug(`[lsp] textDocumentHover`,e);let{lens:t}=await this.sync(),n=Ny.parse(e.textDocument.uri),r=await this.client.textDocumentHover({...e,textDocument:{uri:this.documentUri},position:t.transformPosition(e.position,n)});return r?(typeof r.contents==`object`&&`kind`in r.contents&&(r.contents={kind:`markdown`,value:r.contents.value}),r.contents=db(r.contents)??r.contents,r.contents===``?null:(r.range&&=t.reverseRange(r.range,n),r)):(L.debug(`[lsp] no hover result`),r)}async textDocumentCompletion(e){let{lens:t}=await this.sync();if(!Ny.is(e.textDocument.uri))return L.error(`[lsp] Invalid cell document URI in completion request`,e.textDocument.uri),null;let n=Ny.parse(e.textDocument.uri);if(!n||n===`undefined`)return L.error(`[lsp] Invalid cellId 'undefined' in completion request`,{cellId:n,uri:e.textDocument.uri,availableCellIds:t.cellIds}),null;t.cellIds.includes(n)||L.warn(`[lsp] CellId in completion request not found in current lens`,{cellId:n,uri:e.textDocument.uri,availableCellIds:t.cellIds});let r=t.transformPosition(e.position,n);return Db(await this.client.textDocumentCompletion({...e,textDocument:{uri:this.documentUri},position:r}))}patchProcessNotification(){z(Fy(this.client),`processNotification is not a method on the client`);let e=this.client.processNotification.bind(this.client),t=t=>{if(Mb(t)){let n=t.params.version;if(n!=null){let e=this.latestDiagnosticsVersion;if(e!==null&&Number.isFinite(n)&&n<e){L.debug(`[lsp] dropping stale diagnostics notification`,t);return}this.latestDiagnosticsVersion=n}L.debug(`[lsp] handling diagnostics`,t);let r=this.snapshotter.getLatestSnapshot(),i=t.params.diagnostics,{lens:a}=r,o=++this.forwardedDiagnosticsVersion,s=new Map;for(let e of i)for(let t of a.cellIds)if(a.isInRange(e.range,t)){s.has(t)||s.set(t,[]);let n=this.reverseRelatedInformation(e.relatedInformation,a),r={...e,range:a.reverseRange(e.range,t),...n?{relatedInformation:n}:{}};s.get(t)?.push(r);break}let c=new Set(a.cellIds);this.pruneSeenCellUris(c);let l=new Set(this.seenCellDocumentUris);for(let[n,r]of s.entries()){L.debug(`[lsp] diagnostics for cell`,n,r);let i=Ny.of(n);l.delete(i),e({...t,params:{...t.params,uri:i,version:o,diagnostics:r}})}if(l.size>0){L.debug(`[lsp] clearing diagnostics`,l);for(let t of l)e({method:`textDocument/publishDiagnostics`,params:{uri:t,version:o,diagnostics:[]}})}return}return e(t)};this.client.processNotification=t}},Pb=1e3,Fb=new Set([`textDocument/didOpen`,`textDocument/didChange`,`textDocument/didClose`]),Ib=new Set([`initialize`,`initialized`,`workspace/didChangeConfiguration`,`textDocument/didOpen`]),Lb=class{delegate;connectionPromise;isDelegateConnected=!1;connectionGeneration=0;restoringGeneration;isClosed=!1;hasConnectedBefore=!1;messageHandlers=new Set;pendingMessages=[];inFlightBacklog;hasLoggedQueueOverflow=!1;disposeDelegateMessage;disposeDelegateClose;options;onReconnect;constructor(e){this.options={...e,retries:e.retries??1,retryDelayMs:e.retryDelayMs??1e3},this.onReconnect=e.onReconnect}async connect(){if(this.isClosed)throw Error(`Transport is closed`);if(this.isDelegateConnected)return;if(this.connectionPromise)return this.connectionPromise;let e=++this.connectionGeneration,t=this.connectWithRetries(e).finally(()=>{this.connectionPromise===t&&(this.connectionPromise=void 0)});return this.connectionPromise=t,t}isStale(e){return this.isClosed||e!==this.connectionGeneration}send(e){if(!this.isClosed){if(this.delegate&&this.isDelegateConnected&&(this.restoringGeneration===void 0||this.canSendWhileRestoring(e))){this.delegate.send(e);return}this.pendingMessages.length<Pb?this.pendingMessages.push(e):this.hasLoggedQueueOverflow||(this.hasLoggedQueueOverflow=!0,L.error(`LSP reconnect queue is full (${Pb}); dropping messages until it drains`)),this.reconnect()}}onMessage(e){return this.messageHandlers.add(e),()=>{this.messageHandlers.delete(e)}}close(){this.isClosed||(this.isClosed=!0,this.isDelegateConnected=!1,this.restoringGeneration=void 0,this.connectionGeneration++,this.connectionPromise=void 0,this.pendingMessages=[],this.inFlightBacklog=void 0,this.messageHandlers.clear(),this.disposeDelegate(),this.delegate?.close(),this.delegate=void 0)}async connectWithRetries(e){let t;for(let n=1;n<=this.options.retries;n++)try{await this.connectDelegate(e);return}catch(r){if(t=r instanceof Error?r:Error(String(r)),this.isStale(e))throw t;this.invalidateDelegate(),L.warn(`WebSocket connection attempt ${n}/${this.options.retries} failed`,t),n<this.options.retries&&await new Promise(e=>setTimeout(e,this.options.retryDelayMs))}let n=t??Error(`WebSocket connection failed`);throw this.options.onConnectionFailure?.(n),n}async connectDelegate(e){if(await this.options.waitForConnection?.(),this.isStale(e))throw Error(`Connection attempt abandoned`);let t=this.createDelegate();if(await t.connect(),this.isStale(e)||this.delegate!==t)throw t.close(),Error(`Transport closed while connecting`);this.isDelegateConnected=!0;let n=this.hasConnectedBefore;this.hasConnectedBefore=!0;let r=this.detachPendingMessages();this.inFlightBacklog=r;try{if(n){this.restoringGeneration=e;try{await this.onReconnect?.()}finally{this.restoringGeneration===e&&(this.restoringGeneration=void 0)}}if(this.isStale(e)||this.delegate!==t||!this.isDelegateConnected)throw Error(`WebSocket closed while restoring LSP state`)}catch(t){throw this.isStale(e)||this.reclaimInFlightBacklog(),t}let i=n&&this.onReconnect?r.filter(e=>!(`method`in e&&Fb.has(e.method))):r;this.inFlightBacklog=void 0;for(let e of[...i,...this.detachPendingMessages()])t.send(e);L.log(`WebSocket transport connected successfully`)}detachPendingMessages(){let e=this.pendingMessages;return this.pendingMessages=[],this.hasLoggedQueueOverflow=!1,e}reclaimInFlightBacklog(){this.inFlightBacklog&&=(this.pendingMessages=[...this.inFlightBacklog,...this.pendingMessages].slice(0,Pb),void 0)}canSendWhileRestoring(e){return!(`method`in e)||Ib.has(e.method)}createDelegate(){this.invalidateDelegate();let e=new Ad(this.options.getWsUrl());return this.delegate=e,this.disposeDelegateMessage=e.onMessage(e=>{for(let t of this.messageHandlers)try{t(e)}catch(e){L.error(`LSP message handler failed`,e)}}),this.disposeDelegateClose=e.onClose(t=>{this.delegate!==e||this.isClosed||(L.warn(`WebSocket transport connection closed`,t),this.isDelegateConnected=!1,this.disposeDelegate(),this.delegate=void 0,this.restoringGeneration=void 0,this.reclaimInFlightBacklog(),this.connectionPromise=void 0,queueMicrotask(()=>this.reconnect()))}),e}reconnect(){this.connect().catch(e=>{L.error(`WebSocket transport reconnection failed`,e)})}invalidateDelegate(){this.isDelegateConnected=!1,this.restoringGeneration=void 0,this.disposeDelegate(),this.delegate?.close(),this.delegate=void 0}disposeDelegate(){this.disposeDelegateMessage?.(),this.disposeDelegateMessage=void 0,this.disposeDelegateClose?.(),this.disposeDelegateClose=void 0}},Rb=new Set([1,2]);function zb(e,t){if(!(`method`in t)||t.method!==`window/logMessage`)return;let n=t.params;!Ky(n)||typeof n.message!=`string`||OM({logs:[{timestamp:Date.now()/1e3,level:Rb.has(n.type)?`stderr`:`stdout`,message:n.message,source:{type:`lsp`,name:e}}]})}function Bb(e,t){let n=Ce(),r=new Lb({getWsUrl:()=>n.getLSPURL(e).toString(),waitForConnection:async()=>{await be()},onReconnect:t});return r.onMessage(t=>zb(e,t)),r}xn.define(),new En;function Vb(e){return e.facet(pn.readOnly)}function Hb(e){return[cn(e),dn.of([{key:`ArrowRight`,preventDefault:!0,run:t=>Ub(t,e)},{key:`Tab`,preventDefault:!0,run:t=>Ub(t,e)}])]}function Ub(e,t){if(Vb(e.state))return!1;let n=e.state.doc.length;return n===0&&(e.dispatch({changes:{from:0,to:n,insert:t},selection:{head:t.length,anchor:t.length}}),!0)}function Wb(e){let{beforeText:t,linkText:n,afterText:r,onClick:i}=e;return[cn(e=>{let a=document.createElement(`span`);a.append(document.createTextNode(t));let o=document.createElement(`span`);return o.textContent=n,o.classList.add(`cm-clickable-placeholder`),o.onclick=t=>{t.stopPropagation(),i(e)},a.append(o),a.append(document.createTextNode(r)),a}),Kn.theme({".cm-placeholder":{color:`var(--slate-8)`},".cm-clickable-placeholder":{cursor:`pointer !important`,pointerEvents:`auto`,color:`var(--slate-9)`,textDecoration:`underline`,textUnderlineOffset:`0.2em`},".cm-clickable-placeholder:hover":{color:`var(--sky-11)`}})]}var Gb=Er(e=>{let t,n={transport:Bb(`pylsp`,async()=>{await t?.()}),rootUri:Ly(),workspaceFolders:Ry()},r=e?.pylsp,i=[`D100`,`D103`],a=[`W292`,`E402`,`E302`,`E305`],o=[`B018`,`I001`],s={pylsp:{plugins:{marimo_plugin:{enabled:!0},jedi:{auto_import_modules:[`numpy`]},jedi_completion:{include_params:!0,resolve_at_most:50},flake8:{enabled:r?.enable_flake8,extendIgnore:a},pydocstyle:{enabled:r?.enable_pydocstyle,ignore:i},pylint:{enabled:r?.enable_pylint},pyflakes:{enabled:r?.enable_pyflakes},pylsp_mypy:{enabled:r?.enable_mypy,live_mode:!0},ruff:{enabled:r?.enable_ruff,extendIgnore:[...a,...i,...o]},signature:{formatter:r?.enable_ruff?`ruff`:`black`,line_length:88}}}},c=new Nb(new kd({...n}),s);return t=()=>c.resyncAllDocuments(),c}),Kb=Er(e=>{let t,n=new Nb(new kd({transport:Bb(`ty`,async()=>{await t?.()}),rootUri:Ly(),workspaceFolders:Ry(),getWorkspaceConfiguration:()=>[{disableLanguageServices:!0}]}),{});return t=()=>n.resyncAllDocuments(),n}),qb=Er(e=>{let t,n=new Nb(new kd({transport:Bb(`pyrefly`,async()=>{await t?.()}),rootUri:Ly(),workspaceFolders:Ry(),initializationOptions:{pyrefly:{displayTypeErrors:e.diagnostics?.enabled??!1?`force-on`:`force-off`}}}),{});return t=()=>n.resyncAllDocuments(),n}),Jb=Er(e=>{let t,n=new Nb(new kd({transport:Bb(`basedpyright`,async()=>{await t?.()}),rootUri:Ly(),workspaceFolders:Ry()}),{});return t=()=>n.resyncAllDocuments(),n}),Yb=class{parser=new Qm;type=`python`;defaultCode=this.parser.defaultCode;defaultMetadata=this.parser.defaultMetadata;transformIn(e){let t=this.parser.transformIn(e);return[t.code,t.offset,t.metadata]}transformOut(e,t){let n=this.parser.transformOut(e,t);return[n.code,n.offset]}isSupported(e){return this.parser.isSupported(e)}getExtension(e,t,n,r,i){return[(()=>{let r={defaultKeymap:!1,activateOnTyping:t.activate_on_typing,closeOnBlur:!1},a={hideOnChange:!0},o=[];i?.pylsp?.enabled&&tg(`pylsp`)&&o.push(Gb(i)),i?.ty?.enabled&&tg(`ty`)&&o.push(Kb(i)),i?.pyrefly?.enabled&&tg(`pyrefly`)&&o.push(qb(i)),i?.basedpyright?.enabled&&tg(`basedpyright`)&&o.push(Jb(i));let s=t.signature_hint_on_typing,c=s?/(\w+|\w+\.|\/)$/:/(\w+|\w+\.|\(|\/|,)$/;if(o.length>0){let t=o.length===1?o[0]:new Hy(o),l=e=>{L.debug(`openExternalLocation`,e),!(t.documentUri===e.uri||Iy(e.uri))&&Br().openFile({path:e.uri.replace(`file://`,``)})};return[Yd({client:t,languageId:`python`,allowHTMLContent:!0,markdownRenderer:Gy(),useSnippetOnCompletion:!0,clientSideFiltering:!0,hoverConfig:a,completionConfig:r,diagnosticsEnabled:i.diagnostics?.enabled??!1,sendIncrementalChanges:!1,signatureHelpEnabled:!0,signatureActivateOnTyping:s,signatureHelpOptions:{position:`above`},keyboardShortcuts:{signatureHelp:n.getHotkey(`cell.signatureHelp`).key,goToDefinition:n.getHotkey(`cell.goToDefinition`).key,rename:n.getHotkey(`cell.renameSymbol`).key},completionMatchBefore:c,onGoToDefinition:l,onShowLocation:l}),vd.of(Ny.of(e))]}return[Fr({...r,override:[Gv]}),Uv]})(),Qb(),Xb(r)]}};function Xb(e){return e===`marimo-import`?gn.highest(Hb(`import marimo as mo`)):e===`ai`?Wb({beforeText:`Start coding or `,linkText:`generate`,afterText:` with AI.`,onClick:e=>{e.state.facet(kf).aiCellCompletion()}}):[]}var Zb=ri.configure({props:[un.add({ParenthesizedExpression:Cn,ArgList:Cn})]});function Qb(){return new Jn(Zb,[Zb.data.of({autocomplete:ii}),Zb.data.of({autocomplete:oi})])}function $b(e){return typeof e==`object`&&!Array.isArray(e)&&!ex(e)}function ex(e){if(typeof e!=`object`||Array.isArray(e)||!(`self`in e)||!(`children`in e))return!1;let t=e.self;return typeof t==`object`&&!!t&&!Array.isArray(t)&&typeof t.label==`string`}function tx(e){return Array.isArray(e)}function nx(e,t,n,r){let i=e.length;if(t===`string`||t===`completion`&&r&&tx(r))return`column`;if(t===`namespace`&&n){if(tx(n))return`table`;if($b(n))return Object.values(n).some(e=>tx(e)||ex(e)&&tx(e.children))?i<=1?`database`:`schema`:i===0?`database`:`namespace`}if(t===`completion`&&n)return tx(n)?`table`:($b(n)&&Object.values(n).some(e=>tx(e)||ex(e)&&tx(e.children)),i<=1?`database`:`schema`);switch(i){case 0:return`database`;case 1:return`schema`;default:return`namespace`}}function rx(e,t,n={}){let{maxDepth:r=10}=n;if((typeof t==`string`?t===``:t.length===0)&&ex(e)){let t=nx([],`completion`,e.children);return{completion:e.self,path:[],type:`completion`,semanticType:t,namespace:e.children}}let i=(typeof t==`string`?t.split(`.`):t).filter(e=>e.length>0);return i.length===0||i.length>r?null:ix(e,i,[],n)}function ix(e,t,n,r,i){if(t.length===0){if(ex(e)){let t=nx(n,`completion`,e.children,i);return{completion:e.self,path:n,type:`completion`,semanticType:t,namespace:e.children}}return{path:n,type:`namespace`,semanticType:nx(n,`namespace`,e,i),namespace:e}}let[a,...o]=t,{caseSensitive:s=!1}=r;if(!a)return null;if($b(e)){let t=s?Object.keys(e).find(e=>e===a):Object.keys(e).find(e=>e.toLowerCase()===a.toLowerCase());if(t){let i=e[t];if(i)return ix(i,o,[...n,t],r,e)}}else if(ex(e))return ix(e.children,t,n,r,e);else if(tx(e)){for(let t of e)if(typeof t==`string`){if((s?t===a:t.toLowerCase()===a.toLowerCase())&&o.length===0){let r=nx([...n,t],`string`,void 0,e);return{value:t,path:[...n,t],type:`string`,semanticType:r}}}else if((s?t.label===a:t.label.toLowerCase()===a.toLowerCase())&&o.length===0){let r=nx([...n,t.label],`completion`,void 0,e);return{completion:t,path:[...n,t.label],type:`completion`,semanticType:r}}}return null}function ax(e,t,n={}){let r=[];if(t.includes(`.`)){let r=t.lastIndexOf(`.`),i=t.substring(0,r),a=t.substring(r+1),o=rx(e,i,n);if(o?.namespace)return ox(o.namespace,a,o.path,n)}else return ox(e,t,[],n);return r}function ox(e,t,n,r){let i=[],{caseSensitive:a=!1,allowPartialMatch:o=!0}=r;if($b(e)){for(let[r,s]of Object.entries(e))if(o?a?r.startsWith(t):r.toLowerCase().startsWith(t.toLowerCase()):a?r===t:r.toLowerCase()===t.toLowerCase()){if(ex(s)){let t=nx([...n,r],`completion`,s.children,e);i.push({completion:s.self,path:[...n,r],type:`completion`,semanticType:t,namespace:s.children})}else{let t=nx([...n,r],`namespace`,s,e);i.push({path:[...n,r],type:`namespace`,semanticType:t,namespace:s})}}}else if(ex(e)){if(o?a?e.self.label.startsWith(t):e.self.label.toLowerCase().startsWith(t.toLowerCase()):a?e.self.label===t:e.self.label.toLowerCase()===t.toLowerCase()){let t=nx([...n,e.self.label],`completion`,e.children);i.push({completion:e.self,path:[...n,e.self.label],type:`completion`,semanticType:t,namespace:e.children})}i.push(...ox(e.children,t,n,r))}else if(tx(e)){for(let r of e)if(typeof r==`string`){if(o?a?r.startsWith(t):r.toLowerCase().startsWith(t.toLowerCase()):a?r===t:r.toLowerCase()===t.toLowerCase()){let t=nx([...n,r],`string`,void 0,e);i.push({value:r,path:[...n,r],type:`string`,semanticType:t})}}else if(o?a?r.label.startsWith(t):r.label.toLowerCase().startsWith(t.toLowerCase()):a?r.label===t:r.label.toLowerCase()===t.toLowerCase()){let t=nx([...n,r.label],`completion`,void 0,e);i.push({completion:r,path:[...n,r.label],type:`completion`,semanticType:t})}}return i}function sx(e,t,n={}){let r=[],{maxDepth:i=10}=n;cx(e,[],r,i);let{caseSensitive:a=!1}=n;return r.filter(e=>e.path.some(e=>a?e===t:e.toLowerCase()===t.toLowerCase())).sort((e,n)=>{let r=a?e.path[e.path.length-1]===t:e.path[e.path.length-1]?.toLowerCase()===t.toLowerCase(),i=a?n.path[n.path.length-1]===t:n.path[n.path.length-1]?.toLowerCase()===t.toLowerCase();return r&&!i?-1:!r&&i?1:e.path.length-n.path.length})}function cx(e,t,n,r){if(!(t.length>=r)){if($b(e))for(let[i,a]of Object.entries(e)){let o=[...t,i];if(ex(a)){let t=nx(o,`completion`,a.children,e);n.push({completion:a.self,path:o,type:`completion`,semanticType:t,namespace:a.children}),cx(a.children,o,n,r)}else{let t=nx(o,`namespace`,a,e);n.push({path:o,type:`namespace`,semanticType:t,namespace:a}),cx(a,o,n,r)}}else if(ex(e)){let i=nx(t,`completion`,e.children);n.push({completion:e.self,path:t,type:`completion`,semanticType:i,namespace:e.children}),cx(e.children,t,n,r)}else if(tx(e))for(let r of e)if(typeof r==`string`){let i=nx([...t,r],`string`,void 0,e);n.push({value:r,path:[...t,r],type:`string`,semanticType:i})}else{let i=nx([...t,r.label],`completion`,void 0,e);n.push({completion:r,path:[...t,r.label],type:`completion`,semanticType:i})}}}function lx(e,t,n={}){let{enableFuzzySearch:r=!1}=n,i=rx(e,t,n);if(i)return i;let a=ax(e,t,n);if(a.length>0)return a[0]||null;if(r){let r=sx(e,t,n);if(r.length>0)return r[0]||null}return null}var ux=vn.define({combine:e=>e[0]??null});function dx(e,t){let n=e??t.state.facet(ux);return n==null?null:typeof n==`function`?n(t):n}function fx(e,t){let n=e??t.state.facet(ux);return n==null?null:typeof n==`function`?t.view?n(t.view):null:n}function px(e){if(e==null)return null;let t=ex(e)?e.children:e;return tx(t)?t:null}function mx(e,t){let n=px(rx(e,t,{caseSensitive:!1})?.namespace);if(n)return n;let r=(typeof t==`string`?t.split(`.`):t).map(e=>e.toLowerCase()),i=r[r.length-1];if(!i)return null;let a=sx(e,i).filter(e=>{if(px(e.namespace)===null||e.path.length<r.length)return!1;let t=e.path.slice(-r.length).map(e=>e.toLowerCase());return r.every((e,n)=>t[n]===e)});return a.length===1?px(a[0]?.namespace):null}function hx(e,t,n){if(typeof e==`string`)return n===void 0?{label:e,type:`property`,detail:t}:{label:e,type:`property`,detail:t,boost:n};let r={...e,type:`property`,detail:e.detail??t};return n!==void 0&&r.boost===void 0&&(r.boost=n),r}var gx=e=>{let t;return async()=>(t||=e(),await t)},_x=class{opts;parser=null;offsetRecord={};constructor(e={}){this.opts=e}getParser=gx(async()=>{if(this.parser)return this.parser;let t=await U(()=>import(`./node-sql-parser-DDkYZCP2.js`).then(t=>e(t.default,1)),__vite__mapDeps([213,1]),import.meta.url),{Parser:n}=t.default||t;return this.parser=new n,this.parser});async parse(e,t){this.offsetRecord={};let n=this.opts.getParserOptions?.(t.state),r=await this.sanitizeSql(e,n);try{let e=await this.getParser();return n?.database===`DuckDB`?this.parseWithDuckDBSupport(r,n):{success:!0,errors:[],ast:e.astify(r,n)}}catch(e){return{success:!1,errors:[this.extractErrorInfo(e,r)]}}}async sanitizeSql(e,t){if(t?.ignoreBrackets){let{sql:t,offsetRecord:n}=bx(e);return this.offsetRecord=n,t}return e}async parseWithDuckDBSupport(e,t){let n=await this.getParser(),r=vx(e).trimStart().toLowerCase();if(r.startsWith(`from`)||r.includes(`macro`))return{success:!0,errors:[]};let i=e;r.includes(`create or replace table`)&&(this.offsetRecord[e.indexOf(`create or replace table`)]=-11,i=e.replace(/create or replace table/i,`create table`));try{let e={...t,database:`PostgreSQL`};return{success:!0,errors:[],ast:n.astify(i,e)}}catch(t){return{success:!1,errors:[this.extractErrorInfo(t,e)]}}}extractErrorInfo(e,t){let n=1,r=1,i=e?.message||`SQL parsing error`,a=e;if(a?.location)n=a.location.start?.line||1,r=a.location.start?.column||1;else if(a?.hash)n=a.hash.line||1,r=a.hash.loc?.first_column||1;else{let e=i.match(/line (\d+)/i),t=i.match(/column (\d+)/i);e?.[1]&&(n=parseInt(e[1],10)),t?.[1]&&(r=parseInt(t[1],10))}let o=Object.entries(this.offsetRecord).map(([e,t])=>({position:parseInt(e,10),offset:t})).sort((e,t)=>e.position-t.position),s=0;for(let{position:e,offset:i}of o){let a=e+s;s+=i;let o=t.slice(0,a),c=(o.match(/\n/g)?.length??0)+1,l=a-o.lastIndexOf(`
|
|
102
102
|
`);n===c&&r>l&&(r-=i)}return r>t.length&&(r=t.length),{message:this.cleanErrorMessage(i),line:Math.max(1,n),column:Math.max(1,r),severity:`error`}}cleanErrorMessage(e){return e.replace(/^Error: /,``).replace(/Expected .* but .* found\./i,e=>e.replace(/but .* found/,`found unexpected token`)).trim()}async validateSql(e,t){return(await this.parse(e,t)).errors}async extractTableReferences(e,t){let n=t?this.opts.getParserOptions?.(t.state):void 0;try{return(await this.getParser()).tableList(e,n).map(e=>{let t=e.split(`::`);return t[t.length-1]||e})}catch{return[]}}async extractColumnReferences(e,t){let n=t?.state?this.opts.getParserOptions?.(t.state):void 0;try{return(await this.getParser()).columnList(e,n).map(e=>{let t=e.split(`::`);return t[t.length-1]||e})}catch{return[]}}};function vx(e,t=[`/*`,`--`]){let n=[];if(t.includes(`/*`)&&n.push(`/\\*[\\s\\S]*?\\*/`),t.includes(`--`)&&n.push(`--[^\\n]*`),n.length===0)return e;let r=RegExp(`^\\s*(${n.join(`|`)})\\s*`,``),i=e,a=``;for(;i!==a;)a=i,i=i.replace(r,``);return i}var yx=2;function bx(e){let t={};return{sql:e.replace(/("[^"\\]*(?:\\.[^"\\]*)*")|('[^'\\]*(?:\\.[^'\\]*)*')|(\{[^}]*\})/g,(e,n,r,i,a)=>n||r?e:i?(t[a]=yx,`'${i}'`):e),offsetRecord:t}}function xx(){return{tables:[],ctes:[],aliases:new Map,selectAliases:[]}}function Sx(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Cx(e){return Array.isArray(e)?e:[]}function wx(e){let t=e[0],n=e[e.length-1];return e.length>=2&&(t===`"`&&n===`"`||t===`'`&&n===`'`||t==="`"&&n==="`"||t===`[`&&n===`]`)?e.slice(1,-1):e}function Tx(e){return typeof e==`string`?e:Sx(e)&&typeof e.value==`string`?e.value:null}function Ex(e){if(!Sx(e)||e.type!==`column_ref`)return null;let t=e.column;if(typeof t==`string`)return t;if(Sx(t)){let e=t.expr,n=Sx(e)?e.value:t.value;if(typeof n==`string`)return n}return null}function Dx(e){let t=Cx(e.columns).map(e=>Tx(e)??Ex(e)??Tx(e.column)).filter(e=>typeof e==`string`);if(t.length>0)return t;let n=e.stmt,r=Sx(n)?n.ast??n:null;if(!Sx(r)||r.type!==`select`)return[];let i=[];for(let e of Cx(r.columns))if(typeof e.as==`string`)i.push(e.as);else{let t=Ex(e.expr);t&&t!==`*`&&i.push(t)}return i}function Ox(e,t){if(typeof e.table!=`string`||e.table.length===0)return;let n=[e.db??e.catalog,e.schema,e.table].filter(e=>typeof e==`string`&&e.length>0).map(wx),r=typeof e.as==`string`?wx(e.as):void 0,i=`${n.join(`.`).toLowerCase()}::${r?.toLowerCase()??``}`;t.seenTables.has(i)||(t.seenTables.add(i),t.tables.push({name:wx(e.table),path:n,...r?{alias:r}:{}}))}function kx(e,t,n){if(Array.isArray(e)){for(let r of e)kx(r,t,n);return}if(!(!Sx(e)||n.has(e))){n.add(e);for(let n of Cx(e.with)){let e=Tx(n.name);e&&!t.seenCtes.has(e.toLowerCase())&&(t.seenCtes.add(e.toLowerCase()),t.ctes.push({name:wx(e),columns:Dx(n).map(wx),from:-1,to:-1}))}for(let n of[`from`,`table`])for(let r of Cx(e[n]))Ox(r,t);for(let[r,i]of Object.entries(e))r!==`loc`&&r!==`tableList`&&r!==`columnList`&&kx(i,t,n)}}function Ax(e,t){if(e.type===`select`)for(let n of Cx(e.columns))typeof n.as==`string`&&t.selectAliases.push(wx(n.as))}function jx(e,t){let n=t.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),r=`(?:"${n}"|\`${n}\`|\\[${n}\\]|\\b${n})`,i=RegExp(`(${r})\\s*(?:\\([^)]*\\)\\s*)?AS\\s*\\(`,`i`).exec(e);return!i||i.index<0||!i[1]?{from:-1,to:-1}:{from:i.index,to:i.index+i[1].length}}var Mx=new Set(`as.on.using.where.join.inner.left.right.full.cross.outer.natural.lateral.group.order.limit.offset.having.union.intersect.except.select.set.values.when.then.and.or.not.in.is.asc.desc.fetch.window.qualify.returning.with`.split(`.`)),Nx=String.raw`(?:[\w$]+|"[^"]+"|\`[^\`]+\`|\[[^\]]+\])`,Px=`(?!(?:${[...Mx].join(`|`)})\\b)`,Fx=new RegExp(String.raw`\b(?:from|join)\s+(${Nx}(?:\.${Nx})*)(?:\s+(?:as\s+)?${Px}(${Nx}))?`,`gi`);function Ix(e){let t=e.split(``),n=0;for(;n<e.length;){let r=e[n],i=e[n+1];if(r===`-`&&i===`-`){for(;n<e.length&&e[n]!==`
|
|
103
103
|
`;)t[n]=` `,n++;continue}if(r===`/`&&i===`*`){for(t[n]=` `,t[n+1]=` `,n+=2;n<e.length&&(e[n]!==`*`||e[n+1]!==`/`);)t[n]=` `,n++;n<e.length&&(t[n]=` `,t[n+1]=` `,n+=2);continue}if(r===`"`||r==="`"||r===`[`){let t=r===`[`?`]`:r;for(n++;n<e.length&&e[n]!==t;)n++;n++;continue}if(r===`'`){for(t[n]=` `,n++;n<e.length;){if(e[n]===`'`){if(t[n]=` `,e[n+1]===`'`){t[n+1]=` `,n+=2;continue}n++;break}t[n]=` `,n++}continue}n++}return t.join(``)}function Lx(e){let t={tables:[],ctes:[],selectAliases:[],seenTables:new Set,seenCtes:new Set},n=Ix(e);Rx(n,t),Fx.lastIndex=0;let r=Fx.exec(n);for(;r!==null;){let e=r[1],i=r[2];if(e){let n=e.split(`.`).map(wx),r=n[n.length-1]??``,a=i&&!Mx.has(i.toLowerCase())?wx(i):void 0,o=`${n.join(`.`).toLowerCase()}::${a?.toLowerCase()??``}`;r&&!t.seenTables.has(o)&&(t.seenTables.add(o),t.tables.push({name:r,path:n,...a?{alias:a}:{}}))}r=Fx.exec(n)}return Vx(t)}function Rx(e,t){let n=/\bWITH\s+(?:RECURSIVE\s+)?/gi,r=new RegExp(String.raw`^(${Nx})\s*(?:\(([^)]*)\)\s*)?AS\s*\(`,`i`),i=n.exec(e);for(;i!==null;){let a=i.index+i[0].length;for(;;){let n=r.exec(e.slice(a)),i=n?.[1],o=i?wx(i):void 0;if(!n||!i||!o)break;let s=a+n[0].length,c=s,l=1;for(;c<e.length&&l>0;)e[c]===`(`?l++:e[c]===`)`&&l--,c++;if(!t.seenCtes.has(o.toLowerCase())){t.seenCtes.add(o.toLowerCase());let r=(n[2]??``).split(`,`).map(e=>wx(e.trim())).filter(e=>e.length>0);t.ctes.push({name:o,columns:r.length>0?r:Bx(e.slice(s,Math.max(s,c-1))),from:a,to:a+i.length})}let u=/^\s*,\s*/.exec(e.slice(c));if(!u)break;a=c+u[0].length}i=n.exec(e)}}function zx(e){let t=[],n=0,r=``;for(let i of e)i===`(`?n++:i===`)`&&(n=Math.max(0,n-1)),i===`,`&&n===0?(t.push(r),r=``):r+=i;return t.push(r),t}function Bx(e){let t=/^\s*SELECT\s+(?:DISTINCT\s+)?([\s\S]*?)\s+FROM\s/i.exec(e);if(!t||!t[1])return[];let n=[];for(let e of zx(t[1])){let t=e.trim(),r=new RegExp(String.raw`\s+AS\s+(${Nx})$`,`i`).exec(t);if(r?.[1]){n.push(wx(r[1]));continue}if(/^(?:[\w$]+\.)*[\w$]+$/.test(t)){let e=t.split(`.`),r=e[e.length-1];r&&r!==`*`&&n.push(r)}}return n}function Vx(e){let t=new Map;for(let n of e.tables)if(n.alias){let e=n.alias.toLowerCase();t.has(e)||t.set(e,n.path.join(`.`))}return{tables:e.tables,ctes:e.ctes,aliases:t,selectAliases:e.selectAliases}}async function Hx(e,t,n){if(!e.trim())return xx();let r=null;try{let i=await t.parse(e,n);i.success&&i.ast!=null&&(r=i.ast)}catch{}if(r==null)return Lx(e);try{let t={tables:[],ctes:[],selectAliases:[],seenTables:new Set,seenCtes:new Set},n=Array.isArray(r)?r:[r];for(let e of n)Sx(e)&&Ax(e,t);kx(r,t,new Set);let i=Ix(e);for(let e of t.ctes){let t=jx(i,e.name);e.from=t.from,e.to=t.to}return Vx(t)}catch{return Lx(e)}}var Ux=class{parser;cache=new Map;MAX_CACHE_SIZE=20;constructor(e=new _x){this.parser=e}async getContext(e,t){let n=this.cache.get(e);if(n)return n;let r=await Hx(e,this.parser,t);if(this.cache.set(e,r),this.cache.size>this.MAX_CACHE_SIZE){let e=this.cache.keys().next().value;e!==void 0&&this.cache.delete(e)}return r}clearCache(){this.cache.clear()}},Wx=class{parser;cache=new Map;MAX_CACHE_SIZE=10;constructor(e){this.parser=e}async analyzeDocument(e){let t=e.doc.toString(),n=this.cache.get(t);if(n)return n;let r=await this.extractStatements(t,e);if(this.cache.set(t,r),this.cache.size>this.MAX_CACHE_SIZE){let e=this.cache.keys().next().value;e!==void 0&&this.cache.delete(e)}return r}async getStatementAtPosition(e,t){return(await this.analyzeDocument(e)).find(e=>t>=e.from&&t<=e.to)||null}async getStatementsInRange(e,t,n){return(await this.analyzeDocument(e)).filter(e=>e.from<=n&&e.to>=t)}async extractStatements(e,t){let n=[],r=this.splitByStatementSeparators(e),i=0;for(let e of r){let r=e.trim();if(r.length===0){i+=e.length;continue}let a=i+e.indexOf(r),o=a+r.length,s=t.doc.lineAt(a),c=t.doc.lineAt(o),l=this.stripComments(r);if(l.trim().length===0||l.trim()===`;`){i+=e.length;continue}let u=await this.parser.parse(r,{state:t}),d=this.determineStatementType(l),f=l.endsWith(`;`)?l.slice(0,-1).trim():l.trim();n.push({from:a,to:o,lineFrom:s.number,lineTo:c.number,content:f,type:d,isValid:u.success,errors:u.errors??[]}),i+=e.length}return n}splitByStatementSeparators(e){let t=[],n=``,r=!1,i=``,a=!1,o=!1,s=0;for(;s<e.length;){let c=e[s],l=e[s+1];if(!r&&!o&&c===`-`&&l===`-`){a=!0,n+=c+l,s+=2;continue}if(!r&&!a&&c===`/`&&l===`*`){o=!0,n+=c+l,s+=2;continue}if(o&&c===`*`&&l===`/`){o=!1,n+=c+l,s+=2;continue}if(a&&(c===`
|
|
104
104
|
`||c===`\r`)){a=!1,n+=c,s++;continue}if(a||o){n+=c,s++;continue}if(!r&&(c===`'`||c===`"`||c==="`"))r=!0,i=c,n+=c;else if(r&&c===i){if(l===i){n+=c+l,s+=2;continue}r=!1,i=``,n+=c}else!r&&c===`;`?(n+=c,t.push(n),n=``):n+=c;s++}return n.trim()&&t.push(n),t}determineStatementType(e){let t=e.trim().toLowerCase();return t.startsWith(`select`)?`select`:t.startsWith(`insert`)?`insert`:t.startsWith(`update`)?`update`:t.startsWith(`delete`)?`delete`:t.startsWith(`create`)?`create`:t.startsWith(`drop`)?`drop`:t.startsWith(`alter`)?`alter`:t.startsWith(`use`)?`use`:`other`}stripComments(e){let t=``,n=!1,r=``,i=!1,a=!1,o=0;for(;o<e.length;){let s=e[o],c=e[o+1];if(!n&&!a&&s===`-`&&c===`-`){i=!0,o+=2;continue}if(!n&&!i&&s===`/`&&c===`*`){a=!0,o+=2;continue}if(a&&s===`*`&&c===`/`){a=!1,o+=2;continue}if(i&&(s===`
|
|
@@ -110,15 +110,15 @@ mark line col
|
|
|
110
110
|
transition: opacity 150ms ease-in-out;
|
|
111
111
|
border-radius: 1px;
|
|
112
112
|
`,e}eq(e){return this.isCurrent===e.isCurrent&&this.isValid===e.isValid&&this.isFocused===e.isFocused&&this.config===e.config}};function DC(e,t){let n=jn.empty;if(t.whenHide?.(e))return n;let r=e.state.field(wC,!1);if(!r)return n;let{currentStatement:i,allStatements:a,isFocused:o}=r;try{let r=e.state.doc.lineAt(e.viewport.from).number,s=e.state.doc.lineAt(e.viewport.to).number;for(let c of a){if(c.lineTo<r||c.lineFrom>s)continue;let a=i?.from===c.from&&i?.to===c.to;if(!c.isValid&&t.showInvalid===!1)continue;let l=new EC(t,a,c.isValid,o),u=Math.max(c.lineFrom,r),d=Math.min(c.lineTo,s);for(let t=u;t<=d;t++)try{if(t<1||t>e.state.doc.lines)continue;let r=e.state.doc.line(t);n=n.update({add:[l.range(r.from)]})}catch(e){console.warn(`SqlGutter: Invalid line number`,t,e)}}}catch(e){console.warn(`SqlGutter: Error creating markers`,e)}return n}async function OC(e,t){let{state:n}=e,r=n.selection.main.head,i=await t.analyzeDocument(n),a={currentStatement:await t.getStatementAtPosition(n,r),allStatements:i,cursorPosition:r,isFocused:e.hasFocus};e.dispatch({effects:CC.of(a)})}function kC(e){return Yn.define(t=>(OC(t,e),{update(t){!t.docChanged&&!t.selectionSet&&!t.focusChanged||OC(t.view,e)}}))}function AC(e){let t=e.width||3;return Kn.baseTheme({".cm-sql-gutter":{width:`${t}px`,minWidth:`${t}px`},".cm-sql-gutter .cm-gutterElement":{width:`${t}px`,padding:`0`,margin:`0`},".cm-sql-gutter-marker":{width:`100%`,height:`100%`,display:`block`},".cm-lineNumbers .cm-gutterElement":{paddingLeft:`8px`,paddingRight:`8px`}})}function jC(e){return Zn({class:`cm-sql-gutter ${e.className||``}`,markers:t=>DC(t,e)})}function MC(e={}){return[wC,kC(new Wx(e.parser||new _x)),AC(e),jC(e)]}function NC(e={}){let t=[],{schema:n,enableLinting:r=!0,enableSemanticLinting:i=!0,enableGutterMarkers:a=!0,enableHover:o=!0,enableNavigation:s=!0,linterConfig:c,semanticLinterConfig:l,gutterConfig:u,hoverConfig:d,navigationConfig:f}=e;if(n!=null&&t.push(ux.of(n)),r&&t.push(TS(c)),i){let e=l?.parser??c?.parser,n=l?.structureAnalyzer??(l?.parser==null?c?.structureAnalyzer:void 0);t.push(SC({...l,parser:e,structureAnalyzer:n}))}if(a&&t.push(MC(u)),o&&(t.push(kS(d)),t.push(d?.theme??LS())),s){let e=f?.parser??c?.parser,n=f?.structureAnalyzer??(f?.parser==null?c?.structureAnalyzer:void 0);t.push(...nC({...f,parser:e,structureAnalyzer:n}))}return t}var PC=class e{delegate;toKey;cache;static jsonStringifySortKeys(){return e=>typeof e!=`object`||!e?String(e):JSON.stringify(e,Object.keys(e).toSorted(),2)}constructor(t,n={}){this.delegate=t,this.toKey=n.toKey??e.jsonStringifySortKeys();let r=n.maxSize??128;this.cache=new Sp(r)}request(e){let t=this.toKey(e),n=this.cache.get(t);if(n!==void 0)return n;let r=this.delegate.request(e);return this.cache.set(t,r),r.catch(e=>{throw this.cache.delete(t),e})}resolve(e,t){this.delegate.resolve(e,t)}reject(e,t){this.delegate.reject(e,t)}},FC=new Xt(`data-source-discovery-result`,async e=>{await Br().discoverDataSources({requestId:e})}),IC=new Xt(`sql-table-preview`,async(e,t)=>{await Br().previewSQLTable({requestId:e,...t})}),LC=new Xt(`sql-schema-list-preview`,async(e,t)=>{await Br().previewSQLSchemaList({requestId:e,...t})}),RC=new Xt(`sql-table-list-preview`,async(e,t)=>{await Br().previewSQLTableList({requestId:e,...t})}),zC=new PC(new Xt(`validate-sql`,async(e,t)=>{await Br().validateSQL({requestId:e,...t})}),{maxSize:3}),BC=o(new Map),VC=e=>{let t=(0,X.c)(3),n=s(BC),r;return t[0]!==e||t[1]!==n?(r=n.get(e),t[0]=e,t[1]=n,t[2]=r):r=t[2],r};function HC(e){let t=u.get(BC),n=new Map(t);n.delete(e),u.set(BC,n)}function UC(){u.set(BC,new Map)}function WC({cellId:e,errorMessage:t,dialect:n}){let r=u.get(BC),i=new Map(r),a=n===`DuckDB`?GC(t):KC(t);i.set(e,a),u.set(BC,i)}function GC(e){let{errorType:t,errorMessage:n}=KC(e),r=n,i,a=n.indexOf(`LINE `);return a!==-1&&(i=n.slice(Math.max(0,a)).trim(),r=n.slice(0,Math.max(0,a)).trim()),{errorType:t,errorMessage:r,codeblock:i}}function KC(e){return{errorType:e.split(`:`)[0].trim(),errorMessage:e.split(`:`).slice(1).join(`:`).trim()}}function qC(e){return e.field(jy)}function JC(){return e=>{let t=qC(e.state).engine,n=cm.getCompletionSource(t);return n&&Ur(n)(e)||null}}function YC(){return e=>{let t=qC(e.state).engine,n=cm.getDialect(t);return e.matchBefore(/\.\w*/)?null:Qr(n,!0,(e,t)=>({label:e,type:t,info:async()=>{let t=(await XC())[e.toLocaleLowerCase()];if(!t)return null;let n=document.createElement(`div`);return n.innerHTML=IS.keyword({keyword:e,info:t}),n}}))(e)}}var XC=Er(async()=>{let e=await U(()=>import(`./common-keywords-FICkW4yv.js`),[],import.meta.url),t=await U(()=>import(`./duckdb-keywords-iJc26n2t.js`),[],import.meta.url);return{...e.default.keywords,...t.default.keywords}}),ZC=ye(`marimo:notebook-sql-mode`,`default`,Fh);function QC(){let e=(0,X.c)(3),[t,n]=a(ZC),r;return e[0]!==n||e[1]!==t?(r={sqlMode:t,setSQLMode:n},e[0]=n,e[1]=t,e[2]=r):r=e[2],r}function $C(){return u.get(ZC)}var ew=Pf,tw=`DuckDB`,nw=new En;function rw(){let{latestEngineSelected:e,connectionsMap:t}=u.get(hp);return e===null?[...t.values()].reverse().find(e=>!Vf.has(e.name)&&e.source!==`iceberg`)?.name??`__marimo_duckdb`:e}var iw=class{parser=new eh;type=`sql`;sqlModeEnabled;constructor(){this.sqlModeEnabled=!0}get defaultMetadata(){return{...this.parser.defaultMetadata,engine:rw()||`__marimo_duckdb`}}get defaultCode(){let e=rw();return e&&e!==`__marimo_duckdb`?`_df = mo.sql(f"""SELECT * FROM """, engine=${e})`:this.parser.defaultCode}static fromQuery=e=>eh.fromQuery(e);transformIn(e){this.parser.defaultMetadata.engine=rw()||`__marimo_duckdb`;let t=this.parser.transformIn(e),n=t.metadata;return n.engine&&n.engine!==`__marimo_duckdb`&&yp(n.engine),[t.code,t.offset,n]}transformOut(e,t){let n=this.parser.transformOut(e,t);return[n.code,n.offset]}isSupported(e){return this.parser.isSupported(e)}getExtension(e,t,n,r,i){let a=aw(),o=[nw.of(Wr({dialect:ew})),dn.of([{key:`Tab`,run:e=>Mr(e)||er(e),preventDefault:!0}]),Fr({defaultKeymap:!1,activateOnTyping:!0,override:[JC(),by,YC(),a.cteCompletionSource,a.aliasCompletionSource,a.columnCompletionSource]})];if(i?.diagnostics?.sql_linter??!1){let e=u.get(li),t=new lw({getParserOptions:e=>({database:_w(e)??tw})});o.push(NC({schema:hw,enableLinting:!0,linterConfig:{delay:250,parser:t,perStatement:!1},enableSemanticLinting:!0,semanticLinterConfig:{parser:a.parser,structureAnalyzer:a.structureAnalyzer,severity:{unknownTable:`off`,unknownColumn:`warning`,ambiguousColumn:`warning`}},enableGutterMarkers:!0,gutterConfig:{backgroundColor:`#3b82f6`,errorBackgroundColor:`#ef4444`,hideWhenNotFocused:!0,parser:t},hoverConfig:{hoverTime:300,enableKeywords:!0,enableTables:!0,enableColumns:!0,parser:a.parser,contextAnalyzer:a.contextAnalyzer,theme:LS(e)},enableNavigation:!0,navigationConfig:{contextAnalyzer:a.contextAnalyzer,keymap:!1,parser:a.parser,structureAnalyzer:a.structureAnalyzer}}),Kn.updateListener.of(e=>{e.focusChanged&&t.setFocusState(e.view.hasFocus)}))}return this.sqlModeEnabled&&o.push(bw()),o}};function aw(){let e=new _x({getParserOptions:e=>({database:ow(e)})}),t=new sw(e),n=new cw(e);return{parser:e,contextAnalyzer:t,structureAnalyzer:n,cteCompletionSource:bS({parser:e,contextAnalyzer:t,structureAnalyzer:n}),aliasCompletionSource:Gx({schema:hw,parser:e,contextAnalyzer:t}),columnCompletionSource:Yx({schema:hw,parser:e,contextAnalyzer:t})}}function ow(e){return _w(e)??tw}var sw=class extends Ux{analyzers=new Map;analysisParser;constructor(e){super(e),this.analysisParser=e}getContext(e,t){return this.getAnalyzer(t.state).getContext(e,t)}clearCache(){for(let e of this.analyzers.values())e.clearCache()}getAnalyzer(e){let t=ow(e),n=this.analyzers.get(t);return n||(n=new Ux(this.analysisParser),this.analyzers.set(t,n)),n}},cw=class extends Wx{analyzers=new Map;analysisParser;constructor(e){super(e),this.analysisParser=e}analyzeDocument(e){return this.getAnalyzer(e).analyzeDocument(e)}getStatementAtPosition(e,t){return this.getAnalyzer(e).getStatementAtPosition(e,t)}getStatementsInRange(e,t,n){return this.getAnalyzer(e).getStatementsInRange(e,t,n)}clearCache(){for(let e of this.analyzers.values())e.clearCache()}getAnalyzer(e){let t=ow(e),n=this.analyzers.get(t);return n||(n=new Wx(this.analysisParser),this.analyzers.set(t,n)),n}},lw=class extends _x{validationTimeout=null;pendingValidationResolve=null;VALIDATION_DELAY_MS=300;isFocused=!1;setFocusState(e){this.isFocused=e}resolvePendingValidation(e){this.pendingValidationResolve?.(e),this.pendingValidationResolve=null}async validateWithDelay(e,t,n){return this.validationTimeout&&(window.clearTimeout(this.validationTimeout),this.resolvePendingValidation([])),new Promise(r=>{this.pendingValidationResolve=r,this.validationTimeout=window.setTimeout(async()=>{if(this.validationTimeout=null,!this.isFocused){this.resolvePendingValidation([]);return}try{let r=await xw(e,t,n,Vf.has(t)?$C():`default`);if(r.error){L.error(`Failed to validate SQL`,{error:r.error}),this.resolvePendingValidation([]);return}this.resolvePendingValidation(r.parse_result?.errors??[])}catch(e){L.error(`Failed to validate SQL`,{error:e}),this.resolvePendingValidation([])}},this.VALIDATION_DELAY_MS)})}async validateSql(e,t){let n=mw(t.state),r=vw(n.engine);return this.isFocused?uw(n.engine,r)?this.validateWithDelay(e,n.engine,r??tw):super.validateSql(e,t):[]}async parse(e,t){let n=mw(t.state).engine;return uw(n,vw(n))?{success:!0,errors:[]}:super.parse(e,t)}};function uw(e,t){return e===`__marimo_duckdb`||t===`DuckDB`}function dw(e,t){e.dispatch({effects:nw.reconfigure(Wr({dialect:t}))})}function fw(e,t){dw(e,cm.getDialect(t))}function pw(e){let t=mw(e.state).engine;dw(e,cm.getDialect(t))}function mw(e){return e.field(jy)}function hw(e){let t=mw(e.state).engine,n=cm.getCompletionSource(t);if(!n?.schema)return{};let r=n.schema;if(!gw(r))return r;let i=n.defaultSchema,a=i?r[i]:void 0;return a&&!Array.isArray(a)&&typeof a==`object`&&`children`in a&&gw(a.children)?{...r,...Object.fromEntries(Object.entries(a.children).filter(([e])=>!Object.hasOwn(r,e)))}:r}function gw(e){if(Array.isArray(e))return!1;if(!(`self`in e)||!(`children`in e))return!0;let t=e.self;return!(typeof t==`object`&&t&&!Array.isArray(t)&&`label`in t&&typeof t.label==`string`)}function _w(e){let t=mw(e).engine;return vw(t)}function vw(e){let t=cm.getInternalDialect(e)?.toLowerCase();if(!t||!If(t))return null;switch(t){case`postgresql`:case`postgres`:return`PostgreSQL`;case`db2`:case`db2i`:return`DB2`;case`mysql`:return`MySQL`;case`sqlite`:return`Sqlite`;case`mssql`:case`sqlserver`:case`microsoft sql server`:return`TransactSQL`;case`duckdb`:return`DuckDB`;case`mariadb`:return`MariaDB`;case`cassandra`:return`Noql`;case`athena`:case`awsathena`:return`Athena`;case`bigquery`:return`BigQuery`;case`hive`:return`Hive`;case`redshift`:return`Redshift`;case`snowflake`:return`Snowflake`;case`flink`:return`FlinkSQL`;case`mongodb`:case`noql`:return`Noql`;case`oracle`:case`oracledb`:case`timescaledb`:case`couchbase`:case`trino`:case`tidb`:case`singlestoredb`:case`spark`:case`databricks`:case`datafusion`:case`dremio`:return L.debug(`Unsupported dialect`,{dialect:t}),null;default:return Lr(t),null}}var yw=300;function bw(){return Yn.define(e=>{let t,n=null,r=e.state.facet(Af);return{update(e){if(!e.docChanged)return;let i=$C();if(i==="default")return;let a=mw(e.state).engine;if(!Vf.has(a))return;let o=e.state.doc.toString();t&&window.clearTimeout(t),t=window.setTimeout(async()=>{if(n!==o){if(n=o,o===``){HC(r);return}try{let e=vw(a),t=(await xw(o,a,e,i)).validate_result;t?.error_message?WC({cellId:r,errorMessage:t.error_message,dialect:e}):HC(r)}catch(e){L.error(`Failed to validate SQL`,{error:e})}}},yw)},destroy(){t&&window.clearTimeout(t),HC(r)}}})}async function xw(e,t,n,r){let i=await zC.request({onlyParse:r==="default",engine:t,dialect:n,query:e});if(i.error)throw Error(i.error);return i}var Sw=Er(()=>new Yb),Cw=Er(()=>new My),ww=Er(()=>new iw),Tw={get python(){return Sw()},get markdown(){return Cw()},get sql(){return ww()}};function Ew(){return Object.values(Tw)}var Dw=G.forwardRef((e,t)=>{let n=(0,X.c)(13),r,i;n[0]===e?(r=n[1],i=n[2]):({className:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a;n[3]===r?a=n[4]:(a=V(`flex items-center justify-center peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background focus-visible:outline-hidden focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground data-[state=indeterminate]:bg-primary data-[state=indeterminate]:text-primary-foreground`,r),n[3]=r,n[4]=a);let o;n[5]===Symbol.for(`react.memo_cache_sentinel`)?(o=V(`flex items-center justify-center text-current max-h-[14px] overflow-hidden`),n[5]=o):o=n[5];let s;n[6]===i.checked?s=n[7]:(s=(0,K.jsx)(ta,{className:o,children:i.checked===`indeterminate`?(0,K.jsx)(Lo,{className:`h-4 w-4`}):(0,K.jsx)(jt,{className:`h-4 w-4`})}),n[6]=i.checked,n[7]=s);let c;return n[8]!==i||n[9]!==t||n[10]!==a||n[11]!==s?(c=(0,K.jsx)($i,{ref:t,className:a,...i,children:s}),n[8]=i,n[9]=t,n[10]=a,n[11]=s,n[12]=c):c=n[12],c});Dw.displayName=$i.displayName;var Ow=new Set(`__*.marimo.app.False.None.True.__peg_parser__.and.as.assert.async.await.break.class.continue.def.del.elif.else.except.finally.for.from.global.if.import.in.is.lambda.nonlocal.not.or.pass.raise.return.try.while.with.yield.None.setup`.split(`.`));function kw(e,t=!0){return e=e.trim(),e?(/^\d/.test(e)&&(e=`_${e}`),e=e.replaceAll(/\W/g,`_`),t?e.toLowerCase():e):`_`}function Aw(e,t){let n=new Set(t),r=e,i=e=>!n.has(e)&&!Ow.has(e);if(i(e))return e;let a=1;for(;!i(r);)r=`${e}_${a}`,a++;return r}function jw(e,t){return Mw(e)?`cell-${t}`:e}function Mw(e){return!e||e===`_`||e===`__`}function Nw(e){let t=(0,X.c)(15),{minWidth:n,padding:r}=e,i=n===void 0?70:n,a=r===void 0?15:r,[o,s]=(0,G.useState)(50),c=(0,G.useRef)(null),l=(0,G.useRef)(null),u;t[0]===a?u=t[1]:(u=e=>{if(l.current&&c.current){let t=l.current;t.style.fontSize=window.getComputedStyle(c.current).fontSize,t.style.fontFamily=window.getComputedStyle(c.current).fontFamily,t.textContent=e;let n=t.offsetWidth;s(n+a)}},t[0]=a,t[1]=u);let d=u,f;t[2]===d?f=t[3]:(f=()=>{d(c.current?.value??``)},t[2]=d,t[3]=f),H(f);let p;t[4]===d?p=t[5]:(p=e=>{d(e.target.value)},t[4]=d,t[5]=p);let m=`${o}px`,h=`${i}px`,g;t[6]!==m||t[7]!==h?(g={width:m,minWidth:h},t[6]=m,t[7]=h,t[8]=g):g=t[8];let _;t[9]!==p||t[10]!==g?(_={ref:c,type:`text`,onChange:p,style:g},t[9]=p,t[10]=g,t[11]=_):_=t[11];let v=_,y;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(y={ref:l,style:{visibility:`hidden`,position:`absolute`,whiteSpace:`pre`}},t[12]=y):y=t[12];let b=y,x;return t[13]===v?x=t[14]:(x={inputProps:v,spanProps:b},t[13]=v,t[14]=x),x}function Pw({currentQuotePrefix:e,checked:t,prefix:n}){let r=e;return t?e===``?r=n:e!==`rf`&&n!==e&&(r=`rf`):e===n?r=``:e===`rf`&&(r=n===`r`?`f`:`r`),r}var Fw=()=>{let e=(0,X.c)(2),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,K.jsxs)(`section`,{className:`flex flex-col gap-0.5`,children:[(0,K.jsxs)(`header`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(`code`,{className:`text-xs px-1 py-0.5 bg-(--slate-2) rounded`,children:`r`}),(0,K.jsx)(`span`,{className:`font-semibold`,children:`Raw String`})]}),(0,K.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Write LaTeX without escaping special characters`}),(0,K.jsx)(`pre`,{className:`text-xs bg-(--slate-2) p-2 rounded`,children:`\\alpha \\beta`})]}),e[0]=t):t=e[0];let n;return e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,K.jsxs)(`div`,{className:`flex flex-col gap-3.5`,children:[t,(0,K.jsxs)(`section`,{className:`flex flex-col gap-0.5`,children:[(0,K.jsxs)(`header`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(`code`,{className:`text-xs px-1 py-0.5 bg-(--slate-2) rounded`,children:`f`}),(0,K.jsx)(`span`,{className:`font-semibold`,children:`Format String`})]}),(0,K.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Interpolate Python values`}),(0,K.jsxs)(`pre`,{className:`text-xs bg-(--slate-2) p-2 rounded`,children:[`Hello `,`{name}`,`! 😁`]})]})]}),e[1]=n):n=e[1],n},Iw=`data-cell-id`;function Lw(e){return{[Iw]:e}}var Rw=`data-for-cell-id`;function zw(e){return{[Rw]:e}}var Bw=`data:image/svg+xml,%3csvg%20role='img'%20viewBox='0%200%2024%2024'%20xmlns='http://www.w3.org/2000/svg'%3e%3ctitle%3eClickHouse%3c/title%3e%3cpath%20d='M21.333%2010H24v4h-2.667ZM16%201.335h2.667v21.33H16Zm-5.333%200h2.666v21.33h-2.666ZM0%2022.665V1.335h2.667v21.33zm5.333-21.33H8v21.33H5.333Z'/%3e%3c/svg%3e`,Vw=`data:image/svg+xml,%3csvg%20role='img'%20viewBox='0%200%2024%2024'%20xmlns='http://www.w3.org/2000/svg'%3e%3ctitle%3eDatabricks%3c/title%3e%3cpath%20d='M.95%2014.184L12%2020.403l9.919-5.55v2.21L12%2022.662l-10.484-5.96-.565.308v.77L12%2024l11.05-6.218v-4.317l-.515-.309L12%2019.118l-9.867-5.653v-2.21L12%2016.805l11.05-6.218V6.32l-.515-.308L12%2011.974%202.647%206.681%2012%201.388l7.76%204.368.668-.411v-.566L12%200%20.95%206.27v.72L12%2013.207l9.919-5.55v2.26L12%2015.52%201.516%209.56l-.565.308Z'/%3e%3c/svg%3e`,Hw=`data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAGcElEQVR4nNxZa2wcVxU+99557M6+vLazj6xjO6+maWVTl0YpLU1DU9KARNqooQhFVYJUqUWgiocqIVRESPlRoEhIqYoqgSiCItqQPkAEKUWQtlGSJtAY00R5mTjZTfze94x3HvdedMdZnKgS6s7O2kk/a7R3xvY933fOd874yhhucCyYAIWA9IOH2r+35/HUnjU96sBC8fAERQLpj0+mXjdeXM6rzy/no88uK6zolHu97EX8p/f/IWHAv38i9bsH+kIPo/ozhAJBgpR9J419je437xb62Zc7n/tcf+gRsebADYQAxLW2N/ApL/vNq4AdA7Ht2/piT4q15fAp1wEYAGEALYA18TzT1TXQ09O75qPuKbWS8NW4Lan27/pM4gWrBIgFnaIDvKZIpPPKt+nlgpMTi0q5PKqoqvZR950XAREZaz/fmHmFOFijwGHkDDu5PKGs1SlQ5gAAQ+S9U9Y/xM+Wy+WxRvaeFwE770z+OBNQbmYWwPlp63BPh3q7XQaCxAi50gP7Tldf87J3ywVszEQ2bumOf5WZAAajeWoDJjYOMM5BCECEw9miefxwduaol/1b2sQdCon/8BOZX3ETYWYiODFhvrNUC6ylFgJqzl27DxV+xD3GaGkFnl6deS4G8mJqAmRrtaGkoqxiJnazPpt9gPNVa3DvqfKrXmO0rAJ3RSLrHojHd4jMMwvBSMn+d1pSVrv37oXdz50Hx79JOXgtQGsqIAEiT8V7djtVzEiQ4w+K+t9uCmn3uNmX5rL/l8ullw5c1g80E6slFXgkuuixJVKw3y5jxEzExnV7pB3k7rr3hZDBiZl3njk+9u1mY/legSgm0cfiXbtcTziYHJmovNEXC99PZzAV41KMzaLtXGBVmaQltWfCdPLNxPNdwFdii58KYykhXM2AO5MGvTSAgw9aLnUx8zlomCxTKdeHdP14s/F8tdAiIie2RpPfAPcPNYAjRumNOwLRLZwL2rPgHAGnCF6aHPuJ5869Cr5WYFs0/S0ZkTDns9SK1BltI/JicYcEcXAX8L5R+vOblanf+hHTNwFtWGr7QiT9BAPklnWoVt5/qxrZILQI7wvyjHPrjKkfeL0y9QID76Pzavhmoa3RzNdkLMcYEKCA4aJtncjIgVs4oFnbCCGASDtRVrw3Uz7sV1xfBKiAlc2RJV+vkz9vWYMZWesTa1ER5vYEgot27YPvjJ/dXGBOwY+44JeAdaHkQxpRU9QVQGDIrPz1FjV+f/3eFcaRFcdKosicsh8x6/ClBzaEu7YLoqJNDUonVKR0UCTuRT9w9wshpAzb+qmcY2b9iFlH0xVow0r81sCiz9azfdCY3rNWSzw8a5/ZZ2ItPv9UmfiFP7Tn0HQFPhlMbuKIyOKkhThjNc4rBCtRJl5jrvO5W4mSY+beMib/4A/tOTQtYCCY2kTdszmHE7X8/tWBTtf7s7S528IYELxcuviMycWZzF80baHVgdT6/00fu3oso7Tdwa5Ypt7Aw5Zx7M1K7pf+UL4WTVWgQwqnQ5LWLexTpfblEFaT7Jrsc3GMLDw7+a9tFDj1j/YcmqpAWkn06yhERaYP6ZdeHtC6tl6deYPx4q7xY5+/YFfP+kf5WniqQELp6J6hNaNdia8s4TCojkmrjOYVHGin7qsLQdYqvb976uijk455yX/ac/AkYNLKZx9Nb/kNQkAsLJNBW9+/Uk3eJzI/ZlUG36qcfv6MXf3nmtjtO/ZO/v27/tOeA/L6iyu0pfdu7/riATF93s0fffq+toGdM5zmJ+ziuRgJpWSEgy/mXlk/Zk2f8ZfytfDcxOeM828XHH04TAIJjOTgDAlIiPNEmgQTw9Xh146UBn/aavLgVUAmkLk5IkdXFh09l62NHloaWblZjFGMONjMrsTUjqV5qzjuP90Pw9MUmrKms/2x276U0pbcO2Hlh9qUzj6GMJiclk/q5/b+Ovfqg+P29LD/dD+MhnsgSMLhnlDvPQVrOrcmfufjF2cuvI0BqVlj5GDBKmQZsJbMe9+BAZP1yU3fF+tloVV3LzSfhtEbXrWhO7Ri3ULz8PwmzoRXfTqr/+ddf+k0Dk8CEGBMOWccmC8H82bgSUAmfNO6S/q5Bc8+eBUQDXWtz1VP36gCMC4xnfPrZFw2/I9uLZi6u2aXs7ZdGWkNpcbQcAU0LX2XYYxeF/YBLwIYs0twndjnY4H/BgAA//95CrBYRwImwgAAAABJRU5ErkJggg==`,Uw=`data:image/svg+xml,%3csvg%20role='img'%20viewBox='0%200%2024%2024'%20xmlns='http://www.w3.org/2000/svg'%3e%3ctitle%3eDuckDB%3c/title%3e%3cpath%20d='M12%200C5.363%200%200%205.363%200%2012s5.363%2012%2012%2012%2012-5.363%2012-12S18.637%200%2012%200zM9.502%207.03a4.974%204.974%200%200%201%204.97%204.97%204.974%204.974%200%200%201-4.97%204.97A4.974%204.974%200%200%201%204.532%2012a4.974%204.974%200%200%201%204.97-4.97zm6.563%203.183h2.351c.98%200%201.787.782%201.787%201.762s-.807%201.789-1.787%201.789h-2.351v-3.551z'/%3e%3c/svg%3e`,Ww=`data:image/svg+xml,%3csvg%20role='img'%20viewBox='0%200%2024%2024'%20xmlns='http://www.w3.org/2000/svg'%3e%3ctitle%3eGoogle%20BigQuery%3c/title%3e%3cpath%20d='M5.676%2010.595h2.052v5.244a5.892%205.892%200%200%201-2.052-2.088v-3.156zm18.179%2010.836a.504.504%200%200%201%200%20.708l-1.716%201.716a.504.504%200%200%201-.708%200l-4.248-4.248a.206.206%200%200%201-.007-.007c-.02-.02-.028-.045-.043-.066a10.736%2010.736%200%200%201-6.334%202.065C4.835%2021.599%200%2016.764%200%2010.799S4.835%200%2010.8%200s10.799%204.835%2010.799%2010.8c0%202.369-.772%204.553-2.066%206.333.025.017.052.028.074.05l4.248%204.248zm-5.028-10.632a8.015%208.015%200%201%200-8.028%208.028h.024a8.016%208.016%200%200%200%208.004-8.028zm-4.86%204.98a6.002%206.002%200%200%200%202.04-2.184v-1.764h-2.04v3.948zm-4.5.948c.442.057.887.08%201.332.072.4.025.8.025%201.2%200V7.692H9.468v9.035z'/%3e%3c/svg%3e`,Gw=new URL(`iceberg-COKYXo-A.png`,import.meta.url).href,Kw=`data:image/svg+xml,%3csvg%20role='img'%20viewBox='0%200%2024%2024'%20xmlns='http://www.w3.org/2000/svg'%3e%3ctitle%3eMotherDuck%3c/title%3e%3cg%20transform='scale(0.85)%20translate(0,%202)'%3e%3cpath%20fill='%23ff9538'%20d='M1.71%2015.86s7.45%205.32%207.89%205.59c.44.27%201.08.33%201.64.11.56-.22.98-.71%201.11-1.21s1.85-9.49%201.85-9.49c.02-.12.07-.48-.13-.83-.27-.47-.86-.71-1.38-.57-.42.12-.64.44-.7.55-.09.17-.26.45-.57.7-.24.19-.47.3-.58.34-.96.38-2.02.06-2.61-.72-.38-.48-1.04-.67-1.64-.43-.6.24-.94.84-.89%201.45.11.98-.44%201.94-1.4%202.32-.51.21-1.06.21-1.54.05-.12-.03-.51-.12-.89.09-.48.26-.74.84-.61%201.37.09.39.38.62.48.69z'%20/%3e%3cpath%20fill='%23ff9538'%20d='M14.12%204.21s2.65%208.76%202.83%209.24c.19.48.66.92%201.23%201.09.58.16%201.21.03%201.62-.28.41-.31%207.25-6.39%207.25-6.39.09-.08.35-.34.4-.74.07-.53-.25-1.09-.75-1.29-.4-.16-.78-.04-.89%200-.18.08-.48.2-.88.2-.3.01-.55-.05-.67-.08-.99-.28-1.64-1.18-1.63-2.16-.01-.61-.42-1.17-1.04-1.35-.62-.18-1.26.09-1.59.6-.51.84-1.53%201.27-2.52.99-.53-.15-.96-.48-1.25-.91-.07-.09-.33-.4-.76-.48-.54-.09-1.1.22-1.32.71-.16.37-.08.72-.04.84z'%20/%3e%3c/g%3e%3c/svg%3e`,qw=`data:image/svg+xml,%3csvg%20role='img'%20viewBox='0%200%2024%2024'%20xmlns='http://www.w3.org/2000/svg'%3e%3ctitle%3eMySQL%3c/title%3e%3cpath%20d='M16.405%205.501c-.115%200-.193.014-.274.033v.013h.014c.054.104.146.18.214.273.054.107.1.214.154.32l.014-.015c.094-.066.14-.172.14-.333-.04-.047-.046-.094-.08-.14-.04-.067-.126-.1-.18-.153zM5.77%2018.695h-.927a50.854%2050.854%200%2000-.27-4.41h-.008l-1.41%204.41H2.45l-1.4-4.41h-.01a72.892%2072.892%200%2000-.195%204.41H0c.055-1.966.192-3.81.41-5.53h1.15l1.335%204.064h.008l1.347-4.064h1.095c.242%202.015.384%203.86.428%205.53zm4.017-4.08c-.378%202.045-.876%203.533-1.492%204.46-.482.716-1.01%201.073-1.583%201.073-.153%200-.34-.046-.566-.138v-.494c.11.017.24.026.386.026.268%200%20.483-.075.647-.222.197-.18.295-.382.295-.605%200-.155-.077-.47-.23-.944L6.23%2014.615h.91l.727%202.36c.164.536.233.91.205%201.123.4-1.064.678-2.227.835-3.483zm12.325%204.08h-2.63v-5.53h.885v4.85h1.745zm-3.32.135l-1.016-.5c.09-.076.177-.158.255-.25.433-.506.648-1.258.648-2.253%200-1.83-.718-2.746-2.155-2.746-.704%200-1.254.232-1.65.697-.43.508-.646%201.256-.646%202.245%200%20.972.19%201.686.574%202.14.35.41.877.615%201.583.615.264%200%20.506-.033.725-.098l1.325.772.36-.622zM15.5%2017.588c-.225-.36-.337-.94-.337-1.736%200-1.393.424-2.09%201.27-2.09.443%200%20.77.167.977.5.224.362.336.936.336%201.723%200%201.404-.424%202.108-1.27%202.108-.445%200-.77-.167-.978-.5zm-1.658-.425c0%20.47-.172.856-.516%201.156-.344.3-.803.45-1.384.45-.543%200-1.064-.172-1.573-.515l.237-.476c.438.22.833.328%201.19.328.332%200%20.593-.073.783-.22a.754.754%200%2000.3-.615c0-.33-.23-.61-.648-.845-.388-.213-1.163-.657-1.163-.657-.422-.307-.632-.636-.632-1.177%200-.45.157-.81.47-1.085.315-.278.72-.415%201.22-.415.512%200%20.98.136%201.4.41l-.213.476a2.726%202.726%200%2000-1.064-.23c-.283%200-.502.068-.654.206a.685.685%200%2000-.248.524c0%20.328.234.61.666.85.393.215%201.187.67%201.187.67.433.305.648.63.648%201.168zm9.382-5.852c-.535-.014-.95.04-1.297.188-.1.04-.26.04-.274.167.055.053.063.14.11.214.08.134.218.313.346.407.14.11.28.216.427.31.26.16.555.255.81.416.145.094.293.213.44.313.073.05.12.14.214.172v-.02c-.046-.06-.06-.147-.105-.214-.067-.067-.134-.127-.2-.193a3.223%203.223%200%2000-.695-.675c-.214-.146-.682-.35-.77-.595l-.013-.014c.146-.013.32-.066.46-.106.227-.06.435-.047.67-.106.106-.027.213-.06.32-.094v-.06c-.12-.12-.21-.283-.334-.395a8.867%208.867%200%2000-1.104-.823c-.21-.134-.476-.22-.697-.334-.08-.04-.214-.06-.26-.127-.12-.146-.19-.34-.275-.514a17.69%2017.69%200%2001-.547-1.163c-.12-.262-.193-.523-.34-.763-.69-1.137-1.437-1.826-2.586-2.5-.247-.14-.543-.2-.856-.274-.167-.008-.334-.02-.5-.027-.11-.047-.216-.174-.31-.235-.38-.24-1.364-.76-1.644-.072-.18.434.267.862.422%201.082.115.153.26.328.34.5.047.116.06.235.107.356.106.294.207.622.347.897.073.14.153.287.247.413.054.073.146.107.167.227-.094.136-.1.334-.154.5-.24.757-.146%201.693.194%202.25.107.166.362.534.703.393.3-.12.234-.5.32-.835.02-.08.007-.133.048-.187v.015c.094.188.188.367.274.555.206.328.566.668.867.895.16.12.287.328.487.402v-.02h-.015c-.043-.058-.1-.086-.154-.133a3.445%203.445%200%2001-.35-.4%208.76%208.76%200%2001-.747-1.218c-.11-.21-.202-.436-.29-.643-.04-.08-.04-.2-.107-.24-.1.146-.247.273-.32.453-.127.288-.14.642-.188%201.01-.027.007-.014%200-.027.014-.214-.052-.287-.274-.367-.46-.2-.475-.233-1.238-.06-1.785.047-.14.247-.582.167-.716-.042-.127-.174-.2-.247-.303a2.478%202.478%200%2001-.24-.427c-.16-.374-.24-.788-.414-1.162-.08-.173-.22-.354-.334-.513-.127-.18-.267-.307-.368-.52-.033-.073-.08-.194-.027-.274.014-.054.042-.075.094-.09.088-.072.335.022.422.062.247.1.455.194.662.334.094.066.195.193.315.226h.14c.214.047.455.014.655.073.355.114.675.28.962.46a5.953%205.953%200%20012.085%202.286c.08.154.115.295.188.455.14.33.313.663.455.982.14.315.275.636.476.897.1.14.502.213.682.286.133.06.34.115.46.188.23.14.454.3.67.454.11.076.443.243.463.378z'/%3e%3c/svg%3e`,Jw=new URL(`postgresql-q8VEBKGg.svg`,import.meta.url).href,Yw={sqlite:`data:image/svg+xml,%3csvg%20role='img'%20viewBox='0%200%2024%2024'%20xmlns='http://www.w3.org/2000/svg'%3e%3ctitle%3eSQLite%3c/title%3e%3cpath%20d='M21.678.521c-1.032-.92-2.28-.55-3.513.544a8.71%208.71%200%200%200-.547.535c-2.109%202.237-4.066%206.38-4.674%209.544.237.48.422%201.093.544%201.561a13.044%2013.044%200%200%201%20.164.703s-.019-.071-.096-.296l-.05-.146a1.689%201.689%200%200%200-.033-.08c-.138-.32-.518-.995-.686-1.289-.143.423-.27.818-.376%201.176.484.884.778%202.4.778%202.4s-.025-.099-.147-.442c-.107-.303-.644-1.244-.772-1.464-.217.804-.304%201.346-.226%201.478.152.256.296.698.422%201.186.286%201.1.485%202.44.485%202.44l.017.224a22.41%2022.41%200%200%200%20.056%202.748c.095%201.146.273%202.13.5%202.657l.155-.084c-.334-1.038-.47-2.399-.41-3.967.09-2.398.642-5.29%201.661-8.304%201.723-4.55%204.113-8.201%206.3-9.945-1.993%201.8-4.692%207.63-5.5%209.788-.904%202.416-1.545%204.684-1.931%206.857.666-2.037%202.821-2.912%202.821-2.912s1.057-1.304%202.292-3.166c-.74.169-1.955.458-2.362.629-.6.251-.762.337-.762.337s1.945-1.184%203.613-1.72C21.695%207.9%2024.195%202.767%2021.678.521m-18.573.543A1.842%201.842%200%200%200%201.27%202.9v16.608a1.84%201.84%200%200%200%201.835%201.834h9.418a22.953%2022.953%200%200%201-.052-2.707c-.006-.062-.011-.141-.016-.2a27.01%2027.01%200%200%200-.473-2.378c-.121-.47-.275-.898-.369-1.057-.116-.197-.098-.31-.097-.432%200-.12.015-.245.037-.386a9.98%209.98%200%200%201%20.234-1.045l.217-.028c-.017-.035-.014-.065-.031-.097l-.041-.381a32.8%2032.8%200%200%201%20.382-1.194l.2-.019c-.008-.016-.01-.038-.018-.053l-.043-.316c.63-3.28%202.587-7.443%204.8-9.791.066-.069.133-.128.198-.194Z'/%3e%3c/svg%3e`,duckdb:Uw,motherduck:Kw,postgres:Jw,postgresql:Jw,mysql:qw,snowflake:`data:image/svg+xml,%3csvg%20role='img'%20viewBox='0%200%2024%2024'%20xmlns='http://www.w3.org/2000/svg'%3e%3ctitle%3eSnowflake%3c/title%3e%3cpath%20d='M24%203.459c0%20.646-.418%201.18-1.141%201.18-.723%200-1.142-.534-1.142-1.18%200-.647.419-1.18%201.142-1.18.723%200%201.141.533%201.141%201.18zm-.228%200c0-.533-.38-.951-.913-.951s-.913.38-.913.95c0%20.533.38.952.913.952.57%200%20.913-.419.913-.951zm-1.37-.533h.495c.266%200%20.456.152.456.38%200%20.153-.076.229-.19.305l.19.266v.038h-.266l-.19-.266h-.229v.266h-.266zm.495.228h-.229v.267h.229c.114%200%20.152-.038.152-.114.038-.077-.038-.153-.152-.153zM7.602%2012.4c.038-.151.076-.304.076-.456%200-.114-.038-.228-.038-.342-.114-.343-.304-.647-.646-.838l-4.87-2.777c-.685-.38-1.56-.152-1.94.533-.381.685-.153%201.56.532%201.94l2.701%201.56-2.701%201.56c-.685.38-.913%201.256-.533%201.94.38.685%201.256.914%201.94.533l4.832-2.777c.343-.267.571-.533.647-.876zm1.332%202.626c-.266-.038-.57.038-.837.19l-4.832%202.777c-.685.38-.913%201.256-.532%201.94.38.686%201.255.914%201.94.533l2.701-1.56v3.12c0%20.8.647%201.408%201.446%201.408.799%200%201.407-.647%201.407-1.408v-5.592c0-.761-.57-1.37-1.293-1.408zm4.946-6.088c.266.038.57-.038.837-.19l4.832-2.777c.685-.38.913-1.256.532-1.94-.38-.686-1.255-.914-1.94-.533l-2.701%201.56V1.975c0-.799-.647-1.408-1.446-1.408-.799%200-1.446.609-1.446%201.408V7.53c0%20.76.609%201.37%201.332%201.407zM3.265%205.97l4.832%202.777c.266.152.533.19.837.19.723-.038%201.331-.684%201.331-1.407V1.975c0-.799-.646-1.408-1.407-1.408-.799%200-1.446.647-1.446%201.408v3.12l-2.701-1.56c-.685-.38-1.56-.152-1.94.533-.419.646-.19%201.521.494%201.902zm9.093%206.011a.412.412%200%2000-.114-.266l-.57-.571a.346.346%200%2000-.267-.114.412.412%200%2000-.266.114l-.571.57a.411.411%200%2000-.114.267c0%20.076.038.19.114.267l.57.57a.345.345%200%2000.267.114c.076%200%20.19-.038.266-.114l.571-.57a.412.412%200%2000.114-.267zm1.598.533L11.94%2014.53c-.039.038-.153.114-.229.114h-.608a.411.411%200%2001-.267-.114L8.82%2012.514a.408.408%200%2001-.076-.229v-.608c0-.076.038-.19.114-.267l2.016-2.016a.41.41%200%2001.267-.114h.608a.41.41%200%2001.267.114l2.016%202.016a.347.347%200%2001.114.267v.608c-.076.077-.114.19-.19.229zm5.593%205.44l-4.832-2.777c-.266-.152-.57-.19-.837-.152-.723.038-1.332.684-1.332%201.408v5.554c0%20.8.647%201.408%201.408%201.408.799%200%201.446-.647%201.446-1.408v-3.12l2.7%201.56c.686.38%201.561.152%201.941-.533.419-.646.19-1.521-.494-1.94zm2.549-7.533l-2.701%201.56%202.7%201.56c.686.38.914%201.256.533%201.94-.38.685-1.255.913-1.94.533l-4.832-2.778a1.644%201.644%200%2001-.647-.798c-.037-.153-.076-.305-.076-.457%200-.114.039-.228.039-.342.114-.343.342-.647.646-.837l4.832-2.778c.685-.38%201.56-.152%201.94.533.457.609.19%201.484-.494%201.864'/%3e%3c/svg%3e`,databricks:Vw,clickhouse:Bw,timeplus:`data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='UTF-8'?%3e%3c!--%20Generated%20by%20Pixelmator%20Pro%203.6.17%20--%3e%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20id='Option2SymbolB'%3e%3cg%20id='Layer1-2'%3e%3cg%20id='Group'%20opacity='0.4'%3e%3cpath%20id='Path'%20fill='%23d53c97'%20stroke='none'%20d='M%2017.016802%2012.188573%20C%2017.016802%209.607646%2015.86018%207.293022%2014.039526%205.731081%20C%2013.942595%205.70038%2013.844628%205.671406%2013.745972%205.645189%20C%2013.131133%205.809095%2012.54265%206.059378%2011.998103%206.388559%20C%2013.964327%207.575191%2015.281006%209.730104%2015.281006%2012.188573%20C%2015.279476%2014.563734%2014.033739%2016.764488%2011.998103%2017.988243%20C%2012.542634%2018.317537%2013.131119%2018.567936%2013.745972%2018.731958%20C%2013.844628%2018.705742%2013.942595%2018.67642%2014.039526%2018.645721%20C%2015.86018%2017.084126%2017.016802%2014.769501%2017.016802%2012.188573%20Z'/%3e%3cpath%20id='path1'%20fill='%23d53c97'%20stroke='none'%20d='M%2013.897406%205.609659%20L%2013.894991%205.60759%20C%2013.844973%205.619663%2013.7953%205.631737%2013.745972%205.645189%20C%2013.79599%205.631737%2013.847043%205.622078%2013.897406%205.609659%20Z'/%3e%3cpath%20id='path2'%20fill='%23d53c97'%20stroke='none'%20d='M%201.735796%2012.188573%20C%201.735796%209.164728%203.728925%206.59622%206.470945%205.729357%20C%207.554634%204.797861%208.856011%204.155121%2010.254373%203.860756%20C%209.680216%203.740549%209.095179%203.679977%208.508574%203.68%20C%203.816888%203.68%20-0%207.496887%20-0%2012.188573%20C%20-0%2016.880259%203.816888%2020.697147%208.508574%2020.697147%20C%209.0952%2020.697229%209.680255%2020.636539%2010.254373%2020.516048%20C%208.855971%2020.221794%207.554568%2019.579041%206.470945%2018.647446%20C%203.728925%2017.780582%201.735796%2015.213453%201.735796%2012.188573%20Z'/%3e%3cpath%20id='path3'%20fill='%23d53c97'%20stroke='none'%20d='M%2013.745972%2018.731958%20C%2013.7953%2018.745068%2013.844973%2018.757484%2013.894991%2018.769558%20C%2013.894991%2018.769558%2013.896715%2018.769558%2013.897406%2018.767488%20C%2013.847043%2018.754379%2013.79599%2018.745411%2013.745972%2018.731958%20Z'/%3e%3c/g%3e%3cpath%20id='path4'%20fill='%23ff3b65'%20stroke='none'%20d='M%2020.508402%2012.188573%20C%2020.508402%209.606611%2019.351088%207.290262%2017.5294%205.729357%20C%2016.301817%205.342468%2014.989366%205.313629%2013.745972%205.646223%20C%2016.636665%206.418224%2018.772606%209.058484%2018.772606%2012.189609%20C%2018.772606%2015.320732%2016.636665%2017.960991%2013.745972%2018.731958%20C%2014.98947%2019.064316%2016.301983%2019.034998%2017.5294%2018.647446%20C%2019.419907%2017.034296%2020.508638%2014.673781%2020.508402%2012.188573%20Z'/%3e%3cpath%20id='path5'%20fill='%23ff3b65'%20stroke='none'%20d='M%209.962543%2018.647446%20C%207.220525%2017.780582%205.227395%2015.213453%205.227395%2012.188573%20C%205.227395%209.163693%207.220525%206.59622%209.962543%205.729357%20C%2011.046233%204.797861%2012.34761%204.155121%2013.745972%203.860756%20C%2013.171818%203.74053%2012.586779%203.679956%2012.000173%203.68%20C%207.308832%203.68%203.491599%207.496887%203.491599%2012.188573%20C%203.491599%2016.880259%207.308487%2020.697147%2012.000173%2020.697147%20C%2012.586799%2020.697247%2013.171857%2020.636557%2013.745972%2020.516048%20C%2012.34757%2020.221794%2011.046167%2019.579041%209.962543%2018.647446%20Z'/%3e%3cpath%20id='path6'%20fill='%23383838'%20stroke='none'%20d='M%2015.491772%203.68%20C%2010.800431%203.68%206.983198%207.496887%206.983198%2012.188573%20C%206.983198%2016.880259%2010.800086%2020.697147%2015.491772%2020.697147%20C%2020.183456%2020.697147%2024%2016.880259%2024%2012.188573%20C%2024%207.496887%2020.183456%203.68%2015.491772%203.68%20Z%20M%2022.264549%2012.188573%20C%2022.264549%2015.923018%2019.226215%2018.961351%2015.491772%2018.961351%20C%2011.757326%2018.961351%208.718994%2015.923018%208.718994%2012.188573%20C%208.718994%208.454128%2011.757326%205.415796%2015.491772%205.415796%20C%2019.226215%205.415796%2022.264549%208.454128%2022.264549%2012.188573%20Z'/%3e%3c/g%3e%3c/g%3e%3c/svg%3e`,bigquery:Ww,trino:new URL(`trino-DFsJbQoT.svg`,import.meta.url).href,iceberg:Gw,datafusion:Hw,pyspark:`data:image/svg+xml,%3csvg%20role='img'%20viewBox='0%200%2024%2024'%20xmlns='http://www.w3.org/2000/svg'%3e%3ctitle%3eApache%20Spark%3c/title%3e%3cpath%20d='M10.812%200c-.425.013-.845.215-1.196.605a3.593%203.593%200%2000-.493.722c-.355.667-.425%201.415-.556%202.143a551.9%20551.9%200%2000-.726%204.087c-.027.16-.096.227-.244.273C5.83%208.386%204.06%208.94%202.3%209.514c-.387.125-.773.289-1.114.506-1.042.665-1.196%201.753-.415%202.71.346.422.79.715%201.284.936%201.1.49%202.202.976%203.3%201.47.019.01.036.013.053.019h-.004l1.306.535c0%20.023.002.045%200%20.073-.2%202.03-.39%204.063-.58%206.095-.04.419-.012.831.134%201.23.317.87%201.065%201.148%201.881.701.372-.204.666-.497.937-.818%201.372-1.623%202.746-3.244%204.113-4.872.111-.133.205-.15.363-.098.349.117.697.231%201.045.347h.001c.02.012.045.02.073.03l.142.042c1.248.416%202.68.775%203.929%201.19.4.132.622.164%201.045.098.311-.048.592-.062.828-.236.602-.33.995-.957.988-1.682-.005-.427-.154-.813-.35-1.186-.82-1.556-1.637-3.113-2.461-4.666-.078-.148-.076-.243.037-.375%201.381-1.615%202.756-3.236%204.133-4.855.272-.32.513-.658.653-1.058.308-.878-.09-1.57-1-1.741a2.783%202.783%200%2000-1.235.069c-1.974.521-3.947%201.041-5.918%201.57-.175.047-.26.015-.355-.144a353.08%20353.08%200%2000-2.421-4.018%204.61%204.61%200%2000-.652-.849c-.371-.37-.802-.549-1.227-.536zm.172%203.703a.592.592%200%2001.189.211c.87%201.446%201.742%202.89%202.609%204.338.07.118.135.16.277.121%201.525-.41%203.052-.813%204.579-1.217.367-.098.735-.193%201.103-.289a.399.399%200%2001-.1.2c-1.259%201.48-2.516%202.962-3.779%204.438-.11.13-.12.22-.04.37.937%201.803%201.768%203.309%202.498%204.76l-3.696-1.019c-.538-.18-1.077-.358-1.615-.539-.163-.055-.25-.03-.36.1-1.248%201.488-2.504%202.97-3.759%204.454a.398.398%200%2001-.18.132c.035-.378.068-.757.104-1.136.149-1.572.297-3.144.451-4.716-.03-.318.117-.405-.322-.545-1.493-.593-3.346-1.321-4.816-1.905a.595.595%200%2001.24-.134c1.797-.57%203.595-1.14%205.394-1.705.127-.04.199-.092.211-.233.013-.148.05-.294.076-.441.241-1.363.483-2.726.726-4.088.068-.386.14-.771.21-1.157z'/%3e%3c/svg%3e`,redshift:`data:image/svg+xml,%3csvg%20role='img'%20viewBox='0%200%2024%2024'%20xmlns='http://www.w3.org/2000/svg'%3e%3ctitle%3eAmazon%20Redshift%3c/title%3e%3cpath%20d='M16.639%209.932a.822.822%200%200%201-.822-.82.823.823%200%200%201%201.645%200c0%20.452-.37.82-.823.82m-2.086%204.994a.823.823%200%200%201-.822-.822.822.822%200%200%201%201.645%200%20.822.822%200%200%201-.823.822m-5.004-.833a.822.822%200%201%201%20.002-1.644.822.822%200%200%201-.002%201.644m-2.083%204.578a.823.823%200%200%201-.823-.82.823.823%200%200%201%201.645%200c0%20.452-.37.82-.822.82m9.173-11.236a1.68%201.68%200%200%200-1.68%201.676c0%20.566.285%201.066.718%201.37l-.782%201.982a1.674%201.674%200%200%200-1.923%201.104l-1.753-.398a1.675%201.675%200%200%200-3.348.103c0%20.432.169.823.438%201.12l-.764%201.79c-.028-.001-.053-.008-.08-.008a1.68%201.68%200%200%200-1.68%201.676%201.68%201.68%200%200%200%203.36%200c0-.593-.312-1.112-.778-1.41l.674-1.579c.161.052.33.088.508.088.661%200%201.228-.386%201.502-.94l1.856.42a1.68%201.68%200%200%200%203.327-.325c0-.5-.224-.943-.574-1.25l.822-2.083c.053.005.104.016.157.016a1.68%201.68%200%200%200%201.68-1.676%201.68%201.68%200%200%200-1.68-1.676M12%2023.145c-4.17%200-7.286-1.252-7.286-2.37V4.79C6.14%205.938%209.131%206.547%2012%206.547c2.869%200%205.86-.609%207.286-1.756v15.983c0%201.12-3.116%202.37-7.286%202.37M12%20.856c4.293%200%207.286%201.274%207.286%202.419%200%201.143-2.993%202.418-7.286%202.418-4.293%200-7.286-1.275-7.286-2.418C4.714%202.129%207.707.855%2012%20.855m8.143%202.419C20.143%201.147%2015.947%200%2012%200%208.052%200%203.857%201.147%203.857%203.274l.002.01h-.002v17.49C3.857%2022.87%208.052%2024%2012%2024c3.947%200%208.143-1.13%208.143-3.226V3.284h-.002l.002-.01'/%3e%3c/svg%3e`,supabase:`data:image/svg+xml,%3csvg%20role='img'%20viewBox='0%200%2024%2024'%20xmlns='http://www.w3.org/2000/svg'%3e%3ctitle%3eSupabase%3c/title%3e%3cpath%20d='M11.9%201.036c-.015-.986-1.26-1.41-1.874-.637L.764%2012.05C-.33%2013.427.65%2015.455%202.409%2015.455h9.579l.113%207.51c.014.985%201.259%201.408%201.873.636l9.262-11.653c1.093-1.375.113-3.403-1.645-3.403h-9.642z'/%3e%3c/svg%3e`},Xw=e=>{let t=(0,X.c)(11),{name:n,className:r}=e,i=Yw[n.toLowerCase()];if(!i){let e;t[0]===r?e=t[1]:(e=V(`mt-0.5`,r),t[0]=r,t[1]=e);let n;return t[2]===e?n=t[3]:(n=(0,K.jsx)(Ct,{className:e}),t[2]=e,t[3]=n),n}let a;t[4]!==r||t[5]!==i?(a=V(`invert-[.5] dark:invert-[.7]`,r,i.endsWith(`.png`)&&`brightness-100 dark:brightness-100 invert-0 dark:invert-0`),t[4]=r,t[5]=i,t[6]=a):a=t[6];let o;return t[7]!==n||t[8]!==a||t[9]!==i?(o=(0,K.jsx)(`img`,{src:i,alt:n,className:a}),t[7]=n,t[8]=a,t[9]=i,t[10]=o):o=t[10],o},Zw=e=>e.type===`checkbox`,Qw=e=>e instanceof Date,$w=e=>e==null,eT=e=>typeof e==`object`,tT=e=>!$w(e)&&!Array.isArray(e)&&eT(e)&&!Qw(e),nT=e=>tT(e)&&e.target?Zw(e.target)?e.target.checked:e.target.value:e,rT=e=>e.substring(0,e.search(/\.\d+(\.|$)/))||e,iT=(e,t)=>e.has(rT(t)),aT=e=>{let t=e.constructor&&e.constructor.prototype;return tT(t)&&t.hasOwnProperty(`isPrototypeOf`)},oT=typeof window<`u`&&window.HTMLElement!==void 0&&typeof document<`u`;function sT(e){let t,n=Array.isArray(e),r=typeof FileList<`u`&&e instanceof FileList;if(e instanceof Date)t=new Date(e);else if(e instanceof Set)t=new Set(e);else if(!(oT&&(e instanceof Blob||r))&&(n||tT(e))){if(t=n?[]:{},!n&&!aT(e))t=e;else for(let n in e)e.hasOwnProperty(n)&&(t[n]=sT(e[n]))}else return e;return t}var cT=e=>Array.isArray(e)?e.filter(Boolean):[],lT=e=>e===void 0,$=(e,t,n)=>{if(!t||!tT(e))return n;let r=cT(t.split(/[,[\].]+?/)).reduce((e,t)=>$w(e)?e:e[t],e);return lT(r)||r===e?lT(e[t])?n:e[t]:r},uT=e=>typeof e==`boolean`,dT=e=>/^\w*$/.test(e),fT=e=>cT(e.replace(/["|']|\]/g,``).split(/\.|\[/)),pT=(e,t,n)=>{let r=-1,i=dT(t)?[t]:fT(t),a=i.length,o=a-1;for(;++r<a;){let t=i[r],a=n;if(r!==o){let n=e[t];a=tT(n)||Array.isArray(n)?n:isNaN(+i[r+1])?{}:[]}if(t===`__proto__`||t===`constructor`||t===`prototype`)return;e[t]=a,e=e[t]}return e},mT={BLUR:`blur`,FOCUS_OUT:`focusout`,CHANGE:`change`},hT={onBlur:`onBlur`,onChange:`onChange`,onSubmit:`onSubmit`,onTouched:`onTouched`,all:`all`},gT={max:`max`,min:`min`,maxLength:`maxLength`,minLength:`minLength`,pattern:`pattern`,required:`required`,validate:`validate`},_T=G.createContext(null),vT=()=>G.useContext(_T),yT=e=>{let{children:t,...n}=e;return G.createElement(_T.Provider,{value:n},t)},bT=(e,t,n,r=!0)=>{let i={defaultValues:t._defaultValues};for(let a in e)Object.defineProperty(i,a,{get:()=>{let i=a;return t._proxyFormState[i]!==hT.all&&(t._proxyFormState[i]=!r||hT.all),n&&(n[i]=!0),e[i]}});return i},xT=e=>tT(e)&&!Object.keys(e).length,ST=(e,t,n,r)=>{n(e);let{name:i,...a}=e;return xT(a)||Object.keys(a).length>=Object.keys(t).length||Object.keys(a).find(e=>t[e]===(!r||hT.all))},CT=e=>Array.isArray(e)?e:[e],wT=(e,t,n)=>!e||!t||e===t||CT(e).some(e=>e&&(n?e===t:e.startsWith(t)||t.startsWith(e)));function TT(e){let t=G.useRef(e);t.current=e,G.useEffect(()=>{let n=!e.disabled&&t.current.subject&&t.current.subject.subscribe({next:t.current.next});return()=>{n&&n.unsubscribe()}},[e.disabled])}function ET(e){let t=vT(),{control:n=t.control,disabled:r,name:i,exact:a}=e||{},[o,s]=G.useState(n._formState),c=G.useRef(!0),l=G.useRef({isDirty:!1,isLoading:!1,dirtyFields:!1,touchedFields:!1,validatingFields:!1,isValidating:!1,isValid:!1,errors:!1}),u=G.useRef(i);return u.current=i,TT({disabled:r,next:e=>c.current&&wT(u.current,e.name,a)&&ST(e,l.current,n._updateFormState)&&s({...n._formState,...e}),subject:n._subjects.state}),G.useEffect(()=>(c.current=!0,l.current.isValid&&n._updateValid(!0),()=>{c.current=!1}),[n]),G.useMemo(()=>bT(o,n,l.current,!1),[o,n])}var DT=e=>typeof e==`string`,OT=(e,t,n,r,i)=>DT(e)?(r&&t.watch.add(e),$(n,e,i)):Array.isArray(e)?e.map(e=>(r&&t.watch.add(e),$(n,e))):(r&&(t.watchAll=!0),n);function kT(e){let t=vT(),{control:n=t.control,name:r,defaultValue:i,disabled:a,exact:o}=e||{},s=G.useRef(r);s.current=r,TT({disabled:a,subject:n._subjects.values,next:e=>{wT(s.current,e.name,o)&&l(sT(OT(s.current,n._names,e.values||n._formValues,!1,i)))}});let[c,l]=G.useState(n._getWatch(r,i));return G.useEffect(()=>n._removeUnmounted()),c}function AT(e){let t=vT(),{name:n,disabled:r,control:i=t.control,shouldUnregister:a}=e,o=iT(i._names.array,n),s=kT({control:i,name:n,defaultValue:$(i._formValues,n,$(i._defaultValues,n,e.defaultValue)),exact:!0}),c=ET({control:i,name:n,exact:!0}),l=G.useRef(i.register(n,{...e.rules,value:s,...uT(e.disabled)?{disabled:e.disabled}:{}})),u=G.useMemo(()=>Object.defineProperties({},{invalid:{enumerable:!0,get:()=>!!$(c.errors,n)},isDirty:{enumerable:!0,get:()=>!!$(c.dirtyFields,n)},isTouched:{enumerable:!0,get:()=>!!$(c.touchedFields,n)},isValidating:{enumerable:!0,get:()=>!!$(c.validatingFields,n)},error:{enumerable:!0,get:()=>$(c.errors,n)}}),[c,n]),d=G.useMemo(()=>({name:n,value:s,...uT(r)||c.disabled?{disabled:c.disabled||r}:{},onChange:e=>l.current.onChange({target:{value:nT(e),name:n},type:mT.CHANGE}),onBlur:()=>l.current.onBlur({target:{value:$(i._formValues,n),name:n},type:mT.BLUR}),ref:e=>{let t=$(i._fields,n);t&&e&&(t._f.ref={focus:()=>e.focus(),select:()=>e.select(),setCustomValidity:t=>e.setCustomValidity(t),reportValidity:()=>e.reportValidity()})}}),[n,i._formValues,r,c.disabled,s,i._fields]);return G.useEffect(()=>{let e=i._options.shouldUnregister||a,t=(e,t)=>{let n=$(i._fields,e);n&&n._f&&(n._f.mount=t)};if(t(n,!0),e){let e=sT($(i._options.defaultValues,n));pT(i._defaultValues,n,e),lT($(i._formValues,n))&&pT(i._formValues,n,e)}return!o&&i.register(n),()=>{(o?e&&!i._state.action:e)?i.unregister(n):t(n,!1)}},[n,i,o,a]),G.useEffect(()=>{i._updateDisabledField({disabled:r,fields:i._fields,name:n})},[r,n,i]),G.useMemo(()=>({field:d,formState:c,fieldState:u}),[d,c,u])}var jT=e=>e.render(AT(e)),MT=(e,t,n,r,i)=>t?{...n[e],types:{...n[e]&&n[e].types?n[e].types:{},[r]:i||!0}}:{},NT=()=>{let e=typeof performance>`u`?Date.now():performance.now()*1e3;return`xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx`.replace(/[xy]/g,t=>{let n=(Math.random()*16+e)%16|0;return(t==`x`?n:n&3|8).toString(16)})},PT=(e,t,n={})=>n.shouldFocus||lT(n.shouldFocus)?n.focusName||`${e}.${lT(n.focusIndex)?t:n.focusIndex}.`:``,FT=e=>({isOnSubmit:!e||e===hT.onSubmit,isOnBlur:e===hT.onBlur,isOnChange:e===hT.onChange,isOnAll:e===hT.all,isOnTouch:e===hT.onTouched}),IT=(e,t,n)=>!n&&(t.watchAll||t.watch.has(e)||[...t.watch].some(t=>e.startsWith(t)&&/^\.\w+/.test(e.slice(t.length)))),LT=(e,t,n,r)=>{for(let i of n||Object.keys(e)){let n=$(e,i);if(n){let{_f:e,...a}=n;if(e){if(e.refs&&e.refs[0]&&t(e.refs[0],i)&&!r||e.ref&&t(e.ref,e.name)&&!r)return!0;if(LT(a,t))break}else if(tT(a)&<(a,t))break}}},RT=(e,t,n)=>{let r=CT($(e,n));return pT(r,`root`,t[n]),pT(e,n,r),e},zT=e=>e.type===`file`,BT=e=>typeof e==`function`,VT=e=>{if(!oT)return!1;let t=e?e.ownerDocument:0;return e instanceof(t&&t.defaultView?t.defaultView.HTMLElement:HTMLElement)},HT=e=>DT(e),UT=e=>e.type===`radio`,WT=e=>e instanceof RegExp,GT={value:!1,isValid:!1},KT={value:!0,isValid:!0},qT=e=>{if(Array.isArray(e)){if(e.length>1){let t=e.filter(e=>e&&e.checked&&!e.disabled).map(e=>e.value);return{value:t,isValid:!!t.length}}return e[0].checked&&!e[0].disabled?e[0].attributes&&!lT(e[0].attributes.value)?lT(e[0].value)||e[0].value===``?KT:{value:e[0].value,isValid:!0}:KT:GT}return GT},JT={isValid:!1,value:null},YT=e=>Array.isArray(e)?e.reduce((e,t)=>t&&t.checked&&!t.disabled?{isValid:!0,value:t.value}:e,JT):JT;function XT(e,t,n=`validate`){if(HT(e)||Array.isArray(e)&&e.every(HT)||uT(e)&&!e)return{type:n,message:HT(e)?e:``,ref:t}}var ZT=e=>tT(e)&&!WT(e)?e:{value:e,message:``},QT=async(e,t,n,r,i,a)=>{let{ref:o,refs:s,required:c,maxLength:l,minLength:u,min:d,max:f,pattern:p,validate:m,name:h,valueAsNumber:g,mount:_}=e._f,v=$(n,h);if(!_||t.has(h))return{};let y=s?s[0]:o,b=e=>{i&&y.reportValidity&&(y.setCustomValidity(uT(e)?``:e||``),y.reportValidity())},x={},S=UT(o),C=Zw(o),w=S||C,T=(g||zT(o))&&lT(o.value)&&lT(v)||VT(o)&&o.value===``||v===``||Array.isArray(v)&&!v.length,E=MT.bind(null,h,r,x),D=(e,t,n,r=gT.maxLength,i=gT.minLength)=>{let a=e?t:n;x[h]={type:e?r:i,message:a,ref:o,...E(e?r:i,a)}};if(a?!Array.isArray(v)||!v.length:c&&(!w&&(T||$w(v))||uT(v)&&!v||C&&!qT(s).isValid||S&&!YT(s).isValid)){let{value:e,message:t}=HT(c)?{value:!!c,message:c}:ZT(c);if(e&&(x[h]={type:gT.required,message:t,ref:y,...E(gT.required,t)},!r))return b(t),x}if(!T&&(!$w(d)||!$w(f))){let e,t,n=ZT(f),i=ZT(d);if(!$w(v)&&!isNaN(v)){let r=o.valueAsNumber||v&&+v;$w(n.value)||(e=r>n.value),$w(i.value)||(t=r<i.value)}else{let r=o.valueAsDate||new Date(v),a=e=>new Date(new Date().toDateString()+` `+e),s=o.type==`time`,c=o.type==`week`;DT(n.value)&&v&&(e=s?a(v)>a(n.value):c?v>n.value:r>new Date(n.value)),DT(i.value)&&v&&(t=s?a(v)<a(i.value):c?v<i.value:r<new Date(i.value))}if((e||t)&&(D(!!e,n.message,i.message,gT.max,gT.min),!r))return b(x[h].message),x}if((l||u)&&!T&&(DT(v)||a&&Array.isArray(v))){let e=ZT(l),t=ZT(u),n=!$w(e.value)&&v.length>+e.value,i=!$w(t.value)&&v.length<+t.value;if((n||i)&&(D(n,e.message,t.message),!r))return b(x[h].message),x}if(p&&!T&&DT(v)){let{value:e,message:t}=ZT(p);if(WT(e)&&!v.match(e)&&(x[h]={type:gT.pattern,message:t,ref:o,...E(gT.pattern,t)},!r))return b(t),x}if(m){if(BT(m)){let e=XT(await m(v,n),y);if(e&&(x[h]={...e,...E(gT.validate,e.message)},!r))return b(e.message),x}else if(tT(m)){let e={};for(let t in m){if(!xT(e)&&!r)break;let i=XT(await m[t](v,n),y,t);i&&(e={...i,...E(t,i.message)},b(i.message),r&&(x[h]=e))}if(!xT(e)&&(x[h]={ref:y,...e},!r))return x}}return b(!0),x},$T=(e,t)=>[...e,...CT(t)],eE=e=>Array.isArray(e)?e.map(()=>void 0):void 0;function tE(e,t,n){return[...e.slice(0,t),...CT(n),...e.slice(t)]}var nE=(e,t,n)=>Array.isArray(e)?(lT(e[n])&&(e[n]=void 0),e.splice(n,0,e.splice(t,1)[0]),e):[],rE=(e,t)=>[...CT(t),...CT(e)];function iE(e,t){let n=0,r=[...e];for(let e of t)r.splice(e-n,1),n++;return cT(r).length?r:[]}var aE=(e,t)=>lT(t)?[]:iE(e,CT(t).sort((e,t)=>e-t)),oE=(e,t,n)=>{[e[t],e[n]]=[e[n],e[t]]};function sE(e,t){let n=t.slice(0,-1).length,r=0;for(;r<n;)e=lT(e)?r++:e[t[r++]];return e}function cE(e){for(let t in e)if(e.hasOwnProperty(t)&&!lT(e[t]))return!1;return!0}function lE(e,t){let n=Array.isArray(t)?t:dT(t)?[t]:fT(t),r=n.length===1?e:sE(e,n),i=n.length-1,a=n[i];return r&&delete r[a],i!==0&&(tT(r)&&xT(r)||Array.isArray(r)&&cE(r))&&lE(e,n.slice(0,-1)),e}var uE=(e,t,n)=>(e[t]=n,e);function dE(e){let t=vT(),{control:n=t.control,name:r,keyName:i=`id`,shouldUnregister:a,rules:o}=e,[s,c]=G.useState(n._getFieldArray(r)),l=G.useRef(n._getFieldArray(r).map(NT)),u=G.useRef(s),d=G.useRef(r),f=G.useRef(!1);d.current=r,u.current=s,n._names.array.add(r),o&&n.register(r,o),TT({next:({values:e,name:t})=>{if(t===d.current||!t){let t=$(e,d.current);Array.isArray(t)&&(c(t),l.current=t.map(NT))}},subject:n._subjects.array});let p=G.useCallback(e=>{f.current=!0,n._updateFieldArray(r,e)},[n,r]);return G.useEffect(()=>{if(n._state.action=!1,IT(r,n._names)&&n._subjects.state.next({...n._formState}),f.current&&(!FT(n._options.mode).isOnSubmit||n._formState.isSubmitted)){if(n._options.resolver)n._executeSchema([r]).then(e=>{let t=$(e.errors,r),i=$(n._formState.errors,r);(i?!t&&i.type||t&&(i.type!==t.type||i.message!==t.message):t&&t.type)&&(t?pT(n._formState.errors,r,t):lE(n._formState.errors,r),n._subjects.state.next({errors:n._formState.errors}))});else{let e=$(n._fields,r);e&&e._f&&!(FT(n._options.reValidateMode).isOnSubmit&&FT(n._options.mode).isOnSubmit)&&QT(e,n._names.disabled,n._formValues,n._options.criteriaMode===hT.all,n._options.shouldUseNativeValidation,!0).then(e=>!xT(e)&&n._subjects.state.next({errors:RT(n._formState.errors,e,r)}))}}n._subjects.values.next({name:r,values:{...n._formValues}}),n._names.focus&<(n._fields,(e,t)=>{if(n._names.focus&&t.startsWith(n._names.focus)&&e.focus)return e.focus(),1}),n._names.focus=``,n._updateValid(),f.current=!1},[s,r,n]),G.useEffect(()=>(!$(n._formValues,r)&&n._updateFieldArray(r),()=>{(n._options.shouldUnregister||a)&&n.unregister(r)}),[r,n,i,a]),{swap:G.useCallback((e,t)=>{let i=n._getFieldArray(r);oE(i,e,t),oE(l.current,e,t),p(i),c(i),n._updateFieldArray(r,i,oE,{argA:e,argB:t},!1)},[p,r,n]),move:G.useCallback((e,t)=>{let i=n._getFieldArray(r);nE(i,e,t),nE(l.current,e,t),p(i),c(i),n._updateFieldArray(r,i,nE,{argA:e,argB:t},!1)},[p,r,n]),prepend:G.useCallback((e,t)=>{let i=CT(sT(e)),a=rE(n._getFieldArray(r),i);n._names.focus=PT(r,0,t),l.current=rE(l.current,i.map(NT)),p(a),c(a),n._updateFieldArray(r,a,rE,{argA:eE(e)})},[p,r,n]),append:G.useCallback((e,t)=>{let i=CT(sT(e)),a=$T(n._getFieldArray(r),i);n._names.focus=PT(r,a.length-1,t),l.current=$T(l.current,i.map(NT)),p(a),c(a),n._updateFieldArray(r,a,$T,{argA:eE(e)})},[p,r,n]),remove:G.useCallback(e=>{let t=aE(n._getFieldArray(r),e);l.current=aE(l.current,e),p(t),c(t),!Array.isArray($(n._fields,r))&&pT(n._fields,r,void 0),n._updateFieldArray(r,t,aE,{argA:e})},[p,r,n]),insert:G.useCallback((e,t,i)=>{let a=CT(sT(t)),o=tE(n._getFieldArray(r),e,a);n._names.focus=PT(r,e,i),l.current=tE(l.current,e,a.map(NT)),p(o),c(o),n._updateFieldArray(r,o,tE,{argA:e,argB:eE(t)})},[p,r,n]),update:G.useCallback((e,t)=>{let i=sT(t),a=uE(n._getFieldArray(r),e,i);l.current=[...a].map((t,n)=>!t||n===e?NT():l.current[n]),p(a),c([...a]),n._updateFieldArray(r,a,uE,{argA:e,argB:i},!0,!1)},[p,r,n]),replace:G.useCallback(e=>{let t=CT(sT(e));l.current=t.map(NT),p([...t]),c([...t]),n._updateFieldArray(r,[...t],e=>e,{},!0,!1)},[p,r,n]),fields:G.useMemo(()=>s.map((e,t)=>({...e,[i]:l.current[t]||NT()})),[s,i])}}var fE=()=>{let e=[];return{get observers(){return e},next:t=>{for(let n of e)n.next&&n.next(t)},subscribe:t=>(e.push(t),{unsubscribe:()=>{e=e.filter(e=>e!==t)}}),unsubscribe:()=>{e=[]}}},pE=e=>$w(e)||!eT(e);function mE(e,t){if(pE(e)||pE(t))return e===t;if(Qw(e)&&Qw(t))return e.getTime()===t.getTime();let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let i of n){let n=e[i];if(!r.includes(i))return!1;if(i!==`ref`){let e=t[i];if(Qw(n)&&Qw(e)||tT(n)&&tT(e)||Array.isArray(n)&&Array.isArray(e)?!mE(n,e):n!==e)return!1}}return!0}var hE=e=>e.type===`select-multiple`,gE=e=>UT(e)||Zw(e),_E=e=>VT(e)&&e.isConnected,vE=e=>{for(let t in e)if(BT(e[t]))return!0;return!1};function yE(e,t={}){let n=Array.isArray(e);if(tT(e)||n)for(let n in e)Array.isArray(e[n])||tT(e[n])&&!vE(e[n])?(t[n]=Array.isArray(e[n])?[]:{},yE(e[n],t[n])):$w(e[n])||(t[n]=!0);return t}function bE(e,t,n){let r=Array.isArray(e);if(tT(e)||r)for(let r in e)Array.isArray(e[r])||tT(e[r])&&!vE(e[r])?lT(t)||pE(n[r])?n[r]=Array.isArray(e[r])?yE(e[r],[]):{...yE(e[r])}:bE(e[r],$w(t)?{}:t[r],n[r]):n[r]=!mE(e[r],t[r]);return n}var xE=(e,t)=>bE(e,t,yE(t)),SE=(e,{valueAsNumber:t,valueAsDate:n,setValueAs:r})=>lT(e)?e:t?e===``?NaN:e&&+e:n&&DT(e)?new Date(e):r?r(e):e;function CE(e){let t=e.ref;return zT(t)?t.files:UT(t)?YT(e.refs).value:hE(t)?[...t.selectedOptions].map(({value:e})=>e):Zw(t)?qT(e.refs).value:SE(lT(t.value)?e.ref.value:t.value,e)}var wE=(e,t,n,r)=>{let i={};for(let n of e){let e=$(t,n);e&&pT(i,n,e._f)}return{criteriaMode:n,names:[...e],fields:i,shouldUseNativeValidation:r}},TE=e=>lT(e)?e:WT(e)?e.source:tT(e)?WT(e.value)?e.value.source:e.value:e,EE=`AsyncFunction`,DE=e=>!!e&&!!e.validate&&!!(BT(e.validate)&&e.validate.constructor.name===EE||tT(e.validate)&&Object.values(e.validate).find(e=>e.constructor.name===EE)),OE=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate);function kE(e,t,n){let r=$(e,n);if(r||dT(n))return{error:r,name:n};let i=n.split(`.`);for(;i.length;){let r=i.join(`.`),a=$(t,r),o=$(e,r);if(a&&!Array.isArray(a)&&n!==r)return{name:n};if(o&&o.type)return{name:r,error:o};i.pop()}return{name:n}}var AE=(e,t,n,r,i)=>i.isOnAll?!1:!n&&i.isOnTouch?!(t||e):(n?r.isOnBlur:i.isOnBlur)?!e:!(n?r.isOnChange:i.isOnChange)||e,jE=(e,t)=>!cT($(e,t)).length&&lE(e,t),ME={mode:hT.onSubmit,reValidateMode:hT.onChange,shouldFocusError:!0};function NE(e={}){let t={...ME,...e},n={submitCount:0,isDirty:!1,isLoading:BT(t.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{},errors:t.errors||{},disabled:t.disabled||!1},r={},i=(tT(t.defaultValues)||tT(t.values))&&sT(t.defaultValues||t.values)||{},a=t.shouldUnregister?{}:sT(i),o={action:!1,mount:!1,watch:!1},s={mount:new Set,disabled:new Set,unMount:new Set,array:new Set,watch:new Set},c,l=0,u={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},d={values:fE(),array:fE(),state:fE()},f=FT(t.mode),p=FT(t.reValidateMode),m=t.criteriaMode===hT.all,h=e=>t=>{clearTimeout(l),l=setTimeout(e,t)},g=async e=>{if(!t.disabled&&(u.isValid||e)){let e=t.resolver?xT((await w()).errors):await E(r,!0);e!==n.isValid&&d.state.next({isValid:e})}},_=(e,r)=>{!t.disabled&&(u.isValidating||u.validatingFields)&&((e||Array.from(s.mount)).forEach(e=>{e&&(r?pT(n.validatingFields,e,r):lE(n.validatingFields,e))}),d.state.next({validatingFields:n.validatingFields,isValidating:!xT(n.validatingFields)}))},v=(e,s=[],c,l,f=!0,p=!0)=>{if(l&&c&&!t.disabled){if(o.action=!0,p&&Array.isArray($(r,e))){let t=c($(r,e),l.argA,l.argB);f&&pT(r,e,t)}if(p&&Array.isArray($(n.errors,e))){let t=c($(n.errors,e),l.argA,l.argB);f&&pT(n.errors,e,t),jE(n.errors,e)}if(u.touchedFields&&p&&Array.isArray($(n.touchedFields,e))){let t=c($(n.touchedFields,e),l.argA,l.argB);f&&pT(n.touchedFields,e,t)}u.dirtyFields&&(n.dirtyFields=xE(i,a)),d.state.next({name:e,isDirty:O(e,s),dirtyFields:n.dirtyFields,errors:n.errors,isValid:n.isValid})}else pT(a,e,s)},y=(e,t)=>{pT(n.errors,e,t),d.state.next({errors:n.errors})},b=e=>{n.errors=e,d.state.next({errors:n.errors,isValid:!1})},x=(e,t,n,s)=>{let c=$(r,e);if(c){let r=$(a,e,lT(n)?$(i,e):n);lT(r)||s&&s.defaultChecked||t?pT(a,e,t?r:CE(c._f)):j(e,r),o.mount&&g()}},S=(e,a,o,s,c)=>{let l=!1,f=!1,p={name:e};if(!t.disabled){let t=!!($(r,e)&&$(r,e)._f&&$(r,e)._f.disabled);if(!o||s){u.isDirty&&(f=n.isDirty,n.isDirty=p.isDirty=O(),l=f!==p.isDirty);let r=t||mE($(i,e),a);f=!!(!t&&$(n.dirtyFields,e)),r||t?lE(n.dirtyFields,e):pT(n.dirtyFields,e,!0),p.dirtyFields=n.dirtyFields,l||=u.dirtyFields&&f!==!r}if(o){let t=$(n.touchedFields,e);t||(pT(n.touchedFields,e,o),p.touchedFields=n.touchedFields,l||=u.touchedFields&&t!==o)}l&&c&&d.state.next(p)}return l?p:{}},C=(e,r,i,a)=>{let o=$(n.errors,e),s=u.isValid&&uT(r)&&n.isValid!==r;if(t.delayError&&i?(c=h(()=>y(e,i)),c(t.delayError)):(clearTimeout(l),c=null,i?pT(n.errors,e,i):lE(n.errors,e)),(i?!mE(o,i):o)||!xT(a)||s){let t={...a,...s&&uT(r)?{isValid:r}:{},errors:n.errors,name:e};n={...n,...t},d.state.next(t)}},w=async e=>{_(e,!0);let n=await t.resolver(a,t.context,wE(e||s.mount,r,t.criteriaMode,t.shouldUseNativeValidation));return _(e),n},T=async e=>{let{errors:t}=await w(e);if(e)for(let r of e){let e=$(t,r);e?pT(n.errors,r,e):lE(n.errors,r)}else n.errors=t;return t},E=async(e,r,i={valid:!0})=>{for(let o in e){let c=e[o];if(c){let{_f:e,...l}=c;if(e){let l=s.array.has(e.name),d=c._f&&DE(c._f);d&&u.validatingFields&&_([o],!0);let f=await QT(c,s.disabled,a,m,t.shouldUseNativeValidation&&!r,l);if(d&&u.validatingFields&&_([o]),f[e.name]&&(i.valid=!1,r))break;!r&&($(f,e.name)?l?RT(n.errors,f,e.name):pT(n.errors,e.name,f[e.name]):lE(n.errors,e.name))}!xT(l)&&await E(l,r,i)}}return i.valid},D=()=>{for(let e of s.unMount){let t=$(r,e);t&&(t._f.refs?t._f.refs.every(e=>!_E(e)):!_E(t._f.ref))&&oe(e)}s.unMount=new Set},O=(e,n)=>!t.disabled&&(e&&n&&pT(a,e,n),!mE(re(),i)),k=(e,t,n)=>OT(e,s,{...o.mount?a:lT(t)?i:DT(e)?{[e]:t}:t},n,t),A=e=>cT($(o.mount?a:i,e,t.shouldUnregister?$(i,e,[]):[])),j=(e,t,n={})=>{let i=$(r,e),o=t;if(i){let n=i._f;n&&(!n.disabled&&pT(a,e,SE(t,n)),o=VT(n.ref)&&$w(t)?``:t,hE(n.ref)?[...n.ref.options].forEach(e=>e.selected=o.includes(e.value)):n.refs?Zw(n.ref)?n.refs.length>1?n.refs.forEach(e=>(!e.defaultChecked||!e.disabled)&&(e.checked=Array.isArray(o)?!!o.find(t=>t===e.value):o===e.value)):n.refs[0]&&(n.refs[0].checked=!!o):n.refs.forEach(e=>e.checked=e.value===o):zT(n.ref)?n.ref.value=``:(n.ref.value=o,n.ref.type||d.values.next({name:e,values:{...a}})))}(n.shouldDirty||n.shouldTouch)&&S(e,o,n.shouldTouch,n.shouldDirty,!0),n.shouldValidate&&ne(e)},ee=(e,t,n)=>{for(let i in t){let a=t[i],o=`${e}.${i}`,c=$(r,o);(s.array.has(e)||tT(a)||c&&!c._f)&&!Qw(a)?ee(o,a,n):j(o,a,n)}},M=(e,t,c={})=>{let l=$(r,e),f=s.array.has(e),p=sT(t);pT(a,e,p),f?(d.array.next({name:e,values:{...a}}),(u.isDirty||u.dirtyFields)&&c.shouldDirty&&d.state.next({name:e,dirtyFields:xE(i,a),isDirty:O(e,p)})):l&&!l._f&&!$w(p)?ee(e,p,c):j(e,p,c),IT(e,s)&&d.state.next({...n}),d.values.next({name:o.mount?e:void 0,values:{...a}})},N=async e=>{o.mount=!0;let i=e.target,l=i.name,h=!0,v=$(r,l),y=()=>i.type?CE(v._f):nT(e),b=e=>{h=Number.isNaN(e)||Qw(e)&&isNaN(e.getTime())||mE(e,$(a,l,e))};if(v){let i,o,x=y(),T=e.type===mT.BLUR||e.type===mT.FOCUS_OUT,D=!OE(v._f)&&!t.resolver&&!$(n.errors,l)&&!v._f.deps||AE(T,$(n.touchedFields,l),n.isSubmitted,p,f),O=IT(l,s,T);pT(a,l,x),T?(v._f.onBlur&&v._f.onBlur(e),c&&c(0)):v._f.onChange&&v._f.onChange(e);let k=S(l,x,T,!1),A=!xT(k)||O;if(!T&&d.values.next({name:l,type:e.type,values:{...a}}),D)return u.isValid&&(t.mode===`onBlur`&&T?g():T||g()),A&&d.state.next({name:l,...O?{}:k});if(!T&&O&&d.state.next({...n}),t.resolver){let{errors:e}=await w([l]);if(b(x),h){let t=kE(n.errors,r,l),a=kE(e,r,t.name||l);i=a.error,l=a.name,o=xT(e)}}else _([l],!0),i=(await QT(v,s.disabled,a,m,t.shouldUseNativeValidation))[l],_([l]),b(x),h&&(i?o=!1:u.isValid&&(o=await E(r,!0)));h&&(v._f.deps&&ne(v._f.deps),C(l,o,i,k))}},te=(e,t)=>{if($(n.errors,t)&&e.focus)return e.focus(),1},ne=async(e,i={})=>{let a,o,c=CT(e);if(t.resolver){let t=await T(lT(e)?e:c);a=xT(t),o=e?!c.some(e=>$(t,e)):a}else e?(o=(await Promise.all(c.map(async e=>{let t=$(r,e);return await E(t&&t._f?{[e]:t}:t)}))).every(Boolean),!(!o&&!n.isValid)&&g()):o=a=await E(r);return d.state.next({...!DT(e)||u.isValid&&a!==n.isValid?{}:{name:e},...t.resolver||!e?{isValid:a}:{},errors:n.errors}),i.shouldFocus&&!o&<(r,te,e?c:s.mount),o},re=e=>{let t={...o.mount?a:i};return lT(e)?t:DT(e)?$(t,e):e.map(e=>$(t,e))},ie=(e,t)=>({invalid:!!$((t||n).errors,e),isDirty:!!$((t||n).dirtyFields,e),error:$((t||n).errors,e),isValidating:!!$(n.validatingFields,e),isTouched:!!$((t||n).touchedFields,e)}),P=e=>{e&&CT(e).forEach(e=>lE(n.errors,e)),d.state.next({errors:e?n.errors:{}})},ae=(e,t,i)=>{let a=($(r,e,{_f:{}})._f||{}).ref,{ref:o,message:s,type:c,...l}=$(n.errors,e)||{};pT(n.errors,e,{...l,...t,ref:a}),d.state.next({name:e,errors:n.errors,isValid:!1}),i&&i.shouldFocus&&a&&a.focus&&a.focus()},F=(e,t)=>BT(e)?d.values.subscribe({next:n=>e(k(void 0,t),n)}):k(e,t,!0),oe=(e,o={})=>{for(let c of e?CT(e):s.mount)s.mount.delete(c),s.array.delete(c),o.keepValue||(lE(r,c),lE(a,c)),!o.keepError&&lE(n.errors,c),!o.keepDirty&&lE(n.dirtyFields,c),!o.keepTouched&&lE(n.touchedFields,c),!o.keepIsValidating&&lE(n.validatingFields,c),!t.shouldUnregister&&!o.keepDefaultValue&&lE(i,c);d.values.next({values:{...a}}),d.state.next({...n,...o.keepDirty?{isDirty:O()}:{}}),!o.keepIsValid&&g()},I=({disabled:e,name:t,field:n,fields:r})=>{(uT(e)&&o.mount||e||s.disabled.has(t))&&(e?s.disabled.add(t):s.disabled.delete(t),S(t,CE(n?n._f:$(r,t)._f),!1,!1,!0))},se=(e,n={})=>{let a=$(r,e),c=uT(n.disabled)||uT(t.disabled);return pT(r,e,{...a||{},_f:{...a&&a._f?a._f:{ref:{name:e}},name:e,mount:!0,...n}}),s.mount.add(e),a?I({field:a,disabled:uT(n.disabled)?n.disabled:t.disabled,name:e}):x(e,!0,n.value),{...c?{disabled:n.disabled||t.disabled}:{},...t.progressive?{required:!!n.required,min:TE(n.min),max:TE(n.max),minLength:TE(n.minLength),maxLength:TE(n.maxLength),pattern:TE(n.pattern)}:{},name:e,onChange:N,onBlur:N,ref:c=>{if(c){se(e,n),a=$(r,e);let t=lT(c.value)&&c.querySelectorAll&&c.querySelectorAll(`input,select,textarea`)[0]||c,o=gE(t),s=a._f.refs||[];if(o?s.find(e=>e===t):t===a._f.ref)return;pT(r,e,{_f:{...a._f,...o?{refs:[...s.filter(_E),t,...Array.isArray($(i,e))?[{}]:[]],ref:{type:t.type,name:e}}:{ref:t}}}),x(e,!1,void 0,t)}else a=$(r,e,{}),a._f&&(a._f.mount=!1),(t.shouldUnregister||n.shouldUnregister)&&!(iT(s.array,e)&&o.action)&&s.unMount.add(e)}}},ce=()=>t.shouldFocusError&<(r,te,s.mount),L=e=>{uT(e)&&(d.state.next({disabled:e}),LT(r,(t,n)=>{let i=$(r,n);i&&(t.disabled=i._f.disabled||e,Array.isArray(i._f.refs)&&i._f.refs.forEach(t=>{t.disabled=i._f.disabled||e}))},0,!1))},le=(e,i)=>async o=>{let c;o&&(o.preventDefault&&o.preventDefault(),o.persist&&o.persist());let l=sT(a);if(s.disabled.size)for(let e of s.disabled)pT(l,e,void 0);if(d.state.next({isSubmitting:!0}),t.resolver){let{errors:e,values:t}=await w();n.errors=e,l=t}else await E(r);if(lE(n.errors,`root`),xT(n.errors)){d.state.next({errors:{}});try{await e(l,o)}catch(e){c=e}}else i&&await i({...n.errors},o),ce(),setTimeout(ce);if(d.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:xT(n.errors)&&!c,submitCount:n.submitCount+1,errors:n.errors}),c)throw c},ue=(e,t={})=>{$(r,e)&&(lT(t.defaultValue)?M(e,sT($(i,e))):(M(e,t.defaultValue),pT(i,e,sT(t.defaultValue))),t.keepTouched||lE(n.touchedFields,e),t.keepDirty||(lE(n.dirtyFields,e),n.isDirty=t.defaultValue?O(e,sT($(i,e))):O()),t.keepError||(lE(n.errors,e),u.isValid&&g()),d.state.next({...n}))},de=(e,c={})=>{let l=e?sT(e):i,f=sT(l),p=xT(e),m=p?i:f;if(c.keepDefaultValues||(i=l),!c.keepValues){if(c.keepDirtyValues){let e=new Set([...s.mount,...Object.keys(xE(i,a))]);for(let t of Array.from(e))$(n.dirtyFields,t)?pT(m,t,$(a,t)):M(t,$(m,t))}else{if(oT&&lT(e))for(let e of s.mount){let t=$(r,e);if(t&&t._f){let e=Array.isArray(t._f.refs)?t._f.refs[0]:t._f.ref;if(VT(e)){let t=e.closest(`form`);if(t){t.reset();break}}}}r={}}a=t.shouldUnregister?c.keepDefaultValues?sT(i):{}:sT(m),d.array.next({values:{...m}}),d.values.next({values:{...m}})}s={mount:c.keepDirtyValues?s.mount:new Set,unMount:new Set,array:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:``},o.mount=!u.isValid||!!c.keepIsValid||!!c.keepDirtyValues,o.watch=!!t.shouldUnregister,d.state.next({submitCount:c.keepSubmitCount?n.submitCount:0,isDirty:p?!1:c.keepDirty?n.isDirty:!!(c.keepDefaultValues&&!mE(e,i)),isSubmitted:c.keepIsSubmitted?n.isSubmitted:!1,dirtyFields:p?{}:c.keepDirtyValues?c.keepDefaultValues&&a?xE(i,a):n.dirtyFields:c.keepDefaultValues&&e?xE(i,e):c.keepDirty?n.dirtyFields:{},touchedFields:c.keepTouched?n.touchedFields:{},errors:c.keepErrors?n.errors:{},isSubmitSuccessful:c.keepIsSubmitSuccessful?n.isSubmitSuccessful:!1,isSubmitting:!1})},R=(e,t)=>de(BT(e)?e(a):e,t);return{control:{register:se,unregister:oe,getFieldState:ie,handleSubmit:le,setError:ae,_executeSchema:w,_getWatch:k,_getDirty:O,_updateValid:g,_removeUnmounted:D,_updateFieldArray:v,_updateDisabledField:I,_getFieldArray:A,_reset:de,_resetDefaultValues:()=>BT(t.defaultValues)&&t.defaultValues().then(e=>{R(e,t.resetOptions),d.state.next({isLoading:!1})}),_updateFormState:e=>{n={...n,...e}},_disableForm:L,_subjects:d,_proxyFormState:u,_setErrors:b,get _fields(){return r},get _formValues(){return a},get _state(){return o},set _state(e){o=e},get _defaultValues(){return i},get _names(){return s},set _names(e){s=e},get _formState(){return n},set _formState(e){n=e},get _options(){return t},set _options(e){t={...t,...e}}},trigger:ne,register:se,handleSubmit:le,watch:F,setValue:M,getValues:re,reset:R,resetField:ue,clearErrors:P,unregister:oe,setError:ae,setFocus:(e,t={})=>{let n=$(r,e),i=n&&n._f;if(i){let e=i.refs?i.refs[0]:i.ref;e.focus&&(e.focus(),t.shouldSelect&&BT(e.select)&&e.select())}},getFieldState:ie}}function PE(e={}){let t=G.useRef(void 0),n=G.useRef(void 0),[r,i]=G.useState({isDirty:!1,isValidating:!1,isLoading:BT(e.defaultValues),isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,submitCount:0,dirtyFields:{},touchedFields:{},validatingFields:{},errors:e.errors||{},disabled:e.disabled||!1,defaultValues:BT(e.defaultValues)?void 0:e.defaultValues});t.current||={...NE(e),formState:r};let a=t.current.control;return a._options=e,TT({subject:a._subjects.state,next:e=>{ST(e,a._proxyFormState,a._updateFormState,!0)&&i({...a._formState})}}),G.useEffect(()=>a._disableForm(e.disabled),[a,e.disabled]),G.useEffect(()=>{if(a._proxyFormState.isDirty){let e=a._getDirty();e!==r.isDirty&&a._subjects.state.next({isDirty:e})}},[a,r.isDirty]),G.useEffect(()=>{e.values&&!mE(e.values,n.current)?(a._reset(e.values,a._options.resetOptions),n.current=e.values,i(e=>({...e}))):a._resetDefaultValues()},[e.values,a]),G.useEffect(()=>{e.errors&&a._setErrors(e.errors)},[e.errors,a]),G.useEffect(()=>{a._state.mount||(a._updateValid(),a._state.mount=!0),a._state.watch&&(a._state.watch=!1,a._subjects.state.next({...a._formState})),a._removeUnmounted()}),G.useEffect(()=>{e.shouldUnregister&&a._subjects.values.next({values:a._getWatch()})},[e.shouldUnregister,a]),t.current.formState=bT(r,a),t.current}var FE=(e,t,n)=>{if(e&&`reportValidity`in e){let r=$(n,t);e.setCustomValidity(r&&r.message||``),e.reportValidity()}},IE=(e,t)=>{for(let n in t.fields){let r=t.fields[n];r&&r.ref&&`reportValidity`in r.ref?FE(r.ref,n,e):r&&r.refs&&r.refs.forEach(t=>FE(t,n,e))}},LE=(e,t)=>{t.shouldUseNativeValidation&&IE(e,t);let n={};for(let r in e){let i=$(t.fields,r),a=Object.assign(e[r]||{},{ref:i&&i.refs?i.refs[0]:i&&i.ref});if(RE(t.names||Object.keys(e),r)){let e=Object.assign({},$(n,r));pT(e,`root`,a),pT(n,r,e)}else pT(n,r,a)}return n},RE=(e,t)=>{let n=zE(t).replace(/[.*+?^${}()|\\]/g,`\\$&`);return e.some(e=>zE(e).match(`^${n}\\.\\d+`))};function zE(e){return e.replace(/\[(\d+)]/g,`.$1`).replace(/[[\]]/g,``)}function BE(){return BE=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},BE.apply(null,arguments)}function VE(e,t){try{var n=e()}catch(e){return t(e)}return n&&n.then?n.then(void 0,t):n}function HE(e,t){for(var n=Object.create(null);e.length;){var r=e[0],i=r.code,a=r.message,o=r.path.join(`.`);if(!n[o]){if(`unionErrors`in r){var s=r.unionErrors.reduce(function(e,t){return t.errors.length<e.errors.length?t:e}).errors[0];n[o]={message:s?.message??a,type:s?.code??i}}else n[o]={message:a,type:i}}if(`unionErrors`in r&&r.unionErrors.forEach(function(t){return t.errors.forEach(function(t){return e.push(t)})}),t){var c=n[o].types,l=c&&c[r.code];n[o]=MT(o,t,n,i,l?[].concat(l,r.message):r.message)}e.shift()}return n}function UE(e,t){for(var n=Object.create(null),r=function(){var r=e[0],i=r.code,a=r.message,o=r.path.join(`.`);if(!n[o]){if(r.code===`invalid_union`&&r.errors.length>0){var s=r.errors.reduce(function(e,t){return t.length<e.length?t:e})[0];n[o]={message:s?.message??a,type:s?.code??i}}else n[o]={message:a,type:i}}if(r.code===`invalid_union`&&r.errors.forEach(function(t){return t.forEach(function(t){return e.push(BE({},t,{path:[].concat(r.path,t.path)}))})}),t){var c=n[o].types,l=c&&c[r.code];n[o]=MT(o,t,n,i,l?[].concat(l,r.message):r.message)}e.shift()};e.length;)r();return n}function WE(e,t,n){if(n===void 0&&(n={}),function(e){return`_zod`in e&&typeof e._zod==`object`}(e))return function(r,i,a){try{return Promise.resolve(VE(function(){function i(e){return a.shouldUseNativeValidation&&IE({},a),{errors:{},values:n.raw?Object.assign({},r):e}}var o=e;return n.mode===`sync`?i(o.parse(r,t)):Promise.resolve(o.parseAsync(r,t)).then(i)},function(e){if(function(e){var t;return!(e==null||(t=e._zod)==null||(t=t.traits)==null||!t.has(`$ZodError`))}(e))return{values:{},errors:LE(UE(e.issues,!a.shouldUseNativeValidation&&a.criteriaMode===`all`),a)};throw e}))}catch(e){return Promise.reject(e)}};if(function(e){return`_def`in e&&typeof e._def==`object`}(e))return function(r,i,a){try{return Promise.resolve(VE(function(){return Promise.resolve(e[n.mode===`sync`?`parse`:`parseAsync`](r,t)).then(function(e){return a.shouldUseNativeValidation&&IE({},a),{errors:{},values:n.raw?Object.assign({},r):e}})},function(e){if(function(e){return Array.isArray(e?.issues)}(e))return{values:{},errors:LE(HE(e.errors,!a.shouldUseNativeValidation&&a.criteriaMode===`all`),a)};throw e}))}catch(e){return Promise.reject(e)}};throw Error(`Invalid input: not a Zod schema`)}var GE={of(e){return JSON.stringify(e)},parse(e){if(!e)return{};try{return JSON.parse(e)}catch{return{label:e}}}};function KE(){return Math.floor(Math.random()*1e5)}var qE=1,JE=.9,YE=.8,XE=.17,ZE=.1,QE=.999,$E=.9999,eD=.99,tD=/[\\\/_+.#"@\[\(\{&]/,nD=/[\\\/_+.#"@\[\(\{&]/g,rD=/[\s-]/,iD=/[\s-]/g;function aD(e,t,n,r,i,a,o){if(a===t.length)return i===e.length?qE:eD;var s=`${i},${a}`;if(o[s]!==void 0)return o[s];for(var c=r.charAt(a),l=n.indexOf(c,i),u=0,d,f,p,m;l>=0;)d=aD(e,t,n,r,l+1,a+1,o),d>u&&(l===i?d*=qE:tD.test(e.charAt(l-1))?(d*=YE,p=e.slice(i,l-1).match(nD),p&&i>0&&(d*=QE**+p.length)):rD.test(e.charAt(l-1))?(d*=JE,m=e.slice(i,l-1).match(iD),m&&i>0&&(d*=QE**+m.length)):(d*=XE,i>0&&(d*=QE**+(l-i))),e.charAt(l)!==t.charAt(a)&&(d*=$E)),(d<ZE&&n.charAt(l-1)===r.charAt(a+1)||r.charAt(a+1)===r.charAt(a)&&n.charAt(l-1)!==r.charAt(a))&&(f=aD(e,t,n,r,l+1,a+2,o),f*ZE>d&&(d=f*ZE)),d>u&&(u=d),l=n.indexOf(c,l+1);return o[s]=u,u}function oD(e){return e.toLowerCase().replace(iD,` `)}function sD(e,t,n){return e=n&&n.length>0?`${e+` `+n.join(` `)}`:e,aD(e,t,oD(e),oD(t),0,0,{})}var cD=`[cmdk-group=""]`,lD=`[cmdk-group-items=""]`,uD=`[cmdk-group-heading=""]`,dD=`[cmdk-item=""]`,fD=`${dD}:not([aria-disabled="true"])`,pD=`cmdk-item-select`,mD=`data-value`,hD=(e,t,n)=>sD(e,t,n),gD=G.createContext(void 0),_D=()=>G.useContext(gD),vD=G.createContext(void 0),yD=()=>G.useContext(vD),bD=G.createContext(void 0),xD=G.forwardRef((e,t)=>{let n=FD(()=>({search:``,value:e.value??e.defaultValue??``,selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}})),r=FD(()=>new Set),i=FD(()=>new Map),a=FD(()=>new Map),o=FD(()=>new Set),s=ND(e),{label:c,children:l,value:u,onValueChange:d,filter:f,shouldFilter:p,loop:m,disablePointerSelection:h=!1,vimBindings:g=!0,..._}=e,v=Ve(),y=Ve(),b=Ve(),x=G.useRef(null),S=RD();PD(()=>{if(u!==void 0){let e=u.trim();n.current.value=e,C.emit()}},[u]),PD(()=>{S(6,k)},[]);let C=G.useMemo(()=>({subscribe:e=>(o.current.add(e),()=>o.current.delete(e)),snapshot:()=>n.current,setState:(e,t,r)=>{var i,a,o;if(!Object.is(n.current[e],t)){if(n.current[e]=t,e===`search`)O(),E(),S(1,D);else if(e===`value`){if(document.activeElement.hasAttribute(`cmdk-input`)||document.activeElement.hasAttribute(`cmdk-root`)){let e=document.getElementById(b);e?e.focus():(i=document.getElementById(v))==null||i.focus()}if(S(7,()=>{n.current.selectedItemId=A()?.id,C.emit()}),r||S(5,k),s.current?.value!==void 0){let e=t??``;(o=(a=s.current).onValueChange)==null||o.call(a,e);return}}C.emit()}},emit:()=>{o.current.forEach(e=>e())}}),[]),w=G.useMemo(()=>({value:(e,t,r)=>{t!==a.current.get(e)?.value&&(a.current.set(e,{value:t,keywords:r}),n.current.filtered.items.set(e,T(t,r)),S(2,()=>{E(),C.emit()}))},item:(e,t)=>(r.current.add(e),t&&(i.current.has(t)?i.current.get(t).add(e):i.current.set(t,new Set([e]))),S(3,()=>{O(),E(),n.current.value||D(),C.emit()}),()=>{a.current.delete(e),r.current.delete(e),n.current.filtered.items.delete(e);let t=A();S(4,()=>{O(),t?.getAttribute(`id`)===e&&D(),C.emit()})}),group:e=>(i.current.has(e)||i.current.set(e,new Set),()=>{a.current.delete(e),i.current.delete(e)}),filter:()=>s.current.shouldFilter,label:c||e[`aria-label`],getDisablePointerSelection:()=>s.current.disablePointerSelection,listId:v,inputId:b,labelId:y,listInnerRef:x}),[]);function T(e,t){let r=s.current?.filter??hD;return e?r(e,n.current.search,t):0}function E(){if(!n.current.search||s.current.shouldFilter===!1)return;let e=n.current.filtered.items,t=[];n.current.filtered.groups.forEach(n=>{let r=i.current.get(n),a=0;r.forEach(t=>{let n=e.get(t);a=Math.max(n,a)}),t.push([n,a])});let r=x.current;j().sort((t,n)=>{let r=t.getAttribute(`id`),i=n.getAttribute(`id`);return(e.get(i)??0)-(e.get(r)??0)}).forEach(e=>{let t=e.closest(lD);t?t.appendChild(e.parentElement===t?e:e.closest(`${lD} > *`)):r.appendChild(e.parentElement===r?e:e.closest(`${lD} > *`))}),t.sort((e,t)=>t[1]-e[1]).forEach(e=>{let t=x.current?.querySelector(`${cD}[${mD}="${encodeURIComponent(e[0])}"]`);t?.parentElement.appendChild(t)})}function D(){let e=j().find(e=>e.getAttribute(`aria-disabled`)!==`true`)?.getAttribute(mD);C.setState(`value`,e||void 0)}function O(){if(!n.current.search||s.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let e=0;for(let t of r.current){let r=T(a.current.get(t)?.value??``,a.current.get(t)?.keywords??[]);n.current.filtered.items.set(t,r),r>0&&e++}for(let[e,t]of i.current)for(let r of t)if(n.current.filtered.items.get(r)>0){n.current.filtered.groups.add(e);break}n.current.filtered.count=e}function k(){var e;let t=A();t&&(t.parentElement?.firstChild===t&&((e=t.closest(cD)?.querySelector(uD))==null||e.scrollIntoView({block:`nearest`})),t.scrollIntoView({block:`nearest`}))}function A(){return x.current?.querySelector(`${dD}[aria-selected="true"]`)}function j(){return Array.from(x.current?.querySelectorAll(fD)||[])}function ee(e){let t=j()[e];t&&C.setState(`value`,t.getAttribute(mD))}function M(e){var t;let n=A(),r=j(),i=r.findIndex(e=>e===n),a=r[i+e];(t=s.current)!=null&&t.loop&&(a=i+e<0?r[r.length-1]:i+e===r.length?r[0]:r[i+e]),a&&C.setState(`value`,a.getAttribute(mD))}function N(e){let t=A()?.closest(cD),n;for(;t&&!n;)t=e>0?jD(t,cD):MD(t,cD),n=t?.querySelector(fD);n?C.setState(`value`,n.getAttribute(mD)):M(e)}let te=()=>ee(j().length-1),ne=e=>{e.preventDefault(),e.metaKey?te():e.altKey?N(1):M(1)},re=e=>{e.preventDefault(),e.metaKey?ee(0):e.altKey?N(-1):M(-1)};return G.createElement(De.div,{ref:t,tabIndex:-1,..._,"cmdk-root":``,onKeyDown:e=>{var t;(t=_.onKeyDown)==null||t.call(_,e);let n=e.nativeEvent.isComposing||e.keyCode===229;if(!(e.defaultPrevented||n))switch(e.key){case`n`:case`j`:g&&e.ctrlKey&&ne(e);break;case`ArrowDown`:ne(e);break;case`p`:case`k`:g&&e.ctrlKey&&re(e);break;case`ArrowUp`:re(e);break;case`Home`:e.preventDefault(),ee(0);break;case`End`:e.preventDefault(),te();break;case`Enter`:{e.preventDefault();let t=A();if(t){let e=new Event(pD);t.dispatchEvent(e)}}}}},G.createElement(`label`,{"cmdk-label":``,htmlFor:w.inputId,id:w.labelId,style:VD},c),BD(e,e=>G.createElement(vD.Provider,{value:C},G.createElement(gD.Provider,{value:w},e))))}),SD=G.forwardRef((e,t)=>{let n=Ve(),r=G.useRef(null),i=G.useContext(bD),a=_D(),o=ND(e),s=o.current?.forceMount??i?.forceMount;PD(()=>{if(!s)return a.item(n,i?.id)},[s]);let c=LD(n,r,[e.value,e.children,r],e.keywords),l=yD(),u=ID(e=>e.value&&e.value===c.current),d=ID(e=>s||a.filter()===!1?!0:!e.search||e.filtered.items.get(n)>0);G.useEffect(()=>{let t=r.current;if(!(!t||e.disabled))return t.addEventListener(pD,f),()=>t.removeEventListener(pD,f)},[d,e.onSelect,e.disabled]);function f(){var e,t;p(),(t=(e=o.current).onSelect)==null||t.call(e,c.current)}function p(){l.setState(`value`,c.current,!0)}if(!d)return null;let{disabled:m,value:h,onSelect:g,forceMount:_,keywords:v,...y}=e;return G.createElement(De.div,{ref:I(r,t),...y,id:n,"cmdk-item":``,role:`option`,"aria-disabled":!!m,"aria-selected":!!u,"data-disabled":!!m,"data-selected":!!u,onPointerMove:m||a.getDisablePointerSelection()?void 0:p,onClick:m?void 0:f},e.children)}),CD=G.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:i,...a}=e,o=Ve(),s=G.useRef(null),c=G.useRef(null),l=Ve(),u=_D(),d=ID(e=>i||u.filter()===!1?!0:!e.search||e.filtered.groups.has(o));PD(()=>u.group(o),[]),LD(o,s,[e.value,e.heading,c]);let f=G.useMemo(()=>({id:o,forceMount:i}),[i]);return G.createElement(De.div,{ref:I(s,t),...a,"cmdk-group":``,role:`presentation`,hidden:!d||void 0},n&&G.createElement(`div`,{ref:c,"cmdk-group-heading":``,"aria-hidden":!0,id:l},n),BD(e,e=>G.createElement(`div`,{"cmdk-group-items":``,role:`group`,"aria-labelledby":n?l:void 0},G.createElement(bD.Provider,{value:f},e))))}),wD=G.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,i=G.useRef(null),a=ID(e=>!e.search);return!n&&!a?null:G.createElement(De.div,{ref:I(i,t),...r,"cmdk-separator":``,role:`separator`})}),TD=G.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,i=e.value!=null,a=yD(),o=ID(e=>e.search),s=ID(e=>e.selectedItemId),c=_D();return G.useEffect(()=>{e.value!=null&&a.setState(`search`,e.value)},[e.value]),G.createElement(De.input,{ref:t,...r,"cmdk-input":``,autoComplete:`off`,autoCorrect:`off`,spellCheck:!1,"aria-autocomplete":`list`,role:`combobox`,"aria-expanded":!0,"aria-controls":c.listId,"aria-labelledby":c.labelId,"aria-activedescendant":s,id:c.inputId,type:`text`,value:i?e.value:o,onChange:e=>{i||a.setState(`search`,e.target.value),n?.(e.target.value)}})}),ED=G.forwardRef((e,t)=>{let{children:n,label:r=`Suggestions`,...i}=e,a=G.useRef(null),o=G.useRef(null),s=ID(e=>e.selectedItemId),c=_D();return G.useEffect(()=>{if(o.current&&a.current){let e=o.current,t=a.current,n,r=new ResizeObserver(()=>{n=requestAnimationFrame(()=>{let n=e.offsetHeight;t.style.setProperty(`--cmdk-list-height`,n.toFixed(1)+`px`)})});return r.observe(e),()=>{cancelAnimationFrame(n),r.unobserve(e)}}},[]),G.createElement(De.div,{ref:I(a,t),...i,"cmdk-list":``,role:`listbox`,tabIndex:-1,"aria-activedescendant":s,"aria-label":r,id:c.listId},BD(e,e=>G.createElement(`div`,{ref:I(o,c.listInnerRef),"cmdk-list-sizer":``},e)))}),DD=G.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:i,contentClassName:a,container:o,...s}=e;return G.createElement($e,{open:n,onOpenChange:r},G.createElement(tt,{container:o},G.createElement(et,{"cmdk-overlay":``,className:i}),G.createElement(Qe,{"aria-label":e.label,"cmdk-dialog":``,className:a},G.createElement(xD,{ref:t,...s}))))}),OD=G.forwardRef((e,t)=>ID(e=>e.filtered.count===0)?G.createElement(De.div,{ref:t,...e,"cmdk-empty":``,role:`presentation`}):null),kD=G.forwardRef((e,t)=>{let{progress:n,children:r,label:i=`Loading...`,...a}=e;return G.createElement(De.div,{ref:t,...a,"cmdk-loading":``,role:`progressbar`,"aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":i},BD(e,e=>G.createElement(`div`,{"aria-hidden":!0},e)))}),AD=Object.assign(xD,{List:ED,Item:SD,Input:TD,Group:CD,Separator:wD,Dialog:DD,Empty:OD,Loading:kD});function jD(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function MD(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function ND(e){let t=G.useRef(e);return PD(()=>{t.current=e}),t}var PD=typeof window>`u`?G.useEffect:G.useLayoutEffect;function FD(e){let t=G.useRef();return t.current===void 0&&(t.current=e()),t}function ID(e){let t=yD(),n=()=>e(t.snapshot());return G.useSyncExternalStore(t.subscribe,n,n)}function LD(e,t,n,r=[]){let i=G.useRef(),a=_D();return PD(()=>{var o;let s=(()=>{for(let e of n){if(typeof e==`string`)return e.trim();if(typeof e==`object`&&`current`in e)return e.current?e.current.textContent?.trim():i.current}})(),c=r.map(e=>e.trim());a.value(e,s,c),(o=t.current)==null||o.setAttribute(mD,s),i.current=s}),i}var RD=()=>{let[e,t]=G.useState(),n=FD(()=>new Map);return PD(()=>{n.current.forEach(e=>e()),n.current=new Map},[e]),(e,r)=>{n.current.set(e,r),t({})}};function zD(e){let t=e.type;return typeof t==`function`?t(e.props):`render`in t?t.render(e.props):e}function BD({asChild:e,children:t},n){return e&&G.isValidElement(t)?G.cloneElement(zD(t),{ref:t.ref},n(t.props.children)):n(t)}var VD={position:`absolute`,width:`1px`,height:`1px`,padding:`0`,margin:`-1px`,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,borderWidth:`0`};function HD(e){return e.toLowerCase().match(/[\da-z]+/g)||[]}function UD(e,t){let n=HD(e);if(n.length===0)return!0;let r=Array.isArray(t)?t:[t],i=[];for(let e of r)e&&i.push(...HD(e));return n.every(e=>i.some(t=>t.startsWith(e)))}function WD(e,t,n){return UD(t,e)?1:n&&UD(t,n)?.8:0}var GD=G.forwardRef((e,t)=>{let n=(0,X.c)(9),r,i;n[0]===e?(r=n[1],i=n[2]):({className:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a;n[3]===r?a=n[4]:(a=V(`flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground`,r),n[3]=r,n[4]=a);let o;return n[5]!==i||n[6]!==t||n[7]!==a?(o=(0,K.jsx)(AD,{ref:t,filter:WD,className:a,...i}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});GD.displayName=AD.displayName;var KD=e=>{let t=(0,X.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({children:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=(0,K.jsx)($t,{className:`overflow-hidden p-0 shadow-2xl`,usePortal:!0,children:(0,K.jsx)(GD,{className:`**:[[cmdk-group-heading]]:px-2 **:[[cmdk-group-heading]]:font-medium **:[[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 **:[[cmdk-group]]:px-2 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 **:[[cmdk-input]]:h-12 **:[[cmdk-item]]:px-2 **:[[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5`,children:n})}),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,K.jsx)(Qt,{...r,children:i}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a},qD=G.forwardRef((e,t)=>{let n=(0,X.c)(19),r,i,a,o;n[0]===e?(r=n[1],i=n[2],a=n[3],o=n[4]):({className:r,icon:i,rootClassName:o,...a}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o);let s;n[5]===o?s=n[6]:(s=V(`flex items-center border-b px-3`,o),n[5]=o,n[6]=s);let c;n[7]===i?c=n[8]:(c=i===null?null:(0,K.jsx)(tn,{className:`mr-2 h-4 w-4 shrink-0 opacity-50`}),n[7]=i,n[8]=c);let l;n[9]===r?l=n[10]:(l=V(`placeholder:text-foreground-muted flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-hidden disabled:cursor-not-allowed disabled:opacity-50`,r),n[9]=r,n[10]=l);let u;n[11]!==a||n[12]!==t||n[13]!==l?(u=(0,K.jsx)(AD.Input,{ref:t,className:l,...a}),n[11]=a,n[12]=t,n[13]=l,n[14]=u):u=n[14];let d;return n[15]!==s||n[16]!==c||n[17]!==u?(d=(0,K.jsxs)(`div`,{className:s,"cmdk-input-wrapper":``,children:[c,u]}),n[15]=s,n[16]=c,n[17]=u,n[18]=d):d=n[18],d});qD.displayName=AD.Input.displayName;var JD=G.forwardRef((e,t)=>{let n=(0,X.c)(9),r,i;n[0]===e?(r=n[1],i=n[2]):({className:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a;n[3]===r?a=n[4]:(a=V(`max-h-[300px] overflow-y-auto overflow-x-hidden`,r),n[3]=r,n[4]=a);let o;return n[5]!==i||n[6]!==t||n[7]!==a?(o=(0,K.jsx)(AD.List,{ref:t,className:a,...i}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});JD.displayName=AD.List.displayName;var YD=G.forwardRef((e,t)=>{let n=(0,X.c)(3),r;return n[0]!==e||n[1]!==t?(r=(0,K.jsx)(AD.Empty,{ref:t,className:`py-6 text-center text-sm`,...e}),n[0]=e,n[1]=t,n[2]=r):r=n[2],r});YD.displayName=AD.Empty.displayName;var XD=G.forwardRef((e,t)=>{let n=(0,X.c)(9),r,i;n[0]===e?(r=n[1],i=n[2]):({className:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a;n[3]===r?a=n[4]:(a=V(`overflow-hidden p-1 text-foreground **:[[cmdk-group-heading]]:px-2 **:[[cmdk-group-heading]]:py-1.5 **:[[cmdk-group-heading]]:text-xs **:[[cmdk-group-heading]]:font-medium **:[[cmdk-group-heading]]:text-muted-foreground`,r),n[3]=r,n[4]=a);let o;return n[5]!==i||n[6]!==t||n[7]!==a?(o=(0,K.jsx)(AD.Group,{ref:t,className:a,...i}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});XD.displayName=AD.Group.displayName;var ZD=G.forwardRef((e,t)=>{let n=(0,X.c)(9),r,i;n[0]===e?(r=n[1],i=n[2]):({className:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a;n[3]===r?a=n[4]:(a=qe({className:r}),n[3]=r,n[4]=a);let o;return n[5]!==i||n[6]!==t||n[7]!==a?(o=(0,K.jsx)(AD.Separator,{ref:t,className:a,...i}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});ZD.displayName=AD.Separator.displayName;var QD=G.forwardRef((e,t)=>{let n=(0,X.c)(16),r,i,a,o;n[0]===e?(r=n[1],i=n[2],a=n[3],o=n[4]):({className:r,variant:o,inset:i,...a}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o);let s;n[5]!==r||n[6]!==i||n[7]!==o?(s=V(Ye({variant:o,inset:i}).replace(Xe,`data-[disabled=false]:pointer-events-all data-[disabled=false]:opacity-100 data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50`),r),n[5]=r,n[6]=i,n[7]=o,n[8]=s):s=n[8];let c;n[9]===a.value?c=n[10]:(c=zr.htmlEscape(a.value),n[9]=a.value,n[10]=c);let l;return n[11]!==a||n[12]!==t||n[13]!==s||n[14]!==c?(l=(0,K.jsx)(AD.Item,{ref:t,className:s,...a,value:c}),n[11]=a,n[12]=t,n[13]=s,n[14]=c,n[15]=l):l=n[15],l});QD.displayName=AD.Item.displayName;var $D=Je,eO=Na,tO=Fa,nO=Pe(Ia),rO=Ra,iO=Oe(La),aO=G.forwardRef((e,t)=>{let n=(0,X.c)(22),r,i,a,o,s,c;n[0]===e?(r=n[1],i=n[2],a=n[3],o=n[4],s=n[5],c=n[6]):({className:r,align:a,sideOffset:o,portal:s,scrollable:c,...i}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o,n[5]=s,n[6]=c);let l=a===void 0?`center`:a,u=o===void 0?4:o,d=s===void 0||s,f=c!==void 0&&c,p=f&&`overflow-auto`,m;n[7]!==r||n[8]!==p?(m=V(`z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-hidden animate-in data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,r,p),n[7]=r,n[8]=p,n[9]=m):m=n[9];let h=f?`calc(var(--radix-popover-content-available-height) - ${Re}px)`:void 0,g;n[10]!==i.style||n[11]!==h?(g={...i.style,maxHeight:h},n[10]=i.style,n[11]=h,n[12]=g):g=n[12];let _;n[13]!==l||n[14]!==i||n[15]!==t||n[16]!==u||n[17]!==m||n[18]!==g?(_=(0,K.jsx)(Le,{children:(0,K.jsx)(iO,{ref:t,align:l,sideOffset:u,className:m,style:g,...i})}),n[13]=l,n[14]=i,n[15]=t,n[16]=u,n[17]=m,n[18]=g,n[19]=_):_=n[19];let v=_;if(d){let e;return n[20]===v?e=n[21]:(e=(0,K.jsx)(nO,{children:v}),n[20]=v,n[21]=e),e}return v});aO.displayName=La.displayName;var oO=(0,G.createContext)({isSelected:()=>!1,onSelect:oe.NOOP}),sO=e=>{let t=(0,X.c)(106),n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v,y,b,x,S,C,w,T;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6],c=t[7],l=t[8],u=t[9],d=t[10],f=t[11],p=t[12],m=t[13],h=t[14],g=t[15],_=t[16],v=t[17],y=t[18],b=t[19],x=t[20],S=t[21],C=t[22],w=t[23],T=t[24]):({children:n,displayValue:s,className:i,placeholder:h,value:T,defaultValue:o,onValueChange:p,multiple:y,shouldFilter:b,filterFn:c,open:m,defaultOpen:a,onOpenChange:d,inputPlaceholder:x,search:v,onSearchChange:f,emptyState:S,chips:C,chipsClassName:r,keepPopoverOpenOnSelect:u,id:l,disabled:w,renderValue:g,..._}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s,t[7]=c,t[8]=l,t[9]=u,t[10]=d,t[11]=f,t[12]=p,t[13]=m,t[14]=h,t[15]=g,t[16]=_,t[17]=v,t[18]=y,t[19]=b,t[20]=x,t[21]=S,t[22]=C,t[23]=w,t[24]=T);let E=y!==void 0&&y,D=b===void 0||b,O=x===void 0?`Search...`:x,k=S===void 0?`Nothing found.`:S,A=C!==void 0&&C,j=w!==void 0&&w,ee=a??!1,M;t[25]!==d||t[26]!==m||t[27]!==ee?(M={prop:m,defaultProp:ee,onChange:d},t[25]=d,t[26]=m,t[27]=ee,t[28]=M):M=t[28];let[N,te]=Be(M),ne=N!==void 0&&N,re;t[29]===p?re=t[30]:(re=e=>{p?.(e)},t[29]=p,t[30]=re);let ie;t[31]!==o||t[32]!==re||t[33]!==T?(ie={prop:T,defaultProp:o,onChange:re},t[31]=o,t[32]=re,t[33]=T,t[34]=ie):ie=t[34];let[P,ae]=Be(ie),F;t[35]===P?F=t[36]:(F=e=>Array.isArray(P)?P.includes(e):P===e,t[35]=P,t[36]=F);let oe=F,I;t[37]!==u||t[38]!==E||t[39]!==te||t[40]!==ae||t[41]!==P?(I=e=>{let t=e;if(E){if(Array.isArray(P)){if(P.includes(t)){let n=P.filter(t=>t!==e);t=n.length>0?n:[]}else t=[...P,t]}else t=[t]}else P===e&&(t=null);ae(t),(u??E)||te(!1)},t[37]=u,t[38]=E,t[39]=te,t[40]=ae,t[41]=P,t[42]=I):I=t[42];let se=I,ce;t[43]!==A||t[44]!==s||t[45]!==E||t[46]!==h||t[47]!==P?(ce=()=>E&&A&&h?h:P==null?h??`--`:Array.isArray(P)?P.length===0?h??`--`:P.length===1&&s!==void 0?s(P[0]):`${P.length} selected`:s===void 0?h??`--`:s(P),t[43]=A,t[44]=s,t[45]=E,t[46]=h,t[47]=P,t[48]=ce):ce=t[48];let L=ce,le;t[49]!==se||t[50]!==oe?(le={isSelected:oe,onSelect:se},t[49]=se,t[50]=oe,t[51]=le):le=t[51];let ue=le,de;t[52]===Symbol.for(`react.memo_cache_sentinel`)?(de=V(`relative`),t[52]=de):de=t[52];let R;t[53]!==j||t[54]!==te?(R=e=>{j&&e||te(e)},t[53]=j,t[54]=te,t[55]=R):R=t[55];let z=j&&`cursor-not-allowed opacity-50`,fe;t[56]!==i||t[57]!==z?(fe=V(`flex h-6 w-fit mb-1 shadow-xs-solid items-center justify-between rounded-sm border border-input bg-transparent px-2 text-sm font-prose ring-offset-background placeholder:text-muted-foreground hover:shadow-sm-solid focus-visible:outline-hidden focus-visible:ring-1 focus-visible:ring-ring focus-visible:border-primary focus-visible:shadow-md-solid`,z,i),t[56]=i,t[57]=z,t[58]=fe):fe=t[58];let pe;t[59]!==g||t[60]!==L||t[61]!==P?(pe=g?g(P??null):L(),t[59]=g,t[60]=L,t[61]=P,t[62]=pe):pe=t[62];let me;t[63]===pe?me=t[64]:(me=(0,K.jsx)(`span`,{className:`truncate flex-1 min-w-0`,children:pe}),t[63]=pe,t[64]=me);let he;t[65]===Symbol.for(`react.memo_cache_sentinel`)?(he=(0,K.jsx)(Mt,{className:`ml-3 w-4 h-4 opacity-50 shrink-0`}),t[65]=he):he=t[65];let ge;t[66]!==j||t[67]!==l||t[68]!==ne||t[69]!==fe||t[70]!==me?(ge=(0,K.jsx)(tO,{asChild:!0,children:(0,K.jsxs)(`button`,{id:l,type:`button`,className:fe,"aria-expanded":ne,"aria-disabled":j,children:[me,he]})}),t[66]=j,t[67]=l,t[68]=ne,t[69]=fe,t[70]=me,t[71]=ge):ge=t[71];let B;t[72]!==O||t[73]!==f||t[74]!==v?(B=(0,K.jsx)(qD,{placeholder:O,rootClassName:`px-1 h-8`,autoFocus:!0,value:v,onValueChange:f}),t[72]=O,t[73]=f,t[74]=v,t[75]=B):B=t[75];let _e;t[76]===k?_e=t[77]:(_e=(0,K.jsx)(YD,{children:k}),t[76]=k,t[77]=_e);let ve;t[78]!==n||t[79]!==ue?(ve=(0,K.jsx)(oO,{value:ue,children:n}),t[78]=n,t[79]=ue,t[80]=ve):ve=t[80];let ye;t[81]!==_e||t[82]!==ve?(ye=(0,K.jsxs)(JD,{className:`max-h-60 py-.5`,children:[_e,ve]}),t[81]=_e,t[82]=ve,t[83]=ye):ye=t[83];let be;t[84]!==c||t[85]!==D||t[86]!==B||t[87]!==ye?(be=(0,K.jsx)(aO,{className:`w-full min-w-(--radix-popover-trigger-width) p-0`,align:`start`,children:(0,K.jsxs)(GD,{filter:c,shouldFilter:D,children:[B,ye]})}),t[84]=c,t[85]=D,t[86]=B,t[87]=ye,t[88]=be):be=t[88];let xe;t[89]!==ne||t[90]!==R||t[91]!==ge||t[92]!==be?(xe=(0,K.jsxs)(eO,{open:ne,onOpenChange:R,children:[ge,be]}),t[89]=ne,t[90]=R,t[91]=ge,t[92]=be,t[93]=xe):xe=t[93];let Se;t[94]!==A||t[95]!==r||t[96]!==j||t[97]!==s||t[98]!==se||t[99]!==E||t[100]!==P?(Se=E&&A&&(0,K.jsx)(`div`,{className:V(`flex flex-col gap-1 items-start`,r),children:Array.isArray(P)&&P.map(e=>e==null?null:(0,K.jsxs)($r,{variant:`secondary`,children:[s?.(e)??String(e),(0,K.jsx)(Oo,{onClick:()=>{j||se(e)},className:V(`w-3 h-3 opacity-50 hover:opacity-100 ml-1 cursor-pointer`,j&&`pointer-events-none`)})]},String(e)))}),t[94]=A,t[95]=r,t[96]=j,t[97]=s,t[98]=se,t[99]=E,t[100]=P,t[101]=Se):Se=t[101];let Ce;return t[102]!==_||t[103]!==xe||t[104]!==Se?(Ce=(0,K.jsxs)(`div`,{className:de,..._,children:[xe,Se]}),t[102]=_,t[103]=xe,t[104]=Se,t[105]=Ce):Ce=t[105],Ce},cO=G.forwardRef((e,t)=>{let n=(0,X.c)(20),{children:r,className:i,value:a,onSelect:o,disabled:s}=e,c=typeof a==`object`&&`value`in a?a.value:String(a),l=G.use(oO),u;n[0]!==l||n[1]!==a?(u=l.isSelected(a),n[0]=l,n[1]=a,n[2]=u):u=n[2];let d=u,f;n[3]===i?f=n[4]:(f=V(`pl-6 m-1 py-1`,i),n[3]=i,n[4]=f);let p;n[5]!==l||n[6]!==o||n[7]!==a?(p=()=>{l.onSelect(a),o?.(a)},n[5]=l,n[6]=o,n[7]=a,n[8]=p):p=n[8];let m;n[9]===d?m=n[10]:(m=d&&(0,K.jsx)(jt,{className:`absolute left-1 h-4 w-4`}),n[9]=d,n[10]=m);let h;return n[11]!==r||n[12]!==s||n[13]!==d||n[14]!==t||n[15]!==f||n[16]!==p||n[17]!==m||n[18]!==c?(h=(0,K.jsxs)(QD,{ref:t,className:f,role:`option`,"aria-selected":d,value:c,disabled:s,onSelect:p,children:[m,r]}),n[11]=r,n[12]=s,n[13]=d,n[14]=t,n[15]=f,n[16]=p,n[17]=m,n[18]=c,n[19]=h):h=n[19],h});cO.displayName=`ComboboxItem`;var lO=G.forwardRef((e,t)=>{let n=(0,X.c)(9),r,i;n[0]===e?(r=n[1],i=n[2]):({className:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a;n[3]===r?a=n[4]:(a=V(`grid gap-2`,r),n[3]=r,n[4]=a);let o;return n[5]!==i||n[6]!==t||n[7]!==a?(o=(0,K.jsx)(lo,{className:a,...i,ref:t}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});lO.displayName=lo.displayName;var uO=G.forwardRef((e,t)=>{let n=(0,X.c)(13),r,i,a;n[0]===e?(r=n[1],i=n[2],a=n[3]):({className:i,children:r,...a}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a);let o;n[4]===i?o=n[5]:(o=V(`h-[16px] w-[16px] transition-shadow data-[state=unchecked]:shadow-xs-solid rounded-full border border-input text-primary ring-offset-background focus:outline-hidden focus:shadow-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:border-primary data-[state=checked]:shadow-none`,i),n[4]=i,n[5]=o);let s;n[6]===r?s=n[7]:(s=r??(0,K.jsx)(_o,{className:`flex items-center justify-center`,children:(0,K.jsx)(at,{className:`h-[10px] w-[10px] fill-primary text-current`})}),n[6]=r,n[7]=s);let c;return n[8]!==a||n[9]!==t||n[10]!==o||n[11]!==s?(c=(0,K.jsx)(ho,{ref:t,className:o,...a,children:s}),n[8]=a,n[9]=t,n[10]=o,n[11]=s,n[12]=c):c=n[12],c});uO.displayName=ho.displayName;function dO(e){return e instanceof k}function fO(e){return e instanceof j}function pO(e){return e instanceof T}var mO=yT,hO=()=>{let e=(0,X.c)(4),t=vT().formState.errors;if(Object.keys(t).length===0)return null;let n;e[0]===t?n=e[1]:(n=Object.values(t).map(EO).filter(Boolean),e[0]=t,e[1]=n);let r=n.join(`, `),i;return e[2]===r?i=e[3]:(i=(0,K.jsx)(`div`,{className:`text-destructive p-2 rounded-md bg-red-500/10`,children:r}),e[2]=r,e[3]=i),i},gO=G.createContext({}),_O=e=>{let t=(0,X.c)(10),n;t[0]===e?n=t[1]:({...n}=e,t[0]=e,t[1]=n);let r;t[2]===n.name?r=t[3]:(r={name:n.name},t[2]=n.name,t[3]=r);let i;t[4]===n?i=t[5]:(i=(0,K.jsx)(jT,{...n}),t[4]=n,t[5]=i);let a;return t[6]!==n.name||t[7]!==r||t[8]!==i?(a=(0,K.jsx)(gO,{value:r,children:i},n.name),t[6]=n.name,t[7]=r,t[8]=i,t[9]=a):a=t[9],a},vO=()=>{let e=(0,X.c)(11),t=G.use(gO),n=G.use(yO),{getFieldState:r,formState:i}=vT(),a;e[0]!==t.name||e[1]!==i||e[2]!==r?(a=r(t.name,i),e[0]=t.name,e[1]=i,e[2]=r,e[3]=a):a=e[3];let o=a;if(!t)throw Error(`useFormField should be used within <FormField>`);let{id:s}=n,c=`${s}-form-item`,l=`${s}-form-item-description`,u=`${s}-form-item-message`,d;return e[4]!==t.name||e[5]!==o||e[6]!==s||e[7]!==c||e[8]!==l||e[9]!==u?(d={id:s,name:t.name,formItemId:c,formDescriptionId:l,formMessageId:u,...o},e[4]=t.name,e[5]=o,e[6]=s,e[7]=c,e[8]=l,e[9]=u,e[10]=d):d=e[10],d},yO=G.createContext({}),bO=G.forwardRef((e,t)=>{let n=(0,X.c)(14),r,i;n[0]===e?(r=n[1],i=n[2]):({className:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a=G.useId(),o;n[3]===a?o=n[4]:(o={id:a},n[3]=a,n[4]=o);let s;n[5]===r?s=n[6]:(s=V(`flex flex-col gap-1`,r),n[5]=r,n[6]=s);let c;n[7]!==i||n[8]!==t||n[9]!==s?(c=(0,K.jsx)(`div`,{ref:t,className:s,...i}),n[7]=i,n[8]=t,n[9]=s,n[10]=c):c=n[10];let l;return n[11]!==o||n[12]!==c?(l=(0,K.jsx)(yO,{value:o,children:c}),n[11]=o,n[12]=c,n[13]=l):l=n[13],l});bO.displayName=`FormItem`;var xO=G.forwardRef((e,t)=>{let n=(0,X.c)(11),r,i;n[0]===e?(r=n[1],i=n[2]):({className:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let{error:a,formItemId:o}=vO();if(!i.children)return;let s=a&&`text-destructive`,c;n[3]!==r||n[4]!==s?(c=V(s,r),n[3]=r,n[4]=s,n[5]=c):c=n[5];let l;return n[6]!==o||n[7]!==i||n[8]!==t||n[9]!==c?(l=(0,K.jsx)(ct,{ref:t,className:c,htmlFor:o,...i}),n[6]=o,n[7]=i,n[8]=t,n[9]=c,n[10]=l):l=n[10],l});xO.displayName=`FormLabel`;var SO=G.forwardRef((e,t)=>{let n=(0,X.c)(8),r;n[0]===e?r=n[1]:({...r}=e,n[0]=e,n[1]=r);let{error:i,formItemId:a,formDescriptionId:o,formMessageId:s}=vO(),c=i?`${o} ${s}`:o,l=!!i,u;return n[2]!==a||n[3]!==r||n[4]!==t||n[5]!==c||n[6]!==l?(u=(0,K.jsx)(le,{ref:t,id:a,"aria-describedby":c,"aria-invalid":l,...r}),n[2]=a,n[3]=r,n[4]=t,n[5]=c,n[6]=l,n[7]=u):u=n[7],u});SO.displayName=`FormControl`;var CO=G.forwardRef((e,t)=>{let n=(0,X.c)(10),r,i;n[0]===e?(r=n[1],i=n[2]):({className:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let{formDescriptionId:a}=vO();if(!i.children)return null;let o;n[3]===r?o=n[4]:(o=V(`text-sm text-muted-foreground`,r),n[3]=r,n[4]=o);let s;return n[5]!==a||n[6]!==i||n[7]!==t||n[8]!==o?(s=(0,K.jsx)(`p`,{ref:t,id:a,className:o,...i}),n[5]=a,n[6]=i,n[7]=t,n[8]=o,n[9]=s):s=n[9],s});CO.displayName=`FormDescription`;var wO=G.forwardRef((e,t)=>{let n=(0,X.c)(12),r,i,a;n[0]===e?(r=n[1],i=n[2],a=n[3]):({className:i,children:r,...a}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a);let{error:o,formMessageId:s}=vO(),c=o?.message?String(o?.message):r;if(!c)return null;let l;n[4]===i?l=n[5]:(l=V(`text-xs font-medium text-destructive`,i),n[4]=i,n[5]=l);let u;return n[6]!==c||n[7]!==s||n[8]!==a||n[9]!==t||n[10]!==l?(u=(0,K.jsx)(`p`,{ref:t,id:s,className:l,...a,children:c}),n[6]=c,n[7]=s,n[8]=a,n[9]=t,n[10]=l,n[11]=u):u=n[11],u});wO.displayName=`FormMessage`;var TO=e=>{let t=(0,X.c)(7),{className:n}=e,{error:r}=vO(),i=r?.message?String(r?.message):null;if(!i)return null;let a;t[0]===n?a=t[1]:(a=V(`stroke-[1.8px]`,n),t[0]=n,t[1]=a);let o;t[2]===a?o=t[3]:(o=(0,K.jsx)(Eo,{className:a}),t[2]=a,t[3]=o);let s;return t[4]!==i||t[5]!==o?(s=(0,K.jsx)(vt,{content:i,children:o}),t[4]=i,t[5]=o,t[6]=s):s=t[6],s};TO.displayName=`FormMessageTooltip`;function EO(e){return e?.message}function DO(e){return`unwrap`in e?e.unwrap():e}function OO(e){let t=e=>{if(e instanceof D){let t=[...e.values];return e.values.size===1?t[0]:t}if(e instanceof S){let t=e.def.defaultValue;return typeof t==`function`?t():t}if(fO(e))return t(e.in);if(pO(e))return e.def.items.map(e=>t(e));if(`unwrap`in e)return t(DO(e))};return e instanceof x||e instanceof A?t(e.options[0]):dO(e)?AO(e)?[OO(e.element)]:[]:e instanceof O?``:e instanceof M?e.options[0]:e instanceof C?Object.fromEntries(Object.entries(e.shape).map(([e,n])=>[e,t(n)])):t(e)}function kO(e){if(e instanceof D)return e;if(e instanceof C){let t=e.shape.type;if(t instanceof D)return t;throw Error(`Invalid schema`)}if(e instanceof x||e instanceof A)return kO(e.options[0]);throw L.warn(e),Error(`Invalid schema`)}function AO(e){return!e.safeParse([]).success}var jO=we(V(`inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors hover:bg-muted hover:text-muted-foreground focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50`,`data-[state=on]:bg-muted data-[state=on]:text-muted-foreground`),{variants:{variant:{default:`bg-transparent`,outline:`border border-input bg-transparent hover:bg-muted hover:text-muted-foreground`},size:{default:`h-9 px-3`,xs:`h-4 w-4`,sm:`h-6 px-2`,lg:`h-10 px-5`}},defaultVariants:{variant:`default`,size:`default`}}),MO=G.forwardRef((e,t)=>{let n=(0,X.c)(13),r,i,a,o;n[0]===e?(r=n[1],i=n[2],a=n[3],o=n[4]):({className:r,variant:o,size:a,...i}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o);let s;n[5]!==r||n[6]!==a||n[7]!==o?(s=V(jO({variant:o,size:a,className:r})),n[5]=r,n[6]=a,n[7]=o,n[8]=s):s=n[8];let c;return n[9]!==i||n[10]!==t||n[11]!==s?(c=(0,K.jsx)(xo,{ref:t,className:s,...i}),n[9]=i,n[10]=t,n[11]=s,n[12]=c):c=n[12],c});MO.displayName=xo.displayName;var NO=`
|
|
113
|
-
`,PO=e=>{let t=(0,X.c)(24),{value:n,options:r,onChange:i,className:a,placeholder:o,textAreaClassName:s,comboBoxClassName:c}=e,[l,u]=(0,G.useState)(!1),d;t[0]===n?d=t[1]:(d=IO(n),t[0]=n,t[1]=d);let f=d,p;t[2]!==c||t[3]!==i||t[4]!==r||t[5]!==o||t[6]!==l||t[7]!==s||t[8]!==f?(p=()=>l?(0,K.jsx)(FO,{value:f,className:s,onChange:i,placeholder:o?`${o}: one per line`:`One value per line`}):(0,K.jsx)(sO,{placeholder:o,displayValue:LO,className:V(`w-full max-w-[400px]`,c),multiple:!0,value:f,onValueChange:i,keepPopoverOpenOnSelect:!0,chips:!0,chipsClassName:`flex-row flex-wrap min-w-[210px]`,children:r.map(RO)}),t[2]=c,t[3]=i,t[4]=r,t[5]=o,t[6]=l,t[7]=s,t[8]=f,t[9]=p):p=t[9];let m=p,h;t[10]===a?h=t[11]:(h=V(`flex gap-1`,a),t[10]=a,t[11]=h);let g;t[12]===m?g=t[13]:(g=m(),t[12]=m,t[13]=g);let _=l?`Switch to multi-select`:`Switch to textarea`,v;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,K.jsx)(Ko,{className:`w-3 h-3`}),t[14]=v):v=t[14];let y;t[15]===l?y=t[16]:(y=(0,K.jsx)(MO,{size:`xs`,onPressedChange:u,pressed:l,children:v}),t[15]=l,t[16]=y);let b;t[17]!==_||t[18]!==y?(b=(0,K.jsx)(vt,{content:_,children:y}),t[17]=_,t[18]=y,t[19]=b):b=t[19];let x;return t[20]!==h||t[21]!==g||t[22]!==b?(x=(0,K.jsxs)(`div`,{className:h,children:[g,b]}),t[20]=h,t[21]=g,t[22]=b,t[23]=x):x=t[23],x},FO=e=>{let t=(0,X.c)(11),{className:n,value:r,onChange:i,placeholder:a}=e,o,s;if(t[0]!==r){let e=IO(r);o=Lt,s=e.join(NO),t[0]=r,t[1]=o,t[2]=s}else o=t[1],s=t[2];let c;t[3]===i?c=t[4]:(c=e=>{if(e.target.value===``){i([]);return}i(e.target.value.split(NO))},t[3]=i,t[4]=c);let l=a?`${a}: one per line`:`One value per line`,u;return t[5]!==o||t[6]!==n||t[7]!==s||t[8]!==c||t[9]!==l?(u=(0,K.jsx)(o,{value:s,className:n,rows:4,onChange:c,placeholder:l}),t[5]=o,t[6]=n,t[7]=s,t[8]=c,t[9]=l,t[10]=u):u=t[10],u};function IO(e){return e==null?[]:Array.isArray(e)?e:[e].filter(e=>e!=null||e!==``)}function LO(e){return e}function RO(e){return(0,K.jsx)(cO,{value:e,children:e},e)}var zO=[],BO=e=>{let t=(0,X.c)(9),{schema:n,form:r,path:i,renderers:a,children:o}=e,s=i===void 0?``:i,c=a===void 0?zO:a,l;t[0]!==r||t[1]!==s||t[2]!==c||t[3]!==n?(l=VO({schema:n,form:r,path:s,renderers:c}),t[0]=r,t[1]=s,t[2]=c,t[3]=n,t[4]=l):l=t[4];let u;return t[5]!==o||t[6]!==r||t[7]!==l?(u=(0,K.jsxs)(yT,{...r,children:[o,l]}),t[5]=o,t[6]=r,t[7]=l,t[8]=u):u=t[8],u};function VO({schema:e,form:t,path:n,renderers:r}){for(let i of r){let{isMatch:r,Component:a}=i;if(r(e))return(0,K.jsx)(a,{schema:e,form:t,path:n})}let{label:i,description:a,special:o,direction:s=`column`,minLength:c}=GE.parse(e.description||``);if(e instanceof S){let i=e.unwrap();return i=!i.description&&e.description?i.describe(e.description):i,VO({schema:i,form:t,path:n,renderers:r})}if(e instanceof w){let i=e.unwrap();return i=!i.description&&e.description?i.describe(e.description):i,VO({schema:i,form:t,path:n,renderers:r})}if(e instanceof C)return(0,K.jsxs)(`div`,{className:V(`flex`,s===`row`?`flex-row gap-6 items-start`:s===`two-columns`?`grid grid-cols-2 gap-y-6`:`flex-col gap-6`),children:[(0,K.jsx)(xO,{children:i}),R.entries(e.shape).map(([e,i])=>{let a=i instanceof D,o=VO({schema:i,form:t,path:qO(n,e),renderers:r});return a?(0,K.jsx)(G.Fragment,{children:o},e):(0,K.jsx)(`div`,{className:`flex flex-row align-start`,children:o},e)})]});if(e instanceof O)return o===`time`?(0,K.jsx)(_O,{control:t.control,name:n,render:({field:e})=>(0,K.jsxs)(bO,{children:[(0,K.jsx)(xO,{children:i}),(0,K.jsx)(CO,{children:a}),(0,K.jsx)(SO,{children:(0,K.jsx)(nn,{...e,onValueChange:e.onChange,type:`time`,className:`my-0`})}),(0,K.jsx)(wO,{})]})}):(0,K.jsx)(UO,{schema:e,form:t,path:n});if(e instanceof ee)return(0,K.jsx)(_O,{control:t.control,name:n,render:({field:e})=>(0,K.jsxs)(bO,{children:[(0,K.jsxs)(`div`,{className:V(`flex flex-row gap-2`,a?`items-start`:`items-center`),children:[(0,K.jsx)(SO,{children:(0,K.jsx)(Dw,{"data-testid":`marimo-plugin-data-frames-boolean-checkbox`,checked:e.value,onCheckedChange:e.onChange,className:a?`mt-0.5`:void 0})}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,K.jsx)(xO,{children:i}),(0,K.jsx)(CO,{children:a})]})]}),(0,K.jsx)(wO,{})]})});if(e instanceof te)return o===`random_number_button`?(0,K.jsx)(_O,{control:t.control,name:n,render:({field:e})=>(0,K.jsxs)(bt,{size:`xs`,"data-testid":`marimo-plugin-data-frames-random-number-button`,variant:`secondary`,onClick:()=>{e.onChange(KE())},children:[(0,K.jsx)(Vo,{className:`w-3.5 h-3.5 mr-1`}),i]})}):(0,K.jsx)(_O,{control:t.control,name:n,render:({field:e})=>(0,K.jsxs)(bO,{children:[(0,K.jsx)(xO,{children:i}),(0,K.jsx)(CO,{children:a}),(0,K.jsx)(SO,{children:(0,K.jsx)(en,{...e,className:`my-0`,onValueChange:e.onChange})}),(0,K.jsx)(wO,{})]})});if(e instanceof E){let e=o===`datetime`?`datetime-local`:o===`time`?`time`:`date`;return(0,K.jsx)(_O,{control:t.control,name:n,render:({field:t})=>(0,K.jsxs)(bO,{children:[(0,K.jsx)(xO,{children:i}),(0,K.jsx)(CO,{children:a}),(0,K.jsx)(SO,{children:(0,K.jsx)(nn,{...t,onValueChange:t.onChange,type:e,className:`my-0`})}),(0,K.jsx)(wO,{})]})})}if(e instanceof N)return(0,K.jsx)(UO,{schema:e,form:t,path:n});if(e instanceof M){let r=e.options.map(e=>e.toString());return(0,K.jsx)(GO,{schema:e,form:t,path:n,options:r})}if(e instanceof k){if(o===`text_area_multiline`)return(0,K.jsx)(WO,{schema:e,form:t,path:n});let a=e.element;if(a instanceof M){let r=a.options.map(e=>e.toString());return(0,K.jsx)(KO,{schema:e,form:t,path:n,itemLabel:i,options:r})}return(0,K.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,K.jsx)(ct,{children:i}),(0,K.jsx)(HO,{schema:e.element,form:t,path:n,minLength:c,renderers:r},n)]})}if(e instanceof A){let a=e.def,o=a.options,s=a.discriminator,c=e=>o.find(t=>kO(t).value===e);return(0,K.jsx)(_O,{control:t.control,name:n,render:({field:e})=>{let a=e.value,l=o.map(e=>kO(e).value),u=a&&typeof a==`object`&&s in a?a[s]:l[0],d=c(u);return(0,K.jsxs)(`div`,{className:`flex flex-col`,children:[(0,K.jsx)(xO,{className:`mb-2`,children:i}),(0,K.jsx)(`div`,{className:`flex border-b mb-4`,children:l.map(t=>(0,K.jsx)(`button`,{type:`button`,className:`px-4 py-2 text-sm ${u===t?`border-b-2 border-primary font-medium`:`text-muted-foreground`}`,onClick:()=>{let n=c(t);n?e.onChange(OO(n)):e.onChange({[s]:t})},children:t},t))}),(0,K.jsx)(`div`,{className:`flex flex-col`,children:d&&VO({schema:d,form:t,path:n,renderers:r})},u)]})}})}return e instanceof x?(0,K.jsx)(_O,{control:t.control,name:n,render:({field:a})=>{let o=e.options,s=a.value,c=o.map(e=>kO(e).value);s||=c[0];let l=o.find(e=>kO(e).value===s);return(0,K.jsxs)(`div`,{className:`flex flex-col mb-4 gap-1`,children:[(0,K.jsx)(xO,{children:i}),(0,K.jsx)(ut,{"data-testid":`marimo-plugin-data-frames-union-select`,...a,children:c.map(e=>(0,K.jsx)(`option`,{value:e,children:e},e))}),l&&VO({schema:l,form:t,path:n,renderers:r})]})}}):e instanceof D?(0,K.jsx)(_O,{control:t.control,name:n,render:({field:t})=>(0,K.jsx)(`input`,{...t,type:`hidden`,value:String([...e.values][0]??``)})}):`unwrap`in e?VO({schema:DO(e),form:t,path:n,renderers:r}):fO(e)?VO({schema:e.in,form:t,path:n,renderers:r}):(0,K.jsxs)(`div`,{children:[`Unknown schema type`,` `,e==null?n:JSON.stringify(e.type??e)]})}var HO=e=>{let t=(0,X.c)(39),{schema:n,form:r,path:i,minLength:a,renderers:o}=e,s;t[0]===n.description?s=t[1]:(s=GE.parse(n.description||``),t[0]=n.description,t[1]=s);let{label:c,description:l}=s,u=r.control,d;t[2]!==u||t[3]!==i?(d={control:u,name:i},t[2]=u,t[3]=i,t[4]=d):d=t[4];let{fields:f,append:p,remove:m}=dE(d),h=a!=null&&f.length<a,g=a==null||f.length>a,_;t[5]===c?_=t[6]:(_=(0,K.jsx)(xO,{children:c}),t[5]=c,t[6]=_);let v;t[7]===l?v=t[8]:(v=(0,K.jsx)(CO,{children:l}),t[7]=l,t[8]=v);let y;if(t[9]!==g||t[10]!==f||t[11]!==r||t[12]!==i||t[13]!==m||t[14]!==o||t[15]!==n){let e;t[17]!==g||t[18]!==r||t[19]!==i||t[20]!==m||t[21]!==o||t[22]!==n?(e=(e,t)=>(0,K.jsxs)(`div`,{className:`flex flex-row pl-2 ml-2 border-l-2 border-disabled hover-actions-parent relative pr-5 pt-1 items-center w-fit`,onKeyDown:yt.onEnter(JO),children:[VO({schema:n,form:r,path:`${i}[${t}]`,renderers:o}),g&&(0,K.jsx)(rn,{className:`w-4 h-4 ml-2 my-1 text-muted-foreground hover:text-destructive cursor-pointer absolute right-0 top-5`,onClick:()=>{m(t)}})]},e.id),t[17]=g,t[18]=r,t[19]=i,t[20]=m,t[21]=o,t[22]=n,t[23]=e):e=t[23],y=f.map(e),t[9]=g,t[10]=f,t[11]=r,t[12]=i,t[13]=m,t[14]=o,t[15]=n,t[16]=y}else y=t[16];let b;t[24]!==h||t[25]!==a?(b=h&&(0,K.jsx)(`div`,{className:`text-destructive text-xs font-semibold`,children:(0,K.jsxs)(`div`,{children:[`At least `,a,` required.`]})}),t[24]=h,t[25]=a,t[26]=b):b=t[26];let x;t[27]!==p||t[28]!==n?(x=()=>{p(OO(n))},t[27]=p,t[28]=n,t[29]=x):x=t[29];let S;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,K.jsx)(Zt,{className:`w-3.5 h-3.5 mr-1`}),t[30]=S):S=t[30];let C;t[31]===x?C=t[32]:(C=(0,K.jsx)(`div`,{children:(0,K.jsxs)(bt,{size:`xs`,"data-testid":`marimo-plugin-data-frames-add-array-item`,variant:`text`,className:`hover:text-accent-foreground`,onClick:x,children:[S,`Add`]})}),t[31]=x,t[32]=C);let w;return t[33]!==_||t[34]!==v||t[35]!==y||t[36]!==b||t[37]!==C?(w=(0,K.jsxs)(`div`,{className:`flex flex-col gap-2 min-w-[220px]`,children:[_,v,y,b,C]}),t[33]=_,t[34]=v,t[35]=y,t[36]=b,t[37]=C,t[38]=w):w=t[38],w},UO=e=>{let t=(0,X.c)(21),{schema:n,form:r,path:i}=e,a;t[0]===n.description?a=t[1]:(a=GE.parse(n.description),t[0]=n.description,t[1]=a);let{label:o,description:s,placeholder:c,disabled:l,inputType:u}=a;if(u===`textarea`){let e;t[2]!==s||t[3]!==l||t[4]!==o||t[5]!==c?(e=e=>{let{field:t}=e;return(0,K.jsxs)(bO,{children:[(0,K.jsx)(xO,{children:o}),(0,K.jsx)(CO,{children:s}),(0,K.jsx)(SO,{children:(0,K.jsx)(Lt,{...t,value:t.value,onChange:t.onChange,className:`my-0`,placeholder:c,disabled:l})}),(0,K.jsx)(wO,{})]})},t[2]=s,t[3]=l,t[4]=o,t[5]=c,t[6]=e):e=t[6];let n;return t[7]!==r.control||t[8]!==i||t[9]!==e?(n=(0,K.jsx)(_O,{control:r.control,name:i,render:e}),t[7]=r.control,t[8]=i,t[9]=e,t[10]=n):n=t[10],n}let d;t[11]!==s||t[12]!==l||t[13]!==u||t[14]!==o||t[15]!==c?(d=e=>{let{field:t}=e;return(0,K.jsxs)(bO,{children:[(0,K.jsx)(xO,{children:o}),(0,K.jsx)(CO,{children:s}),(0,K.jsx)(SO,{children:(0,K.jsx)(nn,{...t,type:u,value:t.value,onValueChange:t.onChange,className:`my-0`,placeholder:c,disabled:l})}),(0,K.jsx)(wO,{})]})},t[11]=s,t[12]=l,t[13]=u,t[14]=o,t[15]=c,t[16]=d):d=t[16];let f;return t[17]!==r.control||t[18]!==i||t[19]!==d?(f=(0,K.jsx)(_O,{control:r.control,name:i,render:d}),t[17]=r.control,t[18]=i,t[19]=d,t[20]=f):f=t[20],f},WO=e=>{let t=(0,X.c)(10),{schema:n,form:r,path:i}=e,a;t[0]===n.description?a=t[1]:(a=GE.parse(n.description),t[0]=n.description,t[1]=a);let{label:o,description:s,placeholder:c}=a,l;t[2]!==s||t[3]!==o||t[4]!==c?(l=e=>{let{field:t}=e;return(0,K.jsxs)(bO,{children:[(0,K.jsx)(xO,{children:o}),(0,K.jsx)(CO,{children:s}),(0,K.jsx)(SO,{children:(0,K.jsx)(FO,{...t,placeholder:c})}),(0,K.jsx)(wO,{})]})},t[2]=s,t[3]=o,t[4]=c,t[5]=l):l=t[5];let u;return t[6]!==r.control||t[7]!==i||t[8]!==l?(u=(0,K.jsx)(_O,{control:r.control,name:i,render:l}),t[6]=r.control,t[7]=i,t[8]=l,t[9]=u):u=t[9],u},GO=e=>{let t=(0,X.c)(22),{schema:n,form:r,path:i,options:a,textTransform:o}=e,s;t[0]===n.description?s=t[1]:(s=GE.parse(n.description),t[0]=n.description,t[1]=s);let{label:c,description:l,disabled:u,special:d}=s;if(d===`radio_group`){let e;t[2]!==l||t[3]!==c||t[4]!==a||t[5]!==i?(e=e=>{let{field:t}=e;return(0,K.jsxs)(bO,{children:[(0,K.jsx)(xO,{children:c}),(0,K.jsx)(CO,{children:l}),(0,K.jsx)(SO,{children:(0,K.jsx)(lO,{className:`flex flex-row gap-2 pt-1 items-center`,value:t.value,onValueChange:t.onChange,children:a.map(e=>(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(uO,{value:e,id:`${i}-${e}`},e),(0,K.jsx)(xO,{className:`whitespace-pre`,htmlFor:`${i}-${e}`,children:zr.startCase(e)})]},e))})}),(0,K.jsx)(wO,{})]})},t[2]=l,t[3]=c,t[4]=a,t[5]=i,t[6]=e):e=t[6];let n;return t[7]!==u||t[8]!==r.control||t[9]!==i||t[10]!==e?(n=(0,K.jsx)(_O,{control:r.control,name:i,disabled:u,render:e}),t[7]=u,t[8]=r.control,t[9]=i,t[10]=e,t[11]=n):n=t[11],n}let f;t[12]!==l||t[13]!==c||t[14]!==a||t[15]!==o?(f=e=>{let{field:t}=e;return(0,K.jsxs)(bO,{children:[(0,K.jsx)(xO,{className:`whitespace-pre`,children:c}),(0,K.jsx)(CO,{children:l}),(0,K.jsx)(SO,{children:(0,K.jsxs)(ht,{"data-testid":`marimo-plugin-data-frames-select`,value:t.value,onValueChange:t.onChange,children:[(0,K.jsx)(mt,{className:`min-w-[180px]`,children:(0,K.jsx)(st,{placeholder:`--`})}),(0,K.jsx)(dt,{children:(0,K.jsxs)(pt,{children:[a.map(e=>(0,K.jsx)(lt,{value:e,children:o?.(e)??e},e)),a.length===0&&(0,K.jsx)(lt,{disabled:!0,value:`--`,children:`No options`})]})})]})}),(0,K.jsx)(wO,{})]})},t[12]=l,t[13]=c,t[14]=a,t[15]=o,t[16]=f):f=t[16];let p;return t[17]!==u||t[18]!==r.control||t[19]!==i||t[20]!==f?(p=(0,K.jsx)(_O,{control:r.control,name:i,disabled:u,render:f}),t[17]=u,t[18]=r.control,t[19]=i,t[20]=f,t[21]=p):p=t[21],p},KO=e=>{let t=(0,X.c)(15),{schema:n,form:r,path:i,options:a,itemLabel:o,showSwitchable:s}=e,c;t[0]===n.description?c=t[1]:(c=GE.parse(n.description),t[0]=n.description,t[1]=c);let{label:l,description:u,placeholder:d}=c,f;t[2]!==o||t[3]!==d?(f=d??(o?`Select ${o?.toLowerCase()}`:void 0),t[2]=o,t[3]=d,t[4]=f):f=t[4];let p=f,m;t[5]!==u||t[6]!==l||t[7]!==a||t[8]!==p||t[9]!==s?(m=e=>{let{field:t}=e,n=IO(t.value);return(0,K.jsxs)(bO,{children:[(0,K.jsx)(xO,{className:`whitespace-pre`,children:l}),(0,K.jsx)(CO,{children:u}),(0,K.jsx)(SO,{children:s?(0,K.jsx)(PO,{...t,value:n,options:a,placeholder:p}):(0,K.jsx)(sO,{className:`min-w-[180px]`,placeholder:p,displayValue:YO,multiple:!0,chips:!0,keepPopoverOpenOnSelect:!0,value:n,onValueChange:t.onChange,children:a.map(XO)})}),(0,K.jsx)(wO,{})]})},t[5]=u,t[6]=l,t[7]=a,t[8]=p,t[9]=s,t[10]=m):m=t[10];let h;return t[11]!==r.control||t[12]!==i||t[13]!==m?(h=(0,K.jsx)(_O,{control:r.control,name:i,render:m}),t[11]=r.control,t[12]=i,t[13]=m,t[14]=h):h=t[14],h};function qO(...e){return e.filter(e=>e!==``).join(`.`)}function JO(e){return e.preventDefault()}function YO(e){return zr.startCase(e)}function XO(e){return(0,K.jsx)(cO,{value:e,children:e},e)}function ZO({moduleName:e,variableName:t,onAddImport:n,appStore:r=u}){if(t in r.get(Ah))return!1;let{cellData:i,cellIds:a}=r.get(SM),o=RegExp(`import[ \t]+${e}[ \t]+as[ \t]+${t}`,`g`);for(let e of a.inOrderIds)if(o.test(i[e].code))return!1;return n(`import ${e} as ${t}`),!0}function QO({autoInstantiate:e,createNewCell:t,fromCellId:n,before:r}){let i=Br(),a=null;return ZO({moduleName:`marimo`,variableName:`mo`,onAddImport:o=>{a=Pi.create(),t({cellId:n??`__end__`,before:r??!1,code:o,lastCodeRun:e?o:void 0,newCellId:a,skipIfCodeExists:!0,autoFocus:!1}),e&&i.sendRun({cellIds:[a],codes:[o]})}})?a:null}function $O({autoInstantiate:e,createNewCell:t,fromCellId:n}){let r=Br(),i=null;return ZO({moduleName:`altair`,variableName:`alt`,onAddImport:a=>{i=Pi.create(),t({cellId:n??`__end__`,before:!1,code:a,lastCodeRun:e?a:void 0,newCellId:i,skipIfCodeExists:!0,autoFocus:!1}),e&&r.sendRun({cellIds:[i],codes:[a]})}})?i:null}function ek(){return{focusedCellId:null,lastFocusedCellId:null}}var{reducer:tk,createActions:nk,valueAtom:rk,useActions:ik}=kr(ek,{focusCell:(e,t)=>({...e,focusedCellId:t.cellId,lastFocusedCellId:t.cellId}),toggleCell:(e,t)=>e.focusedCellId===t.cellId?{...e,focusedCellId:null}:{...e,focusedCellId:t.cellId,lastFocusedCellId:t.cellId},blurCell:e=>({...e,focusedCellId:null})}),ak=o(e=>e(rk).lastFocusedCellId);function ok(){return s(ak)}var sk=o(e=>{let t=e(ak);return!t||t===`__scratch__`?null:lk(t,e(SM))});function ck(e){return o(t=>lk(e,t(SM)))}function lk(e,t){let{cellData:n,cellHandles:r,cellRuntime:i}=t,a=n[e],o=i[e],s=r[e]?.current;return!a||!s?null:{cellId:e,name:a.name,config:a.config,status:o?o.status:`idle`,getEditorView:()=>s.editorViewOrNull,hasOutput:o?.output!=null,hasConsoleOutput:o?.consoleOutputs!=null}}function uk(e,t){if(!t)return{recommended:[],other:[...e]};let n;try{n=new RegExp(t,`i`)}catch{return{recommended:[],other:[...e]}}let r=[],i=[];for(let t of e)n.test(t)?r.push(t):i.push(t);return{recommended:r,other:i}}var dk=e=>`Use "${e}"`,fk=e=>{let t=(0,X.c)(96),{value:n,onChange:r,placeholder:i,secretsOnly:a,recommendedKeys:o,otherKeys:s,onCreateSecret:c,className:l,searchPlaceholder:u,formatCustomValueLabel:d,createSecretLabel:f,allowCustomValue:p,allowCreateSecret:m}=e,h=a!==void 0&&a,g=d===void 0?dk:d,_=f===void 0?`Create a new secret`:f,[v,y]=(0,G.useState)(!1),[b,x]=(0,G.useState)(``),S,C,w,T,E,D,O,k,A,j,ee,M,N,te,ne,re,ie,P;if(t[0]!==m||t[1]!==p||t[2]!==l||t[3]!==g||t[4]!==r||t[5]!==v||t[6]!==i||t[7]!==b||t[8]!==u||t[9]!==h||t[10]!==n){P=b.trim();let e=!h&&P.length>0&&P!==n&&(p?.(P)??!0);O=m?.(P)??!0;let a;bb0:{if(!n){a=null;break bb0}if(Kt(n)){let e;t[29]===n?e=t[30]:(e=Gt(n),t[29]=n,t[30]=e),a=e;break bb0}a=n}let o=a,s;t[31]===r?s=t[32]:(s=e=>{r(Bt(e)),y(!1),x(``)},t[31]=r,t[32]=s),D=s;let c;t[33]===r?c=t[34]:(c=e=>{r(e),y(!1),x(``)},t[33]=r,t[34]=c);let d=c,f;t[35]===r?f=t[36]:(f=()=>{r(``),x(``),y(!1)},t[35]=r,t[36]=f),E=f,t[37]===l?ee=t[38]:(ee=V(`flex w-full min-w-48 mb-1 items-center gap-1`,l),t[37]=l,t[38]=ee),T=eO,ie=!0,k=v,t[39]===Symbol.for(`react.memo_cache_sentinel`)?(A=e=>{y(e),e||x(``)},t[39]=A):A=t[39];let _;t[40]===n?_=t[41]:(_=V(`flex h-6 min-w-0 flex-1 shadow-xs-solid items-center justify-between`,`rounded-sm border border-input bg-background px-1.5 text-sm font-code ring-offset-background placeholder:text-muted-foreground`,`hover:shadow-sm-solid focus:outline-hidden focus:ring-1 focus:ring-ring focus:border-primary focus:shadow-md-solid`,Kt(n)&&`bg-accent`),t[40]=n,t[41]=_);let ae;t[42]!==o||t[43]!==i||t[44]!==n?(ae=(0,K.jsx)(`span`,{className:`truncate flex-1 min-w-0 text-left flex items-center gap-1.5`,children:o?(0,K.jsxs)(K.Fragment,{children:[Kt(n)&&(0,K.jsx)(Rt,{className:`h-3 w-3 shrink-0 opacity-70`}),(0,K.jsx)(`span`,{className:`truncate`,children:o})]}):(0,K.jsx)(`span`,{className:`text-muted-foreground`,children:i})}),t[42]=o,t[43]=i,t[44]=n,t[45]=ae):ae=t[45];let F;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,K.jsx)(Mt,{className:`ml-1 h-4 w-4 opacity-50 shrink-0`}),t[46]=F):F=t[46],t[47]!==v||t[48]!==_||t[49]!==ae?(j=(0,K.jsx)(tO,{asChild:!0,children:(0,K.jsxs)(`button`,{type:`button`,className:_,"aria-expanded":v,children:[ae,F]})}),t[47]=v,t[48]=_,t[49]=ae,t[50]=j):j=t[50],w=aO,ne=`w-(--radix-popover-trigger-width) p-0`,re=`start`,C=GD;let oe=u??(h?`Search secrets...`:`Type a value or search secrets...`);t[51]!==b||t[52]!==oe?(te=(0,K.jsx)(qD,{placeholder:oe,rootClassName:`px-1 h-8`,autoFocus:!0,value:b,onValueChange:x}),t[51]=b,t[52]=oe,t[53]=te):te=t[53],S=JD,M=`max-h-60 overscroll-contain`,N=e&&(0,K.jsx)(XD,{children:(0,K.jsx)(QD,{value:`use custom value ${P}`,onSelect:()=>d(P),children:g(P)})}),t[0]=m,t[1]=p,t[2]=l,t[3]=g,t[4]=r,t[5]=v,t[6]=i,t[7]=b,t[8]=u,t[9]=h,t[10]=n,t[11]=S,t[12]=C,t[13]=w,t[14]=T,t[15]=E,t[16]=D,t[17]=O,t[18]=k,t[19]=A,t[20]=j,t[21]=ee,t[22]=M,t[23]=N,t[24]=te,t[25]=ne,t[26]=re,t[27]=ie,t[28]=P}else S=t[11],C=t[12],w=t[13],T=t[14],E=t[15],D=t[16],O=t[17],k=t[18],A=t[19],j=t[20],ee=t[21],M=t[22],N=t[23],te=t[24],ne=t[25],re=t[26],ie=t[27],P=t[28];let ae;t[54]!==_||t[55]!==c||t[56]!==O||t[57]!==P?(ae=O&&(0,K.jsx)(XD,{className:`mt-0`,children:(0,K.jsxs)(QD,{value:`create new secret ${P}`,onSelect:()=>{let e=P||void 0;y(!1),x(``),c(e)},children:[(0,K.jsx)(Do,{className:`mr-2 h-3.5 w-3.5`}),_]})}),t[54]=_,t[55]=c,t[56]=O,t[57]=P,t[58]=ae):ae=t[58];let F;t[59]!==o||t[60]!==D?(F=o.length>0&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(ZD,{className:`mt-0`}),(0,K.jsx)(XD,{heading:`Recommended`,children:o.map(e=>(0,K.jsxs)(QD,{value:e,onSelect:()=>D(e),children:[(0,K.jsx)(Rt,{className:`mr-2 h-3 w-3 opacity-70`}),e]},e))})]}),t[59]=o,t[60]=D,t[61]=F):F=t[61];let oe;t[62]!==s||t[63]!==o.length||t[64]!==D?(oe=s.length>0&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(ZD,{className:`mt-0`}),(0,K.jsx)(XD,{heading:o.length>0?`Other`:void 0,children:s.map(e=>(0,K.jsxs)(QD,{value:e,onSelect:()=>D(e),children:[(0,K.jsx)(Rt,{className:`mr-2 h-3 w-3 opacity-70`}),e]},e))})]}),t[62]=s,t[63]=o.length,t[64]=D,t[65]=oe):oe=t[65];let I;t[66]!==S||t[67]!==ae||t[68]!==F||t[69]!==oe||t[70]!==M||t[71]!==N?(I=(0,K.jsxs)(S,{className:M,children:[N,ae,F,oe]}),t[66]=S,t[67]=ae,t[68]=F,t[69]=oe,t[70]=M,t[71]=N,t[72]=I):I=t[72];let se;t[73]!==C||t[74]!==I||t[75]!==te?(se=(0,K.jsxs)(C,{children:[te,I]}),t[73]=C,t[74]=I,t[75]=te,t[76]=se):se=t[76];let ce;t[77]!==w||t[78]!==se||t[79]!==ne||t[80]!==re?(ce=(0,K.jsx)(w,{className:ne,align:re,children:se}),t[77]=w,t[78]=se,t[79]=ne,t[80]=re,t[81]=ce):ce=t[81];let L;t[82]!==T||t[83]!==k||t[84]!==A||t[85]!==j||t[86]!==ce||t[87]!==ie?(L=(0,K.jsxs)(T,{modal:ie,open:k,onOpenChange:A,children:[j,ce]}),t[82]=T,t[83]=k,t[84]=A,t[85]=j,t[86]=ce,t[87]=ie,t[88]=L):L=t[88];let le;t[89]!==E||t[90]!==n?(le=n&&(0,K.jsx)(`button`,{type:`button`,"aria-label":`Clear`,className:V(`flex h-6 w-6 shrink-0 items-center justify-center rounded-sm`,`text-muted-foreground hover:bg-muted hover:text-foreground`,`focus:outline-hidden focus:ring-1 focus:ring-ring`),onClick:E,children:(0,K.jsx)(Nt,{className:`h-3.5 w-3.5`})}),t[89]=E,t[90]=n,t[91]=le):le=t[91];let ue;return t[92]!==ee||t[93]!==L||t[94]!==le?(ue=(0,K.jsxs)(`div`,{className:ee,children:[L,le]}),t[92]=ee,t[93]=L,t[94]=le,t[95]=ue):ue=t[95],ue},pk=(0,G.createContext)({providerNames:[],secretKeys:[],loading:!1,error:void 0,refreshSecrets:oe.NOOP}),mk=()=>(0,G.use)(pk),hk=e=>{let t=(0,X.c)(14),{children:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=[],t[0]=r):r=t[0];let{data:i,isPending:a,error:o,refetch:s}=ui(xk,r);i?.secretKeys,i?.providerNames;let c;t[1]===i?.secretKeys?c=t[2]:(c=i?.secretKeys||[],t[1]=i?.secretKeys,t[2]=c);let l;t[3]===i?.providerNames?l=t[4]:(l=i?.providerNames||[],t[3]=i?.providerNames,t[4]=l);let u;t[5]!==o||t[6]!==a||t[7]!==s||t[8]!==c||t[9]!==l?(u={secretKeys:c,providerNames:l,loading:a,error:o,refreshSecrets:s},t[5]=o,t[6]=a,t[7]=s,t[8]=c,t[9]=l,t[10]=u):u=t[10];let d=u,f;return t[11]!==n||t[12]!==d?(f=(0,K.jsx)(pk,{value:d,children:n}),t[11]=n,t[12]=d,t[13]=f):f=t[13],f},gk={isMatch:e=>{if(e instanceof O){let{optionRegex:t}=GE.parse(e.description||``);return!!t}return!1},Component:({schema:e,form:t,path:n})=>{let{secretKeys:r,providerNames:i,refreshSecrets:a}=mk(),{openModal:o,closeModal:s}=zt(),{label:c,description:l,placeholder:u,optionRegex:d=``,inputType:f}=GE.parse(e.description||``),p=f===`password`,{recommended:m,other:h}=uk(r,d);return(0,K.jsx)(_O,{control:t.control,name:n,render:({field:e})=>(0,K.jsxs)(bO,{children:[(0,K.jsx)(xO,{children:c}),(0,K.jsx)(CO,{children:l}),(0,K.jsx)(SO,{children:(0,K.jsx)(fk,{value:e.value?String(e.value):``,onChange:e.onChange,placeholder:u,secretsOnly:p,recommendedKeys:m,otherKeys:h,onCreateSecret:t=>{o((0,K.jsx)(qt,{providerNames:i,initialValue:t,onSuccess:t=>{a(),e.onChange(Bt(t)),s()},onClose:s}))}})}),(0,K.jsx)(wO,{})]})})}},_k={isMatch:e=>{if(e instanceof O){let{special:t}=GE.parse(e.description||``);return t===`secret_textarea`}return!1},Component:({schema:e,form:t,path:n})=>{let{secretKeys:r,providerNames:i,refreshSecrets:a}=mk(),{openModal:o,closeModal:s}=zt(),{label:c,description:l,placeholder:u}=GE.parse(e.description||``);return(0,K.jsx)(_O,{control:t.control,name:n,render:({field:e})=>{let t=e.value?String(e.value):``,n=Jt(t)?Ht(t):t;return(0,K.jsxs)(bO,{children:[(0,K.jsxs)(xO,{className:`flex items-center gap-1`,children:[c,(0,K.jsx)(vt,{content:`Enter a path to a file on disk, or create a secret to paste JSON directly.`,delayDuration:300,children:(0,K.jsx)(`button`,{type:`button`,className:`inline-flex`,"aria-label":`Credential input help`,children:(0,K.jsx)(Po,{className:`h-3.5 w-3.5`})})})]}),(0,K.jsx)(CO,{children:l}),(0,K.jsx)(SO,{children:(0,K.jsx)(fk,{value:n,onChange:t=>{e.onChange(!t||Kt(t)||Jt(t)?t:Vt(t))},placeholder:u,searchPlaceholder:`Type a file path or paste JSON`,formatCustomValueLabel:e=>`Use "${e}" as a file path`,createSecretLabel:`Paste JSON credentials`,allowCustomValue:e=>!Ut(e),allowCreateSecret:e=>!e||Ut(e),recommendedKeys:[],otherKeys:r,onCreateSecret:t=>{o((0,K.jsx)(qt,{providerNames:i,initialValue:t,multiline:!0,onSuccess:t=>{a(),e.onChange(Bt(t)),s()},onClose:s}))}})}),(0,K.jsx)(wO,{})]})}})}};function vk(e){return e.provider!==`env`}function yk(e){return e.name}function bk(e){return e.keys}async function xk(){let e=await Yt.request({}),t=Wt(e.secrets).filter(vk).map(yk);return{secretKeys:e.secrets.flatMap(bk).toSorted(),providerNames:t}}var Sk=[gk,_k],Ck=e=>{let t=(0,X.c)(2),{children:n}=e,r;return t[0]===n?r=t[1]:(r=(0,K.jsx)(`div`,{className:`grid grid-cols-2 md:grid-cols-3 gap-4`,children:n}),t[0]=n,t[1]=r),r},wk=e=>{let t=(0,X.c)(9),{name:n,color:r,icon:i,onSelect:a}=e,o;t[0]===r?o=t[1]:(o={backgroundColor:r},t[0]=r,t[1]=o);let s;t[2]===n?s=t[3]:(s=(0,K.jsx)(`span`,{className:`text-white font-medium text-lg`,children:n}),t[2]=n,t[3]=s);let c;return t[4]!==i||t[5]!==a||t[6]!==o||t[7]!==s?(c=(0,K.jsxs)(`button`,{type:`button`,className:`py-3 flex flex-col items-center justify-center gap-1 transition-[scale,filter,box-shadow] hover:scale-105 hover:brightness-110 rounded shadow-sm-solid hover:shadow-md-solid`,style:o,onClick:a,children:[i,s]}),t[4]=i,t[5]=a,t[6]=o,t[7]=s,t[8]=c):c=t[8],c},Tk=e=>{let t=(0,X.c)(25),{onBack:n,isValid:r,libraries:i,preferredLibrary:a,onLibraryChange:o,displayNames:s,libraryLabel:c}=e,l=c===void 0?`Preferred library`:c,u;t[0]===n?u=t[1]:(u=(0,K.jsx)(bt,{type:`button`,variant:`outline`,onClick:n,children:`Back`}),t[0]=n,t[1]=u);let d=!r,f;t[2]===d?f=t[3]:(f=(0,K.jsx)(bt,{type:`submit`,disabled:d,children:`Add`}),t[2]=d,t[3]=f);let p;t[4]!==u||t[5]!==f?(p=(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[u,f]}),t[4]=u,t[5]=f,t[6]=p):p=t[6];let m;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,K.jsx)(mt,{children:(0,K.jsx)(st,{placeholder:`Select a library`})}),t[7]=m):m=t[7];let h;t[8]===l?h=t[9]:(h=(0,K.jsxs)(`div`,{className:`flex flex-col gap-1 items-end`,children:[m,(0,K.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:l})]}),t[8]=l,t[9]=h);let g;if(t[10]!==s||t[11]!==i){let e;t[13]===s?e=t[14]:(e=e=>(0,K.jsx)(lt,{value:e,children:s[e]??e},e),t[13]=s,t[14]=e),g=i.map(e),t[10]=s,t[11]=i,t[12]=g}else g=t[12];let _;t[15]===g?_=t[16]:(_=(0,K.jsx)(dt,{children:(0,K.jsx)(pt,{children:g})}),t[15]=g,t[16]=_);let v;t[17]!==o||t[18]!==a||t[19]!==h||t[20]!==_?(v=(0,K.jsx)(`div`,{children:(0,K.jsxs)(ht,{value:a,onValueChange:o,children:[h,_]})}),t[17]=o,t[18]=a,t[19]=h,t[20]=_,t[21]=v):v=t[21];let y;return t[22]!==v||t[23]!==p?(y=(0,K.jsxs)(`div`,{className:`flex gap-2 justify-between`,children:[p,v]}),t[22]=v,t[23]=p,t[24]=y):y=t[24],y};function Ek(){let e=(0,X.c)(4),{createNewCell:t}=gN(),n=ok(),r=s(F),i;return e[0]!==r||e[1]!==t||e[2]!==n?(i=e=>{/\bmo\./.test(e)&&QO({autoInstantiate:r,createNewCell:t,fromCellId:n}),t({code:e,before:!1,cellId:n??`__end__`,skipIfCodeExists:!0})},e[0]=r,e[1]=t,e[2]=n,e[3]=i):i=e[3],i}function Dk(e){let t=(0,X.c)(3),n=Ek(),r;return t[0]!==n||t[1]!==e?(r=t=>{n(t.code),e?.()},t[0]=n,t[1]=e,t[2]=r):r=t[2],r}var Ok=e=>{let t=(0,X.c)(30),{schema:n,libraries:r,preferredLibrary:i,displayNames:a,libraryLabel:o,generateCode:s,onSubmit:c,onBack:l}=e,u;t[0]===n?u=t[1]:(u=OO(n),t[0]=n,t[1]=u);let d=u,f;t[2]===n?f=t[3]:(f=WE(n),t[2]=n,t[3]=f);let p;t[4]!==d||t[5]!==f?(p={defaultValues:d,resolver:f,reValidateMode:`onChange`},t[4]=d,t[5]=f,t[6]=p):p=t[6];let m=PE(p),[h,g]=G.useState(i),_=Ek(),v;t[7]!==s||t[8]!==_||t[9]!==c||t[10]!==h?(v=e=>{_(s(e,h)),c()},t[7]=s,t[8]=_,t[9]=c,t[10]=h,t[11]=v):v=t[11];let y=v,b;t[12]!==m||t[13]!==y?(b=m.handleSubmit(y),t[12]=m,t[13]=y,t[14]=b):b=t[14];let x;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,K.jsx)(hO,{}),t[15]=x):x=t[15];let S;t[16]!==m||t[17]!==n?(S=(0,K.jsx)(hk,{children:(0,K.jsx)(BO,{schema:n,form:m,renderers:Sk,children:x})}),t[16]=m,t[17]=n,t[18]=S):S=t[18];let C;t[19]!==a||t[20]!==m.formState.isValid||t[21]!==r||t[22]!==o||t[23]!==l||t[24]!==h?(C=(0,K.jsx)(Tk,{onBack:l,isValid:m.formState.isValid,libraries:r,preferredLibrary:h,onLibraryChange:g,displayNames:a,libraryLabel:o}),t[19]=a,t[20]=m.formState.isValid,t[21]=r,t[22]=o,t[23]=l,t[24]=h,t[25]=C):C=t[25];let w;return t[26]!==b||t[27]!==S||t[28]!==C?(w=(0,K.jsxs)(`form`,{onSubmit:b,className:`space-y-4`,children:[S,C]}),t[26]=b,t[27]=S,t[28]=C,t[29]=w):w=t[29],w};function kk(e,t){return!t||e.category===`object-storage`==(t===`storage`)}function Ak(e,t){let n=e.hidesWhen;return n.kind===`dialect`?n.substrings.some(e=>t.dialects.some(t=>t.includes(e))):n.protocols.some(e=>t.storageProtocols.has(e))?!0:n.backendTypes.some(e=>t.storageBackendTypes.has(e))}var jk=o(0),Mk,Nk=0;function Pk(){let e=u.get(jk);return(!Mk||Nk!==e)&&(Nk=e,Mk=B().then(()=>FC.request({})).then(e=>e.sources).catch(t=>{throw Nk===e&&(Mk=void 0),t})),Mk}function Fk(){Mk=void 0,u.set(jk,e=>e+1)}var Ik=new Xt(`storage-list-entries`,async(e,t)=>{await Br().listStorageEntries({requestId:e,...t})}),Lk=new Xt(`storage-download`,async(e,t)=>{await Br().downloadStorage({requestId:e,...t})});function Rk(e,t){return`${e}::${t??``}`}function zk(e){return`${e}::`}function Bk(){return{namespaces:[],entriesByPath:new Map,pageMetadataByPath:new Map}}var{reducer:Vk,createActions:Hk,valueAtom:Uk,useActions:Wk}=kr(Bk,{setNamespaces:(e,t)=>{let n=new Map(e.namespaces.map(e=>[e.name,e]));for(let e of t.namespaces)n.set(e.name,e);return{...e,namespaces:[...n.values()]}},setEntries:(e,t)=>{let n=Rk(t.namespace,t.prefix),r=new Map(e.entriesByPath),i=t.append&&r.has(n)?[...r.get(n)??[],...t.entries]:t.entries;r.set(n,i);let a=new Map(e.pageMetadataByPath);return a.set(n,{nextPageToken:t.nextPageToken??null}),{...e,entriesByPath:r,pageMetadataByPath:a}},clearNamespaceCache:(e,t)=>{let n=new Map(e.entriesByPath),r=new Map(e.pageMetadataByPath),i=zk(t);for(let e of n.keys())e.startsWith(i)&&n.delete(e);for(let e of r.keys())e.startsWith(i)&&r.delete(e);return{...e,entriesByPath:n,pageMetadataByPath:r}},filterFromVariables:(e,t)=>{let n=new Set(t),r=e.namespaces.filter(e=>n.has(e.name));return{...e,namespaces:r}}}),Gk=()=>s(Uk),Kk=o(e=>e(Uk).namespaces);function qk(){return Wk()}async function Jk({namespace:e,prefix:t,pageToken:n,append:r,setEntries:i}){let a=await Ik.request({namespace:e,prefix:t??``,limit:150,...n==null?{}:{pageToken:n}});if(a.error)throw Error(a.error);return i({namespace:e,prefix:t,entries:a.entries,nextPageToken:a.next_page_token,append:r}),a}function Yk(e,t){let{entriesByPath:n,pageMetadataByPath:r}=Gk(),{setEntries:i}=qk(),a=Rk(e,t),o=n.get(a),s=r.get(a)?.nextPageToken??null,c=(0,G.useRef)(!1),[l,u]=(0,G.useState)(!1),[d,f]=(0,G.useState)(),{isPending:p,error:m,refetch:h}=ui(async()=>{o||await Jk({namespace:e,prefix:t,setEntries:i})},[e,t,o===void 0]),g=(0,G.useCallback)(async()=>{if(!(s==null||c.current)){c.current=!0,u(!0),f(void 0);try{await Jk({namespace:e,prefix:t,pageToken:s,append:!0,setEntries:i})}catch(e){f(e instanceof Error?e:Error(String(e)))}finally{c.current=!1,u(!1)}}},[e,t,s,i]);return{entries:o??[],isPending:p&&!o,error:o?void 0:m,hasMore:s!==null,loadMore:g,isLoadingMore:l,loadMoreError:d,refetch:h}}function Xk(){let e=(0,X.c)(2),{setEntries:t}=qk(),n;return e[0]===t?n=e[1]:(n=e=>Jk({...e,setEntries:t}),e[0]=t,e[1]=n),n}function Zk(){let e=(0,X.c)(2),t=s(jk),n;return e[0]===t?n=e[1]:(n=[t],e[0]=t,e[1]=n),ui(Pk,n)}function Qk(e){let t=(0,X.c)(6),{data:n}=Zk(),r=s(_p),i=s(Kk),a;bb0:{if(!n){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[0]=e):e=t[0],a=e;break bb0}let o;if(t[1]!==r||t[2]!==n||t[3]!==e||t[4]!==i){let a={dialects:[...r.values()].map(tA),storageProtocols:new Set(i.map(eA)),storageBackendTypes:new Set(i.map($k))};o=n.filter(t=>kk(t,e)&&!Ak(t,a)),t[1]=r,t[2]=n,t[3]=e,t[4]=i,t[5]=o}else o=t[5];a=o}return a}function $k(e){return e.backendType.toLowerCase()}function eA(e){return e.protocol.toLowerCase()}function tA(e){return e.dialect.toLowerCase()}function nA(){let e=(0,X.c)(1),[,t]=(0,G.useState)(0),n;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=()=>{t(rA)},e[0]=n):n=e[0],n}function rA(e){return e+1}var iA=e=>{let t=(0,X.c)(6),n=Qk(`database`);if(n.length===0){let r;return t[0]!==n||t[1]!==e?(r=(0,K.jsx)(oA,{...e,detectedDataSources:n}),t[0]=n,t[1]=e,t[2]=r):r=t[2],r}let r;return t[3]!==n||t[4]!==e?(r=(0,K.jsx)(aA,{...e,detectedDataSources:n}),t[3]=n,t[4]=e,t[5]=r):r=t[5],r},aA=e=>{let t=(0,X.c)(7),n,r;t[0]===e?(n=t[1],r=t[2]):({detectedDataSources:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i=Dk(),a;return t[3]!==i||t[4]!==n||t[5]!==r?(a=(0,K.jsx)(oA,{...r,detectedDataSources:n,addDetectedDataSource:i}),t[3]=i,t[4]=n,t[5]=r,t[6]=a):a=t[6],a},oA=e=>{let t=(0,X.c)(42),{selectedEngine:n,onChange:r,cellId:i,detectedDataSources:a,addDetectedDataSource:o}=e,c=s(_p),l=[],u=[];for(let[e,t]of c.entries())Vf.has(e)?l.push(t):u.push(t);let d=nA(),f;t[0]!==c||t[1]!==n?(f=n&&!c.has(n),t[0]=c,t[1]=n,t[2]=f):f=t[2];let p=f,m;t[3]!==o||t[4]!==c||t[5]!==a||t[6]!==r||t[7]!==d?(m=e=>{if(e===sA){window.open(lA,`_blank`);return}if(e.startsWith(cA)){let t=e.slice(cA.length),n=a.find(e=>e.id===t);n&&o&&o(n);return}let t=c.get(e);t&&(d(),r(t.name),yp(t.name))},t[3]=o,t[4]=c,t[5]=a,t[6]=r,t[7]=d,t[8]=m):m=t[8];let h=m,g=mA,_=ht,v;t[9]===i?v=t[10]:(v=zw(i),t[9]=i,t[10]=v);let y;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,K.jsx)(st,{placeholder:`Select an engine`}),t[11]=y):y=t[11];let b;t[12]===v?b=t[13]:(b=(0,K.jsx)(dA,{...v,children:y}),t[12]=v,t[13]=b);let x=dt,S;t[14]===i?S=t[15]:(S=zw(i),t[14]=i,t[15]=S);let C=pt,w;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,K.jsx)(ot,{children:`Database connections`}),t[16]=w):w=t[16];let T;t[17]!==p||t[18]!==n?(T=p&&(0,K.jsx)(lt,{value:n,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-1 opacity-50`,children:[(0,K.jsx)(Eo,{className:`h-3 w-3`}),(0,K.jsx)(`span`,{className:`truncate`,children:wp(n)})]})},n),t[17]=p,t[18]=n,t[19]=T):T=t[19];let E=g(u),D=u.length>0&&(0,K.jsx)(ft,{}),O=g(l),k;t[20]===a?k=t[21]:(k=a.length>0&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(ft,{}),(0,K.jsx)(ot,{children:`Detected in your environment`}),a.map(hA)]}),t[20]=a,t[21]=k);let A;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,K.jsx)(ft,{}),t[22]=A):A=t[22];let j;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(j=(0,K.jsx)(lt,{className:`text-muted-foreground`,value:sA,children:(0,K.jsxs)(`a`,{className:`flex items-center gap-1`,href:lA,target:`_blank`,rel:`noreferrer`,children:[(0,K.jsx)(Pt,{className:`h-3 w-3`}),(0,K.jsx)(`span`,{children:`How to add a database connection`})]})}),t[23]=j):j=t[23];let ee;t[24]!==C||t[25]!==E||t[26]!==D||t[27]!==O||t[28]!==k||t[29]!==w||t[30]!==T?(ee=(0,K.jsxs)(C,{children:[w,T,E,D,O,k,A,j]}),t[24]=C,t[25]=E,t[26]=D,t[27]=O,t[28]=k,t[29]=w,t[30]=T,t[31]=ee):ee=t[31];let M;t[32]!==x||t[33]!==ee||t[34]!==S?(M=(0,K.jsx)(x,{...S,children:ee}),t[32]=x,t[33]=ee,t[34]=S,t[35]=M):M=t[35];let N;return t[36]!==_||t[37]!==h||t[38]!==n||t[39]!==M||t[40]!==b?(N=(0,K.jsx)(`div`,{className:`flex flex-row gap-1 items-center`,children:(0,K.jsxs)(_,{value:n,onValueChange:h,children:[b,M]})}),t[36]=_,t[37]=h,t[38]=n,t[39]=M,t[40]=b,t[41]=N):N=t[41],N},sA=`__help__`,cA=`__detected_source__:`,lA=`http://docs.marimo.io/guides/working_with_data/sql/#connecting-to-a-custom-database`,uA=()=>{let e=(0,X.c)(16),{sqlMode:t,setSQLMode:n}=QC(),r;e[0]!==n||e[1]!==t?(r=()=>{let e=t===`validate`?`default`:`validate`;e==="default"&&UC(),n(e)},e[0]=n,e[1]=t,e[2]=r):r=e[2];let i=r,a=gA,o=_A,s;e[3]===t?s=e[4]:(s=o(t),e[3]=t,e[4]=s);let c;e[5]===t?c=e[6]:(c=a(t),e[5]=t,e[6]=c);let l=t===`validate`?`Validate`:`Default`,u;e[7]===l?u=e[8]:(u=(0,K.jsx)(`span`,{className:`ml-1`,children:l}),e[7]=l,e[8]=u);let d;e[9]!==i||e[10]!==c||e[11]!==u?(d=(0,K.jsxs)(bt,{variant:`ghost`,size:`sm`,onClick:i,className:`h-5 px-1.5 text-xs border-border shadow-none hover:bg-accent`,children:[c,u]}),e[9]=i,e[10]=c,e[11]=u,e[12]=d):d=e[12];let f;return e[13]!==s||e[14]!==d?(f=(0,K.jsx)(`div`,{className:`flex flex-row gap-1 items-center`,children:(0,K.jsx)(vt,{delayDuration:300,content:s,children:d})}),e[13]=s,e[14]=d,e[15]=f):f=e[15],f},dA=e=>{let t=(0,X.c)(6),n,r;t[0]===e?(n=t[1],r=t[2]):({children:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;return t[3]!==n||t[4]!==r?(i=(0,K.jsx)(mt,{className:`text-xs border-border shadow-none! ring-0! h-5 px-1.5 hover:bg-accent transition-colors`,...r,children:n}),t[3]=n,t[4]=r,t[5]=i):i=t[5],i};function fA(e){return e.source!==`iceberg`}function pA(e){return(0,K.jsx)(lt,{value:e.name,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(Xw,{className:`h-3 w-3`,name:e.dialect}),(0,K.jsx)(`span`,{className:`truncate ml-0.5`,children:wp(e.display_name)})]})},e.name)}function mA(e){return e=e.filter(fA),e.map(pA)}function hA(e){return(0,K.jsx)(lt,{value:`${cA}${e.id}`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(Wo,{className:`h-3 w-3 text-(--blue-9)`}),(0,K.jsxs)(`span`,{className:`truncate ml-0.5`,children:[`Add `,e.displayName,` connection`]})]})},e.id)}function gA(e){return e===`validate`?(0,K.jsx)(Uo,{className:`h-3 w-3`}):(0,K.jsx)(It,{className:`h-3 w-3`})}function _A(e){return e===`validate`?(0,K.jsxs)(`div`,{className:`text-xs`,children:[(0,K.jsxs)(`div`,{className:`font-semibold mb-1 flex flex-row items-center gap-1`,children:[(0,K.jsx)(Uo,{className:`h-3 w-3`}),`Validate Mode`]}),(0,K.jsx)(`p`,{children:`Queries are validated as you write them`})]}):(0,K.jsxs)(`div`,{className:`text-xs`,children:[(0,K.jsxs)(`div`,{className:`font-semibold mb-1 flex flex-row items-center gap-1`,children:[(0,K.jsx)(It,{className:`h-3 w-3`}),`Default Mode`]}),(0,K.jsx)(`p`,{children:`Standard editing`})]})}var vA=()=>{let e=(0,X.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,K.jsx)(`div`,{className:`h-4 border-r border-border`}),e[0]=t):t=e[0],t},yA=e=>{let t=(0,X.c)(102),{view:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r={minWidth:50},t[0]=r):r=t[0];let{spanProps:i,inputProps:a}=Nw(r),o;t[1]===n.state?o=t[2]:(o=n.state.field(SA),t[1]=n.state,t[2]=o);let s=o,c;t[3]===n.state?c=t[4]:(c=n.state.facet(Af),t[3]=n.state,t[4]=c);let l=c,u;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,K.jsx)(`div`,{}),t[5]=u):u=t[5];let d=u,f=!1,p;t[6]===n?p=t[7]:(p=e=>{n.dispatch({effects:Ay.of(e),changes:{from:0,to:n.state.doc.length,insert:n.state.doc.toString()}})},t[6]=n,t[7]=p);let m=p;if(s instanceof iw){let e;t[8]===n.state?e=t[9]:(e=n.state.field(jy),t[8]=n.state,t[9]=e);let r=e;f=!0;let o;t[10]===m?o=t[11]:(o=e=>{let t=kw(e.currentTarget.value,!1);e.currentTarget.value=t,m({dataframeName:t})},t[10]=m,t[11]=o);let s=o,c;t[12]!==m||t[13]!==n?(c=e=>{m({engine:e}),fw(n,e)},t[12]=m,t[13]=n,t[14]=c):c=t[14];let u=c,p;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,K.jsx)(`span`,{className:`select-none`,children:`Output variable: `}),t[15]=p):p=t[15];let h;t[16]===a?h=t[17]:(h=e=>{a.onChange?.(e)},t[16]=a,t[17]=h);let g;t[18]===s?g=t[19]:(g=e=>{e.key===`Enter`&&e.shiftKey&&s(e)},t[18]=s,t[19]=g);let _;t[20]!==a||t[21]!==r.dataframeName||t[22]!==s||t[23]!==h||t[24]!==g?(_=(0,K.jsx)(`input`,{...a,defaultValue:r.dataframeName,onChange:h,onBlur:s,onKeyDown:g,className:`min-w-14 w-auto border border-border rounded px-1 focus-visible:outline-hidden focus-visible:ring-1 focus-visible:ring-ring`}),t[20]=a,t[21]=r.dataframeName,t[22]=s,t[23]=h,t[24]=g,t[25]=_):_=t[25];let v;t[26]===i?v=t[27]:(v=(0,K.jsx)(`span`,{...i}),t[26]=i,t[27]=v);let y;t[28]!==_||t[29]!==v?(y=(0,K.jsxs)(`label`,{className:`flex gap-2 items-center`,children:[p,_,v]}),t[28]=_,t[29]=v,t[30]=y):y=t[30];let b;t[31]!==l||t[32]!==r.engine||t[33]!==u?(b=(0,K.jsx)(iA,{selectedEngine:r.engine,onChange:u,cellId:l}),t[31]=l,t[32]=r.engine,t[33]=u,t[34]=b):b=t[34];let x;t[35]===r.engine?x=t[36]:(x=r.engine===`__marimo_duckdb`&&(0,K.jsx)(uA,{}),t[35]=r.engine,t[36]=x);let S;t[37]!==r.engine||t[38]!==n?(S=async()=>{await fm(n,r.engine)},t[37]=r.engine,t[38]=n,t[39]=S):S=t[39];let C;t[40]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,K.jsx)(Bo,{className:`h-3 w-3`}),t[40]=C):C=t[40];let w;t[41]===S?w=t[42]:(w=(0,K.jsx)(vt,{content:`Format SQL`,children:(0,K.jsx)(bt,{variant:`text`,size:`icon`,onClick:S,children:C})}),t[41]=S,t[42]=w);let T;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,K.jsx)(vA,{}),t[43]=T):T=t[43];let E;t[44]===m?E=t[45]:(E=e=>{m({showOutput:!e.target.checked})},t[44]=m,t[45]=E);let D=!r.showOutput,O;t[46]!==E||t[47]!==D?(O=(0,K.jsx)(`input`,{type:`checkbox`,onChange:E,checked:D}),t[46]=E,t[47]=D,t[48]=O):O=t[48];let k;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(k=(0,K.jsx)(`span`,{className:`select-none`,children:`Hide output`}),t[49]=k):k=t[49];let A;t[50]===O?A=t[51]:(A=(0,K.jsxs)(`label`,{className:`flex items-center gap-2`,children:[O,k]}),t[50]=O,t[51]=A);let j;t[52]!==x||t[53]!==w||t[54]!==A?(j=(0,K.jsxs)(`div`,{className:`flex items-center gap-2 ml-auto`,children:[x,w,T,A]}),t[52]=x,t[53]=w,t[54]=A,t[55]=j):j=t[55];let ee;t[56]!==y||t[57]!==b||t[58]!==j?(ee=(0,K.jsxs)(`div`,{className:`flex flex-1 gap-2 items-center`,children:[y,b,j]}),t[56]=y,t[57]=b,t[58]=j,t[59]=ee):ee=t[59],d=ee}if(s instanceof My){f=!0;let e,r,i,a,o,s,c,l,u,p;if(t[60]!==m||t[61]!==n.state){let{quotePrefix:d}=n.state.field(jy);r=d,r===void 0&&(r=`r`,m({quotePrefix:r})),p=(e,t)=>{if(typeof t!=`boolean`)return;let n=Pw({currentQuotePrefix:r,checked:t,prefix:e});m({quotePrefix:n})},a=`flex flex-row w-full justify-end gap-1.5 items-center`,u=`flex items-center gap-1.5`,t[72]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,K.jsx)(`span`,{children:`r`}),t[72]=i):i=t[72],e=Dw,s=`Toggle raw string`,c=`w-3 h-3`,l=r.includes(`r`),o=e=>{p(`r`,e)},t[60]=m,t[61]=n.state,t[62]=e,t[63]=r,t[64]=i,t[65]=a,t[66]=o,t[67]=s,t[68]=c,t[69]=l,t[70]=u,t[71]=p}else e=t[62],r=t[63],i=t[64],a=t[65],o=t[66],s=t[67],c=t[68],l=t[69],u=t[70],p=t[71];let h;t[73]!==e||t[74]!==o||t[75]!==s||t[76]!==c||t[77]!==l?(h=(0,K.jsx)(e,{"aria-label":s,className:c,checked:l,onCheckedChange:o}),t[73]=e,t[74]=o,t[75]=s,t[76]=c,t[77]=l,t[78]=h):h=t[78];let g;t[79]!==i||t[80]!==h||t[81]!==u?(g=(0,K.jsxs)(`div`,{className:u,children:[i,h]}),t[79]=i,t[80]=h,t[81]=u,t[82]=g):g=t[82];let _;t[83]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,K.jsx)(`span`,{children:`f`}),t[83]=_):_=t[83];let v;t[84]===r?v=t[85]:(v=r.includes(`f`),t[84]=r,t[85]=v);let y;t[86]===p?y=t[87]:(y=e=>{p(`f`,e)},t[86]=p,t[87]=y);let b;t[88]!==v||t[89]!==y?(b=(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[_,(0,K.jsx)(Dw,{"aria-label":`Toggle f-string`,className:`w-3 h-3`,checked:v,onCheckedChange:y})]}),t[88]=v,t[89]=y,t[90]=b):b=t[90];let x;t[91]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,K.jsx)(vt,{content:(0,K.jsx)(Fw,{}),children:(0,K.jsx)(Po,{className:`w-3 h-3`})}),t[91]=x):x=t[91];let S;t[92]!==a||t[93]!==g||t[94]!==b?(S=(0,K.jsxs)(`div`,{className:a,children:[g,b,x]}),t[92]=a,t[93]=g,t[94]=b,t[95]=S):S=t[95],d=S}let h;t[96]===f?h=t[97]:(h=f&&(0,K.jsx)(vA,{}),t[96]=f,t[97]=h);let g;return t[98]!==d||t[99]!==s.type||t[100]!==h?(g=(0,K.jsx)(_t,{children:(0,K.jsxs)(`div`,{className:`flex justify-between items-center gap-4 pl-2 pt-2`,children:[d,h,s.type]})}),t[98]=d,t[99]=s.type,t[100]=h,t[101]=g):g=t[101],g},bA=new En,xA=xn.define(),SA=on.define({create(){return Tw.python},update(e,t){for(let e of t.effects)if(e.is(xA))return e.value;return e},provide:e=>bn.from(e,e=>e.type===`python`?null:e=>mm(e,yA))});function CA(){let e=Ew(),t=(n,r)=>{let i=e[r%e.length];return i.isSupported(n)?i:t(n,r+1)};return[dn.of([{key:`F4`,preventDefault:!0,run:n=>{let r=n.state.field(SA),i=e.findIndex(e=>e.type===r.type),a=n.state.doc.toString(),o=t(a,i+1);return r!==o&&(wA({view:n,nextLanguage:o,opts:{keepCodeAsIs:!1}}),!0)}}])]}function wA({view:e,nextLanguage:t,opts:n}){let r=e.state.field(SA),i=e.state.doc.toString(),a=e.state.facet(nf),o=e.state.facet(rf),s=e.state.facet(af),c=e.state.facet(of),l=e.state.facet(sf),u=e.state.field(jy),d=e.state.selection.main.head,f;if(n.keepCodeAsIs)f=i,r.type!==t.type&&(u={...t.defaultMetadata});else{let[e,n]=r.transformOut(i,u),[a,o,s]=t.transformIn(e);d+=n,d-=o,d=wr(d,0,a.length),f=a,u=s}e.dispatch({effects:[xA.of(t),ky.of(u),bA.reconfigure(t.getExtension(c,a,o,s,l)),lf.reconfigure([]),lm.of(!0)],changes:n.keepCodeAsIs?void 0:{from:0,to:e.state.doc.length,insert:f},selection:n.keepCodeAsIs?void 0:On.cursor(d)}),e.dispatch({effects:[lf.reconfigure([ar()])]}),t.type===`sql`&&pw(e)}function TA(e){let{placeholderType:t,completionConfig:n,hotkeys:r,cellId:i,lspConfig:a}=e;return[CA(),bA.of(Tw.python.getExtension(i,n,r,t,a)),SA,jy]}function EA(e){return DA(AA({state:e}).trim())}function DA(e){return e?Tw.markdown.isSupported(e)?Tw.markdown:Tw.sql.isSupported(e)?Tw.sql:Tw.python:Tw.python}function OA(e,t){e.state.field(SA).type!==t.language&&wA({view:e,nextLanguage:Tw[t.language],opts:{keepCodeAsIs:t.keepCodeAsIs??!1}})}function kA(e,{completionConfig:t,hotkeysProvider:n,lspConfig:r}){let i=e.state.field(SA),a=e.state.facet(af),o=e.state.facet(of);return o===void 0&&L.error(`Cell ID is undefined in reconfigureLanguageEffect`),a===void 0&&L.error(`Placeholder type is undefined in reconfigureLanguageEffect`),t===void 0&&L.error(`Completion config is undefined in reconfigureLanguageEffect`),bA.reconfigure(i.getExtension(o,t,n,a,r))}function AA(e,t,n){let r=e.state.field(SA),i=e.state.field(jy),a=e.state.doc.toString();return t===void 0?r.transformOut(a,i)[0]:r.transformOut(a.slice(t,n),i)[0]}function jA(e,t){let n=e.state.field(SA),r=DA(t);r.type!==n.type&&OA(e,{language:r.type,keepCodeAsIs:!0});let[i]=e.state.field(SA).transformIn(t);return ef(e,i),i}function MA(e){let t=e.state.selection.main.head,n=e.state.doc.toString(),r=n.length>0&&n[t-1]===`
|
|
113
|
+
`,PO=e=>{let t=(0,X.c)(24),{value:n,options:r,onChange:i,className:a,placeholder:o,textAreaClassName:s,comboBoxClassName:c}=e,[l,u]=(0,G.useState)(!1),d;t[0]===n?d=t[1]:(d=IO(n),t[0]=n,t[1]=d);let f=d,p;t[2]!==c||t[3]!==i||t[4]!==r||t[5]!==o||t[6]!==l||t[7]!==s||t[8]!==f?(p=()=>l?(0,K.jsx)(FO,{value:f,className:s,onChange:i,placeholder:o?`${o}: one per line`:`One value per line`}):(0,K.jsx)(sO,{placeholder:o,displayValue:LO,className:V(`w-full max-w-[400px]`,c),multiple:!0,value:f,onValueChange:i,keepPopoverOpenOnSelect:!0,chips:!0,chipsClassName:`flex-row flex-wrap min-w-[210px]`,children:r.map(RO)}),t[2]=c,t[3]=i,t[4]=r,t[5]=o,t[6]=l,t[7]=s,t[8]=f,t[9]=p):p=t[9];let m=p,h;t[10]===a?h=t[11]:(h=V(`flex gap-1`,a),t[10]=a,t[11]=h);let g;t[12]===m?g=t[13]:(g=m(),t[12]=m,t[13]=g);let _=l?`Switch to multi-select`:`Switch to textarea`,v;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,K.jsx)(Ko,{className:`w-3 h-3`}),t[14]=v):v=t[14];let y;t[15]===l?y=t[16]:(y=(0,K.jsx)(MO,{size:`xs`,onPressedChange:u,pressed:l,children:v}),t[15]=l,t[16]=y);let b;t[17]!==_||t[18]!==y?(b=(0,K.jsx)(vt,{content:_,children:y}),t[17]=_,t[18]=y,t[19]=b):b=t[19];let x;return t[20]!==h||t[21]!==g||t[22]!==b?(x=(0,K.jsxs)(`div`,{className:h,children:[g,b]}),t[20]=h,t[21]=g,t[22]=b,t[23]=x):x=t[23],x},FO=e=>{let t=(0,X.c)(11),{className:n,value:r,onChange:i,placeholder:a}=e,o,s;if(t[0]!==r){let e=IO(r);o=Lt,s=e.join(NO),t[0]=r,t[1]=o,t[2]=s}else o=t[1],s=t[2];let c;t[3]===i?c=t[4]:(c=e=>{if(e.target.value===``){i([]);return}i(e.target.value.split(NO))},t[3]=i,t[4]=c);let l=a?`${a}: one per line`:`One value per line`,u;return t[5]!==o||t[6]!==n||t[7]!==s||t[8]!==c||t[9]!==l?(u=(0,K.jsx)(o,{value:s,className:n,rows:4,onChange:c,placeholder:l}),t[5]=o,t[6]=n,t[7]=s,t[8]=c,t[9]=l,t[10]=u):u=t[10],u};function IO(e){return e==null?[]:Array.isArray(e)?e:[e].filter(e=>e!=null||e!==``)}function LO(e){return e}function RO(e){return(0,K.jsx)(cO,{value:e,children:e},e)}var zO=[],BO=e=>{let t=(0,X.c)(9),{schema:n,form:r,path:i,renderers:a,children:o}=e,s=i===void 0?``:i,c=a===void 0?zO:a,l;t[0]!==r||t[1]!==s||t[2]!==c||t[3]!==n?(l=VO({schema:n,form:r,path:s,renderers:c}),t[0]=r,t[1]=s,t[2]=c,t[3]=n,t[4]=l):l=t[4];let u;return t[5]!==o||t[6]!==r||t[7]!==l?(u=(0,K.jsxs)(yT,{...r,children:[o,l]}),t[5]=o,t[6]=r,t[7]=l,t[8]=u):u=t[8],u};function VO({schema:e,form:t,path:n,renderers:r}){for(let i of r){let{isMatch:r,Component:a}=i;if(r(e))return(0,K.jsx)(a,{schema:e,form:t,path:n})}let{label:i,description:a,special:o,direction:s=`column`,minLength:c}=GE.parse(e.description||``);if(e instanceof S){let i=e.unwrap();return i=!i.description&&e.description?i.describe(e.description):i,VO({schema:i,form:t,path:n,renderers:r})}if(e instanceof w){let i=e.unwrap();return i=!i.description&&e.description?i.describe(e.description):i,VO({schema:i,form:t,path:n,renderers:r})}if(e instanceof C)return(0,K.jsxs)(`div`,{className:V(`flex`,s===`row`?`flex-row gap-6 items-start`:s===`two-columns`?`grid grid-cols-2 gap-y-6`:`flex-col gap-6`),children:[(0,K.jsx)(xO,{children:i}),R.entries(e.shape).map(([e,i])=>{let a=i instanceof D,o=VO({schema:i,form:t,path:qO(n,e),renderers:r});return a?(0,K.jsx)(G.Fragment,{children:o},e):(0,K.jsx)(`div`,{className:`flex flex-row align-start`,children:o},e)})]});if(e instanceof O)return o===`time`?(0,K.jsx)(_O,{control:t.control,name:n,render:({field:e})=>(0,K.jsxs)(bO,{children:[(0,K.jsx)(xO,{children:i}),(0,K.jsx)(CO,{children:a}),(0,K.jsx)(SO,{children:(0,K.jsx)(nn,{...e,onValueChange:e.onChange,type:`time`,className:`my-0`})}),(0,K.jsx)(wO,{})]})}):(0,K.jsx)(UO,{schema:e,form:t,path:n});if(e instanceof ee)return(0,K.jsx)(_O,{control:t.control,name:n,render:({field:e})=>(0,K.jsxs)(bO,{children:[(0,K.jsxs)(`div`,{className:V(`flex flex-row gap-2`,a?`items-start`:`items-center`),children:[(0,K.jsx)(SO,{children:(0,K.jsx)(Dw,{"data-testid":`marimo-plugin-data-frames-boolean-checkbox`,checked:e.value,onCheckedChange:e.onChange,className:a?`mt-0.5`:void 0})}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,K.jsx)(xO,{children:i}),(0,K.jsx)(CO,{children:a})]})]}),(0,K.jsx)(wO,{})]})});if(e instanceof te)return o===`random_number_button`?(0,K.jsx)(_O,{control:t.control,name:n,render:({field:e})=>(0,K.jsxs)(bt,{size:`xs`,"data-testid":`marimo-plugin-data-frames-random-number-button`,variant:`secondary`,onClick:()=>{e.onChange(KE())},children:[(0,K.jsx)(Vo,{className:`w-3.5 h-3.5 mr-1`}),i]})}):(0,K.jsx)(_O,{control:t.control,name:n,render:({field:e})=>(0,K.jsxs)(bO,{children:[(0,K.jsx)(xO,{children:i}),(0,K.jsx)(CO,{children:a}),(0,K.jsx)(SO,{children:(0,K.jsx)(en,{...e,className:`my-0`,onValueChange:e.onChange})}),(0,K.jsx)(wO,{})]})});if(e instanceof E){let e=o===`datetime`?`datetime-local`:o===`time`?`time`:`date`;return(0,K.jsx)(_O,{control:t.control,name:n,render:({field:t})=>(0,K.jsxs)(bO,{children:[(0,K.jsx)(xO,{children:i}),(0,K.jsx)(CO,{children:a}),(0,K.jsx)(SO,{children:(0,K.jsx)(nn,{...t,onValueChange:t.onChange,type:e,className:`my-0`})}),(0,K.jsx)(wO,{})]})})}if(e instanceof N)return(0,K.jsx)(UO,{schema:e,form:t,path:n});if(e instanceof M){let r=e.options.map(e=>e.toString());return(0,K.jsx)(GO,{schema:e,form:t,path:n,options:r})}if(e instanceof k){if(o===`text_area_multiline`)return(0,K.jsx)(WO,{schema:e,form:t,path:n});let a=e.element;if(a instanceof M){let r=a.options.map(e=>e.toString());return(0,K.jsx)(KO,{schema:e,form:t,path:n,itemLabel:i,options:r})}return(0,K.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,K.jsx)(ct,{children:i}),(0,K.jsx)(HO,{schema:e.element,form:t,path:n,minLength:c,renderers:r},n)]})}if(e instanceof A){let a=e.def,o=a.options,s=a.discriminator,c=e=>o.find(t=>kO(t).value===e);return(0,K.jsx)(_O,{control:t.control,name:n,render:({field:e})=>{let a=e.value,l=o.map(e=>kO(e).value),u=a&&typeof a==`object`&&s in a?a[s]:l[0],d=c(u);return(0,K.jsxs)(`div`,{className:`flex flex-col`,children:[(0,K.jsx)(xO,{className:`mb-2`,children:i}),(0,K.jsx)(`div`,{className:`flex border-b mb-4`,children:l.map(t=>(0,K.jsx)(`button`,{type:`button`,className:`px-4 py-2 text-sm ${u===t?`border-b-2 border-primary font-medium`:`text-muted-foreground`}`,onClick:()=>{let n=c(t);n?e.onChange(OO(n)):e.onChange({[s]:t})},children:t},t))}),(0,K.jsx)(`div`,{className:`flex flex-col`,children:d&&VO({schema:d,form:t,path:n,renderers:r})},u)]})}})}return e instanceof x?(0,K.jsx)(_O,{control:t.control,name:n,render:({field:a})=>{let o=e.options,s=a.value,c=o.map(e=>kO(e).value);s||=c[0];let l=o.find(e=>kO(e).value===s);return(0,K.jsxs)(`div`,{className:`flex flex-col mb-4 gap-1`,children:[(0,K.jsx)(xO,{children:i}),(0,K.jsx)(ut,{"data-testid":`marimo-plugin-data-frames-union-select`,...a,children:c.map(e=>(0,K.jsx)(`option`,{value:e,children:e},e))}),l&&VO({schema:l,form:t,path:n,renderers:r})]})}}):e instanceof D?(0,K.jsx)(_O,{control:t.control,name:n,render:({field:t})=>(0,K.jsx)(`input`,{...t,type:`hidden`,value:String([...e.values][0]??``)})}):`unwrap`in e?VO({schema:DO(e),form:t,path:n,renderers:r}):fO(e)?VO({schema:e.in,form:t,path:n,renderers:r}):(0,K.jsxs)(`div`,{children:[`Unknown schema type`,` `,e==null?n:JSON.stringify(e.type??e)]})}var HO=e=>{let t=(0,X.c)(39),{schema:n,form:r,path:i,minLength:a,renderers:o}=e,s;t[0]===n.description?s=t[1]:(s=GE.parse(n.description||``),t[0]=n.description,t[1]=s);let{label:c,description:l}=s,u=r.control,d;t[2]!==u||t[3]!==i?(d={control:u,name:i},t[2]=u,t[3]=i,t[4]=d):d=t[4];let{fields:f,append:p,remove:m}=dE(d),h=a!=null&&f.length<a,g=a==null||f.length>a,_;t[5]===c?_=t[6]:(_=(0,K.jsx)(xO,{children:c}),t[5]=c,t[6]=_);let v;t[7]===l?v=t[8]:(v=(0,K.jsx)(CO,{children:l}),t[7]=l,t[8]=v);let y;if(t[9]!==g||t[10]!==f||t[11]!==r||t[12]!==i||t[13]!==m||t[14]!==o||t[15]!==n){let e;t[17]!==g||t[18]!==r||t[19]!==i||t[20]!==m||t[21]!==o||t[22]!==n?(e=(e,t)=>(0,K.jsxs)(`div`,{className:`flex flex-row pl-2 ml-2 border-l-2 border-disabled hover-actions-parent relative pr-5 pt-1 items-center w-fit`,onKeyDown:yt.onEnter(JO),children:[VO({schema:n,form:r,path:`${i}[${t}]`,renderers:o}),g&&(0,K.jsx)(rn,{className:`w-4 h-4 ml-2 my-1 text-muted-foreground hover:text-destructive cursor-pointer absolute right-0 top-5`,onClick:()=>{m(t)}})]},e.id),t[17]=g,t[18]=r,t[19]=i,t[20]=m,t[21]=o,t[22]=n,t[23]=e):e=t[23],y=f.map(e),t[9]=g,t[10]=f,t[11]=r,t[12]=i,t[13]=m,t[14]=o,t[15]=n,t[16]=y}else y=t[16];let b;t[24]!==h||t[25]!==a?(b=h&&(0,K.jsx)(`div`,{className:`text-destructive text-xs font-semibold`,children:(0,K.jsxs)(`div`,{children:[`At least `,a,` required.`]})}),t[24]=h,t[25]=a,t[26]=b):b=t[26];let x;t[27]!==p||t[28]!==n?(x=()=>{p(OO(n))},t[27]=p,t[28]=n,t[29]=x):x=t[29];let S;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,K.jsx)(Zt,{className:`w-3.5 h-3.5 mr-1`}),t[30]=S):S=t[30];let C;t[31]===x?C=t[32]:(C=(0,K.jsx)(`div`,{children:(0,K.jsxs)(bt,{size:`xs`,"data-testid":`marimo-plugin-data-frames-add-array-item`,variant:`text`,className:`hover:text-accent-foreground`,onClick:x,children:[S,`Add`]})}),t[31]=x,t[32]=C);let w;return t[33]!==_||t[34]!==v||t[35]!==y||t[36]!==b||t[37]!==C?(w=(0,K.jsxs)(`div`,{className:`flex flex-col gap-2 min-w-[220px]`,children:[_,v,y,b,C]}),t[33]=_,t[34]=v,t[35]=y,t[36]=b,t[37]=C,t[38]=w):w=t[38],w},UO=e=>{let t=(0,X.c)(21),{schema:n,form:r,path:i}=e,a;t[0]===n.description?a=t[1]:(a=GE.parse(n.description),t[0]=n.description,t[1]=a);let{label:o,description:s,placeholder:c,disabled:l,inputType:u}=a;if(u===`textarea`){let e;t[2]!==s||t[3]!==l||t[4]!==o||t[5]!==c?(e=e=>{let{field:t}=e;return(0,K.jsxs)(bO,{children:[(0,K.jsx)(xO,{children:o}),(0,K.jsx)(CO,{children:s}),(0,K.jsx)(SO,{children:(0,K.jsx)(Lt,{...t,value:t.value,onChange:t.onChange,className:`my-0`,placeholder:c,disabled:l})}),(0,K.jsx)(wO,{})]})},t[2]=s,t[3]=l,t[4]=o,t[5]=c,t[6]=e):e=t[6];let n;return t[7]!==r.control||t[8]!==i||t[9]!==e?(n=(0,K.jsx)(_O,{control:r.control,name:i,render:e}),t[7]=r.control,t[8]=i,t[9]=e,t[10]=n):n=t[10],n}let d;t[11]!==s||t[12]!==l||t[13]!==u||t[14]!==o||t[15]!==c?(d=e=>{let{field:t}=e;return(0,K.jsxs)(bO,{children:[(0,K.jsx)(xO,{children:o}),(0,K.jsx)(CO,{children:s}),(0,K.jsx)(SO,{children:(0,K.jsx)(nn,{...t,type:u,value:t.value,onValueChange:t.onChange,className:`my-0`,placeholder:c,disabled:l})}),(0,K.jsx)(wO,{})]})},t[11]=s,t[12]=l,t[13]=u,t[14]=o,t[15]=c,t[16]=d):d=t[16];let f;return t[17]!==r.control||t[18]!==i||t[19]!==d?(f=(0,K.jsx)(_O,{control:r.control,name:i,render:d}),t[17]=r.control,t[18]=i,t[19]=d,t[20]=f):f=t[20],f},WO=e=>{let t=(0,X.c)(10),{schema:n,form:r,path:i}=e,a;t[0]===n.description?a=t[1]:(a=GE.parse(n.description),t[0]=n.description,t[1]=a);let{label:o,description:s,placeholder:c}=a,l;t[2]!==s||t[3]!==o||t[4]!==c?(l=e=>{let{field:t}=e;return(0,K.jsxs)(bO,{children:[(0,K.jsx)(xO,{children:o}),(0,K.jsx)(CO,{children:s}),(0,K.jsx)(SO,{children:(0,K.jsx)(FO,{...t,placeholder:c})}),(0,K.jsx)(wO,{})]})},t[2]=s,t[3]=o,t[4]=c,t[5]=l):l=t[5];let u;return t[6]!==r.control||t[7]!==i||t[8]!==l?(u=(0,K.jsx)(_O,{control:r.control,name:i,render:l}),t[6]=r.control,t[7]=i,t[8]=l,t[9]=u):u=t[9],u},GO=e=>{let t=(0,X.c)(22),{schema:n,form:r,path:i,options:a,textTransform:o}=e,s;t[0]===n.description?s=t[1]:(s=GE.parse(n.description),t[0]=n.description,t[1]=s);let{label:c,description:l,disabled:u,special:d}=s;if(d===`radio_group`){let e;t[2]!==l||t[3]!==c||t[4]!==a||t[5]!==i?(e=e=>{let{field:t}=e;return(0,K.jsxs)(bO,{children:[(0,K.jsx)(xO,{children:c}),(0,K.jsx)(CO,{children:l}),(0,K.jsx)(SO,{children:(0,K.jsx)(lO,{className:`flex flex-row gap-2 pt-1 items-center`,value:t.value,onValueChange:t.onChange,children:a.map(e=>(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(uO,{value:e,id:`${i}-${e}`},e),(0,K.jsx)(xO,{className:`whitespace-pre`,htmlFor:`${i}-${e}`,children:zr.startCase(e)})]},e))})}),(0,K.jsx)(wO,{})]})},t[2]=l,t[3]=c,t[4]=a,t[5]=i,t[6]=e):e=t[6];let n;return t[7]!==u||t[8]!==r.control||t[9]!==i||t[10]!==e?(n=(0,K.jsx)(_O,{control:r.control,name:i,disabled:u,render:e}),t[7]=u,t[8]=r.control,t[9]=i,t[10]=e,t[11]=n):n=t[11],n}let f;t[12]!==l||t[13]!==c||t[14]!==a||t[15]!==o?(f=e=>{let{field:t}=e;return(0,K.jsxs)(bO,{children:[(0,K.jsx)(xO,{className:`whitespace-pre`,children:c}),(0,K.jsx)(CO,{children:l}),(0,K.jsx)(SO,{children:(0,K.jsxs)(ht,{"data-testid":`marimo-plugin-data-frames-select`,value:t.value,onValueChange:t.onChange,children:[(0,K.jsx)(mt,{className:`min-w-[180px]`,children:(0,K.jsx)(st,{placeholder:`--`})}),(0,K.jsx)(dt,{children:(0,K.jsxs)(pt,{children:[a.map(e=>(0,K.jsx)(lt,{value:e,children:o?.(e)??e},e)),a.length===0&&(0,K.jsx)(lt,{disabled:!0,value:`--`,children:`No options`})]})})]})}),(0,K.jsx)(wO,{})]})},t[12]=l,t[13]=c,t[14]=a,t[15]=o,t[16]=f):f=t[16];let p;return t[17]!==u||t[18]!==r.control||t[19]!==i||t[20]!==f?(p=(0,K.jsx)(_O,{control:r.control,name:i,disabled:u,render:f}),t[17]=u,t[18]=r.control,t[19]=i,t[20]=f,t[21]=p):p=t[21],p},KO=e=>{let t=(0,X.c)(15),{schema:n,form:r,path:i,options:a,itemLabel:o,showSwitchable:s}=e,c;t[0]===n.description?c=t[1]:(c=GE.parse(n.description),t[0]=n.description,t[1]=c);let{label:l,description:u,placeholder:d}=c,f;t[2]!==o||t[3]!==d?(f=d??(o?`Select ${o?.toLowerCase()}`:void 0),t[2]=o,t[3]=d,t[4]=f):f=t[4];let p=f,m;t[5]!==u||t[6]!==l||t[7]!==a||t[8]!==p||t[9]!==s?(m=e=>{let{field:t}=e,n=IO(t.value);return(0,K.jsxs)(bO,{children:[(0,K.jsx)(xO,{className:`whitespace-pre`,children:l}),(0,K.jsx)(CO,{children:u}),(0,K.jsx)(SO,{children:s?(0,K.jsx)(PO,{...t,value:n,options:a,placeholder:p}):(0,K.jsx)(sO,{className:`min-w-[180px]`,placeholder:p,displayValue:YO,multiple:!0,chips:!0,keepPopoverOpenOnSelect:!0,value:n,onValueChange:t.onChange,children:a.map(XO)})}),(0,K.jsx)(wO,{})]})},t[5]=u,t[6]=l,t[7]=a,t[8]=p,t[9]=s,t[10]=m):m=t[10];let h;return t[11]!==r.control||t[12]!==i||t[13]!==m?(h=(0,K.jsx)(_O,{control:r.control,name:i,render:m}),t[11]=r.control,t[12]=i,t[13]=m,t[14]=h):h=t[14],h};function qO(...e){return e.filter(e=>e!==``).join(`.`)}function JO(e){return e.preventDefault()}function YO(e){return zr.startCase(e)}function XO(e){return(0,K.jsx)(cO,{value:e,children:e},e)}function ZO({moduleName:e,variableName:t,onAddImport:n,appStore:r=u}){if(t in r.get(Ah))return!1;let{cellData:i,cellIds:a}=r.get(CM),o=RegExp(`import[ \t]+${e}[ \t]+as[ \t]+${t}`,`g`);for(let e of a.inOrderIds)if(o.test(i[e].code))return!1;return n(`import ${e} as ${t}`),!0}function QO({autoInstantiate:e,createNewCell:t,fromCellId:n,before:r}){let i=Br(),a=null;return ZO({moduleName:`marimo`,variableName:`mo`,onAddImport:o=>{a=Pi.create(),t({cellId:n??`__end__`,before:r??!1,code:o,lastCodeRun:e?o:void 0,newCellId:a,skipIfCodeExists:!0,autoFocus:!1}),e&&i.sendRun({cellIds:[a],codes:[o]})}})?a:null}function $O({autoInstantiate:e,createNewCell:t,fromCellId:n}){let r=Br(),i=null;return ZO({moduleName:`altair`,variableName:`alt`,onAddImport:a=>{i=Pi.create(),t({cellId:n??`__end__`,before:!1,code:a,lastCodeRun:e?a:void 0,newCellId:i,skipIfCodeExists:!0,autoFocus:!1}),e&&r.sendRun({cellIds:[i],codes:[a]})}})?i:null}function ek(){return{focusedCellId:null,lastFocusedCellId:null}}var{reducer:tk,createActions:nk,valueAtom:rk,useActions:ik}=kr(ek,{focusCell:(e,t)=>({...e,focusedCellId:t.cellId,lastFocusedCellId:t.cellId}),toggleCell:(e,t)=>e.focusedCellId===t.cellId?{...e,focusedCellId:null}:{...e,focusedCellId:t.cellId,lastFocusedCellId:t.cellId},blurCell:e=>({...e,focusedCellId:null})}),ak=o(e=>e(rk).lastFocusedCellId);function ok(){return s(ak)}var sk=o(e=>{let t=e(ak);return!t||t===`__scratch__`?null:lk(t,e(CM))});function ck(e){return o(t=>lk(e,t(CM)))}function lk(e,t){let{cellData:n,cellHandles:r,cellRuntime:i}=t,a=n[e],o=i[e],s=r[e]?.current;return!a||!s?null:{cellId:e,name:a.name,config:a.config,status:o?o.status:`idle`,getEditorView:()=>s.editorViewOrNull,hasOutput:o?.output!=null,hasConsoleOutput:o?.consoleOutputs!=null}}function uk(e,t){if(!t)return{recommended:[],other:[...e]};let n;try{n=new RegExp(t,`i`)}catch{return{recommended:[],other:[...e]}}let r=[],i=[];for(let t of e)n.test(t)?r.push(t):i.push(t);return{recommended:r,other:i}}var dk=e=>`Use "${e}"`,fk=e=>{let t=(0,X.c)(96),{value:n,onChange:r,placeholder:i,secretsOnly:a,recommendedKeys:o,otherKeys:s,onCreateSecret:c,className:l,searchPlaceholder:u,formatCustomValueLabel:d,createSecretLabel:f,allowCustomValue:p,allowCreateSecret:m}=e,h=a!==void 0&&a,g=d===void 0?dk:d,_=f===void 0?`Create a new secret`:f,[v,y]=(0,G.useState)(!1),[b,x]=(0,G.useState)(``),S,C,w,T,E,D,O,k,A,j,ee,M,N,te,ne,re,ie,P;if(t[0]!==m||t[1]!==p||t[2]!==l||t[3]!==g||t[4]!==r||t[5]!==v||t[6]!==i||t[7]!==b||t[8]!==u||t[9]!==h||t[10]!==n){P=b.trim();let e=!h&&P.length>0&&P!==n&&(p?.(P)??!0);O=m?.(P)??!0;let a;bb0:{if(!n){a=null;break bb0}if(Kt(n)){let e;t[29]===n?e=t[30]:(e=Gt(n),t[29]=n,t[30]=e),a=e;break bb0}a=n}let o=a,s;t[31]===r?s=t[32]:(s=e=>{r(Bt(e)),y(!1),x(``)},t[31]=r,t[32]=s),D=s;let c;t[33]===r?c=t[34]:(c=e=>{r(e),y(!1),x(``)},t[33]=r,t[34]=c);let d=c,f;t[35]===r?f=t[36]:(f=()=>{r(``),x(``),y(!1)},t[35]=r,t[36]=f),E=f,t[37]===l?ee=t[38]:(ee=V(`flex w-full min-w-48 mb-1 items-center gap-1`,l),t[37]=l,t[38]=ee),T=eO,ie=!0,k=v,t[39]===Symbol.for(`react.memo_cache_sentinel`)?(A=e=>{y(e),e||x(``)},t[39]=A):A=t[39];let _;t[40]===n?_=t[41]:(_=V(`flex h-6 min-w-0 flex-1 shadow-xs-solid items-center justify-between`,`rounded-sm border border-input bg-background px-1.5 text-sm font-code ring-offset-background placeholder:text-muted-foreground`,`hover:shadow-sm-solid focus:outline-hidden focus:ring-1 focus:ring-ring focus:border-primary focus:shadow-md-solid`,Kt(n)&&`bg-accent`),t[40]=n,t[41]=_);let ae;t[42]!==o||t[43]!==i||t[44]!==n?(ae=(0,K.jsx)(`span`,{className:`truncate flex-1 min-w-0 text-left flex items-center gap-1.5`,children:o?(0,K.jsxs)(K.Fragment,{children:[Kt(n)&&(0,K.jsx)(Rt,{className:`h-3 w-3 shrink-0 opacity-70`}),(0,K.jsx)(`span`,{className:`truncate`,children:o})]}):(0,K.jsx)(`span`,{className:`text-muted-foreground`,children:i})}),t[42]=o,t[43]=i,t[44]=n,t[45]=ae):ae=t[45];let F;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,K.jsx)(Mt,{className:`ml-1 h-4 w-4 opacity-50 shrink-0`}),t[46]=F):F=t[46],t[47]!==v||t[48]!==_||t[49]!==ae?(j=(0,K.jsx)(tO,{asChild:!0,children:(0,K.jsxs)(`button`,{type:`button`,className:_,"aria-expanded":v,children:[ae,F]})}),t[47]=v,t[48]=_,t[49]=ae,t[50]=j):j=t[50],w=aO,ne=`w-(--radix-popover-trigger-width) p-0`,re=`start`,C=GD;let oe=u??(h?`Search secrets...`:`Type a value or search secrets...`);t[51]!==b||t[52]!==oe?(te=(0,K.jsx)(qD,{placeholder:oe,rootClassName:`px-1 h-8`,autoFocus:!0,value:b,onValueChange:x}),t[51]=b,t[52]=oe,t[53]=te):te=t[53],S=JD,M=`max-h-60 overscroll-contain`,N=e&&(0,K.jsx)(XD,{children:(0,K.jsx)(QD,{value:`use custom value ${P}`,onSelect:()=>d(P),children:g(P)})}),t[0]=m,t[1]=p,t[2]=l,t[3]=g,t[4]=r,t[5]=v,t[6]=i,t[7]=b,t[8]=u,t[9]=h,t[10]=n,t[11]=S,t[12]=C,t[13]=w,t[14]=T,t[15]=E,t[16]=D,t[17]=O,t[18]=k,t[19]=A,t[20]=j,t[21]=ee,t[22]=M,t[23]=N,t[24]=te,t[25]=ne,t[26]=re,t[27]=ie,t[28]=P}else S=t[11],C=t[12],w=t[13],T=t[14],E=t[15],D=t[16],O=t[17],k=t[18],A=t[19],j=t[20],ee=t[21],M=t[22],N=t[23],te=t[24],ne=t[25],re=t[26],ie=t[27],P=t[28];let ae;t[54]!==_||t[55]!==c||t[56]!==O||t[57]!==P?(ae=O&&(0,K.jsx)(XD,{className:`mt-0`,children:(0,K.jsxs)(QD,{value:`create new secret ${P}`,onSelect:()=>{let e=P||void 0;y(!1),x(``),c(e)},children:[(0,K.jsx)(Do,{className:`mr-2 h-3.5 w-3.5`}),_]})}),t[54]=_,t[55]=c,t[56]=O,t[57]=P,t[58]=ae):ae=t[58];let F;t[59]!==o||t[60]!==D?(F=o.length>0&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(ZD,{className:`mt-0`}),(0,K.jsx)(XD,{heading:`Recommended`,children:o.map(e=>(0,K.jsxs)(QD,{value:e,onSelect:()=>D(e),children:[(0,K.jsx)(Rt,{className:`mr-2 h-3 w-3 opacity-70`}),e]},e))})]}),t[59]=o,t[60]=D,t[61]=F):F=t[61];let oe;t[62]!==s||t[63]!==o.length||t[64]!==D?(oe=s.length>0&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(ZD,{className:`mt-0`}),(0,K.jsx)(XD,{heading:o.length>0?`Other`:void 0,children:s.map(e=>(0,K.jsxs)(QD,{value:e,onSelect:()=>D(e),children:[(0,K.jsx)(Rt,{className:`mr-2 h-3 w-3 opacity-70`}),e]},e))})]}),t[62]=s,t[63]=o.length,t[64]=D,t[65]=oe):oe=t[65];let I;t[66]!==S||t[67]!==ae||t[68]!==F||t[69]!==oe||t[70]!==M||t[71]!==N?(I=(0,K.jsxs)(S,{className:M,children:[N,ae,F,oe]}),t[66]=S,t[67]=ae,t[68]=F,t[69]=oe,t[70]=M,t[71]=N,t[72]=I):I=t[72];let se;t[73]!==C||t[74]!==I||t[75]!==te?(se=(0,K.jsxs)(C,{children:[te,I]}),t[73]=C,t[74]=I,t[75]=te,t[76]=se):se=t[76];let ce;t[77]!==w||t[78]!==se||t[79]!==ne||t[80]!==re?(ce=(0,K.jsx)(w,{className:ne,align:re,children:se}),t[77]=w,t[78]=se,t[79]=ne,t[80]=re,t[81]=ce):ce=t[81];let L;t[82]!==T||t[83]!==k||t[84]!==A||t[85]!==j||t[86]!==ce||t[87]!==ie?(L=(0,K.jsxs)(T,{modal:ie,open:k,onOpenChange:A,children:[j,ce]}),t[82]=T,t[83]=k,t[84]=A,t[85]=j,t[86]=ce,t[87]=ie,t[88]=L):L=t[88];let le;t[89]!==E||t[90]!==n?(le=n&&(0,K.jsx)(`button`,{type:`button`,"aria-label":`Clear`,className:V(`flex h-6 w-6 shrink-0 items-center justify-center rounded-sm`,`text-muted-foreground hover:bg-muted hover:text-foreground`,`focus:outline-hidden focus:ring-1 focus:ring-ring`),onClick:E,children:(0,K.jsx)(Nt,{className:`h-3.5 w-3.5`})}),t[89]=E,t[90]=n,t[91]=le):le=t[91];let ue;return t[92]!==ee||t[93]!==L||t[94]!==le?(ue=(0,K.jsxs)(`div`,{className:ee,children:[L,le]}),t[92]=ee,t[93]=L,t[94]=le,t[95]=ue):ue=t[95],ue},pk=(0,G.createContext)({providerNames:[],secretKeys:[],loading:!1,error:void 0,refreshSecrets:oe.NOOP}),mk=()=>(0,G.use)(pk),hk=e=>{let t=(0,X.c)(14),{children:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=[],t[0]=r):r=t[0];let{data:i,isPending:a,error:o,refetch:s}=ui(xk,r);i?.secretKeys,i?.providerNames;let c;t[1]===i?.secretKeys?c=t[2]:(c=i?.secretKeys||[],t[1]=i?.secretKeys,t[2]=c);let l;t[3]===i?.providerNames?l=t[4]:(l=i?.providerNames||[],t[3]=i?.providerNames,t[4]=l);let u;t[5]!==o||t[6]!==a||t[7]!==s||t[8]!==c||t[9]!==l?(u={secretKeys:c,providerNames:l,loading:a,error:o,refreshSecrets:s},t[5]=o,t[6]=a,t[7]=s,t[8]=c,t[9]=l,t[10]=u):u=t[10];let d=u,f;return t[11]!==n||t[12]!==d?(f=(0,K.jsx)(pk,{value:d,children:n}),t[11]=n,t[12]=d,t[13]=f):f=t[13],f},gk={isMatch:e=>{if(e instanceof O){let{optionRegex:t}=GE.parse(e.description||``);return!!t}return!1},Component:({schema:e,form:t,path:n})=>{let{secretKeys:r,providerNames:i,refreshSecrets:a}=mk(),{openModal:o,closeModal:s}=zt(),{label:c,description:l,placeholder:u,optionRegex:d=``,inputType:f}=GE.parse(e.description||``),p=f===`password`,{recommended:m,other:h}=uk(r,d);return(0,K.jsx)(_O,{control:t.control,name:n,render:({field:e})=>(0,K.jsxs)(bO,{children:[(0,K.jsx)(xO,{children:c}),(0,K.jsx)(CO,{children:l}),(0,K.jsx)(SO,{children:(0,K.jsx)(fk,{value:e.value?String(e.value):``,onChange:e.onChange,placeholder:u,secretsOnly:p,recommendedKeys:m,otherKeys:h,onCreateSecret:t=>{o((0,K.jsx)(qt,{providerNames:i,initialValue:t,onSuccess:t=>{a(),e.onChange(Bt(t)),s()},onClose:s}))}})}),(0,K.jsx)(wO,{})]})})}},_k={isMatch:e=>{if(e instanceof O){let{special:t}=GE.parse(e.description||``);return t===`secret_textarea`}return!1},Component:({schema:e,form:t,path:n})=>{let{secretKeys:r,providerNames:i,refreshSecrets:a}=mk(),{openModal:o,closeModal:s}=zt(),{label:c,description:l,placeholder:u}=GE.parse(e.description||``);return(0,K.jsx)(_O,{control:t.control,name:n,render:({field:e})=>{let t=e.value?String(e.value):``,n=Jt(t)?Ht(t):t;return(0,K.jsxs)(bO,{children:[(0,K.jsxs)(xO,{className:`flex items-center gap-1`,children:[c,(0,K.jsx)(vt,{content:`Enter a path to a file on disk, or create a secret to paste JSON directly.`,delayDuration:300,children:(0,K.jsx)(`button`,{type:`button`,className:`inline-flex`,"aria-label":`Credential input help`,children:(0,K.jsx)(Po,{className:`h-3.5 w-3.5`})})})]}),(0,K.jsx)(CO,{children:l}),(0,K.jsx)(SO,{children:(0,K.jsx)(fk,{value:n,onChange:t=>{e.onChange(!t||Kt(t)||Jt(t)?t:Vt(t))},placeholder:u,searchPlaceholder:`Type a file path or paste JSON`,formatCustomValueLabel:e=>`Use "${e}" as a file path`,createSecretLabel:`Paste JSON credentials`,allowCustomValue:e=>!Ut(e),allowCreateSecret:e=>!e||Ut(e),recommendedKeys:[],otherKeys:r,onCreateSecret:t=>{o((0,K.jsx)(qt,{providerNames:i,initialValue:t,multiline:!0,onSuccess:t=>{a(),e.onChange(Bt(t)),s()},onClose:s}))}})}),(0,K.jsx)(wO,{})]})}})}};function vk(e){return e.provider!==`env`}function yk(e){return e.name}function bk(e){return e.keys}async function xk(){let e=await Yt.request({}),t=Wt(e.secrets).filter(vk).map(yk);return{secretKeys:e.secrets.flatMap(bk).toSorted(),providerNames:t}}var Sk=[gk,_k],Ck=e=>{let t=(0,X.c)(2),{children:n}=e,r;return t[0]===n?r=t[1]:(r=(0,K.jsx)(`div`,{className:`grid grid-cols-2 md:grid-cols-3 gap-4`,children:n}),t[0]=n,t[1]=r),r},wk=e=>{let t=(0,X.c)(9),{name:n,color:r,icon:i,onSelect:a}=e,o;t[0]===r?o=t[1]:(o={backgroundColor:r},t[0]=r,t[1]=o);let s;t[2]===n?s=t[3]:(s=(0,K.jsx)(`span`,{className:`text-white font-medium text-lg`,children:n}),t[2]=n,t[3]=s);let c;return t[4]!==i||t[5]!==a||t[6]!==o||t[7]!==s?(c=(0,K.jsxs)(`button`,{type:`button`,className:`py-3 flex flex-col items-center justify-center gap-1 transition-[scale,filter,box-shadow] hover:scale-105 hover:brightness-110 rounded shadow-sm-solid hover:shadow-md-solid`,style:o,onClick:a,children:[i,s]}),t[4]=i,t[5]=a,t[6]=o,t[7]=s,t[8]=c):c=t[8],c},Tk=e=>{let t=(0,X.c)(25),{onBack:n,isValid:r,libraries:i,preferredLibrary:a,onLibraryChange:o,displayNames:s,libraryLabel:c}=e,l=c===void 0?`Preferred library`:c,u;t[0]===n?u=t[1]:(u=(0,K.jsx)(bt,{type:`button`,variant:`outline`,onClick:n,children:`Back`}),t[0]=n,t[1]=u);let d=!r,f;t[2]===d?f=t[3]:(f=(0,K.jsx)(bt,{type:`submit`,disabled:d,children:`Add`}),t[2]=d,t[3]=f);let p;t[4]!==u||t[5]!==f?(p=(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[u,f]}),t[4]=u,t[5]=f,t[6]=p):p=t[6];let m;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,K.jsx)(mt,{children:(0,K.jsx)(st,{placeholder:`Select a library`})}),t[7]=m):m=t[7];let h;t[8]===l?h=t[9]:(h=(0,K.jsxs)(`div`,{className:`flex flex-col gap-1 items-end`,children:[m,(0,K.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:l})]}),t[8]=l,t[9]=h);let g;if(t[10]!==s||t[11]!==i){let e;t[13]===s?e=t[14]:(e=e=>(0,K.jsx)(lt,{value:e,children:s[e]??e},e),t[13]=s,t[14]=e),g=i.map(e),t[10]=s,t[11]=i,t[12]=g}else g=t[12];let _;t[15]===g?_=t[16]:(_=(0,K.jsx)(dt,{children:(0,K.jsx)(pt,{children:g})}),t[15]=g,t[16]=_);let v;t[17]!==o||t[18]!==a||t[19]!==h||t[20]!==_?(v=(0,K.jsx)(`div`,{children:(0,K.jsxs)(ht,{value:a,onValueChange:o,children:[h,_]})}),t[17]=o,t[18]=a,t[19]=h,t[20]=_,t[21]=v):v=t[21];let y;return t[22]!==v||t[23]!==p?(y=(0,K.jsxs)(`div`,{className:`flex gap-2 justify-between`,children:[p,v]}),t[22]=v,t[23]=p,t[24]=y):y=t[24],y};function Ek(){let e=(0,X.c)(4),{createNewCell:t}=_N(),n=ok(),r=s(F),i;return e[0]!==r||e[1]!==t||e[2]!==n?(i=e=>{/\bmo\./.test(e)&&QO({autoInstantiate:r,createNewCell:t,fromCellId:n}),t({code:e,before:!1,cellId:n??`__end__`,skipIfCodeExists:!0})},e[0]=r,e[1]=t,e[2]=n,e[3]=i):i=e[3],i}function Dk(e){let t=(0,X.c)(3),n=Ek(),r;return t[0]!==n||t[1]!==e?(r=t=>{n(t.code),e?.()},t[0]=n,t[1]=e,t[2]=r):r=t[2],r}var Ok=e=>{let t=(0,X.c)(30),{schema:n,libraries:r,preferredLibrary:i,displayNames:a,libraryLabel:o,generateCode:s,onSubmit:c,onBack:l}=e,u;t[0]===n?u=t[1]:(u=OO(n),t[0]=n,t[1]=u);let d=u,f;t[2]===n?f=t[3]:(f=WE(n),t[2]=n,t[3]=f);let p;t[4]!==d||t[5]!==f?(p={defaultValues:d,resolver:f,reValidateMode:`onChange`},t[4]=d,t[5]=f,t[6]=p):p=t[6];let m=PE(p),[h,g]=G.useState(i),_=Ek(),v;t[7]!==s||t[8]!==_||t[9]!==c||t[10]!==h?(v=e=>{_(s(e,h)),c()},t[7]=s,t[8]=_,t[9]=c,t[10]=h,t[11]=v):v=t[11];let y=v,b;t[12]!==m||t[13]!==y?(b=m.handleSubmit(y),t[12]=m,t[13]=y,t[14]=b):b=t[14];let x;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,K.jsx)(hO,{}),t[15]=x):x=t[15];let S;t[16]!==m||t[17]!==n?(S=(0,K.jsx)(hk,{children:(0,K.jsx)(BO,{schema:n,form:m,renderers:Sk,children:x})}),t[16]=m,t[17]=n,t[18]=S):S=t[18];let C;t[19]!==a||t[20]!==m.formState.isValid||t[21]!==r||t[22]!==o||t[23]!==l||t[24]!==h?(C=(0,K.jsx)(Tk,{onBack:l,isValid:m.formState.isValid,libraries:r,preferredLibrary:h,onLibraryChange:g,displayNames:a,libraryLabel:o}),t[19]=a,t[20]=m.formState.isValid,t[21]=r,t[22]=o,t[23]=l,t[24]=h,t[25]=C):C=t[25];let w;return t[26]!==b||t[27]!==S||t[28]!==C?(w=(0,K.jsxs)(`form`,{onSubmit:b,className:`space-y-4`,children:[S,C]}),t[26]=b,t[27]=S,t[28]=C,t[29]=w):w=t[29],w};function kk(e,t){return!t||e.category===`object-storage`==(t===`storage`)}function Ak(e,t){let n=e.hidesWhen;return n.kind===`dialect`?n.substrings.some(e=>t.dialects.some(t=>t.includes(e))):n.protocols.some(e=>t.storageProtocols.has(e))?!0:n.backendTypes.some(e=>t.storageBackendTypes.has(e))}var jk=o(0),Mk,Nk=0;function Pk(){let e=u.get(jk);return(!Mk||Nk!==e)&&(Nk=e,Mk=B().then(()=>FC.request({})).then(e=>e.sources).catch(t=>{throw Nk===e&&(Mk=void 0),t})),Mk}function Fk(){Mk=void 0,u.set(jk,e=>e+1)}var Ik=new Xt(`storage-list-entries`,async(e,t)=>{await Br().listStorageEntries({requestId:e,...t})}),Lk=new Xt(`storage-download`,async(e,t)=>{await Br().downloadStorage({requestId:e,...t})});function Rk(e,t){return`${e}::${t??``}`}function zk(e){return`${e}::`}function Bk(){return{namespaces:[],entriesByPath:new Map,pageMetadataByPath:new Map}}var{reducer:Vk,createActions:Hk,valueAtom:Uk,useActions:Wk}=kr(Bk,{setNamespaces:(e,t)=>{let n=new Map(e.namespaces.map(e=>[e.name,e]));for(let e of t.namespaces)n.set(e.name,e);return{...e,namespaces:[...n.values()]}},setEntries:(e,t)=>{let n=Rk(t.namespace,t.prefix),r=new Map(e.entriesByPath),i=t.append&&r.has(n)?[...r.get(n)??[],...t.entries]:t.entries;r.set(n,i);let a=new Map(e.pageMetadataByPath);return a.set(n,{nextPageToken:t.nextPageToken??null}),{...e,entriesByPath:r,pageMetadataByPath:a}},clearNamespaceCache:(e,t)=>{let n=new Map(e.entriesByPath),r=new Map(e.pageMetadataByPath),i=zk(t);for(let e of n.keys())e.startsWith(i)&&n.delete(e);for(let e of r.keys())e.startsWith(i)&&r.delete(e);return{...e,entriesByPath:n,pageMetadataByPath:r}},filterFromVariables:(e,t)=>{let n=new Set(t),r=e.namespaces.filter(e=>n.has(e.name));return{...e,namespaces:r}}}),Gk=()=>s(Uk),Kk=o(e=>e(Uk).namespaces);function qk(){return Wk()}async function Jk({namespace:e,prefix:t,pageToken:n,append:r,setEntries:i}){let a=await Ik.request({namespace:e,prefix:t??``,limit:150,...n==null?{}:{pageToken:n}});if(a.error)throw Error(a.error);return i({namespace:e,prefix:t,entries:a.entries,nextPageToken:a.next_page_token,append:r}),a}function Yk(e,t){let{entriesByPath:n,pageMetadataByPath:r}=Gk(),{setEntries:i}=qk(),a=Rk(e,t),o=n.get(a),s=r.get(a)?.nextPageToken??null,c=(0,G.useRef)(!1),[l,u]=(0,G.useState)(!1),[d,f]=(0,G.useState)(),{isPending:p,error:m,refetch:h}=ui(async()=>{o||await Jk({namespace:e,prefix:t,setEntries:i})},[e,t,o===void 0]),g=(0,G.useCallback)(async()=>{if(!(s==null||c.current)){c.current=!0,u(!0),f(void 0);try{await Jk({namespace:e,prefix:t,pageToken:s,append:!0,setEntries:i})}catch(e){f(e instanceof Error?e:Error(String(e)))}finally{c.current=!1,u(!1)}}},[e,t,s,i]);return{entries:o??[],isPending:p&&!o,error:o?void 0:m,hasMore:s!==null,loadMore:g,isLoadingMore:l,loadMoreError:d,refetch:h}}function Xk(){let e=(0,X.c)(2),{setEntries:t}=qk(),n;return e[0]===t?n=e[1]:(n=e=>Jk({...e,setEntries:t}),e[0]=t,e[1]=n),n}function Zk(){let e=(0,X.c)(2),t=s(jk),n;return e[0]===t?n=e[1]:(n=[t],e[0]=t,e[1]=n),ui(Pk,n)}function Qk(e){let t=(0,X.c)(6),{data:n}=Zk(),r=s(_p),i=s(Kk),a;bb0:{if(!n){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[0]=e):e=t[0],a=e;break bb0}let o;if(t[1]!==r||t[2]!==n||t[3]!==e||t[4]!==i){let a={dialects:[...r.values()].map(tA),storageProtocols:new Set(i.map(eA)),storageBackendTypes:new Set(i.map($k))};o=n.filter(t=>kk(t,e)&&!Ak(t,a)),t[1]=r,t[2]=n,t[3]=e,t[4]=i,t[5]=o}else o=t[5];a=o}return a}function $k(e){return e.backendType.toLowerCase()}function eA(e){return e.protocol.toLowerCase()}function tA(e){return e.dialect.toLowerCase()}function nA(){let e=(0,X.c)(1),[,t]=(0,G.useState)(0),n;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=()=>{t(rA)},e[0]=n):n=e[0],n}function rA(e){return e+1}var iA=e=>{let t=(0,X.c)(6),n=Qk(`database`);if(n.length===0){let r;return t[0]!==n||t[1]!==e?(r=(0,K.jsx)(oA,{...e,detectedDataSources:n}),t[0]=n,t[1]=e,t[2]=r):r=t[2],r}let r;return t[3]!==n||t[4]!==e?(r=(0,K.jsx)(aA,{...e,detectedDataSources:n}),t[3]=n,t[4]=e,t[5]=r):r=t[5],r},aA=e=>{let t=(0,X.c)(7),n,r;t[0]===e?(n=t[1],r=t[2]):({detectedDataSources:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i=Dk(),a;return t[3]!==i||t[4]!==n||t[5]!==r?(a=(0,K.jsx)(oA,{...r,detectedDataSources:n,addDetectedDataSource:i}),t[3]=i,t[4]=n,t[5]=r,t[6]=a):a=t[6],a},oA=e=>{let t=(0,X.c)(42),{selectedEngine:n,onChange:r,cellId:i,detectedDataSources:a,addDetectedDataSource:o}=e,c=s(_p),l=[],u=[];for(let[e,t]of c.entries())Vf.has(e)?l.push(t):u.push(t);let d=nA(),f;t[0]!==c||t[1]!==n?(f=n&&!c.has(n),t[0]=c,t[1]=n,t[2]=f):f=t[2];let p=f,m;t[3]!==o||t[4]!==c||t[5]!==a||t[6]!==r||t[7]!==d?(m=e=>{if(e===sA){window.open(lA,`_blank`);return}if(e.startsWith(cA)){let t=e.slice(cA.length),n=a.find(e=>e.id===t);n&&o&&o(n);return}let t=c.get(e);t&&(d(),r(t.name),yp(t.name))},t[3]=o,t[4]=c,t[5]=a,t[6]=r,t[7]=d,t[8]=m):m=t[8];let h=m,g=mA,_=ht,v;t[9]===i?v=t[10]:(v=zw(i),t[9]=i,t[10]=v);let y;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,K.jsx)(st,{placeholder:`Select an engine`}),t[11]=y):y=t[11];let b;t[12]===v?b=t[13]:(b=(0,K.jsx)(dA,{...v,children:y}),t[12]=v,t[13]=b);let x=dt,S;t[14]===i?S=t[15]:(S=zw(i),t[14]=i,t[15]=S);let C=pt,w;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,K.jsx)(ot,{children:`Database connections`}),t[16]=w):w=t[16];let T;t[17]!==p||t[18]!==n?(T=p&&(0,K.jsx)(lt,{value:n,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-1 opacity-50`,children:[(0,K.jsx)(Eo,{className:`h-3 w-3`}),(0,K.jsx)(`span`,{className:`truncate`,children:wp(n)})]})},n),t[17]=p,t[18]=n,t[19]=T):T=t[19];let E=g(u),D=u.length>0&&(0,K.jsx)(ft,{}),O=g(l),k;t[20]===a?k=t[21]:(k=a.length>0&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(ft,{}),(0,K.jsx)(ot,{children:`Detected in your environment`}),a.map(hA)]}),t[20]=a,t[21]=k);let A;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,K.jsx)(ft,{}),t[22]=A):A=t[22];let j;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(j=(0,K.jsx)(lt,{className:`text-muted-foreground`,value:sA,children:(0,K.jsxs)(`a`,{className:`flex items-center gap-1`,href:lA,target:`_blank`,rel:`noreferrer`,children:[(0,K.jsx)(Pt,{className:`h-3 w-3`}),(0,K.jsx)(`span`,{children:`How to add a database connection`})]})}),t[23]=j):j=t[23];let ee;t[24]!==C||t[25]!==E||t[26]!==D||t[27]!==O||t[28]!==k||t[29]!==w||t[30]!==T?(ee=(0,K.jsxs)(C,{children:[w,T,E,D,O,k,A,j]}),t[24]=C,t[25]=E,t[26]=D,t[27]=O,t[28]=k,t[29]=w,t[30]=T,t[31]=ee):ee=t[31];let M;t[32]!==x||t[33]!==ee||t[34]!==S?(M=(0,K.jsx)(x,{...S,children:ee}),t[32]=x,t[33]=ee,t[34]=S,t[35]=M):M=t[35];let N;return t[36]!==_||t[37]!==h||t[38]!==n||t[39]!==M||t[40]!==b?(N=(0,K.jsx)(`div`,{className:`flex flex-row gap-1 items-center`,children:(0,K.jsxs)(_,{value:n,onValueChange:h,children:[b,M]})}),t[36]=_,t[37]=h,t[38]=n,t[39]=M,t[40]=b,t[41]=N):N=t[41],N},sA=`__help__`,cA=`__detected_source__:`,lA=`http://docs.marimo.io/guides/working_with_data/sql/#connecting-to-a-custom-database`,uA=()=>{let e=(0,X.c)(16),{sqlMode:t,setSQLMode:n}=QC(),r;e[0]!==n||e[1]!==t?(r=()=>{let e=t===`validate`?`default`:`validate`;e==="default"&&UC(),n(e)},e[0]=n,e[1]=t,e[2]=r):r=e[2];let i=r,a=gA,o=_A,s;e[3]===t?s=e[4]:(s=o(t),e[3]=t,e[4]=s);let c;e[5]===t?c=e[6]:(c=a(t),e[5]=t,e[6]=c);let l=t===`validate`?`Validate`:`Default`,u;e[7]===l?u=e[8]:(u=(0,K.jsx)(`span`,{className:`ml-1`,children:l}),e[7]=l,e[8]=u);let d;e[9]!==i||e[10]!==c||e[11]!==u?(d=(0,K.jsxs)(bt,{variant:`ghost`,size:`sm`,onClick:i,className:`h-5 px-1.5 text-xs border-border shadow-none hover:bg-accent`,children:[c,u]}),e[9]=i,e[10]=c,e[11]=u,e[12]=d):d=e[12];let f;return e[13]!==s||e[14]!==d?(f=(0,K.jsx)(`div`,{className:`flex flex-row gap-1 items-center`,children:(0,K.jsx)(vt,{delayDuration:300,content:s,children:d})}),e[13]=s,e[14]=d,e[15]=f):f=e[15],f},dA=e=>{let t=(0,X.c)(6),n,r;t[0]===e?(n=t[1],r=t[2]):({children:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;return t[3]!==n||t[4]!==r?(i=(0,K.jsx)(mt,{className:`text-xs border-border shadow-none! ring-0! h-5 px-1.5 hover:bg-accent transition-colors`,...r,children:n}),t[3]=n,t[4]=r,t[5]=i):i=t[5],i};function fA(e){return e.source!==`iceberg`}function pA(e){return(0,K.jsx)(lt,{value:e.name,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(Xw,{className:`h-3 w-3`,name:e.dialect}),(0,K.jsx)(`span`,{className:`truncate ml-0.5`,children:wp(e.display_name)})]})},e.name)}function mA(e){return e=e.filter(fA),e.map(pA)}function hA(e){return(0,K.jsx)(lt,{value:`${cA}${e.id}`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(Wo,{className:`h-3 w-3 text-(--blue-9)`}),(0,K.jsxs)(`span`,{className:`truncate ml-0.5`,children:[`Add `,e.displayName,` connection`]})]})},e.id)}function gA(e){return e===`validate`?(0,K.jsx)(Uo,{className:`h-3 w-3`}):(0,K.jsx)(It,{className:`h-3 w-3`})}function _A(e){return e===`validate`?(0,K.jsxs)(`div`,{className:`text-xs`,children:[(0,K.jsxs)(`div`,{className:`font-semibold mb-1 flex flex-row items-center gap-1`,children:[(0,K.jsx)(Uo,{className:`h-3 w-3`}),`Validate Mode`]}),(0,K.jsx)(`p`,{children:`Queries are validated as you write them`})]}):(0,K.jsxs)(`div`,{className:`text-xs`,children:[(0,K.jsxs)(`div`,{className:`font-semibold mb-1 flex flex-row items-center gap-1`,children:[(0,K.jsx)(It,{className:`h-3 w-3`}),`Default Mode`]}),(0,K.jsx)(`p`,{children:`Standard editing`})]})}var vA=()=>{let e=(0,X.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,K.jsx)(`div`,{className:`h-4 border-r border-border`}),e[0]=t):t=e[0],t},yA=e=>{let t=(0,X.c)(102),{view:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r={minWidth:50},t[0]=r):r=t[0];let{spanProps:i,inputProps:a}=Nw(r),o;t[1]===n.state?o=t[2]:(o=n.state.field(SA),t[1]=n.state,t[2]=o);let s=o,c;t[3]===n.state?c=t[4]:(c=n.state.facet(Af),t[3]=n.state,t[4]=c);let l=c,u;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,K.jsx)(`div`,{}),t[5]=u):u=t[5];let d=u,f=!1,p;t[6]===n?p=t[7]:(p=e=>{n.dispatch({effects:Ay.of(e),changes:{from:0,to:n.state.doc.length,insert:n.state.doc.toString()}})},t[6]=n,t[7]=p);let m=p;if(s instanceof iw){let e;t[8]===n.state?e=t[9]:(e=n.state.field(jy),t[8]=n.state,t[9]=e);let r=e;f=!0;let o;t[10]===m?o=t[11]:(o=e=>{let t=kw(e.currentTarget.value,!1);e.currentTarget.value=t,m({dataframeName:t})},t[10]=m,t[11]=o);let s=o,c;t[12]!==m||t[13]!==n?(c=e=>{m({engine:e}),fw(n,e)},t[12]=m,t[13]=n,t[14]=c):c=t[14];let u=c,p;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,K.jsx)(`span`,{className:`select-none`,children:`Output variable: `}),t[15]=p):p=t[15];let h;t[16]===a?h=t[17]:(h=e=>{a.onChange?.(e)},t[16]=a,t[17]=h);let g;t[18]===s?g=t[19]:(g=e=>{e.key===`Enter`&&e.shiftKey&&s(e)},t[18]=s,t[19]=g);let _;t[20]!==a||t[21]!==r.dataframeName||t[22]!==s||t[23]!==h||t[24]!==g?(_=(0,K.jsx)(`input`,{...a,defaultValue:r.dataframeName,onChange:h,onBlur:s,onKeyDown:g,className:`min-w-14 w-auto border border-border rounded px-1 focus-visible:outline-hidden focus-visible:ring-1 focus-visible:ring-ring`}),t[20]=a,t[21]=r.dataframeName,t[22]=s,t[23]=h,t[24]=g,t[25]=_):_=t[25];let v;t[26]===i?v=t[27]:(v=(0,K.jsx)(`span`,{...i}),t[26]=i,t[27]=v);let y;t[28]!==_||t[29]!==v?(y=(0,K.jsxs)(`label`,{className:`flex gap-2 items-center`,children:[p,_,v]}),t[28]=_,t[29]=v,t[30]=y):y=t[30];let b;t[31]!==l||t[32]!==r.engine||t[33]!==u?(b=(0,K.jsx)(iA,{selectedEngine:r.engine,onChange:u,cellId:l}),t[31]=l,t[32]=r.engine,t[33]=u,t[34]=b):b=t[34];let x;t[35]===r.engine?x=t[36]:(x=r.engine===`__marimo_duckdb`&&(0,K.jsx)(uA,{}),t[35]=r.engine,t[36]=x);let S;t[37]!==r.engine||t[38]!==n?(S=async()=>{await fm(n,r.engine)},t[37]=r.engine,t[38]=n,t[39]=S):S=t[39];let C;t[40]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,K.jsx)(Bo,{className:`h-3 w-3`}),t[40]=C):C=t[40];let w;t[41]===S?w=t[42]:(w=(0,K.jsx)(vt,{content:`Format SQL`,children:(0,K.jsx)(bt,{"aria-label":`Format SQL`,variant:`text`,size:`icon`,onClick:S,children:C})}),t[41]=S,t[42]=w);let T;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,K.jsx)(vA,{}),t[43]=T):T=t[43];let E;t[44]===m?E=t[45]:(E=e=>{m({showOutput:!e.target.checked})},t[44]=m,t[45]=E);let D=!r.showOutput,O;t[46]!==E||t[47]!==D?(O=(0,K.jsx)(`input`,{type:`checkbox`,onChange:E,checked:D}),t[46]=E,t[47]=D,t[48]=O):O=t[48];let k;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(k=(0,K.jsx)(`span`,{className:`select-none`,children:`Hide output`}),t[49]=k):k=t[49];let A;t[50]===O?A=t[51]:(A=(0,K.jsxs)(`label`,{className:`flex items-center gap-2`,children:[O,k]}),t[50]=O,t[51]=A);let j;t[52]!==x||t[53]!==w||t[54]!==A?(j=(0,K.jsxs)(`div`,{className:`flex items-center gap-2 ml-auto`,children:[x,w,T,A]}),t[52]=x,t[53]=w,t[54]=A,t[55]=j):j=t[55];let ee;t[56]!==y||t[57]!==b||t[58]!==j?(ee=(0,K.jsxs)(`div`,{className:`flex flex-1 gap-2 items-center`,children:[y,b,j]}),t[56]=y,t[57]=b,t[58]=j,t[59]=ee):ee=t[59],d=ee}if(s instanceof My){f=!0;let e,r,i,a,o,s,c,l,u,p;if(t[60]!==m||t[61]!==n.state){let{quotePrefix:d}=n.state.field(jy);r=d,r===void 0&&(r=`r`,m({quotePrefix:r})),p=(e,t)=>{if(typeof t!=`boolean`)return;let n=Pw({currentQuotePrefix:r,checked:t,prefix:e});m({quotePrefix:n})},a=`flex flex-row w-full justify-end gap-1.5 items-center`,u=`flex items-center gap-1.5`,t[72]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,K.jsx)(`span`,{children:`r`}),t[72]=i):i=t[72],e=Dw,s=`Toggle raw string`,c=`w-3 h-3`,l=r.includes(`r`),o=e=>{p(`r`,e)},t[60]=m,t[61]=n.state,t[62]=e,t[63]=r,t[64]=i,t[65]=a,t[66]=o,t[67]=s,t[68]=c,t[69]=l,t[70]=u,t[71]=p}else e=t[62],r=t[63],i=t[64],a=t[65],o=t[66],s=t[67],c=t[68],l=t[69],u=t[70],p=t[71];let h;t[73]!==e||t[74]!==o||t[75]!==s||t[76]!==c||t[77]!==l?(h=(0,K.jsx)(e,{"aria-label":s,className:c,checked:l,onCheckedChange:o}),t[73]=e,t[74]=o,t[75]=s,t[76]=c,t[77]=l,t[78]=h):h=t[78];let g;t[79]!==i||t[80]!==h||t[81]!==u?(g=(0,K.jsxs)(`div`,{className:u,children:[i,h]}),t[79]=i,t[80]=h,t[81]=u,t[82]=g):g=t[82];let _;t[83]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,K.jsx)(`span`,{children:`f`}),t[83]=_):_=t[83];let v;t[84]===r?v=t[85]:(v=r.includes(`f`),t[84]=r,t[85]=v);let y;t[86]===p?y=t[87]:(y=e=>{p(`f`,e)},t[86]=p,t[87]=y);let b;t[88]!==v||t[89]!==y?(b=(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[_,(0,K.jsx)(Dw,{"aria-label":`Toggle f-string`,className:`w-3 h-3`,checked:v,onCheckedChange:y})]}),t[88]=v,t[89]=y,t[90]=b):b=t[90];let x;t[91]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,K.jsx)(vt,{content:(0,K.jsx)(Fw,{}),children:(0,K.jsx)(Po,{className:`w-3 h-3`})}),t[91]=x):x=t[91];let S;t[92]!==a||t[93]!==g||t[94]!==b?(S=(0,K.jsxs)(`div`,{className:a,children:[g,b,x]}),t[92]=a,t[93]=g,t[94]=b,t[95]=S):S=t[95],d=S}let h;t[96]===f?h=t[97]:(h=f&&(0,K.jsx)(vA,{}),t[96]=f,t[97]=h);let g;return t[98]!==d||t[99]!==s.type||t[100]!==h?(g=(0,K.jsx)(_t,{children:(0,K.jsxs)(`div`,{className:`flex justify-between items-center gap-4 pl-2 pt-2`,children:[d,h,s.type]})}),t[98]=d,t[99]=s.type,t[100]=h,t[101]=g):g=t[101],g},bA=new En,xA=xn.define(),SA=on.define({create(){return Tw.python},update(e,t){for(let e of t.effects)if(e.is(xA))return e.value;return e},provide:e=>bn.from(e,e=>e.type===`python`?null:e=>mm(e,yA))});function CA(){let e=Ew(),t=(n,r)=>{let i=e[r%e.length];return i.isSupported(n)?i:t(n,r+1)};return[dn.of([{key:`F4`,preventDefault:!0,run:n=>{let r=n.state.field(SA),i=e.findIndex(e=>e.type===r.type),a=n.state.doc.toString(),o=t(a,i+1);return r!==o&&(wA({view:n,nextLanguage:o,opts:{keepCodeAsIs:!1}}),!0)}}])]}function wA({view:e,nextLanguage:t,opts:n}){let r=e.state.field(SA),i=e.state.doc.toString(),a=e.state.facet(nf),o=e.state.facet(rf),s=e.state.facet(af),c=e.state.facet(of),l=e.state.facet(sf),u=e.state.field(jy),d=e.state.selection.main.head,f;if(n.keepCodeAsIs)f=i,r.type!==t.type&&(u={...t.defaultMetadata});else{let[e,n]=r.transformOut(i,u),[a,o,s]=t.transformIn(e);d+=n,d-=o,d=wr(d,0,a.length),f=a,u=s}e.dispatch({effects:[xA.of(t),ky.of(u),bA.reconfigure(t.getExtension(c,a,o,s,l)),lf.reconfigure([]),lm.of(!0)],changes:n.keepCodeAsIs?void 0:{from:0,to:e.state.doc.length,insert:f},selection:n.keepCodeAsIs?void 0:On.cursor(d)}),e.dispatch({effects:[lf.reconfigure([ar()])]}),t.type===`sql`&&pw(e)}function TA(e){let{placeholderType:t,completionConfig:n,hotkeys:r,cellId:i,lspConfig:a}=e;return[CA(),bA.of(Tw.python.getExtension(i,n,r,t,a)),SA,jy]}function EA(e){return DA(AA({state:e}).trim())}function DA(e){return e?Tw.markdown.isSupported(e)?Tw.markdown:Tw.sql.isSupported(e)?Tw.sql:Tw.python:Tw.python}function OA(e,t){e.state.field(SA).type!==t.language&&wA({view:e,nextLanguage:Tw[t.language],opts:{keepCodeAsIs:t.keepCodeAsIs??!1}})}function kA(e,{completionConfig:t,hotkeysProvider:n,lspConfig:r}){let i=e.state.field(SA),a=e.state.facet(af),o=e.state.facet(of);return o===void 0&&L.error(`Cell ID is undefined in reconfigureLanguageEffect`),a===void 0&&L.error(`Placeholder type is undefined in reconfigureLanguageEffect`),t===void 0&&L.error(`Completion config is undefined in reconfigureLanguageEffect`),bA.reconfigure(i.getExtension(o,t,n,a,r))}function AA(e,t,n){let r=e.state.field(SA),i=e.state.field(jy),a=e.state.doc.toString();return t===void 0?r.transformOut(a,i)[0]:r.transformOut(a.slice(t,n),i)[0]}function jA(e,t){let n=e.state.field(SA),r=DA(t);r.type!==n.type&&OA(e,{language:r.type,keepCodeAsIs:!0});let[i]=e.state.field(SA).transformIn(t);return ef(e,i),i}function MA(e){let t=e.state.selection.main.head,n=e.state.doc.toString(),r=n.length>0&&n[t-1]===`
|
|
114
114
|
`,i=n.length>0&&n[t]===`
|
|
115
115
|
`,a=r?t-1:t,o=i?t+1:t;return{beforeCursorCode:AA(e,0,a),afterCursorCode:AA(e,o)}}if(typeof document<`u`){let e=`data-temp-href-target`;di.addHook(`beforeSanitizeAttributes`,t=>{t.tagName===`A`&&(t.hasAttribute(`target`)||t.setAttribute(`target`,`_self`),t.hasAttribute(`target`)&&t.setAttribute(e,t.getAttribute(`target`)||``))}),di.addHook(`afterSanitizeAttributes`,t=>{t.tagName===`A`&&t.hasAttribute(e)&&(t.setAttribute(`target`,t.getAttribute(e)||``),t.removeAttribute(e),t.getAttribute(`target`)===`_blank`&&t.setAttribute(`rel`,`noopener noreferrer`))})}function NA(e){let t={USE_PROFILES:{html:!0,svg:!0,mathMl:!0},ADD_TAGS:[`use`],ADD_ATTR:[`href`,`xlink:href`],FORCE_BODY:!0,CUSTOM_ELEMENT_HANDLING:{tagNameCheck:/^(marimo-[A-Za-z][\w-]*|iconify-icon)$/,attributeNameCheck:/^[A-Za-z][\w-]*$/},SAFE_FOR_XML:!e.includes(`marimo-mermaid`)};return di.sanitize(e,t)}var PA=[`marimo-carousel`,`marimo-tabs`,`marimo-accordion`,`marimo-sidebar`],FA=`h1, h2, h3, h4, h5, h6`;function IA(e){if(typeof DOMParser>`u`)return null;let t=[],n=new DOMParser().parseFromString(e,`text/html`).querySelectorAll(FA);for(let e of Array.from(n)){let n=e.textContent;if(PA.some(t=>e.closest(t))||!n)continue;let r=Number.parseInt(e.tagName[1],10),i=e.innerHTML,a={name:n,level:r,by:RA(e)};i!==n&&(a.html=NA(i)),t.push(a)}return{items:t}}function LA(e){if(!e.includes(`"`))return`"${e}"`;if(!e.includes(`'`))return`'${e}'`;let t=e.split(`"`),n=[];for(let[e,r]of t.entries())r&&n.push(`"${r}"`),e<t.length-1&&n.push(`'"'`);return`concat(${n.join(`, `)})`}function RA(e){let t=e.id;if(t)return{id:t};let n=e.textContent??``;return{path:`//${e.tagName}[contains(., ${LA(n)})]`}}function zA(e){return{items:e.filter(Boolean).flatMap(e=>e.items)}}function BA(e){if(e==null||e.mimetype!==`text/html`&&e.mimetype!==`text/markdown`||e.data==null)return null;try{return z(typeof e.data==`string`,`expected string`),IA(e.data)}catch{return L.error(`Failed to parse outline`),null}}function VA(e){return e!=null&&e.items.some(e=>e.level<=3)}function HA(e,t){let n=e=>e.items.length===0?7:Math.min(...e.items.map(e=>e.level)),r=t[e];if(r==null||r.items.length===0)return L.warn(`Failed to find a starting outline`),null;let i=n(r),a=e+1;for(;a<t.length;){let r=t[a];if(r&&n(r)<=i)return[e,a-1];a++}return[e,t.length-1]}var UA=ye(`marimo:rtc:username`,``,Fh),WA=Er(()=>_h(`rtc_v2`));function GA(e){return e!==Mi}var KA=class e{lines=[``];cursor={row:0,col:0};static ESCAPE_REGEX=new RegExp(String.raw`\u001B\[([0-9;]*)([A-DJKH])`,`u`);ensureLine(e){for(;this.lines.length<=e;)this.lines.push(``)}moveCursor(e,t){this.cursor.row=Math.max(0,this.cursor.row+e),this.cursor.col=Math.max(0,this.cursor.col+t),this.ensureLine(this.cursor.row)}setCursor(e,t){this.cursor.row=Math.max(0,e),this.cursor.col=Math.max(0,t),this.ensureLine(this.cursor.row)}writeChar(e){this.ensureLine(this.cursor.row);let t=this.lines[this.cursor.row].padEnd(this.cursor.col,` `);this.lines[this.cursor.row]=t.slice(0,this.cursor.col)+e+t.slice(this.cursor.col+1),this.cursor.col++}writeString(e){if(e.length===0)return;this.ensureLine(this.cursor.row);let t=this.lines[this.cursor.row].padEnd(this.cursor.col,` `);this.lines[this.cursor.row]=t.slice(0,this.cursor.col)+e+t.slice(this.cursor.col+e.length),this.cursor.col+=e.length}control(e){switch(e){case`
|
|
116
116
|
`:this.cursor.row++,this.cursor.col=0,this.ensureLine(this.cursor.row);break;case`\r`:this.cursor.col=0;break;case` `:this.writeChar(` `);break;case`\b`:this.cursor.col=Math.max(0,this.cursor.col-1);break;case`\v`:this.cursor.row++,this.ensureLine(this.cursor.row)}}handleEscape(t){let n=e.ESCAPE_REGEX.exec(t);if(!n){this.writeString(t);return}let r=n[1].split(`;`).map(e=>e===``?1:Number.parseInt(e,10));switch(n[2]){case`A`:this.moveCursor(-r[0],0);break;case`B`:this.moveCursor(r[0],0);break;case`C`:this.moveCursor(0,r[0]);break;case`D`:this.moveCursor(0,-r[0]);break;case`H`:this.setCursor(r[0]-1||0,r[1]-1||0);break;case`J`:r[0]===2&&(this.lines=[``],this.setCursor(0,0));break;case`K`:switch(this.ensureLine(this.cursor.row),r[0]){case 0:this.lines[this.cursor.row]=this.lines[this.cursor.row].slice(0,this.cursor.col);break;case 1:{let e=this.lines[this.cursor.row].length;this.lines[this.cursor.row]=` `.repeat(this.cursor.col)+this.lines[this.cursor.row].slice(this.cursor.col,e);break}case 2:this.lines[this.cursor.row]=``}break;default:this.writeString(t)}}render(){return this.lines.join(`
|
|
117
117
|
`)}},qA=class{ESC_REGEX=new RegExp(String.raw`\u001B(?:\[[0-9;]*[A-Za-z]|\([0-9A-Za-z])`,`gu`);parse(e){let t=[],n=0;for(let r of e.matchAll(this.ESC_REGEX)){let i=r.index??0;i>n&&t.push({type:`text`,value:e.slice(n,i)}),t.push({type:`escape`,value:r[0]}),n=i+r[0].length}return n<e.length&&t.push({type:`text`,value:e.slice(n)}),t}},JA=class{parser=new qA;buffer=new KA;reduce(e){return this.reset(),this.append(e),this.render()}append(e){let t=this.parser.parse(e);if(t.length===1&&t[0].type===`text`){let e=t[0].value;if(!this.hasControlChars(e)){this.buffer.writeString(e);return}}for(let e of t)e.type===`text`?this.processText(e.value):this.buffer.handleEscape(e.value)}reset(){this.buffer=new KA}render(){return this.buffer.render()}hasControlChars(e){for(let t of e)if(t<` `)return!0;return!1}processText(e){let t=0,n=e.length;for(let r=0;r<n;r++){let n=e[r];if(n===`
|
|
118
|
-
`||n===`\r`||n===` `||n===`\b`||n===`\v`){if(r>t){let n=e.slice(t,r),i=this.filterControlChars(n);i.length>0&&this.buffer.writeString(i)}this.buffer.control(n),t=r+1}else if(n<` `){if(r>t){let n=e.slice(t,r);n.length>0&&this.buffer.writeString(n)}t=r+1}}if(t<n){let n=e.slice(t),r=this.filterControlChars(n);r.length>0&&this.buffer.writeString(r)}}filterControlChars(e){let t=!1;for(let n of e)if(n<` `){t=!0;break}if(!t)return e;let n=``;for(let t of e)t>=` `&&(n+=t);return n}},YA=class e{mimetype;channel;timestamp;code;ansiReducer=new JA;_data;get data(){return this._data}static create(t){let n=new JA;return n.append(t.data),new e(t.mimetype,t.channel,t.timestamp,n,t.code)}constructor(e,t,n,r,i){this.mimetype=e,this.channel=t,this.timestamp=n,this.code=i,this.ansiReducer=r,this._data=this.ansiReducer.render()}appendData(t){return this.ansiReducer.append(t),new e(this.mimetype,this.channel,this.timestamp,this.ansiReducer,this.code)}toJSON(){return{mimetype:this.mimetype,channel:this.channel,timestamp:this.timestamp,data:this.data,...this.code===void 0?{}:{code:this.code}}}};function XA(e,t=5e3){let n=[...e];if(n.length<2)return tj(n.map(QA),t);let r=n[n.length-1],i=n[n.length-2];return ZA(r,i)&&(ej(r),ej(i),n[n.length-2]=$A(i,r),n.pop()),tj(n,t)}function ZA(e,t){let n=e.mimetype===`text/plain`&&t.mimetype===`text/plain`;if(!n)return!1;let r=e.channel===t.channel,i=e.channel!==`stdin`;return n&&r&&i}function QA(e){return e instanceof YA?e:typeof e.data==`string`?YA.create(e):e}function $A(e,t){return e instanceof YA?e.appendData(t.data):YA.create(e).appendData(t.data)}function ej(e){z(typeof e.data==`string`,`expected string output`)}function tj(e,t){let n=0,r;for(r=e.length-1;r>=0&&n<t;r--){let t=e[r];t.mimetype===`text/plain`?(z(typeof t.data==`string`,`expected string`),n+=t.data.split(`
|
|
118
|
+
`||n===`\r`||n===` `||n===`\b`||n===`\v`){if(r>t){let n=e.slice(t,r),i=this.filterControlChars(n);i.length>0&&this.buffer.writeString(i)}this.buffer.control(n),t=r+1}else if(n<` `){if(r>t){let n=e.slice(t,r);n.length>0&&this.buffer.writeString(n)}t=r+1}}if(t<n){let n=e.slice(t),r=this.filterControlChars(n);r.length>0&&this.buffer.writeString(r)}}filterControlChars(e){let t=!1;for(let n of e)if(n<` `){t=!0;break}if(!t)return e;let n=``;for(let t of e)t>=` `&&(n+=t);return n}},YA=class e{mimetype;channel;timestamp;code;id;ansiReducer=new JA;_data;get data(){return this._data}static create(t){let n=new JA;return n.append(t.data),new e(t.mimetype,t.channel,t.timestamp,n,t.code,t.id)}constructor(e,t,n,r,i,a){this.mimetype=e,this.channel=t,this.timestamp=n,this.code=i,this.id=a,this.ansiReducer=r,this._data=this.ansiReducer.render()}appendData(t){return this.ansiReducer.append(t),new e(this.mimetype,this.channel,this.timestamp,this.ansiReducer,this.code,this.id)}toJSON(){return{mimetype:this.mimetype,channel:this.channel,timestamp:this.timestamp,data:this.data,...this.code===void 0?{}:{code:this.code}}}};function XA(e,t=5e3){let n=[...e];if(n.length<2)return tj(n.map(QA),t);let r=n[n.length-1],i=n[n.length-2];return ZA(r,i)&&(ej(r),ej(i),n[n.length-2]=$A(i,r),n.pop()),tj(n,t)}function ZA(e,t){let n=e.mimetype===`text/plain`&&t.mimetype===`text/plain`;if(!n)return!1;let r=e.channel===t.channel,i=e.channel!==`stdin`;return n&&r&&i}function QA(e){return e instanceof YA?e:typeof e.data==`string`?YA.create(e):e}function $A(e,t){return e instanceof YA?e.appendData(t.data):YA.create(e).appendData(t.data)}function ej(e){z(typeof e.data==`string`,`expected string output`)}function tj(e,t){let n=0,r;for(r=e.length-1;r>=0&&n<t;r--){let t=e[r];t.mimetype===`text/plain`?(z(typeof t.data==`string`,`expected string`),n+=t.data.split(`
|
|
119
119
|
`).length):n++}if(n<t)return e;let i=r+1,a={channel:`stderr`,mimetype:`text/html`,data:`<pre>Streaming output truncated to last ${t} lines.\n</pre>`,timestamp:-1},o=e[i];if(o==null)return[a,...e.slice(i+1)];if(o.mimetype===`text/plain`){z(typeof o.data==`string`,`expected string`);let r=o.data.split(`
|
|
120
120
|
`),s=t-(n-r.length);return[a,{...o,data:r.slice(-s).join(`
|
|
121
|
-
`)},...e.slice(i+1)]}return[a,...e.slice(i+1)]}function nj(e,t){let n={...e};switch(t.status){case`queued`:n.interrupted=!1,n.errored=!1,n.runElapsedTimeMs=null,n.debuggerActive=!1;break;case`running`:n.interrupted=!1,e.stopped&&(n.output=null),n.status===`queued`&&(n.consoleOutputs=[]),n.stopped=!1,n.runStartTimestamp=t.timestamp,n.lastRunStartTimestamp=t.timestamp;break;case`idle`:e.runStartTimestamp&&(n.runElapsedTimeMs=bv.fromSeconds((t.timestamp??0)-e.runStartTimestamp).toMilliseconds(),n.runStartTimestamp=null,n.staleInputs=!1),!e.lastRunStartTimestamp&&t.timestamp&&(n.lastRunStartTimestamp=t.timestamp),n.debuggerActive=!1;break;case null:break;case`disabled-transitively`:break;case void 0:break;default:Lr(t.status)}n.output=t.output??n.output,n.staleInputs=t.stale_inputs??n.staleInputs,n.status=t.status??n.status,t.serialization!==void 0&&(n.serialization=t.serialization);let r=!1;t.output!=null&&t.output.mimetype===`application/vnd.marimo+error`&&((n.status===`queued`||n.status===`running`)&&(n.status=`idle`),z(Array.isArray(t.output.data),`Expected error output data to be an array`),t.output.data.some(e=>e.type===`interruption`)?(n.interrupted=!0,r=!0):t.output.data.some(e=>e.type.includes(`ancestor`))?n.stopped=!0:n.errored=!0);let i=e.consoleOutputs;(r||t.status===`idle`)&&(n.debuggerActive=!1,i=i.map(e=>e.channel===`stdin`?{channel:e.channel,mimetype:e.mimetype,data:e.data,timestamp:e.timestamp,response:e.response??``}:e));let a=t.console;a!=null&&(i=XA(Array.isArray(a)?a:[...i,a])),n.consoleOutputs=i,n.outline=BA(n.output);let o=[t.console].flat().filter(Boolean).filter(e=>e.channel===`pdb`);return o.length>0&&o.some(e=>e.data===`start`)&&(n.debuggerActive=!0),n}function rj(e){let t={...e};return e.status!==`disabled-transitively`&&(t.status=`queued`),t.interrupted=!1,t.errored=!1,t.runElapsedTimeMs=null,t.debuggerActive=!1,t}function ij(e){return e===`running`||e===`queued`}function aj(e,t){let{status:n,output:r,runStartTimestamp:i,interrupted:a,staleInputs:o}=e;if(a)return!1;if(t)return!0;let s=ij(n),c=n===`running`&&r!==null&&i!==null&&(r.timestamp??0)>i;return s&&!c?!0:o}function oj(e,t){if(!e){L.warn(`getCell: cellId is undefined`);return}let n=t.cellData[e];if(!n){L.warn(`getCell: cell ${e} not found in state`);return}return n}function sj(e,t){let n=t.cellIds.inOrderIds,r=n.indexOf(e);if(r>0)return{after:n[r-1]};if(r===0&&n.length>1)return{before:n[1]}}function cj(e){let t=new Map,n=e.cellIds.getColumns();for(let[e,r]of n.entries())for(let n of r.inOrderIds)t.set(n,e);return t}function lj(e,t){let n=new Set(e.cellIds.inOrderIds),r=[];for(let e of t.cellIds.inOrderIds)if(!n.has(e)){let n=oj(e,t);n&&r.push({type:`create-cell`,cellId:n.id,code:n.code,name:n.name,config:n.config,...sj(n.id,t)})}return r}function uj(e,t){let n=new Set(t.cellIds.inOrderIds),r=[];for(let t of e.cellIds.inOrderIds)n.has(t)||r.push({type:`delete-cell`,cellId:t});return r}function dj(e,t){let n=cj(e),r=cj(t),i=[];for(let[e,a]of r)if(n.get(e)!==a){let n=oj(e,t);i.push({type:`set-config`,cellId:e,column:a,disabled:n?.config.disabled??!1,hideCode:n?.config.hide_code??!1,expandOutput:n?.config.expand_output??!1})}return i.push({type:`reorder-cells`,cellIds:t.cellIds.inOrderIds}),i}function fj(e,t,n){switch(n.type){case`createNewCell`:return lj(e,t);case`deleteCell`:return[{type:`delete-cell`,cellId:n.payload.cellId}];case`moveCell`:case`sendToTop`:case`sendToBottom`:{let{cellId:e}=n.payload;return[{type:`move-cell`,cellId:e,...sj(e,t)}]}case`dropCellOverCell`:case`dropCellOverColumn`:case`moveCellToIndex`:case`moveCellsRelativeTo`:return dj(e,t);case`updateCellCode`:{let e=oj(n.payload.cellId,t);return e?[{type:`set-code`,cellId:e.id,code:e.code}]:[]}case`updateCellName`:{let e=oj(n.payload.cellId,t);return e?[{type:`set-name`,cellId:e.id,name:e.name}]:[]}case`updateCellConfig`:{let{cellId:e}=n.payload,r=oj(e,t);return r?[{type:`set-config`,cellId:e,column:r.config.column??null,disabled:r.config.disabled??!1,hideCode:r.config.hide_code??!1,expandOutput:r.config.expand_output??!1}]:[]}case`dropOverNewColumn`:case`moveColumn`:case`addColumnBreakpoint`:case`deleteColumn`:case`mergeAllColumns`:case`compactColumns`:return dj(e,t);case`addColumn`:return[...lj(e,t),...dj(e,t)];case`undoDeleteCell`:{let n=lj(e,t),r=dj(e,t);return n.length===0?r:r.length>1?[...n,...r]:n}case`splitCell`:{let{cellId:r}=n.payload,i=oj(r,t);return i?[{type:`set-code`,cellId:r,code:i.code},...lj(e,t)]:[]}case`undoSplitCell`:{let{cellId:r}=n.payload,i=oj(r,t);return i?[{type:`set-code`,cellId:r,code:i.code},...uj(e,t)]:[]}case`moveToNextCell`:return lj(e,t);case`addSetupCellIfDoesntExist`:return lj(e,t);case`focusCell`:case`focusTopCell`:case`focusBottomCell`:case`scrollToTarget`:case`showCellIfHidden`:case`markTouched`:case`markUntouched`:return[];case`prepareForRun`:case`handleCellMessage`:case`setCellIds`:case`rebuildCellColumns`:case`setCellCodes`:case`setCells`:case`setStdinResponse`:case`clearSerializedEditorState`:case`clearCellOutput`:case`clearCellConsoleOutput`:case`clearAllCellOutputs`:case`clearLogs`:case`addLogs`:return[];case`foldAll`:case`unfoldAll`:case`collapseCell`:case`expandCell`:case`collapseAllCells`:case`expandAllCells`:return[];default:Rr(n)}}function pj(e){let t=new Set,n=new Set;for(let r of e)r.type===`create-cell`?t.add(r.cellId):r.type===`delete-cell`&&n.add(r.cellId);return t.intersection(n)}function mj(e,t){let n=[];for(let r of e)switch(r.type){case`create-cell`:{let e=`__end__`,t=!1;r.after?(e=r.after,t=!1):r.before&&(e=r.before,t=!0),n.push({type:`createNewCell`,payload:{cellId:e,before:t,code:r.code,newCellId:r.cellId,autoFocus:!1,hideCode:r.config?.hide_code??!1}}),r.name&&n.push({type:`updateCellName`,payload:{cellId:r.cellId,name:r.name}}),(r.config?.disabled!=null||r.config?.column!=null||r.config?.expand_output!=null)&&n.push({type:`updateCellConfig`,payload:{cellId:r.cellId,config:{...r.config.disabled!=null&&{disabled:r.config.disabled},...r.config.column!=null&&{column:r.config.column},...r.config.expand_output!=null&&{expand_output:r.config.expand_output}}}});break}case`delete-cell`:n.push({type:`deleteCell`,payload:{cellId:r.cellId}});break;case`move-cell`:{let e=[...t()],i=r.cellId,a=e.indexOf(i);if(a<0)break;if(e.splice(a,1),r.after){let t=e.indexOf(r.after);t>=0?e.splice(t+1,0,i):e.push(i)}else if(r.before){let t=e.indexOf(r.before);t>=0?e.splice(t,0,i):e.unshift(i)}else e.push(i);n.push({type:`setCellIds`,payload:{cellIds:e}});break}case`reorder-cells`:n.push({type:`setCellIds`,payload:{cellIds:r.cellIds}});break;case`set-code`:n.push({type:`setCellCodes`,payload:{ids:[r.cellId],codes:[r.code],codeIsStale:!0}});break;case`set-name`:n.push({type:`updateCellName`,payload:{cellId:r.cellId,name:r.name}});break;case`set-config`:n.push({type:`updateCellConfig`,payload:{cellId:r.cellId,config:{column:r.column,disabled:r.disabled,hide_code:r.hideCode,expand_output:r.expandOutput}}})}return n}var hj=new Set([`set-code`,`set-name`,`set-config`]),gj=new Set([`set-code`,`set-name`,`set-config`,`move-cell`]);function _j(e){let t=new Set;for(let n of e)n.type===`delete-cell`&&t.add(n.cellId);let n=e.filter(e=>!(gj.has(e.type)&&`cellId`in e&&t.has(e.cellId))),r=new Map;return n.forEach((e,t)=>{hj.has(e.type)&&`cellId`in e&&r.set(`${e.type}:${e.cellId}`,t)}),n.filter((e,t)=>hj.has(e.type)&&`cellId`in e?r.get(`${e.type}:${e.cellId}`)===t:!0)}var vj=[],yj=[],bj=Promise.resolve(),xj=0,Sj=null,Cj={status:`synchronized`};function wj(){if(Cj.status===`failed`)return;let e=_j(vj);vj=[],e.length>0&&yj.push(e)}async function Tj(e){if(e===xj){if(Cj.status===`failed`)throw Cj.error;for(;yj.length>0;){let t=yj[0];try{await Br().sendDocumentTransaction({changes:t})}catch(t){if(e!==xj)return;throw Cj={status:`failed`,error:t},yj=yj.slice(1),t}if(e!==xj)return;yj.shift()}}}function Ej(){let e=xj,t=Sj?.promise??Promise.resolve(),n=Promise.all([bj.catch(()=>void 0),t]).then(()=>Tj(e));return bj=n,n}var Dj=re(()=>{wj(),Ej().catch(()=>void 0)},400);async function Oj(){if(Cj.status===`failed`)throw Cj.error;Dj.cancel(),wj();let e=Ej();for(;;){if(await e,Dj.cancel(),wj(),vj.length===0&&yj.length===0&&bj===e)return;e=bj===e?Ej():bj}}function kj(){if(Cj.status!==`failed`)return null;Dj.cancel();let e=vj,t=yj;return vj=[],yj=[],{failure:Cj,includedChanges:e,includedTransactions:t}}function Aj(e){e!==null&&Cj===e.failure&&(vj=[...e.includedChanges,...vj],yj=[...e.includedTransactions,...yj])}async function jj(e){e!==null&&(await bj.catch(()=>void 0),Cj===e.failure&&(Cj={status:`synchronized`},bj=Promise.resolve(),vj.length>0&&Dj()))}function Mj(e){Sj===e&&(Sj=null),e.resolve()}async function Nj(e){let t=null;try{await Oj()}catch(e){if(t=kj(),t===null)throw e}let n=new ci;Sj=n;try{let r=await e();return Mj(n),await jj(t),r}catch(e){throw Aj(t),Mj(n),e}}function Pj(e){return`cellId`in e&&e.cellId===`__scratch__`}function Fj(e){u.get(me)||Pj(e)||(vj.push(e),Cj.status===`synchronized`&&Dj())}function Ij(e,t,n){for(let r of fj(e,t,n))Fj(r)}function Lj(e,t,n){let r=pj(e),i=[...e.filter(e=>e.type!==`set-config`),...e.filter(e=>e.type===`set-config`)],a=!1,o=null;for(let e of i)if(!(r.size>0&&`cellId`in e&&r.has(e.cellId))){e.type===`set-config`&&(a=!0),e.type===`create-cell`&&e.config?.column!=null&&(a=!0),e.type===`reorder-cells`&&(o=e.cellIds);for(let r of mj([e],n))t[r.type](r.payload)}a&&t.rebuildCellColumns({cellIds:o??n()})}function Rj(e,t){return Ft(e*1e3,t?.in)}var zj=function(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e},Bj;(function(e){e[e.EOS=0]=`EOS`,e[e.Text=1]=`Text`,e[e.Incomplete=2]=`Incomplete`,e[e.ESC=3]=`ESC`,e[e.Unknown=4]=`Unknown`,e[e.SGR=5]=`SGR`,e[e.OSCURL=6]=`OSCURL`})(Bj||={});var Vj=class{constructor(){this.VERSION=`6.0.6`,this.setup_palettes(),this._use_classes=!1,this.bold=!1,this.faint=!1,this.italic=!1,this.underline=!1,this.fg=this.bg=null,this._buffer=``,this._url_allowlist={http:1,https:1},this._escape_html=!0,this.boldStyle=`font-weight:bold`,this.faintStyle=`opacity:0.7`,this.italicStyle=`font-style:italic`,this.underlineStyle=`text-decoration:underline`}set use_classes(e){this._use_classes=e}get use_classes(){return this._use_classes}set url_allowlist(e){this._url_allowlist=e}get url_allowlist(){return this._url_allowlist}set escape_html(e){this._escape_html=e}get escape_html(){return this._escape_html}set boldStyle(e){this._boldStyle=e}get boldStyle(){return this._boldStyle}set faintStyle(e){this._faintStyle=e}get faintStyle(){return this._faintStyle}set italicStyle(e){this._italicStyle=e}get italicStyle(){return this._italicStyle}set underlineStyle(e){this._underlineStyle=e}get underlineStyle(){return this._underlineStyle}setup_palettes(){this.ansi_colors=[[{rgb:[0,0,0],class_name:`ansi-black`},{rgb:[187,0,0],class_name:`ansi-red`},{rgb:[0,187,0],class_name:`ansi-green`},{rgb:[187,187,0],class_name:`ansi-yellow`},{rgb:[0,0,187],class_name:`ansi-blue`},{rgb:[187,0,187],class_name:`ansi-magenta`},{rgb:[0,187,187],class_name:`ansi-cyan`},{rgb:[255,255,255],class_name:`ansi-white`}],[{rgb:[85,85,85],class_name:`ansi-bright-black`},{rgb:[255,85,85],class_name:`ansi-bright-red`},{rgb:[0,255,0],class_name:`ansi-bright-green`},{rgb:[255,255,85],class_name:`ansi-bright-yellow`},{rgb:[85,85,255],class_name:`ansi-bright-blue`},{rgb:[255,85,255],class_name:`ansi-bright-magenta`},{rgb:[85,255,255],class_name:`ansi-bright-cyan`},{rgb:[255,255,255],class_name:`ansi-bright-white`}]],this.palette_256=[],this.ansi_colors.forEach(e=>{e.forEach(e=>{this.palette_256.push(e)})});let e=[0,95,135,175,215,255];for(let t=0;t<6;++t)for(let n=0;n<6;++n)for(let r=0;r<6;++r){let i={rgb:[e[t],e[n],e[r]],class_name:`truecolor`};this.palette_256.push(i)}let t=8;for(let e=0;e<24;++e,t+=10){let e={rgb:[t,t,t],class_name:`truecolor`};this.palette_256.push(e)}}escape_txt_for_html(e){return this._escape_html?e.replace(/[&<>"']/gm,e=>{if(e===`&`)return`&`;if(e===`<`)return`<`;if(e===`>`)return`>`;if(e===`"`)return`"`;if(e===`'`)return`'`}):e}append_buffer(e){var t=this._buffer+e;this._buffer=t}get_next_packet(){var e={kind:Bj.EOS,text:``,url:``},t=this._buffer.length;if(t==0)return e;var n=this._buffer.indexOf(`\x1B`);if(n==-1)return e.kind=Bj.Text,e.text=this._buffer,this._buffer=``,e;if(n>0)return e.kind=Bj.Text,e.text=this._buffer.slice(0,n),this._buffer=this._buffer.slice(n),e;if(n==0){if(t<3)return e.kind=Bj.Incomplete,e;var r=this._buffer.charAt(1);if(r!=`[`&&r!=`]`&&r!=`(`)return e.kind=Bj.ESC,e.text=this._buffer.slice(0,1),this._buffer=this._buffer.slice(1),e;if(r==`[`){this._csi_regex||=Hj(Wj||=zj([`
|
|
121
|
+
`)},...e.slice(i+1)]}return[a,...e.slice(i+1)]}function nj(e){return(e.at(-1)?.id??0)+1}function rj(e,t){let n={...e};switch(t.status){case`queued`:n.interrupted=!1,n.errored=!1,n.runElapsedTimeMs=null,n.debuggerActive=!1;break;case`running`:n.interrupted=!1,e.stopped&&(n.output=null),n.status===`queued`&&(n.consoleOutputs=[]),n.stopped=!1,n.runStartTimestamp=t.timestamp,n.lastRunStartTimestamp=t.timestamp;break;case`idle`:e.runStartTimestamp&&(n.runElapsedTimeMs=bv.fromSeconds((t.timestamp??0)-e.runStartTimestamp).toMilliseconds(),n.runStartTimestamp=null,n.staleInputs=!1),!e.lastRunStartTimestamp&&t.timestamp&&(n.lastRunStartTimestamp=t.timestamp),n.debuggerActive=!1;break;case null:break;case`disabled-transitively`:break;case void 0:break;default:Lr(t.status)}n.output=t.output??n.output,n.staleInputs=t.stale_inputs??n.staleInputs,n.status=t.status??n.status,t.serialization!==void 0&&(n.serialization=t.serialization);let r=!1;t.output!=null&&t.output.mimetype===`application/vnd.marimo+error`&&((n.status===`queued`||n.status===`running`)&&(n.status=`idle`),z(Array.isArray(t.output.data),`Expected error output data to be an array`),t.output.data.some(e=>e.type===`interruption`)?(n.interrupted=!0,r=!0):t.output.data.some(e=>e.type.includes(`ancestor`))?n.stopped=!0:n.errored=!0);let i=e.consoleOutputs;(r||t.status===`idle`)&&(n.debuggerActive=!1,i=i.map(e=>e.channel===`stdin`?{channel:e.channel,mimetype:e.mimetype,data:e.data,timestamp:e.timestamp,id:e.id,response:e.response??``}:e));let a=t.console;a!=null&&(i=XA(Array.isArray(a)?a.map((e,t)=>({...e,id:t+1})):[...i,{...a,id:nj(i)}])),n.consoleOutputs=i,n.outline=BA(n.output);let o=[t.console].flat().filter(Boolean).filter(e=>e.channel===`pdb`);return o.length>0&&o.some(e=>e.data===`start`)&&(n.debuggerActive=!0),n}function ij(e){let t={...e};return e.status!==`disabled-transitively`&&(t.status=`queued`),t.interrupted=!1,t.errored=!1,t.runElapsedTimeMs=null,t.debuggerActive=!1,t}function aj(e){return e===`running`||e===`queued`}function oj(e,t){let{status:n,output:r,runStartTimestamp:i,interrupted:a,staleInputs:o}=e;if(a)return!1;if(t)return!0;let s=aj(n),c=n===`running`&&r!==null&&i!==null&&(r.timestamp??0)>i;return s&&!c?!0:o}function sj(e,t){if(!e){L.warn(`getCell: cellId is undefined`);return}let n=t.cellData[e];if(!n){L.warn(`getCell: cell ${e} not found in state`);return}return n}function cj(e,t){let n=t.cellIds.inOrderIds,r=n.indexOf(e);if(r>0)return{after:n[r-1]};if(r===0&&n.length>1)return{before:n[1]}}function lj(e){let t=new Map,n=e.cellIds.getColumns();for(let[e,r]of n.entries())for(let n of r.inOrderIds)t.set(n,e);return t}function uj(e,t){let n=new Set(e.cellIds.inOrderIds),r=[];for(let e of t.cellIds.inOrderIds)if(!n.has(e)){let n=sj(e,t);n&&r.push({type:`create-cell`,cellId:n.id,code:n.code,name:n.name,config:n.config,...cj(n.id,t)})}return r}function dj(e,t){let n=new Set(t.cellIds.inOrderIds),r=[];for(let t of e.cellIds.inOrderIds)n.has(t)||r.push({type:`delete-cell`,cellId:t});return r}function fj(e,t){let n=lj(e),r=lj(t),i=[];for(let[e,a]of r)if(n.get(e)!==a){let n=sj(e,t);i.push({type:`set-config`,cellId:e,column:a,disabled:n?.config.disabled??!1,hideCode:n?.config.hide_code??!1,expandOutput:n?.config.expand_output??!1})}return i.push({type:`reorder-cells`,cellIds:t.cellIds.inOrderIds}),i}function pj(e,t,n){switch(n.type){case`createNewCell`:return uj(e,t);case`deleteCell`:return[{type:`delete-cell`,cellId:n.payload.cellId}];case`moveCell`:case`sendToTop`:case`sendToBottom`:{let{cellId:e}=n.payload;return[{type:`move-cell`,cellId:e,...cj(e,t)}]}case`dropCellOverCell`:case`dropCellOverColumn`:case`moveCellToIndex`:case`moveCellsRelativeTo`:return fj(e,t);case`updateCellCode`:{let e=sj(n.payload.cellId,t);return e?[{type:`set-code`,cellId:e.id,code:e.code}]:[]}case`updateCellName`:{let e=sj(n.payload.cellId,t);return e?[{type:`set-name`,cellId:e.id,name:e.name}]:[]}case`updateCellConfig`:{let{cellId:e}=n.payload,r=sj(e,t);return r?[{type:`set-config`,cellId:e,column:r.config.column??null,disabled:r.config.disabled??!1,hideCode:r.config.hide_code??!1,expandOutput:r.config.expand_output??!1}]:[]}case`dropOverNewColumn`:case`moveColumn`:case`addColumnBreakpoint`:case`deleteColumn`:case`mergeAllColumns`:case`compactColumns`:return fj(e,t);case`addColumn`:return[...uj(e,t),...fj(e,t)];case`undoDeleteCell`:{let n=uj(e,t),r=fj(e,t);return n.length===0?r:r.length>1?[...n,...r]:n}case`splitCell`:{let{cellId:r}=n.payload,i=sj(r,t);return i?[{type:`set-code`,cellId:r,code:i.code},...uj(e,t)]:[]}case`undoSplitCell`:{let{cellId:r}=n.payload,i=sj(r,t);return i?[{type:`set-code`,cellId:r,code:i.code},...dj(e,t)]:[]}case`moveToNextCell`:return uj(e,t);case`addSetupCellIfDoesntExist`:return uj(e,t);case`focusCell`:case`focusTopCell`:case`focusBottomCell`:case`scrollToTarget`:case`showCellIfHidden`:case`markTouched`:case`markUntouched`:return[];case`prepareForRun`:case`handleCellMessage`:case`setCellIds`:case`rebuildCellColumns`:case`setCellCodes`:case`setCells`:case`setStdinResponse`:case`clearSerializedEditorState`:case`clearCellOutput`:case`clearCellConsoleOutput`:case`clearAllCellOutputs`:case`clearLogs`:case`addLogs`:return[];case`foldAll`:case`unfoldAll`:case`collapseCell`:case`expandCell`:case`collapseAllCells`:case`expandAllCells`:return[];default:Rr(n)}}function mj(e){let t=new Set,n=new Set;for(let r of e)r.type===`create-cell`?t.add(r.cellId):r.type===`delete-cell`&&n.add(r.cellId);return t.intersection(n)}function hj(e,t){let n=[];for(let r of e)switch(r.type){case`create-cell`:{let e=`__end__`,t=!1;r.after?(e=r.after,t=!1):r.before&&(e=r.before,t=!0),n.push({type:`createNewCell`,payload:{cellId:e,before:t,code:r.code,newCellId:r.cellId,autoFocus:!1,hideCode:r.config?.hide_code??!1}}),r.name&&n.push({type:`updateCellName`,payload:{cellId:r.cellId,name:r.name}}),(r.config?.disabled!=null||r.config?.column!=null||r.config?.expand_output!=null)&&n.push({type:`updateCellConfig`,payload:{cellId:r.cellId,config:{...r.config.disabled!=null&&{disabled:r.config.disabled},...r.config.column!=null&&{column:r.config.column},...r.config.expand_output!=null&&{expand_output:r.config.expand_output}}}});break}case`delete-cell`:n.push({type:`deleteCell`,payload:{cellId:r.cellId}});break;case`move-cell`:{let e=[...t()],i=r.cellId,a=e.indexOf(i);if(a<0)break;if(e.splice(a,1),r.after){let t=e.indexOf(r.after);t>=0?e.splice(t+1,0,i):e.push(i)}else if(r.before){let t=e.indexOf(r.before);t>=0?e.splice(t,0,i):e.unshift(i)}else e.push(i);n.push({type:`setCellIds`,payload:{cellIds:e}});break}case`reorder-cells`:n.push({type:`setCellIds`,payload:{cellIds:r.cellIds}});break;case`set-code`:n.push({type:`setCellCodes`,payload:{ids:[r.cellId],codes:[r.code],codeIsStale:!0}});break;case`set-name`:n.push({type:`updateCellName`,payload:{cellId:r.cellId,name:r.name}});break;case`set-config`:n.push({type:`updateCellConfig`,payload:{cellId:r.cellId,config:{column:r.column,disabled:r.disabled,hide_code:r.hideCode,expand_output:r.expandOutput}}})}return n}var gj=new Set([`set-code`,`set-name`,`set-config`]),_j=new Set([`set-code`,`set-name`,`set-config`,`move-cell`]);function vj(e){let t=new Set;for(let n of e)n.type===`delete-cell`&&t.add(n.cellId);let n=e.filter(e=>!(_j.has(e.type)&&`cellId`in e&&t.has(e.cellId))),r=new Map;return n.forEach((e,t)=>{gj.has(e.type)&&`cellId`in e&&r.set(`${e.type}:${e.cellId}`,t)}),n.filter((e,t)=>gj.has(e.type)&&`cellId`in e?r.get(`${e.type}:${e.cellId}`)===t:!0)}var yj=[],bj=[],xj=Promise.resolve(),Sj=0,Cj=null,wj={status:`synchronized`};function Tj(){if(wj.status===`failed`)return;let e=vj(yj);yj=[],e.length>0&&bj.push(e)}async function Ej(e){if(e===Sj){if(wj.status===`failed`)throw wj.error;for(;bj.length>0;){let t=bj[0];try{await Br().sendDocumentTransaction({changes:t})}catch(t){if(e!==Sj)return;throw wj={status:`failed`,error:t},bj=bj.slice(1),t}if(e!==Sj)return;bj.shift()}}}function Dj(){let e=Sj,t=Cj?.promise??Promise.resolve(),n=Promise.all([xj.catch(()=>void 0),t]).then(()=>Ej(e));return xj=n,n}var Oj=re(()=>{Tj(),Dj().catch(()=>void 0)},400);async function kj(){if(wj.status===`failed`)throw wj.error;Oj.cancel(),Tj();let e=Dj();for(;;){if(await e,Oj.cancel(),Tj(),yj.length===0&&bj.length===0&&xj===e)return;e=xj===e?Dj():xj}}function Aj(){if(wj.status!==`failed`)return null;Oj.cancel();let e=yj,t=bj;return yj=[],bj=[],{failure:wj,includedChanges:e,includedTransactions:t}}function jj(e){e!==null&&wj===e.failure&&(yj=[...e.includedChanges,...yj],bj=[...e.includedTransactions,...bj])}async function Mj(e){e!==null&&(await xj.catch(()=>void 0),wj===e.failure&&(wj={status:`synchronized`},xj=Promise.resolve(),yj.length>0&&Oj()))}function Nj(e){Cj===e&&(Cj=null),e.resolve()}async function Pj(e){let t=null;try{await kj()}catch(e){if(t=Aj(),t===null)throw e}let n=new ci;Cj=n;try{let r=await e();return Nj(n),await Mj(t),r}catch(e){throw jj(t),Nj(n),e}}function Fj(e){return`cellId`in e&&e.cellId===`__scratch__`}function Ij(e){u.get(me)||Fj(e)||(yj.push(e),wj.status===`synchronized`&&Oj())}function Lj(e,t,n){for(let r of pj(e,t,n))Ij(r)}function Rj(e,t,n){let r=mj(e),i=[...e.filter(e=>e.type!==`set-config`),...e.filter(e=>e.type===`set-config`)],a=!1,o=null;for(let e of i)if(!(r.size>0&&`cellId`in e&&r.has(e.cellId))){e.type===`set-config`&&(a=!0),e.type===`create-cell`&&e.config?.column!=null&&(a=!0),e.type===`reorder-cells`&&(o=e.cellIds);for(let r of hj([e],n))t[r.type](r.payload)}a&&t.rebuildCellColumns({cellIds:o??n()})}function zj(e,t){return Ft(e*1e3,t?.in)}var Bj=function(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e},Vj;(function(e){e[e.EOS=0]=`EOS`,e[e.Text=1]=`Text`,e[e.Incomplete=2]=`Incomplete`,e[e.ESC=3]=`ESC`,e[e.Unknown=4]=`Unknown`,e[e.SGR=5]=`SGR`,e[e.OSCURL=6]=`OSCURL`})(Vj||={});var Hj=class{constructor(){this.VERSION=`6.0.6`,this.setup_palettes(),this._use_classes=!1,this.bold=!1,this.faint=!1,this.italic=!1,this.underline=!1,this.fg=this.bg=null,this._buffer=``,this._url_allowlist={http:1,https:1},this._escape_html=!0,this.boldStyle=`font-weight:bold`,this.faintStyle=`opacity:0.7`,this.italicStyle=`font-style:italic`,this.underlineStyle=`text-decoration:underline`}set use_classes(e){this._use_classes=e}get use_classes(){return this._use_classes}set url_allowlist(e){this._url_allowlist=e}get url_allowlist(){return this._url_allowlist}set escape_html(e){this._escape_html=e}get escape_html(){return this._escape_html}set boldStyle(e){this._boldStyle=e}get boldStyle(){return this._boldStyle}set faintStyle(e){this._faintStyle=e}get faintStyle(){return this._faintStyle}set italicStyle(e){this._italicStyle=e}get italicStyle(){return this._italicStyle}set underlineStyle(e){this._underlineStyle=e}get underlineStyle(){return this._underlineStyle}setup_palettes(){this.ansi_colors=[[{rgb:[0,0,0],class_name:`ansi-black`},{rgb:[187,0,0],class_name:`ansi-red`},{rgb:[0,187,0],class_name:`ansi-green`},{rgb:[187,187,0],class_name:`ansi-yellow`},{rgb:[0,0,187],class_name:`ansi-blue`},{rgb:[187,0,187],class_name:`ansi-magenta`},{rgb:[0,187,187],class_name:`ansi-cyan`},{rgb:[255,255,255],class_name:`ansi-white`}],[{rgb:[85,85,85],class_name:`ansi-bright-black`},{rgb:[255,85,85],class_name:`ansi-bright-red`},{rgb:[0,255,0],class_name:`ansi-bright-green`},{rgb:[255,255,85],class_name:`ansi-bright-yellow`},{rgb:[85,85,255],class_name:`ansi-bright-blue`},{rgb:[255,85,255],class_name:`ansi-bright-magenta`},{rgb:[85,255,255],class_name:`ansi-bright-cyan`},{rgb:[255,255,255],class_name:`ansi-bright-white`}]],this.palette_256=[],this.ansi_colors.forEach(e=>{e.forEach(e=>{this.palette_256.push(e)})});let e=[0,95,135,175,215,255];for(let t=0;t<6;++t)for(let n=0;n<6;++n)for(let r=0;r<6;++r){let i={rgb:[e[t],e[n],e[r]],class_name:`truecolor`};this.palette_256.push(i)}let t=8;for(let e=0;e<24;++e,t+=10){let e={rgb:[t,t,t],class_name:`truecolor`};this.palette_256.push(e)}}escape_txt_for_html(e){return this._escape_html?e.replace(/[&<>"']/gm,e=>{if(e===`&`)return`&`;if(e===`<`)return`<`;if(e===`>`)return`>`;if(e===`"`)return`"`;if(e===`'`)return`'`}):e}append_buffer(e){var t=this._buffer+e;this._buffer=t}get_next_packet(){var e={kind:Vj.EOS,text:``,url:``},t=this._buffer.length;if(t==0)return e;var n=this._buffer.indexOf(`\x1B`);if(n==-1)return e.kind=Vj.Text,e.text=this._buffer,this._buffer=``,e;if(n>0)return e.kind=Vj.Text,e.text=this._buffer.slice(0,n),this._buffer=this._buffer.slice(n),e;if(n==0){if(t<3)return e.kind=Vj.Incomplete,e;var r=this._buffer.charAt(1);if(r!=`[`&&r!=`]`&&r!=`(`)return e.kind=Vj.ESC,e.text=this._buffer.slice(0,1),this._buffer=this._buffer.slice(1),e;if(r==`[`){this._csi_regex||=Uj(Gj||=Bj([`
|
|
122
122
|
^ # beginning of line
|
|
123
123
|
#
|
|
124
124
|
# First attempt
|
|
@@ -152,7 +152,7 @@ mark line col
|
|
|
152
152
|
[\\x20-\\x7e]* # anything legal
|
|
153
153
|
([\\x00-\\x1f:]) # anything illegal
|
|
154
154
|
)
|
|
155
|
-
`]));let t=this._buffer.match(this._csi_regex);if(t===null)return e.kind=
|
|
155
|
+
`]));let t=this._buffer.match(this._csi_regex);if(t===null)return e.kind=Vj.Incomplete,e;if(t[4])return e.kind=Vj.ESC,e.text=this._buffer.slice(0,1),this._buffer=this._buffer.slice(1),e;e.kind=t[1]!=``||t[3]!=`m`?Vj.Unknown:Vj.SGR,e.text=t[2];var i=t[0].length;return this._buffer=this._buffer.slice(i),e}if(r==`]`){if(t<4)return e.kind=Vj.Incomplete,e;if(this._buffer.charAt(2)!=`8`||this._buffer.charAt(3)!=`;`)return e.kind=Vj.ESC,e.text=this._buffer.slice(0,1),this._buffer=this._buffer.slice(1),e;this._osc_st||=Wj(Kj||=Bj([`
|
|
156
156
|
(?: # legal sequence
|
|
157
157
|
(\x1B\\) # ESC | # alternate
|
|
158
158
|
(\x07) # BEL (what xterm did)
|
|
@@ -179,7 +179,7 @@ mark line col
|
|
|
179
179
|
| # alternate
|
|
180
180
|
[\\x1c-\\x1f] # anything illegal
|
|
181
181
|
)
|
|
182
|
-
`])),this._osc_st.lastIndex=0;{let t=this._osc_st.exec(this._buffer);if(t===null)return e.kind=
|
|
182
|
+
`])),this._osc_st.lastIndex=0;{let t=this._osc_st.exec(this._buffer);if(t===null)return e.kind=Vj.Incomplete,e;if(t[3])return e.kind=Vj.ESC,e.text=this._buffer.slice(0,1),this._buffer=this._buffer.slice(1),e}{let t=this._osc_st.exec(this._buffer);if(t===null)return e.kind=Vj.Incomplete,e;if(t[3])return e.kind=Vj.ESC,e.text=this._buffer.slice(0,1),this._buffer=this._buffer.slice(1),e}this._osc_regex||=Uj(qj||=Bj([`
|
|
183
183
|
^ # beginning of line
|
|
184
184
|
#
|
|
185
185
|
\x1B]8; # OSC Hyperlink
|
|
@@ -215,6 +215,6 @@ mark line col
|
|
|
215
215
|
| # alternate
|
|
216
216
|
(?:\\x07) # BEL (what xterm did)
|
|
217
217
|
)
|
|
218
|
-
`]));let n=this._buffer.match(this._osc_regex);if(n===null)return e.kind=
|
|
218
|
+
`]));let n=this._buffer.match(this._osc_regex);if(n===null)return e.kind=Vj.ESC,e.text=this._buffer.slice(0,1),this._buffer=this._buffer.slice(1),e;e.kind=Vj.OSCURL,e.url=n[1],e.text=n[2];var i=n[0].length;return this._buffer=this._buffer.slice(i),e}if(r==`(`)return e.kind=Vj.Unknown,this._buffer=this._buffer.slice(3),e}}ansi_to_html(e){this.append_buffer(e);for(var t=[];;){var n=this.get_next_packet();if(n.kind==Vj.EOS||n.kind==Vj.Incomplete)break;n.kind!=Vj.ESC&&n.kind!=Vj.Unknown&&(n.kind==Vj.Text?t.push(this.transform_to_html(this.with_state(n))):n.kind==Vj.SGR?this.process_ansi(n):n.kind==Vj.OSCURL&&t.push(this.process_hyperlink(n)))}return t.join(``)}with_state(e){return{bold:this.bold,faint:this.faint,italic:this.italic,underline:this.underline,fg:this.fg,bg:this.bg,text:e.text}}process_ansi(e){let t=e.text.split(`;`);for(;t.length>0;){let e=t.shift(),n=parseInt(e,10);if(isNaN(n)||n===0)this.fg=null,this.bg=null,this.bold=!1,this.faint=!1,this.italic=!1,this.underline=!1;else if(n===1)this.bold=!0;else if(n===2)this.faint=!0;else if(n===3)this.italic=!0;else if(n===4)this.underline=!0;else if(n===21)this.bold=!1;else if(n===22)this.faint=!1,this.bold=!1;else if(n===23)this.italic=!1;else if(n===24)this.underline=!1;else if(n===39)this.fg=null;else if(n===49)this.bg=null;else if(n>=30&&n<38)this.fg=this.ansi_colors[0][n-30];else if(n>=40&&n<48)this.bg=this.ansi_colors[0][n-40];else if(n>=90&&n<98)this.fg=this.ansi_colors[1][n-90];else if(n>=100&&n<108)this.bg=this.ansi_colors[1][n-100];else if((n===38||n===48)&&t.length>0){let e=n===38,r=t.shift();if(r===`5`&&t.length>0){let n=parseInt(t.shift(),10);n>=0&&n<=255&&(e?this.fg=this.palette_256[n]:this.bg=this.palette_256[n])}if(r===`2`&&t.length>2){let n=parseInt(t.shift(),10),r=parseInt(t.shift(),10),i=parseInt(t.shift(),10);if(n>=0&&n<=255&&r>=0&&r<=255&&i>=0&&i<=255){let t={rgb:[n,r,i],class_name:`truecolor`};e?this.fg=t:this.bg=t}}}}}transform_to_html(e){let t=e.text;if(t.length===0||(t=this.escape_txt_for_html(t),!e.bold&&!e.italic&&!e.faint&&!e.underline&&e.fg===null&&e.bg===null))return t;let n=[],r=[],i=e.fg,a=e.bg;e.bold&&n.push(this._boldStyle),e.faint&&n.push(this._faintStyle),e.italic&&n.push(this._italicStyle),e.underline&&n.push(this._underlineStyle),this._use_classes?(i&&(i.class_name===`truecolor`?n.push(`color:rgb(${i.rgb.join(`,`)})`):r.push(`${i.class_name}-fg`)),a&&(a.class_name===`truecolor`?n.push(`background-color:rgb(${a.rgb.join(`,`)})`):r.push(`${a.class_name}-bg`))):(i&&n.push(`color:rgb(${i.rgb.join(`,`)})`),a&&n.push(`background-color:rgb(${a.rgb})`));let o=``,s=``;return r.length&&(o=` class="${r.join(` `)}"`),n.length&&(s=` style="${n.join(`;`)}"`),`<span${s}${o}>${t}</span>`}process_hyperlink(e){let t=e.url.split(`:`);return t.length<1||!this._url_allowlist[t[0]]?``:`<a href="${this.escape_txt_for_html(e.url)}">${this.escape_txt_for_html(e.text)}</a>`}};function Uj(e,...t){let n=e.raw[0].replace(/^\s+|\s+\n|\s*#[\s\S]*?\n|\n/gm,``);return new RegExp(n)}function Wj(e,...t){let n=e.raw[0].replace(/^\s+|\s+\n|\s*#[\s\S]*?\n|\n/gm,``);return new RegExp(n,`g`)}var Gj,Kj,qj,Jj=new Hj;function Yj(e){try{let t=document.createElement(`div`);return t.innerHTML=e,(t.textContent||t.innerText||``).split(`
|
|
219
219
|
`).map(e=>e.trimEnd()).join(`
|
|
220
|
-
`)}catch(t){return L.error(`Error parsing HTML content:`,t),e}}function Yj(e){if(!e)return``;try{return Jj(qj.ansi_to_html(e))}catch(t){return L.error(`Error converting ANSI to plain text:`,t),e}}var Xj=o(null);function Zj(e){return e.type===`cell`?e.cellId:`lsp:${e.name}`}var Qj=!1;function $j(e){let t=[],n=[e.console].filter(Boolean).flat();for(let r of n){let n=r.mimetype===`text/plain`,i=r.mimetype===`text/html`||r.mimetype===`application/vnd.marimo+traceback`;if(n||i){let n=r.channel===`stderr`||r.channel===`marimo-error`;switch(r.channel){case`stdout`:case`stderr`:case`marimo-error`:{let a=zr.asString(r.data),o=i?Jj(a):a;t.push({timestamp:r.timestamp||Date.now(),level:n?`stderr`:`stdout`,message:o,source:{type:`cell`,cellId:e.cell_id}});break}}}}if(t.forEach(eM.log),n.length===0&&ff(e.output?.mimetype)&&Array.isArray(e.output.data)){e.output.data.forEach(t=>{eM.log({level:`stderr`,source:{type:`cell`,cellId:e.cell_id},timestamp:e.timestamp??0,message:JSON.stringify(t)})});let t=e.output.data.filter(e=>`type`in e&&e.type===`exception`||e.type===`internal`),n=u.get(pe)===`read`;if(t.length>0&&!Qj&&n){Qj=!0;let e=t.find(e=>e.traceback);an(e?{title:`An internal error occurred`,description:e.msg||`Click 'View' to see traceback`,variant:`danger`,action:G.createElement(gt,{altText:`View traceback`,onClick:()=>{u.set(Xj,{traceback:e.traceback,errorMessage:e.msg||`An internal error occurred`})}},`View`)}:{title:`An internal error occurred`,description:`See console for details.`,variant:`danger`})}}return t}var eM={log:e=>{let t=e.level===`stdout`?`gray`:e.level===`stderr`?`red`:`orange`,n=e.level.toUpperCase();console.log(`%c[${n}]`,`color:${t}; padding:2px 0; border-radius:2px; font-weight:bold`,`[${tM(e.timestamp)}]`,`(${Zj(e.source)}) ${e.message}`)}};function tM(e){try{return Rj(e).toLocaleTimeString(void 0,{hour12:!0,hour:`numeric`,minute:`numeric`,second:`numeric`})}catch{return``}}function nM(e,t){let n=dN(t);n?n.focus():L.warn(`[CellFocusManager] focusCellEditor: element not found: ${t}`)}function rM(e){let t=document.getElementById(Fi.create(e));t?oM(t):L.warn(`[CellFocusManager] focusCell: element not found: ${e}`)}function iM(e){requestAnimationFrame(()=>{requestAnimationFrame(e)})}function aM(){return document.activeElement instanceof HTMLElement&&document.activeElement.classList.contains(`marimo-cell`)}function oM(e){try{e.focus()}catch{L.warn(`[CellFocusManager] element may not be focusable`,e)}}function sM(e,t){let{retries:n,delay:r,initialDelay:i=0}=t,a=0,o=()=>{if(a<n){try{if(e())return}catch(e){L.error(`Error executing function on attempt ${a+1}, retrying`,{error:e})}a++,setTimeout(o,r)}};i>0?setTimeout(o,i):o()}function cM({cellId:e,cell:t,isCodeHidden:n,codeFocus:r,variableName:i}){if(!t)return;let a=document.getElementById(Fi.create(e));if(!a){L.warn(`scrollCellIntoView: element not found`);return}if(aM()){oM(a);return}if(n)oM(a);else{Ws.promote(e);let n=t.current?.editorView;if(!n){L.warn(`scrollCellIntoView: editor not found`,e);return}if(n.hasFocus||!document.hasFocus())return;if(sM(()=>(n.focus(),n.hasFocus),{retries:5,delay:20}),r===`top`)n.dispatch({selection:{anchor:0,head:0}});else if(r===`bottom`){let e=n.state.doc.line(n.state.doc.lines);n.dispatch({selection:{anchor:e.from,head:e.from}})}else i&&V_(n,i)}a.scrollIntoView({behavior:`smooth`,block:`nearest`})}function lM(e){let t=document.getElementById(Fi.create(e));if(!t){L.warn(`scrollCellIntoView: element not found`);return}t.classList.add(`focus-outline`),setTimeout(()=>{t.classList.remove(`focus-outline`)},2e3),t.scrollIntoView({behavior:`smooth`,block:`center`})}function uM(){let e=document.getElementById(`App`);e?.scrollTo({top:e.scrollHeight,behavior:`smooth`})}function dM(){document.getElementById(`App`)?.scrollTo({top:0,behavior:`smooth`})}function fM(e){let t=dN(e);if(t?.hasFocus){Eh(t,{behavior:`instant`});return}let n=document.getElementById(Fi.create(e));n?n.scrollIntoView({behavior:`instant`,block:`nearest`}):L.warn(`[CellFocusManager] scrollCellIntoView: element not found: ${e}`)}function pM({id:e,name:t=`_`,code:n=``,lastCodeRun:r=null,lastExecutionTime:i=null,edited:a=!1,config:o,serializedEditorState:s=null}){return{id:e,config:o||{hide_code:!1,disabled:!1,column:null,expand_output:!1},name:t,code:n,edited:a,lastCodeRun:r,lastExecutionTime:i,serializedEditorState:s}}function mM(e){return{hide_code:!1,disabled:!1,column:null,expand_output:!1,...e}}function hM(e){return{outline:null,output:null,consoleOutputs:[],status:`idle`,staleInputs:!1,interrupted:!1,errored:!1,stopped:!1,runElapsedTimeMs:null,runStartTimestamp:null,lastRunStartTimestamp:null,debuggerActive:!1,...e}}function gM(e){let t={column:0,hide_code:!1,disabled:!1,expand_output:!1};return{...e,cellData:{[Mi]:pM({id:Mi,config:t}),...e.cellData},cellRuntime:{[Mi]:hM(),...e.cellRuntime},cellHandles:{[Mi]:(0,G.createRef)(),...e.cellHandles}}}function _M(){return gM({cellIds:ys.from([]),cellData:{},cellRuntime:{},cellHandles:{},history:[],scrollKey:null,cellLogs:[],untouchedNewCells:new Set})}var{reducer:vM,addMiddleware:yM,createActions:bM,useActions:xM,valueAtom:SM}=kr(_M,{createNewCell:(e,t)=>{let{cellId:n,before:r,code:i,name:a,config:o,lastCodeRun:s=null,lastExecutionTime:c=null,autoFocus:l=!0,skipIfCodeExists:u=!1,hideCode:d=void 0}=t,f,p;if(u){for(let t of e.cellIds.inOrderIds)if(e.cellData[t]?.code===i)return e}if(n===`__end__`){let t=e.cellIds.atOrThrow(0);f=t.id,p=t.length}else if(typeof n==`string`){let t=e.cellIds.findWithId(n);f=t.id,p=t.topLevelIds.indexOf(n)}else if(n.type===`__end__`){let t=e.cellIds.get(n.columnId)||e.cellIds.atOrThrow(0);f=t.id,p=t.length}else throw Error(`Invalid cellId`);let m=t.newCellId||Pi.create(),h=r?p:p+1;return{...e,cellIds:e.cellIds.insertId(m,f,h),cellData:{...e.cellData,[m]:pM({id:m,code:i,name:a,lastCodeRun:s,config:mM({...o,...d!=null&&{hide_code:d}}),lastExecutionTime:c,edited:!!i&&i!==s})},cellRuntime:{...e.cellRuntime,[m]:hM()},cellHandles:{...e.cellHandles,[m]:(0,G.createRef)()},scrollKey:l?m:null,untouchedNewCells:d&&l?new Set([...e.untouchedNewCells,m]):e.untouchedNewCells}},moveCell:(e,t)=>{let{cellId:n,before:r,direction:i}=t;if(r!==void 0&&i!==void 0&&L.warn(`Both before and direction specified for moveCell. Ignoring one.`),i){let t=e.cellIds.findWithId(n),r=e.cellIds.indexOf(t),a=i===`left`?r-1:r+1,o=e.cellIds.at(a);return o?{...e,cellIds:e.cellIds.moveAcrossColumns(t.id,n,o.id,void 0),scrollKey:n}:e}let a=e.cellIds.findWithId(n),o=a.indexOfOrThrow(n);return r&&o===0?{...e,cellIds:e.cellIds.moveWithinColumn(a.id,o,0),scrollKey:n}:!r&&o===a.length-1?{...e,cellIds:e.cellIds.moveWithinColumn(a.id,o,a.length-1),scrollKey:n}:r?{...e,cellIds:e.cellIds.moveWithinColumn(a.id,o,o-1),scrollKey:n}:{...e,cellIds:e.cellIds.moveWithinColumn(a.id,o,o+1),scrollKey:n}},moveCellToIndex:(e,t)=>{let{cellId:n,columnId:r,index:i}=t,a=e.cellIds.findWithId(n),o=a.indexOfOrThrow(n),s=e.cellIds.get(r);if(!s)return e;let c=Math.max(0,Math.min(i,s.length)),l=a.id===r&&o<c?c-1:c;if(a.id===r&&o===l)return e;let u=e.cellIds.deleteById(n),d=u.get(r);return d?{...e,cellIds:u.insertId(n,r,Math.max(0,Math.min(l,d.length))),scrollKey:null}:e},dropCellOverCell:(e,t)=>{let{cellId:n,overCellId:r}=t,i=e.cellIds.findWithId(n),a=e.cellIds.findWithId(r),o=i.indexOfOrThrow(n),s=a.indexOfOrThrow(r);return i.id===a.id?o===s?e:{...e,cellIds:e.cellIds.moveWithinColumn(i.id,o,s),scrollKey:null}:{...e,cellIds:e.cellIds.moveAcrossColumns(i.id,n,a.id,r),scrollKey:null}},moveCellsRelativeTo:(e,t)=>{let{cellIds:n,targetCellId:r,position:i,previousPlacements:a}=t;if(n.length===0)return e;let o=e.cellIds.moveCellsRelativeTo(n,r,i),s=a&&a.length===n.length?[...e.history,{type:`move`,cellIds:n,placements:a}]:e.history;return{...e,cellIds:o,history:s,scrollKey:null}},dropCellOverColumn:(e,t)=>{let{cellId:n,columnId:r}=t,i=e.cellIds.findWithId(n);return{...e,cellIds:e.cellIds.moveAcrossColumns(i.id,n,r,void 0)}},dropOverNewColumn:(e,t)=>{let{cellId:n}=t;return{...e,cellIds:e.cellIds.moveToNewColumn(n)}},moveColumn:(e,t)=>t.column===t.overColumn?e:{...e,cellIds:e.cellIds.moveColumn(t.column,t.overColumn)},focusCell:(e,t)=>{let n=e.cellIds.findWithId(t.cellId);if(n.length===0)return e;let{cellId:r,where:i}=t,a=n.indexOfOrThrow(r),o;o=i===`before`?wr(a-1,0,n.length-1):i===`after`?wr(a+1,0,n.length-1):a;let s=n.atOrThrow(o);return cM({cellId:s,cell:e.cellHandles[s],isCodeHidden:CM(e,s),codeFocus:i===`after`?`top`:`bottom`,variableName:void 0}),e},focusTopCell:e=>{let t=e.cellIds.getColumns().at(0);if(t===void 0||t.length===0)return e;let n=t.first();return cM({cellId:n,cell:e.cellHandles[n],isCodeHidden:CM(e,n),codeFocus:void 0,variableName:void 0}),dM(),e},focusBottomCell:e=>{let t=e.cellIds.getColumns().at(-1);if(t===void 0||t.length===0)return e;let n=t.last();return cM({cellId:n,cell:e.cellHandles[n],isCodeHidden:CM(e,n),codeFocus:void 0,variableName:void 0}),uM(),e},sendToTop:(e,t)=>{let n=e.cellIds.findWithId(t.cellId);if(n.length===0)return e;let{cellId:r,scroll:i=!0}=t,a=n.indexOfOrThrow(r);return a===0?e:{...e,cellIds:e.cellIds.moveWithinColumn(n.id,a,0),scrollKey:i?r:null}},sendToBottom:(e,t)=>{let n=e.cellIds.findWithId(t.cellId);if(n.length===0)return e;let{cellId:r,scroll:i=!0}=t,a=n.indexOfOrThrow(r),o=n.length-1;return a===o?e:{...e,cellIds:e.cellIds.moveWithinColumn(n.id,a,o),scrollKey:i?r:null}},addColumn:(e,t)=>{let n=Pi.create();return{...e,cellIds:e.cellIds.addColumn(t.columnId,[n]),cellData:{...e.cellData,[n]:pM({id:n})},cellRuntime:{...e.cellRuntime,[n]:hM()},cellHandles:{...e.cellHandles,[n]:(0,G.createRef)()},scrollKey:n}},addColumnBreakpoint:(e,t)=>{let{cellId:n}=t;return e.cellIds.getColumns()[0].inOrderIds[0]===n?e:{...e,cellIds:e.cellIds.insertBreakpoint(n)}},deleteColumn:(e,t)=>{let{columnId:n}=t;return{...e,cellIds:e.cellIds.delete(n)}},mergeAllColumns:e=>({...e,cellIds:e.cellIds.mergeAllColumns()}),compactColumns:e=>({...e,cellIds:e.cellIds.compact()}),deleteCell:(e,t)=>{let n=t.cellId;if(e.cellIds.hasOnlyOneId())return e;let r;try{r=e.cellIds.findWithId(n)}catch(t){return L.warn(`Skipping delete for missing cellId`,{cellId:n,error:t}),e}let i=r.indexOfOrThrow(n),a=i===0?1:i-1,o=null;r.length>1&&(o=r.atOrThrow(a));let s=(e.cellHandles[n].current?.editorView)?.state.toJSON({history:nr});s&&(s.doc=e.cellData[n].code),oN(n);let c=e.cellData[n];return{...e,cellIds:e.cellIds.deleteById(n),history:[...e.history,{type:`delete`,name:c.name,serializedEditorState:s,column:r.id,index:i,isSetupCell:n===Ni,config:c.config}],scrollKey:o}},undoDeleteCell:e=>{if(e.history.length===0)return e;let t=e.history[e.history.length-1];if(t.type===`move`){let{cellIds:n,placements:r}=t;if(n.length===0||r.length!==n.length||n.some(t=>!e.cellData[t]))return{...e,history:e.history.slice(0,-1)};let i=n.map((e,t)=>({id:e,columnId:r[t].columnId,index:r[t].index}));return{...e,cellIds:e.cellIds.placeCells(i),history:e.history.slice(0,-1),scrollKey:n[0]??null}}let{name:n,serializedEditorState:r={doc:``},column:i,index:a,isSetupCell:o,config:s}=t,c=o?Ni:Pi.create(),l=pM({id:c,name:n,code:r.doc,edited:r.doc.trim().length>0,serializedEditorState:r,config:s});return{...e,cellIds:e.cellIds.insertId(c,i,a),cellData:{...e.cellData,[c]:l},cellRuntime:{...e.cellRuntime,[c]:hM()},cellHandles:{...e.cellHandles,[c]:(0,G.createRef)()},history:e.history.slice(0,-1),scrollKey:c}},clearSerializedEditorState:(e,t)=>{let{cellId:n}=t;return TM({state:e,cellId:n,cellReducer:e=>({...e,serializedEditorState:null})})},updateCellCode:(e,t)=>{let{cellId:n,code:r,formattingChange:i}=t;return e.cellData[n]?TM({state:e,cellId:n,cellReducer:e=>i?{...e,code:r,lastCodeRun:e.edited?e.lastCodeRun:r}:{...e,code:r,edited:r.trim()!==e.lastCodeRun}}):e},updateCellName:(e,t)=>{let{cellId:n,name:r}=t;return TM({state:e,cellId:n,cellReducer:e=>({...e,name:r})})},updateCellConfig:(e,t)=>{let{cellId:n,config:r}=t;return TM({state:e,cellId:n,cellReducer:e=>({...e,config:mM({...e.config,...r})})})},prepareForRun:(e,t)=>TM({state:wM({state:e,cellId:t.cellId,cellReducer:e=>rj(e)}),cellId:t.cellId,cellReducer:e=>({...e,edited:!1,lastCodeRun:e.code.trim()})}),handleCellMessage:(e,t)=>{let n=t.cell_id,r=wM({state:e,cellId:n,cellReducer:e=>nj(e,t)});return t.status===`queued`&&(r=TM({state:r,cellId:n,cellReducer:e=>({...e,lastCodeRun:e.code.trim(),edited:!1})})),{...r,cellLogs:[...r.cellLogs,...$j(t)]}},addLogs:(e,t)=>({...e,cellLogs:[...e.cellLogs,...t.logs]}),setCellIds:(e,t)=>{if(l(e.cellIds.inOrderIds,t.cellIds))return e;let n={...e.cellData},r={...e.cellRuntime},i={...e.cellHandles};for(let a of t.cellIds)a in e.cellData||(n[a]=pM({id:a})),a in e.cellRuntime||(r[a]=hM()),a in e.cellHandles||(i[a]=(0,G.createRef)());return{...e,cellIds:ys.fromWithPreviousShape(t.cellIds,e.cellIds),cellData:n,cellRuntime:r,cellHandles:i}},rebuildCellColumns:(e,t)=>{let n=ys.fromIdsAndColumns(t.cellIds.map(t=>[t,e.cellData[t]?.config.column??null]));return{...e,cellIds:n}},setCellCodes:(e,t)=>{z(t.codes.length===t.ids.length,`Expected codes and ids to have the same length`);let n={...e},r=({cell:e,code:r,cellId:i,name:a,config:o})=>{if(!e)return pM({id:i,code:r,name:a,config:o,lastCodeRun:t.codeIsStale?null:r,edited:t.codeIsStale&&r.trim().length>0});let s=t.codeIsStale?e.lastCodeRun:r,c=s?s.trim()!==r.trim():!!r;if(e.code.trim()===r.trim())return{...e,code:r,edited:c,lastCodeRun:s,...a!==void 0&&{name:a},...o!==void 0&&{config:o}};if(!WA()||!GA(i)){let e=n.cellHandles[i].current;e?.editorViewOrNull&&jA(e.editorViewOrNull,r)}return{...e,code:r,edited:c,lastCodeRun:s,...a!==void 0&&{name:a},...o!==void 0&&{config:o}}};for(let e=0;e<t.ids.length;e++){let i=t.ids[e],a=t.codes[e];if(i===void 0||a===void 0)continue;let o=t.names?.[e],s=t.configs?.[e];n={...n,cellData:{...n.cellData,[i]:r({cell:n.cellData[i],code:a,cellId:i,name:o,config:s})}}}return n},setStdinResponse:(e,t)=>{let{cellId:n,response:r,outputIndex:i}=t;return wM({state:e,cellId:n,cellReducer:e=>{let t=[...e.consoleOutputs],n=t[i];return n==null||n.channel!==`stdin`?(L.warn(`Expected stdin output`),e):(t[i]={channel:`stdin`,mimetype:n.mimetype,data:n.data,timestamp:n.timestamp,response:n.mimetype===`text/password`?``:r},{...e,interrupted:!1,consoleOutputs:t})}})},setCells:(e,t)=>{let n=Object.fromEntries(t.map(e=>[e.id,e])),r=ve(),i=t=>{if(!r)return hM();let n=e.cellRuntime[t];return n&&(n.output!=null||n.consoleOutputs.length>0)?n:hM()},a=Object.fromEntries(t.map(e=>[e.id,i(e.id)]));return gM({...e,cellIds:ys.fromIdsAndColumns(t.map(e=>[e.id,e.config.column])),cellData:n,cellRuntime:a,cellHandles:Object.fromEntries(t.map(e=>[e.id,(0,G.createRef)()]))})},moveToNextCell:(e,t)=>{let{cellId:n,before:r,noCreate:i=!1}=t;if(n===`__scratch__`)return e;let a=e.cellIds.findWithId(n),o=a.indexOfOrThrow(n),s=r?o-1:o+1,c=s===a.length,l=s===-1;if(c&&!i){let t=Pi.create();return{...e,cellIds:e.cellIds.insertId(t,a.id,s),cellData:{...e.cellData,[t]:pM({id:t})},cellRuntime:{...e.cellRuntime,[t]:hM()},cellHandles:{...e.cellHandles,[t]:(0,G.createRef)()},scrollKey:t}}if(l&&!i){let t=Pi.create();return{...e,cellIds:e.cellIds.insertId(t,a.id,0),cellData:{...e.cellData,[t]:pM({id:t})},cellRuntime:{...e.cellRuntime,[t]:hM()},cellHandles:{...e.cellHandles,[t]:(0,G.createRef)()},scrollKey:t}}if((c||l)&&i)return e;if(s>=0&&s<a.length){let t=a.atOrThrow(s);cM({cellId:t,cell:e.cellHandles[t],isCodeHidden:CM(e,t),codeFocus:r?`bottom`:`top`,variableName:void 0})}return e},markTouched:(e,t)=>{let{cellId:n}=t;if(e.untouchedNewCells.has(n)){let t=new Set(e.untouchedNewCells);return t.delete(n),{...e,untouchedNewCells:t}}return e},markUntouched:(e,t)=>{let{cellId:n}=t;if(!e.untouchedNewCells.has(n)){let t=new Set(e.untouchedNewCells);return t.add(n),{...e,untouchedNewCells:t}}return e},scrollToTarget:e=>{let t=e.scrollKey;if(t===null)return e;let n=e.cellIds.findWithId(t),r=n.indexOfOrThrow(t),i=r===n.length-1?n.last():n.atOrThrow(r);return cM({cellId:i,cell:e.cellHandles[i],isCodeHidden:CM(e,i),codeFocus:void 0,variableName:void 0}),{...e,scrollKey:null}},foldAll:e=>(zs(Object.values(e.cellHandles).map(e=>e.current?.editorView)),e),unfoldAll:e=>(Bs(Object.values(e.cellHandles).map(e=>e.current?.editorView)),e),clearLogs:e=>({...e,cellLogs:[]}),collapseCell:(e,t)=>{let{cellId:n}=t,r=e.cellIds.findWithId(n),i=r.topLevelIds.map(t=>e.cellRuntime[t].outline),a=HA(r.indexOfOrThrow(n),i);if(!a)return e;let o=r.atOrThrow(a[1]);return{...e,cellIds:e.cellIds.transformWithCellId(n,e=>e.collapse(n,o)),scrollKey:n}},expandCell:(e,t)=>{let{cellId:n}=t;return{...e,cellIds:e.cellIds.transformWithCellId(n,e=>e.expand(n)),scrollKey:n}},collapseAllCells:e=>({...e,cellIds:e.cellIds.transformAll(t=>{let n=t.topLevelIds.map(t=>e.cellRuntime[t].outline),r=[...t.nodes],i=new Map,a=[],o=r.length-1;for(;o>=0;){let e=HA(o,n);if(e){let n=o,r=e[1],s=i.get(r)??r;i.set(r,n);let c=t.atOrThrow(n),l=t.atOrThrow(s);a.push({id:c,until:l})}else a.push(null);o--}let s=a.toReversed();return t.collapseAll(s)})}),expandAllCells:e=>({...e,cellIds:e.cellIds.transformAll(e=>e.expandAll())}),showCellIfHidden:(e,t)=>{let{cellId:n}=t,r=e.cellIds.findWithId(n),i=r,a=r.findAndExpandDeep(n);return a.equals(i)?e:{...e,cellIds:e.cellIds.transformWithCellId(n,()=>a)}},splitCell:(e,t)=>{let{cellId:n}=t,r=e.cellIds.findWithId(n),i=r.indexOfOrThrow(n),a=e.cellData[n],o=e.cellHandles[n].current;if(o?.editorView==null)return e;let{beforeCursorCode:s,afterCursorCode:c}=MA(o.editorView);jA(o.editorView,s);let l=Pi.create();return{...e,cellIds:e.cellIds.insertId(l,r.id,i+1),cellData:{...e.cellData,[n]:{...a,code:s,edited:!!s&&s.trim()!==a.lastCodeRun?.trim()},[l]:pM({id:l,code:c,edited:!!c})},cellRuntime:{...e.cellRuntime,[n]:{...e.cellRuntime[n],output:null,consoleOutputs:[]},[l]:hM()},cellHandles:{...e.cellHandles,[l]:(0,G.createRef)()},scrollKey:l}},undoSplitCell:(e,t)=>{let{cellId:n,snapshot:r}=t,i=e.cellData[n],a=e.cellHandles[n].current;return a?.editorView==null?e:(jA(a.editorView,r),{...e,cellIds:e.cellIds.transformWithCellId(n,e=>{let t=e.indexOfOrThrow(n)+1;return e.deleteAtIndex(t)}),cellData:{...e.cellData,[n]:{...i,code:r,edited:!!r&&r?.trim()!==i.lastCodeRun?.trim()}},cellRuntime:{...e.cellRuntime,[n]:{...e.cellRuntime[n],output:null,consoleOutputs:[]}},cellHandles:{...e.cellHandles}})},clearCellOutput:(e,t)=>{let{cellId:n}=t;return wM({state:e,cellId:n,cellReducer:e=>({...e,output:null,consoleOutputs:[]})})},clearCellConsoleOutput:(e,t)=>{let{cellId:n}=t;return wM({state:e,cellId:n,cellReducer:e=>({...e,consoleOutputs:e.consoleOutputs.filter(e=>e.channel===`stdin`&&e.response==null)})})},clearAllCellOutputs:e=>{let t={...e.cellRuntime};for(let n of e.cellIds.inOrderIds)t[n]={...t[n],output:null,consoleOutputs:[]};return{...e,cellRuntime:t}},addSetupCellIfDoesntExist:(e,t)=>{let{code:n}=t;return e.cellIds.setupCellExists()?{...e,scrollKey:Ni}:{...e,cellIds:e.cellIds.insertId(Ni,e.cellIds.atOrThrow(0).id,0),cellData:{...e.cellData,[Ni]:pM({id:Ni,name:Ni,code:n,edited:!!n})},cellRuntime:{...e.cellRuntime,[Ni]:hM()},cellHandles:{...e.cellHandles,[Ni]:(0,G.createRef)()},scrollKey:Ni}}});yM(Ij);function CM(e,t){return!!e.cellData[t].config.hide_code&&!e.untouchedNewCells.has(t)}function wM({state:e,cellId:t,cellReducer:n}){return t in e.cellRuntime?{...e,cellRuntime:{...e.cellRuntime,[t]:n(e.cellRuntime[t])}}:(L.warn(`Cell ${t} not found in state`),e)}function TM({state:e,cellId:t,cellReducer:n}){return t in e.cellData?{...e,cellData:{...e.cellData,[t]:n(e.cellData[t])}}:(L.warn(`Cell ${t} not found in state`),e)}function EM(e){let t=e.cellData,n={column:null};return e.cellIds.getColumns().length>1?e.cellIds.getColumns().flatMap((e,r)=>e.inOrderIds.map((e,i)=>{let a={...n};return i===0&&(a.column=r),{...t[e].config,...a}})):e.cellIds.getColumns().flatMap(e=>e.inOrderIds.map(e=>({...t[e].config,...n})))}var DM=bM(e=>{u.set(SM,t=>vM(t,e))}).addLogs,OM=o(e=>e(SM).cellIds),kM=o(e=>e(OM).hasOnlyOneId()),AM=o(e=>vf(e(SM)).length>0);o(e=>yf(e(SM)).length>0);var jM=o(e=>bf(e(SM))),MM=o(e=>xf(e(SM))),NM=o(e=>hf(e(SM))),PM=o(e=>{let{cellIds:t,cellRuntime:n,cellData:r}=e(SM);return t.inOrderIds.map(e=>{let t=n[e],{name:i}=r[e];if(ff(t.output?.mimetype)){z(Array.isArray(t.output.data),`Expected array data`);let n=t.output.data.filter(e=>!e.type.includes(`ancestor`));if(n.length>0)return{output:{...t.output,data:n},cellId:e,cellName:i}}return null}).filter(Boolean)}),FM=o(e=>{let t=e(OM),n=e(XM);return zA(t.inOrderIds.map(e=>n[e].outline))}),IM=o(e=>e(PM).length),LM=c(o(e=>{let{cellIds:t,cellData:n}=e(SM);return R.fromEntries(t.inOrderIds.map(e=>[e,n[e]?.name]))})),RM=o(e=>e(SM).scrollKey),zM=()=>s(SM),BM=()=>s(OM),VM=()=>s(LM),HM=()=>s(PM),UM=()=>s(SM).cellLogs,WM=()=>s(RM),GM=()=>u.get(SM),KM=()=>u.get(SM).cellIds,qM=()=>{let{cellIds:e,cellData:t}=u.get(SM);return e.inOrderIds.map(e=>t[e]?.name).filter(Boolean)},JM=xe(ge(SM,e=>e.cellIds.inOrderIds.map(t=>e.cellData[t]))),YM=()=>a(JM),XM=o(e=>e(SM).cellRuntime),ZM=o(e=>pf(e(SM))),QM=o(e=>{let{cellRuntime:t}=e(SM);return Object.entries(t).every(([e,t])=>t.status!==`running`||e===`__scratch__`)}),$M=o(e=>mf(e(SM))),eN=o(e=>e(SM).cellIds.colLength),tN=o(e=>e(SM).cellIds.idLength>0),nN=o(e=>e(SM).cellIds.getColumnIds()),rN=_e(e=>o(t=>t(SM).cellData[e])),iN=_e(e=>o(t=>t(SM).cellRuntime[e])),aN=_e(e=>o(t=>t(SM).cellHandles[e]));function oN(e){rN.remove(e),iN.remove(e),aN.remove(e)}var sN=e=>{let t=(0,X.c)(2),n;return t[0]===e?n=t[1]:(n=rN(e),t[0]=e,t[1]=n),s(n)},cN=e=>{let t=(0,X.c)(2),n;return t[0]===e?n=t[1]:(n=iN(e),t[0]=e,t[1]=n),s(n)},lN=e=>{let t=(0,X.c)(2),n;return t[0]===e?n=t[1]:(n=aN(e),t[0]=e,t[1]=n),s(n)},uN=()=>{let{cellIds:e,cellHandles:t}=u.get(SM);return e.inOrderIds.map(e=>t[e]?.current?.editorViewOrNull).filter(Boolean)},dN=e=>{let{cellHandles:t}=u.get(SM);return t[e].current?.editorView},fN=e=>(Ws.promote(e),dN(e));function pN(e){let{cellIds:t,cellData:n,cellRuntime:r}=e;return t.getColumns().flatMap(e=>e.topLevelIds.map(e=>({...n[e],...r[e]})))}function mN(e){return o(t=>t(SM).untouchedNewCells.has(e))}function hN(e){let t=iN(e);return o(n=>{let r=n(t);if(!r||r.status===`queued`||r.status===`running`)return;let i=[],a=r.consoleOutputs;if(a&&a.length>0){let e=a.find(e=>e.mimetype===`application/vnd.marimo+traceback`);if(e){let t=e.data;i.push(...Ls(t))}}let o=r.output;if(o?.mimetype===`application/vnd.marimo+error`){let t=o.data;if(Array.isArray(t))for(let n of t)n.type===`syntax`&&n.lineno!=null&&i.push({kind:`cell`,cellId:e,lineNumber:n.lineno}),n.type===`import-star`&&n.lineno!=null&&i.push({kind:`cell`,cellId:e,lineNumber:n.lineno})}return i.length>0?i:void 0})}function gN(e){let t=(0,X.c)(2),n;return t[0]===e?n=t[1]:(n=e===void 0?{}:e,t[0]=e,t[1]=n),xM(n)}export{Lj as $,Lo as $a,kf as $i,Ky as $n,Mh as $r,_O as $t,HM as A,ys as Aa,Cp as Ai,kT as An,bi as Ao,b_ as Ar,wk as At,lM as B,ns as Ba,ip as Bi,Dw as Bn,ig as Br,QO as Bt,$M as C,pu as Ca,Qp as Ci,ED as Cn,Ni as Co,D_ as Cr,Yk as Ct,gN as D,Is as Da,Tp as Di,dE as Dn,Oi as Do,k_ as Dr,Ik as Dt,MM as E,Ls as Ea,kp as Ei,WE as En,Di as Eo,E_ as Er,Lk as Et,cN as F,cs as Fa,xp as Fi,zw as Fn,gg as Fr,sk as Ft,aM as G,qo as Ga,Qf as Gi,LC as Gn,Hh as Gr,IO as Gt,sM as H,Xo as Ha,Kf as Hi,iw as Hn,eg as Hr,VO as Ht,zM as I,os as Ia,gp as Ii,jw as In,ug as Ir,ak as It,Zj as J,Ho as Ja,Jf as Ji,zC as Jn,Ih as Jr,kO as Jt,iM as K,Ko as Ka,Uf as Ki,IC as Kn,Qh as Kr,MO as Kt,WM as L,rs as La,sp as Li,Aw as Ln,ag as Lr,ik as Lt,BM as M,ps as Ma,vp as Mi,Iw as Mn,bg as Mr,Dk as Mt,UM as N,ls as Na,_p as Ni,Rw as Nn,pg as Nr,rk as Nt,sN as O,Ns as Oa,Dp as Oi,PE as On,Si as Oo,d_ as Or,Fk as Ot,VM as P,ss as Pa,hp as Pi,Lw as Pn,vg as Pr,ck as Pt,Vj as Q,Ro as Qa,Vf as Qi,qy as Qn,Fh as Qr,hO as Qt,pM as R,ts as Ra,ap as Ri,Mw as Rn,rg as Rr,ok as Rt,FM as S,kd as Sa,Zp as Si,WD as Sn,Mi as So,S_ as Sr,qk as St,QM as T,Fs as Ta,Op as Ti,KE as Tn,Ii as To,w_ as Tr,Rk as Tt,rM as U,Yo as Ua,Wf as Ui,VC as Un,Yh as Ur,PO as Ut,fM as V,Zo as Va,cp as Vi,Tw as Vn,ng as Vr,BO as Vt,nM as W,Jo as Wa,Gf as Wi,FC as Wn,$h as Wr,FO as Wt,Yj as X,Bo as Xa,Hf as Xi,Lb as Xn,Rh as Xr,SO as Xt,Xj as Y,Vo as Ya,Zf as Yi,Qb as Yn,Lh as Yr,mO as Yt,Jj as Z,zo as Za,Bf as Zi,Yy as Zn,Ph as Zr,CO as Zt,AM as _,tf as _a,dm as _i,QD as _n,Hi as _o,q_ as _r,xA as _t,XM as a,Sf as aa,_h as ai,uO as an,ko as ao,ly as ar,WA as at,SM as b,Vd as ba,Bp as bi,$D as bn,Ri as bo,T_ as br,Kk as bt,fN as c,gf as ca,fh as ci,eO as cn,Eo as co,Uv as cr,RA as ct,EM as d,Cf as da,uh as di,tO as dn,So as do,xv as dr,AA as dt,Af as ea,Nh as ei,bO as en,Io as eo,My as er,Oj as et,dN as f,ff as fa,lh as fi,GD as fn,Pa as fo,cv as fr,jA as ft,tN as g,cf as ga,Om as gi,qD as gn,Vi as go,Z_ as gr,kA as gt,GM as h,lf as ha,Zm as hi,XD as hn,Bi as ho,uv as hr,SA as ht,OM as i,yf as ia,Ch as ii,lO as in,jo as io,hy as ir,GA as it,lN as j,hs as ja,bp as ji,Xw as jn,hi as jo,wg as jr,Ck as jt,YM as k,Ms as ka,Ep as ki,vT as kn,Ci as ko,x_ as kr,Ok as kt,pN as l,Df as la,ch as li,rO as ln,wo as lo,Rv as lr,BA as lt,KM as m,df as ma,eh as mi,YD as mn,Ui as mo,tv as mr,EA as mt,rN as n,Ef as na,Th as ni,wO as nn,Po as no,ky as nr,ij as nt,nN as o,wf as oa,hh as oi,sO as on,Oo as oo,uy as or,UA as ot,qM as p,uf as pa,dh as pi,KD as pn,Ra as po,lv as pr,TA as pt,tM as q,Wo as qa,qf as qi,RC as qn,Zh as qr,OO as qt,IM as r,vf as ra,xh as ri,TO as rn,Mo as ro,Ay as rr,aj as rt,mN as s,_f as sa,ph as si,cO as sn,Do as so,Wv as sr,VA as st,jM as t,Tf as ta,Ah as ti,xO as tn,J as to,jy as tr,Nj as tt,uN as u,Of as ua,sh as ui,aO as un,Co as uo,bv as ur,NA as ut,kM as v,ef as va,um as vi,JD as vn,zi as vo,Y_ as vr,OA as vt,eN as w,Ws as wa,Wp as wi,GE as wn,Li as wo,O_ as wr,Xk as wt,ZM as x,Hd as xa,zp as xi,UD as xn,Fi as xo,C_ as xr,Gk as xt,NM as y,Yd as ya,Np as yi,ZD as yn,Pi as yo,V_ as yr,Qk as yt,hM as z,es as za,op as zi,kw as zn,Q as zr,$O as zt};
|
|
220
|
+
`)}catch(t){return L.error(`Error parsing HTML content:`,t),e}}function Xj(e){if(!e)return``;try{return Yj(Jj.ansi_to_html(e))}catch(t){return L.error(`Error converting ANSI to plain text:`,t),e}}var Zj=o(null);function Qj(e){return e.type===`cell`?e.cellId:`lsp:${e.name}`}var $j=!1;function eM(e){let t=[],n=[e.console].filter(Boolean).flat();for(let r of n){let n=r.mimetype===`text/plain`,i=r.mimetype===`text/html`||r.mimetype===`application/vnd.marimo+traceback`;if(n||i){let n=r.channel===`stderr`||r.channel===`marimo-error`;switch(r.channel){case`stdout`:case`stderr`:case`marimo-error`:{let a=zr.asString(r.data),o=i?Yj(a):a;t.push({timestamp:r.timestamp||Date.now(),level:n?`stderr`:`stdout`,message:o,source:{type:`cell`,cellId:e.cell_id}});break}}}}if(t.forEach(tM.log),n.length===0&&ff(e.output?.mimetype)&&Array.isArray(e.output.data)){e.output.data.forEach(t=>{tM.log({level:`stderr`,source:{type:`cell`,cellId:e.cell_id},timestamp:e.timestamp??0,message:JSON.stringify(t)})});let t=e.output.data.filter(e=>`type`in e&&e.type===`exception`||e.type===`internal`),n=u.get(pe)===`read`;if(t.length>0&&!$j&&n){$j=!0;let e=t.find(e=>e.traceback);an(e?{title:`An internal error occurred`,description:e.msg||`Click 'View' to see traceback`,variant:`danger`,action:G.createElement(gt,{altText:`View traceback`,onClick:()=>{u.set(Zj,{traceback:e.traceback,errorMessage:e.msg||`An internal error occurred`})}},`View`)}:{title:`An internal error occurred`,description:`See console for details.`,variant:`danger`})}}return t}var tM={log:e=>{let t=e.level===`stdout`?`gray`:e.level===`stderr`?`red`:`orange`,n=e.level.toUpperCase();console.log(`%c[${n}]`,`color:${t}; padding:2px 0; border-radius:2px; font-weight:bold`,`[${nM(e.timestamp)}]`,`(${Qj(e.source)}) ${e.message}`)}};function nM(e){try{return zj(e).toLocaleTimeString(void 0,{hour12:!0,hour:`numeric`,minute:`numeric`,second:`numeric`})}catch{return``}}function rM(e,t){let n=fN(t);n?n.focus():L.warn(`[CellFocusManager] focusCellEditor: element not found: ${t}`)}function iM(e){let t=document.getElementById(Fi.create(e));t?sM(t):L.warn(`[CellFocusManager] focusCell: element not found: ${e}`)}function aM(e){requestAnimationFrame(()=>{requestAnimationFrame(e)})}function oM(){return document.activeElement instanceof HTMLElement&&document.activeElement.classList.contains(`marimo-cell`)}function sM(e){try{e.focus()}catch{L.warn(`[CellFocusManager] element may not be focusable`,e)}}function cM(e,t){let{retries:n,delay:r,initialDelay:i=0}=t,a=0,o=()=>{if(a<n){try{if(e())return}catch(e){L.error(`Error executing function on attempt ${a+1}, retrying`,{error:e})}a++,setTimeout(o,r)}};i>0?setTimeout(o,i):o()}function lM({cellId:e,cell:t,isCodeHidden:n,codeFocus:r,variableName:i}){if(!t)return;let a=document.getElementById(Fi.create(e));if(!a){L.warn(`scrollCellIntoView: element not found`);return}if(oM()){sM(a);return}if(n)sM(a);else{Ws.promote(e);let n=t.current?.editorView;if(!n){L.warn(`scrollCellIntoView: editor not found`,e);return}if(n.hasFocus||!document.hasFocus())return;if(cM(()=>(n.focus(),n.hasFocus),{retries:5,delay:20}),r===`top`)n.dispatch({selection:{anchor:0,head:0}});else if(r===`bottom`){let e=n.state.doc.line(n.state.doc.lines);n.dispatch({selection:{anchor:e.from,head:e.from}})}else i&&V_(n,i)}a.scrollIntoView({behavior:`smooth`,block:`nearest`})}function uM(e){let t=document.getElementById(Fi.create(e));if(!t){L.warn(`scrollCellIntoView: element not found`);return}t.classList.add(`focus-outline`),setTimeout(()=>{t.classList.remove(`focus-outline`)},2e3),t.scrollIntoView({behavior:`smooth`,block:`center`})}function dM(){let e=document.getElementById(`App`);e?.scrollTo({top:e.scrollHeight,behavior:`smooth`})}function fM(){document.getElementById(`App`)?.scrollTo({top:0,behavior:`smooth`})}function pM(e){let t=fN(e);if(t?.hasFocus){Eh(t,{behavior:`instant`});return}let n=document.getElementById(Fi.create(e));n?n.scrollIntoView({behavior:`instant`,block:`nearest`}):L.warn(`[CellFocusManager] scrollCellIntoView: element not found: ${e}`)}function mM({id:e,name:t=`_`,code:n=``,lastCodeRun:r=null,lastExecutionTime:i=null,edited:a=!1,config:o,serializedEditorState:s=null}){return{id:e,config:o||{hide_code:!1,disabled:!1,column:null,expand_output:!1},name:t,code:n,edited:a,lastCodeRun:r,lastExecutionTime:i,serializedEditorState:s}}function hM(e){return{hide_code:!1,disabled:!1,column:null,expand_output:!1,...e}}function gM(e){return{outline:null,output:null,consoleOutputs:[],status:`idle`,staleInputs:!1,interrupted:!1,errored:!1,stopped:!1,runElapsedTimeMs:null,runStartTimestamp:null,lastRunStartTimestamp:null,debuggerActive:!1,...e}}function _M(e){let t={column:0,hide_code:!1,disabled:!1,expand_output:!1};return{...e,cellData:{[Mi]:mM({id:Mi,config:t}),...e.cellData},cellRuntime:{[Mi]:gM(),...e.cellRuntime},cellHandles:{[Mi]:(0,G.createRef)(),...e.cellHandles}}}function vM(){return _M({cellIds:ys.from([]),cellData:{},cellRuntime:{},cellHandles:{},history:[],scrollKey:null,cellLogs:[],untouchedNewCells:new Set})}var{reducer:yM,addMiddleware:bM,createActions:xM,useActions:SM,valueAtom:CM}=kr(vM,{createNewCell:(e,t)=>{let{cellId:n,before:r,code:i,name:a,config:o,lastCodeRun:s=null,lastExecutionTime:c=null,autoFocus:l=!0,skipIfCodeExists:u=!1,hideCode:d=void 0}=t,f,p;if(u){for(let t of e.cellIds.inOrderIds)if(e.cellData[t]?.code===i)return e}if(n===`__end__`){let t=e.cellIds.atOrThrow(0);f=t.id,p=t.length}else if(typeof n==`string`){let t=e.cellIds.findWithId(n);f=t.id,p=t.topLevelIds.indexOf(n)}else if(n.type===`__end__`){let t=e.cellIds.get(n.columnId)||e.cellIds.atOrThrow(0);f=t.id,p=t.length}else throw Error(`Invalid cellId`);let m=t.newCellId||Pi.create(),h=r?p:p+1;return{...e,cellIds:e.cellIds.insertId(m,f,h),cellData:{...e.cellData,[m]:mM({id:m,code:i,name:a,lastCodeRun:s,config:hM({...o,...d!=null&&{hide_code:d}}),lastExecutionTime:c,edited:!!i&&i!==s})},cellRuntime:{...e.cellRuntime,[m]:gM()},cellHandles:{...e.cellHandles,[m]:(0,G.createRef)()},scrollKey:l?m:null,untouchedNewCells:d&&l?new Set([...e.untouchedNewCells,m]):e.untouchedNewCells}},moveCell:(e,t)=>{let{cellId:n,before:r,direction:i}=t;if(r!==void 0&&i!==void 0&&L.warn(`Both before and direction specified for moveCell. Ignoring one.`),i){let t=e.cellIds.findWithId(n),r=e.cellIds.indexOf(t),a=i===`left`?r-1:r+1,o=e.cellIds.at(a);return o?{...e,cellIds:e.cellIds.moveAcrossColumns(t.id,n,o.id,void 0),scrollKey:n}:e}let a=e.cellIds.findWithId(n),o=a.indexOfOrThrow(n);return r&&o===0?{...e,cellIds:e.cellIds.moveWithinColumn(a.id,o,0),scrollKey:n}:!r&&o===a.length-1?{...e,cellIds:e.cellIds.moveWithinColumn(a.id,o,a.length-1),scrollKey:n}:r?{...e,cellIds:e.cellIds.moveWithinColumn(a.id,o,o-1),scrollKey:n}:{...e,cellIds:e.cellIds.moveWithinColumn(a.id,o,o+1),scrollKey:n}},moveCellToIndex:(e,t)=>{let{cellId:n,columnId:r,index:i}=t,a=e.cellIds.findWithId(n),o=a.indexOfOrThrow(n),s=e.cellIds.get(r);if(!s)return e;let c=Math.max(0,Math.min(i,s.length)),l=a.id===r&&o<c?c-1:c;if(a.id===r&&o===l)return e;let u=e.cellIds.deleteById(n),d=u.get(r);return d?{...e,cellIds:u.insertId(n,r,Math.max(0,Math.min(l,d.length))),scrollKey:null}:e},dropCellOverCell:(e,t)=>{let{cellId:n,overCellId:r}=t,i=e.cellIds.findWithId(n),a=e.cellIds.findWithId(r),o=i.indexOfOrThrow(n),s=a.indexOfOrThrow(r);return i.id===a.id?o===s?e:{...e,cellIds:e.cellIds.moveWithinColumn(i.id,o,s),scrollKey:null}:{...e,cellIds:e.cellIds.moveAcrossColumns(i.id,n,a.id,r),scrollKey:null}},moveCellsRelativeTo:(e,t)=>{let{cellIds:n,targetCellId:r,position:i,previousPlacements:a}=t;if(n.length===0)return e;let o=e.cellIds.moveCellsRelativeTo(n,r,i),s=a&&a.length===n.length?[...e.history,{type:`move`,cellIds:n,placements:a}]:e.history;return{...e,cellIds:o,history:s,scrollKey:null}},dropCellOverColumn:(e,t)=>{let{cellId:n,columnId:r}=t,i=e.cellIds.findWithId(n);return{...e,cellIds:e.cellIds.moveAcrossColumns(i.id,n,r,void 0)}},dropOverNewColumn:(e,t)=>{let{cellId:n}=t;return{...e,cellIds:e.cellIds.moveToNewColumn(n)}},moveColumn:(e,t)=>t.column===t.overColumn?e:{...e,cellIds:e.cellIds.moveColumn(t.column,t.overColumn)},focusCell:(e,t)=>{let n=e.cellIds.findWithId(t.cellId);if(n.length===0)return e;let{cellId:r,where:i}=t,a=n.indexOfOrThrow(r),o;o=i===`before`?wr(a-1,0,n.length-1):i===`after`?wr(a+1,0,n.length-1):a;let s=n.atOrThrow(o);return lM({cellId:s,cell:e.cellHandles[s],isCodeHidden:wM(e,s),codeFocus:i===`after`?`top`:`bottom`,variableName:void 0}),e},focusTopCell:e=>{let t=e.cellIds.getColumns().at(0);if(t===void 0||t.length===0)return e;let n=t.first();return lM({cellId:n,cell:e.cellHandles[n],isCodeHidden:wM(e,n),codeFocus:void 0,variableName:void 0}),fM(),e},focusBottomCell:e=>{let t=e.cellIds.getColumns().at(-1);if(t===void 0||t.length===0)return e;let n=t.last();return lM({cellId:n,cell:e.cellHandles[n],isCodeHidden:wM(e,n),codeFocus:void 0,variableName:void 0}),dM(),e},sendToTop:(e,t)=>{let n=e.cellIds.findWithId(t.cellId);if(n.length===0)return e;let{cellId:r,scroll:i=!0}=t,a=n.indexOfOrThrow(r);return a===0?e:{...e,cellIds:e.cellIds.moveWithinColumn(n.id,a,0),scrollKey:i?r:null}},sendToBottom:(e,t)=>{let n=e.cellIds.findWithId(t.cellId);if(n.length===0)return e;let{cellId:r,scroll:i=!0}=t,a=n.indexOfOrThrow(r),o=n.length-1;return a===o?e:{...e,cellIds:e.cellIds.moveWithinColumn(n.id,a,o),scrollKey:i?r:null}},addColumn:(e,t)=>{let n=Pi.create();return{...e,cellIds:e.cellIds.addColumn(t.columnId,[n]),cellData:{...e.cellData,[n]:mM({id:n})},cellRuntime:{...e.cellRuntime,[n]:gM()},cellHandles:{...e.cellHandles,[n]:(0,G.createRef)()},scrollKey:n}},addColumnBreakpoint:(e,t)=>{let{cellId:n}=t;return e.cellIds.getColumns()[0].inOrderIds[0]===n?e:{...e,cellIds:e.cellIds.insertBreakpoint(n)}},deleteColumn:(e,t)=>{let{columnId:n}=t;return{...e,cellIds:e.cellIds.delete(n)}},mergeAllColumns:e=>({...e,cellIds:e.cellIds.mergeAllColumns()}),compactColumns:e=>({...e,cellIds:e.cellIds.compact()}),deleteCell:(e,t)=>{let n=t.cellId;if(e.cellIds.hasOnlyOneId())return e;let r;try{r=e.cellIds.findWithId(n)}catch(t){return L.warn(`Skipping delete for missing cellId`,{cellId:n,error:t}),e}let i=r.indexOfOrThrow(n),a=i===0?1:i-1,o=null;r.length>1&&(o=r.atOrThrow(a));let s=(e.cellHandles[n].current?.editorView)?.state.toJSON({history:nr});s&&(s.doc=e.cellData[n].code),sN(n);let c=e.cellData[n];return{...e,cellIds:e.cellIds.deleteById(n),history:[...e.history,{type:`delete`,name:c.name,serializedEditorState:s,column:r.id,index:i,isSetupCell:n===Ni,config:c.config}],scrollKey:o}},undoDeleteCell:e=>{if(e.history.length===0)return e;let t=e.history[e.history.length-1];if(t.type===`move`){let{cellIds:n,placements:r}=t;if(n.length===0||r.length!==n.length||n.some(t=>!e.cellData[t]))return{...e,history:e.history.slice(0,-1)};let i=n.map((e,t)=>({id:e,columnId:r[t].columnId,index:r[t].index}));return{...e,cellIds:e.cellIds.placeCells(i),history:e.history.slice(0,-1),scrollKey:n[0]??null}}let{name:n,serializedEditorState:r={doc:``},column:i,index:a,isSetupCell:o,config:s}=t,c=o?Ni:Pi.create(),l=mM({id:c,name:n,code:r.doc,edited:r.doc.trim().length>0,serializedEditorState:r,config:s});return{...e,cellIds:e.cellIds.insertId(c,i,a),cellData:{...e.cellData,[c]:l},cellRuntime:{...e.cellRuntime,[c]:gM()},cellHandles:{...e.cellHandles,[c]:(0,G.createRef)()},history:e.history.slice(0,-1),scrollKey:c}},clearSerializedEditorState:(e,t)=>{let{cellId:n}=t;return EM({state:e,cellId:n,cellReducer:e=>({...e,serializedEditorState:null})})},updateCellCode:(e,t)=>{let{cellId:n,code:r,formattingChange:i}=t;return e.cellData[n]?EM({state:e,cellId:n,cellReducer:e=>i?{...e,code:r,lastCodeRun:e.edited?e.lastCodeRun:r}:{...e,code:r,edited:r.trim()!==e.lastCodeRun}}):e},updateCellName:(e,t)=>{let{cellId:n,name:r}=t;return EM({state:e,cellId:n,cellReducer:e=>({...e,name:r})})},updateCellConfig:(e,t)=>{let{cellId:n,config:r}=t;return EM({state:e,cellId:n,cellReducer:e=>({...e,config:hM({...e.config,...r})})})},prepareForRun:(e,t)=>EM({state:TM({state:e,cellId:t.cellId,cellReducer:e=>ij(e)}),cellId:t.cellId,cellReducer:e=>({...e,edited:!1,lastCodeRun:e.code.trim()})}),handleCellMessage:(e,t)=>{let n=t.cell_id,r=TM({state:e,cellId:n,cellReducer:e=>rj(e,t)});return t.status===`queued`&&(r=EM({state:r,cellId:n,cellReducer:e=>({...e,lastCodeRun:e.code.trim(),edited:!1})})),{...r,cellLogs:[...r.cellLogs,...eM(t)]}},addLogs:(e,t)=>({...e,cellLogs:[...e.cellLogs,...t.logs]}),setCellIds:(e,t)=>{if(l(e.cellIds.inOrderIds,t.cellIds))return e;let n={...e.cellData},r={...e.cellRuntime},i={...e.cellHandles};for(let a of t.cellIds)a in e.cellData||(n[a]=mM({id:a})),a in e.cellRuntime||(r[a]=gM()),a in e.cellHandles||(i[a]=(0,G.createRef)());return{...e,cellIds:ys.fromWithPreviousShape(t.cellIds,e.cellIds),cellData:n,cellRuntime:r,cellHandles:i}},rebuildCellColumns:(e,t)=>{let n=ys.fromIdsAndColumns(t.cellIds.map(t=>[t,e.cellData[t]?.config.column??null]));return{...e,cellIds:n}},setCellCodes:(e,t)=>{z(t.codes.length===t.ids.length,`Expected codes and ids to have the same length`);let n={...e},r=({cell:e,code:r,cellId:i,name:a,config:o})=>{if(!e)return mM({id:i,code:r,name:a,config:o,lastCodeRun:t.codeIsStale?null:r,edited:t.codeIsStale&&r.trim().length>0});let s=t.codeIsStale?e.lastCodeRun:r,c=s?s.trim()!==r.trim():!!r;if(e.code.trim()===r.trim())return{...e,code:r,edited:c,lastCodeRun:s,...a!==void 0&&{name:a},...o!==void 0&&{config:o}};if(!WA()||!GA(i)){let e=n.cellHandles[i].current;e?.editorViewOrNull&&jA(e.editorViewOrNull,r)}return{...e,code:r,edited:c,lastCodeRun:s,...a!==void 0&&{name:a},...o!==void 0&&{config:o}}};for(let e=0;e<t.ids.length;e++){let i=t.ids[e],a=t.codes[e];if(i===void 0||a===void 0)continue;let o=t.names?.[e],s=t.configs?.[e];n={...n,cellData:{...n.cellData,[i]:r({cell:n.cellData[i],code:a,cellId:i,name:o,config:s})}}}return n},setStdinResponse:(e,t)=>{let{cellId:n,response:r,outputIndex:i}=t;return TM({state:e,cellId:n,cellReducer:e=>{let t=[...e.consoleOutputs],n=t[i];return n==null||n.channel!==`stdin`?(L.warn(`Expected stdin output`),e):(t[i]={channel:`stdin`,mimetype:n.mimetype,data:n.data,timestamp:n.timestamp,id:n.id,response:n.mimetype===`text/password`?``:r},{...e,interrupted:!1,consoleOutputs:t})}})},setCells:(e,t)=>{let n=Object.fromEntries(t.map(e=>[e.id,e])),r=ve(),i=t=>{if(!r)return gM();let n=e.cellRuntime[t];return n&&(n.output!=null||n.consoleOutputs.length>0)?n:gM()},a=Object.fromEntries(t.map(e=>[e.id,i(e.id)]));return _M({...e,cellIds:ys.fromIdsAndColumns(t.map(e=>[e.id,e.config.column])),cellData:n,cellRuntime:a,cellHandles:Object.fromEntries(t.map(e=>[e.id,(0,G.createRef)()]))})},moveToNextCell:(e,t)=>{let{cellId:n,before:r,noCreate:i=!1}=t;if(n===`__scratch__`)return e;let a=e.cellIds.findWithId(n),o=a.indexOfOrThrow(n),s=r?o-1:o+1,c=s===a.length,l=s===-1;if(c&&!i){let t=Pi.create();return{...e,cellIds:e.cellIds.insertId(t,a.id,s),cellData:{...e.cellData,[t]:mM({id:t})},cellRuntime:{...e.cellRuntime,[t]:gM()},cellHandles:{...e.cellHandles,[t]:(0,G.createRef)()},scrollKey:t}}if(l&&!i){let t=Pi.create();return{...e,cellIds:e.cellIds.insertId(t,a.id,0),cellData:{...e.cellData,[t]:mM({id:t})},cellRuntime:{...e.cellRuntime,[t]:gM()},cellHandles:{...e.cellHandles,[t]:(0,G.createRef)()},scrollKey:t}}if((c||l)&&i)return e;if(s>=0&&s<a.length){let t=a.atOrThrow(s);lM({cellId:t,cell:e.cellHandles[t],isCodeHidden:wM(e,t),codeFocus:r?`bottom`:`top`,variableName:void 0})}return e},markTouched:(e,t)=>{let{cellId:n}=t;if(e.untouchedNewCells.has(n)){let t=new Set(e.untouchedNewCells);return t.delete(n),{...e,untouchedNewCells:t}}return e},markUntouched:(e,t)=>{let{cellId:n}=t;if(!e.untouchedNewCells.has(n)){let t=new Set(e.untouchedNewCells);return t.add(n),{...e,untouchedNewCells:t}}return e},scrollToTarget:e=>{let t=e.scrollKey;if(t===null)return e;let n=e.cellIds.findWithId(t),r=n.indexOfOrThrow(t),i=r===n.length-1?n.last():n.atOrThrow(r);return lM({cellId:i,cell:e.cellHandles[i],isCodeHidden:wM(e,i),codeFocus:void 0,variableName:void 0}),{...e,scrollKey:null}},foldAll:e=>(zs(Object.values(e.cellHandles).map(e=>e.current?.editorView)),e),unfoldAll:e=>(Bs(Object.values(e.cellHandles).map(e=>e.current?.editorView)),e),clearLogs:e=>({...e,cellLogs:[]}),collapseCell:(e,t)=>{let{cellId:n}=t,r=e.cellIds.findWithId(n),i=r.topLevelIds.map(t=>e.cellRuntime[t].outline),a=HA(r.indexOfOrThrow(n),i);if(!a)return e;let o=r.atOrThrow(a[1]);return{...e,cellIds:e.cellIds.transformWithCellId(n,e=>e.collapse(n,o)),scrollKey:n}},expandCell:(e,t)=>{let{cellId:n}=t;return{...e,cellIds:e.cellIds.transformWithCellId(n,e=>e.expand(n)),scrollKey:n}},collapseAllCells:e=>({...e,cellIds:e.cellIds.transformAll(t=>{let n=t.topLevelIds.map(t=>e.cellRuntime[t].outline),r=[...t.nodes],i=new Map,a=[],o=r.length-1;for(;o>=0;){let e=HA(o,n);if(e){let n=o,r=e[1],s=i.get(r)??r;i.set(r,n);let c=t.atOrThrow(n),l=t.atOrThrow(s);a.push({id:c,until:l})}else a.push(null);o--}let s=a.toReversed();return t.collapseAll(s)})}),expandAllCells:e=>({...e,cellIds:e.cellIds.transformAll(e=>e.expandAll())}),showCellIfHidden:(e,t)=>{let{cellId:n}=t,r=e.cellIds.findWithId(n),i=r,a=r.findAndExpandDeep(n);return a.equals(i)?e:{...e,cellIds:e.cellIds.transformWithCellId(n,()=>a)}},splitCell:(e,t)=>{let{cellId:n}=t,r=e.cellIds.findWithId(n),i=r.indexOfOrThrow(n),a=e.cellData[n],o=e.cellHandles[n].current;if(o?.editorView==null)return e;let{beforeCursorCode:s,afterCursorCode:c}=MA(o.editorView);jA(o.editorView,s);let l=Pi.create();return{...e,cellIds:e.cellIds.insertId(l,r.id,i+1),cellData:{...e.cellData,[n]:{...a,code:s,edited:!!s&&s.trim()!==a.lastCodeRun?.trim()},[l]:mM({id:l,code:c,edited:!!c})},cellRuntime:{...e.cellRuntime,[n]:{...e.cellRuntime[n],output:null,consoleOutputs:[]},[l]:gM()},cellHandles:{...e.cellHandles,[l]:(0,G.createRef)()},scrollKey:l}},undoSplitCell:(e,t)=>{let{cellId:n,snapshot:r}=t,i=e.cellData[n],a=e.cellHandles[n].current;return a?.editorView==null?e:(jA(a.editorView,r),{...e,cellIds:e.cellIds.transformWithCellId(n,e=>{let t=e.indexOfOrThrow(n)+1;return e.deleteAtIndex(t)}),cellData:{...e.cellData,[n]:{...i,code:r,edited:!!r&&r?.trim()!==i.lastCodeRun?.trim()}},cellRuntime:{...e.cellRuntime,[n]:{...e.cellRuntime[n],output:null,consoleOutputs:[]}},cellHandles:{...e.cellHandles}})},clearCellOutput:(e,t)=>{let{cellId:n}=t;return TM({state:e,cellId:n,cellReducer:e=>({...e,output:null,consoleOutputs:[]})})},clearCellConsoleOutput:(e,t)=>{let{cellId:n}=t;return TM({state:e,cellId:n,cellReducer:e=>({...e,consoleOutputs:e.consoleOutputs.filter(e=>e.channel===`stdin`&&e.response==null)})})},clearAllCellOutputs:e=>{let t={...e.cellRuntime};for(let n of e.cellIds.inOrderIds)t[n]={...t[n],output:null,consoleOutputs:[]};return{...e,cellRuntime:t}},addSetupCellIfDoesntExist:(e,t)=>{let{code:n}=t;return e.cellIds.setupCellExists()?{...e,scrollKey:Ni}:{...e,cellIds:e.cellIds.insertId(Ni,e.cellIds.atOrThrow(0).id,0),cellData:{...e.cellData,[Ni]:mM({id:Ni,name:Ni,code:n,edited:!!n})},cellRuntime:{...e.cellRuntime,[Ni]:gM()},cellHandles:{...e.cellHandles,[Ni]:(0,G.createRef)()},scrollKey:Ni}}});bM(Lj);function wM(e,t){return!!e.cellData[t].config.hide_code&&!e.untouchedNewCells.has(t)}function TM({state:e,cellId:t,cellReducer:n}){return t in e.cellRuntime?{...e,cellRuntime:{...e.cellRuntime,[t]:n(e.cellRuntime[t])}}:(L.warn(`Cell ${t} not found in state`),e)}function EM({state:e,cellId:t,cellReducer:n}){return t in e.cellData?{...e,cellData:{...e.cellData,[t]:n(e.cellData[t])}}:(L.warn(`Cell ${t} not found in state`),e)}function DM(e){let t=e.cellData,n={column:null};return e.cellIds.getColumns().length>1?e.cellIds.getColumns().flatMap((e,r)=>e.inOrderIds.map((e,i)=>{let a={...n};return i===0&&(a.column=r),{...t[e].config,...a}})):e.cellIds.getColumns().flatMap(e=>e.inOrderIds.map(e=>({...t[e].config,...n})))}var OM=xM(e=>{u.set(CM,t=>yM(t,e))}).addLogs,kM=o(e=>e(CM).cellIds),AM=o(e=>e(kM).hasOnlyOneId()),jM=o(e=>vf(e(CM)).length>0);o(e=>yf(e(CM)).length>0);var MM=o(e=>bf(e(CM))),NM=o(e=>xf(e(CM))),PM=o(e=>hf(e(CM))),FM=o(e=>{let{cellIds:t,cellRuntime:n,cellData:r}=e(CM);return t.inOrderIds.map(e=>{let t=n[e],{name:i}=r[e];if(ff(t.output?.mimetype)){z(Array.isArray(t.output.data),`Expected array data`);let n=t.output.data.filter(e=>!e.type.includes(`ancestor`));if(n.length>0)return{output:{...t.output,data:n},cellId:e,cellName:i}}return null}).filter(Boolean)}),IM=o(e=>{let t=e(kM),n=e(ZM);return zA(t.inOrderIds.map(e=>n[e].outline))}),LM=o(e=>e(FM).length),RM=c(o(e=>{let{cellIds:t,cellData:n}=e(CM);return R.fromEntries(t.inOrderIds.map(e=>[e,n[e]?.name]))})),zM=o(e=>e(CM).scrollKey),BM=()=>s(CM),VM=()=>s(kM),HM=()=>s(RM),UM=()=>s(FM),WM=()=>s(CM).cellLogs,GM=()=>s(zM),KM=()=>u.get(CM),qM=()=>u.get(CM).cellIds,JM=()=>{let{cellIds:e,cellData:t}=u.get(CM);return e.inOrderIds.map(e=>t[e]?.name).filter(Boolean)},YM=xe(ge(CM,e=>e.cellIds.inOrderIds.map(t=>e.cellData[t]))),XM=()=>a(YM),ZM=o(e=>e(CM).cellRuntime),QM=o(e=>pf(e(CM))),$M=o(e=>{let{cellRuntime:t}=e(CM);return Object.entries(t).every(([e,t])=>t.status!==`running`||e===`__scratch__`)}),eN=o(e=>mf(e(CM))),tN=o(e=>e(CM).cellIds.colLength),nN=o(e=>e(CM).cellIds.idLength>0),rN=o(e=>e(CM).cellIds.getColumnIds()),iN=_e(e=>o(t=>t(CM).cellData[e])),aN=_e(e=>o(t=>t(CM).cellRuntime[e])),oN=_e(e=>o(t=>t(CM).cellHandles[e]));function sN(e){iN.remove(e),aN.remove(e),oN.remove(e)}var cN=e=>{let t=(0,X.c)(2),n;return t[0]===e?n=t[1]:(n=iN(e),t[0]=e,t[1]=n),s(n)},lN=e=>{let t=(0,X.c)(2),n;return t[0]===e?n=t[1]:(n=aN(e),t[0]=e,t[1]=n),s(n)},uN=e=>{let t=(0,X.c)(2),n;return t[0]===e?n=t[1]:(n=oN(e),t[0]=e,t[1]=n),s(n)},dN=()=>{let{cellIds:e,cellHandles:t}=u.get(CM);return e.inOrderIds.map(e=>t[e]?.current?.editorViewOrNull).filter(Boolean)},fN=e=>{let{cellHandles:t}=u.get(CM);return t[e].current?.editorView},pN=e=>(Ws.promote(e),fN(e));function mN(e){let{cellIds:t,cellData:n,cellRuntime:r}=e;return t.getColumns().flatMap(e=>e.topLevelIds.map(e=>({...n[e],...r[e]})))}function hN(e){return o(t=>t(CM).untouchedNewCells.has(e))}function gN(e){let t=aN(e);return o(n=>{let r=n(t);if(!r||r.status===`queued`||r.status===`running`)return;let i=[],a=r.consoleOutputs;if(a&&a.length>0){let e=a.find(e=>e.mimetype===`application/vnd.marimo+traceback`);if(e){let t=e.data;i.push(...Ls(t))}}let o=r.output;if(o?.mimetype===`application/vnd.marimo+error`){let t=o.data;if(Array.isArray(t))for(let n of t)n.type===`syntax`&&n.lineno!=null&&i.push({kind:`cell`,cellId:e,lineNumber:n.lineno}),n.type===`import-star`&&n.lineno!=null&&i.push({kind:`cell`,cellId:e,lineNumber:n.lineno})}return i.length>0?i:void 0})}function _N(e){let t=(0,X.c)(2),n;return t[0]===e?n=t[1]:(n=e===void 0?{}:e,t[0]=e,t[1]=n),SM(n)}export{Rj as $,Lo as $a,kf as $i,Ky as $n,Mh as $r,_O as $t,UM as A,ys as Aa,Cp as Ai,kT as An,bi as Ao,b_ as Ar,wk as At,uM as B,ns as Ba,ip as Bi,Dw as Bn,ig as Br,QO as Bt,eN as C,pu as Ca,Qp as Ci,ED as Cn,Ni as Co,D_ as Cr,Yk as Ct,_N as D,Is as Da,Tp as Di,dE as Dn,Oi as Do,k_ as Dr,Ik as Dt,NM as E,Ls as Ea,kp as Ei,WE as En,Di as Eo,E_ as Er,Lk as Et,lN as F,cs as Fa,xp as Fi,zw as Fn,gg as Fr,sk as Ft,oM as G,qo as Ga,Qf as Gi,LC as Gn,Hh as Gr,IO as Gt,cM as H,Xo as Ha,Kf as Hi,iw as Hn,eg as Hr,VO as Ht,BM as I,os as Ia,gp as Ii,jw as In,ug as Ir,ak as It,Qj as J,Ho as Ja,Jf as Ji,zC as Jn,Ih as Jr,kO as Jt,aM as K,Ko as Ka,Uf as Ki,IC as Kn,Qh as Kr,MO as Kt,GM as L,rs as La,sp as Li,Aw as Ln,ag as Lr,ik as Lt,VM as M,ps as Ma,vp as Mi,Iw as Mn,bg as Mr,Dk as Mt,WM as N,ls as Na,_p as Ni,Rw as Nn,pg as Nr,rk as Nt,cN as O,Ns as Oa,Dp as Oi,PE as On,Si as Oo,d_ as Or,Fk as Ot,HM as P,ss as Pa,hp as Pi,Lw as Pn,vg as Pr,ck as Pt,Hj as Q,Ro as Qa,Vf as Qi,qy as Qn,Fh as Qr,hO as Qt,mM as R,ts as Ra,ap as Ri,Mw as Rn,rg as Rr,ok as Rt,IM as S,kd as Sa,Zp as Si,WD as Sn,Mi as So,S_ as Sr,qk as St,$M as T,Fs as Ta,Op as Ti,KE as Tn,Ii as To,w_ as Tr,Rk as Tt,iM as U,Yo as Ua,Wf as Ui,VC as Un,Yh as Ur,PO as Ut,pM as V,Zo as Va,cp as Vi,Tw as Vn,ng as Vr,BO as Vt,rM as W,Jo as Wa,Gf as Wi,FC as Wn,$h as Wr,FO as Wt,Xj as X,Bo as Xa,Hf as Xi,Lb as Xn,Rh as Xr,SO as Xt,Zj as Y,Vo as Ya,Zf as Yi,Qb as Yn,Lh as Yr,mO as Yt,Yj as Z,zo as Za,Bf as Zi,Yy as Zn,Ph as Zr,CO as Zt,jM as _,tf as _a,dm as _i,QD as _n,Hi as _o,q_ as _r,xA as _t,ZM as a,Sf as aa,_h as ai,uO as an,ko as ao,ly as ar,WA as at,CM as b,Vd as ba,Bp as bi,$D as bn,Ri as bo,T_ as br,Kk as bt,pN as c,gf as ca,fh as ci,eO as cn,Eo as co,Uv as cr,RA as ct,DM as d,Cf as da,uh as di,tO as dn,So as do,xv as dr,AA as dt,Af as ea,Nh as ei,bO as en,Io as eo,My as er,kj as et,fN as f,ff as fa,lh as fi,GD as fn,Pa as fo,cv as fr,jA as ft,nN as g,cf as ga,Om as gi,qD as gn,Vi as go,Z_ as gr,kA as gt,KM as h,lf as ha,Zm as hi,XD as hn,Bi as ho,uv as hr,SA as ht,kM as i,yf as ia,Ch as ii,lO as in,jo as io,hy as ir,GA as it,uN as j,hs as ja,bp as ji,Xw as jn,hi as jo,wg as jr,Ck as jt,XM as k,Ms as ka,Ep as ki,vT as kn,Ci as ko,x_ as kr,Ok as kt,mN as l,Df as la,ch as li,rO as ln,wo as lo,Rv as lr,BA as lt,qM as m,df as ma,eh as mi,YD as mn,Ui as mo,tv as mr,EA as mt,iN as n,Ef as na,Th as ni,wO as nn,Po as no,ky as nr,aj as nt,rN as o,wf as oa,hh as oi,sO as on,Oo as oo,uy as or,UA as ot,JM as p,uf as pa,dh as pi,KD as pn,Ra as po,lv as pr,TA as pt,nM as q,Wo as qa,qf as qi,RC as qn,Zh as qr,OO as qt,LM as r,vf as ra,xh as ri,TO as rn,Mo as ro,Ay as rr,oj as rt,hN as s,_f as sa,ph as si,cO as sn,Do as so,Wv as sr,VA as st,MM as t,Tf as ta,Ah as ti,xO as tn,J as to,jy as tr,Pj as tt,dN as u,Of as ua,sh as ui,aO as un,Co as uo,bv as ur,NA as ut,AM as v,ef as va,um as vi,JD as vn,zi as vo,Y_ as vr,OA as vt,tN as w,Ws as wa,Wp as wi,GE as wn,Li as wo,O_ as wr,Xk as wt,QM as x,Hd as xa,zp as xi,UD as xn,Fi as xo,C_ as xr,Gk as xt,PM as y,Yd as ya,Np as yi,ZD as yn,Pi as yo,V_ as yr,Qk as yt,gM as z,es as za,op as zi,kw as zn,Q as zr,$O as zt};
|