From 6f1a3173579293fa477476b77c5e4cf8aed9a7a3 Mon Sep 17 00:00:00 2001 From: Ben Baryo <19845603+ctrl-escp@users.noreply.github.com> Date: Sat, 15 Jun 2024 00:31:36 +0300 Subject: [PATCH] Overhaul WiP --- dist/assets/index-BQDMKZTC.css | 1 + dist/assets/index-Df8N4Trg.css | 1 - .../{index-DOa6sDZm.js => index-F3uZgETI.js} | 45 +- dist/flast.js | 20300 +--------------- dist/index.html | 4 +- flast-pkg-builder/build-flast.js | 36 +- flast-pkg-builder/flast-src.js | 4 +- index.html | 2 + package-lock.json | 345 +- public/arborist.js | 3 + public/flast.js | 346 +- src/App.vue | 8 +- src/ComposeEditor.vue | 109 + src/{components => }/FilterEditor.vue | 33 +- src/NavBar.vue | 19 +- src/TransformEditor.vue | 93 + src/components/CodeEditor.vue | 11 +- src/components/CodeViewSwitch.vue | 22 - src/components/InputCodeEditor.vue | 4 +- src/components/NodesList.vue | 8 +- src/components/ParseButton.vue | 13 +- src/main.js | 2 +- src/store.js | 60 +- src/store/exploration.js | 14 - src/store/index.js | 51 - src/store/transformation.js | 2 - src/tabs/ExplorationTab.vue | 62 - src/tabs/TransformationTab.vue | 62 - 28 files changed, 849 insertions(+), 20811 deletions(-) create mode 100644 dist/assets/index-BQDMKZTC.css delete mode 100644 dist/assets/index-Df8N4Trg.css rename dist/assets/{index-DOa6sDZm.js => index-F3uZgETI.js} (88%) create mode 100644 public/arborist.js create mode 100644 src/ComposeEditor.vue rename src/{components => }/FilterEditor.vue (86%) create mode 100644 src/TransformEditor.vue delete mode 100644 src/components/CodeViewSwitch.vue delete mode 100644 src/store/exploration.js delete mode 100644 src/store/index.js delete mode 100644 src/store/transformation.js delete mode 100644 src/tabs/ExplorationTab.vue delete mode 100644 src/tabs/TransformationTab.vue diff --git a/dist/assets/index-BQDMKZTC.css b/dist/assets/index-BQDMKZTC.css new file mode 100644 index 0000000..56aabc1 --- /dev/null +++ b/dist/assets/index-BQDMKZTC.css @@ -0,0 +1 @@ +:root{--vt-c-white: #ffffff;--vt-c-white-soft: #f8f8f8;--vt-c-white-mute: #f2f2f2;--vt-c-black: #181818;--vt-c-black-soft: #222222;--vt-c-black-mute: #282828;--vt-c-indigo: #2c3e50;--vt-c-divider-light-1: rgba(60, 60, 60, .29);--vt-c-divider-light-2: rgba(60, 60, 60, .12);--vt-c-divider-dark-1: rgba(84, 84, 84, .65);--vt-c-divider-dark-2: rgba(84, 84, 84, .48);--vt-c-text-light-1: var(--vt-c-indigo);--vt-c-text-light-2: rgba(60, 60, 60, .66);--vt-c-text-dark-1: var(--vt-c-white);--vt-c-text-dark-2: rgba(235, 235, 235, .64)}:root{--color-background: var(--vt-c-white);--color-background-soft: var(--vt-c-white-soft);--color-background-mute: var(--vt-c-white-mute);--color-border: var(--vt-c-divider-light-2);--color-border-hover: var(--vt-c-divider-light-1);--color-heading: var(--vt-c-text-light-1);--color-text: var(--vt-c-text-light-1);--section-gap: 160px}@media (prefers-color-scheme: dark){:root{--color-background: var(--vt-c-black);--color-background-soft: var(--vt-c-black-soft);--color-background-mute: var(--vt-c-black-mute);--color-border: var(--vt-c-divider-dark-2);--color-border-hover: var(--vt-c-divider-dark-1);--color-heading: var(--vt-c-text-dark-1);--color-text: var(--vt-c-text-dark-2)}}*,*:before,*:after{box-sizing:border-box;margin:0}body{color:var(--color-text);background:var(--color-background);transition:color .5s,background-color .5s;line-height:1.6;font-family:Inter,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,Fira Sans,Droid Sans,Helvetica Neue,sans-serif;font-size:15px;text-rendering:optimizeLegibility;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}:root{--nav-height: 62px}body{padding:2px}.btn{padding:2px 10px;border-radius:8px;font-size:larger;line-height:30px;vertical-align:middle;cursor:pointer;border:1px solid}.btn:active{transform:translate(1px,1px)}.btn:disabled{transform:none;cursor:not-allowed}.highlighted-code{background-color:#ffea0045}.cm-editor{height:100%}.cm-scroller{height:47vh;max-height:47vh}legend{height:1.5rem}.btn-load-file[data-v-60cc057b]{background-color:#a892cb}.inputFile[data-v-60cc057b]{display:none}.unparsed[data-v-495cc9b9]{background-color:#d05858}.parsed[data-v-495cc9b9]{background-color:#41e804}a[data-v-b40af671]{display:flex;align-items:center}a[data-v-b40af671]:link{text-decoration:none}.active[data-v-b40af671]{box-shadow:0 0 .7rem .4rem #ff00004d}.github-text[data-v-b40af671]{color:#fff;margin-right:10px}main[data-v-b40af671]{margin-top:.5rem}nav[data-v-b40af671]{background-color:#212121;display:flex;align-items:center;border-radius:10px;justify-content:space-between;height:var(--nav-height)}.nav-left[data-v-b40af671]{display:flex;align-items:center}.nav-title[data-v-b40af671]{font-size:2.4rem}.top-btn[data-v-b40af671]{margin:0 5px}.top-buttons[data-v-b40af671]{display:flex;flex-direction:row}.ast-list-wrapper[data-v-45fa1d29]{display:flex;flex:1;flex-direction:column;height:50vh;padding:0 5px;overflow-x:hidden;overflow-y:auto}.prev-page[data-v-45fa1d29],.next-page[data-v-45fa1d29]{background-color:transparent;color:#fff;font-size:large}.highlight-node[data-v-45fa1d29]{background-color:#ffea0045}legend[data-v-45fa1d29]{font-size:larger}.node-container[data-v-45fa1d29]{display:flex;margin:2px 0;white-space:nowrap;text-overflow:ellipsis;gap:.5rem}.node-parent-type[data-v-45fa1d29]{color:green;vertical-align:super;font-size:x-small}.node-src[data-v-45fa1d29]{max-width:calc(50vw - 20rem);min-width:30vw;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.node-type[data-v-45fa1d29]{color:#41e804}.paged[data-v-45fa1d29]{margin-inline-end:10px}.code-editor[data-v-34dc6d07]{width:100%;height:100%}.code-editor-wrapper[data-v-57219ecd]{flex:1;min-width:40vw;padding:0;width:100%;height:50vh}legend[data-v-57219ecd]{font-size:larger}.code-and-nodes[data-v-ef72c9dc]{flex:1;display:flex;flex-wrap:wrap}.applied-filters-wrapper[data-v-1962bad8]{flex:1;padding:5px;overflow:auto;min-width:41%}.applied-filters-wrapper>fieldset[data-v-1962bad8]{min-width:40vw}.btn-apply[data-v-1962bad8]{background-color:#adff2f}.btn-clear-all-filters[data-v-1962bad8]{float:right;margin-right:0!important;margin-left:5px}.btn-group[data-v-1962bad8]{display:flex;justify-content:space-between}.btn-group>*>button[data-v-1962bad8]{margin-right:5px}.btn-group-inline[data-v-1962bad8]{display:flex;align-items:center;float:right;margin-right:5px}.filter-controller[data-v-1962bad8]{margin-top:5px;width:100%}.filter-display[data-v-1962bad8]{display:flex;flex-wrap:wrap;height:90%}.filter-editor-wrapper[data-v-1962bad8]{flex:1;overflow:auto;padding:0}.filter-line[data-v-1962bad8]{display:flex;flex:1}.filter-src[data-v-1962bad8]{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.icon-inline[data-v-1962bad8]{cursor:pointer;width:20px;margin:0 .3rem}legend[data-v-1962bad8]{font-size:larger}.applied-filters-wrapper[data-v-c883ae44]{flex:1;padding:5px;overflow:auto;min-width:41%}.applied-filters-wrapper>fieldset[data-v-c883ae44]{min-width:40vw}.btn-apply[data-v-c883ae44]{background-color:#adff2f}.btn-clear-all-filters[data-v-c883ae44]{float:right;margin-right:0!important;margin-left:5px}.btn-group[data-v-c883ae44]{display:flex;justify-content:space-between}.btn-group>*>button[data-v-c883ae44]{margin-right:5px}.btn-group-inline[data-v-c883ae44]{display:flex;align-items:center;float:right;margin-right:5px}.filter-controller[data-v-c883ae44]{margin-top:5px;width:100%}.filter-display[data-v-c883ae44]{display:flex;flex-wrap:wrap;height:90%}.filter-editor-wrapper[data-v-c883ae44]{flex:1;overflow:auto;padding:0}.filter-line[data-v-c883ae44]{display:flex;flex:1}.filter-src[data-v-c883ae44]{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.icon-inline[data-v-c883ae44]{cursor:pointer;width:20px}legend[data-v-c883ae44]{font-size:larger}.toast[data-v-5d1358b2]{padding:10px;margin:5px;color:#000;font-size:larger;text-align:center;width:fit-content;height:fit-content;border-radius:8px;z-index:10;min-width:350px;max-width:500px;min-height:30px;max-height:80px;text-overflow:ellipsis;overflow:hidden}.toast-close-message[data-v-5d1358b2]{float:right;font-size:larger;margin-top:-8px;background-color:transparent;border:none}.toast-close-message[data-v-5d1358b2]:active{transform:translate(1px,2px)}.toast-error[data-v-5d1358b2]{background-color:red}.toast-info[data-v-5d1358b2]{background-color:#ff0}.toast-success[data-v-5d1358b2]{background-color:#adff2f}.toast-appear[data-v-810ce0bb]{visibility:visible;-webkit-animation:fadein-810ce0bb .5s;animation:fadein-810ce0bb .5s;animation-fill-mode:forwards}.toast-disappear[data-v-810ce0bb]{-webkit-animation:fadeout-810ce0bb .5s;animation:fadeout-810ce0bb .5s;animation-fill-mode:forwards}.toaster[data-v-810ce0bb]{justify-content:center;position:fixed;bottom:30px}toaster-message[data-v-810ce0bb]{visibility:hidden}@-webkit-keyframes fadein-810ce0bb{0%{bottom:0;opacity:0}to{bottom:30px;opacity:1}}@keyframes fadein-810ce0bb{0%{bottom:0;opacity:0}to{bottom:30px;opacity:1}}@-webkit-keyframes fadeout-810ce0bb{0%{bottom:30px;opacity:1}to{bottom:0;opacity:0}}@keyframes fadeout-810ce0bb{0%{bottom:30px;opacity:1}to{bottom:0;opacity:0}}main[data-v-e6172598]{margin-top:.5rem}.pane-bottom[data-v-e6172598]{flex:1;display:flex}.panes[data-v-e6172598]{display:flex;flex-direction:column;height:calc(95vh - var(--nav-height));gap:.2rem;width:100%} diff --git a/dist/assets/index-Df8N4Trg.css b/dist/assets/index-Df8N4Trg.css deleted file mode 100644 index 52f069f..0000000 --- a/dist/assets/index-Df8N4Trg.css +++ /dev/null @@ -1 +0,0 @@ -:root{--vt-c-white: #ffffff;--vt-c-white-soft: #f8f8f8;--vt-c-white-mute: #f2f2f2;--vt-c-black: #181818;--vt-c-black-soft: #222222;--vt-c-black-mute: #282828;--vt-c-indigo: #2c3e50;--vt-c-divider-light-1: rgba(60, 60, 60, .29);--vt-c-divider-light-2: rgba(60, 60, 60, .12);--vt-c-divider-dark-1: rgba(84, 84, 84, .65);--vt-c-divider-dark-2: rgba(84, 84, 84, .48);--vt-c-text-light-1: var(--vt-c-indigo);--vt-c-text-light-2: rgba(60, 60, 60, .66);--vt-c-text-dark-1: var(--vt-c-white);--vt-c-text-dark-2: rgba(235, 235, 235, .64)}:root{--color-background: var(--vt-c-white);--color-background-soft: var(--vt-c-white-soft);--color-background-mute: var(--vt-c-white-mute);--color-border: var(--vt-c-divider-light-2);--color-border-hover: var(--vt-c-divider-light-1);--color-heading: var(--vt-c-text-light-1);--color-text: var(--vt-c-text-light-1);--section-gap: 160px}@media (prefers-color-scheme: dark){:root{--color-background: var(--vt-c-black);--color-background-soft: var(--vt-c-black-soft);--color-background-mute: var(--vt-c-black-mute);--color-border: var(--vt-c-divider-dark-2);--color-border-hover: var(--vt-c-divider-dark-1);--color-heading: var(--vt-c-text-dark-1);--color-text: var(--vt-c-text-dark-2)}}*,*:before,*:after{box-sizing:border-box;margin:0}body{color:var(--color-text);background:var(--color-background);transition:color .5s,background-color .5s;line-height:1.6;font-family:Inter,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,Fira Sans,Droid Sans,Helvetica Neue,sans-serif;font-size:15px;text-rendering:optimizeLegibility;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}:root{--nav-height: 62px}body{padding:2px}.btn{padding:2px 10px;border-radius:8px;font-size:larger;line-height:30px;vertical-align:middle;cursor:pointer;border:1px solid}.btn:active{transform:translate(1px,1px)}.btn:disabled{transform:none;cursor:not-allowed}.highlighted-code{background-color:#ffea0045}.cm-editor{height:100%}.cm-scroller{height:47vh;max-height:47vh}legend{height:1.5rem}.btn-load-file[data-v-60cc057b]{background-color:#a892cb}.inputFile[data-v-60cc057b]{display:none}.unparsed[data-v-495cc9b9]{background-color:#d05858}.parsed[data-v-495cc9b9]{background-color:#41e804}a[data-v-dcc72627]{display:flex;align-items:center}a[data-v-dcc72627]:link{text-decoration:none}.active[data-v-dcc72627]{box-shadow:0 0 .7rem .4rem #ff00004d}.btn-transform[data-v-dcc72627]{background-color:transparent;color:#fff}.github-text[data-v-dcc72627]{color:#fff;margin-right:10px}main[data-v-dcc72627]{margin-top:.5rem}nav[data-v-dcc72627]{background-color:#212121;display:flex;align-items:center;border-radius:10px;justify-content:space-between;height:var(--nav-height)}.nav-left[data-v-dcc72627]{display:flex;align-items:center}.nav-title[data-v-dcc72627]{font-size:2.4rem}.top-btn[data-v-dcc72627]{margin:0 5px}.top-buttons[data-v-dcc72627]{display:flex;flex-direction:row}.ast-list-wrapper[data-v-45fa1d29]{display:flex;flex:1;flex-direction:column;height:50vh;padding:0 5px;overflow-x:hidden;overflow-y:auto}.prev-page[data-v-45fa1d29],.next-page[data-v-45fa1d29]{background-color:transparent;color:#fff;font-size:large}.highlight-node[data-v-45fa1d29]{background-color:#ffea0045}legend[data-v-45fa1d29]{font-size:larger}.node-container[data-v-45fa1d29]{display:flex;margin:2px 0;white-space:nowrap;text-overflow:ellipsis;gap:.5rem}.node-parent-type[data-v-45fa1d29]{color:green;vertical-align:super;font-size:x-small}.node-src[data-v-45fa1d29]{max-width:calc(50vw - 20rem);min-width:30vw;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.node-type[data-v-45fa1d29]{color:#41e804}.paged[data-v-45fa1d29]{margin-inline-end:10px}.code-editor[data-v-982160fb]{width:100%;height:100%}.code-editor-wrapper[data-v-667f3d58]{flex:1;min-width:40vw;padding:0;width:100%;height:50vh}legend[data-v-667f3d58]{font-size:larger}.code-and-nodes[data-v-ef72c9dc]{flex:1;display:flex;flex-wrap:wrap}.toast[data-v-5d1358b2]{padding:10px;margin:5px;color:#000;font-size:larger;text-align:center;width:fit-content;height:fit-content;border-radius:8px;z-index:10;min-width:350px;max-width:500px;min-height:30px;max-height:80px;text-overflow:ellipsis;overflow:hidden}.toast-close-message[data-v-5d1358b2]{float:right;font-size:larger;margin-top:-8px;background-color:transparent;border:none}.toast-close-message[data-v-5d1358b2]:active{transform:translate(1px,2px)}.toast-error[data-v-5d1358b2]{background-color:red}.toast-info[data-v-5d1358b2]{background-color:#ff0}.toast-success[data-v-5d1358b2]{background-color:#adff2f}.toast-appear[data-v-810ce0bb]{visibility:visible;-webkit-animation:fadein-810ce0bb .5s;animation:fadein-810ce0bb .5s;animation-fill-mode:forwards}.toast-disappear[data-v-810ce0bb]{-webkit-animation:fadeout-810ce0bb .5s;animation:fadeout-810ce0bb .5s;animation-fill-mode:forwards}.toaster[data-v-810ce0bb]{justify-content:center;position:fixed;bottom:30px}toaster-message[data-v-810ce0bb]{visibility:hidden}@-webkit-keyframes fadein-810ce0bb{0%{bottom:0;opacity:0}to{bottom:30px;opacity:1}}@keyframes fadein-810ce0bb{0%{bottom:0;opacity:0}to{bottom:30px;opacity:1}}@-webkit-keyframes fadeout-810ce0bb{0%{bottom:30px;opacity:1}to{bottom:0;opacity:0}}@keyframes fadeout-810ce0bb{0%{bottom:30px;opacity:1}to{bottom:0;opacity:0}}.applied-filters-wrapper[data-v-a9d18325]{flex:1;padding:5px;overflow:auto;min-width:41%}.applied-filters-wrapper>fieldset[data-v-a9d18325]{min-width:40vw}.btn-apply[data-v-a9d18325]{background-color:#adff2f}.btn-clear-all-filters[data-v-a9d18325]{float:right;margin-right:0!important;margin-left:5px}.btn-group[data-v-a9d18325]{display:flex;justify-content:space-between}.btn-group>*>button[data-v-a9d18325]{margin-right:5px}.btn-group-inline[data-v-a9d18325]{display:flex;align-items:center;float:right;margin-right:5px}.filter-controller[data-v-a9d18325]{margin-top:5px;width:100%}.filter-display[data-v-a9d18325]{display:flex;flex-wrap:wrap;height:90%}.filter-editor-wrapper[data-v-a9d18325]{flex:1;overflow:auto;padding:0}.filter-line[data-v-a9d18325]{display:flex;flex:1}.filter-src[data-v-a9d18325]{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.icon-inline[data-v-a9d18325]{cursor:pointer;width:20px}legend[data-v-a9d18325]{font-size:larger}main[data-v-108a0431]{margin-top:.5rem}.pane-bottom[data-v-108a0431]{flex:1;display:flex}.panes[data-v-108a0431]{display:flex;flex-direction:column;height:calc(95vh - var(--nav-height));gap:.2rem;width:100%} diff --git a/dist/assets/index-DOa6sDZm.js b/dist/assets/index-F3uZgETI.js similarity index 88% rename from dist/assets/index-DOa6sDZm.js rename to dist/assets/index-F3uZgETI.js index 03a7528..7669b46 100644 --- a/dist/assets/index-DOa6sDZm.js +++ b/dist/assets/index-F3uZgETI.js @@ -13,11 +13,11 @@ **/const stack=[];function warn$1(r,...e){pauseTracking();const n=stack.length?stack[stack.length-1].component:null,s=n&&n.appContext.config.warnHandler,o=getComponentTrace();if(s)callWithErrorHandling(s,n,11,[r+e.map(l=>{var a,c;return(c=(a=l.toString)==null?void 0:a.call(l))!=null?c:JSON.stringify(l)}).join(""),n&&n.proxy,o.map(({vnode:l})=>`at <${formatComponentName(n,l.type)}>`).join(` `),o]);else{const l=[`[Vue warn]: ${r}`,...e];o.length&&l.push(` `,...formatTrace(o)),console.warn(...l)}resetTracking()}function getComponentTrace(){let r=stack[stack.length-1];if(!r)return[];const e=[];for(;r;){const n=e[0];n&&n.vnode===r?n.recurseCount++:e.push({vnode:r,recurseCount:0});const s=r.component&&r.component.parent;r=s&&s.vnode}return e}function formatTrace(r){const e=[];return r.forEach((n,s)=>{e.push(...s===0?[]:[` -`],...formatTraceEntry(n))}),e}function formatTraceEntry({vnode:r,recurseCount:e}){const n=e>0?`... (${e} recursive calls)`:"",s=r.component?r.component.parent==null:!1,o=` at <${formatComponentName(r.component,r.type,s)}`,l=">"+n;return r.props?[o,...formatProps(r.props),l]:[o+l]}function formatProps(r){const e=[],n=Object.keys(r);return n.slice(0,3).forEach(s=>{e.push(...formatProp(s,r[s]))}),n.length>3&&e.push(" ..."),e}function formatProp(r,e,n){return isString(e)?(e=JSON.stringify(e),n?e:[`${r}=${e}`]):typeof e=="number"||typeof e=="boolean"||e==null?n?e:[`${r}=${e}`]:isRef(e)?(e=formatProp(r,toRaw(e.value),!0),n?e:[`${r}=Ref<`,e,">"]):isFunction(e)?[`${r}=fn${e.name?`<${e.name}>`:""}`]:(e=toRaw(e),n?e:[`${r}=`,e])}function callWithErrorHandling(r,e,n,s){try{return s?r(...s):r()}catch(o){handleError(o,e,n)}}function callWithAsyncErrorHandling(r,e,n,s){if(isFunction(r)){const o=callWithErrorHandling(r,e,n,s);return o&&isPromise(o)&&o.catch(l=>{handleError(l,e,n)}),o}if(isArray(r)){const o=[];for(let l=0;l>>1,o=queue[s],l=getId(o);lflushIndex&&queue.splice(e,1)}function queuePostFlushCb(r){isArray(r)?pendingPostFlushCbs.push(...r):(!activePostFlushCbs||!activePostFlushCbs.includes(r,r.allowRecurse?postFlushIndex+1:postFlushIndex))&&pendingPostFlushCbs.push(r),queueFlush()}function flushPreFlushCbs(r,e,n=isFlushing?flushIndex+1:0){for(;ngetId(n)-getId(s));if(pendingPostFlushCbs.length=0,activePostFlushCbs){activePostFlushCbs.push(...e);return}for(activePostFlushCbs=e,postFlushIndex=0;postFlushIndexr.id==null?1/0:r.id,comparator=(r,e)=>{const n=getId(r)-getId(e);if(n===0){if(r.pre&&!e.pre)return-1;if(e.pre&&!r.pre)return 1}return n};function flushJobs(r){isFlushPending=!1,isFlushing=!0,queue.sort(comparator);try{for(flushIndex=0;flushIndexisString(O)?O.trim():O)),d&&(o=n.map(looseToNumber))}let c,h=s[c=toHandlerKey(e)]||s[c=toHandlerKey(camelize(e))];!h&&l&&(h=s[c=toHandlerKey(hyphenate(e))]),h&&callWithAsyncErrorHandling(h,r,6,o);const f=s[c+"Once"];if(f){if(!r.emitted)r.emitted={};else if(r.emitted[c])return;r.emitted[c]=!0,callWithAsyncErrorHandling(f,r,6,o)}}function normalizeEmitsOptions(r,e,n=!1){const s=e.emitsCache,o=s.get(r);if(o!==void 0)return o;const l=r.emits;let a={},c=!1;if(!isFunction(r)){const h=f=>{const u=normalizeEmitsOptions(f,e,!0);u&&(c=!0,extend$1(a,u))};!n&&e.mixins.length&&e.mixins.forEach(h),r.extends&&h(r.extends),r.mixins&&r.mixins.forEach(h)}return!l&&!c?(isObject(r)&&s.set(r,null),null):(isArray(l)?l.forEach(h=>a[h]=null):extend$1(a,l),isObject(r)&&s.set(r,a),a)}function isEmitListener(r,e){return!r||!isOn(e)?!1:(e=e.slice(2).replace(/Once$/,""),hasOwn(r,e[0].toLowerCase()+e.slice(1))||hasOwn(r,hyphenate(e))||hasOwn(r,e))}let currentRenderingInstance=null,currentScopeId=null;function setCurrentRenderingInstance(r){const e=currentRenderingInstance;return currentRenderingInstance=r,currentScopeId=r&&r.type.__scopeId||null,e}function pushScopeId(r){currentScopeId=r}function popScopeId(){currentScopeId=null}function withCtx(r,e=currentRenderingInstance,n){if(!e||r._n)return r;const s=(...o)=>{s._d&&setBlockTracking(-1);const l=setCurrentRenderingInstance(e);let a;try{a=r(...o)}finally{setCurrentRenderingInstance(l),s._d&&setBlockTracking(1)}return a};return s._n=!0,s._c=!0,s._d=!0,s}function markAttrsAccessed(){}function renderComponentRoot(r){const{type:e,vnode:n,proxy:s,withProxy:o,propsOptions:[l],slots:a,attrs:c,emit:h,render:f,renderCache:u,props:d,data:g,setupState:O,ctx:m,inheritAttrs:y}=r,b=setCurrentRenderingInstance(r);let w,P;try{if(n.shapeFlag&4){const A=o||s,v=A;w=normalizeVNode(f.call(v,A,u,d,O,g,m)),P=c}else{const A=e;w=normalizeVNode(A.length>1?A(d,{attrs:c,slots:a,emit:h}):A(d,null)),P=e.props?c:getFunctionalFallthrough(c)}}catch(A){blockStack.length=0,handleError(A,r,1),w=createVNode(Comment)}let $=w;if(P&&y!==!1){const A=Object.keys(P),{shapeFlag:v}=$;A.length&&v&7&&(l&&A.some(isModelListener)&&(P=filterModelListeners(P,l)),$=cloneVNode($,P,!1,!0))}return n.dirs&&($=cloneVNode($,null,!1,!0),$.dirs=$.dirs?$.dirs.concat(n.dirs):n.dirs),n.transition&&($.transition=n.transition),w=$,setCurrentRenderingInstance(b),w}const getFunctionalFallthrough=r=>{let e;for(const n in r)(n==="class"||n==="style"||isOn(n))&&((e||(e={}))[n]=r[n]);return e},filterModelListeners=(r,e)=>{const n={};for(const s in r)(!isModelListener(s)||!(s.slice(9)in e))&&(n[s]=r[s]);return n};function shouldUpdateComponent(r,e,n){const{props:s,children:o,component:l}=r,{props:a,children:c,patchFlag:h}=e,f=l.emitsOptions;if(e.dirs||e.transition)return!0;if(n&&h>=0){if(h&1024)return!0;if(h&16)return s?hasPropsChanged(s,a,f):!!a;if(h&8){const u=e.dynamicProps;for(let d=0;dr.__isSuspense;function queueEffectWithSuspense(r,e){e&&e.pendingBranch?isArray(r)?e.effects.push(...r):e.effects.push(r):queuePostFlushCb(r)}const ssrContextKey=Symbol.for("v-scx"),useSSRContext=()=>inject(ssrContextKey),INITIAL_WATCHER_VALUE={};function watch(r,e,n){return doWatch(r,e,n)}function doWatch(r,e,{immediate:n,deep:s,flush:o,once:l,onTrack:a,onTrigger:c}=EMPTY_OBJ){if(e&&l){const Q=e;e=(..._)=>{Q(..._),v()}}const h=currentInstance,f=Q=>s===!0?Q:traverse(Q,s===!1?1:void 0);let u,d=!1,g=!1;if(isRef(r)?(u=()=>r.value,d=isShallow(r)):isReactive(r)?(u=()=>f(r),d=!0):isArray(r)?(g=!0,d=r.some(Q=>isReactive(Q)||isShallow(Q)),u=()=>r.map(Q=>{if(isRef(Q))return Q.value;if(isReactive(Q))return f(Q);if(isFunction(Q))return callWithErrorHandling(Q,h,2)})):isFunction(r)?e?u=()=>callWithErrorHandling(r,h,2):u=()=>(O&&O(),callWithAsyncErrorHandling(r,h,3,[m])):u=NOOP,e&&s){const Q=u;u=()=>traverse(Q())}let O,m=Q=>{O=$.onStop=()=>{callWithErrorHandling(Q,h,4),O=$.onStop=void 0}},y;if(isInSSRComponentSetup)if(m=NOOP,e?n&&callWithAsyncErrorHandling(e,h,3,[u(),g?[]:void 0,m]):u(),o==="sync"){const Q=useSSRContext();y=Q.__watcherHandles||(Q.__watcherHandles=[])}else return NOOP;let b=g?new Array(r.length).fill(INITIAL_WATCHER_VALUE):INITIAL_WATCHER_VALUE;const w=()=>{if(!(!$.active||!$.dirty))if(e){const Q=$.run();(s||d||(g?Q.some((_,W)=>hasChanged(_,b[W])):hasChanged(Q,b)))&&(O&&O(),callWithAsyncErrorHandling(e,h,3,[Q,b===INITIAL_WATCHER_VALUE?void 0:g&&b[0]===INITIAL_WATCHER_VALUE?[]:b,m]),b=Q)}else $.run()};w.allowRecurse=!!e;let P;o==="sync"?P=w:o==="post"?P=()=>queuePostRenderEffect(w,h&&h.suspense):(w.pre=!0,h&&(w.id=h.uid),P=()=>queueJob(w));const $=new ReactiveEffect(u,NOOP,P),A=getCurrentScope(),v=()=>{$.stop(),A&&remove$1(A.effects,$)};return e?n?w():b=$.run():o==="post"?queuePostRenderEffect($.run.bind($),h&&h.suspense):$.run(),y&&y.push(v),v}function instanceWatch(r,e,n){const s=this.proxy,o=isString(r)?r.includes(".")?createPathGetter(s,r):()=>s[r]:r.bind(s,s);let l;isFunction(e)?l=e:(l=e.handler,n=e);const a=setCurrentInstance(this),c=doWatch(o,l.bind(s),n);return a(),c}function createPathGetter(r,e){const n=e.split(".");return()=>{let s=r;for(let o=0;o{traverse(s,e,n)});else if(isPlainObject(r))for(const s in r)traverse(r[s],e,n);return r}function withDirectives(r,e){if(currentRenderingInstance===null)return r;const n=getExposeProxy(currentRenderingInstance)||currentRenderingInstance.proxy,s=r.dirs||(r.dirs=[]);for(let o=0;o!!r.type.__asyncLoader,isKeepAlive=r=>r.type.__isKeepAlive;function onActivated(r,e){registerKeepAliveHook(r,"a",e)}function onDeactivated(r,e){registerKeepAliveHook(r,"da",e)}function registerKeepAliveHook(r,e,n=currentInstance){const s=r.__wdc||(r.__wdc=()=>{let o=n;for(;o;){if(o.isDeactivated)return;o=o.parent}return r()});if(injectHook(e,s,n),n){let o=n.parent;for(;o&&o.parent;)isKeepAlive(o.parent.vnode)&&injectToKeepAliveRoot(s,e,n,o),o=o.parent}}function injectToKeepAliveRoot(r,e,n,s){const o=injectHook(e,r,s,!0);onUnmounted(()=>{remove$1(s[e],o)},n)}function injectHook(r,e,n=currentInstance,s=!1){if(n){const o=n[r]||(n[r]=[]),l=e.__weh||(e.__weh=(...a)=>{if(n.isUnmounted)return;pauseTracking();const c=setCurrentInstance(n),h=callWithAsyncErrorHandling(e,n,r,a);return c(),resetTracking(),h});return s?o.unshift(l):o.push(l),l}}const createHook=r=>(e,n=currentInstance)=>(!isInSSRComponentSetup||r==="sp")&&injectHook(r,(...s)=>e(...s),n),onBeforeMount=createHook("bm"),onMounted=createHook("m"),onBeforeUpdate=createHook("bu"),onUpdated=createHook("u"),onBeforeUnmount=createHook("bum"),onUnmounted=createHook("um"),onServerPrefetch=createHook("sp"),onRenderTriggered=createHook("rtg"),onRenderTracked=createHook("rtc");function onErrorCaptured(r,e=currentInstance){injectHook("ec",r,e)}function renderList(r,e,n,s){let o;const l=n;if(isArray(r)||isString(r)){o=new Array(r.length);for(let a=0,c=r.length;ae(a,c,void 0,l));else{const a=Object.keys(r);o=new Array(a.length);for(let c=0,h=a.length;cr?isStatefulComponent(r)?getExposeProxy(r)||r.proxy:getPublicInstance(r.parent):null,publicPropertiesMap=extend$1(Object.create(null),{$:r=>r,$el:r=>r.vnode.el,$data:r=>r.data,$props:r=>r.props,$attrs:r=>r.attrs,$slots:r=>r.slots,$refs:r=>r.refs,$parent:r=>getPublicInstance(r.parent),$root:r=>getPublicInstance(r.root),$emit:r=>r.emit,$options:r=>resolveMergedOptions(r),$forceUpdate:r=>r.f||(r.f=()=>{r.effect.dirty=!0,queueJob(r.update)}),$nextTick:r=>r.n||(r.n=nextTick.bind(r.proxy)),$watch:r=>instanceWatch.bind(r)}),hasSetupBinding=(r,e)=>r!==EMPTY_OBJ&&!r.__isScriptSetup&&hasOwn(r,e),PublicInstanceProxyHandlers={get({_:r},e){if(e==="__v_skip")return!0;const{ctx:n,setupState:s,data:o,props:l,accessCache:a,type:c,appContext:h}=r;let f;if(e[0]!=="$"){const O=a[e];if(O!==void 0)switch(O){case 1:return s[e];case 2:return o[e];case 4:return n[e];case 3:return l[e]}else{if(hasSetupBinding(s,e))return a[e]=1,s[e];if(o!==EMPTY_OBJ&&hasOwn(o,e))return a[e]=2,o[e];if((f=r.propsOptions[0])&&hasOwn(f,e))return a[e]=3,l[e];if(n!==EMPTY_OBJ&&hasOwn(n,e))return a[e]=4,n[e];shouldCacheAccess&&(a[e]=0)}}const u=publicPropertiesMap[e];let d,g;if(u)return e==="$attrs"&&track(r.attrs,"get",""),u(r);if((d=c.__cssModules)&&(d=d[e]))return d;if(n!==EMPTY_OBJ&&hasOwn(n,e))return a[e]=4,n[e];if(g=h.config.globalProperties,hasOwn(g,e))return g[e]},set({_:r},e,n){const{data:s,setupState:o,ctx:l}=r;return hasSetupBinding(o,e)?(o[e]=n,!0):s!==EMPTY_OBJ&&hasOwn(s,e)?(s[e]=n,!0):hasOwn(r.props,e)||e[0]==="$"&&e.slice(1)in r?!1:(l[e]=n,!0)},has({_:{data:r,setupState:e,accessCache:n,ctx:s,appContext:o,propsOptions:l}},a){let c;return!!n[a]||r!==EMPTY_OBJ&&hasOwn(r,a)||hasSetupBinding(e,a)||(c=l[0])&&hasOwn(c,a)||hasOwn(s,a)||hasOwn(publicPropertiesMap,a)||hasOwn(o.config.globalProperties,a)},defineProperty(r,e,n){return n.get!=null?r._.accessCache[e]=0:hasOwn(n,"value")&&this.set(r,e,n.value,null),Reflect.defineProperty(r,e,n)}};function normalizePropsOrEmits(r){return isArray(r)?r.reduce((e,n)=>(e[n]=null,e),{}):r}let shouldCacheAccess=!0;function applyOptions(r){const e=resolveMergedOptions(r),n=r.proxy,s=r.ctx;shouldCacheAccess=!1,e.beforeCreate&&callHook(e.beforeCreate,r,"bc");const{data:o,computed:l,methods:a,watch:c,provide:h,inject:f,created:u,beforeMount:d,mounted:g,beforeUpdate:O,updated:m,activated:y,deactivated:b,beforeDestroy:w,beforeUnmount:P,destroyed:$,unmounted:A,render:v,renderTracked:Q,renderTriggered:_,errorCaptured:W,serverPrefetch:q,expose:Y,inheritAttrs:z,components:L,directives:H,filters:G}=e;if(f&&resolveInjections(f,s,null),a)for(const j in a){const F=a[j];isFunction(F)&&(s[j]=F.bind(n))}if(o){const j=o.call(n,n);isObject(j)&&(r.data=reactive(j))}if(shouldCacheAccess=!0,l)for(const j in l){const F=l[j],se=isFunction(F)?F.bind(n,n):isFunction(F.get)?F.get.bind(n,n):NOOP,te=!isFunction(F)&&isFunction(F.set)?F.set.bind(n):NOOP,oe=computed({get:se,set:te});Object.defineProperty(s,j,{enumerable:!0,configurable:!0,get:()=>oe.value,set:re=>oe.value=re})}if(c)for(const j in c)createWatcher(c[j],s,n,j);if(h){const j=isFunction(h)?h.call(n):h;Reflect.ownKeys(j).forEach(F=>{provide(F,j[F])})}u&&callHook(u,r,"c");function K(j,F){isArray(F)?F.forEach(se=>j(se.bind(n))):F&&j(F.bind(n))}if(K(onBeforeMount,d),K(onMounted,g),K(onBeforeUpdate,O),K(onUpdated,m),K(onActivated,y),K(onDeactivated,b),K(onErrorCaptured,W),K(onRenderTracked,Q),K(onRenderTriggered,_),K(onBeforeUnmount,P),K(onUnmounted,A),K(onServerPrefetch,q),isArray(Y))if(Y.length){const j=r.exposed||(r.exposed={});Y.forEach(F=>{Object.defineProperty(j,F,{get:()=>n[F],set:se=>n[F]=se})})}else r.exposed||(r.exposed={});v&&r.render===NOOP&&(r.render=v),z!=null&&(r.inheritAttrs=z),L&&(r.components=L),H&&(r.directives=H)}function resolveInjections(r,e,n=NOOP){isArray(r)&&(r=normalizeInject(r));for(const s in r){const o=r[s];let l;isObject(o)?"default"in o?l=inject(o.from||s,o.default,!0):l=inject(o.from||s):l=inject(o),isRef(l)?Object.defineProperty(e,s,{enumerable:!0,configurable:!0,get:()=>l.value,set:a=>l.value=a}):e[s]=l}}function callHook(r,e,n){callWithAsyncErrorHandling(isArray(r)?r.map(s=>s.bind(e.proxy)):r.bind(e.proxy),e,n)}function createWatcher(r,e,n,s){const o=s.includes(".")?createPathGetter(n,s):()=>n[s];if(isString(r)){const l=e[r];isFunction(l)&&watch(o,l)}else if(isFunction(r))watch(o,r.bind(n));else if(isObject(r))if(isArray(r))r.forEach(l=>createWatcher(l,e,n,s));else{const l=isFunction(r.handler)?r.handler.bind(n):e[r.handler];isFunction(l)&&watch(o,l,r)}}function resolveMergedOptions(r){const e=r.type,{mixins:n,extends:s}=e,{mixins:o,optionsCache:l,config:{optionMergeStrategies:a}}=r.appContext,c=l.get(e);let h;return c?h=c:!o.length&&!n&&!s?h=e:(h={},o.length&&o.forEach(f=>mergeOptions(h,f,a,!0)),mergeOptions(h,e,a)),isObject(e)&&l.set(e,h),h}function mergeOptions(r,e,n,s=!1){const{mixins:o,extends:l}=e;l&&mergeOptions(r,l,n,!0),o&&o.forEach(a=>mergeOptions(r,a,n,!0));for(const a in e)if(!(s&&a==="expose")){const c=internalOptionMergeStrats[a]||n&&n[a];r[a]=c?c(r[a],e[a]):e[a]}return r}const internalOptionMergeStrats={data:mergeDataFn,props:mergeEmitsOrPropsOptions,emits:mergeEmitsOrPropsOptions,methods:mergeObjectOptions,computed:mergeObjectOptions,beforeCreate:mergeAsArray,created:mergeAsArray,beforeMount:mergeAsArray,mounted:mergeAsArray,beforeUpdate:mergeAsArray,updated:mergeAsArray,beforeDestroy:mergeAsArray,beforeUnmount:mergeAsArray,destroyed:mergeAsArray,unmounted:mergeAsArray,activated:mergeAsArray,deactivated:mergeAsArray,errorCaptured:mergeAsArray,serverPrefetch:mergeAsArray,components:mergeObjectOptions,directives:mergeObjectOptions,watch:mergeWatchOptions,provide:mergeDataFn,inject:mergeInject};function mergeDataFn(r,e){return e?r?function(){return extend$1(isFunction(r)?r.call(this,this):r,isFunction(e)?e.call(this,this):e)}:e:r}function mergeInject(r,e){return mergeObjectOptions(normalizeInject(r),normalizeInject(e))}function normalizeInject(r){if(isArray(r)){const e={};for(let n=0;n1)return n&&isFunction(e)?e.call(s&&s.proxy):e}}const internalObjectProto={},createInternalObject=()=>Object.create(internalObjectProto),isInternalObject=r=>Object.getPrototypeOf(r)===internalObjectProto;function initProps(r,e,n,s=!1){const o={},l=createInternalObject();r.propsDefaults=Object.create(null),setFullProps(r,e,o,l);for(const a in r.propsOptions[0])a in o||(o[a]=void 0);n?r.props=s?o:shallowReactive(o):r.type.props?r.props=o:r.props=l,r.attrs=l}function updateProps(r,e,n,s){const{props:o,attrs:l,vnode:{patchFlag:a}}=r,c=toRaw(o),[h]=r.propsOptions;let f=!1;if((s||a>0)&&!(a&16)){if(a&8){const u=r.vnode.dynamicProps;for(let d=0;d{h=!0;const[g,O]=normalizePropsOptions(d,e,!0);extend$1(a,g),O&&c.push(...O)};!n&&e.mixins.length&&e.mixins.forEach(u),r.extends&&u(r.extends),r.mixins&&r.mixins.forEach(u)}if(!l&&!h)return isObject(r)&&s.set(r,EMPTY_ARR),EMPTY_ARR;if(isArray(l))for(let u=0;u-1,O[1]=y<0||m-1||hasOwn(O,"default"))&&c.push(d)}}}const f=[a,c];return isObject(r)&&s.set(r,f),f}function validatePropName(r){return r[0]!=="$"&&!isReservedProp(r)}function getType(r){return r===null?"null":typeof r=="function"?r.name||"":typeof r=="object"&&r.constructor&&r.constructor.name||""}function isSameType(r,e){return getType(r)===getType(e)}function getTypeIndex(r,e){return isArray(e)?e.findIndex(n=>isSameType(n,r)):isFunction(e)&&isSameType(e,r)?0:-1}const isInternalKey=r=>r[0]==="_"||r==="$stable",normalizeSlotValue=r=>isArray(r)?r.map(normalizeVNode):[normalizeVNode(r)],normalizeSlot=(r,e,n)=>{if(e._n)return e;const s=withCtx((...o)=>normalizeSlotValue(e(...o)),n);return s._c=!1,s},normalizeObjectSlots=(r,e,n)=>{const s=r._ctx;for(const o in r){if(isInternalKey(o))continue;const l=r[o];if(isFunction(l))e[o]=normalizeSlot(o,l,s);else if(l!=null){const a=normalizeSlotValue(l);e[o]=()=>a}}},normalizeVNodeSlots=(r,e)=>{const n=normalizeSlotValue(e);r.slots.default=()=>n},initSlots=(r,e)=>{const n=r.slots=createInternalObject();if(r.vnode.shapeFlag&32){const s=e._;s?(extend$1(n,e),def(n,"_",s,!0)):normalizeObjectSlots(e,n)}else e&&normalizeVNodeSlots(r,e)},updateSlots=(r,e,n)=>{const{vnode:s,slots:o}=r;let l=!0,a=EMPTY_OBJ;if(s.shapeFlag&32){const c=e._;c?n&&c===1?l=!1:(extend$1(o,e),!n&&c===1&&delete o._):(l=!e.$stable,normalizeObjectSlots(e,o)),a=e}else e&&(normalizeVNodeSlots(r,e),a={default:1});if(l)for(const c in o)!isInternalKey(c)&&a[c]==null&&delete o[c]};function setRef(r,e,n,s,o=!1){if(isArray(r)){r.forEach((g,O)=>setRef(g,e&&(isArray(e)?e[O]:e),n,s,o));return}if(isAsyncWrapper(s)&&!o)return;const l=s.shapeFlag&4?getExposeProxy(s.component)||s.component.proxy:s.el,a=o?null:l,{i:c,r:h}=r,f=e&&e.r,u=c.refs===EMPTY_OBJ?c.refs={}:c.refs,d=c.setupState;if(f!=null&&f!==h&&(isString(f)?(u[f]=null,hasOwn(d,f)&&(d[f]=null)):isRef(f)&&(f.value=null)),isFunction(h))callWithErrorHandling(h,c,12,[a,u]);else{const g=isString(h),O=isRef(h);if(g||O){const m=()=>{if(r.f){const y=g?hasOwn(d,h)?d[h]:u[h]:h.value;o?isArray(y)&&remove$1(y,l):isArray(y)?y.includes(l)||y.push(l):g?(u[h]=[l],hasOwn(d,h)&&(d[h]=u[h])):(h.value=[l],r.k&&(u[r.k]=h.value))}else g?(u[h]=a,hasOwn(d,h)&&(d[h]=a)):O&&(h.value=a,r.k&&(u[r.k]=a))};a?(m.id=-1,queuePostRenderEffect(m,n)):m()}}}const queuePostRenderEffect=queueEffectWithSuspense;function createRenderer(r){return baseCreateRenderer(r)}function baseCreateRenderer(r,e){const n=getGlobalThis();n.__VUE__=!0;const{insert:s,remove:o,patchProp:l,createElement:a,createText:c,createComment:h,setText:f,setElementText:u,parentNode:d,nextSibling:g,setScopeId:O=NOOP,insertStaticContent:m}=r,y=(S,x,k,T=null,R=null,Z=null,D=void 0,E=null,B=!!x.dynamicChildren)=>{if(S===x)return;S&&!isSameVNodeType(S,x)&&(T=ye(S),re(S,R,Z,!0),S=null),x.patchFlag===-2&&(B=!1,x.dynamicChildren=null);const{type:M,ref:I,shapeFlag:N}=x;switch(M){case Text$1:b(S,x,k,T);break;case Comment:w(S,x,k,T);break;case Static:S==null&&P(x,k,T,D);break;case Fragment:L(S,x,k,T,R,Z,D,E,B);break;default:N&1?v(S,x,k,T,R,Z,D,E,B):N&6?H(S,x,k,T,R,Z,D,E,B):(N&64||N&128)&&M.process(S,x,k,T,R,Z,D,E,B,Oe)}I!=null&&R&&setRef(I,S&&S.ref,Z,x||S,!x)},b=(S,x,k,T)=>{if(S==null)s(x.el=c(x.children),k,T);else{const R=x.el=S.el;x.children!==S.children&&f(R,x.children)}},w=(S,x,k,T)=>{S==null?s(x.el=h(x.children||""),k,T):x.el=S.el},P=(S,x,k,T)=>{[S.el,S.anchor]=m(S.children,x,k,T,S.el,S.anchor)},$=({el:S,anchor:x},k,T)=>{let R;for(;S&&S!==x;)R=g(S),s(S,k,T),S=R;s(x,k,T)},A=({el:S,anchor:x})=>{let k;for(;S&&S!==x;)k=g(S),o(S),S=k;o(x)},v=(S,x,k,T,R,Z,D,E,B)=>{x.type==="svg"?D="svg":x.type==="math"&&(D="mathml"),S==null?Q(x,k,T,R,Z,D,E,B):q(S,x,R,Z,D,E,B)},Q=(S,x,k,T,R,Z,D,E)=>{let B,M;const{props:I,shapeFlag:N,transition:V,dirs:X}=S;if(B=S.el=a(S.type,Z,I&&I.is,I),N&8?u(B,S.children):N&16&&W(S.children,B,null,T,R,resolveChildrenNamespace(S,Z),D,E),X&&invokeDirectiveHook(S,null,T,"created"),_(B,S,S.scopeId,D,T),I){for(const J in I)J!=="value"&&!isReservedProp(J)&&l(B,J,null,I[J],Z,S.children,T,R,ce);"value"in I&&l(B,"value",null,I.value,Z),(M=I.onVnodeBeforeMount)&&invokeVNodeHook(M,T,S)}X&&invokeDirectiveHook(S,null,T,"beforeMount");const U=needTransition(R,V);U&&V.beforeEnter(B),s(B,x,k),((M=I&&I.onVnodeMounted)||U||X)&&queuePostRenderEffect(()=>{M&&invokeVNodeHook(M,T,S),U&&V.enter(B),X&&invokeDirectiveHook(S,null,T,"mounted")},R)},_=(S,x,k,T,R)=>{if(k&&O(S,k),T)for(let Z=0;Z{for(let M=B;M{const E=x.el=S.el;let{patchFlag:B,dynamicChildren:M,dirs:I}=x;B|=S.patchFlag&16;const N=S.props||EMPTY_OBJ,V=x.props||EMPTY_OBJ;let X;if(k&&toggleRecurse(k,!1),(X=V.onVnodeBeforeUpdate)&&invokeVNodeHook(X,k,x,S),I&&invokeDirectiveHook(x,S,k,"beforeUpdate"),k&&toggleRecurse(k,!0),M?Y(S.dynamicChildren,M,E,k,T,resolveChildrenNamespace(x,R),Z):D||F(S,x,E,null,k,T,resolveChildrenNamespace(x,R),Z,!1),B>0){if(B&16)z(E,x,N,V,k,T,R);else if(B&2&&N.class!==V.class&&l(E,"class",null,V.class,R),B&4&&l(E,"style",N.style,V.style,R),B&8){const U=x.dynamicProps;for(let J=0;J{X&&invokeVNodeHook(X,k,x,S),I&&invokeDirectiveHook(x,S,k,"updated")},T)},Y=(S,x,k,T,R,Z,D)=>{for(let E=0;E{if(k!==T){if(k!==EMPTY_OBJ)for(const E in k)!isReservedProp(E)&&!(E in T)&&l(S,E,k[E],null,D,x.children,R,Z,ce);for(const E in T){if(isReservedProp(E))continue;const B=T[E],M=k[E];B!==M&&E!=="value"&&l(S,E,M,B,D,x.children,R,Z,ce)}"value"in T&&l(S,"value",k.value,T.value,D)}},L=(S,x,k,T,R,Z,D,E,B)=>{const M=x.el=S?S.el:c(""),I=x.anchor=S?S.anchor:c("");let{patchFlag:N,dynamicChildren:V,slotScopeIds:X}=x;X&&(E=E?E.concat(X):X),S==null?(s(M,k,T),s(I,k,T),W(x.children||[],k,I,R,Z,D,E,B)):N>0&&N&64&&V&&S.dynamicChildren?(Y(S.dynamicChildren,V,k,R,Z,D,E),(x.key!=null||R&&x===R.subTree)&&traverseStaticChildren(S,x,!0)):F(S,x,k,I,R,Z,D,E,B)},H=(S,x,k,T,R,Z,D,E,B)=>{x.slotScopeIds=E,S==null?x.shapeFlag&512?R.ctx.activate(x,k,T,D,B):G(x,k,T,R,Z,D,B):ee(S,x,B)},G=(S,x,k,T,R,Z,D)=>{const E=S.component=createComponentInstance(S,T,R);if(isKeepAlive(S)&&(E.ctx.renderer=Oe),setupComponent(E),E.asyncDep){if(R&&R.registerDep(E,K),!S.el){const B=E.subTree=createVNode(Comment);w(null,B,x,k)}}else K(E,S,x,k,R,Z,D)},ee=(S,x,k)=>{const T=x.component=S.component;if(shouldUpdateComponent(S,x,k))if(T.asyncDep&&!T.asyncResolved){j(T,x,k);return}else T.next=x,invalidateJob(T.update),T.effect.dirty=!0,T.update();else x.el=S.el,T.vnode=x},K=(S,x,k,T,R,Z,D)=>{const E=()=>{if(S.isMounted){let{next:I,bu:N,u:V,parent:X,vnode:U}=S;{const ge=locateNonHydratedAsyncRoot(S);if(ge){I&&(I.el=U.el,j(S,I,D)),ge.asyncDep.then(()=>{S.isUnmounted||E()});return}}let J=I,ne;toggleRecurse(S,!1),I?(I.el=U.el,j(S,I,D)):I=U,N&&invokeArrayFns(N),(ne=I.props&&I.props.onVnodeBeforeUpdate)&&invokeVNodeHook(ne,X,I,U),toggleRecurse(S,!0);const le=renderComponentRoot(S),he=S.subTree;S.subTree=le,y(he,le,d(he.el),ye(he),S,R,Z),I.el=le.el,J===null&&updateHOCHostEl(S,le.el),V&&queuePostRenderEffect(V,R),(ne=I.props&&I.props.onVnodeUpdated)&&queuePostRenderEffect(()=>invokeVNodeHook(ne,X,I,U),R)}else{let I;const{el:N,props:V}=x,{bm:X,m:U,parent:J}=S,ne=isAsyncWrapper(x);if(toggleRecurse(S,!1),X&&invokeArrayFns(X),!ne&&(I=V&&V.onVnodeBeforeMount)&&invokeVNodeHook(I,J,x),toggleRecurse(S,!0),N&&we){const le=()=>{S.subTree=renderComponentRoot(S),we(N,S.subTree,S,R,null)};ne?x.type.__asyncLoader().then(()=>!S.isUnmounted&&le()):le()}else{const le=S.subTree=renderComponentRoot(S);y(null,le,k,T,S,R,Z),x.el=le.el}if(U&&queuePostRenderEffect(U,R),!ne&&(I=V&&V.onVnodeMounted)){const le=x;queuePostRenderEffect(()=>invokeVNodeHook(I,J,le),R)}(x.shapeFlag&256||J&&isAsyncWrapper(J.vnode)&&J.vnode.shapeFlag&256)&&S.a&&queuePostRenderEffect(S.a,R),S.isMounted=!0,x=k=T=null}},B=S.effect=new ReactiveEffect(E,NOOP,()=>queueJob(M),S.scope),M=S.update=()=>{B.dirty&&B.run()};M.id=S.uid,toggleRecurse(S,!0),M()},j=(S,x,k)=>{x.component=S;const T=S.vnode.props;S.vnode=x,S.next=null,updateProps(S,x.props,T,k),updateSlots(S,x.children,k),pauseTracking(),flushPreFlushCbs(S),resetTracking()},F=(S,x,k,T,R,Z,D,E,B=!1)=>{const M=S&&S.children,I=S?S.shapeFlag:0,N=x.children,{patchFlag:V,shapeFlag:X}=x;if(V>0){if(V&128){te(M,N,k,T,R,Z,D,E,B);return}else if(V&256){se(M,N,k,T,R,Z,D,E,B);return}}X&8?(I&16&&ce(M,R,Z),N!==M&&u(k,N)):I&16?X&16?te(M,N,k,T,R,Z,D,E,B):ce(M,R,Z,!0):(I&8&&u(k,""),X&16&&W(N,k,T,R,Z,D,E,B))},se=(S,x,k,T,R,Z,D,E,B)=>{S=S||EMPTY_ARR,x=x||EMPTY_ARR;const M=S.length,I=x.length,N=Math.min(M,I);let V;for(V=0;VI?ce(S,R,Z,!0,!1,N):W(x,k,T,R,Z,D,E,B,N)},te=(S,x,k,T,R,Z,D,E,B)=>{let M=0;const I=x.length;let N=S.length-1,V=I-1;for(;M<=N&&M<=V;){const X=S[M],U=x[M]=B?cloneIfMounted(x[M]):normalizeVNode(x[M]);if(isSameVNodeType(X,U))y(X,U,k,null,R,Z,D,E,B);else break;M++}for(;M<=N&&M<=V;){const X=S[N],U=x[V]=B?cloneIfMounted(x[V]):normalizeVNode(x[V]);if(isSameVNodeType(X,U))y(X,U,k,null,R,Z,D,E,B);else break;N--,V--}if(M>N){if(M<=V){const X=V+1,U=XV)for(;M<=N;)re(S[M],R,Z,!0),M++;else{const X=M,U=M,J=new Map;for(M=U;M<=V;M++){const ae=x[M]=B?cloneIfMounted(x[M]):normalizeVNode(x[M]);ae.key!=null&&J.set(ae.key,M)}let ne,le=0;const he=V-U+1;let ge=!1,ke=0;const me=new Array(he);for(M=0;M=he){re(ae,R,Z,!0);continue}let ue;if(ae.key!=null)ue=J.get(ae.key);else for(ne=U;ne<=V;ne++)if(me[ne-U]===0&&isSameVNodeType(ae,x[ne])){ue=ne;break}ue===void 0?re(ae,R,Z,!0):(me[ue-U]=M+1,ue>=ke?ke=ue:ge=!0,y(ae,x[ue],k,null,R,Z,D,E,B),le++)}const Pe=ge?getSequence(me):EMPTY_ARR;for(ne=Pe.length-1,M=he-1;M>=0;M--){const ae=U+M,ue=x[ae],ve=ae+1{const{el:Z,type:D,transition:E,children:B,shapeFlag:M}=S;if(M&6){oe(S.component.subTree,x,k,T);return}if(M&128){S.suspense.move(x,k,T);return}if(M&64){D.move(S,x,k,Oe);return}if(D===Fragment){s(Z,x,k);for(let N=0;NE.enter(Z),R);else{const{leave:N,delayLeave:V,afterLeave:X}=E,U=()=>s(Z,x,k),J=()=>{N(Z,()=>{U(),X&&X()})};V?V(Z,U,J):J()}else s(Z,x,k)},re=(S,x,k,T=!1,R=!1)=>{const{type:Z,props:D,ref:E,children:B,dynamicChildren:M,shapeFlag:I,patchFlag:N,dirs:V}=S;if(E!=null&&setRef(E,null,k,S,!0),I&256){x.ctx.deactivate(S);return}const X=I&1&&V,U=!isAsyncWrapper(S);let J;if(U&&(J=D&&D.onVnodeBeforeUnmount)&&invokeVNodeHook(J,x,S),I&6)pe(S.component,k,T);else{if(I&128){S.suspense.unmount(k,T);return}X&&invokeDirectiveHook(S,null,x,"beforeUnmount"),I&64?S.type.remove(S,x,k,R,Oe,T):M&&(Z!==Fragment||N>0&&N&64)?ce(M,x,k,!1,!0):(Z===Fragment&&N&384||!R&&I&16)&&ce(B,x,k),T&&fe(S)}(U&&(J=D&&D.onVnodeUnmounted)||X)&&queuePostRenderEffect(()=>{J&&invokeVNodeHook(J,x,S),X&&invokeDirectiveHook(S,null,x,"unmounted")},k)},fe=S=>{const{type:x,el:k,anchor:T,transition:R}=S;if(x===Fragment){de(k,T);return}if(x===Static){A(S);return}const Z=()=>{o(k),R&&!R.persisted&&R.afterLeave&&R.afterLeave()};if(S.shapeFlag&1&&R&&!R.persisted){const{leave:D,delayLeave:E}=R,B=()=>D(k,Z);E?E(S.el,Z,B):B()}else Z()},de=(S,x)=>{let k;for(;S!==x;)k=g(S),o(S),S=k;o(x)},pe=(S,x,k)=>{const{bum:T,scope:R,update:Z,subTree:D,um:E}=S;T&&invokeArrayFns(T),R.stop(),Z&&(Z.active=!1,re(D,S,x,k)),E&&queuePostRenderEffect(E,x),queuePostRenderEffect(()=>{S.isUnmounted=!0},x),x&&x.pendingBranch&&!x.isUnmounted&&S.asyncDep&&!S.asyncResolved&&S.suspenseId===x.pendingId&&(x.deps--,x.deps===0&&x.resolve())},ce=(S,x,k,T=!1,R=!1,Z=0)=>{for(let D=Z;DS.shapeFlag&6?ye(S.component.subTree):S.shapeFlag&128?S.suspense.next():g(S.anchor||S.el);let Se=!1;const be=(S,x,k)=>{S==null?x._vnode&&re(x._vnode,null,null,!0):y(x._vnode||null,S,x,null,null,null,k),Se||(Se=!0,flushPreFlushCbs(),flushPostFlushCbs(),Se=!1),x._vnode=S},Oe={p:y,um:re,m:oe,r:fe,mt:G,mc:W,pc:F,pbc:Y,n:ye,o:r};let xe,we;return{render:be,hydrate:xe,createApp:createAppAPI(be,xe)}}function resolveChildrenNamespace({type:r,props:e},n){return n==="svg"&&r==="foreignObject"||n==="mathml"&&r==="annotation-xml"&&e&&e.encoding&&e.encoding.includes("html")?void 0:n}function toggleRecurse({effect:r,update:e},n){r.allowRecurse=e.allowRecurse=n}function needTransition(r,e){return(!r||r&&!r.pendingBranch)&&e&&!e.persisted}function traverseStaticChildren(r,e,n=!1){const s=r.children,o=e.children;if(isArray(s)&&isArray(o))for(let l=0;l>1,r[n[c]]0&&(e[s]=n[l-1]),n[l]=s)}}for(l=n.length,a=n[l-1];l-- >0;)n[l]=a,a=e[a];return n}function locateNonHydratedAsyncRoot(r){const e=r.subTree.component;if(e)return e.asyncDep&&!e.asyncResolved?e:locateNonHydratedAsyncRoot(e)}const isTeleport=r=>r.__isTeleport,Fragment=Symbol.for("v-fgt"),Text$1=Symbol.for("v-txt"),Comment=Symbol.for("v-cmt"),Static=Symbol.for("v-stc"),blockStack=[];let currentBlock=null;function openBlock(r=!1){blockStack.push(currentBlock=r?null:[])}function closeBlock(){blockStack.pop(),currentBlock=blockStack[blockStack.length-1]||null}let isBlockTreeEnabled=1;function setBlockTracking(r){isBlockTreeEnabled+=r}function setupBlock(r){return r.dynamicChildren=isBlockTreeEnabled>0?currentBlock||EMPTY_ARR:null,closeBlock(),isBlockTreeEnabled>0&¤tBlock&¤tBlock.push(r),r}function createElementBlock(r,e,n,s,o,l){return setupBlock(createBaseVNode(r,e,n,s,o,l,!0))}function createBlock(r,e,n,s,o){return setupBlock(createVNode(r,e,n,s,o,!0))}function isVNode(r){return r?r.__v_isVNode===!0:!1}function isSameVNodeType(r,e){return r.type===e.type&&r.key===e.key}const normalizeKey=({key:r})=>r??null,normalizeRef=({ref:r,ref_key:e,ref_for:n})=>(typeof r=="number"&&(r=""+r),r!=null?isString(r)||isRef(r)||isFunction(r)?{i:currentRenderingInstance,r,k:e,f:!!n}:r:null);function createBaseVNode(r,e=null,n=null,s=0,o=null,l=r===Fragment?0:1,a=!1,c=!1){const h={__v_isVNode:!0,__v_skip:!0,type:r,props:e,key:e&&normalizeKey(e),ref:e&&normalizeRef(e),scopeId:currentScopeId,slotScopeIds:null,children:n,component:null,suspense:null,ssContent:null,ssFallback:null,dirs:null,transition:null,el:null,anchor:null,target:null,targetAnchor:null,staticCount:0,shapeFlag:l,patchFlag:s,dynamicProps:o,dynamicChildren:null,appContext:null,ctx:currentRenderingInstance};return c?(normalizeChildren(h,n),l&128&&r.normalize(h)):n&&(h.shapeFlag|=isString(n)?8:16),isBlockTreeEnabled>0&&!a&¤tBlock&&(h.patchFlag>0||l&6)&&h.patchFlag!==32&¤tBlock.push(h),h}const createVNode=_createVNode;function _createVNode(r,e=null,n=null,s=0,o=null,l=!1){if((!r||r===NULL_DYNAMIC_COMPONENT)&&(r=Comment),isVNode(r)){const c=cloneVNode(r,e,!0);return n&&normalizeChildren(c,n),isBlockTreeEnabled>0&&!l&¤tBlock&&(c.shapeFlag&6?currentBlock[currentBlock.indexOf(r)]=c:currentBlock.push(c)),c.patchFlag|=-2,c}if(isClassComponent(r)&&(r=r.__vccOpts),e){e=guardReactiveProps(e);let{class:c,style:h}=e;c&&!isString(c)&&(e.class=normalizeClass(c)),isObject(h)&&(isProxy(h)&&!isArray(h)&&(h=extend$1({},h)),e.style=normalizeStyle(h))}const a=isString(r)?1:isSuspense(r)?128:isTeleport(r)?64:isObject(r)?4:isFunction(r)?2:0;return createBaseVNode(r,e,n,s,o,a,l,!0)}function guardReactiveProps(r){return r?isProxy(r)||isInternalObject(r)?extend$1({},r):r:null}function cloneVNode(r,e,n=!1,s=!1){const{props:o,ref:l,patchFlag:a,children:c,transition:h}=r,f=e?mergeProps(o||{},e):o,u={__v_isVNode:!0,__v_skip:!0,type:r.type,props:f,key:f&&normalizeKey(f),ref:e&&e.ref?n&&l?isArray(l)?l.concat(normalizeRef(e)):[l,normalizeRef(e)]:normalizeRef(e):l,scopeId:r.scopeId,slotScopeIds:r.slotScopeIds,children:c,target:r.target,targetAnchor:r.targetAnchor,staticCount:r.staticCount,shapeFlag:r.shapeFlag,patchFlag:e&&r.type!==Fragment?a===-1?16:a|16:a,dynamicProps:r.dynamicProps,dynamicChildren:r.dynamicChildren,appContext:r.appContext,dirs:r.dirs,transition:h,component:r.component,suspense:r.suspense,ssContent:r.ssContent&&cloneVNode(r.ssContent),ssFallback:r.ssFallback&&cloneVNode(r.ssFallback),el:r.el,anchor:r.anchor,ctx:r.ctx,ce:r.ce};return h&&s&&(u.transition=h.clone(u)),u}function createTextVNode(r=" ",e=0){return createVNode(Text$1,null,r,e)}function createStaticVNode(r,e){const n=createVNode(Static,null,r);return n.staticCount=e,n}function createCommentVNode(r="",e=!1){return e?(openBlock(),createBlock(Comment,null,r)):createVNode(Comment,null,r)}function normalizeVNode(r){return r==null||typeof r=="boolean"?createVNode(Comment):isArray(r)?createVNode(Fragment,null,r.slice()):typeof r=="object"?cloneIfMounted(r):createVNode(Text$1,null,String(r))}function cloneIfMounted(r){return r.el===null&&r.patchFlag!==-1||r.memo?r:cloneVNode(r)}function normalizeChildren(r,e){let n=0;const{shapeFlag:s}=r;if(e==null)e=null;else if(isArray(e))n=16;else if(typeof e=="object")if(s&65){const o=e.default;o&&(o._c&&(o._d=!1),normalizeChildren(r,o()),o._c&&(o._d=!0));return}else{n=32;const o=e._;!o&&!isInternalObject(e)?e._ctx=currentRenderingInstance:o===3&¤tRenderingInstance&&(currentRenderingInstance.slots._===1?e._=1:(e._=2,r.patchFlag|=1024))}else isFunction(e)?(e={default:e,_ctx:currentRenderingInstance},n=32):(e=String(e),s&64?(n=16,e=[createTextVNode(e)]):n=8);r.children=e,r.shapeFlag|=n}function mergeProps(...r){const e={};for(let n=0;n{let o;return(o=r[n])||(o=r[n]=[]),o.push(s),l=>{o.length>1?o.forEach(a=>a(l)):o[0](l)}};internalSetCurrentInstance=e("__VUE_INSTANCE_SETTERS__",n=>currentInstance=n),setInSSRSetupState=e("__VUE_SSR_SETTERS__",n=>isInSSRComponentSetup=n)}const setCurrentInstance=r=>{const e=currentInstance;return internalSetCurrentInstance(r),r.scope.on(),()=>{r.scope.off(),internalSetCurrentInstance(e)}},unsetCurrentInstance=()=>{currentInstance&¤tInstance.scope.off(),internalSetCurrentInstance(null)};function isStatefulComponent(r){return r.vnode.shapeFlag&4}let isInSSRComponentSetup=!1;function setupComponent(r,e=!1){e&&setInSSRSetupState(e);const{props:n,children:s}=r.vnode,o=isStatefulComponent(r);initProps(r,n,o,e),initSlots(r,s);const l=o?setupStatefulComponent(r,e):void 0;return e&&setInSSRSetupState(!1),l}function setupStatefulComponent(r,e){const n=r.type;r.accessCache=Object.create(null),r.proxy=new Proxy(r.ctx,PublicInstanceProxyHandlers);const{setup:s}=n;if(s){const o=r.setupContext=s.length>1?createSetupContext(r):null,l=setCurrentInstance(r);pauseTracking();const a=callWithErrorHandling(s,r,0,[r.props,o]);if(resetTracking(),l(),isPromise(a)){if(a.then(unsetCurrentInstance,unsetCurrentInstance),e)return a.then(c=>{handleSetupResult(r,c,e)}).catch(c=>{handleError(c,r,0)});r.asyncDep=a}else handleSetupResult(r,a,e)}else finishComponentSetup(r,e)}function handleSetupResult(r,e,n){isFunction(e)?r.type.__ssrInlineRender?r.ssrRender=e:r.render=e:isObject(e)&&(r.setupState=proxyRefs(e)),finishComponentSetup(r,n)}let compile;function finishComponentSetup(r,e,n){const s=r.type;if(!r.render){if(!e&&compile&&!s.render){const o=s.template||resolveMergedOptions(r).template;if(o){const{isCustomElement:l,compilerOptions:a}=r.appContext.config,{delimiters:c,compilerOptions:h}=s,f=extend$1(extend$1({isCustomElement:l,delimiters:c},a),h);s.render=compile(o,f)}}r.render=s.render||NOOP}{const o=setCurrentInstance(r);pauseTracking();try{applyOptions(r)}finally{resetTracking(),o()}}}const attrsProxyHandlers={get(r,e){return track(r,"get",""),r[e]}};function createSetupContext(r){const e=n=>{r.exposed=n||{}};return{attrs:new Proxy(r.attrs,attrsProxyHandlers),slots:r.slots,emit:r.emit,expose:e}}function getExposeProxy(r){if(r.exposed)return r.exposeProxy||(r.exposeProxy=new Proxy(proxyRefs(markRaw(r.exposed)),{get(e,n){if(n in e)return e[n];if(n in publicPropertiesMap)return publicPropertiesMap[n](r)},has(e,n){return n in e||n in publicPropertiesMap}}))}const classifyRE=/(?:^|[-_])(\w)/g,classify=r=>r.replace(classifyRE,e=>e.toUpperCase()).replace(/[-_]/g,"");function getComponentName(r,e=!0){return isFunction(r)?r.displayName||r.name:r.name||e&&r.__name}function formatComponentName(r,e,n=!1){let s=getComponentName(e);if(!s&&e.__file){const o=e.__file.match(/([^/\\]+)\.\w+$/);o&&(s=o[1])}if(!s&&r&&r.parent){const o=l=>{for(const a in l)if(l[a]===e)return a};s=o(r.components||r.parent.type.components)||o(r.appContext.components)}return s?classify(s):n?"App":"Anonymous"}function isClassComponent(r){return isFunction(r)&&"__vccOpts"in r}const computed=(r,e)=>computed$1(r,e,isInSSRComponentSetup),version="3.4.27";/** +`],...formatTraceEntry(n))}),e}function formatTraceEntry({vnode:r,recurseCount:e}){const n=e>0?`... (${e} recursive calls)`:"",s=r.component?r.component.parent==null:!1,o=` at <${formatComponentName(r.component,r.type,s)}`,l=">"+n;return r.props?[o,...formatProps(r.props),l]:[o+l]}function formatProps(r){const e=[],n=Object.keys(r);return n.slice(0,3).forEach(s=>{e.push(...formatProp(s,r[s]))}),n.length>3&&e.push(" ..."),e}function formatProp(r,e,n){return isString(e)?(e=JSON.stringify(e),n?e:[`${r}=${e}`]):typeof e=="number"||typeof e=="boolean"||e==null?n?e:[`${r}=${e}`]:isRef(e)?(e=formatProp(r,toRaw(e.value),!0),n?e:[`${r}=Ref<`,e,">"]):isFunction(e)?[`${r}=fn${e.name?`<${e.name}>`:""}`]:(e=toRaw(e),n?e:[`${r}=`,e])}function callWithErrorHandling(r,e,n,s){try{return s?r(...s):r()}catch(o){handleError(o,e,n)}}function callWithAsyncErrorHandling(r,e,n,s){if(isFunction(r)){const o=callWithErrorHandling(r,e,n,s);return o&&isPromise(o)&&o.catch(l=>{handleError(l,e,n)}),o}if(isArray(r)){const o=[];for(let l=0;l>>1,o=queue[s],l=getId(o);lflushIndex&&queue.splice(e,1)}function queuePostFlushCb(r){isArray(r)?pendingPostFlushCbs.push(...r):(!activePostFlushCbs||!activePostFlushCbs.includes(r,r.allowRecurse?postFlushIndex+1:postFlushIndex))&&pendingPostFlushCbs.push(r),queueFlush()}function flushPreFlushCbs(r,e,n=isFlushing?flushIndex+1:0){for(;ngetId(n)-getId(s));if(pendingPostFlushCbs.length=0,activePostFlushCbs){activePostFlushCbs.push(...e);return}for(activePostFlushCbs=e,postFlushIndex=0;postFlushIndexr.id==null?1/0:r.id,comparator=(r,e)=>{const n=getId(r)-getId(e);if(n===0){if(r.pre&&!e.pre)return-1;if(e.pre&&!r.pre)return 1}return n};function flushJobs(r){isFlushPending=!1,isFlushing=!0,queue.sort(comparator);try{for(flushIndex=0;flushIndexisString(O)?O.trim():O)),d&&(o=n.map(looseToNumber))}let c,h=s[c=toHandlerKey(e)]||s[c=toHandlerKey(camelize(e))];!h&&l&&(h=s[c=toHandlerKey(hyphenate(e))]),h&&callWithAsyncErrorHandling(h,r,6,o);const f=s[c+"Once"];if(f){if(!r.emitted)r.emitted={};else if(r.emitted[c])return;r.emitted[c]=!0,callWithAsyncErrorHandling(f,r,6,o)}}function normalizeEmitsOptions(r,e,n=!1){const s=e.emitsCache,o=s.get(r);if(o!==void 0)return o;const l=r.emits;let a={},c=!1;if(!isFunction(r)){const h=f=>{const u=normalizeEmitsOptions(f,e,!0);u&&(c=!0,extend$1(a,u))};!n&&e.mixins.length&&e.mixins.forEach(h),r.extends&&h(r.extends),r.mixins&&r.mixins.forEach(h)}return!l&&!c?(isObject(r)&&s.set(r,null),null):(isArray(l)?l.forEach(h=>a[h]=null):extend$1(a,l),isObject(r)&&s.set(r,a),a)}function isEmitListener(r,e){return!r||!isOn(e)?!1:(e=e.slice(2).replace(/Once$/,""),hasOwn(r,e[0].toLowerCase()+e.slice(1))||hasOwn(r,hyphenate(e))||hasOwn(r,e))}let currentRenderingInstance=null,currentScopeId=null;function setCurrentRenderingInstance(r){const e=currentRenderingInstance;return currentRenderingInstance=r,currentScopeId=r&&r.type.__scopeId||null,e}function pushScopeId(r){currentScopeId=r}function popScopeId(){currentScopeId=null}function withCtx(r,e=currentRenderingInstance,n){if(!e||r._n)return r;const s=(...o)=>{s._d&&setBlockTracking(-1);const l=setCurrentRenderingInstance(e);let a;try{a=r(...o)}finally{setCurrentRenderingInstance(l),s._d&&setBlockTracking(1)}return a};return s._n=!0,s._c=!0,s._d=!0,s}function markAttrsAccessed(){}function renderComponentRoot(r){const{type:e,vnode:n,proxy:s,withProxy:o,propsOptions:[l],slots:a,attrs:c,emit:h,render:f,renderCache:u,props:d,data:g,setupState:O,ctx:m,inheritAttrs:S}=r,b=setCurrentRenderingInstance(r);let w,P;try{if(n.shapeFlag&4){const A=o||s,v=A;w=normalizeVNode(f.call(v,A,u,d,O,g,m)),P=c}else{const A=e;w=normalizeVNode(A.length>1?A(d,{attrs:c,slots:a,emit:h}):A(d,null)),P=e.props?c:getFunctionalFallthrough(c)}}catch(A){blockStack.length=0,handleError(A,r,1),w=createVNode(Comment)}let $=w;if(P&&S!==!1){const A=Object.keys(P),{shapeFlag:v}=$;A.length&&v&7&&(l&&A.some(isModelListener)&&(P=filterModelListeners(P,l)),$=cloneVNode($,P,!1,!0))}return n.dirs&&($=cloneVNode($,null,!1,!0),$.dirs=$.dirs?$.dirs.concat(n.dirs):n.dirs),n.transition&&($.transition=n.transition),w=$,setCurrentRenderingInstance(b),w}const getFunctionalFallthrough=r=>{let e;for(const n in r)(n==="class"||n==="style"||isOn(n))&&((e||(e={}))[n]=r[n]);return e},filterModelListeners=(r,e)=>{const n={};for(const s in r)(!isModelListener(s)||!(s.slice(9)in e))&&(n[s]=r[s]);return n};function shouldUpdateComponent(r,e,n){const{props:s,children:o,component:l}=r,{props:a,children:c,patchFlag:h}=e,f=l.emitsOptions;if(e.dirs||e.transition)return!0;if(n&&h>=0){if(h&1024)return!0;if(h&16)return s?hasPropsChanged(s,a,f):!!a;if(h&8){const u=e.dynamicProps;for(let d=0;dr.__isSuspense;function queueEffectWithSuspense(r,e){e&&e.pendingBranch?isArray(r)?e.effects.push(...r):e.effects.push(r):queuePostFlushCb(r)}const ssrContextKey=Symbol.for("v-scx"),useSSRContext=()=>inject(ssrContextKey),INITIAL_WATCHER_VALUE={};function watch(r,e,n){return doWatch(r,e,n)}function doWatch(r,e,{immediate:n,deep:s,flush:o,once:l,onTrack:a,onTrigger:c}=EMPTY_OBJ){if(e&&l){const Q=e;e=(..._)=>{Q(..._),v()}}const h=currentInstance,f=Q=>s===!0?Q:traverse(Q,s===!1?1:void 0);let u,d=!1,g=!1;if(isRef(r)?(u=()=>r.value,d=isShallow(r)):isReactive(r)?(u=()=>f(r),d=!0):isArray(r)?(g=!0,d=r.some(Q=>isReactive(Q)||isShallow(Q)),u=()=>r.map(Q=>{if(isRef(Q))return Q.value;if(isReactive(Q))return f(Q);if(isFunction(Q))return callWithErrorHandling(Q,h,2)})):isFunction(r)?e?u=()=>callWithErrorHandling(r,h,2):u=()=>(O&&O(),callWithAsyncErrorHandling(r,h,3,[m])):u=NOOP,e&&s){const Q=u;u=()=>traverse(Q())}let O,m=Q=>{O=$.onStop=()=>{callWithErrorHandling(Q,h,4),O=$.onStop=void 0}},S;if(isInSSRComponentSetup)if(m=NOOP,e?n&&callWithAsyncErrorHandling(e,h,3,[u(),g?[]:void 0,m]):u(),o==="sync"){const Q=useSSRContext();S=Q.__watcherHandles||(Q.__watcherHandles=[])}else return NOOP;let b=g?new Array(r.length).fill(INITIAL_WATCHER_VALUE):INITIAL_WATCHER_VALUE;const w=()=>{if(!(!$.active||!$.dirty))if(e){const Q=$.run();(s||d||(g?Q.some((_,N)=>hasChanged(_,b[N])):hasChanged(Q,b)))&&(O&&O(),callWithAsyncErrorHandling(e,h,3,[Q,b===INITIAL_WATCHER_VALUE?void 0:g&&b[0]===INITIAL_WATCHER_VALUE?[]:b,m]),b=Q)}else $.run()};w.allowRecurse=!!e;let P;o==="sync"?P=w:o==="post"?P=()=>queuePostRenderEffect(w,h&&h.suspense):(w.pre=!0,h&&(w.id=h.uid),P=()=>queueJob(w));const $=new ReactiveEffect(u,NOOP,P),A=getCurrentScope(),v=()=>{$.stop(),A&&remove$1(A.effects,$)};return e?n?w():b=$.run():o==="post"?queuePostRenderEffect($.run.bind($),h&&h.suspense):$.run(),S&&S.push(v),v}function instanceWatch(r,e,n){const s=this.proxy,o=isString(r)?r.includes(".")?createPathGetter(s,r):()=>s[r]:r.bind(s,s);let l;isFunction(e)?l=e:(l=e.handler,n=e);const a=setCurrentInstance(this),c=doWatch(o,l.bind(s),n);return a(),c}function createPathGetter(r,e){const n=e.split(".");return()=>{let s=r;for(let o=0;o{traverse(s,e,n)});else if(isPlainObject(r))for(const s in r)traverse(r[s],e,n);return r}function invokeDirectiveHook(r,e,n,s){const o=r.dirs,l=e&&e.dirs;for(let a=0;a!!r.type.__asyncLoader,isKeepAlive=r=>r.type.__isKeepAlive;function onActivated(r,e){registerKeepAliveHook(r,"a",e)}function onDeactivated(r,e){registerKeepAliveHook(r,"da",e)}function registerKeepAliveHook(r,e,n=currentInstance){const s=r.__wdc||(r.__wdc=()=>{let o=n;for(;o;){if(o.isDeactivated)return;o=o.parent}return r()});if(injectHook(e,s,n),n){let o=n.parent;for(;o&&o.parent;)isKeepAlive(o.parent.vnode)&&injectToKeepAliveRoot(s,e,n,o),o=o.parent}}function injectToKeepAliveRoot(r,e,n,s){const o=injectHook(e,r,s,!0);onUnmounted(()=>{remove$1(s[e],o)},n)}function injectHook(r,e,n=currentInstance,s=!1){if(n){const o=n[r]||(n[r]=[]),l=e.__weh||(e.__weh=(...a)=>{if(n.isUnmounted)return;pauseTracking();const c=setCurrentInstance(n),h=callWithAsyncErrorHandling(e,n,r,a);return c(),resetTracking(),h});return s?o.unshift(l):o.push(l),l}}const createHook=r=>(e,n=currentInstance)=>(!isInSSRComponentSetup||r==="sp")&&injectHook(r,(...s)=>e(...s),n),onBeforeMount=createHook("bm"),onMounted=createHook("m"),onBeforeUpdate=createHook("bu"),onUpdated=createHook("u"),onBeforeUnmount=createHook("bum"),onUnmounted=createHook("um"),onServerPrefetch=createHook("sp"),onRenderTriggered=createHook("rtg"),onRenderTracked=createHook("rtc");function onErrorCaptured(r,e=currentInstance){injectHook("ec",r,e)}function renderList(r,e,n,s){let o;const l=n;if(isArray(r)||isString(r)){o=new Array(r.length);for(let a=0,c=r.length;ae(a,c,void 0,l));else{const a=Object.keys(r);o=new Array(a.length);for(let c=0,h=a.length;cr?isStatefulComponent(r)?getExposeProxy(r)||r.proxy:getPublicInstance(r.parent):null,publicPropertiesMap=extend$1(Object.create(null),{$:r=>r,$el:r=>r.vnode.el,$data:r=>r.data,$props:r=>r.props,$attrs:r=>r.attrs,$slots:r=>r.slots,$refs:r=>r.refs,$parent:r=>getPublicInstance(r.parent),$root:r=>getPublicInstance(r.root),$emit:r=>r.emit,$options:r=>resolveMergedOptions(r),$forceUpdate:r=>r.f||(r.f=()=>{r.effect.dirty=!0,queueJob(r.update)}),$nextTick:r=>r.n||(r.n=nextTick.bind(r.proxy)),$watch:r=>instanceWatch.bind(r)}),hasSetupBinding=(r,e)=>r!==EMPTY_OBJ&&!r.__isScriptSetup&&hasOwn(r,e),PublicInstanceProxyHandlers={get({_:r},e){if(e==="__v_skip")return!0;const{ctx:n,setupState:s,data:o,props:l,accessCache:a,type:c,appContext:h}=r;let f;if(e[0]!=="$"){const O=a[e];if(O!==void 0)switch(O){case 1:return s[e];case 2:return o[e];case 4:return n[e];case 3:return l[e]}else{if(hasSetupBinding(s,e))return a[e]=1,s[e];if(o!==EMPTY_OBJ&&hasOwn(o,e))return a[e]=2,o[e];if((f=r.propsOptions[0])&&hasOwn(f,e))return a[e]=3,l[e];if(n!==EMPTY_OBJ&&hasOwn(n,e))return a[e]=4,n[e];shouldCacheAccess&&(a[e]=0)}}const u=publicPropertiesMap[e];let d,g;if(u)return e==="$attrs"&&track(r.attrs,"get",""),u(r);if((d=c.__cssModules)&&(d=d[e]))return d;if(n!==EMPTY_OBJ&&hasOwn(n,e))return a[e]=4,n[e];if(g=h.config.globalProperties,hasOwn(g,e))return g[e]},set({_:r},e,n){const{data:s,setupState:o,ctx:l}=r;return hasSetupBinding(o,e)?(o[e]=n,!0):s!==EMPTY_OBJ&&hasOwn(s,e)?(s[e]=n,!0):hasOwn(r.props,e)||e[0]==="$"&&e.slice(1)in r?!1:(l[e]=n,!0)},has({_:{data:r,setupState:e,accessCache:n,ctx:s,appContext:o,propsOptions:l}},a){let c;return!!n[a]||r!==EMPTY_OBJ&&hasOwn(r,a)||hasSetupBinding(e,a)||(c=l[0])&&hasOwn(c,a)||hasOwn(s,a)||hasOwn(publicPropertiesMap,a)||hasOwn(o.config.globalProperties,a)},defineProperty(r,e,n){return n.get!=null?r._.accessCache[e]=0:hasOwn(n,"value")&&this.set(r,e,n.value,null),Reflect.defineProperty(r,e,n)}};function normalizePropsOrEmits(r){return isArray(r)?r.reduce((e,n)=>(e[n]=null,e),{}):r}let shouldCacheAccess=!0;function applyOptions(r){const e=resolveMergedOptions(r),n=r.proxy,s=r.ctx;shouldCacheAccess=!1,e.beforeCreate&&callHook(e.beforeCreate,r,"bc");const{data:o,computed:l,methods:a,watch:c,provide:h,inject:f,created:u,beforeMount:d,mounted:g,beforeUpdate:O,updated:m,activated:S,deactivated:b,beforeDestroy:w,beforeUnmount:P,destroyed:$,unmounted:A,render:v,renderTracked:Q,renderTriggered:_,errorCaptured:N,serverPrefetch:q,expose:Y,inheritAttrs:z,components:L,directives:H,filters:G}=e;if(f&&resolveInjections(f,s,null),a)for(const j in a){const F=a[j];isFunction(F)&&(s[j]=F.bind(n))}if(o){const j=o.call(n,n);isObject(j)&&(r.data=reactive(j))}if(shouldCacheAccess=!0,l)for(const j in l){const F=l[j],se=isFunction(F)?F.bind(n,n):isFunction(F.get)?F.get.bind(n,n):NOOP,te=!isFunction(F)&&isFunction(F.set)?F.set.bind(n):NOOP,oe=computed({get:se,set:te});Object.defineProperty(s,j,{enumerable:!0,configurable:!0,get:()=>oe.value,set:re=>oe.value=re})}if(c)for(const j in c)createWatcher(c[j],s,n,j);if(h){const j=isFunction(h)?h.call(n):h;Reflect.ownKeys(j).forEach(F=>{provide(F,j[F])})}u&&callHook(u,r,"c");function K(j,F){isArray(F)?F.forEach(se=>j(se.bind(n))):F&&j(F.bind(n))}if(K(onBeforeMount,d),K(onMounted,g),K(onBeforeUpdate,O),K(onUpdated,m),K(onActivated,S),K(onDeactivated,b),K(onErrorCaptured,N),K(onRenderTracked,Q),K(onRenderTriggered,_),K(onBeforeUnmount,P),K(onUnmounted,A),K(onServerPrefetch,q),isArray(Y))if(Y.length){const j=r.exposed||(r.exposed={});Y.forEach(F=>{Object.defineProperty(j,F,{get:()=>n[F],set:se=>n[F]=se})})}else r.exposed||(r.exposed={});v&&r.render===NOOP&&(r.render=v),z!=null&&(r.inheritAttrs=z),L&&(r.components=L),H&&(r.directives=H)}function resolveInjections(r,e,n=NOOP){isArray(r)&&(r=normalizeInject(r));for(const s in r){const o=r[s];let l;isObject(o)?"default"in o?l=inject(o.from||s,o.default,!0):l=inject(o.from||s):l=inject(o),isRef(l)?Object.defineProperty(e,s,{enumerable:!0,configurable:!0,get:()=>l.value,set:a=>l.value=a}):e[s]=l}}function callHook(r,e,n){callWithAsyncErrorHandling(isArray(r)?r.map(s=>s.bind(e.proxy)):r.bind(e.proxy),e,n)}function createWatcher(r,e,n,s){const o=s.includes(".")?createPathGetter(n,s):()=>n[s];if(isString(r)){const l=e[r];isFunction(l)&&watch(o,l)}else if(isFunction(r))watch(o,r.bind(n));else if(isObject(r))if(isArray(r))r.forEach(l=>createWatcher(l,e,n,s));else{const l=isFunction(r.handler)?r.handler.bind(n):e[r.handler];isFunction(l)&&watch(o,l,r)}}function resolveMergedOptions(r){const e=r.type,{mixins:n,extends:s}=e,{mixins:o,optionsCache:l,config:{optionMergeStrategies:a}}=r.appContext,c=l.get(e);let h;return c?h=c:!o.length&&!n&&!s?h=e:(h={},o.length&&o.forEach(f=>mergeOptions(h,f,a,!0)),mergeOptions(h,e,a)),isObject(e)&&l.set(e,h),h}function mergeOptions(r,e,n,s=!1){const{mixins:o,extends:l}=e;l&&mergeOptions(r,l,n,!0),o&&o.forEach(a=>mergeOptions(r,a,n,!0));for(const a in e)if(!(s&&a==="expose")){const c=internalOptionMergeStrats[a]||n&&n[a];r[a]=c?c(r[a],e[a]):e[a]}return r}const internalOptionMergeStrats={data:mergeDataFn,props:mergeEmitsOrPropsOptions,emits:mergeEmitsOrPropsOptions,methods:mergeObjectOptions,computed:mergeObjectOptions,beforeCreate:mergeAsArray,created:mergeAsArray,beforeMount:mergeAsArray,mounted:mergeAsArray,beforeUpdate:mergeAsArray,updated:mergeAsArray,beforeDestroy:mergeAsArray,beforeUnmount:mergeAsArray,destroyed:mergeAsArray,unmounted:mergeAsArray,activated:mergeAsArray,deactivated:mergeAsArray,errorCaptured:mergeAsArray,serverPrefetch:mergeAsArray,components:mergeObjectOptions,directives:mergeObjectOptions,watch:mergeWatchOptions,provide:mergeDataFn,inject:mergeInject};function mergeDataFn(r,e){return e?r?function(){return extend$1(isFunction(r)?r.call(this,this):r,isFunction(e)?e.call(this,this):e)}:e:r}function mergeInject(r,e){return mergeObjectOptions(normalizeInject(r),normalizeInject(e))}function normalizeInject(r){if(isArray(r)){const e={};for(let n=0;n1)return n&&isFunction(e)?e.call(s&&s.proxy):e}}const internalObjectProto={},createInternalObject=()=>Object.create(internalObjectProto),isInternalObject=r=>Object.getPrototypeOf(r)===internalObjectProto;function initProps(r,e,n,s=!1){const o={},l=createInternalObject();r.propsDefaults=Object.create(null),setFullProps(r,e,o,l);for(const a in r.propsOptions[0])a in o||(o[a]=void 0);n?r.props=s?o:shallowReactive(o):r.type.props?r.props=o:r.props=l,r.attrs=l}function updateProps(r,e,n,s){const{props:o,attrs:l,vnode:{patchFlag:a}}=r,c=toRaw(o),[h]=r.propsOptions;let f=!1;if((s||a>0)&&!(a&16)){if(a&8){const u=r.vnode.dynamicProps;for(let d=0;d{h=!0;const[g,O]=normalizePropsOptions(d,e,!0);extend$1(a,g),O&&c.push(...O)};!n&&e.mixins.length&&e.mixins.forEach(u),r.extends&&u(r.extends),r.mixins&&r.mixins.forEach(u)}if(!l&&!h)return isObject(r)&&s.set(r,EMPTY_ARR),EMPTY_ARR;if(isArray(l))for(let u=0;u-1,O[1]=S<0||m-1||hasOwn(O,"default"))&&c.push(d)}}}const f=[a,c];return isObject(r)&&s.set(r,f),f}function validatePropName(r){return r[0]!=="$"&&!isReservedProp(r)}function getType(r){return r===null?"null":typeof r=="function"?r.name||"":typeof r=="object"&&r.constructor&&r.constructor.name||""}function isSameType(r,e){return getType(r)===getType(e)}function getTypeIndex(r,e){return isArray(e)?e.findIndex(n=>isSameType(n,r)):isFunction(e)&&isSameType(e,r)?0:-1}const isInternalKey=r=>r[0]==="_"||r==="$stable",normalizeSlotValue=r=>isArray(r)?r.map(normalizeVNode):[normalizeVNode(r)],normalizeSlot=(r,e,n)=>{if(e._n)return e;const s=withCtx((...o)=>normalizeSlotValue(e(...o)),n);return s._c=!1,s},normalizeObjectSlots=(r,e,n)=>{const s=r._ctx;for(const o in r){if(isInternalKey(o))continue;const l=r[o];if(isFunction(l))e[o]=normalizeSlot(o,l,s);else if(l!=null){const a=normalizeSlotValue(l);e[o]=()=>a}}},normalizeVNodeSlots=(r,e)=>{const n=normalizeSlotValue(e);r.slots.default=()=>n},initSlots=(r,e)=>{const n=r.slots=createInternalObject();if(r.vnode.shapeFlag&32){const s=e._;s?(extend$1(n,e),def(n,"_",s,!0)):normalizeObjectSlots(e,n)}else e&&normalizeVNodeSlots(r,e)},updateSlots=(r,e,n)=>{const{vnode:s,slots:o}=r;let l=!0,a=EMPTY_OBJ;if(s.shapeFlag&32){const c=e._;c?n&&c===1?l=!1:(extend$1(o,e),!n&&c===1&&delete o._):(l=!e.$stable,normalizeObjectSlots(e,o)),a=e}else e&&(normalizeVNodeSlots(r,e),a={default:1});if(l)for(const c in o)!isInternalKey(c)&&a[c]==null&&delete o[c]};function setRef(r,e,n,s,o=!1){if(isArray(r)){r.forEach((g,O)=>setRef(g,e&&(isArray(e)?e[O]:e),n,s,o));return}if(isAsyncWrapper(s)&&!o)return;const l=s.shapeFlag&4?getExposeProxy(s.component)||s.component.proxy:s.el,a=o?null:l,{i:c,r:h}=r,f=e&&e.r,u=c.refs===EMPTY_OBJ?c.refs={}:c.refs,d=c.setupState;if(f!=null&&f!==h&&(isString(f)?(u[f]=null,hasOwn(d,f)&&(d[f]=null)):isRef(f)&&(f.value=null)),isFunction(h))callWithErrorHandling(h,c,12,[a,u]);else{const g=isString(h),O=isRef(h);if(g||O){const m=()=>{if(r.f){const S=g?hasOwn(d,h)?d[h]:u[h]:h.value;o?isArray(S)&&remove$1(S,l):isArray(S)?S.includes(l)||S.push(l):g?(u[h]=[l],hasOwn(d,h)&&(d[h]=u[h])):(h.value=[l],r.k&&(u[r.k]=h.value))}else g?(u[h]=a,hasOwn(d,h)&&(d[h]=a)):O&&(h.value=a,r.k&&(u[r.k]=a))};a?(m.id=-1,queuePostRenderEffect(m,n)):m()}}}const queuePostRenderEffect=queueEffectWithSuspense;function createRenderer(r){return baseCreateRenderer(r)}function baseCreateRenderer(r,e){const n=getGlobalThis();n.__VUE__=!0;const{insert:s,remove:o,patchProp:l,createElement:a,createText:c,createComment:h,setText:f,setElementText:u,parentNode:d,nextSibling:g,setScopeId:O=NOOP,insertStaticContent:m}=r,S=(y,x,k,T=null,R=null,Z=null,D=void 0,M=null,B=!!x.dynamicChildren)=>{if(y===x)return;y&&!isSameVNodeType(y,x)&&(T=Se(y),re(y,R,Z,!0),y=null),x.patchFlag===-2&&(B=!1,x.dynamicChildren=null);const{type:E,ref:I,shapeFlag:W}=x;switch(E){case Text$1:b(y,x,k,T);break;case Comment:w(y,x,k,T);break;case Static:y==null&&P(x,k,T,D);break;case Fragment:L(y,x,k,T,R,Z,D,M,B);break;default:W&1?v(y,x,k,T,R,Z,D,M,B):W&6?H(y,x,k,T,R,Z,D,M,B):(W&64||W&128)&&E.process(y,x,k,T,R,Z,D,M,B,Oe)}I!=null&&R&&setRef(I,y&&y.ref,Z,x||y,!x)},b=(y,x,k,T)=>{if(y==null)s(x.el=c(x.children),k,T);else{const R=x.el=y.el;x.children!==y.children&&f(R,x.children)}},w=(y,x,k,T)=>{y==null?s(x.el=h(x.children||""),k,T):x.el=y.el},P=(y,x,k,T)=>{[y.el,y.anchor]=m(y.children,x,k,T,y.el,y.anchor)},$=({el:y,anchor:x},k,T)=>{let R;for(;y&&y!==x;)R=g(y),s(y,k,T),y=R;s(x,k,T)},A=({el:y,anchor:x})=>{let k;for(;y&&y!==x;)k=g(y),o(y),y=k;o(x)},v=(y,x,k,T,R,Z,D,M,B)=>{x.type==="svg"?D="svg":x.type==="math"&&(D="mathml"),y==null?Q(x,k,T,R,Z,D,M,B):q(y,x,R,Z,D,M,B)},Q=(y,x,k,T,R,Z,D,M)=>{let B,E;const{props:I,shapeFlag:W,transition:V,dirs:X}=y;if(B=y.el=a(y.type,Z,I&&I.is,I),W&8?u(B,y.children):W&16&&N(y.children,B,null,T,R,resolveChildrenNamespace(y,Z),D,M),X&&invokeDirectiveHook(y,null,T,"created"),_(B,y,y.scopeId,D,T),I){for(const J in I)J!=="value"&&!isReservedProp(J)&&l(B,J,null,I[J],Z,y.children,T,R,ce);"value"in I&&l(B,"value",null,I.value,Z),(E=I.onVnodeBeforeMount)&&invokeVNodeHook(E,T,y)}X&&invokeDirectiveHook(y,null,T,"beforeMount");const U=needTransition(R,V);U&&V.beforeEnter(B),s(B,x,k),((E=I&&I.onVnodeMounted)||U||X)&&queuePostRenderEffect(()=>{E&&invokeVNodeHook(E,T,y),U&&V.enter(B),X&&invokeDirectiveHook(y,null,T,"mounted")},R)},_=(y,x,k,T,R)=>{if(k&&O(y,k),T)for(let Z=0;Z{for(let E=B;E{const M=x.el=y.el;let{patchFlag:B,dynamicChildren:E,dirs:I}=x;B|=y.patchFlag&16;const W=y.props||EMPTY_OBJ,V=x.props||EMPTY_OBJ;let X;if(k&&toggleRecurse(k,!1),(X=V.onVnodeBeforeUpdate)&&invokeVNodeHook(X,k,x,y),I&&invokeDirectiveHook(x,y,k,"beforeUpdate"),k&&toggleRecurse(k,!0),E?Y(y.dynamicChildren,E,M,k,T,resolveChildrenNamespace(x,R),Z):D||F(y,x,M,null,k,T,resolveChildrenNamespace(x,R),Z,!1),B>0){if(B&16)z(M,x,W,V,k,T,R);else if(B&2&&W.class!==V.class&&l(M,"class",null,V.class,R),B&4&&l(M,"style",W.style,V.style,R),B&8){const U=x.dynamicProps;for(let J=0;J{X&&invokeVNodeHook(X,k,x,y),I&&invokeDirectiveHook(x,y,k,"updated")},T)},Y=(y,x,k,T,R,Z,D)=>{for(let M=0;M{if(k!==T){if(k!==EMPTY_OBJ)for(const M in k)!isReservedProp(M)&&!(M in T)&&l(y,M,k[M],null,D,x.children,R,Z,ce);for(const M in T){if(isReservedProp(M))continue;const B=T[M],E=k[M];B!==E&&M!=="value"&&l(y,M,E,B,D,x.children,R,Z,ce)}"value"in T&&l(y,"value",k.value,T.value,D)}},L=(y,x,k,T,R,Z,D,M,B)=>{const E=x.el=y?y.el:c(""),I=x.anchor=y?y.anchor:c("");let{patchFlag:W,dynamicChildren:V,slotScopeIds:X}=x;X&&(M=M?M.concat(X):X),y==null?(s(E,k,T),s(I,k,T),N(x.children||[],k,I,R,Z,D,M,B)):W>0&&W&64&&V&&y.dynamicChildren?(Y(y.dynamicChildren,V,k,R,Z,D,M),(x.key!=null||R&&x===R.subTree)&&traverseStaticChildren(y,x,!0)):F(y,x,k,I,R,Z,D,M,B)},H=(y,x,k,T,R,Z,D,M,B)=>{x.slotScopeIds=M,y==null?x.shapeFlag&512?R.ctx.activate(x,k,T,D,B):G(x,k,T,R,Z,D,B):ee(y,x,B)},G=(y,x,k,T,R,Z,D)=>{const M=y.component=createComponentInstance(y,T,R);if(isKeepAlive(y)&&(M.ctx.renderer=Oe),setupComponent(M),M.asyncDep){if(R&&R.registerDep(M,K),!y.el){const B=M.subTree=createVNode(Comment);w(null,B,x,k)}}else K(M,y,x,k,R,Z,D)},ee=(y,x,k)=>{const T=x.component=y.component;if(shouldUpdateComponent(y,x,k))if(T.asyncDep&&!T.asyncResolved){j(T,x,k);return}else T.next=x,invalidateJob(T.update),T.effect.dirty=!0,T.update();else x.el=y.el,T.vnode=x},K=(y,x,k,T,R,Z,D)=>{const M=()=>{if(y.isMounted){let{next:I,bu:W,u:V,parent:X,vnode:U}=y;{const ge=locateNonHydratedAsyncRoot(y);if(ge){I&&(I.el=U.el,j(y,I,D)),ge.asyncDep.then(()=>{y.isUnmounted||M()});return}}let J=I,ne;toggleRecurse(y,!1),I?(I.el=U.el,j(y,I,D)):I=U,W&&invokeArrayFns(W),(ne=I.props&&I.props.onVnodeBeforeUpdate)&&invokeVNodeHook(ne,X,I,U),toggleRecurse(y,!0);const le=renderComponentRoot(y),he=y.subTree;y.subTree=le,S(he,le,d(he.el),Se(he),y,R,Z),I.el=le.el,J===null&&updateHOCHostEl(y,le.el),V&&queuePostRenderEffect(V,R),(ne=I.props&&I.props.onVnodeUpdated)&&queuePostRenderEffect(()=>invokeVNodeHook(ne,X,I,U),R)}else{let I;const{el:W,props:V}=x,{bm:X,m:U,parent:J}=y,ne=isAsyncWrapper(x);if(toggleRecurse(y,!1),X&&invokeArrayFns(X),!ne&&(I=V&&V.onVnodeBeforeMount)&&invokeVNodeHook(I,J,x),toggleRecurse(y,!0),W&&we){const le=()=>{y.subTree=renderComponentRoot(y),we(W,y.subTree,y,R,null)};ne?x.type.__asyncLoader().then(()=>!y.isUnmounted&&le()):le()}else{const le=y.subTree=renderComponentRoot(y);S(null,le,k,T,y,R,Z),x.el=le.el}if(U&&queuePostRenderEffect(U,R),!ne&&(I=V&&V.onVnodeMounted)){const le=x;queuePostRenderEffect(()=>invokeVNodeHook(I,J,le),R)}(x.shapeFlag&256||J&&isAsyncWrapper(J.vnode)&&J.vnode.shapeFlag&256)&&y.a&&queuePostRenderEffect(y.a,R),y.isMounted=!0,x=k=T=null}},B=y.effect=new ReactiveEffect(M,NOOP,()=>queueJob(E),y.scope),E=y.update=()=>{B.dirty&&B.run()};E.id=y.uid,toggleRecurse(y,!0),E()},j=(y,x,k)=>{x.component=y;const T=y.vnode.props;y.vnode=x,y.next=null,updateProps(y,x.props,T,k),updateSlots(y,x.children,k),pauseTracking(),flushPreFlushCbs(y),resetTracking()},F=(y,x,k,T,R,Z,D,M,B=!1)=>{const E=y&&y.children,I=y?y.shapeFlag:0,W=x.children,{patchFlag:V,shapeFlag:X}=x;if(V>0){if(V&128){te(E,W,k,T,R,Z,D,M,B);return}else if(V&256){se(E,W,k,T,R,Z,D,M,B);return}}X&8?(I&16&&ce(E,R,Z),W!==E&&u(k,W)):I&16?X&16?te(E,W,k,T,R,Z,D,M,B):ce(E,R,Z,!0):(I&8&&u(k,""),X&16&&N(W,k,T,R,Z,D,M,B))},se=(y,x,k,T,R,Z,D,M,B)=>{y=y||EMPTY_ARR,x=x||EMPTY_ARR;const E=y.length,I=x.length,W=Math.min(E,I);let V;for(V=0;VI?ce(y,R,Z,!0,!1,W):N(x,k,T,R,Z,D,M,B,W)},te=(y,x,k,T,R,Z,D,M,B)=>{let E=0;const I=x.length;let W=y.length-1,V=I-1;for(;E<=W&&E<=V;){const X=y[E],U=x[E]=B?cloneIfMounted(x[E]):normalizeVNode(x[E]);if(isSameVNodeType(X,U))S(X,U,k,null,R,Z,D,M,B);else break;E++}for(;E<=W&&E<=V;){const X=y[W],U=x[V]=B?cloneIfMounted(x[V]):normalizeVNode(x[V]);if(isSameVNodeType(X,U))S(X,U,k,null,R,Z,D,M,B);else break;W--,V--}if(E>W){if(E<=V){const X=V+1,U=XV)for(;E<=W;)re(y[E],R,Z,!0),E++;else{const X=E,U=E,J=new Map;for(E=U;E<=V;E++){const ae=x[E]=B?cloneIfMounted(x[E]):normalizeVNode(x[E]);ae.key!=null&&J.set(ae.key,E)}let ne,le=0;const he=V-U+1;let ge=!1,ke=0;const me=new Array(he);for(E=0;E=he){re(ae,R,Z,!0);continue}let ue;if(ae.key!=null)ue=J.get(ae.key);else for(ne=U;ne<=V;ne++)if(me[ne-U]===0&&isSameVNodeType(ae,x[ne])){ue=ne;break}ue===void 0?re(ae,R,Z,!0):(me[ue-U]=E+1,ue>=ke?ke=ue:ge=!0,S(ae,x[ue],k,null,R,Z,D,M,B),le++)}const Pe=ge?getSequence(me):EMPTY_ARR;for(ne=Pe.length-1,E=he-1;E>=0;E--){const ae=U+E,ue=x[ae],ve=ae+1{const{el:Z,type:D,transition:M,children:B,shapeFlag:E}=y;if(E&6){oe(y.component.subTree,x,k,T);return}if(E&128){y.suspense.move(x,k,T);return}if(E&64){D.move(y,x,k,Oe);return}if(D===Fragment){s(Z,x,k);for(let W=0;WM.enter(Z),R);else{const{leave:W,delayLeave:V,afterLeave:X}=M,U=()=>s(Z,x,k),J=()=>{W(Z,()=>{U(),X&&X()})};V?V(Z,U,J):J()}else s(Z,x,k)},re=(y,x,k,T=!1,R=!1)=>{const{type:Z,props:D,ref:M,children:B,dynamicChildren:E,shapeFlag:I,patchFlag:W,dirs:V}=y;if(M!=null&&setRef(M,null,k,y,!0),I&256){x.ctx.deactivate(y);return}const X=I&1&&V,U=!isAsyncWrapper(y);let J;if(U&&(J=D&&D.onVnodeBeforeUnmount)&&invokeVNodeHook(J,x,y),I&6)pe(y.component,k,T);else{if(I&128){y.suspense.unmount(k,T);return}X&&invokeDirectiveHook(y,null,x,"beforeUnmount"),I&64?y.type.remove(y,x,k,R,Oe,T):E&&(Z!==Fragment||W>0&&W&64)?ce(E,x,k,!1,!0):(Z===Fragment&&W&384||!R&&I&16)&&ce(B,x,k),T&&fe(y)}(U&&(J=D&&D.onVnodeUnmounted)||X)&&queuePostRenderEffect(()=>{J&&invokeVNodeHook(J,x,y),X&&invokeDirectiveHook(y,null,x,"unmounted")},k)},fe=y=>{const{type:x,el:k,anchor:T,transition:R}=y;if(x===Fragment){de(k,T);return}if(x===Static){A(y);return}const Z=()=>{o(k),R&&!R.persisted&&R.afterLeave&&R.afterLeave()};if(y.shapeFlag&1&&R&&!R.persisted){const{leave:D,delayLeave:M}=R,B=()=>D(k,Z);M?M(y.el,Z,B):B()}else Z()},de=(y,x)=>{let k;for(;y!==x;)k=g(y),o(y),y=k;o(x)},pe=(y,x,k)=>{const{bum:T,scope:R,update:Z,subTree:D,um:M}=y;T&&invokeArrayFns(T),R.stop(),Z&&(Z.active=!1,re(D,y,x,k)),M&&queuePostRenderEffect(M,x),queuePostRenderEffect(()=>{y.isUnmounted=!0},x),x&&x.pendingBranch&&!x.isUnmounted&&y.asyncDep&&!y.asyncResolved&&y.suspenseId===x.pendingId&&(x.deps--,x.deps===0&&x.resolve())},ce=(y,x,k,T=!1,R=!1,Z=0)=>{for(let D=Z;Dy.shapeFlag&6?Se(y.component.subTree):y.shapeFlag&128?y.suspense.next():g(y.anchor||y.el);let ye=!1;const be=(y,x,k)=>{y==null?x._vnode&&re(x._vnode,null,null,!0):S(x._vnode||null,y,x,null,null,null,k),ye||(ye=!0,flushPreFlushCbs(),flushPostFlushCbs(),ye=!1),x._vnode=y},Oe={p:S,um:re,m:oe,r:fe,mt:G,mc:N,pc:F,pbc:Y,n:Se,o:r};let xe,we;return{render:be,hydrate:xe,createApp:createAppAPI(be,xe)}}function resolveChildrenNamespace({type:r,props:e},n){return n==="svg"&&r==="foreignObject"||n==="mathml"&&r==="annotation-xml"&&e&&e.encoding&&e.encoding.includes("html")?void 0:n}function toggleRecurse({effect:r,update:e},n){r.allowRecurse=e.allowRecurse=n}function needTransition(r,e){return(!r||r&&!r.pendingBranch)&&e&&!e.persisted}function traverseStaticChildren(r,e,n=!1){const s=r.children,o=e.children;if(isArray(s)&&isArray(o))for(let l=0;l>1,r[n[c]]0&&(e[s]=n[l-1]),n[l]=s)}}for(l=n.length,a=n[l-1];l-- >0;)n[l]=a,a=e[a];return n}function locateNonHydratedAsyncRoot(r){const e=r.subTree.component;if(e)return e.asyncDep&&!e.asyncResolved?e:locateNonHydratedAsyncRoot(e)}const isTeleport=r=>r.__isTeleport,Fragment=Symbol.for("v-fgt"),Text$1=Symbol.for("v-txt"),Comment=Symbol.for("v-cmt"),Static=Symbol.for("v-stc"),blockStack=[];let currentBlock=null;function openBlock(r=!1){blockStack.push(currentBlock=r?null:[])}function closeBlock(){blockStack.pop(),currentBlock=blockStack[blockStack.length-1]||null}let isBlockTreeEnabled=1;function setBlockTracking(r){isBlockTreeEnabled+=r}function setupBlock(r){return r.dynamicChildren=isBlockTreeEnabled>0?currentBlock||EMPTY_ARR:null,closeBlock(),isBlockTreeEnabled>0&¤tBlock&¤tBlock.push(r),r}function createElementBlock(r,e,n,s,o,l){return setupBlock(createBaseVNode(r,e,n,s,o,l,!0))}function createBlock(r,e,n,s,o){return setupBlock(createVNode(r,e,n,s,o,!0))}function isVNode(r){return r?r.__v_isVNode===!0:!1}function isSameVNodeType(r,e){return r.type===e.type&&r.key===e.key}const normalizeKey=({key:r})=>r??null,normalizeRef=({ref:r,ref_key:e,ref_for:n})=>(typeof r=="number"&&(r=""+r),r!=null?isString(r)||isRef(r)||isFunction(r)?{i:currentRenderingInstance,r,k:e,f:!!n}:r:null);function createBaseVNode(r,e=null,n=null,s=0,o=null,l=r===Fragment?0:1,a=!1,c=!1){const h={__v_isVNode:!0,__v_skip:!0,type:r,props:e,key:e&&normalizeKey(e),ref:e&&normalizeRef(e),scopeId:currentScopeId,slotScopeIds:null,children:n,component:null,suspense:null,ssContent:null,ssFallback:null,dirs:null,transition:null,el:null,anchor:null,target:null,targetAnchor:null,staticCount:0,shapeFlag:l,patchFlag:s,dynamicProps:o,dynamicChildren:null,appContext:null,ctx:currentRenderingInstance};return c?(normalizeChildren(h,n),l&128&&r.normalize(h)):n&&(h.shapeFlag|=isString(n)?8:16),isBlockTreeEnabled>0&&!a&¤tBlock&&(h.patchFlag>0||l&6)&&h.patchFlag!==32&¤tBlock.push(h),h}const createVNode=_createVNode;function _createVNode(r,e=null,n=null,s=0,o=null,l=!1){if((!r||r===NULL_DYNAMIC_COMPONENT)&&(r=Comment),isVNode(r)){const c=cloneVNode(r,e,!0);return n&&normalizeChildren(c,n),isBlockTreeEnabled>0&&!l&¤tBlock&&(c.shapeFlag&6?currentBlock[currentBlock.indexOf(r)]=c:currentBlock.push(c)),c.patchFlag|=-2,c}if(isClassComponent(r)&&(r=r.__vccOpts),e){e=guardReactiveProps(e);let{class:c,style:h}=e;c&&!isString(c)&&(e.class=normalizeClass(c)),isObject(h)&&(isProxy(h)&&!isArray(h)&&(h=extend$1({},h)),e.style=normalizeStyle(h))}const a=isString(r)?1:isSuspense(r)?128:isTeleport(r)?64:isObject(r)?4:isFunction(r)?2:0;return createBaseVNode(r,e,n,s,o,a,l,!0)}function guardReactiveProps(r){return r?isProxy(r)||isInternalObject(r)?extend$1({},r):r:null}function cloneVNode(r,e,n=!1,s=!1){const{props:o,ref:l,patchFlag:a,children:c,transition:h}=r,f=e?mergeProps(o||{},e):o,u={__v_isVNode:!0,__v_skip:!0,type:r.type,props:f,key:f&&normalizeKey(f),ref:e&&e.ref?n&&l?isArray(l)?l.concat(normalizeRef(e)):[l,normalizeRef(e)]:normalizeRef(e):l,scopeId:r.scopeId,slotScopeIds:r.slotScopeIds,children:c,target:r.target,targetAnchor:r.targetAnchor,staticCount:r.staticCount,shapeFlag:r.shapeFlag,patchFlag:e&&r.type!==Fragment?a===-1?16:a|16:a,dynamicProps:r.dynamicProps,dynamicChildren:r.dynamicChildren,appContext:r.appContext,dirs:r.dirs,transition:h,component:r.component,suspense:r.suspense,ssContent:r.ssContent&&cloneVNode(r.ssContent),ssFallback:r.ssFallback&&cloneVNode(r.ssFallback),el:r.el,anchor:r.anchor,ctx:r.ctx,ce:r.ce};return h&&s&&(u.transition=h.clone(u)),u}function createTextVNode(r=" ",e=0){return createVNode(Text$1,null,r,e)}function createStaticVNode(r,e){const n=createVNode(Static,null,r);return n.staticCount=e,n}function createCommentVNode(r="",e=!1){return e?(openBlock(),createBlock(Comment,null,r)):createVNode(Comment,null,r)}function normalizeVNode(r){return r==null||typeof r=="boolean"?createVNode(Comment):isArray(r)?createVNode(Fragment,null,r.slice()):typeof r=="object"?cloneIfMounted(r):createVNode(Text$1,null,String(r))}function cloneIfMounted(r){return r.el===null&&r.patchFlag!==-1||r.memo?r:cloneVNode(r)}function normalizeChildren(r,e){let n=0;const{shapeFlag:s}=r;if(e==null)e=null;else if(isArray(e))n=16;else if(typeof e=="object")if(s&65){const o=e.default;o&&(o._c&&(o._d=!1),normalizeChildren(r,o()),o._c&&(o._d=!0));return}else{n=32;const o=e._;!o&&!isInternalObject(e)?e._ctx=currentRenderingInstance:o===3&¤tRenderingInstance&&(currentRenderingInstance.slots._===1?e._=1:(e._=2,r.patchFlag|=1024))}else isFunction(e)?(e={default:e,_ctx:currentRenderingInstance},n=32):(e=String(e),s&64?(n=16,e=[createTextVNode(e)]):n=8);r.children=e,r.shapeFlag|=n}function mergeProps(...r){const e={};for(let n=0;n{let o;return(o=r[n])||(o=r[n]=[]),o.push(s),l=>{o.length>1?o.forEach(a=>a(l)):o[0](l)}};internalSetCurrentInstance=e("__VUE_INSTANCE_SETTERS__",n=>currentInstance=n),setInSSRSetupState=e("__VUE_SSR_SETTERS__",n=>isInSSRComponentSetup=n)}const setCurrentInstance=r=>{const e=currentInstance;return internalSetCurrentInstance(r),r.scope.on(),()=>{r.scope.off(),internalSetCurrentInstance(e)}},unsetCurrentInstance=()=>{currentInstance&¤tInstance.scope.off(),internalSetCurrentInstance(null)};function isStatefulComponent(r){return r.vnode.shapeFlag&4}let isInSSRComponentSetup=!1;function setupComponent(r,e=!1){e&&setInSSRSetupState(e);const{props:n,children:s}=r.vnode,o=isStatefulComponent(r);initProps(r,n,o,e),initSlots(r,s);const l=o?setupStatefulComponent(r,e):void 0;return e&&setInSSRSetupState(!1),l}function setupStatefulComponent(r,e){const n=r.type;r.accessCache=Object.create(null),r.proxy=new Proxy(r.ctx,PublicInstanceProxyHandlers);const{setup:s}=n;if(s){const o=r.setupContext=s.length>1?createSetupContext(r):null,l=setCurrentInstance(r);pauseTracking();const a=callWithErrorHandling(s,r,0,[r.props,o]);if(resetTracking(),l(),isPromise(a)){if(a.then(unsetCurrentInstance,unsetCurrentInstance),e)return a.then(c=>{handleSetupResult(r,c,e)}).catch(c=>{handleError(c,r,0)});r.asyncDep=a}else handleSetupResult(r,a,e)}else finishComponentSetup(r,e)}function handleSetupResult(r,e,n){isFunction(e)?r.type.__ssrInlineRender?r.ssrRender=e:r.render=e:isObject(e)&&(r.setupState=proxyRefs(e)),finishComponentSetup(r,n)}let compile;function finishComponentSetup(r,e,n){const s=r.type;if(!r.render){if(!e&&compile&&!s.render){const o=s.template||resolveMergedOptions(r).template;if(o){const{isCustomElement:l,compilerOptions:a}=r.appContext.config,{delimiters:c,compilerOptions:h}=s,f=extend$1(extend$1({isCustomElement:l,delimiters:c},a),h);s.render=compile(o,f)}}r.render=s.render||NOOP}{const o=setCurrentInstance(r);pauseTracking();try{applyOptions(r)}finally{resetTracking(),o()}}}const attrsProxyHandlers={get(r,e){return track(r,"get",""),r[e]}};function createSetupContext(r){const e=n=>{r.exposed=n||{}};return{attrs:new Proxy(r.attrs,attrsProxyHandlers),slots:r.slots,emit:r.emit,expose:e}}function getExposeProxy(r){if(r.exposed)return r.exposeProxy||(r.exposeProxy=new Proxy(proxyRefs(markRaw(r.exposed)),{get(e,n){if(n in e)return e[n];if(n in publicPropertiesMap)return publicPropertiesMap[n](r)},has(e,n){return n in e||n in publicPropertiesMap}}))}const classifyRE=/(?:^|[-_])(\w)/g,classify=r=>r.replace(classifyRE,e=>e.toUpperCase()).replace(/[-_]/g,"");function getComponentName(r,e=!0){return isFunction(r)?r.displayName||r.name:r.name||e&&r.__name}function formatComponentName(r,e,n=!1){let s=getComponentName(e);if(!s&&e.__file){const o=e.__file.match(/([^/\\]+)\.\w+$/);o&&(s=o[1])}if(!s&&r&&r.parent){const o=l=>{for(const a in l)if(l[a]===e)return a};s=o(r.components||r.parent.type.components)||o(r.appContext.components)}return s?classify(s):n?"App":"Anonymous"}function isClassComponent(r){return isFunction(r)&&"__vccOpts"in r}const computed=(r,e)=>computed$1(r,e,isInSSRComponentSetup),version="3.4.27";/** * @vue/runtime-dom v3.4.27 * (c) 2018-present Yuxi (Evan) You and Vue contributors * @license MIT -**/const svgNS="http://www.w3.org/2000/svg",mathmlNS="http://www.w3.org/1998/Math/MathML",doc$1=typeof document<"u"?document:null,templateContainer=doc$1&&doc$1.createElement("template"),nodeOps={insert:(r,e,n)=>{e.insertBefore(r,n||null)},remove:r=>{const e=r.parentNode;e&&e.removeChild(r)},createElement:(r,e,n,s)=>{const o=e==="svg"?doc$1.createElementNS(svgNS,r):e==="mathml"?doc$1.createElementNS(mathmlNS,r):doc$1.createElement(r,n?{is:n}:void 0);return r==="select"&&s&&s.multiple!=null&&o.setAttribute("multiple",s.multiple),o},createText:r=>doc$1.createTextNode(r),createComment:r=>doc$1.createComment(r),setText:(r,e)=>{r.nodeValue=e},setElementText:(r,e)=>{r.textContent=e},parentNode:r=>r.parentNode,nextSibling:r=>r.nextSibling,querySelector:r=>doc$1.querySelector(r),setScopeId(r,e){r.setAttribute(e,"")},insertStaticContent(r,e,n,s,o,l){const a=n?n.previousSibling:e.lastChild;if(o&&(o===l||o.nextSibling))for(;e.insertBefore(o.cloneNode(!0),n),!(o===l||!(o=o.nextSibling)););else{templateContainer.innerHTML=s==="svg"?`${r}`:s==="mathml"?`${r}`:r;const c=templateContainer.content;if(s==="svg"||s==="mathml"){const h=c.firstChild;for(;h.firstChild;)c.appendChild(h.firstChild);c.removeChild(h)}e.insertBefore(c,n)}return[a?a.nextSibling:e.firstChild,n?n.previousSibling:e.lastChild]}},vtcKey=Symbol("_vtc");function patchClass(r,e,n){const s=r[vtcKey];s&&(e=(e?[e,...s]:[...s]).join(" ")),e==null?r.removeAttribute("class"):n?r.setAttribute("class",e):r.className=e}const vShowOriginalDisplay=Symbol("_vod"),vShowHidden=Symbol("_vsh"),vShow={beforeMount(r,{value:e},{transition:n}){r[vShowOriginalDisplay]=r.style.display==="none"?"":r.style.display,n&&e?n.beforeEnter(r):setDisplay(r,e)},mounted(r,{value:e},{transition:n}){n&&e&&n.enter(r)},updated(r,{value:e,oldValue:n},{transition:s}){!e!=!n&&(s?e?(s.beforeEnter(r),setDisplay(r,!0),s.enter(r)):s.leave(r,()=>{setDisplay(r,!1)}):setDisplay(r,e))},beforeUnmount(r,{value:e}){setDisplay(r,e)}};function setDisplay(r,e){r.style.display=e?r[vShowOriginalDisplay]:"none",r[vShowHidden]=!e}const CSS_VAR_TEXT=Symbol(""),displayRE=/(^|;)\s*display\s*:/;function patchStyle(r,e,n){const s=r.style,o=isString(n);let l=!1;if(n&&!o){if(e)if(isString(e))for(const a of e.split(";")){const c=a.slice(0,a.indexOf(":")).trim();n[c]==null&&setStyle(s,c,"")}else for(const a in e)n[a]==null&&setStyle(s,a,"");for(const a in n)a==="display"&&(l=!0),setStyle(s,a,n[a])}else if(o){if(e!==n){const a=s[CSS_VAR_TEXT];a&&(n+=";"+a),s.cssText=n,l=displayRE.test(n)}}else e&&r.removeAttribute("style");vShowOriginalDisplay in r&&(r[vShowOriginalDisplay]=l?s.display:"",r[vShowHidden]&&(s.display="none"))}const importantRE=/\s*!important$/;function setStyle(r,e,n){if(isArray(n))n.forEach(s=>setStyle(r,e,s));else if(n==null&&(n=""),e.startsWith("--"))r.setProperty(e,n);else{const s=autoPrefix(r,e);importantRE.test(n)?r.setProperty(hyphenate(s),n.replace(importantRE,""),"important"):r[s]=n}}const prefixes=["Webkit","Moz","ms"],prefixCache={};function autoPrefix(r,e){const n=prefixCache[e];if(n)return n;let s=camelize(e);if(s!=="filter"&&s in r)return prefixCache[e]=s;s=capitalize(s);for(let o=0;ocachedNow||(p.then(()=>cachedNow=0),cachedNow=Date.now());function createInvoker(r,e){const n=s=>{if(!s._vts)s._vts=Date.now();else if(s._vts<=n.attached)return;callWithAsyncErrorHandling(patchStopImmediatePropagation(s,n.value),e,5,[s])};return n.value=r,n.attached=getNow(),n}function patchStopImmediatePropagation(r,e){if(isArray(e)){const n=r.stopImmediatePropagation;return r.stopImmediatePropagation=()=>{n.call(r),r._stopped=!0},e.map(s=>o=>!o._stopped&&s&&s(o))}else return e}const isNativeOn=r=>r.charCodeAt(0)===111&&r.charCodeAt(1)===110&&r.charCodeAt(2)>96&&r.charCodeAt(2)<123,patchProp=(r,e,n,s,o,l,a,c,h)=>{const f=o==="svg";e==="class"?patchClass(r,s,f):e==="style"?patchStyle(r,n,s):isOn(e)?isModelListener(e)||patchEvent(r,e,n,s,a):(e[0]==="."?(e=e.slice(1),!0):e[0]==="^"?(e=e.slice(1),!1):shouldSetAsProp(r,e,s,f))?patchDOMProp(r,e,s,l,a,c,h):(e==="true-value"?r._trueValue=s:e==="false-value"&&(r._falseValue=s),patchAttr(r,e,s,f))};function shouldSetAsProp(r,e,n,s){if(s)return!!(e==="innerHTML"||e==="textContent"||e in r&&isNativeOn(e)&&isFunction(n));if(e==="spellcheck"||e==="draggable"||e==="translate"||e==="form"||e==="list"&&r.tagName==="INPUT"||e==="type"&&r.tagName==="TEXTAREA")return!1;if(e==="width"||e==="height"){const o=r.tagName;if(o==="IMG"||o==="VIDEO"||o==="CANVAS"||o==="SOURCE")return!1}return isNativeOn(e)&&isString(n)?!1:e in r}const rendererOptions=extend$1({patchProp},nodeOps);let renderer;function ensureRenderer(){return renderer||(renderer=createRenderer(rendererOptions))}const createApp=(...r)=>{const e=ensureRenderer().createApp(...r),{mount:n}=e;return e.mount=s=>{const o=normalizeContainer(s);if(!o)return;const l=e._component;!isFunction(l)&&!l.render&&!l.template&&(l.template=o.innerHTML),o.innerHTML="";const a=n(o,!1,resolveRootNamespace(o));return o instanceof Element&&(o.removeAttribute("v-cloak"),o.setAttribute("data-v-app","")),a},e};function resolveRootNamespace(r){if(r instanceof SVGElement)return"svg";if(typeof MathMLElement=="function"&&r instanceof MathMLElement)return"mathml"}function normalizeContainer(r){return isString(r)?document.querySelector(r):r}function getEditor(r){return store.editors.find(e=>e.editorId===r)}function setContent(r,e){r.dispatch({changes:[{from:0,to:r.state.doc.length},{from:0,insert:e}]})}const store=reactive({currentBottomPane:"filter",changeViewTo(r){this.currentBottomPane=r},editors:[],editorIds:{inputCodeEditor:"inputCodeEditor",filterEditor:"filterEditor"},getEditor,setContent,ast:[],filters:[],logMessage(r,e){},nodesPageSize:100,page:0,isTransformed:!1,filteredNodes:[],areFiltersActive:!0,resetParsedState(){},parseContent(){}}),_export_sfc=(r,e)=>{const n=r.__vccOpts||r;for(const[s,o]of e)n[s]=o;return n},_sfc_main$f={},_hoisted_1$c={xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 16 16",height:"45",width:"45","data-view-component":"true"},_hoisted_2$9=createBaseVNode("title",null,"GitHub icon",-1),_hoisted_3$5=createBaseVNode("path",{fill:"white","fill-rule":"evenodd",d:"M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0016 8c0-4.42-3.58-8-8-8z"},null,-1),_hoisted_4$4=[_hoisted_2$9,_hoisted_3$5];function _sfc_render$4(r,e){return openBlock(),createElementBlock("svg",_hoisted_1$c,_hoisted_4$4)}const IconGithub=_export_sfc(_sfc_main$f,[["render",_sfc_render$4]]),_sfc_main$e={},_hoisted_1$b={xmlns:"http://www.w3.org/2000/svg",x:"0px",y:"0px",viewBox:"0 0 300 500",width:"60",height:"60","xml:space":"preserve"},_hoisted_2$8=createStaticVNode(`Flaster (band-aid){e.insertBefore(r,n||null)},remove:r=>{const e=r.parentNode;e&&e.removeChild(r)},createElement:(r,e,n,s)=>{const o=e==="svg"?doc$1.createElementNS(svgNS,r):e==="mathml"?doc$1.createElementNS(mathmlNS,r):doc$1.createElement(r,n?{is:n}:void 0);return r==="select"&&s&&s.multiple!=null&&o.setAttribute("multiple",s.multiple),o},createText:r=>doc$1.createTextNode(r),createComment:r=>doc$1.createComment(r),setText:(r,e)=>{r.nodeValue=e},setElementText:(r,e)=>{r.textContent=e},parentNode:r=>r.parentNode,nextSibling:r=>r.nextSibling,querySelector:r=>doc$1.querySelector(r),setScopeId(r,e){r.setAttribute(e,"")},insertStaticContent(r,e,n,s,o,l){const a=n?n.previousSibling:e.lastChild;if(o&&(o===l||o.nextSibling))for(;e.insertBefore(o.cloneNode(!0),n),!(o===l||!(o=o.nextSibling)););else{templateContainer.innerHTML=s==="svg"?`${r}`:s==="mathml"?`${r}`:r;const c=templateContainer.content;if(s==="svg"||s==="mathml"){const h=c.firstChild;for(;h.firstChild;)c.appendChild(h.firstChild);c.removeChild(h)}e.insertBefore(c,n)}return[a?a.nextSibling:e.firstChild,n?n.previousSibling:e.lastChild]}},vtcKey=Symbol("_vtc");function patchClass(r,e,n){const s=r[vtcKey];s&&(e=(e?[e,...s]:[...s]).join(" ")),e==null?r.removeAttribute("class"):n?r.setAttribute("class",e):r.className=e}const vShowOriginalDisplay=Symbol("_vod"),vShowHidden=Symbol("_vsh"),CSS_VAR_TEXT=Symbol(""),displayRE=/(^|;)\s*display\s*:/;function patchStyle(r,e,n){const s=r.style,o=isString(n);let l=!1;if(n&&!o){if(e)if(isString(e))for(const a of e.split(";")){const c=a.slice(0,a.indexOf(":")).trim();n[c]==null&&setStyle(s,c,"")}else for(const a in e)n[a]==null&&setStyle(s,a,"");for(const a in n)a==="display"&&(l=!0),setStyle(s,a,n[a])}else if(o){if(e!==n){const a=s[CSS_VAR_TEXT];a&&(n+=";"+a),s.cssText=n,l=displayRE.test(n)}}else e&&r.removeAttribute("style");vShowOriginalDisplay in r&&(r[vShowOriginalDisplay]=l?s.display:"",r[vShowHidden]&&(s.display="none"))}const importantRE=/\s*!important$/;function setStyle(r,e,n){if(isArray(n))n.forEach(s=>setStyle(r,e,s));else if(n==null&&(n=""),e.startsWith("--"))r.setProperty(e,n);else{const s=autoPrefix(r,e);importantRE.test(n)?r.setProperty(hyphenate(s),n.replace(importantRE,""),"important"):r[s]=n}}const prefixes=["Webkit","Moz","ms"],prefixCache={};function autoPrefix(r,e){const n=prefixCache[e];if(n)return n;let s=camelize(e);if(s!=="filter"&&s in r)return prefixCache[e]=s;s=capitalize(s);for(let o=0;ocachedNow||(p.then(()=>cachedNow=0),cachedNow=Date.now());function createInvoker(r,e){const n=s=>{if(!s._vts)s._vts=Date.now();else if(s._vts<=n.attached)return;callWithAsyncErrorHandling(patchStopImmediatePropagation(s,n.value),e,5,[s])};return n.value=r,n.attached=getNow(),n}function patchStopImmediatePropagation(r,e){if(isArray(e)){const n=r.stopImmediatePropagation;return r.stopImmediatePropagation=()=>{n.call(r),r._stopped=!0},e.map(s=>o=>!o._stopped&&s&&s(o))}else return e}const isNativeOn=r=>r.charCodeAt(0)===111&&r.charCodeAt(1)===110&&r.charCodeAt(2)>96&&r.charCodeAt(2)<123,patchProp=(r,e,n,s,o,l,a,c,h)=>{const f=o==="svg";e==="class"?patchClass(r,s,f):e==="style"?patchStyle(r,n,s):isOn(e)?isModelListener(e)||patchEvent(r,e,n,s,a):(e[0]==="."?(e=e.slice(1),!0):e[0]==="^"?(e=e.slice(1),!1):shouldSetAsProp(r,e,s,f))?patchDOMProp(r,e,s,l,a,c,h):(e==="true-value"?r._trueValue=s:e==="false-value"&&(r._falseValue=s),patchAttr(r,e,s,f))};function shouldSetAsProp(r,e,n,s){if(s)return!!(e==="innerHTML"||e==="textContent"||e in r&&isNativeOn(e)&&isFunction(n));if(e==="spellcheck"||e==="draggable"||e==="translate"||e==="form"||e==="list"&&r.tagName==="INPUT"||e==="type"&&r.tagName==="TEXTAREA")return!1;if(e==="width"||e==="height"){const o=r.tagName;if(o==="IMG"||o==="VIDEO"||o==="CANVAS"||o==="SOURCE")return!1}return isNativeOn(e)&&isString(n)?!1:e in r}const rendererOptions=extend$1({patchProp},nodeOps);let renderer;function ensureRenderer(){return renderer||(renderer=createRenderer(rendererOptions))}const createApp=(...r)=>{const e=ensureRenderer().createApp(...r),{mount:n}=e;return e.mount=s=>{const o=normalizeContainer(s);if(!o)return;const l=e._component;!isFunction(l)&&!l.render&&!l.template&&(l.template=o.innerHTML),o.innerHTML="";const a=n(o,!1,resolveRootNamespace(o));return o instanceof Element&&(o.removeAttribute("v-cloak"),o.setAttribute("data-v-app","")),a},e};function resolveRootNamespace(r){if(r instanceof SVGElement)return"svg";if(typeof MathMLElement=="function"&&r instanceof MathMLElement)return"mathml"}function normalizeContainer(r){return isString(r)?document.querySelector(r):r}function getEditor(r){return store.editors.find(e=>e.editorId===r)}function setContent(r,e){r.dispatch({changes:[{from:0,to:r.state.doc.length},{from:0,insert:e}]})}const store=reactive({currentBottomPane:"filter",changeViewTo(r){this.currentBottomPane=r},editors:[],editorIds:{inputCodeEditor:"inputCodeEditor",filterEditor:"filterEditor"},getEditor,setContent,ast:[],filters:[],logMessage(r,e){},nodesPageSize:100,page:0,isTransformed:!1,filteredNodes:[],areFiltersActive:!0,resetParsedState(){},parseContent(){}}),_export_sfc=(r,e)=>{const n=r.__vccOpts||r;for(const[s,o]of e)n[s]=o;return n},_sfc_main$g={},_hoisted_1$d={xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 16 16",height:"45",width:"45","data-view-component":"true"},_hoisted_2$a=createBaseVNode("title",null,"GitHub icon",-1),_hoisted_3$6=createBaseVNode("path",{fill:"white","fill-rule":"evenodd",d:"M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0016 8c0-4.42-3.58-8-8-8z"},null,-1),_hoisted_4$5=[_hoisted_2$a,_hoisted_3$6];function _sfc_render$4(r,e){return openBlock(),createElementBlock("svg",_hoisted_1$d,_hoisted_4$5)}const IconGithub=_export_sfc(_sfc_main$g,[["render",_sfc_render$4]]),_sfc_main$f={},_hoisted_1$c={xmlns:"http://www.w3.org/2000/svg",x:"0px",y:"0px",viewBox:"0 0 300 500",width:"60",height:"60","xml:space":"preserve"},_hoisted_2$9=createStaticVNode(`Flaster (band-aid)`,2),_hoisted_4$3=[_hoisted_2$8];function _sfc_render$3(r,e){return openBlock(),createElementBlock("svg",_hoisted_1$b,_hoisted_4$3)}const IconBandaid=_export_sfc(_sfc_main$e,[["render",_sfc_render$3]]),_hoisted_1$a={class:"btn btn-load-file"},_sfc_main$d={__name:"FileLoader",setup(r){const e={noFile:"Load File",loaded:""},n=ref(null),s=store.editorIds.inputCodeEditor;onMounted(()=>{n.value&&(n.value.innerText=e.noFile)});function o(l){var h;const a=((h=l.target)==null?void 0:h.files)||[];let c;a.length&&(c=a[0]),c?(c.text().then(f=>{store.setContent(store.getEditor(s),f),store.resetParsedState()}),n.value.innerText=e.loaded+c.name.substring(0,30)):(store.setContent(store.getEditor(s),""),n.value.innerText=e.noFile,store.resetParsedState())}return(l,a)=>(openBlock(),createElementBlock("div",null,[createBaseVNode("button",_hoisted_1$a,[createBaseVNode("label",null,[createBaseVNode("span",{class:"file-status",ref_key:"status",ref:n},null,512),createBaseVNode("input",{class:"inputFile",type:"file",onChange:o},null,32)])])]))}},FileLoader=_export_sfc(_sfc_main$d,[["__scopeId","data-v-60cc057b"]]),_sfc_main$c={__name:"ParseButton",setup(r){const e={parseContent:"Parse Content",contentParsed:"Content is Parsed ",astParseFail:"Unable to Parse AST",emptyCode:"No Content"},n=ref(null);function s(){const c=n.value;store.getEditor(store.editorIds.inputCodeEditor).isParsed=!0,c.classList.add("parsed"),c.classList.remove("unparsed")}function o(){const c=n.value,h=store.getEditor(store.editorIds.inputCodeEditor);h&&(h.isParsed=!1),c.classList.add("unparsed"),c.classList.remove("parsed")}function l(){store.ast=[],store.matchingNodes=[],o(),store.page=0}onMounted(()=>{store.resetParsedState=l,store.parseContent=a,n.value&&o()});function a(){try{l();const c=store.getEditor(store.editorIds.inputCodeEditor).state.doc.toString();c!=null&&c.length?new Promise(()=>{store.filteredNodes=store.ast=[],store.ast=window.flast.generateFlatAST(c,{detailed:!1}),store.ast.length?store.logMessage(`Parsed ${c.length} chars into ${store.ast.length} nodes`,"success"):store.logMessage(e.astParseFail,"error"),store.filteredNodes=store.ast,s()}).catch(h=>store.logMessage(h.message,"error")):store.logMessage(e.emptyCode,"error")}catch(c){store.logMessage(c.message,"error")}}return(c,h)=>(openBlock(),createElementBlock("button",{ref_key:"parsedStatusEl",ref:n,class:"btn unparsed",onClick:a},toDisplayString(e.parseContent),513))}},ParseButton=_export_sfc(_sfc_main$c,[["__scopeId","data-v-495cc9b9"]]),_withScopeId$1=r=>(pushScopeId("data-v-dcc72627"),r=r(),popScopeId(),r),_hoisted_1$9={class:"nav-left",title:"flASTer"},_hoisted_2$7=_withScopeId$1(()=>createBaseVNode("span",{class:"nav-title"},[createTextVNode("fl"),createBaseVNode("b",null,"AST"),createTextVNode("er")],-1)),_hoisted_3$4={class:"top-buttons"},_hoisted_4$2=["disabled"],_hoisted_5$2={title:"View code on GitHub"},_hoisted_6$2={href:"https://github.com/ctrl-escp/flaster",title:"flASTer on GitHub"},_hoisted_7$3=_withScopeId$1(()=>createBaseVNode("span",{class:"github-text"},"View on GitHub",-1)),_sfc_main$b={__name:"NavBar",setup(r){const e=[FileLoader,ParseButton],n=computed(()=>store.areFiltersActive&&store.filters.find(l=>l==null?void 0:l.enabled)),s=computed(()=>!1),o=computed(()=>n.value?s.value?"compose":"transform":"filter");return(l,a)=>(openBlock(),createElementBlock("nav",null,[createBaseVNode("span",_hoisted_1$9,[createVNode(IconBandaid),_hoisted_2$7]),createBaseVNode("div",_hoisted_3$4,[(openBlock(),createElementBlock(Fragment,null,renderList(e,c=>createBaseVNode("span",{key:c,class:"top-btn"},[(openBlock(),createBlock(resolveDynamicComponent(c)))])),64)),withDirectives(createBaseVNode("button",{class:"btn top-btn btn-filter",disabled:unref(store).currentBottomPane==="filter",onClick:a[0]||(a[0]=c=>unref(store).changeViewTo("filter"))},"Filter",8,_hoisted_4$2),[[vShow,unref(store).ast.length]]),withDirectives(createBaseVNode("button",{class:normalizeClass(["btn btn-transform",{active:o.value==="transform"}]),onClick:a[1]||(a[1]=c=>unref(store).changeViewTo("transform"))},"Transform",2),[[vShow,n.value]]),withDirectives(createBaseVNode("button",{class:normalizeClass(["btn btn-compose",{active:o.value==="compose"}]),onClick:a[2]||(a[2]=c=>unref(store).changeViewTo("transform"))},"compose",2),[[vShow,s.value]])]),createBaseVNode("span",_hoisted_5$2,[createBaseVNode("a",_hoisted_6$2,[_hoisted_7$3,createVNode(IconGithub)])])]))}},NavBar=_export_sfc(_sfc_main$b,[["__scopeId","data-v-dcc72627"]]),_hoisted_1$8={class:"ast-list-wrapper"},_hoisted_2$6={key:0},_hoisted_3$3={key:0,class:"paged"},_hoisted_4$1={key:1},_hoisted_5$1=["data-nodeid","onClick"],_hoisted_6$1=["title"],_hoisted_7$2={class:"node-parent-type",title:"Parent node type"},_hoisted_8$1={class:"node-src",title:"Click to show node in code"},_sfc_main$a={__name:"NodesList",setup(r){const e=reactive({highlightedNodeId:-1});function n(O){const m=store.getEditor(store.editorIds.inputCodeEditor);if(e.highlightedNodeId>-1){const y=document.querySelector(".highlight-node");y&&y.classList.remove("highlight-node")}O.nodeId===e.highlightedNodeId?(e.highlightedNodeId=-1,m.highlightRange()):(e.highlightedNodeId=O.nodeId,window.selectedNode=O,m.highlightRange(O.range[0],O.range[1]),document.querySelector(`div[data-nodeid="${O.nodeId}"]`).classList.add("highlight-node"))}const s=computed(()=>store.areFiltersActive?store.filteredNodes:store.ast),o=computed(()=>Number(store.page*store.nodesPageSize)),l=computed(()=>s.value.slice(o.value,o.value+store.nodesPageSize)),a=computed(()=>f.value?Math.floor(s.value.length/store.nodesPageSize):1),c=computed(()=>o.value<0?s.value.length+o.value:o.value),h=computed(()=>store.areFiltersActive&&store.filteredNodes.lengths.value.length>store.nodesPageSize),u=computed(()=>{const O=f.value?c.value+1:1;let m=c.value+l.value.length;return m=m>s.value.length?s.value.length:m,`${O} - ${m}`}),d=()=>store.page===a.value?store.page=0:store.page++,g=()=>store.page?store.page--:store.page=a.value;return onMounted(()=>{}),(O,m)=>(openBlock(),createElementBlock("fieldset",_hoisted_1$8,[unref(store).ast.length?(openBlock(),createElementBlock("legend",_hoisted_2$6,[f.value?(openBlock(),createElementBlock("span",_hoisted_3$3,[createBaseVNode("button",{class:"prev-page",title:"Previous page",onClick:g},"<"),createBaseVNode("button",{class:"next-page",title:"Next page",onClick:d},">")])):createCommentVNode("",!0),createBaseVNode("span",null,toDisplayString(u.value)+" / "+toDisplayString(unref(store)[unref(store).areFiltersActive?"filteredNodes":"ast"].length)+toDisplayString(h.value?" filtered":"")+" out of "+toDisplayString(unref(store).ast.length)+" nodes",1)])):(openBlock(),createElementBlock("legend",_hoisted_4$1,"Nodes")),(openBlock(!0),createElementBlock(Fragment,null,renderList(l.value,y=>{var b;return openBlock(),createElementBlock("div",{key:y.nodeId,class:"node-container","data-nodeid":y.nodeId,onClick:w=>n(y)},[createBaseVNode("span",{class:"node-type",title:"NodeId: "+y.nodeId},[createTextVNode(" ["),createBaseVNode("span",_hoisted_7$2,toDisplayString(y.parentNode?y.parentNode.type+"=>":""),1),createTextVNode(toDisplayString(y.type)+"] ",1)],8,_hoisted_6$1),createBaseVNode("span",_hoisted_8$1,toDisplayString((b=y.src)!=null&&b.substring?y.src.substring(0,200):"N/A"),1)],8,_hoisted_5$1)}),128))]))}},NodesList=_export_sfc(_sfc_main$a,[["__scopeId","data-v-45fa1d29"]]);class Text{lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,n,s){[e,n]=clip(this,e,n);let o=[];return this.decompose(0,e,o,2),s.length&&s.decompose(0,s.length,o,3),this.decompose(n,this.length,o,1),TextNode.from(o,this.length-(n-e)+s.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,n=this.length){[e,n]=clip(this,e,n);let s=[];return this.decompose(e,n,s,0),TextNode.from(s,n-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let n=this.scanIdentical(e,1),s=this.length-this.scanIdentical(e,-1),o=new RawTextCursor(this),l=new RawTextCursor(e);for(let a=n,c=n;;){if(o.next(a),l.next(a),a=0,o.lineBreak!=l.lineBreak||o.done!=l.done||o.value!=l.value)return!1;if(c+=o.value.length,o.done||c>=s)return!0}}iter(e=1){return new RawTextCursor(this,e)}iterRange(e,n=this.length){return new PartialTextCursor(this,e,n)}iterLines(e,n){let s;if(e==null)s=this.iter();else{n==null&&(n=this.lines+1);let o=this.line(e).from;s=this.iterRange(o,Math.max(o,n==this.lines+1?this.length:n<=1?0:this.line(n-1).to))}return new LineCursor(s)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?Text.empty:e.length<=32?new TextLeaf(e):TextNode.from(TextLeaf.split(e,[]))}}class TextLeaf extends Text{constructor(e,n=textLength(e)){super(),this.text=e,this.length=n}get lines(){return this.text.length}get children(){return null}lineInner(e,n,s,o){for(let l=0;;l++){let a=this.text[l],c=o+a.length;if((n?s:c)>=e)return new Line(o,c,s,a);o=c+1,s++}}decompose(e,n,s,o){let l=e<=0&&n>=this.length?this:new TextLeaf(sliceText(this.text,e,n),Math.min(n,this.length)-Math.max(0,e));if(o&1){let a=s.pop(),c=appendText(l.text,a.text.slice(),0,l.length);if(c.length<=32)s.push(new TextLeaf(c,a.length+l.length));else{let h=c.length>>1;s.push(new TextLeaf(c.slice(0,h)),new TextLeaf(c.slice(h)))}}else s.push(l)}replace(e,n,s){if(!(s instanceof TextLeaf))return super.replace(e,n,s);[e,n]=clip(this,e,n);let o=appendText(this.text,appendText(s.text,sliceText(this.text,0,e)),n),l=this.length+s.length-(n-e);return o.length<=32?new TextLeaf(o,l):TextNode.from(TextLeaf.split(o,[]),l)}sliceString(e,n=this.length,s=` + S277.53,436.109,273.102,436.109z">`,2),_hoisted_4$4=[_hoisted_2$9];function _sfc_render$3(r,e){return openBlock(),createElementBlock("svg",_hoisted_1$c,_hoisted_4$4)}const IconBandaid=_export_sfc(_sfc_main$f,[["render",_sfc_render$3]]),_hoisted_1$b={class:"btn btn-load-file"},_sfc_main$e={__name:"FileLoader",setup(r){const e={noFile:"Load File",loaded:""},n=ref(null),s=store.editorIds.inputCodeEditor;onMounted(()=>{n.value&&(n.value.innerText=e.noFile)});function o(l){var h;const a=((h=l.target)==null?void 0:h.files)||[];let c;a.length&&(c=a[0]),c?(c.text().then(f=>{store.setContent(store.getEditor(s),f),store.resetParsedState()}),n.value.innerText=e.loaded+c.name.substring(0,30)):(store.setContent(store.getEditor(s),""),n.value.innerText=e.noFile,store.resetParsedState())}return(l,a)=>(openBlock(),createElementBlock("div",null,[createBaseVNode("button",_hoisted_1$b,[createBaseVNode("label",null,[createBaseVNode("span",{class:"file-status",ref_key:"status",ref:n},null,512),createBaseVNode("input",{class:"inputFile",type:"file",onChange:o},null,32)])])]))}},FileLoader=_export_sfc(_sfc_main$e,[["__scopeId","data-v-60cc057b"]]),_sfc_main$d={__name:"ParseButton",setup(r){const e={parseContent:"Parse Content",contentParsed:"Content is Parsed ",astParseFail:"Unable to Parse AST",emptyCode:"No Content"},n=ref(null);function s(){const c=n.value;store.getEditor(store.editorIds.inputCodeEditor).isParsed=!0,c.classList.add("parsed"),c.classList.remove("unparsed")}function o(){const c=n.value,h=store.getEditor(store.editorIds.inputCodeEditor);h&&(h.isParsed=!1),c.classList.add("unparsed"),c.classList.remove("parsed")}function l(){store.ast=[],store.matchingNodes=[],o(),store.page=0}onMounted(()=>{store.resetParsedState=l,store.parseContent=a,n.value&&o()});function a(){try{l();const c=store.getEditor(store.editorIds.inputCodeEditor).state.doc.toString();c!=null&&c.length?new Promise(()=>{store.filteredNodes=store.ast=[],store.ast=window.flast.generateFlatAST(c,{detailed:!1}),store.ast.length?store.logMessage(`Parsed ${c.length} chars into ${store.ast.length} nodes`,"success"):store.logMessage(e.astParseFail,"error"),store.filteredNodes=store.ast,s()}).catch(h=>store.logMessage(h.message,"error")):store.logMessage(e.emptyCode,"error")}catch(c){store.logMessage(c.message,"error")}}return(c,h)=>(openBlock(),createElementBlock("button",{ref_key:"parsedStatusEl",ref:n,class:"btn unparsed",onClick:a},toDisplayString(e.parseContent),513))}},ParseButton=_export_sfc(_sfc_main$d,[["__scopeId","data-v-495cc9b9"]]),_withScopeId$2=r=>(pushScopeId("data-v-b40af671"),r=r(),popScopeId(),r),_hoisted_1$a={class:"nav-left",title:"flASTer"},_hoisted_2$8=_withScopeId$2(()=>createBaseVNode("span",{class:"nav-title"},[createTextVNode("fl"),createBaseVNode("b",null,"AST"),createTextVNode("er")],-1)),_hoisted_3$5={class:"top-buttons"},_hoisted_4$3=["disabled"],_hoisted_5$3=["disabled"],_hoisted_6$3=["disabled"],_hoisted_7$4={title:"View code on GitHub"},_hoisted_8$3={href:"https://github.com/ctrl-escp/flaster",title:"flASTer on GitHub"},_hoisted_9$2=_withScopeId$2(()=>createBaseVNode("span",{class:"github-text"},"View on GitHub",-1)),_sfc_main$c={__name:"NavBar",setup(r){const e=[FileLoader,ParseButton],n=computed(()=>store.areFiltersActive&&store.filters.find(l=>l==null?void 0:l.enabled)),s=computed(()=>!1),o=computed(()=>n.value?s.value?"compose":"transform":"filter");return(l,a)=>(openBlock(),createElementBlock("nav",null,[createBaseVNode("span",_hoisted_1$a,[createVNode(IconBandaid),_hoisted_2$8]),createBaseVNode("div",_hoisted_3$5,[(openBlock(),createElementBlock(Fragment,null,renderList(e,c=>createBaseVNode("span",{key:c,class:"top-btn"},[(openBlock(),createBlock(resolveDynamicComponent(c)))])),64)),createBaseVNode("button",{class:"btn top-btn",disabled:!unref(store).ast.length||unref(store).currentBottomPane==="filter",onClick:a[0]||(a[0]=c=>unref(store).changeViewTo("filter"))},"Filter",8,_hoisted_4$3),createBaseVNode("button",{class:normalizeClass(["btn top-btn",{active:o.value==="transform"}]),onClick:a[1]||(a[1]=c=>unref(store).changeViewTo("transform")),disabled:!unref(store).ast.length||unref(store).currentBottomPane==="transform"||o.value!=="transform"},"Transform",10,_hoisted_5$3),createBaseVNode("button",{class:normalizeClass(["btn top-btn",{active:o.value==="compose"}]),onClick:a[2]||(a[2]=c=>unref(store).changeViewTo("transform")),disabled:!unref(store).ast.length||unref(store).currentBottomPane==="compose"||o.value!=="compose"},"compose",10,_hoisted_6$3)]),createBaseVNode("span",_hoisted_7$4,[createBaseVNode("a",_hoisted_8$3,[_hoisted_9$2,createVNode(IconGithub)])])]))}},NavBar=_export_sfc(_sfc_main$c,[["__scopeId","data-v-b40af671"]]),_hoisted_1$9={class:"ast-list-wrapper"},_hoisted_2$7={key:0},_hoisted_3$4={key:0,class:"paged"},_hoisted_4$2={key:1},_hoisted_5$2=["data-nodeid","onClick"],_hoisted_6$2=["title"],_hoisted_7$3={class:"node-parent-type",title:"Parent node type"},_hoisted_8$2={class:"node-src",title:"Click to show node in code"},_sfc_main$b={__name:"NodesList",setup(r){const e=reactive({highlightedNodeId:-1});function n(O){const m=store.getEditor(store.editorIds.inputCodeEditor);if(e.highlightedNodeId>-1){const S=document.querySelector(".highlight-node");S&&S.classList.remove("highlight-node")}O.nodeId===e.highlightedNodeId?(e.highlightedNodeId=-1,m.highlightRange()):(e.highlightedNodeId=O.nodeId,window.selectedNode=O,m.highlightRange(O.range[0],O.range[1]),document.querySelector(`div[data-nodeid="${O.nodeId}"]`).classList.add("highlight-node"))}const s=computed(()=>store.areFiltersActive?store.filteredNodes:store.ast),o=computed(()=>Number(store.page*store.nodesPageSize)),l=computed(()=>s.value.slice(o.value,o.value+store.nodesPageSize)),a=computed(()=>f.value?Math.floor(s.value.length/store.nodesPageSize):1),c=computed(()=>o.value<0?s.value.length+o.value:o.value),h=computed(()=>store.areFiltersActive&&store.filteredNodes.lengths.value.length>store.nodesPageSize),u=computed(()=>{const O=f.value?c.value+1:1;let m=c.value+l.value.length;return m=m>s.value.length?s.value.length:m,`${O} - ${m}`}),d=()=>store.page===a.value?store.page=0:store.page++,g=()=>store.page?store.page--:store.page=a.value;return onMounted(()=>{}),(O,m)=>(openBlock(),createElementBlock("fieldset",_hoisted_1$9,[unref(store).ast.length?(openBlock(),createElementBlock("legend",_hoisted_2$7,[f.value?(openBlock(),createElementBlock("span",_hoisted_3$4,[createBaseVNode("button",{class:"prev-page",title:"Previous page",onClick:g},"<"),createBaseVNode("button",{class:"next-page",title:"Next page",onClick:d},">")])):createCommentVNode("",!0),createBaseVNode("span",null,toDisplayString(u.value)+" / "+toDisplayString(unref(store)[unref(store).areFiltersActive?"filteredNodes":"ast"].length)+toDisplayString(h.value?" filtered":"")+" out of "+toDisplayString(unref(store).ast.length)+" nodes",1)])):(openBlock(),createElementBlock("legend",_hoisted_4$2,"Nodes")),(openBlock(!0),createElementBlock(Fragment,null,renderList(l.value,S=>{var b;return openBlock(),createElementBlock("div",{key:S.nodeId,class:"node-container","data-nodeid":S.nodeId,onClick:w=>n(S)},[createBaseVNode("span",{class:"node-type",title:"NodeId: "+S.nodeId},[createTextVNode(" ["),createBaseVNode("span",_hoisted_7$3,toDisplayString(S.parentNode?S.parentNode.type+"=>":""),1),createTextVNode(toDisplayString(S.type)+"] ",1)],8,_hoisted_6$2),createBaseVNode("span",_hoisted_8$2,toDisplayString((b=S.src)!=null&&b.substring?S.src.substring(0,200):"N/A"),1)],8,_hoisted_5$2)}),128))]))}},NodesList=_export_sfc(_sfc_main$b,[["__scopeId","data-v-45fa1d29"]]);class Text{lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,n,s){[e,n]=clip(this,e,n);let o=[];return this.decompose(0,e,o,2),s.length&&s.decompose(0,s.length,o,3),this.decompose(n,this.length,o,1),TextNode.from(o,this.length-(n-e)+s.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,n=this.length){[e,n]=clip(this,e,n);let s=[];return this.decompose(e,n,s,0),TextNode.from(s,n-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let n=this.scanIdentical(e,1),s=this.length-this.scanIdentical(e,-1),o=new RawTextCursor(this),l=new RawTextCursor(e);for(let a=n,c=n;;){if(o.next(a),l.next(a),a=0,o.lineBreak!=l.lineBreak||o.done!=l.done||o.value!=l.value)return!1;if(c+=o.value.length,o.done||c>=s)return!0}}iter(e=1){return new RawTextCursor(this,e)}iterRange(e,n=this.length){return new PartialTextCursor(this,e,n)}iterLines(e,n){let s;if(e==null)s=this.iter();else{n==null&&(n=this.lines+1);let o=this.line(e).from;s=this.iterRange(o,Math.max(o,n==this.lines+1?this.length:n<=1?0:this.line(n-1).to))}return new LineCursor(s)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?Text.empty:e.length<=32?new TextLeaf(e):TextNode.from(TextLeaf.split(e,[]))}}class TextLeaf extends Text{constructor(e,n=textLength(e)){super(),this.text=e,this.length=n}get lines(){return this.text.length}get children(){return null}lineInner(e,n,s,o){for(let l=0;;l++){let a=this.text[l],c=o+a.length;if((n?s:c)>=e)return new Line(o,c,s,a);o=c+1,s++}}decompose(e,n,s,o){let l=e<=0&&n>=this.length?this:new TextLeaf(sliceText(this.text,e,n),Math.min(n,this.length)-Math.max(0,e));if(o&1){let a=s.pop(),c=appendText(l.text,a.text.slice(),0,l.length);if(c.length<=32)s.push(new TextLeaf(c,a.length+l.length));else{let h=c.length>>1;s.push(new TextLeaf(c.slice(0,h)),new TextLeaf(c.slice(h)))}}else s.push(l)}replace(e,n,s){if(!(s instanceof TextLeaf))return super.replace(e,n,s);[e,n]=clip(this,e,n);let o=appendText(this.text,appendText(s.text,sliceText(this.text,0,e)),n),l=this.length+s.length-(n-e);return o.length<=32?new TextLeaf(o,l):TextNode.from(TextLeaf.split(o,[]),l)}sliceString(e,n=this.length,s=` `){[e,n]=clip(this,e,n);let o="";for(let l=0,a=0;l<=n&&ae&&a&&(o+=s),el&&(o+=c.slice(Math.max(0,e-l),n-l)),l=h+1}return o}flatten(e){for(let n of this.text)e.push(n)}scanIdentical(){return 0}static split(e,n){let s=[],o=-1;for(let l of e)s.push(l),o+=l.length+1,s.length==32&&(n.push(new TextLeaf(s,o)),s=[],o=-1);return o>-1&&n.push(new TextLeaf(s,o)),n}}class TextNode extends Text{constructor(e,n){super(),this.children=e,this.length=n,this.lines=0;for(let s of e)this.lines+=s.lines}lineInner(e,n,s,o){for(let l=0;;l++){let a=this.children[l],c=o+a.length,h=s+a.lines-1;if((n?h:c)>=e)return a.lineInner(e,n,s,o);o=c+1,s=h+1}}decompose(e,n,s,o){for(let l=0,a=0;a<=n&&l=a){let f=o&((a<=e?1:0)|(h>=n?2:0));a>=e&&h<=n&&!f?s.push(c):c.decompose(e-a,n-a,s,f)}a=h+1}}replace(e,n,s){if([e,n]=clip(this,e,n),s.lines=l&&n<=c){let h=a.replace(e-l,n-l,s),f=this.lines-a.lines+h.lines;if(h.lines>4&&h.lines>f>>6){let u=this.children.slice();return u[o]=h,new TextNode(u,this.length-(n-e)+s.length)}return super.replace(l,c,h)}l=c+1}return super.replace(e,n,s)}sliceString(e,n=this.length,s=` -`){[e,n]=clip(this,e,n);let o="";for(let l=0,a=0;le&&l&&(o+=s),ea&&(o+=c.sliceString(e-a,n-a,s)),a=h+1}return o}flatten(e){for(let n of this.children)n.flatten(e)}scanIdentical(e,n){if(!(e instanceof TextNode))return 0;let s=0,[o,l,a,c]=n>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;o+=n,l+=n){if(o==a||l==c)return s;let h=this.children[o],f=e.children[l];if(h!=f)return s+h.scanIdentical(f,n);s+=h.length+1}}static from(e,n=e.reduce((s,o)=>s+o.length+1,-1)){let s=0;for(let O of e)s+=O.lines;if(s<32){let O=[];for(let m of e)m.flatten(O);return new TextLeaf(O,n)}let o=Math.max(32,s>>5),l=o<<1,a=o>>1,c=[],h=0,f=-1,u=[];function d(O){let m;if(O.lines>l&&O instanceof TextNode)for(let y of O.children)d(y);else O.lines>a&&(h>a||!h)?(g(),c.push(O)):O instanceof TextLeaf&&h&&(m=u[u.length-1])instanceof TextLeaf&&O.lines+m.lines<=32?(h+=O.lines,f+=O.length+1,u[u.length-1]=new TextLeaf(m.text.concat(O.text),m.length+1+O.length)):(h+O.lines>o&&g(),h+=O.lines,f+=O.length+1,u.push(O))}function g(){h!=0&&(c.push(u.length==1?u[0]:TextNode.from(u,f)),f=-1,h=u.length=0)}for(let O of e)d(O);return g(),c.length==1?c[0]:new TextNode(c,n)}}Text.empty=new TextLeaf([""],0);function textLength(r){let e=-1;for(let n of r)e+=n.length+1;return e}function appendText(r,e,n=0,s=1e9){for(let o=0,l=0,a=!0;l=n&&(h>s&&(c=c.slice(0,s-o)),o0?1:(e instanceof TextLeaf?e.text.length:e.children.length)<<1]}nextInner(e,n){for(this.done=this.lineBreak=!1;;){let s=this.nodes.length-1,o=this.nodes[s],l=this.offsets[s],a=l>>1,c=o instanceof TextLeaf?o.text.length:o.children.length;if(a==(n>0?c:0)){if(s==0)return this.done=!0,this.value="",this;n>0&&this.offsets[s-1]++,this.nodes.pop(),this.offsets.pop()}else if((l&1)==(n>0?0:1)){if(this.offsets[s]+=n,e==0)return this.lineBreak=!0,this.value=` -`,this;e--}else if(o instanceof TextLeaf){let h=o.text[a+(n<0?-1:0)];if(this.offsets[s]+=n,h.length>Math.max(0,e))return this.value=e==0?h:n>0?h.slice(e):h.slice(0,h.length-e),this;e-=h.length}else{let h=o.children[a+(n<0?-1:0)];e>h.length?(e-=h.length,this.offsets[s]+=n):(n<0&&this.offsets[s]--,this.nodes.push(h),this.offsets.push(n>0?1:(h instanceof TextLeaf?h.text.length:h.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class PartialTextCursor{constructor(e,n,s){this.value="",this.done=!1,this.cursor=new RawTextCursor(e,n>s?-1:1),this.pos=n>s?e.length:0,this.from=Math.min(n,s),this.to=Math.max(n,s)}nextInner(e,n){if(n<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,n<0?this.pos-this.to:this.from-this.pos);let s=n<0?this.pos-this.from:this.to-this.pos;e>s&&(e=s),s-=e;let{value:o}=this.cursor.next(e);return this.pos+=(o.length+e)*n,this.value=o.length<=s?o:n<0?o.slice(o.length-s):o.slice(0,s),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=""}}class LineCursor{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:n,lineBreak:s,value:o}=this.inner.next(e);return n&&this.afterBreak?(this.value="",this.afterBreak=!1):n?(this.done=!0,this.value=""):s?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=o,this.afterBreak=!1),this}get lineBreak(){return!1}}typeof Symbol<"u"&&(Text.prototype[Symbol.iterator]=function(){return this.iter()},RawTextCursor.prototype[Symbol.iterator]=PartialTextCursor.prototype[Symbol.iterator]=LineCursor.prototype[Symbol.iterator]=function(){return this});class Line{constructor(e,n,s,o){this.from=e,this.to=n,this.number=s,this.text=o}get length(){return this.to-this.from}}function clip(r,e,n){return e=Math.max(0,Math.min(r.length,e)),[e,Math.max(e,Math.min(r.length,n))]}let extend="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(r=>r?parseInt(r,36):1);for(let r=1;rr)return extend[e-1]<=r;return!1}function isRegionalIndicator(r){return r>=127462&&r<=127487}const ZWJ=8205;function findClusterBreak(r,e,n=!0,s=!0){return(n?nextClusterBreak:prevClusterBreak)(r,e,s)}function nextClusterBreak(r,e,n){if(e==r.length)return e;e&&surrogateLow(r.charCodeAt(e))&&surrogateHigh(r.charCodeAt(e-1))&&e--;let s=codePointAt(r,e);for(e+=codePointSize(s);e=0&&isRegionalIndicator(codePointAt(r,a));)l++,a-=2;if(l%2==0)break;e+=2}else break}return e}function prevClusterBreak(r,e,n){for(;e>0;){let s=nextClusterBreak(r,e-2,n);if(s=56320&&r<57344}function surrogateHigh(r){return r>=55296&&r<56320}function codePointAt(r,e){let n=r.charCodeAt(e);if(!surrogateHigh(n)||e+1==r.length)return n;let s=r.charCodeAt(e+1);return surrogateLow(s)?(n-55296<<10)+(s-56320)+65536:n}function fromCodePoint(r){return r<=65535?String.fromCharCode(r):(r-=65536,String.fromCharCode((r>>10)+55296,(r&1023)+56320))}function codePointSize(r){return r<65536?1:2}const DefaultSplit=/\r\n?|\n/;var MapMode=function(r){return r[r.Simple=0]="Simple",r[r.TrackDel=1]="TrackDel",r[r.TrackBefore=2]="TrackBefore",r[r.TrackAfter=3]="TrackAfter",r}(MapMode||(MapMode={}));class ChangeDesc{constructor(e){this.sections=e}get length(){let e=0;for(let n=0;ne)return l+(e-o);l+=c}else{if(s!=MapMode.Simple&&f>=e&&(s==MapMode.TrackDel&&oe||s==MapMode.TrackBefore&&oe))return null;if(f>e||f==e&&n<0&&!c)return e==o||n<0?l:l+h;l+=h}o=f}if(e>o)throw new RangeError(`Position ${e} is out of range for changeset of length ${o}`);return l}touchesRange(e,n=e){for(let s=0,o=0;s=0&&o<=n&&c>=e)return on?"cover":!0;o=c}return!1}toString(){let e="";for(let n=0;n=0?":"+o:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(n=>typeof n!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new ChangeDesc(e)}static create(e){return new ChangeDesc(e)}}class ChangeSet extends ChangeDesc{constructor(e,n){super(e),this.inserted=n}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return iterChanges(this,(n,s,o,l,a)=>e=e.replace(o,o+(s-n),a),!1),e}mapDesc(e,n=!1){return mapSet(this,e,n,!0)}invert(e){let n=this.sections.slice(),s=[];for(let o=0,l=0;o=0){n[o]=c,n[o+1]=a;let h=o>>1;for(;s.length0&&addInsert(s,n,l.text),l.forward(u),c+=u}let f=e[a++];for(;c>1].toJSON()))}return e}static of(e,n,s){let o=[],l=[],a=0,c=null;function h(u=!1){if(!u&&!o.length)return;ag||d<0||g>n)throw new RangeError(`Invalid change range ${d} to ${g} (in doc of length ${n})`);let m=O?typeof O=="string"?Text.of(O.split(s||DefaultSplit)):O:Text.empty,y=m.length;if(d==g&&y==0)return;da&&addSection(o,d-a,-1),addSection(o,g-d,y),addInsert(l,o,m),a=g}}return f(e),h(!c),c}static empty(e){return new ChangeSet(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let n=[],s=[];for(let o=0;oc&&typeof a!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(l.length==1)n.push(l[0],0);else{for(;s.length=0&&n<=0&&n==r[o+1]?r[o]+=e:e==0&&r[o]==0?r[o+1]+=n:s?(r[o]+=e,r[o+1]+=n):r.push(e,n)}function addInsert(r,e,n){if(n.length==0)return;let s=e.length-2>>1;if(s>1])),!(n||a==r.sections.length||r.sections[a+1]<0);)c=r.sections[a++],h=r.sections[a++];e(o,f,l,u,d),o=f,l=u}}}function mapSet(r,e,n,s=!1){let o=[],l=s?[]:null,a=new SectionIter(r),c=new SectionIter(e);for(let h=-1;;)if(a.ins==-1&&c.ins==-1){let f=Math.min(a.len,c.len);addSection(o,f,-1),a.forward(f),c.forward(f)}else if(c.ins>=0&&(a.ins<0||h==a.i||a.off==0&&(c.len=0&&h=0){let f=0,u=a.len;for(;u;)if(c.ins==-1){let d=Math.min(u,c.len);f+=d,u-=d,c.forward(d)}else if(c.ins==0&&c.lenh||a.ins>=0&&a.len>h)&&(c||s.length>f),l.forward2(h),a.forward(h)}}}}class SectionIter{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i>1;return n>=e.length?Text.empty:e[n]}textBit(e){let{inserted:n}=this.set,s=this.i-2>>1;return s>=n.length&&!e?Text.empty:n[s].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}}class SelectionRange{constructor(e,n,s){this.from=e,this.to=n,this.flags=s}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}get goalColumn(){let e=this.flags>>6;return e==16777215?void 0:e}map(e,n=-1){let s,o;return this.empty?s=o=e.mapPos(this.from,n):(s=e.mapPos(this.from,1),o=e.mapPos(this.to,-1)),s==this.from&&o==this.to?this:new SelectionRange(s,o,this.flags)}extend(e,n=e){if(e<=this.anchor&&n>=this.anchor)return EditorSelection.range(e,n);let s=Math.abs(e-this.anchor)>Math.abs(n-this.anchor)?e:n;return EditorSelection.range(this.anchor,s)}eq(e,n=!1){return this.anchor==e.anchor&&this.head==e.head&&(!n||!this.empty||this.assoc==e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return EditorSelection.range(e.anchor,e.head)}static create(e,n,s){return new SelectionRange(e,n,s)}}class EditorSelection{constructor(e,n){this.ranges=e,this.mainIndex=n}map(e,n=-1){return e.empty?this:EditorSelection.create(this.ranges.map(s=>s.map(e,n)),this.mainIndex)}eq(e,n=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let s=0;se.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new EditorSelection(e.ranges.map(n=>SelectionRange.fromJSON(n)),e.main)}static single(e,n=e){return new EditorSelection([EditorSelection.range(e,n)],0)}static create(e,n=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let s=0,o=0;oe?8:0)|l)}static normalized(e,n=0){let s=e[n];e.sort((o,l)=>o.from-l.from),n=e.indexOf(s);for(let o=1;ol.head?EditorSelection.range(h,c):EditorSelection.range(c,h))}}return new EditorSelection(e,n)}}function checkSelection(r,e){for(let n of r.ranges)if(n.to>e)throw new RangeError("Selection points outside of document")}let nextID=0;class Facet{constructor(e,n,s,o,l){this.combine=e,this.compareInput=n,this.compare=s,this.isStatic=o,this.id=nextID++,this.default=e([]),this.extensions=typeof l=="function"?l(this):l}get reader(){return this}static define(e={}){return new Facet(e.combine||(n=>n),e.compareInput||((n,s)=>n===s),e.compare||(e.combine?(n,s)=>n===s:sameArray$1),!!e.static,e.enables)}of(e){return new FacetProvider([],this,0,e)}compute(e,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new FacetProvider(e,this,1,n)}computeN(e,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new FacetProvider(e,this,2,n)}from(e,n){return n||(n=s=>s),this.compute([e],s=>n(s.field(e)))}}function sameArray$1(r,e){return r==e||r.length==e.length&&r.every((n,s)=>n===e[s])}class FacetProvider{constructor(e,n,s,o){this.dependencies=e,this.facet=n,this.type=s,this.value=o,this.id=nextID++}dynamicSlot(e){var n;let s=this.value,o=this.facet.compareInput,l=this.id,a=e[l]>>1,c=this.type==2,h=!1,f=!1,u=[];for(let d of this.dependencies)d=="doc"?h=!0:d=="selection"?f=!0:((n=e[d.id])!==null&&n!==void 0?n:1)&1||u.push(e[d.id]);return{create(d){return d.values[a]=s(d),1},update(d,g){if(h&&g.docChanged||f&&(g.docChanged||g.selection)||ensureAll(d,u)){let O=s(d);if(c?!compareArray(O,d.values[a],o):!o(O,d.values[a]))return d.values[a]=O,1}return 0},reconfigure:(d,g)=>{let O,m=g.config.address[l];if(m!=null){let y=getAddr(g,m);if(this.dependencies.every(b=>b instanceof Facet?g.facet(b)===d.facet(b):b instanceof StateField?g.field(b,!1)==d.field(b,!1):!0)||(c?compareArray(O=s(d),y,o):o(O=s(d),y)))return d.values[a]=y,0}else O=s(d);return d.values[a]=O,1}}}}function compareArray(r,e,n){if(r.length!=e.length)return!1;for(let s=0;sr[h.id]),o=n.map(h=>h.type),l=s.filter(h=>!(h&1)),a=r[e.id]>>1;function c(h){let f=[];for(let u=0;us===o),e);return e.provide&&(n.provides=e.provide(n)),n}create(e){let n=e.facet(initField).find(s=>s.field==this);return((n==null?void 0:n.create)||this.createF)(e)}slot(e){let n=e[this.id]>>1;return{create:s=>(s.values[n]=this.create(s),1),update:(s,o)=>{let l=s.values[n],a=this.updateF(l,o);return this.compareF(l,a)?0:(s.values[n]=a,1)},reconfigure:(s,o)=>o.config.address[this.id]!=null?(s.values[n]=o.field(this),0):(s.values[n]=this.create(s),1)}}init(e){return[this,initField.of({field:this,create:e})]}get extension(){return this}}const Prec_={lowest:4,low:3,default:2,high:1,highest:0};function prec(r){return e=>new PrecExtension(e,r)}const Prec={highest:prec(Prec_.highest),high:prec(Prec_.high),default:prec(Prec_.default),low:prec(Prec_.low),lowest:prec(Prec_.lowest)};class PrecExtension{constructor(e,n){this.inner=e,this.prec=n}}class Compartment{of(e){return new CompartmentInstance(this,e)}reconfigure(e){return Compartment.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class CompartmentInstance{constructor(e,n){this.compartment=e,this.inner=n}}class Configuration{constructor(e,n,s,o,l,a){for(this.base=e,this.compartments=n,this.dynamicSlots=s,this.address=o,this.staticValues=l,this.facets=a,this.statusTemplate=[];this.statusTemplate.length>1]}static resolve(e,n,s){let o=[],l=Object.create(null),a=new Map;for(let g of flatten(e,n,a))g instanceof StateField?o.push(g):(l[g.facet.id]||(l[g.facet.id]=[])).push(g);let c=Object.create(null),h=[],f=[];for(let g of o)c[g.id]=f.length<<1,f.push(O=>g.slot(O));let u=s==null?void 0:s.config.facets;for(let g in l){let O=l[g],m=O[0].facet,y=u&&u[g]||[];if(O.every(b=>b.type==0))if(c[m.id]=h.length<<1|1,sameArray$1(y,O))h.push(s.facet(m));else{let b=m.combine(O.map(w=>w.value));h.push(s&&m.compare(b,s.facet(m))?s.facet(m):b)}else{for(let b of O)b.type==0?(c[b.id]=h.length<<1|1,h.push(b.value)):(c[b.id]=f.length<<1,f.push(w=>b.dynamicSlot(w)));c[m.id]=f.length<<1,f.push(b=>dynamicFacetSlot(b,m,O))}}let d=f.map(g=>g(c));return new Configuration(e,a,d,c,h,l)}}function flatten(r,e,n){let s=[[],[],[],[],[]],o=new Map;function l(a,c){let h=o.get(a);if(h!=null){if(h<=c)return;let f=s[h].indexOf(a);f>-1&&s[h].splice(f,1),a instanceof CompartmentInstance&&n.delete(a.compartment)}if(o.set(a,c),Array.isArray(a))for(let f of a)l(f,c);else if(a instanceof CompartmentInstance){if(n.has(a.compartment))throw new RangeError("Duplicate use of compartment in extensions");let f=e.get(a.compartment)||a.inner;n.set(a.compartment,f),l(f,c)}else if(a instanceof PrecExtension)l(a.inner,a.prec);else if(a instanceof StateField)s[c].push(a),a.provides&&l(a.provides,c);else if(a instanceof FacetProvider)s[c].push(a),a.facet.extensions&&l(a.facet.extensions,Prec_.default);else{let f=a.extension;if(!f)throw new Error(`Unrecognized extension value in extension set (${a}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);l(f,c)}}return l(r,Prec_.default),s.reduce((a,c)=>a.concat(c))}function ensureAddr(r,e){if(e&1)return 2;let n=e>>1,s=r.status[n];if(s==4)throw new Error("Cyclic dependency between fields and/or facets");if(s&2)return s;r.status[n]=4;let o=r.computeSlot(r,r.config.dynamicSlots[n]);return r.status[n]=2|o}function getAddr(r,e){return e&1?r.config.staticValues[e>>1]:r.values[e>>1]}const languageData=Facet.define(),allowMultipleSelections=Facet.define({combine:r=>r.some(e=>e),static:!0}),lineSeparator=Facet.define({combine:r=>r.length?r[0]:void 0,static:!0}),changeFilter=Facet.define(),transactionFilter=Facet.define(),transactionExtender=Facet.define(),readOnly=Facet.define({combine:r=>r.length?r[0]:!1});class Annotation{constructor(e,n){this.type=e,this.value=n}static define(){return new AnnotationType}}class AnnotationType{of(e){return new Annotation(this,e)}}class StateEffectType{constructor(e){this.map=e}of(e){return new StateEffect(this,e)}}class StateEffect{constructor(e,n){this.type=e,this.value=n}map(e){let n=this.type.map(this.value,e);return n===void 0?void 0:n==this.value?this:new StateEffect(this.type,n)}is(e){return this.type==e}static define(e={}){return new StateEffectType(e.map||(n=>n))}static mapEffects(e,n){if(!e.length)return e;let s=[];for(let o of e){let l=o.map(n);l&&s.push(l)}return s}}StateEffect.reconfigure=StateEffect.define();StateEffect.appendConfig=StateEffect.define();class Transaction{constructor(e,n,s,o,l,a){this.startState=e,this.changes=n,this.selection=s,this.effects=o,this.annotations=l,this.scrollIntoView=a,this._doc=null,this._state=null,s&&checkSelection(s,n.newLength),l.some(c=>c.type==Transaction.time)||(this.annotations=l.concat(Transaction.time.of(Date.now())))}static create(e,n,s,o,l,a){return new Transaction(e,n,s,o,l,a)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let n of this.annotations)if(n.type==e)return n.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let n=this.annotation(Transaction.userEvent);return!!(n&&(n==e||n.length>e.length&&n.slice(0,e.length)==e&&n[e.length]=="."))}}Transaction.time=Annotation.define();Transaction.userEvent=Annotation.define();Transaction.addToHistory=Annotation.define();Transaction.remote=Annotation.define();function joinRanges(r,e){let n=[];for(let s=0,o=0;;){let l,a;if(s=r[s]))l=r[s++],a=r[s++];else if(o=0;o--){let l=s[o](r);l instanceof Transaction?r=l:Array.isArray(l)&&l.length==1&&l[0]instanceof Transaction?r=l[0]:r=resolveTransaction(e,asArray$1(l),!1)}return r}function extendTransaction(r){let e=r.startState,n=e.facet(transactionExtender),s=r;for(let o=n.length-1;o>=0;o--){let l=n[o](r);l&&Object.keys(l).length&&(s=mergeTransaction(s,resolveTransactionInner(e,l,r.changes.newLength),!0))}return s==r?r:Transaction.create(e,r.changes,r.selection,s.effects,s.annotations,s.scrollIntoView)}const none$2=[];function asArray$1(r){return r==null?none$2:Array.isArray(r)?r:[r]}var CharCategory=function(r){return r[r.Word=0]="Word",r[r.Space=1]="Space",r[r.Other=2]="Other",r}(CharCategory||(CharCategory={}));const nonASCIISingleCaseWordChar=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let wordChar;try{wordChar=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function hasWordChar(r){if(wordChar)return wordChar.test(r);for(let e=0;e"€"&&(n.toUpperCase()!=n.toLowerCase()||nonASCIISingleCaseWordChar.test(n)))return!0}return!1}function makeCategorizer(r){return e=>{if(!/\S/.test(e))return CharCategory.Space;if(hasWordChar(e))return CharCategory.Word;for(let n=0;n-1)return CharCategory.Word;return CharCategory.Other}}class EditorState{constructor(e,n,s,o,l,a){this.config=e,this.doc=n,this.selection=s,this.values=o,this.status=e.statusTemplate.slice(),this.computeSlot=l,a&&(a._state=this);for(let c=0;co.set(f,h)),n=null),o.set(c.value.compartment,c.value.extension)):c.is(StateEffect.reconfigure)?(n=null,s=c.value):c.is(StateEffect.appendConfig)&&(n=null,s=asArray$1(s).concat(c.value));let l;n?l=e.startState.values.slice():(n=Configuration.resolve(s,o,this),l=new EditorState(n,this.doc,this.selection,n.dynamicSlots.map(()=>null),(h,f)=>f.reconfigure(h,this),null).values);let a=e.startState.facet(allowMultipleSelections)?e.newSelection:e.newSelection.asSingle();new EditorState(n,e.newDoc,a,l,(c,h)=>h.update(c,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(n=>({changes:{from:n.from,to:n.to,insert:e},range:EditorSelection.cursor(n.from+e.length)}))}changeByRange(e){let n=this.selection,s=e(n.ranges[0]),o=this.changes(s.changes),l=[s.range],a=asArray$1(s.effects);for(let c=1;ca.spec.fromJSON(c,h)))}}return EditorState.create({doc:e.doc,selection:EditorSelection.fromJSON(e.selection),extensions:n.extensions?o.concat([n.extensions]):o})}static create(e={}){let n=Configuration.resolve(e.extensions||[],new Map),s=e.doc instanceof Text?e.doc:Text.of((e.doc||"").split(n.staticFacet(EditorState.lineSeparator)||DefaultSplit)),o=e.selection?e.selection instanceof EditorSelection?e.selection:EditorSelection.single(e.selection.anchor,e.selection.head):EditorSelection.single(0);return checkSelection(o,s.length),n.staticFacet(allowMultipleSelections)||(o=o.asSingle()),new EditorState(n,s,o,n.dynamicSlots.map(()=>null),(l,a)=>a.create(l),null)}get tabSize(){return this.facet(EditorState.tabSize)}get lineBreak(){return this.facet(EditorState.lineSeparator)||` -`}get readOnly(){return this.facet(readOnly)}phrase(e,...n){for(let s of this.facet(EditorState.phrases))if(Object.prototype.hasOwnProperty.call(s,e)){e=s[e];break}return n.length&&(e=e.replace(/\$(\$|\d*)/g,(s,o)=>{if(o=="$")return"$";let l=+(o||1);return!l||l>n.length?s:n[l-1]})),e}languageDataAt(e,n,s=-1){let o=[];for(let l of this.facet(languageData))for(let a of l(this,n,s))Object.prototype.hasOwnProperty.call(a,e)&&o.push(a[e]);return o}charCategorizer(e){return makeCategorizer(this.languageDataAt("wordChars",e).join(""))}wordAt(e){let{text:n,from:s,length:o}=this.doc.lineAt(e),l=this.charCategorizer(e),a=e-s,c=e-s;for(;a>0;){let h=findClusterBreak(n,a,!1);if(l(n.slice(h,a))!=CharCategory.Word)break;a=h}for(;cr.length?r[0]:4});EditorState.lineSeparator=lineSeparator;EditorState.readOnly=readOnly;EditorState.phrases=Facet.define({compare(r,e){let n=Object.keys(r),s=Object.keys(e);return n.length==s.length&&n.every(o=>r[o]==e[o])}});EditorState.languageData=languageData;EditorState.changeFilter=changeFilter;EditorState.transactionFilter=transactionFilter;EditorState.transactionExtender=transactionExtender;Compartment.reconfigure=StateEffect.define();function combineConfig(r,e,n={}){let s={};for(let o of r)for(let l of Object.keys(o)){let a=o[l],c=s[l];if(c===void 0)s[l]=a;else if(!(c===a||a===void 0))if(Object.hasOwnProperty.call(n,l))s[l]=n[l](c,a);else throw new Error("Config merge conflict for field "+l)}for(let o in e)s[o]===void 0&&(s[o]=e[o]);return s}class RangeValue{eq(e){return this==e}range(e,n=e){return Range$1.create(e,n,this)}}RangeValue.prototype.startSide=RangeValue.prototype.endSide=0;RangeValue.prototype.point=!1;RangeValue.prototype.mapMode=MapMode.TrackDel;let Range$1=class Ce{constructor(e,n,s){this.from=e,this.to=n,this.value=s}static create(e,n,s){return new Ce(e,n,s)}};function cmpRange(r,e){return r.from-e.from||r.value.startSide-e.value.startSide}class Chunk{constructor(e,n,s,o){this.from=e,this.to=n,this.value=s,this.maxPoint=o}get length(){return this.to[this.to.length-1]}findIndex(e,n,s,o=0){let l=s?this.to:this.from;for(let a=o,c=l.length;;){if(a==c)return a;let h=a+c>>1,f=l[h]-e||(s?this.value[h].endSide:this.value[h].startSide)-n;if(h==a)return f>=0?a:c;f>=0?c=h:a=h+1}}between(e,n,s,o){for(let l=this.findIndex(n,-1e9,!0),a=this.findIndex(s,1e9,!1,l);lO||g==O&&f.startSide>0&&f.endSide<=0)continue;(O-g||f.endSide-f.startSide)<0||(a<0&&(a=g),f.point&&(c=Math.max(c,O-g)),s.push(f),o.push(g-a),l.push(O-a))}return{mapped:s.length?new Chunk(o,l,s,c):null,pos:a}}}class RangeSet{constructor(e,n,s,o){this.chunkPos=e,this.chunk=n,this.nextLayer=s,this.maxPoint=o}static create(e,n,s,o){return new RangeSet(e,n,s,o)}get length(){let e=this.chunk.length-1;return e<0?0:Math.max(this.chunkEnd(e),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let e=this.nextLayer.size;for(let n of this.chunk)e+=n.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:n=[],sort:s=!1,filterFrom:o=0,filterTo:l=this.length}=e,a=e.filter;if(n.length==0&&!a)return this;if(s&&(n=n.slice().sort(cmpRange)),this.isEmpty)return n.length?RangeSet.of(n):this;let c=new LayerCursor(this,null,-1).goto(0),h=0,f=[],u=new RangeSetBuilder;for(;c.value||h=0){let d=n[h++];u.addInner(d.from,d.to,d.value)||f.push(d)}else c.rangeIndex==1&&c.chunkIndexthis.chunkEnd(c.chunkIndex)||lc.to||l=l&&e<=l+a.length&&a.between(l,e-l,n-l,s)===!1)return}this.nextLayer.between(e,n,s)}}iter(e=0){return HeapCursor.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,n=0){return HeapCursor.from(e).goto(n)}static compare(e,n,s,o,l=-1){let a=e.filter(d=>d.maxPoint>0||!d.isEmpty&&d.maxPoint>=l),c=n.filter(d=>d.maxPoint>0||!d.isEmpty&&d.maxPoint>=l),h=findSharedChunks(a,c,s),f=new SpanCursor(a,h,l),u=new SpanCursor(c,h,l);s.iterGaps((d,g,O)=>compare(f,d,u,g,O,o)),s.empty&&s.length==0&&compare(f,0,u,0,0,o)}static eq(e,n,s=0,o){o==null&&(o=999999999);let l=e.filter(u=>!u.isEmpty&&n.indexOf(u)<0),a=n.filter(u=>!u.isEmpty&&e.indexOf(u)<0);if(l.length!=a.length)return!1;if(!l.length)return!0;let c=findSharedChunks(l,a),h=new SpanCursor(l,c,0).goto(s),f=new SpanCursor(a,c,0).goto(s);for(;;){if(h.to!=f.to||!sameValues(h.active,f.active)||h.point&&(!f.point||!h.point.eq(f.point)))return!1;if(h.to>o)return!0;h.next(),f.next()}}static spans(e,n,s,o,l=-1){let a=new SpanCursor(e,null,l).goto(n),c=n,h=a.openStart;for(;;){let f=Math.min(a.to,s);if(a.point){let u=a.activeForPoint(a.to),d=a.pointFromc&&(o.span(c,f,a.active,h),h=a.openEnd(f));if(a.to>s)return h+(a.point&&a.to>s?1:0);c=a.to,a.next()}}static of(e,n=!1){let s=new RangeSetBuilder;for(let o of e instanceof Range$1?[e]:n?lazySort(e):e)s.add(o.from,o.to,o.value);return s.finish()}static join(e){if(!e.length)return RangeSet.empty;let n=e[e.length-1];for(let s=e.length-2;s>=0;s--)for(let o=e[s];o!=RangeSet.empty;o=o.nextLayer)n=new RangeSet(o.chunkPos,o.chunk,n,Math.max(o.maxPoint,n.maxPoint));return n}}RangeSet.empty=new RangeSet([],[],null,-1);function lazySort(r){if(r.length>1)for(let e=r[0],n=1;n0)return r.slice().sort(cmpRange);e=s}return r}RangeSet.empty.nextLayer=RangeSet.empty;class RangeSetBuilder{finishChunk(e){this.chunks.push(new Chunk(this.from,this.to,this.value,this.maxPoint)),this.chunkPos.push(this.chunkStart),this.chunkStart=-1,this.setMaxPoint=Math.max(this.setMaxPoint,this.maxPoint),this.maxPoint=-1,e&&(this.from=[],this.to=[],this.value=[])}constructor(){this.chunks=[],this.chunkPos=[],this.chunkStart=-1,this.last=null,this.lastFrom=-1e9,this.lastTo=-1e9,this.from=[],this.to=[],this.value=[],this.maxPoint=-1,this.setMaxPoint=-1,this.nextLayer=null}add(e,n,s){this.addInner(e,n,s)||(this.nextLayer||(this.nextLayer=new RangeSetBuilder)).add(e,n,s)}addInner(e,n,s){let o=e-this.lastTo||s.startSide-this.last.endSide;if(o<=0&&(e-this.lastFrom||s.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return o<0?!1:(this.from.length==250&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(n-this.chunkStart),this.last=s,this.lastFrom=e,this.lastTo=n,this.value.push(s),s.point&&(this.maxPoint=Math.max(this.maxPoint,n-e)),!0)}addChunk(e,n){if((e-this.lastTo||n.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,n.maxPoint),this.chunks.push(n),this.chunkPos.push(e);let s=n.value.length-1;return this.last=n.value[s],this.lastFrom=n.from[s]+e,this.lastTo=n.to[s]+e,!0}finish(){return this.finishInner(RangeSet.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let n=RangeSet.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,n}}function findSharedChunks(r,e,n){let s=new Map;for(let l of r)for(let a=0;a=this.minPoint)break}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex=s&&o.push(new LayerCursor(a,n,s,l));return o.length==1?o[0]:new HeapCursor(o)}get startSide(){return this.value?this.value.startSide:0}goto(e,n=-1e9){for(let s of this.heap)s.goto(e,n);for(let s=this.heap.length>>1;s>=0;s--)heapBubble(this.heap,s);return this.next(),this}forward(e,n){for(let s of this.heap)s.forward(e,n);for(let s=this.heap.length>>1;s>=0;s--)heapBubble(this.heap,s);(this.to-e||this.value.endSide-n)<0&&this.next()}next(){if(this.heap.length==0)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let e=this.heap[0];this.from=e.from,this.to=e.to,this.value=e.value,this.rank=e.rank,e.value&&e.next(),heapBubble(this.heap,0)}}}function heapBubble(r,e){for(let n=r[e];;){let s=(e<<1)+1;if(s>=r.length)break;let o=r[s];if(s+1=0&&(o=r[s+1],s++),n.compare(o)<0)break;r[s]=n,r[e]=o,e=s}}class SpanCursor{constructor(e,n,s){this.minPoint=s,this.active=[],this.activeTo=[],this.activeRank=[],this.minActive=-1,this.point=null,this.pointFrom=0,this.pointRank=0,this.to=-1e9,this.endSide=0,this.openStart=-1,this.cursor=HeapCursor.from(e,n,s)}goto(e,n=-1e9){return this.cursor.goto(e,n),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=n,this.openStart=-1,this.next(),this}forward(e,n){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-n)<0;)this.removeActive(this.minActive);this.cursor.forward(e,n)}removeActive(e){remove(this.active,e),remove(this.activeTo,e),remove(this.activeRank,e),this.minActive=findMinIndex(this.active,this.activeTo)}addActive(e){let n=0,{value:s,to:o,rank:l}=this.cursor;for(;n0;)n++;insert(this.active,n,s),insert(this.activeTo,n,o),insert(this.activeRank,n,l),e&&insert(e,n,this.cursor.from),this.minActive=findMinIndex(this.active,this.activeTo)}next(){let e=this.to,n=this.point;this.point=null;let s=this.openStart<0?[]:null;for(;;){let o=this.minActive;if(o>-1&&(this.activeTo[o]-this.cursor.from||this.active[o].endSide-this.cursor.startSide)<0){if(this.activeTo[o]>e){this.to=this.activeTo[o],this.endSide=this.active[o].endSide;break}this.removeActive(o),s&&remove(s,o)}else if(this.cursor.value)if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let l=this.cursor.value;if(!l.point)this.addActive(s),this.cursor.next();else if(n&&this.cursor.to==this.to&&this.cursor.from=0&&s[o]=0&&!(this.activeRank[s]e||this.activeTo[s]==e&&this.active[s].endSide>=this.point.endSide)&&n.push(this.active[s]);return n.reverse()}openEnd(e){let n=0;for(let s=this.activeTo.length-1;s>=0&&this.activeTo[s]>e;s--)n++;return n}}function compare(r,e,n,s,o,l){r.goto(e),n.goto(s);let a=s+o,c=s,h=s-e;for(;;){let f=r.to+h-n.to||r.endSide-n.endSide,u=f<0?r.to+h:n.to,d=Math.min(u,a);if(r.point||n.point?r.point&&n.point&&(r.point==n.point||r.point.eq(n.point))&&sameValues(r.activeForPoint(r.to),n.activeForPoint(n.to))||l.comparePoint(c,d,r.point,n.point):d>c&&!sameValues(r.active,n.active)&&l.compareRange(c,d,r.active,n.active),u>a)break;c=u,f<=0&&r.next(),f>=0&&n.next()}}function sameValues(r,e){if(r.length!=e.length)return!1;for(let n=0;n=e;s--)r[s+1]=r[s];r[e]=n}function findMinIndex(r,e){let n=-1,s=1e9;for(let o=0;o=e)return o;if(o==r.length)break;l+=r.charCodeAt(o)==9?n-l%n:1,o=findClusterBreak(r,o)}return s===!0?-1:r.length}const C="ͼ",COUNT=typeof Symbol>"u"?"__"+C:Symbol.for(C),SET=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),top=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};class StyleModule{constructor(e,n){this.rules=[];let{finish:s}=n||{};function o(a){return/^@/.test(a)?[a]:a.split(/,\s*/)}function l(a,c,h,f){let u=[],d=/^@(\w+)\b/.exec(a[0]),g=d&&d[1]=="keyframes";if(d&&c==null)return h.push(a[0]+";");for(let O in c){let m=c[O];if(/&/.test(O))l(O.split(/,\s*/).map(y=>a.map(b=>y.replace(/&/,b))).reduce((y,b)=>y.concat(b)),m,h);else if(m&&typeof m=="object"){if(!d)throw new RangeError("The value of a property ("+O+") should be a primitive value.");l(o(O),m,u,g)}else m!=null&&u.push(O.replace(/_.*/,"").replace(/[A-Z]/g,y=>"-"+y.toLowerCase())+": "+m+";")}(u.length||g)&&h.push((s&&!d&&!f?a.map(s):a).join(", ")+" {"+u.join(" ")+"}")}for(let a in e)l(o(a),e[a],this.rules)}getRules(){return this.rules.join(` +`){[e,n]=clip(this,e,n);let o="";for(let l=0,a=0;le&&l&&(o+=s),ea&&(o+=c.sliceString(e-a,n-a,s)),a=h+1}return o}flatten(e){for(let n of this.children)n.flatten(e)}scanIdentical(e,n){if(!(e instanceof TextNode))return 0;let s=0,[o,l,a,c]=n>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;o+=n,l+=n){if(o==a||l==c)return s;let h=this.children[o],f=e.children[l];if(h!=f)return s+h.scanIdentical(f,n);s+=h.length+1}}static from(e,n=e.reduce((s,o)=>s+o.length+1,-1)){let s=0;for(let O of e)s+=O.lines;if(s<32){let O=[];for(let m of e)m.flatten(O);return new TextLeaf(O,n)}let o=Math.max(32,s>>5),l=o<<1,a=o>>1,c=[],h=0,f=-1,u=[];function d(O){let m;if(O.lines>l&&O instanceof TextNode)for(let S of O.children)d(S);else O.lines>a&&(h>a||!h)?(g(),c.push(O)):O instanceof TextLeaf&&h&&(m=u[u.length-1])instanceof TextLeaf&&O.lines+m.lines<=32?(h+=O.lines,f+=O.length+1,u[u.length-1]=new TextLeaf(m.text.concat(O.text),m.length+1+O.length)):(h+O.lines>o&&g(),h+=O.lines,f+=O.length+1,u.push(O))}function g(){h!=0&&(c.push(u.length==1?u[0]:TextNode.from(u,f)),f=-1,h=u.length=0)}for(let O of e)d(O);return g(),c.length==1?c[0]:new TextNode(c,n)}}Text.empty=new TextLeaf([""],0);function textLength(r){let e=-1;for(let n of r)e+=n.length+1;return e}function appendText(r,e,n=0,s=1e9){for(let o=0,l=0,a=!0;l=n&&(h>s&&(c=c.slice(0,s-o)),o0?1:(e instanceof TextLeaf?e.text.length:e.children.length)<<1]}nextInner(e,n){for(this.done=this.lineBreak=!1;;){let s=this.nodes.length-1,o=this.nodes[s],l=this.offsets[s],a=l>>1,c=o instanceof TextLeaf?o.text.length:o.children.length;if(a==(n>0?c:0)){if(s==0)return this.done=!0,this.value="",this;n>0&&this.offsets[s-1]++,this.nodes.pop(),this.offsets.pop()}else if((l&1)==(n>0?0:1)){if(this.offsets[s]+=n,e==0)return this.lineBreak=!0,this.value=` +`,this;e--}else if(o instanceof TextLeaf){let h=o.text[a+(n<0?-1:0)];if(this.offsets[s]+=n,h.length>Math.max(0,e))return this.value=e==0?h:n>0?h.slice(e):h.slice(0,h.length-e),this;e-=h.length}else{let h=o.children[a+(n<0?-1:0)];e>h.length?(e-=h.length,this.offsets[s]+=n):(n<0&&this.offsets[s]--,this.nodes.push(h),this.offsets.push(n>0?1:(h instanceof TextLeaf?h.text.length:h.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class PartialTextCursor{constructor(e,n,s){this.value="",this.done=!1,this.cursor=new RawTextCursor(e,n>s?-1:1),this.pos=n>s?e.length:0,this.from=Math.min(n,s),this.to=Math.max(n,s)}nextInner(e,n){if(n<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,n<0?this.pos-this.to:this.from-this.pos);let s=n<0?this.pos-this.from:this.to-this.pos;e>s&&(e=s),s-=e;let{value:o}=this.cursor.next(e);return this.pos+=(o.length+e)*n,this.value=o.length<=s?o:n<0?o.slice(o.length-s):o.slice(0,s),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=""}}class LineCursor{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:n,lineBreak:s,value:o}=this.inner.next(e);return n&&this.afterBreak?(this.value="",this.afterBreak=!1):n?(this.done=!0,this.value=""):s?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=o,this.afterBreak=!1),this}get lineBreak(){return!1}}typeof Symbol<"u"&&(Text.prototype[Symbol.iterator]=function(){return this.iter()},RawTextCursor.prototype[Symbol.iterator]=PartialTextCursor.prototype[Symbol.iterator]=LineCursor.prototype[Symbol.iterator]=function(){return this});class Line{constructor(e,n,s,o){this.from=e,this.to=n,this.number=s,this.text=o}get length(){return this.to-this.from}}function clip(r,e,n){return e=Math.max(0,Math.min(r.length,e)),[e,Math.max(e,Math.min(r.length,n))]}let extend="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(r=>r?parseInt(r,36):1);for(let r=1;rr)return extend[e-1]<=r;return!1}function isRegionalIndicator(r){return r>=127462&&r<=127487}const ZWJ=8205;function findClusterBreak(r,e,n=!0,s=!0){return(n?nextClusterBreak:prevClusterBreak)(r,e,s)}function nextClusterBreak(r,e,n){if(e==r.length)return e;e&&surrogateLow(r.charCodeAt(e))&&surrogateHigh(r.charCodeAt(e-1))&&e--;let s=codePointAt(r,e);for(e+=codePointSize(s);e=0&&isRegionalIndicator(codePointAt(r,a));)l++,a-=2;if(l%2==0)break;e+=2}else break}return e}function prevClusterBreak(r,e,n){for(;e>0;){let s=nextClusterBreak(r,e-2,n);if(s=56320&&r<57344}function surrogateHigh(r){return r>=55296&&r<56320}function codePointAt(r,e){let n=r.charCodeAt(e);if(!surrogateHigh(n)||e+1==r.length)return n;let s=r.charCodeAt(e+1);return surrogateLow(s)?(n-55296<<10)+(s-56320)+65536:n}function fromCodePoint(r){return r<=65535?String.fromCharCode(r):(r-=65536,String.fromCharCode((r>>10)+55296,(r&1023)+56320))}function codePointSize(r){return r<65536?1:2}const DefaultSplit=/\r\n?|\n/;var MapMode=function(r){return r[r.Simple=0]="Simple",r[r.TrackDel=1]="TrackDel",r[r.TrackBefore=2]="TrackBefore",r[r.TrackAfter=3]="TrackAfter",r}(MapMode||(MapMode={}));class ChangeDesc{constructor(e){this.sections=e}get length(){let e=0;for(let n=0;ne)return l+(e-o);l+=c}else{if(s!=MapMode.Simple&&f>=e&&(s==MapMode.TrackDel&&oe||s==MapMode.TrackBefore&&oe))return null;if(f>e||f==e&&n<0&&!c)return e==o||n<0?l:l+h;l+=h}o=f}if(e>o)throw new RangeError(`Position ${e} is out of range for changeset of length ${o}`);return l}touchesRange(e,n=e){for(let s=0,o=0;s=0&&o<=n&&c>=e)return on?"cover":!0;o=c}return!1}toString(){let e="";for(let n=0;n=0?":"+o:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(n=>typeof n!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new ChangeDesc(e)}static create(e){return new ChangeDesc(e)}}class ChangeSet extends ChangeDesc{constructor(e,n){super(e),this.inserted=n}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return iterChanges(this,(n,s,o,l,a)=>e=e.replace(o,o+(s-n),a),!1),e}mapDesc(e,n=!1){return mapSet(this,e,n,!0)}invert(e){let n=this.sections.slice(),s=[];for(let o=0,l=0;o=0){n[o]=c,n[o+1]=a;let h=o>>1;for(;s.length0&&addInsert(s,n,l.text),l.forward(u),c+=u}let f=e[a++];for(;c>1].toJSON()))}return e}static of(e,n,s){let o=[],l=[],a=0,c=null;function h(u=!1){if(!u&&!o.length)return;ag||d<0||g>n)throw new RangeError(`Invalid change range ${d} to ${g} (in doc of length ${n})`);let m=O?typeof O=="string"?Text.of(O.split(s||DefaultSplit)):O:Text.empty,S=m.length;if(d==g&&S==0)return;da&&addSection(o,d-a,-1),addSection(o,g-d,S),addInsert(l,o,m),a=g}}return f(e),h(!c),c}static empty(e){return new ChangeSet(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let n=[],s=[];for(let o=0;oc&&typeof a!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(l.length==1)n.push(l[0],0);else{for(;s.length=0&&n<=0&&n==r[o+1]?r[o]+=e:e==0&&r[o]==0?r[o+1]+=n:s?(r[o]+=e,r[o+1]+=n):r.push(e,n)}function addInsert(r,e,n){if(n.length==0)return;let s=e.length-2>>1;if(s>1])),!(n||a==r.sections.length||r.sections[a+1]<0);)c=r.sections[a++],h=r.sections[a++];e(o,f,l,u,d),o=f,l=u}}}function mapSet(r,e,n,s=!1){let o=[],l=s?[]:null,a=new SectionIter(r),c=new SectionIter(e);for(let h=-1;;)if(a.ins==-1&&c.ins==-1){let f=Math.min(a.len,c.len);addSection(o,f,-1),a.forward(f),c.forward(f)}else if(c.ins>=0&&(a.ins<0||h==a.i||a.off==0&&(c.len=0&&h=0){let f=0,u=a.len;for(;u;)if(c.ins==-1){let d=Math.min(u,c.len);f+=d,u-=d,c.forward(d)}else if(c.ins==0&&c.lenh||a.ins>=0&&a.len>h)&&(c||s.length>f),l.forward2(h),a.forward(h)}}}}class SectionIter{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i>1;return n>=e.length?Text.empty:e[n]}textBit(e){let{inserted:n}=this.set,s=this.i-2>>1;return s>=n.length&&!e?Text.empty:n[s].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}}class SelectionRange{constructor(e,n,s){this.from=e,this.to=n,this.flags=s}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}get goalColumn(){let e=this.flags>>6;return e==16777215?void 0:e}map(e,n=-1){let s,o;return this.empty?s=o=e.mapPos(this.from,n):(s=e.mapPos(this.from,1),o=e.mapPos(this.to,-1)),s==this.from&&o==this.to?this:new SelectionRange(s,o,this.flags)}extend(e,n=e){if(e<=this.anchor&&n>=this.anchor)return EditorSelection.range(e,n);let s=Math.abs(e-this.anchor)>Math.abs(n-this.anchor)?e:n;return EditorSelection.range(this.anchor,s)}eq(e,n=!1){return this.anchor==e.anchor&&this.head==e.head&&(!n||!this.empty||this.assoc==e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return EditorSelection.range(e.anchor,e.head)}static create(e,n,s){return new SelectionRange(e,n,s)}}class EditorSelection{constructor(e,n){this.ranges=e,this.mainIndex=n}map(e,n=-1){return e.empty?this:EditorSelection.create(this.ranges.map(s=>s.map(e,n)),this.mainIndex)}eq(e,n=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let s=0;se.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new EditorSelection(e.ranges.map(n=>SelectionRange.fromJSON(n)),e.main)}static single(e,n=e){return new EditorSelection([EditorSelection.range(e,n)],0)}static create(e,n=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let s=0,o=0;oe?8:0)|l)}static normalized(e,n=0){let s=e[n];e.sort((o,l)=>o.from-l.from),n=e.indexOf(s);for(let o=1;ol.head?EditorSelection.range(h,c):EditorSelection.range(c,h))}}return new EditorSelection(e,n)}}function checkSelection(r,e){for(let n of r.ranges)if(n.to>e)throw new RangeError("Selection points outside of document")}let nextID=0;class Facet{constructor(e,n,s,o,l){this.combine=e,this.compareInput=n,this.compare=s,this.isStatic=o,this.id=nextID++,this.default=e([]),this.extensions=typeof l=="function"?l(this):l}get reader(){return this}static define(e={}){return new Facet(e.combine||(n=>n),e.compareInput||((n,s)=>n===s),e.compare||(e.combine?(n,s)=>n===s:sameArray$1),!!e.static,e.enables)}of(e){return new FacetProvider([],this,0,e)}compute(e,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new FacetProvider(e,this,1,n)}computeN(e,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new FacetProvider(e,this,2,n)}from(e,n){return n||(n=s=>s),this.compute([e],s=>n(s.field(e)))}}function sameArray$1(r,e){return r==e||r.length==e.length&&r.every((n,s)=>n===e[s])}class FacetProvider{constructor(e,n,s,o){this.dependencies=e,this.facet=n,this.type=s,this.value=o,this.id=nextID++}dynamicSlot(e){var n;let s=this.value,o=this.facet.compareInput,l=this.id,a=e[l]>>1,c=this.type==2,h=!1,f=!1,u=[];for(let d of this.dependencies)d=="doc"?h=!0:d=="selection"?f=!0:((n=e[d.id])!==null&&n!==void 0?n:1)&1||u.push(e[d.id]);return{create(d){return d.values[a]=s(d),1},update(d,g){if(h&&g.docChanged||f&&(g.docChanged||g.selection)||ensureAll(d,u)){let O=s(d);if(c?!compareArray(O,d.values[a],o):!o(O,d.values[a]))return d.values[a]=O,1}return 0},reconfigure:(d,g)=>{let O,m=g.config.address[l];if(m!=null){let S=getAddr(g,m);if(this.dependencies.every(b=>b instanceof Facet?g.facet(b)===d.facet(b):b instanceof StateField?g.field(b,!1)==d.field(b,!1):!0)||(c?compareArray(O=s(d),S,o):o(O=s(d),S)))return d.values[a]=S,0}else O=s(d);return d.values[a]=O,1}}}}function compareArray(r,e,n){if(r.length!=e.length)return!1;for(let s=0;sr[h.id]),o=n.map(h=>h.type),l=s.filter(h=>!(h&1)),a=r[e.id]>>1;function c(h){let f=[];for(let u=0;us===o),e);return e.provide&&(n.provides=e.provide(n)),n}create(e){let n=e.facet(initField).find(s=>s.field==this);return((n==null?void 0:n.create)||this.createF)(e)}slot(e){let n=e[this.id]>>1;return{create:s=>(s.values[n]=this.create(s),1),update:(s,o)=>{let l=s.values[n],a=this.updateF(l,o);return this.compareF(l,a)?0:(s.values[n]=a,1)},reconfigure:(s,o)=>o.config.address[this.id]!=null?(s.values[n]=o.field(this),0):(s.values[n]=this.create(s),1)}}init(e){return[this,initField.of({field:this,create:e})]}get extension(){return this}}const Prec_={lowest:4,low:3,default:2,high:1,highest:0};function prec(r){return e=>new PrecExtension(e,r)}const Prec={highest:prec(Prec_.highest),high:prec(Prec_.high),default:prec(Prec_.default),low:prec(Prec_.low),lowest:prec(Prec_.lowest)};class PrecExtension{constructor(e,n){this.inner=e,this.prec=n}}class Compartment{of(e){return new CompartmentInstance(this,e)}reconfigure(e){return Compartment.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class CompartmentInstance{constructor(e,n){this.compartment=e,this.inner=n}}class Configuration{constructor(e,n,s,o,l,a){for(this.base=e,this.compartments=n,this.dynamicSlots=s,this.address=o,this.staticValues=l,this.facets=a,this.statusTemplate=[];this.statusTemplate.length>1]}static resolve(e,n,s){let o=[],l=Object.create(null),a=new Map;for(let g of flatten(e,n,a))g instanceof StateField?o.push(g):(l[g.facet.id]||(l[g.facet.id]=[])).push(g);let c=Object.create(null),h=[],f=[];for(let g of o)c[g.id]=f.length<<1,f.push(O=>g.slot(O));let u=s==null?void 0:s.config.facets;for(let g in l){let O=l[g],m=O[0].facet,S=u&&u[g]||[];if(O.every(b=>b.type==0))if(c[m.id]=h.length<<1|1,sameArray$1(S,O))h.push(s.facet(m));else{let b=m.combine(O.map(w=>w.value));h.push(s&&m.compare(b,s.facet(m))?s.facet(m):b)}else{for(let b of O)b.type==0?(c[b.id]=h.length<<1|1,h.push(b.value)):(c[b.id]=f.length<<1,f.push(w=>b.dynamicSlot(w)));c[m.id]=f.length<<1,f.push(b=>dynamicFacetSlot(b,m,O))}}let d=f.map(g=>g(c));return new Configuration(e,a,d,c,h,l)}}function flatten(r,e,n){let s=[[],[],[],[],[]],o=new Map;function l(a,c){let h=o.get(a);if(h!=null){if(h<=c)return;let f=s[h].indexOf(a);f>-1&&s[h].splice(f,1),a instanceof CompartmentInstance&&n.delete(a.compartment)}if(o.set(a,c),Array.isArray(a))for(let f of a)l(f,c);else if(a instanceof CompartmentInstance){if(n.has(a.compartment))throw new RangeError("Duplicate use of compartment in extensions");let f=e.get(a.compartment)||a.inner;n.set(a.compartment,f),l(f,c)}else if(a instanceof PrecExtension)l(a.inner,a.prec);else if(a instanceof StateField)s[c].push(a),a.provides&&l(a.provides,c);else if(a instanceof FacetProvider)s[c].push(a),a.facet.extensions&&l(a.facet.extensions,Prec_.default);else{let f=a.extension;if(!f)throw new Error(`Unrecognized extension value in extension set (${a}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);l(f,c)}}return l(r,Prec_.default),s.reduce((a,c)=>a.concat(c))}function ensureAddr(r,e){if(e&1)return 2;let n=e>>1,s=r.status[n];if(s==4)throw new Error("Cyclic dependency between fields and/or facets");if(s&2)return s;r.status[n]=4;let o=r.computeSlot(r,r.config.dynamicSlots[n]);return r.status[n]=2|o}function getAddr(r,e){return e&1?r.config.staticValues[e>>1]:r.values[e>>1]}const languageData=Facet.define(),allowMultipleSelections=Facet.define({combine:r=>r.some(e=>e),static:!0}),lineSeparator=Facet.define({combine:r=>r.length?r[0]:void 0,static:!0}),changeFilter=Facet.define(),transactionFilter=Facet.define(),transactionExtender=Facet.define(),readOnly=Facet.define({combine:r=>r.length?r[0]:!1});class Annotation{constructor(e,n){this.type=e,this.value=n}static define(){return new AnnotationType}}class AnnotationType{of(e){return new Annotation(this,e)}}class StateEffectType{constructor(e){this.map=e}of(e){return new StateEffect(this,e)}}class StateEffect{constructor(e,n){this.type=e,this.value=n}map(e){let n=this.type.map(this.value,e);return n===void 0?void 0:n==this.value?this:new StateEffect(this.type,n)}is(e){return this.type==e}static define(e={}){return new StateEffectType(e.map||(n=>n))}static mapEffects(e,n){if(!e.length)return e;let s=[];for(let o of e){let l=o.map(n);l&&s.push(l)}return s}}StateEffect.reconfigure=StateEffect.define();StateEffect.appendConfig=StateEffect.define();class Transaction{constructor(e,n,s,o,l,a){this.startState=e,this.changes=n,this.selection=s,this.effects=o,this.annotations=l,this.scrollIntoView=a,this._doc=null,this._state=null,s&&checkSelection(s,n.newLength),l.some(c=>c.type==Transaction.time)||(this.annotations=l.concat(Transaction.time.of(Date.now())))}static create(e,n,s,o,l,a){return new Transaction(e,n,s,o,l,a)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let n of this.annotations)if(n.type==e)return n.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let n=this.annotation(Transaction.userEvent);return!!(n&&(n==e||n.length>e.length&&n.slice(0,e.length)==e&&n[e.length]=="."))}}Transaction.time=Annotation.define();Transaction.userEvent=Annotation.define();Transaction.addToHistory=Annotation.define();Transaction.remote=Annotation.define();function joinRanges(r,e){let n=[];for(let s=0,o=0;;){let l,a;if(s=r[s]))l=r[s++],a=r[s++];else if(o=0;o--){let l=s[o](r);l instanceof Transaction?r=l:Array.isArray(l)&&l.length==1&&l[0]instanceof Transaction?r=l[0]:r=resolveTransaction(e,asArray$1(l),!1)}return r}function extendTransaction(r){let e=r.startState,n=e.facet(transactionExtender),s=r;for(let o=n.length-1;o>=0;o--){let l=n[o](r);l&&Object.keys(l).length&&(s=mergeTransaction(s,resolveTransactionInner(e,l,r.changes.newLength),!0))}return s==r?r:Transaction.create(e,r.changes,r.selection,s.effects,s.annotations,s.scrollIntoView)}const none$2=[];function asArray$1(r){return r==null?none$2:Array.isArray(r)?r:[r]}var CharCategory=function(r){return r[r.Word=0]="Word",r[r.Space=1]="Space",r[r.Other=2]="Other",r}(CharCategory||(CharCategory={}));const nonASCIISingleCaseWordChar=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let wordChar;try{wordChar=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function hasWordChar(r){if(wordChar)return wordChar.test(r);for(let e=0;e"€"&&(n.toUpperCase()!=n.toLowerCase()||nonASCIISingleCaseWordChar.test(n)))return!0}return!1}function makeCategorizer(r){return e=>{if(!/\S/.test(e))return CharCategory.Space;if(hasWordChar(e))return CharCategory.Word;for(let n=0;n-1)return CharCategory.Word;return CharCategory.Other}}class EditorState{constructor(e,n,s,o,l,a){this.config=e,this.doc=n,this.selection=s,this.values=o,this.status=e.statusTemplate.slice(),this.computeSlot=l,a&&(a._state=this);for(let c=0;co.set(f,h)),n=null),o.set(c.value.compartment,c.value.extension)):c.is(StateEffect.reconfigure)?(n=null,s=c.value):c.is(StateEffect.appendConfig)&&(n=null,s=asArray$1(s).concat(c.value));let l;n?l=e.startState.values.slice():(n=Configuration.resolve(s,o,this),l=new EditorState(n,this.doc,this.selection,n.dynamicSlots.map(()=>null),(h,f)=>f.reconfigure(h,this),null).values);let a=e.startState.facet(allowMultipleSelections)?e.newSelection:e.newSelection.asSingle();new EditorState(n,e.newDoc,a,l,(c,h)=>h.update(c,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(n=>({changes:{from:n.from,to:n.to,insert:e},range:EditorSelection.cursor(n.from+e.length)}))}changeByRange(e){let n=this.selection,s=e(n.ranges[0]),o=this.changes(s.changes),l=[s.range],a=asArray$1(s.effects);for(let c=1;ca.spec.fromJSON(c,h)))}}return EditorState.create({doc:e.doc,selection:EditorSelection.fromJSON(e.selection),extensions:n.extensions?o.concat([n.extensions]):o})}static create(e={}){let n=Configuration.resolve(e.extensions||[],new Map),s=e.doc instanceof Text?e.doc:Text.of((e.doc||"").split(n.staticFacet(EditorState.lineSeparator)||DefaultSplit)),o=e.selection?e.selection instanceof EditorSelection?e.selection:EditorSelection.single(e.selection.anchor,e.selection.head):EditorSelection.single(0);return checkSelection(o,s.length),n.staticFacet(allowMultipleSelections)||(o=o.asSingle()),new EditorState(n,s,o,n.dynamicSlots.map(()=>null),(l,a)=>a.create(l),null)}get tabSize(){return this.facet(EditorState.tabSize)}get lineBreak(){return this.facet(EditorState.lineSeparator)||` +`}get readOnly(){return this.facet(readOnly)}phrase(e,...n){for(let s of this.facet(EditorState.phrases))if(Object.prototype.hasOwnProperty.call(s,e)){e=s[e];break}return n.length&&(e=e.replace(/\$(\$|\d*)/g,(s,o)=>{if(o=="$")return"$";let l=+(o||1);return!l||l>n.length?s:n[l-1]})),e}languageDataAt(e,n,s=-1){let o=[];for(let l of this.facet(languageData))for(let a of l(this,n,s))Object.prototype.hasOwnProperty.call(a,e)&&o.push(a[e]);return o}charCategorizer(e){return makeCategorizer(this.languageDataAt("wordChars",e).join(""))}wordAt(e){let{text:n,from:s,length:o}=this.doc.lineAt(e),l=this.charCategorizer(e),a=e-s,c=e-s;for(;a>0;){let h=findClusterBreak(n,a,!1);if(l(n.slice(h,a))!=CharCategory.Word)break;a=h}for(;cr.length?r[0]:4});EditorState.lineSeparator=lineSeparator;EditorState.readOnly=readOnly;EditorState.phrases=Facet.define({compare(r,e){let n=Object.keys(r),s=Object.keys(e);return n.length==s.length&&n.every(o=>r[o]==e[o])}});EditorState.languageData=languageData;EditorState.changeFilter=changeFilter;EditorState.transactionFilter=transactionFilter;EditorState.transactionExtender=transactionExtender;Compartment.reconfigure=StateEffect.define();function combineConfig(r,e,n={}){let s={};for(let o of r)for(let l of Object.keys(o)){let a=o[l],c=s[l];if(c===void 0)s[l]=a;else if(!(c===a||a===void 0))if(Object.hasOwnProperty.call(n,l))s[l]=n[l](c,a);else throw new Error("Config merge conflict for field "+l)}for(let o in e)s[o]===void 0&&(s[o]=e[o]);return s}class RangeValue{eq(e){return this==e}range(e,n=e){return Range$1.create(e,n,this)}}RangeValue.prototype.startSide=RangeValue.prototype.endSide=0;RangeValue.prototype.point=!1;RangeValue.prototype.mapMode=MapMode.TrackDel;let Range$1=class Ce{constructor(e,n,s){this.from=e,this.to=n,this.value=s}static create(e,n,s){return new Ce(e,n,s)}};function cmpRange(r,e){return r.from-e.from||r.value.startSide-e.value.startSide}class Chunk{constructor(e,n,s,o){this.from=e,this.to=n,this.value=s,this.maxPoint=o}get length(){return this.to[this.to.length-1]}findIndex(e,n,s,o=0){let l=s?this.to:this.from;for(let a=o,c=l.length;;){if(a==c)return a;let h=a+c>>1,f=l[h]-e||(s?this.value[h].endSide:this.value[h].startSide)-n;if(h==a)return f>=0?a:c;f>=0?c=h:a=h+1}}between(e,n,s,o){for(let l=this.findIndex(n,-1e9,!0),a=this.findIndex(s,1e9,!1,l);lO||g==O&&f.startSide>0&&f.endSide<=0)continue;(O-g||f.endSide-f.startSide)<0||(a<0&&(a=g),f.point&&(c=Math.max(c,O-g)),s.push(f),o.push(g-a),l.push(O-a))}return{mapped:s.length?new Chunk(o,l,s,c):null,pos:a}}}class RangeSet{constructor(e,n,s,o){this.chunkPos=e,this.chunk=n,this.nextLayer=s,this.maxPoint=o}static create(e,n,s,o){return new RangeSet(e,n,s,o)}get length(){let e=this.chunk.length-1;return e<0?0:Math.max(this.chunkEnd(e),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let e=this.nextLayer.size;for(let n of this.chunk)e+=n.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:n=[],sort:s=!1,filterFrom:o=0,filterTo:l=this.length}=e,a=e.filter;if(n.length==0&&!a)return this;if(s&&(n=n.slice().sort(cmpRange)),this.isEmpty)return n.length?RangeSet.of(n):this;let c=new LayerCursor(this,null,-1).goto(0),h=0,f=[],u=new RangeSetBuilder;for(;c.value||h=0){let d=n[h++];u.addInner(d.from,d.to,d.value)||f.push(d)}else c.rangeIndex==1&&c.chunkIndexthis.chunkEnd(c.chunkIndex)||lc.to||l=l&&e<=l+a.length&&a.between(l,e-l,n-l,s)===!1)return}this.nextLayer.between(e,n,s)}}iter(e=0){return HeapCursor.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,n=0){return HeapCursor.from(e).goto(n)}static compare(e,n,s,o,l=-1){let a=e.filter(d=>d.maxPoint>0||!d.isEmpty&&d.maxPoint>=l),c=n.filter(d=>d.maxPoint>0||!d.isEmpty&&d.maxPoint>=l),h=findSharedChunks(a,c,s),f=new SpanCursor(a,h,l),u=new SpanCursor(c,h,l);s.iterGaps((d,g,O)=>compare(f,d,u,g,O,o)),s.empty&&s.length==0&&compare(f,0,u,0,0,o)}static eq(e,n,s=0,o){o==null&&(o=999999999);let l=e.filter(u=>!u.isEmpty&&n.indexOf(u)<0),a=n.filter(u=>!u.isEmpty&&e.indexOf(u)<0);if(l.length!=a.length)return!1;if(!l.length)return!0;let c=findSharedChunks(l,a),h=new SpanCursor(l,c,0).goto(s),f=new SpanCursor(a,c,0).goto(s);for(;;){if(h.to!=f.to||!sameValues(h.active,f.active)||h.point&&(!f.point||!h.point.eq(f.point)))return!1;if(h.to>o)return!0;h.next(),f.next()}}static spans(e,n,s,o,l=-1){let a=new SpanCursor(e,null,l).goto(n),c=n,h=a.openStart;for(;;){let f=Math.min(a.to,s);if(a.point){let u=a.activeForPoint(a.to),d=a.pointFromc&&(o.span(c,f,a.active,h),h=a.openEnd(f));if(a.to>s)return h+(a.point&&a.to>s?1:0);c=a.to,a.next()}}static of(e,n=!1){let s=new RangeSetBuilder;for(let o of e instanceof Range$1?[e]:n?lazySort(e):e)s.add(o.from,o.to,o.value);return s.finish()}static join(e){if(!e.length)return RangeSet.empty;let n=e[e.length-1];for(let s=e.length-2;s>=0;s--)for(let o=e[s];o!=RangeSet.empty;o=o.nextLayer)n=new RangeSet(o.chunkPos,o.chunk,n,Math.max(o.maxPoint,n.maxPoint));return n}}RangeSet.empty=new RangeSet([],[],null,-1);function lazySort(r){if(r.length>1)for(let e=r[0],n=1;n0)return r.slice().sort(cmpRange);e=s}return r}RangeSet.empty.nextLayer=RangeSet.empty;class RangeSetBuilder{finishChunk(e){this.chunks.push(new Chunk(this.from,this.to,this.value,this.maxPoint)),this.chunkPos.push(this.chunkStart),this.chunkStart=-1,this.setMaxPoint=Math.max(this.setMaxPoint,this.maxPoint),this.maxPoint=-1,e&&(this.from=[],this.to=[],this.value=[])}constructor(){this.chunks=[],this.chunkPos=[],this.chunkStart=-1,this.last=null,this.lastFrom=-1e9,this.lastTo=-1e9,this.from=[],this.to=[],this.value=[],this.maxPoint=-1,this.setMaxPoint=-1,this.nextLayer=null}add(e,n,s){this.addInner(e,n,s)||(this.nextLayer||(this.nextLayer=new RangeSetBuilder)).add(e,n,s)}addInner(e,n,s){let o=e-this.lastTo||s.startSide-this.last.endSide;if(o<=0&&(e-this.lastFrom||s.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return o<0?!1:(this.from.length==250&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(n-this.chunkStart),this.last=s,this.lastFrom=e,this.lastTo=n,this.value.push(s),s.point&&(this.maxPoint=Math.max(this.maxPoint,n-e)),!0)}addChunk(e,n){if((e-this.lastTo||n.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,n.maxPoint),this.chunks.push(n),this.chunkPos.push(e);let s=n.value.length-1;return this.last=n.value[s],this.lastFrom=n.from[s]+e,this.lastTo=n.to[s]+e,!0}finish(){return this.finishInner(RangeSet.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let n=RangeSet.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,n}}function findSharedChunks(r,e,n){let s=new Map;for(let l of r)for(let a=0;a=this.minPoint)break}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex=s&&o.push(new LayerCursor(a,n,s,l));return o.length==1?o[0]:new HeapCursor(o)}get startSide(){return this.value?this.value.startSide:0}goto(e,n=-1e9){for(let s of this.heap)s.goto(e,n);for(let s=this.heap.length>>1;s>=0;s--)heapBubble(this.heap,s);return this.next(),this}forward(e,n){for(let s of this.heap)s.forward(e,n);for(let s=this.heap.length>>1;s>=0;s--)heapBubble(this.heap,s);(this.to-e||this.value.endSide-n)<0&&this.next()}next(){if(this.heap.length==0)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let e=this.heap[0];this.from=e.from,this.to=e.to,this.value=e.value,this.rank=e.rank,e.value&&e.next(),heapBubble(this.heap,0)}}}function heapBubble(r,e){for(let n=r[e];;){let s=(e<<1)+1;if(s>=r.length)break;let o=r[s];if(s+1=0&&(o=r[s+1],s++),n.compare(o)<0)break;r[s]=n,r[e]=o,e=s}}class SpanCursor{constructor(e,n,s){this.minPoint=s,this.active=[],this.activeTo=[],this.activeRank=[],this.minActive=-1,this.point=null,this.pointFrom=0,this.pointRank=0,this.to=-1e9,this.endSide=0,this.openStart=-1,this.cursor=HeapCursor.from(e,n,s)}goto(e,n=-1e9){return this.cursor.goto(e,n),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=n,this.openStart=-1,this.next(),this}forward(e,n){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-n)<0;)this.removeActive(this.minActive);this.cursor.forward(e,n)}removeActive(e){remove(this.active,e),remove(this.activeTo,e),remove(this.activeRank,e),this.minActive=findMinIndex(this.active,this.activeTo)}addActive(e){let n=0,{value:s,to:o,rank:l}=this.cursor;for(;n0;)n++;insert(this.active,n,s),insert(this.activeTo,n,o),insert(this.activeRank,n,l),e&&insert(e,n,this.cursor.from),this.minActive=findMinIndex(this.active,this.activeTo)}next(){let e=this.to,n=this.point;this.point=null;let s=this.openStart<0?[]:null;for(;;){let o=this.minActive;if(o>-1&&(this.activeTo[o]-this.cursor.from||this.active[o].endSide-this.cursor.startSide)<0){if(this.activeTo[o]>e){this.to=this.activeTo[o],this.endSide=this.active[o].endSide;break}this.removeActive(o),s&&remove(s,o)}else if(this.cursor.value)if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let l=this.cursor.value;if(!l.point)this.addActive(s),this.cursor.next();else if(n&&this.cursor.to==this.to&&this.cursor.from=0&&s[o]=0&&!(this.activeRank[s]e||this.activeTo[s]==e&&this.active[s].endSide>=this.point.endSide)&&n.push(this.active[s]);return n.reverse()}openEnd(e){let n=0;for(let s=this.activeTo.length-1;s>=0&&this.activeTo[s]>e;s--)n++;return n}}function compare(r,e,n,s,o,l){r.goto(e),n.goto(s);let a=s+o,c=s,h=s-e;for(;;){let f=r.to+h-n.to||r.endSide-n.endSide,u=f<0?r.to+h:n.to,d=Math.min(u,a);if(r.point||n.point?r.point&&n.point&&(r.point==n.point||r.point.eq(n.point))&&sameValues(r.activeForPoint(r.to),n.activeForPoint(n.to))||l.comparePoint(c,d,r.point,n.point):d>c&&!sameValues(r.active,n.active)&&l.compareRange(c,d,r.active,n.active),u>a)break;c=u,f<=0&&r.next(),f>=0&&n.next()}}function sameValues(r,e){if(r.length!=e.length)return!1;for(let n=0;n=e;s--)r[s+1]=r[s];r[e]=n}function findMinIndex(r,e){let n=-1,s=1e9;for(let o=0;o=e)return o;if(o==r.length)break;l+=r.charCodeAt(o)==9?n-l%n:1,o=findClusterBreak(r,o)}return s===!0?-1:r.length}const C="ͼ",COUNT=typeof Symbol>"u"?"__"+C:Symbol.for(C),SET=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),top=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};class StyleModule{constructor(e,n){this.rules=[];let{finish:s}=n||{};function o(a){return/^@/.test(a)?[a]:a.split(/,\s*/)}function l(a,c,h,f){let u=[],d=/^@(\w+)\b/.exec(a[0]),g=d&&d[1]=="keyframes";if(d&&c==null)return h.push(a[0]+";");for(let O in c){let m=c[O];if(/&/.test(O))l(O.split(/,\s*/).map(S=>a.map(b=>S.replace(/&/,b))).reduce((S,b)=>S.concat(b)),m,h);else if(m&&typeof m=="object"){if(!d)throw new RangeError("The value of a property ("+O+") should be a primitive value.");l(o(O),m,u,g)}else m!=null&&u.push(O.replace(/_.*/,"").replace(/[A-Z]/g,S=>"-"+S.toLowerCase())+": "+m+";")}(u.length||g)&&h.push((s&&!d&&!f?a.map(s):a).join(", ")+" {"+u.join(" ")+"}")}for(let a in e)l(o(a),e[a],this.rules)}getRules(){return this.rules.join(` `)}static newName(){let e=top[COUNT]||1;return top[COUNT]=e+1,C+e.toString(36)}static mount(e,n,s){let o=e[SET],l=s&&s.nonce;o?l&&o.setNonce(l):o=new StyleSet(e,l),o.mount(Array.isArray(n)?n:[n],e)}}let adoptedSet=new Map;class StyleSet{constructor(e,n){let s=e.ownerDocument||e,o=s.defaultView;if(!e.head&&e.adoptedStyleSheets&&o.CSSStyleSheet){let l=adoptedSet.get(s);if(l)return e[SET]=l;this.sheet=new o.CSSStyleSheet,adoptedSet.set(s,this)}else this.styleTag=s.createElement("style"),n&&this.styleTag.setAttribute("nonce",n);this.modules=[],e[SET]=this}mount(e,n){let s=this.sheet,o=0,l=0;for(let a=0;a-1&&(this.modules.splice(h,1),l--,h=-1),h==-1){if(this.modules.splice(l++,0,c),s)for(let f=0;f",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},mac=typeof navigator<"u"&&/Mac/.test(navigator.platform),ie$1=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var i=0;i<10;i++)base[48+i]=base[96+i]=String(i);for(var i=1;i<=24;i++)base[i+111]="F"+i;for(var i=65;i<=90;i++)base[i]=String.fromCharCode(i+32),shift[i]=String.fromCharCode(i);for(var code in base)shift.hasOwnProperty(code)||(shift[code]=base[code]);function keyName(r){var e=mac&&r.metaKey&&r.shiftKey&&!r.ctrlKey&&!r.altKey||ie$1&&r.shiftKey&&r.key&&r.key.length==1||r.key=="Unidentified",n=!e&&r.key||(r.shiftKey?shift:base)[r.keyCode]||r.key||"Unidentified";return n=="Esc"&&(n="Escape"),n=="Del"&&(n="Delete"),n=="Left"&&(n="ArrowLeft"),n=="Up"&&(n="ArrowUp"),n=="Right"&&(n="ArrowRight"),n=="Down"&&(n="ArrowDown"),n}function getSelection(r){let e;return r.nodeType==11?e=r.getSelection?r:r.ownerDocument:e=r,e.getSelection()}function contains(r,e){return e?r==e||r.contains(e.nodeType!=1?e.parentNode:e):!1}function deepActiveElement(r){let e=r.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function hasSelection(r,e){if(!e.anchorNode)return!1;try{return contains(r,e.anchorNode)}catch{return!1}}function clientRectsFor(r){return r.nodeType==3?textRange(r,0,r.nodeValue.length).getClientRects():r.nodeType==1?r.getClientRects():[]}function isEquivalentPosition(r,e,n,s){return n?scanFor(r,e,n,s,-1)||scanFor(r,e,n,s,1):!1}function domIndex(r){for(var e=0;;e++)if(r=r.previousSibling,!r)return e}function isBlockElement(r){return r.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(r.nodeName)}function scanFor(r,e,n,s,o){for(;;){if(r==n&&e==s)return!0;if(e==(o<0?0:maxOffset(r))){if(r.nodeName=="DIV")return!1;let l=r.parentNode;if(!l||l.nodeType!=1)return!1;e=domIndex(r)+(o<0?0:1),r=l}else if(r.nodeType==1){if(r=r.childNodes[e+(o<0?-1:0)],r.nodeType==1&&r.contentEditable=="false")return!1;e=o<0?maxOffset(r):0}else return!1}}function maxOffset(r){return r.nodeType==3?r.nodeValue.length:r.childNodes.length}function flattenRect(r,e){let n=e?r.left:r.right;return{left:n,right:n,top:r.top,bottom:r.bottom}}function windowRect(r){let e=r.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:r.innerWidth,top:0,bottom:r.innerHeight}}function getScale(r,e){let n=e.width/r.offsetWidth,s=e.height/r.offsetHeight;return(n>.995&&n<1.005||!isFinite(n)||Math.abs(e.width-r.offsetWidth)<1)&&(n=1),(s>.995&&s<1.005||!isFinite(s)||Math.abs(e.height-r.offsetHeight)<1)&&(s=1),{scaleX:n,scaleY:s}}function scrollRectIntoView(r,e,n,s,o,l,a,c){let h=r.ownerDocument,f=h.defaultView||window;for(let u=r,d=!1;u&&!d;)if(u.nodeType==1){let g,O=u==h.body,m=1,y=1;if(O)g=windowRect(f);else{if(/^(fixed|sticky)$/.test(getComputedStyle(u).position)&&(d=!0),u.scrollHeight<=u.clientHeight&&u.scrollWidth<=u.clientWidth){u=u.assignedSlot||u.parentNode;continue}let P=u.getBoundingClientRect();({scaleX:m,scaleY:y}=getScale(u,P)),g={left:P.left,right:P.left+u.clientWidth*m,top:P.top,bottom:P.top+u.clientHeight*y}}let b=0,w=0;if(o=="nearest")e.top0&&e.bottom>g.bottom+w&&(w=e.bottom-g.bottom+w+a)):e.bottom>g.bottom&&(w=e.bottom-g.bottom+a,n<0&&e.top-w0&&e.right>g.right+b&&(b=e.right-g.right+b+l)):e.right>g.right&&(b=e.right-g.right+l,n<0&&e.leftn.clientHeight||n.scrollWidth>n.clientWidth)return n;n=n.assignedSlot||n.parentNode}else if(n.nodeType==11)n=n.host;else break;return null}class DOMSelectionState{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(e){return this.anchorNode==e.anchorNode&&this.anchorOffset==e.anchorOffset&&this.focusNode==e.focusNode&&this.focusOffset==e.focusOffset}setRange(e){let{anchorNode:n,focusNode:s}=e;this.set(n,Math.min(e.anchorOffset,n?maxOffset(n):0),s,Math.min(e.focusOffset,s?maxOffset(s):0))}set(e,n,s,o){this.anchorNode=e,this.anchorOffset=n,this.focusNode=s,this.focusOffset=o}}let preventScrollSupported=null;function focusPreventScroll(r){if(r.setActive)return r.setActive();if(preventScrollSupported)return r.focus(preventScrollSupported);let e=[];for(let n=r;n&&(e.push(n,n.scrollTop,n.scrollLeft),n!=n.ownerDocument);n=n.parentNode);if(r.focus(preventScrollSupported==null?{get preventScroll(){return preventScrollSupported={preventScroll:!0},!0}}:void 0),!preventScrollSupported){preventScrollSupported=!1;for(let n=0;nMath.max(1,r.scrollHeight-r.clientHeight-4)}function textNodeBefore(r,e){for(let n=r,s=e;;){if(n.nodeType==3&&s>0)return{node:n,offset:s};if(n.nodeType==1&&s>0){if(n.contentEditable=="false")return null;n=n.childNodes[s-1],s=maxOffset(n)}else if(n.parentNode&&!isBlockElement(n))s=domIndex(n),n=n.parentNode;else return null}}function textNodeAfter(r,e){for(let n=r,s=e;;){if(n.nodeType==3&&sn)return d.domBoundsAround(e,n,f);if(g>=e&&o==-1&&(o=h,l=f),f>n&&d.dom.parentNode==this.dom){a=h,c=u;break}u=g,f=g+d.breakAfter}return{from:l,to:c<0?s+this.length:c,startDOM:(o?this.children[o-1].dom.nextSibling:null)||this.dom.firstChild,endDOM:a=0?this.children[a].dom:null}}markDirty(e=!1){this.flags|=2,this.markParentsDirty(e)}markParentsDirty(e){for(let n=this.parent;n;n=n.parent){if(e&&(n.flags|=2),n.flags&1)return;n.flags|=1,e=!1}}setParent(e){this.parent!=e&&(this.parent=e,this.flags&7&&this.markParentsDirty(!0))}setDOM(e){this.dom!=e&&(this.dom&&(this.dom.cmView=null),this.dom=e,e.cmView=this)}get rootView(){for(let e=this;;){let n=e.parent;if(!n)return e;e=n}}replaceChildren(e,n,s=noChildren){this.markDirty();for(let o=e;othis.pos||e==this.pos&&(n>0||this.i==0||this.children[this.i-1].breakAfter))return this.off=e-this.pos,this;let s=this.children[--this.i];this.pos-=s.length+s.breakAfter}}}function replaceRange(r,e,n,s,o,l,a,c,h){let{children:f}=r,u=f.length?f[e]:null,d=l.length?l[l.length-1]:null,g=d?d.breakAfter:a;if(!(e==s&&u&&!a&&!g&&l.length<2&&u.merge(n,o,l.length?d:null,n==0,c,h))){if(s0&&(!a&&l.length&&u.merge(n,u.length,l[0],!1,c,0)?u.breakAfter=l.shift().breakAfter:(n2);var browser={mac:ios||/Mac/.test(nav.platform),windows:/Win/.test(nav.platform),linux:/Linux|X11/.test(nav.platform),ie,ie_version:ie_upto10?doc.documentMode||6:ie_11up?+ie_11up[1]:ie_edge?+ie_edge[1]:0,gecko,gecko_version:gecko?+(/Firefox\/(\d+)/.exec(nav.userAgent)||[0,0])[1]:0,chrome:!!chrome,chrome_version:chrome?+chrome[1]:0,ios,android:/Android\b/.test(nav.userAgent),webkit,safari,webkit_version:webkit?+(/\bAppleWebKit\/(\d+)/.exec(nav.userAgent)||[0,0])[1]:0,tabSize:doc.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};const MaxJoinLen=256;class TextView extends ContentView{constructor(e){super(),this.text=e}get length(){return this.text.length}createDOM(e){this.setDOM(e||document.createTextNode(this.text))}sync(e,n){this.dom||this.createDOM(),this.dom.nodeValue!=this.text&&(n&&n.node==this.dom&&(n.written=!0),this.dom.nodeValue=this.text)}reuseDOM(e){e.nodeType==3&&this.createDOM(e)}merge(e,n,s){return this.flags&8||s&&(!(s instanceof TextView)||this.length-(n-e)+s.length>MaxJoinLen||s.flags&8)?!1:(this.text=this.text.slice(0,e)+(s?s.text:"")+this.text.slice(n),this.markDirty(),!0)}split(e){let n=new TextView(this.text.slice(e));return this.text=this.text.slice(0,e),this.markDirty(),n.flags|=this.flags&8,n}localPosFromDOM(e,n){return e==this.dom?n:n?this.text.length:0}domAtPos(e){return new DOMPos(this.dom,e)}domBoundsAround(e,n,s){return{from:s,to:s+this.length,startDOM:this.dom,endDOM:this.dom.nextSibling}}coordsAt(e,n){return textCoords(this.dom,e,n)}}class MarkView extends ContentView{constructor(e,n=[],s=0){super(),this.mark=e,this.children=n,this.length=s;for(let o of n)o.setParent(this)}setAttrs(e){if(clearAttributes(e),this.mark.class&&(e.className=this.mark.class),this.mark.attrs)for(let n in this.mark.attrs)e.setAttribute(n,this.mark.attrs[n]);return e}canReuseDOM(e){return super.canReuseDOM(e)&&!((this.flags|e.flags)&8)}reuseDOM(e){e.nodeName==this.mark.tagName.toUpperCase()&&(this.setDOM(e),this.flags|=6)}sync(e,n){this.dom?this.flags&4&&this.setAttrs(this.dom):this.setDOM(this.setAttrs(document.createElement(this.mark.tagName))),super.sync(e,n)}merge(e,n,s,o,l,a){return s&&(!(s instanceof MarkView&&s.mark.eq(this.mark))||e&&l<=0||ne&&n.push(s=e&&(o=l),s=h,l++}let a=this.length-e;return this.length=e,o>-1&&(this.children.length=o,this.markDirty()),new MarkView(this.mark,n,a)}domAtPos(e){return inlineDOMAtPos(this,e)}coordsAt(e,n){return coordsInChildren(this,e,n)}}function textCoords(r,e,n){let s=r.nodeValue.length;e>s&&(e=s);let o=e,l=e,a=0;e==0&&n<0||e==s&&n>=0?browser.chrome||browser.gecko||(e?(o--,a=1):l=0)?0:c.length-1];return browser.safari&&!a&&h.width==0&&(h=Array.prototype.find.call(c,f=>f.width)||h),a?flattenRect(h,a<0):h||null}class WidgetView extends ContentView{static create(e,n,s){return new WidgetView(e,n,s)}constructor(e,n,s){super(),this.widget=e,this.length=n,this.side=s,this.prevWidget=null}split(e){let n=WidgetView.create(this.widget,this.length-e,this.side);return this.length-=e,n}sync(e){(!this.dom||!this.widget.updateDOM(this.dom,e))&&(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(e)),this.widget.editable||(this.dom.contentEditable="false"))}getSide(){return this.side}merge(e,n,s,o,l,a){return s&&(!(s instanceof WidgetView)||!this.widget.compare(s.widget)||e>0&&l<=0||n0)?DOMPos.before(this.dom):DOMPos.after(this.dom,e==this.length)}domBoundsAround(){return null}coordsAt(e,n){let s=this.widget.coordsAt(this.dom,e,n);if(s)return s;let o=this.dom.getClientRects(),l=null;if(!o.length)return null;let a=this.side?this.side<0:e>0;for(let c=a?o.length-1:0;l=o[c],!(e>0?c==0:c==o.length-1||l.top0?DOMPos.before(this.dom):DOMPos.after(this.dom)}localPosFromDOM(){return 0}domBoundsAround(){return null}coordsAt(e){return this.dom.getBoundingClientRect()}get overrideDOMText(){return Text.empty}get isHidden(){return!0}}TextView.prototype.children=WidgetView.prototype.children=WidgetBufferView.prototype.children=noChildren;function inlineDOMAtPos(r,e){let n=r.dom,{children:s}=r,o=0;for(let l=0;ol&&e0;l--){let a=s[l-1];if(a.dom.parentNode==n)return a.domAtPos(a.length)}for(let l=o;l0&&e instanceof MarkView&&o.length&&(s=o[o.length-1])instanceof MarkView&&s.mark.eq(e.mark)?joinInlineInto(s,e.children[0],n-1):(o.push(e),e.setParent(r)),r.length+=e.length}function coordsInChildren(r,e,n){let s=null,o=-1,l=null,a=-1;function c(f,u){for(let d=0,g=0;d=u&&(O.children.length?c(O,u-g):(!l||l.isHidden&&n>0)&&(m>u||g==m&&O.getSide()>0)?(l=O,a=u-g):(g-1?1:0)!=o.length-(n&&o.indexOf(n)>-1?1:0))return!1;for(let l of s)if(l!=n&&(o.indexOf(l)==-1||r[l]!==e[l]))return!1;return!0}function updateAttrs(r,e,n){let s=!1;if(e)for(let o in e)n&&o in n||(s=!0,o=="style"?r.style.cssText="":r.removeAttribute(o));if(n)for(let o in n)e&&e[o]==n[o]||(s=!0,o=="style"?r.style.cssText=n[o]:r.setAttribute(o,n[o]));return s}function getAttrs(r){let e=Object.create(null);for(let n=0;n0&&this.children[s-1].length==0;)this.children[--s].destroy();return this.children.length=s,this.markDirty(),this.length=e,n}transferDOM(e){this.dom&&(this.markDirty(),e.setDOM(this.dom),e.prevAttrs=this.prevAttrs===void 0?this.attrs:this.prevAttrs,this.prevAttrs=void 0,this.dom=null)}setDeco(e){attrsEq(this.attrs,e)||(this.dom&&(this.prevAttrs=this.attrs,this.markDirty()),this.attrs=e)}append(e,n){joinInlineInto(this,e,n)}addLineDeco(e){let n=e.spec.attributes,s=e.spec.class;n&&(this.attrs=combineAttrs(n,this.attrs||{})),s&&(this.attrs=combineAttrs({class:s},this.attrs||{}))}domAtPos(e){return inlineDOMAtPos(this,e)}reuseDOM(e){e.nodeName=="DIV"&&(this.setDOM(e),this.flags|=6)}sync(e,n){var s;this.dom?this.flags&4&&(clearAttributes(this.dom),this.dom.className="cm-line",this.prevAttrs=this.attrs?null:void 0):(this.setDOM(document.createElement("div")),this.dom.className="cm-line",this.prevAttrs=this.attrs?null:void 0),this.prevAttrs!==void 0&&(updateAttrs(this.dom,this.prevAttrs,this.attrs),this.dom.classList.add("cm-line"),this.prevAttrs=void 0),super.sync(e,n);let o=this.dom.lastChild;for(;o&&ContentView.get(o)instanceof MarkView;)o=o.lastChild;if(!o||!this.length||o.nodeName!="BR"&&((s=ContentView.get(o))===null||s===void 0?void 0:s.isEditable)==!1&&(!browser.ios||!this.children.some(l=>l instanceof TextView))){let l=document.createElement("BR");l.cmIgnore=!0,this.dom.appendChild(l)}}measureTextSize(){if(this.children.length==0||this.length>20)return null;let e=0,n;for(let s of this.children){if(!(s instanceof TextView)||/[^ -~]/.test(s.text))return null;let o=clientRectsFor(s.dom);if(o.length!=1)return null;e+=o[0].width,n=o[0].height}return e?{lineHeight:this.dom.getBoundingClientRect().height,charWidth:e/this.length,textHeight:n}:null}coordsAt(e,n){let s=coordsInChildren(this,e,n);if(!this.children.length&&s&&this.parent){let{heightOracle:o}=this.parent.view.viewState,l=s.bottom-s.top;if(Math.abs(l-o.lineHeight)<2&&o.textHeight=n){if(l instanceof LineView)return l;if(a>n)break}o=a+l.breakAfter}return null}}class BlockWidgetView extends ContentView{constructor(e,n,s){super(),this.widget=e,this.length=n,this.deco=s,this.breakAfter=0,this.prevWidget=null}merge(e,n,s,o,l,a){return s&&(!(s instanceof BlockWidgetView)||!this.widget.compare(s.widget)||e>0&&l<=0||n0}}class WidgetType{eq(e){return!1}updateDOM(e,n){return!1}compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}get estimatedHeight(){return-1}get lineBreaks(){return 0}ignoreEvent(e){return!0}coordsAt(e,n,s){return null}get isHidden(){return!1}get editable(){return!1}destroy(e){}}var BlockType=function(r){return r[r.Text=0]="Text",r[r.WidgetBefore=1]="WidgetBefore",r[r.WidgetAfter=2]="WidgetAfter",r[r.WidgetRange=3]="WidgetRange",r}(BlockType||(BlockType={}));class Decoration extends RangeValue{constructor(e,n,s,o){super(),this.startSide=e,this.endSide=n,this.widget=s,this.spec=o}get heightRelevant(){return!1}static mark(e){return new MarkDecoration(e)}static widget(e){let n=Math.max(-1e4,Math.min(1e4,e.side||0)),s=!!e.block;return n+=s&&!e.inlineOrder?n>0?3e8:-4e8:n>0?1e8:-1e8,new PointDecoration(e,n,n,s,e.widget||null,!1)}static replace(e){let n=!!e.block,s,o;if(e.isBlockGap)s=-5e8,o=4e8;else{let{start:l,end:a}=getInclusive(e,n);s=(l?n?-3e8:-1:5e8)-1,o=(a?n?2e8:1:-6e8)+1}return new PointDecoration(e,s,o,n,e.widget||null,!0)}static line(e){return new LineDecoration(e)}static set(e,n=!1){return RangeSet.of(e,n)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}}Decoration.none=RangeSet.empty;class MarkDecoration extends Decoration{constructor(e){let{start:n,end:s}=getInclusive(e);super(n?-1:5e8,s?1:-6e8,null,e),this.tagName=e.tagName||"span",this.class=e.class||"",this.attrs=e.attributes||null}eq(e){var n,s;return this==e||e instanceof MarkDecoration&&this.tagName==e.tagName&&(this.class||((n=this.attrs)===null||n===void 0?void 0:n.class))==(e.class||((s=e.attrs)===null||s===void 0?void 0:s.class))&&attrsEq(this.attrs,e.attrs,"class")}range(e,n=e){if(e>=n)throw new RangeError("Mark decorations may not be empty");return super.range(e,n)}}MarkDecoration.prototype.point=!1;class LineDecoration extends Decoration{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof LineDecoration&&this.spec.class==e.spec.class&&attrsEq(this.spec.attributes,e.spec.attributes)}range(e,n=e){if(n!=e)throw new RangeError("Line decoration ranges must be zero-length");return super.range(e,n)}}LineDecoration.prototype.mapMode=MapMode.TrackBefore;LineDecoration.prototype.point=!0;class PointDecoration extends Decoration{constructor(e,n,s,o,l,a){super(n,s,l,e),this.block=o,this.isReplace=a,this.mapMode=o?n<=0?MapMode.TrackBefore:MapMode.TrackAfter:MapMode.TrackDel}get type(){return this.startSide!=this.endSide?BlockType.WidgetRange:this.startSide<=0?BlockType.WidgetBefore:BlockType.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof PointDecoration&&widgetsEq(this.widget,e.widget)&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide}range(e,n=e){if(this.isReplace&&(e>n||e==n&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&n!=e)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(e,n)}}PointDecoration.prototype.point=!0;function getInclusive(r,e=!1){let{inclusiveStart:n,inclusiveEnd:s}=r;return n==null&&(n=r.inclusive),s==null&&(s=r.inclusive),{start:n??e,end:s??e}}function widgetsEq(r,e){return r==e||!!(r&&e&&r.compare(e))}function addRange(r,e,n,s=0){let o=n.length-1;o>=0&&n[o]+s>=r?n[o]=Math.max(n[o],e):n.push(r,e)}class ContentBuilder{constructor(e,n,s,o){this.doc=e,this.pos=n,this.end=s,this.disallowBlockEffectsFor=o,this.content=[],this.curLine=null,this.breakAtStart=0,this.pendingBuffer=0,this.bufferMarks=[],this.atCursorPos=!0,this.openStart=-1,this.openEnd=-1,this.text="",this.textOff=0,this.cursor=e.iter(),this.skip=n}posCovered(){if(this.content.length==0)return!this.breakAtStart&&this.doc.lineAt(this.pos).from!=this.pos;let e=this.content[this.content.length-1];return!(e.breakAfter||e instanceof BlockWidgetView&&e.deco.endSide<0)}getLine(){return this.curLine||(this.content.push(this.curLine=new LineView),this.atCursorPos=!0),this.curLine}flushBuffer(e=this.bufferMarks){this.pendingBuffer&&(this.curLine.append(wrapMarks(new WidgetBufferView(-1),e),e.length),this.pendingBuffer=0)}addBlockWidget(e){this.flushBuffer(),this.curLine=null,this.content.push(e)}finish(e){this.pendingBuffer&&e<=this.bufferMarks.length?this.flushBuffer():this.pendingBuffer=0,!this.posCovered()&&!(e&&this.content.length&&this.content[this.content.length-1]instanceof BlockWidgetView)&&this.getLine()}buildText(e,n,s){for(;e>0;){if(this.textOff==this.text.length){let{value:l,lineBreak:a,done:c}=this.cursor.next(this.skip);if(this.skip=0,c)throw new Error("Ran out of text content when drawing inline views");if(a){this.posCovered()||this.getLine(),this.content.length?this.content[this.content.length-1].breakAfter=1:this.breakAtStart=1,this.flushBuffer(),this.curLine=null,this.atCursorPos=!0,e--;continue}else this.text=l,this.textOff=0}let o=Math.min(this.text.length-this.textOff,e,512);this.flushBuffer(n.slice(n.length-s)),this.getLine().append(wrapMarks(new TextView(this.text.slice(this.textOff,this.textOff+o)),n),s),this.atCursorPos=!0,this.textOff+=o,e-=o,s=0}}span(e,n,s,o){this.buildText(n-e,s,o),this.pos=n,this.openStart<0&&(this.openStart=o)}point(e,n,s,o,l,a){if(this.disallowBlockEffectsFor[a]&&s instanceof PointDecoration){if(s.block)throw new RangeError("Block decorations may not be specified via plugins");if(n>this.doc.lineAt(this.pos).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}let c=n-e;if(s instanceof PointDecoration)if(s.block)s.startSide>0&&!this.posCovered()&&this.getLine(),this.addBlockWidget(new BlockWidgetView(s.widget||NullWidget.block,c,s));else{let h=WidgetView.create(s.widget||NullWidget.inline,c,c?0:s.startSide),f=this.atCursorPos&&!h.isEditable&&l<=o.length&&(e0),u=!h.isEditable&&(eo.length||s.startSide<=0),d=this.getLine();this.pendingBuffer==2&&!f&&!h.isEditable&&(this.pendingBuffer=0),this.flushBuffer(o),f&&(d.append(wrapMarks(new WidgetBufferView(1),o),l),l=o.length+Math.max(0,l-o.length)),d.append(wrapMarks(h,o),l),this.atCursorPos=u,this.pendingBuffer=u?eo.length?1:2:0,this.pendingBuffer&&(this.bufferMarks=o.slice())}else this.doc.lineAt(this.pos).from==this.pos&&this.getLine().addLineDeco(s);c&&(this.textOff+c<=this.text.length?this.textOff+=c:(this.skip+=c-(this.text.length-this.textOff),this.text="",this.textOff=0),this.pos=n),this.openStart<0&&(this.openStart=l)}static build(e,n,s,o,l){let a=new ContentBuilder(e,n,s,l);return a.openEnd=RangeSet.spans(o,n,s,a),a.openStart<0&&(a.openStart=a.openEnd),a.finish(a.openEnd),a}}function wrapMarks(r,e){for(let n of e)r=new MarkView(n,[r],r.length);return r}class NullWidget extends WidgetType{constructor(e){super(),this.tag=e}eq(e){return e.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(e){return e.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}}NullWidget.inline=new NullWidget("span");NullWidget.block=new NullWidget("div");var Direction=function(r){return r[r.LTR=0]="LTR",r[r.RTL=1]="RTL",r}(Direction||(Direction={}));const LTR=Direction.LTR,RTL=Direction.RTL;function dec(r){let e=[];for(let n=0;n=n){if(c.level==s)return a;(l<0||(o!=0?o<0?c.fromn:e[l].level>c.level))&&(l=a)}}if(l<0)throw new RangeError("Index out of range");return l}}function isolatesEq(r,e){if(r.length!=e.length)return!1;for(let n=0;n=0;y-=3)if(BracketStack[y+1]==-O){let b=BracketStack[y+2],w=b&2?o:b&4?b&1?l:o:0;w&&(types[d]=types[BracketStack[y]]=w),c=y;break}}else{if(BracketStack.length==189)break;BracketStack[c++]=d,BracketStack[c++]=g,BracketStack[c++]=h}else if((m=types[d])==2||m==1){let y=m==o;h=y?0:1;for(let b=c-3;b>=0;b-=3){let w=BracketStack[b+2];if(w&2)break;if(y)BracketStack[b+2]|=2;else{if(w&4)break;BracketStack[b+2]|=4}}}}}function processNeutrals(r,e,n,s){for(let o=0,l=s;o<=n.length;o++){let a=o?n[o-1].to:r,c=oh;)m==b&&(m=n[--y].from,b=y?n[y-1].to:r),types[--m]=O;h=u}else l=f,h++}}}function emitSpans(r,e,n,s,o,l,a){let c=s%2?2:1;if(s%2==o%2)for(let h=e,f=0;hh&&a.push(new BidiSpan(h,y.from,O));let b=y.direction==LTR!=!(O%2);computeSectionOrder(r,b?s+1:s,o,y.inner,y.from,y.to,a),h=y.to}m=y.to}else{if(m==n||(u?types[m]!=c:types[m]==c))break;m++}g?emitSpans(r,h,m,s+1,o,g,a):he;){let u=!0,d=!1;if(!f||h>l[f-1].to){let y=types[h-1];y!=c&&(u=!1,d=y==16)}let g=!u&&c==1?[]:null,O=u?s:s+1,m=h;e:for(;;)if(f&&m==l[f-1].to){if(d)break e;let y=l[--f];if(!u)for(let b=y.from,w=f;;){if(b==e)break e;if(w&&l[w-1].to==b)b=l[--w].from;else{if(types[b-1]==c)break e;break}}if(g)g.push(y);else{y.totypes.length;)types[types.length]=256;let s=[],o=e==LTR?0:1;return computeSectionOrder(r,o,o,n,0,r.length,s),s}function trivialOrder(r){return[new BidiSpan(0,r,0)]}let movedOver="";function moveVisually(r,e,n,s,o){var l;let a=s.head-r.from,c=BidiSpan.find(e,a,(l=s.bidiLevel)!==null&&l!==void 0?l:-1,s.assoc),h=e[c],f=h.side(o,n);if(a==f){let g=c+=o?1:-1;if(g<0||g>=e.length)return null;h=e[c=g],a=h.side(!o,n),f=h.side(o,n)}let u=findClusterBreak(r.text,a,h.forward(o,n));(uh.to)&&(u=f),movedOver=r.text.slice(Math.min(a,u),Math.max(a,u));let d=c==(o?e.length-1:0)?null:e[c+(o?1:-1)];return d&&u==f&&d.level+(o?0:1)r.some(e=>e)}),nativeSelectionHidden=Facet.define({combine:r=>r.some(e=>e)}),scrollHandler=Facet.define();class ScrollTarget{constructor(e,n="nearest",s="nearest",o=5,l=5,a=!1){this.range=e,this.y=n,this.x=s,this.yMargin=o,this.xMargin=l,this.isSnapshot=a}map(e){return e.empty?this:new ScrollTarget(this.range.map(e),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(e){return this.range.to<=e.doc.length?this:new ScrollTarget(EditorSelection.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const scrollIntoView$1=StateEffect.define({map:(r,e)=>r.map(e)}),setEditContextFormatting=StateEffect.define();function logException(r,e,n){let s=r.facet(exceptionSink);s.length?s[0](e):window.onerror?window.onerror(String(e),n,void 0,void 0,e):n?console.error(n+":",e):console.error(e)}const editable=Facet.define({combine:r=>r.length?r[0]:!0});let nextPluginID=0;const viewPlugin=Facet.define();class ViewPlugin{constructor(e,n,s,o,l){this.id=e,this.create=n,this.domEventHandlers=s,this.domEventObservers=o,this.extension=l(this)}static define(e,n){const{eventHandlers:s,eventObservers:o,provide:l,decorations:a}=n||{};return new ViewPlugin(nextPluginID++,e,s,o,c=>{let h=[viewPlugin.of(c)];return a&&h.push(decorations.of(f=>{let u=f.plugin(c);return u?a(u):Decoration.none})),l&&h.push(l(c)),h})}static fromClass(e,n){return ViewPlugin.define(s=>new e(s),n)}}class PluginInstance{constructor(e){this.spec=e,this.mustUpdate=null,this.value=null}update(e){if(this.value){if(this.mustUpdate){let n=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(n)}catch(s){if(logException(n.state,s,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch{}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.create(e)}catch(n){logException(e.state,n,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var n;if(!((n=this.value)===null||n===void 0)&&n.destroy)try{this.value.destroy()}catch(s){logException(e.state,s,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const editorAttributes=Facet.define(),contentAttributes=Facet.define(),decorations=Facet.define(),outerDecorations=Facet.define(),atomicRanges=Facet.define(),bidiIsolatedRanges=Facet.define();function getIsolatedRanges(r,e){let n=r.state.facet(bidiIsolatedRanges);if(!n.length)return n;let s=n.map(l=>l instanceof Function?l(r):l),o=[];return RangeSet.spans(s,e.from,e.to,{point(){},span(l,a,c,h){let f=l-e.from,u=a-e.from,d=o;for(let g=c.length-1;g>=0;g--,h--){let O=c[g].spec.bidiIsolate,m;if(O==null&&(O=autoDirection(e.text,f,u)),h>0&&d.length&&(m=d[d.length-1]).to==f&&m.direction==O)m.to=u,d=m.inner;else{let y={from:f,to:u,direction:O,inner:[]};d.push(y),d=y.inner}}}}),o}const scrollMargins=Facet.define();function getScrollMargins(r){let e=0,n=0,s=0,o=0;for(let l of r.state.facet(scrollMargins)){let a=l(r);a&&(a.left!=null&&(e=Math.max(e,a.left)),a.right!=null&&(n=Math.max(n,a.right)),a.top!=null&&(s=Math.max(s,a.top)),a.bottom!=null&&(o=Math.max(o,a.bottom)))}return{left:e,right:n,top:s,bottom:o}}const styleModule=Facet.define();class ChangedRange{constructor(e,n,s,o){this.fromA=e,this.toA=n,this.fromB=s,this.toB=o}join(e){return new ChangedRange(Math.min(this.fromA,e.fromA),Math.max(this.toA,e.toA),Math.min(this.fromB,e.fromB),Math.max(this.toB,e.toB))}addToSet(e){let n=e.length,s=this;for(;n>0;n--){let o=e[n-1];if(!(o.fromA>s.toA)){if(o.toAu)break;l+=2}if(!h)return s;new ChangedRange(h.fromA,h.toA,h.fromB,h.toB).addToSet(s),a=h.toA,c=h.toB}}}class ViewUpdate{constructor(e,n,s){this.view=e,this.state=n,this.transactions=s,this.flags=0,this.startState=e.state,this.changes=ChangeSet.empty(this.startState.doc.length);for(let l of s)this.changes=this.changes.compose(l.changes);let o=[];this.changes.iterChangedRanges((l,a,c,h)=>o.push(new ChangedRange(l,a,c,h))),this.changedRanges=o}static create(e,n,s){return new ViewUpdate(e,n,s)}get viewportChanged(){return(this.flags&4)>0}get heightChanged(){return(this.flags&2)>0}get geometryChanged(){return this.docChanged||(this.flags&10)>0}get focusChanged(){return(this.flags&1)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(e=>e.selection)}get empty(){return this.flags==0&&this.transactions.length==0}}class DocView extends ContentView{get length(){return this.view.state.doc.length}constructor(e){super(),this.view=e,this.decorations=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.markedForComposition=new Set,this.editContextFormatting=Decoration.none,this.lastCompositionAfterCursor=!1,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.setDOM(e.contentDOM),this.children=[new LineView],this.children[0].setParent(this),this.updateDeco(),this.updateInner([new ChangedRange(0,0,0,e.state.doc.length)],0,null)}update(e){var n;let s=e.changedRanges;this.minWidth>0&&s.length&&(s.every(({fromA:f,toA:u})=>uthis.minWidthTo)?(this.minWidthFrom=e.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=e.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0),this.updateEditContextFormatting(e);let o=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&(!((n=this.domChanged)===null||n===void 0)&&n.newSel?o=this.domChanged.newSel.head:!touchesComposition(e.changes,this.hasComposition)&&!e.selectionSet&&(o=e.state.selection.main.head));let l=o>-1?findCompositionRange(this.view,e.changes,o):null;if(this.domChanged=null,this.hasComposition){this.markedForComposition.clear();let{from:f,to:u}=this.hasComposition;s=new ChangedRange(f,u,e.changes.mapPos(f,-1),e.changes.mapPos(u,1)).addToSet(s.slice())}this.hasComposition=l?{from:l.range.fromB,to:l.range.toB}:null,(browser.ie||browser.chrome)&&!l&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let a=this.decorations,c=this.updateDeco(),h=findChangedDeco(a,c,e.changes);return s=ChangedRange.extendWithRanges(s,h),!(this.flags&7)&&s.length==0?!1:(this.updateInner(s,e.startState.doc.length,l),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,n,s){this.view.viewState.mustMeasureContent=!0,this.updateChildren(e,n,s);let{observer:o}=this.view;o.ignore(()=>{this.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let a=browser.chrome||browser.ios?{node:o.selectionRange.focusNode,written:!1}:void 0;this.sync(this.view,a),this.flags&=-8,a&&(a.written||o.selectionRange.focusNode!=a.node)&&(this.forceSelection=!0),this.dom.style.height=""}),this.markedForComposition.forEach(a=>a.flags&=-9);let l=[];if(this.view.viewport.from||this.view.viewport.to=0?o[a]:null;if(!c)break;let{fromA:h,toA:f,fromB:u,toB:d}=c,g,O,m,y;if(s&&s.range.fromBu){let A=ContentBuilder.build(this.view.state.doc,u,s.range.fromB,this.decorations,this.dynamicDecorationMap),v=ContentBuilder.build(this.view.state.doc,s.range.toB,d,this.decorations,this.dynamicDecorationMap);O=A.breakAtStart,m=A.openStart,y=v.openEnd;let Q=this.compositionView(s);v.breakAtStart?Q.breakAfter=1:v.content.length&&Q.merge(Q.length,Q.length,v.content[0],!1,v.openStart,0)&&(Q.breakAfter=v.content[0].breakAfter,v.content.shift()),A.content.length&&Q.merge(0,0,A.content[A.content.length-1],!0,0,A.openEnd)&&A.content.pop(),g=A.content.concat(Q).concat(v.content)}else({content:g,breakAtStart:O,openStart:m,openEnd:y}=ContentBuilder.build(this.view.state.doc,u,d,this.decorations,this.dynamicDecorationMap));let{i:b,off:w}=l.findPos(f,1),{i:P,off:$}=l.findPos(h,-1);replaceRange(this,P,$,b,w,g,O,m,y)}s&&this.fixCompositionDOM(s)}updateEditContextFormatting(e){this.editContextFormatting=this.editContextFormatting.map(e.changes);for(let n of e.transactions)for(let s of n.effects)s.is(setEditContextFormatting)&&(this.editContextFormatting=s.value)}compositionView(e){let n=new TextView(e.text.nodeValue);n.flags|=8;for(let{deco:o}of e.marks)n=new MarkView(o,[n],n.length);let s=new LineView;return s.append(n,0),s}fixCompositionDOM(e){let n=(l,a)=>{a.flags|=8|(a.children.some(h=>h.flags&7)?1:0),this.markedForComposition.add(a);let c=ContentView.get(l);c&&c!=a&&(c.dom=null),a.setDOM(l)},s=this.childPos(e.range.fromB,1),o=this.children[s.i];n(e.line,o);for(let l=e.marks.length-1;l>=-1;l--)s=o.childPos(s.off,1),o=o.children[s.i],n(l>=0?e.marks[l].node:e.text,o)}updateSelection(e=!1,n=!1){(e||!this.view.observer.selectionRange.focusNode)&&this.view.observer.readSelectionRange();let s=this.view.root.activeElement,o=s==this.dom,l=!o&&hasSelection(this.dom,this.view.observer.selectionRange)&&!(s&&this.dom.contains(s));if(!(o||n||l))return;let a=this.forceSelection;this.forceSelection=!1;let c=this.view.state.selection.main,h=this.moveToLine(this.domAtPos(c.anchor)),f=c.empty?h:this.moveToLine(this.domAtPos(c.head));if(browser.gecko&&c.empty&&!this.hasComposition&&betweenUneditable(h)){let d=document.createTextNode("");this.view.observer.ignore(()=>h.node.insertBefore(d,h.node.childNodes[h.offset]||null)),h=f=new DOMPos(d,0),a=!0}let u=this.view.observer.selectionRange;(a||!u.focusNode||(!isEquivalentPosition(h.node,h.offset,u.anchorNode,u.anchorOffset)||!isEquivalentPosition(f.node,f.offset,u.focusNode,u.focusOffset))&&!this.suppressWidgetCursorChange(u,c))&&(this.view.observer.ignore(()=>{browser.android&&browser.chrome&&this.dom.contains(u.focusNode)&&inUneditable(u.focusNode,this.dom)&&(this.dom.blur(),this.dom.focus({preventScroll:!0}));let d=getSelection(this.view.root);if(d)if(c.empty){if(browser.gecko){let g=nextToUneditable(h.node,h.offset);if(g&&g!=3){let O=(g==1?textNodeBefore:textNodeAfter)(h.node,h.offset);O&&(h=new DOMPos(O.node,O.offset))}}d.collapse(h.node,h.offset),c.bidiLevel!=null&&d.caretBidiLevel!==void 0&&(d.caretBidiLevel=c.bidiLevel)}else if(d.extend){d.collapse(h.node,h.offset);try{d.extend(f.node,f.offset)}catch{}}else{let g=document.createRange();c.anchor>c.head&&([h,f]=[f,h]),g.setEnd(f.node,f.offset),g.setStart(h.node,h.offset),d.removeAllRanges(),d.addRange(g)}l&&this.view.root.activeElement==this.dom&&(this.dom.blur(),s&&s.focus())}),this.view.observer.setSelectionRange(h,f)),this.impreciseAnchor=h.precise?null:new DOMPos(u.anchorNode,u.anchorOffset),this.impreciseHead=f.precise?null:new DOMPos(u.focusNode,u.focusOffset)}suppressWidgetCursorChange(e,n){return this.hasComposition&&n.empty&&isEquivalentPosition(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==n.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,n=e.state.selection.main,s=getSelection(e.root),{anchorNode:o,anchorOffset:l}=e.observer.selectionRange;if(!s||!n.empty||!n.assoc||!s.modify)return;let a=LineView.find(this,n.head);if(!a)return;let c=a.posAtStart;if(n.head==c||n.head==c+a.length)return;let h=this.coordsAt(n.head,-1),f=this.coordsAt(n.head,1);if(!h||!f||h.bottom>f.top)return;let u=this.domAtPos(n.head+n.assoc);s.collapse(u.node,u.offset),s.modify("move",n.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let d=e.observer.selectionRange;e.docView.posFromDOM(d.anchorNode,d.anchorOffset)!=n.from&&s.collapse(o,l)}moveToLine(e){let n=this.dom,s;if(e.node!=n)return e;for(let o=e.offset;!s&&o=0;o--){let l=ContentView.get(n.childNodes[o]);l instanceof LineView&&(s=l.domAtPos(l.length))}return s?new DOMPos(s.node,s.offset,!0):e}nearest(e){for(let n=e;n;){let s=ContentView.get(n);if(s&&s.rootView==this)return s;n=n.parentNode}return null}posFromDOM(e,n){let s=this.nearest(e);if(!s)throw new RangeError("Trying to find position for a DOM position outside of the document");return s.localPosFromDOM(e,n)+s.posAtStart}domAtPos(e){let{i:n,off:s}=this.childCursor().findPos(e,-1);for(;n=0;a--){let c=this.children[a],h=l-c.breakAfter,f=h-c.length;if(he||c.covers(1))&&(!s||c instanceof LineView&&!(s instanceof LineView&&n>=0)))s=c,o=f;else if(s&&f==e&&h==e&&c instanceof BlockWidgetView&&Math.abs(n)<2){if(c.deco.startSide<0)break;a&&(s=null)}l=f}return s?s.coordsAt(e-o,n):null}coordsForChar(e){let{i:n,off:s}=this.childPos(e,1),o=this.children[n];if(!(o instanceof LineView))return null;for(;o.children.length;){let{i:c,off:h}=o.childPos(s,1);for(;;c++){if(c==o.children.length)return null;if((o=o.children[c]).length)break}s=h}if(!(o instanceof TextView))return null;let l=findClusterBreak(o.text,s);if(l==s)return null;let a=textRange(o.dom,s,l).getClientRects();for(let c=0;cMath.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,c=-1,h=this.view.textDirection==Direction.LTR;for(let f=0,u=0;uo)break;if(f>=s){let O=d.dom.getBoundingClientRect();if(n.push(O.height),a){let m=d.dom.lastChild,y=m?clientRectsFor(m):[];if(y.length){let b=y[y.length-1],w=h?b.right-O.left:O.right-b.left;w>c&&(c=w,this.minWidth=l,this.minWidthFrom=f,this.minWidthTo=g)}}}f=g+d.breakAfter}return n}textDirectionAt(e){let{i:n}=this.childPos(e,1);return getComputedStyle(this.children[n].dom).direction=="rtl"?Direction.RTL:Direction.LTR}measureTextSize(){for(let l of this.children)if(l instanceof LineView){let a=l.measureTextSize();if(a)return a}let e=document.createElement("div"),n,s,o;return e.className="cm-line",e.style.width="99999px",e.style.position="absolute",e.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.dom.appendChild(e);let l=clientRectsFor(e.firstChild)[0];n=e.getBoundingClientRect().height,s=l?l.width/27:7,o=l?l.height:n,e.remove()}),{lineHeight:n,charWidth:s,textHeight:o}}childCursor(e=this.length){let n=this.children.length;return n&&(e-=this.children[--n].length),new ChildCursor(this.children,e,n)}computeBlockGapDeco(){let e=[],n=this.view.viewState;for(let s=0,o=0;;o++){let l=o==n.viewports.length?null:n.viewports[o],a=l?l.from-1:this.length;if(a>s){let c=(n.lineBlockAt(a).bottom-n.lineBlockAt(s).top)/this.view.scaleY;e.push(Decoration.replace({widget:new BlockGapWidget(c),block:!0,inclusive:!0,isBlockGap:!0}).range(s,a))}if(!l)break;s=l.to+1}return Decoration.set(e)}updateDeco(){let e=1,n=this.view.state.facet(decorations).map(l=>(this.dynamicDecorationMap[e++]=typeof l=="function")?l(this.view):l),s=!1,o=this.view.state.facet(outerDecorations).map((l,a)=>{let c=typeof l=="function";return c&&(s=!0),c?l(this.view):l});for(o.length&&(this.dynamicDecorationMap[e++]=s,n.push(RangeSet.join(o))),this.decorations=[this.editContextFormatting,...n,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];en.anchor?-1:1),o;if(!s)return;!n.empty&&(o=this.coordsAt(n.anchor,n.anchor>n.head?-1:1))&&(s={left:Math.min(s.left,o.left),top:Math.min(s.top,o.top),right:Math.max(s.right,o.right),bottom:Math.max(s.bottom,o.bottom)});let l=getScrollMargins(this.view),a={left:s.left-l.left,top:s.top-l.top,right:s.right+l.right,bottom:s.bottom+l.bottom},{offsetWidth:c,offsetHeight:h}=this.view.scrollDOM;scrollRectIntoView(this.view.scrollDOM,a,n.head{se.from&&(n=!0)}),n}function groupAt(r,e,n=1){let s=r.charCategorizer(e),o=r.doc.lineAt(e),l=e-o.from;if(o.length==0)return EditorSelection.cursor(e);l==0?n=1:l==o.length&&(n=-1);let a=l,c=l;n<0?a=findClusterBreak(o.text,l,!1):c=findClusterBreak(o.text,l);let h=s(o.text.slice(a,c));for(;a>0;){let f=findClusterBreak(o.text,a,!1);if(s(o.text.slice(f,a))!=h)break;a=f}for(;cr?e.left-r:Math.max(0,r-e.right)}function getdy(r,e){return e.top>r?e.top-r:Math.max(0,r-e.bottom)}function yOverlap(r,e){return r.tope.top+1}function upTop(r,e){return er.bottom?{top:r.top,left:r.left,right:r.right,bottom:e}:r}function domPosAtCoords(r,e,n){let s,o,l,a,c=!1,h,f,u,d;for(let m=r.firstChild;m;m=m.nextSibling){let y=clientRectsFor(m);for(let b=0;b$||a==$&&l>P){s=m,o=w,l=P,a=$;let A=$?n0?b0)}P==0?n>w.bottom&&(!u||u.bottomw.top)&&(f=m,d=w):u&&yOverlap(u,w)?u=upBot(u,w.bottom):d&&yOverlap(d,w)&&(d=upTop(d,w.top))}}if(u&&u.bottom>=n?(s=h,o=u):d&&d.top<=n&&(s=f,o=d),!s)return{node:r,offset:0};let g=Math.max(o.left,Math.min(o.right,e));if(s.nodeType==3)return domPosInText(s,g,n);if(c&&s.contentEditable!="false")return domPosAtCoords(s,g,n);let O=Array.prototype.indexOf.call(r.childNodes,s)+(e>=(o.left+o.right)/2?1:0);return{node:r,offset:O}}function domPosInText(r,e,n){let s=r.nodeValue.length,o=-1,l=1e9,a=0;for(let c=0;cn?u.top-n:n-u.bottom)-1;if(u.left-1<=e&&u.right+1>=e&&d=(u.left+u.right)/2,O=g;if((browser.chrome||browser.gecko)&&textRange(r,c).getBoundingClientRect().left==u.right&&(O=!g),d<=0)return{node:r,offset:c+(O?1:0)};o=c+(O?1:0),l=d}}}return{node:r,offset:o>-1?o:a>0?r.nodeValue.length:0}}function posAtCoords(r,e,n,s=-1){var o,l;let a=r.contentDOM.getBoundingClientRect(),c=a.top+r.viewState.paddingTop,h,{docHeight:f}=r.viewState,{x:u,y:d}=e,g=d-c;if(g<0)return 0;if(g>f)return r.state.doc.length;for(let A=r.viewState.heightOracle.textHeight/2,v=!1;h=r.elementAtHeight(g),h.type!=BlockType.Text;)for(;g=s>0?h.bottom+A:h.top-A,!(g>=0&&g<=f);){if(v)return n?null:0;v=!0,s=-s}d=c+g;let O=h.from;if(Or.viewport.to)return r.viewport.to==r.state.doc.length?r.state.doc.length:n?null:posAtCoordsImprecise(r,a,h,u,d);let m=r.dom.ownerDocument,y=r.root.elementFromPoint?r.root:m,b=y.elementFromPoint(u,d);b&&!r.contentDOM.contains(b)&&(b=null),b||(u=Math.max(a.left+1,Math.min(a.right-1,u)),b=y.elementFromPoint(u,d),b&&!r.contentDOM.contains(b)&&(b=null));let w,P=-1;if(b&&((o=r.docView.nearest(b))===null||o===void 0?void 0:o.isEditable)!=!1){if(m.caretPositionFromPoint){let A=m.caretPositionFromPoint(u,d);A&&({offsetNode:w,offset:P}=A)}else if(m.caretRangeFromPoint){let A=m.caretRangeFromPoint(u,d);A&&({startContainer:w,startOffset:P}=A,(!r.contentDOM.contains(w)||browser.safari&&isSuspiciousSafariCaretResult(w,P,u)||browser.chrome&&isSuspiciousChromeCaretResult(w,P,u))&&(w=void 0))}}if(!w||!r.docView.dom.contains(w)){let A=LineView.find(r.docView,O);if(!A)return g>h.top+h.height/2?h.to:h.from;({node:w,offset:P}=domPosAtCoords(A.dom,u,d))}let $=r.docView.nearest(w);if(!$)return null;if($.isWidget&&((l=$.dom)===null||l===void 0?void 0:l.nodeType)==1){let A=$.dom.getBoundingClientRect();return e.yr.defaultLineHeight*1.5){let c=r.viewState.heightOracle.textHeight,h=Math.floor((o-n.top-(r.defaultLineHeight-c)*.5)/c);l+=h*r.viewState.heightOracle.lineLength}let a=r.state.sliceDoc(n.from,n.to);return n.from+findColumn(a,l,r.state.tabSize)}function isSuspiciousSafariCaretResult(r,e,n){let s;if(r.nodeType!=3||e!=(s=r.nodeValue.length))return!1;for(let o=r.nextSibling;o;o=o.nextSibling)if(o.nodeType!=1||o.nodeName!="BR")return!1;return textRange(r,s-1,s).getBoundingClientRect().left>n}function isSuspiciousChromeCaretResult(r,e,n){if(e!=0)return!1;for(let o=r;;){let l=o.parentNode;if(!l||l.nodeType!=1||l.firstChild!=o)return!1;if(l.classList.contains("cm-line"))break;o=l}let s=r.nodeType==1?r.getBoundingClientRect():textRange(r,0,Math.max(r.nodeValue.length,1)).getBoundingClientRect();return n-s.left>5}function blockAt(r,e){let n=r.lineBlockAt(e);if(Array.isArray(n.type)){for(let s of n.type)if(s.to>e||s.to==e&&(s.to==n.to||s.type==BlockType.Text))return s}return n}function moveToLineBoundary(r,e,n,s){let o=blockAt(r,e.head),l=!s||o.type!=BlockType.Text||!(r.lineWrapping||o.widgetLineBreaks)?null:r.coordsAtPos(e.assoc<0&&e.head>o.from?e.head-1:e.head);if(l){let a=r.dom.getBoundingClientRect(),c=r.textDirectionAt(o.from),h=r.posAtCoords({x:n==(c==Direction.LTR)?a.right-1:a.left+1,y:(l.top+l.bottom)/2});if(h!=null)return EditorSelection.cursor(h,n?-1:1)}return EditorSelection.cursor(n?o.to:o.from,n?-1:1)}function moveByChar(r,e,n,s){let o=r.state.doc.lineAt(e.head),l=r.bidiSpans(o),a=r.textDirectionAt(o.from);for(let c=e,h=null;;){let f=moveVisually(o,l,a,c,n),u=movedOver;if(!f){if(o.number==(n?r.state.doc.lines:1))return c;u=` -`,o=r.state.doc.line(o.number+(n?1:-1)),l=r.bidiSpans(o),f=r.visualLineSide(o,!n)}if(h){if(!h(u))return c}else{if(!s)return f;h=s(u)}c=f}}function byGroup(r,e,n){let s=r.state.charCategorizer(e),o=s(n);return l=>{let a=s(l);return o==CharCategory.Space&&(o=a),o==a}}function moveVertically(r,e,n,s){let o=e.head,l=n?1:-1;if(o==(n?r.state.doc.length:0))return EditorSelection.cursor(o,e.assoc);let a=e.goalColumn,c,h=r.contentDOM.getBoundingClientRect(),f=r.coordsAtPos(o,e.assoc||-1),u=r.documentTop;if(f)a==null&&(a=f.left-h.left),c=l<0?f.top:f.bottom;else{let O=r.viewState.lineBlockAt(o);a==null&&(a=Math.min(h.right-h.left,r.defaultCharacterWidth*(o-O.from))),c=(l<0?O.top:O.bottom)+u}let d=h.left+a,g=s??r.viewState.heightOracle.textHeight>>1;for(let O=0;;O+=10){let m=c+(g+O)*l,y=posAtCoords(r,{x:d,y:m},!1,l);if(mh.bottom||(l<0?yo)){let b=r.docView.coordsForChar(y),w=!b||m{if(e>l&&eo(r)),n.from,e.head>n.from?-1:1);return s==n.from?n:EditorSelection.cursor(s,snull),browser.gecko&&firefoxCopyCutHack(e.contentDOM.ownerDocument)}handleEvent(e){!eventBelongsToEditor(this.view,e)||this.ignoreDuringComposition(e)||e.type=="keydown"&&this.keydown(e)||this.runHandlers(e.type,e)}runHandlers(e,n){let s=this.handlers[e];if(s){for(let o of s.observers)o(this.view,n);for(let o of s.handlers){if(n.defaultPrevented)break;if(o(this.view,n)){n.preventDefault();break}}}}ensureHandlers(e){let n=computeHandlers(e),s=this.handlers,o=this.view.contentDOM;for(let l in n)if(l!="scroll"){let a=!n[l].handlers.length,c=s[l];c&&a!=!c.handlers.length&&(o.removeEventListener(l,this.handleEvent),c=null),c||o.addEventListener(l,this.handleEvent,{passive:a})}for(let l in s)l!="scroll"&&!n[l]&&o.removeEventListener(l,this.handleEvent);this.handlers=n}keydown(e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),e.keyCode==9&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&e.keyCode!=27&&modifierCodes.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),browser.android&&browser.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;let n;return browser.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&((n=PendingKeys.find(s=>s.keyCode==e.keyCode))&&!e.ctrlKey||EmacsyPendingKeys.indexOf(e.key)>-1&&e.ctrlKey&&!e.shiftKey)?(this.pendingIOSKey=n||e,setTimeout(()=>this.flushIOSKey(),250),!0):(e.keyCode!=229&&this.view.observer.forceFlush(),!1)}flushIOSKey(e){let n=this.pendingIOSKey;return!n||n.key=="Enter"&&e&&e.from0?!0:browser.safari&&!browser.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100?(this.compositionPendingKey=!1,!0):!1:!1}startMouseSelection(e){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=e}update(e){this.view.observer.update(e),this.mouseSelection&&this.mouseSelection.update(e),this.draggedContent&&e.docChanged&&(this.draggedContent=this.draggedContent.map(e.changes)),e.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}}function bindHandler(r,e){return(n,s)=>{try{return e.call(r,s,n)}catch(o){logException(n.state,o)}}}function computeHandlers(r){let e=Object.create(null);function n(s){return e[s]||(e[s]={observers:[],handlers:[]})}for(let s of r){let o=s.spec;if(o&&o.domEventHandlers)for(let l in o.domEventHandlers){let a=o.domEventHandlers[l];a&&n(l).handlers.push(bindHandler(s.value,a))}if(o&&o.domEventObservers)for(let l in o.domEventObservers){let a=o.domEventObservers[l];a&&n(l).observers.push(bindHandler(s.value,a))}}for(let s in handlers)n(s).handlers.push(handlers[s]);for(let s in observers)n(s).observers.push(observers[s]);return e}const PendingKeys=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],EmacsyPendingKeys="dthko",modifierCodes=[16,17,18,20,91,92,224,225],dragScrollMargin=6;function dragScrollSpeed(r){return Math.max(0,r)*.7+8}function dist(r,e){return Math.max(Math.abs(r.clientX-e.clientX),Math.abs(r.clientY-e.clientY))}class MouseSelection{constructor(e,n,s,o){this.view=e,this.startEvent=n,this.style=s,this.mustSelect=o,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=n,this.scrollParent=scrollableParent(e.contentDOM),this.atoms=e.state.facet(atomicRanges).map(a=>a(e));let l=e.contentDOM.ownerDocument;l.addEventListener("mousemove",this.move=this.move.bind(this)),l.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=n.shiftKey,this.multiple=e.state.facet(EditorState.allowMultipleSelections)&&addsSelectionRange(e,n),this.dragging=isInPrimarySelection(e,n)&&getClickType(n)==1?null:!1}start(e){this.dragging===!1&&this.select(e)}move(e){var n;if(e.buttons==0)return this.destroy();if(this.dragging||this.dragging==null&&dist(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let s=0,o=0,l=((n=this.scrollParent)===null||n===void 0?void 0:n.getBoundingClientRect())||{left:0,top:0,right:this.view.win.innerWidth,bottom:this.view.win.innerHeight},a=getScrollMargins(this.view);e.clientX-a.left<=l.left+dragScrollMargin?s=-dragScrollSpeed(l.left-e.clientX):e.clientX+a.right>=l.right-dragScrollMargin&&(s=dragScrollSpeed(e.clientX-l.right)),e.clientY-a.top<=l.top+dragScrollMargin?o=-dragScrollSpeed(l.top-e.clientY):e.clientY+a.bottom>=l.bottom-dragScrollMargin&&(o=dragScrollSpeed(e.clientY-l.bottom)),this.setScrollSpeed(s,o)}up(e){this.dragging==null&&this.select(this.lastEvent),this.dragging||e.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let e=this.view.contentDOM.ownerDocument;e.removeEventListener("mousemove",this.move),e.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(e,n){this.scrollSpeed={x:e,y:n},e||n?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){this.scrollParent?(this.scrollParent.scrollLeft+=this.scrollSpeed.x,this.scrollParent.scrollTop+=this.scrollSpeed.y):this.view.win.scrollBy(this.scrollSpeed.x,this.scrollSpeed.y),this.dragging===!1&&this.select(this.lastEvent)}skipAtoms(e){let n=null;for(let s=0;sn.isUserEvent("input.type"))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}}function addsSelectionRange(r,e){let n=r.state.facet(clickAddsSelectionRange);return n.length?n[0](e):browser.mac?e.metaKey:e.ctrlKey}function dragMovesSelection(r,e){let n=r.state.facet(dragMovesSelection$1);return n.length?n[0](e):browser.mac?!e.altKey:!e.ctrlKey}function isInPrimarySelection(r,e){let{main:n}=r.state.selection;if(n.empty)return!1;let s=getSelection(r.root);if(!s||s.rangeCount==0)return!0;let o=s.getRangeAt(0).getClientRects();for(let l=0;l=e.clientX&&a.top<=e.clientY&&a.bottom>=e.clientY)return!0}return!1}function eventBelongsToEditor(r,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let n=e.target,s;n!=r.contentDOM;n=n.parentNode)if(!n||n.nodeType==11||(s=ContentView.get(n))&&s.ignoreEvent(e))return!1;return!0}const handlers=Object.create(null),observers=Object.create(null),brokenClipboardAPI=browser.ie&&browser.ie_version<15||browser.ios&&browser.webkit_version<604;function capturePaste(r){let e=r.dom.parentNode;if(!e)return;let n=e.appendChild(document.createElement("textarea"));n.style.cssText="position: fixed; left: -10000px; top: 10px",n.focus(),setTimeout(()=>{r.focus(),n.remove(),doPaste(r,n.value)},50)}function doPaste(r,e){let{state:n}=r,s,o=1,l=n.toText(e),a=l.lines==n.selection.ranges.length;if(lastLinewiseCopy!=null&&n.selection.ranges.every(h=>h.empty)&&lastLinewiseCopy==l.toString()){let h=-1;s=n.changeByRange(f=>{let u=n.doc.lineAt(f.from);if(u.from==h)return{range:f};h=u.from;let d=n.toText((a?l.line(o++).text:e)+n.lineBreak);return{changes:{from:u.from,insert:d},range:EditorSelection.cursor(f.from+d.length)}})}else a?s=n.changeByRange(h=>{let f=l.line(o++);return{changes:{from:h.from,to:h.to,insert:f.text},range:EditorSelection.cursor(h.from+f.length)}}):s=n.replaceSelection(l);r.dispatch(s,{userEvent:"input.paste",scrollIntoView:!0})}observers.scroll=r=>{r.inputState.lastScrollTop=r.scrollDOM.scrollTop,r.inputState.lastScrollLeft=r.scrollDOM.scrollLeft};handlers.keydown=(r,e)=>(r.inputState.setSelectionOrigin("select"),e.keyCode==27&&r.inputState.tabFocusMode!=0&&(r.inputState.tabFocusMode=Date.now()+2e3),!1);observers.touchstart=(r,e)=>{r.inputState.lastTouchTime=Date.now(),r.inputState.setSelectionOrigin("select.pointer")};observers.touchmove=r=>{r.inputState.setSelectionOrigin("select.pointer")};handlers.mousedown=(r,e)=>{if(r.observer.flush(),r.inputState.lastTouchTime>Date.now()-2e3)return!1;let n=null;for(let s of r.state.facet(mouseSelectionStyle))if(n=s(r,e),n)break;if(!n&&e.button==0&&(n=basicMouseSelection(r,e)),n){let s=!r.hasFocus;r.inputState.startMouseSelection(new MouseSelection(r,e,n,s)),s&&r.observer.ignore(()=>{focusPreventScroll(r.contentDOM);let l=r.root.activeElement;l&&!l.contains(r.contentDOM)&&l.blur()});let o=r.inputState.mouseSelection;if(o)return o.start(e),o.dragging===!1}return!1};function rangeForClick(r,e,n,s){if(s==1)return EditorSelection.cursor(e,n);if(s==2)return groupAt(r.state,e,n);{let o=LineView.find(r.docView,e),l=r.state.doc.lineAt(o?o.posAtEnd:e),a=o?o.posAtStart:l.from,c=o?o.posAtEnd:l.to;return cr>=e.top&&r<=e.bottom,inside=(r,e,n)=>insideY(e,n)&&r>=n.left&&r<=n.right;function findPositionSide(r,e,n,s){let o=LineView.find(r.docView,e);if(!o)return 1;let l=e-o.posAtStart;if(l==0)return 1;if(l==o.length)return-1;let a=o.coordsAt(l,-1);if(a&&inside(n,s,a))return-1;let c=o.coordsAt(l,1);return c&&inside(n,s,c)?1:a&&insideY(s,a)?-1:1}function queryPos(r,e){let n=r.posAtCoords({x:e.clientX,y:e.clientY},!1);return{pos:n,bias:findPositionSide(r,n,e.clientX,e.clientY)}}const BadMouseDetail=browser.ie&&browser.ie_version<=11;let lastMouseDown=null,lastMouseDownCount=0,lastMouseDownTime=0;function getClickType(r){if(!BadMouseDetail)return r.detail;let e=lastMouseDown,n=lastMouseDownTime;return lastMouseDown=r,lastMouseDownTime=Date.now(),lastMouseDownCount=!e||n>Date.now()-400&&Math.abs(e.clientX-r.clientX)<2&&Math.abs(e.clientY-r.clientY)<2?(lastMouseDownCount+1)%3:1}function basicMouseSelection(r,e){let n=queryPos(r,e),s=getClickType(e),o=r.state.selection;return{update(l){l.docChanged&&(n.pos=l.changes.mapPos(n.pos),o=o.map(l.changes))},get(l,a,c){let h=queryPos(r,l),f,u=rangeForClick(r,h.pos,h.bias,s);if(n.pos!=h.pos&&!a){let d=rangeForClick(r,n.pos,n.bias,s),g=Math.min(d.from,u.from),O=Math.max(d.to,u.to);u=g1&&(f=removeRangeAround(o,h.pos))?f:c?o.addRange(u):EditorSelection.create([u])}}}function removeRangeAround(r,e){for(let n=0;n=e)return EditorSelection.create(r.ranges.slice(0,n).concat(r.ranges.slice(n+1)),r.mainIndex==n?0:r.mainIndex-(r.mainIndex>n?1:0))}return null}handlers.dragstart=(r,e)=>{let{selection:{main:n}}=r.state;if(e.target.draggable){let o=r.docView.nearest(e.target);if(o&&o.isWidget){let l=o.posAtStart,a=l+o.length;(l>=n.to||a<=n.from)&&(n=EditorSelection.range(l,a))}}let{inputState:s}=r;return s.mouseSelection&&(s.mouseSelection.dragging=!0),s.draggedContent=n,e.dataTransfer&&(e.dataTransfer.setData("Text",r.state.sliceDoc(n.from,n.to)),e.dataTransfer.effectAllowed="copyMove"),!1};handlers.dragend=r=>(r.inputState.draggedContent=null,!1);function dropText(r,e,n,s){if(!n)return;let o=r.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:l}=r.inputState,a=s&&l&&dragMovesSelection(r,e)?{from:l.from,to:l.to}:null,c={from:o,insert:n},h=r.state.changes(a?[a,c]:c);r.focus(),r.dispatch({changes:h,selection:{anchor:h.mapPos(o,-1),head:h.mapPos(o,1)},userEvent:a?"move.drop":"input.drop"}),r.inputState.draggedContent=null}handlers.drop=(r,e)=>{if(!e.dataTransfer)return!1;if(r.state.readOnly)return!0;let n=e.dataTransfer.files;if(n&&n.length){let s=Array(n.length),o=0,l=()=>{++o==n.length&&dropText(r,e,s.filter(a=>a!=null).join(r.state.lineBreak),!1)};for(let a=0;a{/[\x00-\x08\x0e-\x1f]{2}/.test(c.result)||(s[a]=c.result),l()},c.readAsText(n[a])}return!0}else{let s=e.dataTransfer.getData("Text");if(s)return dropText(r,e,s,!0),!0}return!1};handlers.paste=(r,e)=>{if(r.state.readOnly)return!0;r.observer.flush();let n=brokenClipboardAPI?null:e.clipboardData;return n?(doPaste(r,n.getData("text/plain")||n.getData("text/uri-list")),!0):(capturePaste(r),!1)};function captureCopy(r,e){let n=r.dom.parentNode;if(!n)return;let s=n.appendChild(document.createElement("textarea"));s.style.cssText="position: fixed; left: -10000px; top: 10px",s.value=e,s.focus(),s.selectionEnd=e.length,s.selectionStart=0,setTimeout(()=>{s.remove(),r.focus()},50)}function copiedRange(r){let e=[],n=[],s=!1;for(let o of r.selection.ranges)o.empty||(e.push(r.sliceDoc(o.from,o.to)),n.push(o));if(!e.length){let o=-1;for(let{from:l}of r.selection.ranges){let a=r.doc.lineAt(l);a.number>o&&(e.push(a.text),n.push({from:a.from,to:Math.min(r.doc.length,a.to+1)})),o=a.number}s=!0}return{text:e.join(r.lineBreak),ranges:n,linewise:s}}let lastLinewiseCopy=null;handlers.copy=handlers.cut=(r,e)=>{let{text:n,ranges:s,linewise:o}=copiedRange(r.state);if(!n&&!o)return!1;lastLinewiseCopy=o?n:null,e.type=="cut"&&!r.state.readOnly&&r.dispatch({changes:s,scrollIntoView:!0,userEvent:"delete.cut"});let l=brokenClipboardAPI?null:e.clipboardData;return l?(l.clearData(),l.setData("text/plain",n),!0):(captureCopy(r,n),!1)};const isFocusChange=Annotation.define();function focusChangeTransaction(r,e){let n=[];for(let s of r.facet(focusChangeEffect)){let o=s(r,e);o&&n.push(o)}return n?r.update({effects:n,annotations:isFocusChange.of(!0)}):null}function updateForFocusChange(r){setTimeout(()=>{let e=r.hasFocus;if(e!=r.inputState.notifiedFocused){let n=focusChangeTransaction(r.state,e);n?r.dispatch(n):r.update([])}},10)}observers.focus=r=>{r.inputState.lastFocusTime=Date.now(),!r.scrollDOM.scrollTop&&(r.inputState.lastScrollTop||r.inputState.lastScrollLeft)&&(r.scrollDOM.scrollTop=r.inputState.lastScrollTop,r.scrollDOM.scrollLeft=r.inputState.lastScrollLeft),updateForFocusChange(r)};observers.blur=r=>{r.observer.clearSelectionRange(),updateForFocusChange(r)};observers.compositionstart=observers.compositionupdate=r=>{r.observer.editContext||(r.inputState.compositionFirstChange==null&&(r.inputState.compositionFirstChange=!0),r.inputState.composing<0&&(r.inputState.composing=0))};observers.compositionend=r=>{r.observer.editContext||(r.inputState.composing=-1,r.inputState.compositionEndedAt=Date.now(),r.inputState.compositionPendingKey=!0,r.inputState.compositionPendingChange=r.observer.pendingRecords().length>0,r.inputState.compositionFirstChange=null,browser.chrome&&browser.android?r.observer.flushSoon():r.inputState.compositionPendingChange?Promise.resolve().then(()=>r.observer.flush()):setTimeout(()=>{r.inputState.composing<0&&r.docView.hasComposition&&r.update([])},50))};observers.contextmenu=r=>{r.inputState.lastContextMenu=Date.now()};handlers.beforeinput=(r,e)=>{var n;let s;if(browser.chrome&&browser.android&&(s=PendingKeys.find(o=>o.inputType==e.inputType))&&(r.observer.delayAndroidKey(s.key,s.keyCode),s.key=="Backspace"||s.key=="Delete")){let o=((n=window.visualViewport)===null||n===void 0?void 0:n.height)||0;setTimeout(()=>{var l;(((l=window.visualViewport)===null||l===void 0?void 0:l.height)||0)>o+10&&r.hasFocus&&(r.contentDOM.blur(),r.focus())},100)}return browser.ios&&e.inputType=="deleteContentForward"&&r.observer.flushSoon(),browser.safari&&e.inputType=="insertText"&&r.inputState.composing>=0&&setTimeout(()=>observers.compositionend(r,e),20),!1};const appliedFirefoxHack=new Set;function firefoxCopyCutHack(r){appliedFirefoxHack.has(r)||(appliedFirefoxHack.add(r),r.addEventListener("copy",()=>{}),r.addEventListener("cut",()=>{}))}const wrappingWhiteSpace=["pre-wrap","normal","pre-line","break-spaces"];class HeightOracle{constructor(e){this.lineWrapping=e,this.doc=Text.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30,this.heightChanged=!1}heightForGap(e,n){let s=this.doc.lineAt(n).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(s+=Math.max(0,Math.ceil((n-e-s*this.lineLength*.5)/this.lineLength))),this.lineHeight*s}heightForLine(e){return this.lineWrapping?(1+Math.max(0,Math.ceil((e-this.lineLength)/(this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return wrappingWhiteSpace.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let n=!1;for(let s=0;s-1,h=Math.round(n)!=Math.round(this.lineHeight)||this.lineWrapping!=c;if(this.lineWrapping=c,this.lineHeight=n,this.charWidth=s,this.textHeight=o,this.lineLength=l,h){this.heightSamples={};for(let f=0;f0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e,n){this.height!=n&&(Math.abs(this.height-n)>Epsilon&&(e.heightChanged=!0),this.height=n)}replace(e,n,s){return HeightMap.of(s)}decomposeLeft(e,n){n.push(this)}decomposeRight(e,n){n.push(this)}applyChanges(e,n,s,o){let l=this,a=s.doc;for(let c=o.length-1;c>=0;c--){let{fromA:h,toA:f,fromB:u,toB:d}=o[c],g=l.lineAt(h,QueryType$1.ByPosNoHeight,s.setDoc(n),0,0),O=g.to>=f?g:l.lineAt(f,QueryType$1.ByPosNoHeight,s,0,0);for(d+=O.to-f,f=O.to;c>0&&g.from<=o[c-1].toA;)h=o[c-1].fromA,u=o[c-1].fromB,c--,hl*2){let c=e[n-1];c.break?e.splice(--n,1,c.left,null,c.right):e.splice(--n,1,c.left,c.right),s+=1+c.break,o-=c.size}else if(l>o*2){let c=e[s];c.break?e.splice(s,1,c.left,null,c.right):e.splice(s,1,c.left,c.right),s+=2+c.break,l-=c.size}else break;else if(o=l&&a(this.blockAt(0,s,o,l))}updateHeight(e,n=0,s=!1,o){return o&&o.from<=n&&o.more&&this.setHeight(e,o.heights[o.index++]),this.outdated=!1,this}toString(){return`block(${this.length})`}}class HeightMapText extends HeightMapBlock{constructor(e,n){super(e,n,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0}blockAt(e,n,s,o){return new BlockInfo(o,this.length,s,this.height,this.breaks)}replace(e,n,s){let o=s[0];return s.length==1&&(o instanceof HeightMapText||o instanceof HeightMapGap&&o.flags&4)&&Math.abs(this.length-o.length)<10?(o instanceof HeightMapGap?o=new HeightMapText(o.length,this.height):o.height=this.height,this.outdated||(o.outdated=!1),o):HeightMap.of(s)}updateHeight(e,n=0,s=!1,o){return o&&o.from<=n&&o.more?this.setHeight(e,o.heights[o.index++]):(s||this.outdated)&&this.setHeight(e,Math.max(this.widgetHeight,e.heightForLine(this.length-this.collapsed))+this.breaks*e.lineHeight),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}}class HeightMapGap extends HeightMap{constructor(e){super(e,0)}heightMetrics(e,n){let s=e.doc.lineAt(n).number,o=e.doc.lineAt(n+this.length).number,l=o-s+1,a,c=0;if(e.lineWrapping){let h=Math.min(this.height,e.lineHeight*l);a=h/l,this.length>l+1&&(c=(this.height-h)/(this.length-l-1))}else a=this.height/l;return{firstLine:s,lastLine:o,perLine:a,perChar:c}}blockAt(e,n,s,o){let{firstLine:l,lastLine:a,perLine:c,perChar:h}=this.heightMetrics(n,o);if(n.lineWrapping){let f=o+(e0){let l=s[s.length-1];l instanceof HeightMapGap?s[s.length-1]=new HeightMapGap(l.length+o):s.push(null,new HeightMapGap(o-1))}if(e>0){let l=s[0];l instanceof HeightMapGap?s[0]=new HeightMapGap(e+l.length):s.unshift(new HeightMapGap(e-1),null)}return HeightMap.of(s)}decomposeLeft(e,n){n.push(new HeightMapGap(e-1),null)}decomposeRight(e,n){n.push(null,new HeightMapGap(this.length-e-1))}updateHeight(e,n=0,s=!1,o){let l=n+this.length;if(o&&o.from<=n+this.length&&o.more){let a=[],c=Math.max(n,o.from),h=-1;for(o.from>n&&a.push(new HeightMapGap(o.from-n-1).updateHeight(e,n));c<=l&&o.more;){let u=e.doc.lineAt(c).length;a.length&&a.push(null);let d=o.heights[o.index++];h==-1?h=d:Math.abs(d-h)>=Epsilon&&(h=-2);let g=new HeightMapText(u,d);g.outdated=!1,a.push(g),c+=u+1}c<=l&&a.push(null,new HeightMapGap(l-c).updateHeight(e,c));let f=HeightMap.of(a);return(h<0||Math.abs(f.height-this.height)>=Epsilon||Math.abs(h-this.heightMetrics(e,n).perLine)>=Epsilon)&&(e.heightChanged=!0),f}else(s||this.outdated)&&(this.setHeight(e,e.heightForGap(n,n+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}}class HeightMapBranch extends HeightMap{constructor(e,n,s){super(e.length+n+s.length,e.height+s.height,n|(e.outdated||s.outdated?2:0)),this.left=e,this.right=s,this.size=e.size+s.size}get break(){return this.flags&1}blockAt(e,n,s,o){let l=s+this.left.height;return ec))return f;let u=n==QueryType$1.ByPosNoHeight?QueryType$1.ByPosNoHeight:QueryType$1.ByPos;return h?f.join(this.right.lineAt(c,u,s,a,c)):this.left.lineAt(c,u,s,o,l).join(f)}forEachLine(e,n,s,o,l,a){let c=o+this.left.height,h=l+this.left.length+this.break;if(this.break)e=h&&this.right.forEachLine(e,n,s,c,h,a);else{let f=this.lineAt(h,QueryType$1.ByPos,s,o,l);e=e&&f.from<=n&&a(f),n>f.to&&this.right.forEachLine(f.to+1,n,s,c,h,a)}}replace(e,n,s){let o=this.left.length+this.break;if(nthis.left.length)return this.balanced(this.left,this.right.replace(e-o,n-o,s));let l=[];e>0&&this.decomposeLeft(e,l);let a=l.length;for(let c of s)l.push(c);if(e>0&&mergeGaps(l,a-1),n=s&&n.push(null)),e>s&&this.right.decomposeLeft(e-s,n)}decomposeRight(e,n){let s=this.left.length,o=s+this.break;if(e>=o)return this.right.decomposeRight(e-o,n);e2*n.size||n.size>2*e.size?HeightMap.of(this.break?[e,null,n]:[e,n]):(this.left=e,this.right=n,this.height=e.height+n.height,this.outdated=e.outdated||n.outdated,this.size=e.size+n.size,this.length=e.length+this.break+n.length,this)}updateHeight(e,n=0,s=!1,o){let{left:l,right:a}=this,c=n+l.length+this.break,h=null;return o&&o.from<=n+l.length&&o.more?h=l=l.updateHeight(e,n,s,o):l.updateHeight(e,n,s),o&&o.from<=c+a.length&&o.more?h=a=a.updateHeight(e,c,s,o):a.updateHeight(e,c,s),h?this.balanced(l,a):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function mergeGaps(r,e){let n,s;r[e]==null&&(n=r[e-1])instanceof HeightMapGap&&(s=r[e+1])instanceof HeightMapGap&&r.splice(e-1,3,new HeightMapGap(n.length+1+s.length))}const relevantWidgetHeight=5;class NodeBuilder{constructor(e,n){this.pos=e,this.oracle=n,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=e}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(e,n){if(this.lineStart>-1){let s=Math.min(n,this.lineEnd),o=this.nodes[this.nodes.length-1];o instanceof HeightMapText?o.length+=s-this.pos:(s>this.pos||!this.isCovered)&&this.nodes.push(new HeightMapText(s-this.pos,-1)),this.writtenTo=s,n>s&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=n}point(e,n,s){if(e=relevantWidgetHeight)&&this.addLineDeco(o,l,a)}else n>e&&this.span(e,n);this.lineEnd>-1&&this.lineEnd-1)return;let{from:e,to:n}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=n,this.writtenToe&&this.nodes.push(new HeightMapText(this.pos-e,-1)),this.writtenTo=this.pos}blankContent(e,n){let s=new HeightMapGap(n-e);return this.oracle.doc.lineAt(e).to==n&&(s.flags|=4),s}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof HeightMapText)return e;let n=new HeightMapText(0,-1);return this.nodes.push(n),n}addBlock(e){this.enterLine();let n=e.deco;n&&n.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,n&&n.endSide>0&&(this.covering=e)}addLineDeco(e,n,s){let o=this.ensureLine();o.length+=s,o.collapsed+=s,o.widgetHeight=Math.max(o.widgetHeight,e),o.breaks+=n,this.writtenTo=this.pos=this.pos+s}finish(e){let n=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(n instanceof HeightMapText)&&!this.isCovered?this.nodes.push(new HeightMapText(0,-1)):(this.writtenTou.clientHeight||u.scrollWidth>u.clientWidth)&&d.overflow!="visible"){let g=u.getBoundingClientRect();l=Math.max(l,g.left),a=Math.min(a,g.right),c=Math.max(c,g.top),h=f==r.parentNode?g.bottom:Math.min(h,g.bottom)}f=d.position=="absolute"||d.position=="fixed"?u.offsetParent:u.parentNode}else if(f.nodeType==11)f=f.host;else break;return{left:l-n.left,right:Math.max(l,a)-n.left,top:c-(n.top+e),bottom:Math.max(c,h)-(n.top+e)}}function fullPixelRange(r,e){let n=r.getBoundingClientRect();return{left:0,right:n.right-n.left,top:e,bottom:n.bottom-(n.top+e)}}class LineGap{constructor(e,n,s){this.from=e,this.to=n,this.size=s}static same(e,n){if(e.length!=n.length)return!1;for(let s=0;stypeof s!="function"&&s.class=="cm-lineWrapping");this.heightOracle=new HeightOracle(n),this.stateDeco=e.facet(decorations).filter(s=>typeof s!="function"),this.heightMap=HeightMap.empty().applyChanges(this.stateDeco,Text.empty,this.heightOracle.setDoc(e.doc),[new ChangedRange(0,0,0,e.doc.length)]);for(let s=0;s<2&&(this.viewport=this.getViewport(0,null),!!this.updateForViewport());s++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=Decoration.set(this.lineGaps.map(s=>s.draw(this,!1))),this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:n}=this.state.selection;for(let s=0;s<=1;s++){let o=s?n.head:n.anchor;if(!e.some(({from:l,to:a})=>o>=l&&o<=a)){let{from:l,to:a}=this.lineBlockAt(o);e.push(new Viewport(l,a))}}return this.viewports=e.sort((s,o)=>s.from-o.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?IdScaler:new BigScaler(this.heightOracle,this.heightMap,this.viewports),e.eq(this.scaler)?0:2}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,e=>{this.viewportLines.push(scaleBlock(e,this.scaler))})}update(e,n=null){this.state=e.state;let s=this.stateDeco;this.stateDeco=this.state.facet(decorations).filter(u=>typeof u!="function");let o=e.changedRanges,l=ChangedRange.extendWithRanges(o,heightRelevantDecoChanges(s,this.stateDeco,e?e.changes:ChangeSet.empty(this.state.doc.length))),a=this.heightMap.height,c=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollTop);this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),l),this.heightMap.height!=a&&(e.flags|=2),c?(this.scrollAnchorPos=e.changes.mapPos(c.from,-1),this.scrollAnchorHeight=c.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=this.heightMap.height);let h=l.length?this.mapViewport(this.viewport,e.changes):this.viewport;(n&&(n.range.headh.to)||!this.viewportIsAppropriate(h))&&(h=this.getViewport(0,n));let f=h.from!=this.viewport.from||h.to!=this.viewport.to;this.viewport=h,e.flags|=this.updateForViewport(),(f||!e.changes.empty||e.flags&2)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,e.changes))),e.flags|=this.computeVisibleRanges(),n&&(this.scrollTarget=n),!this.mustEnforceCursorAssoc&&e.selectionSet&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(nativeSelectionHidden)&&(this.mustEnforceCursorAssoc=!0)}measure(e){let n=e.contentDOM,s=window.getComputedStyle(n),o=this.heightOracle,l=s.whiteSpace;this.defaultTextDirection=s.direction=="rtl"?Direction.RTL:Direction.LTR;let a=this.heightOracle.mustRefreshForWrapping(l),c=n.getBoundingClientRect(),h=a||this.mustMeasureContent||this.contentDOMHeight!=c.height;this.contentDOMHeight=c.height,this.mustMeasureContent=!1;let f=0,u=0;if(c.width&&c.height){let{scaleX:A,scaleY:v}=getScale(n,c);(A>.005&&Math.abs(this.scaleX-A)>.005||v>.005&&Math.abs(this.scaleY-v)>.005)&&(this.scaleX=A,this.scaleY=v,f|=8,a=h=!0)}let d=(parseInt(s.paddingTop)||0)*this.scaleY,g=(parseInt(s.paddingBottom)||0)*this.scaleY;(this.paddingTop!=d||this.paddingBottom!=g)&&(this.paddingTop=d,this.paddingBottom=g,f|=10),this.editorWidth!=e.scrollDOM.clientWidth&&(o.lineWrapping&&(h=!0),this.editorWidth=e.scrollDOM.clientWidth,f|=8);let O=e.scrollDOM.scrollTop*this.scaleY;this.scrollTop!=O&&(this.scrollAnchorHeight=-1,this.scrollTop=O),this.scrolledToBottom=isScrolledToBottom(e.scrollDOM);let m=(this.printing?fullPixelRange:visiblePixelRange)(n,this.paddingTop),y=m.top-this.pixelViewport.top,b=m.bottom-this.pixelViewport.bottom;this.pixelViewport=m;let w=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(w!=this.inView&&(this.inView=w,w&&(h=!0)),!this.inView&&!this.scrollTarget)return 0;let P=c.width;if((this.contentDOMWidth!=P||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=c.width,this.editorHeight=e.scrollDOM.clientHeight,f|=8),h){let A=e.docView.measureVisibleLineHeights(this.viewport);if(o.mustRefreshForHeights(A)&&(a=!0),a||o.lineWrapping&&Math.abs(P-this.contentDOMWidth)>o.charWidth){let{lineHeight:v,charWidth:Q,textHeight:_}=e.docView.measureTextSize();a=v>0&&o.refresh(l,v,Q,_,P/Q,A),a&&(e.docView.minWidth=0,f|=8)}y>0&&b>0?u=Math.max(y,b):y<0&&b<0&&(u=Math.min(y,b)),o.heightChanged=!1;for(let v of this.viewports){let Q=v.from==this.viewport.from?A:e.docView.measureVisibleLineHeights(v);this.heightMap=(a?HeightMap.empty().applyChanges(this.stateDeco,Text.empty,this.heightOracle,[new ChangedRange(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(o,0,a,new MeasuredHeights(v.from,Q))}o.heightChanged&&(f|=2)}let $=!this.viewportIsAppropriate(this.viewport,u)||this.scrollTarget&&(this.scrollTarget.range.headthis.viewport.to);return $&&(f&2&&(f|=this.updateScaler()),this.viewport=this.getViewport(u,this.scrollTarget),f|=this.updateForViewport()),(f&2||$)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(a?[]:this.lineGaps,e)),f|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),f}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,n){let s=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),o=this.heightMap,l=this.heightOracle,{visibleTop:a,visibleBottom:c}=this,h=new Viewport(o.lineAt(a-s*1e3,QueryType$1.ByHeight,l,0,0).from,o.lineAt(c+(1-s)*1e3,QueryType$1.ByHeight,l,0,0).to);if(n){let{head:f}=n.range;if(fh.to){let u=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),d=o.lineAt(f,QueryType$1.ByPos,l,0,0),g;n.y=="center"?g=(d.top+d.bottom)/2-u/2:n.y=="start"||n.y=="nearest"&&f=c+Math.max(10,Math.min(s,250)))&&o>a-2*1e3&&l>1,a=o<<1;if(this.defaultTextDirection!=Direction.LTR&&!s)return[];let c=[],h=(u,d,g,O)=>{if(d-uu&&ww.from>=g.from&&w.to<=g.to&&Math.abs(w.from-u)w.fromP));if(!b){if(dw.from<=d&&w.to>=d)){let w=n.moveToLineBoundary(EditorSelection.cursor(d),!1,!0).head;w>u&&(d=w)}b=new LineGap(u,d,this.gapSize(g,u,d,O))}c.push(b)},f=u=>{if(u.lengthu.from&&h(u.from,O,u,d),mn.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(){let e=this.stateDeco;this.lineGaps.length&&(e=e.concat(this.lineGapDeco));let n=[];RangeSet.spans(e,this.viewport.from,this.viewport.to,{span(o,l){n.push({from:o,to:l})},point(){}},20);let s=n.length!=this.visibleRanges.length||this.visibleRanges.some((o,l)=>o.from!=n[l].from||o.to!=n[l].to);return this.visibleRanges=n,s?4:0}lineBlockAt(e){return e>=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(n=>n.from<=e&&n.to>=e)||scaleBlock(this.heightMap.lineAt(e,QueryType$1.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(e){return e>=this.viewportLines[0].top&&e<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find(n=>n.top<=e&&n.bottom>=e)||scaleBlock(this.heightMap.lineAt(this.scaler.fromDOM(e),QueryType$1.ByHeight,this.heightOracle,0,0),this.scaler)}scrollAnchorAt(e){let n=this.lineBlockAtHeight(e+8);return n.from>=this.viewport.from||this.viewportLines[0].top-e>200?n:this.viewportLines[0]}elementAtHeight(e){return scaleBlock(this.heightMap.blockAt(this.scaler.fromDOM(e),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}}class Viewport{constructor(e,n){this.from=e,this.to=n}}function lineStructure(r,e,n){let s=[],o=r,l=0;return RangeSet.spans(n,r,e,{span(){},point(a,c){a>o&&(s.push({from:o,to:a}),l+=a-o),o=c}},20),o=1)return e[e.length-1].to;let s=Math.floor(r*n);for(let o=0;;o++){let{from:l,to:a}=e[o],c=a-l;if(s<=c)return l+s;s-=c}}function findFraction(r,e){let n=0;for(let{from:s,to:o}of r.ranges){if(e<=o){n+=e-s;break}n+=o-s}return n/r.total}function find(r,e){for(let n of r)if(e(n))return n}const IdScaler={toDOM(r){return r},fromDOM(r){return r},scale:1,eq(r){return r==this}};class BigScaler{constructor(e,n,s){let o=0,l=0,a=0;this.viewports=s.map(({from:c,to:h})=>{let f=n.lineAt(c,QueryType$1.ByPos,e,0,0).top,u=n.lineAt(h,QueryType$1.ByPos,e,0,0).bottom;return o+=u-f,{from:c,to:h,top:f,bottom:u,domTop:0,domBottom:0}}),this.scale=(7e6-o)/(n.height-o);for(let c of this.viewports)c.domTop=a+(c.top-l)*this.scale,a=c.domBottom=c.domTop+(c.bottom-c.top),l=c.bottom}toDOM(e){for(let n=0,s=0,o=0;;n++){let l=nn.from==e.viewports[s].from&&n.to==e.viewports[s].to):!1}}function scaleBlock(r,e){if(e.scale==1)return r;let n=e.toDOM(r.top),s=e.toDOM(r.bottom);return new BlockInfo(r.from,r.length,n,s-n,Array.isArray(r._content)?r._content.map(o=>scaleBlock(o,e)):r._content)}const theme=Facet.define({combine:r=>r.join(" ")}),darkTheme=Facet.define({combine:r=>r.indexOf(!0)>-1}),baseThemeID=StyleModule.newName(),baseLightID=StyleModule.newName(),baseDarkID=StyleModule.newName(),lightDarkIDs={"&light":"."+baseLightID,"&dark":"."+baseDarkID};function buildTheme(r,e,n){return new StyleModule(e,{finish(s){return/&/.test(s)?s.replace(/&\w*/,o=>{if(o=="&")return r;if(!n||!n[o])throw new RangeError(`Unsupported selector: ${o}`);return n[o]}):r+" "+s}})}const baseTheme$1$2=buildTheme("."+baseThemeID,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#444"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",insetInlineStart:0,zIndex:200},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",borderRight:"1px solid #ddd"},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top"},".cm-highlightSpace:before":{content:"attr(data-display)",position:"absolute",pointerEvents:"none",color:"#888"},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,')`,backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},lightDarkIDs),LineBreakPlaceholder="￿";class DOMReader{constructor(e,n){this.points=e,this.text="",this.lineSeparator=n.facet(EditorState.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=LineBreakPlaceholder}readRange(e,n){if(!e)return this;let s=e.parentNode;for(let o=e;;){this.findPointBefore(s,o);let l=this.text.length;this.readNode(o);let a=o.nextSibling;if(a==n)break;let c=ContentView.get(o),h=ContentView.get(a);(c&&h?c.breakAfter:(c?c.breakAfter:isBlockElement(o))||isBlockElement(a)&&(o.nodeName!="BR"||o.cmIgnore)&&this.text.length>l)&&this.lineBreak(),o=a}return this.findPointBefore(s,n),this}readTextNode(e){let n=e.nodeValue;for(let s of this.points)s.node==e&&(s.pos=this.text.length+Math.min(s.offset,n.length));for(let s=0,o=this.lineSeparator?null:/\r\n?|\n/g;;){let l=-1,a=1,c;if(this.lineSeparator?(l=n.indexOf(this.lineSeparator,s),a=this.lineSeparator.length):(c=o.exec(n))&&(l=c.index,a=c[0].length),this.append(n.slice(s,l<0?n.length:l)),l<0)break;if(this.lineBreak(),a>1)for(let h of this.points)h.node==e&&h.pos>this.text.length&&(h.pos-=a-1);s=l+a}}readNode(e){if(e.cmIgnore)return;let n=ContentView.get(e),s=n&&n.overrideDOMText;if(s!=null){this.findPointInside(e,s.length);for(let o=s.iter();!o.next().done;)o.lineBreak?this.lineBreak():this.append(o.value)}else e.nodeType==3?this.readTextNode(e):e.nodeName=="BR"?e.nextSibling&&this.lineBreak():e.nodeType==1&&this.readRange(e.firstChild,null)}findPointBefore(e,n){for(let s of this.points)s.node==e&&e.childNodes[s.offset]==n&&(s.pos=this.text.length)}findPointInside(e,n){for(let s of this.points)(e.nodeType==3?s.node==e:e.contains(s.node))&&(s.pos=this.text.length+(isAtEnd(e,s.node,s.offset)?n:0))}}function isAtEnd(r,e,n){for(;;){if(!e||n-1;let{impreciseHead:l,impreciseAnchor:a}=e.docView;if(e.state.readOnly&&n>-1)this.newSel=null;else if(n>-1&&(this.bounds=e.docView.domBoundsAround(n,s,0))){let c=l||a?[]:selectionPoints(e),h=new DOMReader(c,e.state);h.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=h.text,this.newSel=selectionFromPoints(c,this.bounds.from)}else{let c=e.observer.selectionRange,h=l&&l.node==c.focusNode&&l.offset==c.focusOffset||!contains(e.contentDOM,c.focusNode)?e.state.selection.main.head:e.docView.posFromDOM(c.focusNode,c.focusOffset),f=a&&a.node==c.anchorNode&&a.offset==c.anchorOffset||!contains(e.contentDOM,c.anchorNode)?e.state.selection.main.anchor:e.docView.posFromDOM(c.anchorNode,c.anchorOffset),u=e.viewport;if((browser.ios||browser.chrome)&&e.state.selection.main.empty&&h!=f&&(u.from>0||u.toDate.now()-100?r.inputState.lastKeyCode:-1;if(e.bounds){let{from:a,to:c}=e.bounds,h=o.from,f=null;(l===8||browser.android&&e.text.length=o.from&&n.to<=o.to&&(n.from!=o.from||n.to!=o.to)&&o.to-o.from-(n.to-n.from)<=4?n={from:o.from,to:o.to,insert:r.state.doc.slice(o.from,n.from).append(n.insert).append(r.state.doc.slice(n.to,o.to))}:(browser.mac||browser.android)&&n&&n.from==n.to&&n.from==o.head-1&&/^\. ?$/.test(n.insert.toString())&&r.contentDOM.getAttribute("autocorrect")=="off"?(s&&n.insert.length==2&&(s=EditorSelection.single(s.main.anchor-1,s.main.head-1)),n={from:o.from,to:o.to,insert:Text.of([" "])}):browser.chrome&&n&&n.from==n.to&&n.from==o.head&&n.insert.toString()==` - `&&r.lineWrapping&&(s&&(s=EditorSelection.single(s.main.anchor-1,s.main.head-1)),n={from:o.from,to:o.to,insert:Text.of([" "])}),n)return applyDOMChangeInner(r,n,s,l);if(s&&!s.main.eq(o)){let a=!1,c="select";return r.inputState.lastSelectionTime>Date.now()-50&&(r.inputState.lastSelectionOrigin=="select"&&(a=!0),c=r.inputState.lastSelectionOrigin),r.dispatch({selection:s,scrollIntoView:a,userEvent:c}),!0}else return!1}function applyDOMChangeInner(r,e,n,s=-1){if(browser.ios&&r.inputState.flushIOSKey(e))return!0;let o=r.state.selection.main;if(browser.android&&(e.to==o.to&&(e.from==o.from||e.from==o.from-1&&r.state.sliceDoc(e.from,o.from)==" ")&&e.insert.length==1&&e.insert.lines==2&&dispatchKey(r.contentDOM,"Enter",13)||(e.from==o.from-1&&e.to==o.to&&e.insert.length==0||s==8&&e.insert.lengtho.head)&&dispatchKey(r.contentDOM,"Backspace",8)||e.from==o.from&&e.to==o.to+1&&e.insert.length==0&&dispatchKey(r.contentDOM,"Delete",46)))return!0;let l=e.insert.toString();r.inputState.composing>=0&&r.inputState.composing++;let a,c=()=>a||(a=applyDefaultInsert(r,e,n));return r.state.facet(inputHandler$1).some(h=>h(r,e.from,e.to,l,c))||r.dispatch(c()),!0}function applyDefaultInsert(r,e,n){let s,o=r.state,l=o.selection.main;if(e.from>=l.from&&e.to<=l.to&&e.to-e.from>=(l.to-l.from)/3&&(!n||n.main.empty&&n.main.from==e.from+e.insert.length)&&r.inputState.composing<0){let c=l.frome.to?o.sliceDoc(e.to,l.to):"";s=o.replaceSelection(r.state.toText(c+e.insert.sliceString(0,void 0,r.state.lineBreak)+h))}else{let c=o.changes(e),h=n&&n.main.to<=c.newLength?n.main:void 0;if(o.selection.ranges.length>1&&r.inputState.composing>=0&&e.to<=l.to&&e.to>=l.to-10){let f=r.state.sliceDoc(e.from,e.to),u,d=n&&findCompositionNode(r,n.main.head);if(d){let m=e.insert.length-(e.to-e.from);u={from:d.from,to:d.to-m}}else u=r.state.doc.lineAt(l.head);let g=l.to-e.to,O=l.to-l.from;s=o.changeByRange(m=>{if(m.from==l.from&&m.to==l.to)return{changes:c,range:h||m.map(c)};let y=m.to-g,b=y-f.length;if(m.to-m.from!=O||r.state.sliceDoc(b,y)!=f||m.to>=u.from&&m.from<=u.to)return{range:m};let w=o.changes({from:b,to:y,insert:e.insert}),P=m.to-l.to;return{changes:w,range:h?EditorSelection.range(Math.max(0,h.anchor+P),Math.max(0,h.head+P)):m.map(w)}})}else s={changes:c,selection:h&&o.selection.replaceRange(h)}}let a="input.type";return(r.composing||r.inputState.compositionPendingChange&&r.inputState.compositionEndedAt>Date.now()-50)&&(r.inputState.compositionPendingChange=!1,a+=".compose",r.inputState.compositionFirstChange&&(a+=".start",r.inputState.compositionFirstChange=!1)),o.update(s,{userEvent:a,scrollIntoView:!0})}function findDiff(r,e,n,s){let o=Math.min(r.length,e.length),l=0;for(;l0&&c>0&&r.charCodeAt(a-1)==e.charCodeAt(c-1);)a--,c--;if(s=="end"){let h=Math.max(0,l-Math.min(a,c));n-=a+h-l}if(a=a?l-n:0;l-=h,c=l+(c-a),a=l}else if(c=c?l-n:0;l-=h,a=l+(a-c),c=l}return{from:l,toA:a,toB:c}}function selectionPoints(r){let e=[];if(r.root.activeElement!=r.contentDOM)return e;let{anchorNode:n,anchorOffset:s,focusNode:o,focusOffset:l}=r.observer.selectionRange;return n&&(e.push(new DOMPoint(n,s)),(o!=n||l!=s)&&e.push(new DOMPoint(o,l))),e}function selectionFromPoints(r,e){if(r.length==0)return null;let n=r[0].pos,s=r.length==2?r[1].pos:n;return n>-1&&s>-1?EditorSelection.single(n+e,s+e):null}const observeOptions={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},useCharData=browser.ie&&browser.ie_version<=11;class DOMObserver{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new DOMSelectionState,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver(n=>{for(let s of n)this.queue.push(s);(browser.ie&&browser.ie_version<=11||browser.ios&&e.composing)&&n.some(s=>s.type=="childList"&&s.removedNodes.length||s.type=="characterData"&&s.oldValue.length>s.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&e.constructor.EDIT_CONTEXT===!0&&(this.editContext=new EditContextManager(e),e.state.facet(editable)&&(e.contentDOM.editContext=this.editContext.editContext)),useCharData&&(this.onCharData=n=>{this.queue.push({target:n.target,type:"characterData",oldValue:n.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),window.matchMedia&&(this.printQuery=window.matchMedia("print")),typeof ResizeObserver=="function"&&(this.resizeScroll=new ResizeObserver(()=>{var n;((n=this.view.docView)===null||n===void 0?void 0:n.lastUpdate){this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),n.length>0&&n[n.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(n=>{n.length>0&&n[n.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(e){this.view.inputState.runHandlers("scroll",e),this.intersecting&&this.view.measure()}onScroll(e){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(e){e.type=="change"&&!e.matches||(this.view.viewState.printing=!0,this.view.measure(),setTimeout(()=>{this.view.viewState.printing=!1,this.view.requestMeasure()},500))}updateGaps(e){if(this.gapIntersection&&(e.length!=this.gaps.length||this.gaps.some((n,s)=>n!=e[s]))){this.gapIntersection.disconnect();for(let n of e)this.gapIntersection.observe(n);this.gaps=e}}onSelectionChange(e){let n=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:s}=this,o=this.selectionRange;if(s.state.facet(editable)?s.root.activeElement!=this.dom:!hasSelection(s.dom,o))return;let l=o.anchorNode&&s.docView.nearest(o.anchorNode);if(l&&l.ignoreEvent(e)){n||(this.selectionChanged=!1);return}(browser.ie&&browser.ie_version<=11||browser.android&&browser.chrome)&&!s.state.selection.main.empty&&o.focusNode&&isEquivalentPosition(o.focusNode,o.focusOffset,o.anchorNode,o.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,n=getSelection(e.root);if(!n)return!1;let s=browser.safari&&e.root.nodeType==11&&deepActiveElement(this.dom.ownerDocument)==this.dom&&safariSelectionRangeHack(this.view,n)||n;if(!s||this.selectionRange.eq(s))return!1;let o=hasSelection(this.dom,s);return o&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime{let l=this.delayedAndroidKey;l&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=l.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&l.force&&dispatchKey(this.dom,l.key,l.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(o)}(!this.delayedAndroidKey||e=="Enter")&&(this.delayedAndroidKey={key:e,keyCode:n,force:this.lastChange{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}processRecords(){let e=this.pendingRecords();e.length&&(this.queue=[]);let n=-1,s=-1,o=!1;for(let l of e){let a=this.readMutation(l);a&&(a.typeOver&&(o=!0),n==-1?{from:n,to:s}=a:(n=Math.min(a.from,n),s=Math.max(a.to,s)))}return{from:n,to:s,typeOver:o}}readChange(){let{from:e,to:n,typeOver:s}=this.processRecords(),o=this.selectionChanged&&hasSelection(this.dom,this.selectionRange);if(e<0&&!o)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let l=new DOMChange(this.view,e,n,s);return this.view.docView.domChanged={newSel:l.newSel?l.newSel.main:null},l}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let n=this.readChange();if(!n)return this.view.requestMeasure(),!1;let s=this.view.state,o=applyDOMChange(this.view,n);return this.view.state==s&&(n.domChanged||n.newSel&&!n.newSel.main.eq(this.view.state.selection.main))&&this.view.update([]),o}readMutation(e){let n=this.view.docView.nearest(e.target);if(!n||n.ignoreMutation(e))return null;if(n.markDirty(e.type=="attributes"),e.type=="attributes"&&(n.flags|=4),e.type=="childList"){let s=findChild(n,e.previousSibling||e.target.previousSibling,-1),o=findChild(n,e.nextSibling||e.target.nextSibling,1);return{from:s?n.posAfter(s):n.posAtStart,to:o?n.posBefore(o):n.posAtEnd,typeOver:!1}}else return e.type=="characterData"?{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener("change",this.onPrint):e.addEventListener("beforeprint",this.onPrint),e.addEventListener("scroll",this.onScroll),e.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener("scroll",this.onScroll),e.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener("change",this.onPrint):e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}update(e){this.editContext&&(this.editContext.update(e),e.startState.facet(editable)!=e.state.facet(editable)&&(e.view.contentDOM.editContext=e.state.facet(editable)?this.editContext.editContext:null))}destroy(){var e,n,s;this.stop(),(e=this.intersection)===null||e===void 0||e.disconnect(),(n=this.gapIntersection)===null||n===void 0||n.disconnect(),(s=this.resizeScroll)===null||s===void 0||s.disconnect();for(let o of this.scrollTargets)o.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey)}}function findChild(r,e,n){for(;e;){let s=ContentView.get(e);if(s&&s.parent==r)return s;let o=e.parentNode;e=o!=r.dom?o:n>0?e.nextSibling:e.previousSibling}return null}function buildSelectionRangeFromRange(r,e){let n=e.startContainer,s=e.startOffset,o=e.endContainer,l=e.endOffset,a=r.docView.domAtPos(r.state.selection.main.anchor);return isEquivalentPosition(a.node,a.offset,o,l)&&([n,s,o,l]=[o,l,n,s]),{anchorNode:n,anchorOffset:s,focusNode:o,focusOffset:l}}function safariSelectionRangeHack(r,e){if(e.getComposedRanges){let o=e.getComposedRanges(r.root)[0];if(o)return buildSelectionRangeFromRange(r,o)}let n=null;function s(o){o.preventDefault(),o.stopImmediatePropagation(),n=o.getTargetRanges()[0]}return r.contentDOM.addEventListener("beforeinput",s,!0),r.dom.ownerDocument.execCommand("indent"),r.contentDOM.removeEventListener("beforeinput",s,!0),n?buildSelectionRangeFromRange(r,n):null}class EditContextManager{constructor(e){this.from=0,this.to=0,this.pendingContextChange=null,this.resetRange(e.state);let n=this.editContext=new window.EditContext({text:e.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,e.state.selection.main.anchor))),selectionEnd:this.toContextPos(e.state.selection.main.head)});n.addEventListener("textupdate",s=>{let{anchor:o}=e.state.selection.main,l={from:this.toEditorPos(s.updateRangeStart),to:this.toEditorPos(s.updateRangeEnd),insert:Text.of(s.text.split(` -`))};l.from==this.from&&othis.to&&(l.to=o),!(l.from==l.to&&!l.insert.length)&&(this.pendingContextChange=l,applyDOMChangeInner(e,l,EditorSelection.single(this.toEditorPos(s.selectionStart),this.toEditorPos(s.selectionEnd))),this.pendingContextChange&&this.revertPending(e.state))}),n.addEventListener("characterboundsupdate",s=>{let o=[],l=null;for(let a=this.toEditorPos(s.rangeStart),c=this.toEditorPos(s.rangeEnd);a{let o=[];for(let l of s.getTextFormats()){let a=l.underlineStyle,c=l.underlineThickness;if(a!="None"&&c!="None"){let h=`text-decoration: underline ${a=="Dashed"?"dashed ":a=="Squiggle"?"wavy ":""}${c=="Thin"?1:2}px`;o.push(Decoration.mark({attributes:{style:h}}).range(this.toEditorPos(l.rangeStart),this.toEditorPos(l.rangeEnd)))}}e.dispatch({effects:setEditContextFormatting.of(Decoration.set(o))})}),n.addEventListener("compositionstart",()=>{e.inputState.composing<0&&(e.inputState.composing=0,e.inputState.compositionFirstChange=!0)}),n.addEventListener("compositionend",()=>{e.inputState.composing=-1,e.inputState.compositionFirstChange=null}),this.measureReq={read:s=>{this.editContext.updateControlBounds(s.contentDOM.getBoundingClientRect());let o=getSelection(s.root);o&&o.rangeCount&&this.editContext.updateSelectionBounds(o.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let n=0,s=!1,o=this.pendingContextChange;return e.changes.iterChanges((l,a,c,h,f)=>{if(s)return;let u=f.length-(a-l);if(o&&a>=o.to)if(o.from==l&&o.to==a&&o.insert.eq(f)){o=this.pendingContextChange=null,n+=u;return}else o=null,this.revertPending(e.state);if(l+=n,a+=n,a<=this.from)this.from+=u,this.to+=u;else if(lthis.to||this.to-this.from+f.length>3e4){s=!0;return}this.editContext.updateText(this.toContextPos(l),this.toContextPos(a),f.toString()),this.to+=u}n+=u}),o&&!s&&this.revertPending(e.state),!s}update(e){!this.applyEdits(e)||!this.rangeIsValid(e.state)?(this.pendingContextChange=null,this.resetRange(e.state),this.editContext.updateText(0,this.editContext.text.length,e.state.doc.sliceString(this.from,this.to)),this.setSelection(e.state)):(e.docChanged||e.selectionSet)&&this.setSelection(e.state),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:n}=e.selection.main;this.from=Math.max(0,n-1e4),this.to=Math.min(e.doc.length,n+1e4)}revertPending(e){let n=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(n.from),this.toContextPos(n.to+n.insert.length),e.doc.sliceString(n.from,n.to))}setSelection(e){let{main:n}=e.selection,s=this.toContextPos(Math.max(this.from,Math.min(this.to,n.anchor))),o=this.toContextPos(n.head);(this.editContext.selectionStart!=s||this.editContext.selectionEnd!=o)&&this.editContext.updateSelection(s,o)}rangeIsValid(e){let{head:n}=e.selection.main;return!(this.from>0&&n-this.from<500||this.to1e4*3)}toEditorPos(e){return e+this.from}toContextPos(e){return e-this.from}}class EditorView{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return this.inputState.composing>0}get compositionStarted(){return this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(e={}){this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),e.parent&&e.parent.appendChild(this.dom);let{dispatch:n}=e;this.dispatchTransactions=e.dispatchTransactions||n&&(s=>s.forEach(o=>n(o,this)))||(s=>this.update(s)),this.dispatch=this.dispatch.bind(this),this._root=e.root||getRoot(e.parent)||document,this.viewState=new ViewState(e.state||EditorState.create(e)),e.scrollTo&&e.scrollTo.is(scrollIntoView$1)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(viewPlugin).map(s=>new PluginInstance(s));for(let s of this.plugins)s.update(this);this.observer=new DOMObserver(this),this.inputState=new InputState(this),this.inputState.ensureHandlers(this.plugins),this.docView=new DocView(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure()}dispatch(...e){let n=e.length==1&&e[0]instanceof Transaction?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(n,this)}update(e){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let n=!1,s=!1,o,l=this.state;for(let g of e){if(g.startState!=l)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");l=g.state}if(this.destroyed){this.viewState.state=l;return}let a=this.hasFocus,c=0,h=null;e.some(g=>g.annotation(isFocusChange))?(this.inputState.notifiedFocused=a,c=1):a!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=a,h=focusChangeTransaction(l,a),h||(c=1));let f=this.observer.delayedAndroidKey,u=null;if(f?(this.observer.clearDelayedAndroidKey(),u=this.observer.readChange(),(u&&!this.state.doc.eq(l.doc)||!this.state.selection.eq(l.selection))&&(u=null)):this.observer.clear(),l.facet(EditorState.phrases)!=this.state.facet(EditorState.phrases))return this.setState(l);o=ViewUpdate.create(this,l,e),o.flags|=c;let d=this.viewState.scrollTarget;try{this.updateState=2;for(let g of e){if(d&&(d=d.map(g.changes)),g.scrollIntoView){let{main:O}=g.state.selection;d=new ScrollTarget(O.empty?O:EditorSelection.cursor(O.head,O.head>O.anchor?-1:1))}for(let O of g.effects)O.is(scrollIntoView$1)&&(d=O.value.clip(this.state))}this.viewState.update(o,d),this.bidiCache=CachedOrder.update(this.bidiCache,o.changes),o.empty||(this.updatePlugins(o),this.inputState.update(o)),n=this.docView.update(o),this.state.facet(styleModule)!=this.styleModules&&this.mountStyles(),s=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(n,e.some(g=>g.isUserEvent("select.pointer")))}finally{this.updateState=0}if(o.startState.facet(theme)!=o.state.facet(theme)&&(this.viewState.mustMeasureContent=!0),(n||s||d||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),n&&this.docViewUpdate(),!o.empty)for(let g of this.state.facet(updateListener))try{g(o)}catch(O){logException(this.state,O,"update listener")}(h||u)&&Promise.resolve().then(()=>{h&&this.state==h.startState&&this.dispatch(h),u&&!applyDOMChange(this,u)&&f.force&&dispatchKey(this.contentDOM,f.key,f.keyCode)})}setState(e){if(this.updateState!=0)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed){this.viewState.state=e;return}this.updateState=2;let n=this.hasFocus;try{for(let s of this.plugins)s.destroy(this);this.viewState=new ViewState(e),this.plugins=e.facet(viewPlugin).map(s=>new PluginInstance(s)),this.pluginMap.clear();for(let s of this.plugins)s.update(this);this.docView.destroy(),this.docView=new DocView(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}n&&this.focus(),this.requestMeasure()}updatePlugins(e){let n=e.startState.facet(viewPlugin),s=e.state.facet(viewPlugin);if(n!=s){let o=[];for(let l of s){let a=n.indexOf(l);if(a<0)o.push(new PluginInstance(l));else{let c=this.plugins[a];c.mustUpdate=e,o.push(c)}}for(let l of this.plugins)l.mustUpdate!=e&&l.destroy(this);this.plugins=o,this.pluginMap.clear()}else for(let o of this.plugins)o.mustUpdate=e;for(let o=0;o-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let n=null,s=this.scrollDOM,o=s.scrollTop*this.scaleY,{scrollAnchorPos:l,scrollAnchorHeight:a}=this.viewState;Math.abs(o-this.viewState.scrollTop)>1&&(a=-1),this.viewState.scrollAnchorHeight=-1;try{for(let c=0;;c++){if(a<0)if(isScrolledToBottom(s))l=-1,a=this.viewState.heightMap.height;else{let O=this.viewState.scrollAnchorAt(o);l=O.from,a=O.top}this.updateState=1;let h=this.viewState.measure(this);if(!h&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(c>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let f=[];h&4||([this.measureRequests,f]=[f,this.measureRequests]);let u=f.map(O=>{try{return O.read(this)}catch(m){return logException(this.state,m),BadMeasure}}),d=ViewUpdate.create(this,this.state,[]),g=!1;d.flags|=h,n?n.flags|=h:n=d,this.updateState=2,d.empty||(this.updatePlugins(d),this.inputState.update(d),this.updateAttrs(),g=this.docView.update(d),g&&this.docViewUpdate());for(let O=0;O1||m<-1){o=o+m,s.scrollTop=o/this.scaleY,a=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(n&&!n.empty)for(let c of this.state.facet(updateListener))c(n)}get themeClasses(){return baseThemeID+" "+(this.state.facet(darkTheme)?baseDarkID:baseLightID)+" "+this.state.facet(theme)}updateAttrs(){let e=attrsFromFacet(this,editorAttributes,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),n={spellcheck:"false",autocorrect:"off",autocapitalize:"off",translate:"no",contenteditable:this.state.facet(editable)?"true":"false",class:"cm-content",style:`${browser.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(n["aria-readonly"]="true"),attrsFromFacet(this,contentAttributes,n);let s=this.observer.ignore(()=>{let o=updateAttrs(this.contentDOM,this.contentAttrs,n),l=updateAttrs(this.dom,this.editorAttrs,e);return o||l});return this.editorAttrs=e,this.contentAttrs=n,s}showAnnouncements(e){let n=!0;for(let s of e)for(let o of s.effects)if(o.is(EditorView.announce)){n&&(this.announceDOM.textContent=""),n=!1;let l=this.announceDOM.appendChild(document.createElement("div"));l.textContent=o.value}}mountStyles(){this.styleModules=this.state.facet(styleModule);let e=this.state.facet(EditorView.cspNonce);StyleModule.mount(this.root,this.styleModules.concat(baseTheme$1$2).reverse(),e?{nonce:e}:void 0)}readMeasured(){if(this.updateState==2)throw new Error("Reading the editor layout isn't allowed during an update");this.updateState==0&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(e){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),e){if(this.measureRequests.indexOf(e)>-1)return;if(e.key!=null){for(let n=0;ns.spec==e)||null),n&&n.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(e){return this.readMeasured(),this.viewState.elementAtHeight(e)}lineBlockAtHeight(e){return this.readMeasured(),this.viewState.lineBlockAtHeight(e)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(e){return this.viewState.lineBlockAt(e)}get contentHeight(){return this.viewState.contentHeight}moveByChar(e,n,s){return skipAtoms(this,e,moveByChar(this,e,n,s))}moveByGroup(e,n){return skipAtoms(this,e,moveByChar(this,e,n,s=>byGroup(this,e.head,s)))}visualLineSide(e,n){let s=this.bidiSpans(e),o=this.textDirectionAt(e.from),l=s[n?s.length-1:0];return EditorSelection.cursor(l.side(n,o)+e.from,l.forward(!n,o)?1:-1)}moveToLineBoundary(e,n,s=!0){return moveToLineBoundary(this,e,n,s)}moveVertically(e,n,s){return skipAtoms(this,e,moveVertically(this,e,n,s))}domAtPos(e){return this.docView.domAtPos(e)}posAtDOM(e,n=0){return this.docView.posFromDOM(e,n)}posAtCoords(e,n=!0){return this.readMeasured(),posAtCoords(this,e,n)}coordsAtPos(e,n=1){this.readMeasured();let s=this.docView.coordsAt(e,n);if(!s||s.left==s.right)return s;let o=this.state.doc.lineAt(e),l=this.bidiSpans(o),a=l[BidiSpan.find(l,e-o.from,-1,n)];return flattenRect(s,a.dir==Direction.LTR==n>0)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(e){return!this.state.facet(perLineTextDirection)||ethis.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>MaxBidiLine)return trivialOrder(e.length);let n=this.textDirectionAt(e.from),s;for(let l of this.bidiCache)if(l.from==e.from&&l.dir==n&&(l.fresh||isolatesEq(l.isolates,s=getIsolatedRanges(this,e))))return l.order;s||(s=getIsolatedRanges(this,e));let o=computeOrder(e.text,n,s);return this.bidiCache.push(new CachedOrder(e.from,e.to,n,s,!0,o)),o}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||browser.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{focusPreventScroll(this.contentDOM),this.docView.updateSelection()})}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((e.nodeType==9?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,n={}){return scrollIntoView$1.of(new ScrollTarget(typeof e=="number"?EditorSelection.cursor(e):e,n.y,n.x,n.yMargin,n.xMargin))}scrollSnapshot(){let{scrollTop:e,scrollLeft:n}=this.scrollDOM,s=this.viewState.scrollAnchorAt(e);return scrollIntoView$1.of(new ScrollTarget(EditorSelection.cursor(s.from),"start","start",s.top-e,n,!0))}setTabFocusMode(e){e==null?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:typeof e=="boolean"?this.inputState.tabFocusMode=e?0:-1:this.inputState.tabFocusMode!=0&&(this.inputState.tabFocusMode=Date.now()+e)}static domEventHandlers(e){return ViewPlugin.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return ViewPlugin.define(()=>({}),{eventObservers:e})}static theme(e,n){let s=StyleModule.newName(),o=[theme.of(s),styleModule.of(buildTheme(`.${s}`,e))];return n&&n.dark&&o.push(darkTheme.of(!0)),o}static baseTheme(e){return Prec.lowest(styleModule.of(buildTheme("."+baseThemeID,e,lightDarkIDs)))}static findFromDOM(e){var n;let s=e.querySelector(".cm-content"),o=s&&ContentView.get(s)||ContentView.get(e);return((n=o==null?void 0:o.rootView)===null||n===void 0?void 0:n.view)||null}}EditorView.styleModule=styleModule;EditorView.inputHandler=inputHandler$1;EditorView.scrollHandler=scrollHandler;EditorView.focusChangeEffect=focusChangeEffect;EditorView.perLineTextDirection=perLineTextDirection;EditorView.exceptionSink=exceptionSink;EditorView.updateListener=updateListener;EditorView.editable=editable;EditorView.mouseSelectionStyle=mouseSelectionStyle;EditorView.dragMovesSelection=dragMovesSelection$1;EditorView.clickAddsSelectionRange=clickAddsSelectionRange;EditorView.decorations=decorations;EditorView.outerDecorations=outerDecorations;EditorView.atomicRanges=atomicRanges;EditorView.bidiIsolatedRanges=bidiIsolatedRanges;EditorView.scrollMargins=scrollMargins;EditorView.darkTheme=darkTheme;EditorView.cspNonce=Facet.define({combine:r=>r.length?r[0]:""});EditorView.contentAttributes=contentAttributes;EditorView.editorAttributes=editorAttributes;EditorView.lineWrapping=EditorView.contentAttributes.of({class:"cm-lineWrapping"});EditorView.announce=StateEffect.define();const MaxBidiLine=4096,BadMeasure={};class CachedOrder{constructor(e,n,s,o,l,a){this.from=e,this.to=n,this.dir=s,this.isolates=o,this.fresh=l,this.order=a}static update(e,n){if(n.empty&&!e.some(l=>l.fresh))return e;let s=[],o=e.length?e[e.length-1].dir:Direction.LTR;for(let l=Math.max(0,e.length-10);l=0;o--){let l=s[o],a=typeof l=="function"?l(r):l;a&&combineAttrs(a,n)}return n}const currentPlatform=browser.mac?"mac":browser.windows?"win":browser.linux?"linux":"key";function normalizeKeyName(r,e){const n=r.split(/-(?!$)/);let s=n[n.length-1];s=="Space"&&(s=" ");let o,l,a,c;for(let h=0;hs.concat(o),[]))),n}function runScopeHandlers(r,e,n){return runHandlers(getKeymap(r.state),e,r,n)}let storedPrefix=null;const PrefixTimeout=4e3;function buildKeymap(r,e=currentPlatform){let n=Object.create(null),s=Object.create(null),o=(a,c)=>{let h=s[a];if(h==null)s[a]=c;else if(h!=c)throw new Error("Key binding "+a+" is used both as a regular binding and as a multi-stroke prefix")},l=(a,c,h,f,u)=>{var d,g;let O=n[a]||(n[a]=Object.create(null)),m=c.split(/ (?!$)/).map(w=>normalizeKeyName(w,e));for(let w=1;w{let A=storedPrefix={view:$,prefix:P,scope:a};return setTimeout(()=>{storedPrefix==A&&(storedPrefix=null)},PrefixTimeout),!0}]})}let y=m.join(" ");o(y,!1);let b=O[y]||(O[y]={preventDefault:!1,stopPropagation:!1,run:((g=(d=O._any)===null||d===void 0?void 0:d.run)===null||g===void 0?void 0:g.slice())||[]});h&&b.run.push(h),f&&(b.preventDefault=!0),u&&(b.stopPropagation=!0)};for(let a of r){let c=a.scope?a.scope.split(" "):["editor"];if(a.any)for(let f of c){let u=n[f]||(n[f]=Object.create(null));u._any||(u._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:d}=a;for(let g in u)u[g].run.push(O=>d(O,currentKeyEvent))}let h=a[e]||a.key;if(h)for(let f of c)l(f,h,a.run,a.preventDefault,a.stopPropagation),a.shift&&l(f,"Shift-"+h,a.shift,a.preventDefault,a.stopPropagation)}return n}let currentKeyEvent=null;function runHandlers(r,e,n,s){currentKeyEvent=e;let o=keyName(e),l=codePointAt(o,0),a=codePointSize(l)==o.length&&o!=" ",c="",h=!1,f=!1,u=!1;storedPrefix&&storedPrefix.view==n&&storedPrefix.scope==s&&(c=storedPrefix.prefix+" ",modifierCodes.indexOf(e.keyCode)<0&&(f=!0,storedPrefix=null));let d=new Set,g=b=>{if(b){for(let w of b.run)if(!d.has(w)&&(d.add(w),w(n)))return b.stopPropagation&&(u=!0),!0;b.preventDefault&&(b.stopPropagation&&(u=!0),f=!0)}return!1},O=r[s],m,y;return O&&(g(O[c+modifiers(o,e,!a)])?h=!0:a&&(e.altKey||e.metaKey||e.ctrlKey)&&!(browser.windows&&e.ctrlKey&&e.altKey)&&(m=base[e.keyCode])&&m!=o?(g(O[c+modifiers(m,e,!0)])||e.shiftKey&&(y=shift[e.keyCode])!=o&&y!=m&&g(O[c+modifiers(y,e,!1)]))&&(h=!0):a&&e.shiftKey&&g(O[c+modifiers(o,e,!0)])&&(h=!0),!h&&g(O._any)&&(h=!0)),f&&(h=!0),h&&u&&e.stopPropagation(),currentKeyEvent=null,h}class RectangleMarker{constructor(e,n,s,o,l){this.className=e,this.left=n,this.top=s,this.width=o,this.height=l}draw(){let e=document.createElement("div");return e.className=this.className,this.adjust(e),e}update(e,n){return n.className!=this.className?!1:(this.adjust(e),!0)}adjust(e){e.style.left=this.left+"px",e.style.top=this.top+"px",this.width!=null&&(e.style.width=this.width+"px"),e.style.height=this.height+"px"}eq(e){return this.left==e.left&&this.top==e.top&&this.width==e.width&&this.height==e.height&&this.className==e.className}static forRange(e,n,s){if(s.empty){let o=e.coordsAtPos(s.head,s.assoc||1);if(!o)return[];let l=getBase(e);return[new RectangleMarker(n,o.left-l.left,o.top-l.top,null,o.bottom-o.top)]}else return rectanglesForRange(e,n,s)}}function getBase(r){let e=r.scrollDOM.getBoundingClientRect();return{left:(r.textDirection==Direction.LTR?e.left:e.right-r.scrollDOM.clientWidth*r.scaleX)-r.scrollDOM.scrollLeft*r.scaleX,top:e.top-r.scrollDOM.scrollTop*r.scaleY}}function wrappedLine(r,e,n,s){let o=r.coordsAtPos(e,n*2);if(!o)return s;let l=r.dom.getBoundingClientRect(),a=(o.top+o.bottom)/2,c=r.posAtCoords({x:l.left+1,y:a}),h=r.posAtCoords({x:l.right-1,y:a});return c==null||h==null?s:{from:Math.max(s.from,Math.min(c,h)),to:Math.min(s.to,Math.max(c,h))}}function rectanglesForRange(r,e,n){if(n.to<=r.viewport.from||n.from>=r.viewport.to)return[];let s=Math.max(n.from,r.viewport.from),o=Math.min(n.to,r.viewport.to),l=r.textDirection==Direction.LTR,a=r.contentDOM,c=a.getBoundingClientRect(),h=getBase(r),f=a.querySelector(".cm-line"),u=f&&window.getComputedStyle(f),d=c.left+(u?parseInt(u.paddingLeft)+Math.min(0,parseInt(u.textIndent)):0),g=c.right-(u?parseInt(u.paddingRight):0),O=blockAt(r,s),m=blockAt(r,o),y=O.type==BlockType.Text?O:null,b=m.type==BlockType.Text?m:null;if(y&&(r.lineWrapping||O.widgetLineBreaks)&&(y=wrappedLine(r,s,1,y)),b&&(r.lineWrapping||m.widgetLineBreaks)&&(b=wrappedLine(r,o,-1,b)),y&&b&&y.from==b.from&&y.to==b.to)return P($(n.from,n.to,y));{let v=y?$(n.from,null,y):A(O,!1),Q=b?$(null,n.to,b):A(m,!0),_=[];return(y||O).to<(b||m).from-(y&&b?1:0)||O.widgetLineBreaks>1&&v.bottom+r.defaultLineHeight/2L&&G.from=K)break;te>ee&&z(Math.max(se,ee),v==null&&se<=L,Math.min(te,K),Q==null&&te>=H,F.dir)}if(ee=j.to+1,ee>=K)break}return Y.length==0&&z(L,v==null,H,Q==null,r.textDirection),{top:W,bottom:q,horizontal:Y}}function A(v,Q){let _=c.top+(Q?v.top:v.bottom);return{top:_,bottom:_,horizontal:[]}}}function sameMarker(r,e){return r.constructor==e.constructor&&r.eq(e)}class LayerView{constructor(e,n){this.view=e,this.layer=n,this.drawn=[],this.scaleX=1,this.scaleY=1,this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=e.scrollDOM.appendChild(document.createElement("div")),this.dom.classList.add("cm-layer"),n.above&&this.dom.classList.add("cm-layer-above"),n.class&&this.dom.classList.add(n.class),this.scale(),this.dom.setAttribute("aria-hidden","true"),this.setOrder(e.state),e.requestMeasure(this.measureReq),n.mount&&n.mount(this.dom,e)}update(e){e.startState.facet(layerOrder)!=e.state.facet(layerOrder)&&this.setOrder(e.state),(this.layer.update(e,this.dom)||e.geometryChanged)&&(this.scale(),e.view.requestMeasure(this.measureReq))}docViewUpdate(e){this.layer.updateOnDocViewUpdate!==!1&&e.requestMeasure(this.measureReq)}setOrder(e){let n=0,s=e.facet(layerOrder);for(;n!sameMarker(n,this.drawn[s]))){let n=this.dom.firstChild,s=0;for(let o of e)o.update&&n&&o.constructor&&this.drawn[s].constructor&&o.update(n,this.drawn[s])?(n=n.nextSibling,s++):this.dom.insertBefore(o.draw(),n);for(;n;){let o=n.nextSibling;n.remove(),n=o}this.drawn=e}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}}const layerOrder=Facet.define();function layer(r){return[ViewPlugin.define(e=>new LayerView(e,r)),layerOrder.of(r)]}const CanHidePrimary=!browser.ios,selectionConfig=Facet.define({combine(r){return combineConfig(r,{cursorBlinkRate:1200,drawRangeCursor:!0},{cursorBlinkRate:(e,n)=>Math.min(e,n),drawRangeCursor:(e,n)=>e||n})}});function drawSelection(r={}){return[selectionConfig.of(r),cursorLayer,selectionLayer,hideNativeSelection,nativeSelectionHidden.of(!0)]}function configChanged(r){return r.startState.facet(selectionConfig)!=r.state.facet(selectionConfig)}const cursorLayer=layer({above:!0,markers(r){let{state:e}=r,n=e.facet(selectionConfig),s=[];for(let o of e.selection.ranges){let l=o==e.selection.main;if(o.empty?!l||CanHidePrimary:n.drawRangeCursor){let a=l?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",c=o.empty?o:EditorSelection.cursor(o.head,o.head>o.anchor?-1:1);for(let h of RectangleMarker.forRange(r,a,c))s.push(h)}}return s},update(r,e){r.transactions.some(s=>s.selection)&&(e.style.animationName=e.style.animationName=="cm-blink"?"cm-blink2":"cm-blink");let n=configChanged(r);return n&&setBlinkRate(r.state,e),r.docChanged||r.selectionSet||n},mount(r,e){setBlinkRate(e.state,r)},class:"cm-cursorLayer"});function setBlinkRate(r,e){e.style.animationDuration=r.facet(selectionConfig).cursorBlinkRate+"ms"}const selectionLayer=layer({above:!1,markers(r){return r.state.selection.ranges.map(e=>e.empty?[]:RectangleMarker.forRange(r,"cm-selectionBackground",e)).reduce((e,n)=>e.concat(n))},update(r,e){return r.docChanged||r.selectionSet||r.viewportChanged||configChanged(r)},class:"cm-selectionLayer"}),themeSpec={".cm-line":{"& ::selection, &::selection":{backgroundColor:"transparent !important"}},".cm-content":{"& :focus":{caretColor:"initial !important","&::selection, & ::selection":{backgroundColor:"Highlight !important"}}}};CanHidePrimary&&(themeSpec[".cm-line"].caretColor=themeSpec[".cm-content"].caretColor="transparent !important");const hideNativeSelection=Prec.highest(EditorView.theme(themeSpec)),setDropCursorPos=StateEffect.define({map(r,e){return r==null?null:e.mapPos(r)}}),dropCursorPos=StateField.define({create(){return null},update(r,e){return r!=null&&(r=e.changes.mapPos(r)),e.effects.reduce((n,s)=>s.is(setDropCursorPos)?s.value:n,r)}}),drawDropCursor=ViewPlugin.fromClass(class{constructor(r){this.view=r,this.cursor=null,this.measureReq={read:this.readPos.bind(this),write:this.drawCursor.bind(this)}}update(r){var e;let n=r.state.field(dropCursorPos);n==null?this.cursor!=null&&((e=this.cursor)===null||e===void 0||e.remove(),this.cursor=null):(this.cursor||(this.cursor=this.view.scrollDOM.appendChild(document.createElement("div")),this.cursor.className="cm-dropCursor"),(r.startState.field(dropCursorPos)!=n||r.docChanged||r.geometryChanged)&&this.view.requestMeasure(this.measureReq))}readPos(){let{view:r}=this,e=r.state.field(dropCursorPos),n=e!=null&&r.coordsAtPos(e);if(!n)return null;let s=r.scrollDOM.getBoundingClientRect();return{left:n.left-s.left+r.scrollDOM.scrollLeft*r.scaleX,top:n.top-s.top+r.scrollDOM.scrollTop*r.scaleY,height:n.bottom-n.top}}drawCursor(r){if(this.cursor){let{scaleX:e,scaleY:n}=this.view;r?(this.cursor.style.left=r.left/e+"px",this.cursor.style.top=r.top/n+"px",this.cursor.style.height=r.height/n+"px"):this.cursor.style.left="-100000px"}}destroy(){this.cursor&&this.cursor.remove()}setDropPos(r){this.view.state.field(dropCursorPos)!=r&&this.view.dispatch({effects:setDropCursorPos.of(r)})}},{eventObservers:{dragover(r){this.setDropPos(this.view.posAtCoords({x:r.clientX,y:r.clientY}))},dragleave(r){(r.target==this.view.contentDOM||!this.view.contentDOM.contains(r.relatedTarget))&&this.setDropPos(null)},dragend(){this.setDropPos(null)},drop(){this.setDropPos(null)}}});function dropCursor(){return[dropCursorPos,drawDropCursor]}function iterMatches(r,e,n,s,o){e.lastIndex=0;for(let l=r.iterRange(n,s),a=n,c;!l.next().done;a+=l.value.length)if(!l.lineBreak)for(;c=e.exec(l.value);)o(a+c.index,c)}function matchRanges(r,e){let n=r.visibleRanges;if(n.length==1&&n[0].from==r.viewport.from&&n[0].to==r.viewport.to)return n;let s=[];for(let{from:o,to:l}of n)o=Math.max(r.state.doc.lineAt(o).from,o-e),l=Math.min(r.state.doc.lineAt(l).to,l+e),s.length&&s[s.length-1].to>=o?s[s.length-1].to=l:s.push({from:o,to:l});return s}class MatchDecorator{constructor(e){const{regexp:n,decoration:s,decorate:o,boundary:l,maxLength:a=1e3}=e;if(!n.global)throw new RangeError("The regular expression given to MatchDecorator should have its 'g' flag set");if(this.regexp=n,o)this.addMatch=(c,h,f,u)=>o(u,f,f+c[0].length,c,h);else if(typeof s=="function")this.addMatch=(c,h,f,u)=>{let d=s(c,h,f);d&&u(f,f+c[0].length,d)};else if(s)this.addMatch=(c,h,f,u)=>u(f,f+c[0].length,s);else throw new RangeError("Either 'decorate' or 'decoration' should be provided to MatchDecorator");this.boundary=l,this.maxLength=a}createDeco(e){let n=new RangeSetBuilder,s=n.add.bind(n);for(let{from:o,to:l}of matchRanges(e,this.maxLength))iterMatches(e.state.doc,this.regexp,o,l,(a,c)=>this.addMatch(c,e,a,s));return n.finish()}updateDeco(e,n){let s=1e9,o=-1;return e.docChanged&&e.changes.iterChanges((l,a,c,h)=>{h>e.view.viewport.from&&c1e3?this.createDeco(e.view):o>-1?this.updateRange(e.view,n.map(e.changes),s,o):n}updateRange(e,n,s,o){for(let l of e.visibleRanges){let a=Math.max(l.from,s),c=Math.min(l.to,o);if(c>a){let h=e.state.doc.lineAt(a),f=h.toh.from;a--)if(this.boundary.test(h.text[a-1-h.from])){u=a;break}for(;cg.push(w.range(y,b));if(h==f)for(this.regexp.lastIndex=u-h.from;(O=this.regexp.exec(h.text))&&O.indexthis.addMatch(b,e,y,m));n=n.update({filterFrom:u,filterTo:d,filter:(y,b)=>yd,add:g})}}return n}}const UnicodeRegexpSupport=/x/.unicode!=null?"gu":"g",Specials=new RegExp(`[\0-\b ---Ÿ­؜​‎‏\u2028\u2029‭‮⁦⁧⁩\uFEFF-]`,UnicodeRegexpSupport),Names={0:"null",7:"bell",8:"backspace",10:"newline",11:"vertical tab",13:"carriage return",27:"escape",8203:"zero width space",8204:"zero width non-joiner",8205:"zero width joiner",8206:"left-to-right mark",8207:"right-to-left mark",8232:"line separator",8237:"left-to-right override",8238:"right-to-left override",8294:"left-to-right isolate",8295:"right-to-left isolate",8297:"pop directional isolate",8233:"paragraph separator",65279:"zero width no-break space",65532:"object replacement"};let _supportsTabSize=null;function supportsTabSize(){var r;if(_supportsTabSize==null&&typeof document<"u"&&document.body){let e=document.body.style;_supportsTabSize=((r=e.tabSize)!==null&&r!==void 0?r:e.MozTabSize)!=null}return _supportsTabSize||!1}const specialCharConfig=Facet.define({combine(r){let e=combineConfig(r,{render:null,specialChars:Specials,addSpecialChars:null});return(e.replaceTabs=!supportsTabSize())&&(e.specialChars=new RegExp(" |"+e.specialChars.source,UnicodeRegexpSupport)),e.addSpecialChars&&(e.specialChars=new RegExp(e.specialChars.source+"|"+e.addSpecialChars.source,UnicodeRegexpSupport)),e}});function highlightSpecialChars(r={}){return[specialCharConfig.of(r),specialCharPlugin()]}let _plugin=null;function specialCharPlugin(){return _plugin||(_plugin=ViewPlugin.fromClass(class{constructor(r){this.view=r,this.decorations=Decoration.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(r.state.facet(specialCharConfig)),this.decorations=this.decorator.createDeco(r)}makeDecorator(r){return new MatchDecorator({regexp:r.specialChars,decoration:(e,n,s)=>{let{doc:o}=n.state,l=codePointAt(e[0],0);if(l==9){let a=o.lineAt(s),c=n.state.tabSize,h=countColumn(a.text,c,s-a.from);return Decoration.replace({widget:new TabWidget((c-h%c)*this.view.defaultCharacterWidth/this.view.scaleX)})}return this.decorationCache[l]||(this.decorationCache[l]=Decoration.replace({widget:new SpecialCharWidget(r,l)}))},boundary:r.replaceTabs?void 0:/[^]/})}update(r){let e=r.state.facet(specialCharConfig);r.startState.facet(specialCharConfig)!=e?(this.decorator=this.makeDecorator(e),this.decorations=this.decorator.createDeco(r.view)):this.decorations=this.decorator.updateDeco(r,this.decorations)}},{decorations:r=>r.decorations}))}const DefaultPlaceholder="•";function placeholder$1(r){return r>=32?DefaultPlaceholder:r==10?"␤":String.fromCharCode(9216+r)}class SpecialCharWidget extends WidgetType{constructor(e,n){super(),this.options=e,this.code=n}eq(e){return e.code==this.code}toDOM(e){let n=placeholder$1(this.code),s=e.state.phrase("Control character")+" "+(Names[this.code]||"0x"+this.code.toString(16)),o=this.options.render&&this.options.render(this.code,s,n);if(o)return o;let l=document.createElement("span");return l.textContent=n,l.title=s,l.setAttribute("aria-label",s),l.className="cm-specialChar",l}ignoreEvent(){return!1}}class TabWidget extends WidgetType{constructor(e){super(),this.width=e}eq(e){return e.width==this.width}toDOM(){let e=document.createElement("span");return e.textContent=" ",e.className="cm-tab",e.style.width=this.width+"px",e}ignoreEvent(){return!1}}function highlightActiveLine(){return activeLineHighlighter}const lineDeco=Decoration.line({class:"cm-activeLine"}),activeLineHighlighter=ViewPlugin.fromClass(class{constructor(r){this.decorations=this.getDeco(r)}update(r){(r.docChanged||r.selectionSet)&&(this.decorations=this.getDeco(r.view))}getDeco(r){let e=-1,n=[];for(let s of r.state.selection.ranges){let o=r.lineBlockAt(s.head);o.from>e&&(n.push(lineDeco.range(o.from)),e=o.from)}return Decoration.set(n)}},{decorations:r=>r.decorations}),MaxOff=2e3;function rectangleFor(r,e,n){let s=Math.min(e.line,n.line),o=Math.max(e.line,n.line),l=[];if(e.off>MaxOff||n.off>MaxOff||e.col<0||n.col<0){let a=Math.min(e.off,n.off),c=Math.max(e.off,n.off);for(let h=s;h<=o;h++){let f=r.doc.line(h);f.length<=c&&l.push(EditorSelection.range(f.from+a,f.to+c))}}else{let a=Math.min(e.col,n.col),c=Math.max(e.col,n.col);for(let h=s;h<=o;h++){let f=r.doc.line(h),u=findColumn(f.text,a,r.tabSize,!0);if(u<0)l.push(EditorSelection.cursor(f.to));else{let d=findColumn(f.text,c,r.tabSize);l.push(EditorSelection.range(f.from+u,f.from+d))}}}return l}function absoluteColumn(r,e){let n=r.coordsAtPos(r.viewport.from);return n?Math.round(Math.abs((n.left-e)/r.defaultCharacterWidth)):-1}function getPos(r,e){let n=r.posAtCoords({x:e.clientX,y:e.clientY},!1),s=r.state.doc.lineAt(n),o=n-s.from,l=o>MaxOff?-1:o==s.length?absoluteColumn(r,e.clientX):countColumn(s.text,r.state.tabSize,n-s.from);return{line:s.number,col:l,off:o}}function rectangleSelectionStyle(r,e){let n=getPos(r,e),s=r.state.selection;return n?{update(o){if(o.docChanged){let l=o.changes.mapPos(o.startState.doc.line(n.line).from),a=o.state.doc.lineAt(l);n={line:a.number,col:n.col,off:Math.min(n.off,a.length)},s=s.map(o.changes)}},get(o,l,a){let c=getPos(r,o);if(!c)return s;let h=rectangleFor(r.state,n,c);return h.length?a?EditorSelection.create(h.concat(s.ranges)):EditorSelection.create(h):s}}:null}function rectangularSelection(r){let e=n=>n.altKey&&n.button==0;return EditorView.mouseSelectionStyle.of((n,s)=>e(s)?rectangleSelectionStyle(n,s):null)}const keys={Alt:[18,r=>!!r.altKey],Control:[17,r=>!!r.ctrlKey],Shift:[16,r=>!!r.shiftKey],Meta:[91,r=>!!r.metaKey]},showCrosshair={style:"cursor: crosshair"};function crosshairCursor(r={}){let[e,n]=keys[r.key||"Alt"],s=ViewPlugin.fromClass(class{constructor(o){this.view=o,this.isDown=!1}set(o){this.isDown!=o&&(this.isDown=o,this.view.update([]))}},{eventObservers:{keydown(o){this.set(o.keyCode==e||n(o))},keyup(o){(o.keyCode==e||!n(o))&&this.set(!1)},mousemove(o){this.set(n(o))}}});return[s,EditorView.contentAttributes.of(o=>{var l;return!((l=o.plugin(s))===null||l===void 0)&&l.isDown?showCrosshair:null})]}const Outside="-10000px";class TooltipViewManager{constructor(e,n,s,o){this.facet=n,this.createTooltipView=s,this.removeTooltipView=o,this.input=e.state.facet(n),this.tooltips=this.input.filter(a=>a);let l=null;this.tooltipViews=this.tooltips.map(a=>l=s(a,l))}update(e,n){var s;let o=e.state.facet(this.facet),l=o.filter(h=>h);if(o===this.input){for(let h of this.tooltipViews)h.update&&h.update(e);return!1}let a=[],c=n?[]:null;for(let h=0;hn[f]=h),n.length=c.length),this.input=o,this.tooltips=l,this.tooltipViews=a,!0}}function windowSpace(r){let{win:e}=r;return{top:0,left:0,bottom:e.innerHeight,right:e.innerWidth}}const tooltipConfig=Facet.define({combine:r=>{var e,n,s;return{position:browser.ios?"absolute":((e=r.find(o=>o.position))===null||e===void 0?void 0:e.position)||"fixed",parent:((n=r.find(o=>o.parent))===null||n===void 0?void 0:n.parent)||null,tooltipSpace:((s=r.find(o=>o.tooltipSpace))===null||s===void 0?void 0:s.tooltipSpace)||windowSpace}}}),knownHeight=new WeakMap,tooltipPlugin=ViewPlugin.fromClass(class{constructor(r){this.view=r,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let e=r.state.facet(tooltipConfig);this.position=e.position,this.parent=e.parent,this.classes=r.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.resizeObserver=typeof ResizeObserver=="function"?new ResizeObserver(()=>this.measureSoon()):null,this.manager=new TooltipViewManager(r,showTooltip,(n,s)=>this.createTooltip(n,s),n=>{this.resizeObserver&&this.resizeObserver.unobserve(n.dom),n.dom.remove()}),this.above=this.manager.tooltips.map(n=>!!n.above),this.intersectionObserver=typeof IntersectionObserver=="function"?new IntersectionObserver(n=>{Date.now()>this.lastTransaction-50&&n.length>0&&n[n.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),r.win.addEventListener("resize",this.measureSoon=this.measureSoon.bind(this)),this.maybeMeasure()}createContainer(){this.parent?(this.container=document.createElement("div"),this.container.style.position="relative",this.container.className=this.view.themeClasses,this.parent.appendChild(this.container)):this.container=this.view.dom}observeIntersection(){if(this.intersectionObserver){this.intersectionObserver.disconnect();for(let r of this.manager.tooltipViews)this.intersectionObserver.observe(r.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(r){r.transactions.length&&(this.lastTransaction=Date.now());let e=this.manager.update(r,this.above);e&&this.observeIntersection();let n=e||r.geometryChanged,s=r.state.facet(tooltipConfig);if(s.position!=this.position&&!this.madeAbsolute){this.position=s.position;for(let o of this.manager.tooltipViews)o.dom.style.position=this.position;n=!0}if(s.parent!=this.parent){this.parent&&this.container.remove(),this.parent=s.parent,this.createContainer();for(let o of this.manager.tooltipViews)this.container.appendChild(o.dom);n=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);n&&this.maybeMeasure()}createTooltip(r,e){let n=r.create(this.view),s=e?e.dom:null;if(n.dom.classList.add("cm-tooltip"),r.arrow&&!n.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let o=document.createElement("div");o.className="cm-tooltip-arrow",n.dom.appendChild(o)}return n.dom.style.position=this.position,n.dom.style.top=Outside,n.dom.style.left="0px",this.container.insertBefore(n.dom,s),n.mount&&n.mount(this.view),this.resizeObserver&&this.resizeObserver.observe(n.dom),n}destroy(){var r,e,n;this.view.win.removeEventListener("resize",this.measureSoon);for(let s of this.manager.tooltipViews)s.dom.remove(),(r=s.destroy)===null||r===void 0||r.call(s);this.parent&&this.container.remove(),(e=this.resizeObserver)===null||e===void 0||e.disconnect(),(n=this.intersectionObserver)===null||n===void 0||n.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let r=this.view.dom.getBoundingClientRect(),e=1,n=1,s=!1;if(this.position=="fixed"&&this.manager.tooltipViews.length){let{dom:o}=this.manager.tooltipViews[0];if(browser.gecko)s=o.offsetParent!=this.container.ownerDocument.body;else if(o.style.top==Outside&&o.style.left=="0px"){let l=o.getBoundingClientRect();s=Math.abs(l.top+1e4)>1||Math.abs(l.left)>1}}if(s||this.position=="absolute")if(this.parent){let o=this.parent.getBoundingClientRect();o.width&&o.height&&(e=o.width/this.parent.offsetWidth,n=o.height/this.parent.offsetHeight)}else({scaleX:e,scaleY:n}=this.view.viewState);return{editor:r,parent:this.parent?this.container.getBoundingClientRect():r,pos:this.manager.tooltips.map((o,l)=>{let a=this.manager.tooltipViews[l];return a.getCoords?a.getCoords(o.pos):this.view.coordsAtPos(o.pos)}),size:this.manager.tooltipViews.map(({dom:o})=>o.getBoundingClientRect()),space:this.view.state.facet(tooltipConfig).tooltipSpace(this.view),scaleX:e,scaleY:n,makeAbsolute:s}}writeMeasure(r){var e;if(r.makeAbsolute){this.madeAbsolute=!0,this.position="absolute";for(let c of this.manager.tooltipViews)c.dom.style.position="absolute"}let{editor:n,space:s,scaleX:o,scaleY:l}=r,a=[];for(let c=0;c=Math.min(n.bottom,s.bottom)||d.rightMath.min(n.right,s.right)+.1){u.style.top=Outside;continue}let O=h.arrow?f.dom.querySelector(".cm-tooltip-arrow"):null,m=O?7:0,y=g.right-g.left,b=(e=knownHeight.get(f))!==null&&e!==void 0?e:g.bottom-g.top,w=f.offset||noOffset,P=this.view.textDirection==Direction.LTR,$=g.width>s.right-s.left?P?s.left:s.right-g.width:P?Math.min(d.left-(O?14:0)+w.x,s.right-y):Math.max(s.left,d.left-y+(O?14:0)-w.x),A=this.above[c];!h.strictSide&&(A?d.top-(g.bottom-g.top)-w.ys.bottom)&&A==s.bottom-d.bottom>d.top-s.top&&(A=this.above[c]=!A);let v=(A?d.top-s.top:s.bottom-d.bottom)-m;if(v$&&W.topQ&&(Q=A?W.top-b-2-m:W.bottom+m+2);if(this.position=="absolute"?(u.style.top=(Q-r.parent.top)/l+"px",u.style.left=($-r.parent.left)/o+"px"):(u.style.top=Q/l+"px",u.style.left=$/o+"px"),O){let W=d.left+(P?w.x:-w.x)-($+14-7);O.style.left=W/o+"px"}f.overlap!==!0&&a.push({left:$,top:Q,right:_,bottom:Q+b}),u.classList.toggle("cm-tooltip-above",A),u.classList.toggle("cm-tooltip-below",!A),f.positioned&&f.positioned(r.space)}}maybeMeasure(){if(this.manager.tooltips.length&&(this.view.inView&&this.view.requestMeasure(this.measureReq),this.inView!=this.view.inView&&(this.inView=this.view.inView,!this.inView)))for(let r of this.manager.tooltipViews)r.dom.style.top=Outside}},{eventObservers:{scroll(){this.maybeMeasure()}}}),baseTheme$5=EditorView.baseTheme({".cm-tooltip":{zIndex:100,boxSizing:"border-box"},"&light .cm-tooltip":{border:"1px solid #bbb",backgroundColor:"#f5f5f5"},"&light .cm-tooltip-section:not(:first-child)":{borderTop:"1px solid #bbb"},"&dark .cm-tooltip":{backgroundColor:"#333338",color:"white"},".cm-tooltip-arrow":{height:"7px",width:`${7*2}px`,position:"absolute",zIndex:-1,overflow:"hidden","&:before, &:after":{content:"''",position:"absolute",width:0,height:0,borderLeft:"7px solid transparent",borderRight:"7px solid transparent"},".cm-tooltip-above &":{bottom:"-7px","&:before":{borderTop:"7px solid #bbb"},"&:after":{borderTop:"7px solid #f5f5f5",bottom:"1px"}},".cm-tooltip-below &":{top:"-7px","&:before":{borderBottom:"7px solid #bbb"},"&:after":{borderBottom:"7px solid #f5f5f5",top:"1px"}}},"&dark .cm-tooltip .cm-tooltip-arrow":{"&:before":{borderTopColor:"#333338",borderBottomColor:"#333338"},"&:after":{borderTopColor:"transparent",borderBottomColor:"transparent"}}}),noOffset={x:0,y:0},showTooltip=Facet.define({enables:[tooltipPlugin,baseTheme$5]}),showHoverTooltip=Facet.define({combine:r=>r.reduce((e,n)=>e.concat(n),[])});class HoverTooltipHost{static create(e){return new HoverTooltipHost(e)}constructor(e){this.view=e,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new TooltipViewManager(e,showHoverTooltip,(n,s)=>this.createHostedView(n,s),n=>n.dom.remove())}createHostedView(e,n){let s=e.create(this.view);return s.dom.classList.add("cm-tooltip-section"),this.dom.insertBefore(s.dom,n?n.dom.nextSibling:this.dom.firstChild),this.mounted&&s.mount&&s.mount(this.view),s}mount(e){for(let n of this.manager.tooltipViews)n.mount&&n.mount(e);this.mounted=!0}positioned(e){for(let n of this.manager.tooltipViews)n.positioned&&n.positioned(e)}update(e){this.manager.update(e)}destroy(){var e;for(let n of this.manager.tooltipViews)(e=n.destroy)===null||e===void 0||e.call(n)}passProp(e){let n;for(let s of this.manager.tooltipViews){let o=s[e];if(o!==void 0){if(n===void 0)n=o;else if(n!==o)return}}return n}get offset(){return this.passProp("offset")}get getCoords(){return this.passProp("getCoords")}get overlap(){return this.passProp("overlap")}get resize(){return this.passProp("resize")}}const showHoverTooltipHost=showTooltip.compute([showHoverTooltip],r=>{let e=r.facet(showHoverTooltip);return e.length===0?null:{pos:Math.min(...e.map(n=>n.pos)),end:Math.max(...e.map(n=>{var s;return(s=n.end)!==null&&s!==void 0?s:n.pos})),create:HoverTooltipHost.create,above:e[0].above,arrow:e.some(n=>n.arrow)}});class HoverPlugin{constructor(e,n,s,o,l){this.view=e,this.source=n,this.field=s,this.setHover=o,this.hoverTime=l,this.hoverTimeout=-1,this.restartTimeout=-1,this.pending=null,this.lastMove={x:0,y:0,target:e.dom,time:0},this.checkHover=this.checkHover.bind(this),e.dom.addEventListener("mouseleave",this.mouseleave=this.mouseleave.bind(this)),e.dom.addEventListener("mousemove",this.mousemove=this.mousemove.bind(this))}update(){this.pending&&(this.pending=null,clearTimeout(this.restartTimeout),this.restartTimeout=setTimeout(()=>this.startHover(),20))}get active(){return this.view.state.field(this.field)}checkHover(){if(this.hoverTimeout=-1,this.active.length)return;let e=Date.now()-this.lastMove.time;ec.bottom||n.xc.right+e.defaultCharacterWidth)return;let h=e.bidiSpans(e.state.doc.lineAt(o)).find(u=>u.from<=o&&u.to>=o),f=h&&h.dir==Direction.RTL?-1:1;l=n.x{this.pending==c&&(this.pending=null,h&&!(Array.isArray(h)&&!h.length)&&e.dispatch({effects:this.setHover.of(Array.isArray(h)?h:[h])}))},h=>logException(e.state,h,"hover tooltip"))}else a&&!(Array.isArray(a)&&!a.length)&&e.dispatch({effects:this.setHover.of(Array.isArray(a)?a:[a])})}get tooltip(){let e=this.view.plugin(tooltipPlugin),n=e?e.manager.tooltips.findIndex(s=>s.create==HoverTooltipHost.create):-1;return n>-1?e.manager.tooltipViews[n]:null}mousemove(e){var n,s;this.lastMove={x:e.clientX,y:e.clientY,target:e.target,time:Date.now()},this.hoverTimeout<0&&(this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime));let{active:o,tooltip:l}=this;if(o.length&&l&&!isInTooltip(l.dom,e)||this.pending){let{pos:a}=o[0]||this.pending,c=(s=(n=o[0])===null||n===void 0?void 0:n.end)!==null&&s!==void 0?s:a;(a==c?this.view.posAtCoords(this.lastMove)!=a:!isOverRange(this.view,a,c,e.clientX,e.clientY))&&(this.view.dispatch({effects:this.setHover.of([])}),this.pending=null)}}mouseleave(e){clearTimeout(this.hoverTimeout),this.hoverTimeout=-1;let{active:n}=this;if(n.length){let{tooltip:s}=this;s&&s.dom.contains(e.relatedTarget)?this.watchTooltipLeave(s.dom):this.view.dispatch({effects:this.setHover.of([])})}}watchTooltipLeave(e){let n=s=>{e.removeEventListener("mouseleave",n),this.active.length&&!this.view.dom.contains(s.relatedTarget)&&this.view.dispatch({effects:this.setHover.of([])})};e.addEventListener("mouseleave",n)}destroy(){clearTimeout(this.hoverTimeout),this.view.dom.removeEventListener("mouseleave",this.mouseleave),this.view.dom.removeEventListener("mousemove",this.mousemove)}}const tooltipMargin=4;function isInTooltip(r,e){let n=r.getBoundingClientRect();return e.clientX>=n.left-tooltipMargin&&e.clientX<=n.right+tooltipMargin&&e.clientY>=n.top-tooltipMargin&&e.clientY<=n.bottom+tooltipMargin}function isOverRange(r,e,n,s,o,l){let a=r.scrollDOM.getBoundingClientRect(),c=r.documentTop+r.documentPadding.top+r.contentHeight;if(a.left>s||a.righto||Math.min(a.bottom,c)=e&&h<=n}function hoverTooltip(r,e={}){let n=StateEffect.define(),s=StateField.define({create(){return[]},update(o,l){if(o.length&&(e.hideOnChange&&(l.docChanged||l.selection)?o=[]:e.hideOn&&(o=o.filter(a=>!e.hideOn(l,a))),l.docChanged)){let a=[];for(let c of o){let h=l.changes.mapPos(c.pos,-1,MapMode.TrackDel);if(h!=null){let f=Object.assign(Object.create(null),c);f.pos=h,f.end!=null&&(f.end=l.changes.mapPos(f.end)),a.push(f)}}o=a}for(let a of l.effects)a.is(n)&&(o=a.value),a.is(closeHoverTooltipEffect)&&(o=[]);return o},provide:o=>showHoverTooltip.from(o)});return[s,ViewPlugin.define(o=>new HoverPlugin(o,r,s,n,e.hoverTime||300)),showHoverTooltipHost]}function getTooltip(r,e){let n=r.plugin(tooltipPlugin);if(!n)return null;let s=n.manager.tooltips.indexOf(e);return s<0?null:n.manager.tooltipViews[s]}const closeHoverTooltipEffect=StateEffect.define(),panelConfig=Facet.define({combine(r){let e,n;for(let s of r)e=e||s.topContainer,n=n||s.bottomContainer;return{topContainer:e,bottomContainer:n}}});function getPanel(r,e){let n=r.plugin(panelPlugin),s=n?n.specs.indexOf(e):-1;return s>-1?n.panels[s]:null}const panelPlugin=ViewPlugin.fromClass(class{constructor(r){this.input=r.state.facet(showPanel),this.specs=this.input.filter(n=>n),this.panels=this.specs.map(n=>n(r));let e=r.state.facet(panelConfig);this.top=new PanelGroup(r,!0,e.topContainer),this.bottom=new PanelGroup(r,!1,e.bottomContainer),this.top.sync(this.panels.filter(n=>n.top)),this.bottom.sync(this.panels.filter(n=>!n.top));for(let n of this.panels)n.dom.classList.add("cm-panel"),n.mount&&n.mount()}update(r){let e=r.state.facet(panelConfig);this.top.container!=e.topContainer&&(this.top.sync([]),this.top=new PanelGroup(r.view,!0,e.topContainer)),this.bottom.container!=e.bottomContainer&&(this.bottom.sync([]),this.bottom=new PanelGroup(r.view,!1,e.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let n=r.state.facet(showPanel);if(n!=this.input){let s=n.filter(h=>h),o=[],l=[],a=[],c=[];for(let h of s){let f=this.specs.indexOf(h),u;f<0?(u=h(r.view),c.push(u)):(u=this.panels[f],u.update&&u.update(r)),o.push(u),(u.top?l:a).push(u)}this.specs=s,this.panels=o,this.top.sync(l),this.bottom.sync(a);for(let h of c)h.dom.classList.add("cm-panel"),h.mount&&h.mount()}else for(let s of this.panels)s.update&&s.update(r)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:r=>EditorView.scrollMargins.of(e=>{let n=e.plugin(r);return n&&{top:n.top.scrollMargin(),bottom:n.bottom.scrollMargin()}})});class PanelGroup{constructor(e,n,s){this.view=e,this.top=n,this.container=s,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()}sync(e){for(let n of this.panels)n.destroy&&e.indexOf(n)<0&&n.destroy();this.panels=e,this.syncDOM()}syncDOM(){if(this.panels.length==0){this.dom&&(this.dom.remove(),this.dom=void 0);return}if(!this.dom){this.dom=document.createElement("div"),this.dom.className=this.top?"cm-panels cm-panels-top":"cm-panels cm-panels-bottom",this.dom.style[this.top?"top":"bottom"]="0";let n=this.container||this.view.dom;n.insertBefore(this.dom,this.top?n.firstChild:null)}let e=this.dom.firstChild;for(let n of this.panels)if(n.dom.parentNode==this.dom){for(;e!=n.dom;)e=rm(e);e=e.nextSibling}else this.dom.insertBefore(n.dom,e);for(;e;)e=rm(e)}scrollMargin(){return!this.dom||this.container?0:Math.max(0,this.top?this.dom.getBoundingClientRect().bottom-Math.max(0,this.view.scrollDOM.getBoundingClientRect().top):Math.min(innerHeight,this.view.scrollDOM.getBoundingClientRect().bottom)-this.dom.getBoundingClientRect().top)}syncClasses(){if(!(!this.container||this.classes==this.view.themeClasses)){for(let e of this.classes.split(" "))e&&this.container.classList.remove(e);for(let e of(this.classes=this.view.themeClasses).split(" "))e&&this.container.classList.add(e)}}}function rm(r){let e=r.nextSibling;return r.remove(),e}const showPanel=Facet.define({enables:panelPlugin});class GutterMarker extends RangeValue{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}GutterMarker.prototype.elementClass="";GutterMarker.prototype.toDOM=void 0;GutterMarker.prototype.mapMode=MapMode.TrackBefore;GutterMarker.prototype.startSide=GutterMarker.prototype.endSide=-1;GutterMarker.prototype.point=!0;const gutterLineClass=Facet.define(),defaults$1={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>RangeSet.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{}},activeGutters=Facet.define();function gutter(r){return[gutters(),activeGutters.of(Object.assign(Object.assign({},defaults$1),r))]}const unfixGutters=Facet.define({combine:r=>r.some(e=>e)});function gutters(r){return[gutterView]}const gutterView=ViewPlugin.fromClass(class{constructor(r){this.view=r,this.prevViewport=r.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.gutters=r.state.facet(activeGutters).map(e=>new SingleGutterView(r,e));for(let e of this.gutters)this.dom.appendChild(e.dom);this.fixed=!r.state.facet(unfixGutters),this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),r.scrollDOM.insertBefore(this.dom,r.contentDOM)}update(r){if(this.updateGutters(r)){let e=this.prevViewport,n=r.view.viewport,s=Math.min(e.to,n.to)-Math.max(e.from,n.from);this.syncGutters(s<(n.to-n.from)*.8)}r.geometryChanged&&(this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px"),this.view.state.facet(unfixGutters)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":""),this.prevViewport=r.view.viewport}syncGutters(r){let e=this.dom.nextSibling;r&&this.dom.remove();let n=RangeSet.iter(this.view.state.facet(gutterLineClass),this.view.viewport.from),s=[],o=this.gutters.map(l=>new UpdateContext(l,this.view.viewport,-this.view.documentPadding.top));for(let l of this.view.viewportLineBlocks)if(s.length&&(s=[]),Array.isArray(l.type)){let a=!0;for(let c of l.type)if(c.type==BlockType.Text&&a){advanceCursor(n,s,c.from);for(let h of o)h.line(this.view,c,s);a=!1}else if(c.widget)for(let h of o)h.widget(this.view,c)}else if(l.type==BlockType.Text){advanceCursor(n,s,l.from);for(let a of o)a.line(this.view,l,s)}else if(l.widget)for(let a of o)a.widget(this.view,l);for(let l of o)l.finish();r&&this.view.scrollDOM.insertBefore(this.dom,e)}updateGutters(r){let e=r.startState.facet(activeGutters),n=r.state.facet(activeGutters),s=r.docChanged||r.heightChanged||r.viewportChanged||!RangeSet.eq(r.startState.facet(gutterLineClass),r.state.facet(gutterLineClass),r.view.viewport.from,r.view.viewport.to);if(e==n)for(let o of this.gutters)o.update(r)&&(s=!0);else{s=!0;let o=[];for(let l of n){let a=e.indexOf(l);a<0?o.push(new SingleGutterView(this.view,l)):(this.gutters[a].update(r),o.push(this.gutters[a]))}for(let l of this.gutters)l.dom.remove(),o.indexOf(l)<0&&l.destroy();for(let l of o)this.dom.appendChild(l.dom);this.gutters=o}return s}destroy(){for(let r of this.gutters)r.destroy();this.dom.remove()}},{provide:r=>EditorView.scrollMargins.of(e=>{let n=e.plugin(r);return!n||n.gutters.length==0||!n.fixed?null:e.textDirection==Direction.LTR?{left:n.dom.offsetWidth*e.scaleX}:{right:n.dom.offsetWidth*e.scaleX}})});function asArray(r){return Array.isArray(r)?r:[r]}function advanceCursor(r,e,n){for(;r.value&&r.from<=n;)r.from==n&&e.push(r.value),r.next()}class UpdateContext{constructor(e,n,s){this.gutter=e,this.height=s,this.i=0,this.cursor=RangeSet.iter(e.markers,n.from)}addElement(e,n,s){let{gutter:o}=this,l=(n.top-this.height)/e.scaleY,a=n.height/e.scaleY;if(this.i==o.elements.length){let c=new GutterElement(e,a,l,s);o.elements.push(c),o.dom.appendChild(c.dom)}else o.elements[this.i].update(e,a,l,s);this.height=n.bottom,this.i++}line(e,n,s){let o=[];advanceCursor(this.cursor,o,n.from),s.length&&(o=o.concat(s));let l=this.gutter.config.lineMarker(e,n,o);l&&o.unshift(l);let a=this.gutter;o.length==0&&!a.config.renderEmptyElements||this.addElement(e,n,o)}widget(e,n){let s=this.gutter.config.widgetMarker(e,n.widget,n);s&&this.addElement(e,n,[s])}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let n=e.elements.pop();e.dom.removeChild(n.dom),n.destroy()}}}class SingleGutterView{constructor(e,n){this.view=e,this.config=n,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let s in n.domEventHandlers)this.dom.addEventListener(s,o=>{let l=o.target,a;if(l!=this.dom&&this.dom.contains(l)){for(;l.parentNode!=this.dom;)l=l.parentNode;let h=l.getBoundingClientRect();a=(h.top+h.bottom)/2}else a=o.clientY;let c=e.lineBlockAtHeight(a-e.documentTop);n.domEventHandlers[s](e,c,o)&&o.preventDefault()});this.markers=asArray(n.markers(e)),n.initialSpacer&&(this.spacer=new GutterElement(e,0,0,[n.initialSpacer(e)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(e){let n=this.markers;if(this.markers=asArray(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let o=this.config.updateSpacer(this.spacer.markers[0],e);o!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[o])}let s=e.view.viewport;return!RangeSet.eq(this.markers,n,s.from,s.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(e):!1)}destroy(){for(let e of this.elements)e.destroy()}}class GutterElement{constructor(e,n,s,o){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(e,n,s,o)}update(e,n,s,o){this.height!=n&&(this.height=n,this.dom.style.height=n+"px"),this.above!=s&&(this.dom.style.marginTop=(this.above=s)?s+"px":""),sameMarkers(this.markers,o)||this.setMarkers(e,o)}setMarkers(e,n){let s="cm-gutterElement",o=this.dom.firstChild;for(let l=0,a=0;;){let c=a,h=ll(c,h,f)||a(c,h,f):a}return s}})}});class NumberMarker extends GutterMarker{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}}function formatNumber(r,e){return r.state.facet(lineNumberConfig).formatNumber(e,r.state)}const lineNumberGutter=activeGutters.compute([lineNumberConfig],r=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(e){return e.state.facet(lineNumberMarkers)},lineMarker(e,n,s){return s.some(o=>o.toDOM)?null:new NumberMarker(formatNumber(e,e.state.doc.lineAt(n.from).number))},widgetMarker:()=>null,lineMarkerChange:e=>e.startState.facet(lineNumberConfig)!=e.state.facet(lineNumberConfig),initialSpacer(e){return new NumberMarker(formatNumber(e,maxLineNumber(e.state.doc.lines)))},updateSpacer(e,n){let s=formatNumber(n.view,maxLineNumber(n.view.state.doc.lines));return s==e.number?e:new NumberMarker(s)},domEventHandlers:r.facet(lineNumberConfig).domEventHandlers}));function lineNumbers(r={}){return[lineNumberConfig.of(r),gutters(),lineNumberGutter]}function maxLineNumber(r){let e=9;for(;e{let e=[],n=-1;for(let s of r.selection.ranges){let o=r.doc.lineAt(s.head).from;o>n&&(n=o,e.push(activeLineGutterMarker.range(o)))}return RangeSet.of(e)});function highlightActiveLineGutter(){return activeLineGutterHighlighter}function crelt(){var r=arguments[0];typeof r=="string"&&(r=document.createElement(r));var e=1,n=arguments[1];if(n&&typeof n=="object"&&n.nodeType==null&&!Array.isArray(n)){for(var s in n)if(Object.prototype.hasOwnProperty.call(n,s)){var o=n[s];typeof o=="string"?r.setAttribute(s,o):o!=null&&(r[s]=o)}e++}for(;ec.from==c.to||c.from==c.to-1&&s.doc.lineAt(c.from).to==c.from?Decoration.widget({widget:new DiagnosticWidget(c),diagnostic:c}).range(c.from):Decoration.mark({attributes:{class:"cm-lintRange cm-lintRange-"+c.severity+(c.markClass?" "+c.markClass:"")},diagnostic:c,inclusive:!0}).range(c.from,c.to)),!0);return new LintState(a,n,findDiagnostic(a))}}function findDiagnostic(r,e=null,n=0){let s=null;return r.between(n,1e9,(o,l,{spec:a})=>{if(!(e&&a.diagnostic!=e))return s=new SelectedDiagnostic(o,l,a.diagnostic),!1}),s}function hideTooltip(r,e){let n=e.pos,s=e.end||n,o=r.state.facet(lintConfig).hideOn(r,n,s);if(o!=null)return o;let l=r.startState.doc.lineAt(e.pos);return!!(r.effects.some(a=>a.is(setDiagnosticsEffect))||r.changes.touchesRange(l.from,Math.max(l.to,s)))}function maybeEnableLint(r,e){return r.field(lintState,!1)?e:e.concat(StateEffect.appendConfig.of(lintExtensions))}const setDiagnosticsEffect=StateEffect.define(),togglePanel$1=StateEffect.define(),movePanelSelection=StateEffect.define(),lintState=StateField.define({create(){return new LintState(Decoration.none,null,null)},update(r,e){if(e.docChanged&&r.diagnostics.size){let n=r.diagnostics.map(e.changes),s=null,o=r.panel;if(r.selected){let l=e.changes.mapPos(r.selected.from,1);s=findDiagnostic(n,r.selected.diagnostic,l)||findDiagnostic(n,null,l)}!n.size&&o&&e.state.facet(lintConfig).autoPanel&&(o=null),r=new LintState(n,o,s)}for(let n of e.effects)if(n.is(setDiagnosticsEffect)){let s=e.state.facet(lintConfig).autoPanel?n.value.length?LintPanel.open:null:r.panel;r=LintState.init(n.value,s,e.state)}else n.is(togglePanel$1)?r=new LintState(r.diagnostics,n.value?LintPanel.open:null,r.selected):n.is(movePanelSelection)&&(r=new LintState(r.diagnostics,r.panel,n.value));return r},provide:r=>[showPanel.from(r,e=>e.panel),EditorView.decorations.from(r,e=>e.diagnostics)]}),activeMark=Decoration.mark({class:"cm-lintRange cm-lintRange-active",inclusive:!0});function lintTooltip(r,e,n){let{diagnostics:s}=r.state.field(lintState),o=[],l=2e8,a=0;s.between(e-(n<0?1:0),e+(n>0?1:0),(h,f,{spec:u})=>{e>=h&&e<=f&&(h==f||(e>h||n>0)&&(erenderDiagnostic(r,n,!1)))}const openLintPanel=r=>{let e=r.state.field(lintState,!1);(!e||!e.panel)&&r.dispatch({effects:maybeEnableLint(r.state,[togglePanel$1.of(!0)])});let n=getPanel(r,LintPanel.open);return n&&n.dom.querySelector(".cm-panel-lint ul").focus(),!0},closeLintPanel=r=>{let e=r.state.field(lintState,!1);return!e||!e.panel?!1:(r.dispatch({effects:togglePanel$1.of(!1)}),!0)},nextDiagnostic=r=>{let e=r.state.field(lintState,!1);if(!e)return!1;let n=r.state.selection.main,s=e.diagnostics.iter(n.to+1);return!s.value&&(s=e.diagnostics.iter(0),!s.value||s.from==n.from&&s.to==n.to)?!1:(r.dispatch({selection:{anchor:s.from,head:s.to},scrollIntoView:!0}),!0)},lintKeymap=[{key:"Mod-Shift-m",run:openLintPanel,preventDefault:!0},{key:"F8",run:nextDiagnostic}],lintConfig=Facet.define({combine(r){return Object.assign({sources:r.map(e=>e.source).filter(e=>e!=null)},combineConfig(r.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{needsRefresh:(e,n)=>e?n?s=>e(s)||n(s):e:n}))}});function assignKeys(r){let e=[];if(r)e:for(let{name:n}of r){for(let s=0;sl.toLowerCase()==o.toLowerCase())){e.push(o);continue e}}e.push("")}return e}function renderDiagnostic(r,e,n){var s;let o=n?assignKeys(e.actions):[];return crelt("li",{class:"cm-diagnostic cm-diagnostic-"+e.severity},crelt("span",{class:"cm-diagnosticText"},e.renderMessage?e.renderMessage(r):e.message),(s=e.actions)===null||s===void 0?void 0:s.map((l,a)=>{let c=!1,h=g=>{if(g.preventDefault(),c)return;c=!0;let O=findDiagnostic(r.state.field(lintState).diagnostics,e);O&&l.apply(r,O.from,O.to)},{name:f}=l,u=o[a]?f.indexOf(o[a]):-1,d=u<0?f:[f.slice(0,u),crelt("u",f.slice(u,u+1)),f.slice(u+1)];return crelt("button",{type:"button",class:"cm-diagnosticAction",onclick:h,onmousedown:h,"aria-label":` Action: ${f}${u<0?"":` (access key "${o[a]})"`}.`},d)}),e.source&&crelt("div",{class:"cm-diagnosticSource"},e.source))}class DiagnosticWidget extends WidgetType{constructor(e){super(),this.diagnostic=e}eq(e){return e.diagnostic==this.diagnostic}toDOM(){return crelt("span",{class:"cm-lintPoint cm-lintPoint-"+this.diagnostic.severity})}}class PanelItem{constructor(e,n){this.diagnostic=n,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=renderDiagnostic(e,n,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class LintPanel{constructor(e){this.view=e,this.items=[];let n=o=>{if(o.keyCode==27)closeLintPanel(this.view),this.view.focus();else if(o.keyCode==38||o.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(o.keyCode==40||o.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(o.keyCode==36)this.moveSelection(0);else if(o.keyCode==35)this.moveSelection(this.items.length-1);else if(o.keyCode==13)this.view.focus();else if(o.keyCode>=65&&o.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:l}=this.items[this.selectedIndex],a=assignKeys(l.actions);for(let c=0;c{for(let l=0;lcloseLintPanel(this.view)},"×")),this.update()}get selectedIndex(){let e=this.view.state.field(lintState).selected;if(!e)return-1;for(let n=0;n{let f=-1,u;for(let d=s;ds&&(this.items.splice(s,f-s),o=!0)),n&&u.diagnostic==n.diagnostic?u.dom.hasAttribute("aria-selected")||(u.dom.setAttribute("aria-selected","true"),l=u):u.dom.hasAttribute("aria-selected")&&u.dom.removeAttribute("aria-selected"),s++});s({sel:l.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:a,panel:c})=>{let h=c.height/this.list.offsetHeight;a.topc.bottom&&(this.list.scrollTop+=(a.bottom-c.bottom)/h)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),o&&this.sync()}sync(){let e=this.list.firstChild;function n(){let s=e;e=s.nextSibling,s.remove()}for(let s of this.items)if(s.dom.parentNode==this.list){for(;e!=s.dom;)n();e=s.dom.nextSibling}else this.list.insertBefore(s.dom,e);for(;e;)n()}moveSelection(e){if(this.selectedIndex<0)return;let n=this.view.state.field(lintState),s=findDiagnostic(n.diagnostics,this.items[e].diagnostic);s&&this.view.dispatch({selection:{anchor:s.from,head:s.to},scrollIntoView:!0,effects:movePanelSelection.of(s)})}static open(e){return new LintPanel(e)}}function svg(r,e='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,${encodeURIComponent(r)}')`}function underline(r){return svg(``,'width="6" height="3"')}const baseTheme$4=EditorView.baseTheme({".cm-diagnostic":{padding:"3px 6px 3px 8px",marginLeft:"-1px",display:"block",whiteSpace:"pre-wrap"},".cm-diagnostic-error":{borderLeft:"5px solid #d11"},".cm-diagnostic-warning":{borderLeft:"5px solid orange"},".cm-diagnostic-info":{borderLeft:"5px solid #999"},".cm-diagnostic-hint":{borderLeft:"5px solid #66d"},".cm-diagnosticAction":{font:"inherit",border:"none",padding:"2px 4px",backgroundColor:"#444",color:"white",borderRadius:"3px",marginLeft:"8px",cursor:"pointer"},".cm-diagnosticSource":{fontSize:"70%",opacity:.7},".cm-lintRange":{backgroundPosition:"left bottom",backgroundRepeat:"repeat-x",paddingBottom:"0.7px"},".cm-lintRange-error":{backgroundImage:underline("#d11")},".cm-lintRange-warning":{backgroundImage:underline("orange")},".cm-lintRange-info":{backgroundImage:underline("#999")},".cm-lintRange-hint":{backgroundImage:underline("#66d")},".cm-lintRange-active":{backgroundColor:"#ffdd9980"},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:"relative","&:after":{content:'""',position:"absolute",bottom:0,left:"-2px",borderLeft:"3px solid transparent",borderRight:"3px solid transparent",borderBottom:"4px solid #d11"}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:"orange"}},".cm-lintPoint-info":{"&:after":{borderBottomColor:"#999"}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:"#66d"}},".cm-panel.cm-panel-lint":{position:"relative","& ul":{maxHeight:"100px",overflowY:"auto","& [aria-selected]":{backgroundColor:"#ddd","& u":{textDecoration:"underline"}},"&:focus [aria-selected]":{background_fallback:"#bdf",backgroundColor:"Highlight",color_fallback:"white",color:"HighlightText"},"& u":{textDecoration:"none"},padding:0,margin:0},"& [name=close]":{position:"absolute",top:"0",right:"2px",background:"inherit",border:"none",font:"inherit",padding:0,margin:0}}}),lintExtensions=[lintState,EditorView.decorations.compute([lintState],r=>{let{selected:e,panel:n}=r.field(lintState);return!e||!n||e.from==e.to?Decoration.none:Decoration.set([activeMark.range(e.from,e.to)])}),hoverTooltip(lintTooltip,{hideOn:hideTooltip}),baseTheme$4],DefaultBufferLength=1024;let nextPropID=0;class Range{constructor(e,n){this.from=e,this.to=n}}class NodeProp{constructor(e={}){this.id=nextPropID++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")})}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof e!="function"&&(e=NodeType.match(e)),n=>{let s=e(n);return s===void 0?null:[this,s]}}}NodeProp.closedBy=new NodeProp({deserialize:r=>r.split(" ")});NodeProp.openedBy=new NodeProp({deserialize:r=>r.split(" ")});NodeProp.group=new NodeProp({deserialize:r=>r.split(" ")});NodeProp.isolate=new NodeProp({deserialize:r=>{if(r&&r!="rtl"&&r!="ltr"&&r!="auto")throw new RangeError("Invalid value for isolate: "+r);return r||"auto"}});NodeProp.contextHash=new NodeProp({perNode:!0});NodeProp.lookAhead=new NodeProp({perNode:!0});NodeProp.mounted=new NodeProp({perNode:!0});class MountedTree{constructor(e,n,s){this.tree=e,this.overlay=n,this.parser=s}static get(e){return e&&e.props&&e.props[NodeProp.mounted.id]}}const noProps=Object.create(null);class NodeType{constructor(e,n,s,o=0){this.name=e,this.props=n,this.id=s,this.flags=o}static define(e){let n=e.props&&e.props.length?Object.create(null):noProps,s=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),o=new NodeType(e.name||"",n,e.id,s);if(e.props){for(let l of e.props)if(Array.isArray(l)||(l=l(o)),l){if(l[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");n[l[0].id]=l[1]}}return o}prop(e){return this.props[e.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(e){if(typeof e=="string"){if(this.name==e)return!0;let n=this.prop(NodeProp.group);return n?n.indexOf(e)>-1:!1}return this.id==e}static match(e){let n=Object.create(null);for(let s in e)for(let o of s.split(" "))n[o]=e[s];return s=>{for(let o=s.prop(NodeProp.group),l=-1;l<(o?o.length:0);l++){let a=n[l<0?s.name:o[l]];if(a)return a}}}}NodeType.none=new NodeType("",Object.create(null),0,8);class NodeSet{constructor(e){this.types=e;for(let n=0;n0;for(let h=this.cursor(a|IterMode.IncludeAnonymous);;){let f=!1;if(h.from<=l&&h.to>=o&&(!c&&h.type.isAnonymous||n(h)!==!1)){if(h.firstChild())continue;f=!0}for(;f&&s&&(c||!h.type.isAnonymous)&&s(h),!h.nextSibling();){if(!h.parent())return;f=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let n in this.props)e.push([+n,this.props[n]]);return e}balance(e={}){return this.children.length<=8?this:balanceRange(NodeType.none,this.children,this.positions,0,this.children.length,0,this.length,(n,s,o)=>new Tree(this.type,n,s,o,this.propValues),e.makeTree||((n,s,o)=>new Tree(NodeType.none,n,s,o)))}static build(e){return buildTree(e)}}Tree.empty=new Tree(NodeType.none,[],[],0);class FlatBufferCursor{constructor(e,n){this.buffer=e,this.index=n}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new FlatBufferCursor(this.buffer,this.index)}}class TreeBuffer{constructor(e,n,s){this.buffer=e,this.length=n,this.set=s}get type(){return NodeType.none}toString(){let e=[];for(let n=0;n0));h=a[h+3]);return c}slice(e,n,s){let o=this.buffer,l=new Uint16Array(n-e),a=0;for(let c=e,h=0;c=e&&ne;case 1:return n<=e&&s>e;case 2:return s>e;case 4:return!0}}function resolveNode(r,e,n,s){for(var o;r.from==r.to||(n<1?r.from>=e:r.from>e)||(n>-1?r.to<=e:r.to0?c.length:-1;e!=f;e+=n){let u=c[e],d=h[e]+a.from;if(checkSide(o,s,d,d+u.length)){if(u instanceof TreeBuffer){if(l&IterMode.ExcludeBuffers)continue;let g=u.findChild(0,u.buffer.length,n,s-d,o);if(g>-1)return new BufferNode(new BufferContext(a,u,e,d),null,g)}else if(l&IterMode.IncludeAnonymous||!u.type.isAnonymous||hasChild(u)){let g;if(!(l&IterMode.IgnoreMounts)&&(g=MountedTree.get(u))&&!g.overlay)return new TreeNode(g.tree,d,e,a);let O=new TreeNode(u,d,e,a);return l&IterMode.IncludeAnonymous||!O.type.isAnonymous?O:O.nextChild(n<0?u.children.length-1:0,n,s,o)}}}if(l&IterMode.IncludeAnonymous||!a.type.isAnonymous||(a.index>=0?e=a.index+n:e=n<0?-1:a._parent._tree.children.length,a=a._parent,!a))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}enter(e,n,s=0){let o;if(!(s&IterMode.IgnoreOverlays)&&(o=MountedTree.get(this._tree))&&o.overlay){let l=e-this.from;for(let{from:a,to:c}of o.overlay)if((n>0?a<=l:a=l:c>l))return new TreeNode(o.tree,o.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,n,s)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function getChildren(r,e,n,s){let o=r.cursor(),l=[];if(!o.firstChild())return l;if(n!=null){for(let a=!1;!a;)if(a=o.type.is(n),!o.nextSibling())return l}for(;;){if(s!=null&&o.type.is(s))return l;if(o.type.is(e)&&l.push(o.node),!o.nextSibling())return s==null?l:[]}}function matchNodeContext(r,e,n=e.length-1){for(let s=r.parent;n>=0;s=s.parent){if(!s)return!1;if(!s.type.isAnonymous){if(e[n]&&e[n]!=s.name)return!1;n--}}return!0}class BufferContext{constructor(e,n,s,o){this.parent=e,this.buffer=n,this.index=s,this.start=o}}class BufferNode extends BaseNode{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(e,n,s){super(),this.context=e,this._parent=n,this.index=s,this.type=e.buffer.set.types[e.buffer.buffer[s]]}child(e,n,s){let{buffer:o}=this.context,l=o.findChild(this.index+4,o.buffer[this.index+3],e,n-this.context.start,s);return l<0?null:new BufferNode(this.context,this,l)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}enter(e,n,s=0){if(s&IterMode.ExcludeBuffers)return null;let{buffer:o}=this.context,l=o.findChild(this.index+4,o.buffer[this.index+3],n>0?1:-1,e-this.context.start,n);return l<0?null:new BufferNode(this.context,this,l)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:e}=this.context,n=e.buffer[this.index+3];return n<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new BufferNode(this.context,this._parent,n):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,n=this._parent?this._parent.index+4:0;return this.index==n?this.externalSibling(-1):new BufferNode(this.context,this._parent,e.findChild(n,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],n=[],{buffer:s}=this.context,o=this.index+4,l=s.buffer[this.index+3];if(l>o){let a=s.buffer[this.index+1];e.push(s.slice(o,l,a)),n.push(0)}return new Tree(this.type,e,n,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function iterStack(r){if(!r.length)return null;let e=0,n=r[0];for(let l=1;ln.from||a.to=e){let c=new TreeNode(a.tree,a.overlay[0].from+l.from,-1,l);(o||(o=[s])).push(resolveNode(c,e,n,!1))}}return o?iterStack(o):s}class TreeCursor{get name(){return this.type.name}constructor(e,n=0){if(this.mode=n,this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,e instanceof TreeNode)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let s=e._parent;s;s=s._parent)this.stack.unshift(s.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return e?(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0):!1}yieldBuf(e,n){this.index=e;let{start:s,buffer:o}=this.buffer;return this.type=n||o.set.types[o.buffer[e]],this.from=s+o.buffer[e+1],this.to=s+o.buffer[e+2],!0}yield(e){return e?e instanceof TreeNode?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,n,s){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,n,s,this.mode));let{buffer:o}=this.buffer,l=o.findChild(this.index+4,o.buffer[this.index+3],e,n-this.buffer.start,s);return l<0?!1:(this.stack.push(this.index),this.yieldBuf(l))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,n,s=this.mode){return this.buffer?s&IterMode.ExcludeBuffers?!1:this.enterChild(1,e,n):this.yield(this._tree.enter(e,n,s))}parent(){if(!this.buffer)return this.yieldNode(this.mode&IterMode.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&IterMode.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode)):!1;let{buffer:n}=this.buffer,s=this.stack.length-1;if(e<0){let o=s<0?0:this.stack[s]+4;if(this.index!=o)return this.yieldBuf(n.findChild(o,this.index,-1,0,4))}else{let o=n.buffer[this.index+3];if(o<(s<0?n.buffer.length:n.buffer[this.stack[s]+3]))return this.yieldBuf(o)}return s<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let n,s,{buffer:o}=this;if(o){if(e>0){if(this.index-1)for(let l=n+e,a=e<0?-1:s._tree.children.length;l!=a;l+=e){let c=s._tree.children[l];if(this.mode&IterMode.IncludeAnonymous||c instanceof TreeBuffer||!c.type.isAnonymous||hasChild(c))return!1}return!0}move(e,n){if(n&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,n=0){for(;(this.from==this.to||(n<1?this.from>=e:this.from>e)||(n>-1?this.to<=e:this.to=0;){for(let a=e;a;a=a._parent)if(a.index==o){if(o==this.index)return a;n=a,s=l+1;break e}o=this.stack[--l]}for(let o=s;o=0;l--){if(l<0)return matchNodeContext(this.node,e,o);let a=s[n.buffer[this.stack[l]]];if(!a.isAnonymous){if(e[o]&&e[o]!=a.name)return!1;o--}}return!0}}function hasChild(r){return r.children.some(e=>e instanceof TreeBuffer||!e.type.isAnonymous||hasChild(e))}function buildTree(r){var e;let{buffer:n,nodeSet:s,maxBufferLength:o=DefaultBufferLength,reused:l=[],minRepeatType:a=s.types.length}=r,c=Array.isArray(n)?new FlatBufferCursor(n,n.length):n,h=s.types,f=0,u=0;function d(v,Q,_,W,q,Y){let{id:z,start:L,end:H,size:G}=c,ee=u;for(;G<0;)if(c.next(),G==-1){let te=l[z];_.push(te),W.push(L-v);return}else if(G==-3){f=z;return}else if(G==-4){u=z;return}else throw new RangeError(`Unrecognized record size: ${G}`);let K=h[z],j,F,se=L-v;if(H-L<=o&&(F=b(c.pos-Q,q))){let te=new Uint16Array(F.size-F.skip),oe=c.pos-F.size,re=te.length;for(;c.pos>oe;)re=w(F.start,te,re);j=new TreeBuffer(te,H-F.start,s),se=F.start-v}else{let te=c.pos-G;c.next();let oe=[],re=[],fe=z>=a?z:-1,de=0,pe=H;for(;c.pos>te;)fe>=0&&c.id==fe&&c.size>=0?(c.end<=pe-o&&(m(oe,re,L,de,c.end,pe,fe,ee),de=oe.length,pe=c.end),c.next()):Y>2500?g(L,te,oe,re):d(L,te,oe,re,fe,Y+1);if(fe>=0&&de>0&&de-1&&de>0){let ce=O(K);j=balanceRange(K,oe,re,0,oe.length,0,H-L,ce,ce)}else j=y(K,oe,re,H-L,ee-H)}_.push(j),W.push(se)}function g(v,Q,_,W){let q=[],Y=0,z=-1;for(;c.pos>Q;){let{id:L,start:H,end:G,size:ee}=c;if(ee>4)c.next();else{if(z>-1&&H=0;G-=3)L[ee++]=q[G],L[ee++]=q[G+1]-H,L[ee++]=q[G+2]-H,L[ee++]=ee;_.push(new TreeBuffer(L,q[2]-H,s)),W.push(H-v)}}function O(v){return(Q,_,W)=>{let q=0,Y=Q.length-1,z,L;if(Y>=0&&(z=Q[Y])instanceof Tree){if(!Y&&z.type==v&&z.length==W)return z;(L=z.prop(NodeProp.lookAhead))&&(q=_[Y]+z.length+L)}return y(v,Q,_,W,q)}}function m(v,Q,_,W,q,Y,z,L){let H=[],G=[];for(;v.length>W;)H.push(v.pop()),G.push(Q.pop()+_-q);v.push(y(s.types[z],H,G,Y-q,L-Y)),Q.push(q-_)}function y(v,Q,_,W,q=0,Y){if(f){let z=[NodeProp.contextHash,f];Y=Y?[z].concat(Y):[z]}if(q>25){let z=[NodeProp.lookAhead,q];Y=Y?[z].concat(Y):[z]}return new Tree(v,Q,_,W,Y)}function b(v,Q){let _=c.fork(),W=0,q=0,Y=0,z=_.end-o,L={size:0,start:0,skip:0};e:for(let H=_.pos-v;_.pos>H;){let G=_.size;if(_.id==Q&&G>=0){L.size=W,L.start=q,L.skip=Y,Y+=4,W+=4,_.next();continue}let ee=_.pos-G;if(G<0||ee=a?4:0,j=_.start;for(_.next();_.pos>ee;){if(_.size<0)if(_.size==-3)K+=4;else break e;else _.id>=a&&(K+=4);_.next()}q=j,W+=G,Y+=K}return(Q<0||W==v)&&(L.size=W,L.start=q,L.skip=Y),L.size>4?L:void 0}function w(v,Q,_){let{id:W,start:q,end:Y,size:z}=c;if(c.next(),z>=0&&W4){let H=c.pos-(z-4);for(;c.pos>H;)_=w(v,Q,_)}Q[--_]=L,Q[--_]=Y-v,Q[--_]=q-v,Q[--_]=W}else z==-3?f=W:z==-4&&(u=W);return _}let P=[],$=[];for(;c.pos>0;)d(r.start||0,r.bufferStart||0,P,$,-1,0);let A=(e=r.length)!==null&&e!==void 0?e:P.length?$[0]+P[0].length:0;return new Tree(h[r.topID],P.reverse(),$.reverse(),A)}const nodeSizeCache=new WeakMap;function nodeSize(r,e){if(!r.isAnonymous||e instanceof TreeBuffer||e.type!=r)return 1;let n=nodeSizeCache.get(e);if(n==null){n=1;for(let s of e.children){if(s.type!=r||!(s instanceof Tree)){n=1;break}n+=nodeSize(r,s)}nodeSizeCache.set(e,n)}return n}function balanceRange(r,e,n,s,o,l,a,c,h){let f=0;for(let m=s;m=u)break;Q+=_}if($==A+1){if(Q>u){let _=m[A];O(_.children,_.positions,0,_.children.length,y[A]+P);continue}d.push(m[A])}else{let _=y[$-1]+m[$-1].length-v;d.push(balanceRange(r,m,y,A,$,v,_,null,h))}g.push(v+P-l)}}return O(e,n,s,o,0),(c||h)(d,g,a)}class NodeWeakMap{constructor(){this.map=new WeakMap}setBuffer(e,n,s){let o=this.map.get(e);o||this.map.set(e,o=new Map),o.set(n,s)}getBuffer(e,n){let s=this.map.get(e);return s&&s.get(n)}set(e,n){e instanceof BufferNode?this.setBuffer(e.context.buffer,e.index,n):e instanceof TreeNode&&this.map.set(e.tree,n)}get(e){return e instanceof BufferNode?this.getBuffer(e.context.buffer,e.index):e instanceof TreeNode?this.map.get(e.tree):void 0}cursorSet(e,n){e.buffer?this.setBuffer(e.buffer.buffer,e.index,n):this.map.set(e.tree,n)}cursorGet(e){return e.buffer?this.getBuffer(e.buffer.buffer,e.index):this.map.get(e.tree)}}class TreeFragment{constructor(e,n,s,o,l=!1,a=!1){this.from=e,this.to=n,this.tree=s,this.offset=o,this.open=(l?1:0)|(a?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,n=[],s=!1){let o=[new TreeFragment(0,e.length,e,0,!1,s)];for(let l of n)l.to>e.length&&o.push(l);return o}static applyChanges(e,n,s=128){if(!n.length)return e;let o=[],l=1,a=e.length?e[0]:null;for(let c=0,h=0,f=0;;c++){let u=c=s)for(;a&&a.from=g.from||d<=g.to||f){let O=Math.max(g.from,h)-f,m=Math.min(g.to,d)-f;g=O>=m?null:new TreeFragment(O,m,g.tree,g.offset+f,c>0,!!u)}if(g&&o.push(g),a.to>d)break;a=lnew Range(o.from,o.to)):[new Range(0,0)]:[new Range(0,e.length)],this.createParse(e,n||[],s)}parse(e,n,s){let o=this.startParse(e,n,s);for(;;){let l=o.advance();if(l)return l}}}class StringInput{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,n){return this.string.slice(e,n)}}new NodeProp({perNode:!0});var define_process_env_default={};class Stack{constructor(e,n,s,o,l,a,c,h,f,u=0,d){this.p=e,this.stack=n,this.state=s,this.reducePos=o,this.pos=l,this.score=a,this.buffer=c,this.bufferBase=h,this.curContext=f,this.lookAhead=u,this.parent=d}toString(){return`[${this.stack.filter((e,n)=>n%3==0).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(e,n,s=0){let o=e.parser.context;return new Stack(e,[],n,s,s,0,[],0,o?new StackContext(o,o.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(e,n){this.stack.push(this.state,n,this.bufferBase+this.buffer.length),this.state=e}reduce(e){var n;let s=e>>19,o=e&65535,{parser:l}=this.p;this.reducePos=2e3&&!(!((n=this.p.parser.nodeSet.types[o])===null||n===void 0)&&n.isAnonymous)&&(h==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=f):this.p.lastBigReductionSizec;)this.stack.pop();this.reduceContext(o,h)}storeNode(e,n,s,o=4,l=!1){if(e==0&&(!this.stack.length||this.stack[this.stack.length-1]0&&a.buffer[c-4]==0&&a.buffer[c-1]>-1){if(n==s)return;if(a.buffer[c-2]>=n){a.buffer[c-2]=s;return}}}if(!l||this.pos==s)this.buffer.push(e,n,s,o);else{let a=this.buffer.length;if(a>0&&this.buffer[a-4]!=0)for(;a>0&&this.buffer[a-2]>s;)this.buffer[a]=this.buffer[a-4],this.buffer[a+1]=this.buffer[a-3],this.buffer[a+2]=this.buffer[a-2],this.buffer[a+3]=this.buffer[a-1],a-=4,o>4&&(o-=4);this.buffer[a]=e,this.buffer[a+1]=n,this.buffer[a+2]=s,this.buffer[a+3]=o}}shift(e,n,s,o){if(e&131072)this.pushState(e&65535,this.pos);else if(e&262144)this.pos=o,this.shiftContext(n,s),n<=this.p.parser.maxNode&&this.buffer.push(n,s,o,4);else{let l=e,{parser:a}=this.p;(o>this.pos||n<=a.maxNode)&&(this.pos=o,a.stateFlag(l,1)||(this.reducePos=o)),this.pushState(l,s),this.shiftContext(n,s),n<=a.maxNode&&this.buffer.push(n,s,o,4)}}apply(e,n,s,o){e&65536?this.reduce(e):this.shift(e,n,s,o)}useNode(e,n){let s=this.p.reused.length-1;(s<0||this.p.reused[s]!=e)&&(this.p.reused.push(e),s++);let o=this.pos;this.reducePos=this.pos=o+e.length,this.pushState(n,o),this.buffer.push(s,o,this.reducePos,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,e,this,this.p.stream.reset(this.pos-e.length)))}split(){let e=this,n=e.buffer.length;for(;n>0&&e.buffer[n-2]>e.reducePos;)n-=4;let s=e.buffer.slice(n),o=e.bufferBase+n;for(;e&&o==e.bufferBase;)e=e.parent;return new Stack(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,s,o,this.curContext,this.lookAhead,e)}recoverByDelete(e,n){let s=e<=this.p.parser.maxNode;s&&this.storeNode(e,this.pos,n,4),this.storeNode(0,this.pos,n,s?8:4),this.pos=this.reducePos=n,this.score-=190}canShift(e){for(let n=new SimulatedStack(this);;){let s=this.p.parser.stateSlot(n.state,4)||this.p.parser.hasAction(n.state,e);if(s==0)return!1;if(!(s&65536))return!0;n.reduce(s)}}recoverByInsert(e){if(this.stack.length>=300)return[];let n=this.p.parser.nextStates(this.state);if(n.length>8||this.stack.length>=120){let o=[];for(let l=0,a;lh&1&&c==a)||o.push(n[l],a)}n=o}let s=[];for(let o=0;o>19,o=n&65535,l=this.stack.length-s*3;if(l<0||e.getGoto(this.stack[l],o,!1)<0){let a=this.findForcedReduction();if(a==null)return!1;n=a}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(n),!0}findForcedReduction(){let{parser:e}=this.p,n=[],s=(o,l)=>{if(!n.includes(o))return n.push(o),e.allActions(o,a=>{if(!(a&393216))if(a&65536){let c=(a>>19)-l;if(c>1){let h=a&65535,f=this.stack.length-c*3;if(f>=0&&e.getGoto(this.stack[f],h,!1)>=0)return c<<19|65536|h}}else{let c=s(a,l+1);if(c!=null)return c}})};return s(this.state,0)}forceAll(){for(;!this.p.parser.stateFlag(this.state,2);)if(!this.forceReduce()){this.storeNode(0,this.pos,this.pos,4,!0);break}return this}get deadEnd(){if(this.stack.length!=3)return!1;let{parser:e}=this.p;return e.data[e.stateSlot(this.state,1)]==65535&&!e.stateSlot(this.state,4)}restart(){this.storeNode(0,this.pos,this.pos,4,!0),this.state=this.stack[0],this.stack.length=0}sameState(e){if(this.state!=e.state||this.stack.length!=e.stack.length)return!1;for(let n=0;nthis.lookAhead&&(this.emitLookAhead(),this.lookAhead=e)}close(){this.curContext&&this.curContext.tracker.strict&&this.emitContext(),this.lookAhead>0&&this.emitLookAhead()}}class StackContext{constructor(e,n){this.tracker=e,this.context=n,this.hash=e.strict?e.hash(n):0}}class SimulatedStack{constructor(e){this.start=e,this.state=e.state,this.stack=e.stack,this.base=this.stack.length}reduce(e){let n=e&65535,s=e>>19;s==0?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(s-1)*3;let o=this.start.p.parser.getGoto(this.stack[this.base-3],n,!0);this.state=o}}class StackBufferCursor{constructor(e,n,s){this.stack=e,this.pos=n,this.index=s,this.buffer=e.buffer,this.index==0&&this.maybeNext()}static create(e,n=e.bufferBase+e.buffer.length){return new StackBufferCursor(e,n,n-e.bufferBase)}maybeNext(){let e=this.stack.parent;e!=null&&(this.index=this.stack.bufferBase-e.bufferBase,this.stack=e,this.buffer=e.buffer)}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}next(){this.index-=4,this.pos-=4,this.index==0&&this.maybeNext()}fork(){return new StackBufferCursor(this.stack,this.pos,this.index)}}function decodeArray(r,e=Uint16Array){if(typeof r!="string")return r;let n=null;for(let s=0,o=0;s=92&&a--,a>=34&&a--;let h=a-32;if(h>=46&&(h-=46,c=!0),l+=h,c)break;l*=46}n?n[o++]=l:n=new e(l)}return n}class CachedToken{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}}const nullToken=new CachedToken;class InputStream{constructor(e,n){this.input=e,this.ranges=n,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=nullToken,this.rangeIndex=0,this.pos=this.chunkPos=n[0].from,this.range=n[0],this.end=n[n.length-1].to,this.readNext()}resolveOffset(e,n){let s=this.range,o=this.rangeIndex,l=this.pos+e;for(;ls.to:l>=s.to;){if(o==this.ranges.length-1)return null;let a=this.ranges[++o];l+=a.from-s.to,s=a}return l}clipPos(e){if(e>=this.range.from&&ee)return Math.max(e,n.from);return this.end}peek(e){let n=this.chunkOff+e,s,o;if(n>=0&&n=this.chunk2Pos&&sc.to&&(this.chunk2=this.chunk2.slice(0,c.to-s)),o=this.chunk2.charCodeAt(0)}}return s>=this.token.lookAhead&&(this.token.lookAhead=s+1),o}acceptToken(e,n=0){let s=n?this.resolveOffset(n,-1):this.pos;if(s==null||s=this.chunk2Pos&&this.posthis.range.to?e.slice(0,this.range.to-this.pos):e,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?this.next=-1:this.next=this.chunk.charCodeAt(this.chunkOff)}advance(e=1){for(this.chunkOff+=e;this.pos+e>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();e-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=e,this.pos>=this.token.lookAhead&&(this.token.lookAhead=this.pos+1),this.readNext()}setDone(){return this.pos=this.chunkPos=this.end,this.range=this.ranges[this.rangeIndex=this.ranges.length-1],this.chunk="",this.next=-1}reset(e,n){if(n?(this.token=n,n.start=e,n.lookAhead=e+1,n.value=n.extended=-1):this.token=nullToken,this.pos!=e){if(this.pos=e,e==this.end)return this.setDone(),this;for(;e=this.range.to;)this.range=this.ranges[++this.rangeIndex];e>=this.chunkPos&&e=this.chunkPos&&n<=this.chunkPos+this.chunk.length)return this.chunk.slice(e-this.chunkPos,n-this.chunkPos);if(e>=this.chunk2Pos&&n<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(e-this.chunk2Pos,n-this.chunk2Pos);if(e>=this.range.from&&n<=this.range.to)return this.input.read(e,n);let s="";for(let o of this.ranges){if(o.from>=n)break;o.to>e&&(s+=this.input.read(Math.max(o.from,e),Math.min(o.to,n)))}return s}}class TokenGroup{constructor(e,n){this.data=e,this.id=n}token(e,n){let{parser:s}=n.p;readToken(this.data,e,n,this.id,s.data,s.tokenPrecTable)}}TokenGroup.prototype.contextual=TokenGroup.prototype.fallback=TokenGroup.prototype.extend=!1;class LocalTokenGroup{constructor(e,n,s){this.precTable=n,this.elseToken=s,this.data=typeof e=="string"?decodeArray(e):e}token(e,n){let s=e.pos,o=0;for(;;){let l=e.next<0,a=e.resolveOffset(1,1);if(readToken(this.data,e,n,0,this.data,this.precTable),e.token.value>-1)break;if(this.elseToken==null)return;if(l||o++,a==null)break;e.reset(a,e.token)}o&&(e.reset(s,e.token),e.acceptToken(this.elseToken,o))}}LocalTokenGroup.prototype.contextual=TokenGroup.prototype.fallback=TokenGroup.prototype.extend=!1;class ExternalTokenizer{constructor(e,n={}){this.token=e,this.contextual=!!n.contextual,this.fallback=!!n.fallback,this.extend=!!n.extend}}function readToken(r,e,n,s,o,l){let a=0,c=1<0){let m=r[O];if(h.allows(m)&&(e.token.value==-1||e.token.value==m||overrides(m,e.token.value,o,l))){e.acceptToken(m);break}}let u=e.next,d=0,g=r[a+2];if(e.next<0&&g>d&&r[f+g*3-3]==65535){a=r[f+g*3-1];continue e}for(;d>1,m=f+O+(O<<1),y=r[m],b=r[m+1]||65536;if(u=b)d=O+1;else{a=r[m+2],e.advance();continue e}}break}}function findOffset(r,e,n){for(let s=e,o;(o=r[s])!=65535;s++)if(o==n)return s-e;return-1}function overrides(r,e,n,s){let o=findOffset(n,s,e);return o<0||findOffset(n,s,r)e)&&!s.type.isError)return n<0?Math.max(0,Math.min(s.to-1,e-25)):Math.min(r.length,Math.max(s.from+1,e+25));if(n<0?s.prevSibling():s.nextSibling())break;if(!s.parent())return n<0?0:r.length}}class FragmentCursor{constructor(e,n){this.fragments=e,this.nodeSet=n,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.nextFragment()}nextFragment(){let e=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(e){for(this.safeFrom=e.openStart?cutAt(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?cutAt(e.tree,e.to+e.offset,-1)-e.offset:e.to;this.trees.length;)this.trees.pop(),this.start.pop(),this.index.pop();this.trees.push(e.tree),this.start.push(-e.offset),this.index.push(0),this.nextStart=this.safeFrom}else this.nextStart=1e9}nodeAt(e){if(ee)return this.nextStart=a,null;if(l instanceof Tree){if(a==e){if(a=Math.max(this.safeFrom,e)&&(this.trees.push(l),this.start.push(a),this.index.push(0))}else this.index[n]++,this.nextStart=a+l.length}}}class TokenCache{constructor(e,n){this.stream=n,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(s=>new CachedToken)}getActions(e){let n=0,s=null,{parser:o}=e.p,{tokenizers:l}=o,a=o.stateSlot(e.state,3),c=e.curContext?e.curContext.hash:0,h=0;for(let f=0;fd.end+25&&(h=Math.max(d.lookAhead,h)),d.value!=0)){let g=n;if(d.extended>-1&&(n=this.addActions(e,d.extended,d.end,n)),n=this.addActions(e,d.value,d.end,n),!u.extend&&(s=d,n>g))break}}for(;this.actions.length>n;)this.actions.pop();return h&&e.setLookAhead(h),!s&&e.pos==this.stream.end&&(s=new CachedToken,s.value=e.p.parser.eofTerm,s.start=s.end=e.pos,n=this.addActions(e,s.value,s.end,n)),this.mainToken=s,this.actions}getMainToken(e){if(this.mainToken)return this.mainToken;let n=new CachedToken,{pos:s,p:o}=e;return n.start=s,n.end=Math.min(s+1,o.stream.end),n.value=s==o.stream.end?o.parser.eofTerm:0,n}updateCachedToken(e,n,s){let o=this.stream.clipPos(s.pos);if(n.token(this.stream.reset(o,e),s),e.value>-1){let{parser:l}=s.p;for(let a=0;a=0&&s.p.parser.dialect.allows(c>>1)){c&1?e.extended=c>>1:e.value=c>>1;break}}}else e.value=0,e.end=this.stream.clipPos(o+1)}putAction(e,n,s,o){for(let l=0;le.bufferLength*4?new FragmentCursor(s,e.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let e=this.stacks,n=this.minStackPos,s=this.stacks=[],o,l;if(this.bigReductionCount>300&&e.length==1){let[a]=e;for(;a.forceReduce()&&a.stack.length&&a.stack[a.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let a=0;an)s.push(c);else{if(this.advanceStack(c,s,e))continue;{o||(o=[],l=[]),o.push(c);let h=this.tokens.getMainToken(c);l.push(h.value,h.end)}}break}}if(!s.length){let a=o&&findFinished(o);if(a)return verbose&&console.log("Finish with "+this.stackID(a)),this.stackToTree(a);if(this.parser.strict)throw verbose&&o&&console.log("Stuck with token "+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):"none")),new SyntaxError("No parse at "+n);this.recovering||(this.recovering=5)}if(this.recovering&&o){let a=this.stoppedAt!=null&&o[0].pos>this.stoppedAt?o[0]:this.runRecovery(o,l,s);if(a)return verbose&&console.log("Force-finish "+this.stackID(a)),this.stackToTree(a.forceAll())}if(this.recovering){let a=this.recovering==1?1:this.recovering*3;if(s.length>a)for(s.sort((c,h)=>h.score-c.score);s.length>a;)s.pop();s.some(c=>c.reducePos>n)&&this.recovering--}else if(s.length>1){e:for(let a=0;a500&&f.buffer.length>500)if((c.score-f.score||c.buffer.length-f.buffer.length)>0)s.splice(h--,1);else{s.splice(a--,1);continue e}}}s.length>12&&s.splice(12,s.length-12)}this.minStackPos=s[0].pos;for(let a=1;a ":"";if(this.stoppedAt!=null&&o>this.stoppedAt)return e.forceReduce()?e:null;if(this.fragments){let f=e.curContext&&e.curContext.tracker.strict,u=f?e.curContext.hash:0;for(let d=this.fragments.nodeAt(o);d;){let g=this.parser.nodeSet.types[d.type.id]==d.type?l.getGoto(e.state,d.type.id):-1;if(g>-1&&d.length&&(!f||(d.prop(NodeProp.contextHash)||0)==u))return e.useNode(d,g),verbose&&console.log(a+this.stackID(e)+` (via reuse of ${l.getName(d.type.id)})`),!0;if(!(d instanceof Tree)||d.children.length==0||d.positions[0]>0)break;let O=d.children[0];if(O instanceof Tree&&d.positions[0]==0)d=O;else break}}let c=l.stateSlot(e.state,4);if(c>0)return e.reduce(c),verbose&&console.log(a+this.stackID(e)+` (via always-reduce ${l.getName(c&65535)})`),!0;if(e.stack.length>=8400)for(;e.stack.length>6e3&&e.forceReduce(););let h=this.tokens.getActions(e);for(let f=0;fo?n.push(m):s.push(m)}return!1}advanceFully(e,n){let s=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>s)return pushStackDedup(e,n),!0}}runRecovery(e,n,s){let o=null,l=!1;for(let a=0;a ":"";if(c.deadEnd&&(l||(l=!0,c.restart(),verbose&&console.log(u+this.stackID(c)+" (restarted)"),this.advanceFully(c,s))))continue;let d=c.split(),g=u;for(let O=0;d.forceReduce()&&O<10&&(verbose&&console.log(g+this.stackID(d)+" (via force-reduce)"),!this.advanceFully(d,s));O++)verbose&&(g=this.stackID(d)+" -> ");for(let O of c.recoverByInsert(h))verbose&&console.log(u+this.stackID(O)+" (via recover-insert)"),this.advanceFully(O,s);this.stream.end>c.pos?(f==c.pos&&(f++,h=0),c.recoverByDelete(h,f),verbose&&console.log(u+this.stackID(c)+` (via recover-delete ${this.parser.getName(h)})`),pushStackDedup(c,s)):(!o||o.scorer;class ContextTracker{constructor(e){this.start=e.start,this.shift=e.shift||id,this.reduce=e.reduce||id,this.reuse=e.reuse||id,this.hash=e.hash||(()=>0),this.strict=e.strict!==!1}}class LRParser extends Parser{constructor(e){if(super(),this.wrappers=[],e.version!=14)throw new RangeError(`Parser version (${e.version}) doesn't match runtime version (14)`);let n=e.nodeNames.split(" ");this.minRepeatTerm=n.length;for(let c=0;ce.topRules[c][1]),o=[];for(let c=0;c=0)l(u,h,c[f++]);else{let d=c[f+-u];for(let g=-u;g>0;g--)l(c[f++],h,d);f++}}}this.nodeSet=new NodeSet(n.map((c,h)=>NodeType.define({name:h>=this.minRepeatTerm?void 0:c,id:h,props:o[h],top:s.indexOf(h)>-1,error:h==0,skipped:e.skippedNodes&&e.skippedNodes.indexOf(h)>-1}))),e.propSources&&(this.nodeSet=this.nodeSet.extend(...e.propSources)),this.strict=!1,this.bufferLength=DefaultBufferLength;let a=decodeArray(e.tokenData);this.context=e.context,this.specializerSpecs=e.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let c=0;ctypeof c=="number"?new TokenGroup(a,c):c),this.topRules=e.topRules,this.dialects=e.dialects||{},this.dynamicPrecedences=e.dynamicPrecedences||null,this.tokenPrecTable=e.tokenPrec,this.termNames=e.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(e,n,s){let o=new Parse(this,e,n,s);for(let l of this.wrappers)o=l(o,e,n,s);return o}getGoto(e,n,s=!1){let o=this.goto;if(n>=o[0])return-1;for(let l=o[n+1];;){let a=o[l++],c=a&1,h=o[l++];if(c&&s)return h;for(let f=l+(a>>1);l0}validAction(e,n){return!!this.allActions(e,s=>s==n?!0:null)}allActions(e,n){let s=this.stateSlot(e,4),o=s?n(s):void 0;for(let l=this.stateSlot(e,1);o==null;l+=3){if(this.data[l]==65535)if(this.data[l+1]==1)l=pair(this.data,l+2);else break;o=n(pair(this.data,l+1))}return o}nextStates(e){let n=[];for(let s=this.stateSlot(e,1);;s+=3){if(this.data[s]==65535)if(this.data[s+1]==1)s=pair(this.data,s+2);else break;if(!(this.data[s+2]&1)){let o=this.data[s+1];n.some((l,a)=>a&1&&l==o)||n.push(this.data[s],o)}}return n}configure(e){let n=Object.assign(Object.create(LRParser.prototype),this);if(e.props&&(n.nodeSet=this.nodeSet.extend(...e.props)),e.top){let s=this.topRules[e.top];if(!s)throw new RangeError(`Invalid top rule name ${e.top}`);n.top=s}return e.tokenizers&&(n.tokenizers=this.tokenizers.map(s=>{let o=e.tokenizers.find(l=>l.from==s);return o?o.to:s})),e.specializers&&(n.specializers=this.specializers.slice(),n.specializerSpecs=this.specializerSpecs.map((s,o)=>{let l=e.specializers.find(c=>c.from==s.external);if(!l)return s;let a=Object.assign(Object.assign({},s),{external:l.to});return n.specializers[o]=getSpecializer(a),a})),e.contextTracker&&(n.context=e.contextTracker),e.dialect&&(n.dialect=this.parseDialect(e.dialect)),e.strict!=null&&(n.strict=e.strict),e.wrap&&(n.wrappers=n.wrappers.concat(e.wrap)),e.bufferLength!=null&&(n.bufferLength=e.bufferLength),n}hasWrappers(){return this.wrappers.length>0}getName(e){return this.termNames?this.termNames[e]:String(e<=this.maxNode&&this.nodeSet.types[e].name||e)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(e){let n=this.dynamicPrecedences;return n==null?0:n[e]||0}parseDialect(e){let n=Object.keys(this.dialects),s=n.map(()=>!1);if(e)for(let l of e.split(" ")){let a=n.indexOf(l);a>=0&&(s[a]=!0)}let o=null;for(let l=0;ls)&&n.p.parser.stateFlag(n.state,2)&&(!e||e.scorer.external(n,s)<<1|e}return r.get}let nextTagID=0;class Tag{constructor(e,n,s){this.set=e,this.base=n,this.modified=s,this.id=nextTagID++}static define(e){if(e!=null&&e.base)throw new Error("Can not derive from a modified tag");let n=new Tag([],null,[]);if(n.set.push(n),e)for(let s of e.set)n.set.push(s);return n}static defineModifier(){let e=new Modifier;return n=>n.modified.indexOf(e)>-1?n:Modifier.get(n.base||n,n.modified.concat(e).sort((s,o)=>s.id-o.id))}}let nextModifierID=0;class Modifier{constructor(){this.instances=[],this.id=nextModifierID++}static get(e,n){if(!n.length)return e;let s=n[0].instances.find(c=>c.base==e&&sameArray(n,c.modified));if(s)return s;let o=[],l=new Tag(o,e,n);for(let c of n)c.instances.push(l);let a=powerSet(n);for(let c of e.set)if(!c.modified.length)for(let h of a)o.push(Modifier.get(c,h));return l}}function sameArray(r,e){return r.length==e.length&&r.every((n,s)=>n==e[s])}function powerSet(r){let e=[[]];for(let n=0;ns.length-n.length)}function styleTags(r){let e=Object.create(null);for(let n in r){let s=r[n];Array.isArray(s)||(s=[s]);for(let o of n.split(" "))if(o){let l=[],a=2,c=o;for(let d=0;;){if(c=="..."&&d>0&&d+3==o.length){a=1;break}let g=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(c);if(!g)throw new RangeError("Invalid path: "+o);if(l.push(g[0]=="*"?"":g[0][0]=='"'?JSON.parse(g[0]):g[0]),d+=g[0].length,d==o.length)break;let O=o[d++];if(d==o.length&&O=="!"){a=0;break}if(O!="/")throw new RangeError("Invalid path: "+o);c=o.slice(d)}let h=l.length-1,f=l[h];if(!f)throw new RangeError("Invalid path: "+o);let u=new Rule(s,a,h>0?l.slice(0,h):null);e[f]=u.sort(e[f])}}return ruleNodeProp.add(e)}const ruleNodeProp=new NodeProp;class Rule{constructor(e,n,s,o){this.tags=e,this.mode=n,this.context=s,this.next=o}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth{let a=o;for(let c of l)for(let h of c.set){let f=n[h.id];if(f){a=a?a+" "+f:f;break}}return a},scope:s}}function highlightTags(r,e){let n=null;for(let s of r){let o=s.style(e);o&&(n=n?n+" "+o:o)}return n}function highlightTree(r,e,n,s=0,o=r.length){let l=new HighlightBuilder(s,Array.isArray(e)?e:[e],n);l.highlightRange(r.cursor(),s,o,"",l.highlighters),l.flush(o)}class HighlightBuilder{constructor(e,n,s){this.at=e,this.highlighters=n,this.span=s,this.class=""}startSpan(e,n){n!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=n)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,n,s,o,l){let{type:a,from:c,to:h}=e;if(c>=s||h<=n)return;a.isTop&&(l=this.highlighters.filter(O=>!O.scope||O.scope(a)));let f=o,u=getStyleTags(e)||Rule.empty,d=highlightTags(l,u.tags);if(d&&(f&&(f+=" "),f+=d,u.mode==1&&(o+=(o?" ":"")+d)),this.startSpan(Math.max(n,c),f),u.opaque)return;let g=e.tree&&e.tree.prop(NodeProp.mounted);if(g&&g.overlay){let O=e.node.enter(g.overlay[0].from+c,1),m=this.highlighters.filter(b=>!b.scope||b.scope(g.tree.type)),y=e.firstChild();for(let b=0,w=c;;b++){let P=b=$||!e.nextSibling())););if(!P||$>s)break;w=P.to+c,w>n&&(this.highlightRange(O.cursor(),Math.max(n,P.from+c),Math.min(s,w),"",m),this.startSpan(Math.min(s,w),f))}y&&e.parent()}else if(e.firstChild()){g&&(o="");do if(!(e.to<=n)){if(e.from>=s)break;this.highlightRange(e,n,s,o,l),this.startSpan(Math.min(s,e.to),f)}while(e.nextSibling());e.parent()}}}function getStyleTags(r){let e=r.type.prop(ruleNodeProp);for(;e&&e.context&&!r.matchContext(e.context);)e=e.next;return e||null}const t=Tag.define,comment=t(),name=t(),typeName=t(name),propertyName=t(name),literal=t(),string=t(literal),number=t(literal),content=t(),heading=t(content),keyword=t(),operator=t(),punctuation=t(),bracket=t(punctuation),meta=t(),tags={comment,lineComment:t(comment),blockComment:t(comment),docComment:t(comment),name,variableName:t(name),typeName,tagName:t(typeName),propertyName,attributeName:t(propertyName),className:t(name),labelName:t(name),namespace:t(name),macroName:t(name),literal,string,docString:t(string),character:t(string),attributeValue:t(string),number,integer:t(number),float:t(number),bool:t(literal),regexp:t(literal),escape:t(literal),color:t(literal),url:t(literal),keyword,self:t(keyword),null:t(keyword),atom:t(keyword),unit:t(keyword),modifier:t(keyword),operatorKeyword:t(keyword),controlKeyword:t(keyword),definitionKeyword:t(keyword),moduleKeyword:t(keyword),operator,derefOperator:t(operator),arithmeticOperator:t(operator),logicOperator:t(operator),bitwiseOperator:t(operator),compareOperator:t(operator),updateOperator:t(operator),definitionOperator:t(operator),typeOperator:t(operator),controlOperator:t(operator),punctuation,separator:t(punctuation),bracket,angleBracket:t(bracket),squareBracket:t(bracket),paren:t(bracket),brace:t(bracket),content,heading,heading1:t(heading),heading2:t(heading),heading3:t(heading),heading4:t(heading),heading5:t(heading),heading6:t(heading),contentSeparator:t(content),list:t(content),quote:t(content),emphasis:t(content),strong:t(content),link:t(content),monospace:t(content),strikethrough:t(content),inserted:t(),deleted:t(),changed:t(),invalid:t(),meta,documentMeta:t(meta),annotation:t(meta),processingInstruction:t(meta),definition:Tag.defineModifier(),constant:Tag.defineModifier(),function:Tag.defineModifier(),standard:Tag.defineModifier(),local:Tag.defineModifier(),special:Tag.defineModifier()};tagHighlighter([{tag:tags.link,class:"tok-link"},{tag:tags.heading,class:"tok-heading"},{tag:tags.emphasis,class:"tok-emphasis"},{tag:tags.strong,class:"tok-strong"},{tag:tags.keyword,class:"tok-keyword"},{tag:tags.atom,class:"tok-atom"},{tag:tags.bool,class:"tok-bool"},{tag:tags.url,class:"tok-url"},{tag:tags.labelName,class:"tok-labelName"},{tag:tags.inserted,class:"tok-inserted"},{tag:tags.deleted,class:"tok-deleted"},{tag:tags.literal,class:"tok-literal"},{tag:tags.string,class:"tok-string"},{tag:tags.number,class:"tok-number"},{tag:[tags.regexp,tags.escape,tags.special(tags.string)],class:"tok-string2"},{tag:tags.variableName,class:"tok-variableName"},{tag:tags.local(tags.variableName),class:"tok-variableName tok-local"},{tag:tags.definition(tags.variableName),class:"tok-variableName tok-definition"},{tag:tags.special(tags.variableName),class:"tok-variableName2"},{tag:tags.definition(tags.propertyName),class:"tok-propertyName tok-definition"},{tag:tags.typeName,class:"tok-typeName"},{tag:tags.namespace,class:"tok-namespace"},{tag:tags.className,class:"tok-className"},{tag:tags.macroName,class:"tok-macroName"},{tag:tags.propertyName,class:"tok-propertyName"},{tag:tags.operator,class:"tok-operator"},{tag:tags.comment,class:"tok-comment"},{tag:tags.meta,class:"tok-meta"},{tag:tags.invalid,class:"tok-invalid"},{tag:tags.punctuation,class:"tok-punctuation"}]);const noSemi=312,incdec=1,incdecPrefix=2,questionDot=3,JSXStartTag=4,insertSemi=313,spaces=315,newline=316,LineComment=5,BlockComment=6,Dialect_jsx=0,space=[9,10,11,12,13,32,133,160,5760,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8232,8233,8239,8287,12288],braceR=125,semicolon=59,slash=47,star=42,plus=43,minus=45,lt=60,comma=44,question=63,dot=46,trackNewline=new ContextTracker({start:!1,shift(r,e){return e==LineComment||e==BlockComment||e==spaces?r:e==newline},strict:!1}),insertSemicolon=new ExternalTokenizer((r,e)=>{let{next:n}=r;(n==braceR||n==-1||e.context)&&r.acceptToken(insertSemi)},{contextual:!0,fallback:!0}),noSemicolon=new ExternalTokenizer((r,e)=>{let{next:n}=r,s;space.indexOf(n)>-1||n==slash&&((s=r.peek(1))==slash||s==star)||n!=braceR&&n!=semicolon&&n!=-1&&!e.context&&r.acceptToken(noSemi)},{contextual:!0}),operatorToken=new ExternalTokenizer((r,e)=>{let{next:n}=r;if(n==plus||n==minus){if(r.advance(),n==r.next){r.advance();let s=!e.context&&e.canShift(incdec);r.acceptToken(s?incdec:incdecPrefix)}}else n==question&&r.peek(1)==dot&&(r.advance(),r.advance(),(r.next<48||r.next>57)&&r.acceptToken(questionDot))},{contextual:!0});function identifierChar(r,e){return r>=65&&r<=90||r>=97&&r<=122||r==95||r>=192||!e&&r>=48&&r<=57}const jsx=new ExternalTokenizer((r,e)=>{if(r.next!=lt||!e.dialectEnabled(Dialect_jsx)||(r.advance(),r.next==slash))return;let n=0;for(;space.indexOf(r.next)>-1;)r.advance(),n++;if(identifierChar(r.next,!0)){for(r.advance(),n++;identifierChar(r.next,!1);)r.advance(),n++;for(;space.indexOf(r.next)>-1;)r.advance(),n++;if(r.next==comma)return;for(let s=0;;s++){if(s==7){if(!identifierChar(r.next,!0))return;break}if(r.next!="extends".charCodeAt(s))break;r.advance(),n++}}r.acceptToken(JSXStartTag,-n)}),jsHighlight=styleTags({"get set async static":tags.modifier,"for while do if else switch try catch finally return throw break continue default case":tags.controlKeyword,"in of await yield void typeof delete instanceof":tags.operatorKeyword,"let var const using function class extends":tags.definitionKeyword,"import export from":tags.moduleKeyword,"with debugger as new":tags.keyword,TemplateString:tags.special(tags.string),super:tags.atom,BooleanLiteral:tags.bool,this:tags.self,null:tags.null,Star:tags.modifier,VariableName:tags.variableName,"CallExpression/VariableName TaggedTemplateExpression/VariableName":tags.function(tags.variableName),VariableDefinition:tags.definition(tags.variableName),Label:tags.labelName,PropertyName:tags.propertyName,PrivatePropertyName:tags.special(tags.propertyName),"CallExpression/MemberExpression/PropertyName":tags.function(tags.propertyName),"FunctionDeclaration/VariableDefinition":tags.function(tags.definition(tags.variableName)),"ClassDeclaration/VariableDefinition":tags.definition(tags.className),PropertyDefinition:tags.definition(tags.propertyName),PrivatePropertyDefinition:tags.definition(tags.special(tags.propertyName)),UpdateOp:tags.updateOperator,"LineComment Hashbang":tags.lineComment,BlockComment:tags.blockComment,Number:tags.number,String:tags.string,Escape:tags.escape,ArithOp:tags.arithmeticOperator,LogicOp:tags.logicOperator,BitOp:tags.bitwiseOperator,CompareOp:tags.compareOperator,RegExp:tags.regexp,Equals:tags.definitionOperator,Arrow:tags.function(tags.punctuation),": Spread":tags.punctuation,"( )":tags.paren,"[ ]":tags.squareBracket,"{ }":tags.brace,"InterpolationStart InterpolationEnd":tags.special(tags.brace),".":tags.derefOperator,", ;":tags.separator,"@":tags.meta,TypeName:tags.typeName,TypeDefinition:tags.definition(tags.typeName),"type enum interface implements namespace module declare":tags.definitionKeyword,"abstract global Privacy readonly override":tags.modifier,"is keyof unique infer":tags.operatorKeyword,JSXAttributeValue:tags.attributeValue,JSXText:tags.content,"JSXStartTag JSXStartCloseTag JSXSelfCloseEndTag JSXEndTag":tags.angleBracket,"JSXIdentifier JSXNameSpacedName":tags.tagName,"JSXAttribute/JSXIdentifier JSXAttribute/JSXNameSpacedName":tags.attributeName,"JSXBuiltin/JSXIdentifier":tags.standard(tags.tagName)}),spec_identifier={__proto__:null,export:20,as:25,from:33,default:36,async:41,function:42,extends:54,this:58,true:66,false:66,null:78,void:82,typeof:86,super:102,new:136,delete:148,yield:157,await:161,class:166,public:229,private:229,protected:229,readonly:231,instanceof:250,satisfies:253,in:254,const:256,import:290,keyof:345,unique:349,infer:355,is:391,abstract:411,implements:413,type:415,let:418,var:420,using:423,interface:429,enum:433,namespace:439,module:441,declare:445,global:449,for:468,of:477,while:480,with:484,do:488,if:492,else:494,switch:498,case:504,try:510,catch:514,finally:518,return:522,throw:526,break:530,continue:534,debugger:538},spec_word={__proto__:null,async:123,get:125,set:127,declare:189,public:191,private:191,protected:191,static:193,abstract:195,override:197,readonly:203,accessor:205,new:395},spec_LessThan={__proto__:null,"<":187},parser=LRParser.deserialize({version:14,states:"$@QO%TQ^OOO%[Q^OOO'_Q`OOP(lOWOOO*zQ?NdO'#CiO+RO!bO'#CjO+aO#tO'#CjO+oO!0LbO'#D^O.QQ^O'#DdO.bQ^O'#DoO%[Q^O'#DwO0fQ^O'#EPOOQ?Mr'#EX'#EXO1PQWO'#EUOOQO'#Em'#EmOOQO'#Ih'#IhO1XQWO'#GpO1dQWO'#ElO1iQWO'#ElO3hQ?NdO'#JmO6[Q?NdO'#JnO6uQWO'#F[O6zQ&jO'#FsOOQ?Mr'#Fe'#FeO7VO,YO'#FeO7eQ7[O'#FzO9RQWO'#FyOOQ?Mr'#Jn'#JnOOQ?Mp'#Jm'#JmO9WQWO'#GtOOQU'#KZ'#KZO9cQWO'#IUO9hQ?MxO'#IVOOQU'#JZ'#JZOOQU'#IZ'#IZQ`Q^OOO`Q^OOO9pQMnO'#DsO9wQ^O'#D{O:OQ^O'#D}O9^QWO'#GpO:VQ7[O'#CoO:eQWO'#EkO:pQWO'#EvO:uQ7[O'#FdO;dQWO'#GpOOQO'#K['#K[O;iQWO'#K[O;wQWO'#GxO;wQWO'#GyO;wQWO'#G{O9^QWO'#HOOVQWO'#CeO>gQWO'#H_O>oQWO'#HeO>oQWO'#HgO`Q^O'#HiO>oQWO'#HkO>oQWO'#HnO>tQWO'#HtO>yQ?MyO'#HzO%[Q^O'#H|O?UQ?MyO'#IOO?aQ?MyO'#IQO9hQ?MxO'#ISO?lQ?NdO'#CiO@nQ`O'#DiQOQWOOO%[Q^O'#D}OAUQWO'#EQO:VQ7[O'#EkOAaQWO'#EkOAlQpO'#FdOOQU'#Cg'#CgOOQ?Mp'#Dn'#DnOOQ?Mp'#Jq'#JqO%[Q^O'#JqOOQO'#Jt'#JtOOQO'#Id'#IdOBlQ`O'#EdOOQ?Mp'#Ec'#EcOOQ?Mp'#Jx'#JxOChQ?NQO'#EdOCrQ`O'#ETOOQO'#Js'#JsODWQ`O'#JtOEeQ`O'#ETOCrQ`O'#EdPErO#@ItO'#CbPOOO)CDx)CDxOOOO'#I['#I[OE}O!bO,59UOOQ?Mr,59U,59UOOOO'#I]'#I]OF]O#tO,59UO%[Q^O'#D`OOOO'#I_'#I_OFkO!0LbO,59xOOQ?Mr,59x,59xOFyQ^O'#I`OG^QWO'#JoOI]QrO'#JoO+}Q^O'#JoOIdQWO,5:OOIzQWO'#EmOJXQWO'#KOOJdQWO'#J}OJdQWO'#J}OJlQWO,5;ZOJqQWO'#J|OOQ?Mv,5:Z,5:ZOJxQ^O,5:ZOLvQ?NdO,5:cOMgQWO,5:kONQQ?MxO'#J{ONXQWO'#JzO9WQWO'#JzONmQWO'#JzONuQWO,5;YONzQWO'#JzO!#PQrO'#JnOOQ?Mr'#Ci'#CiO%[Q^O'#EPO!#oQrO,5:pOOQQ'#Ju'#JuOOQO-EpOOQU'#Jc'#JcOOQU,5>q,5>qOOQU-EtQWO'#HTO9^QWO'#HVO!DgQWO'#HVO:VQ7[O'#HXO!DlQWO'#HXOOQU,5=m,5=mO!DqQWO'#HYO!ESQWO'#CoO!EXQWO,59PO!EcQWO,59PO!GhQ^O,59POOQU,59P,59PO!GxQ?MxO,59PO%[Q^O,59PO!JTQ^O'#HaOOQU'#Hb'#HbOOQU'#Hc'#HcO`Q^O,5=yO!JkQWO,5=yO`Q^O,5>PO`Q^O,5>RO!JpQWO,5>TO`Q^O,5>VO!JuQWO,5>YO!JzQ^O,5>`OOQU,5>f,5>fO%[Q^O,5>fO9hQ?MxO,5>hOOQU,5>j,5>jO# UQWO,5>jOOQU,5>l,5>lO# UQWO,5>lOOQU,5>n,5>nO# rQ`O'#D[O%[Q^O'#JqO# |Q`O'#JqO#!kQ`O'#DjO#!|Q`O'#DjO#%_Q^O'#DjO#%fQWO'#JpO#%nQWO,5:TO#%sQWO'#EqO#&RQWO'#KPO#&ZQWO,5;[O#&`Q`O'#DjO#&mQ`O'#ESOOQ?Mr,5:l,5:lO%[Q^O,5:lO#&tQWO,5:lO>tQWO,5;VO!A}Q`O,5;VO!BVQ7[O,5;VO:VQ7[O,5;VO#&|QWO,5@]O#'RQ(CYO,5:pOOQO-EzO+}Q^O,5>zOOQO,5?Q,5?QO#*ZQ^O'#I`OOQO-E<^-E<^O#*hQWO,5@ZO#*pQrO,5@ZO#*wQWO,5@iOOQ?Mr1G/j1G/jO%[Q^O,5@jO#+PQWO'#IfOOQO-EuQ?NdO1G0|O#>|Q?NdO1G0|O#AZQ07bO'#CiO#CUQ07bO1G1_O#C]Q07bO'#JnO#CpQ?NdO,5?WOOQ?Mp-EoQWO1G3oO$3VQ^O1G3qO$7ZQ^O'#HpOOQU1G3t1G3tO$7hQWO'#HvO>tQWO'#HxOOQU1G3z1G3zO$7pQ^O1G3zO9hQ?MxO1G4QOOQU1G4S1G4SOOQ?Mp'#G]'#G]O9hQ?MxO1G4UO9hQ?MxO1G4WO$;wQWO,5@]O!(oQ^O,5;]O9WQWO,5;]O>tQWO,5:UO!(oQ^O,5:UO!A}Q`O,5:UO$;|Q07bO,5:UOOQO,5;],5;]O$tQWO1G0qO!A}Q`O1G0qO!BVQ7[O1G0qOOQ?Mp1G5w1G5wO!ArQ?MxO1G0ZOOQO1G0j1G0jO%[Q^O1G0jO$=aQ?MxO1G0jO$=lQ?MxO1G0jO!A}Q`O1G0ZOCrQ`O1G0ZO$=zQ?MxO1G0jOOQO1G0Z1G0ZO$>`Q?NdO1G0jPOOO-EjQpO,5rQrO1G4fOOQO1G4l1G4lO%[Q^O,5>zO$>|QWO1G5uO$?UQWO1G6TO$?^QrO1G6UO9WQWO,5?QO$?hQ?NdO1G6RO%[Q^O1G6RO$?xQ?MxO1G6RO$@ZQWO1G6QO$@ZQWO1G6QO9WQWO1G6QO$@cQWO,5?TO9WQWO,5?TOOQO,5?T,5?TO$@wQWO,5?TO$(PQWO,5?TOOQO-E[OOQU,5>[,5>[O%[Q^O'#HqO%8mQWO'#HsOOQU,5>b,5>bO9WQWO,5>bOOQU,5>d,5>dOOQU7+)f7+)fOOQU7+)l7+)lOOQU7+)p7+)pOOQU7+)r7+)rO%8rQ`O1G5wO%9WQ07bO1G0wO%9bQWO1G0wOOQO1G/p1G/pO%9mQ07bO1G/pO>tQWO1G/pO!(oQ^O'#DjOOQO,5>{,5>{OOQO-E<_-E<_OOQO,5?R,5?ROOQO-EtQWO7+&]O!A}Q`O7+&]OOQO7+%u7+%uO$>`Q?NdO7+&UOOQO7+&U7+&UO%[Q^O7+&UO%9wQ?MxO7+&UO!ArQ?MxO7+%uO!A}Q`O7+%uO%:SQ?MxO7+&UO%:bQ?NdO7++mO%[Q^O7++mO%:rQWO7++lO%:rQWO7++lOOQO1G4o1G4oO9WQWO1G4oO%:zQWO1G4oOOQQ7+%z7+%zO#&wQWO<|O%[Q^O,5>|OOQO-E<`-E<`O%FwQWO1G5xOOQ?Mr<]OOQU,5>_,5>_O&8uQWO1G3|O9WQWO7+&cO!(oQ^O7+&cOOQO7+%[7+%[O&8zQ07bO1G6UO>tQWO7+%[OOQ?Mr<tQWO<`Q?NdO<pQ?NdO,5?_O&@xQ?NdO7+'zO&CWQrO1G4hO&CbQ07bO7+&^O&EcQ07bO,5=UO&GgQ07bO,5=WO&GwQ07bO,5=UO&HXQ07bO,5=WO&HiQ07bO,59rO&JlQ07bO,5tQWO7+)hO'(OQWO<`Q?NdOAN?[OOQOAN>{AN>{O%[Q^OAN?[OOQO<`Q?NdOG24vO#&wQWOLD,nOOQULD,nLD,nO!&_Q7[OLD,nO'5TQrOLD,nO'5[Q07bO7+'xO'6}Q07bO,5?]O'8}Q07bO,5?_O':}Q07bO7+'zO'kOh%VOk+aO![']O%f+`O~O!d+cOa(WX![(WX'u(WX!Y(WX~Oa%lO![XO'u%lO~Oh%VO!i%cO~Oh%VO!i%cO(O%eO~O!d#vO#h(tO~Ob+nO%g+oO(O+kO(QTO(TUO!Z)TP~O!Y+pO`)SX~O[+tO~O`+uO~O![%}O(O%eO(P!lO`)SP~Oh%VO#]+zO~Oh%VOk+}O![$|O~O![,PO~O},RO![XO~O%k%tO~O!u,WO~Oe,]O~Ob,^O(O#nO(QTO(TUO!Z)RP~Oe%{O~O%g!QO(O&WO~P=RO[,cO`,bO~OPYOQYOSfOdzOeyOmkOoYOpkOqkOwkOyYO{YO!PWO!TkO!UkO!fuO!iZO!lYO!mYO!nYO!pvO!uxO!y]O%e}O(QTO(TUO([VO(j[O(yiO~O![!eO!r!gO$V!kO(O!dO~P!EkO`,bOa%lO'u%lO~OPYOQYOSfOd!jOe!iOmkOoYOpkOqkOwkOyYO{YO!PWO!TkO!UkO![!eO!fuO!iZO!lYO!mYO!nYO!pvO!u!hO$V!kO(O!dO(QTO(TUO([VO(j[O(yiO~Oa,hO!rwO#t!OO%i!OO%j!OO%k!OO~P!HTO!i&lO~O&Y,nO~O![,pO~O&k,rO&m,sOP&haQ&haS&haY&haa&had&hae&ham&hao&hap&haq&haw&hay&ha{&ha!P&ha!T&ha!U&ha![&ha!f&ha!i&ha!l&ha!m&ha!n&ha!p&ha!r&ha!u&ha!y&ha#t&ha$V&ha%e&ha%g&ha%i&ha%j&ha%k&ha%n&ha%p&ha%s&ha%t&ha%v&ha&S&ha&Y&ha&[&ha&^&ha&`&ha&c&ha&i&ha&o&ha&q&ha&s&ha&u&ha&w&ha's&ha(O&ha(Q&ha(T&ha([&ha(j&ha(y&ha!Z&ha&a&hab&ha&f&ha~O(O,xO~Oh!bX!Y!OX!Z!OX!d!OX!d!bX!i!bX#]!OX~O!Y!bX!Z!bX~P# ZO!d,}O#],|Oh(eX!Y#eX!Y(eX!Z#eX!Z(eX!d(eX!i(eX~Oh%VO!d-PO!i%cO!Y!^X!Z!^X~Op!nO!P!oO(QTO(TUO(`!mO~OP;POQ;POSfOdkOg'XX!Y'XX~P!+hO!Y.wOg(ka~OSfO![3uO$c3vO~O!Z3zO~Os3{O~P#.aOa$lq!Y$lq'u$lq's$lq!V$lq!h$lqs$lq![$lq%f$lq!d$lq~P!9mO!V3|O~P#.aO})zO!P){O(u%POk'ea(t'ea!Y'ea#]'ea~Og'ea#}'ea~P%)nO})zO!P){Ok'ga(t'ga(u'ga!Y'ga#]'ga~Og'ga#}'ga~P%*aO(m$YO~P#.aO!VfX!V$xX!YfX!Y$xX!d%PX#]fX~P!/gO(OQ#>g#@V#@e#@l#BR#Ba#C|#D[#Db#Dh#Dn#Dx#EO#EU#E`#Er#ExPPPPPPPPPP#FOPPPPPPP#Fs#Iz#KZ#Kb#KjPPP$!sP$!|$%t$,^$,a$,d$-P$-S$-Z$-cP$-i$-lP$.Y$.^$/U$0d$0i$1PPP$1U$1[$1`P$1c$1g$1k$2a$2x$3a$3e$3h$3k$3q$3t$3x$3|R!|RoqOXst!Z#d%k&o&q&r&t,k,p1|2PY!vQ']-]1a5eQ%rvQ%zyQ&R|Q&g!VS'T!e-TQ'c!iS'i!r!yU*e$|*V*jQ+i%{Q+v&TQ,[&aQ-Z'[Q-e'dQ-m'jQ0R*lQ1k,]R;v;T%QdOPWXYZstuvw!Z!`!g!o#S#W#Z#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$_$a$e%k%r&P&h&k&o&q&r&t&x'Q'_'o(P(R(X(`(t(v(z)y+R+V,h,k,p-a-i-w-}.l.s/f0a0g0v1d1t1u1w1y1|2P2R2r2x3^5b5m5}6O6R6f8R8X8h8rS#q];Q!r)Z$Z$n'U)o,|-P.}2b3u5`6]9h9y;P;S;T;W;X;Y;Z;[;];^;_;`;a;b;c;d;f;i;v;x;y;{ < TypeParamList TypeDefinition extends ThisType this LiteralType ArithOp Number BooleanLiteral TemplateType InterpolationEnd Interpolation InterpolationStart NullType null VoidType void TypeofType typeof MemberExpression . PropertyName [ TemplateString Escape Interpolation super RegExp ] ArrayExpression Spread , } { ObjectExpression Property async get set PropertyDefinition Block : NewTarget new NewExpression ) ( ArgList UnaryExpression delete LogicOp BitOp YieldExpression yield AwaitExpression await ParenthesizedExpression ClassExpression class ClassBody MethodDeclaration Decorator @ MemberExpression PrivatePropertyName CallExpression TypeArgList CompareOp < declare Privacy static abstract override PrivatePropertyDefinition PropertyDeclaration readonly accessor Optional TypeAnnotation Equals StaticBlock FunctionExpression ArrowFunction ParamList ParamList ArrayPattern ObjectPattern PatternProperty Privacy readonly Arrow MemberExpression BinaryExpression ArithOp ArithOp ArithOp ArithOp BitOp CompareOp instanceof satisfies in const CompareOp BitOp BitOp BitOp LogicOp LogicOp ConditionalExpression LogicOp LogicOp AssignmentExpression UpdateOp PostfixExpression CallExpression InstantiationExpression TaggedTemplateExpression DynamicImport import ImportMeta JSXElement JSXSelfCloseEndTag JSXSelfClosingTag JSXIdentifier JSXBuiltin JSXIdentifier JSXNamespacedName JSXMemberExpression JSXSpreadAttribute JSXAttribute JSXAttributeValue JSXEscape JSXEndTag JSXOpenTag JSXFragmentTag JSXText JSXEscape JSXStartCloseTag JSXCloseTag PrefixCast ArrowFunction TypeParamList SequenceExpression InstantiationExpression KeyofType keyof UniqueType unique ImportType InferredType infer TypeName ParenthesizedType FunctionSignature ParamList NewSignature IndexedType TupleType Label ArrayType ReadonlyType ObjectType MethodType PropertyType IndexSignature PropertyDefinition CallSignature TypePredicate is NewSignature new UnionType LogicOp IntersectionType LogicOp ConditionalType ParameterizedType ClassDeclaration abstract implements type VariableDeclaration let var using TypeAliasDeclaration InterfaceDeclaration interface EnumDeclaration enum EnumBody NamespaceDeclaration namespace module AmbientDeclaration declare GlobalDeclaration global ClassDeclaration ClassBody AmbientFunctionDeclaration ExportGroup VariableName VariableName ImportDeclaration ImportGroup ForStatement for ForSpec ForInSpec ForOfSpec of WhileStatement while WithStatement with DoStatement do IfStatement if else SwitchStatement switch SwitchBody CaseLabel case DefaultLabel TryStatement try CatchClause catch FinallyClause finally ReturnStatement return ThrowStatement throw BreakStatement break ContinueStatement continue DebuggerStatement debugger LabeledStatement ExpressionStatement SingleExpression SingleClassItem",maxTerm:376,context:trackNewline,nodeProps:[["isolate",-8,5,6,14,34,36,48,50,52,""],["group",-26,9,17,19,65,204,208,212,213,215,218,221,231,233,239,241,243,245,248,254,260,262,264,266,268,270,271,"Statement",-34,13,14,29,32,33,39,48,51,52,54,59,67,69,73,77,79,81,82,107,108,117,118,135,138,140,141,142,143,144,146,147,166,167,169,"Expression",-23,28,30,34,38,40,42,171,173,175,176,178,179,180,182,183,184,186,187,188,198,200,202,203,"Type",-3,85,100,106,"ClassItem"],["openedBy",23,"<",35,"InterpolationStart",53,"[",57,"{",70,"(",159,"JSXStartCloseTag"],["closedBy",24,">",37,"InterpolationEnd",47,"]",58,"}",71,")",164,"JSXEndTag"]],propSources:[jsHighlight],skippedNodes:[0,5,6,274],repeatNodeCount:37,tokenData:"$Fq07[R!bOX%ZXY+gYZ-yZ[+g[]%Z]^.c^p%Zpq+gqr/mrs3cst:_tuEruvJSvwLkwx! Yxy!'iyz!(sz{!)}{|!,q|}!.O}!O!,q!O!P!/Y!P!Q!9j!Q!R#:O!R![#<_![!]#I_!]!^#Jk!^!_#Ku!_!`$![!`!a$$v!a!b$*T!b!c$,r!c!}Er!}#O$-|#O#P$/W#P#Q$4o#Q#R$5y#R#SEr#S#T$7W#T#o$8b#o#p$x#r#s$@U#s$f%Z$f$g+g$g#BYEr#BY#BZ$A`#BZ$ISEr$IS$I_$A`$I_$I|Er$I|$I}$Dk$I}$JO$Dk$JO$JTEr$JT$JU$A`$JU$KVEr$KV$KW$A`$KW&FUEr&FU&FV$A`&FV;'SEr;'S;=`I|<%l?HTEr?HT?HU$A`?HUOEr(n%d_$h&j(Rp(U!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z&j&hT$h&jO!^&c!_#o&c#p;'S&c;'S;=`&w<%lO&c&j&zP;=`<%l&c'|'U]$h&j(U!bOY&}YZ&cZw&}wx&cx!^&}!^!_'}!_#O&}#O#P&c#P#o&}#o#p'}#p;'S&};'S;=`(l<%lO&}!b(SU(U!bOY'}Zw'}x#O'}#P;'S'};'S;=`(f<%lO'}!b(iP;=`<%l'}'|(oP;=`<%l&}'[(y]$h&j(RpOY(rYZ&cZr(rrs&cs!^(r!^!_)r!_#O(r#O#P&c#P#o(r#o#p)r#p;'S(r;'S;=`*a<%lO(rp)wU(RpOY)rZr)rs#O)r#P;'S)r;'S;=`*Z<%lO)rp*^P;=`<%l)r'[*dP;=`<%l(r#S*nX(Rp(U!bOY*gZr*grs'}sw*gwx)rx#O*g#P;'S*g;'S;=`+Z<%lO*g#S+^P;=`<%l*g(n+dP;=`<%l%Z07[+rq$h&j(Rp(U!b'w0/lOX%ZXY+gYZ&cZ[+g[p%Zpq+gqr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p$f%Z$f$g+g$g#BY%Z#BY#BZ+g#BZ$IS%Z$IS$I_+g$I_$JT%Z$JT$JU+g$JU$KV%Z$KV$KW+g$KW&FU%Z&FU&FV+g&FV;'S%Z;'S;=`+a<%l?HT%Z?HT?HU+g?HUO%Z07[.ST(S#S$h&j'x0/lO!^&c!_#o&c#p;'S&c;'S;=`&w<%lO&c07[.n_$h&j(Rp(U!b'x0/lOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z)3p/x`$h&j!m),Q(Rp(U!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_!`0z!`#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z(KW1V`#u(Ch$h&j(Rp(U!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_!`2X!`#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z(KW2d_#u(Ch$h&j(Rp(U!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'At3l_(Q':f$h&j(U!bOY4kYZ5qZr4krs7nsw4kwx5qx!^4k!^!_8p!_#O4k#O#P5q#P#o4k#o#p8p#p;'S4k;'S;=`:X<%lO4k(^4r_$h&j(U!bOY4kYZ5qZr4krs7nsw4kwx5qx!^4k!^!_8p!_#O4k#O#P5q#P#o4k#o#p8p#p;'S4k;'S;=`:X<%lO4k&z5vX$h&jOr5qrs6cs!^5q!^!_6y!_#o5q#o#p6y#p;'S5q;'S;=`7h<%lO5q&z6jT$c`$h&jO!^&c!_#o&c#p;'S&c;'S;=`&w<%lO&c`6|TOr6yrs7]s;'S6y;'S;=`7b<%lO6y`7bO$c``7eP;=`<%l6y&z7kP;=`<%l5q(^7w]$c`$h&j(U!bOY&}YZ&cZw&}wx&cx!^&}!^!_'}!_#O&}#O#P&c#P#o&}#o#p'}#p;'S&};'S;=`(l<%lO&}!r8uZ(U!bOY8pYZ6yZr8prs9hsw8pwx6yx#O8p#O#P6y#P;'S8p;'S;=`:R<%lO8p!r9oU$c`(U!bOY'}Zw'}x#O'}#P;'S'};'S;=`(f<%lO'}!r:UP;=`<%l8p(^:[P;=`<%l4k%9[:hh$h&j(Rp(U!bOY%ZYZ&cZq%Zqr`#P#o`x!^=^!^!_?q!_#O=^#O#P>`#P#o=^#o#p?q#p;'S=^;'S;=`@h<%lO=^&n>gXWS$h&jOY>`YZ&cZ!^>`!^!_?S!_#o>`#o#p?S#p;'S>`;'S;=`?k<%lO>`S?XSWSOY?SZ;'S?S;'S;=`?e<%lO?SS?hP;=`<%l?S&n?nP;=`<%l>`!f?xWWS(U!bOY?qZw?qwx?Sx#O?q#O#P?S#P;'S?q;'S;=`@b<%lO?q!f@eP;=`<%l?q(Q@kP;=`<%l=^'`@w]WS$h&j(RpOY@nYZ&cZr@nrs>`s!^@n!^!_Ap!_#O@n#O#P>`#P#o@n#o#pAp#p;'S@n;'S;=`Bg<%lO@ntAwWWS(RpOYApZrAprs?Ss#OAp#O#P?S#P;'SAp;'S;=`Ba<%lOAptBdP;=`<%lAp'`BjP;=`<%l@n#WBvYWS(Rp(U!bOYBmZrBmrs?qswBmwxApx#OBm#O#P?S#P;'SBm;'S;=`Cf<%lOBm#WCiP;=`<%lBm(rCoP;=`<%l^!Q^$h&j!U7`OY!=yYZ&cZ!P!=y!P!Q!>|!Q!^!=y!^!_!@c!_!}!=y!}#O!CW#O#P!Dy#P#o!=y#o#p!@c#p;'S!=y;'S;=`!Ek<%lO!=y|#X#Z&c#Z#[!>|#[#]&c#]#^!>|#^#a&c#a#b!>|#b#g&c#g#h!>|#h#i&c#i#j!>|#j#k!>|#k#m&c#m#n!>|#n#o&c#p;'S&c;'S;=`&w<%lO&c7`!@hX!U7`OY!@cZ!P!@c!P!Q!AT!Q!}!@c!}#O!Ar#O#P!Bq#P;'S!@c;'S;=`!CQ<%lO!@c7`!AYW!U7`#W#X!AT#Z#[!AT#]#^!AT#a#b!AT#g#h!AT#i#j!AT#j#k!AT#m#n!AT7`!AuVOY!ArZ#O!Ar#O#P!B[#P#Q!@c#Q;'S!Ar;'S;=`!Bk<%lO!Ar7`!B_SOY!ArZ;'S!Ar;'S;=`!Bk<%lO!Ar7`!BnP;=`<%l!Ar7`!BtSOY!@cZ;'S!@c;'S;=`!CQ<%lO!@c7`!CTP;=`<%l!@c^!Ezl$h&j(U!b!U7`OY&}YZ&cZw&}wx&cx!^&}!^!_'}!_#O&}#O#P&c#P#W&}#W#X!Eq#X#Z&}#Z#[!Eq#[#]&}#]#^!Eq#^#a&}#a#b!Eq#b#g&}#g#h!Eq#h#i&}#i#j!Eq#j#k!Eq#k#m&}#m#n!Eq#n#o&}#o#p'}#p;'S&};'S;=`(l<%lO&}8r!GyZ(U!b!U7`OY!GrZw!Grwx!@cx!P!Gr!P!Q!Hl!Q!}!Gr!}#O!JU#O#P!Bq#P;'S!Gr;'S;=`!J|<%lO!Gr8r!Hse(U!b!U7`OY'}Zw'}x#O'}#P#W'}#W#X!Hl#X#Z'}#Z#[!Hl#[#]'}#]#^!Hl#^#a'}#a#b!Hl#b#g'}#g#h!Hl#h#i'}#i#j!Hl#j#k!Hl#k#m'}#m#n!Hl#n;'S'};'S;=`(f<%lO'}8r!JZX(U!bOY!JUZw!JUwx!Arx#O!JU#O#P!B[#P#Q!Gr#Q;'S!JU;'S;=`!Jv<%lO!JU8r!JyP;=`<%l!JU8r!KPP;=`<%l!Gr>^!KZ^$h&j(U!bOY!KSYZ&cZw!KSwx!CWx!^!KS!^!_!JU!_#O!KS#O#P!DR#P#Q!^!LYP;=`<%l!KS>^!L`P;=`<%l!_#c#d#Bq#d#l%Z#l#m#Es#m#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#_#c#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#>j_$h&j(Rp(U!bp'9tOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#?rd$h&j(Rp(U!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q!R#AQ!R!S#AQ!S!^%Z!^!_*g!_#O%Z#O#P&c#P#R%Z#R#S#AQ#S#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#A]f$h&j(Rp(U!bp'9tOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q!R#AQ!R!S#AQ!S!^%Z!^!_*g!_#O%Z#O#P&c#P#R%Z#R#S#AQ#S#b%Z#b#c#>_#c#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#Bzc$h&j(Rp(U!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q!Y#DV!Y!^%Z!^!_*g!_#O%Z#O#P&c#P#R%Z#R#S#DV#S#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#Dbe$h&j(Rp(U!bp'9tOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q!Y#DV!Y!^%Z!^!_*g!_#O%Z#O#P&c#P#R%Z#R#S#DV#S#b%Z#b#c#>_#c#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#E|g$h&j(Rp(U!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q![#Ge![!^%Z!^!_*g!_!c%Z!c!i#Ge!i#O%Z#O#P&c#P#R%Z#R#S#Ge#S#T%Z#T#Z#Ge#Z#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#Gpi$h&j(Rp(U!bp'9tOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q![#Ge![!^%Z!^!_*g!_!c%Z!c!i#Ge!i#O%Z#O#P&c#P#R%Z#R#S#Ge#S#T%Z#T#Z#Ge#Z#b%Z#b#c#>_#c#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z*)x#Il_!d$b$h&j#})Lv(Rp(U!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z)[#Jv_al$h&j(Rp(U!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z04f#LS^h#)`#O-spec_identifier[r]||-1},{term:338,get:r=>spec_word[r]||-1},{term:92,get:r=>spec_LessThan[r]||-1}],tokenPrec:14749});var _a;const languageDataProp=new NodeProp;function defineLanguageFacet(r){return Facet.define({combine:r?e=>e.concat(r):void 0})}const sublanguageProp=new NodeProp;class Language{constructor(e,n,s=[],o=""){this.data=e,this.name=o,EditorState.prototype.hasOwnProperty("tree")||Object.defineProperty(EditorState.prototype,"tree",{get(){return syntaxTree(this)}}),this.parser=n,this.extension=[language.of(this),EditorState.languageData.of((l,a,c)=>{let h=topNodeAt(l,a,c),f=h.type.prop(languageDataProp);if(!f)return[];let u=l.facet(f),d=h.type.prop(sublanguageProp);if(d){let g=h.resolve(a-h.from,c);for(let O of d)if(O.test(g,l)){let m=l.facet(O.facet);return O.type=="replace"?m:m.concat(u)}}return u})].concat(s)}isActiveAt(e,n,s=-1){return topNodeAt(e,n,s).type.prop(languageDataProp)==this.data}findRegions(e){let n=e.facet(language);if((n==null?void 0:n.data)==this.data)return[{from:0,to:e.doc.length}];if(!n||!n.allowsNesting)return[];let s=[],o=(l,a)=>{if(l.prop(languageDataProp)==this.data){s.push({from:a,to:a+l.length});return}let c=l.prop(NodeProp.mounted);if(c){if(c.tree.prop(languageDataProp)==this.data){if(c.overlay)for(let h of c.overlay)s.push({from:h.from+a,to:h.to+a});else s.push({from:a,to:a+l.length});return}else if(c.overlay){let h=s.length;if(o(c.tree,c.overlay[0].from+a),s.length>h)return}}for(let h=0;hs.isTop?n:void 0)]}),e.name)}configure(e,n){return new LRLanguage(this.data,this.parser.configure(e),n||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function syntaxTree(r){let e=r.field(Language.state,!1);return e?e.tree:Tree.empty}class DocInput{constructor(e){this.doc=e,this.cursorPos=0,this.string="",this.cursor=e.iter()}get length(){return this.doc.length}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,n){let s=this.cursorPos-this.string.length;return e=this.cursorPos?this.doc.sliceString(e,n):this.string.slice(e-s,n-s)}}let currentContext=null;class ParseContext{constructor(e,n,s=[],o,l,a,c,h){this.parser=e,this.state=n,this.fragments=s,this.tree=o,this.treeLen=l,this.viewport=a,this.skipped=c,this.scheduleOn=h,this.parse=null,this.tempSkipped=[]}static create(e,n,s){return new ParseContext(e,n,[],Tree.empty,0,s,[],null)}startParse(){return this.parser.startParse(new DocInput(this.state.doc),this.fragments)}work(e,n){return n!=null&&n>=this.state.doc.length&&(n=void 0),this.tree!=Tree.empty&&this.isDone(n??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var s;if(typeof e=="number"){let o=Date.now()+e;e=()=>Date.now()>o}for(this.parse||(this.parse=this.startParse()),n!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>n)&&n=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(n=this.parse.advance()););}),this.treeLen=e,this.tree=n,this.fragments=this.withoutTempSkipped(TreeFragment.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let n=currentContext;currentContext=this;try{return e()}finally{currentContext=n}}withoutTempSkipped(e){for(let n;n=this.tempSkipped.pop();)e=cutFragments(e,n.from,n.to);return e}changes(e,n){let{fragments:s,tree:o,treeLen:l,viewport:a,skipped:c}=this;if(this.takeTree(),!e.empty){let h=[];if(e.iterChangedRanges((f,u,d,g)=>h.push({fromA:f,toA:u,fromB:d,toB:g})),s=TreeFragment.applyChanges(s,h),o=Tree.empty,l=0,a={from:e.mapPos(a.from,-1),to:e.mapPos(a.to,1)},this.skipped.length){c=[];for(let f of this.skipped){let u=e.mapPos(f.from,1),d=e.mapPos(f.to,-1);ue.from&&(this.fragments=cutFragments(this.fragments,o,l),this.skipped.splice(s--,1))}return this.skipped.length>=n?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,n){this.skipped.push({from:e,to:n})}static getSkippingParser(e){return new class extends Parser{createParse(n,s,o){let l=o[0].from,a=o[o.length-1].to;return{parsedPos:l,advance(){let h=currentContext;if(h){for(let f of o)h.tempSkipped.push(f);e&&(h.scheduleOn=h.scheduleOn?Promise.all([h.scheduleOn,e]):e)}return this.parsedPos=a,new Tree(NodeType.none,[],[],a-l)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let n=this.fragments;return this.treeLen>=e&&n.length&&n[0].from==0&&n[0].to>=e}static get(){return currentContext}}function cutFragments(r,e,n){return TreeFragment.applyChanges(r,[{fromA:e,toA:n,fromB:e,toB:n}])}class LanguageState{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let n=this.context.changes(e.changes,e.state),s=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),n.viewport.to);return n.work(20,s)||n.takeTree(),new LanguageState(n)}static init(e){let n=Math.min(3e3,e.doc.length),s=ParseContext.create(e.facet(language).parser,e,{from:0,to:n});return s.work(20,n)||s.takeTree(),new LanguageState(s)}}Language.state=StateField.define({create:LanguageState.init,update(r,e){for(let n of e.effects)if(n.is(Language.setState))return n.value;return e.startState.facet(language)!=e.state.facet(language)?LanguageState.init(e.state):r.apply(e)}});let requestIdle=r=>{let e=setTimeout(()=>r(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(requestIdle=r=>{let e=-1,n=setTimeout(()=>{e=requestIdleCallback(r,{timeout:400})},100);return()=>e<0?clearTimeout(n):cancelIdleCallback(e)});const isInputPending=typeof navigator<"u"&&(!((_a=navigator.scheduling)===null||_a===void 0)&&_a.isInputPending)?()=>navigator.scheduling.isInputPending():null,parseWorker=ViewPlugin.fromClass(class{constructor(e){this.view=e,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(e){let n=this.view.state.field(Language.state).context;(n.updateViewport(e.view.viewport)||this.view.viewport.to>n.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(n)}scheduleWork(){if(this.working)return;let{state:e}=this.view,n=e.field(Language.state);(n.tree!=n.context.tree||!n.context.isDone(e.doc.length))&&(this.working=requestIdle(this.work))}work(e){this.working=null;let n=Date.now();if(this.chunkEndo+1e3,h=l.context.work(()=>isInputPending&&isInputPending()||Date.now()>a,o+(c?0:1e5));this.chunkBudget-=Date.now()-n,(h||this.chunkBudget<=0)&&(l.context.takeTree(),this.view.dispatch({effects:Language.setState.of(new LanguageState(l.context))})),this.chunkBudget>0&&!(h&&!c)&&this.scheduleWork(),this.checkAsyncSchedule(l.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(n=>logException(this.view.state,n)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),language=Facet.define({combine(r){return r.length?r[0]:null},enables:r=>[Language.state,parseWorker,EditorView.contentAttributes.compute([r],e=>{let n=e.facet(r);return n&&n.name?{"data-language":n.name}:{}})]});class LanguageSupport{constructor(e,n=[]){this.language=e,this.support=n,this.extension=[e,n]}}const indentService=Facet.define(),indentUnit=Facet.define({combine:r=>{if(!r.length)return" ";let e=r[0];if(!e||/\S/.test(e)||Array.from(e).some(n=>n!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(r[0]));return e}});function getIndentUnit(r){let e=r.facet(indentUnit);return e.charCodeAt(0)==9?r.tabSize*e.length:e.length}function indentString(r,e){let n="",s=r.tabSize,o=r.facet(indentUnit)[0];if(o==" "){for(;e>=s;)n+=" ",e-=s;o=" "}for(let l=0;l=e?syntaxIndentation(r,n,e):null}class IndentContext{constructor(e,n={}){this.state=e,this.options=n,this.unit=getIndentUnit(e)}lineAt(e,n=1){let s=this.state.doc.lineAt(e),{simulateBreak:o,simulateDoubleBreak:l}=this.options;return o!=null&&o>=s.from&&o<=s.to?l&&o==e?{text:"",from:e}:(n<0?o-1&&(l+=a-this.countColumn(s,s.search(/\S|$/))),l}countColumn(e,n=e.length){return countColumn(e,this.state.tabSize,n)}lineIndent(e,n=1){let{text:s,from:o}=this.lineAt(e,n),l=this.options.overrideIndentation;if(l){let a=l(o);if(a>-1)return a}return this.countColumn(s,s.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const indentNodeProp=new NodeProp;function syntaxIndentation(r,e,n){let s=e.resolveStack(n),o=s.node.enterUnfinishedNodesBefore(n);if(o!=s.node){let l=[];for(let a=o;a!=s.node;a=a.parent)l.push(a);for(let a=l.length-1;a>=0;a--)s={node:l[a],next:s}}return indentFor(s,r,n)}function indentFor(r,e,n){for(let s=r;s;s=s.next){let o=indentStrategy(s.node);if(o)return o(TreeIndentContext.create(e,n,s))}return 0}function ignoreClosed(r){return r.pos==r.options.simulateBreak&&r.options.simulateDoubleBreak}function indentStrategy(r){let e=r.type.prop(indentNodeProp);if(e)return e;let n=r.firstChild,s;if(n&&(s=n.type.prop(NodeProp.closedBy))){let o=r.lastChild,l=o&&s.indexOf(o.name)>-1;return a=>delimitedStrategy(a,!0,1,void 0,l&&!ignoreClosed(a)?o.from:void 0)}return r.parent==null?topIndent:null}function topIndent(){return 0}class TreeIndentContext extends IndentContext{constructor(e,n,s){super(e.state,e.options),this.base=e,this.pos=n,this.context=s}get node(){return this.context.node}static create(e,n,s){return new TreeIndentContext(e,n,s)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let n=this.state.doc.lineAt(e.from);for(;;){let s=e.resolve(n.from);for(;s.parent&&s.parent.from==s.from;)s=s.parent;if(isParent(s,e))break;n=this.state.doc.lineAt(s.from)}return this.lineIndent(n.from)}continue(){return indentFor(this.context.next,this.base,this.pos)}}function isParent(r,e){for(let n=e;n;n=n.parent)if(r==n)return!0;return!1}function bracketedAligned(r){let e=r.node,n=e.childAfter(e.from),s=e.lastChild;if(!n)return null;let o=r.options.simulateBreak,l=r.state.doc.lineAt(n.from),a=o==null||o<=l.from?l.to:Math.min(l.to,o);for(let c=n.to;;){let h=e.childAfter(c);if(!h||h==s)return null;if(!h.type.isSkipped)return h.fromdelimitedStrategy(s,e,n,r)}function delimitedStrategy(r,e,n,s,o){let l=r.textAfter,a=l.match(/^\s*/)[0].length,c=s&&l.slice(a,a+s.length)==s||o==r.pos+a,h=e?bracketedAligned(r):null;return h?c?r.column(h.from):r.column(h.to):r.baseIndent+(c?0:r.unit*n)}const flatIndent=r=>r.baseIndent;function continuedIndent({except:r,units:e=1}={}){return n=>{let s=r&&r.test(n.textAfter);return n.baseIndent+(s?0:e*n.unit)}}const DontIndentBeyond=200;function indentOnInput(){return EditorState.transactionFilter.of(r=>{if(!r.docChanged||!r.isUserEvent("input.type")&&!r.isUserEvent("input.complete"))return r;let e=r.startState.languageDataAt("indentOnInput",r.startState.selection.main.head);if(!e.length)return r;let n=r.newDoc,{head:s}=r.newSelection.main,o=n.lineAt(s);if(s>o.from+DontIndentBeyond)return r;let l=n.sliceString(o.from,s);if(!e.some(f=>f.test(l)))return r;let{state:a}=r,c=-1,h=[];for(let{head:f}of a.selection.ranges){let u=a.doc.lineAt(f);if(u.from==c)continue;c=u.from;let d=getIndentation(a,u.from);if(d==null)continue;let g=/^\s*/.exec(u.text)[0],O=indentString(a,d);g!=O&&h.push({from:u.from,to:u.from+g.length,insert:O})}return h.length?[r,{changes:h,sequential:!0}]:r})}const foldService=Facet.define(),foldNodeProp=new NodeProp;function foldInside(r){let e=r.firstChild,n=r.lastChild;return e&&e.ton)continue;if(l&&c.from=e&&f.to>n&&(l=f)}}return l}function isUnfinished(r){let e=r.lastChild;return e&&e.to==r.to&&e.type.isError}function foldable(r,e,n){for(let s of r.facet(foldService)){let o=s(r,e,n);if(o)return o}return syntaxFolding(r,e,n)}function mapRange(r,e){let n=e.mapPos(r.from,1),s=e.mapPos(r.to,-1);return n>=s?void 0:{from:n,to:s}}const foldEffect=StateEffect.define({map:mapRange}),unfoldEffect=StateEffect.define({map:mapRange});function selectedLines(r){let e=[];for(let{head:n}of r.state.selection.ranges)e.some(s=>s.from<=n&&s.to>=n)||e.push(r.lineBlockAt(n));return e}const foldState=StateField.define({create(){return Decoration.none},update(r,e){r=r.map(e.changes);for(let n of e.effects)if(n.is(foldEffect)&&!foldExists(r,n.value.from,n.value.to)){let{preparePlaceholder:s}=e.state.facet(foldConfig),o=s?Decoration.replace({widget:new PreparedFoldWidget(s(e.state,n.value))}):foldWidget;r=r.update({add:[o.range(n.value.from,n.value.to)]})}else n.is(unfoldEffect)&&(r=r.update({filter:(s,o)=>n.value.from!=s||n.value.to!=o,filterFrom:n.value.from,filterTo:n.value.to}));if(e.selection){let n=!1,{head:s}=e.selection.main;r.between(s,s,(o,l)=>{os&&(n=!0)}),n&&(r=r.update({filterFrom:s,filterTo:s,filter:(o,l)=>l<=s||o>=s}))}return r},provide:r=>EditorView.decorations.from(r),toJSON(r,e){let n=[];return r.between(0,e.doc.length,(s,o)=>{n.push(s,o)}),n},fromJSON(r){if(!Array.isArray(r)||r.length%2)throw new RangeError("Invalid JSON for fold state");let e=[];for(let n=0;n{(!o||o.from>l)&&(o={from:l,to:a})}),o}function foldExists(r,e,n){let s=!1;return r.between(e,e,(o,l)=>{o==e&&l==n&&(s=!0)}),s}function maybeEnable(r,e){return r.field(foldState,!1)?e:e.concat(StateEffect.appendConfig.of(codeFolding()))}const foldCode=r=>{for(let e of selectedLines(r)){let n=foldable(r.state,e.from,e.to);if(n)return r.dispatch({effects:maybeEnable(r.state,[foldEffect.of(n),announceFold(r,n)])}),!0}return!1},unfoldCode=r=>{if(!r.state.field(foldState,!1))return!1;let e=[];for(let n of selectedLines(r)){let s=findFold(r.state,n.from,n.to);s&&e.push(unfoldEffect.of(s),announceFold(r,s,!1))}return e.length&&r.dispatch({effects:e}),e.length>0};function announceFold(r,e,n=!0){let s=r.state.doc.lineAt(e.from).number,o=r.state.doc.lineAt(e.to).number;return EditorView.announce.of(`${r.state.phrase(n?"Folded lines":"Unfolded lines")} ${s} ${r.state.phrase("to")} ${o}.`)}const foldAll=r=>{let{state:e}=r,n=[];for(let s=0;s{let e=r.state.field(foldState,!1);if(!e||!e.size)return!1;let n=[];return e.between(0,r.state.doc.length,(s,o)=>{n.push(unfoldEffect.of({from:s,to:o}))}),r.dispatch({effects:n}),!0},foldKeymap=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:foldCode},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:unfoldCode},{key:"Ctrl-Alt-[",run:foldAll},{key:"Ctrl-Alt-]",run:unfoldAll}],defaultConfig={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},foldConfig=Facet.define({combine(r){return combineConfig(r,defaultConfig)}});function codeFolding(r){return[foldState,baseTheme$1$1]}function widgetToDOM(r,e){let{state:n}=r,s=n.facet(foldConfig),o=a=>{let c=r.lineBlockAt(r.posAtDOM(a.target)),h=findFold(r.state,c.from,c.to);h&&r.dispatch({effects:unfoldEffect.of(h)}),a.preventDefault()};if(s.placeholderDOM)return s.placeholderDOM(r,o,e);let l=document.createElement("span");return l.textContent=s.placeholderText,l.setAttribute("aria-label",n.phrase("folded code")),l.title=n.phrase("unfold"),l.className="cm-foldPlaceholder",l.onclick=o,l}const foldWidget=Decoration.replace({widget:new class extends WidgetType{toDOM(r){return widgetToDOM(r,null)}}});class PreparedFoldWidget extends WidgetType{constructor(e){super(),this.value=e}eq(e){return this.value==e.value}toDOM(e){return widgetToDOM(e,this.value)}}const foldGutterDefaults={openText:"⌄",closedText:"›",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class FoldMarker extends GutterMarker{constructor(e,n){super(),this.config=e,this.open=n}eq(e){return this.config==e.config&&this.open==e.open}toDOM(e){if(this.config.markerDOM)return this.config.markerDOM(this.open);let n=document.createElement("span");return n.textContent=this.open?this.config.openText:this.config.closedText,n.title=e.state.phrase(this.open?"Fold line":"Unfold line"),n}}function foldGutter(r={}){let e=Object.assign(Object.assign({},foldGutterDefaults),r),n=new FoldMarker(e,!0),s=new FoldMarker(e,!1),o=ViewPlugin.fromClass(class{constructor(a){this.from=a.viewport.from,this.markers=this.buildMarkers(a)}update(a){(a.docChanged||a.viewportChanged||a.startState.facet(language)!=a.state.facet(language)||a.startState.field(foldState,!1)!=a.state.field(foldState,!1)||syntaxTree(a.startState)!=syntaxTree(a.state)||e.foldingChanged(a))&&(this.markers=this.buildMarkers(a.view))}buildMarkers(a){let c=new RangeSetBuilder;for(let h of a.viewportLineBlocks){let f=findFold(a.state,h.from,h.to)?s:foldable(a.state,h.from,h.to)?n:null;f&&c.add(h.from,h.from,f)}return c.finish()}}),{domEventHandlers:l}=e;return[o,gutter({class:"cm-foldGutter",markers(a){var c;return((c=a.plugin(o))===null||c===void 0?void 0:c.markers)||RangeSet.empty},initialSpacer(){return new FoldMarker(e,!1)},domEventHandlers:Object.assign(Object.assign({},l),{click:(a,c,h)=>{if(l.click&&l.click(a,c,h))return!0;let f=findFold(a.state,c.from,c.to);if(f)return a.dispatch({effects:unfoldEffect.of(f)}),!0;let u=foldable(a.state,c.from,c.to);return u?(a.dispatch({effects:foldEffect.of(u)}),!0):!1}})}),codeFolding()]}const baseTheme$1$1=EditorView.baseTheme({".cm-foldPlaceholder":{backgroundColor:"#eee",border:"1px solid #ddd",color:"#888",borderRadius:".2em",margin:"0 1px",padding:"0 1px",cursor:"pointer"},".cm-foldGutter span":{padding:"0 1px",cursor:"pointer"}});class HighlightStyle{constructor(e,n){this.specs=e;let s;function o(c){let h=StyleModule.newName();return(s||(s=Object.create(null)))["."+h]=c,h}const l=typeof n.all=="string"?n.all:n.all?o(n.all):void 0,a=n.scope;this.scope=a instanceof Language?c=>c.prop(languageDataProp)==a.data:a?c=>c==a:void 0,this.style=tagHighlighter(e.map(c=>({tag:c.tag,class:c.class||o(Object.assign({},c,{tag:null}))})),{all:l}).style,this.module=s?new StyleModule(s):null,this.themeType=n.themeType}static define(e,n){return new HighlightStyle(e,n||{})}}const highlighterFacet=Facet.define(),fallbackHighlighter=Facet.define({combine(r){return r.length?[r[0]]:null}});function getHighlighters(r){let e=r.facet(highlighterFacet);return e.length?e:r.facet(fallbackHighlighter)}function syntaxHighlighting(r,e){let n=[treeHighlighter],s;return r instanceof HighlightStyle&&(r.module&&n.push(EditorView.styleModule.of(r.module)),s=r.themeType),e!=null&&e.fallback?n.push(fallbackHighlighter.of(r)):s?n.push(highlighterFacet.computeN([EditorView.darkTheme],o=>o.facet(EditorView.darkTheme)==(s=="dark")?[r]:[])):n.push(highlighterFacet.of(r)),n}class TreeHighlighter{constructor(e){this.markCache=Object.create(null),this.tree=syntaxTree(e.state),this.decorations=this.buildDeco(e,getHighlighters(e.state)),this.decoratedTo=e.viewport.to}update(e){let n=syntaxTree(e.state),s=getHighlighters(e.state),o=s!=getHighlighters(e.startState),{viewport:l}=e.view,a=e.changes.mapPos(this.decoratedTo,1);n.length=l.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=a):(n!=this.tree||e.viewportChanged||o)&&(this.tree=n,this.decorations=this.buildDeco(e.view,s),this.decoratedTo=l.to)}buildDeco(e,n){if(!n||!this.tree.length)return Decoration.none;let s=new RangeSetBuilder;for(let{from:o,to:l}of e.visibleRanges)highlightTree(this.tree,n,(a,c,h)=>{s.add(a,c,this.markCache[h]||(this.markCache[h]=Decoration.mark({class:h})))},o,l);return s.finish()}}const treeHighlighter=Prec.high(ViewPlugin.fromClass(TreeHighlighter,{decorations:r=>r.decorations})),baseTheme$3=EditorView.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),DefaultScanDist=1e4,DefaultBrackets="()[]{}",bracketMatchingConfig=Facet.define({combine(r){return combineConfig(r,{afterCursor:!0,brackets:DefaultBrackets,maxScanDistance:DefaultScanDist,renderMatch:defaultRenderMatch})}}),matchingMark=Decoration.mark({class:"cm-matchingBracket"}),nonmatchingMark=Decoration.mark({class:"cm-nonmatchingBracket"});function defaultRenderMatch(r){let e=[],n=r.matched?matchingMark:nonmatchingMark;return e.push(n.range(r.start.from,r.start.to)),r.end&&e.push(n.range(r.end.from,r.end.to)),e}const bracketMatchingState=StateField.define({create(){return Decoration.none},update(r,e){if(!e.docChanged&&!e.selection)return r;let n=[],s=e.state.facet(bracketMatchingConfig);for(let o of e.state.selection.ranges){if(!o.empty)continue;let l=matchBrackets(e.state,o.head,-1,s)||o.head>0&&matchBrackets(e.state,o.head-1,1,s)||s.afterCursor&&(matchBrackets(e.state,o.head,1,s)||o.headEditorView.decorations.from(r)}),bracketMatchingUnique=[bracketMatchingState,baseTheme$3];function bracketMatching(r={}){return[bracketMatchingConfig.of(r),bracketMatchingUnique]}const bracketMatchingHandle=new NodeProp;function matchingNodes(r,e,n){let s=r.prop(e<0?NodeProp.openedBy:NodeProp.closedBy);if(s)return s;if(r.name.length==1){let o=n.indexOf(r.name);if(o>-1&&o%2==(e<0?1:0))return[n[o+e]]}return null}function findHandle(r){let e=r.type.prop(bracketMatchingHandle);return e?e(r.node):r}function matchBrackets(r,e,n,s={}){let o=s.maxScanDistance||DefaultScanDist,l=s.brackets||DefaultBrackets,a=syntaxTree(r),c=a.resolveInner(e,n);for(let h=c;h;h=h.parent){let f=matchingNodes(h.type,n,l);if(f&&h.from0?e>=u.from&&eu.from&&e<=u.to))return matchMarkedBrackets(r,e,n,h,u,f,l)}}return matchPlainBrackets(r,e,n,a,c.type,o,l)}function matchMarkedBrackets(r,e,n,s,o,l,a){let c=s.parent,h={from:o.from,to:o.to},f=0,u=c==null?void 0:c.cursor();if(u&&(n<0?u.childBefore(s.from):u.childAfter(s.to)))do if(n<0?u.to<=s.from:u.from>=s.to){if(f==0&&l.indexOf(u.type.name)>-1&&u.from0)return null;let f={from:n<0?e-1:e,to:n>0?e+1:e},u=r.doc.iterRange(e,n>0?r.doc.length:0),d=0;for(let g=0;!u.next().done&&g<=l;){let O=u.value;n<0&&(g+=O.length);let m=e+g*n;for(let y=n>0?0:O.length-1,b=n>0?O.length:-1;y!=b;y+=n){let w=a.indexOf(O[y]);if(!(w<0||s.resolveInner(m+y,1).type!=o))if(w%2==0==n>0)d++;else{if(d==1)return{start:f,end:{from:m+y,to:m+y+1},matched:w>>1==h>>1};d--}}n>0&&(g+=O.length)}return u.done?{start:f,matched:!1}:null}const noTokens=Object.create(null),typeArray=[NodeType.none],warned=[],byTag=Object.create(null),defaultTable=Object.create(null);for(let[r,e]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])defaultTable[r]=createTokenType(noTokens,e);function warnForPart(r,e){warned.indexOf(r)>-1||(warned.push(r),console.warn(e))}function createTokenType(r,e){let n=[];for(let c of e.split(" ")){let h=[];for(let f of c.split(".")){let u=r[f]||tags[f];u?typeof u=="function"?h.length?h=h.map(u):warnForPart(f,`Modifier ${f} used at start of tag`):h.length?warnForPart(f,`Tag ${f} used as modifier`):h=Array.isArray(u)?u:[u]:warnForPart(f,`Unknown highlighting tag ${f}`)}for(let f of h)n.push(f)}if(!n.length)return 0;let s=e.replace(/ /g,"_"),o=s+" "+n.map(c=>c.id),l=byTag[o];if(l)return l.id;let a=byTag[o]=NodeType.define({id:typeArray.length,name:s,props:[styleTags({[s]:n})]});return typeArray.push(a),a.id}Direction.RTL,Direction.LTR;class CompletionContext{constructor(e,n,s){this.state=e,this.pos=n,this.explicit=s,this.abortListeners=[]}tokenBefore(e){let n=syntaxTree(this.state).resolveInner(this.pos,-1);for(;n&&e.indexOf(n.name)<0;)n=n.parent;return n?{from:n.from,to:this.pos,text:this.state.sliceDoc(n.from,this.pos),type:n.type}:null}matchBefore(e){let n=this.state.doc.lineAt(this.pos),s=Math.max(n.from,this.pos-250),o=n.text.slice(s-n.from,this.pos-n.from),l=o.search(ensureAnchor(e,!1));return l<0?null:{from:s+l,to:this.pos,text:o.slice(l)}}get aborted(){return this.abortListeners==null}addEventListener(e,n){e=="abort"&&this.abortListeners&&this.abortListeners.push(n)}}function toSet(r){let e=Object.keys(r).join(""),n=/\w/.test(e);return n&&(e=e.replace(/\w/g,"")),`[${n?"\\w":""}${e.replace(/[^\w\s]/g,"\\$&")}]`}function prefixMatch(r){let e=Object.create(null),n=Object.create(null);for(let{label:o}of r){e[o[0]]=!0;for(let l=1;ltypeof o=="string"?{label:o}:o),[n,s]=e.every(o=>/^\w+$/.test(o.label))?[/\w*$/,/\w+$/]:prefixMatch(e);return o=>{let l=o.matchBefore(s);return l||o.explicit?{from:l?l.from:o.pos,options:e,validFor:n}:null}}function ifNotIn(r,e){return n=>{for(let s=syntaxTree(n.state).resolveInner(n.pos,-1);s;s=s.parent){if(r.indexOf(s.name)>-1)return null;if(s.type.isTop)break}return e(n)}}class Option{constructor(e,n,s,o){this.completion=e,this.source=n,this.match=s,this.score=o}}function cur(r){return r.selection.main.from}function ensureAnchor(r,e){var n;let{source:s}=r,o=e&&s[0]!="^",l=s[s.length-1]!="$";return!o&&!l?r:new RegExp(`${o?"^":""}(?:${s})${l?"$":""}`,(n=r.flags)!==null&&n!==void 0?n:r.ignoreCase?"i":"")}const pickedCompletion=Annotation.define();function insertCompletionText(r,e,n,s){let{main:o}=r.selection,l=n-o.from,a=s-o.from;return Object.assign(Object.assign({},r.changeByRange(c=>c!=o&&n!=s&&r.sliceDoc(c.from+l,c.from+a)!=r.sliceDoc(n,s)?{range:c}:{changes:{from:c.from+l,to:s==o.from?c.to:c.from+a,insert:e},range:EditorSelection.cursor(c.from+l+e.length)})),{scrollIntoView:!0,userEvent:"input.complete"})}const SourceCache=new WeakMap;function asSource(r){if(!Array.isArray(r))return r;let e=SourceCache.get(r);return e||SourceCache.set(r,e=completeFromList(r)),e}const startCompletionEffect=StateEffect.define(),closeCompletionEffect=StateEffect.define();class FuzzyMatcher{constructor(e){this.pattern=e,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let n=0;n=48&&v<=57||v>=97&&v<=122?2:v>=65&&v<=90?1:0:(Q=fromCodePoint(v))!=Q.toLowerCase()?1:Q!=Q.toUpperCase()?2:0;(!P||_==1&&b||A==0&&_!=0)&&(n[d]==v||s[d]==v&&(g=!0)?a[d++]=P:a.length&&(w=!1)),A=_,P+=codePointSize(v)}return d==h&&a[0]==0&&w?this.result(-100+(g?-200:0),a,e):O==h&&m==0?this.ret(-200-e.length+(y==e.length?0:-100),[0,y]):c>-1?this.ret(-700-e.length,[c,c+this.pattern.length]):O==h?this.ret(-900-e.length,[m,y]):d==h?this.result(-100+(g?-200:0)+-700+(w?0:-1100),a,e):n.length==2?null:this.result((o[0]?-700:0)+-200+-1100,o,e)}result(e,n,s){let o=[],l=0;for(let a of n){let c=a+(this.astral?codePointSize(codePointAt(s,a)):1);l&&o[l-1]==a?o[l-1]=c:(o[l++]=a,o[l++]=c)}return this.ret(e-s.length,o)}}class StrictMatcher{constructor(e){this.pattern=e,this.matched=[],this.score=0,this.folded=e.toLowerCase()}match(e){if(e.length!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:defaultPositionInfo,filterStrict:!1,compareCompletions:(e,n)=>e.label.localeCompare(n.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(e,n)=>e&&n,closeOnBlur:(e,n)=>e&&n,icons:(e,n)=>e&&n,tooltipClass:(e,n)=>s=>joinClass(e(s),n(s)),optionClass:(e,n)=>s=>joinClass(e(s),n(s)),addToOptions:(e,n)=>e.concat(n),filterStrict:(e,n)=>e||n})}});function joinClass(r,e){return r?e?r+" "+e:r:e}function defaultPositionInfo(r,e,n,s,o,l){let a=r.textDirection==Direction.RTL,c=a,h=!1,f="top",u,d,g=e.left-o.left,O=o.right-e.right,m=s.right-s.left,y=s.bottom-s.top;if(c&&g=y||P>e.top?u=n.bottom-e.top:(f="bottom",u=e.bottom-n.top)}let b=(e.bottom-e.top)/l.offsetHeight,w=(e.right-e.left)/l.offsetWidth;return{style:`${f}: ${u/b}px; max-width: ${d/w}px`,class:"cm-completionInfo-"+(h?a?"left-narrow":"right-narrow":c?"left":"right")}}function optionContent(r){let e=r.addToOptions.slice();return r.icons&&e.push({render(n){let s=document.createElement("div");return s.classList.add("cm-completionIcon"),n.type&&s.classList.add(...n.type.split(/\s+/g).map(o=>"cm-completionIcon-"+o)),s.setAttribute("aria-hidden","true"),s},position:20}),e.push({render(n,s,o,l){let a=document.createElement("span");a.className="cm-completionLabel";let c=n.displayLabel||n.label,h=0;for(let f=0;fh&&a.appendChild(document.createTextNode(c.slice(h,u)));let g=a.appendChild(document.createElement("span"));g.appendChild(document.createTextNode(c.slice(u,d))),g.className="cm-completionMatchedText",h=d}return hn.position-s.position).map(n=>n.render)}function rangeAroundSelected(r,e,n){if(r<=n)return{from:0,to:r};if(e<0&&(e=0),e<=r>>1){let o=Math.floor(e/n);return{from:o*n,to:(o+1)*n}}let s=Math.floor((r-e)/n);return{from:r-(s+1)*n,to:r-s*n}}class CompletionTooltip{constructor(e,n,s){this.view=e,this.stateField=n,this.applyCompletion=s,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:h=>this.placeInfo(h),key:this},this.space=null,this.currentClass="";let o=e.state.field(n),{options:l,selected:a}=o.open,c=e.state.facet(completionConfig);this.optionContent=optionContent(c),this.optionClass=c.optionClass,this.tooltipClass=c.tooltipClass,this.range=rangeAroundSelected(l.length,a,c.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(e.state),this.dom.addEventListener("mousedown",h=>{let{options:f}=e.state.field(n).open;for(let u=h.target,d;u&&u!=this.dom;u=u.parentNode)if(u.nodeName=="LI"&&(d=/-(\d+)$/.exec(u.id))&&+d[1]{let f=e.state.field(this.stateField,!1);f&&f.tooltip&&e.state.facet(completionConfig).closeOnBlur&&h.relatedTarget!=e.contentDOM&&e.dispatch({effects:closeCompletionEffect.of(null)})}),this.showOptions(l,o.id)}mount(){this.updateSel()}showOptions(e,n){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(e,n,this.range)),this.list.addEventListener("scroll",()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}update(e){var n;let s=e.state.field(this.stateField),o=e.startState.field(this.stateField);if(this.updateTooltipClass(e.state),s!=o){let{options:l,selected:a,disabled:c}=s.open;(!o.open||o.open.options!=l)&&(this.range=rangeAroundSelected(l.length,a,e.state.facet(completionConfig).maxRenderedOptions),this.showOptions(l,s.id)),this.updateSel(),c!=((n=o.open)===null||n===void 0?void 0:n.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!c)}}updateTooltipClass(e){let n=this.tooltipClass(e);if(n!=this.currentClass){for(let s of this.currentClass.split(" "))s&&this.dom.classList.remove(s);for(let s of n.split(" "))s&&this.dom.classList.add(s);this.currentClass=n}}positioned(e){this.space=e,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let e=this.view.state.field(this.stateField),n=e.open;if((n.selected>-1&&n.selected=this.range.to)&&(this.range=rangeAroundSelected(n.options.length,n.selected,this.view.state.facet(completionConfig).maxRenderedOptions),this.showOptions(n.options,e.id)),this.updateSelectedOption(n.selected)){this.destroyInfo();let{completion:s}=n.options[n.selected],{info:o}=s;if(!o)return;let l=typeof o=="string"?document.createTextNode(o):o(s);if(!l)return;"then"in l?l.then(a=>{a&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(a,s)}).catch(a=>logException(this.view.state,a,"completion info")):this.addInfoPane(l,s)}}addInfoPane(e,n){this.destroyInfo();let s=this.info=document.createElement("div");if(s.className="cm-tooltip cm-completionInfo",e.nodeType!=null)s.appendChild(e),this.infoDestroy=null;else{let{dom:o,destroy:l}=e;s.appendChild(o),this.infoDestroy=l||null}this.dom.appendChild(s),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(e){let n=null;for(let s=this.list.firstChild,o=this.range.from;s;s=s.nextSibling,o++)s.nodeName!="LI"||!s.id?o--:o==e?s.hasAttribute("aria-selected")||(s.setAttribute("aria-selected","true"),n=s):s.hasAttribute("aria-selected")&&s.removeAttribute("aria-selected");return n&&scrollIntoView(this.list,n),n}measureInfo(){let e=this.dom.querySelector("[aria-selected]");if(!e||!this.info)return null;let n=this.dom.getBoundingClientRect(),s=this.info.getBoundingClientRect(),o=e.getBoundingClientRect(),l=this.space;if(!l){let a=this.dom.ownerDocument.defaultView||window;l={left:0,top:0,right:a.innerWidth,bottom:a.innerHeight}}return o.top>Math.min(l.bottom,n.bottom)-10||o.bottoms.from||s.from==0))if(l=g,typeof f!="string"&&f.header)o.appendChild(f.header(f));else{let O=o.appendChild(document.createElement("completion-section"));O.textContent=g}}const u=o.appendChild(document.createElement("li"));u.id=n+"-"+a,u.setAttribute("role","option");let d=this.optionClass(c);d&&(u.className=d);for(let g of this.optionContent){let O=g(c,this.view.state,this.view,h);O&&u.appendChild(O)}}return s.from&&o.classList.add("cm-completionListIncompleteTop"),s.tonew CompletionTooltip(n,r,e)}function scrollIntoView(r,e){let n=r.getBoundingClientRect(),s=e.getBoundingClientRect(),o=n.height/r.offsetHeight;s.topn.bottom&&(r.scrollTop+=(s.bottom-n.bottom)/o)}function score(r){return(r.boost||0)*100+(r.apply?10:0)+(r.info?5:0)+(r.type?1:0)}function sortOptions(r,e){let n=[],s=null,o=f=>{n.push(f);let{section:u}=f.completion;if(u){s||(s=[]);let d=typeof u=="string"?u:u.name;s.some(g=>g.name==d)||s.push(typeof u=="string"?{name:d}:u)}},l=e.facet(completionConfig);for(let f of r)if(f.hasResult()){let u=f.result.getMatch;if(f.result.filter===!1)for(let d of f.result.options)o(new Option(d,f.source,u?u(d):[],1e9-n.length));else{let d=e.sliceDoc(f.from,f.to),g,O=l.filterStrict?new StrictMatcher(d):new FuzzyMatcher(d);for(let m of f.result.options)if(g=O.match(m.label)){let y=m.displayLabel?u?u(m,g.matched):[]:g.matched;o(new Option(m,f.source,y,g.score+(m.boost||0)))}}}if(s){let f=Object.create(null),u=0,d=(g,O)=>{var m,y;return((m=g.rank)!==null&&m!==void 0?m:1e9)-((y=O.rank)!==null&&y!==void 0?y:1e9)||(g.named.score-u.score||h(u.completion,d.completion))){let u=f.completion;!c||c.label!=u.label||c.detail!=u.detail||c.type!=null&&u.type!=null&&c.type!=u.type||c.apply!=u.apply||c.boost!=u.boost?a.push(f):score(f.completion)>score(c)&&(a[a.length-1]=f),c=f.completion}return a}class CompletionDialog{constructor(e,n,s,o,l,a){this.options=e,this.attrs=n,this.tooltip=s,this.timestamp=o,this.selected=l,this.disabled=a}setSelected(e,n){return e==this.selected||e>=this.options.length?this:new CompletionDialog(this.options,makeAttrs(n,e),this.tooltip,this.timestamp,e,this.disabled)}static build(e,n,s,o,l){let a=sortOptions(e,n);if(!a.length)return o&&e.some(h=>h.state==1)?new CompletionDialog(o.options,o.attrs,o.tooltip,o.timestamp,o.selected,!0):null;let c=n.facet(completionConfig).selectOnOpen?0:-1;if(o&&o.selected!=c&&o.selected!=-1){let h=o.options[o.selected].completion;for(let f=0;ff.hasResult()?Math.min(h,f.from):h,1e8),create:createTooltip,above:l.aboveCursor},o?o.timestamp:Date.now(),c,!1)}map(e){return new CompletionDialog(this.options,this.attrs,Object.assign(Object.assign({},this.tooltip),{pos:e.mapPos(this.tooltip.pos)}),this.timestamp,this.selected,this.disabled)}}class CompletionState{constructor(e,n,s){this.active=e,this.id=n,this.open=s}static start(){return new CompletionState(none$1,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null)}update(e){let{state:n}=e,s=n.facet(completionConfig),l=(s.override||n.languageDataAt("autocomplete",cur(n)).map(asSource)).map(c=>(this.active.find(f=>f.source==c)||new ActiveSource(c,this.active.some(f=>f.state!=0)?1:0)).update(e,s));l.length==this.active.length&&l.every((c,h)=>c==this.active[h])&&(l=this.active);let a=this.open;a&&e.docChanged&&(a=a.map(e.changes)),e.selection||l.some(c=>c.hasResult()&&e.changes.touchesRange(c.from,c.to))||!sameResults(l,this.active)?a=CompletionDialog.build(l,n,this.id,a,s):a&&a.disabled&&!l.some(c=>c.state==1)&&(a=null),!a&&l.every(c=>c.state!=1)&&l.some(c=>c.hasResult())&&(l=l.map(c=>c.hasResult()?new ActiveSource(c.source,0):c));for(let c of e.effects)c.is(setSelectedEffect)&&(a=a&&a.setSelected(c.value,this.id));return l==this.active&&a==this.open?this:new CompletionState(l,this.id,a)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:baseAttrs}}function sameResults(r,e){if(r==e)return!0;for(let n=0,s=0;;){for(;n-1&&(n["aria-activedescendant"]=r+"-"+e),n}const none$1=[];function getUserEvent(r,e){if(r.isUserEvent("input.complete")){let n=r.annotation(pickedCompletion);if(n&&e.activateOnCompletion(n))return"input"}return r.isUserEvent("input.type")?"input":r.isUserEvent("delete.backward")?"delete":null}class ActiveSource{constructor(e,n,s=-1){this.source=e,this.state=n,this.explicitPos=s}hasResult(){return!1}update(e,n){let s=getUserEvent(e,n),o=this;s?o=o.handleUserEvent(e,s,n):e.docChanged?o=o.handleChange(e):e.selection&&o.state!=0&&(o=new ActiveSource(o.source,0));for(let l of e.effects)if(l.is(startCompletionEffect))o=new ActiveSource(o.source,1,l.value?cur(e.state):-1);else if(l.is(closeCompletionEffect))o=new ActiveSource(o.source,0);else if(l.is(setActiveEffect))for(let a of l.value)a.source==o.source&&(o=a);return o}handleUserEvent(e,n,s){return n=="delete"||!s.activateOnTyping?this.map(e.changes):new ActiveSource(this.source,1)}handleChange(e){return e.changes.touchesRange(cur(e.startState))?new ActiveSource(this.source,0):this.map(e.changes)}map(e){return e.empty||this.explicitPos<0?this:new ActiveSource(this.source,this.state,e.mapPos(this.explicitPos))}}class ActiveResult extends ActiveSource{constructor(e,n,s,o,l){super(e,2,n),this.result=s,this.from=o,this.to=l}hasResult(){return!0}handleUserEvent(e,n,s){var o;let l=this.result;l.map&&!e.changes.empty&&(l=l.map(l,e.changes));let a=e.changes.mapPos(this.from),c=e.changes.mapPos(this.to,1),h=cur(e.state);if((this.explicitPos<0?h<=a:hc||!l||n=="delete"&&cur(e.startState)==this.from)return new ActiveSource(this.source,n=="input"&&s.activateOnTyping?1:0);let f=this.explicitPos<0?-1:e.changes.mapPos(this.explicitPos);return checkValid(l.validFor,e.state,a,c)?new ActiveResult(this.source,f,l,a,c):l.update&&(l=l.update(l,a,c,new CompletionContext(e.state,h,f>=0)))?new ActiveResult(this.source,f,l,l.from,(o=l.to)!==null&&o!==void 0?o:cur(e.state)):new ActiveSource(this.source,1,f)}handleChange(e){return e.changes.touchesRange(this.from,this.to)?new ActiveSource(this.source,0):this.map(e.changes)}map(e){return e.empty?this:(this.result.map?this.result.map(this.result,e):this.result)?new ActiveResult(this.source,this.explicitPos<0?-1:e.mapPos(this.explicitPos),this.result,e.mapPos(this.from),e.mapPos(this.to,1)):new ActiveSource(this.source,0)}}function checkValid(r,e,n,s){if(!r)return!1;let o=e.sliceDoc(n,s);return typeof r=="function"?r(o,n,s,e):ensureAnchor(r,!0).test(o)}const setActiveEffect=StateEffect.define({map(r,e){return r.map(n=>n.map(e))}}),setSelectedEffect=StateEffect.define(),completionState=StateField.define({create(){return CompletionState.start()},update(r,e){return r.update(e)},provide:r=>[showTooltip.from(r,e=>e.tooltip),EditorView.contentAttributes.from(r,e=>e.attrs)]});function applyCompletion(r,e){const n=e.completion.apply||e.completion.label;let s=r.state.field(completionState).active.find(o=>o.source==e.source);return s instanceof ActiveResult?(typeof n=="string"?r.dispatch(Object.assign(Object.assign({},insertCompletionText(r.state,n,s.from,s.to)),{annotations:pickedCompletion.of(e.completion)})):n(r,e.completion,s.from,s.to),!0):!1}const createTooltip=completionTooltip(completionState,applyCompletion);function moveCompletionSelection(r,e="option"){return n=>{let s=n.state.field(completionState,!1);if(!s||!s.open||s.open.disabled||Date.now()-s.open.timestamp-1?s.open.selected+o*(r?1:-1):r?0:a-1;return c<0?c=e=="page"?0:a-1:c>=a&&(c=e=="page"?a-1:0),n.dispatch({effects:setSelectedEffect.of(c)}),!0}}const acceptCompletion=r=>{let e=r.state.field(completionState,!1);return r.state.readOnly||!e||!e.open||e.open.selected<0||e.open.disabled||Date.now()-e.open.timestampr.state.field(completionState,!1)?(r.dispatch({effects:startCompletionEffect.of(!0)}),!0):!1,closeCompletion=r=>{let e=r.state.field(completionState,!1);return!e||!e.active.some(n=>n.state!=0)?!1:(r.dispatch({effects:closeCompletionEffect.of(null)}),!0)};class RunningQuery{constructor(e,n){this.active=e,this.context=n,this.time=Date.now(),this.updates=[],this.done=void 0}}const MaxUpdateCount=50,MinAbortTime=1e3,completionPlugin=ViewPlugin.fromClass(class{constructor(r){this.view=r,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let e of r.state.field(completionState).active)e.state==1&&this.startQuery(e)}update(r){let e=r.state.field(completionState),n=r.state.facet(completionConfig);if(!r.selectionSet&&!r.docChanged&&r.startState.field(completionState)==e)return;let s=r.transactions.some(l=>(l.selection||l.docChanged)&&!getUserEvent(l,n));for(let l=0;lMaxUpdateCount&&Date.now()-a.time>MinAbortTime){for(let c of a.context.abortListeners)try{c()}catch(h){logException(this.view.state,h)}a.context.abortListeners=null,this.running.splice(l--,1)}else a.updates.push(...r.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),r.transactions.some(l=>l.effects.some(a=>a.is(startCompletionEffect)))&&(this.pendingStart=!0);let o=this.pendingStart?50:n.activateOnTypingDelay;if(this.debounceUpdate=e.active.some(l=>l.state==1&&!this.running.some(a=>a.active.source==l.source))?setTimeout(()=>this.startUpdate(),o):-1,this.composing!=0)for(let l of r.transactions)getUserEvent(l,n)=="input"?this.composing=2:this.composing==2&&l.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:r}=this.view,e=r.field(completionState);for(let n of e.active)n.state==1&&!this.running.some(s=>s.active.source==n.source)&&this.startQuery(n)}startQuery(r){let{state:e}=this.view,n=cur(e),s=new CompletionContext(e,n,r.explicitPos==n),o=new RunningQuery(r,s);this.running.push(o),Promise.resolve(r.source(s)).then(l=>{o.context.aborted||(o.done=l||null,this.scheduleAccept())},l=>{this.view.dispatch({effects:closeCompletionEffect.of(null)}),logException(this.view.state,l)})}scheduleAccept(){this.running.every(r=>r.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(completionConfig).updateSyncTime))}accept(){var r;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],n=this.view.state.facet(completionConfig);for(let s=0;sa.source==o.active.source);if(l&&l.state==1)if(o.done==null){let a=new ActiveSource(o.active.source,0);for(let c of o.updates)a=a.update(c,n);a.state!=1&&e.push(a)}else this.startQuery(l)}e.length&&this.view.dispatch({effects:setActiveEffect.of(e)})}},{eventHandlers:{blur(r){let e=this.view.state.field(completionState,!1);if(e&&e.tooltip&&this.view.state.facet(completionConfig).closeOnBlur){let n=e.open&&getTooltip(this.view,e.open.tooltip);(!n||!n.dom.contains(r.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:closeCompletionEffect.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:startCompletionEffect.of(!1)}),20),this.composing=0}}}),windows=typeof navigator=="object"&&/Win/.test(navigator.platform),commitCharacters=Prec.highest(EditorView.domEventHandlers({keydown(r,e){let n=e.state.field(completionState,!1);if(!n||!n.open||n.open.disabled||n.open.selected<0||r.key.length>1||r.ctrlKey&&!(windows&&r.altKey)||r.metaKey)return!1;let s=n.open.options[n.open.selected],o=n.active.find(a=>a.source==s.source),l=s.completion.commitCharacters||o.result.commitCharacters;return l&&l.indexOf(r.key)>-1&&applyCompletion(e,s),!1}})),baseTheme$2=EditorView.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:"monospace",whiteSpace:"nowrap",overflow:"hidden auto",maxWidth_fallback:"700px",maxWidth:"min(700px, 95vw)",minWidth:"250px",maxHeight:"10em",height:"100%",listStyle:"none",margin:0,padding:0,"& > li, & > completion-section":{padding:"1px 3px",lineHeight:1.2},"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer"},"& > completion-section":{display:"list-item",borderBottom:"1px solid silver",paddingLeft:"0.5em",opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#777"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#444"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"···"',opacity:.5,display:"block",textAlign:"center"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"400px",boxSizing:"border-box"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:"30px"},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"30px"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6",boxSizing:"content-box"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'ƒ'"}},".cm-completionIcon-class":{"&:after":{content:"'○'"}},".cm-completionIcon-interface":{"&:after":{content:"'◌'"}},".cm-completionIcon-variable":{"&:after":{content:"'𝑥'"}},".cm-completionIcon-constant":{"&:after":{content:"'𝐶'"}},".cm-completionIcon-type":{"&:after":{content:"'𝑡'"}},".cm-completionIcon-enum":{"&:after":{content:"'∪'"}},".cm-completionIcon-property":{"&:after":{content:"'□'"}},".cm-completionIcon-keyword":{"&:after":{content:"'🔑︎'"}},".cm-completionIcon-namespace":{"&:after":{content:"'▢'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}});class FieldPos{constructor(e,n,s,o){this.field=e,this.line=n,this.from=s,this.to=o}}class FieldRange{constructor(e,n,s){this.field=e,this.from=n,this.to=s}map(e){let n=e.mapPos(this.from,-1,MapMode.TrackDel),s=e.mapPos(this.to,1,MapMode.TrackDel);return n==null||s==null?null:new FieldRange(this.field,n,s)}}class Snippet{constructor(e,n){this.lines=e,this.fieldPositions=n}instantiate(e,n){let s=[],o=[n],l=e.doc.lineAt(n),a=/^\s*/.exec(l.text)[0];for(let h of this.lines){if(s.length){let f=a,u=/^\t*/.exec(h)[0].length;for(let d=0;dnew FieldRange(h.field,o[h.line]+h.from,o[h.line]+h.to));return{text:s,ranges:c}}static parse(e){let n=[],s=[],o=[],l;for(let a of e.split(/\r\n?|\n/)){for(;l=/[#$]\{(?:(\d+)(?::([^}]*))?|((?:\\[{}]|[^}])*))\}/.exec(a);){let c=l[1]?+l[1]:null,h=l[2]||l[3]||"",f=-1,u=h.replace(/\\[{}]/g,d=>d[1]);for(let d=0;d=f&&g.field++}o.push(new FieldPos(f,s.length,l.index,l.index+u.length)),a=a.slice(0,l.index)+h+a.slice(l.index+l[0].length)}a=a.replace(/\\([{}])/g,(c,h,f)=>{for(let u of o)u.line==s.length&&u.from>f&&(u.from--,u.to--);return h}),s.push(a)}return new Snippet(s,o)}}let fieldMarker=Decoration.widget({widget:new class extends WidgetType{toDOM(){let r=document.createElement("span");return r.className="cm-snippetFieldPosition",r}ignoreEvent(){return!1}}}),fieldRange=Decoration.mark({class:"cm-snippetField"});class ActiveSnippet{constructor(e,n){this.ranges=e,this.active=n,this.deco=Decoration.set(e.map(s=>(s.from==s.to?fieldMarker:fieldRange).range(s.from,s.to)))}map(e){let n=[];for(let s of this.ranges){let o=s.map(e);if(!o)return null;n.push(o)}return new ActiveSnippet(n,this.active)}selectionInsideField(e){return e.ranges.every(n=>this.ranges.some(s=>s.field==this.active&&s.from<=n.from&&s.to>=n.to))}}const setActive=StateEffect.define({map(r,e){return r&&r.map(e)}}),moveToField=StateEffect.define(),snippetState=StateField.define({create(){return null},update(r,e){for(let n of e.effects){if(n.is(setActive))return n.value;if(n.is(moveToField)&&r)return new ActiveSnippet(r.ranges,n.value)}return r&&e.docChanged&&(r=r.map(e.changes)),r&&e.selection&&!r.selectionInsideField(e.selection)&&(r=null),r},provide:r=>EditorView.decorations.from(r,e=>e?e.deco:Decoration.none)});function fieldSelection(r,e){return EditorSelection.create(r.filter(n=>n.field==e).map(n=>EditorSelection.range(n.from,n.to)))}function snippet(r){let e=Snippet.parse(r);return(n,s,o,l)=>{let{text:a,ranges:c}=e.instantiate(n.state,o),h={changes:{from:o,to:l,insert:Text.of(a)},scrollIntoView:!0,annotations:s?[pickedCompletion.of(s),Transaction.userEvent.of("input.complete")]:void 0};if(c.length&&(h.selection=fieldSelection(c,0)),c.some(f=>f.field>0)){let f=new ActiveSnippet(c,0),u=h.effects=[setActive.of(f)];n.state.field(snippetState,!1)===void 0&&u.push(StateEffect.appendConfig.of([snippetState,addSnippetKeymap,snippetPointerHandler,baseTheme$2]))}n.dispatch(n.state.update(h))}}function moveField(r){return({state:e,dispatch:n})=>{let s=e.field(snippetState,!1);if(!s||r<0&&s.active==0)return!1;let o=s.active+r,l=r>0&&!s.ranges.some(a=>a.field==o+r);return n(e.update({selection:fieldSelection(s.ranges,o),effects:setActive.of(l?null:new ActiveSnippet(s.ranges,o)),scrollIntoView:!0})),!0}}const clearSnippet=({state:r,dispatch:e})=>r.field(snippetState,!1)?(e(r.update({effects:setActive.of(null)})),!0):!1,nextSnippetField=moveField(1),prevSnippetField=moveField(-1),defaultSnippetKeymap=[{key:"Tab",run:nextSnippetField,shift:prevSnippetField},{key:"Escape",run:clearSnippet}],snippetKeymap=Facet.define({combine(r){return r.length?r[0]:defaultSnippetKeymap}}),addSnippetKeymap=Prec.highest(keymap.compute([snippetKeymap],r=>r.facet(snippetKeymap)));function snippetCompletion(r,e){return Object.assign(Object.assign({},e),{apply:snippet(r)})}const snippetPointerHandler=EditorView.domEventHandlers({mousedown(r,e){let n=e.state.field(snippetState,!1),s;if(!n||(s=e.posAtCoords({x:r.clientX,y:r.clientY}))==null)return!1;let o=n.ranges.find(l=>l.from<=s&&l.to>=s);return!o||o.field==n.active?!1:(e.dispatch({selection:fieldSelection(n.ranges,o.field),effects:setActive.of(n.ranges.some(l=>l.field>o.field)?new ActiveSnippet(n.ranges,o.field):null),scrollIntoView:!0}),!0)}}),defaults={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},closeBracketEffect=StateEffect.define({map(r,e){let n=e.mapPos(r,-1,MapMode.TrackAfter);return n??void 0}}),closedBracket=new class extends RangeValue{};closedBracket.startSide=1;closedBracket.endSide=-1;const bracketState=StateField.define({create(){return RangeSet.empty},update(r,e){if(r=r.map(e.changes),e.selection){let n=e.state.doc.lineAt(e.selection.main.head);r=r.update({filter:s=>s>=n.from&&s<=n.to})}for(let n of e.effects)n.is(closeBracketEffect)&&(r=r.update({add:[closedBracket.range(n.value,n.value+1)]}));return r}});function closeBrackets(){return[inputHandler,bracketState]}const definedClosing="()[]{}<>";function closing(r){for(let e=0;e{if((android$1?r.composing:r.compositionStarted)||r.state.readOnly)return!1;let o=r.state.selection.main;if(s.length>2||s.length==2&&codePointSize(codePointAt(s,0))==1||e!=o.from||n!=o.to)return!1;let l=insertBracket(r.state,s);return l?(r.dispatch(l),!0):!1}),deleteBracketPair=({state:r,dispatch:e})=>{if(r.readOnly)return!1;let s=config(r,r.selection.main.head).brackets||defaults.brackets,o=null,l=r.changeByRange(a=>{if(a.empty){let c=prevChar(r.doc,a.head);for(let h of s)if(h==c&&nextChar(r.doc,a.head)==closing(codePointAt(h,0)))return{changes:{from:a.head-h.length,to:a.head+h.length},range:EditorSelection.cursor(a.head-h.length)}}return{range:o=a}});return o||e(r.update(l,{scrollIntoView:!0,userEvent:"delete.backward"})),!o},closeBracketsKeymap=[{key:"Backspace",run:deleteBracketPair}];function insertBracket(r,e){let n=config(r,r.selection.main.head),s=n.brackets||defaults.brackets;for(let o of s){let l=closing(codePointAt(o,0));if(e==o)return l==o?handleSame(r,o,s.indexOf(o+o+o)>-1,n):handleOpen(r,o,l,n.before||defaults.before);if(e==l&&closedBracketAt(r,r.selection.main.from))return handleClose(r,o,l)}return null}function closedBracketAt(r,e){let n=!1;return r.field(bracketState).between(0,r.doc.length,s=>{s==e&&(n=!0)}),n}function nextChar(r,e){let n=r.sliceString(e,e+2);return n.slice(0,codePointSize(codePointAt(n,0)))}function prevChar(r,e){let n=r.sliceString(e-2,e);return codePointSize(codePointAt(n,0))==n.length?n:n.slice(1)}function handleOpen(r,e,n,s){let o=null,l=r.changeByRange(a=>{if(!a.empty)return{changes:[{insert:e,from:a.from},{insert:n,from:a.to}],effects:closeBracketEffect.of(a.to+e.length),range:EditorSelection.range(a.anchor+e.length,a.head+e.length)};let c=nextChar(r.doc,a.head);return!c||/\s/.test(c)||s.indexOf(c)>-1?{changes:{insert:e+n,from:a.head},effects:closeBracketEffect.of(a.head+e.length),range:EditorSelection.cursor(a.head+e.length)}:{range:o=a}});return o?null:r.update(l,{scrollIntoView:!0,userEvent:"input.type"})}function handleClose(r,e,n){let s=null,o=r.changeByRange(l=>l.empty&&nextChar(r.doc,l.head)==n?{changes:{from:l.head,to:l.head+n.length,insert:n},range:EditorSelection.cursor(l.head+n.length)}:s={range:l});return s?null:r.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function handleSame(r,e,n,s){let o=s.stringPrefixes||defaults.stringPrefixes,l=null,a=r.changeByRange(c=>{if(!c.empty)return{changes:[{insert:e,from:c.from},{insert:e,from:c.to}],effects:closeBracketEffect.of(c.to+e.length),range:EditorSelection.range(c.anchor+e.length,c.head+e.length)};let h=c.head,f=nextChar(r.doc,h),u;if(f==e){if(nodeStart(r,h))return{changes:{insert:e+e,from:h},effects:closeBracketEffect.of(h+e.length),range:EditorSelection.cursor(h+e.length)};if(closedBracketAt(r,h)){let g=n&&r.sliceDoc(h,h+e.length*3)==e+e+e?e+e+e:e;return{changes:{from:h,to:h+g.length,insert:g},range:EditorSelection.cursor(h+g.length)}}}else{if(n&&r.sliceDoc(h-2*e.length,h)==e+e&&(u=canStartStringAt(r,h-2*e.length,o))>-1&&nodeStart(r,u))return{changes:{insert:e+e+e+e,from:h},effects:closeBracketEffect.of(h+e.length),range:EditorSelection.cursor(h+e.length)};if(r.charCategorizer(h)(f)!=CharCategory.Word&&canStartStringAt(r,h,o)>-1&&!probablyInString(r,h,e,o))return{changes:{insert:e+e,from:h},effects:closeBracketEffect.of(h+e.length),range:EditorSelection.cursor(h+e.length)}}return{range:l=c}});return l?null:r.update(a,{scrollIntoView:!0,userEvent:"input.type"})}function nodeStart(r,e){let n=syntaxTree(r).resolveInner(e+1);return n.parent&&n.from==e}function probablyInString(r,e,n,s){let o=syntaxTree(r).resolveInner(e,-1),l=s.reduce((a,c)=>Math.max(a,c.length),0);for(let a=0;a<5;a++){let c=r.sliceDoc(o.from,Math.min(o.to,o.from+n.length+l)),h=c.indexOf(n);if(!h||h>-1&&s.indexOf(c.slice(0,h))>-1){let u=o.firstChild;for(;u&&u.from==o.from&&u.to-u.from>n.length+h;){if(r.sliceDoc(u.to-n.length,u.to)==n)return!1;u=u.firstChild}return!0}let f=o.to==e&&o.parent;if(!f)break;o=f}return!1}function canStartStringAt(r,e,n){let s=r.charCategorizer(e);if(s(r.sliceDoc(e-1,e))!=CharCategory.Word)return e;for(let o of n){let l=e-o.length;if(r.sliceDoc(l,e)==o&&s(r.sliceDoc(l-1,l))!=CharCategory.Word)return l}return-1}function autocompletion(r={}){return[commitCharacters,completionState,completionConfig.of(r),completionPlugin,completionKeymapExt,baseTheme$2]}const completionKeymap=[{key:"Ctrl-Space",run:startCompletion},{key:"Escape",run:closeCompletion},{key:"ArrowDown",run:moveCompletionSelection(!0)},{key:"ArrowUp",run:moveCompletionSelection(!1)},{key:"PageDown",run:moveCompletionSelection(!0,"page")},{key:"PageUp",run:moveCompletionSelection(!1,"page")},{key:"Enter",run:acceptCompletion}],completionKeymapExt=Prec.highest(keymap.computeN([completionConfig],r=>r.facet(completionConfig).defaultKeymap?[completionKeymap]:[])),snippets=[snippetCompletion("function ${name}(${params}) {\n ${}\n}",{label:"function",detail:"definition",type:"keyword"}),snippetCompletion("for (let ${index} = 0; ${index} < ${bound}; ${index}++) {\n ${}\n}",{label:"for",detail:"loop",type:"keyword"}),snippetCompletion("for (let ${name} of ${collection}) {\n ${}\n}",{label:"for",detail:"of loop",type:"keyword"}),snippetCompletion("do {\n ${}\n} while (${})",{label:"do",detail:"loop",type:"keyword"}),snippetCompletion("while (${}) {\n ${}\n}",{label:"while",detail:"loop",type:"keyword"}),snippetCompletion(`try { +`;this.styleTag.textContent=a;let c=n.head||n;this.styleTag.parentNode!=c&&c.insertBefore(this.styleTag,c.firstChild)}}setNonce(e){this.styleTag&&this.styleTag.getAttribute("nonce")!=e&&this.styleTag.setAttribute("nonce",e)}}var base={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},shift={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},mac=typeof navigator<"u"&&/Mac/.test(navigator.platform),ie$1=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var i=0;i<10;i++)base[48+i]=base[96+i]=String(i);for(var i=1;i<=24;i++)base[i+111]="F"+i;for(var i=65;i<=90;i++)base[i]=String.fromCharCode(i+32),shift[i]=String.fromCharCode(i);for(var code in base)shift.hasOwnProperty(code)||(shift[code]=base[code]);function keyName(r){var e=mac&&r.metaKey&&r.shiftKey&&!r.ctrlKey&&!r.altKey||ie$1&&r.shiftKey&&r.key&&r.key.length==1||r.key=="Unidentified",n=!e&&r.key||(r.shiftKey?shift:base)[r.keyCode]||r.key||"Unidentified";return n=="Esc"&&(n="Escape"),n=="Del"&&(n="Delete"),n=="Left"&&(n="ArrowLeft"),n=="Up"&&(n="ArrowUp"),n=="Right"&&(n="ArrowRight"),n=="Down"&&(n="ArrowDown"),n}function getSelection(r){let e;return r.nodeType==11?e=r.getSelection?r:r.ownerDocument:e=r,e.getSelection()}function contains(r,e){return e?r==e||r.contains(e.nodeType!=1?e.parentNode:e):!1}function deepActiveElement(r){let e=r.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function hasSelection(r,e){if(!e.anchorNode)return!1;try{return contains(r,e.anchorNode)}catch{return!1}}function clientRectsFor(r){return r.nodeType==3?textRange(r,0,r.nodeValue.length).getClientRects():r.nodeType==1?r.getClientRects():[]}function isEquivalentPosition(r,e,n,s){return n?scanFor(r,e,n,s,-1)||scanFor(r,e,n,s,1):!1}function domIndex(r){for(var e=0;;e++)if(r=r.previousSibling,!r)return e}function isBlockElement(r){return r.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(r.nodeName)}function scanFor(r,e,n,s,o){for(;;){if(r==n&&e==s)return!0;if(e==(o<0?0:maxOffset(r))){if(r.nodeName=="DIV")return!1;let l=r.parentNode;if(!l||l.nodeType!=1)return!1;e=domIndex(r)+(o<0?0:1),r=l}else if(r.nodeType==1){if(r=r.childNodes[e+(o<0?-1:0)],r.nodeType==1&&r.contentEditable=="false")return!1;e=o<0?maxOffset(r):0}else return!1}}function maxOffset(r){return r.nodeType==3?r.nodeValue.length:r.childNodes.length}function flattenRect(r,e){let n=e?r.left:r.right;return{left:n,right:n,top:r.top,bottom:r.bottom}}function windowRect(r){let e=r.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:r.innerWidth,top:0,bottom:r.innerHeight}}function getScale(r,e){let n=e.width/r.offsetWidth,s=e.height/r.offsetHeight;return(n>.995&&n<1.005||!isFinite(n)||Math.abs(e.width-r.offsetWidth)<1)&&(n=1),(s>.995&&s<1.005||!isFinite(s)||Math.abs(e.height-r.offsetHeight)<1)&&(s=1),{scaleX:n,scaleY:s}}function scrollRectIntoView(r,e,n,s,o,l,a,c){let h=r.ownerDocument,f=h.defaultView||window;for(let u=r,d=!1;u&&!d;)if(u.nodeType==1){let g,O=u==h.body,m=1,S=1;if(O)g=windowRect(f);else{if(/^(fixed|sticky)$/.test(getComputedStyle(u).position)&&(d=!0),u.scrollHeight<=u.clientHeight&&u.scrollWidth<=u.clientWidth){u=u.assignedSlot||u.parentNode;continue}let P=u.getBoundingClientRect();({scaleX:m,scaleY:S}=getScale(u,P)),g={left:P.left,right:P.left+u.clientWidth*m,top:P.top,bottom:P.top+u.clientHeight*S}}let b=0,w=0;if(o=="nearest")e.top0&&e.bottom>g.bottom+w&&(w=e.bottom-g.bottom+w+a)):e.bottom>g.bottom&&(w=e.bottom-g.bottom+a,n<0&&e.top-w0&&e.right>g.right+b&&(b=e.right-g.right+b+l)):e.right>g.right&&(b=e.right-g.right+l,n<0&&e.leftn.clientHeight||n.scrollWidth>n.clientWidth)return n;n=n.assignedSlot||n.parentNode}else if(n.nodeType==11)n=n.host;else break;return null}class DOMSelectionState{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(e){return this.anchorNode==e.anchorNode&&this.anchorOffset==e.anchorOffset&&this.focusNode==e.focusNode&&this.focusOffset==e.focusOffset}setRange(e){let{anchorNode:n,focusNode:s}=e;this.set(n,Math.min(e.anchorOffset,n?maxOffset(n):0),s,Math.min(e.focusOffset,s?maxOffset(s):0))}set(e,n,s,o){this.anchorNode=e,this.anchorOffset=n,this.focusNode=s,this.focusOffset=o}}let preventScrollSupported=null;function focusPreventScroll(r){if(r.setActive)return r.setActive();if(preventScrollSupported)return r.focus(preventScrollSupported);let e=[];for(let n=r;n&&(e.push(n,n.scrollTop,n.scrollLeft),n!=n.ownerDocument);n=n.parentNode);if(r.focus(preventScrollSupported==null?{get preventScroll(){return preventScrollSupported={preventScroll:!0},!0}}:void 0),!preventScrollSupported){preventScrollSupported=!1;for(let n=0;nMath.max(1,r.scrollHeight-r.clientHeight-4)}function textNodeBefore(r,e){for(let n=r,s=e;;){if(n.nodeType==3&&s>0)return{node:n,offset:s};if(n.nodeType==1&&s>0){if(n.contentEditable=="false")return null;n=n.childNodes[s-1],s=maxOffset(n)}else if(n.parentNode&&!isBlockElement(n))s=domIndex(n),n=n.parentNode;else return null}}function textNodeAfter(r,e){for(let n=r,s=e;;){if(n.nodeType==3&&sn)return d.domBoundsAround(e,n,f);if(g>=e&&o==-1&&(o=h,l=f),f>n&&d.dom.parentNode==this.dom){a=h,c=u;break}u=g,f=g+d.breakAfter}return{from:l,to:c<0?s+this.length:c,startDOM:(o?this.children[o-1].dom.nextSibling:null)||this.dom.firstChild,endDOM:a=0?this.children[a].dom:null}}markDirty(e=!1){this.flags|=2,this.markParentsDirty(e)}markParentsDirty(e){for(let n=this.parent;n;n=n.parent){if(e&&(n.flags|=2),n.flags&1)return;n.flags|=1,e=!1}}setParent(e){this.parent!=e&&(this.parent=e,this.flags&7&&this.markParentsDirty(!0))}setDOM(e){this.dom!=e&&(this.dom&&(this.dom.cmView=null),this.dom=e,e.cmView=this)}get rootView(){for(let e=this;;){let n=e.parent;if(!n)return e;e=n}}replaceChildren(e,n,s=noChildren){this.markDirty();for(let o=e;othis.pos||e==this.pos&&(n>0||this.i==0||this.children[this.i-1].breakAfter))return this.off=e-this.pos,this;let s=this.children[--this.i];this.pos-=s.length+s.breakAfter}}}function replaceRange(r,e,n,s,o,l,a,c,h){let{children:f}=r,u=f.length?f[e]:null,d=l.length?l[l.length-1]:null,g=d?d.breakAfter:a;if(!(e==s&&u&&!a&&!g&&l.length<2&&u.merge(n,o,l.length?d:null,n==0,c,h))){if(s0&&(!a&&l.length&&u.merge(n,u.length,l[0],!1,c,0)?u.breakAfter=l.shift().breakAfter:(n2);var browser={mac:ios||/Mac/.test(nav.platform),windows:/Win/.test(nav.platform),linux:/Linux|X11/.test(nav.platform),ie,ie_version:ie_upto10?doc.documentMode||6:ie_11up?+ie_11up[1]:ie_edge?+ie_edge[1]:0,gecko,gecko_version:gecko?+(/Firefox\/(\d+)/.exec(nav.userAgent)||[0,0])[1]:0,chrome:!!chrome,chrome_version:chrome?+chrome[1]:0,ios,android:/Android\b/.test(nav.userAgent),webkit,safari,webkit_version:webkit?+(/\bAppleWebKit\/(\d+)/.exec(nav.userAgent)||[0,0])[1]:0,tabSize:doc.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};const MaxJoinLen=256;class TextView extends ContentView{constructor(e){super(),this.text=e}get length(){return this.text.length}createDOM(e){this.setDOM(e||document.createTextNode(this.text))}sync(e,n){this.dom||this.createDOM(),this.dom.nodeValue!=this.text&&(n&&n.node==this.dom&&(n.written=!0),this.dom.nodeValue=this.text)}reuseDOM(e){e.nodeType==3&&this.createDOM(e)}merge(e,n,s){return this.flags&8||s&&(!(s instanceof TextView)||this.length-(n-e)+s.length>MaxJoinLen||s.flags&8)?!1:(this.text=this.text.slice(0,e)+(s?s.text:"")+this.text.slice(n),this.markDirty(),!0)}split(e){let n=new TextView(this.text.slice(e));return this.text=this.text.slice(0,e),this.markDirty(),n.flags|=this.flags&8,n}localPosFromDOM(e,n){return e==this.dom?n:n?this.text.length:0}domAtPos(e){return new DOMPos(this.dom,e)}domBoundsAround(e,n,s){return{from:s,to:s+this.length,startDOM:this.dom,endDOM:this.dom.nextSibling}}coordsAt(e,n){return textCoords(this.dom,e,n)}}class MarkView extends ContentView{constructor(e,n=[],s=0){super(),this.mark=e,this.children=n,this.length=s;for(let o of n)o.setParent(this)}setAttrs(e){if(clearAttributes(e),this.mark.class&&(e.className=this.mark.class),this.mark.attrs)for(let n in this.mark.attrs)e.setAttribute(n,this.mark.attrs[n]);return e}canReuseDOM(e){return super.canReuseDOM(e)&&!((this.flags|e.flags)&8)}reuseDOM(e){e.nodeName==this.mark.tagName.toUpperCase()&&(this.setDOM(e),this.flags|=6)}sync(e,n){this.dom?this.flags&4&&this.setAttrs(this.dom):this.setDOM(this.setAttrs(document.createElement(this.mark.tagName))),super.sync(e,n)}merge(e,n,s,o,l,a){return s&&(!(s instanceof MarkView&&s.mark.eq(this.mark))||e&&l<=0||ne&&n.push(s=e&&(o=l),s=h,l++}let a=this.length-e;return this.length=e,o>-1&&(this.children.length=o,this.markDirty()),new MarkView(this.mark,n,a)}domAtPos(e){return inlineDOMAtPos(this,e)}coordsAt(e,n){return coordsInChildren(this,e,n)}}function textCoords(r,e,n){let s=r.nodeValue.length;e>s&&(e=s);let o=e,l=e,a=0;e==0&&n<0||e==s&&n>=0?browser.chrome||browser.gecko||(e?(o--,a=1):l=0)?0:c.length-1];return browser.safari&&!a&&h.width==0&&(h=Array.prototype.find.call(c,f=>f.width)||h),a?flattenRect(h,a<0):h||null}class WidgetView extends ContentView{static create(e,n,s){return new WidgetView(e,n,s)}constructor(e,n,s){super(),this.widget=e,this.length=n,this.side=s,this.prevWidget=null}split(e){let n=WidgetView.create(this.widget,this.length-e,this.side);return this.length-=e,n}sync(e){(!this.dom||!this.widget.updateDOM(this.dom,e))&&(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(e)),this.widget.editable||(this.dom.contentEditable="false"))}getSide(){return this.side}merge(e,n,s,o,l,a){return s&&(!(s instanceof WidgetView)||!this.widget.compare(s.widget)||e>0&&l<=0||n0)?DOMPos.before(this.dom):DOMPos.after(this.dom,e==this.length)}domBoundsAround(){return null}coordsAt(e,n){let s=this.widget.coordsAt(this.dom,e,n);if(s)return s;let o=this.dom.getClientRects(),l=null;if(!o.length)return null;let a=this.side?this.side<0:e>0;for(let c=a?o.length-1:0;l=o[c],!(e>0?c==0:c==o.length-1||l.top0?DOMPos.before(this.dom):DOMPos.after(this.dom)}localPosFromDOM(){return 0}domBoundsAround(){return null}coordsAt(e){return this.dom.getBoundingClientRect()}get overrideDOMText(){return Text.empty}get isHidden(){return!0}}TextView.prototype.children=WidgetView.prototype.children=WidgetBufferView.prototype.children=noChildren;function inlineDOMAtPos(r,e){let n=r.dom,{children:s}=r,o=0;for(let l=0;ol&&e0;l--){let a=s[l-1];if(a.dom.parentNode==n)return a.domAtPos(a.length)}for(let l=o;l0&&e instanceof MarkView&&o.length&&(s=o[o.length-1])instanceof MarkView&&s.mark.eq(e.mark)?joinInlineInto(s,e.children[0],n-1):(o.push(e),e.setParent(r)),r.length+=e.length}function coordsInChildren(r,e,n){let s=null,o=-1,l=null,a=-1;function c(f,u){for(let d=0,g=0;d=u&&(O.children.length?c(O,u-g):(!l||l.isHidden&&n>0)&&(m>u||g==m&&O.getSide()>0)?(l=O,a=u-g):(g-1?1:0)!=o.length-(n&&o.indexOf(n)>-1?1:0))return!1;for(let l of s)if(l!=n&&(o.indexOf(l)==-1||r[l]!==e[l]))return!1;return!0}function updateAttrs(r,e,n){let s=!1;if(e)for(let o in e)n&&o in n||(s=!0,o=="style"?r.style.cssText="":r.removeAttribute(o));if(n)for(let o in n)e&&e[o]==n[o]||(s=!0,o=="style"?r.style.cssText=n[o]:r.setAttribute(o,n[o]));return s}function getAttrs(r){let e=Object.create(null);for(let n=0;n0&&this.children[s-1].length==0;)this.children[--s].destroy();return this.children.length=s,this.markDirty(),this.length=e,n}transferDOM(e){this.dom&&(this.markDirty(),e.setDOM(this.dom),e.prevAttrs=this.prevAttrs===void 0?this.attrs:this.prevAttrs,this.prevAttrs=void 0,this.dom=null)}setDeco(e){attrsEq(this.attrs,e)||(this.dom&&(this.prevAttrs=this.attrs,this.markDirty()),this.attrs=e)}append(e,n){joinInlineInto(this,e,n)}addLineDeco(e){let n=e.spec.attributes,s=e.spec.class;n&&(this.attrs=combineAttrs(n,this.attrs||{})),s&&(this.attrs=combineAttrs({class:s},this.attrs||{}))}domAtPos(e){return inlineDOMAtPos(this,e)}reuseDOM(e){e.nodeName=="DIV"&&(this.setDOM(e),this.flags|=6)}sync(e,n){var s;this.dom?this.flags&4&&(clearAttributes(this.dom),this.dom.className="cm-line",this.prevAttrs=this.attrs?null:void 0):(this.setDOM(document.createElement("div")),this.dom.className="cm-line",this.prevAttrs=this.attrs?null:void 0),this.prevAttrs!==void 0&&(updateAttrs(this.dom,this.prevAttrs,this.attrs),this.dom.classList.add("cm-line"),this.prevAttrs=void 0),super.sync(e,n);let o=this.dom.lastChild;for(;o&&ContentView.get(o)instanceof MarkView;)o=o.lastChild;if(!o||!this.length||o.nodeName!="BR"&&((s=ContentView.get(o))===null||s===void 0?void 0:s.isEditable)==!1&&(!browser.ios||!this.children.some(l=>l instanceof TextView))){let l=document.createElement("BR");l.cmIgnore=!0,this.dom.appendChild(l)}}measureTextSize(){if(this.children.length==0||this.length>20)return null;let e=0,n;for(let s of this.children){if(!(s instanceof TextView)||/[^ -~]/.test(s.text))return null;let o=clientRectsFor(s.dom);if(o.length!=1)return null;e+=o[0].width,n=o[0].height}return e?{lineHeight:this.dom.getBoundingClientRect().height,charWidth:e/this.length,textHeight:n}:null}coordsAt(e,n){let s=coordsInChildren(this,e,n);if(!this.children.length&&s&&this.parent){let{heightOracle:o}=this.parent.view.viewState,l=s.bottom-s.top;if(Math.abs(l-o.lineHeight)<2&&o.textHeight=n){if(l instanceof LineView)return l;if(a>n)break}o=a+l.breakAfter}return null}}class BlockWidgetView extends ContentView{constructor(e,n,s){super(),this.widget=e,this.length=n,this.deco=s,this.breakAfter=0,this.prevWidget=null}merge(e,n,s,o,l,a){return s&&(!(s instanceof BlockWidgetView)||!this.widget.compare(s.widget)||e>0&&l<=0||n0}}class WidgetType{eq(e){return!1}updateDOM(e,n){return!1}compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}get estimatedHeight(){return-1}get lineBreaks(){return 0}ignoreEvent(e){return!0}coordsAt(e,n,s){return null}get isHidden(){return!1}get editable(){return!1}destroy(e){}}var BlockType=function(r){return r[r.Text=0]="Text",r[r.WidgetBefore=1]="WidgetBefore",r[r.WidgetAfter=2]="WidgetAfter",r[r.WidgetRange=3]="WidgetRange",r}(BlockType||(BlockType={}));class Decoration extends RangeValue{constructor(e,n,s,o){super(),this.startSide=e,this.endSide=n,this.widget=s,this.spec=o}get heightRelevant(){return!1}static mark(e){return new MarkDecoration(e)}static widget(e){let n=Math.max(-1e4,Math.min(1e4,e.side||0)),s=!!e.block;return n+=s&&!e.inlineOrder?n>0?3e8:-4e8:n>0?1e8:-1e8,new PointDecoration(e,n,n,s,e.widget||null,!1)}static replace(e){let n=!!e.block,s,o;if(e.isBlockGap)s=-5e8,o=4e8;else{let{start:l,end:a}=getInclusive(e,n);s=(l?n?-3e8:-1:5e8)-1,o=(a?n?2e8:1:-6e8)+1}return new PointDecoration(e,s,o,n,e.widget||null,!0)}static line(e){return new LineDecoration(e)}static set(e,n=!1){return RangeSet.of(e,n)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}}Decoration.none=RangeSet.empty;class MarkDecoration extends Decoration{constructor(e){let{start:n,end:s}=getInclusive(e);super(n?-1:5e8,s?1:-6e8,null,e),this.tagName=e.tagName||"span",this.class=e.class||"",this.attrs=e.attributes||null}eq(e){var n,s;return this==e||e instanceof MarkDecoration&&this.tagName==e.tagName&&(this.class||((n=this.attrs)===null||n===void 0?void 0:n.class))==(e.class||((s=e.attrs)===null||s===void 0?void 0:s.class))&&attrsEq(this.attrs,e.attrs,"class")}range(e,n=e){if(e>=n)throw new RangeError("Mark decorations may not be empty");return super.range(e,n)}}MarkDecoration.prototype.point=!1;class LineDecoration extends Decoration{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof LineDecoration&&this.spec.class==e.spec.class&&attrsEq(this.spec.attributes,e.spec.attributes)}range(e,n=e){if(n!=e)throw new RangeError("Line decoration ranges must be zero-length");return super.range(e,n)}}LineDecoration.prototype.mapMode=MapMode.TrackBefore;LineDecoration.prototype.point=!0;class PointDecoration extends Decoration{constructor(e,n,s,o,l,a){super(n,s,l,e),this.block=o,this.isReplace=a,this.mapMode=o?n<=0?MapMode.TrackBefore:MapMode.TrackAfter:MapMode.TrackDel}get type(){return this.startSide!=this.endSide?BlockType.WidgetRange:this.startSide<=0?BlockType.WidgetBefore:BlockType.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof PointDecoration&&widgetsEq(this.widget,e.widget)&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide}range(e,n=e){if(this.isReplace&&(e>n||e==n&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&n!=e)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(e,n)}}PointDecoration.prototype.point=!0;function getInclusive(r,e=!1){let{inclusiveStart:n,inclusiveEnd:s}=r;return n==null&&(n=r.inclusive),s==null&&(s=r.inclusive),{start:n??e,end:s??e}}function widgetsEq(r,e){return r==e||!!(r&&e&&r.compare(e))}function addRange(r,e,n,s=0){let o=n.length-1;o>=0&&n[o]+s>=r?n[o]=Math.max(n[o],e):n.push(r,e)}class ContentBuilder{constructor(e,n,s,o){this.doc=e,this.pos=n,this.end=s,this.disallowBlockEffectsFor=o,this.content=[],this.curLine=null,this.breakAtStart=0,this.pendingBuffer=0,this.bufferMarks=[],this.atCursorPos=!0,this.openStart=-1,this.openEnd=-1,this.text="",this.textOff=0,this.cursor=e.iter(),this.skip=n}posCovered(){if(this.content.length==0)return!this.breakAtStart&&this.doc.lineAt(this.pos).from!=this.pos;let e=this.content[this.content.length-1];return!(e.breakAfter||e instanceof BlockWidgetView&&e.deco.endSide<0)}getLine(){return this.curLine||(this.content.push(this.curLine=new LineView),this.atCursorPos=!0),this.curLine}flushBuffer(e=this.bufferMarks){this.pendingBuffer&&(this.curLine.append(wrapMarks(new WidgetBufferView(-1),e),e.length),this.pendingBuffer=0)}addBlockWidget(e){this.flushBuffer(),this.curLine=null,this.content.push(e)}finish(e){this.pendingBuffer&&e<=this.bufferMarks.length?this.flushBuffer():this.pendingBuffer=0,!this.posCovered()&&!(e&&this.content.length&&this.content[this.content.length-1]instanceof BlockWidgetView)&&this.getLine()}buildText(e,n,s){for(;e>0;){if(this.textOff==this.text.length){let{value:l,lineBreak:a,done:c}=this.cursor.next(this.skip);if(this.skip=0,c)throw new Error("Ran out of text content when drawing inline views");if(a){this.posCovered()||this.getLine(),this.content.length?this.content[this.content.length-1].breakAfter=1:this.breakAtStart=1,this.flushBuffer(),this.curLine=null,this.atCursorPos=!0,e--;continue}else this.text=l,this.textOff=0}let o=Math.min(this.text.length-this.textOff,e,512);this.flushBuffer(n.slice(n.length-s)),this.getLine().append(wrapMarks(new TextView(this.text.slice(this.textOff,this.textOff+o)),n),s),this.atCursorPos=!0,this.textOff+=o,e-=o,s=0}}span(e,n,s,o){this.buildText(n-e,s,o),this.pos=n,this.openStart<0&&(this.openStart=o)}point(e,n,s,o,l,a){if(this.disallowBlockEffectsFor[a]&&s instanceof PointDecoration){if(s.block)throw new RangeError("Block decorations may not be specified via plugins");if(n>this.doc.lineAt(this.pos).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}let c=n-e;if(s instanceof PointDecoration)if(s.block)s.startSide>0&&!this.posCovered()&&this.getLine(),this.addBlockWidget(new BlockWidgetView(s.widget||NullWidget.block,c,s));else{let h=WidgetView.create(s.widget||NullWidget.inline,c,c?0:s.startSide),f=this.atCursorPos&&!h.isEditable&&l<=o.length&&(e0),u=!h.isEditable&&(eo.length||s.startSide<=0),d=this.getLine();this.pendingBuffer==2&&!f&&!h.isEditable&&(this.pendingBuffer=0),this.flushBuffer(o),f&&(d.append(wrapMarks(new WidgetBufferView(1),o),l),l=o.length+Math.max(0,l-o.length)),d.append(wrapMarks(h,o),l),this.atCursorPos=u,this.pendingBuffer=u?eo.length?1:2:0,this.pendingBuffer&&(this.bufferMarks=o.slice())}else this.doc.lineAt(this.pos).from==this.pos&&this.getLine().addLineDeco(s);c&&(this.textOff+c<=this.text.length?this.textOff+=c:(this.skip+=c-(this.text.length-this.textOff),this.text="",this.textOff=0),this.pos=n),this.openStart<0&&(this.openStart=l)}static build(e,n,s,o,l){let a=new ContentBuilder(e,n,s,l);return a.openEnd=RangeSet.spans(o,n,s,a),a.openStart<0&&(a.openStart=a.openEnd),a.finish(a.openEnd),a}}function wrapMarks(r,e){for(let n of e)r=new MarkView(n,[r],r.length);return r}class NullWidget extends WidgetType{constructor(e){super(),this.tag=e}eq(e){return e.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(e){return e.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}}NullWidget.inline=new NullWidget("span");NullWidget.block=new NullWidget("div");var Direction=function(r){return r[r.LTR=0]="LTR",r[r.RTL=1]="RTL",r}(Direction||(Direction={}));const LTR=Direction.LTR,RTL=Direction.RTL;function dec(r){let e=[];for(let n=0;n=n){if(c.level==s)return a;(l<0||(o!=0?o<0?c.fromn:e[l].level>c.level))&&(l=a)}}if(l<0)throw new RangeError("Index out of range");return l}}function isolatesEq(r,e){if(r.length!=e.length)return!1;for(let n=0;n=0;S-=3)if(BracketStack[S+1]==-O){let b=BracketStack[S+2],w=b&2?o:b&4?b&1?l:o:0;w&&(types[d]=types[BracketStack[S]]=w),c=S;break}}else{if(BracketStack.length==189)break;BracketStack[c++]=d,BracketStack[c++]=g,BracketStack[c++]=h}else if((m=types[d])==2||m==1){let S=m==o;h=S?0:1;for(let b=c-3;b>=0;b-=3){let w=BracketStack[b+2];if(w&2)break;if(S)BracketStack[b+2]|=2;else{if(w&4)break;BracketStack[b+2]|=4}}}}}function processNeutrals(r,e,n,s){for(let o=0,l=s;o<=n.length;o++){let a=o?n[o-1].to:r,c=oh;)m==b&&(m=n[--S].from,b=S?n[S-1].to:r),types[--m]=O;h=u}else l=f,h++}}}function emitSpans(r,e,n,s,o,l,a){let c=s%2?2:1;if(s%2==o%2)for(let h=e,f=0;hh&&a.push(new BidiSpan(h,S.from,O));let b=S.direction==LTR!=!(O%2);computeSectionOrder(r,b?s+1:s,o,S.inner,S.from,S.to,a),h=S.to}m=S.to}else{if(m==n||(u?types[m]!=c:types[m]==c))break;m++}g?emitSpans(r,h,m,s+1,o,g,a):he;){let u=!0,d=!1;if(!f||h>l[f-1].to){let S=types[h-1];S!=c&&(u=!1,d=S==16)}let g=!u&&c==1?[]:null,O=u?s:s+1,m=h;e:for(;;)if(f&&m==l[f-1].to){if(d)break e;let S=l[--f];if(!u)for(let b=S.from,w=f;;){if(b==e)break e;if(w&&l[w-1].to==b)b=l[--w].from;else{if(types[b-1]==c)break e;break}}if(g)g.push(S);else{S.totypes.length;)types[types.length]=256;let s=[],o=e==LTR?0:1;return computeSectionOrder(r,o,o,n,0,r.length,s),s}function trivialOrder(r){return[new BidiSpan(0,r,0)]}let movedOver="";function moveVisually(r,e,n,s,o){var l;let a=s.head-r.from,c=BidiSpan.find(e,a,(l=s.bidiLevel)!==null&&l!==void 0?l:-1,s.assoc),h=e[c],f=h.side(o,n);if(a==f){let g=c+=o?1:-1;if(g<0||g>=e.length)return null;h=e[c=g],a=h.side(!o,n),f=h.side(o,n)}let u=findClusterBreak(r.text,a,h.forward(o,n));(uh.to)&&(u=f),movedOver=r.text.slice(Math.min(a,u),Math.max(a,u));let d=c==(o?e.length-1:0)?null:e[c+(o?1:-1)];return d&&u==f&&d.level+(o?0:1)r.some(e=>e)}),nativeSelectionHidden=Facet.define({combine:r=>r.some(e=>e)}),scrollHandler=Facet.define();class ScrollTarget{constructor(e,n="nearest",s="nearest",o=5,l=5,a=!1){this.range=e,this.y=n,this.x=s,this.yMargin=o,this.xMargin=l,this.isSnapshot=a}map(e){return e.empty?this:new ScrollTarget(this.range.map(e),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(e){return this.range.to<=e.doc.length?this:new ScrollTarget(EditorSelection.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const scrollIntoView$1=StateEffect.define({map:(r,e)=>r.map(e)}),setEditContextFormatting=StateEffect.define();function logException(r,e,n){let s=r.facet(exceptionSink);s.length?s[0](e):window.onerror?window.onerror(String(e),n,void 0,void 0,e):n?console.error(n+":",e):console.error(e)}const editable=Facet.define({combine:r=>r.length?r[0]:!0});let nextPluginID=0;const viewPlugin=Facet.define();class ViewPlugin{constructor(e,n,s,o,l){this.id=e,this.create=n,this.domEventHandlers=s,this.domEventObservers=o,this.extension=l(this)}static define(e,n){const{eventHandlers:s,eventObservers:o,provide:l,decorations:a}=n||{};return new ViewPlugin(nextPluginID++,e,s,o,c=>{let h=[viewPlugin.of(c)];return a&&h.push(decorations.of(f=>{let u=f.plugin(c);return u?a(u):Decoration.none})),l&&h.push(l(c)),h})}static fromClass(e,n){return ViewPlugin.define(s=>new e(s),n)}}class PluginInstance{constructor(e){this.spec=e,this.mustUpdate=null,this.value=null}update(e){if(this.value){if(this.mustUpdate){let n=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(n)}catch(s){if(logException(n.state,s,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch{}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.create(e)}catch(n){logException(e.state,n,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var n;if(!((n=this.value)===null||n===void 0)&&n.destroy)try{this.value.destroy()}catch(s){logException(e.state,s,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const editorAttributes=Facet.define(),contentAttributes=Facet.define(),decorations=Facet.define(),outerDecorations=Facet.define(),atomicRanges=Facet.define(),bidiIsolatedRanges=Facet.define();function getIsolatedRanges(r,e){let n=r.state.facet(bidiIsolatedRanges);if(!n.length)return n;let s=n.map(l=>l instanceof Function?l(r):l),o=[];return RangeSet.spans(s,e.from,e.to,{point(){},span(l,a,c,h){let f=l-e.from,u=a-e.from,d=o;for(let g=c.length-1;g>=0;g--,h--){let O=c[g].spec.bidiIsolate,m;if(O==null&&(O=autoDirection(e.text,f,u)),h>0&&d.length&&(m=d[d.length-1]).to==f&&m.direction==O)m.to=u,d=m.inner;else{let S={from:f,to:u,direction:O,inner:[]};d.push(S),d=S.inner}}}}),o}const scrollMargins=Facet.define();function getScrollMargins(r){let e=0,n=0,s=0,o=0;for(let l of r.state.facet(scrollMargins)){let a=l(r);a&&(a.left!=null&&(e=Math.max(e,a.left)),a.right!=null&&(n=Math.max(n,a.right)),a.top!=null&&(s=Math.max(s,a.top)),a.bottom!=null&&(o=Math.max(o,a.bottom)))}return{left:e,right:n,top:s,bottom:o}}const styleModule=Facet.define();class ChangedRange{constructor(e,n,s,o){this.fromA=e,this.toA=n,this.fromB=s,this.toB=o}join(e){return new ChangedRange(Math.min(this.fromA,e.fromA),Math.max(this.toA,e.toA),Math.min(this.fromB,e.fromB),Math.max(this.toB,e.toB))}addToSet(e){let n=e.length,s=this;for(;n>0;n--){let o=e[n-1];if(!(o.fromA>s.toA)){if(o.toAu)break;l+=2}if(!h)return s;new ChangedRange(h.fromA,h.toA,h.fromB,h.toB).addToSet(s),a=h.toA,c=h.toB}}}class ViewUpdate{constructor(e,n,s){this.view=e,this.state=n,this.transactions=s,this.flags=0,this.startState=e.state,this.changes=ChangeSet.empty(this.startState.doc.length);for(let l of s)this.changes=this.changes.compose(l.changes);let o=[];this.changes.iterChangedRanges((l,a,c,h)=>o.push(new ChangedRange(l,a,c,h))),this.changedRanges=o}static create(e,n,s){return new ViewUpdate(e,n,s)}get viewportChanged(){return(this.flags&4)>0}get heightChanged(){return(this.flags&2)>0}get geometryChanged(){return this.docChanged||(this.flags&10)>0}get focusChanged(){return(this.flags&1)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(e=>e.selection)}get empty(){return this.flags==0&&this.transactions.length==0}}class DocView extends ContentView{get length(){return this.view.state.doc.length}constructor(e){super(),this.view=e,this.decorations=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.markedForComposition=new Set,this.editContextFormatting=Decoration.none,this.lastCompositionAfterCursor=!1,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.setDOM(e.contentDOM),this.children=[new LineView],this.children[0].setParent(this),this.updateDeco(),this.updateInner([new ChangedRange(0,0,0,e.state.doc.length)],0,null)}update(e){var n;let s=e.changedRanges;this.minWidth>0&&s.length&&(s.every(({fromA:f,toA:u})=>uthis.minWidthTo)?(this.minWidthFrom=e.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=e.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0),this.updateEditContextFormatting(e);let o=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&(!((n=this.domChanged)===null||n===void 0)&&n.newSel?o=this.domChanged.newSel.head:!touchesComposition(e.changes,this.hasComposition)&&!e.selectionSet&&(o=e.state.selection.main.head));let l=o>-1?findCompositionRange(this.view,e.changes,o):null;if(this.domChanged=null,this.hasComposition){this.markedForComposition.clear();let{from:f,to:u}=this.hasComposition;s=new ChangedRange(f,u,e.changes.mapPos(f,-1),e.changes.mapPos(u,1)).addToSet(s.slice())}this.hasComposition=l?{from:l.range.fromB,to:l.range.toB}:null,(browser.ie||browser.chrome)&&!l&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let a=this.decorations,c=this.updateDeco(),h=findChangedDeco(a,c,e.changes);return s=ChangedRange.extendWithRanges(s,h),!(this.flags&7)&&s.length==0?!1:(this.updateInner(s,e.startState.doc.length,l),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,n,s){this.view.viewState.mustMeasureContent=!0,this.updateChildren(e,n,s);let{observer:o}=this.view;o.ignore(()=>{this.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let a=browser.chrome||browser.ios?{node:o.selectionRange.focusNode,written:!1}:void 0;this.sync(this.view,a),this.flags&=-8,a&&(a.written||o.selectionRange.focusNode!=a.node)&&(this.forceSelection=!0),this.dom.style.height=""}),this.markedForComposition.forEach(a=>a.flags&=-9);let l=[];if(this.view.viewport.from||this.view.viewport.to=0?o[a]:null;if(!c)break;let{fromA:h,toA:f,fromB:u,toB:d}=c,g,O,m,S;if(s&&s.range.fromBu){let A=ContentBuilder.build(this.view.state.doc,u,s.range.fromB,this.decorations,this.dynamicDecorationMap),v=ContentBuilder.build(this.view.state.doc,s.range.toB,d,this.decorations,this.dynamicDecorationMap);O=A.breakAtStart,m=A.openStart,S=v.openEnd;let Q=this.compositionView(s);v.breakAtStart?Q.breakAfter=1:v.content.length&&Q.merge(Q.length,Q.length,v.content[0],!1,v.openStart,0)&&(Q.breakAfter=v.content[0].breakAfter,v.content.shift()),A.content.length&&Q.merge(0,0,A.content[A.content.length-1],!0,0,A.openEnd)&&A.content.pop(),g=A.content.concat(Q).concat(v.content)}else({content:g,breakAtStart:O,openStart:m,openEnd:S}=ContentBuilder.build(this.view.state.doc,u,d,this.decorations,this.dynamicDecorationMap));let{i:b,off:w}=l.findPos(f,1),{i:P,off:$}=l.findPos(h,-1);replaceRange(this,P,$,b,w,g,O,m,S)}s&&this.fixCompositionDOM(s)}updateEditContextFormatting(e){this.editContextFormatting=this.editContextFormatting.map(e.changes);for(let n of e.transactions)for(let s of n.effects)s.is(setEditContextFormatting)&&(this.editContextFormatting=s.value)}compositionView(e){let n=new TextView(e.text.nodeValue);n.flags|=8;for(let{deco:o}of e.marks)n=new MarkView(o,[n],n.length);let s=new LineView;return s.append(n,0),s}fixCompositionDOM(e){let n=(l,a)=>{a.flags|=8|(a.children.some(h=>h.flags&7)?1:0),this.markedForComposition.add(a);let c=ContentView.get(l);c&&c!=a&&(c.dom=null),a.setDOM(l)},s=this.childPos(e.range.fromB,1),o=this.children[s.i];n(e.line,o);for(let l=e.marks.length-1;l>=-1;l--)s=o.childPos(s.off,1),o=o.children[s.i],n(l>=0?e.marks[l].node:e.text,o)}updateSelection(e=!1,n=!1){(e||!this.view.observer.selectionRange.focusNode)&&this.view.observer.readSelectionRange();let s=this.view.root.activeElement,o=s==this.dom,l=!o&&hasSelection(this.dom,this.view.observer.selectionRange)&&!(s&&this.dom.contains(s));if(!(o||n||l))return;let a=this.forceSelection;this.forceSelection=!1;let c=this.view.state.selection.main,h=this.moveToLine(this.domAtPos(c.anchor)),f=c.empty?h:this.moveToLine(this.domAtPos(c.head));if(browser.gecko&&c.empty&&!this.hasComposition&&betweenUneditable(h)){let d=document.createTextNode("");this.view.observer.ignore(()=>h.node.insertBefore(d,h.node.childNodes[h.offset]||null)),h=f=new DOMPos(d,0),a=!0}let u=this.view.observer.selectionRange;(a||!u.focusNode||(!isEquivalentPosition(h.node,h.offset,u.anchorNode,u.anchorOffset)||!isEquivalentPosition(f.node,f.offset,u.focusNode,u.focusOffset))&&!this.suppressWidgetCursorChange(u,c))&&(this.view.observer.ignore(()=>{browser.android&&browser.chrome&&this.dom.contains(u.focusNode)&&inUneditable(u.focusNode,this.dom)&&(this.dom.blur(),this.dom.focus({preventScroll:!0}));let d=getSelection(this.view.root);if(d)if(c.empty){if(browser.gecko){let g=nextToUneditable(h.node,h.offset);if(g&&g!=3){let O=(g==1?textNodeBefore:textNodeAfter)(h.node,h.offset);O&&(h=new DOMPos(O.node,O.offset))}}d.collapse(h.node,h.offset),c.bidiLevel!=null&&d.caretBidiLevel!==void 0&&(d.caretBidiLevel=c.bidiLevel)}else if(d.extend){d.collapse(h.node,h.offset);try{d.extend(f.node,f.offset)}catch{}}else{let g=document.createRange();c.anchor>c.head&&([h,f]=[f,h]),g.setEnd(f.node,f.offset),g.setStart(h.node,h.offset),d.removeAllRanges(),d.addRange(g)}l&&this.view.root.activeElement==this.dom&&(this.dom.blur(),s&&s.focus())}),this.view.observer.setSelectionRange(h,f)),this.impreciseAnchor=h.precise?null:new DOMPos(u.anchorNode,u.anchorOffset),this.impreciseHead=f.precise?null:new DOMPos(u.focusNode,u.focusOffset)}suppressWidgetCursorChange(e,n){return this.hasComposition&&n.empty&&isEquivalentPosition(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==n.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,n=e.state.selection.main,s=getSelection(e.root),{anchorNode:o,anchorOffset:l}=e.observer.selectionRange;if(!s||!n.empty||!n.assoc||!s.modify)return;let a=LineView.find(this,n.head);if(!a)return;let c=a.posAtStart;if(n.head==c||n.head==c+a.length)return;let h=this.coordsAt(n.head,-1),f=this.coordsAt(n.head,1);if(!h||!f||h.bottom>f.top)return;let u=this.domAtPos(n.head+n.assoc);s.collapse(u.node,u.offset),s.modify("move",n.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let d=e.observer.selectionRange;e.docView.posFromDOM(d.anchorNode,d.anchorOffset)!=n.from&&s.collapse(o,l)}moveToLine(e){let n=this.dom,s;if(e.node!=n)return e;for(let o=e.offset;!s&&o=0;o--){let l=ContentView.get(n.childNodes[o]);l instanceof LineView&&(s=l.domAtPos(l.length))}return s?new DOMPos(s.node,s.offset,!0):e}nearest(e){for(let n=e;n;){let s=ContentView.get(n);if(s&&s.rootView==this)return s;n=n.parentNode}return null}posFromDOM(e,n){let s=this.nearest(e);if(!s)throw new RangeError("Trying to find position for a DOM position outside of the document");return s.localPosFromDOM(e,n)+s.posAtStart}domAtPos(e){let{i:n,off:s}=this.childCursor().findPos(e,-1);for(;n=0;a--){let c=this.children[a],h=l-c.breakAfter,f=h-c.length;if(he||c.covers(1))&&(!s||c instanceof LineView&&!(s instanceof LineView&&n>=0)))s=c,o=f;else if(s&&f==e&&h==e&&c instanceof BlockWidgetView&&Math.abs(n)<2){if(c.deco.startSide<0)break;a&&(s=null)}l=f}return s?s.coordsAt(e-o,n):null}coordsForChar(e){let{i:n,off:s}=this.childPos(e,1),o=this.children[n];if(!(o instanceof LineView))return null;for(;o.children.length;){let{i:c,off:h}=o.childPos(s,1);for(;;c++){if(c==o.children.length)return null;if((o=o.children[c]).length)break}s=h}if(!(o instanceof TextView))return null;let l=findClusterBreak(o.text,s);if(l==s)return null;let a=textRange(o.dom,s,l).getClientRects();for(let c=0;cMath.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,c=-1,h=this.view.textDirection==Direction.LTR;for(let f=0,u=0;uo)break;if(f>=s){let O=d.dom.getBoundingClientRect();if(n.push(O.height),a){let m=d.dom.lastChild,S=m?clientRectsFor(m):[];if(S.length){let b=S[S.length-1],w=h?b.right-O.left:O.right-b.left;w>c&&(c=w,this.minWidth=l,this.minWidthFrom=f,this.minWidthTo=g)}}}f=g+d.breakAfter}return n}textDirectionAt(e){let{i:n}=this.childPos(e,1);return getComputedStyle(this.children[n].dom).direction=="rtl"?Direction.RTL:Direction.LTR}measureTextSize(){for(let l of this.children)if(l instanceof LineView){let a=l.measureTextSize();if(a)return a}let e=document.createElement("div"),n,s,o;return e.className="cm-line",e.style.width="99999px",e.style.position="absolute",e.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.dom.appendChild(e);let l=clientRectsFor(e.firstChild)[0];n=e.getBoundingClientRect().height,s=l?l.width/27:7,o=l?l.height:n,e.remove()}),{lineHeight:n,charWidth:s,textHeight:o}}childCursor(e=this.length){let n=this.children.length;return n&&(e-=this.children[--n].length),new ChildCursor(this.children,e,n)}computeBlockGapDeco(){let e=[],n=this.view.viewState;for(let s=0,o=0;;o++){let l=o==n.viewports.length?null:n.viewports[o],a=l?l.from-1:this.length;if(a>s){let c=(n.lineBlockAt(a).bottom-n.lineBlockAt(s).top)/this.view.scaleY;e.push(Decoration.replace({widget:new BlockGapWidget(c),block:!0,inclusive:!0,isBlockGap:!0}).range(s,a))}if(!l)break;s=l.to+1}return Decoration.set(e)}updateDeco(){let e=1,n=this.view.state.facet(decorations).map(l=>(this.dynamicDecorationMap[e++]=typeof l=="function")?l(this.view):l),s=!1,o=this.view.state.facet(outerDecorations).map((l,a)=>{let c=typeof l=="function";return c&&(s=!0),c?l(this.view):l});for(o.length&&(this.dynamicDecorationMap[e++]=s,n.push(RangeSet.join(o))),this.decorations=[this.editContextFormatting,...n,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];en.anchor?-1:1),o;if(!s)return;!n.empty&&(o=this.coordsAt(n.anchor,n.anchor>n.head?-1:1))&&(s={left:Math.min(s.left,o.left),top:Math.min(s.top,o.top),right:Math.max(s.right,o.right),bottom:Math.max(s.bottom,o.bottom)});let l=getScrollMargins(this.view),a={left:s.left-l.left,top:s.top-l.top,right:s.right+l.right,bottom:s.bottom+l.bottom},{offsetWidth:c,offsetHeight:h}=this.view.scrollDOM;scrollRectIntoView(this.view.scrollDOM,a,n.head{se.from&&(n=!0)}),n}function groupAt(r,e,n=1){let s=r.charCategorizer(e),o=r.doc.lineAt(e),l=e-o.from;if(o.length==0)return EditorSelection.cursor(e);l==0?n=1:l==o.length&&(n=-1);let a=l,c=l;n<0?a=findClusterBreak(o.text,l,!1):c=findClusterBreak(o.text,l);let h=s(o.text.slice(a,c));for(;a>0;){let f=findClusterBreak(o.text,a,!1);if(s(o.text.slice(f,a))!=h)break;a=f}for(;cr?e.left-r:Math.max(0,r-e.right)}function getdy(r,e){return e.top>r?e.top-r:Math.max(0,r-e.bottom)}function yOverlap(r,e){return r.tope.top+1}function upTop(r,e){return er.bottom?{top:r.top,left:r.left,right:r.right,bottom:e}:r}function domPosAtCoords(r,e,n){let s,o,l,a,c=!1,h,f,u,d;for(let m=r.firstChild;m;m=m.nextSibling){let S=clientRectsFor(m);for(let b=0;b$||a==$&&l>P){s=m,o=w,l=P,a=$;let A=$?n0?b0)}P==0?n>w.bottom&&(!u||u.bottomw.top)&&(f=m,d=w):u&&yOverlap(u,w)?u=upBot(u,w.bottom):d&&yOverlap(d,w)&&(d=upTop(d,w.top))}}if(u&&u.bottom>=n?(s=h,o=u):d&&d.top<=n&&(s=f,o=d),!s)return{node:r,offset:0};let g=Math.max(o.left,Math.min(o.right,e));if(s.nodeType==3)return domPosInText(s,g,n);if(c&&s.contentEditable!="false")return domPosAtCoords(s,g,n);let O=Array.prototype.indexOf.call(r.childNodes,s)+(e>=(o.left+o.right)/2?1:0);return{node:r,offset:O}}function domPosInText(r,e,n){let s=r.nodeValue.length,o=-1,l=1e9,a=0;for(let c=0;cn?u.top-n:n-u.bottom)-1;if(u.left-1<=e&&u.right+1>=e&&d=(u.left+u.right)/2,O=g;if((browser.chrome||browser.gecko)&&textRange(r,c).getBoundingClientRect().left==u.right&&(O=!g),d<=0)return{node:r,offset:c+(O?1:0)};o=c+(O?1:0),l=d}}}return{node:r,offset:o>-1?o:a>0?r.nodeValue.length:0}}function posAtCoords(r,e,n,s=-1){var o,l;let a=r.contentDOM.getBoundingClientRect(),c=a.top+r.viewState.paddingTop,h,{docHeight:f}=r.viewState,{x:u,y:d}=e,g=d-c;if(g<0)return 0;if(g>f)return r.state.doc.length;for(let A=r.viewState.heightOracle.textHeight/2,v=!1;h=r.elementAtHeight(g),h.type!=BlockType.Text;)for(;g=s>0?h.bottom+A:h.top-A,!(g>=0&&g<=f);){if(v)return n?null:0;v=!0,s=-s}d=c+g;let O=h.from;if(Or.viewport.to)return r.viewport.to==r.state.doc.length?r.state.doc.length:n?null:posAtCoordsImprecise(r,a,h,u,d);let m=r.dom.ownerDocument,S=r.root.elementFromPoint?r.root:m,b=S.elementFromPoint(u,d);b&&!r.contentDOM.contains(b)&&(b=null),b||(u=Math.max(a.left+1,Math.min(a.right-1,u)),b=S.elementFromPoint(u,d),b&&!r.contentDOM.contains(b)&&(b=null));let w,P=-1;if(b&&((o=r.docView.nearest(b))===null||o===void 0?void 0:o.isEditable)!=!1){if(m.caretPositionFromPoint){let A=m.caretPositionFromPoint(u,d);A&&({offsetNode:w,offset:P}=A)}else if(m.caretRangeFromPoint){let A=m.caretRangeFromPoint(u,d);A&&({startContainer:w,startOffset:P}=A,(!r.contentDOM.contains(w)||browser.safari&&isSuspiciousSafariCaretResult(w,P,u)||browser.chrome&&isSuspiciousChromeCaretResult(w,P,u))&&(w=void 0))}}if(!w||!r.docView.dom.contains(w)){let A=LineView.find(r.docView,O);if(!A)return g>h.top+h.height/2?h.to:h.from;({node:w,offset:P}=domPosAtCoords(A.dom,u,d))}let $=r.docView.nearest(w);if(!$)return null;if($.isWidget&&((l=$.dom)===null||l===void 0?void 0:l.nodeType)==1){let A=$.dom.getBoundingClientRect();return e.yr.defaultLineHeight*1.5){let c=r.viewState.heightOracle.textHeight,h=Math.floor((o-n.top-(r.defaultLineHeight-c)*.5)/c);l+=h*r.viewState.heightOracle.lineLength}let a=r.state.sliceDoc(n.from,n.to);return n.from+findColumn(a,l,r.state.tabSize)}function isSuspiciousSafariCaretResult(r,e,n){let s;if(r.nodeType!=3||e!=(s=r.nodeValue.length))return!1;for(let o=r.nextSibling;o;o=o.nextSibling)if(o.nodeType!=1||o.nodeName!="BR")return!1;return textRange(r,s-1,s).getBoundingClientRect().left>n}function isSuspiciousChromeCaretResult(r,e,n){if(e!=0)return!1;for(let o=r;;){let l=o.parentNode;if(!l||l.nodeType!=1||l.firstChild!=o)return!1;if(l.classList.contains("cm-line"))break;o=l}let s=r.nodeType==1?r.getBoundingClientRect():textRange(r,0,Math.max(r.nodeValue.length,1)).getBoundingClientRect();return n-s.left>5}function blockAt(r,e){let n=r.lineBlockAt(e);if(Array.isArray(n.type)){for(let s of n.type)if(s.to>e||s.to==e&&(s.to==n.to||s.type==BlockType.Text))return s}return n}function moveToLineBoundary(r,e,n,s){let o=blockAt(r,e.head),l=!s||o.type!=BlockType.Text||!(r.lineWrapping||o.widgetLineBreaks)?null:r.coordsAtPos(e.assoc<0&&e.head>o.from?e.head-1:e.head);if(l){let a=r.dom.getBoundingClientRect(),c=r.textDirectionAt(o.from),h=r.posAtCoords({x:n==(c==Direction.LTR)?a.right-1:a.left+1,y:(l.top+l.bottom)/2});if(h!=null)return EditorSelection.cursor(h,n?-1:1)}return EditorSelection.cursor(n?o.to:o.from,n?-1:1)}function moveByChar(r,e,n,s){let o=r.state.doc.lineAt(e.head),l=r.bidiSpans(o),a=r.textDirectionAt(o.from);for(let c=e,h=null;;){let f=moveVisually(o,l,a,c,n),u=movedOver;if(!f){if(o.number==(n?r.state.doc.lines:1))return c;u=` +`,o=r.state.doc.line(o.number+(n?1:-1)),l=r.bidiSpans(o),f=r.visualLineSide(o,!n)}if(h){if(!h(u))return c}else{if(!s)return f;h=s(u)}c=f}}function byGroup(r,e,n){let s=r.state.charCategorizer(e),o=s(n);return l=>{let a=s(l);return o==CharCategory.Space&&(o=a),o==a}}function moveVertically(r,e,n,s){let o=e.head,l=n?1:-1;if(o==(n?r.state.doc.length:0))return EditorSelection.cursor(o,e.assoc);let a=e.goalColumn,c,h=r.contentDOM.getBoundingClientRect(),f=r.coordsAtPos(o,e.assoc||-1),u=r.documentTop;if(f)a==null&&(a=f.left-h.left),c=l<0?f.top:f.bottom;else{let O=r.viewState.lineBlockAt(o);a==null&&(a=Math.min(h.right-h.left,r.defaultCharacterWidth*(o-O.from))),c=(l<0?O.top:O.bottom)+u}let d=h.left+a,g=s??r.viewState.heightOracle.textHeight>>1;for(let O=0;;O+=10){let m=c+(g+O)*l,S=posAtCoords(r,{x:d,y:m},!1,l);if(mh.bottom||(l<0?So)){let b=r.docView.coordsForChar(S),w=!b||m{if(e>l&&eo(r)),n.from,e.head>n.from?-1:1);return s==n.from?n:EditorSelection.cursor(s,snull),browser.gecko&&firefoxCopyCutHack(e.contentDOM.ownerDocument)}handleEvent(e){!eventBelongsToEditor(this.view,e)||this.ignoreDuringComposition(e)||e.type=="keydown"&&this.keydown(e)||this.runHandlers(e.type,e)}runHandlers(e,n){let s=this.handlers[e];if(s){for(let o of s.observers)o(this.view,n);for(let o of s.handlers){if(n.defaultPrevented)break;if(o(this.view,n)){n.preventDefault();break}}}}ensureHandlers(e){let n=computeHandlers(e),s=this.handlers,o=this.view.contentDOM;for(let l in n)if(l!="scroll"){let a=!n[l].handlers.length,c=s[l];c&&a!=!c.handlers.length&&(o.removeEventListener(l,this.handleEvent),c=null),c||o.addEventListener(l,this.handleEvent,{passive:a})}for(let l in s)l!="scroll"&&!n[l]&&o.removeEventListener(l,this.handleEvent);this.handlers=n}keydown(e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),e.keyCode==9&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&e.keyCode!=27&&modifierCodes.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),browser.android&&browser.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;let n;return browser.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&((n=PendingKeys.find(s=>s.keyCode==e.keyCode))&&!e.ctrlKey||EmacsyPendingKeys.indexOf(e.key)>-1&&e.ctrlKey&&!e.shiftKey)?(this.pendingIOSKey=n||e,setTimeout(()=>this.flushIOSKey(),250),!0):(e.keyCode!=229&&this.view.observer.forceFlush(),!1)}flushIOSKey(e){let n=this.pendingIOSKey;return!n||n.key=="Enter"&&e&&e.from0?!0:browser.safari&&!browser.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100?(this.compositionPendingKey=!1,!0):!1:!1}startMouseSelection(e){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=e}update(e){this.view.observer.update(e),this.mouseSelection&&this.mouseSelection.update(e),this.draggedContent&&e.docChanged&&(this.draggedContent=this.draggedContent.map(e.changes)),e.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}}function bindHandler(r,e){return(n,s)=>{try{return e.call(r,s,n)}catch(o){logException(n.state,o)}}}function computeHandlers(r){let e=Object.create(null);function n(s){return e[s]||(e[s]={observers:[],handlers:[]})}for(let s of r){let o=s.spec;if(o&&o.domEventHandlers)for(let l in o.domEventHandlers){let a=o.domEventHandlers[l];a&&n(l).handlers.push(bindHandler(s.value,a))}if(o&&o.domEventObservers)for(let l in o.domEventObservers){let a=o.domEventObservers[l];a&&n(l).observers.push(bindHandler(s.value,a))}}for(let s in handlers)n(s).handlers.push(handlers[s]);for(let s in observers)n(s).observers.push(observers[s]);return e}const PendingKeys=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],EmacsyPendingKeys="dthko",modifierCodes=[16,17,18,20,91,92,224,225],dragScrollMargin=6;function dragScrollSpeed(r){return Math.max(0,r)*.7+8}function dist(r,e){return Math.max(Math.abs(r.clientX-e.clientX),Math.abs(r.clientY-e.clientY))}class MouseSelection{constructor(e,n,s,o){this.view=e,this.startEvent=n,this.style=s,this.mustSelect=o,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=n,this.scrollParent=scrollableParent(e.contentDOM),this.atoms=e.state.facet(atomicRanges).map(a=>a(e));let l=e.contentDOM.ownerDocument;l.addEventListener("mousemove",this.move=this.move.bind(this)),l.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=n.shiftKey,this.multiple=e.state.facet(EditorState.allowMultipleSelections)&&addsSelectionRange(e,n),this.dragging=isInPrimarySelection(e,n)&&getClickType(n)==1?null:!1}start(e){this.dragging===!1&&this.select(e)}move(e){var n;if(e.buttons==0)return this.destroy();if(this.dragging||this.dragging==null&&dist(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let s=0,o=0,l=((n=this.scrollParent)===null||n===void 0?void 0:n.getBoundingClientRect())||{left:0,top:0,right:this.view.win.innerWidth,bottom:this.view.win.innerHeight},a=getScrollMargins(this.view);e.clientX-a.left<=l.left+dragScrollMargin?s=-dragScrollSpeed(l.left-e.clientX):e.clientX+a.right>=l.right-dragScrollMargin&&(s=dragScrollSpeed(e.clientX-l.right)),e.clientY-a.top<=l.top+dragScrollMargin?o=-dragScrollSpeed(l.top-e.clientY):e.clientY+a.bottom>=l.bottom-dragScrollMargin&&(o=dragScrollSpeed(e.clientY-l.bottom)),this.setScrollSpeed(s,o)}up(e){this.dragging==null&&this.select(this.lastEvent),this.dragging||e.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let e=this.view.contentDOM.ownerDocument;e.removeEventListener("mousemove",this.move),e.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(e,n){this.scrollSpeed={x:e,y:n},e||n?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){this.scrollParent?(this.scrollParent.scrollLeft+=this.scrollSpeed.x,this.scrollParent.scrollTop+=this.scrollSpeed.y):this.view.win.scrollBy(this.scrollSpeed.x,this.scrollSpeed.y),this.dragging===!1&&this.select(this.lastEvent)}skipAtoms(e){let n=null;for(let s=0;sn.isUserEvent("input.type"))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}}function addsSelectionRange(r,e){let n=r.state.facet(clickAddsSelectionRange);return n.length?n[0](e):browser.mac?e.metaKey:e.ctrlKey}function dragMovesSelection(r,e){let n=r.state.facet(dragMovesSelection$1);return n.length?n[0](e):browser.mac?!e.altKey:!e.ctrlKey}function isInPrimarySelection(r,e){let{main:n}=r.state.selection;if(n.empty)return!1;let s=getSelection(r.root);if(!s||s.rangeCount==0)return!0;let o=s.getRangeAt(0).getClientRects();for(let l=0;l=e.clientX&&a.top<=e.clientY&&a.bottom>=e.clientY)return!0}return!1}function eventBelongsToEditor(r,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let n=e.target,s;n!=r.contentDOM;n=n.parentNode)if(!n||n.nodeType==11||(s=ContentView.get(n))&&s.ignoreEvent(e))return!1;return!0}const handlers=Object.create(null),observers=Object.create(null),brokenClipboardAPI=browser.ie&&browser.ie_version<15||browser.ios&&browser.webkit_version<604;function capturePaste(r){let e=r.dom.parentNode;if(!e)return;let n=e.appendChild(document.createElement("textarea"));n.style.cssText="position: fixed; left: -10000px; top: 10px",n.focus(),setTimeout(()=>{r.focus(),n.remove(),doPaste(r,n.value)},50)}function doPaste(r,e){let{state:n}=r,s,o=1,l=n.toText(e),a=l.lines==n.selection.ranges.length;if(lastLinewiseCopy!=null&&n.selection.ranges.every(h=>h.empty)&&lastLinewiseCopy==l.toString()){let h=-1;s=n.changeByRange(f=>{let u=n.doc.lineAt(f.from);if(u.from==h)return{range:f};h=u.from;let d=n.toText((a?l.line(o++).text:e)+n.lineBreak);return{changes:{from:u.from,insert:d},range:EditorSelection.cursor(f.from+d.length)}})}else a?s=n.changeByRange(h=>{let f=l.line(o++);return{changes:{from:h.from,to:h.to,insert:f.text},range:EditorSelection.cursor(h.from+f.length)}}):s=n.replaceSelection(l);r.dispatch(s,{userEvent:"input.paste",scrollIntoView:!0})}observers.scroll=r=>{r.inputState.lastScrollTop=r.scrollDOM.scrollTop,r.inputState.lastScrollLeft=r.scrollDOM.scrollLeft};handlers.keydown=(r,e)=>(r.inputState.setSelectionOrigin("select"),e.keyCode==27&&r.inputState.tabFocusMode!=0&&(r.inputState.tabFocusMode=Date.now()+2e3),!1);observers.touchstart=(r,e)=>{r.inputState.lastTouchTime=Date.now(),r.inputState.setSelectionOrigin("select.pointer")};observers.touchmove=r=>{r.inputState.setSelectionOrigin("select.pointer")};handlers.mousedown=(r,e)=>{if(r.observer.flush(),r.inputState.lastTouchTime>Date.now()-2e3)return!1;let n=null;for(let s of r.state.facet(mouseSelectionStyle))if(n=s(r,e),n)break;if(!n&&e.button==0&&(n=basicMouseSelection(r,e)),n){let s=!r.hasFocus;r.inputState.startMouseSelection(new MouseSelection(r,e,n,s)),s&&r.observer.ignore(()=>{focusPreventScroll(r.contentDOM);let l=r.root.activeElement;l&&!l.contains(r.contentDOM)&&l.blur()});let o=r.inputState.mouseSelection;if(o)return o.start(e),o.dragging===!1}return!1};function rangeForClick(r,e,n,s){if(s==1)return EditorSelection.cursor(e,n);if(s==2)return groupAt(r.state,e,n);{let o=LineView.find(r.docView,e),l=r.state.doc.lineAt(o?o.posAtEnd:e),a=o?o.posAtStart:l.from,c=o?o.posAtEnd:l.to;return cr>=e.top&&r<=e.bottom,inside=(r,e,n)=>insideY(e,n)&&r>=n.left&&r<=n.right;function findPositionSide(r,e,n,s){let o=LineView.find(r.docView,e);if(!o)return 1;let l=e-o.posAtStart;if(l==0)return 1;if(l==o.length)return-1;let a=o.coordsAt(l,-1);if(a&&inside(n,s,a))return-1;let c=o.coordsAt(l,1);return c&&inside(n,s,c)?1:a&&insideY(s,a)?-1:1}function queryPos(r,e){let n=r.posAtCoords({x:e.clientX,y:e.clientY},!1);return{pos:n,bias:findPositionSide(r,n,e.clientX,e.clientY)}}const BadMouseDetail=browser.ie&&browser.ie_version<=11;let lastMouseDown=null,lastMouseDownCount=0,lastMouseDownTime=0;function getClickType(r){if(!BadMouseDetail)return r.detail;let e=lastMouseDown,n=lastMouseDownTime;return lastMouseDown=r,lastMouseDownTime=Date.now(),lastMouseDownCount=!e||n>Date.now()-400&&Math.abs(e.clientX-r.clientX)<2&&Math.abs(e.clientY-r.clientY)<2?(lastMouseDownCount+1)%3:1}function basicMouseSelection(r,e){let n=queryPos(r,e),s=getClickType(e),o=r.state.selection;return{update(l){l.docChanged&&(n.pos=l.changes.mapPos(n.pos),o=o.map(l.changes))},get(l,a,c){let h=queryPos(r,l),f,u=rangeForClick(r,h.pos,h.bias,s);if(n.pos!=h.pos&&!a){let d=rangeForClick(r,n.pos,n.bias,s),g=Math.min(d.from,u.from),O=Math.max(d.to,u.to);u=g1&&(f=removeRangeAround(o,h.pos))?f:c?o.addRange(u):EditorSelection.create([u])}}}function removeRangeAround(r,e){for(let n=0;n=e)return EditorSelection.create(r.ranges.slice(0,n).concat(r.ranges.slice(n+1)),r.mainIndex==n?0:r.mainIndex-(r.mainIndex>n?1:0))}return null}handlers.dragstart=(r,e)=>{let{selection:{main:n}}=r.state;if(e.target.draggable){let o=r.docView.nearest(e.target);if(o&&o.isWidget){let l=o.posAtStart,a=l+o.length;(l>=n.to||a<=n.from)&&(n=EditorSelection.range(l,a))}}let{inputState:s}=r;return s.mouseSelection&&(s.mouseSelection.dragging=!0),s.draggedContent=n,e.dataTransfer&&(e.dataTransfer.setData("Text",r.state.sliceDoc(n.from,n.to)),e.dataTransfer.effectAllowed="copyMove"),!1};handlers.dragend=r=>(r.inputState.draggedContent=null,!1);function dropText(r,e,n,s){if(!n)return;let o=r.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:l}=r.inputState,a=s&&l&&dragMovesSelection(r,e)?{from:l.from,to:l.to}:null,c={from:o,insert:n},h=r.state.changes(a?[a,c]:c);r.focus(),r.dispatch({changes:h,selection:{anchor:h.mapPos(o,-1),head:h.mapPos(o,1)},userEvent:a?"move.drop":"input.drop"}),r.inputState.draggedContent=null}handlers.drop=(r,e)=>{if(!e.dataTransfer)return!1;if(r.state.readOnly)return!0;let n=e.dataTransfer.files;if(n&&n.length){let s=Array(n.length),o=0,l=()=>{++o==n.length&&dropText(r,e,s.filter(a=>a!=null).join(r.state.lineBreak),!1)};for(let a=0;a{/[\x00-\x08\x0e-\x1f]{2}/.test(c.result)||(s[a]=c.result),l()},c.readAsText(n[a])}return!0}else{let s=e.dataTransfer.getData("Text");if(s)return dropText(r,e,s,!0),!0}return!1};handlers.paste=(r,e)=>{if(r.state.readOnly)return!0;r.observer.flush();let n=brokenClipboardAPI?null:e.clipboardData;return n?(doPaste(r,n.getData("text/plain")||n.getData("text/uri-list")),!0):(capturePaste(r),!1)};function captureCopy(r,e){let n=r.dom.parentNode;if(!n)return;let s=n.appendChild(document.createElement("textarea"));s.style.cssText="position: fixed; left: -10000px; top: 10px",s.value=e,s.focus(),s.selectionEnd=e.length,s.selectionStart=0,setTimeout(()=>{s.remove(),r.focus()},50)}function copiedRange(r){let e=[],n=[],s=!1;for(let o of r.selection.ranges)o.empty||(e.push(r.sliceDoc(o.from,o.to)),n.push(o));if(!e.length){let o=-1;for(let{from:l}of r.selection.ranges){let a=r.doc.lineAt(l);a.number>o&&(e.push(a.text),n.push({from:a.from,to:Math.min(r.doc.length,a.to+1)})),o=a.number}s=!0}return{text:e.join(r.lineBreak),ranges:n,linewise:s}}let lastLinewiseCopy=null;handlers.copy=handlers.cut=(r,e)=>{let{text:n,ranges:s,linewise:o}=copiedRange(r.state);if(!n&&!o)return!1;lastLinewiseCopy=o?n:null,e.type=="cut"&&!r.state.readOnly&&r.dispatch({changes:s,scrollIntoView:!0,userEvent:"delete.cut"});let l=brokenClipboardAPI?null:e.clipboardData;return l?(l.clearData(),l.setData("text/plain",n),!0):(captureCopy(r,n),!1)};const isFocusChange=Annotation.define();function focusChangeTransaction(r,e){let n=[];for(let s of r.facet(focusChangeEffect)){let o=s(r,e);o&&n.push(o)}return n?r.update({effects:n,annotations:isFocusChange.of(!0)}):null}function updateForFocusChange(r){setTimeout(()=>{let e=r.hasFocus;if(e!=r.inputState.notifiedFocused){let n=focusChangeTransaction(r.state,e);n?r.dispatch(n):r.update([])}},10)}observers.focus=r=>{r.inputState.lastFocusTime=Date.now(),!r.scrollDOM.scrollTop&&(r.inputState.lastScrollTop||r.inputState.lastScrollLeft)&&(r.scrollDOM.scrollTop=r.inputState.lastScrollTop,r.scrollDOM.scrollLeft=r.inputState.lastScrollLeft),updateForFocusChange(r)};observers.blur=r=>{r.observer.clearSelectionRange(),updateForFocusChange(r)};observers.compositionstart=observers.compositionupdate=r=>{r.observer.editContext||(r.inputState.compositionFirstChange==null&&(r.inputState.compositionFirstChange=!0),r.inputState.composing<0&&(r.inputState.composing=0))};observers.compositionend=r=>{r.observer.editContext||(r.inputState.composing=-1,r.inputState.compositionEndedAt=Date.now(),r.inputState.compositionPendingKey=!0,r.inputState.compositionPendingChange=r.observer.pendingRecords().length>0,r.inputState.compositionFirstChange=null,browser.chrome&&browser.android?r.observer.flushSoon():r.inputState.compositionPendingChange?Promise.resolve().then(()=>r.observer.flush()):setTimeout(()=>{r.inputState.composing<0&&r.docView.hasComposition&&r.update([])},50))};observers.contextmenu=r=>{r.inputState.lastContextMenu=Date.now()};handlers.beforeinput=(r,e)=>{var n;let s;if(browser.chrome&&browser.android&&(s=PendingKeys.find(o=>o.inputType==e.inputType))&&(r.observer.delayAndroidKey(s.key,s.keyCode),s.key=="Backspace"||s.key=="Delete")){let o=((n=window.visualViewport)===null||n===void 0?void 0:n.height)||0;setTimeout(()=>{var l;(((l=window.visualViewport)===null||l===void 0?void 0:l.height)||0)>o+10&&r.hasFocus&&(r.contentDOM.blur(),r.focus())},100)}return browser.ios&&e.inputType=="deleteContentForward"&&r.observer.flushSoon(),browser.safari&&e.inputType=="insertText"&&r.inputState.composing>=0&&setTimeout(()=>observers.compositionend(r,e),20),!1};const appliedFirefoxHack=new Set;function firefoxCopyCutHack(r){appliedFirefoxHack.has(r)||(appliedFirefoxHack.add(r),r.addEventListener("copy",()=>{}),r.addEventListener("cut",()=>{}))}const wrappingWhiteSpace=["pre-wrap","normal","pre-line","break-spaces"];class HeightOracle{constructor(e){this.lineWrapping=e,this.doc=Text.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30,this.heightChanged=!1}heightForGap(e,n){let s=this.doc.lineAt(n).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(s+=Math.max(0,Math.ceil((n-e-s*this.lineLength*.5)/this.lineLength))),this.lineHeight*s}heightForLine(e){return this.lineWrapping?(1+Math.max(0,Math.ceil((e-this.lineLength)/(this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return wrappingWhiteSpace.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let n=!1;for(let s=0;s-1,h=Math.round(n)!=Math.round(this.lineHeight)||this.lineWrapping!=c;if(this.lineWrapping=c,this.lineHeight=n,this.charWidth=s,this.textHeight=o,this.lineLength=l,h){this.heightSamples={};for(let f=0;f0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e,n){this.height!=n&&(Math.abs(this.height-n)>Epsilon&&(e.heightChanged=!0),this.height=n)}replace(e,n,s){return HeightMap.of(s)}decomposeLeft(e,n){n.push(this)}decomposeRight(e,n){n.push(this)}applyChanges(e,n,s,o){let l=this,a=s.doc;for(let c=o.length-1;c>=0;c--){let{fromA:h,toA:f,fromB:u,toB:d}=o[c],g=l.lineAt(h,QueryType$1.ByPosNoHeight,s.setDoc(n),0,0),O=g.to>=f?g:l.lineAt(f,QueryType$1.ByPosNoHeight,s,0,0);for(d+=O.to-f,f=O.to;c>0&&g.from<=o[c-1].toA;)h=o[c-1].fromA,u=o[c-1].fromB,c--,hl*2){let c=e[n-1];c.break?e.splice(--n,1,c.left,null,c.right):e.splice(--n,1,c.left,c.right),s+=1+c.break,o-=c.size}else if(l>o*2){let c=e[s];c.break?e.splice(s,1,c.left,null,c.right):e.splice(s,1,c.left,c.right),s+=2+c.break,l-=c.size}else break;else if(o=l&&a(this.blockAt(0,s,o,l))}updateHeight(e,n=0,s=!1,o){return o&&o.from<=n&&o.more&&this.setHeight(e,o.heights[o.index++]),this.outdated=!1,this}toString(){return`block(${this.length})`}}class HeightMapText extends HeightMapBlock{constructor(e,n){super(e,n,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0}blockAt(e,n,s,o){return new BlockInfo(o,this.length,s,this.height,this.breaks)}replace(e,n,s){let o=s[0];return s.length==1&&(o instanceof HeightMapText||o instanceof HeightMapGap&&o.flags&4)&&Math.abs(this.length-o.length)<10?(o instanceof HeightMapGap?o=new HeightMapText(o.length,this.height):o.height=this.height,this.outdated||(o.outdated=!1),o):HeightMap.of(s)}updateHeight(e,n=0,s=!1,o){return o&&o.from<=n&&o.more?this.setHeight(e,o.heights[o.index++]):(s||this.outdated)&&this.setHeight(e,Math.max(this.widgetHeight,e.heightForLine(this.length-this.collapsed))+this.breaks*e.lineHeight),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}}class HeightMapGap extends HeightMap{constructor(e){super(e,0)}heightMetrics(e,n){let s=e.doc.lineAt(n).number,o=e.doc.lineAt(n+this.length).number,l=o-s+1,a,c=0;if(e.lineWrapping){let h=Math.min(this.height,e.lineHeight*l);a=h/l,this.length>l+1&&(c=(this.height-h)/(this.length-l-1))}else a=this.height/l;return{firstLine:s,lastLine:o,perLine:a,perChar:c}}blockAt(e,n,s,o){let{firstLine:l,lastLine:a,perLine:c,perChar:h}=this.heightMetrics(n,o);if(n.lineWrapping){let f=o+(e0){let l=s[s.length-1];l instanceof HeightMapGap?s[s.length-1]=new HeightMapGap(l.length+o):s.push(null,new HeightMapGap(o-1))}if(e>0){let l=s[0];l instanceof HeightMapGap?s[0]=new HeightMapGap(e+l.length):s.unshift(new HeightMapGap(e-1),null)}return HeightMap.of(s)}decomposeLeft(e,n){n.push(new HeightMapGap(e-1),null)}decomposeRight(e,n){n.push(null,new HeightMapGap(this.length-e-1))}updateHeight(e,n=0,s=!1,o){let l=n+this.length;if(o&&o.from<=n+this.length&&o.more){let a=[],c=Math.max(n,o.from),h=-1;for(o.from>n&&a.push(new HeightMapGap(o.from-n-1).updateHeight(e,n));c<=l&&o.more;){let u=e.doc.lineAt(c).length;a.length&&a.push(null);let d=o.heights[o.index++];h==-1?h=d:Math.abs(d-h)>=Epsilon&&(h=-2);let g=new HeightMapText(u,d);g.outdated=!1,a.push(g),c+=u+1}c<=l&&a.push(null,new HeightMapGap(l-c).updateHeight(e,c));let f=HeightMap.of(a);return(h<0||Math.abs(f.height-this.height)>=Epsilon||Math.abs(h-this.heightMetrics(e,n).perLine)>=Epsilon)&&(e.heightChanged=!0),f}else(s||this.outdated)&&(this.setHeight(e,e.heightForGap(n,n+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}}class HeightMapBranch extends HeightMap{constructor(e,n,s){super(e.length+n+s.length,e.height+s.height,n|(e.outdated||s.outdated?2:0)),this.left=e,this.right=s,this.size=e.size+s.size}get break(){return this.flags&1}blockAt(e,n,s,o){let l=s+this.left.height;return ec))return f;let u=n==QueryType$1.ByPosNoHeight?QueryType$1.ByPosNoHeight:QueryType$1.ByPos;return h?f.join(this.right.lineAt(c,u,s,a,c)):this.left.lineAt(c,u,s,o,l).join(f)}forEachLine(e,n,s,o,l,a){let c=o+this.left.height,h=l+this.left.length+this.break;if(this.break)e=h&&this.right.forEachLine(e,n,s,c,h,a);else{let f=this.lineAt(h,QueryType$1.ByPos,s,o,l);e=e&&f.from<=n&&a(f),n>f.to&&this.right.forEachLine(f.to+1,n,s,c,h,a)}}replace(e,n,s){let o=this.left.length+this.break;if(nthis.left.length)return this.balanced(this.left,this.right.replace(e-o,n-o,s));let l=[];e>0&&this.decomposeLeft(e,l);let a=l.length;for(let c of s)l.push(c);if(e>0&&mergeGaps(l,a-1),n=s&&n.push(null)),e>s&&this.right.decomposeLeft(e-s,n)}decomposeRight(e,n){let s=this.left.length,o=s+this.break;if(e>=o)return this.right.decomposeRight(e-o,n);e2*n.size||n.size>2*e.size?HeightMap.of(this.break?[e,null,n]:[e,n]):(this.left=e,this.right=n,this.height=e.height+n.height,this.outdated=e.outdated||n.outdated,this.size=e.size+n.size,this.length=e.length+this.break+n.length,this)}updateHeight(e,n=0,s=!1,o){let{left:l,right:a}=this,c=n+l.length+this.break,h=null;return o&&o.from<=n+l.length&&o.more?h=l=l.updateHeight(e,n,s,o):l.updateHeight(e,n,s),o&&o.from<=c+a.length&&o.more?h=a=a.updateHeight(e,c,s,o):a.updateHeight(e,c,s),h?this.balanced(l,a):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function mergeGaps(r,e){let n,s;r[e]==null&&(n=r[e-1])instanceof HeightMapGap&&(s=r[e+1])instanceof HeightMapGap&&r.splice(e-1,3,new HeightMapGap(n.length+1+s.length))}const relevantWidgetHeight=5;class NodeBuilder{constructor(e,n){this.pos=e,this.oracle=n,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=e}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(e,n){if(this.lineStart>-1){let s=Math.min(n,this.lineEnd),o=this.nodes[this.nodes.length-1];o instanceof HeightMapText?o.length+=s-this.pos:(s>this.pos||!this.isCovered)&&this.nodes.push(new HeightMapText(s-this.pos,-1)),this.writtenTo=s,n>s&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=n}point(e,n,s){if(e=relevantWidgetHeight)&&this.addLineDeco(o,l,a)}else n>e&&this.span(e,n);this.lineEnd>-1&&this.lineEnd-1)return;let{from:e,to:n}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=n,this.writtenToe&&this.nodes.push(new HeightMapText(this.pos-e,-1)),this.writtenTo=this.pos}blankContent(e,n){let s=new HeightMapGap(n-e);return this.oracle.doc.lineAt(e).to==n&&(s.flags|=4),s}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof HeightMapText)return e;let n=new HeightMapText(0,-1);return this.nodes.push(n),n}addBlock(e){this.enterLine();let n=e.deco;n&&n.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,n&&n.endSide>0&&(this.covering=e)}addLineDeco(e,n,s){let o=this.ensureLine();o.length+=s,o.collapsed+=s,o.widgetHeight=Math.max(o.widgetHeight,e),o.breaks+=n,this.writtenTo=this.pos=this.pos+s}finish(e){let n=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(n instanceof HeightMapText)&&!this.isCovered?this.nodes.push(new HeightMapText(0,-1)):(this.writtenTou.clientHeight||u.scrollWidth>u.clientWidth)&&d.overflow!="visible"){let g=u.getBoundingClientRect();l=Math.max(l,g.left),a=Math.min(a,g.right),c=Math.max(c,g.top),h=f==r.parentNode?g.bottom:Math.min(h,g.bottom)}f=d.position=="absolute"||d.position=="fixed"?u.offsetParent:u.parentNode}else if(f.nodeType==11)f=f.host;else break;return{left:l-n.left,right:Math.max(l,a)-n.left,top:c-(n.top+e),bottom:Math.max(c,h)-(n.top+e)}}function fullPixelRange(r,e){let n=r.getBoundingClientRect();return{left:0,right:n.right-n.left,top:e,bottom:n.bottom-(n.top+e)}}class LineGap{constructor(e,n,s){this.from=e,this.to=n,this.size=s}static same(e,n){if(e.length!=n.length)return!1;for(let s=0;stypeof s!="function"&&s.class=="cm-lineWrapping");this.heightOracle=new HeightOracle(n),this.stateDeco=e.facet(decorations).filter(s=>typeof s!="function"),this.heightMap=HeightMap.empty().applyChanges(this.stateDeco,Text.empty,this.heightOracle.setDoc(e.doc),[new ChangedRange(0,0,0,e.doc.length)]);for(let s=0;s<2&&(this.viewport=this.getViewport(0,null),!!this.updateForViewport());s++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=Decoration.set(this.lineGaps.map(s=>s.draw(this,!1))),this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:n}=this.state.selection;for(let s=0;s<=1;s++){let o=s?n.head:n.anchor;if(!e.some(({from:l,to:a})=>o>=l&&o<=a)){let{from:l,to:a}=this.lineBlockAt(o);e.push(new Viewport(l,a))}}return this.viewports=e.sort((s,o)=>s.from-o.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?IdScaler:new BigScaler(this.heightOracle,this.heightMap,this.viewports),e.eq(this.scaler)?0:2}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,e=>{this.viewportLines.push(scaleBlock(e,this.scaler))})}update(e,n=null){this.state=e.state;let s=this.stateDeco;this.stateDeco=this.state.facet(decorations).filter(u=>typeof u!="function");let o=e.changedRanges,l=ChangedRange.extendWithRanges(o,heightRelevantDecoChanges(s,this.stateDeco,e?e.changes:ChangeSet.empty(this.state.doc.length))),a=this.heightMap.height,c=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollTop);this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),l),this.heightMap.height!=a&&(e.flags|=2),c?(this.scrollAnchorPos=e.changes.mapPos(c.from,-1),this.scrollAnchorHeight=c.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=this.heightMap.height);let h=l.length?this.mapViewport(this.viewport,e.changes):this.viewport;(n&&(n.range.headh.to)||!this.viewportIsAppropriate(h))&&(h=this.getViewport(0,n));let f=h.from!=this.viewport.from||h.to!=this.viewport.to;this.viewport=h,e.flags|=this.updateForViewport(),(f||!e.changes.empty||e.flags&2)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,e.changes))),e.flags|=this.computeVisibleRanges(),n&&(this.scrollTarget=n),!this.mustEnforceCursorAssoc&&e.selectionSet&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(nativeSelectionHidden)&&(this.mustEnforceCursorAssoc=!0)}measure(e){let n=e.contentDOM,s=window.getComputedStyle(n),o=this.heightOracle,l=s.whiteSpace;this.defaultTextDirection=s.direction=="rtl"?Direction.RTL:Direction.LTR;let a=this.heightOracle.mustRefreshForWrapping(l),c=n.getBoundingClientRect(),h=a||this.mustMeasureContent||this.contentDOMHeight!=c.height;this.contentDOMHeight=c.height,this.mustMeasureContent=!1;let f=0,u=0;if(c.width&&c.height){let{scaleX:A,scaleY:v}=getScale(n,c);(A>.005&&Math.abs(this.scaleX-A)>.005||v>.005&&Math.abs(this.scaleY-v)>.005)&&(this.scaleX=A,this.scaleY=v,f|=8,a=h=!0)}let d=(parseInt(s.paddingTop)||0)*this.scaleY,g=(parseInt(s.paddingBottom)||0)*this.scaleY;(this.paddingTop!=d||this.paddingBottom!=g)&&(this.paddingTop=d,this.paddingBottom=g,f|=10),this.editorWidth!=e.scrollDOM.clientWidth&&(o.lineWrapping&&(h=!0),this.editorWidth=e.scrollDOM.clientWidth,f|=8);let O=e.scrollDOM.scrollTop*this.scaleY;this.scrollTop!=O&&(this.scrollAnchorHeight=-1,this.scrollTop=O),this.scrolledToBottom=isScrolledToBottom(e.scrollDOM);let m=(this.printing?fullPixelRange:visiblePixelRange)(n,this.paddingTop),S=m.top-this.pixelViewport.top,b=m.bottom-this.pixelViewport.bottom;this.pixelViewport=m;let w=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(w!=this.inView&&(this.inView=w,w&&(h=!0)),!this.inView&&!this.scrollTarget)return 0;let P=c.width;if((this.contentDOMWidth!=P||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=c.width,this.editorHeight=e.scrollDOM.clientHeight,f|=8),h){let A=e.docView.measureVisibleLineHeights(this.viewport);if(o.mustRefreshForHeights(A)&&(a=!0),a||o.lineWrapping&&Math.abs(P-this.contentDOMWidth)>o.charWidth){let{lineHeight:v,charWidth:Q,textHeight:_}=e.docView.measureTextSize();a=v>0&&o.refresh(l,v,Q,_,P/Q,A),a&&(e.docView.minWidth=0,f|=8)}S>0&&b>0?u=Math.max(S,b):S<0&&b<0&&(u=Math.min(S,b)),o.heightChanged=!1;for(let v of this.viewports){let Q=v.from==this.viewport.from?A:e.docView.measureVisibleLineHeights(v);this.heightMap=(a?HeightMap.empty().applyChanges(this.stateDeco,Text.empty,this.heightOracle,[new ChangedRange(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(o,0,a,new MeasuredHeights(v.from,Q))}o.heightChanged&&(f|=2)}let $=!this.viewportIsAppropriate(this.viewport,u)||this.scrollTarget&&(this.scrollTarget.range.headthis.viewport.to);return $&&(f&2&&(f|=this.updateScaler()),this.viewport=this.getViewport(u,this.scrollTarget),f|=this.updateForViewport()),(f&2||$)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(a?[]:this.lineGaps,e)),f|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),f}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,n){let s=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),o=this.heightMap,l=this.heightOracle,{visibleTop:a,visibleBottom:c}=this,h=new Viewport(o.lineAt(a-s*1e3,QueryType$1.ByHeight,l,0,0).from,o.lineAt(c+(1-s)*1e3,QueryType$1.ByHeight,l,0,0).to);if(n){let{head:f}=n.range;if(fh.to){let u=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),d=o.lineAt(f,QueryType$1.ByPos,l,0,0),g;n.y=="center"?g=(d.top+d.bottom)/2-u/2:n.y=="start"||n.y=="nearest"&&f=c+Math.max(10,Math.min(s,250)))&&o>a-2*1e3&&l>1,a=o<<1;if(this.defaultTextDirection!=Direction.LTR&&!s)return[];let c=[],h=(u,d,g,O)=>{if(d-uu&&ww.from>=g.from&&w.to<=g.to&&Math.abs(w.from-u)w.fromP));if(!b){if(dw.from<=d&&w.to>=d)){let w=n.moveToLineBoundary(EditorSelection.cursor(d),!1,!0).head;w>u&&(d=w)}b=new LineGap(u,d,this.gapSize(g,u,d,O))}c.push(b)},f=u=>{if(u.lengthu.from&&h(u.from,O,u,d),mn.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(){let e=this.stateDeco;this.lineGaps.length&&(e=e.concat(this.lineGapDeco));let n=[];RangeSet.spans(e,this.viewport.from,this.viewport.to,{span(o,l){n.push({from:o,to:l})},point(){}},20);let s=n.length!=this.visibleRanges.length||this.visibleRanges.some((o,l)=>o.from!=n[l].from||o.to!=n[l].to);return this.visibleRanges=n,s?4:0}lineBlockAt(e){return e>=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(n=>n.from<=e&&n.to>=e)||scaleBlock(this.heightMap.lineAt(e,QueryType$1.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(e){return e>=this.viewportLines[0].top&&e<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find(n=>n.top<=e&&n.bottom>=e)||scaleBlock(this.heightMap.lineAt(this.scaler.fromDOM(e),QueryType$1.ByHeight,this.heightOracle,0,0),this.scaler)}scrollAnchorAt(e){let n=this.lineBlockAtHeight(e+8);return n.from>=this.viewport.from||this.viewportLines[0].top-e>200?n:this.viewportLines[0]}elementAtHeight(e){return scaleBlock(this.heightMap.blockAt(this.scaler.fromDOM(e),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}}class Viewport{constructor(e,n){this.from=e,this.to=n}}function lineStructure(r,e,n){let s=[],o=r,l=0;return RangeSet.spans(n,r,e,{span(){},point(a,c){a>o&&(s.push({from:o,to:a}),l+=a-o),o=c}},20),o=1)return e[e.length-1].to;let s=Math.floor(r*n);for(let o=0;;o++){let{from:l,to:a}=e[o],c=a-l;if(s<=c)return l+s;s-=c}}function findFraction(r,e){let n=0;for(let{from:s,to:o}of r.ranges){if(e<=o){n+=e-s;break}n+=o-s}return n/r.total}function find(r,e){for(let n of r)if(e(n))return n}const IdScaler={toDOM(r){return r},fromDOM(r){return r},scale:1,eq(r){return r==this}};class BigScaler{constructor(e,n,s){let o=0,l=0,a=0;this.viewports=s.map(({from:c,to:h})=>{let f=n.lineAt(c,QueryType$1.ByPos,e,0,0).top,u=n.lineAt(h,QueryType$1.ByPos,e,0,0).bottom;return o+=u-f,{from:c,to:h,top:f,bottom:u,domTop:0,domBottom:0}}),this.scale=(7e6-o)/(n.height-o);for(let c of this.viewports)c.domTop=a+(c.top-l)*this.scale,a=c.domBottom=c.domTop+(c.bottom-c.top),l=c.bottom}toDOM(e){for(let n=0,s=0,o=0;;n++){let l=nn.from==e.viewports[s].from&&n.to==e.viewports[s].to):!1}}function scaleBlock(r,e){if(e.scale==1)return r;let n=e.toDOM(r.top),s=e.toDOM(r.bottom);return new BlockInfo(r.from,r.length,n,s-n,Array.isArray(r._content)?r._content.map(o=>scaleBlock(o,e)):r._content)}const theme=Facet.define({combine:r=>r.join(" ")}),darkTheme=Facet.define({combine:r=>r.indexOf(!0)>-1}),baseThemeID=StyleModule.newName(),baseLightID=StyleModule.newName(),baseDarkID=StyleModule.newName(),lightDarkIDs={"&light":"."+baseLightID,"&dark":"."+baseDarkID};function buildTheme(r,e,n){return new StyleModule(e,{finish(s){return/&/.test(s)?s.replace(/&\w*/,o=>{if(o=="&")return r;if(!n||!n[o])throw new RangeError(`Unsupported selector: ${o}`);return n[o]}):r+" "+s}})}const baseTheme$1$2=buildTheme("."+baseThemeID,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#444"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",insetInlineStart:0,zIndex:200},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",borderRight:"1px solid #ddd"},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top"},".cm-highlightSpace:before":{content:"attr(data-display)",position:"absolute",pointerEvents:"none",color:"#888"},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,')`,backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},lightDarkIDs),LineBreakPlaceholder="￿";class DOMReader{constructor(e,n){this.points=e,this.text="",this.lineSeparator=n.facet(EditorState.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=LineBreakPlaceholder}readRange(e,n){if(!e)return this;let s=e.parentNode;for(let o=e;;){this.findPointBefore(s,o);let l=this.text.length;this.readNode(o);let a=o.nextSibling;if(a==n)break;let c=ContentView.get(o),h=ContentView.get(a);(c&&h?c.breakAfter:(c?c.breakAfter:isBlockElement(o))||isBlockElement(a)&&(o.nodeName!="BR"||o.cmIgnore)&&this.text.length>l)&&this.lineBreak(),o=a}return this.findPointBefore(s,n),this}readTextNode(e){let n=e.nodeValue;for(let s of this.points)s.node==e&&(s.pos=this.text.length+Math.min(s.offset,n.length));for(let s=0,o=this.lineSeparator?null:/\r\n?|\n/g;;){let l=-1,a=1,c;if(this.lineSeparator?(l=n.indexOf(this.lineSeparator,s),a=this.lineSeparator.length):(c=o.exec(n))&&(l=c.index,a=c[0].length),this.append(n.slice(s,l<0?n.length:l)),l<0)break;if(this.lineBreak(),a>1)for(let h of this.points)h.node==e&&h.pos>this.text.length&&(h.pos-=a-1);s=l+a}}readNode(e){if(e.cmIgnore)return;let n=ContentView.get(e),s=n&&n.overrideDOMText;if(s!=null){this.findPointInside(e,s.length);for(let o=s.iter();!o.next().done;)o.lineBreak?this.lineBreak():this.append(o.value)}else e.nodeType==3?this.readTextNode(e):e.nodeName=="BR"?e.nextSibling&&this.lineBreak():e.nodeType==1&&this.readRange(e.firstChild,null)}findPointBefore(e,n){for(let s of this.points)s.node==e&&e.childNodes[s.offset]==n&&(s.pos=this.text.length)}findPointInside(e,n){for(let s of this.points)(e.nodeType==3?s.node==e:e.contains(s.node))&&(s.pos=this.text.length+(isAtEnd(e,s.node,s.offset)?n:0))}}function isAtEnd(r,e,n){for(;;){if(!e||n-1;let{impreciseHead:l,impreciseAnchor:a}=e.docView;if(e.state.readOnly&&n>-1)this.newSel=null;else if(n>-1&&(this.bounds=e.docView.domBoundsAround(n,s,0))){let c=l||a?[]:selectionPoints(e),h=new DOMReader(c,e.state);h.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=h.text,this.newSel=selectionFromPoints(c,this.bounds.from)}else{let c=e.observer.selectionRange,h=l&&l.node==c.focusNode&&l.offset==c.focusOffset||!contains(e.contentDOM,c.focusNode)?e.state.selection.main.head:e.docView.posFromDOM(c.focusNode,c.focusOffset),f=a&&a.node==c.anchorNode&&a.offset==c.anchorOffset||!contains(e.contentDOM,c.anchorNode)?e.state.selection.main.anchor:e.docView.posFromDOM(c.anchorNode,c.anchorOffset),u=e.viewport;if((browser.ios||browser.chrome)&&e.state.selection.main.empty&&h!=f&&(u.from>0||u.toDate.now()-100?r.inputState.lastKeyCode:-1;if(e.bounds){let{from:a,to:c}=e.bounds,h=o.from,f=null;(l===8||browser.android&&e.text.length=o.from&&n.to<=o.to&&(n.from!=o.from||n.to!=o.to)&&o.to-o.from-(n.to-n.from)<=4?n={from:o.from,to:o.to,insert:r.state.doc.slice(o.from,n.from).append(n.insert).append(r.state.doc.slice(n.to,o.to))}:(browser.mac||browser.android)&&n&&n.from==n.to&&n.from==o.head-1&&/^\. ?$/.test(n.insert.toString())&&r.contentDOM.getAttribute("autocorrect")=="off"?(s&&n.insert.length==2&&(s=EditorSelection.single(s.main.anchor-1,s.main.head-1)),n={from:o.from,to:o.to,insert:Text.of([" "])}):browser.chrome&&n&&n.from==n.to&&n.from==o.head&&n.insert.toString()==` + `&&r.lineWrapping&&(s&&(s=EditorSelection.single(s.main.anchor-1,s.main.head-1)),n={from:o.from,to:o.to,insert:Text.of([" "])}),n)return applyDOMChangeInner(r,n,s,l);if(s&&!s.main.eq(o)){let a=!1,c="select";return r.inputState.lastSelectionTime>Date.now()-50&&(r.inputState.lastSelectionOrigin=="select"&&(a=!0),c=r.inputState.lastSelectionOrigin),r.dispatch({selection:s,scrollIntoView:a,userEvent:c}),!0}else return!1}function applyDOMChangeInner(r,e,n,s=-1){if(browser.ios&&r.inputState.flushIOSKey(e))return!0;let o=r.state.selection.main;if(browser.android&&(e.to==o.to&&(e.from==o.from||e.from==o.from-1&&r.state.sliceDoc(e.from,o.from)==" ")&&e.insert.length==1&&e.insert.lines==2&&dispatchKey(r.contentDOM,"Enter",13)||(e.from==o.from-1&&e.to==o.to&&e.insert.length==0||s==8&&e.insert.lengtho.head)&&dispatchKey(r.contentDOM,"Backspace",8)||e.from==o.from&&e.to==o.to+1&&e.insert.length==0&&dispatchKey(r.contentDOM,"Delete",46)))return!0;let l=e.insert.toString();r.inputState.composing>=0&&r.inputState.composing++;let a,c=()=>a||(a=applyDefaultInsert(r,e,n));return r.state.facet(inputHandler$1).some(h=>h(r,e.from,e.to,l,c))||r.dispatch(c()),!0}function applyDefaultInsert(r,e,n){let s,o=r.state,l=o.selection.main;if(e.from>=l.from&&e.to<=l.to&&e.to-e.from>=(l.to-l.from)/3&&(!n||n.main.empty&&n.main.from==e.from+e.insert.length)&&r.inputState.composing<0){let c=l.frome.to?o.sliceDoc(e.to,l.to):"";s=o.replaceSelection(r.state.toText(c+e.insert.sliceString(0,void 0,r.state.lineBreak)+h))}else{let c=o.changes(e),h=n&&n.main.to<=c.newLength?n.main:void 0;if(o.selection.ranges.length>1&&r.inputState.composing>=0&&e.to<=l.to&&e.to>=l.to-10){let f=r.state.sliceDoc(e.from,e.to),u,d=n&&findCompositionNode(r,n.main.head);if(d){let m=e.insert.length-(e.to-e.from);u={from:d.from,to:d.to-m}}else u=r.state.doc.lineAt(l.head);let g=l.to-e.to,O=l.to-l.from;s=o.changeByRange(m=>{if(m.from==l.from&&m.to==l.to)return{changes:c,range:h||m.map(c)};let S=m.to-g,b=S-f.length;if(m.to-m.from!=O||r.state.sliceDoc(b,S)!=f||m.to>=u.from&&m.from<=u.to)return{range:m};let w=o.changes({from:b,to:S,insert:e.insert}),P=m.to-l.to;return{changes:w,range:h?EditorSelection.range(Math.max(0,h.anchor+P),Math.max(0,h.head+P)):m.map(w)}})}else s={changes:c,selection:h&&o.selection.replaceRange(h)}}let a="input.type";return(r.composing||r.inputState.compositionPendingChange&&r.inputState.compositionEndedAt>Date.now()-50)&&(r.inputState.compositionPendingChange=!1,a+=".compose",r.inputState.compositionFirstChange&&(a+=".start",r.inputState.compositionFirstChange=!1)),o.update(s,{userEvent:a,scrollIntoView:!0})}function findDiff(r,e,n,s){let o=Math.min(r.length,e.length),l=0;for(;l0&&c>0&&r.charCodeAt(a-1)==e.charCodeAt(c-1);)a--,c--;if(s=="end"){let h=Math.max(0,l-Math.min(a,c));n-=a+h-l}if(a=a?l-n:0;l-=h,c=l+(c-a),a=l}else if(c=c?l-n:0;l-=h,a=l+(a-c),c=l}return{from:l,toA:a,toB:c}}function selectionPoints(r){let e=[];if(r.root.activeElement!=r.contentDOM)return e;let{anchorNode:n,anchorOffset:s,focusNode:o,focusOffset:l}=r.observer.selectionRange;return n&&(e.push(new DOMPoint(n,s)),(o!=n||l!=s)&&e.push(new DOMPoint(o,l))),e}function selectionFromPoints(r,e){if(r.length==0)return null;let n=r[0].pos,s=r.length==2?r[1].pos:n;return n>-1&&s>-1?EditorSelection.single(n+e,s+e):null}const observeOptions={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},useCharData=browser.ie&&browser.ie_version<=11;class DOMObserver{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new DOMSelectionState,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver(n=>{for(let s of n)this.queue.push(s);(browser.ie&&browser.ie_version<=11||browser.ios&&e.composing)&&n.some(s=>s.type=="childList"&&s.removedNodes.length||s.type=="characterData"&&s.oldValue.length>s.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&e.constructor.EDIT_CONTEXT===!0&&(this.editContext=new EditContextManager(e),e.state.facet(editable)&&(e.contentDOM.editContext=this.editContext.editContext)),useCharData&&(this.onCharData=n=>{this.queue.push({target:n.target,type:"characterData",oldValue:n.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),window.matchMedia&&(this.printQuery=window.matchMedia("print")),typeof ResizeObserver=="function"&&(this.resizeScroll=new ResizeObserver(()=>{var n;((n=this.view.docView)===null||n===void 0?void 0:n.lastUpdate){this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),n.length>0&&n[n.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(n=>{n.length>0&&n[n.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(e){this.view.inputState.runHandlers("scroll",e),this.intersecting&&this.view.measure()}onScroll(e){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(e){e.type=="change"&&!e.matches||(this.view.viewState.printing=!0,this.view.measure(),setTimeout(()=>{this.view.viewState.printing=!1,this.view.requestMeasure()},500))}updateGaps(e){if(this.gapIntersection&&(e.length!=this.gaps.length||this.gaps.some((n,s)=>n!=e[s]))){this.gapIntersection.disconnect();for(let n of e)this.gapIntersection.observe(n);this.gaps=e}}onSelectionChange(e){let n=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:s}=this,o=this.selectionRange;if(s.state.facet(editable)?s.root.activeElement!=this.dom:!hasSelection(s.dom,o))return;let l=o.anchorNode&&s.docView.nearest(o.anchorNode);if(l&&l.ignoreEvent(e)){n||(this.selectionChanged=!1);return}(browser.ie&&browser.ie_version<=11||browser.android&&browser.chrome)&&!s.state.selection.main.empty&&o.focusNode&&isEquivalentPosition(o.focusNode,o.focusOffset,o.anchorNode,o.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,n=getSelection(e.root);if(!n)return!1;let s=browser.safari&&e.root.nodeType==11&&deepActiveElement(this.dom.ownerDocument)==this.dom&&safariSelectionRangeHack(this.view,n)||n;if(!s||this.selectionRange.eq(s))return!1;let o=hasSelection(this.dom,s);return o&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime{let l=this.delayedAndroidKey;l&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=l.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&l.force&&dispatchKey(this.dom,l.key,l.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(o)}(!this.delayedAndroidKey||e=="Enter")&&(this.delayedAndroidKey={key:e,keyCode:n,force:this.lastChange{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}processRecords(){let e=this.pendingRecords();e.length&&(this.queue=[]);let n=-1,s=-1,o=!1;for(let l of e){let a=this.readMutation(l);a&&(a.typeOver&&(o=!0),n==-1?{from:n,to:s}=a:(n=Math.min(a.from,n),s=Math.max(a.to,s)))}return{from:n,to:s,typeOver:o}}readChange(){let{from:e,to:n,typeOver:s}=this.processRecords(),o=this.selectionChanged&&hasSelection(this.dom,this.selectionRange);if(e<0&&!o)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let l=new DOMChange(this.view,e,n,s);return this.view.docView.domChanged={newSel:l.newSel?l.newSel.main:null},l}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let n=this.readChange();if(!n)return this.view.requestMeasure(),!1;let s=this.view.state,o=applyDOMChange(this.view,n);return this.view.state==s&&(n.domChanged||n.newSel&&!n.newSel.main.eq(this.view.state.selection.main))&&this.view.update([]),o}readMutation(e){let n=this.view.docView.nearest(e.target);if(!n||n.ignoreMutation(e))return null;if(n.markDirty(e.type=="attributes"),e.type=="attributes"&&(n.flags|=4),e.type=="childList"){let s=findChild(n,e.previousSibling||e.target.previousSibling,-1),o=findChild(n,e.nextSibling||e.target.nextSibling,1);return{from:s?n.posAfter(s):n.posAtStart,to:o?n.posBefore(o):n.posAtEnd,typeOver:!1}}else return e.type=="characterData"?{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener("change",this.onPrint):e.addEventListener("beforeprint",this.onPrint),e.addEventListener("scroll",this.onScroll),e.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener("scroll",this.onScroll),e.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener("change",this.onPrint):e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}update(e){this.editContext&&(this.editContext.update(e),e.startState.facet(editable)!=e.state.facet(editable)&&(e.view.contentDOM.editContext=e.state.facet(editable)?this.editContext.editContext:null))}destroy(){var e,n,s;this.stop(),(e=this.intersection)===null||e===void 0||e.disconnect(),(n=this.gapIntersection)===null||n===void 0||n.disconnect(),(s=this.resizeScroll)===null||s===void 0||s.disconnect();for(let o of this.scrollTargets)o.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey)}}function findChild(r,e,n){for(;e;){let s=ContentView.get(e);if(s&&s.parent==r)return s;let o=e.parentNode;e=o!=r.dom?o:n>0?e.nextSibling:e.previousSibling}return null}function buildSelectionRangeFromRange(r,e){let n=e.startContainer,s=e.startOffset,o=e.endContainer,l=e.endOffset,a=r.docView.domAtPos(r.state.selection.main.anchor);return isEquivalentPosition(a.node,a.offset,o,l)&&([n,s,o,l]=[o,l,n,s]),{anchorNode:n,anchorOffset:s,focusNode:o,focusOffset:l}}function safariSelectionRangeHack(r,e){if(e.getComposedRanges){let o=e.getComposedRanges(r.root)[0];if(o)return buildSelectionRangeFromRange(r,o)}let n=null;function s(o){o.preventDefault(),o.stopImmediatePropagation(),n=o.getTargetRanges()[0]}return r.contentDOM.addEventListener("beforeinput",s,!0),r.dom.ownerDocument.execCommand("indent"),r.contentDOM.removeEventListener("beforeinput",s,!0),n?buildSelectionRangeFromRange(r,n):null}class EditContextManager{constructor(e){this.from=0,this.to=0,this.pendingContextChange=null,this.resetRange(e.state);let n=this.editContext=new window.EditContext({text:e.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,e.state.selection.main.anchor))),selectionEnd:this.toContextPos(e.state.selection.main.head)});n.addEventListener("textupdate",s=>{let{anchor:o}=e.state.selection.main,l={from:this.toEditorPos(s.updateRangeStart),to:this.toEditorPos(s.updateRangeEnd),insert:Text.of(s.text.split(` +`))};l.from==this.from&&othis.to&&(l.to=o),!(l.from==l.to&&!l.insert.length)&&(this.pendingContextChange=l,applyDOMChangeInner(e,l,EditorSelection.single(this.toEditorPos(s.selectionStart),this.toEditorPos(s.selectionEnd))),this.pendingContextChange&&this.revertPending(e.state))}),n.addEventListener("characterboundsupdate",s=>{let o=[],l=null;for(let a=this.toEditorPos(s.rangeStart),c=this.toEditorPos(s.rangeEnd);a{let o=[];for(let l of s.getTextFormats()){let a=l.underlineStyle,c=l.underlineThickness;if(a!="None"&&c!="None"){let h=`text-decoration: underline ${a=="Dashed"?"dashed ":a=="Squiggle"?"wavy ":""}${c=="Thin"?1:2}px`;o.push(Decoration.mark({attributes:{style:h}}).range(this.toEditorPos(l.rangeStart),this.toEditorPos(l.rangeEnd)))}}e.dispatch({effects:setEditContextFormatting.of(Decoration.set(o))})}),n.addEventListener("compositionstart",()=>{e.inputState.composing<0&&(e.inputState.composing=0,e.inputState.compositionFirstChange=!0)}),n.addEventListener("compositionend",()=>{e.inputState.composing=-1,e.inputState.compositionFirstChange=null}),this.measureReq={read:s=>{this.editContext.updateControlBounds(s.contentDOM.getBoundingClientRect());let o=getSelection(s.root);o&&o.rangeCount&&this.editContext.updateSelectionBounds(o.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let n=0,s=!1,o=this.pendingContextChange;return e.changes.iterChanges((l,a,c,h,f)=>{if(s)return;let u=f.length-(a-l);if(o&&a>=o.to)if(o.from==l&&o.to==a&&o.insert.eq(f)){o=this.pendingContextChange=null,n+=u;return}else o=null,this.revertPending(e.state);if(l+=n,a+=n,a<=this.from)this.from+=u,this.to+=u;else if(lthis.to||this.to-this.from+f.length>3e4){s=!0;return}this.editContext.updateText(this.toContextPos(l),this.toContextPos(a),f.toString()),this.to+=u}n+=u}),o&&!s&&this.revertPending(e.state),!s}update(e){!this.applyEdits(e)||!this.rangeIsValid(e.state)?(this.pendingContextChange=null,this.resetRange(e.state),this.editContext.updateText(0,this.editContext.text.length,e.state.doc.sliceString(this.from,this.to)),this.setSelection(e.state)):(e.docChanged||e.selectionSet)&&this.setSelection(e.state),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:n}=e.selection.main;this.from=Math.max(0,n-1e4),this.to=Math.min(e.doc.length,n+1e4)}revertPending(e){let n=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(n.from),this.toContextPos(n.to+n.insert.length),e.doc.sliceString(n.from,n.to))}setSelection(e){let{main:n}=e.selection,s=this.toContextPos(Math.max(this.from,Math.min(this.to,n.anchor))),o=this.toContextPos(n.head);(this.editContext.selectionStart!=s||this.editContext.selectionEnd!=o)&&this.editContext.updateSelection(s,o)}rangeIsValid(e){let{head:n}=e.selection.main;return!(this.from>0&&n-this.from<500||this.to1e4*3)}toEditorPos(e){return e+this.from}toContextPos(e){return e-this.from}}class EditorView{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return this.inputState.composing>0}get compositionStarted(){return this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(e={}){this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),e.parent&&e.parent.appendChild(this.dom);let{dispatch:n}=e;this.dispatchTransactions=e.dispatchTransactions||n&&(s=>s.forEach(o=>n(o,this)))||(s=>this.update(s)),this.dispatch=this.dispatch.bind(this),this._root=e.root||getRoot(e.parent)||document,this.viewState=new ViewState(e.state||EditorState.create(e)),e.scrollTo&&e.scrollTo.is(scrollIntoView$1)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(viewPlugin).map(s=>new PluginInstance(s));for(let s of this.plugins)s.update(this);this.observer=new DOMObserver(this),this.inputState=new InputState(this),this.inputState.ensureHandlers(this.plugins),this.docView=new DocView(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure()}dispatch(...e){let n=e.length==1&&e[0]instanceof Transaction?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(n,this)}update(e){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let n=!1,s=!1,o,l=this.state;for(let g of e){if(g.startState!=l)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");l=g.state}if(this.destroyed){this.viewState.state=l;return}let a=this.hasFocus,c=0,h=null;e.some(g=>g.annotation(isFocusChange))?(this.inputState.notifiedFocused=a,c=1):a!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=a,h=focusChangeTransaction(l,a),h||(c=1));let f=this.observer.delayedAndroidKey,u=null;if(f?(this.observer.clearDelayedAndroidKey(),u=this.observer.readChange(),(u&&!this.state.doc.eq(l.doc)||!this.state.selection.eq(l.selection))&&(u=null)):this.observer.clear(),l.facet(EditorState.phrases)!=this.state.facet(EditorState.phrases))return this.setState(l);o=ViewUpdate.create(this,l,e),o.flags|=c;let d=this.viewState.scrollTarget;try{this.updateState=2;for(let g of e){if(d&&(d=d.map(g.changes)),g.scrollIntoView){let{main:O}=g.state.selection;d=new ScrollTarget(O.empty?O:EditorSelection.cursor(O.head,O.head>O.anchor?-1:1))}for(let O of g.effects)O.is(scrollIntoView$1)&&(d=O.value.clip(this.state))}this.viewState.update(o,d),this.bidiCache=CachedOrder.update(this.bidiCache,o.changes),o.empty||(this.updatePlugins(o),this.inputState.update(o)),n=this.docView.update(o),this.state.facet(styleModule)!=this.styleModules&&this.mountStyles(),s=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(n,e.some(g=>g.isUserEvent("select.pointer")))}finally{this.updateState=0}if(o.startState.facet(theme)!=o.state.facet(theme)&&(this.viewState.mustMeasureContent=!0),(n||s||d||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),n&&this.docViewUpdate(),!o.empty)for(let g of this.state.facet(updateListener))try{g(o)}catch(O){logException(this.state,O,"update listener")}(h||u)&&Promise.resolve().then(()=>{h&&this.state==h.startState&&this.dispatch(h),u&&!applyDOMChange(this,u)&&f.force&&dispatchKey(this.contentDOM,f.key,f.keyCode)})}setState(e){if(this.updateState!=0)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed){this.viewState.state=e;return}this.updateState=2;let n=this.hasFocus;try{for(let s of this.plugins)s.destroy(this);this.viewState=new ViewState(e),this.plugins=e.facet(viewPlugin).map(s=>new PluginInstance(s)),this.pluginMap.clear();for(let s of this.plugins)s.update(this);this.docView.destroy(),this.docView=new DocView(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}n&&this.focus(),this.requestMeasure()}updatePlugins(e){let n=e.startState.facet(viewPlugin),s=e.state.facet(viewPlugin);if(n!=s){let o=[];for(let l of s){let a=n.indexOf(l);if(a<0)o.push(new PluginInstance(l));else{let c=this.plugins[a];c.mustUpdate=e,o.push(c)}}for(let l of this.plugins)l.mustUpdate!=e&&l.destroy(this);this.plugins=o,this.pluginMap.clear()}else for(let o of this.plugins)o.mustUpdate=e;for(let o=0;o-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let n=null,s=this.scrollDOM,o=s.scrollTop*this.scaleY,{scrollAnchorPos:l,scrollAnchorHeight:a}=this.viewState;Math.abs(o-this.viewState.scrollTop)>1&&(a=-1),this.viewState.scrollAnchorHeight=-1;try{for(let c=0;;c++){if(a<0)if(isScrolledToBottom(s))l=-1,a=this.viewState.heightMap.height;else{let O=this.viewState.scrollAnchorAt(o);l=O.from,a=O.top}this.updateState=1;let h=this.viewState.measure(this);if(!h&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(c>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let f=[];h&4||([this.measureRequests,f]=[f,this.measureRequests]);let u=f.map(O=>{try{return O.read(this)}catch(m){return logException(this.state,m),BadMeasure}}),d=ViewUpdate.create(this,this.state,[]),g=!1;d.flags|=h,n?n.flags|=h:n=d,this.updateState=2,d.empty||(this.updatePlugins(d),this.inputState.update(d),this.updateAttrs(),g=this.docView.update(d),g&&this.docViewUpdate());for(let O=0;O1||m<-1){o=o+m,s.scrollTop=o/this.scaleY,a=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(n&&!n.empty)for(let c of this.state.facet(updateListener))c(n)}get themeClasses(){return baseThemeID+" "+(this.state.facet(darkTheme)?baseDarkID:baseLightID)+" "+this.state.facet(theme)}updateAttrs(){let e=attrsFromFacet(this,editorAttributes,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),n={spellcheck:"false",autocorrect:"off",autocapitalize:"off",translate:"no",contenteditable:this.state.facet(editable)?"true":"false",class:"cm-content",style:`${browser.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(n["aria-readonly"]="true"),attrsFromFacet(this,contentAttributes,n);let s=this.observer.ignore(()=>{let o=updateAttrs(this.contentDOM,this.contentAttrs,n),l=updateAttrs(this.dom,this.editorAttrs,e);return o||l});return this.editorAttrs=e,this.contentAttrs=n,s}showAnnouncements(e){let n=!0;for(let s of e)for(let o of s.effects)if(o.is(EditorView.announce)){n&&(this.announceDOM.textContent=""),n=!1;let l=this.announceDOM.appendChild(document.createElement("div"));l.textContent=o.value}}mountStyles(){this.styleModules=this.state.facet(styleModule);let e=this.state.facet(EditorView.cspNonce);StyleModule.mount(this.root,this.styleModules.concat(baseTheme$1$2).reverse(),e?{nonce:e}:void 0)}readMeasured(){if(this.updateState==2)throw new Error("Reading the editor layout isn't allowed during an update");this.updateState==0&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(e){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),e){if(this.measureRequests.indexOf(e)>-1)return;if(e.key!=null){for(let n=0;ns.spec==e)||null),n&&n.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(e){return this.readMeasured(),this.viewState.elementAtHeight(e)}lineBlockAtHeight(e){return this.readMeasured(),this.viewState.lineBlockAtHeight(e)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(e){return this.viewState.lineBlockAt(e)}get contentHeight(){return this.viewState.contentHeight}moveByChar(e,n,s){return skipAtoms(this,e,moveByChar(this,e,n,s))}moveByGroup(e,n){return skipAtoms(this,e,moveByChar(this,e,n,s=>byGroup(this,e.head,s)))}visualLineSide(e,n){let s=this.bidiSpans(e),o=this.textDirectionAt(e.from),l=s[n?s.length-1:0];return EditorSelection.cursor(l.side(n,o)+e.from,l.forward(!n,o)?1:-1)}moveToLineBoundary(e,n,s=!0){return moveToLineBoundary(this,e,n,s)}moveVertically(e,n,s){return skipAtoms(this,e,moveVertically(this,e,n,s))}domAtPos(e){return this.docView.domAtPos(e)}posAtDOM(e,n=0){return this.docView.posFromDOM(e,n)}posAtCoords(e,n=!0){return this.readMeasured(),posAtCoords(this,e,n)}coordsAtPos(e,n=1){this.readMeasured();let s=this.docView.coordsAt(e,n);if(!s||s.left==s.right)return s;let o=this.state.doc.lineAt(e),l=this.bidiSpans(o),a=l[BidiSpan.find(l,e-o.from,-1,n)];return flattenRect(s,a.dir==Direction.LTR==n>0)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(e){return!this.state.facet(perLineTextDirection)||ethis.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>MaxBidiLine)return trivialOrder(e.length);let n=this.textDirectionAt(e.from),s;for(let l of this.bidiCache)if(l.from==e.from&&l.dir==n&&(l.fresh||isolatesEq(l.isolates,s=getIsolatedRanges(this,e))))return l.order;s||(s=getIsolatedRanges(this,e));let o=computeOrder(e.text,n,s);return this.bidiCache.push(new CachedOrder(e.from,e.to,n,s,!0,o)),o}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||browser.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{focusPreventScroll(this.contentDOM),this.docView.updateSelection()})}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((e.nodeType==9?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,n={}){return scrollIntoView$1.of(new ScrollTarget(typeof e=="number"?EditorSelection.cursor(e):e,n.y,n.x,n.yMargin,n.xMargin))}scrollSnapshot(){let{scrollTop:e,scrollLeft:n}=this.scrollDOM,s=this.viewState.scrollAnchorAt(e);return scrollIntoView$1.of(new ScrollTarget(EditorSelection.cursor(s.from),"start","start",s.top-e,n,!0))}setTabFocusMode(e){e==null?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:typeof e=="boolean"?this.inputState.tabFocusMode=e?0:-1:this.inputState.tabFocusMode!=0&&(this.inputState.tabFocusMode=Date.now()+e)}static domEventHandlers(e){return ViewPlugin.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return ViewPlugin.define(()=>({}),{eventObservers:e})}static theme(e,n){let s=StyleModule.newName(),o=[theme.of(s),styleModule.of(buildTheme(`.${s}`,e))];return n&&n.dark&&o.push(darkTheme.of(!0)),o}static baseTheme(e){return Prec.lowest(styleModule.of(buildTheme("."+baseThemeID,e,lightDarkIDs)))}static findFromDOM(e){var n;let s=e.querySelector(".cm-content"),o=s&&ContentView.get(s)||ContentView.get(e);return((n=o==null?void 0:o.rootView)===null||n===void 0?void 0:n.view)||null}}EditorView.styleModule=styleModule;EditorView.inputHandler=inputHandler$1;EditorView.scrollHandler=scrollHandler;EditorView.focusChangeEffect=focusChangeEffect;EditorView.perLineTextDirection=perLineTextDirection;EditorView.exceptionSink=exceptionSink;EditorView.updateListener=updateListener;EditorView.editable=editable;EditorView.mouseSelectionStyle=mouseSelectionStyle;EditorView.dragMovesSelection=dragMovesSelection$1;EditorView.clickAddsSelectionRange=clickAddsSelectionRange;EditorView.decorations=decorations;EditorView.outerDecorations=outerDecorations;EditorView.atomicRanges=atomicRanges;EditorView.bidiIsolatedRanges=bidiIsolatedRanges;EditorView.scrollMargins=scrollMargins;EditorView.darkTheme=darkTheme;EditorView.cspNonce=Facet.define({combine:r=>r.length?r[0]:""});EditorView.contentAttributes=contentAttributes;EditorView.editorAttributes=editorAttributes;EditorView.lineWrapping=EditorView.contentAttributes.of({class:"cm-lineWrapping"});EditorView.announce=StateEffect.define();const MaxBidiLine=4096,BadMeasure={};class CachedOrder{constructor(e,n,s,o,l,a){this.from=e,this.to=n,this.dir=s,this.isolates=o,this.fresh=l,this.order=a}static update(e,n){if(n.empty&&!e.some(l=>l.fresh))return e;let s=[],o=e.length?e[e.length-1].dir:Direction.LTR;for(let l=Math.max(0,e.length-10);l=0;o--){let l=s[o],a=typeof l=="function"?l(r):l;a&&combineAttrs(a,n)}return n}const currentPlatform=browser.mac?"mac":browser.windows?"win":browser.linux?"linux":"key";function normalizeKeyName(r,e){const n=r.split(/-(?!$)/);let s=n[n.length-1];s=="Space"&&(s=" ");let o,l,a,c;for(let h=0;hs.concat(o),[]))),n}function runScopeHandlers(r,e,n){return runHandlers(getKeymap(r.state),e,r,n)}let storedPrefix=null;const PrefixTimeout=4e3;function buildKeymap(r,e=currentPlatform){let n=Object.create(null),s=Object.create(null),o=(a,c)=>{let h=s[a];if(h==null)s[a]=c;else if(h!=c)throw new Error("Key binding "+a+" is used both as a regular binding and as a multi-stroke prefix")},l=(a,c,h,f,u)=>{var d,g;let O=n[a]||(n[a]=Object.create(null)),m=c.split(/ (?!$)/).map(w=>normalizeKeyName(w,e));for(let w=1;w{let A=storedPrefix={view:$,prefix:P,scope:a};return setTimeout(()=>{storedPrefix==A&&(storedPrefix=null)},PrefixTimeout),!0}]})}let S=m.join(" ");o(S,!1);let b=O[S]||(O[S]={preventDefault:!1,stopPropagation:!1,run:((g=(d=O._any)===null||d===void 0?void 0:d.run)===null||g===void 0?void 0:g.slice())||[]});h&&b.run.push(h),f&&(b.preventDefault=!0),u&&(b.stopPropagation=!0)};for(let a of r){let c=a.scope?a.scope.split(" "):["editor"];if(a.any)for(let f of c){let u=n[f]||(n[f]=Object.create(null));u._any||(u._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:d}=a;for(let g in u)u[g].run.push(O=>d(O,currentKeyEvent))}let h=a[e]||a.key;if(h)for(let f of c)l(f,h,a.run,a.preventDefault,a.stopPropagation),a.shift&&l(f,"Shift-"+h,a.shift,a.preventDefault,a.stopPropagation)}return n}let currentKeyEvent=null;function runHandlers(r,e,n,s){currentKeyEvent=e;let o=keyName(e),l=codePointAt(o,0),a=codePointSize(l)==o.length&&o!=" ",c="",h=!1,f=!1,u=!1;storedPrefix&&storedPrefix.view==n&&storedPrefix.scope==s&&(c=storedPrefix.prefix+" ",modifierCodes.indexOf(e.keyCode)<0&&(f=!0,storedPrefix=null));let d=new Set,g=b=>{if(b){for(let w of b.run)if(!d.has(w)&&(d.add(w),w(n)))return b.stopPropagation&&(u=!0),!0;b.preventDefault&&(b.stopPropagation&&(u=!0),f=!0)}return!1},O=r[s],m,S;return O&&(g(O[c+modifiers(o,e,!a)])?h=!0:a&&(e.altKey||e.metaKey||e.ctrlKey)&&!(browser.windows&&e.ctrlKey&&e.altKey)&&(m=base[e.keyCode])&&m!=o?(g(O[c+modifiers(m,e,!0)])||e.shiftKey&&(S=shift[e.keyCode])!=o&&S!=m&&g(O[c+modifiers(S,e,!1)]))&&(h=!0):a&&e.shiftKey&&g(O[c+modifiers(o,e,!0)])&&(h=!0),!h&&g(O._any)&&(h=!0)),f&&(h=!0),h&&u&&e.stopPropagation(),currentKeyEvent=null,h}class RectangleMarker{constructor(e,n,s,o,l){this.className=e,this.left=n,this.top=s,this.width=o,this.height=l}draw(){let e=document.createElement("div");return e.className=this.className,this.adjust(e),e}update(e,n){return n.className!=this.className?!1:(this.adjust(e),!0)}adjust(e){e.style.left=this.left+"px",e.style.top=this.top+"px",this.width!=null&&(e.style.width=this.width+"px"),e.style.height=this.height+"px"}eq(e){return this.left==e.left&&this.top==e.top&&this.width==e.width&&this.height==e.height&&this.className==e.className}static forRange(e,n,s){if(s.empty){let o=e.coordsAtPos(s.head,s.assoc||1);if(!o)return[];let l=getBase(e);return[new RectangleMarker(n,o.left-l.left,o.top-l.top,null,o.bottom-o.top)]}else return rectanglesForRange(e,n,s)}}function getBase(r){let e=r.scrollDOM.getBoundingClientRect();return{left:(r.textDirection==Direction.LTR?e.left:e.right-r.scrollDOM.clientWidth*r.scaleX)-r.scrollDOM.scrollLeft*r.scaleX,top:e.top-r.scrollDOM.scrollTop*r.scaleY}}function wrappedLine(r,e,n,s){let o=r.coordsAtPos(e,n*2);if(!o)return s;let l=r.dom.getBoundingClientRect(),a=(o.top+o.bottom)/2,c=r.posAtCoords({x:l.left+1,y:a}),h=r.posAtCoords({x:l.right-1,y:a});return c==null||h==null?s:{from:Math.max(s.from,Math.min(c,h)),to:Math.min(s.to,Math.max(c,h))}}function rectanglesForRange(r,e,n){if(n.to<=r.viewport.from||n.from>=r.viewport.to)return[];let s=Math.max(n.from,r.viewport.from),o=Math.min(n.to,r.viewport.to),l=r.textDirection==Direction.LTR,a=r.contentDOM,c=a.getBoundingClientRect(),h=getBase(r),f=a.querySelector(".cm-line"),u=f&&window.getComputedStyle(f),d=c.left+(u?parseInt(u.paddingLeft)+Math.min(0,parseInt(u.textIndent)):0),g=c.right-(u?parseInt(u.paddingRight):0),O=blockAt(r,s),m=blockAt(r,o),S=O.type==BlockType.Text?O:null,b=m.type==BlockType.Text?m:null;if(S&&(r.lineWrapping||O.widgetLineBreaks)&&(S=wrappedLine(r,s,1,S)),b&&(r.lineWrapping||m.widgetLineBreaks)&&(b=wrappedLine(r,o,-1,b)),S&&b&&S.from==b.from&&S.to==b.to)return P($(n.from,n.to,S));{let v=S?$(n.from,null,S):A(O,!1),Q=b?$(null,n.to,b):A(m,!0),_=[];return(S||O).to<(b||m).from-(S&&b?1:0)||O.widgetLineBreaks>1&&v.bottom+r.defaultLineHeight/2L&&G.from=K)break;te>ee&&z(Math.max(se,ee),v==null&&se<=L,Math.min(te,K),Q==null&&te>=H,F.dir)}if(ee=j.to+1,ee>=K)break}return Y.length==0&&z(L,v==null,H,Q==null,r.textDirection),{top:N,bottom:q,horizontal:Y}}function A(v,Q){let _=c.top+(Q?v.top:v.bottom);return{top:_,bottom:_,horizontal:[]}}}function sameMarker(r,e){return r.constructor==e.constructor&&r.eq(e)}class LayerView{constructor(e,n){this.view=e,this.layer=n,this.drawn=[],this.scaleX=1,this.scaleY=1,this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=e.scrollDOM.appendChild(document.createElement("div")),this.dom.classList.add("cm-layer"),n.above&&this.dom.classList.add("cm-layer-above"),n.class&&this.dom.classList.add(n.class),this.scale(),this.dom.setAttribute("aria-hidden","true"),this.setOrder(e.state),e.requestMeasure(this.measureReq),n.mount&&n.mount(this.dom,e)}update(e){e.startState.facet(layerOrder)!=e.state.facet(layerOrder)&&this.setOrder(e.state),(this.layer.update(e,this.dom)||e.geometryChanged)&&(this.scale(),e.view.requestMeasure(this.measureReq))}docViewUpdate(e){this.layer.updateOnDocViewUpdate!==!1&&e.requestMeasure(this.measureReq)}setOrder(e){let n=0,s=e.facet(layerOrder);for(;n!sameMarker(n,this.drawn[s]))){let n=this.dom.firstChild,s=0;for(let o of e)o.update&&n&&o.constructor&&this.drawn[s].constructor&&o.update(n,this.drawn[s])?(n=n.nextSibling,s++):this.dom.insertBefore(o.draw(),n);for(;n;){let o=n.nextSibling;n.remove(),n=o}this.drawn=e}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}}const layerOrder=Facet.define();function layer(r){return[ViewPlugin.define(e=>new LayerView(e,r)),layerOrder.of(r)]}const CanHidePrimary=!browser.ios,selectionConfig=Facet.define({combine(r){return combineConfig(r,{cursorBlinkRate:1200,drawRangeCursor:!0},{cursorBlinkRate:(e,n)=>Math.min(e,n),drawRangeCursor:(e,n)=>e||n})}});function drawSelection(r={}){return[selectionConfig.of(r),cursorLayer,selectionLayer,hideNativeSelection,nativeSelectionHidden.of(!0)]}function configChanged(r){return r.startState.facet(selectionConfig)!=r.state.facet(selectionConfig)}const cursorLayer=layer({above:!0,markers(r){let{state:e}=r,n=e.facet(selectionConfig),s=[];for(let o of e.selection.ranges){let l=o==e.selection.main;if(o.empty?!l||CanHidePrimary:n.drawRangeCursor){let a=l?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",c=o.empty?o:EditorSelection.cursor(o.head,o.head>o.anchor?-1:1);for(let h of RectangleMarker.forRange(r,a,c))s.push(h)}}return s},update(r,e){r.transactions.some(s=>s.selection)&&(e.style.animationName=e.style.animationName=="cm-blink"?"cm-blink2":"cm-blink");let n=configChanged(r);return n&&setBlinkRate(r.state,e),r.docChanged||r.selectionSet||n},mount(r,e){setBlinkRate(e.state,r)},class:"cm-cursorLayer"});function setBlinkRate(r,e){e.style.animationDuration=r.facet(selectionConfig).cursorBlinkRate+"ms"}const selectionLayer=layer({above:!1,markers(r){return r.state.selection.ranges.map(e=>e.empty?[]:RectangleMarker.forRange(r,"cm-selectionBackground",e)).reduce((e,n)=>e.concat(n))},update(r,e){return r.docChanged||r.selectionSet||r.viewportChanged||configChanged(r)},class:"cm-selectionLayer"}),themeSpec={".cm-line":{"& ::selection, &::selection":{backgroundColor:"transparent !important"}},".cm-content":{"& :focus":{caretColor:"initial !important","&::selection, & ::selection":{backgroundColor:"Highlight !important"}}}};CanHidePrimary&&(themeSpec[".cm-line"].caretColor=themeSpec[".cm-content"].caretColor="transparent !important");const hideNativeSelection=Prec.highest(EditorView.theme(themeSpec)),setDropCursorPos=StateEffect.define({map(r,e){return r==null?null:e.mapPos(r)}}),dropCursorPos=StateField.define({create(){return null},update(r,e){return r!=null&&(r=e.changes.mapPos(r)),e.effects.reduce((n,s)=>s.is(setDropCursorPos)?s.value:n,r)}}),drawDropCursor=ViewPlugin.fromClass(class{constructor(r){this.view=r,this.cursor=null,this.measureReq={read:this.readPos.bind(this),write:this.drawCursor.bind(this)}}update(r){var e;let n=r.state.field(dropCursorPos);n==null?this.cursor!=null&&((e=this.cursor)===null||e===void 0||e.remove(),this.cursor=null):(this.cursor||(this.cursor=this.view.scrollDOM.appendChild(document.createElement("div")),this.cursor.className="cm-dropCursor"),(r.startState.field(dropCursorPos)!=n||r.docChanged||r.geometryChanged)&&this.view.requestMeasure(this.measureReq))}readPos(){let{view:r}=this,e=r.state.field(dropCursorPos),n=e!=null&&r.coordsAtPos(e);if(!n)return null;let s=r.scrollDOM.getBoundingClientRect();return{left:n.left-s.left+r.scrollDOM.scrollLeft*r.scaleX,top:n.top-s.top+r.scrollDOM.scrollTop*r.scaleY,height:n.bottom-n.top}}drawCursor(r){if(this.cursor){let{scaleX:e,scaleY:n}=this.view;r?(this.cursor.style.left=r.left/e+"px",this.cursor.style.top=r.top/n+"px",this.cursor.style.height=r.height/n+"px"):this.cursor.style.left="-100000px"}}destroy(){this.cursor&&this.cursor.remove()}setDropPos(r){this.view.state.field(dropCursorPos)!=r&&this.view.dispatch({effects:setDropCursorPos.of(r)})}},{eventObservers:{dragover(r){this.setDropPos(this.view.posAtCoords({x:r.clientX,y:r.clientY}))},dragleave(r){(r.target==this.view.contentDOM||!this.view.contentDOM.contains(r.relatedTarget))&&this.setDropPos(null)},dragend(){this.setDropPos(null)},drop(){this.setDropPos(null)}}});function dropCursor(){return[dropCursorPos,drawDropCursor]}function iterMatches(r,e,n,s,o){e.lastIndex=0;for(let l=r.iterRange(n,s),a=n,c;!l.next().done;a+=l.value.length)if(!l.lineBreak)for(;c=e.exec(l.value);)o(a+c.index,c)}function matchRanges(r,e){let n=r.visibleRanges;if(n.length==1&&n[0].from==r.viewport.from&&n[0].to==r.viewport.to)return n;let s=[];for(let{from:o,to:l}of n)o=Math.max(r.state.doc.lineAt(o).from,o-e),l=Math.min(r.state.doc.lineAt(l).to,l+e),s.length&&s[s.length-1].to>=o?s[s.length-1].to=l:s.push({from:o,to:l});return s}class MatchDecorator{constructor(e){const{regexp:n,decoration:s,decorate:o,boundary:l,maxLength:a=1e3}=e;if(!n.global)throw new RangeError("The regular expression given to MatchDecorator should have its 'g' flag set");if(this.regexp=n,o)this.addMatch=(c,h,f,u)=>o(u,f,f+c[0].length,c,h);else if(typeof s=="function")this.addMatch=(c,h,f,u)=>{let d=s(c,h,f);d&&u(f,f+c[0].length,d)};else if(s)this.addMatch=(c,h,f,u)=>u(f,f+c[0].length,s);else throw new RangeError("Either 'decorate' or 'decoration' should be provided to MatchDecorator");this.boundary=l,this.maxLength=a}createDeco(e){let n=new RangeSetBuilder,s=n.add.bind(n);for(let{from:o,to:l}of matchRanges(e,this.maxLength))iterMatches(e.state.doc,this.regexp,o,l,(a,c)=>this.addMatch(c,e,a,s));return n.finish()}updateDeco(e,n){let s=1e9,o=-1;return e.docChanged&&e.changes.iterChanges((l,a,c,h)=>{h>e.view.viewport.from&&c1e3?this.createDeco(e.view):o>-1?this.updateRange(e.view,n.map(e.changes),s,o):n}updateRange(e,n,s,o){for(let l of e.visibleRanges){let a=Math.max(l.from,s),c=Math.min(l.to,o);if(c>a){let h=e.state.doc.lineAt(a),f=h.toh.from;a--)if(this.boundary.test(h.text[a-1-h.from])){u=a;break}for(;cg.push(w.range(S,b));if(h==f)for(this.regexp.lastIndex=u-h.from;(O=this.regexp.exec(h.text))&&O.indexthis.addMatch(b,e,S,m));n=n.update({filterFrom:u,filterTo:d,filter:(S,b)=>Sd,add:g})}}return n}}const UnicodeRegexpSupport=/x/.unicode!=null?"gu":"g",Specials=new RegExp(`[\0-\b +--Ÿ­؜​‎‏\u2028\u2029‭‮⁦⁧⁩\uFEFF-]`,UnicodeRegexpSupport),Names={0:"null",7:"bell",8:"backspace",10:"newline",11:"vertical tab",13:"carriage return",27:"escape",8203:"zero width space",8204:"zero width non-joiner",8205:"zero width joiner",8206:"left-to-right mark",8207:"right-to-left mark",8232:"line separator",8237:"left-to-right override",8238:"right-to-left override",8294:"left-to-right isolate",8295:"right-to-left isolate",8297:"pop directional isolate",8233:"paragraph separator",65279:"zero width no-break space",65532:"object replacement"};let _supportsTabSize=null;function supportsTabSize(){var r;if(_supportsTabSize==null&&typeof document<"u"&&document.body){let e=document.body.style;_supportsTabSize=((r=e.tabSize)!==null&&r!==void 0?r:e.MozTabSize)!=null}return _supportsTabSize||!1}const specialCharConfig=Facet.define({combine(r){let e=combineConfig(r,{render:null,specialChars:Specials,addSpecialChars:null});return(e.replaceTabs=!supportsTabSize())&&(e.specialChars=new RegExp(" |"+e.specialChars.source,UnicodeRegexpSupport)),e.addSpecialChars&&(e.specialChars=new RegExp(e.specialChars.source+"|"+e.addSpecialChars.source,UnicodeRegexpSupport)),e}});function highlightSpecialChars(r={}){return[specialCharConfig.of(r),specialCharPlugin()]}let _plugin=null;function specialCharPlugin(){return _plugin||(_plugin=ViewPlugin.fromClass(class{constructor(r){this.view=r,this.decorations=Decoration.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(r.state.facet(specialCharConfig)),this.decorations=this.decorator.createDeco(r)}makeDecorator(r){return new MatchDecorator({regexp:r.specialChars,decoration:(e,n,s)=>{let{doc:o}=n.state,l=codePointAt(e[0],0);if(l==9){let a=o.lineAt(s),c=n.state.tabSize,h=countColumn(a.text,c,s-a.from);return Decoration.replace({widget:new TabWidget((c-h%c)*this.view.defaultCharacterWidth/this.view.scaleX)})}return this.decorationCache[l]||(this.decorationCache[l]=Decoration.replace({widget:new SpecialCharWidget(r,l)}))},boundary:r.replaceTabs?void 0:/[^]/})}update(r){let e=r.state.facet(specialCharConfig);r.startState.facet(specialCharConfig)!=e?(this.decorator=this.makeDecorator(e),this.decorations=this.decorator.createDeco(r.view)):this.decorations=this.decorator.updateDeco(r,this.decorations)}},{decorations:r=>r.decorations}))}const DefaultPlaceholder="•";function placeholder$1(r){return r>=32?DefaultPlaceholder:r==10?"␤":String.fromCharCode(9216+r)}class SpecialCharWidget extends WidgetType{constructor(e,n){super(),this.options=e,this.code=n}eq(e){return e.code==this.code}toDOM(e){let n=placeholder$1(this.code),s=e.state.phrase("Control character")+" "+(Names[this.code]||"0x"+this.code.toString(16)),o=this.options.render&&this.options.render(this.code,s,n);if(o)return o;let l=document.createElement("span");return l.textContent=n,l.title=s,l.setAttribute("aria-label",s),l.className="cm-specialChar",l}ignoreEvent(){return!1}}class TabWidget extends WidgetType{constructor(e){super(),this.width=e}eq(e){return e.width==this.width}toDOM(){let e=document.createElement("span");return e.textContent=" ",e.className="cm-tab",e.style.width=this.width+"px",e}ignoreEvent(){return!1}}function highlightActiveLine(){return activeLineHighlighter}const lineDeco=Decoration.line({class:"cm-activeLine"}),activeLineHighlighter=ViewPlugin.fromClass(class{constructor(r){this.decorations=this.getDeco(r)}update(r){(r.docChanged||r.selectionSet)&&(this.decorations=this.getDeco(r.view))}getDeco(r){let e=-1,n=[];for(let s of r.state.selection.ranges){let o=r.lineBlockAt(s.head);o.from>e&&(n.push(lineDeco.range(o.from)),e=o.from)}return Decoration.set(n)}},{decorations:r=>r.decorations}),MaxOff=2e3;function rectangleFor(r,e,n){let s=Math.min(e.line,n.line),o=Math.max(e.line,n.line),l=[];if(e.off>MaxOff||n.off>MaxOff||e.col<0||n.col<0){let a=Math.min(e.off,n.off),c=Math.max(e.off,n.off);for(let h=s;h<=o;h++){let f=r.doc.line(h);f.length<=c&&l.push(EditorSelection.range(f.from+a,f.to+c))}}else{let a=Math.min(e.col,n.col),c=Math.max(e.col,n.col);for(let h=s;h<=o;h++){let f=r.doc.line(h),u=findColumn(f.text,a,r.tabSize,!0);if(u<0)l.push(EditorSelection.cursor(f.to));else{let d=findColumn(f.text,c,r.tabSize);l.push(EditorSelection.range(f.from+u,f.from+d))}}}return l}function absoluteColumn(r,e){let n=r.coordsAtPos(r.viewport.from);return n?Math.round(Math.abs((n.left-e)/r.defaultCharacterWidth)):-1}function getPos(r,e){let n=r.posAtCoords({x:e.clientX,y:e.clientY},!1),s=r.state.doc.lineAt(n),o=n-s.from,l=o>MaxOff?-1:o==s.length?absoluteColumn(r,e.clientX):countColumn(s.text,r.state.tabSize,n-s.from);return{line:s.number,col:l,off:o}}function rectangleSelectionStyle(r,e){let n=getPos(r,e),s=r.state.selection;return n?{update(o){if(o.docChanged){let l=o.changes.mapPos(o.startState.doc.line(n.line).from),a=o.state.doc.lineAt(l);n={line:a.number,col:n.col,off:Math.min(n.off,a.length)},s=s.map(o.changes)}},get(o,l,a){let c=getPos(r,o);if(!c)return s;let h=rectangleFor(r.state,n,c);return h.length?a?EditorSelection.create(h.concat(s.ranges)):EditorSelection.create(h):s}}:null}function rectangularSelection(r){let e=n=>n.altKey&&n.button==0;return EditorView.mouseSelectionStyle.of((n,s)=>e(s)?rectangleSelectionStyle(n,s):null)}const keys={Alt:[18,r=>!!r.altKey],Control:[17,r=>!!r.ctrlKey],Shift:[16,r=>!!r.shiftKey],Meta:[91,r=>!!r.metaKey]},showCrosshair={style:"cursor: crosshair"};function crosshairCursor(r={}){let[e,n]=keys[r.key||"Alt"],s=ViewPlugin.fromClass(class{constructor(o){this.view=o,this.isDown=!1}set(o){this.isDown!=o&&(this.isDown=o,this.view.update([]))}},{eventObservers:{keydown(o){this.set(o.keyCode==e||n(o))},keyup(o){(o.keyCode==e||!n(o))&&this.set(!1)},mousemove(o){this.set(n(o))}}});return[s,EditorView.contentAttributes.of(o=>{var l;return!((l=o.plugin(s))===null||l===void 0)&&l.isDown?showCrosshair:null})]}const Outside="-10000px";class TooltipViewManager{constructor(e,n,s,o){this.facet=n,this.createTooltipView=s,this.removeTooltipView=o,this.input=e.state.facet(n),this.tooltips=this.input.filter(a=>a);let l=null;this.tooltipViews=this.tooltips.map(a=>l=s(a,l))}update(e,n){var s;let o=e.state.facet(this.facet),l=o.filter(h=>h);if(o===this.input){for(let h of this.tooltipViews)h.update&&h.update(e);return!1}let a=[],c=n?[]:null;for(let h=0;hn[f]=h),n.length=c.length),this.input=o,this.tooltips=l,this.tooltipViews=a,!0}}function windowSpace(r){let{win:e}=r;return{top:0,left:0,bottom:e.innerHeight,right:e.innerWidth}}const tooltipConfig=Facet.define({combine:r=>{var e,n,s;return{position:browser.ios?"absolute":((e=r.find(o=>o.position))===null||e===void 0?void 0:e.position)||"fixed",parent:((n=r.find(o=>o.parent))===null||n===void 0?void 0:n.parent)||null,tooltipSpace:((s=r.find(o=>o.tooltipSpace))===null||s===void 0?void 0:s.tooltipSpace)||windowSpace}}}),knownHeight=new WeakMap,tooltipPlugin=ViewPlugin.fromClass(class{constructor(r){this.view=r,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let e=r.state.facet(tooltipConfig);this.position=e.position,this.parent=e.parent,this.classes=r.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.resizeObserver=typeof ResizeObserver=="function"?new ResizeObserver(()=>this.measureSoon()):null,this.manager=new TooltipViewManager(r,showTooltip,(n,s)=>this.createTooltip(n,s),n=>{this.resizeObserver&&this.resizeObserver.unobserve(n.dom),n.dom.remove()}),this.above=this.manager.tooltips.map(n=>!!n.above),this.intersectionObserver=typeof IntersectionObserver=="function"?new IntersectionObserver(n=>{Date.now()>this.lastTransaction-50&&n.length>0&&n[n.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),r.win.addEventListener("resize",this.measureSoon=this.measureSoon.bind(this)),this.maybeMeasure()}createContainer(){this.parent?(this.container=document.createElement("div"),this.container.style.position="relative",this.container.className=this.view.themeClasses,this.parent.appendChild(this.container)):this.container=this.view.dom}observeIntersection(){if(this.intersectionObserver){this.intersectionObserver.disconnect();for(let r of this.manager.tooltipViews)this.intersectionObserver.observe(r.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(r){r.transactions.length&&(this.lastTransaction=Date.now());let e=this.manager.update(r,this.above);e&&this.observeIntersection();let n=e||r.geometryChanged,s=r.state.facet(tooltipConfig);if(s.position!=this.position&&!this.madeAbsolute){this.position=s.position;for(let o of this.manager.tooltipViews)o.dom.style.position=this.position;n=!0}if(s.parent!=this.parent){this.parent&&this.container.remove(),this.parent=s.parent,this.createContainer();for(let o of this.manager.tooltipViews)this.container.appendChild(o.dom);n=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);n&&this.maybeMeasure()}createTooltip(r,e){let n=r.create(this.view),s=e?e.dom:null;if(n.dom.classList.add("cm-tooltip"),r.arrow&&!n.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let o=document.createElement("div");o.className="cm-tooltip-arrow",n.dom.appendChild(o)}return n.dom.style.position=this.position,n.dom.style.top=Outside,n.dom.style.left="0px",this.container.insertBefore(n.dom,s),n.mount&&n.mount(this.view),this.resizeObserver&&this.resizeObserver.observe(n.dom),n}destroy(){var r,e,n;this.view.win.removeEventListener("resize",this.measureSoon);for(let s of this.manager.tooltipViews)s.dom.remove(),(r=s.destroy)===null||r===void 0||r.call(s);this.parent&&this.container.remove(),(e=this.resizeObserver)===null||e===void 0||e.disconnect(),(n=this.intersectionObserver)===null||n===void 0||n.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let r=this.view.dom.getBoundingClientRect(),e=1,n=1,s=!1;if(this.position=="fixed"&&this.manager.tooltipViews.length){let{dom:o}=this.manager.tooltipViews[0];if(browser.gecko)s=o.offsetParent!=this.container.ownerDocument.body;else if(o.style.top==Outside&&o.style.left=="0px"){let l=o.getBoundingClientRect();s=Math.abs(l.top+1e4)>1||Math.abs(l.left)>1}}if(s||this.position=="absolute")if(this.parent){let o=this.parent.getBoundingClientRect();o.width&&o.height&&(e=o.width/this.parent.offsetWidth,n=o.height/this.parent.offsetHeight)}else({scaleX:e,scaleY:n}=this.view.viewState);return{editor:r,parent:this.parent?this.container.getBoundingClientRect():r,pos:this.manager.tooltips.map((o,l)=>{let a=this.manager.tooltipViews[l];return a.getCoords?a.getCoords(o.pos):this.view.coordsAtPos(o.pos)}),size:this.manager.tooltipViews.map(({dom:o})=>o.getBoundingClientRect()),space:this.view.state.facet(tooltipConfig).tooltipSpace(this.view),scaleX:e,scaleY:n,makeAbsolute:s}}writeMeasure(r){var e;if(r.makeAbsolute){this.madeAbsolute=!0,this.position="absolute";for(let c of this.manager.tooltipViews)c.dom.style.position="absolute"}let{editor:n,space:s,scaleX:o,scaleY:l}=r,a=[];for(let c=0;c=Math.min(n.bottom,s.bottom)||d.rightMath.min(n.right,s.right)+.1){u.style.top=Outside;continue}let O=h.arrow?f.dom.querySelector(".cm-tooltip-arrow"):null,m=O?7:0,S=g.right-g.left,b=(e=knownHeight.get(f))!==null&&e!==void 0?e:g.bottom-g.top,w=f.offset||noOffset,P=this.view.textDirection==Direction.LTR,$=g.width>s.right-s.left?P?s.left:s.right-g.width:P?Math.min(d.left-(O?14:0)+w.x,s.right-S):Math.max(s.left,d.left-S+(O?14:0)-w.x),A=this.above[c];!h.strictSide&&(A?d.top-(g.bottom-g.top)-w.ys.bottom)&&A==s.bottom-d.bottom>d.top-s.top&&(A=this.above[c]=!A);let v=(A?d.top-s.top:s.bottom-d.bottom)-m;if(v$&&N.topQ&&(Q=A?N.top-b-2-m:N.bottom+m+2);if(this.position=="absolute"?(u.style.top=(Q-r.parent.top)/l+"px",u.style.left=($-r.parent.left)/o+"px"):(u.style.top=Q/l+"px",u.style.left=$/o+"px"),O){let N=d.left+(P?w.x:-w.x)-($+14-7);O.style.left=N/o+"px"}f.overlap!==!0&&a.push({left:$,top:Q,right:_,bottom:Q+b}),u.classList.toggle("cm-tooltip-above",A),u.classList.toggle("cm-tooltip-below",!A),f.positioned&&f.positioned(r.space)}}maybeMeasure(){if(this.manager.tooltips.length&&(this.view.inView&&this.view.requestMeasure(this.measureReq),this.inView!=this.view.inView&&(this.inView=this.view.inView,!this.inView)))for(let r of this.manager.tooltipViews)r.dom.style.top=Outside}},{eventObservers:{scroll(){this.maybeMeasure()}}}),baseTheme$5=EditorView.baseTheme({".cm-tooltip":{zIndex:100,boxSizing:"border-box"},"&light .cm-tooltip":{border:"1px solid #bbb",backgroundColor:"#f5f5f5"},"&light .cm-tooltip-section:not(:first-child)":{borderTop:"1px solid #bbb"},"&dark .cm-tooltip":{backgroundColor:"#333338",color:"white"},".cm-tooltip-arrow":{height:"7px",width:`${7*2}px`,position:"absolute",zIndex:-1,overflow:"hidden","&:before, &:after":{content:"''",position:"absolute",width:0,height:0,borderLeft:"7px solid transparent",borderRight:"7px solid transparent"},".cm-tooltip-above &":{bottom:"-7px","&:before":{borderTop:"7px solid #bbb"},"&:after":{borderTop:"7px solid #f5f5f5",bottom:"1px"}},".cm-tooltip-below &":{top:"-7px","&:before":{borderBottom:"7px solid #bbb"},"&:after":{borderBottom:"7px solid #f5f5f5",top:"1px"}}},"&dark .cm-tooltip .cm-tooltip-arrow":{"&:before":{borderTopColor:"#333338",borderBottomColor:"#333338"},"&:after":{borderTopColor:"transparent",borderBottomColor:"transparent"}}}),noOffset={x:0,y:0},showTooltip=Facet.define({enables:[tooltipPlugin,baseTheme$5]}),showHoverTooltip=Facet.define({combine:r=>r.reduce((e,n)=>e.concat(n),[])});class HoverTooltipHost{static create(e){return new HoverTooltipHost(e)}constructor(e){this.view=e,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new TooltipViewManager(e,showHoverTooltip,(n,s)=>this.createHostedView(n,s),n=>n.dom.remove())}createHostedView(e,n){let s=e.create(this.view);return s.dom.classList.add("cm-tooltip-section"),this.dom.insertBefore(s.dom,n?n.dom.nextSibling:this.dom.firstChild),this.mounted&&s.mount&&s.mount(this.view),s}mount(e){for(let n of this.manager.tooltipViews)n.mount&&n.mount(e);this.mounted=!0}positioned(e){for(let n of this.manager.tooltipViews)n.positioned&&n.positioned(e)}update(e){this.manager.update(e)}destroy(){var e;for(let n of this.manager.tooltipViews)(e=n.destroy)===null||e===void 0||e.call(n)}passProp(e){let n;for(let s of this.manager.tooltipViews){let o=s[e];if(o!==void 0){if(n===void 0)n=o;else if(n!==o)return}}return n}get offset(){return this.passProp("offset")}get getCoords(){return this.passProp("getCoords")}get overlap(){return this.passProp("overlap")}get resize(){return this.passProp("resize")}}const showHoverTooltipHost=showTooltip.compute([showHoverTooltip],r=>{let e=r.facet(showHoverTooltip);return e.length===0?null:{pos:Math.min(...e.map(n=>n.pos)),end:Math.max(...e.map(n=>{var s;return(s=n.end)!==null&&s!==void 0?s:n.pos})),create:HoverTooltipHost.create,above:e[0].above,arrow:e.some(n=>n.arrow)}});class HoverPlugin{constructor(e,n,s,o,l){this.view=e,this.source=n,this.field=s,this.setHover=o,this.hoverTime=l,this.hoverTimeout=-1,this.restartTimeout=-1,this.pending=null,this.lastMove={x:0,y:0,target:e.dom,time:0},this.checkHover=this.checkHover.bind(this),e.dom.addEventListener("mouseleave",this.mouseleave=this.mouseleave.bind(this)),e.dom.addEventListener("mousemove",this.mousemove=this.mousemove.bind(this))}update(){this.pending&&(this.pending=null,clearTimeout(this.restartTimeout),this.restartTimeout=setTimeout(()=>this.startHover(),20))}get active(){return this.view.state.field(this.field)}checkHover(){if(this.hoverTimeout=-1,this.active.length)return;let e=Date.now()-this.lastMove.time;ec.bottom||n.xc.right+e.defaultCharacterWidth)return;let h=e.bidiSpans(e.state.doc.lineAt(o)).find(u=>u.from<=o&&u.to>=o),f=h&&h.dir==Direction.RTL?-1:1;l=n.x{this.pending==c&&(this.pending=null,h&&!(Array.isArray(h)&&!h.length)&&e.dispatch({effects:this.setHover.of(Array.isArray(h)?h:[h])}))},h=>logException(e.state,h,"hover tooltip"))}else a&&!(Array.isArray(a)&&!a.length)&&e.dispatch({effects:this.setHover.of(Array.isArray(a)?a:[a])})}get tooltip(){let e=this.view.plugin(tooltipPlugin),n=e?e.manager.tooltips.findIndex(s=>s.create==HoverTooltipHost.create):-1;return n>-1?e.manager.tooltipViews[n]:null}mousemove(e){var n,s;this.lastMove={x:e.clientX,y:e.clientY,target:e.target,time:Date.now()},this.hoverTimeout<0&&(this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime));let{active:o,tooltip:l}=this;if(o.length&&l&&!isInTooltip(l.dom,e)||this.pending){let{pos:a}=o[0]||this.pending,c=(s=(n=o[0])===null||n===void 0?void 0:n.end)!==null&&s!==void 0?s:a;(a==c?this.view.posAtCoords(this.lastMove)!=a:!isOverRange(this.view,a,c,e.clientX,e.clientY))&&(this.view.dispatch({effects:this.setHover.of([])}),this.pending=null)}}mouseleave(e){clearTimeout(this.hoverTimeout),this.hoverTimeout=-1;let{active:n}=this;if(n.length){let{tooltip:s}=this;s&&s.dom.contains(e.relatedTarget)?this.watchTooltipLeave(s.dom):this.view.dispatch({effects:this.setHover.of([])})}}watchTooltipLeave(e){let n=s=>{e.removeEventListener("mouseleave",n),this.active.length&&!this.view.dom.contains(s.relatedTarget)&&this.view.dispatch({effects:this.setHover.of([])})};e.addEventListener("mouseleave",n)}destroy(){clearTimeout(this.hoverTimeout),this.view.dom.removeEventListener("mouseleave",this.mouseleave),this.view.dom.removeEventListener("mousemove",this.mousemove)}}const tooltipMargin=4;function isInTooltip(r,e){let n=r.getBoundingClientRect();return e.clientX>=n.left-tooltipMargin&&e.clientX<=n.right+tooltipMargin&&e.clientY>=n.top-tooltipMargin&&e.clientY<=n.bottom+tooltipMargin}function isOverRange(r,e,n,s,o,l){let a=r.scrollDOM.getBoundingClientRect(),c=r.documentTop+r.documentPadding.top+r.contentHeight;if(a.left>s||a.righto||Math.min(a.bottom,c)=e&&h<=n}function hoverTooltip(r,e={}){let n=StateEffect.define(),s=StateField.define({create(){return[]},update(o,l){if(o.length&&(e.hideOnChange&&(l.docChanged||l.selection)?o=[]:e.hideOn&&(o=o.filter(a=>!e.hideOn(l,a))),l.docChanged)){let a=[];for(let c of o){let h=l.changes.mapPos(c.pos,-1,MapMode.TrackDel);if(h!=null){let f=Object.assign(Object.create(null),c);f.pos=h,f.end!=null&&(f.end=l.changes.mapPos(f.end)),a.push(f)}}o=a}for(let a of l.effects)a.is(n)&&(o=a.value),a.is(closeHoverTooltipEffect)&&(o=[]);return o},provide:o=>showHoverTooltip.from(o)});return[s,ViewPlugin.define(o=>new HoverPlugin(o,r,s,n,e.hoverTime||300)),showHoverTooltipHost]}function getTooltip(r,e){let n=r.plugin(tooltipPlugin);if(!n)return null;let s=n.manager.tooltips.indexOf(e);return s<0?null:n.manager.tooltipViews[s]}const closeHoverTooltipEffect=StateEffect.define(),panelConfig=Facet.define({combine(r){let e,n;for(let s of r)e=e||s.topContainer,n=n||s.bottomContainer;return{topContainer:e,bottomContainer:n}}});function getPanel(r,e){let n=r.plugin(panelPlugin),s=n?n.specs.indexOf(e):-1;return s>-1?n.panels[s]:null}const panelPlugin=ViewPlugin.fromClass(class{constructor(r){this.input=r.state.facet(showPanel),this.specs=this.input.filter(n=>n),this.panels=this.specs.map(n=>n(r));let e=r.state.facet(panelConfig);this.top=new PanelGroup(r,!0,e.topContainer),this.bottom=new PanelGroup(r,!1,e.bottomContainer),this.top.sync(this.panels.filter(n=>n.top)),this.bottom.sync(this.panels.filter(n=>!n.top));for(let n of this.panels)n.dom.classList.add("cm-panel"),n.mount&&n.mount()}update(r){let e=r.state.facet(panelConfig);this.top.container!=e.topContainer&&(this.top.sync([]),this.top=new PanelGroup(r.view,!0,e.topContainer)),this.bottom.container!=e.bottomContainer&&(this.bottom.sync([]),this.bottom=new PanelGroup(r.view,!1,e.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let n=r.state.facet(showPanel);if(n!=this.input){let s=n.filter(h=>h),o=[],l=[],a=[],c=[];for(let h of s){let f=this.specs.indexOf(h),u;f<0?(u=h(r.view),c.push(u)):(u=this.panels[f],u.update&&u.update(r)),o.push(u),(u.top?l:a).push(u)}this.specs=s,this.panels=o,this.top.sync(l),this.bottom.sync(a);for(let h of c)h.dom.classList.add("cm-panel"),h.mount&&h.mount()}else for(let s of this.panels)s.update&&s.update(r)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:r=>EditorView.scrollMargins.of(e=>{let n=e.plugin(r);return n&&{top:n.top.scrollMargin(),bottom:n.bottom.scrollMargin()}})});class PanelGroup{constructor(e,n,s){this.view=e,this.top=n,this.container=s,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()}sync(e){for(let n of this.panels)n.destroy&&e.indexOf(n)<0&&n.destroy();this.panels=e,this.syncDOM()}syncDOM(){if(this.panels.length==0){this.dom&&(this.dom.remove(),this.dom=void 0);return}if(!this.dom){this.dom=document.createElement("div"),this.dom.className=this.top?"cm-panels cm-panels-top":"cm-panels cm-panels-bottom",this.dom.style[this.top?"top":"bottom"]="0";let n=this.container||this.view.dom;n.insertBefore(this.dom,this.top?n.firstChild:null)}let e=this.dom.firstChild;for(let n of this.panels)if(n.dom.parentNode==this.dom){for(;e!=n.dom;)e=rm(e);e=e.nextSibling}else this.dom.insertBefore(n.dom,e);for(;e;)e=rm(e)}scrollMargin(){return!this.dom||this.container?0:Math.max(0,this.top?this.dom.getBoundingClientRect().bottom-Math.max(0,this.view.scrollDOM.getBoundingClientRect().top):Math.min(innerHeight,this.view.scrollDOM.getBoundingClientRect().bottom)-this.dom.getBoundingClientRect().top)}syncClasses(){if(!(!this.container||this.classes==this.view.themeClasses)){for(let e of this.classes.split(" "))e&&this.container.classList.remove(e);for(let e of(this.classes=this.view.themeClasses).split(" "))e&&this.container.classList.add(e)}}}function rm(r){let e=r.nextSibling;return r.remove(),e}const showPanel=Facet.define({enables:panelPlugin});class GutterMarker extends RangeValue{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}GutterMarker.prototype.elementClass="";GutterMarker.prototype.toDOM=void 0;GutterMarker.prototype.mapMode=MapMode.TrackBefore;GutterMarker.prototype.startSide=GutterMarker.prototype.endSide=-1;GutterMarker.prototype.point=!0;const gutterLineClass=Facet.define(),defaults$1={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>RangeSet.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{}},activeGutters=Facet.define();function gutter(r){return[gutters(),activeGutters.of(Object.assign(Object.assign({},defaults$1),r))]}const unfixGutters=Facet.define({combine:r=>r.some(e=>e)});function gutters(r){return[gutterView]}const gutterView=ViewPlugin.fromClass(class{constructor(r){this.view=r,this.prevViewport=r.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.gutters=r.state.facet(activeGutters).map(e=>new SingleGutterView(r,e));for(let e of this.gutters)this.dom.appendChild(e.dom);this.fixed=!r.state.facet(unfixGutters),this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),r.scrollDOM.insertBefore(this.dom,r.contentDOM)}update(r){if(this.updateGutters(r)){let e=this.prevViewport,n=r.view.viewport,s=Math.min(e.to,n.to)-Math.max(e.from,n.from);this.syncGutters(s<(n.to-n.from)*.8)}r.geometryChanged&&(this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px"),this.view.state.facet(unfixGutters)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":""),this.prevViewport=r.view.viewport}syncGutters(r){let e=this.dom.nextSibling;r&&this.dom.remove();let n=RangeSet.iter(this.view.state.facet(gutterLineClass),this.view.viewport.from),s=[],o=this.gutters.map(l=>new UpdateContext(l,this.view.viewport,-this.view.documentPadding.top));for(let l of this.view.viewportLineBlocks)if(s.length&&(s=[]),Array.isArray(l.type)){let a=!0;for(let c of l.type)if(c.type==BlockType.Text&&a){advanceCursor(n,s,c.from);for(let h of o)h.line(this.view,c,s);a=!1}else if(c.widget)for(let h of o)h.widget(this.view,c)}else if(l.type==BlockType.Text){advanceCursor(n,s,l.from);for(let a of o)a.line(this.view,l,s)}else if(l.widget)for(let a of o)a.widget(this.view,l);for(let l of o)l.finish();r&&this.view.scrollDOM.insertBefore(this.dom,e)}updateGutters(r){let e=r.startState.facet(activeGutters),n=r.state.facet(activeGutters),s=r.docChanged||r.heightChanged||r.viewportChanged||!RangeSet.eq(r.startState.facet(gutterLineClass),r.state.facet(gutterLineClass),r.view.viewport.from,r.view.viewport.to);if(e==n)for(let o of this.gutters)o.update(r)&&(s=!0);else{s=!0;let o=[];for(let l of n){let a=e.indexOf(l);a<0?o.push(new SingleGutterView(this.view,l)):(this.gutters[a].update(r),o.push(this.gutters[a]))}for(let l of this.gutters)l.dom.remove(),o.indexOf(l)<0&&l.destroy();for(let l of o)this.dom.appendChild(l.dom);this.gutters=o}return s}destroy(){for(let r of this.gutters)r.destroy();this.dom.remove()}},{provide:r=>EditorView.scrollMargins.of(e=>{let n=e.plugin(r);return!n||n.gutters.length==0||!n.fixed?null:e.textDirection==Direction.LTR?{left:n.dom.offsetWidth*e.scaleX}:{right:n.dom.offsetWidth*e.scaleX}})});function asArray(r){return Array.isArray(r)?r:[r]}function advanceCursor(r,e,n){for(;r.value&&r.from<=n;)r.from==n&&e.push(r.value),r.next()}class UpdateContext{constructor(e,n,s){this.gutter=e,this.height=s,this.i=0,this.cursor=RangeSet.iter(e.markers,n.from)}addElement(e,n,s){let{gutter:o}=this,l=(n.top-this.height)/e.scaleY,a=n.height/e.scaleY;if(this.i==o.elements.length){let c=new GutterElement(e,a,l,s);o.elements.push(c),o.dom.appendChild(c.dom)}else o.elements[this.i].update(e,a,l,s);this.height=n.bottom,this.i++}line(e,n,s){let o=[];advanceCursor(this.cursor,o,n.from),s.length&&(o=o.concat(s));let l=this.gutter.config.lineMarker(e,n,o);l&&o.unshift(l);let a=this.gutter;o.length==0&&!a.config.renderEmptyElements||this.addElement(e,n,o)}widget(e,n){let s=this.gutter.config.widgetMarker(e,n.widget,n);s&&this.addElement(e,n,[s])}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let n=e.elements.pop();e.dom.removeChild(n.dom),n.destroy()}}}class SingleGutterView{constructor(e,n){this.view=e,this.config=n,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let s in n.domEventHandlers)this.dom.addEventListener(s,o=>{let l=o.target,a;if(l!=this.dom&&this.dom.contains(l)){for(;l.parentNode!=this.dom;)l=l.parentNode;let h=l.getBoundingClientRect();a=(h.top+h.bottom)/2}else a=o.clientY;let c=e.lineBlockAtHeight(a-e.documentTop);n.domEventHandlers[s](e,c,o)&&o.preventDefault()});this.markers=asArray(n.markers(e)),n.initialSpacer&&(this.spacer=new GutterElement(e,0,0,[n.initialSpacer(e)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(e){let n=this.markers;if(this.markers=asArray(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let o=this.config.updateSpacer(this.spacer.markers[0],e);o!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[o])}let s=e.view.viewport;return!RangeSet.eq(this.markers,n,s.from,s.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(e):!1)}destroy(){for(let e of this.elements)e.destroy()}}class GutterElement{constructor(e,n,s,o){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(e,n,s,o)}update(e,n,s,o){this.height!=n&&(this.height=n,this.dom.style.height=n+"px"),this.above!=s&&(this.dom.style.marginTop=(this.above=s)?s+"px":""),sameMarkers(this.markers,o)||this.setMarkers(e,o)}setMarkers(e,n){let s="cm-gutterElement",o=this.dom.firstChild;for(let l=0,a=0;;){let c=a,h=ll(c,h,f)||a(c,h,f):a}return s}})}});class NumberMarker extends GutterMarker{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}}function formatNumber(r,e){return r.state.facet(lineNumberConfig).formatNumber(e,r.state)}const lineNumberGutter=activeGutters.compute([lineNumberConfig],r=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(e){return e.state.facet(lineNumberMarkers)},lineMarker(e,n,s){return s.some(o=>o.toDOM)?null:new NumberMarker(formatNumber(e,e.state.doc.lineAt(n.from).number))},widgetMarker:()=>null,lineMarkerChange:e=>e.startState.facet(lineNumberConfig)!=e.state.facet(lineNumberConfig),initialSpacer(e){return new NumberMarker(formatNumber(e,maxLineNumber(e.state.doc.lines)))},updateSpacer(e,n){let s=formatNumber(n.view,maxLineNumber(n.view.state.doc.lines));return s==e.number?e:new NumberMarker(s)},domEventHandlers:r.facet(lineNumberConfig).domEventHandlers}));function lineNumbers(r={}){return[lineNumberConfig.of(r),gutters(),lineNumberGutter]}function maxLineNumber(r){let e=9;for(;e{let e=[],n=-1;for(let s of r.selection.ranges){let o=r.doc.lineAt(s.head).from;o>n&&(n=o,e.push(activeLineGutterMarker.range(o)))}return RangeSet.of(e)});function highlightActiveLineGutter(){return activeLineGutterHighlighter}function crelt(){var r=arguments[0];typeof r=="string"&&(r=document.createElement(r));var e=1,n=arguments[1];if(n&&typeof n=="object"&&n.nodeType==null&&!Array.isArray(n)){for(var s in n)if(Object.prototype.hasOwnProperty.call(n,s)){var o=n[s];typeof o=="string"?r.setAttribute(s,o):o!=null&&(r[s]=o)}e++}for(;ec.from==c.to||c.from==c.to-1&&s.doc.lineAt(c.from).to==c.from?Decoration.widget({widget:new DiagnosticWidget(c),diagnostic:c}).range(c.from):Decoration.mark({attributes:{class:"cm-lintRange cm-lintRange-"+c.severity+(c.markClass?" "+c.markClass:"")},diagnostic:c,inclusive:!0}).range(c.from,c.to)),!0);return new LintState(a,n,findDiagnostic(a))}}function findDiagnostic(r,e=null,n=0){let s=null;return r.between(n,1e9,(o,l,{spec:a})=>{if(!(e&&a.diagnostic!=e))return s=new SelectedDiagnostic(o,l,a.diagnostic),!1}),s}function hideTooltip(r,e){let n=e.pos,s=e.end||n,o=r.state.facet(lintConfig).hideOn(r,n,s);if(o!=null)return o;let l=r.startState.doc.lineAt(e.pos);return!!(r.effects.some(a=>a.is(setDiagnosticsEffect))||r.changes.touchesRange(l.from,Math.max(l.to,s)))}function maybeEnableLint(r,e){return r.field(lintState,!1)?e:e.concat(StateEffect.appendConfig.of(lintExtensions))}const setDiagnosticsEffect=StateEffect.define(),togglePanel$1=StateEffect.define(),movePanelSelection=StateEffect.define(),lintState=StateField.define({create(){return new LintState(Decoration.none,null,null)},update(r,e){if(e.docChanged&&r.diagnostics.size){let n=r.diagnostics.map(e.changes),s=null,o=r.panel;if(r.selected){let l=e.changes.mapPos(r.selected.from,1);s=findDiagnostic(n,r.selected.diagnostic,l)||findDiagnostic(n,null,l)}!n.size&&o&&e.state.facet(lintConfig).autoPanel&&(o=null),r=new LintState(n,o,s)}for(let n of e.effects)if(n.is(setDiagnosticsEffect)){let s=e.state.facet(lintConfig).autoPanel?n.value.length?LintPanel.open:null:r.panel;r=LintState.init(n.value,s,e.state)}else n.is(togglePanel$1)?r=new LintState(r.diagnostics,n.value?LintPanel.open:null,r.selected):n.is(movePanelSelection)&&(r=new LintState(r.diagnostics,r.panel,n.value));return r},provide:r=>[showPanel.from(r,e=>e.panel),EditorView.decorations.from(r,e=>e.diagnostics)]}),activeMark=Decoration.mark({class:"cm-lintRange cm-lintRange-active",inclusive:!0});function lintTooltip(r,e,n){let{diagnostics:s}=r.state.field(lintState),o=[],l=2e8,a=0;s.between(e-(n<0?1:0),e+(n>0?1:0),(h,f,{spec:u})=>{e>=h&&e<=f&&(h==f||(e>h||n>0)&&(erenderDiagnostic(r,n,!1)))}const openLintPanel=r=>{let e=r.state.field(lintState,!1);(!e||!e.panel)&&r.dispatch({effects:maybeEnableLint(r.state,[togglePanel$1.of(!0)])});let n=getPanel(r,LintPanel.open);return n&&n.dom.querySelector(".cm-panel-lint ul").focus(),!0},closeLintPanel=r=>{let e=r.state.field(lintState,!1);return!e||!e.panel?!1:(r.dispatch({effects:togglePanel$1.of(!1)}),!0)},nextDiagnostic=r=>{let e=r.state.field(lintState,!1);if(!e)return!1;let n=r.state.selection.main,s=e.diagnostics.iter(n.to+1);return!s.value&&(s=e.diagnostics.iter(0),!s.value||s.from==n.from&&s.to==n.to)?!1:(r.dispatch({selection:{anchor:s.from,head:s.to},scrollIntoView:!0}),!0)},lintKeymap=[{key:"Mod-Shift-m",run:openLintPanel,preventDefault:!0},{key:"F8",run:nextDiagnostic}],lintConfig=Facet.define({combine(r){return Object.assign({sources:r.map(e=>e.source).filter(e=>e!=null)},combineConfig(r.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{needsRefresh:(e,n)=>e?n?s=>e(s)||n(s):e:n}))}});function assignKeys(r){let e=[];if(r)e:for(let{name:n}of r){for(let s=0;sl.toLowerCase()==o.toLowerCase())){e.push(o);continue e}}e.push("")}return e}function renderDiagnostic(r,e,n){var s;let o=n?assignKeys(e.actions):[];return crelt("li",{class:"cm-diagnostic cm-diagnostic-"+e.severity},crelt("span",{class:"cm-diagnosticText"},e.renderMessage?e.renderMessage(r):e.message),(s=e.actions)===null||s===void 0?void 0:s.map((l,a)=>{let c=!1,h=g=>{if(g.preventDefault(),c)return;c=!0;let O=findDiagnostic(r.state.field(lintState).diagnostics,e);O&&l.apply(r,O.from,O.to)},{name:f}=l,u=o[a]?f.indexOf(o[a]):-1,d=u<0?f:[f.slice(0,u),crelt("u",f.slice(u,u+1)),f.slice(u+1)];return crelt("button",{type:"button",class:"cm-diagnosticAction",onclick:h,onmousedown:h,"aria-label":` Action: ${f}${u<0?"":` (access key "${o[a]})"`}.`},d)}),e.source&&crelt("div",{class:"cm-diagnosticSource"},e.source))}class DiagnosticWidget extends WidgetType{constructor(e){super(),this.diagnostic=e}eq(e){return e.diagnostic==this.diagnostic}toDOM(){return crelt("span",{class:"cm-lintPoint cm-lintPoint-"+this.diagnostic.severity})}}class PanelItem{constructor(e,n){this.diagnostic=n,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=renderDiagnostic(e,n,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class LintPanel{constructor(e){this.view=e,this.items=[];let n=o=>{if(o.keyCode==27)closeLintPanel(this.view),this.view.focus();else if(o.keyCode==38||o.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(o.keyCode==40||o.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(o.keyCode==36)this.moveSelection(0);else if(o.keyCode==35)this.moveSelection(this.items.length-1);else if(o.keyCode==13)this.view.focus();else if(o.keyCode>=65&&o.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:l}=this.items[this.selectedIndex],a=assignKeys(l.actions);for(let c=0;c{for(let l=0;lcloseLintPanel(this.view)},"×")),this.update()}get selectedIndex(){let e=this.view.state.field(lintState).selected;if(!e)return-1;for(let n=0;n{let f=-1,u;for(let d=s;ds&&(this.items.splice(s,f-s),o=!0)),n&&u.diagnostic==n.diagnostic?u.dom.hasAttribute("aria-selected")||(u.dom.setAttribute("aria-selected","true"),l=u):u.dom.hasAttribute("aria-selected")&&u.dom.removeAttribute("aria-selected"),s++});s({sel:l.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:a,panel:c})=>{let h=c.height/this.list.offsetHeight;a.topc.bottom&&(this.list.scrollTop+=(a.bottom-c.bottom)/h)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),o&&this.sync()}sync(){let e=this.list.firstChild;function n(){let s=e;e=s.nextSibling,s.remove()}for(let s of this.items)if(s.dom.parentNode==this.list){for(;e!=s.dom;)n();e=s.dom.nextSibling}else this.list.insertBefore(s.dom,e);for(;e;)n()}moveSelection(e){if(this.selectedIndex<0)return;let n=this.view.state.field(lintState),s=findDiagnostic(n.diagnostics,this.items[e].diagnostic);s&&this.view.dispatch({selection:{anchor:s.from,head:s.to},scrollIntoView:!0,effects:movePanelSelection.of(s)})}static open(e){return new LintPanel(e)}}function svg(r,e='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,${encodeURIComponent(r)}')`}function underline(r){return svg(``,'width="6" height="3"')}const baseTheme$4=EditorView.baseTheme({".cm-diagnostic":{padding:"3px 6px 3px 8px",marginLeft:"-1px",display:"block",whiteSpace:"pre-wrap"},".cm-diagnostic-error":{borderLeft:"5px solid #d11"},".cm-diagnostic-warning":{borderLeft:"5px solid orange"},".cm-diagnostic-info":{borderLeft:"5px solid #999"},".cm-diagnostic-hint":{borderLeft:"5px solid #66d"},".cm-diagnosticAction":{font:"inherit",border:"none",padding:"2px 4px",backgroundColor:"#444",color:"white",borderRadius:"3px",marginLeft:"8px",cursor:"pointer"},".cm-diagnosticSource":{fontSize:"70%",opacity:.7},".cm-lintRange":{backgroundPosition:"left bottom",backgroundRepeat:"repeat-x",paddingBottom:"0.7px"},".cm-lintRange-error":{backgroundImage:underline("#d11")},".cm-lintRange-warning":{backgroundImage:underline("orange")},".cm-lintRange-info":{backgroundImage:underline("#999")},".cm-lintRange-hint":{backgroundImage:underline("#66d")},".cm-lintRange-active":{backgroundColor:"#ffdd9980"},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:"relative","&:after":{content:'""',position:"absolute",bottom:0,left:"-2px",borderLeft:"3px solid transparent",borderRight:"3px solid transparent",borderBottom:"4px solid #d11"}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:"orange"}},".cm-lintPoint-info":{"&:after":{borderBottomColor:"#999"}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:"#66d"}},".cm-panel.cm-panel-lint":{position:"relative","& ul":{maxHeight:"100px",overflowY:"auto","& [aria-selected]":{backgroundColor:"#ddd","& u":{textDecoration:"underline"}},"&:focus [aria-selected]":{background_fallback:"#bdf",backgroundColor:"Highlight",color_fallback:"white",color:"HighlightText"},"& u":{textDecoration:"none"},padding:0,margin:0},"& [name=close]":{position:"absolute",top:"0",right:"2px",background:"inherit",border:"none",font:"inherit",padding:0,margin:0}}}),lintExtensions=[lintState,EditorView.decorations.compute([lintState],r=>{let{selected:e,panel:n}=r.field(lintState);return!e||!n||e.from==e.to?Decoration.none:Decoration.set([activeMark.range(e.from,e.to)])}),hoverTooltip(lintTooltip,{hideOn:hideTooltip}),baseTheme$4],DefaultBufferLength=1024;let nextPropID=0;class Range{constructor(e,n){this.from=e,this.to=n}}class NodeProp{constructor(e={}){this.id=nextPropID++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")})}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof e!="function"&&(e=NodeType.match(e)),n=>{let s=e(n);return s===void 0?null:[this,s]}}}NodeProp.closedBy=new NodeProp({deserialize:r=>r.split(" ")});NodeProp.openedBy=new NodeProp({deserialize:r=>r.split(" ")});NodeProp.group=new NodeProp({deserialize:r=>r.split(" ")});NodeProp.isolate=new NodeProp({deserialize:r=>{if(r&&r!="rtl"&&r!="ltr"&&r!="auto")throw new RangeError("Invalid value for isolate: "+r);return r||"auto"}});NodeProp.contextHash=new NodeProp({perNode:!0});NodeProp.lookAhead=new NodeProp({perNode:!0});NodeProp.mounted=new NodeProp({perNode:!0});class MountedTree{constructor(e,n,s){this.tree=e,this.overlay=n,this.parser=s}static get(e){return e&&e.props&&e.props[NodeProp.mounted.id]}}const noProps=Object.create(null);class NodeType{constructor(e,n,s,o=0){this.name=e,this.props=n,this.id=s,this.flags=o}static define(e){let n=e.props&&e.props.length?Object.create(null):noProps,s=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),o=new NodeType(e.name||"",n,e.id,s);if(e.props){for(let l of e.props)if(Array.isArray(l)||(l=l(o)),l){if(l[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");n[l[0].id]=l[1]}}return o}prop(e){return this.props[e.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(e){if(typeof e=="string"){if(this.name==e)return!0;let n=this.prop(NodeProp.group);return n?n.indexOf(e)>-1:!1}return this.id==e}static match(e){let n=Object.create(null);for(let s in e)for(let o of s.split(" "))n[o]=e[s];return s=>{for(let o=s.prop(NodeProp.group),l=-1;l<(o?o.length:0);l++){let a=n[l<0?s.name:o[l]];if(a)return a}}}}NodeType.none=new NodeType("",Object.create(null),0,8);class NodeSet{constructor(e){this.types=e;for(let n=0;n0;for(let h=this.cursor(a|IterMode.IncludeAnonymous);;){let f=!1;if(h.from<=l&&h.to>=o&&(!c&&h.type.isAnonymous||n(h)!==!1)){if(h.firstChild())continue;f=!0}for(;f&&s&&(c||!h.type.isAnonymous)&&s(h),!h.nextSibling();){if(!h.parent())return;f=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let n in this.props)e.push([+n,this.props[n]]);return e}balance(e={}){return this.children.length<=8?this:balanceRange(NodeType.none,this.children,this.positions,0,this.children.length,0,this.length,(n,s,o)=>new Tree(this.type,n,s,o,this.propValues),e.makeTree||((n,s,o)=>new Tree(NodeType.none,n,s,o)))}static build(e){return buildTree(e)}}Tree.empty=new Tree(NodeType.none,[],[],0);class FlatBufferCursor{constructor(e,n){this.buffer=e,this.index=n}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new FlatBufferCursor(this.buffer,this.index)}}class TreeBuffer{constructor(e,n,s){this.buffer=e,this.length=n,this.set=s}get type(){return NodeType.none}toString(){let e=[];for(let n=0;n0));h=a[h+3]);return c}slice(e,n,s){let o=this.buffer,l=new Uint16Array(n-e),a=0;for(let c=e,h=0;c=e&&ne;case 1:return n<=e&&s>e;case 2:return s>e;case 4:return!0}}function resolveNode(r,e,n,s){for(var o;r.from==r.to||(n<1?r.from>=e:r.from>e)||(n>-1?r.to<=e:r.to0?c.length:-1;e!=f;e+=n){let u=c[e],d=h[e]+a.from;if(checkSide(o,s,d,d+u.length)){if(u instanceof TreeBuffer){if(l&IterMode.ExcludeBuffers)continue;let g=u.findChild(0,u.buffer.length,n,s-d,o);if(g>-1)return new BufferNode(new BufferContext(a,u,e,d),null,g)}else if(l&IterMode.IncludeAnonymous||!u.type.isAnonymous||hasChild(u)){let g;if(!(l&IterMode.IgnoreMounts)&&(g=MountedTree.get(u))&&!g.overlay)return new TreeNode(g.tree,d,e,a);let O=new TreeNode(u,d,e,a);return l&IterMode.IncludeAnonymous||!O.type.isAnonymous?O:O.nextChild(n<0?u.children.length-1:0,n,s,o)}}}if(l&IterMode.IncludeAnonymous||!a.type.isAnonymous||(a.index>=0?e=a.index+n:e=n<0?-1:a._parent._tree.children.length,a=a._parent,!a))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}enter(e,n,s=0){let o;if(!(s&IterMode.IgnoreOverlays)&&(o=MountedTree.get(this._tree))&&o.overlay){let l=e-this.from;for(let{from:a,to:c}of o.overlay)if((n>0?a<=l:a=l:c>l))return new TreeNode(o.tree,o.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,n,s)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function getChildren(r,e,n,s){let o=r.cursor(),l=[];if(!o.firstChild())return l;if(n!=null){for(let a=!1;!a;)if(a=o.type.is(n),!o.nextSibling())return l}for(;;){if(s!=null&&o.type.is(s))return l;if(o.type.is(e)&&l.push(o.node),!o.nextSibling())return s==null?l:[]}}function matchNodeContext(r,e,n=e.length-1){for(let s=r.parent;n>=0;s=s.parent){if(!s)return!1;if(!s.type.isAnonymous){if(e[n]&&e[n]!=s.name)return!1;n--}}return!0}class BufferContext{constructor(e,n,s,o){this.parent=e,this.buffer=n,this.index=s,this.start=o}}class BufferNode extends BaseNode{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(e,n,s){super(),this.context=e,this._parent=n,this.index=s,this.type=e.buffer.set.types[e.buffer.buffer[s]]}child(e,n,s){let{buffer:o}=this.context,l=o.findChild(this.index+4,o.buffer[this.index+3],e,n-this.context.start,s);return l<0?null:new BufferNode(this.context,this,l)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}enter(e,n,s=0){if(s&IterMode.ExcludeBuffers)return null;let{buffer:o}=this.context,l=o.findChild(this.index+4,o.buffer[this.index+3],n>0?1:-1,e-this.context.start,n);return l<0?null:new BufferNode(this.context,this,l)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:e}=this.context,n=e.buffer[this.index+3];return n<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new BufferNode(this.context,this._parent,n):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,n=this._parent?this._parent.index+4:0;return this.index==n?this.externalSibling(-1):new BufferNode(this.context,this._parent,e.findChild(n,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],n=[],{buffer:s}=this.context,o=this.index+4,l=s.buffer[this.index+3];if(l>o){let a=s.buffer[this.index+1];e.push(s.slice(o,l,a)),n.push(0)}return new Tree(this.type,e,n,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function iterStack(r){if(!r.length)return null;let e=0,n=r[0];for(let l=1;ln.from||a.to=e){let c=new TreeNode(a.tree,a.overlay[0].from+l.from,-1,l);(o||(o=[s])).push(resolveNode(c,e,n,!1))}}return o?iterStack(o):s}class TreeCursor{get name(){return this.type.name}constructor(e,n=0){if(this.mode=n,this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,e instanceof TreeNode)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let s=e._parent;s;s=s._parent)this.stack.unshift(s.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return e?(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0):!1}yieldBuf(e,n){this.index=e;let{start:s,buffer:o}=this.buffer;return this.type=n||o.set.types[o.buffer[e]],this.from=s+o.buffer[e+1],this.to=s+o.buffer[e+2],!0}yield(e){return e?e instanceof TreeNode?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,n,s){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,n,s,this.mode));let{buffer:o}=this.buffer,l=o.findChild(this.index+4,o.buffer[this.index+3],e,n-this.buffer.start,s);return l<0?!1:(this.stack.push(this.index),this.yieldBuf(l))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,n,s=this.mode){return this.buffer?s&IterMode.ExcludeBuffers?!1:this.enterChild(1,e,n):this.yield(this._tree.enter(e,n,s))}parent(){if(!this.buffer)return this.yieldNode(this.mode&IterMode.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&IterMode.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode)):!1;let{buffer:n}=this.buffer,s=this.stack.length-1;if(e<0){let o=s<0?0:this.stack[s]+4;if(this.index!=o)return this.yieldBuf(n.findChild(o,this.index,-1,0,4))}else{let o=n.buffer[this.index+3];if(o<(s<0?n.buffer.length:n.buffer[this.stack[s]+3]))return this.yieldBuf(o)}return s<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let n,s,{buffer:o}=this;if(o){if(e>0){if(this.index-1)for(let l=n+e,a=e<0?-1:s._tree.children.length;l!=a;l+=e){let c=s._tree.children[l];if(this.mode&IterMode.IncludeAnonymous||c instanceof TreeBuffer||!c.type.isAnonymous||hasChild(c))return!1}return!0}move(e,n){if(n&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,n=0){for(;(this.from==this.to||(n<1?this.from>=e:this.from>e)||(n>-1?this.to<=e:this.to=0;){for(let a=e;a;a=a._parent)if(a.index==o){if(o==this.index)return a;n=a,s=l+1;break e}o=this.stack[--l]}for(let o=s;o=0;l--){if(l<0)return matchNodeContext(this.node,e,o);let a=s[n.buffer[this.stack[l]]];if(!a.isAnonymous){if(e[o]&&e[o]!=a.name)return!1;o--}}return!0}}function hasChild(r){return r.children.some(e=>e instanceof TreeBuffer||!e.type.isAnonymous||hasChild(e))}function buildTree(r){var e;let{buffer:n,nodeSet:s,maxBufferLength:o=DefaultBufferLength,reused:l=[],minRepeatType:a=s.types.length}=r,c=Array.isArray(n)?new FlatBufferCursor(n,n.length):n,h=s.types,f=0,u=0;function d(v,Q,_,N,q,Y){let{id:z,start:L,end:H,size:G}=c,ee=u;for(;G<0;)if(c.next(),G==-1){let te=l[z];_.push(te),N.push(L-v);return}else if(G==-3){f=z;return}else if(G==-4){u=z;return}else throw new RangeError(`Unrecognized record size: ${G}`);let K=h[z],j,F,se=L-v;if(H-L<=o&&(F=b(c.pos-Q,q))){let te=new Uint16Array(F.size-F.skip),oe=c.pos-F.size,re=te.length;for(;c.pos>oe;)re=w(F.start,te,re);j=new TreeBuffer(te,H-F.start,s),se=F.start-v}else{let te=c.pos-G;c.next();let oe=[],re=[],fe=z>=a?z:-1,de=0,pe=H;for(;c.pos>te;)fe>=0&&c.id==fe&&c.size>=0?(c.end<=pe-o&&(m(oe,re,L,de,c.end,pe,fe,ee),de=oe.length,pe=c.end),c.next()):Y>2500?g(L,te,oe,re):d(L,te,oe,re,fe,Y+1);if(fe>=0&&de>0&&de-1&&de>0){let ce=O(K);j=balanceRange(K,oe,re,0,oe.length,0,H-L,ce,ce)}else j=S(K,oe,re,H-L,ee-H)}_.push(j),N.push(se)}function g(v,Q,_,N){let q=[],Y=0,z=-1;for(;c.pos>Q;){let{id:L,start:H,end:G,size:ee}=c;if(ee>4)c.next();else{if(z>-1&&H=0;G-=3)L[ee++]=q[G],L[ee++]=q[G+1]-H,L[ee++]=q[G+2]-H,L[ee++]=ee;_.push(new TreeBuffer(L,q[2]-H,s)),N.push(H-v)}}function O(v){return(Q,_,N)=>{let q=0,Y=Q.length-1,z,L;if(Y>=0&&(z=Q[Y])instanceof Tree){if(!Y&&z.type==v&&z.length==N)return z;(L=z.prop(NodeProp.lookAhead))&&(q=_[Y]+z.length+L)}return S(v,Q,_,N,q)}}function m(v,Q,_,N,q,Y,z,L){let H=[],G=[];for(;v.length>N;)H.push(v.pop()),G.push(Q.pop()+_-q);v.push(S(s.types[z],H,G,Y-q,L-Y)),Q.push(q-_)}function S(v,Q,_,N,q=0,Y){if(f){let z=[NodeProp.contextHash,f];Y=Y?[z].concat(Y):[z]}if(q>25){let z=[NodeProp.lookAhead,q];Y=Y?[z].concat(Y):[z]}return new Tree(v,Q,_,N,Y)}function b(v,Q){let _=c.fork(),N=0,q=0,Y=0,z=_.end-o,L={size:0,start:0,skip:0};e:for(let H=_.pos-v;_.pos>H;){let G=_.size;if(_.id==Q&&G>=0){L.size=N,L.start=q,L.skip=Y,Y+=4,N+=4,_.next();continue}let ee=_.pos-G;if(G<0||ee=a?4:0,j=_.start;for(_.next();_.pos>ee;){if(_.size<0)if(_.size==-3)K+=4;else break e;else _.id>=a&&(K+=4);_.next()}q=j,N+=G,Y+=K}return(Q<0||N==v)&&(L.size=N,L.start=q,L.skip=Y),L.size>4?L:void 0}function w(v,Q,_){let{id:N,start:q,end:Y,size:z}=c;if(c.next(),z>=0&&N4){let H=c.pos-(z-4);for(;c.pos>H;)_=w(v,Q,_)}Q[--_]=L,Q[--_]=Y-v,Q[--_]=q-v,Q[--_]=N}else z==-3?f=N:z==-4&&(u=N);return _}let P=[],$=[];for(;c.pos>0;)d(r.start||0,r.bufferStart||0,P,$,-1,0);let A=(e=r.length)!==null&&e!==void 0?e:P.length?$[0]+P[0].length:0;return new Tree(h[r.topID],P.reverse(),$.reverse(),A)}const nodeSizeCache=new WeakMap;function nodeSize(r,e){if(!r.isAnonymous||e instanceof TreeBuffer||e.type!=r)return 1;let n=nodeSizeCache.get(e);if(n==null){n=1;for(let s of e.children){if(s.type!=r||!(s instanceof Tree)){n=1;break}n+=nodeSize(r,s)}nodeSizeCache.set(e,n)}return n}function balanceRange(r,e,n,s,o,l,a,c,h){let f=0;for(let m=s;m=u)break;Q+=_}if($==A+1){if(Q>u){let _=m[A];O(_.children,_.positions,0,_.children.length,S[A]+P);continue}d.push(m[A])}else{let _=S[$-1]+m[$-1].length-v;d.push(balanceRange(r,m,S,A,$,v,_,null,h))}g.push(v+P-l)}}return O(e,n,s,o,0),(c||h)(d,g,a)}class NodeWeakMap{constructor(){this.map=new WeakMap}setBuffer(e,n,s){let o=this.map.get(e);o||this.map.set(e,o=new Map),o.set(n,s)}getBuffer(e,n){let s=this.map.get(e);return s&&s.get(n)}set(e,n){e instanceof BufferNode?this.setBuffer(e.context.buffer,e.index,n):e instanceof TreeNode&&this.map.set(e.tree,n)}get(e){return e instanceof BufferNode?this.getBuffer(e.context.buffer,e.index):e instanceof TreeNode?this.map.get(e.tree):void 0}cursorSet(e,n){e.buffer?this.setBuffer(e.buffer.buffer,e.index,n):this.map.set(e.tree,n)}cursorGet(e){return e.buffer?this.getBuffer(e.buffer.buffer,e.index):this.map.get(e.tree)}}class TreeFragment{constructor(e,n,s,o,l=!1,a=!1){this.from=e,this.to=n,this.tree=s,this.offset=o,this.open=(l?1:0)|(a?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,n=[],s=!1){let o=[new TreeFragment(0,e.length,e,0,!1,s)];for(let l of n)l.to>e.length&&o.push(l);return o}static applyChanges(e,n,s=128){if(!n.length)return e;let o=[],l=1,a=e.length?e[0]:null;for(let c=0,h=0,f=0;;c++){let u=c=s)for(;a&&a.from=g.from||d<=g.to||f){let O=Math.max(g.from,h)-f,m=Math.min(g.to,d)-f;g=O>=m?null:new TreeFragment(O,m,g.tree,g.offset+f,c>0,!!u)}if(g&&o.push(g),a.to>d)break;a=lnew Range(o.from,o.to)):[new Range(0,0)]:[new Range(0,e.length)],this.createParse(e,n||[],s)}parse(e,n,s){let o=this.startParse(e,n,s);for(;;){let l=o.advance();if(l)return l}}}class StringInput{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,n){return this.string.slice(e,n)}}new NodeProp({perNode:!0});var define_process_env_default={};class Stack{constructor(e,n,s,o,l,a,c,h,f,u=0,d){this.p=e,this.stack=n,this.state=s,this.reducePos=o,this.pos=l,this.score=a,this.buffer=c,this.bufferBase=h,this.curContext=f,this.lookAhead=u,this.parent=d}toString(){return`[${this.stack.filter((e,n)=>n%3==0).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(e,n,s=0){let o=e.parser.context;return new Stack(e,[],n,s,s,0,[],0,o?new StackContext(o,o.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(e,n){this.stack.push(this.state,n,this.bufferBase+this.buffer.length),this.state=e}reduce(e){var n;let s=e>>19,o=e&65535,{parser:l}=this.p;this.reducePos=2e3&&!(!((n=this.p.parser.nodeSet.types[o])===null||n===void 0)&&n.isAnonymous)&&(h==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=f):this.p.lastBigReductionSizec;)this.stack.pop();this.reduceContext(o,h)}storeNode(e,n,s,o=4,l=!1){if(e==0&&(!this.stack.length||this.stack[this.stack.length-1]0&&a.buffer[c-4]==0&&a.buffer[c-1]>-1){if(n==s)return;if(a.buffer[c-2]>=n){a.buffer[c-2]=s;return}}}if(!l||this.pos==s)this.buffer.push(e,n,s,o);else{let a=this.buffer.length;if(a>0&&this.buffer[a-4]!=0)for(;a>0&&this.buffer[a-2]>s;)this.buffer[a]=this.buffer[a-4],this.buffer[a+1]=this.buffer[a-3],this.buffer[a+2]=this.buffer[a-2],this.buffer[a+3]=this.buffer[a-1],a-=4,o>4&&(o-=4);this.buffer[a]=e,this.buffer[a+1]=n,this.buffer[a+2]=s,this.buffer[a+3]=o}}shift(e,n,s,o){if(e&131072)this.pushState(e&65535,this.pos);else if(e&262144)this.pos=o,this.shiftContext(n,s),n<=this.p.parser.maxNode&&this.buffer.push(n,s,o,4);else{let l=e,{parser:a}=this.p;(o>this.pos||n<=a.maxNode)&&(this.pos=o,a.stateFlag(l,1)||(this.reducePos=o)),this.pushState(l,s),this.shiftContext(n,s),n<=a.maxNode&&this.buffer.push(n,s,o,4)}}apply(e,n,s,o){e&65536?this.reduce(e):this.shift(e,n,s,o)}useNode(e,n){let s=this.p.reused.length-1;(s<0||this.p.reused[s]!=e)&&(this.p.reused.push(e),s++);let o=this.pos;this.reducePos=this.pos=o+e.length,this.pushState(n,o),this.buffer.push(s,o,this.reducePos,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,e,this,this.p.stream.reset(this.pos-e.length)))}split(){let e=this,n=e.buffer.length;for(;n>0&&e.buffer[n-2]>e.reducePos;)n-=4;let s=e.buffer.slice(n),o=e.bufferBase+n;for(;e&&o==e.bufferBase;)e=e.parent;return new Stack(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,s,o,this.curContext,this.lookAhead,e)}recoverByDelete(e,n){let s=e<=this.p.parser.maxNode;s&&this.storeNode(e,this.pos,n,4),this.storeNode(0,this.pos,n,s?8:4),this.pos=this.reducePos=n,this.score-=190}canShift(e){for(let n=new SimulatedStack(this);;){let s=this.p.parser.stateSlot(n.state,4)||this.p.parser.hasAction(n.state,e);if(s==0)return!1;if(!(s&65536))return!0;n.reduce(s)}}recoverByInsert(e){if(this.stack.length>=300)return[];let n=this.p.parser.nextStates(this.state);if(n.length>8||this.stack.length>=120){let o=[];for(let l=0,a;lh&1&&c==a)||o.push(n[l],a)}n=o}let s=[];for(let o=0;o>19,o=n&65535,l=this.stack.length-s*3;if(l<0||e.getGoto(this.stack[l],o,!1)<0){let a=this.findForcedReduction();if(a==null)return!1;n=a}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(n),!0}findForcedReduction(){let{parser:e}=this.p,n=[],s=(o,l)=>{if(!n.includes(o))return n.push(o),e.allActions(o,a=>{if(!(a&393216))if(a&65536){let c=(a>>19)-l;if(c>1){let h=a&65535,f=this.stack.length-c*3;if(f>=0&&e.getGoto(this.stack[f],h,!1)>=0)return c<<19|65536|h}}else{let c=s(a,l+1);if(c!=null)return c}})};return s(this.state,0)}forceAll(){for(;!this.p.parser.stateFlag(this.state,2);)if(!this.forceReduce()){this.storeNode(0,this.pos,this.pos,4,!0);break}return this}get deadEnd(){if(this.stack.length!=3)return!1;let{parser:e}=this.p;return e.data[e.stateSlot(this.state,1)]==65535&&!e.stateSlot(this.state,4)}restart(){this.storeNode(0,this.pos,this.pos,4,!0),this.state=this.stack[0],this.stack.length=0}sameState(e){if(this.state!=e.state||this.stack.length!=e.stack.length)return!1;for(let n=0;nthis.lookAhead&&(this.emitLookAhead(),this.lookAhead=e)}close(){this.curContext&&this.curContext.tracker.strict&&this.emitContext(),this.lookAhead>0&&this.emitLookAhead()}}class StackContext{constructor(e,n){this.tracker=e,this.context=n,this.hash=e.strict?e.hash(n):0}}class SimulatedStack{constructor(e){this.start=e,this.state=e.state,this.stack=e.stack,this.base=this.stack.length}reduce(e){let n=e&65535,s=e>>19;s==0?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(s-1)*3;let o=this.start.p.parser.getGoto(this.stack[this.base-3],n,!0);this.state=o}}class StackBufferCursor{constructor(e,n,s){this.stack=e,this.pos=n,this.index=s,this.buffer=e.buffer,this.index==0&&this.maybeNext()}static create(e,n=e.bufferBase+e.buffer.length){return new StackBufferCursor(e,n,n-e.bufferBase)}maybeNext(){let e=this.stack.parent;e!=null&&(this.index=this.stack.bufferBase-e.bufferBase,this.stack=e,this.buffer=e.buffer)}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}next(){this.index-=4,this.pos-=4,this.index==0&&this.maybeNext()}fork(){return new StackBufferCursor(this.stack,this.pos,this.index)}}function decodeArray(r,e=Uint16Array){if(typeof r!="string")return r;let n=null;for(let s=0,o=0;s=92&&a--,a>=34&&a--;let h=a-32;if(h>=46&&(h-=46,c=!0),l+=h,c)break;l*=46}n?n[o++]=l:n=new e(l)}return n}class CachedToken{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}}const nullToken=new CachedToken;class InputStream{constructor(e,n){this.input=e,this.ranges=n,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=nullToken,this.rangeIndex=0,this.pos=this.chunkPos=n[0].from,this.range=n[0],this.end=n[n.length-1].to,this.readNext()}resolveOffset(e,n){let s=this.range,o=this.rangeIndex,l=this.pos+e;for(;ls.to:l>=s.to;){if(o==this.ranges.length-1)return null;let a=this.ranges[++o];l+=a.from-s.to,s=a}return l}clipPos(e){if(e>=this.range.from&&ee)return Math.max(e,n.from);return this.end}peek(e){let n=this.chunkOff+e,s,o;if(n>=0&&n=this.chunk2Pos&&sc.to&&(this.chunk2=this.chunk2.slice(0,c.to-s)),o=this.chunk2.charCodeAt(0)}}return s>=this.token.lookAhead&&(this.token.lookAhead=s+1),o}acceptToken(e,n=0){let s=n?this.resolveOffset(n,-1):this.pos;if(s==null||s=this.chunk2Pos&&this.posthis.range.to?e.slice(0,this.range.to-this.pos):e,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?this.next=-1:this.next=this.chunk.charCodeAt(this.chunkOff)}advance(e=1){for(this.chunkOff+=e;this.pos+e>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();e-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=e,this.pos>=this.token.lookAhead&&(this.token.lookAhead=this.pos+1),this.readNext()}setDone(){return this.pos=this.chunkPos=this.end,this.range=this.ranges[this.rangeIndex=this.ranges.length-1],this.chunk="",this.next=-1}reset(e,n){if(n?(this.token=n,n.start=e,n.lookAhead=e+1,n.value=n.extended=-1):this.token=nullToken,this.pos!=e){if(this.pos=e,e==this.end)return this.setDone(),this;for(;e=this.range.to;)this.range=this.ranges[++this.rangeIndex];e>=this.chunkPos&&e=this.chunkPos&&n<=this.chunkPos+this.chunk.length)return this.chunk.slice(e-this.chunkPos,n-this.chunkPos);if(e>=this.chunk2Pos&&n<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(e-this.chunk2Pos,n-this.chunk2Pos);if(e>=this.range.from&&n<=this.range.to)return this.input.read(e,n);let s="";for(let o of this.ranges){if(o.from>=n)break;o.to>e&&(s+=this.input.read(Math.max(o.from,e),Math.min(o.to,n)))}return s}}class TokenGroup{constructor(e,n){this.data=e,this.id=n}token(e,n){let{parser:s}=n.p;readToken(this.data,e,n,this.id,s.data,s.tokenPrecTable)}}TokenGroup.prototype.contextual=TokenGroup.prototype.fallback=TokenGroup.prototype.extend=!1;class LocalTokenGroup{constructor(e,n,s){this.precTable=n,this.elseToken=s,this.data=typeof e=="string"?decodeArray(e):e}token(e,n){let s=e.pos,o=0;for(;;){let l=e.next<0,a=e.resolveOffset(1,1);if(readToken(this.data,e,n,0,this.data,this.precTable),e.token.value>-1)break;if(this.elseToken==null)return;if(l||o++,a==null)break;e.reset(a,e.token)}o&&(e.reset(s,e.token),e.acceptToken(this.elseToken,o))}}LocalTokenGroup.prototype.contextual=TokenGroup.prototype.fallback=TokenGroup.prototype.extend=!1;class ExternalTokenizer{constructor(e,n={}){this.token=e,this.contextual=!!n.contextual,this.fallback=!!n.fallback,this.extend=!!n.extend}}function readToken(r,e,n,s,o,l){let a=0,c=1<0){let m=r[O];if(h.allows(m)&&(e.token.value==-1||e.token.value==m||overrides(m,e.token.value,o,l))){e.acceptToken(m);break}}let u=e.next,d=0,g=r[a+2];if(e.next<0&&g>d&&r[f+g*3-3]==65535){a=r[f+g*3-1];continue e}for(;d>1,m=f+O+(O<<1),S=r[m],b=r[m+1]||65536;if(u=b)d=O+1;else{a=r[m+2],e.advance();continue e}}break}}function findOffset(r,e,n){for(let s=e,o;(o=r[s])!=65535;s++)if(o==n)return s-e;return-1}function overrides(r,e,n,s){let o=findOffset(n,s,e);return o<0||findOffset(n,s,r)e)&&!s.type.isError)return n<0?Math.max(0,Math.min(s.to-1,e-25)):Math.min(r.length,Math.max(s.from+1,e+25));if(n<0?s.prevSibling():s.nextSibling())break;if(!s.parent())return n<0?0:r.length}}class FragmentCursor{constructor(e,n){this.fragments=e,this.nodeSet=n,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.nextFragment()}nextFragment(){let e=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(e){for(this.safeFrom=e.openStart?cutAt(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?cutAt(e.tree,e.to+e.offset,-1)-e.offset:e.to;this.trees.length;)this.trees.pop(),this.start.pop(),this.index.pop();this.trees.push(e.tree),this.start.push(-e.offset),this.index.push(0),this.nextStart=this.safeFrom}else this.nextStart=1e9}nodeAt(e){if(ee)return this.nextStart=a,null;if(l instanceof Tree){if(a==e){if(a=Math.max(this.safeFrom,e)&&(this.trees.push(l),this.start.push(a),this.index.push(0))}else this.index[n]++,this.nextStart=a+l.length}}}class TokenCache{constructor(e,n){this.stream=n,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(s=>new CachedToken)}getActions(e){let n=0,s=null,{parser:o}=e.p,{tokenizers:l}=o,a=o.stateSlot(e.state,3),c=e.curContext?e.curContext.hash:0,h=0;for(let f=0;fd.end+25&&(h=Math.max(d.lookAhead,h)),d.value!=0)){let g=n;if(d.extended>-1&&(n=this.addActions(e,d.extended,d.end,n)),n=this.addActions(e,d.value,d.end,n),!u.extend&&(s=d,n>g))break}}for(;this.actions.length>n;)this.actions.pop();return h&&e.setLookAhead(h),!s&&e.pos==this.stream.end&&(s=new CachedToken,s.value=e.p.parser.eofTerm,s.start=s.end=e.pos,n=this.addActions(e,s.value,s.end,n)),this.mainToken=s,this.actions}getMainToken(e){if(this.mainToken)return this.mainToken;let n=new CachedToken,{pos:s,p:o}=e;return n.start=s,n.end=Math.min(s+1,o.stream.end),n.value=s==o.stream.end?o.parser.eofTerm:0,n}updateCachedToken(e,n,s){let o=this.stream.clipPos(s.pos);if(n.token(this.stream.reset(o,e),s),e.value>-1){let{parser:l}=s.p;for(let a=0;a=0&&s.p.parser.dialect.allows(c>>1)){c&1?e.extended=c>>1:e.value=c>>1;break}}}else e.value=0,e.end=this.stream.clipPos(o+1)}putAction(e,n,s,o){for(let l=0;le.bufferLength*4?new FragmentCursor(s,e.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let e=this.stacks,n=this.minStackPos,s=this.stacks=[],o,l;if(this.bigReductionCount>300&&e.length==1){let[a]=e;for(;a.forceReduce()&&a.stack.length&&a.stack[a.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let a=0;an)s.push(c);else{if(this.advanceStack(c,s,e))continue;{o||(o=[],l=[]),o.push(c);let h=this.tokens.getMainToken(c);l.push(h.value,h.end)}}break}}if(!s.length){let a=o&&findFinished(o);if(a)return verbose&&console.log("Finish with "+this.stackID(a)),this.stackToTree(a);if(this.parser.strict)throw verbose&&o&&console.log("Stuck with token "+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):"none")),new SyntaxError("No parse at "+n);this.recovering||(this.recovering=5)}if(this.recovering&&o){let a=this.stoppedAt!=null&&o[0].pos>this.stoppedAt?o[0]:this.runRecovery(o,l,s);if(a)return verbose&&console.log("Force-finish "+this.stackID(a)),this.stackToTree(a.forceAll())}if(this.recovering){let a=this.recovering==1?1:this.recovering*3;if(s.length>a)for(s.sort((c,h)=>h.score-c.score);s.length>a;)s.pop();s.some(c=>c.reducePos>n)&&this.recovering--}else if(s.length>1){e:for(let a=0;a500&&f.buffer.length>500)if((c.score-f.score||c.buffer.length-f.buffer.length)>0)s.splice(h--,1);else{s.splice(a--,1);continue e}}}s.length>12&&s.splice(12,s.length-12)}this.minStackPos=s[0].pos;for(let a=1;a ":"";if(this.stoppedAt!=null&&o>this.stoppedAt)return e.forceReduce()?e:null;if(this.fragments){let f=e.curContext&&e.curContext.tracker.strict,u=f?e.curContext.hash:0;for(let d=this.fragments.nodeAt(o);d;){let g=this.parser.nodeSet.types[d.type.id]==d.type?l.getGoto(e.state,d.type.id):-1;if(g>-1&&d.length&&(!f||(d.prop(NodeProp.contextHash)||0)==u))return e.useNode(d,g),verbose&&console.log(a+this.stackID(e)+` (via reuse of ${l.getName(d.type.id)})`),!0;if(!(d instanceof Tree)||d.children.length==0||d.positions[0]>0)break;let O=d.children[0];if(O instanceof Tree&&d.positions[0]==0)d=O;else break}}let c=l.stateSlot(e.state,4);if(c>0)return e.reduce(c),verbose&&console.log(a+this.stackID(e)+` (via always-reduce ${l.getName(c&65535)})`),!0;if(e.stack.length>=8400)for(;e.stack.length>6e3&&e.forceReduce(););let h=this.tokens.getActions(e);for(let f=0;fo?n.push(m):s.push(m)}return!1}advanceFully(e,n){let s=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>s)return pushStackDedup(e,n),!0}}runRecovery(e,n,s){let o=null,l=!1;for(let a=0;a ":"";if(c.deadEnd&&(l||(l=!0,c.restart(),verbose&&console.log(u+this.stackID(c)+" (restarted)"),this.advanceFully(c,s))))continue;let d=c.split(),g=u;for(let O=0;d.forceReduce()&&O<10&&(verbose&&console.log(g+this.stackID(d)+" (via force-reduce)"),!this.advanceFully(d,s));O++)verbose&&(g=this.stackID(d)+" -> ");for(let O of c.recoverByInsert(h))verbose&&console.log(u+this.stackID(O)+" (via recover-insert)"),this.advanceFully(O,s);this.stream.end>c.pos?(f==c.pos&&(f++,h=0),c.recoverByDelete(h,f),verbose&&console.log(u+this.stackID(c)+` (via recover-delete ${this.parser.getName(h)})`),pushStackDedup(c,s)):(!o||o.scorer;class ContextTracker{constructor(e){this.start=e.start,this.shift=e.shift||id,this.reduce=e.reduce||id,this.reuse=e.reuse||id,this.hash=e.hash||(()=>0),this.strict=e.strict!==!1}}class LRParser extends Parser{constructor(e){if(super(),this.wrappers=[],e.version!=14)throw new RangeError(`Parser version (${e.version}) doesn't match runtime version (14)`);let n=e.nodeNames.split(" ");this.minRepeatTerm=n.length;for(let c=0;ce.topRules[c][1]),o=[];for(let c=0;c=0)l(u,h,c[f++]);else{let d=c[f+-u];for(let g=-u;g>0;g--)l(c[f++],h,d);f++}}}this.nodeSet=new NodeSet(n.map((c,h)=>NodeType.define({name:h>=this.minRepeatTerm?void 0:c,id:h,props:o[h],top:s.indexOf(h)>-1,error:h==0,skipped:e.skippedNodes&&e.skippedNodes.indexOf(h)>-1}))),e.propSources&&(this.nodeSet=this.nodeSet.extend(...e.propSources)),this.strict=!1,this.bufferLength=DefaultBufferLength;let a=decodeArray(e.tokenData);this.context=e.context,this.specializerSpecs=e.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let c=0;ctypeof c=="number"?new TokenGroup(a,c):c),this.topRules=e.topRules,this.dialects=e.dialects||{},this.dynamicPrecedences=e.dynamicPrecedences||null,this.tokenPrecTable=e.tokenPrec,this.termNames=e.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(e,n,s){let o=new Parse(this,e,n,s);for(let l of this.wrappers)o=l(o,e,n,s);return o}getGoto(e,n,s=!1){let o=this.goto;if(n>=o[0])return-1;for(let l=o[n+1];;){let a=o[l++],c=a&1,h=o[l++];if(c&&s)return h;for(let f=l+(a>>1);l0}validAction(e,n){return!!this.allActions(e,s=>s==n?!0:null)}allActions(e,n){let s=this.stateSlot(e,4),o=s?n(s):void 0;for(let l=this.stateSlot(e,1);o==null;l+=3){if(this.data[l]==65535)if(this.data[l+1]==1)l=pair(this.data,l+2);else break;o=n(pair(this.data,l+1))}return o}nextStates(e){let n=[];for(let s=this.stateSlot(e,1);;s+=3){if(this.data[s]==65535)if(this.data[s+1]==1)s=pair(this.data,s+2);else break;if(!(this.data[s+2]&1)){let o=this.data[s+1];n.some((l,a)=>a&1&&l==o)||n.push(this.data[s],o)}}return n}configure(e){let n=Object.assign(Object.create(LRParser.prototype),this);if(e.props&&(n.nodeSet=this.nodeSet.extend(...e.props)),e.top){let s=this.topRules[e.top];if(!s)throw new RangeError(`Invalid top rule name ${e.top}`);n.top=s}return e.tokenizers&&(n.tokenizers=this.tokenizers.map(s=>{let o=e.tokenizers.find(l=>l.from==s);return o?o.to:s})),e.specializers&&(n.specializers=this.specializers.slice(),n.specializerSpecs=this.specializerSpecs.map((s,o)=>{let l=e.specializers.find(c=>c.from==s.external);if(!l)return s;let a=Object.assign(Object.assign({},s),{external:l.to});return n.specializers[o]=getSpecializer(a),a})),e.contextTracker&&(n.context=e.contextTracker),e.dialect&&(n.dialect=this.parseDialect(e.dialect)),e.strict!=null&&(n.strict=e.strict),e.wrap&&(n.wrappers=n.wrappers.concat(e.wrap)),e.bufferLength!=null&&(n.bufferLength=e.bufferLength),n}hasWrappers(){return this.wrappers.length>0}getName(e){return this.termNames?this.termNames[e]:String(e<=this.maxNode&&this.nodeSet.types[e].name||e)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(e){let n=this.dynamicPrecedences;return n==null?0:n[e]||0}parseDialect(e){let n=Object.keys(this.dialects),s=n.map(()=>!1);if(e)for(let l of e.split(" ")){let a=n.indexOf(l);a>=0&&(s[a]=!0)}let o=null;for(let l=0;ls)&&n.p.parser.stateFlag(n.state,2)&&(!e||e.scorer.external(n,s)<<1|e}return r.get}let nextTagID=0;class Tag{constructor(e,n,s){this.set=e,this.base=n,this.modified=s,this.id=nextTagID++}static define(e){if(e!=null&&e.base)throw new Error("Can not derive from a modified tag");let n=new Tag([],null,[]);if(n.set.push(n),e)for(let s of e.set)n.set.push(s);return n}static defineModifier(){let e=new Modifier;return n=>n.modified.indexOf(e)>-1?n:Modifier.get(n.base||n,n.modified.concat(e).sort((s,o)=>s.id-o.id))}}let nextModifierID=0;class Modifier{constructor(){this.instances=[],this.id=nextModifierID++}static get(e,n){if(!n.length)return e;let s=n[0].instances.find(c=>c.base==e&&sameArray(n,c.modified));if(s)return s;let o=[],l=new Tag(o,e,n);for(let c of n)c.instances.push(l);let a=powerSet(n);for(let c of e.set)if(!c.modified.length)for(let h of a)o.push(Modifier.get(c,h));return l}}function sameArray(r,e){return r.length==e.length&&r.every((n,s)=>n==e[s])}function powerSet(r){let e=[[]];for(let n=0;ns.length-n.length)}function styleTags(r){let e=Object.create(null);for(let n in r){let s=r[n];Array.isArray(s)||(s=[s]);for(let o of n.split(" "))if(o){let l=[],a=2,c=o;for(let d=0;;){if(c=="..."&&d>0&&d+3==o.length){a=1;break}let g=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(c);if(!g)throw new RangeError("Invalid path: "+o);if(l.push(g[0]=="*"?"":g[0][0]=='"'?JSON.parse(g[0]):g[0]),d+=g[0].length,d==o.length)break;let O=o[d++];if(d==o.length&&O=="!"){a=0;break}if(O!="/")throw new RangeError("Invalid path: "+o);c=o.slice(d)}let h=l.length-1,f=l[h];if(!f)throw new RangeError("Invalid path: "+o);let u=new Rule(s,a,h>0?l.slice(0,h):null);e[f]=u.sort(e[f])}}return ruleNodeProp.add(e)}const ruleNodeProp=new NodeProp;class Rule{constructor(e,n,s,o){this.tags=e,this.mode=n,this.context=s,this.next=o}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth{let a=o;for(let c of l)for(let h of c.set){let f=n[h.id];if(f){a=a?a+" "+f:f;break}}return a},scope:s}}function highlightTags(r,e){let n=null;for(let s of r){let o=s.style(e);o&&(n=n?n+" "+o:o)}return n}function highlightTree(r,e,n,s=0,o=r.length){let l=new HighlightBuilder(s,Array.isArray(e)?e:[e],n);l.highlightRange(r.cursor(),s,o,"",l.highlighters),l.flush(o)}class HighlightBuilder{constructor(e,n,s){this.at=e,this.highlighters=n,this.span=s,this.class=""}startSpan(e,n){n!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=n)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,n,s,o,l){let{type:a,from:c,to:h}=e;if(c>=s||h<=n)return;a.isTop&&(l=this.highlighters.filter(O=>!O.scope||O.scope(a)));let f=o,u=getStyleTags(e)||Rule.empty,d=highlightTags(l,u.tags);if(d&&(f&&(f+=" "),f+=d,u.mode==1&&(o+=(o?" ":"")+d)),this.startSpan(Math.max(n,c),f),u.opaque)return;let g=e.tree&&e.tree.prop(NodeProp.mounted);if(g&&g.overlay){let O=e.node.enter(g.overlay[0].from+c,1),m=this.highlighters.filter(b=>!b.scope||b.scope(g.tree.type)),S=e.firstChild();for(let b=0,w=c;;b++){let P=b=$||!e.nextSibling())););if(!P||$>s)break;w=P.to+c,w>n&&(this.highlightRange(O.cursor(),Math.max(n,P.from+c),Math.min(s,w),"",m),this.startSpan(Math.min(s,w),f))}S&&e.parent()}else if(e.firstChild()){g&&(o="");do if(!(e.to<=n)){if(e.from>=s)break;this.highlightRange(e,n,s,o,l),this.startSpan(Math.min(s,e.to),f)}while(e.nextSibling());e.parent()}}}function getStyleTags(r){let e=r.type.prop(ruleNodeProp);for(;e&&e.context&&!r.matchContext(e.context);)e=e.next;return e||null}const t=Tag.define,comment=t(),name=t(),typeName=t(name),propertyName=t(name),literal=t(),string=t(literal),number=t(literal),content=t(),heading=t(content),keyword=t(),operator=t(),punctuation=t(),bracket=t(punctuation),meta=t(),tags={comment,lineComment:t(comment),blockComment:t(comment),docComment:t(comment),name,variableName:t(name),typeName,tagName:t(typeName),propertyName,attributeName:t(propertyName),className:t(name),labelName:t(name),namespace:t(name),macroName:t(name),literal,string,docString:t(string),character:t(string),attributeValue:t(string),number,integer:t(number),float:t(number),bool:t(literal),regexp:t(literal),escape:t(literal),color:t(literal),url:t(literal),keyword,self:t(keyword),null:t(keyword),atom:t(keyword),unit:t(keyword),modifier:t(keyword),operatorKeyword:t(keyword),controlKeyword:t(keyword),definitionKeyword:t(keyword),moduleKeyword:t(keyword),operator,derefOperator:t(operator),arithmeticOperator:t(operator),logicOperator:t(operator),bitwiseOperator:t(operator),compareOperator:t(operator),updateOperator:t(operator),definitionOperator:t(operator),typeOperator:t(operator),controlOperator:t(operator),punctuation,separator:t(punctuation),bracket,angleBracket:t(bracket),squareBracket:t(bracket),paren:t(bracket),brace:t(bracket),content,heading,heading1:t(heading),heading2:t(heading),heading3:t(heading),heading4:t(heading),heading5:t(heading),heading6:t(heading),contentSeparator:t(content),list:t(content),quote:t(content),emphasis:t(content),strong:t(content),link:t(content),monospace:t(content),strikethrough:t(content),inserted:t(),deleted:t(),changed:t(),invalid:t(),meta,documentMeta:t(meta),annotation:t(meta),processingInstruction:t(meta),definition:Tag.defineModifier(),constant:Tag.defineModifier(),function:Tag.defineModifier(),standard:Tag.defineModifier(),local:Tag.defineModifier(),special:Tag.defineModifier()};tagHighlighter([{tag:tags.link,class:"tok-link"},{tag:tags.heading,class:"tok-heading"},{tag:tags.emphasis,class:"tok-emphasis"},{tag:tags.strong,class:"tok-strong"},{tag:tags.keyword,class:"tok-keyword"},{tag:tags.atom,class:"tok-atom"},{tag:tags.bool,class:"tok-bool"},{tag:tags.url,class:"tok-url"},{tag:tags.labelName,class:"tok-labelName"},{tag:tags.inserted,class:"tok-inserted"},{tag:tags.deleted,class:"tok-deleted"},{tag:tags.literal,class:"tok-literal"},{tag:tags.string,class:"tok-string"},{tag:tags.number,class:"tok-number"},{tag:[tags.regexp,tags.escape,tags.special(tags.string)],class:"tok-string2"},{tag:tags.variableName,class:"tok-variableName"},{tag:tags.local(tags.variableName),class:"tok-variableName tok-local"},{tag:tags.definition(tags.variableName),class:"tok-variableName tok-definition"},{tag:tags.special(tags.variableName),class:"tok-variableName2"},{tag:tags.definition(tags.propertyName),class:"tok-propertyName tok-definition"},{tag:tags.typeName,class:"tok-typeName"},{tag:tags.namespace,class:"tok-namespace"},{tag:tags.className,class:"tok-className"},{tag:tags.macroName,class:"tok-macroName"},{tag:tags.propertyName,class:"tok-propertyName"},{tag:tags.operator,class:"tok-operator"},{tag:tags.comment,class:"tok-comment"},{tag:tags.meta,class:"tok-meta"},{tag:tags.invalid,class:"tok-invalid"},{tag:tags.punctuation,class:"tok-punctuation"}]);const noSemi=312,incdec=1,incdecPrefix=2,questionDot=3,JSXStartTag=4,insertSemi=313,spaces=315,newline=316,LineComment=5,BlockComment=6,Dialect_jsx=0,space=[9,10,11,12,13,32,133,160,5760,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8232,8233,8239,8287,12288],braceR=125,semicolon=59,slash=47,star=42,plus=43,minus=45,lt=60,comma=44,question=63,dot=46,trackNewline=new ContextTracker({start:!1,shift(r,e){return e==LineComment||e==BlockComment||e==spaces?r:e==newline},strict:!1}),insertSemicolon=new ExternalTokenizer((r,e)=>{let{next:n}=r;(n==braceR||n==-1||e.context)&&r.acceptToken(insertSemi)},{contextual:!0,fallback:!0}),noSemicolon=new ExternalTokenizer((r,e)=>{let{next:n}=r,s;space.indexOf(n)>-1||n==slash&&((s=r.peek(1))==slash||s==star)||n!=braceR&&n!=semicolon&&n!=-1&&!e.context&&r.acceptToken(noSemi)},{contextual:!0}),operatorToken=new ExternalTokenizer((r,e)=>{let{next:n}=r;if(n==plus||n==minus){if(r.advance(),n==r.next){r.advance();let s=!e.context&&e.canShift(incdec);r.acceptToken(s?incdec:incdecPrefix)}}else n==question&&r.peek(1)==dot&&(r.advance(),r.advance(),(r.next<48||r.next>57)&&r.acceptToken(questionDot))},{contextual:!0});function identifierChar(r,e){return r>=65&&r<=90||r>=97&&r<=122||r==95||r>=192||!e&&r>=48&&r<=57}const jsx=new ExternalTokenizer((r,e)=>{if(r.next!=lt||!e.dialectEnabled(Dialect_jsx)||(r.advance(),r.next==slash))return;let n=0;for(;space.indexOf(r.next)>-1;)r.advance(),n++;if(identifierChar(r.next,!0)){for(r.advance(),n++;identifierChar(r.next,!1);)r.advance(),n++;for(;space.indexOf(r.next)>-1;)r.advance(),n++;if(r.next==comma)return;for(let s=0;;s++){if(s==7){if(!identifierChar(r.next,!0))return;break}if(r.next!="extends".charCodeAt(s))break;r.advance(),n++}}r.acceptToken(JSXStartTag,-n)}),jsHighlight=styleTags({"get set async static":tags.modifier,"for while do if else switch try catch finally return throw break continue default case":tags.controlKeyword,"in of await yield void typeof delete instanceof":tags.operatorKeyword,"let var const using function class extends":tags.definitionKeyword,"import export from":tags.moduleKeyword,"with debugger as new":tags.keyword,TemplateString:tags.special(tags.string),super:tags.atom,BooleanLiteral:tags.bool,this:tags.self,null:tags.null,Star:tags.modifier,VariableName:tags.variableName,"CallExpression/VariableName TaggedTemplateExpression/VariableName":tags.function(tags.variableName),VariableDefinition:tags.definition(tags.variableName),Label:tags.labelName,PropertyName:tags.propertyName,PrivatePropertyName:tags.special(tags.propertyName),"CallExpression/MemberExpression/PropertyName":tags.function(tags.propertyName),"FunctionDeclaration/VariableDefinition":tags.function(tags.definition(tags.variableName)),"ClassDeclaration/VariableDefinition":tags.definition(tags.className),PropertyDefinition:tags.definition(tags.propertyName),PrivatePropertyDefinition:tags.definition(tags.special(tags.propertyName)),UpdateOp:tags.updateOperator,"LineComment Hashbang":tags.lineComment,BlockComment:tags.blockComment,Number:tags.number,String:tags.string,Escape:tags.escape,ArithOp:tags.arithmeticOperator,LogicOp:tags.logicOperator,BitOp:tags.bitwiseOperator,CompareOp:tags.compareOperator,RegExp:tags.regexp,Equals:tags.definitionOperator,Arrow:tags.function(tags.punctuation),": Spread":tags.punctuation,"( )":tags.paren,"[ ]":tags.squareBracket,"{ }":tags.brace,"InterpolationStart InterpolationEnd":tags.special(tags.brace),".":tags.derefOperator,", ;":tags.separator,"@":tags.meta,TypeName:tags.typeName,TypeDefinition:tags.definition(tags.typeName),"type enum interface implements namespace module declare":tags.definitionKeyword,"abstract global Privacy readonly override":tags.modifier,"is keyof unique infer":tags.operatorKeyword,JSXAttributeValue:tags.attributeValue,JSXText:tags.content,"JSXStartTag JSXStartCloseTag JSXSelfCloseEndTag JSXEndTag":tags.angleBracket,"JSXIdentifier JSXNameSpacedName":tags.tagName,"JSXAttribute/JSXIdentifier JSXAttribute/JSXNameSpacedName":tags.attributeName,"JSXBuiltin/JSXIdentifier":tags.standard(tags.tagName)}),spec_identifier={__proto__:null,export:20,as:25,from:33,default:36,async:41,function:42,extends:54,this:58,true:66,false:66,null:78,void:82,typeof:86,super:102,new:136,delete:148,yield:157,await:161,class:166,public:229,private:229,protected:229,readonly:231,instanceof:250,satisfies:253,in:254,const:256,import:290,keyof:345,unique:349,infer:355,is:391,abstract:411,implements:413,type:415,let:418,var:420,using:423,interface:429,enum:433,namespace:439,module:441,declare:445,global:449,for:468,of:477,while:480,with:484,do:488,if:492,else:494,switch:498,case:504,try:510,catch:514,finally:518,return:522,throw:526,break:530,continue:534,debugger:538},spec_word={__proto__:null,async:123,get:125,set:127,declare:189,public:191,private:191,protected:191,static:193,abstract:195,override:197,readonly:203,accessor:205,new:395},spec_LessThan={__proto__:null,"<":187},parser=LRParser.deserialize({version:14,states:"$@QO%TQ^OOO%[Q^OOO'_Q`OOP(lOWOOO*zQ?NdO'#CiO+RO!bO'#CjO+aO#tO'#CjO+oO!0LbO'#D^O.QQ^O'#DdO.bQ^O'#DoO%[Q^O'#DwO0fQ^O'#EPOOQ?Mr'#EX'#EXO1PQWO'#EUOOQO'#Em'#EmOOQO'#Ih'#IhO1XQWO'#GpO1dQWO'#ElO1iQWO'#ElO3hQ?NdO'#JmO6[Q?NdO'#JnO6uQWO'#F[O6zQ&jO'#FsOOQ?Mr'#Fe'#FeO7VO,YO'#FeO7eQ7[O'#FzO9RQWO'#FyOOQ?Mr'#Jn'#JnOOQ?Mp'#Jm'#JmO9WQWO'#GtOOQU'#KZ'#KZO9cQWO'#IUO9hQ?MxO'#IVOOQU'#JZ'#JZOOQU'#IZ'#IZQ`Q^OOO`Q^OOO9pQMnO'#DsO9wQ^O'#D{O:OQ^O'#D}O9^QWO'#GpO:VQ7[O'#CoO:eQWO'#EkO:pQWO'#EvO:uQ7[O'#FdO;dQWO'#GpOOQO'#K['#K[O;iQWO'#K[O;wQWO'#GxO;wQWO'#GyO;wQWO'#G{O9^QWO'#HOOVQWO'#CeO>gQWO'#H_O>oQWO'#HeO>oQWO'#HgO`Q^O'#HiO>oQWO'#HkO>oQWO'#HnO>tQWO'#HtO>yQ?MyO'#HzO%[Q^O'#H|O?UQ?MyO'#IOO?aQ?MyO'#IQO9hQ?MxO'#ISO?lQ?NdO'#CiO@nQ`O'#DiQOQWOOO%[Q^O'#D}OAUQWO'#EQO:VQ7[O'#EkOAaQWO'#EkOAlQpO'#FdOOQU'#Cg'#CgOOQ?Mp'#Dn'#DnOOQ?Mp'#Jq'#JqO%[Q^O'#JqOOQO'#Jt'#JtOOQO'#Id'#IdOBlQ`O'#EdOOQ?Mp'#Ec'#EcOOQ?Mp'#Jx'#JxOChQ?NQO'#EdOCrQ`O'#ETOOQO'#Js'#JsODWQ`O'#JtOEeQ`O'#ETOCrQ`O'#EdPErO#@ItO'#CbPOOO)CDx)CDxOOOO'#I['#I[OE}O!bO,59UOOQ?Mr,59U,59UOOOO'#I]'#I]OF]O#tO,59UO%[Q^O'#D`OOOO'#I_'#I_OFkO!0LbO,59xOOQ?Mr,59x,59xOFyQ^O'#I`OG^QWO'#JoOI]QrO'#JoO+}Q^O'#JoOIdQWO,5:OOIzQWO'#EmOJXQWO'#KOOJdQWO'#J}OJdQWO'#J}OJlQWO,5;ZOJqQWO'#J|OOQ?Mv,5:Z,5:ZOJxQ^O,5:ZOLvQ?NdO,5:cOMgQWO,5:kONQQ?MxO'#J{ONXQWO'#JzO9WQWO'#JzONmQWO'#JzONuQWO,5;YONzQWO'#JzO!#PQrO'#JnOOQ?Mr'#Ci'#CiO%[Q^O'#EPO!#oQrO,5:pOOQQ'#Ju'#JuOOQO-EpOOQU'#Jc'#JcOOQU,5>q,5>qOOQU-EtQWO'#HTO9^QWO'#HVO!DgQWO'#HVO:VQ7[O'#HXO!DlQWO'#HXOOQU,5=m,5=mO!DqQWO'#HYO!ESQWO'#CoO!EXQWO,59PO!EcQWO,59PO!GhQ^O,59POOQU,59P,59PO!GxQ?MxO,59PO%[Q^O,59PO!JTQ^O'#HaOOQU'#Hb'#HbOOQU'#Hc'#HcO`Q^O,5=yO!JkQWO,5=yO`Q^O,5>PO`Q^O,5>RO!JpQWO,5>TO`Q^O,5>VO!JuQWO,5>YO!JzQ^O,5>`OOQU,5>f,5>fO%[Q^O,5>fO9hQ?MxO,5>hOOQU,5>j,5>jO# UQWO,5>jOOQU,5>l,5>lO# UQWO,5>lOOQU,5>n,5>nO# rQ`O'#D[O%[Q^O'#JqO# |Q`O'#JqO#!kQ`O'#DjO#!|Q`O'#DjO#%_Q^O'#DjO#%fQWO'#JpO#%nQWO,5:TO#%sQWO'#EqO#&RQWO'#KPO#&ZQWO,5;[O#&`Q`O'#DjO#&mQ`O'#ESOOQ?Mr,5:l,5:lO%[Q^O,5:lO#&tQWO,5:lO>tQWO,5;VO!A}Q`O,5;VO!BVQ7[O,5;VO:VQ7[O,5;VO#&|QWO,5@]O#'RQ(CYO,5:pOOQO-EzO+}Q^O,5>zOOQO,5?Q,5?QO#*ZQ^O'#I`OOQO-E<^-E<^O#*hQWO,5@ZO#*pQrO,5@ZO#*wQWO,5@iOOQ?Mr1G/j1G/jO%[Q^O,5@jO#+PQWO'#IfOOQO-EuQ?NdO1G0|O#>|Q?NdO1G0|O#AZQ07bO'#CiO#CUQ07bO1G1_O#C]Q07bO'#JnO#CpQ?NdO,5?WOOQ?Mp-EoQWO1G3oO$3VQ^O1G3qO$7ZQ^O'#HpOOQU1G3t1G3tO$7hQWO'#HvO>tQWO'#HxOOQU1G3z1G3zO$7pQ^O1G3zO9hQ?MxO1G4QOOQU1G4S1G4SOOQ?Mp'#G]'#G]O9hQ?MxO1G4UO9hQ?MxO1G4WO$;wQWO,5@]O!(oQ^O,5;]O9WQWO,5;]O>tQWO,5:UO!(oQ^O,5:UO!A}Q`O,5:UO$;|Q07bO,5:UOOQO,5;],5;]O$tQWO1G0qO!A}Q`O1G0qO!BVQ7[O1G0qOOQ?Mp1G5w1G5wO!ArQ?MxO1G0ZOOQO1G0j1G0jO%[Q^O1G0jO$=aQ?MxO1G0jO$=lQ?MxO1G0jO!A}Q`O1G0ZOCrQ`O1G0ZO$=zQ?MxO1G0jOOQO1G0Z1G0ZO$>`Q?NdO1G0jPOOO-EjQpO,5rQrO1G4fOOQO1G4l1G4lO%[Q^O,5>zO$>|QWO1G5uO$?UQWO1G6TO$?^QrO1G6UO9WQWO,5?QO$?hQ?NdO1G6RO%[Q^O1G6RO$?xQ?MxO1G6RO$@ZQWO1G6QO$@ZQWO1G6QO9WQWO1G6QO$@cQWO,5?TO9WQWO,5?TOOQO,5?T,5?TO$@wQWO,5?TO$(PQWO,5?TOOQO-E[OOQU,5>[,5>[O%[Q^O'#HqO%8mQWO'#HsOOQU,5>b,5>bO9WQWO,5>bOOQU,5>d,5>dOOQU7+)f7+)fOOQU7+)l7+)lOOQU7+)p7+)pOOQU7+)r7+)rO%8rQ`O1G5wO%9WQ07bO1G0wO%9bQWO1G0wOOQO1G/p1G/pO%9mQ07bO1G/pO>tQWO1G/pO!(oQ^O'#DjOOQO,5>{,5>{OOQO-E<_-E<_OOQO,5?R,5?ROOQO-EtQWO7+&]O!A}Q`O7+&]OOQO7+%u7+%uO$>`Q?NdO7+&UOOQO7+&U7+&UO%[Q^O7+&UO%9wQ?MxO7+&UO!ArQ?MxO7+%uO!A}Q`O7+%uO%:SQ?MxO7+&UO%:bQ?NdO7++mO%[Q^O7++mO%:rQWO7++lO%:rQWO7++lOOQO1G4o1G4oO9WQWO1G4oO%:zQWO1G4oOOQQ7+%z7+%zO#&wQWO<|O%[Q^O,5>|OOQO-E<`-E<`O%FwQWO1G5xOOQ?Mr<]OOQU,5>_,5>_O&8uQWO1G3|O9WQWO7+&cO!(oQ^O7+&cOOQO7+%[7+%[O&8zQ07bO1G6UO>tQWO7+%[OOQ?Mr<tQWO<`Q?NdO<pQ?NdO,5?_O&@xQ?NdO7+'zO&CWQrO1G4hO&CbQ07bO7+&^O&EcQ07bO,5=UO&GgQ07bO,5=WO&GwQ07bO,5=UO&HXQ07bO,5=WO&HiQ07bO,59rO&JlQ07bO,5tQWO7+)hO'(OQWO<`Q?NdOAN?[OOQOAN>{AN>{O%[Q^OAN?[OOQO<`Q?NdOG24vO#&wQWOLD,nOOQULD,nLD,nO!&_Q7[OLD,nO'5TQrOLD,nO'5[Q07bO7+'xO'6}Q07bO,5?]O'8}Q07bO,5?_O':}Q07bO7+'zO'kOh%VOk+aO![']O%f+`O~O!d+cOa(WX![(WX'u(WX!Y(WX~Oa%lO![XO'u%lO~Oh%VO!i%cO~Oh%VO!i%cO(O%eO~O!d#vO#h(tO~Ob+nO%g+oO(O+kO(QTO(TUO!Z)TP~O!Y+pO`)SX~O[+tO~O`+uO~O![%}O(O%eO(P!lO`)SP~Oh%VO#]+zO~Oh%VOk+}O![$|O~O![,PO~O},RO![XO~O%k%tO~O!u,WO~Oe,]O~Ob,^O(O#nO(QTO(TUO!Z)RP~Oe%{O~O%g!QO(O&WO~P=RO[,cO`,bO~OPYOQYOSfOdzOeyOmkOoYOpkOqkOwkOyYO{YO!PWO!TkO!UkO!fuO!iZO!lYO!mYO!nYO!pvO!uxO!y]O%e}O(QTO(TUO([VO(j[O(yiO~O![!eO!r!gO$V!kO(O!dO~P!EkO`,bOa%lO'u%lO~OPYOQYOSfOd!jOe!iOmkOoYOpkOqkOwkOyYO{YO!PWO!TkO!UkO![!eO!fuO!iZO!lYO!mYO!nYO!pvO!u!hO$V!kO(O!dO(QTO(TUO([VO(j[O(yiO~Oa,hO!rwO#t!OO%i!OO%j!OO%k!OO~P!HTO!i&lO~O&Y,nO~O![,pO~O&k,rO&m,sOP&haQ&haS&haY&haa&had&hae&ham&hao&hap&haq&haw&hay&ha{&ha!P&ha!T&ha!U&ha![&ha!f&ha!i&ha!l&ha!m&ha!n&ha!p&ha!r&ha!u&ha!y&ha#t&ha$V&ha%e&ha%g&ha%i&ha%j&ha%k&ha%n&ha%p&ha%s&ha%t&ha%v&ha&S&ha&Y&ha&[&ha&^&ha&`&ha&c&ha&i&ha&o&ha&q&ha&s&ha&u&ha&w&ha's&ha(O&ha(Q&ha(T&ha([&ha(j&ha(y&ha!Z&ha&a&hab&ha&f&ha~O(O,xO~Oh!bX!Y!OX!Z!OX!d!OX!d!bX!i!bX#]!OX~O!Y!bX!Z!bX~P# ZO!d,}O#],|Oh(eX!Y#eX!Y(eX!Z#eX!Z(eX!d(eX!i(eX~Oh%VO!d-PO!i%cO!Y!^X!Z!^X~Op!nO!P!oO(QTO(TUO(`!mO~OP;POQ;POSfOdkOg'XX!Y'XX~P!+hO!Y.wOg(ka~OSfO![3uO$c3vO~O!Z3zO~Os3{O~P#.aOa$lq!Y$lq'u$lq's$lq!V$lq!h$lqs$lq![$lq%f$lq!d$lq~P!9mO!V3|O~P#.aO})zO!P){O(u%POk'ea(t'ea!Y'ea#]'ea~Og'ea#}'ea~P%)nO})zO!P){Ok'ga(t'ga(u'ga!Y'ga#]'ga~Og'ga#}'ga~P%*aO(m$YO~P#.aO!VfX!V$xX!YfX!Y$xX!d%PX#]fX~P!/gO(OQ#>g#@V#@e#@l#BR#Ba#C|#D[#Db#Dh#Dn#Dx#EO#EU#E`#Er#ExPPPPPPPPPP#FOPPPPPPP#Fs#Iz#KZ#Kb#KjPPP$!sP$!|$%t$,^$,a$,d$-P$-S$-Z$-cP$-i$-lP$.Y$.^$/U$0d$0i$1PPP$1U$1[$1`P$1c$1g$1k$2a$2x$3a$3e$3h$3k$3q$3t$3x$3|R!|RoqOXst!Z#d%k&o&q&r&t,k,p1|2PY!vQ']-]1a5eQ%rvQ%zyQ&R|Q&g!VS'T!e-TQ'c!iS'i!r!yU*e$|*V*jQ+i%{Q+v&TQ,[&aQ-Z'[Q-e'dQ-m'jQ0R*lQ1k,]R;v;T%QdOPWXYZstuvw!Z!`!g!o#S#W#Z#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$_$a$e%k%r&P&h&k&o&q&r&t&x'Q'_'o(P(R(X(`(t(v(z)y+R+V,h,k,p-a-i-w-}.l.s/f0a0g0v1d1t1u1w1y1|2P2R2r2x3^5b5m5}6O6R6f8R8X8h8rS#q];Q!r)Z$Z$n'U)o,|-P.}2b3u5`6]9h9y;P;S;T;W;X;Y;Z;[;];^;_;`;a;b;c;d;f;i;v;x;y;{ < TypeParamList TypeDefinition extends ThisType this LiteralType ArithOp Number BooleanLiteral TemplateType InterpolationEnd Interpolation InterpolationStart NullType null VoidType void TypeofType typeof MemberExpression . PropertyName [ TemplateString Escape Interpolation super RegExp ] ArrayExpression Spread , } { ObjectExpression Property async get set PropertyDefinition Block : NewTarget new NewExpression ) ( ArgList UnaryExpression delete LogicOp BitOp YieldExpression yield AwaitExpression await ParenthesizedExpression ClassExpression class ClassBody MethodDeclaration Decorator @ MemberExpression PrivatePropertyName CallExpression TypeArgList CompareOp < declare Privacy static abstract override PrivatePropertyDefinition PropertyDeclaration readonly accessor Optional TypeAnnotation Equals StaticBlock FunctionExpression ArrowFunction ParamList ParamList ArrayPattern ObjectPattern PatternProperty Privacy readonly Arrow MemberExpression BinaryExpression ArithOp ArithOp ArithOp ArithOp BitOp CompareOp instanceof satisfies in const CompareOp BitOp BitOp BitOp LogicOp LogicOp ConditionalExpression LogicOp LogicOp AssignmentExpression UpdateOp PostfixExpression CallExpression InstantiationExpression TaggedTemplateExpression DynamicImport import ImportMeta JSXElement JSXSelfCloseEndTag JSXSelfClosingTag JSXIdentifier JSXBuiltin JSXIdentifier JSXNamespacedName JSXMemberExpression JSXSpreadAttribute JSXAttribute JSXAttributeValue JSXEscape JSXEndTag JSXOpenTag JSXFragmentTag JSXText JSXEscape JSXStartCloseTag JSXCloseTag PrefixCast ArrowFunction TypeParamList SequenceExpression InstantiationExpression KeyofType keyof UniqueType unique ImportType InferredType infer TypeName ParenthesizedType FunctionSignature ParamList NewSignature IndexedType TupleType Label ArrayType ReadonlyType ObjectType MethodType PropertyType IndexSignature PropertyDefinition CallSignature TypePredicate is NewSignature new UnionType LogicOp IntersectionType LogicOp ConditionalType ParameterizedType ClassDeclaration abstract implements type VariableDeclaration let var using TypeAliasDeclaration InterfaceDeclaration interface EnumDeclaration enum EnumBody NamespaceDeclaration namespace module AmbientDeclaration declare GlobalDeclaration global ClassDeclaration ClassBody AmbientFunctionDeclaration ExportGroup VariableName VariableName ImportDeclaration ImportGroup ForStatement for ForSpec ForInSpec ForOfSpec of WhileStatement while WithStatement with DoStatement do IfStatement if else SwitchStatement switch SwitchBody CaseLabel case DefaultLabel TryStatement try CatchClause catch FinallyClause finally ReturnStatement return ThrowStatement throw BreakStatement break ContinueStatement continue DebuggerStatement debugger LabeledStatement ExpressionStatement SingleExpression SingleClassItem",maxTerm:376,context:trackNewline,nodeProps:[["isolate",-8,5,6,14,34,36,48,50,52,""],["group",-26,9,17,19,65,204,208,212,213,215,218,221,231,233,239,241,243,245,248,254,260,262,264,266,268,270,271,"Statement",-34,13,14,29,32,33,39,48,51,52,54,59,67,69,73,77,79,81,82,107,108,117,118,135,138,140,141,142,143,144,146,147,166,167,169,"Expression",-23,28,30,34,38,40,42,171,173,175,176,178,179,180,182,183,184,186,187,188,198,200,202,203,"Type",-3,85,100,106,"ClassItem"],["openedBy",23,"<",35,"InterpolationStart",53,"[",57,"{",70,"(",159,"JSXStartCloseTag"],["closedBy",24,">",37,"InterpolationEnd",47,"]",58,"}",71,")",164,"JSXEndTag"]],propSources:[jsHighlight],skippedNodes:[0,5,6,274],repeatNodeCount:37,tokenData:"$Fq07[R!bOX%ZXY+gYZ-yZ[+g[]%Z]^.c^p%Zpq+gqr/mrs3cst:_tuEruvJSvwLkwx! Yxy!'iyz!(sz{!)}{|!,q|}!.O}!O!,q!O!P!/Y!P!Q!9j!Q!R#:O!R![#<_![!]#I_!]!^#Jk!^!_#Ku!_!`$![!`!a$$v!a!b$*T!b!c$,r!c!}Er!}#O$-|#O#P$/W#P#Q$4o#Q#R$5y#R#SEr#S#T$7W#T#o$8b#o#p$x#r#s$@U#s$f%Z$f$g+g$g#BYEr#BY#BZ$A`#BZ$ISEr$IS$I_$A`$I_$I|Er$I|$I}$Dk$I}$JO$Dk$JO$JTEr$JT$JU$A`$JU$KVEr$KV$KW$A`$KW&FUEr&FU&FV$A`&FV;'SEr;'S;=`I|<%l?HTEr?HT?HU$A`?HUOEr(n%d_$h&j(Rp(U!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z&j&hT$h&jO!^&c!_#o&c#p;'S&c;'S;=`&w<%lO&c&j&zP;=`<%l&c'|'U]$h&j(U!bOY&}YZ&cZw&}wx&cx!^&}!^!_'}!_#O&}#O#P&c#P#o&}#o#p'}#p;'S&};'S;=`(l<%lO&}!b(SU(U!bOY'}Zw'}x#O'}#P;'S'};'S;=`(f<%lO'}!b(iP;=`<%l'}'|(oP;=`<%l&}'[(y]$h&j(RpOY(rYZ&cZr(rrs&cs!^(r!^!_)r!_#O(r#O#P&c#P#o(r#o#p)r#p;'S(r;'S;=`*a<%lO(rp)wU(RpOY)rZr)rs#O)r#P;'S)r;'S;=`*Z<%lO)rp*^P;=`<%l)r'[*dP;=`<%l(r#S*nX(Rp(U!bOY*gZr*grs'}sw*gwx)rx#O*g#P;'S*g;'S;=`+Z<%lO*g#S+^P;=`<%l*g(n+dP;=`<%l%Z07[+rq$h&j(Rp(U!b'w0/lOX%ZXY+gYZ&cZ[+g[p%Zpq+gqr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p$f%Z$f$g+g$g#BY%Z#BY#BZ+g#BZ$IS%Z$IS$I_+g$I_$JT%Z$JT$JU+g$JU$KV%Z$KV$KW+g$KW&FU%Z&FU&FV+g&FV;'S%Z;'S;=`+a<%l?HT%Z?HT?HU+g?HUO%Z07[.ST(S#S$h&j'x0/lO!^&c!_#o&c#p;'S&c;'S;=`&w<%lO&c07[.n_$h&j(Rp(U!b'x0/lOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z)3p/x`$h&j!m),Q(Rp(U!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_!`0z!`#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z(KW1V`#u(Ch$h&j(Rp(U!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_!`2X!`#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z(KW2d_#u(Ch$h&j(Rp(U!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'At3l_(Q':f$h&j(U!bOY4kYZ5qZr4krs7nsw4kwx5qx!^4k!^!_8p!_#O4k#O#P5q#P#o4k#o#p8p#p;'S4k;'S;=`:X<%lO4k(^4r_$h&j(U!bOY4kYZ5qZr4krs7nsw4kwx5qx!^4k!^!_8p!_#O4k#O#P5q#P#o4k#o#p8p#p;'S4k;'S;=`:X<%lO4k&z5vX$h&jOr5qrs6cs!^5q!^!_6y!_#o5q#o#p6y#p;'S5q;'S;=`7h<%lO5q&z6jT$c`$h&jO!^&c!_#o&c#p;'S&c;'S;=`&w<%lO&c`6|TOr6yrs7]s;'S6y;'S;=`7b<%lO6y`7bO$c``7eP;=`<%l6y&z7kP;=`<%l5q(^7w]$c`$h&j(U!bOY&}YZ&cZw&}wx&cx!^&}!^!_'}!_#O&}#O#P&c#P#o&}#o#p'}#p;'S&};'S;=`(l<%lO&}!r8uZ(U!bOY8pYZ6yZr8prs9hsw8pwx6yx#O8p#O#P6y#P;'S8p;'S;=`:R<%lO8p!r9oU$c`(U!bOY'}Zw'}x#O'}#P;'S'};'S;=`(f<%lO'}!r:UP;=`<%l8p(^:[P;=`<%l4k%9[:hh$h&j(Rp(U!bOY%ZYZ&cZq%Zqr`#P#o`x!^=^!^!_?q!_#O=^#O#P>`#P#o=^#o#p?q#p;'S=^;'S;=`@h<%lO=^&n>gXWS$h&jOY>`YZ&cZ!^>`!^!_?S!_#o>`#o#p?S#p;'S>`;'S;=`?k<%lO>`S?XSWSOY?SZ;'S?S;'S;=`?e<%lO?SS?hP;=`<%l?S&n?nP;=`<%l>`!f?xWWS(U!bOY?qZw?qwx?Sx#O?q#O#P?S#P;'S?q;'S;=`@b<%lO?q!f@eP;=`<%l?q(Q@kP;=`<%l=^'`@w]WS$h&j(RpOY@nYZ&cZr@nrs>`s!^@n!^!_Ap!_#O@n#O#P>`#P#o@n#o#pAp#p;'S@n;'S;=`Bg<%lO@ntAwWWS(RpOYApZrAprs?Ss#OAp#O#P?S#P;'SAp;'S;=`Ba<%lOAptBdP;=`<%lAp'`BjP;=`<%l@n#WBvYWS(Rp(U!bOYBmZrBmrs?qswBmwxApx#OBm#O#P?S#P;'SBm;'S;=`Cf<%lOBm#WCiP;=`<%lBm(rCoP;=`<%l^!Q^$h&j!U7`OY!=yYZ&cZ!P!=y!P!Q!>|!Q!^!=y!^!_!@c!_!}!=y!}#O!CW#O#P!Dy#P#o!=y#o#p!@c#p;'S!=y;'S;=`!Ek<%lO!=y|#X#Z&c#Z#[!>|#[#]&c#]#^!>|#^#a&c#a#b!>|#b#g&c#g#h!>|#h#i&c#i#j!>|#j#k!>|#k#m&c#m#n!>|#n#o&c#p;'S&c;'S;=`&w<%lO&c7`!@hX!U7`OY!@cZ!P!@c!P!Q!AT!Q!}!@c!}#O!Ar#O#P!Bq#P;'S!@c;'S;=`!CQ<%lO!@c7`!AYW!U7`#W#X!AT#Z#[!AT#]#^!AT#a#b!AT#g#h!AT#i#j!AT#j#k!AT#m#n!AT7`!AuVOY!ArZ#O!Ar#O#P!B[#P#Q!@c#Q;'S!Ar;'S;=`!Bk<%lO!Ar7`!B_SOY!ArZ;'S!Ar;'S;=`!Bk<%lO!Ar7`!BnP;=`<%l!Ar7`!BtSOY!@cZ;'S!@c;'S;=`!CQ<%lO!@c7`!CTP;=`<%l!@c^!Ezl$h&j(U!b!U7`OY&}YZ&cZw&}wx&cx!^&}!^!_'}!_#O&}#O#P&c#P#W&}#W#X!Eq#X#Z&}#Z#[!Eq#[#]&}#]#^!Eq#^#a&}#a#b!Eq#b#g&}#g#h!Eq#h#i&}#i#j!Eq#j#k!Eq#k#m&}#m#n!Eq#n#o&}#o#p'}#p;'S&};'S;=`(l<%lO&}8r!GyZ(U!b!U7`OY!GrZw!Grwx!@cx!P!Gr!P!Q!Hl!Q!}!Gr!}#O!JU#O#P!Bq#P;'S!Gr;'S;=`!J|<%lO!Gr8r!Hse(U!b!U7`OY'}Zw'}x#O'}#P#W'}#W#X!Hl#X#Z'}#Z#[!Hl#[#]'}#]#^!Hl#^#a'}#a#b!Hl#b#g'}#g#h!Hl#h#i'}#i#j!Hl#j#k!Hl#k#m'}#m#n!Hl#n;'S'};'S;=`(f<%lO'}8r!JZX(U!bOY!JUZw!JUwx!Arx#O!JU#O#P!B[#P#Q!Gr#Q;'S!JU;'S;=`!Jv<%lO!JU8r!JyP;=`<%l!JU8r!KPP;=`<%l!Gr>^!KZ^$h&j(U!bOY!KSYZ&cZw!KSwx!CWx!^!KS!^!_!JU!_#O!KS#O#P!DR#P#Q!^!LYP;=`<%l!KS>^!L`P;=`<%l!_#c#d#Bq#d#l%Z#l#m#Es#m#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#_#c#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#>j_$h&j(Rp(U!bp'9tOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#?rd$h&j(Rp(U!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q!R#AQ!R!S#AQ!S!^%Z!^!_*g!_#O%Z#O#P&c#P#R%Z#R#S#AQ#S#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#A]f$h&j(Rp(U!bp'9tOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q!R#AQ!R!S#AQ!S!^%Z!^!_*g!_#O%Z#O#P&c#P#R%Z#R#S#AQ#S#b%Z#b#c#>_#c#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#Bzc$h&j(Rp(U!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q!Y#DV!Y!^%Z!^!_*g!_#O%Z#O#P&c#P#R%Z#R#S#DV#S#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#Dbe$h&j(Rp(U!bp'9tOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q!Y#DV!Y!^%Z!^!_*g!_#O%Z#O#P&c#P#R%Z#R#S#DV#S#b%Z#b#c#>_#c#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#E|g$h&j(Rp(U!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q![#Ge![!^%Z!^!_*g!_!c%Z!c!i#Ge!i#O%Z#O#P&c#P#R%Z#R#S#Ge#S#T%Z#T#Z#Ge#Z#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#Gpi$h&j(Rp(U!bp'9tOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q![#Ge![!^%Z!^!_*g!_!c%Z!c!i#Ge!i#O%Z#O#P&c#P#R%Z#R#S#Ge#S#T%Z#T#Z#Ge#Z#b%Z#b#c#>_#c#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z*)x#Il_!d$b$h&j#})Lv(Rp(U!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z)[#Jv_al$h&j(Rp(U!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z04f#LS^h#)`#O-spec_identifier[r]||-1},{term:338,get:r=>spec_word[r]||-1},{term:92,get:r=>spec_LessThan[r]||-1}],tokenPrec:14749});var _a;const languageDataProp=new NodeProp;function defineLanguageFacet(r){return Facet.define({combine:r?e=>e.concat(r):void 0})}const sublanguageProp=new NodeProp;class Language{constructor(e,n,s=[],o=""){this.data=e,this.name=o,EditorState.prototype.hasOwnProperty("tree")||Object.defineProperty(EditorState.prototype,"tree",{get(){return syntaxTree(this)}}),this.parser=n,this.extension=[language.of(this),EditorState.languageData.of((l,a,c)=>{let h=topNodeAt(l,a,c),f=h.type.prop(languageDataProp);if(!f)return[];let u=l.facet(f),d=h.type.prop(sublanguageProp);if(d){let g=h.resolve(a-h.from,c);for(let O of d)if(O.test(g,l)){let m=l.facet(O.facet);return O.type=="replace"?m:m.concat(u)}}return u})].concat(s)}isActiveAt(e,n,s=-1){return topNodeAt(e,n,s).type.prop(languageDataProp)==this.data}findRegions(e){let n=e.facet(language);if((n==null?void 0:n.data)==this.data)return[{from:0,to:e.doc.length}];if(!n||!n.allowsNesting)return[];let s=[],o=(l,a)=>{if(l.prop(languageDataProp)==this.data){s.push({from:a,to:a+l.length});return}let c=l.prop(NodeProp.mounted);if(c){if(c.tree.prop(languageDataProp)==this.data){if(c.overlay)for(let h of c.overlay)s.push({from:h.from+a,to:h.to+a});else s.push({from:a,to:a+l.length});return}else if(c.overlay){let h=s.length;if(o(c.tree,c.overlay[0].from+a),s.length>h)return}}for(let h=0;hs.isTop?n:void 0)]}),e.name)}configure(e,n){return new LRLanguage(this.data,this.parser.configure(e),n||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function syntaxTree(r){let e=r.field(Language.state,!1);return e?e.tree:Tree.empty}class DocInput{constructor(e){this.doc=e,this.cursorPos=0,this.string="",this.cursor=e.iter()}get length(){return this.doc.length}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,n){let s=this.cursorPos-this.string.length;return e=this.cursorPos?this.doc.sliceString(e,n):this.string.slice(e-s,n-s)}}let currentContext=null;class ParseContext{constructor(e,n,s=[],o,l,a,c,h){this.parser=e,this.state=n,this.fragments=s,this.tree=o,this.treeLen=l,this.viewport=a,this.skipped=c,this.scheduleOn=h,this.parse=null,this.tempSkipped=[]}static create(e,n,s){return new ParseContext(e,n,[],Tree.empty,0,s,[],null)}startParse(){return this.parser.startParse(new DocInput(this.state.doc),this.fragments)}work(e,n){return n!=null&&n>=this.state.doc.length&&(n=void 0),this.tree!=Tree.empty&&this.isDone(n??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var s;if(typeof e=="number"){let o=Date.now()+e;e=()=>Date.now()>o}for(this.parse||(this.parse=this.startParse()),n!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>n)&&n=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(n=this.parse.advance()););}),this.treeLen=e,this.tree=n,this.fragments=this.withoutTempSkipped(TreeFragment.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let n=currentContext;currentContext=this;try{return e()}finally{currentContext=n}}withoutTempSkipped(e){for(let n;n=this.tempSkipped.pop();)e=cutFragments(e,n.from,n.to);return e}changes(e,n){let{fragments:s,tree:o,treeLen:l,viewport:a,skipped:c}=this;if(this.takeTree(),!e.empty){let h=[];if(e.iterChangedRanges((f,u,d,g)=>h.push({fromA:f,toA:u,fromB:d,toB:g})),s=TreeFragment.applyChanges(s,h),o=Tree.empty,l=0,a={from:e.mapPos(a.from,-1),to:e.mapPos(a.to,1)},this.skipped.length){c=[];for(let f of this.skipped){let u=e.mapPos(f.from,1),d=e.mapPos(f.to,-1);ue.from&&(this.fragments=cutFragments(this.fragments,o,l),this.skipped.splice(s--,1))}return this.skipped.length>=n?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,n){this.skipped.push({from:e,to:n})}static getSkippingParser(e){return new class extends Parser{createParse(n,s,o){let l=o[0].from,a=o[o.length-1].to;return{parsedPos:l,advance(){let h=currentContext;if(h){for(let f of o)h.tempSkipped.push(f);e&&(h.scheduleOn=h.scheduleOn?Promise.all([h.scheduleOn,e]):e)}return this.parsedPos=a,new Tree(NodeType.none,[],[],a-l)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let n=this.fragments;return this.treeLen>=e&&n.length&&n[0].from==0&&n[0].to>=e}static get(){return currentContext}}function cutFragments(r,e,n){return TreeFragment.applyChanges(r,[{fromA:e,toA:n,fromB:e,toB:n}])}class LanguageState{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let n=this.context.changes(e.changes,e.state),s=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),n.viewport.to);return n.work(20,s)||n.takeTree(),new LanguageState(n)}static init(e){let n=Math.min(3e3,e.doc.length),s=ParseContext.create(e.facet(language).parser,e,{from:0,to:n});return s.work(20,n)||s.takeTree(),new LanguageState(s)}}Language.state=StateField.define({create:LanguageState.init,update(r,e){for(let n of e.effects)if(n.is(Language.setState))return n.value;return e.startState.facet(language)!=e.state.facet(language)?LanguageState.init(e.state):r.apply(e)}});let requestIdle=r=>{let e=setTimeout(()=>r(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(requestIdle=r=>{let e=-1,n=setTimeout(()=>{e=requestIdleCallback(r,{timeout:400})},100);return()=>e<0?clearTimeout(n):cancelIdleCallback(e)});const isInputPending=typeof navigator<"u"&&(!((_a=navigator.scheduling)===null||_a===void 0)&&_a.isInputPending)?()=>navigator.scheduling.isInputPending():null,parseWorker=ViewPlugin.fromClass(class{constructor(e){this.view=e,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(e){let n=this.view.state.field(Language.state).context;(n.updateViewport(e.view.viewport)||this.view.viewport.to>n.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(n)}scheduleWork(){if(this.working)return;let{state:e}=this.view,n=e.field(Language.state);(n.tree!=n.context.tree||!n.context.isDone(e.doc.length))&&(this.working=requestIdle(this.work))}work(e){this.working=null;let n=Date.now();if(this.chunkEndo+1e3,h=l.context.work(()=>isInputPending&&isInputPending()||Date.now()>a,o+(c?0:1e5));this.chunkBudget-=Date.now()-n,(h||this.chunkBudget<=0)&&(l.context.takeTree(),this.view.dispatch({effects:Language.setState.of(new LanguageState(l.context))})),this.chunkBudget>0&&!(h&&!c)&&this.scheduleWork(),this.checkAsyncSchedule(l.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(n=>logException(this.view.state,n)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),language=Facet.define({combine(r){return r.length?r[0]:null},enables:r=>[Language.state,parseWorker,EditorView.contentAttributes.compute([r],e=>{let n=e.facet(r);return n&&n.name?{"data-language":n.name}:{}})]});class LanguageSupport{constructor(e,n=[]){this.language=e,this.support=n,this.extension=[e,n]}}const indentService=Facet.define(),indentUnit=Facet.define({combine:r=>{if(!r.length)return" ";let e=r[0];if(!e||/\S/.test(e)||Array.from(e).some(n=>n!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(r[0]));return e}});function getIndentUnit(r){let e=r.facet(indentUnit);return e.charCodeAt(0)==9?r.tabSize*e.length:e.length}function indentString(r,e){let n="",s=r.tabSize,o=r.facet(indentUnit)[0];if(o==" "){for(;e>=s;)n+=" ",e-=s;o=" "}for(let l=0;l=e?syntaxIndentation(r,n,e):null}class IndentContext{constructor(e,n={}){this.state=e,this.options=n,this.unit=getIndentUnit(e)}lineAt(e,n=1){let s=this.state.doc.lineAt(e),{simulateBreak:o,simulateDoubleBreak:l}=this.options;return o!=null&&o>=s.from&&o<=s.to?l&&o==e?{text:"",from:e}:(n<0?o-1&&(l+=a-this.countColumn(s,s.search(/\S|$/))),l}countColumn(e,n=e.length){return countColumn(e,this.state.tabSize,n)}lineIndent(e,n=1){let{text:s,from:o}=this.lineAt(e,n),l=this.options.overrideIndentation;if(l){let a=l(o);if(a>-1)return a}return this.countColumn(s,s.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const indentNodeProp=new NodeProp;function syntaxIndentation(r,e,n){let s=e.resolveStack(n),o=s.node.enterUnfinishedNodesBefore(n);if(o!=s.node){let l=[];for(let a=o;a!=s.node;a=a.parent)l.push(a);for(let a=l.length-1;a>=0;a--)s={node:l[a],next:s}}return indentFor(s,r,n)}function indentFor(r,e,n){for(let s=r;s;s=s.next){let o=indentStrategy(s.node);if(o)return o(TreeIndentContext.create(e,n,s))}return 0}function ignoreClosed(r){return r.pos==r.options.simulateBreak&&r.options.simulateDoubleBreak}function indentStrategy(r){let e=r.type.prop(indentNodeProp);if(e)return e;let n=r.firstChild,s;if(n&&(s=n.type.prop(NodeProp.closedBy))){let o=r.lastChild,l=o&&s.indexOf(o.name)>-1;return a=>delimitedStrategy(a,!0,1,void 0,l&&!ignoreClosed(a)?o.from:void 0)}return r.parent==null?topIndent:null}function topIndent(){return 0}class TreeIndentContext extends IndentContext{constructor(e,n,s){super(e.state,e.options),this.base=e,this.pos=n,this.context=s}get node(){return this.context.node}static create(e,n,s){return new TreeIndentContext(e,n,s)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let n=this.state.doc.lineAt(e.from);for(;;){let s=e.resolve(n.from);for(;s.parent&&s.parent.from==s.from;)s=s.parent;if(isParent(s,e))break;n=this.state.doc.lineAt(s.from)}return this.lineIndent(n.from)}continue(){return indentFor(this.context.next,this.base,this.pos)}}function isParent(r,e){for(let n=e;n;n=n.parent)if(r==n)return!0;return!1}function bracketedAligned(r){let e=r.node,n=e.childAfter(e.from),s=e.lastChild;if(!n)return null;let o=r.options.simulateBreak,l=r.state.doc.lineAt(n.from),a=o==null||o<=l.from?l.to:Math.min(l.to,o);for(let c=n.to;;){let h=e.childAfter(c);if(!h||h==s)return null;if(!h.type.isSkipped)return h.fromdelimitedStrategy(s,e,n,r)}function delimitedStrategy(r,e,n,s,o){let l=r.textAfter,a=l.match(/^\s*/)[0].length,c=s&&l.slice(a,a+s.length)==s||o==r.pos+a,h=e?bracketedAligned(r):null;return h?c?r.column(h.from):r.column(h.to):r.baseIndent+(c?0:r.unit*n)}const flatIndent=r=>r.baseIndent;function continuedIndent({except:r,units:e=1}={}){return n=>{let s=r&&r.test(n.textAfter);return n.baseIndent+(s?0:e*n.unit)}}const DontIndentBeyond=200;function indentOnInput(){return EditorState.transactionFilter.of(r=>{if(!r.docChanged||!r.isUserEvent("input.type")&&!r.isUserEvent("input.complete"))return r;let e=r.startState.languageDataAt("indentOnInput",r.startState.selection.main.head);if(!e.length)return r;let n=r.newDoc,{head:s}=r.newSelection.main,o=n.lineAt(s);if(s>o.from+DontIndentBeyond)return r;let l=n.sliceString(o.from,s);if(!e.some(f=>f.test(l)))return r;let{state:a}=r,c=-1,h=[];for(let{head:f}of a.selection.ranges){let u=a.doc.lineAt(f);if(u.from==c)continue;c=u.from;let d=getIndentation(a,u.from);if(d==null)continue;let g=/^\s*/.exec(u.text)[0],O=indentString(a,d);g!=O&&h.push({from:u.from,to:u.from+g.length,insert:O})}return h.length?[r,{changes:h,sequential:!0}]:r})}const foldService=Facet.define(),foldNodeProp=new NodeProp;function foldInside(r){let e=r.firstChild,n=r.lastChild;return e&&e.ton)continue;if(l&&c.from=e&&f.to>n&&(l=f)}}return l}function isUnfinished(r){let e=r.lastChild;return e&&e.to==r.to&&e.type.isError}function foldable(r,e,n){for(let s of r.facet(foldService)){let o=s(r,e,n);if(o)return o}return syntaxFolding(r,e,n)}function mapRange(r,e){let n=e.mapPos(r.from,1),s=e.mapPos(r.to,-1);return n>=s?void 0:{from:n,to:s}}const foldEffect=StateEffect.define({map:mapRange}),unfoldEffect=StateEffect.define({map:mapRange});function selectedLines(r){let e=[];for(let{head:n}of r.state.selection.ranges)e.some(s=>s.from<=n&&s.to>=n)||e.push(r.lineBlockAt(n));return e}const foldState=StateField.define({create(){return Decoration.none},update(r,e){r=r.map(e.changes);for(let n of e.effects)if(n.is(foldEffect)&&!foldExists(r,n.value.from,n.value.to)){let{preparePlaceholder:s}=e.state.facet(foldConfig),o=s?Decoration.replace({widget:new PreparedFoldWidget(s(e.state,n.value))}):foldWidget;r=r.update({add:[o.range(n.value.from,n.value.to)]})}else n.is(unfoldEffect)&&(r=r.update({filter:(s,o)=>n.value.from!=s||n.value.to!=o,filterFrom:n.value.from,filterTo:n.value.to}));if(e.selection){let n=!1,{head:s}=e.selection.main;r.between(s,s,(o,l)=>{os&&(n=!0)}),n&&(r=r.update({filterFrom:s,filterTo:s,filter:(o,l)=>l<=s||o>=s}))}return r},provide:r=>EditorView.decorations.from(r),toJSON(r,e){let n=[];return r.between(0,e.doc.length,(s,o)=>{n.push(s,o)}),n},fromJSON(r){if(!Array.isArray(r)||r.length%2)throw new RangeError("Invalid JSON for fold state");let e=[];for(let n=0;n{(!o||o.from>l)&&(o={from:l,to:a})}),o}function foldExists(r,e,n){let s=!1;return r.between(e,e,(o,l)=>{o==e&&l==n&&(s=!0)}),s}function maybeEnable(r,e){return r.field(foldState,!1)?e:e.concat(StateEffect.appendConfig.of(codeFolding()))}const foldCode=r=>{for(let e of selectedLines(r)){let n=foldable(r.state,e.from,e.to);if(n)return r.dispatch({effects:maybeEnable(r.state,[foldEffect.of(n),announceFold(r,n)])}),!0}return!1},unfoldCode=r=>{if(!r.state.field(foldState,!1))return!1;let e=[];for(let n of selectedLines(r)){let s=findFold(r.state,n.from,n.to);s&&e.push(unfoldEffect.of(s),announceFold(r,s,!1))}return e.length&&r.dispatch({effects:e}),e.length>0};function announceFold(r,e,n=!0){let s=r.state.doc.lineAt(e.from).number,o=r.state.doc.lineAt(e.to).number;return EditorView.announce.of(`${r.state.phrase(n?"Folded lines":"Unfolded lines")} ${s} ${r.state.phrase("to")} ${o}.`)}const foldAll=r=>{let{state:e}=r,n=[];for(let s=0;s{let e=r.state.field(foldState,!1);if(!e||!e.size)return!1;let n=[];return e.between(0,r.state.doc.length,(s,o)=>{n.push(unfoldEffect.of({from:s,to:o}))}),r.dispatch({effects:n}),!0},foldKeymap=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:foldCode},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:unfoldCode},{key:"Ctrl-Alt-[",run:foldAll},{key:"Ctrl-Alt-]",run:unfoldAll}],defaultConfig={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},foldConfig=Facet.define({combine(r){return combineConfig(r,defaultConfig)}});function codeFolding(r){return[foldState,baseTheme$1$1]}function widgetToDOM(r,e){let{state:n}=r,s=n.facet(foldConfig),o=a=>{let c=r.lineBlockAt(r.posAtDOM(a.target)),h=findFold(r.state,c.from,c.to);h&&r.dispatch({effects:unfoldEffect.of(h)}),a.preventDefault()};if(s.placeholderDOM)return s.placeholderDOM(r,o,e);let l=document.createElement("span");return l.textContent=s.placeholderText,l.setAttribute("aria-label",n.phrase("folded code")),l.title=n.phrase("unfold"),l.className="cm-foldPlaceholder",l.onclick=o,l}const foldWidget=Decoration.replace({widget:new class extends WidgetType{toDOM(r){return widgetToDOM(r,null)}}});class PreparedFoldWidget extends WidgetType{constructor(e){super(),this.value=e}eq(e){return this.value==e.value}toDOM(e){return widgetToDOM(e,this.value)}}const foldGutterDefaults={openText:"⌄",closedText:"›",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class FoldMarker extends GutterMarker{constructor(e,n){super(),this.config=e,this.open=n}eq(e){return this.config==e.config&&this.open==e.open}toDOM(e){if(this.config.markerDOM)return this.config.markerDOM(this.open);let n=document.createElement("span");return n.textContent=this.open?this.config.openText:this.config.closedText,n.title=e.state.phrase(this.open?"Fold line":"Unfold line"),n}}function foldGutter(r={}){let e=Object.assign(Object.assign({},foldGutterDefaults),r),n=new FoldMarker(e,!0),s=new FoldMarker(e,!1),o=ViewPlugin.fromClass(class{constructor(a){this.from=a.viewport.from,this.markers=this.buildMarkers(a)}update(a){(a.docChanged||a.viewportChanged||a.startState.facet(language)!=a.state.facet(language)||a.startState.field(foldState,!1)!=a.state.field(foldState,!1)||syntaxTree(a.startState)!=syntaxTree(a.state)||e.foldingChanged(a))&&(this.markers=this.buildMarkers(a.view))}buildMarkers(a){let c=new RangeSetBuilder;for(let h of a.viewportLineBlocks){let f=findFold(a.state,h.from,h.to)?s:foldable(a.state,h.from,h.to)?n:null;f&&c.add(h.from,h.from,f)}return c.finish()}}),{domEventHandlers:l}=e;return[o,gutter({class:"cm-foldGutter",markers(a){var c;return((c=a.plugin(o))===null||c===void 0?void 0:c.markers)||RangeSet.empty},initialSpacer(){return new FoldMarker(e,!1)},domEventHandlers:Object.assign(Object.assign({},l),{click:(a,c,h)=>{if(l.click&&l.click(a,c,h))return!0;let f=findFold(a.state,c.from,c.to);if(f)return a.dispatch({effects:unfoldEffect.of(f)}),!0;let u=foldable(a.state,c.from,c.to);return u?(a.dispatch({effects:foldEffect.of(u)}),!0):!1}})}),codeFolding()]}const baseTheme$1$1=EditorView.baseTheme({".cm-foldPlaceholder":{backgroundColor:"#eee",border:"1px solid #ddd",color:"#888",borderRadius:".2em",margin:"0 1px",padding:"0 1px",cursor:"pointer"},".cm-foldGutter span":{padding:"0 1px",cursor:"pointer"}});class HighlightStyle{constructor(e,n){this.specs=e;let s;function o(c){let h=StyleModule.newName();return(s||(s=Object.create(null)))["."+h]=c,h}const l=typeof n.all=="string"?n.all:n.all?o(n.all):void 0,a=n.scope;this.scope=a instanceof Language?c=>c.prop(languageDataProp)==a.data:a?c=>c==a:void 0,this.style=tagHighlighter(e.map(c=>({tag:c.tag,class:c.class||o(Object.assign({},c,{tag:null}))})),{all:l}).style,this.module=s?new StyleModule(s):null,this.themeType=n.themeType}static define(e,n){return new HighlightStyle(e,n||{})}}const highlighterFacet=Facet.define(),fallbackHighlighter=Facet.define({combine(r){return r.length?[r[0]]:null}});function getHighlighters(r){let e=r.facet(highlighterFacet);return e.length?e:r.facet(fallbackHighlighter)}function syntaxHighlighting(r,e){let n=[treeHighlighter],s;return r instanceof HighlightStyle&&(r.module&&n.push(EditorView.styleModule.of(r.module)),s=r.themeType),e!=null&&e.fallback?n.push(fallbackHighlighter.of(r)):s?n.push(highlighterFacet.computeN([EditorView.darkTheme],o=>o.facet(EditorView.darkTheme)==(s=="dark")?[r]:[])):n.push(highlighterFacet.of(r)),n}class TreeHighlighter{constructor(e){this.markCache=Object.create(null),this.tree=syntaxTree(e.state),this.decorations=this.buildDeco(e,getHighlighters(e.state)),this.decoratedTo=e.viewport.to}update(e){let n=syntaxTree(e.state),s=getHighlighters(e.state),o=s!=getHighlighters(e.startState),{viewport:l}=e.view,a=e.changes.mapPos(this.decoratedTo,1);n.length=l.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=a):(n!=this.tree||e.viewportChanged||o)&&(this.tree=n,this.decorations=this.buildDeco(e.view,s),this.decoratedTo=l.to)}buildDeco(e,n){if(!n||!this.tree.length)return Decoration.none;let s=new RangeSetBuilder;for(let{from:o,to:l}of e.visibleRanges)highlightTree(this.tree,n,(a,c,h)=>{s.add(a,c,this.markCache[h]||(this.markCache[h]=Decoration.mark({class:h})))},o,l);return s.finish()}}const treeHighlighter=Prec.high(ViewPlugin.fromClass(TreeHighlighter,{decorations:r=>r.decorations})),baseTheme$3=EditorView.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),DefaultScanDist=1e4,DefaultBrackets="()[]{}",bracketMatchingConfig=Facet.define({combine(r){return combineConfig(r,{afterCursor:!0,brackets:DefaultBrackets,maxScanDistance:DefaultScanDist,renderMatch:defaultRenderMatch})}}),matchingMark=Decoration.mark({class:"cm-matchingBracket"}),nonmatchingMark=Decoration.mark({class:"cm-nonmatchingBracket"});function defaultRenderMatch(r){let e=[],n=r.matched?matchingMark:nonmatchingMark;return e.push(n.range(r.start.from,r.start.to)),r.end&&e.push(n.range(r.end.from,r.end.to)),e}const bracketMatchingState=StateField.define({create(){return Decoration.none},update(r,e){if(!e.docChanged&&!e.selection)return r;let n=[],s=e.state.facet(bracketMatchingConfig);for(let o of e.state.selection.ranges){if(!o.empty)continue;let l=matchBrackets(e.state,o.head,-1,s)||o.head>0&&matchBrackets(e.state,o.head-1,1,s)||s.afterCursor&&(matchBrackets(e.state,o.head,1,s)||o.headEditorView.decorations.from(r)}),bracketMatchingUnique=[bracketMatchingState,baseTheme$3];function bracketMatching(r={}){return[bracketMatchingConfig.of(r),bracketMatchingUnique]}const bracketMatchingHandle=new NodeProp;function matchingNodes(r,e,n){let s=r.prop(e<0?NodeProp.openedBy:NodeProp.closedBy);if(s)return s;if(r.name.length==1){let o=n.indexOf(r.name);if(o>-1&&o%2==(e<0?1:0))return[n[o+e]]}return null}function findHandle(r){let e=r.type.prop(bracketMatchingHandle);return e?e(r.node):r}function matchBrackets(r,e,n,s={}){let o=s.maxScanDistance||DefaultScanDist,l=s.brackets||DefaultBrackets,a=syntaxTree(r),c=a.resolveInner(e,n);for(let h=c;h;h=h.parent){let f=matchingNodes(h.type,n,l);if(f&&h.from0?e>=u.from&&eu.from&&e<=u.to))return matchMarkedBrackets(r,e,n,h,u,f,l)}}return matchPlainBrackets(r,e,n,a,c.type,o,l)}function matchMarkedBrackets(r,e,n,s,o,l,a){let c=s.parent,h={from:o.from,to:o.to},f=0,u=c==null?void 0:c.cursor();if(u&&(n<0?u.childBefore(s.from):u.childAfter(s.to)))do if(n<0?u.to<=s.from:u.from>=s.to){if(f==0&&l.indexOf(u.type.name)>-1&&u.from0)return null;let f={from:n<0?e-1:e,to:n>0?e+1:e},u=r.doc.iterRange(e,n>0?r.doc.length:0),d=0;for(let g=0;!u.next().done&&g<=l;){let O=u.value;n<0&&(g+=O.length);let m=e+g*n;for(let S=n>0?0:O.length-1,b=n>0?O.length:-1;S!=b;S+=n){let w=a.indexOf(O[S]);if(!(w<0||s.resolveInner(m+S,1).type!=o))if(w%2==0==n>0)d++;else{if(d==1)return{start:f,end:{from:m+S,to:m+S+1},matched:w>>1==h>>1};d--}}n>0&&(g+=O.length)}return u.done?{start:f,matched:!1}:null}const noTokens=Object.create(null),typeArray=[NodeType.none],warned=[],byTag=Object.create(null),defaultTable=Object.create(null);for(let[r,e]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])defaultTable[r]=createTokenType(noTokens,e);function warnForPart(r,e){warned.indexOf(r)>-1||(warned.push(r),console.warn(e))}function createTokenType(r,e){let n=[];for(let c of e.split(" ")){let h=[];for(let f of c.split(".")){let u=r[f]||tags[f];u?typeof u=="function"?h.length?h=h.map(u):warnForPart(f,`Modifier ${f} used at start of tag`):h.length?warnForPart(f,`Tag ${f} used as modifier`):h=Array.isArray(u)?u:[u]:warnForPart(f,`Unknown highlighting tag ${f}`)}for(let f of h)n.push(f)}if(!n.length)return 0;let s=e.replace(/ /g,"_"),o=s+" "+n.map(c=>c.id),l=byTag[o];if(l)return l.id;let a=byTag[o]=NodeType.define({id:typeArray.length,name:s,props:[styleTags({[s]:n})]});return typeArray.push(a),a.id}Direction.RTL,Direction.LTR;class CompletionContext{constructor(e,n,s){this.state=e,this.pos=n,this.explicit=s,this.abortListeners=[]}tokenBefore(e){let n=syntaxTree(this.state).resolveInner(this.pos,-1);for(;n&&e.indexOf(n.name)<0;)n=n.parent;return n?{from:n.from,to:this.pos,text:this.state.sliceDoc(n.from,this.pos),type:n.type}:null}matchBefore(e){let n=this.state.doc.lineAt(this.pos),s=Math.max(n.from,this.pos-250),o=n.text.slice(s-n.from,this.pos-n.from),l=o.search(ensureAnchor(e,!1));return l<0?null:{from:s+l,to:this.pos,text:o.slice(l)}}get aborted(){return this.abortListeners==null}addEventListener(e,n){e=="abort"&&this.abortListeners&&this.abortListeners.push(n)}}function toSet(r){let e=Object.keys(r).join(""),n=/\w/.test(e);return n&&(e=e.replace(/\w/g,"")),`[${n?"\\w":""}${e.replace(/[^\w\s]/g,"\\$&")}]`}function prefixMatch(r){let e=Object.create(null),n=Object.create(null);for(let{label:o}of r){e[o[0]]=!0;for(let l=1;ltypeof o=="string"?{label:o}:o),[n,s]=e.every(o=>/^\w+$/.test(o.label))?[/\w*$/,/\w+$/]:prefixMatch(e);return o=>{let l=o.matchBefore(s);return l||o.explicit?{from:l?l.from:o.pos,options:e,validFor:n}:null}}function ifNotIn(r,e){return n=>{for(let s=syntaxTree(n.state).resolveInner(n.pos,-1);s;s=s.parent){if(r.indexOf(s.name)>-1)return null;if(s.type.isTop)break}return e(n)}}class Option{constructor(e,n,s,o){this.completion=e,this.source=n,this.match=s,this.score=o}}function cur(r){return r.selection.main.from}function ensureAnchor(r,e){var n;let{source:s}=r,o=e&&s[0]!="^",l=s[s.length-1]!="$";return!o&&!l?r:new RegExp(`${o?"^":""}(?:${s})${l?"$":""}`,(n=r.flags)!==null&&n!==void 0?n:r.ignoreCase?"i":"")}const pickedCompletion=Annotation.define();function insertCompletionText(r,e,n,s){let{main:o}=r.selection,l=n-o.from,a=s-o.from;return Object.assign(Object.assign({},r.changeByRange(c=>c!=o&&n!=s&&r.sliceDoc(c.from+l,c.from+a)!=r.sliceDoc(n,s)?{range:c}:{changes:{from:c.from+l,to:s==o.from?c.to:c.from+a,insert:e},range:EditorSelection.cursor(c.from+l+e.length)})),{scrollIntoView:!0,userEvent:"input.complete"})}const SourceCache=new WeakMap;function asSource(r){if(!Array.isArray(r))return r;let e=SourceCache.get(r);return e||SourceCache.set(r,e=completeFromList(r)),e}const startCompletionEffect=StateEffect.define(),closeCompletionEffect=StateEffect.define();class FuzzyMatcher{constructor(e){this.pattern=e,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let n=0;n=48&&v<=57||v>=97&&v<=122?2:v>=65&&v<=90?1:0:(Q=fromCodePoint(v))!=Q.toLowerCase()?1:Q!=Q.toUpperCase()?2:0;(!P||_==1&&b||A==0&&_!=0)&&(n[d]==v||s[d]==v&&(g=!0)?a[d++]=P:a.length&&(w=!1)),A=_,P+=codePointSize(v)}return d==h&&a[0]==0&&w?this.result(-100+(g?-200:0),a,e):O==h&&m==0?this.ret(-200-e.length+(S==e.length?0:-100),[0,S]):c>-1?this.ret(-700-e.length,[c,c+this.pattern.length]):O==h?this.ret(-900-e.length,[m,S]):d==h?this.result(-100+(g?-200:0)+-700+(w?0:-1100),a,e):n.length==2?null:this.result((o[0]?-700:0)+-200+-1100,o,e)}result(e,n,s){let o=[],l=0;for(let a of n){let c=a+(this.astral?codePointSize(codePointAt(s,a)):1);l&&o[l-1]==a?o[l-1]=c:(o[l++]=a,o[l++]=c)}return this.ret(e-s.length,o)}}class StrictMatcher{constructor(e){this.pattern=e,this.matched=[],this.score=0,this.folded=e.toLowerCase()}match(e){if(e.length!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:defaultPositionInfo,filterStrict:!1,compareCompletions:(e,n)=>e.label.localeCompare(n.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(e,n)=>e&&n,closeOnBlur:(e,n)=>e&&n,icons:(e,n)=>e&&n,tooltipClass:(e,n)=>s=>joinClass(e(s),n(s)),optionClass:(e,n)=>s=>joinClass(e(s),n(s)),addToOptions:(e,n)=>e.concat(n),filterStrict:(e,n)=>e||n})}});function joinClass(r,e){return r?e?r+" "+e:r:e}function defaultPositionInfo(r,e,n,s,o,l){let a=r.textDirection==Direction.RTL,c=a,h=!1,f="top",u,d,g=e.left-o.left,O=o.right-e.right,m=s.right-s.left,S=s.bottom-s.top;if(c&&g=S||P>e.top?u=n.bottom-e.top:(f="bottom",u=e.bottom-n.top)}let b=(e.bottom-e.top)/l.offsetHeight,w=(e.right-e.left)/l.offsetWidth;return{style:`${f}: ${u/b}px; max-width: ${d/w}px`,class:"cm-completionInfo-"+(h?a?"left-narrow":"right-narrow":c?"left":"right")}}function optionContent(r){let e=r.addToOptions.slice();return r.icons&&e.push({render(n){let s=document.createElement("div");return s.classList.add("cm-completionIcon"),n.type&&s.classList.add(...n.type.split(/\s+/g).map(o=>"cm-completionIcon-"+o)),s.setAttribute("aria-hidden","true"),s},position:20}),e.push({render(n,s,o,l){let a=document.createElement("span");a.className="cm-completionLabel";let c=n.displayLabel||n.label,h=0;for(let f=0;fh&&a.appendChild(document.createTextNode(c.slice(h,u)));let g=a.appendChild(document.createElement("span"));g.appendChild(document.createTextNode(c.slice(u,d))),g.className="cm-completionMatchedText",h=d}return hn.position-s.position).map(n=>n.render)}function rangeAroundSelected(r,e,n){if(r<=n)return{from:0,to:r};if(e<0&&(e=0),e<=r>>1){let o=Math.floor(e/n);return{from:o*n,to:(o+1)*n}}let s=Math.floor((r-e)/n);return{from:r-(s+1)*n,to:r-s*n}}class CompletionTooltip{constructor(e,n,s){this.view=e,this.stateField=n,this.applyCompletion=s,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:h=>this.placeInfo(h),key:this},this.space=null,this.currentClass="";let o=e.state.field(n),{options:l,selected:a}=o.open,c=e.state.facet(completionConfig);this.optionContent=optionContent(c),this.optionClass=c.optionClass,this.tooltipClass=c.tooltipClass,this.range=rangeAroundSelected(l.length,a,c.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(e.state),this.dom.addEventListener("mousedown",h=>{let{options:f}=e.state.field(n).open;for(let u=h.target,d;u&&u!=this.dom;u=u.parentNode)if(u.nodeName=="LI"&&(d=/-(\d+)$/.exec(u.id))&&+d[1]{let f=e.state.field(this.stateField,!1);f&&f.tooltip&&e.state.facet(completionConfig).closeOnBlur&&h.relatedTarget!=e.contentDOM&&e.dispatch({effects:closeCompletionEffect.of(null)})}),this.showOptions(l,o.id)}mount(){this.updateSel()}showOptions(e,n){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(e,n,this.range)),this.list.addEventListener("scroll",()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}update(e){var n;let s=e.state.field(this.stateField),o=e.startState.field(this.stateField);if(this.updateTooltipClass(e.state),s!=o){let{options:l,selected:a,disabled:c}=s.open;(!o.open||o.open.options!=l)&&(this.range=rangeAroundSelected(l.length,a,e.state.facet(completionConfig).maxRenderedOptions),this.showOptions(l,s.id)),this.updateSel(),c!=((n=o.open)===null||n===void 0?void 0:n.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!c)}}updateTooltipClass(e){let n=this.tooltipClass(e);if(n!=this.currentClass){for(let s of this.currentClass.split(" "))s&&this.dom.classList.remove(s);for(let s of n.split(" "))s&&this.dom.classList.add(s);this.currentClass=n}}positioned(e){this.space=e,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let e=this.view.state.field(this.stateField),n=e.open;if((n.selected>-1&&n.selected=this.range.to)&&(this.range=rangeAroundSelected(n.options.length,n.selected,this.view.state.facet(completionConfig).maxRenderedOptions),this.showOptions(n.options,e.id)),this.updateSelectedOption(n.selected)){this.destroyInfo();let{completion:s}=n.options[n.selected],{info:o}=s;if(!o)return;let l=typeof o=="string"?document.createTextNode(o):o(s);if(!l)return;"then"in l?l.then(a=>{a&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(a,s)}).catch(a=>logException(this.view.state,a,"completion info")):this.addInfoPane(l,s)}}addInfoPane(e,n){this.destroyInfo();let s=this.info=document.createElement("div");if(s.className="cm-tooltip cm-completionInfo",e.nodeType!=null)s.appendChild(e),this.infoDestroy=null;else{let{dom:o,destroy:l}=e;s.appendChild(o),this.infoDestroy=l||null}this.dom.appendChild(s),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(e){let n=null;for(let s=this.list.firstChild,o=this.range.from;s;s=s.nextSibling,o++)s.nodeName!="LI"||!s.id?o--:o==e?s.hasAttribute("aria-selected")||(s.setAttribute("aria-selected","true"),n=s):s.hasAttribute("aria-selected")&&s.removeAttribute("aria-selected");return n&&scrollIntoView(this.list,n),n}measureInfo(){let e=this.dom.querySelector("[aria-selected]");if(!e||!this.info)return null;let n=this.dom.getBoundingClientRect(),s=this.info.getBoundingClientRect(),o=e.getBoundingClientRect(),l=this.space;if(!l){let a=this.dom.ownerDocument.defaultView||window;l={left:0,top:0,right:a.innerWidth,bottom:a.innerHeight}}return o.top>Math.min(l.bottom,n.bottom)-10||o.bottoms.from||s.from==0))if(l=g,typeof f!="string"&&f.header)o.appendChild(f.header(f));else{let O=o.appendChild(document.createElement("completion-section"));O.textContent=g}}const u=o.appendChild(document.createElement("li"));u.id=n+"-"+a,u.setAttribute("role","option");let d=this.optionClass(c);d&&(u.className=d);for(let g of this.optionContent){let O=g(c,this.view.state,this.view,h);O&&u.appendChild(O)}}return s.from&&o.classList.add("cm-completionListIncompleteTop"),s.tonew CompletionTooltip(n,r,e)}function scrollIntoView(r,e){let n=r.getBoundingClientRect(),s=e.getBoundingClientRect(),o=n.height/r.offsetHeight;s.topn.bottom&&(r.scrollTop+=(s.bottom-n.bottom)/o)}function score(r){return(r.boost||0)*100+(r.apply?10:0)+(r.info?5:0)+(r.type?1:0)}function sortOptions(r,e){let n=[],s=null,o=f=>{n.push(f);let{section:u}=f.completion;if(u){s||(s=[]);let d=typeof u=="string"?u:u.name;s.some(g=>g.name==d)||s.push(typeof u=="string"?{name:d}:u)}},l=e.facet(completionConfig);for(let f of r)if(f.hasResult()){let u=f.result.getMatch;if(f.result.filter===!1)for(let d of f.result.options)o(new Option(d,f.source,u?u(d):[],1e9-n.length));else{let d=e.sliceDoc(f.from,f.to),g,O=l.filterStrict?new StrictMatcher(d):new FuzzyMatcher(d);for(let m of f.result.options)if(g=O.match(m.label)){let S=m.displayLabel?u?u(m,g.matched):[]:g.matched;o(new Option(m,f.source,S,g.score+(m.boost||0)))}}}if(s){let f=Object.create(null),u=0,d=(g,O)=>{var m,S;return((m=g.rank)!==null&&m!==void 0?m:1e9)-((S=O.rank)!==null&&S!==void 0?S:1e9)||(g.named.score-u.score||h(u.completion,d.completion))){let u=f.completion;!c||c.label!=u.label||c.detail!=u.detail||c.type!=null&&u.type!=null&&c.type!=u.type||c.apply!=u.apply||c.boost!=u.boost?a.push(f):score(f.completion)>score(c)&&(a[a.length-1]=f),c=f.completion}return a}class CompletionDialog{constructor(e,n,s,o,l,a){this.options=e,this.attrs=n,this.tooltip=s,this.timestamp=o,this.selected=l,this.disabled=a}setSelected(e,n){return e==this.selected||e>=this.options.length?this:new CompletionDialog(this.options,makeAttrs(n,e),this.tooltip,this.timestamp,e,this.disabled)}static build(e,n,s,o,l){let a=sortOptions(e,n);if(!a.length)return o&&e.some(h=>h.state==1)?new CompletionDialog(o.options,o.attrs,o.tooltip,o.timestamp,o.selected,!0):null;let c=n.facet(completionConfig).selectOnOpen?0:-1;if(o&&o.selected!=c&&o.selected!=-1){let h=o.options[o.selected].completion;for(let f=0;ff.hasResult()?Math.min(h,f.from):h,1e8),create:createTooltip,above:l.aboveCursor},o?o.timestamp:Date.now(),c,!1)}map(e){return new CompletionDialog(this.options,this.attrs,Object.assign(Object.assign({},this.tooltip),{pos:e.mapPos(this.tooltip.pos)}),this.timestamp,this.selected,this.disabled)}}class CompletionState{constructor(e,n,s){this.active=e,this.id=n,this.open=s}static start(){return new CompletionState(none$1,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null)}update(e){let{state:n}=e,s=n.facet(completionConfig),l=(s.override||n.languageDataAt("autocomplete",cur(n)).map(asSource)).map(c=>(this.active.find(f=>f.source==c)||new ActiveSource(c,this.active.some(f=>f.state!=0)?1:0)).update(e,s));l.length==this.active.length&&l.every((c,h)=>c==this.active[h])&&(l=this.active);let a=this.open;a&&e.docChanged&&(a=a.map(e.changes)),e.selection||l.some(c=>c.hasResult()&&e.changes.touchesRange(c.from,c.to))||!sameResults(l,this.active)?a=CompletionDialog.build(l,n,this.id,a,s):a&&a.disabled&&!l.some(c=>c.state==1)&&(a=null),!a&&l.every(c=>c.state!=1)&&l.some(c=>c.hasResult())&&(l=l.map(c=>c.hasResult()?new ActiveSource(c.source,0):c));for(let c of e.effects)c.is(setSelectedEffect)&&(a=a&&a.setSelected(c.value,this.id));return l==this.active&&a==this.open?this:new CompletionState(l,this.id,a)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:baseAttrs}}function sameResults(r,e){if(r==e)return!0;for(let n=0,s=0;;){for(;n-1&&(n["aria-activedescendant"]=r+"-"+e),n}const none$1=[];function getUserEvent(r,e){if(r.isUserEvent("input.complete")){let n=r.annotation(pickedCompletion);if(n&&e.activateOnCompletion(n))return"input"}return r.isUserEvent("input.type")?"input":r.isUserEvent("delete.backward")?"delete":null}class ActiveSource{constructor(e,n,s=-1){this.source=e,this.state=n,this.explicitPos=s}hasResult(){return!1}update(e,n){let s=getUserEvent(e,n),o=this;s?o=o.handleUserEvent(e,s,n):e.docChanged?o=o.handleChange(e):e.selection&&o.state!=0&&(o=new ActiveSource(o.source,0));for(let l of e.effects)if(l.is(startCompletionEffect))o=new ActiveSource(o.source,1,l.value?cur(e.state):-1);else if(l.is(closeCompletionEffect))o=new ActiveSource(o.source,0);else if(l.is(setActiveEffect))for(let a of l.value)a.source==o.source&&(o=a);return o}handleUserEvent(e,n,s){return n=="delete"||!s.activateOnTyping?this.map(e.changes):new ActiveSource(this.source,1)}handleChange(e){return e.changes.touchesRange(cur(e.startState))?new ActiveSource(this.source,0):this.map(e.changes)}map(e){return e.empty||this.explicitPos<0?this:new ActiveSource(this.source,this.state,e.mapPos(this.explicitPos))}}class ActiveResult extends ActiveSource{constructor(e,n,s,o,l){super(e,2,n),this.result=s,this.from=o,this.to=l}hasResult(){return!0}handleUserEvent(e,n,s){var o;let l=this.result;l.map&&!e.changes.empty&&(l=l.map(l,e.changes));let a=e.changes.mapPos(this.from),c=e.changes.mapPos(this.to,1),h=cur(e.state);if((this.explicitPos<0?h<=a:hc||!l||n=="delete"&&cur(e.startState)==this.from)return new ActiveSource(this.source,n=="input"&&s.activateOnTyping?1:0);let f=this.explicitPos<0?-1:e.changes.mapPos(this.explicitPos);return checkValid(l.validFor,e.state,a,c)?new ActiveResult(this.source,f,l,a,c):l.update&&(l=l.update(l,a,c,new CompletionContext(e.state,h,f>=0)))?new ActiveResult(this.source,f,l,l.from,(o=l.to)!==null&&o!==void 0?o:cur(e.state)):new ActiveSource(this.source,1,f)}handleChange(e){return e.changes.touchesRange(this.from,this.to)?new ActiveSource(this.source,0):this.map(e.changes)}map(e){return e.empty?this:(this.result.map?this.result.map(this.result,e):this.result)?new ActiveResult(this.source,this.explicitPos<0?-1:e.mapPos(this.explicitPos),this.result,e.mapPos(this.from),e.mapPos(this.to,1)):new ActiveSource(this.source,0)}}function checkValid(r,e,n,s){if(!r)return!1;let o=e.sliceDoc(n,s);return typeof r=="function"?r(o,n,s,e):ensureAnchor(r,!0).test(o)}const setActiveEffect=StateEffect.define({map(r,e){return r.map(n=>n.map(e))}}),setSelectedEffect=StateEffect.define(),completionState=StateField.define({create(){return CompletionState.start()},update(r,e){return r.update(e)},provide:r=>[showTooltip.from(r,e=>e.tooltip),EditorView.contentAttributes.from(r,e=>e.attrs)]});function applyCompletion(r,e){const n=e.completion.apply||e.completion.label;let s=r.state.field(completionState).active.find(o=>o.source==e.source);return s instanceof ActiveResult?(typeof n=="string"?r.dispatch(Object.assign(Object.assign({},insertCompletionText(r.state,n,s.from,s.to)),{annotations:pickedCompletion.of(e.completion)})):n(r,e.completion,s.from,s.to),!0):!1}const createTooltip=completionTooltip(completionState,applyCompletion);function moveCompletionSelection(r,e="option"){return n=>{let s=n.state.field(completionState,!1);if(!s||!s.open||s.open.disabled||Date.now()-s.open.timestamp-1?s.open.selected+o*(r?1:-1):r?0:a-1;return c<0?c=e=="page"?0:a-1:c>=a&&(c=e=="page"?a-1:0),n.dispatch({effects:setSelectedEffect.of(c)}),!0}}const acceptCompletion=r=>{let e=r.state.field(completionState,!1);return r.state.readOnly||!e||!e.open||e.open.selected<0||e.open.disabled||Date.now()-e.open.timestampr.state.field(completionState,!1)?(r.dispatch({effects:startCompletionEffect.of(!0)}),!0):!1,closeCompletion=r=>{let e=r.state.field(completionState,!1);return!e||!e.active.some(n=>n.state!=0)?!1:(r.dispatch({effects:closeCompletionEffect.of(null)}),!0)};class RunningQuery{constructor(e,n){this.active=e,this.context=n,this.time=Date.now(),this.updates=[],this.done=void 0}}const MaxUpdateCount=50,MinAbortTime=1e3,completionPlugin=ViewPlugin.fromClass(class{constructor(r){this.view=r,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let e of r.state.field(completionState).active)e.state==1&&this.startQuery(e)}update(r){let e=r.state.field(completionState),n=r.state.facet(completionConfig);if(!r.selectionSet&&!r.docChanged&&r.startState.field(completionState)==e)return;let s=r.transactions.some(l=>(l.selection||l.docChanged)&&!getUserEvent(l,n));for(let l=0;lMaxUpdateCount&&Date.now()-a.time>MinAbortTime){for(let c of a.context.abortListeners)try{c()}catch(h){logException(this.view.state,h)}a.context.abortListeners=null,this.running.splice(l--,1)}else a.updates.push(...r.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),r.transactions.some(l=>l.effects.some(a=>a.is(startCompletionEffect)))&&(this.pendingStart=!0);let o=this.pendingStart?50:n.activateOnTypingDelay;if(this.debounceUpdate=e.active.some(l=>l.state==1&&!this.running.some(a=>a.active.source==l.source))?setTimeout(()=>this.startUpdate(),o):-1,this.composing!=0)for(let l of r.transactions)getUserEvent(l,n)=="input"?this.composing=2:this.composing==2&&l.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:r}=this.view,e=r.field(completionState);for(let n of e.active)n.state==1&&!this.running.some(s=>s.active.source==n.source)&&this.startQuery(n)}startQuery(r){let{state:e}=this.view,n=cur(e),s=new CompletionContext(e,n,r.explicitPos==n),o=new RunningQuery(r,s);this.running.push(o),Promise.resolve(r.source(s)).then(l=>{o.context.aborted||(o.done=l||null,this.scheduleAccept())},l=>{this.view.dispatch({effects:closeCompletionEffect.of(null)}),logException(this.view.state,l)})}scheduleAccept(){this.running.every(r=>r.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(completionConfig).updateSyncTime))}accept(){var r;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],n=this.view.state.facet(completionConfig);for(let s=0;sa.source==o.active.source);if(l&&l.state==1)if(o.done==null){let a=new ActiveSource(o.active.source,0);for(let c of o.updates)a=a.update(c,n);a.state!=1&&e.push(a)}else this.startQuery(l)}e.length&&this.view.dispatch({effects:setActiveEffect.of(e)})}},{eventHandlers:{blur(r){let e=this.view.state.field(completionState,!1);if(e&&e.tooltip&&this.view.state.facet(completionConfig).closeOnBlur){let n=e.open&&getTooltip(this.view,e.open.tooltip);(!n||!n.dom.contains(r.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:closeCompletionEffect.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:startCompletionEffect.of(!1)}),20),this.composing=0}}}),windows=typeof navigator=="object"&&/Win/.test(navigator.platform),commitCharacters=Prec.highest(EditorView.domEventHandlers({keydown(r,e){let n=e.state.field(completionState,!1);if(!n||!n.open||n.open.disabled||n.open.selected<0||r.key.length>1||r.ctrlKey&&!(windows&&r.altKey)||r.metaKey)return!1;let s=n.open.options[n.open.selected],o=n.active.find(a=>a.source==s.source),l=s.completion.commitCharacters||o.result.commitCharacters;return l&&l.indexOf(r.key)>-1&&applyCompletion(e,s),!1}})),baseTheme$2=EditorView.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:"monospace",whiteSpace:"nowrap",overflow:"hidden auto",maxWidth_fallback:"700px",maxWidth:"min(700px, 95vw)",minWidth:"250px",maxHeight:"10em",height:"100%",listStyle:"none",margin:0,padding:0,"& > li, & > completion-section":{padding:"1px 3px",lineHeight:1.2},"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer"},"& > completion-section":{display:"list-item",borderBottom:"1px solid silver",paddingLeft:"0.5em",opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#777"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#444"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"···"',opacity:.5,display:"block",textAlign:"center"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"400px",boxSizing:"border-box"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:"30px"},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"30px"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6",boxSizing:"content-box"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'ƒ'"}},".cm-completionIcon-class":{"&:after":{content:"'○'"}},".cm-completionIcon-interface":{"&:after":{content:"'◌'"}},".cm-completionIcon-variable":{"&:after":{content:"'𝑥'"}},".cm-completionIcon-constant":{"&:after":{content:"'𝐶'"}},".cm-completionIcon-type":{"&:after":{content:"'𝑡'"}},".cm-completionIcon-enum":{"&:after":{content:"'∪'"}},".cm-completionIcon-property":{"&:after":{content:"'□'"}},".cm-completionIcon-keyword":{"&:after":{content:"'🔑︎'"}},".cm-completionIcon-namespace":{"&:after":{content:"'▢'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}});class FieldPos{constructor(e,n,s,o){this.field=e,this.line=n,this.from=s,this.to=o}}class FieldRange{constructor(e,n,s){this.field=e,this.from=n,this.to=s}map(e){let n=e.mapPos(this.from,-1,MapMode.TrackDel),s=e.mapPos(this.to,1,MapMode.TrackDel);return n==null||s==null?null:new FieldRange(this.field,n,s)}}class Snippet{constructor(e,n){this.lines=e,this.fieldPositions=n}instantiate(e,n){let s=[],o=[n],l=e.doc.lineAt(n),a=/^\s*/.exec(l.text)[0];for(let h of this.lines){if(s.length){let f=a,u=/^\t*/.exec(h)[0].length;for(let d=0;dnew FieldRange(h.field,o[h.line]+h.from,o[h.line]+h.to));return{text:s,ranges:c}}static parse(e){let n=[],s=[],o=[],l;for(let a of e.split(/\r\n?|\n/)){for(;l=/[#$]\{(?:(\d+)(?::([^}]*))?|((?:\\[{}]|[^}])*))\}/.exec(a);){let c=l[1]?+l[1]:null,h=l[2]||l[3]||"",f=-1,u=h.replace(/\\[{}]/g,d=>d[1]);for(let d=0;d=f&&g.field++}o.push(new FieldPos(f,s.length,l.index,l.index+u.length)),a=a.slice(0,l.index)+h+a.slice(l.index+l[0].length)}a=a.replace(/\\([{}])/g,(c,h,f)=>{for(let u of o)u.line==s.length&&u.from>f&&(u.from--,u.to--);return h}),s.push(a)}return new Snippet(s,o)}}let fieldMarker=Decoration.widget({widget:new class extends WidgetType{toDOM(){let r=document.createElement("span");return r.className="cm-snippetFieldPosition",r}ignoreEvent(){return!1}}}),fieldRange=Decoration.mark({class:"cm-snippetField"});class ActiveSnippet{constructor(e,n){this.ranges=e,this.active=n,this.deco=Decoration.set(e.map(s=>(s.from==s.to?fieldMarker:fieldRange).range(s.from,s.to)))}map(e){let n=[];for(let s of this.ranges){let o=s.map(e);if(!o)return null;n.push(o)}return new ActiveSnippet(n,this.active)}selectionInsideField(e){return e.ranges.every(n=>this.ranges.some(s=>s.field==this.active&&s.from<=n.from&&s.to>=n.to))}}const setActive=StateEffect.define({map(r,e){return r&&r.map(e)}}),moveToField=StateEffect.define(),snippetState=StateField.define({create(){return null},update(r,e){for(let n of e.effects){if(n.is(setActive))return n.value;if(n.is(moveToField)&&r)return new ActiveSnippet(r.ranges,n.value)}return r&&e.docChanged&&(r=r.map(e.changes)),r&&e.selection&&!r.selectionInsideField(e.selection)&&(r=null),r},provide:r=>EditorView.decorations.from(r,e=>e?e.deco:Decoration.none)});function fieldSelection(r,e){return EditorSelection.create(r.filter(n=>n.field==e).map(n=>EditorSelection.range(n.from,n.to)))}function snippet(r){let e=Snippet.parse(r);return(n,s,o,l)=>{let{text:a,ranges:c}=e.instantiate(n.state,o),h={changes:{from:o,to:l,insert:Text.of(a)},scrollIntoView:!0,annotations:s?[pickedCompletion.of(s),Transaction.userEvent.of("input.complete")]:void 0};if(c.length&&(h.selection=fieldSelection(c,0)),c.some(f=>f.field>0)){let f=new ActiveSnippet(c,0),u=h.effects=[setActive.of(f)];n.state.field(snippetState,!1)===void 0&&u.push(StateEffect.appendConfig.of([snippetState,addSnippetKeymap,snippetPointerHandler,baseTheme$2]))}n.dispatch(n.state.update(h))}}function moveField(r){return({state:e,dispatch:n})=>{let s=e.field(snippetState,!1);if(!s||r<0&&s.active==0)return!1;let o=s.active+r,l=r>0&&!s.ranges.some(a=>a.field==o+r);return n(e.update({selection:fieldSelection(s.ranges,o),effects:setActive.of(l?null:new ActiveSnippet(s.ranges,o)),scrollIntoView:!0})),!0}}const clearSnippet=({state:r,dispatch:e})=>r.field(snippetState,!1)?(e(r.update({effects:setActive.of(null)})),!0):!1,nextSnippetField=moveField(1),prevSnippetField=moveField(-1),defaultSnippetKeymap=[{key:"Tab",run:nextSnippetField,shift:prevSnippetField},{key:"Escape",run:clearSnippet}],snippetKeymap=Facet.define({combine(r){return r.length?r[0]:defaultSnippetKeymap}}),addSnippetKeymap=Prec.highest(keymap.compute([snippetKeymap],r=>r.facet(snippetKeymap)));function snippetCompletion(r,e){return Object.assign(Object.assign({},e),{apply:snippet(r)})}const snippetPointerHandler=EditorView.domEventHandlers({mousedown(r,e){let n=e.state.field(snippetState,!1),s;if(!n||(s=e.posAtCoords({x:r.clientX,y:r.clientY}))==null)return!1;let o=n.ranges.find(l=>l.from<=s&&l.to>=s);return!o||o.field==n.active?!1:(e.dispatch({selection:fieldSelection(n.ranges,o.field),effects:setActive.of(n.ranges.some(l=>l.field>o.field)?new ActiveSnippet(n.ranges,o.field):null),scrollIntoView:!0}),!0)}}),defaults={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},closeBracketEffect=StateEffect.define({map(r,e){let n=e.mapPos(r,-1,MapMode.TrackAfter);return n??void 0}}),closedBracket=new class extends RangeValue{};closedBracket.startSide=1;closedBracket.endSide=-1;const bracketState=StateField.define({create(){return RangeSet.empty},update(r,e){if(r=r.map(e.changes),e.selection){let n=e.state.doc.lineAt(e.selection.main.head);r=r.update({filter:s=>s>=n.from&&s<=n.to})}for(let n of e.effects)n.is(closeBracketEffect)&&(r=r.update({add:[closedBracket.range(n.value,n.value+1)]}));return r}});function closeBrackets(){return[inputHandler,bracketState]}const definedClosing="()[]{}<>";function closing(r){for(let e=0;e{if((android$1?r.composing:r.compositionStarted)||r.state.readOnly)return!1;let o=r.state.selection.main;if(s.length>2||s.length==2&&codePointSize(codePointAt(s,0))==1||e!=o.from||n!=o.to)return!1;let l=insertBracket(r.state,s);return l?(r.dispatch(l),!0):!1}),deleteBracketPair=({state:r,dispatch:e})=>{if(r.readOnly)return!1;let s=config(r,r.selection.main.head).brackets||defaults.brackets,o=null,l=r.changeByRange(a=>{if(a.empty){let c=prevChar(r.doc,a.head);for(let h of s)if(h==c&&nextChar(r.doc,a.head)==closing(codePointAt(h,0)))return{changes:{from:a.head-h.length,to:a.head+h.length},range:EditorSelection.cursor(a.head-h.length)}}return{range:o=a}});return o||e(r.update(l,{scrollIntoView:!0,userEvent:"delete.backward"})),!o},closeBracketsKeymap=[{key:"Backspace",run:deleteBracketPair}];function insertBracket(r,e){let n=config(r,r.selection.main.head),s=n.brackets||defaults.brackets;for(let o of s){let l=closing(codePointAt(o,0));if(e==o)return l==o?handleSame(r,o,s.indexOf(o+o+o)>-1,n):handleOpen(r,o,l,n.before||defaults.before);if(e==l&&closedBracketAt(r,r.selection.main.from))return handleClose(r,o,l)}return null}function closedBracketAt(r,e){let n=!1;return r.field(bracketState).between(0,r.doc.length,s=>{s==e&&(n=!0)}),n}function nextChar(r,e){let n=r.sliceString(e,e+2);return n.slice(0,codePointSize(codePointAt(n,0)))}function prevChar(r,e){let n=r.sliceString(e-2,e);return codePointSize(codePointAt(n,0))==n.length?n:n.slice(1)}function handleOpen(r,e,n,s){let o=null,l=r.changeByRange(a=>{if(!a.empty)return{changes:[{insert:e,from:a.from},{insert:n,from:a.to}],effects:closeBracketEffect.of(a.to+e.length),range:EditorSelection.range(a.anchor+e.length,a.head+e.length)};let c=nextChar(r.doc,a.head);return!c||/\s/.test(c)||s.indexOf(c)>-1?{changes:{insert:e+n,from:a.head},effects:closeBracketEffect.of(a.head+e.length),range:EditorSelection.cursor(a.head+e.length)}:{range:o=a}});return o?null:r.update(l,{scrollIntoView:!0,userEvent:"input.type"})}function handleClose(r,e,n){let s=null,o=r.changeByRange(l=>l.empty&&nextChar(r.doc,l.head)==n?{changes:{from:l.head,to:l.head+n.length,insert:n},range:EditorSelection.cursor(l.head+n.length)}:s={range:l});return s?null:r.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function handleSame(r,e,n,s){let o=s.stringPrefixes||defaults.stringPrefixes,l=null,a=r.changeByRange(c=>{if(!c.empty)return{changes:[{insert:e,from:c.from},{insert:e,from:c.to}],effects:closeBracketEffect.of(c.to+e.length),range:EditorSelection.range(c.anchor+e.length,c.head+e.length)};let h=c.head,f=nextChar(r.doc,h),u;if(f==e){if(nodeStart(r,h))return{changes:{insert:e+e,from:h},effects:closeBracketEffect.of(h+e.length),range:EditorSelection.cursor(h+e.length)};if(closedBracketAt(r,h)){let g=n&&r.sliceDoc(h,h+e.length*3)==e+e+e?e+e+e:e;return{changes:{from:h,to:h+g.length,insert:g},range:EditorSelection.cursor(h+g.length)}}}else{if(n&&r.sliceDoc(h-2*e.length,h)==e+e&&(u=canStartStringAt(r,h-2*e.length,o))>-1&&nodeStart(r,u))return{changes:{insert:e+e+e+e,from:h},effects:closeBracketEffect.of(h+e.length),range:EditorSelection.cursor(h+e.length)};if(r.charCategorizer(h)(f)!=CharCategory.Word&&canStartStringAt(r,h,o)>-1&&!probablyInString(r,h,e,o))return{changes:{insert:e+e,from:h},effects:closeBracketEffect.of(h+e.length),range:EditorSelection.cursor(h+e.length)}}return{range:l=c}});return l?null:r.update(a,{scrollIntoView:!0,userEvent:"input.type"})}function nodeStart(r,e){let n=syntaxTree(r).resolveInner(e+1);return n.parent&&n.from==e}function probablyInString(r,e,n,s){let o=syntaxTree(r).resolveInner(e,-1),l=s.reduce((a,c)=>Math.max(a,c.length),0);for(let a=0;a<5;a++){let c=r.sliceDoc(o.from,Math.min(o.to,o.from+n.length+l)),h=c.indexOf(n);if(!h||h>-1&&s.indexOf(c.slice(0,h))>-1){let u=o.firstChild;for(;u&&u.from==o.from&&u.to-u.from>n.length+h;){if(r.sliceDoc(u.to-n.length,u.to)==n)return!1;u=u.firstChild}return!0}let f=o.to==e&&o.parent;if(!f)break;o=f}return!1}function canStartStringAt(r,e,n){let s=r.charCategorizer(e);if(s(r.sliceDoc(e-1,e))!=CharCategory.Word)return e;for(let o of n){let l=e-o.length;if(r.sliceDoc(l,e)==o&&s(r.sliceDoc(l-1,l))!=CharCategory.Word)return l}return-1}function autocompletion(r={}){return[commitCharacters,completionState,completionConfig.of(r),completionPlugin,completionKeymapExt,baseTheme$2]}const completionKeymap=[{key:"Ctrl-Space",run:startCompletion},{key:"Escape",run:closeCompletion},{key:"ArrowDown",run:moveCompletionSelection(!0)},{key:"ArrowUp",run:moveCompletionSelection(!1)},{key:"PageDown",run:moveCompletionSelection(!0,"page")},{key:"PageUp",run:moveCompletionSelection(!1,"page")},{key:"Enter",run:acceptCompletion}],completionKeymapExt=Prec.highest(keymap.computeN([completionConfig],r=>r.facet(completionConfig).defaultKeymap?[completionKeymap]:[])),snippets=[snippetCompletion("function ${name}(${params}) {\n ${}\n}",{label:"function",detail:"definition",type:"keyword"}),snippetCompletion("for (let ${index} = 0; ${index} < ${bound}; ${index}++) {\n ${}\n}",{label:"for",detail:"loop",type:"keyword"}),snippetCompletion("for (let ${name} of ${collection}) {\n ${}\n}",{label:"for",detail:"of loop",type:"keyword"}),snippetCompletion("do {\n ${}\n} while (${})",{label:"do",detail:"loop",type:"keyword"}),snippetCompletion("while (${}) {\n ${}\n}",{label:"while",detail:"loop",type:"keyword"}),snippetCompletion(`try { \${} } catch (\${error}) { \${} @@ -90,13 +90,24 @@ constructor(\${params}) { \${} } -}`,{label:"class",detail:"definition",type:"keyword"}),snippetCompletion('import {${names}} from "${module}"\n${}',{label:"import",detail:"named",type:"keyword"}),snippetCompletion('import ${name} from "${module}"\n${}',{label:"import",detail:"default",type:"keyword"})],typescriptSnippets=snippets.concat([snippetCompletion("interface ${name} {\n ${}\n}",{label:"interface",detail:"definition",type:"keyword"}),snippetCompletion("type ${name} = ${type}",{label:"type",detail:"definition",type:"keyword"}),snippetCompletion("enum ${name} {\n ${}\n}",{label:"enum",detail:"definition",type:"keyword"})]),cache=new NodeWeakMap,ScopeNodes=new Set(["Script","Block","FunctionExpression","FunctionDeclaration","ArrowFunction","MethodDeclaration","ForStatement"]);function defID(r){return(e,n)=>{let s=e.node.getChild("VariableDefinition");return s&&n(s,r),!0}}const functionContext=["FunctionDeclaration"],gatherCompletions={FunctionDeclaration:defID("function"),ClassDeclaration:defID("class"),ClassExpression:()=>!0,EnumDeclaration:defID("constant"),TypeAliasDeclaration:defID("type"),NamespaceDeclaration:defID("namespace"),VariableDefinition(r,e){r.matchContext(functionContext)||e(r,"variable")},TypeDefinition(r,e){e(r,"type")},__proto__:null};function getScope(r,e){let n=cache.get(e);if(n)return n;let s=[],o=!0;function l(a,c){let h=r.sliceString(a.from,a.to);s.push({label:h,type:c})}return e.cursor(IterMode.IncludeAnonymous).iterate(a=>{if(o)o=!1;else if(a.name){let c=gatherCompletions[a.name];if(c&&c(a,l)||ScopeNodes.has(a.name))return!1}else if(a.to-a.from>8192){for(let c of getScope(r,a.node))s.push(c);return!1}}),cache.set(e,s),s}const Identifier=/^[\w$\xa1-\uffff][\w$\d\xa1-\uffff]*$/,dontComplete=["TemplateString","String","RegExp","LineComment","BlockComment","VariableDefinition","TypeDefinition","Label","PropertyDefinition","PropertyName","PrivatePropertyDefinition","PrivatePropertyName",".","?."];function localCompletionSource(r){let e=syntaxTree(r.state).resolveInner(r.pos,-1);if(dontComplete.indexOf(e.name)>-1)return null;let n=e.name=="VariableName"||e.to-e.from<20&&Identifier.test(r.state.sliceDoc(e.from,e.to));if(!n&&!r.explicit)return null;let s=[];for(let o=e;o;o=o.parent)ScopeNodes.has(o.name)&&(s=s.concat(getScope(r.state.doc,o)));return{options:s,from:n?e.from:r.pos,validFor:Identifier}}const javascriptLanguage=LRLanguage.define({name:"javascript",parser:parser.configure({props:[indentNodeProp.add({IfStatement:continuedIndent({except:/^\s*({|else\b)/}),TryStatement:continuedIndent({except:/^\s*({|catch\b|finally\b)/}),LabeledStatement:flatIndent,SwitchBody:r=>{let e=r.textAfter,n=/^\s*\}/.test(e),s=/^\s*(case|default)\b/.test(e);return r.baseIndent+(n?0:s?1:2)*r.unit},Block:delimitedIndent({closing:"}"}),ArrowFunction:r=>r.baseIndent+r.unit,"TemplateString BlockComment":()=>null,"Statement Property":continuedIndent({except:/^{/}),JSXElement(r){let e=/^\s*<\//.test(r.textAfter);return r.lineIndent(r.node.from)+(e?0:r.unit)},JSXEscape(r){let e=/\s*\}/.test(r.textAfter);return r.lineIndent(r.node.from)+(e?0:r.unit)},"JSXOpenTag JSXSelfClosingTag"(r){return r.column(r.node.from)+r.unit}}),foldNodeProp.add({"Block ClassBody SwitchBody EnumBody ObjectExpression ArrayExpression ObjectType":foldInside,BlockComment(r){return{from:r.from+2,to:r.to-2}}})]}),languageData:{closeBrackets:{brackets:["(","[","{","'",'"',"`"]},commentTokens:{line:"//",block:{open:"/*",close:"*/"}},indentOnInput:/^\s*(?:case |default:|\{|\}|<\/)$/,wordChars:"$"}}),jsxSublanguage={test:r=>/^JSX/.test(r.name),facet:defineLanguageFacet({commentTokens:{block:{open:"{/*",close:"*/}"}}})},typescriptLanguage=javascriptLanguage.configure({dialect:"ts"},"typescript"),jsxLanguage=javascriptLanguage.configure({dialect:"jsx",props:[sublanguageProp.add(r=>r.isTop?[jsxSublanguage]:void 0)]}),tsxLanguage=javascriptLanguage.configure({dialect:"jsx ts",props:[sublanguageProp.add(r=>r.isTop?[jsxSublanguage]:void 0)]},"typescript");let kwCompletion=r=>({label:r,type:"keyword"});const keywords="break case const continue default delete export extends false finally in instanceof let new return static super switch this throw true typeof var yield".split(" ").map(kwCompletion),typescriptKeywords=keywords.concat(["declare","implements","private","protected","public"].map(kwCompletion));function javascript(r={}){let e=r.jsx?r.typescript?tsxLanguage:jsxLanguage:r.typescript?typescriptLanguage:javascriptLanguage,n=r.typescript?typescriptSnippets.concat(typescriptKeywords):snippets.concat(keywords);return new LanguageSupport(e,[javascriptLanguage.data.of({autocomplete:ifNotIn(dontComplete,completeFromList(n))}),javascriptLanguage.data.of({autocomplete:localCompletionSource}),r.jsx?autoCloseTags:[]])}function findOpenTag(r){for(;;){if(r.name=="JSXOpenTag"||r.name=="JSXSelfClosingTag"||r.name=="JSXFragmentTag")return r;if(r.name=="JSXEscape"||!r.parent)return null;r=r.parent}}function elementName(r,e,n=r.length){for(let s=e==null?void 0:e.firstChild;s;s=s.nextSibling)if(s.name=="JSXIdentifier"||s.name=="JSXBuiltin"||s.name=="JSXNamespacedName"||s.name=="JSXMemberExpression")return r.sliceString(s.from,Math.min(s.to,n));return""}const android=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),autoCloseTags=EditorView.inputHandler.of((r,e,n,s,o)=>{if((android?r.composing:r.compositionStarted)||r.state.readOnly||e!=n||s!=">"&&s!="/"||!javascriptLanguage.isActiveAt(r.state,e,-1))return!1;let l=o(),{state:a}=l,c=a.changeByRange(h=>{var f;let{head:u}=h,d=syntaxTree(a).resolveInner(u-1,-1),g;if(d.name=="JSXStartTag"&&(d=d.parent),!(a.doc.sliceString(u-1,u)!=s||d.name=="JSXAttributeValue"&&d.to>u)){if(s==">"&&d.name=="JSXFragmentTag")return{range:h,changes:{from:u,insert:""}};if(s=="/"&&d.name=="JSXStartCloseTag"){let O=d.parent,m=O.parent;if(m&&O.from==u-2&&((g=elementName(a.doc,m.firstChild,u))||((f=m.firstChild)===null||f===void 0?void 0:f.name)=="JSXFragmentTag")){let y=`${g}>`;return{range:EditorSelection.cursor(u+y.length,-1),changes:{from:u,insert:y}}}}else if(s==">"){let O=findOpenTag(d);if(O&&O.name=="JSXOpenTag"&&!/^\/?>|^<\//.test(a.doc.sliceString(u,u+2))&&(g=elementName(a.doc,O,u)))return{range:h,changes:{from:u,insert:``}}}}return{range:h}});return c.changes.empty?!1:(r.dispatch([l,a.update(c,{userEvent:"input.complete",scrollIntoView:!0})]),!0)}),toggleComment=r=>{let{state:e}=r,n=e.doc.lineAt(e.selection.main.from),s=getConfig(r.state,n.from);return s.line?toggleLineComment(r):s.block?toggleBlockCommentByLine(r):!1};function command(r,e){return({state:n,dispatch:s})=>{if(n.readOnly)return!1;let o=r(e,n);return o?(s(n.update(o)),!0):!1}}const toggleLineComment=command(changeLineComment,0),toggleBlockComment=command(changeBlockComment,0),toggleBlockCommentByLine=command((r,e)=>changeBlockComment(r,e,selectedLineRanges(e)),0);function getConfig(r,e){let n=r.languageDataAt("commentTokens",e);return n.length?n[0]:{}}const SearchMargin=50;function findBlockComment(r,{open:e,close:n},s,o){let l=r.sliceDoc(s-SearchMargin,s),a=r.sliceDoc(o,o+SearchMargin),c=/\s*$/.exec(l)[0].length,h=/^\s*/.exec(a)[0].length,f=l.length-c;if(l.slice(f-e.length,f)==e&&a.slice(h,h+n.length)==n)return{open:{pos:s-c,margin:c&&1},close:{pos:o+h,margin:h&&1}};let u,d;o-s<=2*SearchMargin?u=d=r.sliceDoc(s,o):(u=r.sliceDoc(s,s+SearchMargin),d=r.sliceDoc(o-SearchMargin,o));let g=/^\s*/.exec(u)[0].length,O=/\s*$/.exec(d)[0].length,m=d.length-O-n.length;return u.slice(g,g+e.length)==e&&d.slice(m,m+n.length)==n?{open:{pos:s+g+e.length,margin:/\s/.test(u.charAt(g+e.length))?1:0},close:{pos:o-O-n.length,margin:/\s/.test(d.charAt(m-1))?1:0}}:null}function selectedLineRanges(r){let e=[];for(let n of r.selection.ranges){let s=r.doc.lineAt(n.from),o=n.to<=s.to?s:r.doc.lineAt(n.to),l=e.length-1;l>=0&&e[l].to>s.from?e[l].to=o.to:e.push({from:s.from+/^\s*/.exec(s.text)[0].length,to:o.to})}return e}function changeBlockComment(r,e,n=e.selection.ranges){let s=n.map(l=>getConfig(e,l.from).block);if(!s.every(l=>l))return null;let o=n.map((l,a)=>findBlockComment(e,s[a],l.from,l.to));if(r!=2&&!o.every(l=>l))return{changes:e.changes(n.map((l,a)=>o[a]?[]:[{from:l.from,insert:s[a].open+" "},{from:l.to,insert:" "+s[a].close}]))};if(r!=1&&o.some(l=>l)){let l=[];for(let a=0,c;ao&&(l==a||a>d.from)){o=d.from;let g=/^\s*/.exec(d.text)[0].length,O=g==d.length,m=d.text.slice(g,g+f.length)==f?g:-1;gl.comment<0&&(!l.empty||l.single))){let l=[];for(let{line:c,token:h,indent:f,empty:u,single:d}of s)(d||!u)&&l.push({from:c.from+f,insert:h+" "});let a=e.changes(l);return{changes:a,selection:e.selection.map(a,1)}}else if(r!=1&&s.some(l=>l.comment>=0)){let l=[];for(let{line:a,comment:c,token:h}of s)if(c>=0){let f=a.from+c,u=f+h.length;a.text[u-a.from]==" "&&u++,l.push({from:f,to:u})}return{changes:l}}return null}const fromHistory=Annotation.define(),isolateHistory=Annotation.define(),invertedEffects=Facet.define(),historyConfig=Facet.define({combine(r){return combineConfig(r,{minDepth:100,newGroupDelay:500,joinToEvent:(e,n)=>n},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,n)=>(s,o)=>e(s,o)||n(s,o)})}}),historyField_=StateField.define({create(){return HistoryState.empty},update(r,e){let n=e.state.facet(historyConfig),s=e.annotation(fromHistory);if(s){let h=HistEvent.fromTransaction(e,s.selection),f=s.side,u=f==0?r.undone:r.done;return h?u=updateBranch(u,u.length,n.minDepth,h):u=addSelection(u,e.startState.selection),new HistoryState(f==0?s.rest:u,f==0?u:s.rest)}let o=e.annotation(isolateHistory);if((o=="full"||o=="before")&&(r=r.isolate()),e.annotation(Transaction.addToHistory)===!1)return e.changes.empty?r:r.addMapping(e.changes.desc);let l=HistEvent.fromTransaction(e),a=e.annotation(Transaction.time),c=e.annotation(Transaction.userEvent);return l?r=r.addChanges(l,a,c,n,e):e.selection&&(r=r.addSelection(e.startState.selection,a,c,n.newGroupDelay)),(o=="full"||o=="after")&&(r=r.isolate()),r},toJSON(r){return{done:r.done.map(e=>e.toJSON()),undone:r.undone.map(e=>e.toJSON())}},fromJSON(r){return new HistoryState(r.done.map(HistEvent.fromJSON),r.undone.map(HistEvent.fromJSON))}});function history(r={}){return[historyField_,historyConfig.of(r),EditorView.domEventHandlers({beforeinput(e,n){let s=e.inputType=="historyUndo"?undo:e.inputType=="historyRedo"?redo:null;return s?(e.preventDefault(),s(n)):!1}})]}function cmd(r,e){return function({state:n,dispatch:s}){if(!e&&n.readOnly)return!1;let o=n.field(historyField_,!1);if(!o)return!1;let l=o.pop(r,n,e);return l?(s(l),!0):!1}}const undo=cmd(0,!1),redo=cmd(1,!1),undoSelection=cmd(0,!0),redoSelection=cmd(1,!0);class HistEvent{constructor(e,n,s,o,l){this.changes=e,this.effects=n,this.mapped=s,this.startSelection=o,this.selectionsAfter=l}setSelAfter(e){return new HistEvent(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,n,s;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(n=this.mapped)===null||n===void 0?void 0:n.toJSON(),startSelection:(s=this.startSelection)===null||s===void 0?void 0:s.toJSON(),selectionsAfter:this.selectionsAfter.map(o=>o.toJSON())}}static fromJSON(e){return new HistEvent(e.changes&&ChangeSet.fromJSON(e.changes),[],e.mapped&&ChangeDesc.fromJSON(e.mapped),e.startSelection&&EditorSelection.fromJSON(e.startSelection),e.selectionsAfter.map(EditorSelection.fromJSON))}static fromTransaction(e,n){let s=none;for(let o of e.startState.facet(invertedEffects)){let l=o(e);l.length&&(s=s.concat(l))}return!s.length&&e.changes.empty?null:new HistEvent(e.changes.invert(e.startState.doc),s,void 0,n||e.startState.selection,none)}static selection(e){return new HistEvent(void 0,none,void 0,void 0,e)}}function updateBranch(r,e,n,s){let o=e+1>n+20?e-n-1:0,l=r.slice(o,e);return l.push(s),l}function isAdjacent(r,e){let n=[],s=!1;return r.iterChangedRanges((o,l)=>n.push(o,l)),e.iterChangedRanges((o,l,a,c)=>{for(let h=0;h=f&&a<=u&&(s=!0)}}),s}function eqSelectionShape(r,e){return r.ranges.length==e.ranges.length&&r.ranges.filter((n,s)=>n.empty!=e.ranges[s].empty).length===0}function conc(r,e){return r.length?e.length?r.concat(e):r:e}const none=[],MaxSelectionsPerEvent=200;function addSelection(r,e){if(r.length){let n=r[r.length-1],s=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-MaxSelectionsPerEvent));return s.length&&s[s.length-1].eq(e)?r:(s.push(e),updateBranch(r,r.length-1,1e9,n.setSelAfter(s)))}else return[HistEvent.selection([e])]}function popSelection(r){let e=r[r.length-1],n=r.slice();return n[r.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),n}function addMappingToBranch(r,e){if(!r.length)return r;let n=r.length,s=none;for(;n;){let o=mapEvent(r[n-1],e,s);if(o.changes&&!o.changes.empty||o.effects.length){let l=r.slice(0,n);return l[n-1]=o,l}else e=o.mapped,n--,s=o.selectionsAfter}return s.length?[HistEvent.selection(s)]:none}function mapEvent(r,e,n){let s=conc(r.selectionsAfter.length?r.selectionsAfter.map(c=>c.map(e)):none,n);if(!r.changes)return HistEvent.selection(s);let o=r.changes.map(e),l=e.mapDesc(r.changes,!0),a=r.mapped?r.mapped.composeDesc(l):l;return new HistEvent(o,StateEffect.mapEffects(r.effects,e),a,r.startSelection.map(l),s)}const joinableUserEvent=/^(input\.type|delete)($|\.)/;class HistoryState{constructor(e,n,s=0,o=void 0){this.done=e,this.undone=n,this.prevTime=s,this.prevUserEvent=o}isolate(){return this.prevTime?new HistoryState(this.done,this.undone):this}addChanges(e,n,s,o,l){let a=this.done,c=a[a.length-1];return c&&c.changes&&!c.changes.empty&&e.changes&&(!s||joinableUserEvent.test(s))&&(!c.selectionsAfter.length&&n-this.prevTime0&&n-this.prevTimen.empty?r.moveByChar(n,e):rangeEnd(n,e))}function ltrAtCursor(r){return r.textDirectionAt(r.state.selection.main.head)==Direction.LTR}const cursorCharLeft=r=>cursorByChar(r,!ltrAtCursor(r)),cursorCharRight=r=>cursorByChar(r,ltrAtCursor(r));function cursorByGroup(r,e){return moveSel(r,n=>n.empty?r.moveByGroup(n,e):rangeEnd(n,e))}const cursorGroupLeft=r=>cursorByGroup(r,!ltrAtCursor(r)),cursorGroupRight=r=>cursorByGroup(r,ltrAtCursor(r));function interestingNode(r,e,n){if(e.type.prop(n))return!0;let s=e.to-e.from;return s&&(s>2||/[^\s,.;:]/.test(r.sliceDoc(e.from,e.to)))||e.firstChild}function moveBySyntax(r,e,n){let s=syntaxTree(r).resolveInner(e.head),o=n?NodeProp.closedBy:NodeProp.openedBy;for(let h=e.head;;){let f=n?s.childAfter(h):s.childBefore(h);if(!f)break;interestingNode(r,f,o)?s=f:h=n?f.to:f.from}let l=s.type.prop(o),a,c;return l&&(a=n?matchBrackets(r,s.from,1):matchBrackets(r,s.to,-1))&&a.matched?c=n?a.end.to:a.end.from:c=n?s.to:s.from,EditorSelection.cursor(c,n?-1:1)}const cursorSyntaxLeft=r=>moveSel(r,e=>moveBySyntax(r.state,e,!ltrAtCursor(r))),cursorSyntaxRight=r=>moveSel(r,e=>moveBySyntax(r.state,e,ltrAtCursor(r)));function cursorByLine(r,e){return moveSel(r,n=>{if(!n.empty)return rangeEnd(n,e);let s=r.moveVertically(n,e);return s.head!=n.head?s:r.moveToLineBoundary(n,e)})}const cursorLineUp=r=>cursorByLine(r,!1),cursorLineDown=r=>cursorByLine(r,!0);function pageInfo(r){let e=r.scrollDOM.clientHeighta.empty?r.moveVertically(a,e,n.height):rangeEnd(a,e));if(o.eq(s.selection))return!1;let l;if(n.selfScroll){let a=r.coordsAtPos(s.selection.main.head),c=r.scrollDOM.getBoundingClientRect(),h=c.top+n.marginTop,f=c.bottom-n.marginBottom;a&&a.top>h&&a.bottomcursorByPage(r,!1),cursorPageDown=r=>cursorByPage(r,!0);function moveByLineBoundary(r,e,n){let s=r.lineBlockAt(e.head),o=r.moveToLineBoundary(e,n);if(o.head==e.head&&o.head!=(n?s.to:s.from)&&(o=r.moveToLineBoundary(e,n,!1)),!n&&o.head==s.from&&s.length){let l=/^\s*/.exec(r.state.sliceDoc(s.from,Math.min(s.from+100,s.to)))[0].length;l&&e.head!=s.from+l&&(o=EditorSelection.cursor(s.from+l))}return o}const cursorLineBoundaryForward=r=>moveSel(r,e=>moveByLineBoundary(r,e,!0)),cursorLineBoundaryBackward=r=>moveSel(r,e=>moveByLineBoundary(r,e,!1)),cursorLineBoundaryLeft=r=>moveSel(r,e=>moveByLineBoundary(r,e,!ltrAtCursor(r))),cursorLineBoundaryRight=r=>moveSel(r,e=>moveByLineBoundary(r,e,ltrAtCursor(r))),cursorLineStart=r=>moveSel(r,e=>EditorSelection.cursor(r.lineBlockAt(e.head).from,1)),cursorLineEnd=r=>moveSel(r,e=>EditorSelection.cursor(r.lineBlockAt(e.head).to,-1));function toMatchingBracket(r,e,n){let s=!1,o=updateSel(r.selection,l=>{let a=matchBrackets(r,l.head,-1)||matchBrackets(r,l.head,1)||l.head>0&&matchBrackets(r,l.head-1,1)||l.headtoMatchingBracket(r,e);function extendSel(r,e){let n=updateSel(r.state.selection,s=>{let o=e(s);return EditorSelection.range(s.anchor,o.head,o.goalColumn,o.bidiLevel||void 0)});return n.eq(r.state.selection)?!1:(r.dispatch(setSel(r.state,n)),!0)}function selectByChar(r,e){return extendSel(r,n=>r.moveByChar(n,e))}const selectCharLeft=r=>selectByChar(r,!ltrAtCursor(r)),selectCharRight=r=>selectByChar(r,ltrAtCursor(r));function selectByGroup(r,e){return extendSel(r,n=>r.moveByGroup(n,e))}const selectGroupLeft=r=>selectByGroup(r,!ltrAtCursor(r)),selectGroupRight=r=>selectByGroup(r,ltrAtCursor(r)),selectSyntaxLeft=r=>extendSel(r,e=>moveBySyntax(r.state,e,!ltrAtCursor(r))),selectSyntaxRight=r=>extendSel(r,e=>moveBySyntax(r.state,e,ltrAtCursor(r)));function selectByLine(r,e){return extendSel(r,n=>r.moveVertically(n,e))}const selectLineUp=r=>selectByLine(r,!1),selectLineDown=r=>selectByLine(r,!0);function selectByPage(r,e){return extendSel(r,n=>r.moveVertically(n,e,pageInfo(r).height))}const selectPageUp=r=>selectByPage(r,!1),selectPageDown=r=>selectByPage(r,!0),selectLineBoundaryForward=r=>extendSel(r,e=>moveByLineBoundary(r,e,!0)),selectLineBoundaryBackward=r=>extendSel(r,e=>moveByLineBoundary(r,e,!1)),selectLineBoundaryLeft=r=>extendSel(r,e=>moveByLineBoundary(r,e,!ltrAtCursor(r))),selectLineBoundaryRight=r=>extendSel(r,e=>moveByLineBoundary(r,e,ltrAtCursor(r))),selectLineStart=r=>extendSel(r,e=>EditorSelection.cursor(r.lineBlockAt(e.head).from)),selectLineEnd=r=>extendSel(r,e=>EditorSelection.cursor(r.lineBlockAt(e.head).to)),cursorDocStart=({state:r,dispatch:e})=>(e(setSel(r,{anchor:0})),!0),cursorDocEnd=({state:r,dispatch:e})=>(e(setSel(r,{anchor:r.doc.length})),!0),selectDocStart=({state:r,dispatch:e})=>(e(setSel(r,{anchor:r.selection.main.anchor,head:0})),!0),selectDocEnd=({state:r,dispatch:e})=>(e(setSel(r,{anchor:r.selection.main.anchor,head:r.doc.length})),!0),selectAll=({state:r,dispatch:e})=>(e(r.update({selection:{anchor:0,head:r.doc.length},userEvent:"select"})),!0),selectLine=({state:r,dispatch:e})=>{let n=selectedLineBlocks(r).map(({from:s,to:o})=>EditorSelection.range(s,Math.min(o+1,r.doc.length)));return e(r.update({selection:EditorSelection.create(n),userEvent:"select"})),!0},selectParentSyntax=({state:r,dispatch:e})=>{let n=updateSel(r.selection,s=>{var o;let l=syntaxTree(r).resolveStack(s.from,1);for(let a=l;a;a=a.next){let{node:c}=a;if((c.from=s.to||c.to>s.to&&c.from<=s.from)&&(!((o=c.parent)===null||o===void 0)&&o.parent))return EditorSelection.range(c.to,c.from)}return s});return e(setSel(r,n)),!0},simplifySelection=({state:r,dispatch:e})=>{let n=r.selection,s=null;return n.ranges.length>1?s=EditorSelection.create([n.main]):n.main.empty||(s=EditorSelection.create([EditorSelection.cursor(n.main.head)])),s?(e(setSel(r,s)),!0):!1};function deleteBy(r,e){if(r.state.readOnly)return!1;let n="delete.selection",{state:s}=r,o=s.changeByRange(l=>{let{from:a,to:c}=l;if(a==c){let h=e(l);ha&&(n="delete.forward",h=skipAtomic(r,h,!0)),a=Math.min(a,h),c=Math.max(c,h)}else a=skipAtomic(r,a,!1),c=skipAtomic(r,c,!0);return a==c?{range:l}:{changes:{from:a,to:c},range:EditorSelection.cursor(a,ao(r)))s.between(e,e,(o,l)=>{oe&&(e=n?l:o)});return e}const deleteByChar=(r,e,n)=>deleteBy(r,s=>{let o=s.from,{state:l}=r,a=l.doc.lineAt(o),c,h;if(n&&!e&&o>a.from&&odeleteByChar(r,!1,!0),deleteCharForward=r=>deleteByChar(r,!0,!1),deleteByGroup=(r,e)=>deleteBy(r,n=>{let s=n.head,{state:o}=r,l=o.doc.lineAt(s),a=o.charCategorizer(s);for(let c=null;;){if(s==(e?l.to:l.from)){s==n.head&&l.number!=(e?o.doc.lines:1)&&(s+=e?1:-1);break}let h=findClusterBreak(l.text,s-l.from,e)+l.from,f=l.text.slice(Math.min(s,h)-l.from,Math.max(s,h)-l.from),u=a(f);if(c!=null&&u!=c)break;(f!=" "||s!=n.head)&&(c=u),s=h}return s}),deleteGroupBackward=r=>deleteByGroup(r,!1),deleteGroupForward=r=>deleteByGroup(r,!0),deleteToLineEnd=r=>deleteBy(r,e=>{let n=r.lineBlockAt(e.head).to;return e.headdeleteBy(r,e=>{let n=r.moveToLineBoundary(e,!1).head;return e.head>n?n:Math.max(0,e.head-1)}),deleteLineBoundaryForward=r=>deleteBy(r,e=>{let n=r.moveToLineBoundary(e,!0).head;return e.head{if(r.readOnly)return!1;let n=r.changeByRange(s=>({changes:{from:s.from,to:s.to,insert:Text.of(["",""])},range:EditorSelection.cursor(s.from)}));return e(r.update(n,{scrollIntoView:!0,userEvent:"input"})),!0},transposeChars=({state:r,dispatch:e})=>{if(r.readOnly)return!1;let n=r.changeByRange(s=>{if(!s.empty||s.from==0||s.from==r.doc.length)return{range:s};let o=s.from,l=r.doc.lineAt(o),a=o==l.from?o-1:findClusterBreak(l.text,o-l.from,!1)+l.from,c=o==l.to?o+1:findClusterBreak(l.text,o-l.from,!0)+l.from;return{changes:{from:a,to:c,insert:r.doc.slice(o,c).append(r.doc.slice(a,o))},range:EditorSelection.cursor(c)}});return n.changes.empty?!1:(e(r.update(n,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function selectedLineBlocks(r){let e=[],n=-1;for(let s of r.selection.ranges){let o=r.doc.lineAt(s.from),l=r.doc.lineAt(s.to);if(!s.empty&&s.to==l.from&&(l=r.doc.lineAt(s.to-1)),n>=o.number){let a=e[e.length-1];a.to=l.to,a.ranges.push(s)}else e.push({from:o.from,to:l.to,ranges:[s]});n=l.number+1}return e}function moveLine(r,e,n){if(r.readOnly)return!1;let s=[],o=[];for(let l of selectedLineBlocks(r)){if(n?l.to==r.doc.length:l.from==0)continue;let a=r.doc.lineAt(n?l.to+1:l.from-1),c=a.length+1;if(n){s.push({from:l.to,to:a.to},{from:l.from,insert:a.text+r.lineBreak});for(let h of l.ranges)o.push(EditorSelection.range(Math.min(r.doc.length,h.anchor+c),Math.min(r.doc.length,h.head+c)))}else{s.push({from:a.from,to:l.from},{from:l.to,insert:r.lineBreak+a.text});for(let h of l.ranges)o.push(EditorSelection.range(h.anchor-c,h.head-c))}}return s.length?(e(r.update({changes:s,scrollIntoView:!0,selection:EditorSelection.create(o,r.selection.mainIndex),userEvent:"move.line"})),!0):!1}const moveLineUp=({state:r,dispatch:e})=>moveLine(r,e,!1),moveLineDown=({state:r,dispatch:e})=>moveLine(r,e,!0);function copyLine(r,e,n){if(r.readOnly)return!1;let s=[];for(let o of selectedLineBlocks(r))n?s.push({from:o.from,insert:r.doc.slice(o.from,o.to)+r.lineBreak}):s.push({from:o.to,insert:r.lineBreak+r.doc.slice(o.from,o.to)});return e(r.update({changes:s,scrollIntoView:!0,userEvent:"input.copyline"})),!0}const copyLineUp=({state:r,dispatch:e})=>copyLine(r,e,!1),copyLineDown=({state:r,dispatch:e})=>copyLine(r,e,!0),deleteLine=r=>{if(r.state.readOnly)return!1;let{state:e}=r,n=e.changes(selectedLineBlocks(e).map(({from:o,to:l})=>(o>0?o--:l{let l;if(r.lineWrapping){let a=r.lineBlockAt(o.head),c=r.coordsAtPos(o.head,o.assoc||1);c&&(l=a.bottom+r.documentTop-c.bottom+r.defaultLineHeight/2)}return r.moveVertically(o,!0,l)}).map(n);return r.dispatch({changes:n,selection:s,scrollIntoView:!0,userEvent:"delete.line"}),!0};function isBetweenBrackets(r,e){if(/\(\)|\[\]|\{\}/.test(r.sliceDoc(e-1,e+1)))return{from:e,to:e};let n=syntaxTree(r).resolveInner(e),s=n.childBefore(e),o=n.childAfter(e),l;return s&&o&&s.to<=e&&o.from>=e&&(l=s.type.prop(NodeProp.closedBy))&&l.indexOf(o.name)>-1&&r.doc.lineAt(s.to).from==r.doc.lineAt(o.from).from&&!/\S/.test(r.sliceDoc(s.to,o.from))?{from:s.to,to:o.from}:null}const insertNewlineAndIndent=newlineAndIndent(!1),insertBlankLine=newlineAndIndent(!0);function newlineAndIndent(r){return({state:e,dispatch:n})=>{if(e.readOnly)return!1;let s=e.changeByRange(o=>{let{from:l,to:a}=o,c=e.doc.lineAt(l),h=!r&&l==a&&isBetweenBrackets(e,l);r&&(l=a=(a<=c.to?c:e.doc.lineAt(a)).to);let f=new IndentContext(e,{simulateBreak:l,simulateDoubleBreak:!!h}),u=getIndentation(f,l);for(u==null&&(u=countColumn(/^\s*/.exec(e.doc.lineAt(l).text)[0],e.tabSize));ac.from&&l{let o=[];for(let a=s.from;a<=s.to;){let c=r.doc.lineAt(a);c.number>n&&(s.empty||s.to>c.from)&&(e(c,o,s),n=c.number),a=c.to+1}let l=r.changes(o);return{changes:o,range:EditorSelection.range(l.mapPos(s.anchor,1),l.mapPos(s.head,1))}})}const indentSelection=({state:r,dispatch:e})=>{if(r.readOnly)return!1;let n=Object.create(null),s=new IndentContext(r,{overrideIndentation:l=>{let a=n[l];return a??-1}}),o=changeBySelectedLine(r,(l,a,c)=>{let h=getIndentation(s,l.from);if(h==null)return;/\S/.test(l.text)||(h=0);let f=/^\s*/.exec(l.text)[0],u=indentString(r,h);(f!=u||c.fromr.readOnly?!1:(e(r.update(changeBySelectedLine(r,(n,s)=>{s.push({from:n.from,insert:r.facet(indentUnit)})}),{userEvent:"input.indent"})),!0),indentLess=({state:r,dispatch:e})=>r.readOnly?!1:(e(r.update(changeBySelectedLine(r,(n,s)=>{let o=/^\s*/.exec(n.text)[0];if(!o)return;let l=countColumn(o,r.tabSize),a=0,c=indentString(r,Math.max(0,l-getIndentUnit(r)));for(;a(r.setTabFocusMode(),!0),emacsStyleKeymap=[{key:"Ctrl-b",run:cursorCharLeft,shift:selectCharLeft,preventDefault:!0},{key:"Ctrl-f",run:cursorCharRight,shift:selectCharRight},{key:"Ctrl-p",run:cursorLineUp,shift:selectLineUp},{key:"Ctrl-n",run:cursorLineDown,shift:selectLineDown},{key:"Ctrl-a",run:cursorLineStart,shift:selectLineStart},{key:"Ctrl-e",run:cursorLineEnd,shift:selectLineEnd},{key:"Ctrl-d",run:deleteCharForward},{key:"Ctrl-h",run:deleteCharBackward},{key:"Ctrl-k",run:deleteToLineEnd},{key:"Ctrl-Alt-h",run:deleteGroupBackward},{key:"Ctrl-o",run:splitLine},{key:"Ctrl-t",run:transposeChars},{key:"Ctrl-v",run:cursorPageDown}],standardKeymap=[{key:"ArrowLeft",run:cursorCharLeft,shift:selectCharLeft,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:cursorGroupLeft,shift:selectGroupLeft,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:cursorLineBoundaryLeft,shift:selectLineBoundaryLeft,preventDefault:!0},{key:"ArrowRight",run:cursorCharRight,shift:selectCharRight,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:cursorGroupRight,shift:selectGroupRight,preventDefault:!0},{mac:"Cmd-ArrowRight",run:cursorLineBoundaryRight,shift:selectLineBoundaryRight,preventDefault:!0},{key:"ArrowUp",run:cursorLineUp,shift:selectLineUp,preventDefault:!0},{mac:"Cmd-ArrowUp",run:cursorDocStart,shift:selectDocStart},{mac:"Ctrl-ArrowUp",run:cursorPageUp,shift:selectPageUp},{key:"ArrowDown",run:cursorLineDown,shift:selectLineDown,preventDefault:!0},{mac:"Cmd-ArrowDown",run:cursorDocEnd,shift:selectDocEnd},{mac:"Ctrl-ArrowDown",run:cursorPageDown,shift:selectPageDown},{key:"PageUp",run:cursorPageUp,shift:selectPageUp},{key:"PageDown",run:cursorPageDown,shift:selectPageDown},{key:"Home",run:cursorLineBoundaryBackward,shift:selectLineBoundaryBackward,preventDefault:!0},{key:"Mod-Home",run:cursorDocStart,shift:selectDocStart},{key:"End",run:cursorLineBoundaryForward,shift:selectLineBoundaryForward,preventDefault:!0},{key:"Mod-End",run:cursorDocEnd,shift:selectDocEnd},{key:"Enter",run:insertNewlineAndIndent},{key:"Mod-a",run:selectAll},{key:"Backspace",run:deleteCharBackward,shift:deleteCharBackward},{key:"Delete",run:deleteCharForward},{key:"Mod-Backspace",mac:"Alt-Backspace",run:deleteGroupBackward},{key:"Mod-Delete",mac:"Alt-Delete",run:deleteGroupForward},{mac:"Mod-Backspace",run:deleteLineBoundaryBackward},{mac:"Mod-Delete",run:deleteLineBoundaryForward}].concat(emacsStyleKeymap.map(r=>({mac:r.key,run:r.run,shift:r.shift}))),defaultKeymap=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:cursorSyntaxLeft,shift:selectSyntaxLeft},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:cursorSyntaxRight,shift:selectSyntaxRight},{key:"Alt-ArrowUp",run:moveLineUp},{key:"Shift-Alt-ArrowUp",run:copyLineUp},{key:"Alt-ArrowDown",run:moveLineDown},{key:"Shift-Alt-ArrowDown",run:copyLineDown},{key:"Escape",run:simplifySelection},{key:"Mod-Enter",run:insertBlankLine},{key:"Alt-l",mac:"Ctrl-l",run:selectLine},{key:"Mod-i",run:selectParentSyntax,preventDefault:!0},{key:"Mod-[",run:indentLess},{key:"Mod-]",run:indentMore},{key:"Mod-Alt-\\",run:indentSelection},{key:"Shift-Mod-k",run:deleteLine},{key:"Shift-Mod-\\",run:cursorMatchingBracket},{key:"Mod-/",run:toggleComment},{key:"Alt-A",run:toggleBlockComment},{key:"Ctrl-m",mac:"Shift-Alt-m",run:toggleTabFocusMode}].concat(standardKeymap),basicNormalize=typeof String.prototype.normalize=="function"?r=>r.normalize("NFKD"):r=>r;class SearchCursor{constructor(e,n,s=0,o=e.length,l,a){this.test=a,this.value={from:0,to:0},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=e.iterRange(s,o),this.bufferStart=s,this.normalize=l?c=>l(basicNormalize(c)):basicNormalize,this.query=this.normalize(n)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return codePointAt(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=!0,this;let n=fromCodePoint(e),s=this.bufferStart+this.bufferPos;this.bufferPos+=codePointSize(e);let o=this.normalize(n);for(let l=0,a=s;;l++){let c=o.charCodeAt(l),h=this.match(c,a,this.bufferPos+this.bufferStart);if(l==o.length-1){if(h)return this.value=h,this;break}a==s&&lthis.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine="":this.getLine(0)}next(){for(let e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let n=this.matchPos<=this.to&&this.re.exec(this.curLine);if(n){let s=this.curLineStart+n.index,o=s+n[0].length;if(this.matchPos=toCharEnd(this.text,o+(s==o?1:0)),s==this.curLineStart+this.curLine.length&&this.nextLine(),(sthis.value.to)&&(!this.test||this.test(s,o,n)))return this.value={from:s,to:o,match:n},this;e=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length=s||o.to<=n){let c=new FlattenedDoc(n,e.sliceString(n,s));return flattened.set(e,c),c}if(o.from==n&&o.to==s)return o;let{text:l,from:a}=o;return a>n&&(l=e.sliceString(n,a)+l,a=n),o.to=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,n=this.re.exec(this.flat.text);if(n&&!n[0]&&n.index==e&&(this.re.lastIndex=e+1,n=this.re.exec(this.flat.text)),n){let s=this.flat.from+n.index,o=s+n[0].length;if((this.flat.to>=this.to||n.index+n[0].length<=this.flat.text.length-10)&&(!this.test||this.test(s,o,n)))return this.value={from:s,to:o,match:n},this.matchPos=toCharEnd(this.text,o+(s==o?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=FlattenedDoc.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}}typeof Symbol<"u"&&(RegExpCursor.prototype[Symbol.iterator]=MultilineRegExpCursor.prototype[Symbol.iterator]=function(){return this});function validRegExp(r){try{return new RegExp(r,baseFlags),!0}catch{return!1}}function toCharEnd(r,e){if(e>=r.length)return e;let n=r.lineAt(e),s;for(;e=56320&&s<57344;)e++;return e}function createLineDialog(r){let e=String(r.state.doc.lineAt(r.state.selection.main.head).number),n=crelt("input",{class:"cm-textfield",name:"line",value:e}),s=crelt("form",{class:"cm-gotoLine",onkeydown:l=>{l.keyCode==27?(l.preventDefault(),r.dispatch({effects:dialogEffect.of(!1)}),r.focus()):l.keyCode==13&&(l.preventDefault(),o())},onsubmit:l=>{l.preventDefault(),o()}},crelt("label",r.state.phrase("Go to line"),": ",n)," ",crelt("button",{class:"cm-button",type:"submit"},r.state.phrase("go")));function o(){let l=/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(n.value);if(!l)return;let{state:a}=r,c=a.doc.lineAt(a.selection.main.head),[,h,f,u,d]=l,g=u?+u.slice(1):0,O=f?+f:c.number;if(f&&d){let b=O/100;h&&(b=b*(h=="-"?-1:1)+c.number/a.doc.lines),O=Math.round(a.doc.lines*b)}else f&&h&&(O=O*(h=="-"?-1:1)+c.number);let m=a.doc.line(Math.max(1,Math.min(a.doc.lines,O))),y=EditorSelection.cursor(m.from+Math.max(0,Math.min(g,m.length)));r.dispatch({effects:[dialogEffect.of(!1),EditorView.scrollIntoView(y.from,{y:"center"})],selection:y}),r.focus()}return{dom:s}}const dialogEffect=StateEffect.define(),dialogField=StateField.define({create(){return!0},update(r,e){for(let n of e.effects)n.is(dialogEffect)&&(r=n.value);return r},provide:r=>showPanel.from(r,e=>e?createLineDialog:null)}),gotoLine=r=>{let e=getPanel(r,createLineDialog);if(!e){let n=[dialogEffect.of(!0)];r.state.field(dialogField,!1)==null&&n.push(StateEffect.appendConfig.of([dialogField,baseTheme$1])),r.dispatch({effects:n}),e=getPanel(r,createLineDialog)}return e&&e.dom.querySelector("input").select(),!0},baseTheme$1=EditorView.baseTheme({".cm-panel.cm-gotoLine":{padding:"2px 6px 4px","& label":{fontSize:"80%"}}}),defaultHighlightOptions={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},highlightConfig=Facet.define({combine(r){return combineConfig(r,defaultHighlightOptions,{highlightWordAroundCursor:(e,n)=>e||n,minSelectionLength:Math.min,maxMatches:Math.min})}});function highlightSelectionMatches(r){return[defaultTheme,matchHighlighter]}const matchDeco=Decoration.mark({class:"cm-selectionMatch"}),mainMatchDeco=Decoration.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function insideWordBoundaries(r,e,n,s){return(n==0||r(e.sliceDoc(n-1,n))!=CharCategory.Word)&&(s==e.doc.length||r(e.sliceDoc(s,s+1))!=CharCategory.Word)}function insideWord(r,e,n,s){return r(e.sliceDoc(n,n+1))==CharCategory.Word&&r(e.sliceDoc(s-1,s))==CharCategory.Word}const matchHighlighter=ViewPlugin.fromClass(class{constructor(r){this.decorations=this.getDeco(r)}update(r){(r.selectionSet||r.docChanged||r.viewportChanged)&&(this.decorations=this.getDeco(r.view))}getDeco(r){let e=r.state.facet(highlightConfig),{state:n}=r,s=n.selection;if(s.ranges.length>1)return Decoration.none;let o=s.main,l,a=null;if(o.empty){if(!e.highlightWordAroundCursor)return Decoration.none;let h=n.wordAt(o.head);if(!h)return Decoration.none;a=n.charCategorizer(o.head),l=n.sliceDoc(h.from,h.to)}else{let h=o.to-o.from;if(h200)return Decoration.none;if(e.wholeWords){if(l=n.sliceDoc(o.from,o.to),a=n.charCategorizer(o.head),!(insideWordBoundaries(a,n,o.from,o.to)&&insideWord(a,n,o.from,o.to)))return Decoration.none}else if(l=n.sliceDoc(o.from,o.to),!l)return Decoration.none}let c=[];for(let h of r.visibleRanges){let f=new SearchCursor(n.doc,l,h.from,h.to);for(;!f.next().done;){let{from:u,to:d}=f.value;if((!a||insideWordBoundaries(a,n,u,d))&&(o.empty&&u<=o.from&&d>=o.to?c.push(mainMatchDeco.range(u,d)):(u>=o.to||d<=o.from)&&c.push(matchDeco.range(u,d)),c.length>e.maxMatches))return Decoration.none}}return Decoration.set(c)}},{decorations:r=>r.decorations}),defaultTheme=EditorView.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}}),selectWord=({state:r,dispatch:e})=>{let{selection:n}=r,s=EditorSelection.create(n.ranges.map(o=>r.wordAt(o.head)||EditorSelection.cursor(o.head)),n.mainIndex);return s.eq(n)?!1:(e(r.update({selection:s})),!0)};function findNextOccurrence(r,e){let{main:n,ranges:s}=r.selection,o=r.wordAt(n.head),l=o&&o.from==n.from&&o.to==n.to;for(let a=!1,c=new SearchCursor(r.doc,e,s[s.length-1].to);;)if(c.next(),c.done){if(a)return null;c=new SearchCursor(r.doc,e,0,Math.max(0,s[s.length-1].from-1)),a=!0}else{if(a&&s.some(h=>h.from==c.value.from))continue;if(l){let h=r.wordAt(c.value.from);if(!h||h.from!=c.value.from||h.to!=c.value.to)continue}return c.value}}const selectNextOccurrence=({state:r,dispatch:e})=>{let{ranges:n}=r.selection;if(n.some(l=>l.from===l.to))return selectWord({state:r,dispatch:e});let s=r.sliceDoc(n[0].from,n[0].to);if(r.selection.ranges.some(l=>r.sliceDoc(l.from,l.to)!=s))return!1;let o=findNextOccurrence(r,s);return o?(e(r.update({selection:r.selection.addRange(EditorSelection.range(o.from,o.to),!1),effects:EditorView.scrollIntoView(o.to)})),!0):!1},searchConfigFacet=Facet.define({combine(r){return combineConfig(r,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new SearchPanel(e),scrollToMatch:e=>EditorView.scrollIntoView(e)})}});class SearchQuery{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||"",this.valid=!!this.search&&(!this.regexp||validRegExp(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(n,s)=>s=="n"?` -`:s=="r"?"\r":s=="t"?" ":"\\")}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord}create(){return this.regexp?new RegExpQuery(this):new StringQuery(this)}getCursor(e,n=0,s){let o=e.doc?e:EditorState.create({doc:e});return s==null&&(s=o.doc.length),this.regexp?regexpCursor(this,o,n,s):stringCursor(this,o,n,s)}}class QueryType{constructor(e){this.spec=e}}function stringCursor(r,e,n,s){return new SearchCursor(e.doc,r.unquoted,n,s,r.caseSensitive?void 0:o=>o.toLowerCase(),r.wholeWord?stringWordTest(e.doc,e.charCategorizer(e.selection.main.head)):void 0)}function stringWordTest(r,e){return(n,s,o,l)=>((l>n||l+o.length=n)return null;o.push(s.value)}return o}highlight(e,n,s,o){let l=stringCursor(this.spec,e,Math.max(0,n-this.spec.unquoted.length),Math.min(s+this.spec.unquoted.length,e.doc.length));for(;!l.next().done;)o(l.value.from,l.value.to)}}function regexpCursor(r,e,n,s){return new RegExpCursor(e.doc,r.search,{ignoreCase:!r.caseSensitive,test:r.wholeWord?regexpWordTest(e.charCategorizer(e.selection.main.head)):void 0},n,s)}function charBefore(r,e){return r.slice(findClusterBreak(r,e,!1),e)}function charAfter(r,e){return r.slice(e,findClusterBreak(r,e))}function regexpWordTest(r){return(e,n,s)=>!s[0].length||(r(charBefore(s.input,s.index))!=CharCategory.Word||r(charAfter(s.input,s.index))!=CharCategory.Word)&&(r(charAfter(s.input,s.index+s[0].length))!=CharCategory.Word||r(charBefore(s.input,s.index+s[0].length))!=CharCategory.Word)}class RegExpQuery extends QueryType{nextMatch(e,n,s){let o=regexpCursor(this.spec,e,s,e.doc.length).next();return o.done&&(o=regexpCursor(this.spec,e,0,n).next()),o.done?null:o.value}prevMatchInRange(e,n,s){for(let o=1;;o++){let l=Math.max(n,s-o*1e4),a=regexpCursor(this.spec,e,l,s),c=null;for(;!a.next().done;)c=a.value;if(c&&(l==n||c.from>l+10))return c;if(l==n)return null}}prevMatch(e,n,s){return this.prevMatchInRange(e,0,n)||this.prevMatchInRange(e,s,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&\d+])/g,(n,s)=>s=="$"?"$":s=="&"?e.match[0]:s!="0"&&+s=n)return null;o.push(s.value)}return o}highlight(e,n,s,o){let l=regexpCursor(this.spec,e,Math.max(0,n-250),Math.min(s+250,e.doc.length));for(;!l.next().done;)o(l.value.from,l.value.to)}}const setSearchQuery=StateEffect.define(),togglePanel=StateEffect.define(),searchState=StateField.define({create(r){return new SearchState(defaultQuery(r).create(),null)},update(r,e){for(let n of e.effects)n.is(setSearchQuery)?r=new SearchState(n.value.create(),r.panel):n.is(togglePanel)&&(r=new SearchState(r.query,n.value?createSearchPanel:null));return r},provide:r=>showPanel.from(r,e=>e.panel)});class SearchState{constructor(e,n){this.query=e,this.panel=n}}const matchMark=Decoration.mark({class:"cm-searchMatch"}),selectedMatchMark=Decoration.mark({class:"cm-searchMatch cm-searchMatch-selected"}),searchHighlighter=ViewPlugin.fromClass(class{constructor(r){this.view=r,this.decorations=this.highlight(r.state.field(searchState))}update(r){let e=r.state.field(searchState);(e!=r.startState.field(searchState)||r.docChanged||r.selectionSet||r.viewportChanged)&&(this.decorations=this.highlight(e))}highlight({query:r,panel:e}){if(!e||!r.spec.valid)return Decoration.none;let{view:n}=this,s=new RangeSetBuilder;for(let o=0,l=n.visibleRanges,a=l.length;ol[o+1].from-2*250;)h=l[++o].to;r.highlight(n.state,c,h,(f,u)=>{let d=n.state.selection.ranges.some(g=>g.from==f&&g.to==u);s.add(f,u,d?selectedMatchMark:matchMark)})}return s.finish()}},{decorations:r=>r.decorations});function searchCommand(r){return e=>{let n=e.state.field(searchState,!1);return n&&n.query.spec.valid?r(e,n):openSearchPanel(e)}}const findNext=searchCommand((r,{query:e})=>{let{to:n}=r.state.selection.main,s=e.nextMatch(r.state,n,n);if(!s)return!1;let o=EditorSelection.single(s.from,s.to),l=r.state.facet(searchConfigFacet);return r.dispatch({selection:o,effects:[announceMatch(r,s),l.scrollToMatch(o.main,r)],userEvent:"select.search"}),selectSearchInput(r),!0}),findPrevious=searchCommand((r,{query:e})=>{let{state:n}=r,{from:s}=n.selection.main,o=e.prevMatch(n,s,s);if(!o)return!1;let l=EditorSelection.single(o.from,o.to),a=r.state.facet(searchConfigFacet);return r.dispatch({selection:l,effects:[announceMatch(r,o),a.scrollToMatch(l.main,r)],userEvent:"select.search"}),selectSearchInput(r),!0}),selectMatches=searchCommand((r,{query:e})=>{let n=e.matchAll(r.state,1e3);return!n||!n.length?!1:(r.dispatch({selection:EditorSelection.create(n.map(s=>EditorSelection.range(s.from,s.to))),userEvent:"select.search.matches"}),!0)}),selectSelectionMatches=({state:r,dispatch:e})=>{let n=r.selection;if(n.ranges.length>1||n.main.empty)return!1;let{from:s,to:o}=n.main,l=[],a=0;for(let c=new SearchCursor(r.doc,r.sliceDoc(s,o));!c.next().done;){if(l.length>1e3)return!1;c.value.from==s&&(a=l.length),l.push(EditorSelection.range(c.value.from,c.value.to))}return e(r.update({selection:EditorSelection.create(l,a),userEvent:"select.search.matches"})),!0},replaceNext=searchCommand((r,{query:e})=>{let{state:n}=r,{from:s,to:o}=n.selection.main;if(n.readOnly)return!1;let l=e.nextMatch(n,s,s);if(!l)return!1;let a=[],c,h,f=[];if(l.from==s&&l.to==o&&(h=n.toText(e.getReplacement(l)),a.push({from:l.from,to:l.to,insert:h}),l=e.nextMatch(n,l.from,l.to),f.push(EditorView.announce.of(n.phrase("replaced match on line $",n.doc.lineAt(s).number)+"."))),l){let u=a.length==0||a[0].from>=l.to?0:l.to-l.from-h.length;c=EditorSelection.single(l.from-u,l.to-u),f.push(announceMatch(r,l)),f.push(n.facet(searchConfigFacet).scrollToMatch(c.main,r))}return r.dispatch({changes:a,selection:c,effects:f,userEvent:"input.replace"}),!0}),replaceAll=searchCommand((r,{query:e})=>{if(r.state.readOnly)return!1;let n=e.matchAll(r.state,1e9).map(o=>{let{from:l,to:a}=o;return{from:l,to:a,insert:e.getReplacement(o)}});if(!n.length)return!1;let s=r.state.phrase("replaced $ matches",n.length)+".";return r.dispatch({changes:n,effects:EditorView.announce.of(s),userEvent:"input.replace.all"}),!0});function createSearchPanel(r){return r.state.facet(searchConfigFacet).createPanel(r)}function defaultQuery(r,e){var n,s,o,l,a;let c=r.selection.main,h=c.empty||c.to>c.from+100?"":r.sliceDoc(c.from,c.to);if(e&&!h)return e;let f=r.facet(searchConfigFacet);return new SearchQuery({search:((n=e==null?void 0:e.literal)!==null&&n!==void 0?n:f.literal)?h:h.replace(/\n/g,"\\n"),caseSensitive:(s=e==null?void 0:e.caseSensitive)!==null&&s!==void 0?s:f.caseSensitive,literal:(o=e==null?void 0:e.literal)!==null&&o!==void 0?o:f.literal,regexp:(l=e==null?void 0:e.regexp)!==null&&l!==void 0?l:f.regexp,wholeWord:(a=e==null?void 0:e.wholeWord)!==null&&a!==void 0?a:f.wholeWord})}function getSearchInput(r){let e=getPanel(r,createSearchPanel);return e&&e.dom.querySelector("[main-field]")}function selectSearchInput(r){let e=getSearchInput(r);e&&e==r.root.activeElement&&e.select()}const openSearchPanel=r=>{let e=r.state.field(searchState,!1);if(e&&e.panel){let n=getSearchInput(r);if(n&&n!=r.root.activeElement){let s=defaultQuery(r.state,e.query.spec);s.valid&&r.dispatch({effects:setSearchQuery.of(s)}),n.focus(),n.select()}}else r.dispatch({effects:[togglePanel.of(!0),e?setSearchQuery.of(defaultQuery(r.state,e.query.spec)):StateEffect.appendConfig.of(searchExtensions)]});return!0},closeSearchPanel=r=>{let e=r.state.field(searchState,!1);if(!e||!e.panel)return!1;let n=getPanel(r,createSearchPanel);return n&&n.dom.contains(r.root.activeElement)&&r.focus(),r.dispatch({effects:togglePanel.of(!1)}),!0},searchKeymap=[{key:"Mod-f",run:openSearchPanel,scope:"editor search-panel"},{key:"F3",run:findNext,shift:findPrevious,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:findNext,shift:findPrevious,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:closeSearchPanel,scope:"editor search-panel"},{key:"Mod-Shift-l",run:selectSelectionMatches},{key:"Mod-Alt-g",run:gotoLine},{key:"Mod-d",run:selectNextOccurrence,preventDefault:!0}];class SearchPanel{constructor(e){this.view=e;let n=this.query=e.state.field(searchState).query.spec;this.commit=this.commit.bind(this),this.searchField=crelt("input",{value:n.search,placeholder:phrase(e,"Find"),"aria-label":phrase(e,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=crelt("input",{value:n.replace,placeholder:phrase(e,"Replace"),"aria-label":phrase(e,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=crelt("input",{type:"checkbox",name:"case",form:"",checked:n.caseSensitive,onchange:this.commit}),this.reField=crelt("input",{type:"checkbox",name:"re",form:"",checked:n.regexp,onchange:this.commit}),this.wordField=crelt("input",{type:"checkbox",name:"word",form:"",checked:n.wholeWord,onchange:this.commit});function s(o,l,a){return crelt("button",{class:"cm-button",name:o,onclick:l,type:"button"},a)}this.dom=crelt("div",{onkeydown:o=>this.keydown(o),class:"cm-search"},[this.searchField,s("next",()=>findNext(e),[phrase(e,"next")]),s("prev",()=>findPrevious(e),[phrase(e,"previous")]),s("select",()=>selectMatches(e),[phrase(e,"all")]),crelt("label",null,[this.caseField,phrase(e,"match case")]),crelt("label",null,[this.reField,phrase(e,"regexp")]),crelt("label",null,[this.wordField,phrase(e,"by word")]),...e.state.readOnly?[]:[crelt("br"),this.replaceField,s("replace",()=>replaceNext(e),[phrase(e,"replace")]),s("replaceAll",()=>replaceAll(e),[phrase(e,"replace all")])],crelt("button",{name:"close",onclick:()=>closeSearchPanel(e),"aria-label":phrase(e,"close"),type:"button"},["×"])])}commit(){let e=new SearchQuery({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:setSearchQuery.of(e)}))}keydown(e){runScopeHandlers(this.view,e,"search-panel")?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?findPrevious:findNext)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),replaceNext(this.view))}update(e){for(let n of e.transactions)for(let s of n.effects)s.is(setSearchQuery)&&!s.value.eq(this.query)&&this.setQuery(s.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(searchConfigFacet).top}}function phrase(r,e){return r.state.phrase(e)}const AnnounceMargin=30,Break=/[\s\.,:;?!]/;function announceMatch(r,{from:e,to:n}){let s=r.state.doc.lineAt(e),o=r.state.doc.lineAt(n).to,l=Math.max(s.from,e-AnnounceMargin),a=Math.min(o,n+AnnounceMargin),c=r.state.sliceDoc(l,a);if(l!=s.from){for(let h=0;hc.length-AnnounceMargin;h--)if(!Break.test(c[h-1])&&Break.test(c[h])){c=c.slice(0,h);break}}return EditorView.announce.of(`${r.state.phrase("current match")}. ${c} ${r.state.phrase("on line")} ${s.number}.`)}const baseTheme=EditorView.baseTheme({".cm-panel.cm-search":{padding:"2px 6px 4px",position:"relative","& [name=close]":{position:"absolute",top:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:0,margin:0},"& input, & button, & label":{margin:".2em .6em .2em 0"},"& input[type=checkbox]":{marginRight:".2em"},"& label":{fontSize:"80%",whiteSpace:"pre"}},"&light .cm-searchMatch":{backgroundColor:"#ffff0054"},"&dark .cm-searchMatch":{backgroundColor:"#00ffff8a"},"&light .cm-searchMatch-selected":{backgroundColor:"#ff6a0054"},"&dark .cm-searchMatch-selected":{backgroundColor:"#ff00ff8a"}}),searchExtensions=[searchState,Prec.low(searchHighlighter),baseTheme],chalky="#e5c07b",coral="#e06c75",cyan="#56b6c2",invalid="#ffffff",ivory="#abb2bf",stone="#7d8799",malibu="#61afef",sage="#98c379",whiskey="#d19a66",violet="#c678dd",darkBackground="#21252b",highlightBackground="#2c313a",background="#282c34",tooltipBackground="#353a42",selection="#3E4451",cursor="#528bff",oneDarkTheme=EditorView.theme({"&":{color:ivory,backgroundColor:background},".cm-content":{caretColor:cursor},".cm-cursor, .cm-dropCursor":{borderLeftColor:cursor},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:selection},".cm-panels":{backgroundColor:darkBackground,color:ivory},".cm-panels.cm-panels-top":{borderBottom:"2px solid black"},".cm-panels.cm-panels-bottom":{borderTop:"2px solid black"},".cm-searchMatch":{backgroundColor:"#72a1ff59",outline:"1px solid #457dff"},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:"#6199ff2f"},".cm-activeLine":{backgroundColor:"#6699ff0b"},".cm-selectionMatch":{backgroundColor:"#aafe661a"},"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bad0f847"},".cm-gutters":{backgroundColor:background,color:stone,border:"none"},".cm-activeLineGutter":{backgroundColor:highlightBackground},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"none",backgroundColor:tooltipBackground},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:tooltipBackground,borderBottomColor:tooltipBackground},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:highlightBackground,color:ivory}}},{dark:!0}),oneDarkHighlightStyle=HighlightStyle.define([{tag:tags.keyword,color:violet},{tag:[tags.name,tags.deleted,tags.character,tags.propertyName,tags.macroName],color:coral},{tag:[tags.function(tags.variableName),tags.labelName],color:malibu},{tag:[tags.color,tags.constant(tags.name),tags.standard(tags.name)],color:whiskey},{tag:[tags.definition(tags.name),tags.separator],color:ivory},{tag:[tags.typeName,tags.className,tags.number,tags.changed,tags.annotation,tags.modifier,tags.self,tags.namespace],color:chalky},{tag:[tags.operator,tags.operatorKeyword,tags.url,tags.escape,tags.regexp,tags.link,tags.special(tags.string)],color:cyan},{tag:[tags.meta,tags.comment],color:stone},{tag:tags.strong,fontWeight:"bold"},{tag:tags.emphasis,fontStyle:"italic"},{tag:tags.strikethrough,textDecoration:"line-through"},{tag:tags.link,color:stone,textDecoration:"underline"},{tag:tags.heading,fontWeight:"bold",color:coral},{tag:[tags.atom,tags.bool,tags.special(tags.variableName)],color:whiskey},{tag:[tags.processingInstruction,tags.string,tags.inserted],color:sage},{tag:tags.invalid,color:invalid}]),oneDark=[oneDarkTheme,syntaxHighlighting(oneDarkHighlightStyle)],_sfc_main$9={__name:"CodeEditor",props:{editorId:{type:String,require:!0},initialValue:{type:String,required:!1,default:""}},setup(r){const e=r,n=ref(null),s=StateEffect.define(),o=StateField.define({create(){return Decoration.none},update(c,h){h.effects.some(f=>f.is(s))&&(c=Decoration.none),c=c.map(h.changes);for(let f of[...h.effects].reverse())if(f.is(s)){c=c.update({add:f.value,sort:!0});break}return c},provide:c=>EditorView.decorations.from(c)}),l=Decoration.mark({class:"highlighted-code"});function a(c,h){if(!arguments.length)document.querySelectorAll(".highlighted-code").forEach(f=>f.classList.remove("highlighted-code"));else{this.dispatch({effects:s.of([l.range(c,h)])});const f=new SelectionRange(c,h);store.getEditor(store.editorIds.inputCodeEditor).dispatch({effects:EditorView.scrollIntoView(f,{y:"center",x:"center"})})}}return onMounted(()=>{const c=new EditorView({parent:n.value,theme:"dracula",state:EditorState.create({doc:e.initialValue,extensions:[autocompletion(),bracketMatching(),closeBrackets(),crosshairCursor(),drawSelection(),dropCursor(),EditorState.allowMultipleSelections.of(!0),foldGutter(),highlightActiveLine(),highlightActiveLineGutter(),o,highlightSelectionMatches(),highlightSpecialChars(),history(),indentOnInput(),javascript(),keymap.of([...closeBracketsKeymap,...defaultKeymap,...searchKeymap,...historyKeymap,...foldKeymap,...completionKeymap,...lintKeymap]),lineNumbers(),oneDark,rectangularSelection(),syntaxHighlighting(oneDarkHighlightStyle,{fallback:!0})]})});c.editorId=e.editorId,c.highlightRange=a,store.editors.push(c)}),(c,h)=>(openBlock(),createElementBlock("div",{ref_key:"editorElement",ref:n,class:"code-editor"},null,512))}},CodeEditor=_export_sfc(_sfc_main$9,[["__scopeId","data-v-982160fb"]]),_hoisted_1$7={class:"code-editor-wrapper"},_hoisted_2$5={key:0},initialValue$1=`// This is the default code for flASTer +}`,{label:"class",detail:"definition",type:"keyword"}),snippetCompletion('import {${names}} from "${module}"\n${}',{label:"import",detail:"named",type:"keyword"}),snippetCompletion('import ${name} from "${module}"\n${}',{label:"import",detail:"default",type:"keyword"})],typescriptSnippets=snippets.concat([snippetCompletion("interface ${name} {\n ${}\n}",{label:"interface",detail:"definition",type:"keyword"}),snippetCompletion("type ${name} = ${type}",{label:"type",detail:"definition",type:"keyword"}),snippetCompletion("enum ${name} {\n ${}\n}",{label:"enum",detail:"definition",type:"keyword"})]),cache=new NodeWeakMap,ScopeNodes=new Set(["Script","Block","FunctionExpression","FunctionDeclaration","ArrowFunction","MethodDeclaration","ForStatement"]);function defID(r){return(e,n)=>{let s=e.node.getChild("VariableDefinition");return s&&n(s,r),!0}}const functionContext=["FunctionDeclaration"],gatherCompletions={FunctionDeclaration:defID("function"),ClassDeclaration:defID("class"),ClassExpression:()=>!0,EnumDeclaration:defID("constant"),TypeAliasDeclaration:defID("type"),NamespaceDeclaration:defID("namespace"),VariableDefinition(r,e){r.matchContext(functionContext)||e(r,"variable")},TypeDefinition(r,e){e(r,"type")},__proto__:null};function getScope(r,e){let n=cache.get(e);if(n)return n;let s=[],o=!0;function l(a,c){let h=r.sliceString(a.from,a.to);s.push({label:h,type:c})}return e.cursor(IterMode.IncludeAnonymous).iterate(a=>{if(o)o=!1;else if(a.name){let c=gatherCompletions[a.name];if(c&&c(a,l)||ScopeNodes.has(a.name))return!1}else if(a.to-a.from>8192){for(let c of getScope(r,a.node))s.push(c);return!1}}),cache.set(e,s),s}const Identifier=/^[\w$\xa1-\uffff][\w$\d\xa1-\uffff]*$/,dontComplete=["TemplateString","String","RegExp","LineComment","BlockComment","VariableDefinition","TypeDefinition","Label","PropertyDefinition","PropertyName","PrivatePropertyDefinition","PrivatePropertyName",".","?."];function localCompletionSource(r){let e=syntaxTree(r.state).resolveInner(r.pos,-1);if(dontComplete.indexOf(e.name)>-1)return null;let n=e.name=="VariableName"||e.to-e.from<20&&Identifier.test(r.state.sliceDoc(e.from,e.to));if(!n&&!r.explicit)return null;let s=[];for(let o=e;o;o=o.parent)ScopeNodes.has(o.name)&&(s=s.concat(getScope(r.state.doc,o)));return{options:s,from:n?e.from:r.pos,validFor:Identifier}}const javascriptLanguage=LRLanguage.define({name:"javascript",parser:parser.configure({props:[indentNodeProp.add({IfStatement:continuedIndent({except:/^\s*({|else\b)/}),TryStatement:continuedIndent({except:/^\s*({|catch\b|finally\b)/}),LabeledStatement:flatIndent,SwitchBody:r=>{let e=r.textAfter,n=/^\s*\}/.test(e),s=/^\s*(case|default)\b/.test(e);return r.baseIndent+(n?0:s?1:2)*r.unit},Block:delimitedIndent({closing:"}"}),ArrowFunction:r=>r.baseIndent+r.unit,"TemplateString BlockComment":()=>null,"Statement Property":continuedIndent({except:/^{/}),JSXElement(r){let e=/^\s*<\//.test(r.textAfter);return r.lineIndent(r.node.from)+(e?0:r.unit)},JSXEscape(r){let e=/\s*\}/.test(r.textAfter);return r.lineIndent(r.node.from)+(e?0:r.unit)},"JSXOpenTag JSXSelfClosingTag"(r){return r.column(r.node.from)+r.unit}}),foldNodeProp.add({"Block ClassBody SwitchBody EnumBody ObjectExpression ArrayExpression ObjectType":foldInside,BlockComment(r){return{from:r.from+2,to:r.to-2}}})]}),languageData:{closeBrackets:{brackets:["(","[","{","'",'"',"`"]},commentTokens:{line:"//",block:{open:"/*",close:"*/"}},indentOnInput:/^\s*(?:case |default:|\{|\}|<\/)$/,wordChars:"$"}}),jsxSublanguage={test:r=>/^JSX/.test(r.name),facet:defineLanguageFacet({commentTokens:{block:{open:"{/*",close:"*/}"}}})},typescriptLanguage=javascriptLanguage.configure({dialect:"ts"},"typescript"),jsxLanguage=javascriptLanguage.configure({dialect:"jsx",props:[sublanguageProp.add(r=>r.isTop?[jsxSublanguage]:void 0)]}),tsxLanguage=javascriptLanguage.configure({dialect:"jsx ts",props:[sublanguageProp.add(r=>r.isTop?[jsxSublanguage]:void 0)]},"typescript");let kwCompletion=r=>({label:r,type:"keyword"});const keywords="break case const continue default delete export extends false finally in instanceof let new return static super switch this throw true typeof var yield".split(" ").map(kwCompletion),typescriptKeywords=keywords.concat(["declare","implements","private","protected","public"].map(kwCompletion));function javascript(r={}){let e=r.jsx?r.typescript?tsxLanguage:jsxLanguage:r.typescript?typescriptLanguage:javascriptLanguage,n=r.typescript?typescriptSnippets.concat(typescriptKeywords):snippets.concat(keywords);return new LanguageSupport(e,[javascriptLanguage.data.of({autocomplete:ifNotIn(dontComplete,completeFromList(n))}),javascriptLanguage.data.of({autocomplete:localCompletionSource}),r.jsx?autoCloseTags:[]])}function findOpenTag(r){for(;;){if(r.name=="JSXOpenTag"||r.name=="JSXSelfClosingTag"||r.name=="JSXFragmentTag")return r;if(r.name=="JSXEscape"||!r.parent)return null;r=r.parent}}function elementName(r,e,n=r.length){for(let s=e==null?void 0:e.firstChild;s;s=s.nextSibling)if(s.name=="JSXIdentifier"||s.name=="JSXBuiltin"||s.name=="JSXNamespacedName"||s.name=="JSXMemberExpression")return r.sliceString(s.from,Math.min(s.to,n));return""}const android=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),autoCloseTags=EditorView.inputHandler.of((r,e,n,s,o)=>{if((android?r.composing:r.compositionStarted)||r.state.readOnly||e!=n||s!=">"&&s!="/"||!javascriptLanguage.isActiveAt(r.state,e,-1))return!1;let l=o(),{state:a}=l,c=a.changeByRange(h=>{var f;let{head:u}=h,d=syntaxTree(a).resolveInner(u-1,-1),g;if(d.name=="JSXStartTag"&&(d=d.parent),!(a.doc.sliceString(u-1,u)!=s||d.name=="JSXAttributeValue"&&d.to>u)){if(s==">"&&d.name=="JSXFragmentTag")return{range:h,changes:{from:u,insert:""}};if(s=="/"&&d.name=="JSXStartCloseTag"){let O=d.parent,m=O.parent;if(m&&O.from==u-2&&((g=elementName(a.doc,m.firstChild,u))||((f=m.firstChild)===null||f===void 0?void 0:f.name)=="JSXFragmentTag")){let S=`${g}>`;return{range:EditorSelection.cursor(u+S.length,-1),changes:{from:u,insert:S}}}}else if(s==">"){let O=findOpenTag(d);if(O&&O.name=="JSXOpenTag"&&!/^\/?>|^<\//.test(a.doc.sliceString(u,u+2))&&(g=elementName(a.doc,O,u)))return{range:h,changes:{from:u,insert:``}}}}return{range:h}});return c.changes.empty?!1:(r.dispatch([l,a.update(c,{userEvent:"input.complete",scrollIntoView:!0})]),!0)}),toggleComment=r=>{let{state:e}=r,n=e.doc.lineAt(e.selection.main.from),s=getConfig(r.state,n.from);return s.line?toggleLineComment(r):s.block?toggleBlockCommentByLine(r):!1};function command(r,e){return({state:n,dispatch:s})=>{if(n.readOnly)return!1;let o=r(e,n);return o?(s(n.update(o)),!0):!1}}const toggleLineComment=command(changeLineComment,0),toggleBlockComment=command(changeBlockComment,0),toggleBlockCommentByLine=command((r,e)=>changeBlockComment(r,e,selectedLineRanges(e)),0);function getConfig(r,e){let n=r.languageDataAt("commentTokens",e);return n.length?n[0]:{}}const SearchMargin=50;function findBlockComment(r,{open:e,close:n},s,o){let l=r.sliceDoc(s-SearchMargin,s),a=r.sliceDoc(o,o+SearchMargin),c=/\s*$/.exec(l)[0].length,h=/^\s*/.exec(a)[0].length,f=l.length-c;if(l.slice(f-e.length,f)==e&&a.slice(h,h+n.length)==n)return{open:{pos:s-c,margin:c&&1},close:{pos:o+h,margin:h&&1}};let u,d;o-s<=2*SearchMargin?u=d=r.sliceDoc(s,o):(u=r.sliceDoc(s,s+SearchMargin),d=r.sliceDoc(o-SearchMargin,o));let g=/^\s*/.exec(u)[0].length,O=/\s*$/.exec(d)[0].length,m=d.length-O-n.length;return u.slice(g,g+e.length)==e&&d.slice(m,m+n.length)==n?{open:{pos:s+g+e.length,margin:/\s/.test(u.charAt(g+e.length))?1:0},close:{pos:o-O-n.length,margin:/\s/.test(d.charAt(m-1))?1:0}}:null}function selectedLineRanges(r){let e=[];for(let n of r.selection.ranges){let s=r.doc.lineAt(n.from),o=n.to<=s.to?s:r.doc.lineAt(n.to),l=e.length-1;l>=0&&e[l].to>s.from?e[l].to=o.to:e.push({from:s.from+/^\s*/.exec(s.text)[0].length,to:o.to})}return e}function changeBlockComment(r,e,n=e.selection.ranges){let s=n.map(l=>getConfig(e,l.from).block);if(!s.every(l=>l))return null;let o=n.map((l,a)=>findBlockComment(e,s[a],l.from,l.to));if(r!=2&&!o.every(l=>l))return{changes:e.changes(n.map((l,a)=>o[a]?[]:[{from:l.from,insert:s[a].open+" "},{from:l.to,insert:" "+s[a].close}]))};if(r!=1&&o.some(l=>l)){let l=[];for(let a=0,c;ao&&(l==a||a>d.from)){o=d.from;let g=/^\s*/.exec(d.text)[0].length,O=g==d.length,m=d.text.slice(g,g+f.length)==f?g:-1;gl.comment<0&&(!l.empty||l.single))){let l=[];for(let{line:c,token:h,indent:f,empty:u,single:d}of s)(d||!u)&&l.push({from:c.from+f,insert:h+" "});let a=e.changes(l);return{changes:a,selection:e.selection.map(a,1)}}else if(r!=1&&s.some(l=>l.comment>=0)){let l=[];for(let{line:a,comment:c,token:h}of s)if(c>=0){let f=a.from+c,u=f+h.length;a.text[u-a.from]==" "&&u++,l.push({from:f,to:u})}return{changes:l}}return null}const fromHistory=Annotation.define(),isolateHistory=Annotation.define(),invertedEffects=Facet.define(),historyConfig=Facet.define({combine(r){return combineConfig(r,{minDepth:100,newGroupDelay:500,joinToEvent:(e,n)=>n},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,n)=>(s,o)=>e(s,o)||n(s,o)})}}),historyField_=StateField.define({create(){return HistoryState.empty},update(r,e){let n=e.state.facet(historyConfig),s=e.annotation(fromHistory);if(s){let h=HistEvent.fromTransaction(e,s.selection),f=s.side,u=f==0?r.undone:r.done;return h?u=updateBranch(u,u.length,n.minDepth,h):u=addSelection(u,e.startState.selection),new HistoryState(f==0?s.rest:u,f==0?u:s.rest)}let o=e.annotation(isolateHistory);if((o=="full"||o=="before")&&(r=r.isolate()),e.annotation(Transaction.addToHistory)===!1)return e.changes.empty?r:r.addMapping(e.changes.desc);let l=HistEvent.fromTransaction(e),a=e.annotation(Transaction.time),c=e.annotation(Transaction.userEvent);return l?r=r.addChanges(l,a,c,n,e):e.selection&&(r=r.addSelection(e.startState.selection,a,c,n.newGroupDelay)),(o=="full"||o=="after")&&(r=r.isolate()),r},toJSON(r){return{done:r.done.map(e=>e.toJSON()),undone:r.undone.map(e=>e.toJSON())}},fromJSON(r){return new HistoryState(r.done.map(HistEvent.fromJSON),r.undone.map(HistEvent.fromJSON))}});function history(r={}){return[historyField_,historyConfig.of(r),EditorView.domEventHandlers({beforeinput(e,n){let s=e.inputType=="historyUndo"?undo:e.inputType=="historyRedo"?redo:null;return s?(e.preventDefault(),s(n)):!1}})]}function cmd(r,e){return function({state:n,dispatch:s}){if(!e&&n.readOnly)return!1;let o=n.field(historyField_,!1);if(!o)return!1;let l=o.pop(r,n,e);return l?(s(l),!0):!1}}const undo=cmd(0,!1),redo=cmd(1,!1),undoSelection=cmd(0,!0),redoSelection=cmd(1,!0);class HistEvent{constructor(e,n,s,o,l){this.changes=e,this.effects=n,this.mapped=s,this.startSelection=o,this.selectionsAfter=l}setSelAfter(e){return new HistEvent(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,n,s;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(n=this.mapped)===null||n===void 0?void 0:n.toJSON(),startSelection:(s=this.startSelection)===null||s===void 0?void 0:s.toJSON(),selectionsAfter:this.selectionsAfter.map(o=>o.toJSON())}}static fromJSON(e){return new HistEvent(e.changes&&ChangeSet.fromJSON(e.changes),[],e.mapped&&ChangeDesc.fromJSON(e.mapped),e.startSelection&&EditorSelection.fromJSON(e.startSelection),e.selectionsAfter.map(EditorSelection.fromJSON))}static fromTransaction(e,n){let s=none;for(let o of e.startState.facet(invertedEffects)){let l=o(e);l.length&&(s=s.concat(l))}return!s.length&&e.changes.empty?null:new HistEvent(e.changes.invert(e.startState.doc),s,void 0,n||e.startState.selection,none)}static selection(e){return new HistEvent(void 0,none,void 0,void 0,e)}}function updateBranch(r,e,n,s){let o=e+1>n+20?e-n-1:0,l=r.slice(o,e);return l.push(s),l}function isAdjacent(r,e){let n=[],s=!1;return r.iterChangedRanges((o,l)=>n.push(o,l)),e.iterChangedRanges((o,l,a,c)=>{for(let h=0;h=f&&a<=u&&(s=!0)}}),s}function eqSelectionShape(r,e){return r.ranges.length==e.ranges.length&&r.ranges.filter((n,s)=>n.empty!=e.ranges[s].empty).length===0}function conc(r,e){return r.length?e.length?r.concat(e):r:e}const none=[],MaxSelectionsPerEvent=200;function addSelection(r,e){if(r.length){let n=r[r.length-1],s=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-MaxSelectionsPerEvent));return s.length&&s[s.length-1].eq(e)?r:(s.push(e),updateBranch(r,r.length-1,1e9,n.setSelAfter(s)))}else return[HistEvent.selection([e])]}function popSelection(r){let e=r[r.length-1],n=r.slice();return n[r.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),n}function addMappingToBranch(r,e){if(!r.length)return r;let n=r.length,s=none;for(;n;){let o=mapEvent(r[n-1],e,s);if(o.changes&&!o.changes.empty||o.effects.length){let l=r.slice(0,n);return l[n-1]=o,l}else e=o.mapped,n--,s=o.selectionsAfter}return s.length?[HistEvent.selection(s)]:none}function mapEvent(r,e,n){let s=conc(r.selectionsAfter.length?r.selectionsAfter.map(c=>c.map(e)):none,n);if(!r.changes)return HistEvent.selection(s);let o=r.changes.map(e),l=e.mapDesc(r.changes,!0),a=r.mapped?r.mapped.composeDesc(l):l;return new HistEvent(o,StateEffect.mapEffects(r.effects,e),a,r.startSelection.map(l),s)}const joinableUserEvent=/^(input\.type|delete)($|\.)/;class HistoryState{constructor(e,n,s=0,o=void 0){this.done=e,this.undone=n,this.prevTime=s,this.prevUserEvent=o}isolate(){return this.prevTime?new HistoryState(this.done,this.undone):this}addChanges(e,n,s,o,l){let a=this.done,c=a[a.length-1];return c&&c.changes&&!c.changes.empty&&e.changes&&(!s||joinableUserEvent.test(s))&&(!c.selectionsAfter.length&&n-this.prevTime0&&n-this.prevTimen.empty?r.moveByChar(n,e):rangeEnd(n,e))}function ltrAtCursor(r){return r.textDirectionAt(r.state.selection.main.head)==Direction.LTR}const cursorCharLeft=r=>cursorByChar(r,!ltrAtCursor(r)),cursorCharRight=r=>cursorByChar(r,ltrAtCursor(r));function cursorByGroup(r,e){return moveSel(r,n=>n.empty?r.moveByGroup(n,e):rangeEnd(n,e))}const cursorGroupLeft=r=>cursorByGroup(r,!ltrAtCursor(r)),cursorGroupRight=r=>cursorByGroup(r,ltrAtCursor(r));function interestingNode(r,e,n){if(e.type.prop(n))return!0;let s=e.to-e.from;return s&&(s>2||/[^\s,.;:]/.test(r.sliceDoc(e.from,e.to)))||e.firstChild}function moveBySyntax(r,e,n){let s=syntaxTree(r).resolveInner(e.head),o=n?NodeProp.closedBy:NodeProp.openedBy;for(let h=e.head;;){let f=n?s.childAfter(h):s.childBefore(h);if(!f)break;interestingNode(r,f,o)?s=f:h=n?f.to:f.from}let l=s.type.prop(o),a,c;return l&&(a=n?matchBrackets(r,s.from,1):matchBrackets(r,s.to,-1))&&a.matched?c=n?a.end.to:a.end.from:c=n?s.to:s.from,EditorSelection.cursor(c,n?-1:1)}const cursorSyntaxLeft=r=>moveSel(r,e=>moveBySyntax(r.state,e,!ltrAtCursor(r))),cursorSyntaxRight=r=>moveSel(r,e=>moveBySyntax(r.state,e,ltrAtCursor(r)));function cursorByLine(r,e){return moveSel(r,n=>{if(!n.empty)return rangeEnd(n,e);let s=r.moveVertically(n,e);return s.head!=n.head?s:r.moveToLineBoundary(n,e)})}const cursorLineUp=r=>cursorByLine(r,!1),cursorLineDown=r=>cursorByLine(r,!0);function pageInfo(r){let e=r.scrollDOM.clientHeighta.empty?r.moveVertically(a,e,n.height):rangeEnd(a,e));if(o.eq(s.selection))return!1;let l;if(n.selfScroll){let a=r.coordsAtPos(s.selection.main.head),c=r.scrollDOM.getBoundingClientRect(),h=c.top+n.marginTop,f=c.bottom-n.marginBottom;a&&a.top>h&&a.bottomcursorByPage(r,!1),cursorPageDown=r=>cursorByPage(r,!0);function moveByLineBoundary(r,e,n){let s=r.lineBlockAt(e.head),o=r.moveToLineBoundary(e,n);if(o.head==e.head&&o.head!=(n?s.to:s.from)&&(o=r.moveToLineBoundary(e,n,!1)),!n&&o.head==s.from&&s.length){let l=/^\s*/.exec(r.state.sliceDoc(s.from,Math.min(s.from+100,s.to)))[0].length;l&&e.head!=s.from+l&&(o=EditorSelection.cursor(s.from+l))}return o}const cursorLineBoundaryForward=r=>moveSel(r,e=>moveByLineBoundary(r,e,!0)),cursorLineBoundaryBackward=r=>moveSel(r,e=>moveByLineBoundary(r,e,!1)),cursorLineBoundaryLeft=r=>moveSel(r,e=>moveByLineBoundary(r,e,!ltrAtCursor(r))),cursorLineBoundaryRight=r=>moveSel(r,e=>moveByLineBoundary(r,e,ltrAtCursor(r))),cursorLineStart=r=>moveSel(r,e=>EditorSelection.cursor(r.lineBlockAt(e.head).from,1)),cursorLineEnd=r=>moveSel(r,e=>EditorSelection.cursor(r.lineBlockAt(e.head).to,-1));function toMatchingBracket(r,e,n){let s=!1,o=updateSel(r.selection,l=>{let a=matchBrackets(r,l.head,-1)||matchBrackets(r,l.head,1)||l.head>0&&matchBrackets(r,l.head-1,1)||l.headtoMatchingBracket(r,e);function extendSel(r,e){let n=updateSel(r.state.selection,s=>{let o=e(s);return EditorSelection.range(s.anchor,o.head,o.goalColumn,o.bidiLevel||void 0)});return n.eq(r.state.selection)?!1:(r.dispatch(setSel(r.state,n)),!0)}function selectByChar(r,e){return extendSel(r,n=>r.moveByChar(n,e))}const selectCharLeft=r=>selectByChar(r,!ltrAtCursor(r)),selectCharRight=r=>selectByChar(r,ltrAtCursor(r));function selectByGroup(r,e){return extendSel(r,n=>r.moveByGroup(n,e))}const selectGroupLeft=r=>selectByGroup(r,!ltrAtCursor(r)),selectGroupRight=r=>selectByGroup(r,ltrAtCursor(r)),selectSyntaxLeft=r=>extendSel(r,e=>moveBySyntax(r.state,e,!ltrAtCursor(r))),selectSyntaxRight=r=>extendSel(r,e=>moveBySyntax(r.state,e,ltrAtCursor(r)));function selectByLine(r,e){return extendSel(r,n=>r.moveVertically(n,e))}const selectLineUp=r=>selectByLine(r,!1),selectLineDown=r=>selectByLine(r,!0);function selectByPage(r,e){return extendSel(r,n=>r.moveVertically(n,e,pageInfo(r).height))}const selectPageUp=r=>selectByPage(r,!1),selectPageDown=r=>selectByPage(r,!0),selectLineBoundaryForward=r=>extendSel(r,e=>moveByLineBoundary(r,e,!0)),selectLineBoundaryBackward=r=>extendSel(r,e=>moveByLineBoundary(r,e,!1)),selectLineBoundaryLeft=r=>extendSel(r,e=>moveByLineBoundary(r,e,!ltrAtCursor(r))),selectLineBoundaryRight=r=>extendSel(r,e=>moveByLineBoundary(r,e,ltrAtCursor(r))),selectLineStart=r=>extendSel(r,e=>EditorSelection.cursor(r.lineBlockAt(e.head).from)),selectLineEnd=r=>extendSel(r,e=>EditorSelection.cursor(r.lineBlockAt(e.head).to)),cursorDocStart=({state:r,dispatch:e})=>(e(setSel(r,{anchor:0})),!0),cursorDocEnd=({state:r,dispatch:e})=>(e(setSel(r,{anchor:r.doc.length})),!0),selectDocStart=({state:r,dispatch:e})=>(e(setSel(r,{anchor:r.selection.main.anchor,head:0})),!0),selectDocEnd=({state:r,dispatch:e})=>(e(setSel(r,{anchor:r.selection.main.anchor,head:r.doc.length})),!0),selectAll=({state:r,dispatch:e})=>(e(r.update({selection:{anchor:0,head:r.doc.length},userEvent:"select"})),!0),selectLine=({state:r,dispatch:e})=>{let n=selectedLineBlocks(r).map(({from:s,to:o})=>EditorSelection.range(s,Math.min(o+1,r.doc.length)));return e(r.update({selection:EditorSelection.create(n),userEvent:"select"})),!0},selectParentSyntax=({state:r,dispatch:e})=>{let n=updateSel(r.selection,s=>{var o;let l=syntaxTree(r).resolveStack(s.from,1);for(let a=l;a;a=a.next){let{node:c}=a;if((c.from=s.to||c.to>s.to&&c.from<=s.from)&&(!((o=c.parent)===null||o===void 0)&&o.parent))return EditorSelection.range(c.to,c.from)}return s});return e(setSel(r,n)),!0},simplifySelection=({state:r,dispatch:e})=>{let n=r.selection,s=null;return n.ranges.length>1?s=EditorSelection.create([n.main]):n.main.empty||(s=EditorSelection.create([EditorSelection.cursor(n.main.head)])),s?(e(setSel(r,s)),!0):!1};function deleteBy(r,e){if(r.state.readOnly)return!1;let n="delete.selection",{state:s}=r,o=s.changeByRange(l=>{let{from:a,to:c}=l;if(a==c){let h=e(l);ha&&(n="delete.forward",h=skipAtomic(r,h,!0)),a=Math.min(a,h),c=Math.max(c,h)}else a=skipAtomic(r,a,!1),c=skipAtomic(r,c,!0);return a==c?{range:l}:{changes:{from:a,to:c},range:EditorSelection.cursor(a,ao(r)))s.between(e,e,(o,l)=>{oe&&(e=n?l:o)});return e}const deleteByChar=(r,e,n)=>deleteBy(r,s=>{let o=s.from,{state:l}=r,a=l.doc.lineAt(o),c,h;if(n&&!e&&o>a.from&&odeleteByChar(r,!1,!0),deleteCharForward=r=>deleteByChar(r,!0,!1),deleteByGroup=(r,e)=>deleteBy(r,n=>{let s=n.head,{state:o}=r,l=o.doc.lineAt(s),a=o.charCategorizer(s);for(let c=null;;){if(s==(e?l.to:l.from)){s==n.head&&l.number!=(e?o.doc.lines:1)&&(s+=e?1:-1);break}let h=findClusterBreak(l.text,s-l.from,e)+l.from,f=l.text.slice(Math.min(s,h)-l.from,Math.max(s,h)-l.from),u=a(f);if(c!=null&&u!=c)break;(f!=" "||s!=n.head)&&(c=u),s=h}return s}),deleteGroupBackward=r=>deleteByGroup(r,!1),deleteGroupForward=r=>deleteByGroup(r,!0),deleteToLineEnd=r=>deleteBy(r,e=>{let n=r.lineBlockAt(e.head).to;return e.headdeleteBy(r,e=>{let n=r.moveToLineBoundary(e,!1).head;return e.head>n?n:Math.max(0,e.head-1)}),deleteLineBoundaryForward=r=>deleteBy(r,e=>{let n=r.moveToLineBoundary(e,!0).head;return e.head{if(r.readOnly)return!1;let n=r.changeByRange(s=>({changes:{from:s.from,to:s.to,insert:Text.of(["",""])},range:EditorSelection.cursor(s.from)}));return e(r.update(n,{scrollIntoView:!0,userEvent:"input"})),!0},transposeChars=({state:r,dispatch:e})=>{if(r.readOnly)return!1;let n=r.changeByRange(s=>{if(!s.empty||s.from==0||s.from==r.doc.length)return{range:s};let o=s.from,l=r.doc.lineAt(o),a=o==l.from?o-1:findClusterBreak(l.text,o-l.from,!1)+l.from,c=o==l.to?o+1:findClusterBreak(l.text,o-l.from,!0)+l.from;return{changes:{from:a,to:c,insert:r.doc.slice(o,c).append(r.doc.slice(a,o))},range:EditorSelection.cursor(c)}});return n.changes.empty?!1:(e(r.update(n,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function selectedLineBlocks(r){let e=[],n=-1;for(let s of r.selection.ranges){let o=r.doc.lineAt(s.from),l=r.doc.lineAt(s.to);if(!s.empty&&s.to==l.from&&(l=r.doc.lineAt(s.to-1)),n>=o.number){let a=e[e.length-1];a.to=l.to,a.ranges.push(s)}else e.push({from:o.from,to:l.to,ranges:[s]});n=l.number+1}return e}function moveLine(r,e,n){if(r.readOnly)return!1;let s=[],o=[];for(let l of selectedLineBlocks(r)){if(n?l.to==r.doc.length:l.from==0)continue;let a=r.doc.lineAt(n?l.to+1:l.from-1),c=a.length+1;if(n){s.push({from:l.to,to:a.to},{from:l.from,insert:a.text+r.lineBreak});for(let h of l.ranges)o.push(EditorSelection.range(Math.min(r.doc.length,h.anchor+c),Math.min(r.doc.length,h.head+c)))}else{s.push({from:a.from,to:l.from},{from:l.to,insert:r.lineBreak+a.text});for(let h of l.ranges)o.push(EditorSelection.range(h.anchor-c,h.head-c))}}return s.length?(e(r.update({changes:s,scrollIntoView:!0,selection:EditorSelection.create(o,r.selection.mainIndex),userEvent:"move.line"})),!0):!1}const moveLineUp=({state:r,dispatch:e})=>moveLine(r,e,!1),moveLineDown=({state:r,dispatch:e})=>moveLine(r,e,!0);function copyLine(r,e,n){if(r.readOnly)return!1;let s=[];for(let o of selectedLineBlocks(r))n?s.push({from:o.from,insert:r.doc.slice(o.from,o.to)+r.lineBreak}):s.push({from:o.to,insert:r.lineBreak+r.doc.slice(o.from,o.to)});return e(r.update({changes:s,scrollIntoView:!0,userEvent:"input.copyline"})),!0}const copyLineUp=({state:r,dispatch:e})=>copyLine(r,e,!1),copyLineDown=({state:r,dispatch:e})=>copyLine(r,e,!0),deleteLine=r=>{if(r.state.readOnly)return!1;let{state:e}=r,n=e.changes(selectedLineBlocks(e).map(({from:o,to:l})=>(o>0?o--:l{let l;if(r.lineWrapping){let a=r.lineBlockAt(o.head),c=r.coordsAtPos(o.head,o.assoc||1);c&&(l=a.bottom+r.documentTop-c.bottom+r.defaultLineHeight/2)}return r.moveVertically(o,!0,l)}).map(n);return r.dispatch({changes:n,selection:s,scrollIntoView:!0,userEvent:"delete.line"}),!0};function isBetweenBrackets(r,e){if(/\(\)|\[\]|\{\}/.test(r.sliceDoc(e-1,e+1)))return{from:e,to:e};let n=syntaxTree(r).resolveInner(e),s=n.childBefore(e),o=n.childAfter(e),l;return s&&o&&s.to<=e&&o.from>=e&&(l=s.type.prop(NodeProp.closedBy))&&l.indexOf(o.name)>-1&&r.doc.lineAt(s.to).from==r.doc.lineAt(o.from).from&&!/\S/.test(r.sliceDoc(s.to,o.from))?{from:s.to,to:o.from}:null}const insertNewlineAndIndent=newlineAndIndent(!1),insertBlankLine=newlineAndIndent(!0);function newlineAndIndent(r){return({state:e,dispatch:n})=>{if(e.readOnly)return!1;let s=e.changeByRange(o=>{let{from:l,to:a}=o,c=e.doc.lineAt(l),h=!r&&l==a&&isBetweenBrackets(e,l);r&&(l=a=(a<=c.to?c:e.doc.lineAt(a)).to);let f=new IndentContext(e,{simulateBreak:l,simulateDoubleBreak:!!h}),u=getIndentation(f,l);for(u==null&&(u=countColumn(/^\s*/.exec(e.doc.lineAt(l).text)[0],e.tabSize));ac.from&&l{let o=[];for(let a=s.from;a<=s.to;){let c=r.doc.lineAt(a);c.number>n&&(s.empty||s.to>c.from)&&(e(c,o,s),n=c.number),a=c.to+1}let l=r.changes(o);return{changes:o,range:EditorSelection.range(l.mapPos(s.anchor,1),l.mapPos(s.head,1))}})}const indentSelection=({state:r,dispatch:e})=>{if(r.readOnly)return!1;let n=Object.create(null),s=new IndentContext(r,{overrideIndentation:l=>{let a=n[l];return a??-1}}),o=changeBySelectedLine(r,(l,a,c)=>{let h=getIndentation(s,l.from);if(h==null)return;/\S/.test(l.text)||(h=0);let f=/^\s*/.exec(l.text)[0],u=indentString(r,h);(f!=u||c.fromr.readOnly?!1:(e(r.update(changeBySelectedLine(r,(n,s)=>{s.push({from:n.from,insert:r.facet(indentUnit)})}),{userEvent:"input.indent"})),!0),indentLess=({state:r,dispatch:e})=>r.readOnly?!1:(e(r.update(changeBySelectedLine(r,(n,s)=>{let o=/^\s*/.exec(n.text)[0];if(!o)return;let l=countColumn(o,r.tabSize),a=0,c=indentString(r,Math.max(0,l-getIndentUnit(r)));for(;a(r.setTabFocusMode(),!0),emacsStyleKeymap=[{key:"Ctrl-b",run:cursorCharLeft,shift:selectCharLeft,preventDefault:!0},{key:"Ctrl-f",run:cursorCharRight,shift:selectCharRight},{key:"Ctrl-p",run:cursorLineUp,shift:selectLineUp},{key:"Ctrl-n",run:cursorLineDown,shift:selectLineDown},{key:"Ctrl-a",run:cursorLineStart,shift:selectLineStart},{key:"Ctrl-e",run:cursorLineEnd,shift:selectLineEnd},{key:"Ctrl-d",run:deleteCharForward},{key:"Ctrl-h",run:deleteCharBackward},{key:"Ctrl-k",run:deleteToLineEnd},{key:"Ctrl-Alt-h",run:deleteGroupBackward},{key:"Ctrl-o",run:splitLine},{key:"Ctrl-t",run:transposeChars},{key:"Ctrl-v",run:cursorPageDown}],standardKeymap=[{key:"ArrowLeft",run:cursorCharLeft,shift:selectCharLeft,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:cursorGroupLeft,shift:selectGroupLeft,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:cursorLineBoundaryLeft,shift:selectLineBoundaryLeft,preventDefault:!0},{key:"ArrowRight",run:cursorCharRight,shift:selectCharRight,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:cursorGroupRight,shift:selectGroupRight,preventDefault:!0},{mac:"Cmd-ArrowRight",run:cursorLineBoundaryRight,shift:selectLineBoundaryRight,preventDefault:!0},{key:"ArrowUp",run:cursorLineUp,shift:selectLineUp,preventDefault:!0},{mac:"Cmd-ArrowUp",run:cursorDocStart,shift:selectDocStart},{mac:"Ctrl-ArrowUp",run:cursorPageUp,shift:selectPageUp},{key:"ArrowDown",run:cursorLineDown,shift:selectLineDown,preventDefault:!0},{mac:"Cmd-ArrowDown",run:cursorDocEnd,shift:selectDocEnd},{mac:"Ctrl-ArrowDown",run:cursorPageDown,shift:selectPageDown},{key:"PageUp",run:cursorPageUp,shift:selectPageUp},{key:"PageDown",run:cursorPageDown,shift:selectPageDown},{key:"Home",run:cursorLineBoundaryBackward,shift:selectLineBoundaryBackward,preventDefault:!0},{key:"Mod-Home",run:cursorDocStart,shift:selectDocStart},{key:"End",run:cursorLineBoundaryForward,shift:selectLineBoundaryForward,preventDefault:!0},{key:"Mod-End",run:cursorDocEnd,shift:selectDocEnd},{key:"Enter",run:insertNewlineAndIndent},{key:"Mod-a",run:selectAll},{key:"Backspace",run:deleteCharBackward,shift:deleteCharBackward},{key:"Delete",run:deleteCharForward},{key:"Mod-Backspace",mac:"Alt-Backspace",run:deleteGroupBackward},{key:"Mod-Delete",mac:"Alt-Delete",run:deleteGroupForward},{mac:"Mod-Backspace",run:deleteLineBoundaryBackward},{mac:"Mod-Delete",run:deleteLineBoundaryForward}].concat(emacsStyleKeymap.map(r=>({mac:r.key,run:r.run,shift:r.shift}))),defaultKeymap=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:cursorSyntaxLeft,shift:selectSyntaxLeft},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:cursorSyntaxRight,shift:selectSyntaxRight},{key:"Alt-ArrowUp",run:moveLineUp},{key:"Shift-Alt-ArrowUp",run:copyLineUp},{key:"Alt-ArrowDown",run:moveLineDown},{key:"Shift-Alt-ArrowDown",run:copyLineDown},{key:"Escape",run:simplifySelection},{key:"Mod-Enter",run:insertBlankLine},{key:"Alt-l",mac:"Ctrl-l",run:selectLine},{key:"Mod-i",run:selectParentSyntax,preventDefault:!0},{key:"Mod-[",run:indentLess},{key:"Mod-]",run:indentMore},{key:"Mod-Alt-\\",run:indentSelection},{key:"Shift-Mod-k",run:deleteLine},{key:"Shift-Mod-\\",run:cursorMatchingBracket},{key:"Mod-/",run:toggleComment},{key:"Alt-A",run:toggleBlockComment},{key:"Ctrl-m",mac:"Shift-Alt-m",run:toggleTabFocusMode}].concat(standardKeymap),basicNormalize=typeof String.prototype.normalize=="function"?r=>r.normalize("NFKD"):r=>r;class SearchCursor{constructor(e,n,s=0,o=e.length,l,a){this.test=a,this.value={from:0,to:0},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=e.iterRange(s,o),this.bufferStart=s,this.normalize=l?c=>l(basicNormalize(c)):basicNormalize,this.query=this.normalize(n)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return codePointAt(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=!0,this;let n=fromCodePoint(e),s=this.bufferStart+this.bufferPos;this.bufferPos+=codePointSize(e);let o=this.normalize(n);for(let l=0,a=s;;l++){let c=o.charCodeAt(l),h=this.match(c,a,this.bufferPos+this.bufferStart);if(l==o.length-1){if(h)return this.value=h,this;break}a==s&&lthis.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine="":this.getLine(0)}next(){for(let e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let n=this.matchPos<=this.to&&this.re.exec(this.curLine);if(n){let s=this.curLineStart+n.index,o=s+n[0].length;if(this.matchPos=toCharEnd(this.text,o+(s==o?1:0)),s==this.curLineStart+this.curLine.length&&this.nextLine(),(sthis.value.to)&&(!this.test||this.test(s,o,n)))return this.value={from:s,to:o,match:n},this;e=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length=s||o.to<=n){let c=new FlattenedDoc(n,e.sliceString(n,s));return flattened.set(e,c),c}if(o.from==n&&o.to==s)return o;let{text:l,from:a}=o;return a>n&&(l=e.sliceString(n,a)+l,a=n),o.to=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,n=this.re.exec(this.flat.text);if(n&&!n[0]&&n.index==e&&(this.re.lastIndex=e+1,n=this.re.exec(this.flat.text)),n){let s=this.flat.from+n.index,o=s+n[0].length;if((this.flat.to>=this.to||n.index+n[0].length<=this.flat.text.length-10)&&(!this.test||this.test(s,o,n)))return this.value={from:s,to:o,match:n},this.matchPos=toCharEnd(this.text,o+(s==o?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=FlattenedDoc.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}}typeof Symbol<"u"&&(RegExpCursor.prototype[Symbol.iterator]=MultilineRegExpCursor.prototype[Symbol.iterator]=function(){return this});function validRegExp(r){try{return new RegExp(r,baseFlags),!0}catch{return!1}}function toCharEnd(r,e){if(e>=r.length)return e;let n=r.lineAt(e),s;for(;e=56320&&s<57344;)e++;return e}function createLineDialog(r){let e=String(r.state.doc.lineAt(r.state.selection.main.head).number),n=crelt("input",{class:"cm-textfield",name:"line",value:e}),s=crelt("form",{class:"cm-gotoLine",onkeydown:l=>{l.keyCode==27?(l.preventDefault(),r.dispatch({effects:dialogEffect.of(!1)}),r.focus()):l.keyCode==13&&(l.preventDefault(),o())},onsubmit:l=>{l.preventDefault(),o()}},crelt("label",r.state.phrase("Go to line"),": ",n)," ",crelt("button",{class:"cm-button",type:"submit"},r.state.phrase("go")));function o(){let l=/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(n.value);if(!l)return;let{state:a}=r,c=a.doc.lineAt(a.selection.main.head),[,h,f,u,d]=l,g=u?+u.slice(1):0,O=f?+f:c.number;if(f&&d){let b=O/100;h&&(b=b*(h=="-"?-1:1)+c.number/a.doc.lines),O=Math.round(a.doc.lines*b)}else f&&h&&(O=O*(h=="-"?-1:1)+c.number);let m=a.doc.line(Math.max(1,Math.min(a.doc.lines,O))),S=EditorSelection.cursor(m.from+Math.max(0,Math.min(g,m.length)));r.dispatch({effects:[dialogEffect.of(!1),EditorView.scrollIntoView(S.from,{y:"center"})],selection:S}),r.focus()}return{dom:s}}const dialogEffect=StateEffect.define(),dialogField=StateField.define({create(){return!0},update(r,e){for(let n of e.effects)n.is(dialogEffect)&&(r=n.value);return r},provide:r=>showPanel.from(r,e=>e?createLineDialog:null)}),gotoLine=r=>{let e=getPanel(r,createLineDialog);if(!e){let n=[dialogEffect.of(!0)];r.state.field(dialogField,!1)==null&&n.push(StateEffect.appendConfig.of([dialogField,baseTheme$1])),r.dispatch({effects:n}),e=getPanel(r,createLineDialog)}return e&&e.dom.querySelector("input").select(),!0},baseTheme$1=EditorView.baseTheme({".cm-panel.cm-gotoLine":{padding:"2px 6px 4px","& label":{fontSize:"80%"}}}),defaultHighlightOptions={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},highlightConfig=Facet.define({combine(r){return combineConfig(r,defaultHighlightOptions,{highlightWordAroundCursor:(e,n)=>e||n,minSelectionLength:Math.min,maxMatches:Math.min})}});function highlightSelectionMatches(r){return[defaultTheme,matchHighlighter]}const matchDeco=Decoration.mark({class:"cm-selectionMatch"}),mainMatchDeco=Decoration.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function insideWordBoundaries(r,e,n,s){return(n==0||r(e.sliceDoc(n-1,n))!=CharCategory.Word)&&(s==e.doc.length||r(e.sliceDoc(s,s+1))!=CharCategory.Word)}function insideWord(r,e,n,s){return r(e.sliceDoc(n,n+1))==CharCategory.Word&&r(e.sliceDoc(s-1,s))==CharCategory.Word}const matchHighlighter=ViewPlugin.fromClass(class{constructor(r){this.decorations=this.getDeco(r)}update(r){(r.selectionSet||r.docChanged||r.viewportChanged)&&(this.decorations=this.getDeco(r.view))}getDeco(r){let e=r.state.facet(highlightConfig),{state:n}=r,s=n.selection;if(s.ranges.length>1)return Decoration.none;let o=s.main,l,a=null;if(o.empty){if(!e.highlightWordAroundCursor)return Decoration.none;let h=n.wordAt(o.head);if(!h)return Decoration.none;a=n.charCategorizer(o.head),l=n.sliceDoc(h.from,h.to)}else{let h=o.to-o.from;if(h200)return Decoration.none;if(e.wholeWords){if(l=n.sliceDoc(o.from,o.to),a=n.charCategorizer(o.head),!(insideWordBoundaries(a,n,o.from,o.to)&&insideWord(a,n,o.from,o.to)))return Decoration.none}else if(l=n.sliceDoc(o.from,o.to),!l)return Decoration.none}let c=[];for(let h of r.visibleRanges){let f=new SearchCursor(n.doc,l,h.from,h.to);for(;!f.next().done;){let{from:u,to:d}=f.value;if((!a||insideWordBoundaries(a,n,u,d))&&(o.empty&&u<=o.from&&d>=o.to?c.push(mainMatchDeco.range(u,d)):(u>=o.to||d<=o.from)&&c.push(matchDeco.range(u,d)),c.length>e.maxMatches))return Decoration.none}}return Decoration.set(c)}},{decorations:r=>r.decorations}),defaultTheme=EditorView.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}}),selectWord=({state:r,dispatch:e})=>{let{selection:n}=r,s=EditorSelection.create(n.ranges.map(o=>r.wordAt(o.head)||EditorSelection.cursor(o.head)),n.mainIndex);return s.eq(n)?!1:(e(r.update({selection:s})),!0)};function findNextOccurrence(r,e){let{main:n,ranges:s}=r.selection,o=r.wordAt(n.head),l=o&&o.from==n.from&&o.to==n.to;for(let a=!1,c=new SearchCursor(r.doc,e,s[s.length-1].to);;)if(c.next(),c.done){if(a)return null;c=new SearchCursor(r.doc,e,0,Math.max(0,s[s.length-1].from-1)),a=!0}else{if(a&&s.some(h=>h.from==c.value.from))continue;if(l){let h=r.wordAt(c.value.from);if(!h||h.from!=c.value.from||h.to!=c.value.to)continue}return c.value}}const selectNextOccurrence=({state:r,dispatch:e})=>{let{ranges:n}=r.selection;if(n.some(l=>l.from===l.to))return selectWord({state:r,dispatch:e});let s=r.sliceDoc(n[0].from,n[0].to);if(r.selection.ranges.some(l=>r.sliceDoc(l.from,l.to)!=s))return!1;let o=findNextOccurrence(r,s);return o?(e(r.update({selection:r.selection.addRange(EditorSelection.range(o.from,o.to),!1),effects:EditorView.scrollIntoView(o.to)})),!0):!1},searchConfigFacet=Facet.define({combine(r){return combineConfig(r,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new SearchPanel(e),scrollToMatch:e=>EditorView.scrollIntoView(e)})}});class SearchQuery{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||"",this.valid=!!this.search&&(!this.regexp||validRegExp(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(n,s)=>s=="n"?` +`:s=="r"?"\r":s=="t"?" ":"\\")}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord}create(){return this.regexp?new RegExpQuery(this):new StringQuery(this)}getCursor(e,n=0,s){let o=e.doc?e:EditorState.create({doc:e});return s==null&&(s=o.doc.length),this.regexp?regexpCursor(this,o,n,s):stringCursor(this,o,n,s)}}class QueryType{constructor(e){this.spec=e}}function stringCursor(r,e,n,s){return new SearchCursor(e.doc,r.unquoted,n,s,r.caseSensitive?void 0:o=>o.toLowerCase(),r.wholeWord?stringWordTest(e.doc,e.charCategorizer(e.selection.main.head)):void 0)}function stringWordTest(r,e){return(n,s,o,l)=>((l>n||l+o.length=n)return null;o.push(s.value)}return o}highlight(e,n,s,o){let l=stringCursor(this.spec,e,Math.max(0,n-this.spec.unquoted.length),Math.min(s+this.spec.unquoted.length,e.doc.length));for(;!l.next().done;)o(l.value.from,l.value.to)}}function regexpCursor(r,e,n,s){return new RegExpCursor(e.doc,r.search,{ignoreCase:!r.caseSensitive,test:r.wholeWord?regexpWordTest(e.charCategorizer(e.selection.main.head)):void 0},n,s)}function charBefore(r,e){return r.slice(findClusterBreak(r,e,!1),e)}function charAfter(r,e){return r.slice(e,findClusterBreak(r,e))}function regexpWordTest(r){return(e,n,s)=>!s[0].length||(r(charBefore(s.input,s.index))!=CharCategory.Word||r(charAfter(s.input,s.index))!=CharCategory.Word)&&(r(charAfter(s.input,s.index+s[0].length))!=CharCategory.Word||r(charBefore(s.input,s.index+s[0].length))!=CharCategory.Word)}class RegExpQuery extends QueryType{nextMatch(e,n,s){let o=regexpCursor(this.spec,e,s,e.doc.length).next();return o.done&&(o=regexpCursor(this.spec,e,0,n).next()),o.done?null:o.value}prevMatchInRange(e,n,s){for(let o=1;;o++){let l=Math.max(n,s-o*1e4),a=regexpCursor(this.spec,e,l,s),c=null;for(;!a.next().done;)c=a.value;if(c&&(l==n||c.from>l+10))return c;if(l==n)return null}}prevMatch(e,n,s){return this.prevMatchInRange(e,0,n)||this.prevMatchInRange(e,s,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&\d+])/g,(n,s)=>s=="$"?"$":s=="&"?e.match[0]:s!="0"&&+s=n)return null;o.push(s.value)}return o}highlight(e,n,s,o){let l=regexpCursor(this.spec,e,Math.max(0,n-250),Math.min(s+250,e.doc.length));for(;!l.next().done;)o(l.value.from,l.value.to)}}const setSearchQuery=StateEffect.define(),togglePanel=StateEffect.define(),searchState=StateField.define({create(r){return new SearchState(defaultQuery(r).create(),null)},update(r,e){for(let n of e.effects)n.is(setSearchQuery)?r=new SearchState(n.value.create(),r.panel):n.is(togglePanel)&&(r=new SearchState(r.query,n.value?createSearchPanel:null));return r},provide:r=>showPanel.from(r,e=>e.panel)});class SearchState{constructor(e,n){this.query=e,this.panel=n}}const matchMark=Decoration.mark({class:"cm-searchMatch"}),selectedMatchMark=Decoration.mark({class:"cm-searchMatch cm-searchMatch-selected"}),searchHighlighter=ViewPlugin.fromClass(class{constructor(r){this.view=r,this.decorations=this.highlight(r.state.field(searchState))}update(r){let e=r.state.field(searchState);(e!=r.startState.field(searchState)||r.docChanged||r.selectionSet||r.viewportChanged)&&(this.decorations=this.highlight(e))}highlight({query:r,panel:e}){if(!e||!r.spec.valid)return Decoration.none;let{view:n}=this,s=new RangeSetBuilder;for(let o=0,l=n.visibleRanges,a=l.length;ol[o+1].from-2*250;)h=l[++o].to;r.highlight(n.state,c,h,(f,u)=>{let d=n.state.selection.ranges.some(g=>g.from==f&&g.to==u);s.add(f,u,d?selectedMatchMark:matchMark)})}return s.finish()}},{decorations:r=>r.decorations});function searchCommand(r){return e=>{let n=e.state.field(searchState,!1);return n&&n.query.spec.valid?r(e,n):openSearchPanel(e)}}const findNext=searchCommand((r,{query:e})=>{let{to:n}=r.state.selection.main,s=e.nextMatch(r.state,n,n);if(!s)return!1;let o=EditorSelection.single(s.from,s.to),l=r.state.facet(searchConfigFacet);return r.dispatch({selection:o,effects:[announceMatch(r,s),l.scrollToMatch(o.main,r)],userEvent:"select.search"}),selectSearchInput(r),!0}),findPrevious=searchCommand((r,{query:e})=>{let{state:n}=r,{from:s}=n.selection.main,o=e.prevMatch(n,s,s);if(!o)return!1;let l=EditorSelection.single(o.from,o.to),a=r.state.facet(searchConfigFacet);return r.dispatch({selection:l,effects:[announceMatch(r,o),a.scrollToMatch(l.main,r)],userEvent:"select.search"}),selectSearchInput(r),!0}),selectMatches=searchCommand((r,{query:e})=>{let n=e.matchAll(r.state,1e3);return!n||!n.length?!1:(r.dispatch({selection:EditorSelection.create(n.map(s=>EditorSelection.range(s.from,s.to))),userEvent:"select.search.matches"}),!0)}),selectSelectionMatches=({state:r,dispatch:e})=>{let n=r.selection;if(n.ranges.length>1||n.main.empty)return!1;let{from:s,to:o}=n.main,l=[],a=0;for(let c=new SearchCursor(r.doc,r.sliceDoc(s,o));!c.next().done;){if(l.length>1e3)return!1;c.value.from==s&&(a=l.length),l.push(EditorSelection.range(c.value.from,c.value.to))}return e(r.update({selection:EditorSelection.create(l,a),userEvent:"select.search.matches"})),!0},replaceNext=searchCommand((r,{query:e})=>{let{state:n}=r,{from:s,to:o}=n.selection.main;if(n.readOnly)return!1;let l=e.nextMatch(n,s,s);if(!l)return!1;let a=[],c,h,f=[];if(l.from==s&&l.to==o&&(h=n.toText(e.getReplacement(l)),a.push({from:l.from,to:l.to,insert:h}),l=e.nextMatch(n,l.from,l.to),f.push(EditorView.announce.of(n.phrase("replaced match on line $",n.doc.lineAt(s).number)+"."))),l){let u=a.length==0||a[0].from>=l.to?0:l.to-l.from-h.length;c=EditorSelection.single(l.from-u,l.to-u),f.push(announceMatch(r,l)),f.push(n.facet(searchConfigFacet).scrollToMatch(c.main,r))}return r.dispatch({changes:a,selection:c,effects:f,userEvent:"input.replace"}),!0}),replaceAll=searchCommand((r,{query:e})=>{if(r.state.readOnly)return!1;let n=e.matchAll(r.state,1e9).map(o=>{let{from:l,to:a}=o;return{from:l,to:a,insert:e.getReplacement(o)}});if(!n.length)return!1;let s=r.state.phrase("replaced $ matches",n.length)+".";return r.dispatch({changes:n,effects:EditorView.announce.of(s),userEvent:"input.replace.all"}),!0});function createSearchPanel(r){return r.state.facet(searchConfigFacet).createPanel(r)}function defaultQuery(r,e){var n,s,o,l,a;let c=r.selection.main,h=c.empty||c.to>c.from+100?"":r.sliceDoc(c.from,c.to);if(e&&!h)return e;let f=r.facet(searchConfigFacet);return new SearchQuery({search:((n=e==null?void 0:e.literal)!==null&&n!==void 0?n:f.literal)?h:h.replace(/\n/g,"\\n"),caseSensitive:(s=e==null?void 0:e.caseSensitive)!==null&&s!==void 0?s:f.caseSensitive,literal:(o=e==null?void 0:e.literal)!==null&&o!==void 0?o:f.literal,regexp:(l=e==null?void 0:e.regexp)!==null&&l!==void 0?l:f.regexp,wholeWord:(a=e==null?void 0:e.wholeWord)!==null&&a!==void 0?a:f.wholeWord})}function getSearchInput(r){let e=getPanel(r,createSearchPanel);return e&&e.dom.querySelector("[main-field]")}function selectSearchInput(r){let e=getSearchInput(r);e&&e==r.root.activeElement&&e.select()}const openSearchPanel=r=>{let e=r.state.field(searchState,!1);if(e&&e.panel){let n=getSearchInput(r);if(n&&n!=r.root.activeElement){let s=defaultQuery(r.state,e.query.spec);s.valid&&r.dispatch({effects:setSearchQuery.of(s)}),n.focus(),n.select()}}else r.dispatch({effects:[togglePanel.of(!0),e?setSearchQuery.of(defaultQuery(r.state,e.query.spec)):StateEffect.appendConfig.of(searchExtensions)]});return!0},closeSearchPanel=r=>{let e=r.state.field(searchState,!1);if(!e||!e.panel)return!1;let n=getPanel(r,createSearchPanel);return n&&n.dom.contains(r.root.activeElement)&&r.focus(),r.dispatch({effects:togglePanel.of(!1)}),!0},searchKeymap=[{key:"Mod-f",run:openSearchPanel,scope:"editor search-panel"},{key:"F3",run:findNext,shift:findPrevious,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:findNext,shift:findPrevious,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:closeSearchPanel,scope:"editor search-panel"},{key:"Mod-Shift-l",run:selectSelectionMatches},{key:"Mod-Alt-g",run:gotoLine},{key:"Mod-d",run:selectNextOccurrence,preventDefault:!0}];class SearchPanel{constructor(e){this.view=e;let n=this.query=e.state.field(searchState).query.spec;this.commit=this.commit.bind(this),this.searchField=crelt("input",{value:n.search,placeholder:phrase(e,"Find"),"aria-label":phrase(e,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=crelt("input",{value:n.replace,placeholder:phrase(e,"Replace"),"aria-label":phrase(e,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=crelt("input",{type:"checkbox",name:"case",form:"",checked:n.caseSensitive,onchange:this.commit}),this.reField=crelt("input",{type:"checkbox",name:"re",form:"",checked:n.regexp,onchange:this.commit}),this.wordField=crelt("input",{type:"checkbox",name:"word",form:"",checked:n.wholeWord,onchange:this.commit});function s(o,l,a){return crelt("button",{class:"cm-button",name:o,onclick:l,type:"button"},a)}this.dom=crelt("div",{onkeydown:o=>this.keydown(o),class:"cm-search"},[this.searchField,s("next",()=>findNext(e),[phrase(e,"next")]),s("prev",()=>findPrevious(e),[phrase(e,"previous")]),s("select",()=>selectMatches(e),[phrase(e,"all")]),crelt("label",null,[this.caseField,phrase(e,"match case")]),crelt("label",null,[this.reField,phrase(e,"regexp")]),crelt("label",null,[this.wordField,phrase(e,"by word")]),...e.state.readOnly?[]:[crelt("br"),this.replaceField,s("replace",()=>replaceNext(e),[phrase(e,"replace")]),s("replaceAll",()=>replaceAll(e),[phrase(e,"replace all")])],crelt("button",{name:"close",onclick:()=>closeSearchPanel(e),"aria-label":phrase(e,"close"),type:"button"},["×"])])}commit(){let e=new SearchQuery({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:setSearchQuery.of(e)}))}keydown(e){runScopeHandlers(this.view,e,"search-panel")?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?findPrevious:findNext)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),replaceNext(this.view))}update(e){for(let n of e.transactions)for(let s of n.effects)s.is(setSearchQuery)&&!s.value.eq(this.query)&&this.setQuery(s.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(searchConfigFacet).top}}function phrase(r,e){return r.state.phrase(e)}const AnnounceMargin=30,Break=/[\s\.,:;?!]/;function announceMatch(r,{from:e,to:n}){let s=r.state.doc.lineAt(e),o=r.state.doc.lineAt(n).to,l=Math.max(s.from,e-AnnounceMargin),a=Math.min(o,n+AnnounceMargin),c=r.state.sliceDoc(l,a);if(l!=s.from){for(let h=0;hc.length-AnnounceMargin;h--)if(!Break.test(c[h-1])&&Break.test(c[h])){c=c.slice(0,h);break}}return EditorView.announce.of(`${r.state.phrase("current match")}. ${c} ${r.state.phrase("on line")} ${s.number}.`)}const baseTheme=EditorView.baseTheme({".cm-panel.cm-search":{padding:"2px 6px 4px",position:"relative","& [name=close]":{position:"absolute",top:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:0,margin:0},"& input, & button, & label":{margin:".2em .6em .2em 0"},"& input[type=checkbox]":{marginRight:".2em"},"& label":{fontSize:"80%",whiteSpace:"pre"}},"&light .cm-searchMatch":{backgroundColor:"#ffff0054"},"&dark .cm-searchMatch":{backgroundColor:"#00ffff8a"},"&light .cm-searchMatch-selected":{backgroundColor:"#ff6a0054"},"&dark .cm-searchMatch-selected":{backgroundColor:"#ff00ff8a"}}),searchExtensions=[searchState,Prec.low(searchHighlighter),baseTheme],chalky="#e5c07b",coral="#e06c75",cyan="#56b6c2",invalid="#ffffff",ivory="#abb2bf",stone="#7d8799",malibu="#61afef",sage="#98c379",whiskey="#d19a66",violet="#c678dd",darkBackground="#21252b",highlightBackground="#2c313a",background="#282c34",tooltipBackground="#353a42",selection="#3E4451",cursor="#528bff",oneDarkTheme=EditorView.theme({"&":{color:ivory,backgroundColor:background},".cm-content":{caretColor:cursor},".cm-cursor, .cm-dropCursor":{borderLeftColor:cursor},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:selection},".cm-panels":{backgroundColor:darkBackground,color:ivory},".cm-panels.cm-panels-top":{borderBottom:"2px solid black"},".cm-panels.cm-panels-bottom":{borderTop:"2px solid black"},".cm-searchMatch":{backgroundColor:"#72a1ff59",outline:"1px solid #457dff"},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:"#6199ff2f"},".cm-activeLine":{backgroundColor:"#6699ff0b"},".cm-selectionMatch":{backgroundColor:"#aafe661a"},"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bad0f847"},".cm-gutters":{backgroundColor:background,color:stone,border:"none"},".cm-activeLineGutter":{backgroundColor:highlightBackground},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"none",backgroundColor:tooltipBackground},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:tooltipBackground,borderBottomColor:tooltipBackground},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:highlightBackground,color:ivory}}},{dark:!0}),oneDarkHighlightStyle=HighlightStyle.define([{tag:tags.keyword,color:violet},{tag:[tags.name,tags.deleted,tags.character,tags.propertyName,tags.macroName],color:coral},{tag:[tags.function(tags.variableName),tags.labelName],color:malibu},{tag:[tags.color,tags.constant(tags.name),tags.standard(tags.name)],color:whiskey},{tag:[tags.definition(tags.name),tags.separator],color:ivory},{tag:[tags.typeName,tags.className,tags.number,tags.changed,tags.annotation,tags.modifier,tags.self,tags.namespace],color:chalky},{tag:[tags.operator,tags.operatorKeyword,tags.url,tags.escape,tags.regexp,tags.link,tags.special(tags.string)],color:cyan},{tag:[tags.meta,tags.comment],color:stone},{tag:tags.strong,fontWeight:"bold"},{tag:tags.emphasis,fontStyle:"italic"},{tag:tags.strikethrough,textDecoration:"line-through"},{tag:tags.link,color:stone,textDecoration:"underline"},{tag:tags.heading,fontWeight:"bold",color:coral},{tag:[tags.atom,tags.bool,tags.special(tags.variableName)],color:whiskey},{tag:[tags.processingInstruction,tags.string,tags.inserted],color:sage},{tag:tags.invalid,color:invalid}]),oneDark=[oneDarkTheme,syntaxHighlighting(oneDarkHighlightStyle)],_sfc_main$a={__name:"CodeEditor",props:{editorId:{type:String,require:!0},initialValue:{type:String,required:!1,default:""}},setup(r){const e=r,n=ref(null),s=StateEffect.define(),o=StateField.define({create(){return Decoration.none},update(c,h){h.effects.some(f=>f.is(s))&&(c=Decoration.none),c=c.map(h.changes);for(let f of[...h.effects].reverse())if(f.is(s)){c=c.update({add:f.value,sort:!0});break}return c},provide:c=>EditorView.decorations.from(c)}),l=Decoration.mark({class:"highlighted-code"});function a(c,h){if(!arguments.length)document.querySelectorAll(".highlighted-code").forEach(f=>f.classList.remove("highlighted-code"));else{this.dispatch({effects:s.of([l.range(c,h)])});const f=new SelectionRange(c,h),u=store.getEditor(store.editorIds.inputCodeEditor);u==null||u.dispatch({effects:EditorView.scrollIntoView(f,{y:"center",x:"center"})})}}return onMounted(()=>{const c=new EditorView({parent:n.value,theme:"dracula",state:EditorState.create({doc:e.initialValue,extensions:[autocompletion(),bracketMatching(),closeBrackets(),crosshairCursor(),drawSelection(),dropCursor(),EditorState.allowMultipleSelections.of(!0),foldGutter(),highlightActiveLine(),highlightActiveLineGutter(),o,highlightSelectionMatches(),highlightSpecialChars(),history(),indentOnInput(),javascript(),keymap.of([...closeBracketsKeymap,...defaultKeymap,...searchKeymap,...historyKeymap,...foldKeymap,...completionKeymap,...lintKeymap]),lineNumbers(),oneDark,rectangularSelection(),syntaxHighlighting(oneDarkHighlightStyle,{fallback:!0})]})});c.editorId=e.editorId,c.highlightRange=a,store.editors.push(c)}),(c,h)=>(openBlock(),createElementBlock("div",{ref_key:"editorElement",ref:n,class:"code-editor"},null,512))}},CodeEditor=_export_sfc(_sfc_main$a,[["__scopeId","data-v-34dc6d07"]]),_hoisted_1$8={class:"code-editor-wrapper"},_hoisted_2$6={key:0},initialValue$2=`// This is the default code for flASTer // Click the button at the top to load a file or paste directly into the editor (function() { - function helloWorld() { return 'hello world';} + function createMessage() {return 'Hello' + ' ' + 'there!';} function print(msg) {console.log(msg)} - print(helloWorld()); -})();`,_sfc_main$8={__name:"InputCodeEditor",setup(r){return(e,n)=>(openBlock(),createElementBlock("fieldset",_hoisted_1$7,[createBaseVNode("legend",null,[createTextVNode("Your code "),unref(store).isTransformed?(openBlock(),createElementBlock("span",_hoisted_2$5,"(transformed)")):createCommentVNode("",!0)]),createVNode(CodeEditor,{"editor-id":unref(store).editorIds.inputCodeEditor,"initial-value":initialValue$1},null,8,["editor-id"])]))}},InputCodeEditor=_export_sfc(_sfc_main$8,[["__scopeId","data-v-667f3d58"]]),_hoisted_1$6={class:"code-and-nodes"},_sfc_main$7={__name:"CodeAndNodes",setup(r){return(e,n)=>(openBlock(),createElementBlock("div",_hoisted_1$6,[createVNode(InputCodeEditor),createVNode(NodesList)]))}},CodeAndNodes=_export_sfc(_sfc_main$7,[["__scopeId","data-v-ef72c9dc"]]),_sfc_main$6={__name:"ToasterMessage",props:{text:{type:String,required:!0},level:{type:String,default:"info"}},setup(r){const e=ref(null);function n(){e.value.remove()}return onMounted(()=>{}),(s,o)=>(openBlock(),createElementBlock("div",{ref_key:"toasterMessage",ref:e,class:normalizeClass(["toast","toast-"+r.level])},[createBaseVNode("button",{class:"toast-close-message",onClick:n},"x"),createBaseVNode("div",null,toDisplayString(r.text),1)],2))}},ToasterMessage=_export_sfc(_sfc_main$6,[["__scopeId","data-v-5d1358b2"]]),_hoisted_1$5={class:"toaster"},TOAST_TIMEOUT=3.5*1e3,_sfc_main$5={__name:"ToasterView",setup(r){const e=reactive({});function n(s,o){const l=o+s;e[l]||(e[l]={text:s,level:o},setTimeout(()=>{const a=document.querySelector(`[data-key="${l}"]`);a&&a.classList.add("toast-disappear"),setTimeout(()=>delete e[l],1e3)},TOAST_TIMEOUT)),console.log(`[${o}] ${s}`)}return onMounted(()=>{store.logMessage=n,window.store=store}),(s,o)=>(openBlock(),createElementBlock("div",_hoisted_1$5,[(openBlock(!0),createElementBlock(Fragment,null,renderList(e,(l,a)=>(openBlock(),createElementBlock("div",{key:a},[createVNode(ToasterMessage,{class:"toast-appear",text:l.text,level:l.level,"data-key":a},null,8,["text","level","data-key"])]))),128))]))}},ToasterView=_export_sfc(_sfc_main$5,[["__scopeId","data-v-810ce0bb"]]),_sfc_main$4={},_hoisted_1$4={viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",stroke:"#ffffff"},_hoisted_2$4=createBaseVNode("path",{d:"M8 12L11 15L16 9M4 16.8002V7.2002C4 6.08009 4 5.51962 4.21799 5.0918C4.40973 4.71547 4.71547 4.40973 5.0918 4.21799C5.51962 4 6.08009 4 7.2002 4H16.8002C17.9203 4 18.4796 4 18.9074 4.21799C19.2837 4.40973 19.5905 4.71547 19.7822 5.0918C20 5.5192 20 6.07899 20 7.19691V16.8036C20 17.9215 20 18.4805 19.7822 18.9079C19.5905 19.2842 19.2837 19.5905 18.9074 19.7822C18.48 20 17.921 20 16.8031 20H7.19691C6.07899 20 5.5192 20 5.0918 19.7822C4.71547 19.5905 4.40973 19.2842 4.21799 18.9079C4 18.4801 4 17.9203 4 16.8002Z",stroke:"#71f22c","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},null,-1),_hoisted_3$2=[_hoisted_2$4];function _sfc_render$2(r,e){return openBlock(),createElementBlock("svg",_hoisted_1$4,_hoisted_3$2)}const IconCheckboxActive=_export_sfc(_sfc_main$4,[["render",_sfc_render$2]]),_sfc_main$3={},_hoisted_1$3={viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},_hoisted_2$3=createBaseVNode("path",{d:"M4 7.2002V16.8002C4 17.9203 4 18.4801 4.21799 18.9079C4.40973 19.2842 4.71547 19.5905 5.0918 19.7822C5.5192 20 6.07899 20 7.19691 20H16.8031C17.921 20 18.48 20 18.9074 19.7822C19.2837 19.5905 19.5905 19.2842 19.7822 18.9079C20 18.4805 20 17.9215 20 16.8036V7.19691C20 6.07899 20 5.5192 19.7822 5.0918C19.5905 4.71547 19.2837 4.40973 18.9074 4.21799C18.4796 4 17.9203 4 16.8002 4H7.2002C6.08009 4 5.51962 4 5.0918 4.21799C4.71547 4.40973 4.40973 4.71547 4.21799 5.0918C4 5.51962 4 6.08009 4 7.2002Z",stroke:"#d20404","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},null,-1),_hoisted_3$1=[_hoisted_2$3];function _sfc_render$1(r,e){return openBlock(),createElementBlock("svg",_hoisted_1$3,_hoisted_3$1)}const IconCheckboxInactive=_export_sfc(_sfc_main$3,[["render",_sfc_render$1]]),_sfc_main$2={},_hoisted_1$2={viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},_hoisted_2$2=createStaticVNode('',5),_hoisted_7$1=[_hoisted_2$2];function _sfc_render(r,e){return openBlock(),createElementBlock("svg",_hoisted_1$2,_hoisted_7$1)}const IconTrash=_export_sfc(_sfc_main$2,[["render",_sfc_render]]),_withScopeId=r=>(pushScopeId("data-v-a9d18325"),r=r(),popScopeId(),r),_hoisted_1$1={key:0,class:"filter-controller"},_hoisted_2$1={class:"btn-group"},_hoisted_3={class:"filter-edit-btn-group"},_hoisted_4={class:"applied-filters-btn-group"},_hoisted_5=["disabled"],_hoisted_6=["disabled"],_hoisted_7=["disabled"],_hoisted_8={class:"filter-display"},_hoisted_9={class:"filter-editor-wrapper"},_hoisted_10=_withScopeId(()=>createBaseVNode("legend",null,"Filter code",-1)),_hoisted_11={class:"applied-filters-wrapper"},_hoisted_12=["onClick","title"],_hoisted_13=["title","onClick"],initialValue="// write content for the filter function `(n) => {}`, like:\nn.type === 'CallExpression' &&\nn.callee.type === 'Identifier'",_sfc_main$1={__name:"FilterEditor",setup(__props){const messages={disableFilters:"Disable all",enableFilters:"Enable all"},numOfEnabledFilters=computed(()=>store.filters.filter(r=>r==null?void 0:r.enabled).length),numOfAvailableFilters=computed(()=>store.filters.length),displayedNumOfFilters=computed(()=>numOfAvailableFilters.value?`${numOfEnabledFilters.value} / ${numOfAvailableFilters.value}`:"No");function findFilter(r){return store.filters.find(e=>(e==null?void 0:e.src)===r)}function applyFilter(filterSrc){if(!filterSrc)return store.logMessage("Missing filter code","error");try{filterSrc=filterSrc.trim(),store.filteredNodes=store.filteredNodes.filter(eval(`n => ${filterSrc}`)),findFilter(filterSrc)||store.filters.push({src:filterSrc,enabled:!0}),store.page=0}catch(r){console.log(`Invalid filter code: ${r.message}`)}}function reapplyFilters(){store.filteredNodes=store.ast;for(const r of store.filters)r!=null&&r.enabled&&applyFilter(r.src);store.page=0}function toggleFilter(r){r.enabled=!r.enabled,reapplyFilters()}function clearAllFilters(){store.filters.length=0,store.filteredNodes=store.ast,store.page=0}function deleteFilter(r){store.filters=store.filters.filter(e=>e!==r),reapplyFilters()}function combineEnabledFilters(){const r=store.filters.filter(e=>e==null?void 0:e.enabled);if(r.length>1){let e=`(${r[0].src}) + print(createMessage()); +})();`,_sfc_main$9={__name:"InputCodeEditor",setup(r){return(e,n)=>(openBlock(),createElementBlock("fieldset",_hoisted_1$8,[createBaseVNode("legend",null,[createTextVNode("Your code "),unref(store).isTransformed?(openBlock(),createElementBlock("span",_hoisted_2$6,"(transformed)")):createCommentVNode("",!0)]),createVNode(CodeEditor,{"editor-id":unref(store).editorIds.inputCodeEditor,"initial-value":initialValue$2},null,8,["editor-id"])]))}},InputCodeEditor=_export_sfc(_sfc_main$9,[["__scopeId","data-v-57219ecd"]]),_hoisted_1$7={class:"code-and-nodes"},_sfc_main$8={__name:"CodeAndNodes",setup(r){return(e,n)=>(openBlock(),createElementBlock("div",_hoisted_1$7,[createVNode(InputCodeEditor),createVNode(NodesList)]))}},CodeAndNodes=_export_sfc(_sfc_main$8,[["__scopeId","data-v-ef72c9dc"]]),_sfc_main$7={},_hoisted_1$6={viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},_hoisted_2$5=createStaticVNode('',5),_hoisted_7$2=[_hoisted_2$5];function _sfc_render$2(r,e){return openBlock(),createElementBlock("svg",_hoisted_1$6,_hoisted_7$2)}const IconTrash=_export_sfc(_sfc_main$7,[["render",_sfc_render$2]]),_sfc_main$6={},_hoisted_1$5={viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",stroke:"#ffffff"},_hoisted_2$4=createBaseVNode("path",{d:"M8 12L11 15L16 9M4 16.8002V7.2002C4 6.08009 4 5.51962 4.21799 5.0918C4.40973 4.71547 4.71547 4.40973 5.0918 4.21799C5.51962 4 6.08009 4 7.2002 4H16.8002C17.9203 4 18.4796 4 18.9074 4.21799C19.2837 4.40973 19.5905 4.71547 19.7822 5.0918C20 5.5192 20 6.07899 20 7.19691V16.8036C20 17.9215 20 18.4805 19.7822 18.9079C19.5905 19.2842 19.2837 19.5905 18.9074 19.7822C18.48 20 17.921 20 16.8031 20H7.19691C6.07899 20 5.5192 20 5.0918 19.7822C4.71547 19.5905 4.40973 19.2842 4.21799 18.9079C4 18.4801 4 17.9203 4 16.8002Z",stroke:"#71f22c","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},null,-1),_hoisted_3$3=[_hoisted_2$4];function _sfc_render$1(r,e){return openBlock(),createElementBlock("svg",_hoisted_1$5,_hoisted_3$3)}const IconCheckboxActive=_export_sfc(_sfc_main$6,[["render",_sfc_render$1]]),_sfc_main$5={},_hoisted_1$4={viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},_hoisted_2$3=createBaseVNode("path",{d:"M4 7.2002V16.8002C4 17.9203 4 18.4801 4.21799 18.9079C4.40973 19.2842 4.71547 19.5905 5.0918 19.7822C5.5192 20 6.07899 20 7.19691 20H16.8031C17.921 20 18.48 20 18.9074 19.7822C19.2837 19.5905 19.5905 19.2842 19.7822 18.9079C20 18.4805 20 17.9215 20 16.8036V7.19691C20 6.07899 20 5.5192 19.7822 5.0918C19.5905 4.71547 19.2837 4.40973 18.9074 4.21799C18.4796 4 17.9203 4 16.8002 4H7.2002C6.08009 4 5.51962 4 5.0918 4.21799C4.71547 4.40973 4.40973 4.71547 4.21799 5.0918C4 5.51962 4 6.08009 4 7.2002Z",stroke:"#d20404","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},null,-1),_hoisted_3$2=[_hoisted_2$3];function _sfc_render(r,e){return openBlock(),createElementBlock("svg",_hoisted_1$4,_hoisted_3$2)}const IconCheckboxInactive=_export_sfc(_sfc_main$5,[["render",_sfc_render]]),_withScopeId$1=r=>(pushScopeId("data-v-1962bad8"),r=r(),popScopeId(),r),_hoisted_1$3={key:0,class:"filter-controller"},_hoisted_2$2={class:"btn-group"},_hoisted_3$1={class:"filter-edit-btn-group"},_hoisted_4$1={class:"applied-filters-btn-group"},_hoisted_5$1=["disabled"],_hoisted_6$1=["disabled"],_hoisted_7$1=["disabled"],_hoisted_8$1={class:"filter-display"},_hoisted_9$1={class:"filter-editor-wrapper"},_hoisted_10$1=_withScopeId$1(()=>createBaseVNode("legend",null,"Filter code",-1)),_hoisted_11$1={class:"applied-filters-wrapper"},_hoisted_12$1=["onClick","title"],_hoisted_13$1=["title","onClick"],initialValue$1="// write content for the filter function `(n) => {}`, like:\nn.type === 'Literal' &&\nn.value.trim().length",_sfc_main$4={__name:"FilterEditor",setup(__props){const messages={disableFilters:"Disable all",enableFilters:"Enable all"},numOfEnabledFilters=computed(()=>store.filters.filter(r=>r==null?void 0:r.enabled).length),numOfAvailableFilters=computed(()=>store.filters.length),displayedNumOfFilters=computed(()=>numOfAvailableFilters.value?`${numOfEnabledFilters.value} / ${numOfAvailableFilters.value}`:"No");function findFilter(r){return store.filters.find(e=>(e==null?void 0:e.src)===r)}function applyFilter(filterSrc){if(!filterSrc)return store.logMessage("Missing filter code","error");try{filterSrc=filterSrc.trim(),store.filteredNodes=store.filteredNodes.filter(eval(`n => ${filterSrc}`)),findFilter(filterSrc)||store.filters.push({src:filterSrc,enabled:!0}),store.page=0}catch(r){console.log(`Invalid filter code: ${r.message}`)}}function reapplyFilters(){store.filteredNodes=store.ast;for(const r of store.filters)r!=null&&r.enabled&&applyFilter(r.src);store.page=0}function toggleFilter(r){r.enabled=!r.enabled,reapplyFilters()}function clearAllFilters(){store.filters.length=0,store.filteredNodes=store.ast,store.page=0}function deleteFilter(r){store.filters=store.filters.filter(e=>e!==r),reapplyFilters()}function combineEnabledFilters(){const r=store.filters.filter(e=>e==null?void 0:e.enabled);if(r.length>1){let e=`(${r[0].src}) `;for(const n of r.slice(1))e+=` && (${n==null?void 0:n.src}) -`;store.filters=store.filters.filter(n=>!r.includes(n)),applyFilter(e)}}function setFilterEditorContent(r){store.setContent(store.getEditor(store.editorIds.filterEditor),r)}function addNewFilter(){var e;const r=(e=store.getEditor(store.editorIds.filterEditor))==null?void 0:e.state.doc.toString();findFilter(r)?store.logMessage("Filter already exists","info"):applyFilter(r)}return(r,e)=>unref(store).ast.length?(openBlock(),createElementBlock("div",_hoisted_1$1,[createBaseVNode("div",_hoisted_2$1,[createBaseVNode("span",_hoisted_3,[createBaseVNode("button",{class:"btn btn-apply",onClick:addNewFilter},"Add"),createBaseVNode("button",{class:"btn btn-clear",onClick:e[0]||(e[0]=n=>setFilterEditorContent(""))},"Clear")]),createBaseVNode("span",_hoisted_4,[createBaseVNode("button",{class:"btn btn-clear-all-filters",onClick:clearAllFilters,disabled:!numOfAvailableFilters.value},"Clear all",8,_hoisted_5),createBaseVNode("button",{class:"btn btn-clear-all-filters",onClick:e[1]||(e[1]=n=>unref(store).areFiltersActive=!unref(store).areFiltersActive),disabled:!numOfAvailableFilters.value},toDisplayString(unref(store).areFiltersActive?messages.disableFilters:messages.enableFilters),9,_hoisted_6),createBaseVNode("button",{class:"btn btn-clear-all-filters",disabled:!numOfEnabledFilters.value||numOfEnabledFilters.value<2,onClick:combineEnabledFilters},"Combine active",8,_hoisted_7)])]),createBaseVNode("div",_hoisted_8,[createBaseVNode("fieldset",_hoisted_9,[_hoisted_10,createVNode(CodeEditor,{"editor-id":unref(store).editorIds.filterEditor,"initial-value":initialValue},null,8,["editor-id"])]),createBaseVNode("fieldset",_hoisted_11,[createBaseVNode("legend",null,[createBaseVNode("span",null,toDisplayString(displayedNumOfFilters.value),1),createTextVNode(" Filters Applied")]),(openBlock(!0),createElementBlock(Fragment,null,renderList(unref(store).filters,n=>(openBlock(),createElementBlock("div",{key:n,class:"filter-line"},[createBaseVNode("span",{class:"btn-group-inline",onClick:s=>toggleFilter(n),title:"Click to "+(n.enabled?"disable":"enable")+" filter"},[n.enabled?(openBlock(),createBlock(IconCheckboxActive,{key:0,class:"icon-inline"})):(openBlock(),createBlock(IconCheckboxInactive,{key:1,class:"icon-inline"}))],8,_hoisted_12),createBaseVNode("span",{class:"filter-src",title:n.src,onClick:s=>setFilterEditorContent(n.src)},toDisplayString(n.src),9,_hoisted_13),createVNode(IconTrash,{class:"icon-inline",onClick:s=>deleteFilter(n),title:"Delete filter"},null,8,["onClick"])]))),128))])])])):createCommentVNode("",!0)}},FilterEditor=_export_sfc(_sfc_main$1,[["__scopeId","data-v-a9d18325"]]),_hoisted_1={class:"panes"},_hoisted_2={class:"pane-bottom"},_sfc_main={__name:"App",setup(r){const e={filter:FilterEditor,transform:"",compose:""};return(n,s)=>(openBlock(),createElementBlock(Fragment,null,[createBaseVNode("header",null,[createVNode(NavBar)]),createBaseVNode("main",null,[createBaseVNode("div",_hoisted_1,[createVNode(CodeAndNodes),createBaseVNode("div",_hoisted_2,[(openBlock(),createBlock(resolveDynamicComponent(e[unref(store).currentBottomPane])))])])]),createVNode(ToasterView)],64))}},App=_export_sfc(_sfc_main,[["__scopeId","data-v-108a0431"]]);createApp(App).mount("#app");window.selectedNode=null; +`;store.filters=store.filters.filter(n=>!r.includes(n)),applyFilter(e)}}function setFilterEditorContent(r){store.setContent(store.getEditor(store.editorIds.filterEditor),r)}function addNewFilter(){var e;const r=(e=store.getEditor(store.editorIds.filterEditor))==null?void 0:e.state.doc.toString();findFilter(r)?store.logMessage("Filter already exists","info"):applyFilter(r)}return(r,e)=>unref(store).ast.length?(openBlock(),createElementBlock("div",_hoisted_1$3,[createBaseVNode("div",_hoisted_2$2,[createBaseVNode("span",_hoisted_3$1,[createBaseVNode("button",{class:"btn btn-apply",onClick:addNewFilter},"Add"),createBaseVNode("button",{class:"btn btn-clear",onClick:e[0]||(e[0]=n=>setFilterEditorContent(""))},"Clear")]),createBaseVNode("span",_hoisted_4$1,[createBaseVNode("button",{class:"btn btn-clear-all-filters",onClick:clearAllFilters,disabled:!numOfAvailableFilters.value},"Clear all",8,_hoisted_5$1),createBaseVNode("button",{class:"btn btn-clear-all-filters",onClick:e[1]||(e[1]=n=>unref(store).areFiltersActive=!unref(store).areFiltersActive),disabled:!numOfAvailableFilters.value},toDisplayString(unref(store).areFiltersActive?messages.disableFilters:messages.enableFilters),9,_hoisted_6$1),createBaseVNode("button",{class:"btn btn-clear-all-filters",disabled:!numOfEnabledFilters.value||numOfEnabledFilters.value<2,onClick:combineEnabledFilters},"Combine active",8,_hoisted_7$1)])]),createBaseVNode("div",_hoisted_8$1,[createBaseVNode("fieldset",_hoisted_9$1,[_hoisted_10$1,createVNode(CodeEditor,{"editor-id":unref(store).editorIds.filterEditor,"initial-value":initialValue$1},null,8,["editor-id"])]),createBaseVNode("fieldset",_hoisted_11$1,[createBaseVNode("legend",null,[createBaseVNode("span",null,toDisplayString(displayedNumOfFilters.value),1),createTextVNode(" Filters Applied")]),(openBlock(!0),createElementBlock(Fragment,null,renderList(unref(store).filters,n=>(openBlock(),createElementBlock("div",{key:n,class:"filter-line"},[createBaseVNode("span",{class:"btn-group-inline",onClick:s=>toggleFilter(n),title:"Click to "+(n.enabled?"disable":"enable")+" filter"},[n.enabled?(openBlock(),createBlock(IconCheckboxActive,{key:0,class:"icon-inline"})):(openBlock(),createBlock(IconCheckboxInactive,{key:1,class:"icon-inline"}))],8,_hoisted_12$1),createBaseVNode("span",{class:"filter-src",title:n.src,onClick:s=>setFilterEditorContent(n.src)},toDisplayString(n.src),9,_hoisted_13$1),createVNode(IconTrash,{class:"icon-inline",onClick:s=>deleteFilter(n),title:"Delete filter"},null,8,["onClick"])]))),128))])])])):createCommentVNode("",!0)}},FilterEditor=_export_sfc(_sfc_main$4,[["__scopeId","data-v-1962bad8"]]),_withScopeId=r=>(pushScopeId("data-v-c883ae44"),r=r(),popScopeId(),r),_hoisted_1$2={key:0,class:"filter-controller"},_hoisted_2$1={class:"btn-group"},_hoisted_3={class:"filter-edit-btn-group"},_hoisted_4={class:"applied-filters-btn-group"},_hoisted_5=["disabled"],_hoisted_6=["disabled"],_hoisted_7=["disabled"],_hoisted_8={class:"filter-display"},_hoisted_9={class:"filter-editor-wrapper"},_hoisted_10=_withScopeId(()=>createBaseVNode("legend",null,"Filter code",-1)),_hoisted_11={class:"applied-filters-wrapper"},_hoisted_12=["onClick","title"],_hoisted_13=["title","onClick"],initialValue=`// write the logic to apply to the node \`(n) => {}\`. +// to delete a node use arb.markNode(n); +// to replace a node with a new 'replacementNode' use arb.markNode(n, replacementNode); +const replacements = {Hello: 'General', 'there!': 'Kenobi'}; +if (replacements[n.value]) arb.markNode(n, { + type: 'Literal', + value: replacements[n.value], + +}); +`,_sfc_main$3={__name:"TransformEditor",setup(__props){const messages={disableFilters:"Disable all",enableFilters:"Enable all"},numOfEnabledFilters=computed(()=>store.filters.filter(r=>r==null?void 0:r.enabled).length),numOfAvailableFilters=computed(()=>store.filters.length),displayedNumOfFilters=computed(()=>numOfAvailableFilters.value?`${numOfEnabledFilters.value} / ${numOfAvailableFilters.value}`:"No");function findFilter(r){return store.filters.find(e=>(e==null?void 0:e.src)===r)}function applyFilter(filterSrc){if(!filterSrc)return store.logMessage("Missing filter code","error");try{filterSrc=filterSrc.trim(),store.filteredNodes=store.filteredNodes.filter(eval(`n => ${filterSrc}`)),findFilter(filterSrc)||store.filters.push({src:filterSrc,enabled:!0}),store.page=0}catch(r){console.log(`Invalid filter code: ${r.message}`)}}function reapplyFilters(){store.filteredNodes=store.ast;for(const r of store.filters)r!=null&&r.enabled&&applyFilter(r.src);store.page=0}function toggleFilter(r){r.enabled=!r.enabled,reapplyFilters()}function clearAllFilters(){store.filters.length=0,store.filteredNodes=store.ast,store.page=0}function deleteFilter(r){store.filters=store.filters.filter(e=>e!==r),reapplyFilters()}function combineEnabledFilters(){const r=store.filters.filter(e=>e==null?void 0:e.enabled);if(r.length>1){let e=`(${r[0].src}) +`;for(const n of r.slice(1))e+=` && (${n==null?void 0:n.src}) +`;store.filters=store.filters.filter(n=>!r.includes(n)),applyFilter(e)}}function setFilterEditorContent(r){store.setContent(store.getEditor(store.editorIds.filterEditor),r)}function addNewFilter(){var e;const r=(e=store.getEditor(store.editorIds.filterEditor))==null?void 0:e.state.doc.toString();findFilter(r)?store.logMessage("Filter already exists","info"):applyFilter(r)}return(r,e)=>unref(store).ast.length?(openBlock(),createElementBlock("div",_hoisted_1$2,[createBaseVNode("div",_hoisted_2$1,[createBaseVNode("span",_hoisted_3,[createBaseVNode("button",{class:"btn btn-apply",onClick:addNewFilter},"Add"),createBaseVNode("button",{class:"btn btn-clear",onClick:e[0]||(e[0]=n=>setFilterEditorContent(""))},"Clear")]),createBaseVNode("span",_hoisted_4,[createBaseVNode("button",{class:"btn btn-clear-all-filters",onClick:clearAllFilters,disabled:!numOfAvailableFilters.value},"Clear all",8,_hoisted_5),createBaseVNode("button",{class:"btn btn-clear-all-filters",onClick:e[1]||(e[1]=n=>unref(store).areFiltersActive=!unref(store).areFiltersActive),disabled:!numOfAvailableFilters.value},toDisplayString(unref(store).areFiltersActive?messages.disableFilters:messages.enableFilters),9,_hoisted_6),createBaseVNode("button",{class:"btn btn-clear-all-filters",disabled:!numOfEnabledFilters.value||numOfEnabledFilters.value<2,onClick:combineEnabledFilters},"Combine active",8,_hoisted_7)])]),createBaseVNode("div",_hoisted_8,[createBaseVNode("fieldset",_hoisted_9,[_hoisted_10,createVNode(CodeEditor,{"editor-id":unref(store).editorIds.filterEditor,"initial-value":initialValue},null,8,["editor-id"])]),createBaseVNode("fieldset",_hoisted_11,[createBaseVNode("legend",null,[createBaseVNode("span",null,toDisplayString(displayedNumOfFilters.value),1),createTextVNode(" Filters Applied")]),(openBlock(!0),createElementBlock(Fragment,null,renderList(unref(store).filters,n=>(openBlock(),createElementBlock("div",{key:n,class:"filter-line"},[createBaseVNode("span",{class:"btn-group-inline",onClick:s=>toggleFilter(n),title:"Click to "+(n.enabled?"disable":"enable")+" filter"},[n.enabled?(openBlock(),createBlock(IconCheckboxActive,{key:0,class:"icon-inline"})):(openBlock(),createBlock(IconCheckboxInactive,{key:1,class:"icon-inline"}))],8,_hoisted_12),createBaseVNode("span",{class:"filter-src",title:n.src,onClick:s=>setFilterEditorContent(n.src)},toDisplayString(n.src),9,_hoisted_13),createVNode(IconTrash,{class:"icon-inline",onClick:s=>deleteFilter(n),title:"Delete filter"},null,8,["onClick"])]))),128))])])])):createCommentVNode("",!0)}},TransformEditor=_export_sfc(_sfc_main$3,[["__scopeId","data-v-c883ae44"]]),_sfc_main$2={__name:"ToasterMessage",props:{text:{type:String,required:!0},level:{type:String,default:"info"}},setup(r){const e=ref(null);function n(){e.value.remove()}return onMounted(()=>{}),(s,o)=>(openBlock(),createElementBlock("div",{ref_key:"toasterMessage",ref:e,class:normalizeClass(["toast","toast-"+r.level])},[createBaseVNode("button",{class:"toast-close-message",onClick:n},"x"),createBaseVNode("div",null,toDisplayString(r.text),1)],2))}},ToasterMessage=_export_sfc(_sfc_main$2,[["__scopeId","data-v-5d1358b2"]]),_hoisted_1$1={class:"toaster"},TOAST_TIMEOUT=3.5*1e3,_sfc_main$1={__name:"ToasterView",setup(r){const e=reactive({});function n(s,o){const l=o+s;e[l]||(e[l]={text:s,level:o},setTimeout(()=>{const a=document.querySelector(`[data-key="${l}"]`);a&&a.classList.add("toast-disappear"),setTimeout(()=>delete e[l],1e3)},TOAST_TIMEOUT)),console.log(`[${o}] ${s}`)}return onMounted(()=>{store.logMessage=n,window.store=store}),(s,o)=>(openBlock(),createElementBlock("div",_hoisted_1$1,[(openBlock(!0),createElementBlock(Fragment,null,renderList(e,(l,a)=>(openBlock(),createElementBlock("div",{key:a},[createVNode(ToasterMessage,{class:"toast-appear",text:l.text,level:l.level,"data-key":a},null,8,["text","level","data-key"])]))),128))]))}},ToasterView=_export_sfc(_sfc_main$1,[["__scopeId","data-v-810ce0bb"]]),_hoisted_1={class:"panes"},_hoisted_2={class:"pane-bottom"},_sfc_main={__name:"App",setup(r){const e={filter:FilterEditor,transform:TransformEditor,compose:""};return(n,s)=>(openBlock(),createElementBlock(Fragment,null,[createBaseVNode("header",null,[createVNode(NavBar)]),createBaseVNode("main",null,[createBaseVNode("div",_hoisted_1,[createVNode(CodeAndNodes),createBaseVNode("div",_hoisted_2,[(openBlock(),createBlock(resolveDynamicComponent(e[unref(store).currentBottomPane])))])])]),createVNode(ToasterView)],64))}},App=_export_sfc(_sfc_main,[["__scopeId","data-v-e6172598"]]);createApp(App).mount("#app");window.selectedNode=null; diff --git a/dist/flast.js b/dist/flast.js index bf2b909..394d861 100644 --- a/dist/flast.js +++ b/dist/flast.js @@ -1,20295 +1,11 @@ (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i...', true, true); - const tokContexts = { - tc_oTag: tc_oTag, - tc_cTag: tc_cTag, - tc_expr: tc_expr - }; - const tokTypes = { - jsxName: new TokenType('jsxName'), - jsxText: new TokenType('jsxText', {beforeExpr: true}), - jsxTagStart: new TokenType('jsxTagStart', {startsExpr: true}), - jsxTagEnd: new TokenType('jsxTagEnd') - }; - - tokTypes.jsxTagStart.updateContext = function() { - this.context.push(tc_expr); // treat as beginning of JSX expression - this.context.push(tc_oTag); // start opening tag context - this.exprAllowed = false; - }; - tokTypes.jsxTagEnd.updateContext = function(prevType) { - let out = this.context.pop(); - if (out === tc_oTag && prevType === tt.slash || out === tc_cTag) { - this.context.pop(); - this.exprAllowed = this.curContext() === tc_expr; - } else { - this.exprAllowed = true; - } - }; - - acornJsx = { tokContexts: tokContexts, tokTypes: tokTypes }; - acornJsxMap.set(acorn, acornJsx); - } - - return acornJsx; -} - -// Transforms JSX element name to string. - -function getQualifiedJSXName(object) { - if (!object) - return object; - - if (object.type === 'JSXIdentifier') - return object.name; - - if (object.type === 'JSXNamespacedName') - return object.namespace.name + ':' + object.name.name; - - if (object.type === 'JSXMemberExpression') - return getQualifiedJSXName(object.object) + '.' + - getQualifiedJSXName(object.property); -} - -module.exports = function(options) { - options = options || {}; - return function(Parser) { - return plugin({ - allowNamespaces: options.allowNamespaces !== false, - allowNamespacedObjects: !!options.allowNamespacedObjects - }, Parser); - }; -}; - -// This is `tokTypes` of the peer dep. -// This can be different instances from the actual `tokTypes` this plugin uses. -Object.defineProperty(module.exports, "tokTypes", { - get: function get_tokTypes() { - return getJsxTokens(require("acorn")).tokTypes; - }, - configurable: true, - enumerable: true -}); - -function plugin(options, Parser) { - const acorn = Parser.acorn || require("acorn"); - const acornJsx = getJsxTokens(acorn); - const tt = acorn.tokTypes; - const tok = acornJsx.tokTypes; - const tokContexts = acorn.tokContexts; - const tc_oTag = acornJsx.tokContexts.tc_oTag; - const tc_cTag = acornJsx.tokContexts.tc_cTag; - const tc_expr = acornJsx.tokContexts.tc_expr; - const isNewLine = acorn.isNewLine; - const isIdentifierStart = acorn.isIdentifierStart; - const isIdentifierChar = acorn.isIdentifierChar; - - return class extends Parser { - // Expose actual `tokTypes` and `tokContexts` to other plugins. - static get acornJsx() { - return acornJsx; - } - - // Reads inline JSX contents token. - jsx_readToken() { - let out = '', chunkStart = this.pos; - for (;;) { - if (this.pos >= this.input.length) - this.raise(this.start, 'Unterminated JSX contents'); - let ch = this.input.charCodeAt(this.pos); - - switch (ch) { - case 60: // '<' - case 123: // '{' - if (this.pos === this.start) { - if (ch === 60 && this.exprAllowed) { - ++this.pos; - return this.finishToken(tok.jsxTagStart); - } - return this.getTokenFromCode(ch); - } - out += this.input.slice(chunkStart, this.pos); - return this.finishToken(tok.jsxText, out); - - case 38: // '&' - out += this.input.slice(chunkStart, this.pos); - out += this.jsx_readEntity(); - chunkStart = this.pos; - break; - - case 62: // '>' - case 125: // '}' - this.raise( - this.pos, - "Unexpected token `" + this.input[this.pos] + "`. Did you mean `" + - (ch === 62 ? ">" : "}") + "` or " + "`{\"" + this.input[this.pos] + "\"}" + "`?" - ); - - default: - if (isNewLine(ch)) { - out += this.input.slice(chunkStart, this.pos); - out += this.jsx_readNewLine(true); - chunkStart = this.pos; - } else { - ++this.pos; - } - } - } - } - - jsx_readNewLine(normalizeCRLF) { - let ch = this.input.charCodeAt(this.pos); - let out; - ++this.pos; - if (ch === 13 && this.input.charCodeAt(this.pos) === 10) { - ++this.pos; - out = normalizeCRLF ? '\n' : '\r\n'; - } else { - out = String.fromCharCode(ch); - } - if (this.options.locations) { - ++this.curLine; - this.lineStart = this.pos; - } - - return out; - } - - jsx_readString(quote) { - let out = '', chunkStart = ++this.pos; - for (;;) { - if (this.pos >= this.input.length) - this.raise(this.start, 'Unterminated string constant'); - let ch = this.input.charCodeAt(this.pos); - if (ch === quote) break; - if (ch === 38) { // '&' - out += this.input.slice(chunkStart, this.pos); - out += this.jsx_readEntity(); - chunkStart = this.pos; - } else if (isNewLine(ch)) { - out += this.input.slice(chunkStart, this.pos); - out += this.jsx_readNewLine(false); - chunkStart = this.pos; - } else { - ++this.pos; - } - } - out += this.input.slice(chunkStart, this.pos++); - return this.finishToken(tt.string, out); - } - - jsx_readEntity() { - let str = '', count = 0, entity; - let ch = this.input[this.pos]; - if (ch !== '&') - this.raise(this.pos, 'Entity must start with an ampersand'); - let startPos = ++this.pos; - while (this.pos < this.input.length && count++ < 10) { - ch = this.input[this.pos++]; - if (ch === ';') { - if (str[0] === '#') { - if (str[1] === 'x') { - str = str.substr(2); - if (hexNumber.test(str)) - entity = String.fromCharCode(parseInt(str, 16)); - } else { - str = str.substr(1); - if (decimalNumber.test(str)) - entity = String.fromCharCode(parseInt(str, 10)); - } - } else { - entity = XHTMLEntities[str]; - } - break; - } - str += ch; - } - if (!entity) { - this.pos = startPos; - return '&'; - } - return entity; - } - - // Read a JSX identifier (valid tag or attribute name). - // - // Optimized version since JSX identifiers can't contain - // escape characters and so can be read as single slice. - // Also assumes that first character was already checked - // by isIdentifierStart in readToken. - - jsx_readWord() { - let ch, start = this.pos; - do { - ch = this.input.charCodeAt(++this.pos); - } while (isIdentifierChar(ch) || ch === 45); // '-' - return this.finishToken(tok.jsxName, this.input.slice(start, this.pos)); - } - - // Parse next token as JSX identifier - - jsx_parseIdentifier() { - let node = this.startNode(); - if (this.type === tok.jsxName) - node.name = this.value; - else if (this.type.keyword) - node.name = this.type.keyword; - else - this.unexpected(); - this.next(); - return this.finishNode(node, 'JSXIdentifier'); - } - - // Parse namespaced identifier. - - jsx_parseNamespacedName() { - let startPos = this.start, startLoc = this.startLoc; - let name = this.jsx_parseIdentifier(); - if (!options.allowNamespaces || !this.eat(tt.colon)) return name; - var node = this.startNodeAt(startPos, startLoc); - node.namespace = name; - node.name = this.jsx_parseIdentifier(); - return this.finishNode(node, 'JSXNamespacedName'); - } - - // Parses element name in any form - namespaced, member - // or single identifier. - - jsx_parseElementName() { - if (this.type === tok.jsxTagEnd) return ''; - let startPos = this.start, startLoc = this.startLoc; - let node = this.jsx_parseNamespacedName(); - if (this.type === tt.dot && node.type === 'JSXNamespacedName' && !options.allowNamespacedObjects) { - this.unexpected(); - } - while (this.eat(tt.dot)) { - let newNode = this.startNodeAt(startPos, startLoc); - newNode.object = node; - newNode.property = this.jsx_parseIdentifier(); - node = this.finishNode(newNode, 'JSXMemberExpression'); - } - return node; - } - - // Parses any type of JSX attribute value. - - jsx_parseAttributeValue() { - switch (this.type) { - case tt.braceL: - let node = this.jsx_parseExpressionContainer(); - if (node.expression.type === 'JSXEmptyExpression') - this.raise(node.start, 'JSX attributes must only be assigned a non-empty expression'); - return node; - - case tok.jsxTagStart: - case tt.string: - return this.parseExprAtom(); - - default: - this.raise(this.start, 'JSX value should be either an expression or a quoted JSX text'); - } - } - - // JSXEmptyExpression is unique type since it doesn't actually parse anything, - // and so it should start at the end of last read token (left brace) and finish - // at the beginning of the next one (right brace). - - jsx_parseEmptyExpression() { - let node = this.startNodeAt(this.lastTokEnd, this.lastTokEndLoc); - return this.finishNodeAt(node, 'JSXEmptyExpression', this.start, this.startLoc); - } - - // Parses JSX expression enclosed into curly brackets. - - jsx_parseExpressionContainer() { - let node = this.startNode(); - this.next(); - node.expression = this.type === tt.braceR - ? this.jsx_parseEmptyExpression() - : this.parseExpression(); - this.expect(tt.braceR); - return this.finishNode(node, 'JSXExpressionContainer'); - } - - // Parses following JSX attribute name-value pair. - - jsx_parseAttribute() { - let node = this.startNode(); - if (this.eat(tt.braceL)) { - this.expect(tt.ellipsis); - node.argument = this.parseMaybeAssign(); - this.expect(tt.braceR); - return this.finishNode(node, 'JSXSpreadAttribute'); - } - node.name = this.jsx_parseNamespacedName(); - node.value = this.eat(tt.eq) ? this.jsx_parseAttributeValue() : null; - return this.finishNode(node, 'JSXAttribute'); - } - - // Parses JSX opening tag starting after '<'. - - jsx_parseOpeningElementAt(startPos, startLoc) { - let node = this.startNodeAt(startPos, startLoc); - node.attributes = []; - let nodeName = this.jsx_parseElementName(); - if (nodeName) node.name = nodeName; - while (this.type !== tt.slash && this.type !== tok.jsxTagEnd) - node.attributes.push(this.jsx_parseAttribute()); - node.selfClosing = this.eat(tt.slash); - this.expect(tok.jsxTagEnd); - return this.finishNode(node, nodeName ? 'JSXOpeningElement' : 'JSXOpeningFragment'); - } - - // Parses JSX closing tag starting after ''); - } - } - let fragmentOrElement = openingElement.name ? 'Element' : 'Fragment'; - - node['opening' + fragmentOrElement] = openingElement; - node['closing' + fragmentOrElement] = closingElement; - node.children = children; - if (this.type === tt.relational && this.value === "<") { - this.raise(this.start, "Adjacent JSX elements must be wrapped in an enclosing tag"); - } - return this.finishNode(node, 'JSX' + fragmentOrElement); - } - - // Parse JSX text - - jsx_parseText() { - let node = this.parseLiteral(this.value); - node.type = "JSXText"; - return node; - } - - // Parses entire JSX element from current position. - - jsx_parseElement() { - let startPos = this.start, startLoc = this.startLoc; - this.next(); - return this.jsx_parseElementAt(startPos, startLoc); - } - - parseExprAtom(refShortHandDefaultPos) { - if (this.type === tok.jsxText) - return this.jsx_parseText(); - else if (this.type === tok.jsxTagStart) - return this.jsx_parseElement(); - else - return super.parseExprAtom(refShortHandDefaultPos); - } - - readToken(code) { - let context = this.curContext(); - - if (context === tc_expr) return this.jsx_readToken(); - - if (context === tc_oTag || context === tc_cTag) { - if (isIdentifierStart(code)) return this.jsx_readWord(); - - if (code == 62) { - ++this.pos; - return this.finishToken(tok.jsxTagEnd); - } - - if ((code === 34 || code === 39) && context == tc_oTag) - return this.jsx_readString(code); - } - - if (code === 60 && this.exprAllowed && this.input.charCodeAt(this.pos + 1) !== 33) { - ++this.pos; - return this.finishToken(tok.jsxTagStart); - } - return super.readToken(code); - } - - updateContext(prevType) { - if (this.type == tt.braceL) { - var curContext = this.curContext(); - if (curContext == tc_oTag) this.context.push(tokContexts.b_expr); - else if (curContext == tc_expr) this.context.push(tokContexts.b_tmpl); - else super.updateContext(prevType); - this.exprAllowed = true; - } else if (this.type === tt.slash && prevType === tok.jsxTagStart) { - this.context.length -= 2; // do not consider JSX expr -> JSX open tag -> ... anymore - this.context.push(tc_cTag); // reconsider as closing tag context - this.exprAllowed = false; - } else { - return super.updateContext(prevType); - } - } - }; -} - -},{"./xhtml":3,"acorn":4}],3:[function(require,module,exports){ +window.flast = require('../node_modules/flast/src/index'); +},{"../node_modules/flast/src/index":2}],2:[function(require,module,exports){ +(function (__dirname){(function (){ module.exports = { - quot: '\u0022', - amp: '&', - apos: '\u0027', - lt: '<', - gt: '>', - nbsp: '\u00A0', - iexcl: '\u00A1', - cent: '\u00A2', - pound: '\u00A3', - curren: '\u00A4', - yen: '\u00A5', - brvbar: '\u00A6', - sect: '\u00A7', - uml: '\u00A8', - copy: '\u00A9', - ordf: '\u00AA', - laquo: '\u00AB', - not: '\u00AC', - shy: '\u00AD', - reg: '\u00AE', - macr: '\u00AF', - deg: '\u00B0', - plusmn: '\u00B1', - sup2: '\u00B2', - sup3: '\u00B3', - acute: '\u00B4', - micro: '\u00B5', - para: '\u00B6', - middot: '\u00B7', - cedil: '\u00B8', - sup1: '\u00B9', - ordm: '\u00BA', - raquo: '\u00BB', - frac14: '\u00BC', - frac12: '\u00BD', - frac34: '\u00BE', - iquest: '\u00BF', - Agrave: '\u00C0', - Aacute: '\u00C1', - Acirc: '\u00C2', - Atilde: '\u00C3', - Auml: '\u00C4', - Aring: '\u00C5', - AElig: '\u00C6', - Ccedil: '\u00C7', - Egrave: '\u00C8', - Eacute: '\u00C9', - Ecirc: '\u00CA', - Euml: '\u00CB', - Igrave: '\u00CC', - Iacute: '\u00CD', - Icirc: '\u00CE', - Iuml: '\u00CF', - ETH: '\u00D0', - Ntilde: '\u00D1', - Ograve: '\u00D2', - Oacute: '\u00D3', - Ocirc: '\u00D4', - Otilde: '\u00D5', - Ouml: '\u00D6', - times: '\u00D7', - Oslash: '\u00D8', - Ugrave: '\u00D9', - Uacute: '\u00DA', - Ucirc: '\u00DB', - Uuml: '\u00DC', - Yacute: '\u00DD', - THORN: '\u00DE', - szlig: '\u00DF', - agrave: '\u00E0', - aacute: '\u00E1', - acirc: '\u00E2', - atilde: '\u00E3', - auml: '\u00E4', - aring: '\u00E5', - aelig: '\u00E6', - ccedil: '\u00E7', - egrave: '\u00E8', - eacute: '\u00E9', - ecirc: '\u00EA', - euml: '\u00EB', - igrave: '\u00EC', - iacute: '\u00ED', - icirc: '\u00EE', - iuml: '\u00EF', - eth: '\u00F0', - ntilde: '\u00F1', - ograve: '\u00F2', - oacute: '\u00F3', - ocirc: '\u00F4', - otilde: '\u00F5', - ouml: '\u00F6', - divide: '\u00F7', - oslash: '\u00F8', - ugrave: '\u00F9', - uacute: '\u00FA', - ucirc: '\u00FB', - uuml: '\u00FC', - yacute: '\u00FD', - thorn: '\u00FE', - yuml: '\u00FF', - OElig: '\u0152', - oelig: '\u0153', - Scaron: '\u0160', - scaron: '\u0161', - Yuml: '\u0178', - fnof: '\u0192', - circ: '\u02C6', - tilde: '\u02DC', - Alpha: '\u0391', - Beta: '\u0392', - Gamma: '\u0393', - Delta: '\u0394', - Epsilon: '\u0395', - Zeta: '\u0396', - Eta: '\u0397', - Theta: '\u0398', - Iota: '\u0399', - Kappa: '\u039A', - Lambda: '\u039B', - Mu: '\u039C', - Nu: '\u039D', - Xi: '\u039E', - Omicron: '\u039F', - Pi: '\u03A0', - Rho: '\u03A1', - Sigma: '\u03A3', - Tau: '\u03A4', - Upsilon: '\u03A5', - Phi: '\u03A6', - Chi: '\u03A7', - Psi: '\u03A8', - Omega: '\u03A9', - alpha: '\u03B1', - beta: '\u03B2', - gamma: '\u03B3', - delta: '\u03B4', - epsilon: '\u03B5', - zeta: '\u03B6', - eta: '\u03B7', - theta: '\u03B8', - iota: '\u03B9', - kappa: '\u03BA', - lambda: '\u03BB', - mu: '\u03BC', - nu: '\u03BD', - xi: '\u03BE', - omicron: '\u03BF', - pi: '\u03C0', - rho: '\u03C1', - sigmaf: '\u03C2', - sigma: '\u03C3', - tau: '\u03C4', - upsilon: '\u03C5', - phi: '\u03C6', - chi: '\u03C7', - psi: '\u03C8', - omega: '\u03C9', - thetasym: '\u03D1', - upsih: '\u03D2', - piv: '\u03D6', - ensp: '\u2002', - emsp: '\u2003', - thinsp: '\u2009', - zwnj: '\u200C', - zwj: '\u200D', - lrm: '\u200E', - rlm: '\u200F', - ndash: '\u2013', - mdash: '\u2014', - lsquo: '\u2018', - rsquo: '\u2019', - sbquo: '\u201A', - ldquo: '\u201C', - rdquo: '\u201D', - bdquo: '\u201E', - dagger: '\u2020', - Dagger: '\u2021', - bull: '\u2022', - hellip: '\u2026', - permil: '\u2030', - prime: '\u2032', - Prime: '\u2033', - lsaquo: '\u2039', - rsaquo: '\u203A', - oline: '\u203E', - frasl: '\u2044', - euro: '\u20AC', - image: '\u2111', - weierp: '\u2118', - real: '\u211C', - trade: '\u2122', - alefsym: '\u2135', - larr: '\u2190', - uarr: '\u2191', - rarr: '\u2192', - darr: '\u2193', - harr: '\u2194', - crarr: '\u21B5', - lArr: '\u21D0', - uArr: '\u21D1', - rArr: '\u21D2', - dArr: '\u21D3', - hArr: '\u21D4', - forall: '\u2200', - part: '\u2202', - exist: '\u2203', - empty: '\u2205', - nabla: '\u2207', - isin: '\u2208', - notin: '\u2209', - ni: '\u220B', - prod: '\u220F', - sum: '\u2211', - minus: '\u2212', - lowast: '\u2217', - radic: '\u221A', - prop: '\u221D', - infin: '\u221E', - ang: '\u2220', - and: '\u2227', - or: '\u2228', - cap: '\u2229', - cup: '\u222A', - 'int': '\u222B', - there4: '\u2234', - sim: '\u223C', - cong: '\u2245', - asymp: '\u2248', - ne: '\u2260', - equiv: '\u2261', - le: '\u2264', - ge: '\u2265', - sub: '\u2282', - sup: '\u2283', - nsub: '\u2284', - sube: '\u2286', - supe: '\u2287', - oplus: '\u2295', - otimes: '\u2297', - perp: '\u22A5', - sdot: '\u22C5', - lceil: '\u2308', - rceil: '\u2309', - lfloor: '\u230A', - rfloor: '\u230B', - lang: '\u2329', - rang: '\u232A', - loz: '\u25CA', - spades: '\u2660', - clubs: '\u2663', - hearts: '\u2665', - diams: '\u2666' -}; - -},{}],4:[function(require,module,exports){ -(function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : - typeof define === 'function' && define.amd ? define(['exports'], factory) : - (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.acorn = {})); -})(this, (function (exports) { 'use strict'; - - // This file was generated. Do not modify manually! - var astralIdentifierCodes = [509, 0, 227, 0, 150, 4, 294, 9, 1368, 2, 2, 1, 6, 3, 41, 2, 5, 0, 166, 1, 574, 3, 9, 9, 370, 1, 81, 2, 71, 10, 50, 3, 123, 2, 54, 14, 32, 10, 3, 1, 11, 3, 46, 10, 8, 0, 46, 9, 7, 2, 37, 13, 2, 9, 6, 1, 45, 0, 13, 2, 49, 13, 9, 3, 2, 11, 83, 11, 7, 0, 3, 0, 158, 11, 6, 9, 7, 3, 56, 1, 2, 6, 3, 1, 3, 2, 10, 0, 11, 1, 3, 6, 4, 4, 193, 17, 10, 9, 5, 0, 82, 19, 13, 9, 214, 6, 3, 8, 28, 1, 83, 16, 16, 9, 82, 12, 9, 9, 84, 14, 5, 9, 243, 14, 166, 9, 71, 5, 2, 1, 3, 3, 2, 0, 2, 1, 13, 9, 120, 6, 3, 6, 4, 0, 29, 9, 41, 6, 2, 3, 9, 0, 10, 10, 47, 15, 406, 7, 2, 7, 17, 9, 57, 21, 2, 13, 123, 5, 4, 0, 2, 1, 2, 6, 2, 0, 9, 9, 49, 4, 2, 1, 2, 4, 9, 9, 330, 3, 10, 1, 2, 0, 49, 6, 4, 4, 14, 9, 5351, 0, 7, 14, 13835, 9, 87, 9, 39, 4, 60, 6, 26, 9, 1014, 0, 2, 54, 8, 3, 82, 0, 12, 1, 19628, 1, 4706, 45, 3, 22, 543, 4, 4, 5, 9, 7, 3, 6, 31, 3, 149, 2, 1418, 49, 513, 54, 5, 49, 9, 0, 15, 0, 23, 4, 2, 14, 1361, 6, 2, 16, 3, 6, 2, 1, 2, 4, 101, 0, 161, 6, 10, 9, 357, 0, 62, 13, 499, 13, 983, 6, 110, 6, 6, 9, 4759, 9, 787719, 239]; - - // This file was generated. Do not modify manually! - var astralIdentifierStartCodes = [0, 11, 2, 25, 2, 18, 2, 1, 2, 14, 3, 13, 35, 122, 70, 52, 268, 28, 4, 48, 48, 31, 14, 29, 6, 37, 11, 29, 3, 35, 5, 7, 2, 4, 43, 157, 19, 35, 5, 35, 5, 39, 9, 51, 13, 10, 2, 14, 2, 6, 2, 1, 2, 10, 2, 14, 2, 6, 2, 1, 68, 310, 10, 21, 11, 7, 25, 5, 2, 41, 2, 8, 70, 5, 3, 0, 2, 43, 2, 1, 4, 0, 3, 22, 11, 22, 10, 30, 66, 18, 2, 1, 11, 21, 11, 25, 71, 55, 7, 1, 65, 0, 16, 3, 2, 2, 2, 28, 43, 28, 4, 28, 36, 7, 2, 27, 28, 53, 11, 21, 11, 18, 14, 17, 111, 72, 56, 50, 14, 50, 14, 35, 349, 41, 7, 1, 79, 28, 11, 0, 9, 21, 43, 17, 47, 20, 28, 22, 13, 52, 58, 1, 3, 0, 14, 44, 33, 24, 27, 35, 30, 0, 3, 0, 9, 34, 4, 0, 13, 47, 15, 3, 22, 0, 2, 0, 36, 17, 2, 24, 20, 1, 64, 6, 2, 0, 2, 3, 2, 14, 2, 9, 8, 46, 39, 7, 3, 1, 3, 21, 2, 6, 2, 1, 2, 4, 4, 0, 19, 0, 13, 4, 159, 52, 19, 3, 21, 2, 31, 47, 21, 1, 2, 0, 185, 46, 42, 3, 37, 47, 21, 0, 60, 42, 14, 0, 72, 26, 38, 6, 186, 43, 117, 63, 32, 7, 3, 0, 3, 7, 2, 1, 2, 23, 16, 0, 2, 0, 95, 7, 3, 38, 17, 0, 2, 0, 29, 0, 11, 39, 8, 0, 22, 0, 12, 45, 20, 0, 19, 72, 264, 8, 2, 36, 18, 0, 50, 29, 113, 6, 2, 1, 2, 37, 22, 0, 26, 5, 2, 1, 2, 31, 15, 0, 328, 18, 16, 0, 2, 12, 2, 33, 125, 0, 80, 921, 103, 110, 18, 195, 2637, 96, 16, 1071, 18, 5, 4026, 582, 8634, 568, 8, 30, 18, 78, 18, 29, 19, 47, 17, 3, 32, 20, 6, 18, 689, 63, 129, 74, 6, 0, 67, 12, 65, 1, 2, 0, 29, 6135, 9, 1237, 43, 8, 8936, 3, 2, 6, 2, 1, 2, 290, 16, 0, 30, 2, 3, 0, 15, 3, 9, 395, 2309, 106, 6, 12, 4, 8, 8, 9, 5991, 84, 2, 70, 2, 1, 3, 0, 3, 1, 3, 3, 2, 11, 2, 0, 2, 6, 2, 64, 2, 3, 3, 7, 2, 6, 2, 27, 2, 3, 2, 4, 2, 0, 4, 6, 2, 339, 3, 24, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 7, 1845, 30, 7, 5, 262, 61, 147, 44, 11, 6, 17, 0, 322, 29, 19, 43, 485, 27, 757, 6, 2, 3, 2, 1, 2, 14, 2, 196, 60, 67, 8, 0, 1205, 3, 2, 26, 2, 1, 2, 0, 3, 0, 2, 9, 2, 3, 2, 0, 2, 0, 7, 0, 5, 0, 2, 0, 2, 0, 2, 2, 2, 1, 2, 0, 3, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 1, 2, 0, 3, 3, 2, 6, 2, 3, 2, 3, 2, 0, 2, 9, 2, 16, 6, 2, 2, 4, 2, 16, 4421, 42719, 33, 4153, 7, 221, 3, 5761, 15, 7472, 16, 621, 2467, 541, 1507, 4938, 6, 4191]; - - // This file was generated. Do not modify manually! - var nonASCIIidentifierChars = "\u200c\u200d\xb7\u0300-\u036f\u0387\u0483-\u0487\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u0669\u0670\u06d6-\u06dc\u06df-\u06e4\u06e7\u06e8\u06ea-\u06ed\u06f0-\u06f9\u0711\u0730-\u074a\u07a6-\u07b0\u07c0-\u07c9\u07eb-\u07f3\u07fd\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0859-\u085b\u0898-\u089f\u08ca-\u08e1\u08e3-\u0903\u093a-\u093c\u093e-\u094f\u0951-\u0957\u0962\u0963\u0966-\u096f\u0981-\u0983\u09bc\u09be-\u09c4\u09c7\u09c8\u09cb-\u09cd\u09d7\u09e2\u09e3\u09e6-\u09ef\u09fe\u0a01-\u0a03\u0a3c\u0a3e-\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a66-\u0a71\u0a75\u0a81-\u0a83\u0abc\u0abe-\u0ac5\u0ac7-\u0ac9\u0acb-\u0acd\u0ae2\u0ae3\u0ae6-\u0aef\u0afa-\u0aff\u0b01-\u0b03\u0b3c\u0b3e-\u0b44\u0b47\u0b48\u0b4b-\u0b4d\u0b55-\u0b57\u0b62\u0b63\u0b66-\u0b6f\u0b82\u0bbe-\u0bc2\u0bc6-\u0bc8\u0bca-\u0bcd\u0bd7\u0be6-\u0bef\u0c00-\u0c04\u0c3c\u0c3e-\u0c44\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0c66-\u0c6f\u0c81-\u0c83\u0cbc\u0cbe-\u0cc4\u0cc6-\u0cc8\u0cca-\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0ce6-\u0cef\u0cf3\u0d00-\u0d03\u0d3b\u0d3c\u0d3e-\u0d44\u0d46-\u0d48\u0d4a-\u0d4d\u0d57\u0d62\u0d63\u0d66-\u0d6f\u0d81-\u0d83\u0dca\u0dcf-\u0dd4\u0dd6\u0dd8-\u0ddf\u0de6-\u0def\u0df2\u0df3\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0e50-\u0e59\u0eb1\u0eb4-\u0ebc\u0ec8-\u0ece\u0ed0-\u0ed9\u0f18\u0f19\u0f20-\u0f29\u0f35\u0f37\u0f39\u0f3e\u0f3f\u0f71-\u0f84\u0f86\u0f87\u0f8d-\u0f97\u0f99-\u0fbc\u0fc6\u102b-\u103e\u1040-\u1049\u1056-\u1059\u105e-\u1060\u1062-\u1064\u1067-\u106d\u1071-\u1074\u1082-\u108d\u108f-\u109d\u135d-\u135f\u1369-\u1371\u1712-\u1715\u1732-\u1734\u1752\u1753\u1772\u1773\u17b4-\u17d3\u17dd\u17e0-\u17e9\u180b-\u180d\u180f-\u1819\u18a9\u1920-\u192b\u1930-\u193b\u1946-\u194f\u19d0-\u19da\u1a17-\u1a1b\u1a55-\u1a5e\u1a60-\u1a7c\u1a7f-\u1a89\u1a90-\u1a99\u1ab0-\u1abd\u1abf-\u1ace\u1b00-\u1b04\u1b34-\u1b44\u1b50-\u1b59\u1b6b-\u1b73\u1b80-\u1b82\u1ba1-\u1bad\u1bb0-\u1bb9\u1be6-\u1bf3\u1c24-\u1c37\u1c40-\u1c49\u1c50-\u1c59\u1cd0-\u1cd2\u1cd4-\u1ce8\u1ced\u1cf4\u1cf7-\u1cf9\u1dc0-\u1dff\u200c\u200d\u203f\u2040\u2054\u20d0-\u20dc\u20e1\u20e5-\u20f0\u2cef-\u2cf1\u2d7f\u2de0-\u2dff\u302a-\u302f\u3099\u309a\u30fb\ua620-\ua629\ua66f\ua674-\ua67d\ua69e\ua69f\ua6f0\ua6f1\ua802\ua806\ua80b\ua823-\ua827\ua82c\ua880\ua881\ua8b4-\ua8c5\ua8d0-\ua8d9\ua8e0-\ua8f1\ua8ff-\ua909\ua926-\ua92d\ua947-\ua953\ua980-\ua983\ua9b3-\ua9c0\ua9d0-\ua9d9\ua9e5\ua9f0-\ua9f9\uaa29-\uaa36\uaa43\uaa4c\uaa4d\uaa50-\uaa59\uaa7b-\uaa7d\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uaaeb-\uaaef\uaaf5\uaaf6\uabe3-\uabea\uabec\uabed\uabf0-\uabf9\ufb1e\ufe00-\ufe0f\ufe20-\ufe2f\ufe33\ufe34\ufe4d-\ufe4f\uff10-\uff19\uff3f\uff65"; - - // This file was generated. Do not modify manually! - var nonASCIIidentifierStartChars = "\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0370-\u0374\u0376\u0377\u037a-\u037d\u037f\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u048a-\u052f\u0531-\u0556\u0559\u0560-\u0588\u05d0-\u05ea\u05ef-\u05f2\u0620-\u064a\u066e\u066f\u0671-\u06d3\u06d5\u06e5\u06e6\u06ee\u06ef\u06fa-\u06fc\u06ff\u0710\u0712-\u072f\u074d-\u07a5\u07b1\u07ca-\u07ea\u07f4\u07f5\u07fa\u0800-\u0815\u081a\u0824\u0828\u0840-\u0858\u0860-\u086a\u0870-\u0887\u0889-\u088e\u08a0-\u08c9\u0904-\u0939\u093d\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098c\u098f\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09bd\u09ce\u09dc\u09dd\u09df-\u09e1\u09f0\u09f1\u09fc\u0a05-\u0a0a\u0a0f\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32\u0a33\u0a35\u0a36\u0a38\u0a39\u0a59-\u0a5c\u0a5e\u0a72-\u0a74\u0a85-\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2\u0ab3\u0ab5-\u0ab9\u0abd\u0ad0\u0ae0\u0ae1\u0af9\u0b05-\u0b0c\u0b0f\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32\u0b33\u0b35-\u0b39\u0b3d\u0b5c\u0b5d\u0b5f-\u0b61\u0b71\u0b83\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99\u0b9a\u0b9c\u0b9e\u0b9f\u0ba3\u0ba4\u0ba8-\u0baa\u0bae-\u0bb9\u0bd0\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c39\u0c3d\u0c58-\u0c5a\u0c5d\u0c60\u0c61\u0c80\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbd\u0cdd\u0cde\u0ce0\u0ce1\u0cf1\u0cf2\u0d04-\u0d0c\u0d0e-\u0d10\u0d12-\u0d3a\u0d3d\u0d4e\u0d54-\u0d56\u0d5f-\u0d61\u0d7a-\u0d7f\u0d85-\u0d96\u0d9a-\u0db1\u0db3-\u0dbb\u0dbd\u0dc0-\u0dc6\u0e01-\u0e30\u0e32\u0e33\u0e40-\u0e46\u0e81\u0e82\u0e84\u0e86-\u0e8a\u0e8c-\u0ea3\u0ea5\u0ea7-\u0eb0\u0eb2\u0eb3\u0ebd\u0ec0-\u0ec4\u0ec6\u0edc-\u0edf\u0f00\u0f40-\u0f47\u0f49-\u0f6c\u0f88-\u0f8c\u1000-\u102a\u103f\u1050-\u1055\u105a-\u105d\u1061\u1065\u1066\u106e-\u1070\u1075-\u1081\u108e\u10a0-\u10c5\u10c7\u10cd\u10d0-\u10fa\u10fc-\u1248\u124a-\u124d\u1250-\u1256\u1258\u125a-\u125d\u1260-\u1288\u128a-\u128d\u1290-\u12b0\u12b2-\u12b5\u12b8-\u12be\u12c0\u12c2-\u12c5\u12c8-\u12d6\u12d8-\u1310\u1312-\u1315\u1318-\u135a\u1380-\u138f\u13a0-\u13f5\u13f8-\u13fd\u1401-\u166c\u166f-\u167f\u1681-\u169a\u16a0-\u16ea\u16ee-\u16f8\u1700-\u1711\u171f-\u1731\u1740-\u1751\u1760-\u176c\u176e-\u1770\u1780-\u17b3\u17d7\u17dc\u1820-\u1878\u1880-\u18a8\u18aa\u18b0-\u18f5\u1900-\u191e\u1950-\u196d\u1970-\u1974\u1980-\u19ab\u19b0-\u19c9\u1a00-\u1a16\u1a20-\u1a54\u1aa7\u1b05-\u1b33\u1b45-\u1b4c\u1b83-\u1ba0\u1bae\u1baf\u1bba-\u1be5\u1c00-\u1c23\u1c4d-\u1c4f\u1c5a-\u1c7d\u1c80-\u1c88\u1c90-\u1cba\u1cbd-\u1cbf\u1ce9-\u1cec\u1cee-\u1cf3\u1cf5\u1cf6\u1cfa\u1d00-\u1dbf\u1e00-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u2071\u207f\u2090-\u209c\u2102\u2107\u210a-\u2113\u2115\u2118-\u211d\u2124\u2126\u2128\u212a-\u2139\u213c-\u213f\u2145-\u2149\u214e\u2160-\u2188\u2c00-\u2ce4\u2ceb-\u2cee\u2cf2\u2cf3\u2d00-\u2d25\u2d27\u2d2d\u2d30-\u2d67\u2d6f\u2d80-\u2d96\u2da0-\u2da6\u2da8-\u2dae\u2db0-\u2db6\u2db8-\u2dbe\u2dc0-\u2dc6\u2dc8-\u2dce\u2dd0-\u2dd6\u2dd8-\u2dde\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303c\u3041-\u3096\u309b-\u309f\u30a1-\u30fa\u30fc-\u30ff\u3105-\u312f\u3131-\u318e\u31a0-\u31bf\u31f0-\u31ff\u3400-\u4dbf\u4e00-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua61f\ua62a\ua62b\ua640-\ua66e\ua67f-\ua69d\ua6a0-\ua6ef\ua717-\ua71f\ua722-\ua788\ua78b-\ua7ca\ua7d0\ua7d1\ua7d3\ua7d5-\ua7d9\ua7f2-\ua801\ua803-\ua805\ua807-\ua80a\ua80c-\ua822\ua840-\ua873\ua882-\ua8b3\ua8f2-\ua8f7\ua8fb\ua8fd\ua8fe\ua90a-\ua925\ua930-\ua946\ua960-\ua97c\ua984-\ua9b2\ua9cf\ua9e0-\ua9e4\ua9e6-\ua9ef\ua9fa-\ua9fe\uaa00-\uaa28\uaa40-\uaa42\uaa44-\uaa4b\uaa60-\uaa76\uaa7a\uaa7e-\uaaaf\uaab1\uaab5\uaab6\uaab9-\uaabd\uaac0\uaac2\uaadb-\uaadd\uaae0-\uaaea\uaaf2-\uaaf4\uab01-\uab06\uab09-\uab0e\uab11-\uab16\uab20-\uab26\uab28-\uab2e\uab30-\uab5a\uab5c-\uab69\uab70-\uabe2\uac00-\ud7a3\ud7b0-\ud7c6\ud7cb-\ud7fb\uf900-\ufa6d\ufa70-\ufad9\ufb00-\ufb06\ufb13-\ufb17\ufb1d\ufb1f-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40\ufb41\ufb43\ufb44\ufb46-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe70-\ufe74\ufe76-\ufefc\uff21-\uff3a\uff41-\uff5a\uff66-\uffbe\uffc2-\uffc7\uffca-\uffcf\uffd2-\uffd7\uffda-\uffdc"; - - // These are a run-length and offset encoded representation of the - // >0xffff code points that are a valid part of identifiers. The - // offset starts at 0x10000, and each pair of numbers represents an - // offset to the next range, and then a size of the range. - - // Reserved word lists for various dialects of the language - - var reservedWords = { - 3: "abstract boolean byte char class double enum export extends final float goto implements import int interface long native package private protected public short static super synchronized throws transient volatile", - 5: "class enum extends super const export import", - 6: "enum", - strict: "implements interface let package private protected public static yield", - strictBind: "eval arguments" - }; - - // And the keywords - - var ecma5AndLessKeywords = "break case catch continue debugger default do else finally for function if return switch throw try var while with null true false instanceof typeof void delete new in this"; - - var keywords$1 = { - 5: ecma5AndLessKeywords, - "5module": ecma5AndLessKeywords + " export import", - 6: ecma5AndLessKeywords + " const class extends export import super" - }; - - var keywordRelationalOperator = /^in(stanceof)?$/; - - // ## Character categories - - var nonASCIIidentifierStart = new RegExp("[" + nonASCIIidentifierStartChars + "]"); - var nonASCIIidentifier = new RegExp("[" + nonASCIIidentifierStartChars + nonASCIIidentifierChars + "]"); - - // This has a complexity linear to the value of the code. The - // assumption is that looking up astral identifier characters is - // rare. - function isInAstralSet(code, set) { - var pos = 0x10000; - for (var i = 0; i < set.length; i += 2) { - pos += set[i]; - if (pos > code) { return false } - pos += set[i + 1]; - if (pos >= code) { return true } - } - return false - } - - // Test whether a given character code starts an identifier. - - function isIdentifierStart(code, astral) { - if (code < 65) { return code === 36 } - if (code < 91) { return true } - if (code < 97) { return code === 95 } - if (code < 123) { return true } - if (code <= 0xffff) { return code >= 0xaa && nonASCIIidentifierStart.test(String.fromCharCode(code)) } - if (astral === false) { return false } - return isInAstralSet(code, astralIdentifierStartCodes) - } - - // Test whether a given character is part of an identifier. - - function isIdentifierChar(code, astral) { - if (code < 48) { return code === 36 } - if (code < 58) { return true } - if (code < 65) { return false } - if (code < 91) { return true } - if (code < 97) { return code === 95 } - if (code < 123) { return true } - if (code <= 0xffff) { return code >= 0xaa && nonASCIIidentifier.test(String.fromCharCode(code)) } - if (astral === false) { return false } - return isInAstralSet(code, astralIdentifierStartCodes) || isInAstralSet(code, astralIdentifierCodes) - } - - // ## Token types - - // The assignment of fine-grained, information-carrying type objects - // allows the tokenizer to store the information it has about a - // token in a way that is very cheap for the parser to look up. - - // All token type variables start with an underscore, to make them - // easy to recognize. - - // The `beforeExpr` property is used to disambiguate between regular - // expressions and divisions. It is set on all token types that can - // be followed by an expression (thus, a slash after them would be a - // regular expression). - // - // The `startsExpr` property is used to check if the token ends a - // `yield` expression. It is set on all token types that either can - // directly start an expression (like a quotation mark) or can - // continue an expression (like the body of a string). - // - // `isLoop` marks a keyword as starting a loop, which is important - // to know when parsing a label, in order to allow or disallow - // continue jumps to that label. - - var TokenType = function TokenType(label, conf) { - if ( conf === void 0 ) conf = {}; - - this.label = label; - this.keyword = conf.keyword; - this.beforeExpr = !!conf.beforeExpr; - this.startsExpr = !!conf.startsExpr; - this.isLoop = !!conf.isLoop; - this.isAssign = !!conf.isAssign; - this.prefix = !!conf.prefix; - this.postfix = !!conf.postfix; - this.binop = conf.binop || null; - this.updateContext = null; - }; - - function binop(name, prec) { - return new TokenType(name, {beforeExpr: true, binop: prec}) - } - var beforeExpr = {beforeExpr: true}, startsExpr = {startsExpr: true}; - - // Map keyword names to token types. - - var keywords = {}; - - // Succinct definitions of keyword token types - function kw(name, options) { - if ( options === void 0 ) options = {}; - - options.keyword = name; - return keywords[name] = new TokenType(name, options) - } - - var types$1 = { - num: new TokenType("num", startsExpr), - regexp: new TokenType("regexp", startsExpr), - string: new TokenType("string", startsExpr), - name: new TokenType("name", startsExpr), - privateId: new TokenType("privateId", startsExpr), - eof: new TokenType("eof"), - - // Punctuation token types. - bracketL: new TokenType("[", {beforeExpr: true, startsExpr: true}), - bracketR: new TokenType("]"), - braceL: new TokenType("{", {beforeExpr: true, startsExpr: true}), - braceR: new TokenType("}"), - parenL: new TokenType("(", {beforeExpr: true, startsExpr: true}), - parenR: new TokenType(")"), - comma: new TokenType(",", beforeExpr), - semi: new TokenType(";", beforeExpr), - colon: new TokenType(":", beforeExpr), - dot: new TokenType("."), - question: new TokenType("?", beforeExpr), - questionDot: new TokenType("?."), - arrow: new TokenType("=>", beforeExpr), - template: new TokenType("template"), - invalidTemplate: new TokenType("invalidTemplate"), - ellipsis: new TokenType("...", beforeExpr), - backQuote: new TokenType("`", startsExpr), - dollarBraceL: new TokenType("${", {beforeExpr: true, startsExpr: true}), - - // Operators. These carry several kinds of properties to help the - // parser use them properly (the presence of these properties is - // what categorizes them as operators). - // - // `binop`, when present, specifies that this operator is a binary - // operator, and will refer to its precedence. - // - // `prefix` and `postfix` mark the operator as a prefix or postfix - // unary operator. - // - // `isAssign` marks all of `=`, `+=`, `-=` etcetera, which act as - // binary operators with a very low precedence, that should result - // in AssignmentExpression nodes. - - eq: new TokenType("=", {beforeExpr: true, isAssign: true}), - assign: new TokenType("_=", {beforeExpr: true, isAssign: true}), - incDec: new TokenType("++/--", {prefix: true, postfix: true, startsExpr: true}), - prefix: new TokenType("!/~", {beforeExpr: true, prefix: true, startsExpr: true}), - logicalOR: binop("||", 1), - logicalAND: binop("&&", 2), - bitwiseOR: binop("|", 3), - bitwiseXOR: binop("^", 4), - bitwiseAND: binop("&", 5), - equality: binop("==/!=/===/!==", 6), - relational: binop("/<=/>=", 7), - bitShift: binop("<>/>>>", 8), - plusMin: new TokenType("+/-", {beforeExpr: true, binop: 9, prefix: true, startsExpr: true}), - modulo: binop("%", 10), - star: binop("*", 10), - slash: binop("/", 10), - starstar: new TokenType("**", {beforeExpr: true}), - coalesce: binop("??", 1), - - // Keyword token types. - _break: kw("break"), - _case: kw("case", beforeExpr), - _catch: kw("catch"), - _continue: kw("continue"), - _debugger: kw("debugger"), - _default: kw("default", beforeExpr), - _do: kw("do", {isLoop: true, beforeExpr: true}), - _else: kw("else", beforeExpr), - _finally: kw("finally"), - _for: kw("for", {isLoop: true}), - _function: kw("function", startsExpr), - _if: kw("if"), - _return: kw("return", beforeExpr), - _switch: kw("switch"), - _throw: kw("throw", beforeExpr), - _try: kw("try"), - _var: kw("var"), - _const: kw("const"), - _while: kw("while", {isLoop: true}), - _with: kw("with"), - _new: kw("new", {beforeExpr: true, startsExpr: true}), - _this: kw("this", startsExpr), - _super: kw("super", startsExpr), - _class: kw("class", startsExpr), - _extends: kw("extends", beforeExpr), - _export: kw("export"), - _import: kw("import", startsExpr), - _null: kw("null", startsExpr), - _true: kw("true", startsExpr), - _false: kw("false", startsExpr), - _in: kw("in", {beforeExpr: true, binop: 7}), - _instanceof: kw("instanceof", {beforeExpr: true, binop: 7}), - _typeof: kw("typeof", {beforeExpr: true, prefix: true, startsExpr: true}), - _void: kw("void", {beforeExpr: true, prefix: true, startsExpr: true}), - _delete: kw("delete", {beforeExpr: true, prefix: true, startsExpr: true}) - }; - - // Matches a whole line break (where CRLF is considered a single - // line break). Used to count lines. - - var lineBreak = /\r\n?|\n|\u2028|\u2029/; - var lineBreakG = new RegExp(lineBreak.source, "g"); - - function isNewLine(code) { - return code === 10 || code === 13 || code === 0x2028 || code === 0x2029 - } - - function nextLineBreak(code, from, end) { - if ( end === void 0 ) end = code.length; - - for (var i = from; i < end; i++) { - var next = code.charCodeAt(i); - if (isNewLine(next)) - { return i < end - 1 && next === 13 && code.charCodeAt(i + 1) === 10 ? i + 2 : i + 1 } - } - return -1 - } - - var nonASCIIwhitespace = /[\u1680\u2000-\u200a\u202f\u205f\u3000\ufeff]/; - - var skipWhiteSpace = /(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g; - - var ref = Object.prototype; - var hasOwnProperty = ref.hasOwnProperty; - var toString = ref.toString; - - var hasOwn = Object.hasOwn || (function (obj, propName) { return ( - hasOwnProperty.call(obj, propName) - ); }); - - var isArray = Array.isArray || (function (obj) { return ( - toString.call(obj) === "[object Array]" - ); }); - - var regexpCache = Object.create(null); - - function wordsRegexp(words) { - return regexpCache[words] || (regexpCache[words] = new RegExp("^(?:" + words.replace(/ /g, "|") + ")$")) - } - - function codePointToString(code) { - // UTF-16 Decoding - if (code <= 0xFFFF) { return String.fromCharCode(code) } - code -= 0x10000; - return String.fromCharCode((code >> 10) + 0xD800, (code & 1023) + 0xDC00) - } - - var loneSurrogate = /(?:[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])/; - - // These are used when `options.locations` is on, for the - // `startLoc` and `endLoc` properties. - - var Position = function Position(line, col) { - this.line = line; - this.column = col; - }; - - Position.prototype.offset = function offset (n) { - return new Position(this.line, this.column + n) - }; - - var SourceLocation = function SourceLocation(p, start, end) { - this.start = start; - this.end = end; - if (p.sourceFile !== null) { this.source = p.sourceFile; } - }; - - // The `getLineInfo` function is mostly useful when the - // `locations` option is off (for performance reasons) and you - // want to find the line/column position for a given character - // offset. `input` should be the code string that the offset refers - // into. - - function getLineInfo(input, offset) { - for (var line = 1, cur = 0;;) { - var nextBreak = nextLineBreak(input, cur, offset); - if (nextBreak < 0) { return new Position(line, offset - cur) } - ++line; - cur = nextBreak; - } - } - - // A second argument must be given to configure the parser process. - // These options are recognized (only `ecmaVersion` is required): - - var defaultOptions = { - // `ecmaVersion` indicates the ECMAScript version to parse. Must be - // either 3, 5, 6 (or 2015), 7 (2016), 8 (2017), 9 (2018), 10 - // (2019), 11 (2020), 12 (2021), 13 (2022), 14 (2023), or `"latest"` - // (the latest version the library supports). This influences - // support for strict mode, the set of reserved words, and support - // for new syntax features. - ecmaVersion: null, - // `sourceType` indicates the mode the code should be parsed in. - // Can be either `"script"` or `"module"`. This influences global - // strict mode and parsing of `import` and `export` declarations. - sourceType: "script", - // `onInsertedSemicolon` can be a callback that will be called when - // a semicolon is automatically inserted. It will be passed the - // position of the inserted semicolon as an offset, and if - // `locations` is enabled, it is given the location as a `{line, - // column}` object as second argument. - onInsertedSemicolon: null, - // `onTrailingComma` is similar to `onInsertedSemicolon`, but for - // trailing commas. - onTrailingComma: null, - // By default, reserved words are only enforced if ecmaVersion >= 5. - // Set `allowReserved` to a boolean value to explicitly turn this on - // an off. When this option has the value "never", reserved words - // and keywords can also not be used as property names. - allowReserved: null, - // When enabled, a return at the top level is not considered an - // error. - allowReturnOutsideFunction: false, - // When enabled, import/export statements are not constrained to - // appearing at the top of the program, and an import.meta expression - // in a script isn't considered an error. - allowImportExportEverywhere: false, - // By default, await identifiers are allowed to appear at the top-level scope only if ecmaVersion >= 2022. - // When enabled, await identifiers are allowed to appear at the top-level scope, - // but they are still not allowed in non-async functions. - allowAwaitOutsideFunction: null, - // When enabled, super identifiers are not constrained to - // appearing in methods and do not raise an error when they appear elsewhere. - allowSuperOutsideMethod: null, - // When enabled, hashbang directive in the beginning of file is - // allowed and treated as a line comment. Enabled by default when - // `ecmaVersion` >= 2023. - allowHashBang: false, - // By default, the parser will verify that private properties are - // only used in places where they are valid and have been declared. - // Set this to false to turn such checks off. - checkPrivateFields: true, - // When `locations` is on, `loc` properties holding objects with - // `start` and `end` properties in `{line, column}` form (with - // line being 1-based and column 0-based) will be attached to the - // nodes. - locations: false, - // A function can be passed as `onToken` option, which will - // cause Acorn to call that function with object in the same - // format as tokens returned from `tokenizer().getToken()`. Note - // that you are not allowed to call the parser from the - // callback—that will corrupt its internal state. - onToken: null, - // A function can be passed as `onComment` option, which will - // cause Acorn to call that function with `(block, text, start, - // end)` parameters whenever a comment is skipped. `block` is a - // boolean indicating whether this is a block (`/* */`) comment, - // `text` is the content of the comment, and `start` and `end` are - // character offsets that denote the start and end of the comment. - // When the `locations` option is on, two more parameters are - // passed, the full `{line, column}` locations of the start and - // end of the comments. Note that you are not allowed to call the - // parser from the callback—that will corrupt its internal state. - // When this option has an array as value, objects representing the - // comments are pushed to it. - onComment: null, - // Nodes have their start and end characters offsets recorded in - // `start` and `end` properties (directly on the node, rather than - // the `loc` object, which holds line/column data. To also add a - // [semi-standardized][range] `range` property holding a `[start, - // end]` array with the same numbers, set the `ranges` option to - // `true`. - // - // [range]: https://bugzilla.mozilla.org/show_bug.cgi?id=745678 - ranges: false, - // It is possible to parse multiple files into a single AST by - // passing the tree produced by parsing the first file as - // `program` option in subsequent parses. This will add the - // toplevel forms of the parsed file to the `Program` (top) node - // of an existing parse tree. - program: null, - // When `locations` is on, you can pass this to record the source - // file in every node's `loc` object. - sourceFile: null, - // This value, if given, is stored in every node, whether - // `locations` is on or off. - directSourceFile: null, - // When enabled, parenthesized expressions are represented by - // (non-standard) ParenthesizedExpression nodes - preserveParens: false - }; - - // Interpret and default an options object - - var warnedAboutEcmaVersion = false; - - function getOptions(opts) { - var options = {}; - - for (var opt in defaultOptions) - { options[opt] = opts && hasOwn(opts, opt) ? opts[opt] : defaultOptions[opt]; } - - if (options.ecmaVersion === "latest") { - options.ecmaVersion = 1e8; - } else if (options.ecmaVersion == null) { - if (!warnedAboutEcmaVersion && typeof console === "object" && console.warn) { - warnedAboutEcmaVersion = true; - console.warn("Since Acorn 8.0.0, options.ecmaVersion is required.\nDefaulting to 2020, but this will stop working in the future."); - } - options.ecmaVersion = 11; - } else if (options.ecmaVersion >= 2015) { - options.ecmaVersion -= 2009; - } - - if (options.allowReserved == null) - { options.allowReserved = options.ecmaVersion < 5; } - - if (!opts || opts.allowHashBang == null) - { options.allowHashBang = options.ecmaVersion >= 14; } - - if (isArray(options.onToken)) { - var tokens = options.onToken; - options.onToken = function (token) { return tokens.push(token); }; - } - if (isArray(options.onComment)) - { options.onComment = pushComment(options, options.onComment); } - - return options - } - - function pushComment(options, array) { - return function(block, text, start, end, startLoc, endLoc) { - var comment = { - type: block ? "Block" : "Line", - value: text, - start: start, - end: end - }; - if (options.locations) - { comment.loc = new SourceLocation(this, startLoc, endLoc); } - if (options.ranges) - { comment.range = [start, end]; } - array.push(comment); - } - } - - // Each scope gets a bitset that may contain these flags - var - SCOPE_TOP = 1, - SCOPE_FUNCTION = 2, - SCOPE_ASYNC = 4, - SCOPE_GENERATOR = 8, - SCOPE_ARROW = 16, - SCOPE_SIMPLE_CATCH = 32, - SCOPE_SUPER = 64, - SCOPE_DIRECT_SUPER = 128, - SCOPE_CLASS_STATIC_BLOCK = 256, - SCOPE_VAR = SCOPE_TOP | SCOPE_FUNCTION | SCOPE_CLASS_STATIC_BLOCK; - - function functionFlags(async, generator) { - return SCOPE_FUNCTION | (async ? SCOPE_ASYNC : 0) | (generator ? SCOPE_GENERATOR : 0) - } - - // Used in checkLVal* and declareName to determine the type of a binding - var - BIND_NONE = 0, // Not a binding - BIND_VAR = 1, // Var-style binding - BIND_LEXICAL = 2, // Let- or const-style binding - BIND_FUNCTION = 3, // Function declaration - BIND_SIMPLE_CATCH = 4, // Simple (identifier pattern) catch binding - BIND_OUTSIDE = 5; // Special case for function names as bound inside the function - - var Parser = function Parser(options, input, startPos) { - this.options = options = getOptions(options); - this.sourceFile = options.sourceFile; - this.keywords = wordsRegexp(keywords$1[options.ecmaVersion >= 6 ? 6 : options.sourceType === "module" ? "5module" : 5]); - var reserved = ""; - if (options.allowReserved !== true) { - reserved = reservedWords[options.ecmaVersion >= 6 ? 6 : options.ecmaVersion === 5 ? 5 : 3]; - if (options.sourceType === "module") { reserved += " await"; } - } - this.reservedWords = wordsRegexp(reserved); - var reservedStrict = (reserved ? reserved + " " : "") + reservedWords.strict; - this.reservedWordsStrict = wordsRegexp(reservedStrict); - this.reservedWordsStrictBind = wordsRegexp(reservedStrict + " " + reservedWords.strictBind); - this.input = String(input); - - // Used to signal to callers of `readWord1` whether the word - // contained any escape sequences. This is needed because words with - // escape sequences must not be interpreted as keywords. - this.containsEsc = false; - - // Set up token state - - // The current position of the tokenizer in the input. - if (startPos) { - this.pos = startPos; - this.lineStart = this.input.lastIndexOf("\n", startPos - 1) + 1; - this.curLine = this.input.slice(0, this.lineStart).split(lineBreak).length; - } else { - this.pos = this.lineStart = 0; - this.curLine = 1; - } - - // Properties of the current token: - // Its type - this.type = types$1.eof; - // For tokens that include more information than their type, the value - this.value = null; - // Its start and end offset - this.start = this.end = this.pos; - // And, if locations are used, the {line, column} object - // corresponding to those offsets - this.startLoc = this.endLoc = this.curPosition(); - - // Position information for the previous token - this.lastTokEndLoc = this.lastTokStartLoc = null; - this.lastTokStart = this.lastTokEnd = this.pos; - - // The context stack is used to superficially track syntactic - // context to predict whether a regular expression is allowed in a - // given position. - this.context = this.initialContext(); - this.exprAllowed = true; - - // Figure out if it's a module code. - this.inModule = options.sourceType === "module"; - this.strict = this.inModule || this.strictDirective(this.pos); - - // Used to signify the start of a potential arrow function - this.potentialArrowAt = -1; - this.potentialArrowInForAwait = false; - - // Positions to delayed-check that yield/await does not exist in default parameters. - this.yieldPos = this.awaitPos = this.awaitIdentPos = 0; - // Labels in scope. - this.labels = []; - // Thus-far undefined exports. - this.undefinedExports = Object.create(null); - - // If enabled, skip leading hashbang line. - if (this.pos === 0 && options.allowHashBang && this.input.slice(0, 2) === "#!") - { this.skipLineComment(2); } - - // Scope tracking for duplicate variable names (see scope.js) - this.scopeStack = []; - this.enterScope(SCOPE_TOP); - - // For RegExp validation - this.regexpState = null; - - // The stack of private names. - // Each element has two properties: 'declared' and 'used'. - // When it exited from the outermost class definition, all used private names must be declared. - this.privateNameStack = []; - }; - - var prototypeAccessors = { inFunction: { configurable: true },inGenerator: { configurable: true },inAsync: { configurable: true },canAwait: { configurable: true },allowSuper: { configurable: true },allowDirectSuper: { configurable: true },treatFunctionsAsVar: { configurable: true },allowNewDotTarget: { configurable: true },inClassStaticBlock: { configurable: true } }; - - Parser.prototype.parse = function parse () { - var node = this.options.program || this.startNode(); - this.nextToken(); - return this.parseTopLevel(node) - }; - - prototypeAccessors.inFunction.get = function () { return (this.currentVarScope().flags & SCOPE_FUNCTION) > 0 }; - - prototypeAccessors.inGenerator.get = function () { return (this.currentVarScope().flags & SCOPE_GENERATOR) > 0 && !this.currentVarScope().inClassFieldInit }; - - prototypeAccessors.inAsync.get = function () { return (this.currentVarScope().flags & SCOPE_ASYNC) > 0 && !this.currentVarScope().inClassFieldInit }; - - prototypeAccessors.canAwait.get = function () { - for (var i = this.scopeStack.length - 1; i >= 0; i--) { - var scope = this.scopeStack[i]; - if (scope.inClassFieldInit || scope.flags & SCOPE_CLASS_STATIC_BLOCK) { return false } - if (scope.flags & SCOPE_FUNCTION) { return (scope.flags & SCOPE_ASYNC) > 0 } - } - return (this.inModule && this.options.ecmaVersion >= 13) || this.options.allowAwaitOutsideFunction - }; - - prototypeAccessors.allowSuper.get = function () { - var ref = this.currentThisScope(); - var flags = ref.flags; - var inClassFieldInit = ref.inClassFieldInit; - return (flags & SCOPE_SUPER) > 0 || inClassFieldInit || this.options.allowSuperOutsideMethod - }; - - prototypeAccessors.allowDirectSuper.get = function () { return (this.currentThisScope().flags & SCOPE_DIRECT_SUPER) > 0 }; - - prototypeAccessors.treatFunctionsAsVar.get = function () { return this.treatFunctionsAsVarInScope(this.currentScope()) }; - - prototypeAccessors.allowNewDotTarget.get = function () { - var ref = this.currentThisScope(); - var flags = ref.flags; - var inClassFieldInit = ref.inClassFieldInit; - return (flags & (SCOPE_FUNCTION | SCOPE_CLASS_STATIC_BLOCK)) > 0 || inClassFieldInit - }; - - prototypeAccessors.inClassStaticBlock.get = function () { - return (this.currentVarScope().flags & SCOPE_CLASS_STATIC_BLOCK) > 0 - }; - - Parser.extend = function extend () { - var plugins = [], len = arguments.length; - while ( len-- ) plugins[ len ] = arguments[ len ]; - - var cls = this; - for (var i = 0; i < plugins.length; i++) { cls = plugins[i](cls); } - return cls - }; - - Parser.parse = function parse (input, options) { - return new this(options, input).parse() - }; - - Parser.parseExpressionAt = function parseExpressionAt (input, pos, options) { - var parser = new this(options, input, pos); - parser.nextToken(); - return parser.parseExpression() - }; - - Parser.tokenizer = function tokenizer (input, options) { - return new this(options, input) - }; - - Object.defineProperties( Parser.prototype, prototypeAccessors ); - - var pp$9 = Parser.prototype; - - // ## Parser utilities - - var literal = /^(?:'((?:\\.|[^'\\])*?)'|"((?:\\.|[^"\\])*?)")/; - pp$9.strictDirective = function(start) { - if (this.options.ecmaVersion < 5) { return false } - for (;;) { - // Try to find string literal. - skipWhiteSpace.lastIndex = start; - start += skipWhiteSpace.exec(this.input)[0].length; - var match = literal.exec(this.input.slice(start)); - if (!match) { return false } - if ((match[1] || match[2]) === "use strict") { - skipWhiteSpace.lastIndex = start + match[0].length; - var spaceAfter = skipWhiteSpace.exec(this.input), end = spaceAfter.index + spaceAfter[0].length; - var next = this.input.charAt(end); - return next === ";" || next === "}" || - (lineBreak.test(spaceAfter[0]) && - !(/[(`.[+\-/*%<>=,?^&]/.test(next) || next === "!" && this.input.charAt(end + 1) === "=")) - } - start += match[0].length; - - // Skip semicolon, if any. - skipWhiteSpace.lastIndex = start; - start += skipWhiteSpace.exec(this.input)[0].length; - if (this.input[start] === ";") - { start++; } - } - }; - - // Predicate that tests whether the next token is of the given - // type, and if yes, consumes it as a side effect. - - pp$9.eat = function(type) { - if (this.type === type) { - this.next(); - return true - } else { - return false - } - }; - - // Tests whether parsed token is a contextual keyword. - - pp$9.isContextual = function(name) { - return this.type === types$1.name && this.value === name && !this.containsEsc - }; - - // Consumes contextual keyword if possible. - - pp$9.eatContextual = function(name) { - if (!this.isContextual(name)) { return false } - this.next(); - return true - }; - - // Asserts that following token is given contextual keyword. - - pp$9.expectContextual = function(name) { - if (!this.eatContextual(name)) { this.unexpected(); } - }; - - // Test whether a semicolon can be inserted at the current position. - - pp$9.canInsertSemicolon = function() { - return this.type === types$1.eof || - this.type === types$1.braceR || - lineBreak.test(this.input.slice(this.lastTokEnd, this.start)) - }; - - pp$9.insertSemicolon = function() { - if (this.canInsertSemicolon()) { - if (this.options.onInsertedSemicolon) - { this.options.onInsertedSemicolon(this.lastTokEnd, this.lastTokEndLoc); } - return true - } - }; - - // Consume a semicolon, or, failing that, see if we are allowed to - // pretend that there is a semicolon at this position. - - pp$9.semicolon = function() { - if (!this.eat(types$1.semi) && !this.insertSemicolon()) { this.unexpected(); } - }; - - pp$9.afterTrailingComma = function(tokType, notNext) { - if (this.type === tokType) { - if (this.options.onTrailingComma) - { this.options.onTrailingComma(this.lastTokStart, this.lastTokStartLoc); } - if (!notNext) - { this.next(); } - return true - } - }; - - // Expect a token of a given type. If found, consume it, otherwise, - // raise an unexpected token error. - - pp$9.expect = function(type) { - this.eat(type) || this.unexpected(); - }; - - // Raise an unexpected token error. - - pp$9.unexpected = function(pos) { - this.raise(pos != null ? pos : this.start, "Unexpected token"); - }; - - var DestructuringErrors = function DestructuringErrors() { - this.shorthandAssign = - this.trailingComma = - this.parenthesizedAssign = - this.parenthesizedBind = - this.doubleProto = - -1; - }; - - pp$9.checkPatternErrors = function(refDestructuringErrors, isAssign) { - if (!refDestructuringErrors) { return } - if (refDestructuringErrors.trailingComma > -1) - { this.raiseRecoverable(refDestructuringErrors.trailingComma, "Comma is not permitted after the rest element"); } - var parens = isAssign ? refDestructuringErrors.parenthesizedAssign : refDestructuringErrors.parenthesizedBind; - if (parens > -1) { this.raiseRecoverable(parens, isAssign ? "Assigning to rvalue" : "Parenthesized pattern"); } - }; - - pp$9.checkExpressionErrors = function(refDestructuringErrors, andThrow) { - if (!refDestructuringErrors) { return false } - var shorthandAssign = refDestructuringErrors.shorthandAssign; - var doubleProto = refDestructuringErrors.doubleProto; - if (!andThrow) { return shorthandAssign >= 0 || doubleProto >= 0 } - if (shorthandAssign >= 0) - { this.raise(shorthandAssign, "Shorthand property assignments are valid only in destructuring patterns"); } - if (doubleProto >= 0) - { this.raiseRecoverable(doubleProto, "Redefinition of __proto__ property"); } - }; - - pp$9.checkYieldAwaitInDefaultParams = function() { - if (this.yieldPos && (!this.awaitPos || this.yieldPos < this.awaitPos)) - { this.raise(this.yieldPos, "Yield expression cannot be a default value"); } - if (this.awaitPos) - { this.raise(this.awaitPos, "Await expression cannot be a default value"); } - }; - - pp$9.isSimpleAssignTarget = function(expr) { - if (expr.type === "ParenthesizedExpression") - { return this.isSimpleAssignTarget(expr.expression) } - return expr.type === "Identifier" || expr.type === "MemberExpression" - }; - - var pp$8 = Parser.prototype; - - // ### Statement parsing - - // Parse a program. Initializes the parser, reads any number of - // statements, and wraps them in a Program node. Optionally takes a - // `program` argument. If present, the statements will be appended - // to its body instead of creating a new node. - - pp$8.parseTopLevel = function(node) { - var exports = Object.create(null); - if (!node.body) { node.body = []; } - while (this.type !== types$1.eof) { - var stmt = this.parseStatement(null, true, exports); - node.body.push(stmt); - } - if (this.inModule) - { for (var i = 0, list = Object.keys(this.undefinedExports); i < list.length; i += 1) - { - var name = list[i]; - - this.raiseRecoverable(this.undefinedExports[name].start, ("Export '" + name + "' is not defined")); - } } - this.adaptDirectivePrologue(node.body); - this.next(); - node.sourceType = this.options.sourceType; - return this.finishNode(node, "Program") - }; - - var loopLabel = {kind: "loop"}, switchLabel = {kind: "switch"}; - - pp$8.isLet = function(context) { - if (this.options.ecmaVersion < 6 || !this.isContextual("let")) { return false } - skipWhiteSpace.lastIndex = this.pos; - var skip = skipWhiteSpace.exec(this.input); - var next = this.pos + skip[0].length, nextCh = this.input.charCodeAt(next); - // For ambiguous cases, determine if a LexicalDeclaration (or only a - // Statement) is allowed here. If context is not empty then only a Statement - // is allowed. However, `let [` is an explicit negative lookahead for - // ExpressionStatement, so special-case it first. - if (nextCh === 91 || nextCh === 92) { return true } // '[', '/' - if (context) { return false } - - if (nextCh === 123 || nextCh > 0xd7ff && nextCh < 0xdc00) { return true } // '{', astral - if (isIdentifierStart(nextCh, true)) { - var pos = next + 1; - while (isIdentifierChar(nextCh = this.input.charCodeAt(pos), true)) { ++pos; } - if (nextCh === 92 || nextCh > 0xd7ff && nextCh < 0xdc00) { return true } - var ident = this.input.slice(next, pos); - if (!keywordRelationalOperator.test(ident)) { return true } - } - return false - }; - - // check 'async [no LineTerminator here] function' - // - 'async /*foo*/ function' is OK. - // - 'async /*\n*/ function' is invalid. - pp$8.isAsyncFunction = function() { - if (this.options.ecmaVersion < 8 || !this.isContextual("async")) - { return false } - - skipWhiteSpace.lastIndex = this.pos; - var skip = skipWhiteSpace.exec(this.input); - var next = this.pos + skip[0].length, after; - return !lineBreak.test(this.input.slice(this.pos, next)) && - this.input.slice(next, next + 8) === "function" && - (next + 8 === this.input.length || - !(isIdentifierChar(after = this.input.charCodeAt(next + 8)) || after > 0xd7ff && after < 0xdc00)) - }; - - // Parse a single statement. - // - // If expecting a statement and finding a slash operator, parse a - // regular expression literal. This is to handle cases like - // `if (foo) /blah/.exec(foo)`, where looking at the previous token - // does not help. - - pp$8.parseStatement = function(context, topLevel, exports) { - var starttype = this.type, node = this.startNode(), kind; - - if (this.isLet(context)) { - starttype = types$1._var; - kind = "let"; - } - - // Most types of statements are recognized by the keyword they - // start with. Many are trivial to parse, some require a bit of - // complexity. - - switch (starttype) { - case types$1._break: case types$1._continue: return this.parseBreakContinueStatement(node, starttype.keyword) - case types$1._debugger: return this.parseDebuggerStatement(node) - case types$1._do: return this.parseDoStatement(node) - case types$1._for: return this.parseForStatement(node) - case types$1._function: - // Function as sole body of either an if statement or a labeled statement - // works, but not when it is part of a labeled statement that is the sole - // body of an if statement. - if ((context && (this.strict || context !== "if" && context !== "label")) && this.options.ecmaVersion >= 6) { this.unexpected(); } - return this.parseFunctionStatement(node, false, !context) - case types$1._class: - if (context) { this.unexpected(); } - return this.parseClass(node, true) - case types$1._if: return this.parseIfStatement(node) - case types$1._return: return this.parseReturnStatement(node) - case types$1._switch: return this.parseSwitchStatement(node) - case types$1._throw: return this.parseThrowStatement(node) - case types$1._try: return this.parseTryStatement(node) - case types$1._const: case types$1._var: - kind = kind || this.value; - if (context && kind !== "var") { this.unexpected(); } - return this.parseVarStatement(node, kind) - case types$1._while: return this.parseWhileStatement(node) - case types$1._with: return this.parseWithStatement(node) - case types$1.braceL: return this.parseBlock(true, node) - case types$1.semi: return this.parseEmptyStatement(node) - case types$1._export: - case types$1._import: - if (this.options.ecmaVersion > 10 && starttype === types$1._import) { - skipWhiteSpace.lastIndex = this.pos; - var skip = skipWhiteSpace.exec(this.input); - var next = this.pos + skip[0].length, nextCh = this.input.charCodeAt(next); - if (nextCh === 40 || nextCh === 46) // '(' or '.' - { return this.parseExpressionStatement(node, this.parseExpression()) } - } - - if (!this.options.allowImportExportEverywhere) { - if (!topLevel) - { this.raise(this.start, "'import' and 'export' may only appear at the top level"); } - if (!this.inModule) - { this.raise(this.start, "'import' and 'export' may appear only with 'sourceType: module'"); } - } - return starttype === types$1._import ? this.parseImport(node) : this.parseExport(node, exports) - - // If the statement does not start with a statement keyword or a - // brace, it's an ExpressionStatement or LabeledStatement. We - // simply start parsing an expression, and afterwards, if the - // next token is a colon and the expression was a simple - // Identifier node, we switch to interpreting it as a label. - default: - if (this.isAsyncFunction()) { - if (context) { this.unexpected(); } - this.next(); - return this.parseFunctionStatement(node, true, !context) - } - - var maybeName = this.value, expr = this.parseExpression(); - if (starttype === types$1.name && expr.type === "Identifier" && this.eat(types$1.colon)) - { return this.parseLabeledStatement(node, maybeName, expr, context) } - else { return this.parseExpressionStatement(node, expr) } - } - }; - - pp$8.parseBreakContinueStatement = function(node, keyword) { - var isBreak = keyword === "break"; - this.next(); - if (this.eat(types$1.semi) || this.insertSemicolon()) { node.label = null; } - else if (this.type !== types$1.name) { this.unexpected(); } - else { - node.label = this.parseIdent(); - this.semicolon(); - } - - // Verify that there is an actual destination to break or - // continue to. - var i = 0; - for (; i < this.labels.length; ++i) { - var lab = this.labels[i]; - if (node.label == null || lab.name === node.label.name) { - if (lab.kind != null && (isBreak || lab.kind === "loop")) { break } - if (node.label && isBreak) { break } - } - } - if (i === this.labels.length) { this.raise(node.start, "Unsyntactic " + keyword); } - return this.finishNode(node, isBreak ? "BreakStatement" : "ContinueStatement") - }; - - pp$8.parseDebuggerStatement = function(node) { - this.next(); - this.semicolon(); - return this.finishNode(node, "DebuggerStatement") - }; - - pp$8.parseDoStatement = function(node) { - this.next(); - this.labels.push(loopLabel); - node.body = this.parseStatement("do"); - this.labels.pop(); - this.expect(types$1._while); - node.test = this.parseParenExpression(); - if (this.options.ecmaVersion >= 6) - { this.eat(types$1.semi); } - else - { this.semicolon(); } - return this.finishNode(node, "DoWhileStatement") - }; - - // Disambiguating between a `for` and a `for`/`in` or `for`/`of` - // loop is non-trivial. Basically, we have to parse the init `var` - // statement or expression, disallowing the `in` operator (see - // the second parameter to `parseExpression`), and then check - // whether the next token is `in` or `of`. When there is no init - // part (semicolon immediately after the opening parenthesis), it - // is a regular `for` loop. - - pp$8.parseForStatement = function(node) { - this.next(); - var awaitAt = (this.options.ecmaVersion >= 9 && this.canAwait && this.eatContextual("await")) ? this.lastTokStart : -1; - this.labels.push(loopLabel); - this.enterScope(0); - this.expect(types$1.parenL); - if (this.type === types$1.semi) { - if (awaitAt > -1) { this.unexpected(awaitAt); } - return this.parseFor(node, null) - } - var isLet = this.isLet(); - if (this.type === types$1._var || this.type === types$1._const || isLet) { - var init$1 = this.startNode(), kind = isLet ? "let" : this.value; - this.next(); - this.parseVar(init$1, true, kind); - this.finishNode(init$1, "VariableDeclaration"); - if ((this.type === types$1._in || (this.options.ecmaVersion >= 6 && this.isContextual("of"))) && init$1.declarations.length === 1) { - if (this.options.ecmaVersion >= 9) { - if (this.type === types$1._in) { - if (awaitAt > -1) { this.unexpected(awaitAt); } - } else { node.await = awaitAt > -1; } - } - return this.parseForIn(node, init$1) - } - if (awaitAt > -1) { this.unexpected(awaitAt); } - return this.parseFor(node, init$1) - } - var startsWithLet = this.isContextual("let"), isForOf = false; - var refDestructuringErrors = new DestructuringErrors; - var init = this.parseExpression(awaitAt > -1 ? "await" : true, refDestructuringErrors); - if (this.type === types$1._in || (isForOf = this.options.ecmaVersion >= 6 && this.isContextual("of"))) { - if (this.options.ecmaVersion >= 9) { - if (this.type === types$1._in) { - if (awaitAt > -1) { this.unexpected(awaitAt); } - } else { node.await = awaitAt > -1; } - } - if (startsWithLet && isForOf) { this.raise(init.start, "The left-hand side of a for-of loop may not start with 'let'."); } - this.toAssignable(init, false, refDestructuringErrors); - this.checkLValPattern(init); - return this.parseForIn(node, init) - } else { - this.checkExpressionErrors(refDestructuringErrors, true); - } - if (awaitAt > -1) { this.unexpected(awaitAt); } - return this.parseFor(node, init) - }; - - pp$8.parseFunctionStatement = function(node, isAsync, declarationPosition) { - this.next(); - return this.parseFunction(node, FUNC_STATEMENT | (declarationPosition ? 0 : FUNC_HANGING_STATEMENT), false, isAsync) - }; - - pp$8.parseIfStatement = function(node) { - this.next(); - node.test = this.parseParenExpression(); - // allow function declarations in branches, but only in non-strict mode - node.consequent = this.parseStatement("if"); - node.alternate = this.eat(types$1._else) ? this.parseStatement("if") : null; - return this.finishNode(node, "IfStatement") - }; - - pp$8.parseReturnStatement = function(node) { - if (!this.inFunction && !this.options.allowReturnOutsideFunction) - { this.raise(this.start, "'return' outside of function"); } - this.next(); - - // In `return` (and `break`/`continue`), the keywords with - // optional arguments, we eagerly look for a semicolon or the - // possibility to insert one. - - if (this.eat(types$1.semi) || this.insertSemicolon()) { node.argument = null; } - else { node.argument = this.parseExpression(); this.semicolon(); } - return this.finishNode(node, "ReturnStatement") - }; - - pp$8.parseSwitchStatement = function(node) { - this.next(); - node.discriminant = this.parseParenExpression(); - node.cases = []; - this.expect(types$1.braceL); - this.labels.push(switchLabel); - this.enterScope(0); - - // Statements under must be grouped (by label) in SwitchCase - // nodes. `cur` is used to keep the node that we are currently - // adding statements to. - - var cur; - for (var sawDefault = false; this.type !== types$1.braceR;) { - if (this.type === types$1._case || this.type === types$1._default) { - var isCase = this.type === types$1._case; - if (cur) { this.finishNode(cur, "SwitchCase"); } - node.cases.push(cur = this.startNode()); - cur.consequent = []; - this.next(); - if (isCase) { - cur.test = this.parseExpression(); - } else { - if (sawDefault) { this.raiseRecoverable(this.lastTokStart, "Multiple default clauses"); } - sawDefault = true; - cur.test = null; - } - this.expect(types$1.colon); - } else { - if (!cur) { this.unexpected(); } - cur.consequent.push(this.parseStatement(null)); - } - } - this.exitScope(); - if (cur) { this.finishNode(cur, "SwitchCase"); } - this.next(); // Closing brace - this.labels.pop(); - return this.finishNode(node, "SwitchStatement") - }; - - pp$8.parseThrowStatement = function(node) { - this.next(); - if (lineBreak.test(this.input.slice(this.lastTokEnd, this.start))) - { this.raise(this.lastTokEnd, "Illegal newline after throw"); } - node.argument = this.parseExpression(); - this.semicolon(); - return this.finishNode(node, "ThrowStatement") - }; - - // Reused empty array added for node fields that are always empty. - - var empty$1 = []; - - pp$8.parseCatchClauseParam = function() { - var param = this.parseBindingAtom(); - var simple = param.type === "Identifier"; - this.enterScope(simple ? SCOPE_SIMPLE_CATCH : 0); - this.checkLValPattern(param, simple ? BIND_SIMPLE_CATCH : BIND_LEXICAL); - this.expect(types$1.parenR); - - return param - }; - - pp$8.parseTryStatement = function(node) { - this.next(); - node.block = this.parseBlock(); - node.handler = null; - if (this.type === types$1._catch) { - var clause = this.startNode(); - this.next(); - if (this.eat(types$1.parenL)) { - clause.param = this.parseCatchClauseParam(); - } else { - if (this.options.ecmaVersion < 10) { this.unexpected(); } - clause.param = null; - this.enterScope(0); - } - clause.body = this.parseBlock(false); - this.exitScope(); - node.handler = this.finishNode(clause, "CatchClause"); - } - node.finalizer = this.eat(types$1._finally) ? this.parseBlock() : null; - if (!node.handler && !node.finalizer) - { this.raise(node.start, "Missing catch or finally clause"); } - return this.finishNode(node, "TryStatement") - }; - - pp$8.parseVarStatement = function(node, kind, allowMissingInitializer) { - this.next(); - this.parseVar(node, false, kind, allowMissingInitializer); - this.semicolon(); - return this.finishNode(node, "VariableDeclaration") - }; - - pp$8.parseWhileStatement = function(node) { - this.next(); - node.test = this.parseParenExpression(); - this.labels.push(loopLabel); - node.body = this.parseStatement("while"); - this.labels.pop(); - return this.finishNode(node, "WhileStatement") - }; - - pp$8.parseWithStatement = function(node) { - if (this.strict) { this.raise(this.start, "'with' in strict mode"); } - this.next(); - node.object = this.parseParenExpression(); - node.body = this.parseStatement("with"); - return this.finishNode(node, "WithStatement") - }; - - pp$8.parseEmptyStatement = function(node) { - this.next(); - return this.finishNode(node, "EmptyStatement") - }; - - pp$8.parseLabeledStatement = function(node, maybeName, expr, context) { - for (var i$1 = 0, list = this.labels; i$1 < list.length; i$1 += 1) - { - var label = list[i$1]; - - if (label.name === maybeName) - { this.raise(expr.start, "Label '" + maybeName + "' is already declared"); - } } - var kind = this.type.isLoop ? "loop" : this.type === types$1._switch ? "switch" : null; - for (var i = this.labels.length - 1; i >= 0; i--) { - var label$1 = this.labels[i]; - if (label$1.statementStart === node.start) { - // Update information about previous labels on this node - label$1.statementStart = this.start; - label$1.kind = kind; - } else { break } - } - this.labels.push({name: maybeName, kind: kind, statementStart: this.start}); - node.body = this.parseStatement(context ? context.indexOf("label") === -1 ? context + "label" : context : "label"); - this.labels.pop(); - node.label = expr; - return this.finishNode(node, "LabeledStatement") - }; - - pp$8.parseExpressionStatement = function(node, expr) { - node.expression = expr; - this.semicolon(); - return this.finishNode(node, "ExpressionStatement") - }; - - // Parse a semicolon-enclosed block of statements, handling `"use - // strict"` declarations when `allowStrict` is true (used for - // function bodies). - - pp$8.parseBlock = function(createNewLexicalScope, node, exitStrict) { - if ( createNewLexicalScope === void 0 ) createNewLexicalScope = true; - if ( node === void 0 ) node = this.startNode(); - - node.body = []; - this.expect(types$1.braceL); - if (createNewLexicalScope) { this.enterScope(0); } - while (this.type !== types$1.braceR) { - var stmt = this.parseStatement(null); - node.body.push(stmt); - } - if (exitStrict) { this.strict = false; } - this.next(); - if (createNewLexicalScope) { this.exitScope(); } - return this.finishNode(node, "BlockStatement") - }; - - // Parse a regular `for` loop. The disambiguation code in - // `parseStatement` will already have parsed the init statement or - // expression. - - pp$8.parseFor = function(node, init) { - node.init = init; - this.expect(types$1.semi); - node.test = this.type === types$1.semi ? null : this.parseExpression(); - this.expect(types$1.semi); - node.update = this.type === types$1.parenR ? null : this.parseExpression(); - this.expect(types$1.parenR); - node.body = this.parseStatement("for"); - this.exitScope(); - this.labels.pop(); - return this.finishNode(node, "ForStatement") - }; - - // Parse a `for`/`in` and `for`/`of` loop, which are almost - // same from parser's perspective. - - pp$8.parseForIn = function(node, init) { - var isForIn = this.type === types$1._in; - this.next(); - - if ( - init.type === "VariableDeclaration" && - init.declarations[0].init != null && - ( - !isForIn || - this.options.ecmaVersion < 8 || - this.strict || - init.kind !== "var" || - init.declarations[0].id.type !== "Identifier" - ) - ) { - this.raise( - init.start, - ((isForIn ? "for-in" : "for-of") + " loop variable declaration may not have an initializer") - ); - } - node.left = init; - node.right = isForIn ? this.parseExpression() : this.parseMaybeAssign(); - this.expect(types$1.parenR); - node.body = this.parseStatement("for"); - this.exitScope(); - this.labels.pop(); - return this.finishNode(node, isForIn ? "ForInStatement" : "ForOfStatement") - }; - - // Parse a list of variable declarations. - - pp$8.parseVar = function(node, isFor, kind, allowMissingInitializer) { - node.declarations = []; - node.kind = kind; - for (;;) { - var decl = this.startNode(); - this.parseVarId(decl, kind); - if (this.eat(types$1.eq)) { - decl.init = this.parseMaybeAssign(isFor); - } else if (!allowMissingInitializer && kind === "const" && !(this.type === types$1._in || (this.options.ecmaVersion >= 6 && this.isContextual("of")))) { - this.unexpected(); - } else if (!allowMissingInitializer && decl.id.type !== "Identifier" && !(isFor && (this.type === types$1._in || this.isContextual("of")))) { - this.raise(this.lastTokEnd, "Complex binding patterns require an initialization value"); - } else { - decl.init = null; - } - node.declarations.push(this.finishNode(decl, "VariableDeclarator")); - if (!this.eat(types$1.comma)) { break } - } - return node - }; - - pp$8.parseVarId = function(decl, kind) { - decl.id = this.parseBindingAtom(); - this.checkLValPattern(decl.id, kind === "var" ? BIND_VAR : BIND_LEXICAL, false); - }; - - var FUNC_STATEMENT = 1, FUNC_HANGING_STATEMENT = 2, FUNC_NULLABLE_ID = 4; - - // Parse a function declaration or literal (depending on the - // `statement & FUNC_STATEMENT`). - - // Remove `allowExpressionBody` for 7.0.0, as it is only called with false - pp$8.parseFunction = function(node, statement, allowExpressionBody, isAsync, forInit) { - this.initFunction(node); - if (this.options.ecmaVersion >= 9 || this.options.ecmaVersion >= 6 && !isAsync) { - if (this.type === types$1.star && (statement & FUNC_HANGING_STATEMENT)) - { this.unexpected(); } - node.generator = this.eat(types$1.star); - } - if (this.options.ecmaVersion >= 8) - { node.async = !!isAsync; } - - if (statement & FUNC_STATEMENT) { - node.id = (statement & FUNC_NULLABLE_ID) && this.type !== types$1.name ? null : this.parseIdent(); - if (node.id && !(statement & FUNC_HANGING_STATEMENT)) - // If it is a regular function declaration in sloppy mode, then it is - // subject to Annex B semantics (BIND_FUNCTION). Otherwise, the binding - // mode depends on properties of the current scope (see - // treatFunctionsAsVar). - { this.checkLValSimple(node.id, (this.strict || node.generator || node.async) ? this.treatFunctionsAsVar ? BIND_VAR : BIND_LEXICAL : BIND_FUNCTION); } - } - - var oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos, oldAwaitIdentPos = this.awaitIdentPos; - this.yieldPos = 0; - this.awaitPos = 0; - this.awaitIdentPos = 0; - this.enterScope(functionFlags(node.async, node.generator)); - - if (!(statement & FUNC_STATEMENT)) - { node.id = this.type === types$1.name ? this.parseIdent() : null; } - - this.parseFunctionParams(node); - this.parseFunctionBody(node, allowExpressionBody, false, forInit); - - this.yieldPos = oldYieldPos; - this.awaitPos = oldAwaitPos; - this.awaitIdentPos = oldAwaitIdentPos; - return this.finishNode(node, (statement & FUNC_STATEMENT) ? "FunctionDeclaration" : "FunctionExpression") - }; - - pp$8.parseFunctionParams = function(node) { - this.expect(types$1.parenL); - node.params = this.parseBindingList(types$1.parenR, false, this.options.ecmaVersion >= 8); - this.checkYieldAwaitInDefaultParams(); - }; - - // Parse a class declaration or literal (depending on the - // `isStatement` parameter). - - pp$8.parseClass = function(node, isStatement) { - this.next(); - - // ecma-262 14.6 Class Definitions - // A class definition is always strict mode code. - var oldStrict = this.strict; - this.strict = true; - - this.parseClassId(node, isStatement); - this.parseClassSuper(node); - var privateNameMap = this.enterClassBody(); - var classBody = this.startNode(); - var hadConstructor = false; - classBody.body = []; - this.expect(types$1.braceL); - while (this.type !== types$1.braceR) { - var element = this.parseClassElement(node.superClass !== null); - if (element) { - classBody.body.push(element); - if (element.type === "MethodDefinition" && element.kind === "constructor") { - if (hadConstructor) { this.raiseRecoverable(element.start, "Duplicate constructor in the same class"); } - hadConstructor = true; - } else if (element.key && element.key.type === "PrivateIdentifier" && isPrivateNameConflicted(privateNameMap, element)) { - this.raiseRecoverable(element.key.start, ("Identifier '#" + (element.key.name) + "' has already been declared")); - } - } - } - this.strict = oldStrict; - this.next(); - node.body = this.finishNode(classBody, "ClassBody"); - this.exitClassBody(); - return this.finishNode(node, isStatement ? "ClassDeclaration" : "ClassExpression") - }; - - pp$8.parseClassElement = function(constructorAllowsSuper) { - if (this.eat(types$1.semi)) { return null } - - var ecmaVersion = this.options.ecmaVersion; - var node = this.startNode(); - var keyName = ""; - var isGenerator = false; - var isAsync = false; - var kind = "method"; - var isStatic = false; - - if (this.eatContextual("static")) { - // Parse static init block - if (ecmaVersion >= 13 && this.eat(types$1.braceL)) { - this.parseClassStaticBlock(node); - return node - } - if (this.isClassElementNameStart() || this.type === types$1.star) { - isStatic = true; - } else { - keyName = "static"; - } - } - node.static = isStatic; - if (!keyName && ecmaVersion >= 8 && this.eatContextual("async")) { - if ((this.isClassElementNameStart() || this.type === types$1.star) && !this.canInsertSemicolon()) { - isAsync = true; - } else { - keyName = "async"; - } - } - if (!keyName && (ecmaVersion >= 9 || !isAsync) && this.eat(types$1.star)) { - isGenerator = true; - } - if (!keyName && !isAsync && !isGenerator) { - var lastValue = this.value; - if (this.eatContextual("get") || this.eatContextual("set")) { - if (this.isClassElementNameStart()) { - kind = lastValue; - } else { - keyName = lastValue; - } - } - } - - // Parse element name - if (keyName) { - // 'async', 'get', 'set', or 'static' were not a keyword contextually. - // The last token is any of those. Make it the element name. - node.computed = false; - node.key = this.startNodeAt(this.lastTokStart, this.lastTokStartLoc); - node.key.name = keyName; - this.finishNode(node.key, "Identifier"); - } else { - this.parseClassElementName(node); - } - - // Parse element value - if (ecmaVersion < 13 || this.type === types$1.parenL || kind !== "method" || isGenerator || isAsync) { - var isConstructor = !node.static && checkKeyName(node, "constructor"); - var allowsDirectSuper = isConstructor && constructorAllowsSuper; - // Couldn't move this check into the 'parseClassMethod' method for backward compatibility. - if (isConstructor && kind !== "method") { this.raise(node.key.start, "Constructor can't have get/set modifier"); } - node.kind = isConstructor ? "constructor" : kind; - this.parseClassMethod(node, isGenerator, isAsync, allowsDirectSuper); - } else { - this.parseClassField(node); - } - - return node - }; - - pp$8.isClassElementNameStart = function() { - return ( - this.type === types$1.name || - this.type === types$1.privateId || - this.type === types$1.num || - this.type === types$1.string || - this.type === types$1.bracketL || - this.type.keyword - ) - }; - - pp$8.parseClassElementName = function(element) { - if (this.type === types$1.privateId) { - if (this.value === "constructor") { - this.raise(this.start, "Classes can't have an element named '#constructor'"); - } - element.computed = false; - element.key = this.parsePrivateIdent(); - } else { - this.parsePropertyName(element); - } - }; - - pp$8.parseClassMethod = function(method, isGenerator, isAsync, allowsDirectSuper) { - // Check key and flags - var key = method.key; - if (method.kind === "constructor") { - if (isGenerator) { this.raise(key.start, "Constructor can't be a generator"); } - if (isAsync) { this.raise(key.start, "Constructor can't be an async method"); } - } else if (method.static && checkKeyName(method, "prototype")) { - this.raise(key.start, "Classes may not have a static property named prototype"); - } - - // Parse value - var value = method.value = this.parseMethod(isGenerator, isAsync, allowsDirectSuper); - - // Check value - if (method.kind === "get" && value.params.length !== 0) - { this.raiseRecoverable(value.start, "getter should have no params"); } - if (method.kind === "set" && value.params.length !== 1) - { this.raiseRecoverable(value.start, "setter should have exactly one param"); } - if (method.kind === "set" && value.params[0].type === "RestElement") - { this.raiseRecoverable(value.params[0].start, "Setter cannot use rest params"); } - - return this.finishNode(method, "MethodDefinition") - }; - - pp$8.parseClassField = function(field) { - if (checkKeyName(field, "constructor")) { - this.raise(field.key.start, "Classes can't have a field named 'constructor'"); - } else if (field.static && checkKeyName(field, "prototype")) { - this.raise(field.key.start, "Classes can't have a static field named 'prototype'"); - } - - if (this.eat(types$1.eq)) { - // To raise SyntaxError if 'arguments' exists in the initializer. - var scope = this.currentThisScope(); - var inClassFieldInit = scope.inClassFieldInit; - scope.inClassFieldInit = true; - field.value = this.parseMaybeAssign(); - scope.inClassFieldInit = inClassFieldInit; - } else { - field.value = null; - } - this.semicolon(); - - return this.finishNode(field, "PropertyDefinition") - }; - - pp$8.parseClassStaticBlock = function(node) { - node.body = []; - - var oldLabels = this.labels; - this.labels = []; - this.enterScope(SCOPE_CLASS_STATIC_BLOCK | SCOPE_SUPER); - while (this.type !== types$1.braceR) { - var stmt = this.parseStatement(null); - node.body.push(stmt); - } - this.next(); - this.exitScope(); - this.labels = oldLabels; - - return this.finishNode(node, "StaticBlock") - }; - - pp$8.parseClassId = function(node, isStatement) { - if (this.type === types$1.name) { - node.id = this.parseIdent(); - if (isStatement) - { this.checkLValSimple(node.id, BIND_LEXICAL, false); } - } else { - if (isStatement === true) - { this.unexpected(); } - node.id = null; - } - }; - - pp$8.parseClassSuper = function(node) { - node.superClass = this.eat(types$1._extends) ? this.parseExprSubscripts(null, false) : null; - }; - - pp$8.enterClassBody = function() { - var element = {declared: Object.create(null), used: []}; - this.privateNameStack.push(element); - return element.declared - }; - - pp$8.exitClassBody = function() { - var ref = this.privateNameStack.pop(); - var declared = ref.declared; - var used = ref.used; - if (!this.options.checkPrivateFields) { return } - var len = this.privateNameStack.length; - var parent = len === 0 ? null : this.privateNameStack[len - 1]; - for (var i = 0; i < used.length; ++i) { - var id = used[i]; - if (!hasOwn(declared, id.name)) { - if (parent) { - parent.used.push(id); - } else { - this.raiseRecoverable(id.start, ("Private field '#" + (id.name) + "' must be declared in an enclosing class")); - } - } - } - }; - - function isPrivateNameConflicted(privateNameMap, element) { - var name = element.key.name; - var curr = privateNameMap[name]; - - var next = "true"; - if (element.type === "MethodDefinition" && (element.kind === "get" || element.kind === "set")) { - next = (element.static ? "s" : "i") + element.kind; - } - - // `class { get #a(){}; static set #a(_){} }` is also conflict. - if ( - curr === "iget" && next === "iset" || - curr === "iset" && next === "iget" || - curr === "sget" && next === "sset" || - curr === "sset" && next === "sget" - ) { - privateNameMap[name] = "true"; - return false - } else if (!curr) { - privateNameMap[name] = next; - return false - } else { - return true - } - } - - function checkKeyName(node, name) { - var computed = node.computed; - var key = node.key; - return !computed && ( - key.type === "Identifier" && key.name === name || - key.type === "Literal" && key.value === name - ) - } - - // Parses module export declaration. - - pp$8.parseExportAllDeclaration = function(node, exports) { - if (this.options.ecmaVersion >= 11) { - if (this.eatContextual("as")) { - node.exported = this.parseModuleExportName(); - this.checkExport(exports, node.exported, this.lastTokStart); - } else { - node.exported = null; - } - } - this.expectContextual("from"); - if (this.type !== types$1.string) { this.unexpected(); } - node.source = this.parseExprAtom(); - this.semicolon(); - return this.finishNode(node, "ExportAllDeclaration") - }; - - pp$8.parseExport = function(node, exports) { - this.next(); - // export * from '...' - if (this.eat(types$1.star)) { - return this.parseExportAllDeclaration(node, exports) - } - if (this.eat(types$1._default)) { // export default ... - this.checkExport(exports, "default", this.lastTokStart); - node.declaration = this.parseExportDefaultDeclaration(); - return this.finishNode(node, "ExportDefaultDeclaration") - } - // export var|const|let|function|class ... - if (this.shouldParseExportStatement()) { - node.declaration = this.parseExportDeclaration(node); - if (node.declaration.type === "VariableDeclaration") - { this.checkVariableExport(exports, node.declaration.declarations); } - else - { this.checkExport(exports, node.declaration.id, node.declaration.id.start); } - node.specifiers = []; - node.source = null; - } else { // export { x, y as z } [from '...'] - node.declaration = null; - node.specifiers = this.parseExportSpecifiers(exports); - if (this.eatContextual("from")) { - if (this.type !== types$1.string) { this.unexpected(); } - node.source = this.parseExprAtom(); - } else { - for (var i = 0, list = node.specifiers; i < list.length; i += 1) { - // check for keywords used as local names - var spec = list[i]; - - this.checkUnreserved(spec.local); - // check if export is defined - this.checkLocalExport(spec.local); - - if (spec.local.type === "Literal") { - this.raise(spec.local.start, "A string literal cannot be used as an exported binding without `from`."); - } - } - - node.source = null; - } - this.semicolon(); - } - return this.finishNode(node, "ExportNamedDeclaration") - }; - - pp$8.parseExportDeclaration = function(node) { - return this.parseStatement(null) - }; - - pp$8.parseExportDefaultDeclaration = function() { - var isAsync; - if (this.type === types$1._function || (isAsync = this.isAsyncFunction())) { - var fNode = this.startNode(); - this.next(); - if (isAsync) { this.next(); } - return this.parseFunction(fNode, FUNC_STATEMENT | FUNC_NULLABLE_ID, false, isAsync) - } else if (this.type === types$1._class) { - var cNode = this.startNode(); - return this.parseClass(cNode, "nullableID") - } else { - var declaration = this.parseMaybeAssign(); - this.semicolon(); - return declaration - } - }; - - pp$8.checkExport = function(exports, name, pos) { - if (!exports) { return } - if (typeof name !== "string") - { name = name.type === "Identifier" ? name.name : name.value; } - if (hasOwn(exports, name)) - { this.raiseRecoverable(pos, "Duplicate export '" + name + "'"); } - exports[name] = true; - }; - - pp$8.checkPatternExport = function(exports, pat) { - var type = pat.type; - if (type === "Identifier") - { this.checkExport(exports, pat, pat.start); } - else if (type === "ObjectPattern") - { for (var i = 0, list = pat.properties; i < list.length; i += 1) - { - var prop = list[i]; - - this.checkPatternExport(exports, prop); - } } - else if (type === "ArrayPattern") - { for (var i$1 = 0, list$1 = pat.elements; i$1 < list$1.length; i$1 += 1) { - var elt = list$1[i$1]; - - if (elt) { this.checkPatternExport(exports, elt); } - } } - else if (type === "Property") - { this.checkPatternExport(exports, pat.value); } - else if (type === "AssignmentPattern") - { this.checkPatternExport(exports, pat.left); } - else if (type === "RestElement") - { this.checkPatternExport(exports, pat.argument); } - }; - - pp$8.checkVariableExport = function(exports, decls) { - if (!exports) { return } - for (var i = 0, list = decls; i < list.length; i += 1) - { - var decl = list[i]; - - this.checkPatternExport(exports, decl.id); - } - }; - - pp$8.shouldParseExportStatement = function() { - return this.type.keyword === "var" || - this.type.keyword === "const" || - this.type.keyword === "class" || - this.type.keyword === "function" || - this.isLet() || - this.isAsyncFunction() - }; - - // Parses a comma-separated list of module exports. - - pp$8.parseExportSpecifier = function(exports) { - var node = this.startNode(); - node.local = this.parseModuleExportName(); - - node.exported = this.eatContextual("as") ? this.parseModuleExportName() : node.local; - this.checkExport( - exports, - node.exported, - node.exported.start - ); - - return this.finishNode(node, "ExportSpecifier") - }; - - pp$8.parseExportSpecifiers = function(exports) { - var nodes = [], first = true; - // export { x, y as z } [from '...'] - this.expect(types$1.braceL); - while (!this.eat(types$1.braceR)) { - if (!first) { - this.expect(types$1.comma); - if (this.afterTrailingComma(types$1.braceR)) { break } - } else { first = false; } - - nodes.push(this.parseExportSpecifier(exports)); - } - return nodes - }; - - // Parses import declaration. - - pp$8.parseImport = function(node) { - this.next(); - - // import '...' - if (this.type === types$1.string) { - node.specifiers = empty$1; - node.source = this.parseExprAtom(); - } else { - node.specifiers = this.parseImportSpecifiers(); - this.expectContextual("from"); - node.source = this.type === types$1.string ? this.parseExprAtom() : this.unexpected(); - } - this.semicolon(); - return this.finishNode(node, "ImportDeclaration") - }; - - // Parses a comma-separated list of module imports. - - pp$8.parseImportSpecifier = function() { - var node = this.startNode(); - node.imported = this.parseModuleExportName(); - - if (this.eatContextual("as")) { - node.local = this.parseIdent(); - } else { - this.checkUnreserved(node.imported); - node.local = node.imported; - } - this.checkLValSimple(node.local, BIND_LEXICAL); - - return this.finishNode(node, "ImportSpecifier") - }; - - pp$8.parseImportDefaultSpecifier = function() { - // import defaultObj, { x, y as z } from '...' - var node = this.startNode(); - node.local = this.parseIdent(); - this.checkLValSimple(node.local, BIND_LEXICAL); - return this.finishNode(node, "ImportDefaultSpecifier") - }; - - pp$8.parseImportNamespaceSpecifier = function() { - var node = this.startNode(); - this.next(); - this.expectContextual("as"); - node.local = this.parseIdent(); - this.checkLValSimple(node.local, BIND_LEXICAL); - return this.finishNode(node, "ImportNamespaceSpecifier") - }; - - pp$8.parseImportSpecifiers = function() { - var nodes = [], first = true; - if (this.type === types$1.name) { - nodes.push(this.parseImportDefaultSpecifier()); - if (!this.eat(types$1.comma)) { return nodes } - } - if (this.type === types$1.star) { - nodes.push(this.parseImportNamespaceSpecifier()); - return nodes - } - this.expect(types$1.braceL); - while (!this.eat(types$1.braceR)) { - if (!first) { - this.expect(types$1.comma); - if (this.afterTrailingComma(types$1.braceR)) { break } - } else { first = false; } - - nodes.push(this.parseImportSpecifier()); - } - return nodes - }; - - pp$8.parseModuleExportName = function() { - if (this.options.ecmaVersion >= 13 && this.type === types$1.string) { - var stringLiteral = this.parseLiteral(this.value); - if (loneSurrogate.test(stringLiteral.value)) { - this.raise(stringLiteral.start, "An export name cannot include a lone surrogate."); - } - return stringLiteral - } - return this.parseIdent(true) - }; - - // Set `ExpressionStatement#directive` property for directive prologues. - pp$8.adaptDirectivePrologue = function(statements) { - for (var i = 0; i < statements.length && this.isDirectiveCandidate(statements[i]); ++i) { - statements[i].directive = statements[i].expression.raw.slice(1, -1); - } - }; - pp$8.isDirectiveCandidate = function(statement) { - return ( - this.options.ecmaVersion >= 5 && - statement.type === "ExpressionStatement" && - statement.expression.type === "Literal" && - typeof statement.expression.value === "string" && - // Reject parenthesized strings. - (this.input[statement.start] === "\"" || this.input[statement.start] === "'") - ) - }; - - var pp$7 = Parser.prototype; - - // Convert existing expression atom to assignable pattern - // if possible. - - pp$7.toAssignable = function(node, isBinding, refDestructuringErrors) { - if (this.options.ecmaVersion >= 6 && node) { - switch (node.type) { - case "Identifier": - if (this.inAsync && node.name === "await") - { this.raise(node.start, "Cannot use 'await' as identifier inside an async function"); } - break - - case "ObjectPattern": - case "ArrayPattern": - case "AssignmentPattern": - case "RestElement": - break - - case "ObjectExpression": - node.type = "ObjectPattern"; - if (refDestructuringErrors) { this.checkPatternErrors(refDestructuringErrors, true); } - for (var i = 0, list = node.properties; i < list.length; i += 1) { - var prop = list[i]; - - this.toAssignable(prop, isBinding); - // Early error: - // AssignmentRestProperty[Yield, Await] : - // `...` DestructuringAssignmentTarget[Yield, Await] - // - // It is a Syntax Error if |DestructuringAssignmentTarget| is an |ArrayLiteral| or an |ObjectLiteral|. - if ( - prop.type === "RestElement" && - (prop.argument.type === "ArrayPattern" || prop.argument.type === "ObjectPattern") - ) { - this.raise(prop.argument.start, "Unexpected token"); - } - } - break - - case "Property": - // AssignmentProperty has type === "Property" - if (node.kind !== "init") { this.raise(node.key.start, "Object pattern can't contain getter or setter"); } - this.toAssignable(node.value, isBinding); - break - - case "ArrayExpression": - node.type = "ArrayPattern"; - if (refDestructuringErrors) { this.checkPatternErrors(refDestructuringErrors, true); } - this.toAssignableList(node.elements, isBinding); - break - - case "SpreadElement": - node.type = "RestElement"; - this.toAssignable(node.argument, isBinding); - if (node.argument.type === "AssignmentPattern") - { this.raise(node.argument.start, "Rest elements cannot have a default value"); } - break - - case "AssignmentExpression": - if (node.operator !== "=") { this.raise(node.left.end, "Only '=' operator can be used for specifying default value."); } - node.type = "AssignmentPattern"; - delete node.operator; - this.toAssignable(node.left, isBinding); - break - - case "ParenthesizedExpression": - this.toAssignable(node.expression, isBinding, refDestructuringErrors); - break - - case "ChainExpression": - this.raiseRecoverable(node.start, "Optional chaining cannot appear in left-hand side"); - break - - case "MemberExpression": - if (!isBinding) { break } - - default: - this.raise(node.start, "Assigning to rvalue"); - } - } else if (refDestructuringErrors) { this.checkPatternErrors(refDestructuringErrors, true); } - return node - }; - - // Convert list of expression atoms to binding list. - - pp$7.toAssignableList = function(exprList, isBinding) { - var end = exprList.length; - for (var i = 0; i < end; i++) { - var elt = exprList[i]; - if (elt) { this.toAssignable(elt, isBinding); } - } - if (end) { - var last = exprList[end - 1]; - if (this.options.ecmaVersion === 6 && isBinding && last && last.type === "RestElement" && last.argument.type !== "Identifier") - { this.unexpected(last.argument.start); } - } - return exprList - }; - - // Parses spread element. - - pp$7.parseSpread = function(refDestructuringErrors) { - var node = this.startNode(); - this.next(); - node.argument = this.parseMaybeAssign(false, refDestructuringErrors); - return this.finishNode(node, "SpreadElement") - }; - - pp$7.parseRestBinding = function() { - var node = this.startNode(); - this.next(); - - // RestElement inside of a function parameter must be an identifier - if (this.options.ecmaVersion === 6 && this.type !== types$1.name) - { this.unexpected(); } - - node.argument = this.parseBindingAtom(); - - return this.finishNode(node, "RestElement") - }; - - // Parses lvalue (assignable) atom. - - pp$7.parseBindingAtom = function() { - if (this.options.ecmaVersion >= 6) { - switch (this.type) { - case types$1.bracketL: - var node = this.startNode(); - this.next(); - node.elements = this.parseBindingList(types$1.bracketR, true, true); - return this.finishNode(node, "ArrayPattern") - - case types$1.braceL: - return this.parseObj(true) - } - } - return this.parseIdent() - }; - - pp$7.parseBindingList = function(close, allowEmpty, allowTrailingComma, allowModifiers) { - var elts = [], first = true; - while (!this.eat(close)) { - if (first) { first = false; } - else { this.expect(types$1.comma); } - if (allowEmpty && this.type === types$1.comma) { - elts.push(null); - } else if (allowTrailingComma && this.afterTrailingComma(close)) { - break - } else if (this.type === types$1.ellipsis) { - var rest = this.parseRestBinding(); - this.parseBindingListItem(rest); - elts.push(rest); - if (this.type === types$1.comma) { this.raiseRecoverable(this.start, "Comma is not permitted after the rest element"); } - this.expect(close); - break - } else { - elts.push(this.parseAssignableListItem(allowModifiers)); - } - } - return elts - }; - - pp$7.parseAssignableListItem = function(allowModifiers) { - var elem = this.parseMaybeDefault(this.start, this.startLoc); - this.parseBindingListItem(elem); - return elem - }; - - pp$7.parseBindingListItem = function(param) { - return param - }; - - // Parses assignment pattern around given atom if possible. - - pp$7.parseMaybeDefault = function(startPos, startLoc, left) { - left = left || this.parseBindingAtom(); - if (this.options.ecmaVersion < 6 || !this.eat(types$1.eq)) { return left } - var node = this.startNodeAt(startPos, startLoc); - node.left = left; - node.right = this.parseMaybeAssign(); - return this.finishNode(node, "AssignmentPattern") - }; - - // The following three functions all verify that a node is an lvalue — - // something that can be bound, or assigned to. In order to do so, they perform - // a variety of checks: - // - // - Check that none of the bound/assigned-to identifiers are reserved words. - // - Record name declarations for bindings in the appropriate scope. - // - Check duplicate argument names, if checkClashes is set. - // - // If a complex binding pattern is encountered (e.g., object and array - // destructuring), the entire pattern is recursively checked. - // - // There are three versions of checkLVal*() appropriate for different - // circumstances: - // - // - checkLValSimple() shall be used if the syntactic construct supports - // nothing other than identifiers and member expressions. Parenthesized - // expressions are also correctly handled. This is generally appropriate for - // constructs for which the spec says - // - // > It is a Syntax Error if AssignmentTargetType of [the production] is not - // > simple. - // - // It is also appropriate for checking if an identifier is valid and not - // defined elsewhere, like import declarations or function/class identifiers. - // - // Examples where this is used include: - // a += …; - // import a from '…'; - // where a is the node to be checked. - // - // - checkLValPattern() shall be used if the syntactic construct supports - // anything checkLValSimple() supports, as well as object and array - // destructuring patterns. This is generally appropriate for constructs for - // which the spec says - // - // > It is a Syntax Error if [the production] is neither an ObjectLiteral nor - // > an ArrayLiteral and AssignmentTargetType of [the production] is not - // > simple. - // - // Examples where this is used include: - // (a = …); - // const a = …; - // try { … } catch (a) { … } - // where a is the node to be checked. - // - // - checkLValInnerPattern() shall be used if the syntactic construct supports - // anything checkLValPattern() supports, as well as default assignment - // patterns, rest elements, and other constructs that may appear within an - // object or array destructuring pattern. - // - // As a special case, function parameters also use checkLValInnerPattern(), - // as they also support defaults and rest constructs. - // - // These functions deliberately support both assignment and binding constructs, - // as the logic for both is exceedingly similar. If the node is the target of - // an assignment, then bindingType should be set to BIND_NONE. Otherwise, it - // should be set to the appropriate BIND_* constant, like BIND_VAR or - // BIND_LEXICAL. - // - // If the function is called with a non-BIND_NONE bindingType, then - // additionally a checkClashes object may be specified to allow checking for - // duplicate argument names. checkClashes is ignored if the provided construct - // is an assignment (i.e., bindingType is BIND_NONE). - - pp$7.checkLValSimple = function(expr, bindingType, checkClashes) { - if ( bindingType === void 0 ) bindingType = BIND_NONE; - - var isBind = bindingType !== BIND_NONE; - - switch (expr.type) { - case "Identifier": - if (this.strict && this.reservedWordsStrictBind.test(expr.name)) - { this.raiseRecoverable(expr.start, (isBind ? "Binding " : "Assigning to ") + expr.name + " in strict mode"); } - if (isBind) { - if (bindingType === BIND_LEXICAL && expr.name === "let") - { this.raiseRecoverable(expr.start, "let is disallowed as a lexically bound name"); } - if (checkClashes) { - if (hasOwn(checkClashes, expr.name)) - { this.raiseRecoverable(expr.start, "Argument name clash"); } - checkClashes[expr.name] = true; - } - if (bindingType !== BIND_OUTSIDE) { this.declareName(expr.name, bindingType, expr.start); } - } - break - - case "ChainExpression": - this.raiseRecoverable(expr.start, "Optional chaining cannot appear in left-hand side"); - break - - case "MemberExpression": - if (isBind) { this.raiseRecoverable(expr.start, "Binding member expression"); } - break - - case "ParenthesizedExpression": - if (isBind) { this.raiseRecoverable(expr.start, "Binding parenthesized expression"); } - return this.checkLValSimple(expr.expression, bindingType, checkClashes) - - default: - this.raise(expr.start, (isBind ? "Binding" : "Assigning to") + " rvalue"); - } - }; - - pp$7.checkLValPattern = function(expr, bindingType, checkClashes) { - if ( bindingType === void 0 ) bindingType = BIND_NONE; - - switch (expr.type) { - case "ObjectPattern": - for (var i = 0, list = expr.properties; i < list.length; i += 1) { - var prop = list[i]; - - this.checkLValInnerPattern(prop, bindingType, checkClashes); - } - break - - case "ArrayPattern": - for (var i$1 = 0, list$1 = expr.elements; i$1 < list$1.length; i$1 += 1) { - var elem = list$1[i$1]; - - if (elem) { this.checkLValInnerPattern(elem, bindingType, checkClashes); } - } - break - - default: - this.checkLValSimple(expr, bindingType, checkClashes); - } - }; - - pp$7.checkLValInnerPattern = function(expr, bindingType, checkClashes) { - if ( bindingType === void 0 ) bindingType = BIND_NONE; - - switch (expr.type) { - case "Property": - // AssignmentProperty has type === "Property" - this.checkLValInnerPattern(expr.value, bindingType, checkClashes); - break - - case "AssignmentPattern": - this.checkLValPattern(expr.left, bindingType, checkClashes); - break - - case "RestElement": - this.checkLValPattern(expr.argument, bindingType, checkClashes); - break - - default: - this.checkLValPattern(expr, bindingType, checkClashes); - } - }; - - // The algorithm used to determine whether a regexp can appear at a - // given point in the program is loosely based on sweet.js' approach. - // See https://github.com/mozilla/sweet.js/wiki/design - - - var TokContext = function TokContext(token, isExpr, preserveSpace, override, generator) { - this.token = token; - this.isExpr = !!isExpr; - this.preserveSpace = !!preserveSpace; - this.override = override; - this.generator = !!generator; - }; - - var types = { - b_stat: new TokContext("{", false), - b_expr: new TokContext("{", true), - b_tmpl: new TokContext("${", false), - p_stat: new TokContext("(", false), - p_expr: new TokContext("(", true), - q_tmpl: new TokContext("`", true, true, function (p) { return p.tryReadTemplateToken(); }), - f_stat: new TokContext("function", false), - f_expr: new TokContext("function", true), - f_expr_gen: new TokContext("function", true, false, null, true), - f_gen: new TokContext("function", false, false, null, true) - }; - - var pp$6 = Parser.prototype; - - pp$6.initialContext = function() { - return [types.b_stat] - }; - - pp$6.curContext = function() { - return this.context[this.context.length - 1] - }; - - pp$6.braceIsBlock = function(prevType) { - var parent = this.curContext(); - if (parent === types.f_expr || parent === types.f_stat) - { return true } - if (prevType === types$1.colon && (parent === types.b_stat || parent === types.b_expr)) - { return !parent.isExpr } - - // The check for `tt.name && exprAllowed` detects whether we are - // after a `yield` or `of` construct. See the `updateContext` for - // `tt.name`. - if (prevType === types$1._return || prevType === types$1.name && this.exprAllowed) - { return lineBreak.test(this.input.slice(this.lastTokEnd, this.start)) } - if (prevType === types$1._else || prevType === types$1.semi || prevType === types$1.eof || prevType === types$1.parenR || prevType === types$1.arrow) - { return true } - if (prevType === types$1.braceL) - { return parent === types.b_stat } - if (prevType === types$1._var || prevType === types$1._const || prevType === types$1.name) - { return false } - return !this.exprAllowed - }; - - pp$6.inGeneratorContext = function() { - for (var i = this.context.length - 1; i >= 1; i--) { - var context = this.context[i]; - if (context.token === "function") - { return context.generator } - } - return false - }; - - pp$6.updateContext = function(prevType) { - var update, type = this.type; - if (type.keyword && prevType === types$1.dot) - { this.exprAllowed = false; } - else if (update = type.updateContext) - { update.call(this, prevType); } - else - { this.exprAllowed = type.beforeExpr; } - }; - - // Used to handle edge cases when token context could not be inferred correctly during tokenization phase - - pp$6.overrideContext = function(tokenCtx) { - if (this.curContext() !== tokenCtx) { - this.context[this.context.length - 1] = tokenCtx; - } - }; - - // Token-specific context update code - - types$1.parenR.updateContext = types$1.braceR.updateContext = function() { - if (this.context.length === 1) { - this.exprAllowed = true; - return - } - var out = this.context.pop(); - if (out === types.b_stat && this.curContext().token === "function") { - out = this.context.pop(); - } - this.exprAllowed = !out.isExpr; - }; - - types$1.braceL.updateContext = function(prevType) { - this.context.push(this.braceIsBlock(prevType) ? types.b_stat : types.b_expr); - this.exprAllowed = true; - }; - - types$1.dollarBraceL.updateContext = function() { - this.context.push(types.b_tmpl); - this.exprAllowed = true; - }; - - types$1.parenL.updateContext = function(prevType) { - var statementParens = prevType === types$1._if || prevType === types$1._for || prevType === types$1._with || prevType === types$1._while; - this.context.push(statementParens ? types.p_stat : types.p_expr); - this.exprAllowed = true; - }; - - types$1.incDec.updateContext = function() { - // tokExprAllowed stays unchanged - }; - - types$1._function.updateContext = types$1._class.updateContext = function(prevType) { - if (prevType.beforeExpr && prevType !== types$1._else && - !(prevType === types$1.semi && this.curContext() !== types.p_stat) && - !(prevType === types$1._return && lineBreak.test(this.input.slice(this.lastTokEnd, this.start))) && - !((prevType === types$1.colon || prevType === types$1.braceL) && this.curContext() === types.b_stat)) - { this.context.push(types.f_expr); } - else - { this.context.push(types.f_stat); } - this.exprAllowed = false; - }; - - types$1.colon.updateContext = function() { - if (this.curContext().token === "function") { this.context.pop(); } - this.exprAllowed = true; - }; - - types$1.backQuote.updateContext = function() { - if (this.curContext() === types.q_tmpl) - { this.context.pop(); } - else - { this.context.push(types.q_tmpl); } - this.exprAllowed = false; - }; - - types$1.star.updateContext = function(prevType) { - if (prevType === types$1._function) { - var index = this.context.length - 1; - if (this.context[index] === types.f_expr) - { this.context[index] = types.f_expr_gen; } - else - { this.context[index] = types.f_gen; } - } - this.exprAllowed = true; - }; - - types$1.name.updateContext = function(prevType) { - var allowed = false; - if (this.options.ecmaVersion >= 6 && prevType !== types$1.dot) { - if (this.value === "of" && !this.exprAllowed || - this.value === "yield" && this.inGeneratorContext()) - { allowed = true; } - } - this.exprAllowed = allowed; - }; - - // A recursive descent parser operates by defining functions for all - // syntactic elements, and recursively calling those, each function - // advancing the input stream and returning an AST node. Precedence - // of constructs (for example, the fact that `!x[1]` means `!(x[1])` - // instead of `(!x)[1]` is handled by the fact that the parser - // function that parses unary prefix operators is called first, and - // in turn calls the function that parses `[]` subscripts — that - // way, it'll receive the node for `x[1]` already parsed, and wraps - // *that* in the unary operator node. - // - // Acorn uses an [operator precedence parser][opp] to handle binary - // operator precedence, because it is much more compact than using - // the technique outlined above, which uses different, nesting - // functions to specify precedence, for all of the ten binary - // precedence levels that JavaScript defines. - // - // [opp]: http://en.wikipedia.org/wiki/Operator-precedence_parser - - - var pp$5 = Parser.prototype; - - // Check if property name clashes with already added. - // Object/class getters and setters are not allowed to clash — - // either with each other or with an init property — and in - // strict mode, init properties are also not allowed to be repeated. - - pp$5.checkPropClash = function(prop, propHash, refDestructuringErrors) { - if (this.options.ecmaVersion >= 9 && prop.type === "SpreadElement") - { return } - if (this.options.ecmaVersion >= 6 && (prop.computed || prop.method || prop.shorthand)) - { return } - var key = prop.key; - var name; - switch (key.type) { - case "Identifier": name = key.name; break - case "Literal": name = String(key.value); break - default: return - } - var kind = prop.kind; - if (this.options.ecmaVersion >= 6) { - if (name === "__proto__" && kind === "init") { - if (propHash.proto) { - if (refDestructuringErrors) { - if (refDestructuringErrors.doubleProto < 0) { - refDestructuringErrors.doubleProto = key.start; - } - } else { - this.raiseRecoverable(key.start, "Redefinition of __proto__ property"); - } - } - propHash.proto = true; - } - return - } - name = "$" + name; - var other = propHash[name]; - if (other) { - var redefinition; - if (kind === "init") { - redefinition = this.strict && other.init || other.get || other.set; - } else { - redefinition = other.init || other[kind]; - } - if (redefinition) - { this.raiseRecoverable(key.start, "Redefinition of property"); } - } else { - other = propHash[name] = { - init: false, - get: false, - set: false - }; - } - other[kind] = true; - }; - - // ### Expression parsing - - // These nest, from the most general expression type at the top to - // 'atomic', nondivisible expression types at the bottom. Most of - // the functions will simply let the function(s) below them parse, - // and, *if* the syntactic construct they handle is present, wrap - // the AST node that the inner parser gave them in another node. - - // Parse a full expression. The optional arguments are used to - // forbid the `in` operator (in for loops initalization expressions) - // and provide reference for storing '=' operator inside shorthand - // property assignment in contexts where both object expression - // and object pattern might appear (so it's possible to raise - // delayed syntax error at correct position). - - pp$5.parseExpression = function(forInit, refDestructuringErrors) { - var startPos = this.start, startLoc = this.startLoc; - var expr = this.parseMaybeAssign(forInit, refDestructuringErrors); - if (this.type === types$1.comma) { - var node = this.startNodeAt(startPos, startLoc); - node.expressions = [expr]; - while (this.eat(types$1.comma)) { node.expressions.push(this.parseMaybeAssign(forInit, refDestructuringErrors)); } - return this.finishNode(node, "SequenceExpression") - } - return expr - }; - - // Parse an assignment expression. This includes applications of - // operators like `+=`. - - pp$5.parseMaybeAssign = function(forInit, refDestructuringErrors, afterLeftParse) { - if (this.isContextual("yield")) { - if (this.inGenerator) { return this.parseYield(forInit) } - // The tokenizer will assume an expression is allowed after - // `yield`, but this isn't that kind of yield - else { this.exprAllowed = false; } - } - - var ownDestructuringErrors = false, oldParenAssign = -1, oldTrailingComma = -1, oldDoubleProto = -1; - if (refDestructuringErrors) { - oldParenAssign = refDestructuringErrors.parenthesizedAssign; - oldTrailingComma = refDestructuringErrors.trailingComma; - oldDoubleProto = refDestructuringErrors.doubleProto; - refDestructuringErrors.parenthesizedAssign = refDestructuringErrors.trailingComma = -1; - } else { - refDestructuringErrors = new DestructuringErrors; - ownDestructuringErrors = true; - } - - var startPos = this.start, startLoc = this.startLoc; - if (this.type === types$1.parenL || this.type === types$1.name) { - this.potentialArrowAt = this.start; - this.potentialArrowInForAwait = forInit === "await"; - } - var left = this.parseMaybeConditional(forInit, refDestructuringErrors); - if (afterLeftParse) { left = afterLeftParse.call(this, left, startPos, startLoc); } - if (this.type.isAssign) { - var node = this.startNodeAt(startPos, startLoc); - node.operator = this.value; - if (this.type === types$1.eq) - { left = this.toAssignable(left, false, refDestructuringErrors); } - if (!ownDestructuringErrors) { - refDestructuringErrors.parenthesizedAssign = refDestructuringErrors.trailingComma = refDestructuringErrors.doubleProto = -1; - } - if (refDestructuringErrors.shorthandAssign >= left.start) - { refDestructuringErrors.shorthandAssign = -1; } // reset because shorthand default was used correctly - if (this.type === types$1.eq) - { this.checkLValPattern(left); } - else - { this.checkLValSimple(left); } - node.left = left; - this.next(); - node.right = this.parseMaybeAssign(forInit); - if (oldDoubleProto > -1) { refDestructuringErrors.doubleProto = oldDoubleProto; } - return this.finishNode(node, "AssignmentExpression") - } else { - if (ownDestructuringErrors) { this.checkExpressionErrors(refDestructuringErrors, true); } - } - if (oldParenAssign > -1) { refDestructuringErrors.parenthesizedAssign = oldParenAssign; } - if (oldTrailingComma > -1) { refDestructuringErrors.trailingComma = oldTrailingComma; } - return left - }; - - // Parse a ternary conditional (`?:`) operator. - - pp$5.parseMaybeConditional = function(forInit, refDestructuringErrors) { - var startPos = this.start, startLoc = this.startLoc; - var expr = this.parseExprOps(forInit, refDestructuringErrors); - if (this.checkExpressionErrors(refDestructuringErrors)) { return expr } - if (this.eat(types$1.question)) { - var node = this.startNodeAt(startPos, startLoc); - node.test = expr; - node.consequent = this.parseMaybeAssign(); - this.expect(types$1.colon); - node.alternate = this.parseMaybeAssign(forInit); - return this.finishNode(node, "ConditionalExpression") - } - return expr - }; - - // Start the precedence parser. - - pp$5.parseExprOps = function(forInit, refDestructuringErrors) { - var startPos = this.start, startLoc = this.startLoc; - var expr = this.parseMaybeUnary(refDestructuringErrors, false, false, forInit); - if (this.checkExpressionErrors(refDestructuringErrors)) { return expr } - return expr.start === startPos && expr.type === "ArrowFunctionExpression" ? expr : this.parseExprOp(expr, startPos, startLoc, -1, forInit) - }; - - // Parse binary operators with the operator precedence parsing - // algorithm. `left` is the left-hand side of the operator. - // `minPrec` provides context that allows the function to stop and - // defer further parser to one of its callers when it encounters an - // operator that has a lower precedence than the set it is parsing. - - pp$5.parseExprOp = function(left, leftStartPos, leftStartLoc, minPrec, forInit) { - var prec = this.type.binop; - if (prec != null && (!forInit || this.type !== types$1._in)) { - if (prec > minPrec) { - var logical = this.type === types$1.logicalOR || this.type === types$1.logicalAND; - var coalesce = this.type === types$1.coalesce; - if (coalesce) { - // Handle the precedence of `tt.coalesce` as equal to the range of logical expressions. - // In other words, `node.right` shouldn't contain logical expressions in order to check the mixed error. - prec = types$1.logicalAND.binop; - } - var op = this.value; - this.next(); - var startPos = this.start, startLoc = this.startLoc; - var right = this.parseExprOp(this.parseMaybeUnary(null, false, false, forInit), startPos, startLoc, prec, forInit); - var node = this.buildBinary(leftStartPos, leftStartLoc, left, right, op, logical || coalesce); - if ((logical && this.type === types$1.coalesce) || (coalesce && (this.type === types$1.logicalOR || this.type === types$1.logicalAND))) { - this.raiseRecoverable(this.start, "Logical expressions and coalesce expressions cannot be mixed. Wrap either by parentheses"); - } - return this.parseExprOp(node, leftStartPos, leftStartLoc, minPrec, forInit) - } - } - return left - }; - - pp$5.buildBinary = function(startPos, startLoc, left, right, op, logical) { - if (right.type === "PrivateIdentifier") { this.raise(right.start, "Private identifier can only be left side of binary expression"); } - var node = this.startNodeAt(startPos, startLoc); - node.left = left; - node.operator = op; - node.right = right; - return this.finishNode(node, logical ? "LogicalExpression" : "BinaryExpression") - }; - - // Parse unary operators, both prefix and postfix. - - pp$5.parseMaybeUnary = function(refDestructuringErrors, sawUnary, incDec, forInit) { - var startPos = this.start, startLoc = this.startLoc, expr; - if (this.isContextual("await") && this.canAwait) { - expr = this.parseAwait(forInit); - sawUnary = true; - } else if (this.type.prefix) { - var node = this.startNode(), update = this.type === types$1.incDec; - node.operator = this.value; - node.prefix = true; - this.next(); - node.argument = this.parseMaybeUnary(null, true, update, forInit); - this.checkExpressionErrors(refDestructuringErrors, true); - if (update) { this.checkLValSimple(node.argument); } - else if (this.strict && node.operator === "delete" && - node.argument.type === "Identifier") - { this.raiseRecoverable(node.start, "Deleting local variable in strict mode"); } - else if (node.operator === "delete" && isPrivateFieldAccess(node.argument)) - { this.raiseRecoverable(node.start, "Private fields can not be deleted"); } - else { sawUnary = true; } - expr = this.finishNode(node, update ? "UpdateExpression" : "UnaryExpression"); - } else if (!sawUnary && this.type === types$1.privateId) { - if ((forInit || this.privateNameStack.length === 0) && this.options.checkPrivateFields) { this.unexpected(); } - expr = this.parsePrivateIdent(); - // only could be private fields in 'in', such as #x in obj - if (this.type !== types$1._in) { this.unexpected(); } - } else { - expr = this.parseExprSubscripts(refDestructuringErrors, forInit); - if (this.checkExpressionErrors(refDestructuringErrors)) { return expr } - while (this.type.postfix && !this.canInsertSemicolon()) { - var node$1 = this.startNodeAt(startPos, startLoc); - node$1.operator = this.value; - node$1.prefix = false; - node$1.argument = expr; - this.checkLValSimple(expr); - this.next(); - expr = this.finishNode(node$1, "UpdateExpression"); - } - } - - if (!incDec && this.eat(types$1.starstar)) { - if (sawUnary) - { this.unexpected(this.lastTokStart); } - else - { return this.buildBinary(startPos, startLoc, expr, this.parseMaybeUnary(null, false, false, forInit), "**", false) } - } else { - return expr - } - }; - - function isPrivateFieldAccess(node) { - return ( - node.type === "MemberExpression" && node.property.type === "PrivateIdentifier" || - node.type === "ChainExpression" && isPrivateFieldAccess(node.expression) - ) - } - - // Parse call, dot, and `[]`-subscript expressions. - - pp$5.parseExprSubscripts = function(refDestructuringErrors, forInit) { - var startPos = this.start, startLoc = this.startLoc; - var expr = this.parseExprAtom(refDestructuringErrors, forInit); - if (expr.type === "ArrowFunctionExpression" && this.input.slice(this.lastTokStart, this.lastTokEnd) !== ")") - { return expr } - var result = this.parseSubscripts(expr, startPos, startLoc, false, forInit); - if (refDestructuringErrors && result.type === "MemberExpression") { - if (refDestructuringErrors.parenthesizedAssign >= result.start) { refDestructuringErrors.parenthesizedAssign = -1; } - if (refDestructuringErrors.parenthesizedBind >= result.start) { refDestructuringErrors.parenthesizedBind = -1; } - if (refDestructuringErrors.trailingComma >= result.start) { refDestructuringErrors.trailingComma = -1; } - } - return result - }; - - pp$5.parseSubscripts = function(base, startPos, startLoc, noCalls, forInit) { - var maybeAsyncArrow = this.options.ecmaVersion >= 8 && base.type === "Identifier" && base.name === "async" && - this.lastTokEnd === base.end && !this.canInsertSemicolon() && base.end - base.start === 5 && - this.potentialArrowAt === base.start; - var optionalChained = false; - - while (true) { - var element = this.parseSubscript(base, startPos, startLoc, noCalls, maybeAsyncArrow, optionalChained, forInit); - - if (element.optional) { optionalChained = true; } - if (element === base || element.type === "ArrowFunctionExpression") { - if (optionalChained) { - var chainNode = this.startNodeAt(startPos, startLoc); - chainNode.expression = element; - element = this.finishNode(chainNode, "ChainExpression"); - } - return element - } - - base = element; - } - }; - - pp$5.shouldParseAsyncArrow = function() { - return !this.canInsertSemicolon() && this.eat(types$1.arrow) - }; - - pp$5.parseSubscriptAsyncArrow = function(startPos, startLoc, exprList, forInit) { - return this.parseArrowExpression(this.startNodeAt(startPos, startLoc), exprList, true, forInit) - }; - - pp$5.parseSubscript = function(base, startPos, startLoc, noCalls, maybeAsyncArrow, optionalChained, forInit) { - var optionalSupported = this.options.ecmaVersion >= 11; - var optional = optionalSupported && this.eat(types$1.questionDot); - if (noCalls && optional) { this.raise(this.lastTokStart, "Optional chaining cannot appear in the callee of new expressions"); } - - var computed = this.eat(types$1.bracketL); - if (computed || (optional && this.type !== types$1.parenL && this.type !== types$1.backQuote) || this.eat(types$1.dot)) { - var node = this.startNodeAt(startPos, startLoc); - node.object = base; - if (computed) { - node.property = this.parseExpression(); - this.expect(types$1.bracketR); - } else if (this.type === types$1.privateId && base.type !== "Super") { - node.property = this.parsePrivateIdent(); - } else { - node.property = this.parseIdent(this.options.allowReserved !== "never"); - } - node.computed = !!computed; - if (optionalSupported) { - node.optional = optional; - } - base = this.finishNode(node, "MemberExpression"); - } else if (!noCalls && this.eat(types$1.parenL)) { - var refDestructuringErrors = new DestructuringErrors, oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos, oldAwaitIdentPos = this.awaitIdentPos; - this.yieldPos = 0; - this.awaitPos = 0; - this.awaitIdentPos = 0; - var exprList = this.parseExprList(types$1.parenR, this.options.ecmaVersion >= 8, false, refDestructuringErrors); - if (maybeAsyncArrow && !optional && this.shouldParseAsyncArrow()) { - this.checkPatternErrors(refDestructuringErrors, false); - this.checkYieldAwaitInDefaultParams(); - if (this.awaitIdentPos > 0) - { this.raise(this.awaitIdentPos, "Cannot use 'await' as identifier inside an async function"); } - this.yieldPos = oldYieldPos; - this.awaitPos = oldAwaitPos; - this.awaitIdentPos = oldAwaitIdentPos; - return this.parseSubscriptAsyncArrow(startPos, startLoc, exprList, forInit) - } - this.checkExpressionErrors(refDestructuringErrors, true); - this.yieldPos = oldYieldPos || this.yieldPos; - this.awaitPos = oldAwaitPos || this.awaitPos; - this.awaitIdentPos = oldAwaitIdentPos || this.awaitIdentPos; - var node$1 = this.startNodeAt(startPos, startLoc); - node$1.callee = base; - node$1.arguments = exprList; - if (optionalSupported) { - node$1.optional = optional; - } - base = this.finishNode(node$1, "CallExpression"); - } else if (this.type === types$1.backQuote) { - if (optional || optionalChained) { - this.raise(this.start, "Optional chaining cannot appear in the tag of tagged template expressions"); - } - var node$2 = this.startNodeAt(startPos, startLoc); - node$2.tag = base; - node$2.quasi = this.parseTemplate({isTagged: true}); - base = this.finishNode(node$2, "TaggedTemplateExpression"); - } - return base - }; - - // Parse an atomic expression — either a single token that is an - // expression, an expression started by a keyword like `function` or - // `new`, or an expression wrapped in punctuation like `()`, `[]`, - // or `{}`. - - pp$5.parseExprAtom = function(refDestructuringErrors, forInit, forNew) { - // If a division operator appears in an expression position, the - // tokenizer got confused, and we force it to read a regexp instead. - if (this.type === types$1.slash) { this.readRegexp(); } - - var node, canBeArrow = this.potentialArrowAt === this.start; - switch (this.type) { - case types$1._super: - if (!this.allowSuper) - { this.raise(this.start, "'super' keyword outside a method"); } - node = this.startNode(); - this.next(); - if (this.type === types$1.parenL && !this.allowDirectSuper) - { this.raise(node.start, "super() call outside constructor of a subclass"); } - // The `super` keyword can appear at below: - // SuperProperty: - // super [ Expression ] - // super . IdentifierName - // SuperCall: - // super ( Arguments ) - if (this.type !== types$1.dot && this.type !== types$1.bracketL && this.type !== types$1.parenL) - { this.unexpected(); } - return this.finishNode(node, "Super") - - case types$1._this: - node = this.startNode(); - this.next(); - return this.finishNode(node, "ThisExpression") - - case types$1.name: - var startPos = this.start, startLoc = this.startLoc, containsEsc = this.containsEsc; - var id = this.parseIdent(false); - if (this.options.ecmaVersion >= 8 && !containsEsc && id.name === "async" && !this.canInsertSemicolon() && this.eat(types$1._function)) { - this.overrideContext(types.f_expr); - return this.parseFunction(this.startNodeAt(startPos, startLoc), 0, false, true, forInit) - } - if (canBeArrow && !this.canInsertSemicolon()) { - if (this.eat(types$1.arrow)) - { return this.parseArrowExpression(this.startNodeAt(startPos, startLoc), [id], false, forInit) } - if (this.options.ecmaVersion >= 8 && id.name === "async" && this.type === types$1.name && !containsEsc && - (!this.potentialArrowInForAwait || this.value !== "of" || this.containsEsc)) { - id = this.parseIdent(false); - if (this.canInsertSemicolon() || !this.eat(types$1.arrow)) - { this.unexpected(); } - return this.parseArrowExpression(this.startNodeAt(startPos, startLoc), [id], true, forInit) - } - } - return id - - case types$1.regexp: - var value = this.value; - node = this.parseLiteral(value.value); - node.regex = {pattern: value.pattern, flags: value.flags}; - return node - - case types$1.num: case types$1.string: - return this.parseLiteral(this.value) - - case types$1._null: case types$1._true: case types$1._false: - node = this.startNode(); - node.value = this.type === types$1._null ? null : this.type === types$1._true; - node.raw = this.type.keyword; - this.next(); - return this.finishNode(node, "Literal") - - case types$1.parenL: - var start = this.start, expr = this.parseParenAndDistinguishExpression(canBeArrow, forInit); - if (refDestructuringErrors) { - if (refDestructuringErrors.parenthesizedAssign < 0 && !this.isSimpleAssignTarget(expr)) - { refDestructuringErrors.parenthesizedAssign = start; } - if (refDestructuringErrors.parenthesizedBind < 0) - { refDestructuringErrors.parenthesizedBind = start; } - } - return expr - - case types$1.bracketL: - node = this.startNode(); - this.next(); - node.elements = this.parseExprList(types$1.bracketR, true, true, refDestructuringErrors); - return this.finishNode(node, "ArrayExpression") - - case types$1.braceL: - this.overrideContext(types.b_expr); - return this.parseObj(false, refDestructuringErrors) - - case types$1._function: - node = this.startNode(); - this.next(); - return this.parseFunction(node, 0) - - case types$1._class: - return this.parseClass(this.startNode(), false) - - case types$1._new: - return this.parseNew() - - case types$1.backQuote: - return this.parseTemplate() - - case types$1._import: - if (this.options.ecmaVersion >= 11) { - return this.parseExprImport(forNew) - } else { - return this.unexpected() - } - - default: - return this.parseExprAtomDefault() - } - }; - - pp$5.parseExprAtomDefault = function() { - this.unexpected(); - }; - - pp$5.parseExprImport = function(forNew) { - var node = this.startNode(); - - // Consume `import` as an identifier for `import.meta`. - // Because `this.parseIdent(true)` doesn't check escape sequences, it needs the check of `this.containsEsc`. - if (this.containsEsc) { this.raiseRecoverable(this.start, "Escape sequence in keyword import"); } - this.next(); - - if (this.type === types$1.parenL && !forNew) { - return this.parseDynamicImport(node) - } else if (this.type === types$1.dot) { - var meta = this.startNodeAt(node.start, node.loc && node.loc.start); - meta.name = "import"; - node.meta = this.finishNode(meta, "Identifier"); - return this.parseImportMeta(node) - } else { - this.unexpected(); - } - }; - - pp$5.parseDynamicImport = function(node) { - this.next(); // skip `(` - - // Parse node.source. - node.source = this.parseMaybeAssign(); - - // Verify ending. - if (!this.eat(types$1.parenR)) { - var errorPos = this.start; - if (this.eat(types$1.comma) && this.eat(types$1.parenR)) { - this.raiseRecoverable(errorPos, "Trailing comma is not allowed in import()"); - } else { - this.unexpected(errorPos); - } - } - - return this.finishNode(node, "ImportExpression") - }; - - pp$5.parseImportMeta = function(node) { - this.next(); // skip `.` - - var containsEsc = this.containsEsc; - node.property = this.parseIdent(true); - - if (node.property.name !== "meta") - { this.raiseRecoverable(node.property.start, "The only valid meta property for import is 'import.meta'"); } - if (containsEsc) - { this.raiseRecoverable(node.start, "'import.meta' must not contain escaped characters"); } - if (this.options.sourceType !== "module" && !this.options.allowImportExportEverywhere) - { this.raiseRecoverable(node.start, "Cannot use 'import.meta' outside a module"); } - - return this.finishNode(node, "MetaProperty") - }; - - pp$5.parseLiteral = function(value) { - var node = this.startNode(); - node.value = value; - node.raw = this.input.slice(this.start, this.end); - if (node.raw.charCodeAt(node.raw.length - 1) === 110) { node.bigint = node.raw.slice(0, -1).replace(/_/g, ""); } - this.next(); - return this.finishNode(node, "Literal") - }; - - pp$5.parseParenExpression = function() { - this.expect(types$1.parenL); - var val = this.parseExpression(); - this.expect(types$1.parenR); - return val - }; - - pp$5.shouldParseArrow = function(exprList) { - return !this.canInsertSemicolon() - }; - - pp$5.parseParenAndDistinguishExpression = function(canBeArrow, forInit) { - var startPos = this.start, startLoc = this.startLoc, val, allowTrailingComma = this.options.ecmaVersion >= 8; - if (this.options.ecmaVersion >= 6) { - this.next(); - - var innerStartPos = this.start, innerStartLoc = this.startLoc; - var exprList = [], first = true, lastIsComma = false; - var refDestructuringErrors = new DestructuringErrors, oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos, spreadStart; - this.yieldPos = 0; - this.awaitPos = 0; - // Do not save awaitIdentPos to allow checking awaits nested in parameters - while (this.type !== types$1.parenR) { - first ? first = false : this.expect(types$1.comma); - if (allowTrailingComma && this.afterTrailingComma(types$1.parenR, true)) { - lastIsComma = true; - break - } else if (this.type === types$1.ellipsis) { - spreadStart = this.start; - exprList.push(this.parseParenItem(this.parseRestBinding())); - if (this.type === types$1.comma) { - this.raiseRecoverable( - this.start, - "Comma is not permitted after the rest element" - ); - } - break - } else { - exprList.push(this.parseMaybeAssign(false, refDestructuringErrors, this.parseParenItem)); - } - } - var innerEndPos = this.lastTokEnd, innerEndLoc = this.lastTokEndLoc; - this.expect(types$1.parenR); - - if (canBeArrow && this.shouldParseArrow(exprList) && this.eat(types$1.arrow)) { - this.checkPatternErrors(refDestructuringErrors, false); - this.checkYieldAwaitInDefaultParams(); - this.yieldPos = oldYieldPos; - this.awaitPos = oldAwaitPos; - return this.parseParenArrowList(startPos, startLoc, exprList, forInit) - } - - if (!exprList.length || lastIsComma) { this.unexpected(this.lastTokStart); } - if (spreadStart) { this.unexpected(spreadStart); } - this.checkExpressionErrors(refDestructuringErrors, true); - this.yieldPos = oldYieldPos || this.yieldPos; - this.awaitPos = oldAwaitPos || this.awaitPos; - - if (exprList.length > 1) { - val = this.startNodeAt(innerStartPos, innerStartLoc); - val.expressions = exprList; - this.finishNodeAt(val, "SequenceExpression", innerEndPos, innerEndLoc); - } else { - val = exprList[0]; - } - } else { - val = this.parseParenExpression(); - } - - if (this.options.preserveParens) { - var par = this.startNodeAt(startPos, startLoc); - par.expression = val; - return this.finishNode(par, "ParenthesizedExpression") - } else { - return val - } - }; - - pp$5.parseParenItem = function(item) { - return item - }; - - pp$5.parseParenArrowList = function(startPos, startLoc, exprList, forInit) { - return this.parseArrowExpression(this.startNodeAt(startPos, startLoc), exprList, false, forInit) - }; - - // New's precedence is slightly tricky. It must allow its argument to - // be a `[]` or dot subscript expression, but not a call — at least, - // not without wrapping it in parentheses. Thus, it uses the noCalls - // argument to parseSubscripts to prevent it from consuming the - // argument list. - - var empty = []; - - pp$5.parseNew = function() { - if (this.containsEsc) { this.raiseRecoverable(this.start, "Escape sequence in keyword new"); } - var node = this.startNode(); - this.next(); - if (this.options.ecmaVersion >= 6 && this.type === types$1.dot) { - var meta = this.startNodeAt(node.start, node.loc && node.loc.start); - meta.name = "new"; - node.meta = this.finishNode(meta, "Identifier"); - this.next(); - var containsEsc = this.containsEsc; - node.property = this.parseIdent(true); - if (node.property.name !== "target") - { this.raiseRecoverable(node.property.start, "The only valid meta property for new is 'new.target'"); } - if (containsEsc) - { this.raiseRecoverable(node.start, "'new.target' must not contain escaped characters"); } - if (!this.allowNewDotTarget) - { this.raiseRecoverable(node.start, "'new.target' can only be used in functions and class static block"); } - return this.finishNode(node, "MetaProperty") - } - var startPos = this.start, startLoc = this.startLoc; - node.callee = this.parseSubscripts(this.parseExprAtom(null, false, true), startPos, startLoc, true, false); - if (this.eat(types$1.parenL)) { node.arguments = this.parseExprList(types$1.parenR, this.options.ecmaVersion >= 8, false); } - else { node.arguments = empty; } - return this.finishNode(node, "NewExpression") - }; - - // Parse template expression. - - pp$5.parseTemplateElement = function(ref) { - var isTagged = ref.isTagged; - - var elem = this.startNode(); - if (this.type === types$1.invalidTemplate) { - if (!isTagged) { - this.raiseRecoverable(this.start, "Bad escape sequence in untagged template literal"); - } - elem.value = { - raw: this.value, - cooked: null - }; - } else { - elem.value = { - raw: this.input.slice(this.start, this.end).replace(/\r\n?/g, "\n"), - cooked: this.value - }; - } - this.next(); - elem.tail = this.type === types$1.backQuote; - return this.finishNode(elem, "TemplateElement") - }; - - pp$5.parseTemplate = function(ref) { - if ( ref === void 0 ) ref = {}; - var isTagged = ref.isTagged; if ( isTagged === void 0 ) isTagged = false; - - var node = this.startNode(); - this.next(); - node.expressions = []; - var curElt = this.parseTemplateElement({isTagged: isTagged}); - node.quasis = [curElt]; - while (!curElt.tail) { - if (this.type === types$1.eof) { this.raise(this.pos, "Unterminated template literal"); } - this.expect(types$1.dollarBraceL); - node.expressions.push(this.parseExpression()); - this.expect(types$1.braceR); - node.quasis.push(curElt = this.parseTemplateElement({isTagged: isTagged})); - } - this.next(); - return this.finishNode(node, "TemplateLiteral") - }; - - pp$5.isAsyncProp = function(prop) { - return !prop.computed && prop.key.type === "Identifier" && prop.key.name === "async" && - (this.type === types$1.name || this.type === types$1.num || this.type === types$1.string || this.type === types$1.bracketL || this.type.keyword || (this.options.ecmaVersion >= 9 && this.type === types$1.star)) && - !lineBreak.test(this.input.slice(this.lastTokEnd, this.start)) - }; - - // Parse an object literal or binding pattern. - - pp$5.parseObj = function(isPattern, refDestructuringErrors) { - var node = this.startNode(), first = true, propHash = {}; - node.properties = []; - this.next(); - while (!this.eat(types$1.braceR)) { - if (!first) { - this.expect(types$1.comma); - if (this.options.ecmaVersion >= 5 && this.afterTrailingComma(types$1.braceR)) { break } - } else { first = false; } - - var prop = this.parseProperty(isPattern, refDestructuringErrors); - if (!isPattern) { this.checkPropClash(prop, propHash, refDestructuringErrors); } - node.properties.push(prop); - } - return this.finishNode(node, isPattern ? "ObjectPattern" : "ObjectExpression") - }; - - pp$5.parseProperty = function(isPattern, refDestructuringErrors) { - var prop = this.startNode(), isGenerator, isAsync, startPos, startLoc; - if (this.options.ecmaVersion >= 9 && this.eat(types$1.ellipsis)) { - if (isPattern) { - prop.argument = this.parseIdent(false); - if (this.type === types$1.comma) { - this.raiseRecoverable(this.start, "Comma is not permitted after the rest element"); - } - return this.finishNode(prop, "RestElement") - } - // Parse argument. - prop.argument = this.parseMaybeAssign(false, refDestructuringErrors); - // To disallow trailing comma via `this.toAssignable()`. - if (this.type === types$1.comma && refDestructuringErrors && refDestructuringErrors.trailingComma < 0) { - refDestructuringErrors.trailingComma = this.start; - } - // Finish - return this.finishNode(prop, "SpreadElement") - } - if (this.options.ecmaVersion >= 6) { - prop.method = false; - prop.shorthand = false; - if (isPattern || refDestructuringErrors) { - startPos = this.start; - startLoc = this.startLoc; - } - if (!isPattern) - { isGenerator = this.eat(types$1.star); } - } - var containsEsc = this.containsEsc; - this.parsePropertyName(prop); - if (!isPattern && !containsEsc && this.options.ecmaVersion >= 8 && !isGenerator && this.isAsyncProp(prop)) { - isAsync = true; - isGenerator = this.options.ecmaVersion >= 9 && this.eat(types$1.star); - this.parsePropertyName(prop); - } else { - isAsync = false; - } - this.parsePropertyValue(prop, isPattern, isGenerator, isAsync, startPos, startLoc, refDestructuringErrors, containsEsc); - return this.finishNode(prop, "Property") - }; - - pp$5.parseGetterSetter = function(prop) { - prop.kind = prop.key.name; - this.parsePropertyName(prop); - prop.value = this.parseMethod(false); - var paramCount = prop.kind === "get" ? 0 : 1; - if (prop.value.params.length !== paramCount) { - var start = prop.value.start; - if (prop.kind === "get") - { this.raiseRecoverable(start, "getter should have no params"); } - else - { this.raiseRecoverable(start, "setter should have exactly one param"); } - } else { - if (prop.kind === "set" && prop.value.params[0].type === "RestElement") - { this.raiseRecoverable(prop.value.params[0].start, "Setter cannot use rest params"); } - } - }; - - pp$5.parsePropertyValue = function(prop, isPattern, isGenerator, isAsync, startPos, startLoc, refDestructuringErrors, containsEsc) { - if ((isGenerator || isAsync) && this.type === types$1.colon) - { this.unexpected(); } - - if (this.eat(types$1.colon)) { - prop.value = isPattern ? this.parseMaybeDefault(this.start, this.startLoc) : this.parseMaybeAssign(false, refDestructuringErrors); - prop.kind = "init"; - } else if (this.options.ecmaVersion >= 6 && this.type === types$1.parenL) { - if (isPattern) { this.unexpected(); } - prop.kind = "init"; - prop.method = true; - prop.value = this.parseMethod(isGenerator, isAsync); - } else if (!isPattern && !containsEsc && - this.options.ecmaVersion >= 5 && !prop.computed && prop.key.type === "Identifier" && - (prop.key.name === "get" || prop.key.name === "set") && - (this.type !== types$1.comma && this.type !== types$1.braceR && this.type !== types$1.eq)) { - if (isGenerator || isAsync) { this.unexpected(); } - this.parseGetterSetter(prop); - } else if (this.options.ecmaVersion >= 6 && !prop.computed && prop.key.type === "Identifier") { - if (isGenerator || isAsync) { this.unexpected(); } - this.checkUnreserved(prop.key); - if (prop.key.name === "await" && !this.awaitIdentPos) - { this.awaitIdentPos = startPos; } - prop.kind = "init"; - if (isPattern) { - prop.value = this.parseMaybeDefault(startPos, startLoc, this.copyNode(prop.key)); - } else if (this.type === types$1.eq && refDestructuringErrors) { - if (refDestructuringErrors.shorthandAssign < 0) - { refDestructuringErrors.shorthandAssign = this.start; } - prop.value = this.parseMaybeDefault(startPos, startLoc, this.copyNode(prop.key)); - } else { - prop.value = this.copyNode(prop.key); - } - prop.shorthand = true; - } else { this.unexpected(); } - }; - - pp$5.parsePropertyName = function(prop) { - if (this.options.ecmaVersion >= 6) { - if (this.eat(types$1.bracketL)) { - prop.computed = true; - prop.key = this.parseMaybeAssign(); - this.expect(types$1.bracketR); - return prop.key - } else { - prop.computed = false; - } - } - return prop.key = this.type === types$1.num || this.type === types$1.string ? this.parseExprAtom() : this.parseIdent(this.options.allowReserved !== "never") - }; - - // Initialize empty function node. - - pp$5.initFunction = function(node) { - node.id = null; - if (this.options.ecmaVersion >= 6) { node.generator = node.expression = false; } - if (this.options.ecmaVersion >= 8) { node.async = false; } - }; - - // Parse object or class method. - - pp$5.parseMethod = function(isGenerator, isAsync, allowDirectSuper) { - var node = this.startNode(), oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos, oldAwaitIdentPos = this.awaitIdentPos; - - this.initFunction(node); - if (this.options.ecmaVersion >= 6) - { node.generator = isGenerator; } - if (this.options.ecmaVersion >= 8) - { node.async = !!isAsync; } - - this.yieldPos = 0; - this.awaitPos = 0; - this.awaitIdentPos = 0; - this.enterScope(functionFlags(isAsync, node.generator) | SCOPE_SUPER | (allowDirectSuper ? SCOPE_DIRECT_SUPER : 0)); - - this.expect(types$1.parenL); - node.params = this.parseBindingList(types$1.parenR, false, this.options.ecmaVersion >= 8); - this.checkYieldAwaitInDefaultParams(); - this.parseFunctionBody(node, false, true, false); - - this.yieldPos = oldYieldPos; - this.awaitPos = oldAwaitPos; - this.awaitIdentPos = oldAwaitIdentPos; - return this.finishNode(node, "FunctionExpression") - }; - - // Parse arrow function expression with given parameters. - - pp$5.parseArrowExpression = function(node, params, isAsync, forInit) { - var oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos, oldAwaitIdentPos = this.awaitIdentPos; - - this.enterScope(functionFlags(isAsync, false) | SCOPE_ARROW); - this.initFunction(node); - if (this.options.ecmaVersion >= 8) { node.async = !!isAsync; } - - this.yieldPos = 0; - this.awaitPos = 0; - this.awaitIdentPos = 0; - - node.params = this.toAssignableList(params, true); - this.parseFunctionBody(node, true, false, forInit); - - this.yieldPos = oldYieldPos; - this.awaitPos = oldAwaitPos; - this.awaitIdentPos = oldAwaitIdentPos; - return this.finishNode(node, "ArrowFunctionExpression") - }; - - // Parse function body and check parameters. - - pp$5.parseFunctionBody = function(node, isArrowFunction, isMethod, forInit) { - var isExpression = isArrowFunction && this.type !== types$1.braceL; - var oldStrict = this.strict, useStrict = false; - - if (isExpression) { - node.body = this.parseMaybeAssign(forInit); - node.expression = true; - this.checkParams(node, false); - } else { - var nonSimple = this.options.ecmaVersion >= 7 && !this.isSimpleParamList(node.params); - if (!oldStrict || nonSimple) { - useStrict = this.strictDirective(this.end); - // If this is a strict mode function, verify that argument names - // are not repeated, and it does not try to bind the words `eval` - // or `arguments`. - if (useStrict && nonSimple) - { this.raiseRecoverable(node.start, "Illegal 'use strict' directive in function with non-simple parameter list"); } - } - // Start a new scope with regard to labels and the `inFunction` - // flag (restore them to their old value afterwards). - var oldLabels = this.labels; - this.labels = []; - if (useStrict) { this.strict = true; } - - // Add the params to varDeclaredNames to ensure that an error is thrown - // if a let/const declaration in the function clashes with one of the params. - this.checkParams(node, !oldStrict && !useStrict && !isArrowFunction && !isMethod && this.isSimpleParamList(node.params)); - // Ensure the function name isn't a forbidden identifier in strict mode, e.g. 'eval' - if (this.strict && node.id) { this.checkLValSimple(node.id, BIND_OUTSIDE); } - node.body = this.parseBlock(false, undefined, useStrict && !oldStrict); - node.expression = false; - this.adaptDirectivePrologue(node.body.body); - this.labels = oldLabels; - } - this.exitScope(); - }; - - pp$5.isSimpleParamList = function(params) { - for (var i = 0, list = params; i < list.length; i += 1) - { - var param = list[i]; - - if (param.type !== "Identifier") { return false - } } - return true - }; - - // Checks function params for various disallowed patterns such as using "eval" - // or "arguments" and duplicate parameters. - - pp$5.checkParams = function(node, allowDuplicates) { - var nameHash = Object.create(null); - for (var i = 0, list = node.params; i < list.length; i += 1) - { - var param = list[i]; - - this.checkLValInnerPattern(param, BIND_VAR, allowDuplicates ? null : nameHash); - } - }; - - // Parses a comma-separated list of expressions, and returns them as - // an array. `close` is the token type that ends the list, and - // `allowEmpty` can be turned on to allow subsequent commas with - // nothing in between them to be parsed as `null` (which is needed - // for array literals). - - pp$5.parseExprList = function(close, allowTrailingComma, allowEmpty, refDestructuringErrors) { - var elts = [], first = true; - while (!this.eat(close)) { - if (!first) { - this.expect(types$1.comma); - if (allowTrailingComma && this.afterTrailingComma(close)) { break } - } else { first = false; } - - var elt = (void 0); - if (allowEmpty && this.type === types$1.comma) - { elt = null; } - else if (this.type === types$1.ellipsis) { - elt = this.parseSpread(refDestructuringErrors); - if (refDestructuringErrors && this.type === types$1.comma && refDestructuringErrors.trailingComma < 0) - { refDestructuringErrors.trailingComma = this.start; } - } else { - elt = this.parseMaybeAssign(false, refDestructuringErrors); - } - elts.push(elt); - } - return elts - }; - - pp$5.checkUnreserved = function(ref) { - var start = ref.start; - var end = ref.end; - var name = ref.name; - - if (this.inGenerator && name === "yield") - { this.raiseRecoverable(start, "Cannot use 'yield' as identifier inside a generator"); } - if (this.inAsync && name === "await") - { this.raiseRecoverable(start, "Cannot use 'await' as identifier inside an async function"); } - if (this.currentThisScope().inClassFieldInit && name === "arguments") - { this.raiseRecoverable(start, "Cannot use 'arguments' in class field initializer"); } - if (this.inClassStaticBlock && (name === "arguments" || name === "await")) - { this.raise(start, ("Cannot use " + name + " in class static initialization block")); } - if (this.keywords.test(name)) - { this.raise(start, ("Unexpected keyword '" + name + "'")); } - if (this.options.ecmaVersion < 6 && - this.input.slice(start, end).indexOf("\\") !== -1) { return } - var re = this.strict ? this.reservedWordsStrict : this.reservedWords; - if (re.test(name)) { - if (!this.inAsync && name === "await") - { this.raiseRecoverable(start, "Cannot use keyword 'await' outside an async function"); } - this.raiseRecoverable(start, ("The keyword '" + name + "' is reserved")); - } - }; - - // Parse the next token as an identifier. If `liberal` is true (used - // when parsing properties), it will also convert keywords into - // identifiers. - - pp$5.parseIdent = function(liberal) { - var node = this.parseIdentNode(); - this.next(!!liberal); - this.finishNode(node, "Identifier"); - if (!liberal) { - this.checkUnreserved(node); - if (node.name === "await" && !this.awaitIdentPos) - { this.awaitIdentPos = node.start; } - } - return node - }; - - pp$5.parseIdentNode = function() { - var node = this.startNode(); - if (this.type === types$1.name) { - node.name = this.value; - } else if (this.type.keyword) { - node.name = this.type.keyword; - - // To fix https://github.com/acornjs/acorn/issues/575 - // `class` and `function` keywords push new context into this.context. - // But there is no chance to pop the context if the keyword is consumed as an identifier such as a property name. - // If the previous token is a dot, this does not apply because the context-managing code already ignored the keyword - if ((node.name === "class" || node.name === "function") && - (this.lastTokEnd !== this.lastTokStart + 1 || this.input.charCodeAt(this.lastTokStart) !== 46)) { - this.context.pop(); - } - this.type = types$1.name; - } else { - this.unexpected(); - } - return node - }; - - pp$5.parsePrivateIdent = function() { - var node = this.startNode(); - if (this.type === types$1.privateId) { - node.name = this.value; - } else { - this.unexpected(); - } - this.next(); - this.finishNode(node, "PrivateIdentifier"); - - // For validating existence - if (this.options.checkPrivateFields) { - if (this.privateNameStack.length === 0) { - this.raise(node.start, ("Private field '#" + (node.name) + "' must be declared in an enclosing class")); - } else { - this.privateNameStack[this.privateNameStack.length - 1].used.push(node); - } - } - - return node - }; - - // Parses yield expression inside generator. - - pp$5.parseYield = function(forInit) { - if (!this.yieldPos) { this.yieldPos = this.start; } - - var node = this.startNode(); - this.next(); - if (this.type === types$1.semi || this.canInsertSemicolon() || (this.type !== types$1.star && !this.type.startsExpr)) { - node.delegate = false; - node.argument = null; - } else { - node.delegate = this.eat(types$1.star); - node.argument = this.parseMaybeAssign(forInit); - } - return this.finishNode(node, "YieldExpression") - }; - - pp$5.parseAwait = function(forInit) { - if (!this.awaitPos) { this.awaitPos = this.start; } - - var node = this.startNode(); - this.next(); - node.argument = this.parseMaybeUnary(null, true, false, forInit); - return this.finishNode(node, "AwaitExpression") - }; - - var pp$4 = Parser.prototype; - - // This function is used to raise exceptions on parse errors. It - // takes an offset integer (into the current `input`) to indicate - // the location of the error, attaches the position to the end - // of the error message, and then raises a `SyntaxError` with that - // message. - - pp$4.raise = function(pos, message) { - var loc = getLineInfo(this.input, pos); - message += " (" + loc.line + ":" + loc.column + ")"; - var err = new SyntaxError(message); - err.pos = pos; err.loc = loc; err.raisedAt = this.pos; - throw err - }; - - pp$4.raiseRecoverable = pp$4.raise; - - pp$4.curPosition = function() { - if (this.options.locations) { - return new Position(this.curLine, this.pos - this.lineStart) - } - }; - - var pp$3 = Parser.prototype; - - var Scope = function Scope(flags) { - this.flags = flags; - // A list of var-declared names in the current lexical scope - this.var = []; - // A list of lexically-declared names in the current lexical scope - this.lexical = []; - // A list of lexically-declared FunctionDeclaration names in the current lexical scope - this.functions = []; - // A switch to disallow the identifier reference 'arguments' - this.inClassFieldInit = false; - }; - - // The functions in this module keep track of declared variables in the current scope in order to detect duplicate variable names. - - pp$3.enterScope = function(flags) { - this.scopeStack.push(new Scope(flags)); - }; - - pp$3.exitScope = function() { - this.scopeStack.pop(); - }; - - // The spec says: - // > At the top level of a function, or script, function declarations are - // > treated like var declarations rather than like lexical declarations. - pp$3.treatFunctionsAsVarInScope = function(scope) { - return (scope.flags & SCOPE_FUNCTION) || !this.inModule && (scope.flags & SCOPE_TOP) - }; - - pp$3.declareName = function(name, bindingType, pos) { - var redeclared = false; - if (bindingType === BIND_LEXICAL) { - var scope = this.currentScope(); - redeclared = scope.lexical.indexOf(name) > -1 || scope.functions.indexOf(name) > -1 || scope.var.indexOf(name) > -1; - scope.lexical.push(name); - if (this.inModule && (scope.flags & SCOPE_TOP)) - { delete this.undefinedExports[name]; } - } else if (bindingType === BIND_SIMPLE_CATCH) { - var scope$1 = this.currentScope(); - scope$1.lexical.push(name); - } else if (bindingType === BIND_FUNCTION) { - var scope$2 = this.currentScope(); - if (this.treatFunctionsAsVar) - { redeclared = scope$2.lexical.indexOf(name) > -1; } - else - { redeclared = scope$2.lexical.indexOf(name) > -1 || scope$2.var.indexOf(name) > -1; } - scope$2.functions.push(name); - } else { - for (var i = this.scopeStack.length - 1; i >= 0; --i) { - var scope$3 = this.scopeStack[i]; - if (scope$3.lexical.indexOf(name) > -1 && !((scope$3.flags & SCOPE_SIMPLE_CATCH) && scope$3.lexical[0] === name) || - !this.treatFunctionsAsVarInScope(scope$3) && scope$3.functions.indexOf(name) > -1) { - redeclared = true; - break - } - scope$3.var.push(name); - if (this.inModule && (scope$3.flags & SCOPE_TOP)) - { delete this.undefinedExports[name]; } - if (scope$3.flags & SCOPE_VAR) { break } - } - } - if (redeclared) { this.raiseRecoverable(pos, ("Identifier '" + name + "' has already been declared")); } - }; - - pp$3.checkLocalExport = function(id) { - // scope.functions must be empty as Module code is always strict. - if (this.scopeStack[0].lexical.indexOf(id.name) === -1 && - this.scopeStack[0].var.indexOf(id.name) === -1) { - this.undefinedExports[id.name] = id; - } - }; - - pp$3.currentScope = function() { - return this.scopeStack[this.scopeStack.length - 1] - }; - - pp$3.currentVarScope = function() { - for (var i = this.scopeStack.length - 1;; i--) { - var scope = this.scopeStack[i]; - if (scope.flags & SCOPE_VAR) { return scope } - } - }; - - // Could be useful for `this`, `new.target`, `super()`, `super.property`, and `super[property]`. - pp$3.currentThisScope = function() { - for (var i = this.scopeStack.length - 1;; i--) { - var scope = this.scopeStack[i]; - if (scope.flags & SCOPE_VAR && !(scope.flags & SCOPE_ARROW)) { return scope } - } - }; - - var Node = function Node(parser, pos, loc) { - this.type = ""; - this.start = pos; - this.end = 0; - if (parser.options.locations) - { this.loc = new SourceLocation(parser, loc); } - if (parser.options.directSourceFile) - { this.sourceFile = parser.options.directSourceFile; } - if (parser.options.ranges) - { this.range = [pos, 0]; } - }; - - // Start an AST node, attaching a start offset. - - var pp$2 = Parser.prototype; - - pp$2.startNode = function() { - return new Node(this, this.start, this.startLoc) - }; - - pp$2.startNodeAt = function(pos, loc) { - return new Node(this, pos, loc) - }; - - // Finish an AST node, adding `type` and `end` properties. - - function finishNodeAt(node, type, pos, loc) { - node.type = type; - node.end = pos; - if (this.options.locations) - { node.loc.end = loc; } - if (this.options.ranges) - { node.range[1] = pos; } - return node - } - - pp$2.finishNode = function(node, type) { - return finishNodeAt.call(this, node, type, this.lastTokEnd, this.lastTokEndLoc) - }; - - // Finish node at given position - - pp$2.finishNodeAt = function(node, type, pos, loc) { - return finishNodeAt.call(this, node, type, pos, loc) - }; - - pp$2.copyNode = function(node) { - var newNode = new Node(this, node.start, this.startLoc); - for (var prop in node) { newNode[prop] = node[prop]; } - return newNode - }; - - // This file contains Unicode properties extracted from the ECMAScript specification. - // The lists are extracted like so: - // $$('#table-binary-unicode-properties > figure > table > tbody > tr > td:nth-child(1) code').map(el => el.innerText) - - // #table-binary-unicode-properties - var ecma9BinaryProperties = "ASCII ASCII_Hex_Digit AHex Alphabetic Alpha Any Assigned Bidi_Control Bidi_C Bidi_Mirrored Bidi_M Case_Ignorable CI Cased Changes_When_Casefolded CWCF Changes_When_Casemapped CWCM Changes_When_Lowercased CWL Changes_When_NFKC_Casefolded CWKCF Changes_When_Titlecased CWT Changes_When_Uppercased CWU Dash Default_Ignorable_Code_Point DI Deprecated Dep Diacritic Dia Emoji Emoji_Component Emoji_Modifier Emoji_Modifier_Base Emoji_Presentation Extender Ext Grapheme_Base Gr_Base Grapheme_Extend Gr_Ext Hex_Digit Hex IDS_Binary_Operator IDSB IDS_Trinary_Operator IDST ID_Continue IDC ID_Start IDS Ideographic Ideo Join_Control Join_C Logical_Order_Exception LOE Lowercase Lower Math Noncharacter_Code_Point NChar Pattern_Syntax Pat_Syn Pattern_White_Space Pat_WS Quotation_Mark QMark Radical Regional_Indicator RI Sentence_Terminal STerm Soft_Dotted SD Terminal_Punctuation Term Unified_Ideograph UIdeo Uppercase Upper Variation_Selector VS White_Space space XID_Continue XIDC XID_Start XIDS"; - var ecma10BinaryProperties = ecma9BinaryProperties + " Extended_Pictographic"; - var ecma11BinaryProperties = ecma10BinaryProperties; - var ecma12BinaryProperties = ecma11BinaryProperties + " EBase EComp EMod EPres ExtPict"; - var ecma13BinaryProperties = ecma12BinaryProperties; - var ecma14BinaryProperties = ecma13BinaryProperties; - - var unicodeBinaryProperties = { - 9: ecma9BinaryProperties, - 10: ecma10BinaryProperties, - 11: ecma11BinaryProperties, - 12: ecma12BinaryProperties, - 13: ecma13BinaryProperties, - 14: ecma14BinaryProperties - }; - - // #table-binary-unicode-properties-of-strings - var ecma14BinaryPropertiesOfStrings = "Basic_Emoji Emoji_Keycap_Sequence RGI_Emoji_Modifier_Sequence RGI_Emoji_Flag_Sequence RGI_Emoji_Tag_Sequence RGI_Emoji_ZWJ_Sequence RGI_Emoji"; - - var unicodeBinaryPropertiesOfStrings = { - 9: "", - 10: "", - 11: "", - 12: "", - 13: "", - 14: ecma14BinaryPropertiesOfStrings - }; - - // #table-unicode-general-category-values - var unicodeGeneralCategoryValues = "Cased_Letter LC Close_Punctuation Pe Connector_Punctuation Pc Control Cc cntrl Currency_Symbol Sc Dash_Punctuation Pd Decimal_Number Nd digit Enclosing_Mark Me Final_Punctuation Pf Format Cf Initial_Punctuation Pi Letter L Letter_Number Nl Line_Separator Zl Lowercase_Letter Ll Mark M Combining_Mark Math_Symbol Sm Modifier_Letter Lm Modifier_Symbol Sk Nonspacing_Mark Mn Number N Open_Punctuation Ps Other C Other_Letter Lo Other_Number No Other_Punctuation Po Other_Symbol So Paragraph_Separator Zp Private_Use Co Punctuation P punct Separator Z Space_Separator Zs Spacing_Mark Mc Surrogate Cs Symbol S Titlecase_Letter Lt Unassigned Cn Uppercase_Letter Lu"; - - // #table-unicode-script-values - var ecma9ScriptValues = "Adlam Adlm Ahom Anatolian_Hieroglyphs Hluw Arabic Arab Armenian Armn Avestan Avst Balinese Bali Bamum Bamu Bassa_Vah Bass Batak Batk Bengali Beng Bhaiksuki Bhks Bopomofo Bopo Brahmi Brah Braille Brai Buginese Bugi Buhid Buhd Canadian_Aboriginal Cans Carian Cari Caucasian_Albanian Aghb Chakma Cakm Cham Cham Cherokee Cher Common Zyyy Coptic Copt Qaac Cuneiform Xsux Cypriot Cprt Cyrillic Cyrl Deseret Dsrt Devanagari Deva Duployan Dupl Egyptian_Hieroglyphs Egyp Elbasan Elba Ethiopic Ethi Georgian Geor Glagolitic Glag Gothic Goth Grantha Gran Greek Grek Gujarati Gujr Gurmukhi Guru Han Hani Hangul Hang Hanunoo Hano Hatran Hatr Hebrew Hebr Hiragana Hira Imperial_Aramaic Armi Inherited Zinh Qaai Inscriptional_Pahlavi Phli Inscriptional_Parthian Prti Javanese Java Kaithi Kthi Kannada Knda Katakana Kana Kayah_Li Kali Kharoshthi Khar Khmer Khmr Khojki Khoj Khudawadi Sind Lao Laoo Latin Latn Lepcha Lepc Limbu Limb Linear_A Lina Linear_B Linb Lisu Lisu Lycian Lyci Lydian Lydi Mahajani Mahj Malayalam Mlym Mandaic Mand Manichaean Mani Marchen Marc Masaram_Gondi Gonm Meetei_Mayek Mtei Mende_Kikakui Mend Meroitic_Cursive Merc Meroitic_Hieroglyphs Mero Miao Plrd Modi Mongolian Mong Mro Mroo Multani Mult Myanmar Mymr Nabataean Nbat New_Tai_Lue Talu Newa Newa Nko Nkoo Nushu Nshu Ogham Ogam Ol_Chiki Olck Old_Hungarian Hung Old_Italic Ital Old_North_Arabian Narb Old_Permic Perm Old_Persian Xpeo Old_South_Arabian Sarb Old_Turkic Orkh Oriya Orya Osage Osge Osmanya Osma Pahawh_Hmong Hmng Palmyrene Palm Pau_Cin_Hau Pauc Phags_Pa Phag Phoenician Phnx Psalter_Pahlavi Phlp Rejang Rjng Runic Runr Samaritan Samr Saurashtra Saur Sharada Shrd Shavian Shaw Siddham Sidd SignWriting Sgnw Sinhala Sinh Sora_Sompeng Sora Soyombo Soyo Sundanese Sund Syloti_Nagri Sylo Syriac Syrc Tagalog Tglg Tagbanwa Tagb Tai_Le Tale Tai_Tham Lana Tai_Viet Tavt Takri Takr Tamil Taml Tangut Tang Telugu Telu Thaana Thaa Thai Thai Tibetan Tibt Tifinagh Tfng Tirhuta Tirh Ugaritic Ugar Vai Vaii Warang_Citi Wara Yi Yiii Zanabazar_Square Zanb"; - var ecma10ScriptValues = ecma9ScriptValues + " Dogra Dogr Gunjala_Gondi Gong Hanifi_Rohingya Rohg Makasar Maka Medefaidrin Medf Old_Sogdian Sogo Sogdian Sogd"; - var ecma11ScriptValues = ecma10ScriptValues + " Elymaic Elym Nandinagari Nand Nyiakeng_Puachue_Hmong Hmnp Wancho Wcho"; - var ecma12ScriptValues = ecma11ScriptValues + " Chorasmian Chrs Diak Dives_Akuru Khitan_Small_Script Kits Yezi Yezidi"; - var ecma13ScriptValues = ecma12ScriptValues + " Cypro_Minoan Cpmn Old_Uyghur Ougr Tangsa Tnsa Toto Vithkuqi Vith"; - var ecma14ScriptValues = ecma13ScriptValues + " Hrkt Katakana_Or_Hiragana Kawi Nag_Mundari Nagm Unknown Zzzz"; - - var unicodeScriptValues = { - 9: ecma9ScriptValues, - 10: ecma10ScriptValues, - 11: ecma11ScriptValues, - 12: ecma12ScriptValues, - 13: ecma13ScriptValues, - 14: ecma14ScriptValues - }; - - var data = {}; - function buildUnicodeData(ecmaVersion) { - var d = data[ecmaVersion] = { - binary: wordsRegexp(unicodeBinaryProperties[ecmaVersion] + " " + unicodeGeneralCategoryValues), - binaryOfStrings: wordsRegexp(unicodeBinaryPropertiesOfStrings[ecmaVersion]), - nonBinary: { - General_Category: wordsRegexp(unicodeGeneralCategoryValues), - Script: wordsRegexp(unicodeScriptValues[ecmaVersion]) - } - }; - d.nonBinary.Script_Extensions = d.nonBinary.Script; - - d.nonBinary.gc = d.nonBinary.General_Category; - d.nonBinary.sc = d.nonBinary.Script; - d.nonBinary.scx = d.nonBinary.Script_Extensions; - } - - for (var i = 0, list = [9, 10, 11, 12, 13, 14]; i < list.length; i += 1) { - var ecmaVersion = list[i]; - - buildUnicodeData(ecmaVersion); - } - - var pp$1 = Parser.prototype; - - var RegExpValidationState = function RegExpValidationState(parser) { - this.parser = parser; - this.validFlags = "gim" + (parser.options.ecmaVersion >= 6 ? "uy" : "") + (parser.options.ecmaVersion >= 9 ? "s" : "") + (parser.options.ecmaVersion >= 13 ? "d" : "") + (parser.options.ecmaVersion >= 15 ? "v" : ""); - this.unicodeProperties = data[parser.options.ecmaVersion >= 14 ? 14 : parser.options.ecmaVersion]; - this.source = ""; - this.flags = ""; - this.start = 0; - this.switchU = false; - this.switchV = false; - this.switchN = false; - this.pos = 0; - this.lastIntValue = 0; - this.lastStringValue = ""; - this.lastAssertionIsQuantifiable = false; - this.numCapturingParens = 0; - this.maxBackReference = 0; - this.groupNames = []; - this.backReferenceNames = []; - }; - - RegExpValidationState.prototype.reset = function reset (start, pattern, flags) { - var unicodeSets = flags.indexOf("v") !== -1; - var unicode = flags.indexOf("u") !== -1; - this.start = start | 0; - this.source = pattern + ""; - this.flags = flags; - if (unicodeSets && this.parser.options.ecmaVersion >= 15) { - this.switchU = true; - this.switchV = true; - this.switchN = true; - } else { - this.switchU = unicode && this.parser.options.ecmaVersion >= 6; - this.switchV = false; - this.switchN = unicode && this.parser.options.ecmaVersion >= 9; - } - }; - - RegExpValidationState.prototype.raise = function raise (message) { - this.parser.raiseRecoverable(this.start, ("Invalid regular expression: /" + (this.source) + "/: " + message)); - }; - - // If u flag is given, this returns the code point at the index (it combines a surrogate pair). - // Otherwise, this returns the code unit of the index (can be a part of a surrogate pair). - RegExpValidationState.prototype.at = function at (i, forceU) { - if ( forceU === void 0 ) forceU = false; - - var s = this.source; - var l = s.length; - if (i >= l) { - return -1 - } - var c = s.charCodeAt(i); - if (!(forceU || this.switchU) || c <= 0xD7FF || c >= 0xE000 || i + 1 >= l) { - return c - } - var next = s.charCodeAt(i + 1); - return next >= 0xDC00 && next <= 0xDFFF ? (c << 10) + next - 0x35FDC00 : c - }; - - RegExpValidationState.prototype.nextIndex = function nextIndex (i, forceU) { - if ( forceU === void 0 ) forceU = false; - - var s = this.source; - var l = s.length; - if (i >= l) { - return l - } - var c = s.charCodeAt(i), next; - if (!(forceU || this.switchU) || c <= 0xD7FF || c >= 0xE000 || i + 1 >= l || - (next = s.charCodeAt(i + 1)) < 0xDC00 || next > 0xDFFF) { - return i + 1 - } - return i + 2 - }; - - RegExpValidationState.prototype.current = function current (forceU) { - if ( forceU === void 0 ) forceU = false; - - return this.at(this.pos, forceU) - }; - - RegExpValidationState.prototype.lookahead = function lookahead (forceU) { - if ( forceU === void 0 ) forceU = false; - - return this.at(this.nextIndex(this.pos, forceU), forceU) - }; - - RegExpValidationState.prototype.advance = function advance (forceU) { - if ( forceU === void 0 ) forceU = false; - - this.pos = this.nextIndex(this.pos, forceU); - }; - - RegExpValidationState.prototype.eat = function eat (ch, forceU) { - if ( forceU === void 0 ) forceU = false; - - if (this.current(forceU) === ch) { - this.advance(forceU); - return true - } - return false - }; - - RegExpValidationState.prototype.eatChars = function eatChars (chs, forceU) { - if ( forceU === void 0 ) forceU = false; - - var pos = this.pos; - for (var i = 0, list = chs; i < list.length; i += 1) { - var ch = list[i]; - - var current = this.at(pos, forceU); - if (current === -1 || current !== ch) { - return false - } - pos = this.nextIndex(pos, forceU); - } - this.pos = pos; - return true - }; - - /** - * Validate the flags part of a given RegExpLiteral. - * - * @param {RegExpValidationState} state The state to validate RegExp. - * @returns {void} - */ - pp$1.validateRegExpFlags = function(state) { - var validFlags = state.validFlags; - var flags = state.flags; - - var u = false; - var v = false; - - for (var i = 0; i < flags.length; i++) { - var flag = flags.charAt(i); - if (validFlags.indexOf(flag) === -1) { - this.raise(state.start, "Invalid regular expression flag"); - } - if (flags.indexOf(flag, i + 1) > -1) { - this.raise(state.start, "Duplicate regular expression flag"); - } - if (flag === "u") { u = true; } - if (flag === "v") { v = true; } - } - if (this.options.ecmaVersion >= 15 && u && v) { - this.raise(state.start, "Invalid regular expression flag"); - } - }; - - /** - * Validate the pattern part of a given RegExpLiteral. - * - * @param {RegExpValidationState} state The state to validate RegExp. - * @returns {void} - */ - pp$1.validateRegExpPattern = function(state) { - this.regexp_pattern(state); - - // The goal symbol for the parse is |Pattern[~U, ~N]|. If the result of - // parsing contains a |GroupName|, reparse with the goal symbol - // |Pattern[~U, +N]| and use this result instead. Throw a *SyntaxError* - // exception if _P_ did not conform to the grammar, if any elements of _P_ - // were not matched by the parse, or if any Early Error conditions exist. - if (!state.switchN && this.options.ecmaVersion >= 9 && state.groupNames.length > 0) { - state.switchN = true; - this.regexp_pattern(state); - } - }; - - // https://www.ecma-international.org/ecma-262/8.0/#prod-Pattern - pp$1.regexp_pattern = function(state) { - state.pos = 0; - state.lastIntValue = 0; - state.lastStringValue = ""; - state.lastAssertionIsQuantifiable = false; - state.numCapturingParens = 0; - state.maxBackReference = 0; - state.groupNames.length = 0; - state.backReferenceNames.length = 0; - - this.regexp_disjunction(state); - - if (state.pos !== state.source.length) { - // Make the same messages as V8. - if (state.eat(0x29 /* ) */)) { - state.raise("Unmatched ')'"); - } - if (state.eat(0x5D /* ] */) || state.eat(0x7D /* } */)) { - state.raise("Lone quantifier brackets"); - } - } - if (state.maxBackReference > state.numCapturingParens) { - state.raise("Invalid escape"); - } - for (var i = 0, list = state.backReferenceNames; i < list.length; i += 1) { - var name = list[i]; - - if (state.groupNames.indexOf(name) === -1) { - state.raise("Invalid named capture referenced"); - } - } - }; - - // https://www.ecma-international.org/ecma-262/8.0/#prod-Disjunction - pp$1.regexp_disjunction = function(state) { - this.regexp_alternative(state); - while (state.eat(0x7C /* | */)) { - this.regexp_alternative(state); - } - - // Make the same message as V8. - if (this.regexp_eatQuantifier(state, true)) { - state.raise("Nothing to repeat"); - } - if (state.eat(0x7B /* { */)) { - state.raise("Lone quantifier brackets"); - } - }; - - // https://www.ecma-international.org/ecma-262/8.0/#prod-Alternative - pp$1.regexp_alternative = function(state) { - while (state.pos < state.source.length && this.regexp_eatTerm(state)) - { } - }; - - // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-Term - pp$1.regexp_eatTerm = function(state) { - if (this.regexp_eatAssertion(state)) { - // Handle `QuantifiableAssertion Quantifier` alternative. - // `state.lastAssertionIsQuantifiable` is true if the last eaten Assertion - // is a QuantifiableAssertion. - if (state.lastAssertionIsQuantifiable && this.regexp_eatQuantifier(state)) { - // Make the same message as V8. - if (state.switchU) { - state.raise("Invalid quantifier"); - } - } - return true - } - - if (state.switchU ? this.regexp_eatAtom(state) : this.regexp_eatExtendedAtom(state)) { - this.regexp_eatQuantifier(state); - return true - } - - return false - }; - - // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-Assertion - pp$1.regexp_eatAssertion = function(state) { - var start = state.pos; - state.lastAssertionIsQuantifiable = false; - - // ^, $ - if (state.eat(0x5E /* ^ */) || state.eat(0x24 /* $ */)) { - return true - } - - // \b \B - if (state.eat(0x5C /* \ */)) { - if (state.eat(0x42 /* B */) || state.eat(0x62 /* b */)) { - return true - } - state.pos = start; - } - - // Lookahead / Lookbehind - if (state.eat(0x28 /* ( */) && state.eat(0x3F /* ? */)) { - var lookbehind = false; - if (this.options.ecmaVersion >= 9) { - lookbehind = state.eat(0x3C /* < */); - } - if (state.eat(0x3D /* = */) || state.eat(0x21 /* ! */)) { - this.regexp_disjunction(state); - if (!state.eat(0x29 /* ) */)) { - state.raise("Unterminated group"); - } - state.lastAssertionIsQuantifiable = !lookbehind; - return true - } - } - - state.pos = start; - return false - }; - - // https://www.ecma-international.org/ecma-262/8.0/#prod-Quantifier - pp$1.regexp_eatQuantifier = function(state, noError) { - if ( noError === void 0 ) noError = false; - - if (this.regexp_eatQuantifierPrefix(state, noError)) { - state.eat(0x3F /* ? */); - return true - } - return false - }; - - // https://www.ecma-international.org/ecma-262/8.0/#prod-QuantifierPrefix - pp$1.regexp_eatQuantifierPrefix = function(state, noError) { - return ( - state.eat(0x2A /* * */) || - state.eat(0x2B /* + */) || - state.eat(0x3F /* ? */) || - this.regexp_eatBracedQuantifier(state, noError) - ) - }; - pp$1.regexp_eatBracedQuantifier = function(state, noError) { - var start = state.pos; - if (state.eat(0x7B /* { */)) { - var min = 0, max = -1; - if (this.regexp_eatDecimalDigits(state)) { - min = state.lastIntValue; - if (state.eat(0x2C /* , */) && this.regexp_eatDecimalDigits(state)) { - max = state.lastIntValue; - } - if (state.eat(0x7D /* } */)) { - // SyntaxError in https://www.ecma-international.org/ecma-262/8.0/#sec-term - if (max !== -1 && max < min && !noError) { - state.raise("numbers out of order in {} quantifier"); - } - return true - } - } - if (state.switchU && !noError) { - state.raise("Incomplete quantifier"); - } - state.pos = start; - } - return false - }; - - // https://www.ecma-international.org/ecma-262/8.0/#prod-Atom - pp$1.regexp_eatAtom = function(state) { - return ( - this.regexp_eatPatternCharacters(state) || - state.eat(0x2E /* . */) || - this.regexp_eatReverseSolidusAtomEscape(state) || - this.regexp_eatCharacterClass(state) || - this.regexp_eatUncapturingGroup(state) || - this.regexp_eatCapturingGroup(state) - ) - }; - pp$1.regexp_eatReverseSolidusAtomEscape = function(state) { - var start = state.pos; - if (state.eat(0x5C /* \ */)) { - if (this.regexp_eatAtomEscape(state)) { - return true - } - state.pos = start; - } - return false - }; - pp$1.regexp_eatUncapturingGroup = function(state) { - var start = state.pos; - if (state.eat(0x28 /* ( */)) { - if (state.eat(0x3F /* ? */) && state.eat(0x3A /* : */)) { - this.regexp_disjunction(state); - if (state.eat(0x29 /* ) */)) { - return true - } - state.raise("Unterminated group"); - } - state.pos = start; - } - return false - }; - pp$1.regexp_eatCapturingGroup = function(state) { - if (state.eat(0x28 /* ( */)) { - if (this.options.ecmaVersion >= 9) { - this.regexp_groupSpecifier(state); - } else if (state.current() === 0x3F /* ? */) { - state.raise("Invalid group"); - } - this.regexp_disjunction(state); - if (state.eat(0x29 /* ) */)) { - state.numCapturingParens += 1; - return true - } - state.raise("Unterminated group"); - } - return false - }; - - // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-ExtendedAtom - pp$1.regexp_eatExtendedAtom = function(state) { - return ( - state.eat(0x2E /* . */) || - this.regexp_eatReverseSolidusAtomEscape(state) || - this.regexp_eatCharacterClass(state) || - this.regexp_eatUncapturingGroup(state) || - this.regexp_eatCapturingGroup(state) || - this.regexp_eatInvalidBracedQuantifier(state) || - this.regexp_eatExtendedPatternCharacter(state) - ) - }; - - // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-InvalidBracedQuantifier - pp$1.regexp_eatInvalidBracedQuantifier = function(state) { - if (this.regexp_eatBracedQuantifier(state, true)) { - state.raise("Nothing to repeat"); - } - return false - }; - - // https://www.ecma-international.org/ecma-262/8.0/#prod-SyntaxCharacter - pp$1.regexp_eatSyntaxCharacter = function(state) { - var ch = state.current(); - if (isSyntaxCharacter(ch)) { - state.lastIntValue = ch; - state.advance(); - return true - } - return false - }; - function isSyntaxCharacter(ch) { - return ( - ch === 0x24 /* $ */ || - ch >= 0x28 /* ( */ && ch <= 0x2B /* + */ || - ch === 0x2E /* . */ || - ch === 0x3F /* ? */ || - ch >= 0x5B /* [ */ && ch <= 0x5E /* ^ */ || - ch >= 0x7B /* { */ && ch <= 0x7D /* } */ - ) - } - - // https://www.ecma-international.org/ecma-262/8.0/#prod-PatternCharacter - // But eat eager. - pp$1.regexp_eatPatternCharacters = function(state) { - var start = state.pos; - var ch = 0; - while ((ch = state.current()) !== -1 && !isSyntaxCharacter(ch)) { - state.advance(); - } - return state.pos !== start - }; - - // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-ExtendedPatternCharacter - pp$1.regexp_eatExtendedPatternCharacter = function(state) { - var ch = state.current(); - if ( - ch !== -1 && - ch !== 0x24 /* $ */ && - !(ch >= 0x28 /* ( */ && ch <= 0x2B /* + */) && - ch !== 0x2E /* . */ && - ch !== 0x3F /* ? */ && - ch !== 0x5B /* [ */ && - ch !== 0x5E /* ^ */ && - ch !== 0x7C /* | */ - ) { - state.advance(); - return true - } - return false - }; - - // GroupSpecifier :: - // [empty] - // `?` GroupName - pp$1.regexp_groupSpecifier = function(state) { - if (state.eat(0x3F /* ? */)) { - if (this.regexp_eatGroupName(state)) { - if (state.groupNames.indexOf(state.lastStringValue) !== -1) { - state.raise("Duplicate capture group name"); - } - state.groupNames.push(state.lastStringValue); - return - } - state.raise("Invalid group"); - } - }; - - // GroupName :: - // `<` RegExpIdentifierName `>` - // Note: this updates `state.lastStringValue` property with the eaten name. - pp$1.regexp_eatGroupName = function(state) { - state.lastStringValue = ""; - if (state.eat(0x3C /* < */)) { - if (this.regexp_eatRegExpIdentifierName(state) && state.eat(0x3E /* > */)) { - return true - } - state.raise("Invalid capture group name"); - } - return false - }; - - // RegExpIdentifierName :: - // RegExpIdentifierStart - // RegExpIdentifierName RegExpIdentifierPart - // Note: this updates `state.lastStringValue` property with the eaten name. - pp$1.regexp_eatRegExpIdentifierName = function(state) { - state.lastStringValue = ""; - if (this.regexp_eatRegExpIdentifierStart(state)) { - state.lastStringValue += codePointToString(state.lastIntValue); - while (this.regexp_eatRegExpIdentifierPart(state)) { - state.lastStringValue += codePointToString(state.lastIntValue); - } - return true - } - return false - }; - - // RegExpIdentifierStart :: - // UnicodeIDStart - // `$` - // `_` - // `\` RegExpUnicodeEscapeSequence[+U] - pp$1.regexp_eatRegExpIdentifierStart = function(state) { - var start = state.pos; - var forceU = this.options.ecmaVersion >= 11; - var ch = state.current(forceU); - state.advance(forceU); - - if (ch === 0x5C /* \ */ && this.regexp_eatRegExpUnicodeEscapeSequence(state, forceU)) { - ch = state.lastIntValue; - } - if (isRegExpIdentifierStart(ch)) { - state.lastIntValue = ch; - return true - } - - state.pos = start; - return false - }; - function isRegExpIdentifierStart(ch) { - return isIdentifierStart(ch, true) || ch === 0x24 /* $ */ || ch === 0x5F /* _ */ - } - - // RegExpIdentifierPart :: - // UnicodeIDContinue - // `$` - // `_` - // `\` RegExpUnicodeEscapeSequence[+U] - // - // - pp$1.regexp_eatRegExpIdentifierPart = function(state) { - var start = state.pos; - var forceU = this.options.ecmaVersion >= 11; - var ch = state.current(forceU); - state.advance(forceU); - - if (ch === 0x5C /* \ */ && this.regexp_eatRegExpUnicodeEscapeSequence(state, forceU)) { - ch = state.lastIntValue; - } - if (isRegExpIdentifierPart(ch)) { - state.lastIntValue = ch; - return true - } - - state.pos = start; - return false - }; - function isRegExpIdentifierPart(ch) { - return isIdentifierChar(ch, true) || ch === 0x24 /* $ */ || ch === 0x5F /* _ */ || ch === 0x200C /* */ || ch === 0x200D /* */ - } - - // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-AtomEscape - pp$1.regexp_eatAtomEscape = function(state) { - if ( - this.regexp_eatBackReference(state) || - this.regexp_eatCharacterClassEscape(state) || - this.regexp_eatCharacterEscape(state) || - (state.switchN && this.regexp_eatKGroupName(state)) - ) { - return true - } - if (state.switchU) { - // Make the same message as V8. - if (state.current() === 0x63 /* c */) { - state.raise("Invalid unicode escape"); - } - state.raise("Invalid escape"); - } - return false - }; - pp$1.regexp_eatBackReference = function(state) { - var start = state.pos; - if (this.regexp_eatDecimalEscape(state)) { - var n = state.lastIntValue; - if (state.switchU) { - // For SyntaxError in https://www.ecma-international.org/ecma-262/8.0/#sec-atomescape - if (n > state.maxBackReference) { - state.maxBackReference = n; - } - return true - } - if (n <= state.numCapturingParens) { - return true - } - state.pos = start; - } - return false - }; - pp$1.regexp_eatKGroupName = function(state) { - if (state.eat(0x6B /* k */)) { - if (this.regexp_eatGroupName(state)) { - state.backReferenceNames.push(state.lastStringValue); - return true - } - state.raise("Invalid named reference"); - } - return false - }; - - // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-CharacterEscape - pp$1.regexp_eatCharacterEscape = function(state) { - return ( - this.regexp_eatControlEscape(state) || - this.regexp_eatCControlLetter(state) || - this.regexp_eatZero(state) || - this.regexp_eatHexEscapeSequence(state) || - this.regexp_eatRegExpUnicodeEscapeSequence(state, false) || - (!state.switchU && this.regexp_eatLegacyOctalEscapeSequence(state)) || - this.regexp_eatIdentityEscape(state) - ) - }; - pp$1.regexp_eatCControlLetter = function(state) { - var start = state.pos; - if (state.eat(0x63 /* c */)) { - if (this.regexp_eatControlLetter(state)) { - return true - } - state.pos = start; - } - return false - }; - pp$1.regexp_eatZero = function(state) { - if (state.current() === 0x30 /* 0 */ && !isDecimalDigit(state.lookahead())) { - state.lastIntValue = 0; - state.advance(); - return true - } - return false - }; - - // https://www.ecma-international.org/ecma-262/8.0/#prod-ControlEscape - pp$1.regexp_eatControlEscape = function(state) { - var ch = state.current(); - if (ch === 0x74 /* t */) { - state.lastIntValue = 0x09; /* \t */ - state.advance(); - return true - } - if (ch === 0x6E /* n */) { - state.lastIntValue = 0x0A; /* \n */ - state.advance(); - return true - } - if (ch === 0x76 /* v */) { - state.lastIntValue = 0x0B; /* \v */ - state.advance(); - return true - } - if (ch === 0x66 /* f */) { - state.lastIntValue = 0x0C; /* \f */ - state.advance(); - return true - } - if (ch === 0x72 /* r */) { - state.lastIntValue = 0x0D; /* \r */ - state.advance(); - return true - } - return false - }; - - // https://www.ecma-international.org/ecma-262/8.0/#prod-ControlLetter - pp$1.regexp_eatControlLetter = function(state) { - var ch = state.current(); - if (isControlLetter(ch)) { - state.lastIntValue = ch % 0x20; - state.advance(); - return true - } - return false - }; - function isControlLetter(ch) { - return ( - (ch >= 0x41 /* A */ && ch <= 0x5A /* Z */) || - (ch >= 0x61 /* a */ && ch <= 0x7A /* z */) - ) - } - - // https://www.ecma-international.org/ecma-262/8.0/#prod-RegExpUnicodeEscapeSequence - pp$1.regexp_eatRegExpUnicodeEscapeSequence = function(state, forceU) { - if ( forceU === void 0 ) forceU = false; - - var start = state.pos; - var switchU = forceU || state.switchU; - - if (state.eat(0x75 /* u */)) { - if (this.regexp_eatFixedHexDigits(state, 4)) { - var lead = state.lastIntValue; - if (switchU && lead >= 0xD800 && lead <= 0xDBFF) { - var leadSurrogateEnd = state.pos; - if (state.eat(0x5C /* \ */) && state.eat(0x75 /* u */) && this.regexp_eatFixedHexDigits(state, 4)) { - var trail = state.lastIntValue; - if (trail >= 0xDC00 && trail <= 0xDFFF) { - state.lastIntValue = (lead - 0xD800) * 0x400 + (trail - 0xDC00) + 0x10000; - return true - } - } - state.pos = leadSurrogateEnd; - state.lastIntValue = lead; - } - return true - } - if ( - switchU && - state.eat(0x7B /* { */) && - this.regexp_eatHexDigits(state) && - state.eat(0x7D /* } */) && - isValidUnicode(state.lastIntValue) - ) { - return true - } - if (switchU) { - state.raise("Invalid unicode escape"); - } - state.pos = start; - } - - return false - }; - function isValidUnicode(ch) { - return ch >= 0 && ch <= 0x10FFFF - } - - // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-IdentityEscape - pp$1.regexp_eatIdentityEscape = function(state) { - if (state.switchU) { - if (this.regexp_eatSyntaxCharacter(state)) { - return true - } - if (state.eat(0x2F /* / */)) { - state.lastIntValue = 0x2F; /* / */ - return true - } - return false - } - - var ch = state.current(); - if (ch !== 0x63 /* c */ && (!state.switchN || ch !== 0x6B /* k */)) { - state.lastIntValue = ch; - state.advance(); - return true - } - - return false - }; - - // https://www.ecma-international.org/ecma-262/8.0/#prod-DecimalEscape - pp$1.regexp_eatDecimalEscape = function(state) { - state.lastIntValue = 0; - var ch = state.current(); - if (ch >= 0x31 /* 1 */ && ch <= 0x39 /* 9 */) { - do { - state.lastIntValue = 10 * state.lastIntValue + (ch - 0x30 /* 0 */); - state.advance(); - } while ((ch = state.current()) >= 0x30 /* 0 */ && ch <= 0x39 /* 9 */) - return true - } - return false - }; - - // Return values used by character set parsing methods, needed to - // forbid negation of sets that can match strings. - var CharSetNone = 0; // Nothing parsed - var CharSetOk = 1; // Construct parsed, cannot contain strings - var CharSetString = 2; // Construct parsed, can contain strings - - // https://www.ecma-international.org/ecma-262/8.0/#prod-CharacterClassEscape - pp$1.regexp_eatCharacterClassEscape = function(state) { - var ch = state.current(); - - if (isCharacterClassEscape(ch)) { - state.lastIntValue = -1; - state.advance(); - return CharSetOk - } - - var negate = false; - if ( - state.switchU && - this.options.ecmaVersion >= 9 && - ((negate = ch === 0x50 /* P */) || ch === 0x70 /* p */) - ) { - state.lastIntValue = -1; - state.advance(); - var result; - if ( - state.eat(0x7B /* { */) && - (result = this.regexp_eatUnicodePropertyValueExpression(state)) && - state.eat(0x7D /* } */) - ) { - if (negate && result === CharSetString) { state.raise("Invalid property name"); } - return result - } - state.raise("Invalid property name"); - } - - return CharSetNone - }; - - function isCharacterClassEscape(ch) { - return ( - ch === 0x64 /* d */ || - ch === 0x44 /* D */ || - ch === 0x73 /* s */ || - ch === 0x53 /* S */ || - ch === 0x77 /* w */ || - ch === 0x57 /* W */ - ) - } - - // UnicodePropertyValueExpression :: - // UnicodePropertyName `=` UnicodePropertyValue - // LoneUnicodePropertyNameOrValue - pp$1.regexp_eatUnicodePropertyValueExpression = function(state) { - var start = state.pos; - - // UnicodePropertyName `=` UnicodePropertyValue - if (this.regexp_eatUnicodePropertyName(state) && state.eat(0x3D /* = */)) { - var name = state.lastStringValue; - if (this.regexp_eatUnicodePropertyValue(state)) { - var value = state.lastStringValue; - this.regexp_validateUnicodePropertyNameAndValue(state, name, value); - return CharSetOk - } - } - state.pos = start; - - // LoneUnicodePropertyNameOrValue - if (this.regexp_eatLoneUnicodePropertyNameOrValue(state)) { - var nameOrValue = state.lastStringValue; - return this.regexp_validateUnicodePropertyNameOrValue(state, nameOrValue) - } - return CharSetNone - }; - - pp$1.regexp_validateUnicodePropertyNameAndValue = function(state, name, value) { - if (!hasOwn(state.unicodeProperties.nonBinary, name)) - { state.raise("Invalid property name"); } - if (!state.unicodeProperties.nonBinary[name].test(value)) - { state.raise("Invalid property value"); } - }; - - pp$1.regexp_validateUnicodePropertyNameOrValue = function(state, nameOrValue) { - if (state.unicodeProperties.binary.test(nameOrValue)) { return CharSetOk } - if (state.switchV && state.unicodeProperties.binaryOfStrings.test(nameOrValue)) { return CharSetString } - state.raise("Invalid property name"); - }; - - // UnicodePropertyName :: - // UnicodePropertyNameCharacters - pp$1.regexp_eatUnicodePropertyName = function(state) { - var ch = 0; - state.lastStringValue = ""; - while (isUnicodePropertyNameCharacter(ch = state.current())) { - state.lastStringValue += codePointToString(ch); - state.advance(); - } - return state.lastStringValue !== "" - }; - - function isUnicodePropertyNameCharacter(ch) { - return isControlLetter(ch) || ch === 0x5F /* _ */ - } - - // UnicodePropertyValue :: - // UnicodePropertyValueCharacters - pp$1.regexp_eatUnicodePropertyValue = function(state) { - var ch = 0; - state.lastStringValue = ""; - while (isUnicodePropertyValueCharacter(ch = state.current())) { - state.lastStringValue += codePointToString(ch); - state.advance(); - } - return state.lastStringValue !== "" - }; - function isUnicodePropertyValueCharacter(ch) { - return isUnicodePropertyNameCharacter(ch) || isDecimalDigit(ch) - } - - // LoneUnicodePropertyNameOrValue :: - // UnicodePropertyValueCharacters - pp$1.regexp_eatLoneUnicodePropertyNameOrValue = function(state) { - return this.regexp_eatUnicodePropertyValue(state) - }; - - // https://www.ecma-international.org/ecma-262/8.0/#prod-CharacterClass - pp$1.regexp_eatCharacterClass = function(state) { - if (state.eat(0x5B /* [ */)) { - var negate = state.eat(0x5E /* ^ */); - var result = this.regexp_classContents(state); - if (!state.eat(0x5D /* ] */)) - { state.raise("Unterminated character class"); } - if (negate && result === CharSetString) - { state.raise("Negated character class may contain strings"); } - return true - } - return false - }; - - // https://tc39.es/ecma262/#prod-ClassContents - // https://www.ecma-international.org/ecma-262/8.0/#prod-ClassRanges - pp$1.regexp_classContents = function(state) { - if (state.current() === 0x5D /* ] */) { return CharSetOk } - if (state.switchV) { return this.regexp_classSetExpression(state) } - this.regexp_nonEmptyClassRanges(state); - return CharSetOk - }; - - // https://www.ecma-international.org/ecma-262/8.0/#prod-NonemptyClassRanges - // https://www.ecma-international.org/ecma-262/8.0/#prod-NonemptyClassRangesNoDash - pp$1.regexp_nonEmptyClassRanges = function(state) { - while (this.regexp_eatClassAtom(state)) { - var left = state.lastIntValue; - if (state.eat(0x2D /* - */) && this.regexp_eatClassAtom(state)) { - var right = state.lastIntValue; - if (state.switchU && (left === -1 || right === -1)) { - state.raise("Invalid character class"); - } - if (left !== -1 && right !== -1 && left > right) { - state.raise("Range out of order in character class"); - } - } - } - }; - - // https://www.ecma-international.org/ecma-262/8.0/#prod-ClassAtom - // https://www.ecma-international.org/ecma-262/8.0/#prod-ClassAtomNoDash - pp$1.regexp_eatClassAtom = function(state) { - var start = state.pos; - - if (state.eat(0x5C /* \ */)) { - if (this.regexp_eatClassEscape(state)) { - return true - } - if (state.switchU) { - // Make the same message as V8. - var ch$1 = state.current(); - if (ch$1 === 0x63 /* c */ || isOctalDigit(ch$1)) { - state.raise("Invalid class escape"); - } - state.raise("Invalid escape"); - } - state.pos = start; - } - - var ch = state.current(); - if (ch !== 0x5D /* ] */) { - state.lastIntValue = ch; - state.advance(); - return true - } - - return false - }; - - // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-ClassEscape - pp$1.regexp_eatClassEscape = function(state) { - var start = state.pos; - - if (state.eat(0x62 /* b */)) { - state.lastIntValue = 0x08; /* */ - return true - } - - if (state.switchU && state.eat(0x2D /* - */)) { - state.lastIntValue = 0x2D; /* - */ - return true - } - - if (!state.switchU && state.eat(0x63 /* c */)) { - if (this.regexp_eatClassControlLetter(state)) { - return true - } - state.pos = start; - } - - return ( - this.regexp_eatCharacterClassEscape(state) || - this.regexp_eatCharacterEscape(state) - ) - }; - - // https://tc39.es/ecma262/#prod-ClassSetExpression - // https://tc39.es/ecma262/#prod-ClassUnion - // https://tc39.es/ecma262/#prod-ClassIntersection - // https://tc39.es/ecma262/#prod-ClassSubtraction - pp$1.regexp_classSetExpression = function(state) { - var result = CharSetOk, subResult; - if (this.regexp_eatClassSetRange(state)) ; else if (subResult = this.regexp_eatClassSetOperand(state)) { - if (subResult === CharSetString) { result = CharSetString; } - // https://tc39.es/ecma262/#prod-ClassIntersection - var start = state.pos; - while (state.eatChars([0x26, 0x26] /* && */)) { - if ( - state.current() !== 0x26 /* & */ && - (subResult = this.regexp_eatClassSetOperand(state)) - ) { - if (subResult !== CharSetString) { result = CharSetOk; } - continue - } - state.raise("Invalid character in character class"); - } - if (start !== state.pos) { return result } - // https://tc39.es/ecma262/#prod-ClassSubtraction - while (state.eatChars([0x2D, 0x2D] /* -- */)) { - if (this.regexp_eatClassSetOperand(state)) { continue } - state.raise("Invalid character in character class"); - } - if (start !== state.pos) { return result } - } else { - state.raise("Invalid character in character class"); - } - // https://tc39.es/ecma262/#prod-ClassUnion - for (;;) { - if (this.regexp_eatClassSetRange(state)) { continue } - subResult = this.regexp_eatClassSetOperand(state); - if (!subResult) { return result } - if (subResult === CharSetString) { result = CharSetString; } - } - }; - - // https://tc39.es/ecma262/#prod-ClassSetRange - pp$1.regexp_eatClassSetRange = function(state) { - var start = state.pos; - if (this.regexp_eatClassSetCharacter(state)) { - var left = state.lastIntValue; - if (state.eat(0x2D /* - */) && this.regexp_eatClassSetCharacter(state)) { - var right = state.lastIntValue; - if (left !== -1 && right !== -1 && left > right) { - state.raise("Range out of order in character class"); - } - return true - } - state.pos = start; - } - return false - }; - - // https://tc39.es/ecma262/#prod-ClassSetOperand - pp$1.regexp_eatClassSetOperand = function(state) { - if (this.regexp_eatClassSetCharacter(state)) { return CharSetOk } - return this.regexp_eatClassStringDisjunction(state) || this.regexp_eatNestedClass(state) - }; - - // https://tc39.es/ecma262/#prod-NestedClass - pp$1.regexp_eatNestedClass = function(state) { - var start = state.pos; - if (state.eat(0x5B /* [ */)) { - var negate = state.eat(0x5E /* ^ */); - var result = this.regexp_classContents(state); - if (state.eat(0x5D /* ] */)) { - if (negate && result === CharSetString) { - state.raise("Negated character class may contain strings"); - } - return result - } - state.pos = start; - } - if (state.eat(0x5C /* \ */)) { - var result$1 = this.regexp_eatCharacterClassEscape(state); - if (result$1) { - return result$1 - } - state.pos = start; - } - return null - }; - - // https://tc39.es/ecma262/#prod-ClassStringDisjunction - pp$1.regexp_eatClassStringDisjunction = function(state) { - var start = state.pos; - if (state.eatChars([0x5C, 0x71] /* \q */)) { - if (state.eat(0x7B /* { */)) { - var result = this.regexp_classStringDisjunctionContents(state); - if (state.eat(0x7D /* } */)) { - return result - } - } else { - // Make the same message as V8. - state.raise("Invalid escape"); - } - state.pos = start; - } - return null - }; - - // https://tc39.es/ecma262/#prod-ClassStringDisjunctionContents - pp$1.regexp_classStringDisjunctionContents = function(state) { - var result = this.regexp_classString(state); - while (state.eat(0x7C /* | */)) { - if (this.regexp_classString(state) === CharSetString) { result = CharSetString; } - } - return result - }; - - // https://tc39.es/ecma262/#prod-ClassString - // https://tc39.es/ecma262/#prod-NonEmptyClassString - pp$1.regexp_classString = function(state) { - var count = 0; - while (this.regexp_eatClassSetCharacter(state)) { count++; } - return count === 1 ? CharSetOk : CharSetString - }; - - // https://tc39.es/ecma262/#prod-ClassSetCharacter - pp$1.regexp_eatClassSetCharacter = function(state) { - var start = state.pos; - if (state.eat(0x5C /* \ */)) { - if ( - this.regexp_eatCharacterEscape(state) || - this.regexp_eatClassSetReservedPunctuator(state) - ) { - return true - } - if (state.eat(0x62 /* b */)) { - state.lastIntValue = 0x08; /* */ - return true - } - state.pos = start; - return false - } - var ch = state.current(); - if (ch < 0 || ch === state.lookahead() && isClassSetReservedDoublePunctuatorCharacter(ch)) { return false } - if (isClassSetSyntaxCharacter(ch)) { return false } - state.advance(); - state.lastIntValue = ch; - return true - }; - - // https://tc39.es/ecma262/#prod-ClassSetReservedDoublePunctuator - function isClassSetReservedDoublePunctuatorCharacter(ch) { - return ( - ch === 0x21 /* ! */ || - ch >= 0x23 /* # */ && ch <= 0x26 /* & */ || - ch >= 0x2A /* * */ && ch <= 0x2C /* , */ || - ch === 0x2E /* . */ || - ch >= 0x3A /* : */ && ch <= 0x40 /* @ */ || - ch === 0x5E /* ^ */ || - ch === 0x60 /* ` */ || - ch === 0x7E /* ~ */ - ) - } - - // https://tc39.es/ecma262/#prod-ClassSetSyntaxCharacter - function isClassSetSyntaxCharacter(ch) { - return ( - ch === 0x28 /* ( */ || - ch === 0x29 /* ) */ || - ch === 0x2D /* - */ || - ch === 0x2F /* / */ || - ch >= 0x5B /* [ */ && ch <= 0x5D /* ] */ || - ch >= 0x7B /* { */ && ch <= 0x7D /* } */ - ) - } - - // https://tc39.es/ecma262/#prod-ClassSetReservedPunctuator - pp$1.regexp_eatClassSetReservedPunctuator = function(state) { - var ch = state.current(); - if (isClassSetReservedPunctuator(ch)) { - state.lastIntValue = ch; - state.advance(); - return true - } - return false - }; - - // https://tc39.es/ecma262/#prod-ClassSetReservedPunctuator - function isClassSetReservedPunctuator(ch) { - return ( - ch === 0x21 /* ! */ || - ch === 0x23 /* # */ || - ch === 0x25 /* % */ || - ch === 0x26 /* & */ || - ch === 0x2C /* , */ || - ch === 0x2D /* - */ || - ch >= 0x3A /* : */ && ch <= 0x3E /* > */ || - ch === 0x40 /* @ */ || - ch === 0x60 /* ` */ || - ch === 0x7E /* ~ */ - ) - } - - // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-ClassControlLetter - pp$1.regexp_eatClassControlLetter = function(state) { - var ch = state.current(); - if (isDecimalDigit(ch) || ch === 0x5F /* _ */) { - state.lastIntValue = ch % 0x20; - state.advance(); - return true - } - return false - }; - - // https://www.ecma-international.org/ecma-262/8.0/#prod-HexEscapeSequence - pp$1.regexp_eatHexEscapeSequence = function(state) { - var start = state.pos; - if (state.eat(0x78 /* x */)) { - if (this.regexp_eatFixedHexDigits(state, 2)) { - return true - } - if (state.switchU) { - state.raise("Invalid escape"); - } - state.pos = start; - } - return false - }; - - // https://www.ecma-international.org/ecma-262/8.0/#prod-DecimalDigits - pp$1.regexp_eatDecimalDigits = function(state) { - var start = state.pos; - var ch = 0; - state.lastIntValue = 0; - while (isDecimalDigit(ch = state.current())) { - state.lastIntValue = 10 * state.lastIntValue + (ch - 0x30 /* 0 */); - state.advance(); - } - return state.pos !== start - }; - function isDecimalDigit(ch) { - return ch >= 0x30 /* 0 */ && ch <= 0x39 /* 9 */ - } - - // https://www.ecma-international.org/ecma-262/8.0/#prod-HexDigits - pp$1.regexp_eatHexDigits = function(state) { - var start = state.pos; - var ch = 0; - state.lastIntValue = 0; - while (isHexDigit(ch = state.current())) { - state.lastIntValue = 16 * state.lastIntValue + hexToInt(ch); - state.advance(); - } - return state.pos !== start - }; - function isHexDigit(ch) { - return ( - (ch >= 0x30 /* 0 */ && ch <= 0x39 /* 9 */) || - (ch >= 0x41 /* A */ && ch <= 0x46 /* F */) || - (ch >= 0x61 /* a */ && ch <= 0x66 /* f */) - ) - } - function hexToInt(ch) { - if (ch >= 0x41 /* A */ && ch <= 0x46 /* F */) { - return 10 + (ch - 0x41 /* A */) - } - if (ch >= 0x61 /* a */ && ch <= 0x66 /* f */) { - return 10 + (ch - 0x61 /* a */) - } - return ch - 0x30 /* 0 */ - } - - // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-LegacyOctalEscapeSequence - // Allows only 0-377(octal) i.e. 0-255(decimal). - pp$1.regexp_eatLegacyOctalEscapeSequence = function(state) { - if (this.regexp_eatOctalDigit(state)) { - var n1 = state.lastIntValue; - if (this.regexp_eatOctalDigit(state)) { - var n2 = state.lastIntValue; - if (n1 <= 3 && this.regexp_eatOctalDigit(state)) { - state.lastIntValue = n1 * 64 + n2 * 8 + state.lastIntValue; - } else { - state.lastIntValue = n1 * 8 + n2; - } - } else { - state.lastIntValue = n1; - } - return true - } - return false - }; - - // https://www.ecma-international.org/ecma-262/8.0/#prod-OctalDigit - pp$1.regexp_eatOctalDigit = function(state) { - var ch = state.current(); - if (isOctalDigit(ch)) { - state.lastIntValue = ch - 0x30; /* 0 */ - state.advance(); - return true - } - state.lastIntValue = 0; - return false - }; - function isOctalDigit(ch) { - return ch >= 0x30 /* 0 */ && ch <= 0x37 /* 7 */ - } - - // https://www.ecma-international.org/ecma-262/8.0/#prod-Hex4Digits - // https://www.ecma-international.org/ecma-262/8.0/#prod-HexDigit - // And HexDigit HexDigit in https://www.ecma-international.org/ecma-262/8.0/#prod-HexEscapeSequence - pp$1.regexp_eatFixedHexDigits = function(state, length) { - var start = state.pos; - state.lastIntValue = 0; - for (var i = 0; i < length; ++i) { - var ch = state.current(); - if (!isHexDigit(ch)) { - state.pos = start; - return false - } - state.lastIntValue = 16 * state.lastIntValue + hexToInt(ch); - state.advance(); - } - return true - }; - - // Object type used to represent tokens. Note that normally, tokens - // simply exist as properties on the parser object. This is only - // used for the onToken callback and the external tokenizer. - - var Token = function Token(p) { - this.type = p.type; - this.value = p.value; - this.start = p.start; - this.end = p.end; - if (p.options.locations) - { this.loc = new SourceLocation(p, p.startLoc, p.endLoc); } - if (p.options.ranges) - { this.range = [p.start, p.end]; } - }; - - // ## Tokenizer - - var pp = Parser.prototype; - - // Move to the next token - - pp.next = function(ignoreEscapeSequenceInKeyword) { - if (!ignoreEscapeSequenceInKeyword && this.type.keyword && this.containsEsc) - { this.raiseRecoverable(this.start, "Escape sequence in keyword " + this.type.keyword); } - if (this.options.onToken) - { this.options.onToken(new Token(this)); } - - this.lastTokEnd = this.end; - this.lastTokStart = this.start; - this.lastTokEndLoc = this.endLoc; - this.lastTokStartLoc = this.startLoc; - this.nextToken(); - }; - - pp.getToken = function() { - this.next(); - return new Token(this) - }; - - // If we're in an ES6 environment, make parsers iterable - if (typeof Symbol !== "undefined") - { pp[Symbol.iterator] = function() { - var this$1$1 = this; - - return { - next: function () { - var token = this$1$1.getToken(); - return { - done: token.type === types$1.eof, - value: token - } - } - } - }; } - - // Toggle strict mode. Re-reads the next number or string to please - // pedantic tests (`"use strict"; 010;` should fail). - - // Read a single token, updating the parser object's token-related - // properties. - - pp.nextToken = function() { - var curContext = this.curContext(); - if (!curContext || !curContext.preserveSpace) { this.skipSpace(); } - - this.start = this.pos; - if (this.options.locations) { this.startLoc = this.curPosition(); } - if (this.pos >= this.input.length) { return this.finishToken(types$1.eof) } - - if (curContext.override) { return curContext.override(this) } - else { this.readToken(this.fullCharCodeAtPos()); } - }; - - pp.readToken = function(code) { - // Identifier or keyword. '\uXXXX' sequences are allowed in - // identifiers, so '\' also dispatches to that. - if (isIdentifierStart(code, this.options.ecmaVersion >= 6) || code === 92 /* '\' */) - { return this.readWord() } - - return this.getTokenFromCode(code) - }; - - pp.fullCharCodeAtPos = function() { - var code = this.input.charCodeAt(this.pos); - if (code <= 0xd7ff || code >= 0xdc00) { return code } - var next = this.input.charCodeAt(this.pos + 1); - return next <= 0xdbff || next >= 0xe000 ? code : (code << 10) + next - 0x35fdc00 - }; - - pp.skipBlockComment = function() { - var startLoc = this.options.onComment && this.curPosition(); - var start = this.pos, end = this.input.indexOf("*/", this.pos += 2); - if (end === -1) { this.raise(this.pos - 2, "Unterminated comment"); } - this.pos = end + 2; - if (this.options.locations) { - for (var nextBreak = (void 0), pos = start; (nextBreak = nextLineBreak(this.input, pos, this.pos)) > -1;) { - ++this.curLine; - pos = this.lineStart = nextBreak; - } - } - if (this.options.onComment) - { this.options.onComment(true, this.input.slice(start + 2, end), start, this.pos, - startLoc, this.curPosition()); } - }; - - pp.skipLineComment = function(startSkip) { - var start = this.pos; - var startLoc = this.options.onComment && this.curPosition(); - var ch = this.input.charCodeAt(this.pos += startSkip); - while (this.pos < this.input.length && !isNewLine(ch)) { - ch = this.input.charCodeAt(++this.pos); - } - if (this.options.onComment) - { this.options.onComment(false, this.input.slice(start + startSkip, this.pos), start, this.pos, - startLoc, this.curPosition()); } - }; - - // Called at the start of the parse and after every token. Skips - // whitespace and comments, and. - - pp.skipSpace = function() { - loop: while (this.pos < this.input.length) { - var ch = this.input.charCodeAt(this.pos); - switch (ch) { - case 32: case 160: // ' ' - ++this.pos; - break - case 13: - if (this.input.charCodeAt(this.pos + 1) === 10) { - ++this.pos; - } - case 10: case 8232: case 8233: - ++this.pos; - if (this.options.locations) { - ++this.curLine; - this.lineStart = this.pos; - } - break - case 47: // '/' - switch (this.input.charCodeAt(this.pos + 1)) { - case 42: // '*' - this.skipBlockComment(); - break - case 47: - this.skipLineComment(2); - break - default: - break loop - } - break - default: - if (ch > 8 && ch < 14 || ch >= 5760 && nonASCIIwhitespace.test(String.fromCharCode(ch))) { - ++this.pos; - } else { - break loop - } - } - } - }; - - // Called at the end of every token. Sets `end`, `val`, and - // maintains `context` and `exprAllowed`, and skips the space after - // the token, so that the next one's `start` will point at the - // right position. - - pp.finishToken = function(type, val) { - this.end = this.pos; - if (this.options.locations) { this.endLoc = this.curPosition(); } - var prevType = this.type; - this.type = type; - this.value = val; - - this.updateContext(prevType); - }; - - // ### Token reading - - // This is the function that is called to fetch the next token. It - // is somewhat obscure, because it works in character codes rather - // than characters, and because operator parsing has been inlined - // into it. - // - // All in the name of speed. - // - pp.readToken_dot = function() { - var next = this.input.charCodeAt(this.pos + 1); - if (next >= 48 && next <= 57) { return this.readNumber(true) } - var next2 = this.input.charCodeAt(this.pos + 2); - if (this.options.ecmaVersion >= 6 && next === 46 && next2 === 46) { // 46 = dot '.' - this.pos += 3; - return this.finishToken(types$1.ellipsis) - } else { - ++this.pos; - return this.finishToken(types$1.dot) - } - }; - - pp.readToken_slash = function() { // '/' - var next = this.input.charCodeAt(this.pos + 1); - if (this.exprAllowed) { ++this.pos; return this.readRegexp() } - if (next === 61) { return this.finishOp(types$1.assign, 2) } - return this.finishOp(types$1.slash, 1) - }; - - pp.readToken_mult_modulo_exp = function(code) { // '%*' - var next = this.input.charCodeAt(this.pos + 1); - var size = 1; - var tokentype = code === 42 ? types$1.star : types$1.modulo; - - // exponentiation operator ** and **= - if (this.options.ecmaVersion >= 7 && code === 42 && next === 42) { - ++size; - tokentype = types$1.starstar; - next = this.input.charCodeAt(this.pos + 2); - } - - if (next === 61) { return this.finishOp(types$1.assign, size + 1) } - return this.finishOp(tokentype, size) - }; - - pp.readToken_pipe_amp = function(code) { // '|&' - var next = this.input.charCodeAt(this.pos + 1); - if (next === code) { - if (this.options.ecmaVersion >= 12) { - var next2 = this.input.charCodeAt(this.pos + 2); - if (next2 === 61) { return this.finishOp(types$1.assign, 3) } - } - return this.finishOp(code === 124 ? types$1.logicalOR : types$1.logicalAND, 2) - } - if (next === 61) { return this.finishOp(types$1.assign, 2) } - return this.finishOp(code === 124 ? types$1.bitwiseOR : types$1.bitwiseAND, 1) - }; - - pp.readToken_caret = function() { // '^' - var next = this.input.charCodeAt(this.pos + 1); - if (next === 61) { return this.finishOp(types$1.assign, 2) } - return this.finishOp(types$1.bitwiseXOR, 1) - }; - - pp.readToken_plus_min = function(code) { // '+-' - var next = this.input.charCodeAt(this.pos + 1); - if (next === code) { - if (next === 45 && !this.inModule && this.input.charCodeAt(this.pos + 2) === 62 && - (this.lastTokEnd === 0 || lineBreak.test(this.input.slice(this.lastTokEnd, this.pos)))) { - // A `-->` line comment - this.skipLineComment(3); - this.skipSpace(); - return this.nextToken() - } - return this.finishOp(types$1.incDec, 2) - } - if (next === 61) { return this.finishOp(types$1.assign, 2) } - return this.finishOp(types$1.plusMin, 1) - }; - - pp.readToken_lt_gt = function(code) { // '<>' - var next = this.input.charCodeAt(this.pos + 1); - var size = 1; - if (next === code) { - size = code === 62 && this.input.charCodeAt(this.pos + 2) === 62 ? 3 : 2; - if (this.input.charCodeAt(this.pos + size) === 61) { return this.finishOp(types$1.assign, size + 1) } - return this.finishOp(types$1.bitShift, size) - } - if (next === 33 && code === 60 && !this.inModule && this.input.charCodeAt(this.pos + 2) === 45 && - this.input.charCodeAt(this.pos + 3) === 45) { - // ` @@ -13,4 +14,5 @@ + diff --git a/package-lock.json b/package-lock.json index 202f2cc..9afebfe 100644 --- a/package-lock.json +++ b/package-lock.json @@ -145,9 +145,9 @@ } }, "node_modules/@esbuild/aix-ppc64": { - "version": "0.20.2", - "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.20.2.tgz", - "integrity": "sha512-D+EBOJHXdNZcLJRBkhENNG8Wji2kgc9AZ9KiPr1JuZjsNtyHzrsfLRrY0tk2H2aoFu6RANO1y1iPPUCDYWkb5g==", + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.21.5.tgz", + "integrity": "sha512-1SDgH6ZSPTlggy1yI6+Dbkiz8xzpHJEVAlF/AM1tHPLsf5STom9rwtjE4hKAF20FfXXNTFqEYXyJNWh1GiZedQ==", "cpu": [ "ppc64" ], @@ -161,9 +161,9 @@ } }, "node_modules/@esbuild/android-arm": { - "version": "0.20.2", - "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.20.2.tgz", - "integrity": "sha512-t98Ra6pw2VaDhqNWO2Oph2LXbz/EJcnLmKLGBJwEwXX/JAN83Fym1rU8l0JUWK6HkIbWONCSSatf4sf2NBRx/w==", + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.21.5.tgz", + "integrity": "sha512-vCPvzSjpPHEi1siZdlvAlsPxXl7WbOVUBBAowWug4rJHb68Ox8KualB+1ocNvT5fjv6wpkX6o/iEpbDrf68zcg==", "cpu": [ "arm" ], @@ -177,9 +177,9 @@ } }, "node_modules/@esbuild/android-arm64": { - "version": "0.20.2", - "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.20.2.tgz", - "integrity": "sha512-mRzjLacRtl/tWU0SvD8lUEwb61yP9cqQo6noDZP/O8VkwafSYwZ4yWy24kan8jE/IMERpYncRt2dw438LP3Xmg==", + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.21.5.tgz", + "integrity": "sha512-c0uX9VAUBQ7dTDCjq+wdyGLowMdtR/GoC2U5IYk/7D1H1JYC0qseD7+11iMP2mRLN9RcCMRcjC4YMclCzGwS/A==", "cpu": [ "arm64" ], @@ -193,9 +193,9 @@ } }, "node_modules/@esbuild/android-x64": { - "version": "0.20.2", - "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.20.2.tgz", - "integrity": "sha512-btzExgV+/lMGDDa194CcUQm53ncxzeBrWJcncOBxuC6ndBkKxnHdFJn86mCIgTELsooUmwUm9FkhSp5HYu00Rg==", + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.21.5.tgz", + "integrity": "sha512-D7aPRUUNHRBwHxzxRvp856rjUHRFW1SdQATKXH2hqA0kAZb1hKmi02OpYRacl0TxIGz/ZmXWlbZgjwWYaCakTA==", "cpu": [ "x64" ], @@ -209,9 +209,9 @@ } }, "node_modules/@esbuild/darwin-arm64": { - "version": "0.20.2", - "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.20.2.tgz", - "integrity": "sha512-4J6IRT+10J3aJH3l1yzEg9y3wkTDgDk7TSDFX+wKFiWjqWp/iCfLIYzGyasx9l0SAFPT1HwSCR+0w/h1ES/MjA==", + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.21.5.tgz", + "integrity": "sha512-DwqXqZyuk5AiWWf3UfLiRDJ5EDd49zg6O9wclZ7kUMv2WRFr4HKjXp/5t8JZ11QbQfUS6/cRCKGwYhtNAY88kQ==", "cpu": [ "arm64" ], @@ -225,9 +225,9 @@ } }, "node_modules/@esbuild/darwin-x64": { - "version": "0.20.2", - "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.20.2.tgz", - "integrity": "sha512-tBcXp9KNphnNH0dfhv8KYkZhjc+H3XBkF5DKtswJblV7KlT9EI2+jeA8DgBjp908WEuYll6pF+UStUCfEpdysA==", + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.21.5.tgz", + "integrity": "sha512-se/JjF8NlmKVG4kNIuyWMV/22ZaerB+qaSi5MdrXtd6R08kvs2qCN4C09miupktDitvh8jRFflwGFBQcxZRjbw==", "cpu": [ "x64" ], @@ -241,9 +241,9 @@ } }, "node_modules/@esbuild/freebsd-arm64": { - "version": "0.20.2", - "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.20.2.tgz", - "integrity": "sha512-d3qI41G4SuLiCGCFGUrKsSeTXyWG6yem1KcGZVS+3FYlYhtNoNgYrWcvkOoaqMhwXSMrZRl69ArHsGJ9mYdbbw==", + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.21.5.tgz", + "integrity": "sha512-5JcRxxRDUJLX8JXp/wcBCy3pENnCgBR9bN6JsY4OmhfUtIHe3ZW0mawA7+RDAcMLrMIZaf03NlQiX9DGyB8h4g==", "cpu": [ "arm64" ], @@ -257,9 +257,9 @@ } }, "node_modules/@esbuild/freebsd-x64": { - "version": "0.20.2", - "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.20.2.tgz", - "integrity": "sha512-d+DipyvHRuqEeM5zDivKV1KuXn9WeRX6vqSqIDgwIfPQtwMP4jaDsQsDncjTDDsExT4lR/91OLjRo8bmC1e+Cw==", + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.21.5.tgz", + "integrity": "sha512-J95kNBj1zkbMXtHVH29bBriQygMXqoVQOQYA+ISs0/2l3T9/kj42ow2mpqerRBxDJnmkUDCaQT/dfNXWX/ZZCQ==", "cpu": [ "x64" ], @@ -273,9 +273,9 @@ } }, "node_modules/@esbuild/linux-arm": { - "version": "0.20.2", - "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.20.2.tgz", - "integrity": "sha512-VhLPeR8HTMPccbuWWcEUD1Az68TqaTYyj6nfE4QByZIQEQVWBB8vup8PpR7y1QHL3CpcF6xd5WVBU/+SBEvGTg==", + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.21.5.tgz", + "integrity": "sha512-bPb5AHZtbeNGjCKVZ9UGqGwo8EUu4cLq68E95A53KlxAPRmUyYv2D6F0uUI65XisGOL1hBP5mTronbgo+0bFcA==", "cpu": [ "arm" ], @@ -289,9 +289,9 @@ } }, "node_modules/@esbuild/linux-arm64": { - "version": "0.20.2", - "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.20.2.tgz", - "integrity": "sha512-9pb6rBjGvTFNira2FLIWqDk/uaf42sSyLE8j1rnUpuzsODBq7FvpwHYZxQ/It/8b+QOS1RYfqgGFNLRI+qlq2A==", + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.21.5.tgz", + "integrity": "sha512-ibKvmyYzKsBeX8d8I7MH/TMfWDXBF3db4qM6sy+7re0YXya+K1cem3on9XgdT2EQGMu4hQyZhan7TeQ8XkGp4Q==", "cpu": [ "arm64" ], @@ -305,9 +305,9 @@ } }, "node_modules/@esbuild/linux-ia32": { - "version": "0.20.2", - "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.20.2.tgz", - "integrity": "sha512-o10utieEkNPFDZFQm9CoP7Tvb33UutoJqg3qKf1PWVeeJhJw0Q347PxMvBgVVFgouYLGIhFYG0UGdBumROyiig==", + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.21.5.tgz", + "integrity": "sha512-YvjXDqLRqPDl2dvRODYmmhz4rPeVKYvppfGYKSNGdyZkA01046pLWyRKKI3ax8fbJoK5QbxblURkwK/MWY18Tg==", "cpu": [ "ia32" ], @@ -321,9 +321,9 @@ } }, "node_modules/@esbuild/linux-loong64": { - "version": "0.20.2", - "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.20.2.tgz", - "integrity": "sha512-PR7sp6R/UC4CFVomVINKJ80pMFlfDfMQMYynX7t1tNTeivQ6XdX5r2XovMmha/VjR1YN/HgHWsVcTRIMkymrgQ==", + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.21.5.tgz", + "integrity": "sha512-uHf1BmMG8qEvzdrzAqg2SIG/02+4/DHB6a9Kbya0XDvwDEKCoC8ZRWI5JJvNdUjtciBGFQ5PuBlpEOXQj+JQSg==", "cpu": [ "loong64" ], @@ -337,9 +337,9 @@ } }, "node_modules/@esbuild/linux-mips64el": { - "version": "0.20.2", - "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.20.2.tgz", - "integrity": "sha512-4BlTqeutE/KnOiTG5Y6Sb/Hw6hsBOZapOVF6njAESHInhlQAghVVZL1ZpIctBOoTFbQyGW+LsVYZ8lSSB3wkjA==", + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.21.5.tgz", + "integrity": "sha512-IajOmO+KJK23bj52dFSNCMsz1QP1DqM6cwLUv3W1QwyxkyIWecfafnI555fvSGqEKwjMXVLokcV5ygHW5b3Jbg==", "cpu": [ "mips64el" ], @@ -353,9 +353,9 @@ } }, "node_modules/@esbuild/linux-ppc64": { - "version": "0.20.2", - "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.20.2.tgz", - "integrity": "sha512-rD3KsaDprDcfajSKdn25ooz5J5/fWBylaaXkuotBDGnMnDP1Uv5DLAN/45qfnf3JDYyJv/ytGHQaziHUdyzaAg==", + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.21.5.tgz", + "integrity": "sha512-1hHV/Z4OEfMwpLO8rp7CvlhBDnjsC3CttJXIhBi+5Aj5r+MBvy4egg7wCbe//hSsT+RvDAG7s81tAvpL2XAE4w==", "cpu": [ "ppc64" ], @@ -369,9 +369,9 @@ } }, "node_modules/@esbuild/linux-riscv64": { - "version": "0.20.2", - "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.20.2.tgz", - "integrity": "sha512-snwmBKacKmwTMmhLlz/3aH1Q9T8v45bKYGE3j26TsaOVtjIag4wLfWSiZykXzXuE1kbCE+zJRmwp+ZbIHinnVg==", + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.21.5.tgz", + "integrity": "sha512-2HdXDMd9GMgTGrPWnJzP2ALSokE/0O5HhTUvWIbD3YdjME8JwvSCnNGBnTThKGEB91OZhzrJ4qIIxk/SBmyDDA==", "cpu": [ "riscv64" ], @@ -385,9 +385,9 @@ } }, "node_modules/@esbuild/linux-s390x": { - "version": "0.20.2", - "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.20.2.tgz", - "integrity": "sha512-wcWISOobRWNm3cezm5HOZcYz1sKoHLd8VL1dl309DiixxVFoFe/o8HnwuIwn6sXre88Nwj+VwZUvJf4AFxkyrQ==", + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.21.5.tgz", + "integrity": "sha512-zus5sxzqBJD3eXxwvjN1yQkRepANgxE9lgOW2qLnmr8ikMTphkjgXu1HR01K4FJg8h1kEEDAqDcZQtbrRnB41A==", "cpu": [ "s390x" ], @@ -401,9 +401,9 @@ } }, "node_modules/@esbuild/linux-x64": { - "version": "0.20.2", - "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.20.2.tgz", - "integrity": "sha512-1MdwI6OOTsfQfek8sLwgyjOXAu+wKhLEoaOLTjbijk6E2WONYpH9ZU2mNtR+lZ2B4uwr+usqGuVfFT9tMtGvGw==", + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.21.5.tgz", + "integrity": "sha512-1rYdTpyv03iycF1+BhzrzQJCdOuAOtaqHTWJZCWvijKD2N5Xu0TtVC8/+1faWqcP9iBCWOmjmhoH94dH82BxPQ==", "cpu": [ "x64" ], @@ -417,9 +417,9 @@ } }, "node_modules/@esbuild/netbsd-x64": { - "version": "0.20.2", - "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.20.2.tgz", - "integrity": "sha512-K8/DhBxcVQkzYc43yJXDSyjlFeHQJBiowJ0uVL6Tor3jGQfSGHNNJcWxNbOI8v5k82prYqzPuwkzHt3J1T1iZQ==", + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.21.5.tgz", + "integrity": "sha512-Woi2MXzXjMULccIwMnLciyZH4nCIMpWQAs049KEeMvOcNADVxo0UBIQPfSmxB3CWKedngg7sWZdLvLczpe0tLg==", "cpu": [ "x64" ], @@ -433,9 +433,9 @@ } }, "node_modules/@esbuild/openbsd-x64": { - "version": "0.20.2", - "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.20.2.tgz", - "integrity": "sha512-eMpKlV0SThJmmJgiVyN9jTPJ2VBPquf6Kt/nAoo6DgHAoN57K15ZghiHaMvqjCye/uU4X5u3YSMgVBI1h3vKrQ==", + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.21.5.tgz", + "integrity": "sha512-HLNNw99xsvx12lFBUwoT8EVCsSvRNDVxNpjZ7bPn947b8gJPzeHWyNVhFsaerc0n3TsbOINvRP2byTZ5LKezow==", "cpu": [ "x64" ], @@ -449,9 +449,9 @@ } }, "node_modules/@esbuild/sunos-x64": { - "version": "0.20.2", - "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.20.2.tgz", - "integrity": "sha512-2UyFtRC6cXLyejf/YEld4Hajo7UHILetzE1vsRcGL3earZEW77JxrFjH4Ez2qaTiEfMgAXxfAZCm1fvM/G/o8w==", + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.21.5.tgz", + "integrity": "sha512-6+gjmFpfy0BHU5Tpptkuh8+uw3mnrvgs+dSPQXQOv3ekbordwnzTVEb4qnIvQcYXq6gzkyTnoZ9dZG+D4garKg==", "cpu": [ "x64" ], @@ -465,9 +465,9 @@ } }, "node_modules/@esbuild/win32-arm64": { - "version": "0.20.2", - "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.20.2.tgz", - "integrity": "sha512-GRibxoawM9ZCnDxnP3usoUDO9vUkpAxIIZ6GQI+IlVmr5kP3zUq+l17xELTHMWTWzjxa2guPNyrpq1GWmPvcGQ==", + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.21.5.tgz", + "integrity": "sha512-Z0gOTd75VvXqyq7nsl93zwahcTROgqvuAcYDUr+vOv8uHhNSKROyU961kgtCD1e95IqPKSQKH7tBTslnS3tA8A==", "cpu": [ "arm64" ], @@ -481,9 +481,9 @@ } }, "node_modules/@esbuild/win32-ia32": { - "version": "0.20.2", - "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.20.2.tgz", - "integrity": "sha512-HfLOfn9YWmkSKRQqovpnITazdtquEW8/SoHW7pWpuEeguaZI4QnCRW6b+oZTztdBnZOS2hqJ6im/D5cPzBTTlQ==", + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.21.5.tgz", + "integrity": "sha512-SWXFF1CL2RVNMaVs+BBClwtfZSvDgtL//G/smwAc5oVK/UPu2Gu9tIaRgFmYFFKrmg3SyAjSrElf0TiJ1v8fYA==", "cpu": [ "ia32" ], @@ -497,9 +497,9 @@ } }, "node_modules/@esbuild/win32-x64": { - "version": "0.20.2", - "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.20.2.tgz", - "integrity": "sha512-N49X4lJX27+l9jbLKSqZ6bKNjzQvHaT8IIFUy+YIqmXQdjYCToGWwOItDrfby14c78aDd5NHQl29xingXfCdLQ==", + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.21.5.tgz", + "integrity": "sha512-tQd/1efJuzPC6rCFwEvLtci/xNFcTZknmXs98FYDfGE4wP9ClFV98nyKrzJKVPMhdDnjzLhdUyMX4PsQAPjwIw==", "cpu": [ "x64" ], @@ -549,12 +549,12 @@ } }, "node_modules/@eslint/config-array": { - "version": "0.15.1", - "resolved": "https://registry.npmjs.org/@eslint/config-array/-/config-array-0.15.1.tgz", - "integrity": "sha512-K4gzNq+yymn/EVsXYmf+SBcBro8MTf+aXJZUphM96CdzUEr+ClGDvAbpmaEK+cGVigVXIgs9gNmvHAlrzzY5JQ==", + "version": "0.16.0", + "resolved": "https://registry.npmjs.org/@eslint/config-array/-/config-array-0.16.0.tgz", + "integrity": "sha512-/jmuSd74i4Czf1XXn7wGRWZCuyaUZ330NH1Bek0Pplatt4Sy1S5haN21SCLLdbeKslQ+S0wEJ+++v5YibSi+Lg==", "dev": true, "dependencies": { - "@eslint/object-schema": "^2.1.3", + "@eslint/object-schema": "^2.1.4", "debug": "^4.3.1", "minimatch": "^3.0.5" }, @@ -586,9 +586,9 @@ } }, "node_modules/@eslint/js": { - "version": "9.4.0", - "resolved": "https://registry.npmjs.org/@eslint/js/-/js-9.4.0.tgz", - "integrity": "sha512-fdI7VJjP3Rvc70lC4xkFXHB0fiPeojiL1PxVG6t1ZvXQrarj893PweuBTujxDUFk0Fxj4R7PIIAZ/aiiyZPZcg==", + "version": "9.5.0", + "resolved": "https://registry.npmjs.org/@eslint/js/-/js-9.5.0.tgz", + "integrity": "sha512-A7+AOT2ICkodvtsWnxZP4Xxk3NbZ3VMHd8oihydLRGrJgqqdEz1qSeEgXYyT/Cu8h1TWWsQRejIx48mtjZ5y1w==", "dev": true, "engines": { "node": "^18.18.0 || ^20.9.0 || >=21.1.0" @@ -928,36 +928,36 @@ } }, "node_modules/@vue/compiler-core": { - "version": "3.4.27", - "resolved": "https://registry.npmjs.org/@vue/compiler-core/-/compiler-core-3.4.27.tgz", - "integrity": "sha512-E+RyqY24KnyDXsCuQrI+mlcdW3ALND6U7Gqa/+bVwbcpcR3BRRIckFoz7Qyd4TTlnugtwuI7YgjbvsLmxb+yvg==", + "version": "3.4.29", + "resolved": "https://registry.npmjs.org/@vue/compiler-core/-/compiler-core-3.4.29.tgz", + "integrity": "sha512-TFKiRkKKsRCKvg/jTSSKK7mYLJEQdUiUfykbG49rubC9SfDyvT2JrzTReopWlz2MxqeLyxh9UZhvxEIBgAhtrg==", "dependencies": { - "@babel/parser": "^7.24.4", - "@vue/shared": "3.4.27", + "@babel/parser": "^7.24.7", + "@vue/shared": "3.4.29", "entities": "^4.5.0", "estree-walker": "^2.0.2", "source-map-js": "^1.2.0" } }, "node_modules/@vue/compiler-dom": { - "version": "3.4.27", - "resolved": "https://registry.npmjs.org/@vue/compiler-dom/-/compiler-dom-3.4.27.tgz", - "integrity": "sha512-kUTvochG/oVgE1w5ViSr3KUBh9X7CWirebA3bezTbB5ZKBQZwR2Mwj9uoSKRMFcz4gSMzzLXBPD6KpCLb9nvWw==", + "version": "3.4.29", + "resolved": "https://registry.npmjs.org/@vue/compiler-dom/-/compiler-dom-3.4.29.tgz", + "integrity": "sha512-A6+iZ2fKIEGnfPJejdB7b1FlJzgiD+Y/sxxKwJWg1EbJu6ZPgzaPQQ51ESGNv0CP6jm6Z7/pO6Ia8Ze6IKrX7w==", "dependencies": { - "@vue/compiler-core": "3.4.27", - "@vue/shared": "3.4.27" + "@vue/compiler-core": "3.4.29", + "@vue/shared": "3.4.29" } }, "node_modules/@vue/compiler-sfc": { - "version": "3.4.27", - "resolved": "https://registry.npmjs.org/@vue/compiler-sfc/-/compiler-sfc-3.4.27.tgz", - "integrity": "sha512-nDwntUEADssW8e0rrmE0+OrONwmRlegDA1pD6QhVeXxjIytV03yDqTey9SBDiALsvAd5U4ZrEKbMyVXhX6mCGA==", - "dependencies": { - "@babel/parser": "^7.24.4", - "@vue/compiler-core": "3.4.27", - "@vue/compiler-dom": "3.4.27", - "@vue/compiler-ssr": "3.4.27", - "@vue/shared": "3.4.27", + "version": "3.4.29", + "resolved": "https://registry.npmjs.org/@vue/compiler-sfc/-/compiler-sfc-3.4.29.tgz", + "integrity": "sha512-zygDcEtn8ZimDlrEQyLUovoWgKQic6aEQqRXce2WXBvSeHbEbcAsXyCk9oG33ZkyWH4sl9D3tkYc1idoOkdqZQ==", + "dependencies": { + "@babel/parser": "^7.24.7", + "@vue/compiler-core": "3.4.29", + "@vue/compiler-dom": "3.4.29", + "@vue/compiler-ssr": "3.4.29", + "@vue/shared": "3.4.29", "estree-walker": "^2.0.2", "magic-string": "^0.30.10", "postcss": "^8.4.38", @@ -965,62 +965,63 @@ } }, "node_modules/@vue/compiler-ssr": { - "version": "3.4.27", - "resolved": "https://registry.npmjs.org/@vue/compiler-ssr/-/compiler-ssr-3.4.27.tgz", - "integrity": "sha512-CVRzSJIltzMG5FcidsW0jKNQnNRYC8bT21VegyMMtHmhW3UOI7knmUehzswXLrExDLE6lQCZdrhD4ogI7c+vuw==", + "version": "3.4.29", + "resolved": "https://registry.npmjs.org/@vue/compiler-ssr/-/compiler-ssr-3.4.29.tgz", + "integrity": "sha512-rFbwCmxJ16tDp3N8XCx5xSQzjhidYjXllvEcqX/lopkoznlNPz3jyy0WGJCyhAaVQK677WWFt3YO/WUEkMMUFQ==", "dependencies": { - "@vue/compiler-dom": "3.4.27", - "@vue/shared": "3.4.27" + "@vue/compiler-dom": "3.4.29", + "@vue/shared": "3.4.29" } }, "node_modules/@vue/reactivity": { - "version": "3.4.27", - "resolved": "https://registry.npmjs.org/@vue/reactivity/-/reactivity-3.4.27.tgz", - "integrity": "sha512-kK0g4NknW6JX2yySLpsm2jlunZJl2/RJGZ0H9ddHdfBVHcNzxmQ0sS0b09ipmBoQpY8JM2KmUw+a6sO8Zo+zIA==", + "version": "3.4.29", + "resolved": "https://registry.npmjs.org/@vue/reactivity/-/reactivity-3.4.29.tgz", + "integrity": "sha512-w8+KV+mb1a8ornnGQitnMdLfE0kXmteaxLdccm2XwdFxXst4q/Z7SEboCV5SqJNpZbKFeaRBBJBhW24aJyGINg==", "dependencies": { - "@vue/shared": "3.4.27" + "@vue/shared": "3.4.29" } }, "node_modules/@vue/runtime-core": { - "version": "3.4.27", - "resolved": "https://registry.npmjs.org/@vue/runtime-core/-/runtime-core-3.4.27.tgz", - "integrity": "sha512-7aYA9GEbOOdviqVvcuweTLe5Za4qBZkUY7SvET6vE8kyypxVgaT1ixHLg4urtOlrApdgcdgHoTZCUuTGap/5WA==", + "version": "3.4.29", + "resolved": "https://registry.npmjs.org/@vue/runtime-core/-/runtime-core-3.4.29.tgz", + "integrity": "sha512-s8fmX3YVR/Rk5ig0ic0NuzTNjK2M7iLuVSZyMmCzN/+Mjuqqif1JasCtEtmtoJWF32pAtUjyuT2ljNKNLeOmnQ==", "dependencies": { - "@vue/reactivity": "3.4.27", - "@vue/shared": "3.4.27" + "@vue/reactivity": "3.4.29", + "@vue/shared": "3.4.29" } }, "node_modules/@vue/runtime-dom": { - "version": "3.4.27", - "resolved": "https://registry.npmjs.org/@vue/runtime-dom/-/runtime-dom-3.4.27.tgz", - "integrity": "sha512-ScOmP70/3NPM+TW9hvVAz6VWWtZJqkbdf7w6ySsws+EsqtHvkhxaWLecrTorFxsawelM5Ys9FnDEMt6BPBDS0Q==", + "version": "3.4.29", + "resolved": "https://registry.npmjs.org/@vue/runtime-dom/-/runtime-dom-3.4.29.tgz", + "integrity": "sha512-gI10atCrtOLf/2MPPMM+dpz3NGulo9ZZR9d1dWo4fYvm+xkfvRrw1ZmJ7mkWtiJVXSsdmPbcK1p5dZzOCKDN0g==", "dependencies": { - "@vue/runtime-core": "3.4.27", - "@vue/shared": "3.4.27", + "@vue/reactivity": "3.4.29", + "@vue/runtime-core": "3.4.29", + "@vue/shared": "3.4.29", "csstype": "^3.1.3" } }, "node_modules/@vue/server-renderer": { - "version": "3.4.27", - "resolved": "https://registry.npmjs.org/@vue/server-renderer/-/server-renderer-3.4.27.tgz", - "integrity": "sha512-dlAMEuvmeA3rJsOMJ2J1kXU7o7pOxgsNHVr9K8hB3ImIkSuBrIdy0vF66h8gf8Tuinf1TK3mPAz2+2sqyf3KzA==", + "version": "3.4.29", + "resolved": "https://registry.npmjs.org/@vue/server-renderer/-/server-renderer-3.4.29.tgz", + "integrity": "sha512-HMLCmPI2j/k8PVkSBysrA2RxcxC5DgBiCdj7n7H2QtR8bQQPqKAe8qoaxLcInzouBmzwJ+J0x20ygN/B5mYBng==", "dependencies": { - "@vue/compiler-ssr": "3.4.27", - "@vue/shared": "3.4.27" + "@vue/compiler-ssr": "3.4.29", + "@vue/shared": "3.4.29" }, "peerDependencies": { - "vue": "3.4.27" + "vue": "3.4.29" } }, "node_modules/@vue/shared": { - "version": "3.4.27", - "resolved": "https://registry.npmjs.org/@vue/shared/-/shared-3.4.27.tgz", - "integrity": "sha512-DL3NmY2OFlqmYYrzp39yi3LDkKxa5vZVwxWdQ3rG0ekuWscHraeIbnI8t+aZK7qhYqEqWKTUdijadunb9pnrgA==" + "version": "3.4.29", + "resolved": "https://registry.npmjs.org/@vue/shared/-/shared-3.4.29.tgz", + "integrity": "sha512-hQ2gAQcBO/CDpC82DCrinJNgOHI2v+FA7BDW4lMSPeBpQ7sRe2OLHWe5cph1s7D8DUQAwRt18dBDfJJ220APEA==" }, "node_modules/acorn": { - "version": "8.11.3", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.11.3.tgz", - "integrity": "sha512-Y9rRfJG5jcKOE0CLisYbojUjIrIEE7AGMzA/Sm4BslANhbS+cDMpgBdcPT91oJ7OuJ9hYJBx59RjbhxVnrF8Xg==", + "version": "8.12.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.12.0.tgz", + "integrity": "sha512-RTvkC4w+KNXrM39/lWCUaG0IbRkWdCv7W/IOW9oU6SawyxulvkQy5HQPVTKxEjczcUvapcrw3cFx/60VN/NRNw==", "bin": { "acorn": "bin/acorn" }, @@ -1815,9 +1816,9 @@ } }, "node_modules/esbuild": { - "version": "0.20.2", - "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.20.2.tgz", - "integrity": "sha512-WdOOppmUNU+IbZ0PaDiTst80zjnrOkyJNHoKupIcVyU8Lvla3Ugx94VzkQ32Ijqd7UhHJy75gNWDMUekcrSJ6g==", + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.21.5.tgz", + "integrity": "sha512-mg3OPMV4hXywwpoDxu3Qda5xCKQi+vCTZq8S9J/EpkhB2HzKXq4SNFZE3+NK93JYxc8VMSep+lOUSC/RVKaBqw==", "dev": true, "hasInstallScript": true, "bin": { @@ -1827,29 +1828,29 @@ "node": ">=12" }, "optionalDependencies": { - "@esbuild/aix-ppc64": "0.20.2", - "@esbuild/android-arm": "0.20.2", - "@esbuild/android-arm64": "0.20.2", - "@esbuild/android-x64": "0.20.2", - "@esbuild/darwin-arm64": "0.20.2", - "@esbuild/darwin-x64": "0.20.2", - "@esbuild/freebsd-arm64": "0.20.2", - "@esbuild/freebsd-x64": "0.20.2", - "@esbuild/linux-arm": "0.20.2", - "@esbuild/linux-arm64": "0.20.2", - "@esbuild/linux-ia32": "0.20.2", - "@esbuild/linux-loong64": "0.20.2", - "@esbuild/linux-mips64el": "0.20.2", - "@esbuild/linux-ppc64": "0.20.2", - "@esbuild/linux-riscv64": "0.20.2", - "@esbuild/linux-s390x": "0.20.2", - "@esbuild/linux-x64": "0.20.2", - "@esbuild/netbsd-x64": "0.20.2", - "@esbuild/openbsd-x64": "0.20.2", - "@esbuild/sunos-x64": "0.20.2", - "@esbuild/win32-arm64": "0.20.2", - "@esbuild/win32-ia32": "0.20.2", - "@esbuild/win32-x64": "0.20.2" + "@esbuild/aix-ppc64": "0.21.5", + "@esbuild/android-arm": "0.21.5", + "@esbuild/android-arm64": "0.21.5", + "@esbuild/android-x64": "0.21.5", + "@esbuild/darwin-arm64": "0.21.5", + "@esbuild/darwin-x64": "0.21.5", + "@esbuild/freebsd-arm64": "0.21.5", + "@esbuild/freebsd-x64": "0.21.5", + "@esbuild/linux-arm": "0.21.5", + "@esbuild/linux-arm64": "0.21.5", + "@esbuild/linux-ia32": "0.21.5", + "@esbuild/linux-loong64": "0.21.5", + "@esbuild/linux-mips64el": "0.21.5", + "@esbuild/linux-ppc64": "0.21.5", + "@esbuild/linux-riscv64": "0.21.5", + "@esbuild/linux-s390x": "0.21.5", + "@esbuild/linux-x64": "0.21.5", + "@esbuild/netbsd-x64": "0.21.5", + "@esbuild/openbsd-x64": "0.21.5", + "@esbuild/sunos-x64": "0.21.5", + "@esbuild/win32-arm64": "0.21.5", + "@esbuild/win32-ia32": "0.21.5", + "@esbuild/win32-x64": "0.21.5" } }, "node_modules/escape-string-regexp": { @@ -1894,16 +1895,16 @@ } }, "node_modules/eslint": { - "version": "9.4.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-9.4.0.tgz", - "integrity": "sha512-sjc7Y8cUD1IlwYcTS9qPSvGjAC8Ne9LctpxKKu3x/1IC9bnOg98Zy6GxEJUfr1NojMgVPlyANXYns8oE2c1TAA==", + "version": "9.5.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-9.5.0.tgz", + "integrity": "sha512-+NAOZFrW/jFTS3dASCGBxX1pkFD0/fsO+hfAkJ4TyYKwgsXZbqzrw+seCYFCcPCYXvnD67tAnglU7GQTz6kcVw==", "dev": true, "dependencies": { "@eslint-community/eslint-utils": "^4.2.0", "@eslint-community/regexpp": "^4.6.1", - "@eslint/config-array": "^0.15.1", + "@eslint/config-array": "^0.16.0", "@eslint/eslintrc": "^3.1.0", - "@eslint/js": "9.4.0", + "@eslint/js": "9.5.0", "@humanwhocodes/module-importer": "^1.0.1", "@humanwhocodes/retry": "^0.3.0", "@nodelib/fs.walk": "^1.2.8", @@ -1915,7 +1916,7 @@ "eslint-scope": "^8.0.1", "eslint-visitor-keys": "^4.0.0", "espree": "^10.0.1", - "esquery": "^1.4.2", + "esquery": "^1.5.0", "esutils": "^2.0.2", "fast-deep-equal": "^3.1.3", "file-entry-cache": "^8.0.0", @@ -1941,7 +1942,7 @@ "node": "^18.18.0 || ^20.9.0 || >=21.1.0" }, "funding": { - "url": "https://opencollective.com/eslint" + "url": "https://eslint.org/donate" } }, "node_modules/eslint-plugin-vue": { @@ -3832,12 +3833,12 @@ "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==" }, "node_modules/vite": { - "version": "5.2.13", - "resolved": "https://registry.npmjs.org/vite/-/vite-5.2.13.tgz", - "integrity": "sha512-SSq1noJfY9pR3I1TUENL3rQYDQCFqgD+lM6fTRAM8Nv6Lsg5hDLaXkjETVeBt+7vZBCMoibD+6IWnT2mJ+Zb/A==", + "version": "5.3.1", + "resolved": "https://registry.npmjs.org/vite/-/vite-5.3.1.tgz", + "integrity": "sha512-XBmSKRLXLxiaPYamLv3/hnP/KXDai1NDexN0FpkTaZXTfycHvkRHoenpgl/fvuK/kPbB6xAgoyiryAhQNxYmAQ==", "dev": true, "dependencies": { - "esbuild": "^0.20.1", + "esbuild": "^0.21.3", "postcss": "^8.4.38", "rollup": "^4.13.0" }, @@ -3892,15 +3893,15 @@ "integrity": "sha512-2ham8XPWTONajOR0ohOKOHXkm3+gaBmGut3SRuu75xLd/RRaY6vqgh8NBYYk7+RW3u5AtzPQZG8F10LHkl0lAQ==" }, "node_modules/vue": { - "version": "3.4.27", - "resolved": "https://registry.npmjs.org/vue/-/vue-3.4.27.tgz", - "integrity": "sha512-8s/56uK6r01r1icG/aEOHqyMVxd1bkYcSe9j8HcKtr/xTOFWvnzIVTehNW+5Yt89f+DLBe4A569pnZLS5HzAMA==", - "dependencies": { - "@vue/compiler-dom": "3.4.27", - "@vue/compiler-sfc": "3.4.27", - "@vue/runtime-dom": "3.4.27", - "@vue/server-renderer": "3.4.27", - "@vue/shared": "3.4.27" + "version": "3.4.29", + "resolved": "https://registry.npmjs.org/vue/-/vue-3.4.29.tgz", + "integrity": "sha512-8QUYfRcYzNlYuzKPfge1UWC6nF9ym0lx7mpGVPJYNhddxEf3DD0+kU07NTL0sXuiT2HuJuKr/iEO8WvXvT0RSQ==", + "dependencies": { + "@vue/compiler-dom": "3.4.29", + "@vue/compiler-sfc": "3.4.29", + "@vue/runtime-dom": "3.4.29", + "@vue/server-renderer": "3.4.29", + "@vue/shared": "3.4.29" }, "peerDependencies": { "typescript": "*" diff --git a/public/arborist.js b/public/arborist.js new file mode 100644 index 0000000..913b792 --- /dev/null +++ b/public/arborist.js @@ -0,0 +1,3 @@ +(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i 0xd7ff && nextCh < 0xdc00) { return true } // '{', astral @@ -1796,13 +1798,19 @@ module.exports = { return this.parseFor(node, init$1) } var startsWithLet = this.isContextual("let"), isForOf = false; + var containsEsc = this.containsEsc; var refDestructuringErrors = new DestructuringErrors; - var init = this.parseExpression(awaitAt > -1 ? "await" : true, refDestructuringErrors); + var initPos = this.start; + var init = awaitAt > -1 + ? this.parseExprSubscripts(refDestructuringErrors, "await") + : this.parseExpression(true, refDestructuringErrors); if (this.type === types$1._in || (isForOf = this.options.ecmaVersion >= 6 && this.isContextual("of"))) { - if (this.options.ecmaVersion >= 9) { - if (this.type === types$1._in) { - if (awaitAt > -1) { this.unexpected(awaitAt); } - } else { node.await = awaitAt > -1; } + if (awaitAt > -1) { // implies `ecmaVersion >= 9` (see declaration of awaitAt) + if (this.type === types$1._in) { this.unexpected(awaitAt); } + node.await = true; + } else if (isForOf && this.options.ecmaVersion >= 8) { + if (init.start === initPos && !containsEsc && init.type === "Identifier" && init.name === "async") { this.unexpected(); } + else if (this.options.ecmaVersion >= 9) { node.await = false; } } if (startsWithLet && isForOf) { this.raise(init.start, "The left-hand side of a for-of loop may not start with 'let'."); } this.toAssignable(init, false, refDestructuringErrors); @@ -3415,8 +3423,7 @@ module.exports = { node.argument = this.parseMaybeUnary(null, true, update, forInit); this.checkExpressionErrors(refDestructuringErrors, true); if (update) { this.checkLValSimple(node.argument); } - else if (this.strict && node.operator === "delete" && - node.argument.type === "Identifier") + else if (this.strict && node.operator === "delete" && isLocalVariableAccess(node.argument)) { this.raiseRecoverable(node.start, "Deleting local variable in strict mode"); } else if (node.operator === "delete" && isPrivateFieldAccess(node.argument)) { this.raiseRecoverable(node.start, "Private fields can not be deleted"); } @@ -3451,10 +3458,18 @@ module.exports = { } }; + function isLocalVariableAccess(node) { + return ( + node.type === "Identifier" || + node.type === "ParenthesizedExpression" && isLocalVariableAccess(node.expression) + ) + } + function isPrivateFieldAccess(node) { return ( node.type === "MemberExpression" && node.property.type === "PrivateIdentifier" || - node.type === "ChainExpression" && isPrivateFieldAccess(node.expression) + node.type === "ChainExpression" && isPrivateFieldAccess(node.expression) || + node.type === "ParenthesizedExpression" && isPrivateFieldAccess(node.expression) ) } @@ -3881,7 +3896,7 @@ module.exports = { this.raiseRecoverable(this.start, "Bad escape sequence in untagged template literal"); } elem.value = { - raw: this.value, + raw: this.value.replace(/\r\n?/g, "\n"), cooked: null }; } else { @@ -4556,6 +4571,30 @@ module.exports = { var pp$1 = Parser.prototype; + // Track disjunction structure to determine whether a duplicate + // capture group name is allowed because it is in a separate branch. + var BranchID = function BranchID(parent, base) { + // Parent disjunction branch + this.parent = parent; + // Identifies this set of sibling branches + this.base = base || this; + }; + + BranchID.prototype.separatedFrom = function separatedFrom (alt) { + // A branch is separate from another branch if they or any of + // their parents are siblings in a given disjunction + for (var self = this; self; self = self.parent) { + for (var other = alt; other; other = other.parent) { + if (self.base === other.base && self !== other) { return true } + } + } + return false + }; + + BranchID.prototype.sibling = function sibling () { + return new BranchID(this.parent, this.base) + }; + var RegExpValidationState = function RegExpValidationState(parser) { this.parser = parser; this.validFlags = "gim" + (parser.options.ecmaVersion >= 6 ? "uy" : "") + (parser.options.ecmaVersion >= 9 ? "s" : "") + (parser.options.ecmaVersion >= 13 ? "d" : "") + (parser.options.ecmaVersion >= 15 ? "v" : ""); @@ -4572,8 +4611,9 @@ module.exports = { this.lastAssertionIsQuantifiable = false; this.numCapturingParens = 0; this.maxBackReference = 0; - this.groupNames = []; + this.groupNames = Object.create(null); this.backReferenceNames = []; + this.branchID = null; }; RegExpValidationState.prototype.reset = function reset (start, pattern, flags) { @@ -4705,6 +4745,11 @@ module.exports = { } }; + function hasProp(obj) { + for (var _ in obj) { return true } + return false + } + /** * Validate the pattern part of a given RegExpLiteral. * @@ -4719,7 +4764,7 @@ module.exports = { // |Pattern[~U, +N]| and use this result instead. Throw a *SyntaxError* // exception if _P_ did not conform to the grammar, if any elements of _P_ // were not matched by the parse, or if any Early Error conditions exist. - if (!state.switchN && this.options.ecmaVersion >= 9 && state.groupNames.length > 0) { + if (!state.switchN && this.options.ecmaVersion >= 9 && hasProp(state.groupNames)) { state.switchN = true; this.regexp_pattern(state); } @@ -4733,8 +4778,9 @@ module.exports = { state.lastAssertionIsQuantifiable = false; state.numCapturingParens = 0; state.maxBackReference = 0; - state.groupNames.length = 0; + state.groupNames = Object.create(null); state.backReferenceNames.length = 0; + state.branchID = null; this.regexp_disjunction(state); @@ -4753,7 +4799,7 @@ module.exports = { for (var i = 0, list = state.backReferenceNames; i < list.length; i += 1) { var name = list[i]; - if (state.groupNames.indexOf(name) === -1) { + if (!state.groupNames[name]) { state.raise("Invalid named capture referenced"); } } @@ -4761,10 +4807,14 @@ module.exports = { // https://www.ecma-international.org/ecma-262/8.0/#prod-Disjunction pp$1.regexp_disjunction = function(state) { + var trackDisjunction = this.options.ecmaVersion >= 16; + if (trackDisjunction) { state.branchID = new BranchID(state.branchID, null); } this.regexp_alternative(state); while (state.eat(0x7C /* | */)) { + if (trackDisjunction) { state.branchID = state.branchID.sibling(); } this.regexp_alternative(state); } + if (trackDisjunction) { state.branchID = state.branchID.parent; } // Make the same message as V8. if (this.regexp_eatQuantifier(state, true)) { @@ -4777,8 +4827,7 @@ module.exports = { // https://www.ecma-international.org/ecma-262/8.0/#prod-Alternative pp$1.regexp_alternative = function(state) { - while (state.pos < state.source.length && this.regexp_eatTerm(state)) - { } + while (state.pos < state.source.length && this.regexp_eatTerm(state)) {} }; // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-Term @@ -5016,14 +5065,26 @@ module.exports = { // `?` GroupName pp$1.regexp_groupSpecifier = function(state) { if (state.eat(0x3F /* ? */)) { - if (this.regexp_eatGroupName(state)) { - if (state.groupNames.indexOf(state.lastStringValue) !== -1) { + if (!this.regexp_eatGroupName(state)) { state.raise("Invalid group"); } + var trackDisjunction = this.options.ecmaVersion >= 16; + var known = state.groupNames[state.lastStringValue]; + if (known) { + if (trackDisjunction) { + for (var i = 0, list = known; i < list.length; i += 1) { + var altID = list[i]; + + if (!altID.separatedFrom(state.branchID)) + { state.raise("Duplicate capture group name"); } + } + } else { state.raise("Duplicate capture group name"); } - state.groupNames.push(state.lastStringValue); - return } - state.raise("Invalid group"); + if (trackDisjunction) { + (known || (state.groupNames[state.lastStringValue] = [])).push(state.branchID); + } else { + state.groupNames[state.lastStringValue] = true; + } } }; @@ -6528,15 +6589,18 @@ module.exports = { break case "$": - if (this.input[this.pos + 1] !== "{") { - break - } - - // falls through + if (this.input[this.pos + 1] !== "{") { break } + // fall through case "`": return this.finishToken(types$1.invalidTemplate, this.input.slice(this.start, this.pos)) - // no default + case "\r": + if (this.input[this.pos + 1] === "\n") { ++this.pos; } + // fall through + case "\n": case "\u2028": case "\u2029": + ++this.curLine; + this.lineStart = this.pos + 1; + break } } this.raise(this.start, "Unterminated template"); @@ -6599,6 +6663,7 @@ module.exports = { if (isNewLine(ch)) { // Unicode new line characters after \ get removed from output in both // template literals and strings + if (this.options.locations) { this.lineStart = this.pos; ++this.curLine; } return "" } return String.fromCharCode(ch) @@ -6677,7 +6742,7 @@ module.exports = { // [walk]: util/walk.js - var version = "8.11.3"; + var version = "8.12.0"; Parser.acorn = { Parser: Parser, @@ -7261,7 +7326,7 @@ var objectKeys = Object.keys || function (obj) { }; }).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"object.assign/polyfill":57,"util/":8}],6:[function(require,module,exports){ +},{"object.assign/polyfill":58,"util/":8}],6:[function(require,module,exports){ if (typeof Object.create === 'function') { // implementation from standard node.js 'util' module module.exports = function inherits(ctor, superCtor) { @@ -7883,7 +7948,7 @@ function hasOwnProperty(obj, prop) { } }).call(this)}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"./support/isBuffer":7,"_process":58,"inherits":6}],9:[function(require,module,exports){ +},{"./support/isBuffer":7,"_process":59,"inherits":6}],9:[function(require,module,exports){ 'use strict'; var GetIntrinsic = require('get-intrinsic'); @@ -7900,7 +7965,7 @@ module.exports = function callBoundIntrinsic(name, allowMissing) { return intrinsic; }; -},{"./":10,"get-intrinsic":46}],10:[function(require,module,exports){ +},{"./":10,"get-intrinsic":47}],10:[function(require,module,exports){ 'use strict'; var bind = require('function-bind'); @@ -7937,7 +8002,7 @@ if ($defineProperty) { module.exports.apply = applyBind; } -},{"es-define-property":12,"es-errors/type":18,"function-bind":45,"get-intrinsic":46,"set-function-length":59}],11:[function(require,module,exports){ +},{"es-define-property":12,"es-errors/type":18,"function-bind":46,"get-intrinsic":47,"set-function-length":60}],11:[function(require,module,exports){ 'use strict'; var $defineProperty = require('es-define-property'); @@ -7995,7 +8060,7 @@ module.exports = function defineDataProperty( } }; -},{"es-define-property":12,"es-errors/syntax":17,"es-errors/type":18,"gopd":47}],12:[function(require,module,exports){ +},{"es-define-property":12,"es-errors/syntax":17,"es-errors/type":18,"gopd":48}],12:[function(require,module,exports){ 'use strict'; var GetIntrinsic = require('get-intrinsic'); @@ -8013,7 +8078,7 @@ if ($defineProperty) { module.exports = $defineProperty; -},{"get-intrinsic":46}],13:[function(require,module,exports){ +},{"get-intrinsic":47}],13:[function(require,module,exports){ 'use strict'; /** @type {import('./eval')} */ @@ -18903,6 +18968,181 @@ exports.tokenize = tokenize; exports.version = version; },{"acorn":4,"acorn-jsx":2,"eslint-visitor-keys":41}],43:[function(require,module,exports){ +window.generateCode = flast.generateCode, window.generateFlatAST = flast.generateFlatAST + +const Arborist = class { + /** + * @param {string|ASTNode[]} scriptOrFlatAstArr - the target script or a flat AST array + * @param {Function} logFunc - (optional) Logging function + */ + constructor(scriptOrFlatAstArr, logFunc = null) { + this.script = ''; + this.ast = []; + this.log = logFunc || (() => true); + this.markedForDeletion = []; // Array of node ids. + this.appliedCounter = 0; // Track the number of times changes were applied. + this.replacements = []; + if (typeof scriptOrFlatAstArr === 'string') { + this.script = scriptOrFlatAstArr; + this.ast = generateFlatAST(scriptOrFlatAstArr); + } else if (Array.isArray(scriptOrFlatAstArr)) { + this.ast = scriptOrFlatAstArr; + } else throw Error(`Undetermined argument`); + } + + /** + * When applicable, replace the provided node with its nearest parent node that can be removed without breaking the code. + * @param {ASTNode} startNode + * @return {ASTNode} + */ + _getCorrectTargetForDeletion(startNode) { + let currentNode = startNode; + while ( + ['ExpressionStatement', 'UnaryExpression', 'UpdateExpression'].includes(currentNode?.parentNode?.type) || + (currentNode.parentNode.type === 'VariableDeclaration' && + (currentNode.parentNode.declarations.length === 1 || + !currentNode.parentNode.declarations.filter(d => d.nodeId !== currentNode.nodeId && !d.isMarked).length) + )) currentNode = currentNode.parentNode; + if (['consequent', 'alternate'].includes(currentNode.parentKey)) currentNode.isEmpty = true; + return currentNode; + } + + /** + * + * @returns {number} The number of changes to be applied. + */ + getNumberOfChanges() { + return this.replacements.length + this.markedForDeletion.length; + } + + /** + * Replace the target node with another node or delete the target node completely, depending on whether a replacement + * node is provided. + * @param targetNode The node to replace or remove. + * @param replacementNode If exists, replace the target node with this node. + */ + markNode(targetNode, replacementNode) { + if (!targetNode.isMarked) { + if (replacementNode) { // Mark for replacement + this.replacements.push([targetNode, replacementNode]); + targetNode.isMarked = true; + } else { // Mark for deletion + targetNode = this._getCorrectTargetForDeletion(targetNode); + if (targetNode.isEmpty) this.markNode(targetNode, {type: 'EmptyStatement'}); + else if (!targetNode.isMarked) { + this.markedForDeletion.push(targetNode.nodeId); + targetNode.isMarked = true; + } + } + } + } + + /** + * Iterate over the complete AST and replace / remove marked nodes, + * then rebuild code and AST to validate changes. + * @return {number} The number of modifications made. + */ + applyChanges() { + let changesCounter = 0; + try { + const that = this; + if (this.getNumberOfChanges() > 0) { + let rootNode = this.ast[0]; + const rootNodeReplacement = this.replacements.find(n => n[0].nodeId === 0); + if (rootNodeReplacement) { + ++changesCounter; + this.log(`[+] Applying changes to the root node...`); + const leadingComments = rootNode.leadingComments || []; + const trailingComments = rootNode.trailingComments || []; + rootNode = rootNodeReplacement[1]; + if (leadingComments.length) rootNode.leadingComments = (rootNode.leadingComments || []).concat(leadingComments); + if (trailingComments.length) rootNode.trailingComments = (rootNode.trailingComments || []).concat(trailingComments); + } else { + for (const targetNodeId of this.markedForDeletion) { + try { + const targetNode = this.ast.find(n => n.nodeId === targetNodeId); + if (targetNode) { + const parent = targetNode.parentNode; + if (parent[targetNode.parentKey] === targetNode) { + parent[targetNode.parentKey] = undefined; + const comments = (targetNode.leadingComments || []).concat(targetNode.trailingComments || []); + if (comments.length) parent.trailingComments = (parent.trailingComments || []).concat(comments); + ++changesCounter; + } else if (Array.isArray(parent[targetNode.parentKey])) { + const idx = parent[targetNode.parentKey].indexOf(targetNode); + parent[targetNode.parentKey][idx] = undefined; + parent[targetNode.parentKey] = parent[targetNode.parentKey].filter(n => n); + const comments = (targetNode.leadingComments || []).concat(targetNode.trailingComments || []); + if (comments.length) { + const targetParent = idx > 0 ? parent[targetNode.parentKey][idx - 1] : parent[targetNode.parentKey].length > 1 ? parent[targetNode.parentKey][idx + 1] : parent; + targetParent.trailingComments = (targetParent.trailingComments || []).concat(comments); + } + ++changesCounter; + } + } + } catch (e) { + that.log(`[-] Unable to delete node: ${e}`); + } + } + for (const [targetNode, replacementNode] of this.replacements) { + try { + if (targetNode) { + const parent = targetNode.parentNode; + if (parent[targetNode.parentKey] === targetNode) { + parent[targetNode.parentKey] = replacementNode; + const leadingComments = targetNode.leadingComments || []; + const trailingComments = targetNode.trailingComments || []; + if (leadingComments.length) replacementNode.leadingComments = (replacementNode.leadingComments || []).concat(leadingComments); + if (trailingComments.length) replacementNode.trailingComments = (replacementNode.trailingComments || []).concat(trailingComments); + ++changesCounter; + } else if (Array.isArray(parent[targetNode.parentKey])) { + const idx = parent[targetNode.parentKey].indexOf(targetNode); + parent[targetNode.parentKey][idx] = replacementNode; + const comments = (targetNode.leadingComments || []).concat(targetNode.trailingComments || []); + if (idx > 0) { + const commentsTarget = parent[targetNode.parentKey][idx - 1]; + commentsTarget.trailingComments = (commentsTarget.trailingComments || []).concat(comments); + } else if (parent[targetNode.parentKey].length > 1) { + const commentsTarget = parent[targetNode.parentKey][idx + 1]; + commentsTarget.leadingComments = (commentsTarget.leadingComments || []).concat(comments); + } else parent.trailingComments = (parent.trailingComments || []).concat(comments); + ++changesCounter; + } + } + } catch (e) { + that.log(`[-] Unable to replace node: ${e}`); + } + } + } + if (changesCounter) { + this.replacements.length = 0; + this.markedForDeletion.length = 0; + // If any of the changes made will break the script the next line will fail and the + // script will remain the same. If it doesn't break, the changes are valid and the script can be marked as modified. + const script = generateCode(rootNode); + const ast = generateFlatAST(script); + if (ast && ast.length) { + this.ast = ast; + this.script = script; + } + else { + this.log(`[-] Modified script is invalid. Reverting ${changesCounter} changes...`); + changesCounter = 0; + } + } + } + } catch (e) { + this.log(`[-] Unable to apply changes to AST: ${e}`); + } + ++this.appliedCounter; + return changesCounter; + } +}; + +module.exports = { + Arborist, +}; +},{}],44:[function(require,module,exports){ const {parse} = require('espree'); const {generate, attachComments} = require('escodegen'); const estraverse = require('estraverse'); @@ -19198,7 +19438,7 @@ module.exports = { parseCode, }; -},{"escodegen":20,"eslint-scope":40,"espree":42,"estraverse":35}],44:[function(require,module,exports){ +},{"escodegen":20,"eslint-scope":40,"espree":42,"estraverse":35}],45:[function(require,module,exports){ 'use strict'; /* eslint no-invalid-this: 1 */ @@ -19284,14 +19524,14 @@ module.exports = function bind(that) { return bound; }; -},{}],45:[function(require,module,exports){ +},{}],46:[function(require,module,exports){ 'use strict'; var implementation = require('./implementation'); module.exports = Function.prototype.bind || implementation; -},{"./implementation":44}],46:[function(require,module,exports){ +},{"./implementation":45}],47:[function(require,module,exports){ 'use strict'; var undefined; @@ -19652,7 +19892,7 @@ module.exports = function GetIntrinsic(name, allowMissing) { return value; }; -},{"es-errors":14,"es-errors/eval":13,"es-errors/range":15,"es-errors/ref":16,"es-errors/syntax":17,"es-errors/type":18,"es-errors/uri":19,"function-bind":45,"has-proto":49,"has-symbols":50,"hasown":52}],47:[function(require,module,exports){ +},{"es-errors":14,"es-errors/eval":13,"es-errors/range":15,"es-errors/ref":16,"es-errors/syntax":17,"es-errors/type":18,"es-errors/uri":19,"function-bind":46,"has-proto":50,"has-symbols":51,"hasown":53}],48:[function(require,module,exports){ 'use strict'; var GetIntrinsic = require('get-intrinsic'); @@ -19670,7 +19910,7 @@ if ($gOPD) { module.exports = $gOPD; -},{"get-intrinsic":46}],48:[function(require,module,exports){ +},{"get-intrinsic":47}],49:[function(require,module,exports){ 'use strict'; var $defineProperty = require('es-define-property'); @@ -19694,7 +19934,7 @@ hasPropertyDescriptors.hasArrayLengthDefineBug = function hasArrayLengthDefineBu module.exports = hasPropertyDescriptors; -},{"es-define-property":12}],49:[function(require,module,exports){ +},{"es-define-property":12}],50:[function(require,module,exports){ 'use strict'; var test = { @@ -19711,7 +19951,7 @@ module.exports = function hasProto() { && !(test instanceof $Object); }; -},{}],50:[function(require,module,exports){ +},{}],51:[function(require,module,exports){ 'use strict'; var origSymbol = typeof Symbol !== 'undefined' && Symbol; @@ -19726,7 +19966,7 @@ module.exports = function hasNativeSymbols() { return hasSymbolSham(); }; -},{"./shams":51}],51:[function(require,module,exports){ +},{"./shams":52}],52:[function(require,module,exports){ 'use strict'; /* eslint complexity: [2, 18], max-statements: [2, 33] */ @@ -19770,7 +20010,7 @@ module.exports = function hasSymbols() { return true; }; -},{}],52:[function(require,module,exports){ +},{}],53:[function(require,module,exports){ 'use strict'; var call = Function.prototype.call; @@ -19780,7 +20020,7 @@ var bind = require('function-bind'); /** @type {import('.')} */ module.exports = bind.call(call, $hasOwn); -},{"function-bind":45}],53:[function(require,module,exports){ +},{"function-bind":46}],54:[function(require,module,exports){ 'use strict'; var keysShim; @@ -19904,7 +20144,7 @@ if (!Object.keys) { } module.exports = keysShim; -},{"./isArguments":55}],54:[function(require,module,exports){ +},{"./isArguments":56}],55:[function(require,module,exports){ 'use strict'; var slice = Array.prototype.slice; @@ -19938,7 +20178,7 @@ keysShim.shim = function shimObjectKeys() { module.exports = keysShim; -},{"./implementation":53,"./isArguments":55}],55:[function(require,module,exports){ +},{"./implementation":54,"./isArguments":56}],56:[function(require,module,exports){ 'use strict'; var toStr = Object.prototype.toString; @@ -19957,7 +20197,7 @@ module.exports = function isArguments(value) { return isArgs; }; -},{}],56:[function(require,module,exports){ +},{}],57:[function(require,module,exports){ 'use strict'; // modified from https://github.com/es-shims/es6-shim @@ -20005,7 +20245,7 @@ module.exports = function assign(target, source1) { return to; // step 4 }; -},{"call-bind/callBound":9,"has-symbols/shams":51,"object-keys":54}],57:[function(require,module,exports){ +},{"call-bind/callBound":9,"has-symbols/shams":52,"object-keys":55}],58:[function(require,module,exports){ 'use strict'; var implementation = require('./implementation'); @@ -20062,7 +20302,7 @@ module.exports = function getPolyfill() { return Object.assign; }; -},{"./implementation":56}],58:[function(require,module,exports){ +},{"./implementation":57}],59:[function(require,module,exports){ // shim for using process in browser var process = module.exports = {}; @@ -20248,7 +20488,7 @@ process.chdir = function (dir) { }; process.umask = function() { return 0; }; -},{}],59:[function(require,module,exports){ +},{}],60:[function(require,module,exports){ 'use strict'; var GetIntrinsic = require('get-intrinsic'); @@ -20292,4 +20532,4 @@ module.exports = function setFunctionLength(fn, length) { return fn; }; -},{"define-data-property":11,"es-errors/type":18,"get-intrinsic":46,"gopd":47,"has-property-descriptors":48}]},{},[1]); +},{"define-data-property":11,"es-errors/type":18,"get-intrinsic":47,"gopd":48,"has-property-descriptors":49}]},{},[1]); diff --git a/src/App.vue b/src/App.vue index 34a2b51..08965d0 100644 --- a/src/App.vue +++ b/src/App.vue @@ -2,13 +2,15 @@ import store from './store'; import NavBar from './NavBar.vue'; import CodeAndNodes from './CodeAndNodes.vue'; +import FilterEditor from './FilterEditor.vue'; +import TransformEditor from './TransformEditor.vue'; +import ComposeEditor from './ComposeEditor.vue'; import ToasterView from './components/ToasterView.vue'; -import FilterEditor from './components/FilterEditor.vue'; const bottomPanes = { filter: FilterEditor, - transform: '', - compose: '', + transform: TransformEditor, + compose: ComposeEditor, }; diff --git a/src/ComposeEditor.vue b/src/ComposeEditor.vue new file mode 100644 index 0000000..58445af --- /dev/null +++ b/src/ComposeEditor.vue @@ -0,0 +1,109 @@ + + + + + \ No newline at end of file diff --git a/src/components/FilterEditor.vue b/src/FilterEditor.vue similarity index 86% rename from src/components/FilterEditor.vue rename to src/FilterEditor.vue index eba0faf..1fd117a 100644 --- a/src/components/FilterEditor.vue +++ b/src/FilterEditor.vue @@ -1,14 +1,14 @@