"use strict";var t=require("obsidian");function e(t,e,i,n){return new(i||(i=Promise))((function(o,s){function r(t){try{a(n.next(t))}catch(t){s(t)}}function l(t){try{a(n.throw(t))}catch(t){s(t)}}function a(t){var e;t.done?o(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(r,l)}a((n=n.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const i=["Custom","editingToolbar","editingToolbarSub","editingToolbarAdd","editingToolbarDelete","editingToolbarReload","codeblock-glyph","underline-glyph","superscript-glyph","subscript-glyph","bot-glyph","header-1","header-2","header-3","header-4","header-5","header-6","header-n","obsidian","obsidian-new","accessibility","activity","air-vent","airplay","alarm-check","alarm-clock-off","alarm-clock","alarm-minus","alarm-plus","album","alert-circle","alert-octagon","alert-triangle","align-center-horizontal","align-center-vertical","align-center","align-end-horizontal","align-end-vertical","align-horizontal-distribute-center","align-horizontal-distribute-end","align-horizontal-distribute-start","align-horizontal-justify-center","align-horizontal-justify-end","align-horizontal-justify-start","align-horizontal-space-around","align-horizontal-space-between","align-justify","align-left","align-right","align-start-horizontal","align-start-vertical","align-vertical-distribute-center","align-vertical-distribute-end","align-vertical-distribute-start","align-vertical-justify-center","align-vertical-justify-end","align-vertical-justify-start","align-vertical-space-around","align-vertical-space-between","anchor","angry","annoyed","aperture","apple","archive-restore","archive","armchair","arrow-big-down","arrow-big-left","arrow-big-right","arrow-big-up","arrow-down-circle","arrow-down-left","arrow-down-right","arrow-down","arrow-left-circle","arrow-left-right","arrow-left","arrow-right-circle","arrow-right","arrow-up-circle","arrow-up-left","arrow-up-right","arrow-up","asterisk","at-sign","award","axe","axis-3d","baby","backpack","baggage-claim","banana","banknote","bar-chart-2","bar-chart-3","bar-chart-4","bar-chart-horizontal","bar-chart","baseline","bath","battery-charging","battery-full","battery-low","battery-medium","battery","beaker","bed-double","bed-single","bed","beer","bell-minus","bell-off","bell-plus","bell-ring","bell","bike","binary","bitcoin","bluetooth-connected","bluetooth-off","bluetooth-searching","bluetooth","bold","bomb","bone","book-open","book","bookmark-minus","bookmark-plus","bookmark","bot","box-select","box","boxes","briefcase","brush","bug","building-2","building","bus","cake","calculator","calendar-check-2","calendar-check","calendar-clock","calendar-days","calendar-heart","calendar-minus","calendar-off","calendar-plus","calendar-range","calendar-search","calendar-x2","calendar-x","calendar","camera-off","camera","car","carrot","cast","check-circle-2","check-circle","check-square","check","chef-hat","cherry","chevron-down","chevron-first","chevron-last","chevron-left","chevron-right","chevron-up","chevrons-down-up","chevrons-down","chevrons-left-right","chevrons-left","chevrons-right-left","chevrons-right","chevrons-up-down","chevrons-up","chrome","cigarette-off","cigarette","circle-dot","circle-ellipsis","circle-slashed","circle","citrus","clapperboard","clipboard-check","clipboard-copy","clipboard-edit","clipboard-list","clipboard-signature","clipboard-type","clipboard-x","clipboard","clock-1","clock-10","clock-11","clock-12","clock-2","clock-3","clock-4","clock-5","clock-6","clock-7","clock-8","clock-9","clock","cloud-cog","cloud-drizzle","cloud-fog","cloud-hail","cloud-lightning","cloud-moon-rain","cloud-moon","cloud-off","cloud-rain-wind","cloud-rain","cloud-snow","cloud-sun-rain","cloud-sun","cloud","cloudy","clover","code-2","code","codepen","codesandbox","coffee","cog","coins","columns","command","compass","component","contact","contrast","cookie","copy","copyleft","copyright","corner-down-left","corner-down-right","corner-left-down","corner-left-up","corner-right-down","corner-right-up","corner-up-left","corner-up-right","cpu","credit-card","croissant","crop","cross","crosshair","crown","cup-soda","curly-braces","currency","database","delete","diamond","dice-1","dice-2","dice-3","dice-4","dice-5","dice-6","dices","diff","disc","divide-circle","divide-square","divide","dollar-sign","download-cloud","download","dribbble","droplet","droplets","drumstick","edit-2","edit-3","edit","egg-fried","egg","equal-not","equal","eraser","euro","expand","external-link","eye-off","eye","facebook","factory","fast-forward","feather","figma","file-archive","file-audio-2","file-audio","file-axis-3d","file-badge-2","file-badge","file-bar-chart-2","file-bar-chart","file-box","file-check-2","file-check","file-clock","file-code","file-cog-2","file-cog","file-diff","file-digit","file-down","file-edit","file-heart","file-image","file-input","file-json-2","file-json","file-key-2","file-key","file-line-chart","file-lock-2","file-lock","file-minus-2","file-minus","file-output","file-pie-chart","file-plus-2","file-plus","file-question","file-scan","file-search-2","file-search","file-signature","file-spreadsheet","file-symlink","file-terminal","file-text","file-type-2","file-type","file-up","file-video-2","file-video","file-volume-2","file-volume","file-warning","file-x2","file-x","file","files","film","filter","fingerprint","flag-off","flag-triangle-left","flag-triangle-right","flag","flame","flashlight-off","flashlight","flask-conical","flask-round","flip-horizontal-2","flip-horizontal","flip-vertical-2","flip-vertical","flower-2","flower","focus","folder-archive","folder-check","folder-clock","folder-closed","folder-cog-2","folder-cog","folder-down","folder-edit","folder-heart","folder-input","folder-key","folder-lock","folder-minus","folder-open","folder-output","folder-plus","folder-search-2","folder-search","folder-symlink","folder-tree","folder-up","folder-x","folder","folders","form-input","forward","frame","framer","frown","fuel","function-square","gamepad-2","gamepad","gauge","gavel","gem","ghost","gift","git-branch-plus","git-branch","git-commit","git-compare","git-fork","git-merge","git-pull-request-closed","git-pull-request-draft","git-pull-request","github","gitlab","glass-water","glasses","globe-2","globe","grab","graduation-cap","grape","grid","grip-horizontal","grip-vertical","hammer","hand-metal","hand","hard-drive","hard-hat","hash","haze","headphones","heart-crack","heart-handshake","heart-off","heart-pulse","heart","help-circle","hexagon","highlighter","history","home","hourglass","ice-cream","image-minus","image-off","image-plus","image","import","inbox","indent","indian-rupee","infinity","info","inspect","instagram","italic","japanese-yen","joystick","key","keyboard","lamp-ceiling","lamp-desk","lamp-floor","lamp-wall-down","lamp-wall-up","lamp","landmark","languages","laptop-2","laptop","lasso-select","lasso","laugh","layers","layout-dashboard","layout-grid","layout-list","layout-template","layout","leaf","library","life-buoy","lightbulb-off","lightbulb","line-chart","link-2off","link-2","link","linkedin","list-checks","list-end","list-minus","list-music","list-ordered","list-plus","list-start","list-video","list-x","list","loader-2","loader","locate-fixed","locate-off","locate","lock","log-in","log-out","luggage","magnet","mail-check","mail-minus","mail-open","mail-plus","mail-question","mail-search","mail-warning","mail-x","mail","mails","map-pin-off","map-pin","map","martini","maximize-2","maximize","medal","megaphone-off","megaphone","meh","menu","message-circle","message-square","mic-2","mic-off","mic","microscope","milestone","minimize-2","minimize","minus-circle","minus-square","minus","monitor-off","monitor-speaker","monitor","moon","more-horizontal","more-vertical","mountain-snow","mountain","mouse-pointer-2","mouse-pointer-click","mouse-pointer","mouse","move-3d","move-diagonal-2","move-diagonal","move-horizontal","move-vertical","move","music-2","music-3","music-4","music","navigation-2off","navigation-2","navigation-off","navigation","network","newspaper","octagon","option","outdent","package-2","package-check","package-minus","package-open","package-plus","package-search","package-x","package","paint-bucket","paintbrush-2","paintbrush","palette","palmtree","paperclip","party-popper","pause-circle","pause-octagon","pause","pen-tool","pencil","percent","person-standing","phone-call","phone-forwarded","phone-incoming","phone-missed","phone-off","phone-outgoing","phone","pie-chart","piggy-bank","pin-off","pin","pipette","pizza","plane","play-circle","play","plug-zap","plus-circle","plus-square","plus","pocket","podcast","pointer","pound-sterling","power-off","power","printer","puzzle","qr-code","quote","radio-receiver","radio","recycle","redo-2","redo","refresh-ccw","refresh-cw","regex","repeat-1","repeat","reply-all","reply","rewind","rocket","rocking-chair","rotate-3d","rotate-ccw","rotate-cw","rss","ruler","russian-ruble","save","scale-3d","scale","scaling","scan-face","scan-line","scan","scissors","screen-share-off","screen-share","scroll","search","send","separator-horizontal","separator-vertical","server-cog","server-crash","server-off","server","settings-2","settings","share-2","share","sheet","shield-alert","shield-check","shield-close","shield-off","shield","shirt","shopping-bag","shopping-cart","shovel","shrink","shrub","shuffle","sidebar-close","sidebar-open","sidebar","sigma","signal-high","signal-low","signal-medium","signal-zero","signal","siren","skip-back","skip-forward","skull","slack","slash","slice","sliders-horizontal","sliders","smartphone-charging","smartphone","smile-plus","smile","snowflake","sofa","sort-asc","sort-desc","speaker","sprout","square","star-half","star-off","star","stethoscope","sticker","sticky-note","stop-circle","stretch-horizontal","stretch-vertical","strikethrough","subscript","sun-dim","sun-medium","sun-moon","sun-snow","sun","sunrise","sunset","superscript","swiss-franc","switch-camera","sword","swords","syringe","table-2","table","tablet","tag","tags","target","tent","terminal-square","terminal","text-cursor-input","text-cursor","thermometer-snowflake","thermometer-sun","thermometer","thumbs-down","thumbs-up","ticket","timer-off","timer-reset","timer","toggle-left","toggle-right","tornado","toy-brick","train","trash-2","trash","tree-deciduous","tree-pine","trees","trello","trending-down","trending-up","triangle","trophy","truck","tv-2","tv","twitch","twitter","type","umbrella","underline","undo-2","undo","unlink-2","unlink","unlock","upload-cloud","upload","usb","user-check","user-cog","user-minus","user-plus","user-x","user","users","utensils-crossed","utensils","venetian-mask","verified","vibrate-off","vibrate","video-off","video","view","voicemail","volume-1","volume-2","volume-x","volume","wallet","wand-2","wand","watch","waves","webcam","webhook","wifi-off","wifi","wind","wine","wrap-text","wrench","x-circle","x-octagon","x-square","x","youtube","zap-off","zap","zoom-in","zoom-out","create-new","trash","search","right-triangle","document","folder","pencil","left-arrow","right-arrow","three-horizontal-bars","dot-network","audio-file","image-file","pdf-file","gear","documents","blocks","go-to-file","presentation","cross-in-box","microphone","microphone-filled","two-columns","link","popup-open","checkmark","hashtag","left-arrow-with-tail","right-arrow-with-tail","up-arrow-with-tail","down-arrow-with-tail","lines-of-text","vertical-three-dots","pin","magnifying-glass","info","horizontal-split","vertical-split","calendar-with-checkmark","folder-minus","sheets-in-box","up-and-down-arrows","broken-link","cross","any-key","reset","star","crossed-star","dice","filled-pin","enter","help","vault","open-vault","paper-plane","bullet-list","uppercase-lowercase-a","star-list","expand-vertically","languages","switch","pane-layout","install","sync","check-in-circle","sync-small","check-small","paused","forward-arrow","stacked-levels","bracket-glyph","note-glyph","tag-glyph","price-tag-glyph","heading-glyph","bold-glyph","italic-glyph","strikethrough-glyph","highlight-glyph","code-glyph","quote-glyph","link-glyph","bullet-list-glyph","number-list-glyph","checkbox-glyph","undo-glyph","redo-glyph","up-chevron-glyph","down-chevron-glyph","left-chevron-glyph","right-chevron-glyph","percent-sign-glyph","keyboard-glyph","double-up-arrow-glyph","double-down-arrow-glyph","image-glyph","wrench-screwdriver-glyph","clock","plus-with-circle","minus-with-circle","indent-glyph","unindent-glyph","fullscreen","exit-fullscreen","cloud","run-command","compress-glyph","enlarge-glyph","scissors-glyph","up-curly-arrow-glyph","down-curly-arrow-glyph","plus-minus-glyph","links-going-out","links-coming-in","add-note-glyph","duplicate-glyph","clock-glyph","calendar-glyph","command-glyph","dice-glyph","file-explorer-glyph","graph-glyph","import-glyph","navigate-glyph","open-elsewhere-glyph","presentation-glyph","paper-plane-glyph","question-mark-glyph","restore-file-glyph","search-glyph","star-glyph","play-audio-glyph","stop-audio-glyph","tomorrow-glyph","wand-glyph","workspace-glyph","yesterday-glyph","box-glyph","merge-files-glyph","merge-files","two-blank-pages","scissors","paste","paste-text","split","select-all-text","wand","github-glyph","reading-glasses","user-manual-filled","discord-filled","chat-bubbles-filled","experiment-filled","bracket-glyph","box-glyph","check-small","dice-glyph","dice","discord","right-triangle","heading-glyph","help","keyboard-toggle","broken-link","experiment","left-arrow","link","link-glyph","links-coming-in","links-going-out","open-vault","paused","question-mark-glyph","right-arrow","sidebar-left","sidebar-right","sheets-in-box","star-list","sync-small","tabs","uppercase-lowercase-a","vault","stack-horizontal","stack-vertical","stretch-horizontal","stretch-vertical","distribute-space-horizontal","distribute-space-vertical"],n=1024;let o=0;class s{constructor(t,e){this.from=t,this.to=e}}class r{constructor(t={}){this.id=o++,this.perNode=!!t.perNode,this.deserialize=t.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")})}add(t){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return"function"!=typeof t&&(t=c.match(t)),e=>{let i=t(e);return void 0===i?null:[this,i]}}}r.closedBy=new r({deserialize:t=>t.split(" ")}),r.openedBy=new r({deserialize:t=>t.split(" ")}),r.group=new r({deserialize:t=>t.split(" ")}),r.isolate=new r({deserialize:t=>{if(t&&"rtl"!=t&&"ltr"!=t&&"auto"!=t)throw new RangeError("Invalid value for isolate: "+t);return t||"auto"}}),r.contextHash=new r({perNode:!0}),r.lookAhead=new r({perNode:!0}),r.mounted=new r({perNode:!0});class l{constructor(t,e,i){this.tree=t,this.overlay=e,this.parser=i}static get(t){return t&&t.props&&t.props[r.mounted.id]}}const a=Object.create(null);class c{constructor(t,e,i,n=0){this.name=t,this.props=e,this.id=i,this.flags=n}static define(t){let e=t.props&&t.props.length?Object.create(null):a,i=(t.top?1:0)|(t.skipped?2:0)|(t.error?4:0)|(null==t.name?8:0),n=new c(t.name||"",e,t.id,i);if(t.props)for(let i of t.props)if(Array.isArray(i)||(i=i(n)),i){if(i[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");e[i[0].id]=i[1]}return n}prop(t){return this.props[t.id]}get isTop(){return(1&this.flags)>0}get isSkipped(){return(2&this.flags)>0}get isError(){return(4&this.flags)>0}get isAnonymous(){return(8&this.flags)>0}is(t){if("string"==typeof t){if(this.name==t)return!0;let e=this.prop(r.group);return!!e&&e.indexOf(t)>-1}return this.id==t}static match(t){let e=Object.create(null);for(let i in t)for(let n of i.split(" "))e[n]=t[i];return t=>{for(let i=t.prop(r.group),n=-1;n<(i?i.length:0);n++){let o=e[n<0?t.name:i[n]];if(o)return o}}}}c.none=new c("",Object.create(null),0,8);const h=new WeakMap,d=new WeakMap;var u;!function(t){t[t.ExcludeBuffers=1]="ExcludeBuffers",t[t.IncludeAnonymous=2]="IncludeAnonymous",t[t.IgnoreMounts=4]="IgnoreMounts",t[t.IgnoreOverlays=8]="IgnoreOverlays"}(u||(u={}));class p{constructor(t,e,i,n,o){if(this.type=t,this.children=e,this.positions=i,this.length=n,this.props=null,o&&o.length){this.props=Object.create(null);for(let[t,e]of o)this.props["number"==typeof t?t:t.id]=e}}toString(){let t=l.get(this);if(t&&!t.overlay)return t.tree.toString();let e="";for(let t of this.children){let i=t.toString();i&&(e&&(e+=","),e+=i)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(e.length?"("+e+")":""):e}cursor(t=0){return new E(this.topNode,t)}cursorAt(t,e=0,i=0){let n=h.get(this)||this.topNode,o=new E(n);return o.moveTo(t,e),h.set(this,o._tree),o}get topNode(){return new y(this,0,0,null)}resolve(t,e=0){let i=b(h.get(this)||this.topNode,t,e,!1);return h.set(this,i),i}resolveInner(t,e=0){let i=b(d.get(this)||this.topNode,t,e,!0);return d.set(this,i),i}resolveStack(t,e=0){return function(t,e,i){let n=t.resolveInner(e,i),o=null;for(let t=n instanceof y?n:n.context.parent;t;t=t.parent)if(t.index<0){let s=t.parent;(o||(o=[n])).push(s.resolve(e,i)),t=s}else{let s=l.get(t.tree);if(s&&s.overlay&&s.overlay[0].from<=e&&s.overlay[s.overlay.length-1].to>=e){let r=new y(s.tree,s.overlay[0].from+t.from,-1,t);(o||(o=[n])).push(b(r,e,i,!1))}}return o?S(o):n}(this,t,e)}iterate(t){let{enter:e,leave:i,from:n=0,to:o=this.length}=t,s=t.mode||0,r=(s&u.IncludeAnonymous)>0;for(let t=this.cursor(s|u.IncludeAnonymous);;){let s=!1;if(t.from<=o&&t.to>=n&&(!r&&t.type.isAnonymous||!1!==e(t))){if(t.firstChild())continue;s=!0}for(;s&&i&&(r||!t.type.isAnonymous)&&i(t),!t.nextSibling();){if(!t.parent())return;s=!0}}}prop(t){return t.perNode?this.props?this.props[t.id]:void 0:this.type.prop(t)}get propValues(){let t=[];if(this.props)for(let e in this.props)t.push([+e,this.props[e]]);return t}balance(t={}){return this.children.length<=8?this:I(c.none,this.children,this.positions,0,this.children.length,0,this.length,((t,e,i)=>new p(this.type,t,e,i,this.propValues)),t.makeTree||((t,e,i)=>new p(c.none,t,e,i)))}static build(t){return function(t){var e;let{buffer:i,nodeSet:o,maxBufferLength:s=n,reused:l=[],minRepeatType:a=o.types.length}=t,c=Array.isArray(i)?new m(i,i.length):i,h=o.types,d=0,u=0;function f(t,e,i,n,r,p){let{id:m,start:k,end:S,size:T}=c,E=u,M=d;for(;T<0;){if(c.next(),-1==T){let e=l[m];return i.push(e),void n.push(k-t)}if(-3==T)return void(d=m);if(-4==T)return void(u=m);throw new RangeError(`Unrecognized record size: ${T}`)}let A,D,O=h[m],B=k-t;if(S-k<=s&&(D=C(c.pos-e,r))){let e=new Uint16Array(D.size-D.skip),i=c.pos-D.size,n=e.length;for(;c.pos>i;)n=x(D.start,e,n);A=new g(e,S-D.start,o),B=D.start-t}else{let t=c.pos-T;c.next();let e=[],i=[],n=m>=a?m:-1,o=0,r=S;for(;c.pos>t;)n>=0&&c.id==n&&c.size>=0?(c.end<=r-s&&(y(e,i,k,o,c.end,r,n,E,M),o=e.length,r=c.end),c.next()):p>2500?b(k,t,e,i):f(k,t,e,i,n,p+1);if(n>=0&&o>0&&o-1&&o>0){let t=v(O,M);A=I(O,e,i,0,e.length,0,S-k,t,t)}else A=w(O,e,i,S-k,E-S,M)}i.push(A),n.push(B)}function b(t,e,i,n){let r=[],l=0,a=-1;for(;c.pos>e;){let{id:t,start:e,end:i,size:n}=c;if(n>4)c.next();else{if(a>-1&&e=0;t-=3)e[i++]=r[t],e[i++]=r[t+1]-s,e[i++]=r[t+2]-s,e[i++]=i;i.push(new g(e,r[2]-s,o)),n.push(s-t)}}function v(t,e){return(i,n,o)=>{let s,l,a=0,c=i.length-1;if(c>=0&&(s=i[c])instanceof p){if(!c&&s.type==t&&s.length==o)return s;(l=s.prop(r.lookAhead))&&(a=n[c]+s.length+l)}return w(t,i,n,o,a,e)}}function y(t,e,i,n,s,r,l,a,c){let h=[],d=[];for(;t.length>n;)h.push(t.pop()),d.push(e.pop()+i-s);t.push(w(o.types[l],h,d,r-s,a-r,c)),e.push(s-i)}function w(t,e,i,n,o,s,l){if(s){let t=[r.contextHash,s];l=l?[t].concat(l):[t]}if(o>25){let t=[r.lookAhead,o];l=l?[t].concat(l):[t]}return new p(t,e,i,n,l)}function C(t,e){let i=c.fork(),n=0,o=0,r=0,l=i.end-s,h={size:0,start:0,skip:0};t:for(let s=i.pos-t;i.pos>s;){let t=i.size;if(i.id==e&&t>=0){h.size=n,h.start=o,h.skip=r,r+=4,n+=4,i.next();continue}let c=i.pos-t;if(t<0||c=a?4:0,u=i.start;for(i.next();i.pos>c;){if(i.size<0){if(-3!=i.size)break t;d+=4}else i.id>=a&&(d+=4);i.next()}o=u,n+=t,r+=d}return(e<0||n==t)&&(h.size=n,h.start=o,h.skip=r),h.size>4?h:void 0}function x(t,e,i){let{id:n,start:o,end:s,size:r}=c;if(c.next(),r>=0&&n4){let n=c.pos-(r-4);for(;c.pos>n;)i=x(t,e,i)}e[--i]=l,e[--i]=s-t,e[--i]=o-t,e[--i]=n}else-3==r?d=n:-4==r&&(u=n);return i}let k=[],S=[];for(;c.pos>0;)f(t.start||0,t.bufferStart||0,k,S,-1,0);let T=null!==(e=t.length)&&void 0!==e?e:k.length?S[0]+k[0].length:0;return new p(h[t.topID],k.reverse(),S.reverse(),T)}(t)}}p.empty=new p(c.none,[],[],0);class m{constructor(t,e){this.buffer=t,this.index=e}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 m(this.buffer,this.index)}}class g{constructor(t,e,i){this.buffer=t,this.length=e,this.set=i}get type(){return c.none}toString(){let t=[];for(let e=0;e0));l=s[l+3]);return r}slice(t,e,i){let n=this.buffer,o=new Uint16Array(e-t),s=0;for(let r=t,l=0;r=e&&ie;case 1:return i<=e&&n>e;case 2:return n>e;case 4:return!0}}function b(t,e,i,n){for(var o;t.from==t.to||(i<1?t.from>=e:t.from>e)||(i>-1?t.to<=e:t.to0?r.length:-1;t!=c;t+=e){let c=r[t],h=a[t]+s.from;if(f(n,i,h,h+c.length))if(c instanceof g){if(o&u.ExcludeBuffers)continue;let r=c.findChild(0,c.buffer.length,e,i-h,n);if(r>-1)return new k(new x(s,c,t,h),null,r)}else if(o&u.IncludeAnonymous||!c.type.isAnonymous||M(c)){let r;if(!(o&u.IgnoreMounts)&&(r=l.get(c))&&!r.overlay)return new y(r.tree,h,t,s);let a=new y(c,h,t,s);return o&u.IncludeAnonymous||!a.type.isAnonymous?a:a.nextChild(e<0?c.children.length-1:0,e,i,n)}}if(o&u.IncludeAnonymous||!s.type.isAnonymous)return null;if(t=s.index>=0?s.index+e:e<0?-1:s._parent._tree.children.length,s=s._parent,!s)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(t){return this.nextChild(0,1,t,2)}childBefore(t){return this.nextChild(this._tree.children.length-1,-1,t,-2)}enter(t,e,i=0){let n;if(!(i&u.IgnoreOverlays)&&(n=l.get(this._tree))&&n.overlay){let i=t-this.from;for(let{from:t,to:o}of n.overlay)if((e>0?t<=i:t=i:o>i))return new y(n.tree,n.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,t,e,i)}nextSignificantParent(){let t=this;for(;t.type.isAnonymous&&t._parent;)t=t._parent;return t}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 w(t,e,i,n){let o=t.cursor(),s=[];if(!o.firstChild())return s;if(null!=i)for(let t=!1;!t;)if(t=o.type.is(i),!o.nextSibling())return s;for(;;){if(null!=n&&o.type.is(n))return s;if(o.type.is(e)&&s.push(o.node),!o.nextSibling())return null==n?s:[]}}function C(t,e,i=e.length-1){for(let n=t;i>=0;n=n.parent){if(!n)return!1;if(!n.type.isAnonymous){if(e[i]&&e[i]!=n.name)return!1;i--}}return!0}class x{constructor(t,e,i,n){this.parent=t,this.buffer=e,this.index=i,this.start=n}}class k extends v{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(t,e,i){super(),this.context=t,this._parent=e,this.index=i,this.type=t.buffer.set.types[t.buffer.buffer[i]]}child(t,e,i){let{buffer:n}=this.context,o=n.findChild(this.index+4,n.buffer[this.index+3],t,e-this.context.start,i);return o<0?null:new k(this.context,this,o)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(t){return this.child(1,t,2)}childBefore(t){return this.child(-1,t,-2)}enter(t,e,i=0){if(i&u.ExcludeBuffers)return null;let{buffer:n}=this.context,o=n.findChild(this.index+4,n.buffer[this.index+3],e>0?1:-1,t-this.context.start,e);return o<0?null:new k(this.context,this,o)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(t){return this._parent?null:this.context.parent.nextChild(this.context.index+t,t,0,4)}get nextSibling(){let{buffer:t}=this.context,e=t.buffer[this.index+3];return e<(this._parent?t.buffer[this._parent.index+3]:t.buffer.length)?new k(this.context,this._parent,e):this.externalSibling(1)}get prevSibling(){let{buffer:t}=this.context,e=this._parent?this._parent.index+4:0;return this.index==e?this.externalSibling(-1):new k(this.context,this._parent,t.findChild(e,this.index,-1,0,4))}get tree(){return null}toTree(){let t=[],e=[],{buffer:i}=this.context,n=this.index+4,o=i.buffer[this.index+3];if(o>n){let s=i.buffer[this.index+1];t.push(i.slice(n,o,s)),e.push(0)}return new p(this.type,t,e,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function S(t){if(!t.length)return null;let e=0,i=t[0];for(let n=1;ni.from||o.to0){if(this.index-1)for(let n=e+t,o=t<0?-1:i._tree.children.length;n!=o;n+=t){let t=i._tree.children[n];if(this.mode&u.IncludeAnonymous||t instanceof g||!t.type.isAnonymous||M(t))return!1}return!0}move(t,e){if(e&&this.enterChild(t,0,4))return!0;for(;;){if(this.sibling(t))return!0;if(this.atLastNode(t)||!this.parent())return!1}}next(t=!0){return this.move(1,t)}prev(t=!0){return this.move(-1,t)}moveTo(t,e=0){for(;(this.from==this.to||(e<1?this.from>=t:this.from>t)||(e>-1?this.to<=t:this.to=0;){for(let s=t;s;s=s._parent)if(s.index==n){if(n==this.index)return s;e=s,i=o+1;break t}n=this.stack[--o]}for(let t=i;t=0;o--){if(o<0)return C(this._tree,t,n);let s=i[e.buffer[this.stack[o]]];if(!s.isAnonymous){if(t[n]&&t[n]!=s.name)return!1;n--}}return!0}}function M(t){return t.children.some((t=>t instanceof g||!t.type.isAnonymous||M(t)))}const A=new WeakMap;function D(t,e){if(!t.isAnonymous||e instanceof g||e.type!=t)return 1;let i=A.get(e);if(null==i){i=1;for(let n of e.children){if(n.type!=t||!(n instanceof p)){i=1;break}i+=D(t,n)}A.set(e,i)}return i}function I(t,e,i,n,o,s,r,l,a){let c=0;for(let i=n;i=h)break;m+=e}if(c==o+1){if(m>h){let t=i[o];e(t.children,t.positions,0,t.children.length,n[o]+l);continue}d.push(i[o])}else{let e=n[c-1]+i[c-1].length-p;d.push(I(t,i,n,o,c,p,e,null,a))}u.push(p+l-s)}}(e,i,n,o,0),(l||a)(d,u,r)}class O{constructor(t,e,i,n,o=!1,s=!1){this.from=t,this.to=e,this.tree=i,this.offset=n,this.open=(o?1:0)|(s?2:0)}get openStart(){return(1&this.open)>0}get openEnd(){return(2&this.open)>0}static addTree(t,e=[],i=!1){let n=[new O(0,t.length,t,0,!1,i)];for(let i of e)i.to>t.length&&n.push(i);return n}static applyChanges(t,e,i=128){if(!e.length)return t;let n=[],o=1,s=t.length?t[0]:null;for(let r=0,l=0,a=0;;r++){let c=r=i)for(;s&&s.from=e.from||h<=e.to||a){let t=Math.max(e.from,l)-a,i=Math.min(e.to,h)-a;e=t>=i?null:new O(t,i,e.tree,e.offset+a,r>0,!!c)}if(e&&n.push(e),s.to>h)break;s=onew s(t.from,t.to))):[new s(0,0)]:[new s(0,t.length)],this.createParse(t,e||[],i)}parse(t,e,i){let n=this.startParse(t,e,i);for(;;){let t=n.advance();if(t)return t}}}class q{constructor(t){this.string=t}get length(){return this.string.length}chunk(t){return this.string.slice(t)}get lineChunks(){return!1}read(t,e){return this.string.slice(t,e)}}new r({perNode:!0});let N=[],L=[];function R(t){if(t<768)return!1;for(let e=0,i=N.length;;){let n=e+i>>1;if(t=L[n]))return!0;e=n+1}if(e==i)return!1}}function P(t){return t>=127462&&t<=127487}(()=>{let t="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((t=>t?parseInt(t,36):1));for(let e=0,i=0;e=0&&P(H(t,n));)i++,n-=2;if(i%2==0)break;e+=2}}}return e}function V(t,e,i){for(;e>0;){let n=F(t,e-2,i);if(n=56320&&t<57344}function $(t){return t>=55296&&t<56320}function W(t){return t<65536?1:2}class U{lineAt(t){if(t<0||t>this.length)throw new RangeError(`Invalid position ${t} in document of length ${this.length}`);return this.lineInner(t,!1,1,0)}line(t){if(t<1||t>this.lines)throw new RangeError(`Invalid line number ${t} in ${this.lines}-line document`);return this.lineInner(t,!0,1,0)}replace(t,e,i){[t,e]=tt(this,t,e);let n=[];return this.decompose(0,t,n,2),i.length&&i.decompose(0,i.length,n,3),this.decompose(e,this.length,n,1),Y.from(n,this.length-(e-t)+i.length)}append(t){return this.replace(this.length,this.length,t)}slice(t,e=this.length){[t,e]=tt(this,t,e);let i=[];return this.decompose(t,e,i,0),Y.from(i,e-t)}eq(t){if(t==this)return!0;if(t.length!=this.length||t.lines!=this.lines)return!1;let e=this.scanIdentical(t,1),i=this.length-this.scanIdentical(t,-1),n=new K(this),o=new K(t);for(let t=e,s=e;;){if(n.next(t),o.next(t),t=0,n.lineBreak!=o.lineBreak||n.done!=o.done||n.value!=o.value)return!1;if(s+=n.value.length,n.done||s>=i)return!0}}iter(t=1){return new K(this,t)}iterRange(t,e=this.length){return new X(this,t,e)}iterLines(t,e){let i;if(null==t)i=this.iter();else{null==e&&(e=this.lines+1);let n=this.line(t).from;i=this.iterRange(n,Math.max(n,e==this.lines+1?this.length:e<=1?0:this.line(e-1).to))}return new J(i)}toString(){return this.sliceString(0)}toJSON(){let t=[];return this.flatten(t),t}constructor(){}static of(t){if(0==t.length)throw new RangeError("A document must have at least one line");return 1!=t.length||t[0]?t.length<=32?new j(t):Y.from(j.split(t,[])):U.empty}}class j extends U{constructor(t,e=function(t){let e=-1;for(let i of t)e+=i.length+1;return e}(t)){super(),this.text=t,this.length=e}get lines(){return this.text.length}get children(){return null}lineInner(t,e,i,n){for(let o=0;;o++){let s=this.text[o],r=n+s.length;if((e?i:r)>=t)return new Q(n,r,i,s);n=r+1,i++}}decompose(t,e,i,n){let o=t<=0&&e>=this.length?this:new j(Z(this.text,t,e),Math.min(e,this.length)-Math.max(0,t));if(1&n){let t=i.pop(),e=G(o.text,t.text.slice(),0,o.length);if(e.length<=32)i.push(new j(e,t.length+o.length));else{let t=e.length>>1;i.push(new j(e.slice(0,t)),new j(e.slice(t)))}}else i.push(o)}replace(t,e,i){if(!(i instanceof j))return super.replace(t,e,i);[t,e]=tt(this,t,e);let n=G(this.text,G(i.text,Z(this.text,0,t)),e),o=this.length+i.length-(e-t);return n.length<=32?new j(n,o):Y.from(j.split(n,[]),o)}sliceString(t,e=this.length,i="\n"){[t,e]=tt(this,t,e);let n="";for(let o=0,s=0;o<=e&&st&&s&&(n+=i),to&&(n+=r.slice(Math.max(0,t-o),e-o)),o=l+1}return n}flatten(t){for(let e of this.text)t.push(e)}scanIdentical(){return 0}static split(t,e){let i=[],n=-1;for(let o of t)i.push(o),n+=o.length+1,32==i.length&&(e.push(new j(i,n)),i=[],n=-1);return n>-1&&e.push(new j(i,n)),e}}class Y extends U{constructor(t,e){super(),this.children=t,this.length=e,this.lines=0;for(let e of t)this.lines+=e.lines}lineInner(t,e,i,n){for(let o=0;;o++){let s=this.children[o],r=n+s.length,l=i+s.lines-1;if((e?l:r)>=t)return s.lineInner(t,e,i,n);n=r+1,i=l+1}}decompose(t,e,i,n){for(let o=0,s=0;s<=e&&o=s){let o=n&((s<=t?1:0)|(l>=e?2:0));s>=t&&l<=e&&!o?i.push(r):r.decompose(t-s,e-s,i,o)}s=l+1}}replace(t,e,i){if([t,e]=tt(this,t,e),i.lines=o&&e<=r){let l=s.replace(t-o,e-o,i),a=this.lines-s.lines+l.lines;if(l.lines>4&&l.lines>a>>6){let o=this.children.slice();return o[n]=l,new Y(o,this.length-(e-t)+i.length)}return super.replace(o,r,l)}o=r+1}return super.replace(t,e,i)}sliceString(t,e=this.length,i="\n"){[t,e]=tt(this,t,e);let n="";for(let o=0,s=0;ot&&o&&(n+=i),ts&&(n+=r.sliceString(t-s,e-s,i)),s=l+1}return n}flatten(t){for(let e of this.children)e.flatten(t)}scanIdentical(t,e){if(!(t instanceof Y))return 0;let i=0,[n,o,s,r]=e>0?[0,0,this.children.length,t.children.length]:[this.children.length-1,t.children.length-1,-1,-1];for(;;n+=e,o+=e){if(n==s||o==r)return i;let l=this.children[n],a=t.children[o];if(l!=a)return i+l.scanIdentical(a,e);i+=l.length+1}}static from(t,e=t.reduce(((t,e)=>t+e.length+1),-1)){let i=0;for(let e of t)i+=e.lines;if(i<32){let i=[];for(let e of t)e.flatten(i);return new j(i,e)}let n=Math.max(32,i>>5),o=n<<1,s=n>>1,r=[],l=0,a=-1,c=[];function h(t){let e;if(t.lines>o&&t instanceof Y)for(let e of t.children)h(e);else t.lines>s&&(l>s||!l)?(d(),r.push(t)):t instanceof j&&l&&(e=c[c.length-1])instanceof j&&t.lines+e.lines<=32?(l+=t.lines,a+=t.length+1,c[c.length-1]=new j(e.text.concat(t.text),e.length+1+t.length)):(l+t.lines>n&&d(),l+=t.lines,a+=t.length+1,c.push(t))}function d(){0!=l&&(r.push(1==c.length?c[0]:Y.from(c,a)),a=-1,l=c.length=0)}for(let e of t)h(e);return d(),1==r.length?r[0]:new Y(r,e)}}function G(t,e,i=0,n=1e9){for(let o=0,s=0,r=!0;s=i&&(a>n&&(l=l.slice(0,n-o)),o0?1:(t instanceof j?t.text.length:t.children.length)<<1]}nextInner(t,e){for(this.done=this.lineBreak=!1;;){let i=this.nodes.length-1,n=this.nodes[i],o=this.offsets[i],s=o>>1,r=n instanceof j?n.text.length:n.children.length;if(s==(e>0?r:0)){if(0==i)return this.done=!0,this.value="",this;e>0&&this.offsets[i-1]++,this.nodes.pop(),this.offsets.pop()}else if((1&o)==(e>0?0:1)){if(this.offsets[i]+=e,0==t)return this.lineBreak=!0,this.value="\n",this;t--}else if(n instanceof j){let o=n.text[s+(e<0?-1:0)];if(this.offsets[i]+=e,o.length>Math.max(0,t))return this.value=0==t?o:e>0?o.slice(t):o.slice(0,o.length-t),this;t-=o.length}else{let o=n.children[s+(e<0?-1:0)];t>o.length?(t-=o.length,this.offsets[i]+=e):(e<0&&this.offsets[i]--,this.nodes.push(o),this.offsets.push(e>0?1:(o instanceof j?o.text.length:o.children.length)<<1))}}}next(t=0){return t<0&&(this.nextInner(-t,-this.dir),t=this.value.length),this.nextInner(t,this.dir)}}class X{constructor(t,e,i){this.value="",this.done=!1,this.cursor=new K(t,e>i?-1:1),this.pos=e>i?t.length:0,this.from=Math.min(e,i),this.to=Math.max(e,i)}nextInner(t,e){if(e<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;t+=Math.max(0,e<0?this.pos-this.to:this.from-this.pos);let i=e<0?this.pos-this.from:this.to-this.pos;t>i&&(t=i),i-=t;let{value:n}=this.cursor.next(t);return this.pos+=(n.length+t)*e,this.value=n.length<=i?n:e<0?n.slice(n.length-i):n.slice(0,i),this.done=!this.value,this}next(t=0){return t<0?t=Math.max(t,this.from-this.pos):t>0&&(t=Math.min(t,this.to-this.pos)),this.nextInner(t,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&""!=this.value}}class J{constructor(t){this.inner=t,this.afterBreak=!0,this.value="",this.done=!1}next(t=0){let{done:e,lineBreak:i,value:n}=this.inner.next(t);return e&&this.afterBreak?(this.value="",this.afterBreak=!1):e?(this.done=!0,this.value=""):i?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=n,this.afterBreak=!1),this}get lineBreak(){return!1}}"undefined"!=typeof Symbol&&(U.prototype[Symbol.iterator]=function(){return this.iter()},K.prototype[Symbol.iterator]=X.prototype[Symbol.iterator]=J.prototype[Symbol.iterator]=function(){return this});class Q{constructor(t,e,i,n){this.from=t,this.to=e,this.number=i,this.text=n}get length(){return this.to-this.from}}function tt(t,e,i){return[e=Math.max(0,Math.min(t.length,e)),Math.max(e,Math.min(t.length,i))]}function et(t,e,i=!0,n=!0){return _(t,e,i,n)}const it=/\r\n?|\n/;var nt=function(t){return t[t.Simple=0]="Simple",t[t.TrackDel=1]="TrackDel",t[t.TrackBefore=2]="TrackBefore",t[t.TrackAfter=3]="TrackAfter",t}(nt||(nt={}));class ot{constructor(t){this.sections=t}get length(){let t=0;for(let e=0;et)return o+(t-n);o+=r}else{if(i!=nt.Simple&&a>=t&&(i==nt.TrackDel&&nt||i==nt.TrackBefore&&nt))return null;if(a>t||a==t&&e<0&&!r)return t==n||e<0?o:o+l;o+=l}n=a}if(t>n)throw new RangeError(`Position ${t} is out of range for changeset of length ${n}`);return o}touchesRange(t,e=t){for(let i=0,n=0;i=0&&n<=e&&o>=t)return!(ne)||"cover";n=o}return!1}toString(){let t="";for(let e=0;e=0?":"+n:"")}return t}toJSON(){return this.sections}static fromJSON(t){if(!Array.isArray(t)||t.length%2||t.some((t=>"number"!=typeof t)))throw new RangeError("Invalid JSON representation of ChangeDesc");return new ot(t)}static create(t){return new ot(t)}}class st extends ot{constructor(t,e){super(t),this.inserted=e}apply(t){if(this.length!=t.length)throw new RangeError("Applying change set to a document with the wrong length");return at(this,((e,i,n,o,s)=>t=t.replace(n,n+(i-e),s)),!1),t}mapDesc(t,e=!1){return ct(this,t,e,!0)}invert(t){let e=this.sections.slice(),i=[];for(let n=0,o=0;n=0){e[n]=r,e[n+1]=s;let l=n>>1;for(;i.length0&<(i,e,o.text),o.forward(t),r+=t}let a=t[s++];for(;r>1].toJSON()))}return t}static of(t,e,i){let n=[],o=[],s=0,r=null;function l(t=!1){if(!t&&!n.length)return;sr||t<0||r>e)throw new RangeError(`Invalid change range ${t} to ${r} (in doc of length ${e})`);let h=c?"string"==typeof c?U.of(c.split(i||it)):c:U.empty,d=h.length;if(t==r&&0==d)return;ts&&rt(n,t-s,-1),rt(n,r-t,d),lt(o,n,h),s=r}}(t),l(!r),r}static empty(t){return new st(t?[t,-1]:[],[])}static fromJSON(t){if(!Array.isArray(t))throw new RangeError("Invalid JSON representation of ChangeSet");let e=[],i=[];for(let n=0;ne&&"string"!=typeof t)))throw new RangeError("Invalid JSON representation of ChangeSet");if(1==o.length)e.push(o[0],0);else{for(;i.length=0&&i<=0&&i==t[o+1]?t[o]+=e:o>=0&&0==e&&0==t[o]?t[o+1]+=i:n?(t[o]+=e,t[o+1]+=i):t.push(e,i)}function lt(t,e,i){if(0==i.length)return;let n=e.length-2>>1;if(n>1])),!(i||r==t.sections.length||t.sections[r+1]<0);)l=t.sections[r++],a=t.sections[r++];e(o,c,s,h,d),o=c,s=h}}}function ct(t,e,i,n=!1){let o=[],s=n?[]:null,r=new dt(t),l=new dt(e);for(let t=-1;;){if(r.done&&l.len||l.done&&r.len)throw new Error("Mismatched change set lengths");if(-1==r.ins&&-1==l.ins){let t=Math.min(r.len,l.len);rt(o,t,-1),r.forward(t),l.forward(t)}else if(l.ins>=0&&(r.ins<0||t==r.i||0==r.off&&(l.len=0&&t=0)){if(r.done&&l.done)return s?st.createSet(o,s):ot.create(o);throw new Error("Mismatched change set lengths")}{let e=0,i=r.len;for(;i;)if(-1==l.ins){let t=Math.min(i,l.len);e+=t,i-=t,l.forward(t)}else{if(!(0==l.ins&&l.lene||r.ins>=0&&r.len>e)&&(t||n.length>i),s.forward2(e),r.forward(e)}}else rt(n,0,r.ins,t),o&<(o,n,r.text),r.next()}}class dt{constructor(t){this.set=t,this.i=0,this.next()}next(){let{sections:t}=this.set;this.i>1;return e>=t.length?U.empty:t[e]}textBit(t){let{inserted:e}=this.set,i=this.i-2>>1;return i>=e.length&&!t?U.empty:e[i].slice(this.off,null==t?void 0:this.off+t)}forward(t){t==this.len?this.next():(this.len-=t,this.off+=t)}forward2(t){-1==this.ins?this.forward(t):t==this.ins?this.next():(this.ins-=t,this.off+=t)}}class ut{constructor(t,e,i){this.from=t,this.to=e,this.flags=i}get anchor(){return 32&this.flags?this.to:this.from}get head(){return 32&this.flags?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return 8&this.flags?-1:16&this.flags?1:0}get bidiLevel(){let t=7&this.flags;return 7==t?null:t}get goalColumn(){let t=this.flags>>6;return 16777215==t?void 0:t}map(t,e=-1){let i,n;return this.empty?i=n=t.mapPos(this.from,e):(i=t.mapPos(this.from,1),n=t.mapPos(this.to,-1)),i==this.from&&n==this.to?this:new ut(i,n,this.flags)}extend(t,e=t){if(t<=this.anchor&&e>=this.anchor)return pt.range(t,e);let i=Math.abs(t-this.anchor)>Math.abs(e-this.anchor)?t:e;return pt.range(this.anchor,i)}eq(t,e=!1){return!(this.anchor!=t.anchor||this.head!=t.head||e&&this.empty&&this.assoc!=t.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(t){if(!t||"number"!=typeof t.anchor||"number"!=typeof t.head)throw new RangeError("Invalid JSON representation for SelectionRange");return pt.range(t.anchor,t.head)}static create(t,e,i){return new ut(t,e,i)}}class pt{constructor(t,e){this.ranges=t,this.mainIndex=e}map(t,e=-1){return t.empty?this:pt.create(this.ranges.map((i=>i.map(t,e))),this.mainIndex)}eq(t,e=!1){if(this.ranges.length!=t.ranges.length||this.mainIndex!=t.mainIndex)return!1;for(let i=0;it.toJSON())),main:this.mainIndex}}static fromJSON(t){if(!t||!Array.isArray(t.ranges)||"number"!=typeof t.main||t.main>=t.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new pt(t.ranges.map((t=>ut.fromJSON(t))),t.main)}static single(t,e=t){return new pt([pt.range(t,e)],0)}static create(t,e=0){if(0==t.length)throw new RangeError("A selection needs at least one range");for(let i=0,n=0;nt?8:0)|o)}static normalized(t,e=0){let i=t[e];t.sort(((t,e)=>t.from-e.from)),e=t.indexOf(i);for(let i=1;in.head?pt.range(r,s):pt.range(s,r))}}return new pt(t,e)}}function mt(t,e){for(let i of t.ranges)if(i.to>e)throw new RangeError("Selection points outside of document")}let gt=0;class ft{constructor(t,e,i,n,o){this.combine=t,this.compareInput=e,this.compare=i,this.isStatic=n,this.id=gt++,this.default=t([]),this.extensions="function"==typeof o?o(this):o}get reader(){return this}static define(t={}){return new ft(t.combine||(t=>t),t.compareInput||((t,e)=>t===e),t.compare||(t.combine?(t,e)=>t===e:bt),!!t.static,t.enables)}of(t){return new vt([],this,0,t)}compute(t,e){if(this.isStatic)throw new Error("Can't compute a static facet");return new vt(t,this,1,e)}computeN(t,e){if(this.isStatic)throw new Error("Can't compute a static facet");return new vt(t,this,2,e)}from(t,e){return e||(e=t=>t),this.compute([t],(i=>e(i.field(t))))}}function bt(t,e){return t==e||t.length==e.length&&t.every(((t,i)=>t===e[i]))}class vt{constructor(t,e,i,n){this.dependencies=t,this.facet=e,this.type=i,this.value=n,this.id=gt++}dynamicSlot(t){var e;let i=this.value,n=this.facet.compareInput,o=this.id,s=t[o]>>1,r=2==this.type,l=!1,a=!1,c=[];for(let i of this.dependencies)"doc"==i?l=!0:"selection"==i?a=!0:1&(null!==(e=t[i.id])&&void 0!==e?e:1)||c.push(t[i.id]);return{create:t=>(t.values[s]=i(t),1),update(t,e){if(l&&e.docChanged||a&&(e.docChanged||e.selection)||wt(t,c)){let e=i(t);if(r?!yt(e,t.values[s],n):!n(e,t.values[s]))return t.values[s]=e,1}return 0},reconfigure:(t,e)=>{let l,a=e.config.address[o];if(null!=a){let o=Lt(e,a);if(this.dependencies.every((i=>i instanceof ft?e.facet(i)===t.facet(i):!(i instanceof kt)||e.field(i,!1)==t.field(i,!1)))||(r?yt(l=i(t),o,n):n(l=i(t),o)))return t.values[s]=o,0}else l=i(t);return t.values[s]=l,1}}}}function yt(t,e,i){if(t.length!=e.length)return!1;for(let n=0;nt[e.id])),o=i.map((t=>t.type)),s=n.filter((t=>!(1&t))),r=t[e.id]>>1;function l(t){let i=[];for(let e=0;et===e),t);return t.provide&&(e.provides=t.provide(e)),e}create(t){let e=t.facet(xt).find((t=>t.field==this));return((null==e?void 0:e.create)||this.createF)(t)}slot(t){let e=t[this.id]>>1;return{create:t=>(t.values[e]=this.create(t),1),update:(t,i)=>{let n=t.values[e],o=this.updateF(n,i);return this.compareF(n,o)?0:(t.values[e]=o,1)},reconfigure:(t,i)=>{let n,o=t.facet(xt),s=i.facet(xt);return(n=o.find((t=>t.field==this)))&&n!=s.find((t=>t.field==this))?(t.values[e]=n.create(t),1):null!=i.config.address[this.id]?(t.values[e]=i.field(this),0):(t.values[e]=this.create(t),1)}}}init(t){return[this,xt.of({field:this,create:t})]}get extension(){return this}}const St=4,Tt=3,Et=2,Mt=1;function At(t){return e=>new It(e,t)}const Dt={highest:At(0),high:At(Mt),default:At(Et),low:At(Tt),lowest:At(St)};class It{constructor(t,e){this.inner=t,this.prec=e}}class Ot{of(t){return new Bt(this,t)}reconfigure(t){return Ot.reconfigure.of({compartment:this,extension:t})}get(t){return t.config.compartments.get(this)}}class Bt{constructor(t,e){this.compartment=t,this.inner=e}}class qt{constructor(t,e,i,n,o,s){for(this.base=t,this.compartments=e,this.dynamicSlots=i,this.address=n,this.staticValues=o,this.facets=s,this.statusTemplate=[];this.statusTemplate.length>1]}static resolve(t,e,i){let n=[],o=Object.create(null),s=new Map;for(let i of function(t,e,i){let n=[[],[],[],[],[]],o=new Map;function s(t,r){let l=o.get(t);if(null!=l){if(l<=r)return;let e=n[l].indexOf(t);e>-1&&n[l].splice(e,1),t instanceof Bt&&i.delete(t.compartment)}if(o.set(t,r),Array.isArray(t))for(let e of t)s(e,r);else if(t instanceof Bt){if(i.has(t.compartment))throw new RangeError("Duplicate use of compartment in extensions");let n=e.get(t.compartment)||t.inner;i.set(t.compartment,n),s(n,r)}else if(t instanceof It)s(t.inner,t.prec);else if(t instanceof kt)n[r].push(t),t.provides&&s(t.provides,r);else if(t instanceof vt)n[r].push(t),t.facet.extensions&&s(t.facet.extensions,Et);else{let e=t.extension;if(!e)throw new Error(`Unrecognized extension value in extension set (${t}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);s(e,r)}}return s(t,Et),n.reduce(((t,e)=>t.concat(e)))}(t,e,s))i instanceof kt?n.push(i):(o[i.facet.id]||(o[i.facet.id]=[])).push(i);let r=Object.create(null),l=[],a=[];for(let t of n)r[t.id]=a.length<<1,a.push((e=>t.slot(e)));let c=null==i?void 0:i.config.facets;for(let t in o){let e=o[t],n=e[0].facet,s=c&&c[t]||[];if(e.every((t=>0==t.type)))if(r[n.id]=l.length<<1|1,bt(s,e))l.push(i.facet(n));else{let t=n.combine(e.map((t=>t.value)));l.push(i&&n.compare(t,i.facet(n))?i.facet(n):t)}else{for(let t of e)0==t.type?(r[t.id]=l.length<<1|1,l.push(t.value)):(r[t.id]=a.length<<1,a.push((e=>t.dynamicSlot(e))));r[n.id]=a.length<<1,a.push((t=>Ct(t,n,e)))}}let h=a.map((t=>t(r)));return new qt(t,s,h,r,l,o)}}function Nt(t,e){if(1&e)return 2;let i=e>>1,n=t.status[i];if(4==n)throw new Error("Cyclic dependency between fields and/or facets");if(2&n)return n;t.status[i]=4;let o=t.computeSlot(t,t.config.dynamicSlots[i]);return t.status[i]=2|o}function Lt(t,e){return 1&e?t.config.staticValues[e>>1]:t.values[e>>1]}const Rt=ft.define(),Pt=ft.define({combine:t=>t.some((t=>t)),static:!0}),_t=ft.define({combine:t=>t.length?t[0]:void 0,static:!0}),Ft=ft.define(),Vt=ft.define(),Ht=ft.define(),zt=ft.define({combine:t=>!!t.length&&t[0]});class $t{constructor(t,e){this.type=t,this.value=e}static define(){return new Wt}}class Wt{of(t){return new $t(this,t)}}class Ut{constructor(t){this.map=t}of(t){return new jt(this,t)}}class jt{constructor(t,e){this.type=t,this.value=e}map(t){let e=this.type.map(this.value,t);return void 0===e?void 0:e==this.value?this:new jt(this.type,e)}is(t){return this.type==t}static define(t={}){return new Ut(t.map||(t=>t))}static mapEffects(t,e){if(!t.length)return t;let i=[];for(let n of t){let t=n.map(e);t&&i.push(t)}return i}}jt.reconfigure=jt.define(),jt.appendConfig=jt.define();class Yt{constructor(t,e,i,n,o,s){this.startState=t,this.changes=e,this.selection=i,this.effects=n,this.annotations=o,this.scrollIntoView=s,this._doc=null,this._state=null,i&&mt(i,e.newLength),o.some((t=>t.type==Yt.time))||(this.annotations=o.concat(Yt.time.of(Date.now())))}static create(t,e,i,n,o,s){return new Yt(t,e,i,n,o,s)}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(t){for(let e of this.annotations)if(e.type==t)return e.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(t){let e=this.annotation(Yt.userEvent);return!(!e||!(e==t||e.length>t.length&&e.slice(0,t.length)==t&&"."==e[t.length]))}}function Gt(t,e){let i=[];for(let n=0,o=0;;){let s,r;if(n=t[n]))s=t[n++],r=t[n++];else{if(!(o=0;o--){let s=i[o](t);s&&Object.keys(s).length&&(n=Zt(n,Kt(e,s,t.changes.newLength),!0))}return n==t?t:Yt.create(e,t.changes,t.selection,n.effects,n.annotations,n.scrollIntoView)}(i?function(t){let e=t.startState,i=!0;for(let n of e.facet(Ft)){let e=n(t);if(!1===e){i=!1;break}Array.isArray(e)&&(i=!0===i?e:Gt(i,e))}if(!0!==i){let n,o;if(!1===i)o=t.changes.invertedDesc,n=st.empty(e.doc.length);else{let e=t.changes.filter(i);n=e.changes,o=e.filtered.mapDesc(e.changes).invertedDesc}t=Yt.create(e,n,t.selection&&t.selection.map(o),jt.mapEffects(t.effects,o),t.annotations,t.scrollIntoView)}let n=e.facet(Vt);for(let i=n.length-1;i>=0;i--){let o=n[i](t);t=o instanceof Yt?o:Array.isArray(o)&&1==o.length&&o[0]instanceof Yt?o[0]:Xt(e,Qt(o),!1)}return t}(o):o)}Yt.time=$t.define(),Yt.userEvent=$t.define(),Yt.addToHistory=$t.define(),Yt.remote=$t.define();const Jt=[];function Qt(t){return null==t?Jt:Array.isArray(t)?t:[t]}var te=function(t){return t[t.Word=0]="Word",t[t.Space=1]="Space",t[t.Other=2]="Other",t}(te||(te={}));const ee=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let ie;try{ie=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch(t){}function ne(t){return e=>{if(!/\S/.test(e))return te.Space;if(function(t){if(ie)return ie.test(t);for(let e=0;e"€"&&(i.toUpperCase()!=i.toLowerCase()||ee.test(i)))return!0}return!1}(e))return te.Word;for(let i=0;i-1)return te.Word;return te.Other}}class oe{constructor(t,e,i,n,o,s){this.config=t,this.doc=e,this.selection=i,this.values=n,this.status=t.statusTemplate.slice(),this.computeSlot=o,s&&(s._state=this);for(let t=0;to.set(e,t))),i=null),o.set(e.value.compartment,e.value.extension)):e.is(jt.reconfigure)?(i=null,n=e.value):e.is(jt.appendConfig)&&(i=null,n=Qt(n).concat(e.value));if(i)e=t.startState.values.slice();else{i=qt.resolve(n,o,this),e=new oe(i,this.doc,this.selection,i.dynamicSlots.map((()=>null)),((t,e)=>e.reconfigure(t,this)),null).values}let s=t.startState.facet(Pt)?t.newSelection:t.newSelection.asSingle();new oe(i,t.newDoc,s,e,((e,i)=>i.update(e,t)),t)}replaceSelection(t){return"string"==typeof t&&(t=this.toText(t)),this.changeByRange((e=>({changes:{from:e.from,to:e.to,insert:t},range:pt.cursor(e.from+t.length)})))}changeByRange(t){let e=this.selection,i=t(e.ranges[0]),n=this.changes(i.changes),o=[i.range],s=Qt(i.effects);for(let i=1;io.spec.fromJSON(s,t))))}return oe.create({doc:t.doc,selection:pt.fromJSON(t.selection),extensions:e.extensions?n.concat([e.extensions]):n})}static create(t={}){let e=qt.resolve(t.extensions||[],new Map),i=t.doc instanceof U?t.doc:U.of((t.doc||"").split(e.staticFacet(oe.lineSeparator)||it)),n=t.selection?t.selection instanceof pt?t.selection:pt.single(t.selection.anchor,t.selection.head):pt.single(0);return mt(n,i.length),e.staticFacet(Pt)||(n=n.asSingle()),new oe(e,i,n,e.dynamicSlots.map((()=>null)),((t,e)=>e.create(t)),null)}get tabSize(){return this.facet(oe.tabSize)}get lineBreak(){return this.facet(oe.lineSeparator)||"\n"}get readOnly(){return this.facet(zt)}phrase(t,...e){for(let e of this.facet(oe.phrases))if(Object.prototype.hasOwnProperty.call(e,t)){t=e[t];break}return e.length&&(t=t.replace(/\$(\$|\d*)/g,((t,i)=>{if("$"==i)return"$";let n=+(i||1);return!n||n>e.length?t:e[n-1]}))),t}languageDataAt(t,e,i=-1){let n=[];for(let o of this.facet(Rt))for(let s of o(this,e,i))Object.prototype.hasOwnProperty.call(s,t)&&n.push(s[t]);return n}charCategorizer(t){return ne(this.languageDataAt("wordChars",t).join(""))}wordAt(t){let{text:e,from:i,length:n}=this.doc.lineAt(t),o=this.charCategorizer(t),s=t-i,r=t-i;for(;s>0;){let t=et(e,s,!1);if(o(e.slice(t,s))!=te.Word)break;s=t}for(;rt.length?t[0]:4}),oe.lineSeparator=_t,oe.readOnly=zt,oe.phrases=ft.define({compare(t,e){let i=Object.keys(t),n=Object.keys(e);return i.length==n.length&&i.every((i=>t[i]==e[i]))}}),oe.languageData=Rt,oe.changeFilter=Ft,oe.transactionFilter=Vt,oe.transactionExtender=Ht,Ot.reconfigure=jt.define();class se{eq(t){return this==t}range(t,e=t){return re.create(t,e,this)}}se.prototype.startSide=se.prototype.endSide=0,se.prototype.point=!1,se.prototype.mapMode=nt.TrackDel;class re{constructor(t,e,i){this.from=t,this.to=e,this.value=i}static create(t,e,i){return new re(t,e,i)}}function le(t,e){return t.from-e.from||t.value.startSide-e.value.startSide}class ae{constructor(t,e,i,n){this.from=t,this.to=e,this.value=i,this.maxPoint=n}get length(){return this.to[this.to.length-1]}findIndex(t,e,i,n=0){let o=i?this.to:this.from;for(let s=n,r=o.length;;){if(s==r)return s;let n=s+r>>1,l=o[n]-t||(i?this.value[n].endSide:this.value[n].startSide)-e;if(n==s)return l>=0?s:r;l>=0?r=n:s=n+1}}between(t,e,i,n){for(let o=this.findIndex(e,-1e9,!0),s=this.findIndex(i,1e9,!1,o);oc||a==c&&h.startSide>0&&h.endSide<=0)continue;(c-a||h.endSide-h.startSide)<0||(s<0&&(s=a),h.point&&(r=Math.max(r,c-a)),i.push(h),n.push(a-s),o.push(c-s))}return{mapped:i.length?new ae(n,o,i,r):null,pos:s}}}class ce{constructor(t,e,i,n){this.chunkPos=t,this.chunk=e,this.nextLayer=i,this.maxPoint=n}static create(t,e,i,n){return new ce(t,e,i,n)}get length(){let t=this.chunk.length-1;return t<0?0:Math.max(this.chunkEnd(t),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let t=this.nextLayer.size;for(let e of this.chunk)t+=e.value.length;return t}chunkEnd(t){return this.chunkPos[t]+this.chunk[t].length}update(t){let{add:e=[],sort:i=!1,filterFrom:n=0,filterTo:o=this.length}=t,s=t.filter;if(0==e.length&&!s)return this;if(i&&(e=e.slice().sort(le)),this.isEmpty)return e.length?ce.of(e):this;let r=new ue(this,null,-1).goto(0),l=0,a=[],c=new he;for(;r.value||l=0){let t=e[l++];c.addInner(t.from,t.to,t.value)||a.push(t)}else 1==r.rangeIndex&&r.chunkIndexthis.chunkEnd(r.chunkIndex)||or.to||o=o&&t<=o+s.length&&!1===s.between(o,t-o,e-o,i))return}this.nextLayer.between(t,e,i)}}iter(t=0){return pe.from([this]).goto(t)}get isEmpty(){return this.nextLayer==this}static iter(t,e=0){return pe.from(t).goto(e)}static compare(t,e,i,n,o=-1){let s=t.filter((t=>t.maxPoint>0||!t.isEmpty&&t.maxPoint>=o)),r=e.filter((t=>t.maxPoint>0||!t.isEmpty&&t.maxPoint>=o)),l=de(s,r,i),a=new ge(s,l,o),c=new ge(r,l,o);i.iterGaps(((t,e,i)=>fe(a,t,c,e,i,n))),i.empty&&0==i.length&&fe(a,0,c,0,0,n)}static eq(t,e,i=0,n){null==n&&(n=999999999);let o=t.filter((t=>!t.isEmpty&&e.indexOf(t)<0)),s=e.filter((e=>!e.isEmpty&&t.indexOf(e)<0));if(o.length!=s.length)return!1;if(!o.length)return!0;let r=de(o,s),l=new ge(o,r,0).goto(i),a=new ge(s,r,0).goto(i);for(;;){if(l.to!=a.to||!be(l.active,a.active)||l.point&&(!a.point||!l.point.eq(a.point)))return!1;if(l.to>n)return!0;l.next(),a.next()}}static spans(t,e,i,n,o=-1){let s=new ge(t,null,o).goto(e),r=e,l=s.openStart;for(;;){let t=Math.min(s.to,i);if(s.point){let i=s.activeForPoint(s.to),o=s.pointFromr&&(n.span(r,t,s.active,l),l=s.openEnd(t));if(s.to>i)return l+(s.point&&s.to>i?1:0);r=s.to,s.next()}}static of(t,e=!1){let i=new he;for(let n of t instanceof re?[t]:e?function(t){if(t.length>1)for(let e=t[0],i=1;i0)return t.slice().sort(le);e=n}return t}(t):t)i.add(n.from,n.to,n.value);return i.finish()}static join(t){if(!t.length)return ce.empty;let e=t[t.length-1];for(let i=t.length-2;i>=0;i--)for(let n=t[i];n!=ce.empty;n=n.nextLayer)e=new ce(n.chunkPos,n.chunk,e,Math.max(n.maxPoint,e.maxPoint));return e}}ce.empty=new ce([],[],null,-1),ce.empty.nextLayer=ce.empty;class he{finishChunk(t){this.chunks.push(new ae(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,t&&(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(t,e,i){this.addInner(t,e,i)||(this.nextLayer||(this.nextLayer=new he)).add(t,e,i)}addInner(t,e,i){let n=t-this.lastTo||i.startSide-this.last.endSide;if(n<=0&&(t-this.lastFrom||i.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return!(n<0)&&(250==this.from.length&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=t),this.from.push(t-this.chunkStart),this.to.push(e-this.chunkStart),this.last=i,this.lastFrom=t,this.lastTo=e,this.value.push(i),i.point&&(this.maxPoint=Math.max(this.maxPoint,e-t)),!0)}addChunk(t,e){if((t-this.lastTo||e.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,e.maxPoint),this.chunks.push(e),this.chunkPos.push(t);let i=e.value.length-1;return this.last=e.value[i],this.lastFrom=e.from[i]+t,this.lastTo=e.to[i]+t,!0}finish(){return this.finishInner(ce.empty)}finishInner(t){if(this.from.length&&this.finishChunk(!1),0==this.chunks.length)return t;let e=ce.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(t):t,this.setMaxPoint);return this.from=null,e}}function de(t,e,i){let n=new Map;for(let e of t)for(let t=0;t=this.minPoint)break}}}setRangeIndex(t){if(t==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex=i&&n.push(new ue(s,e,i,o));return 1==n.length?n[0]:new pe(n)}get startSide(){return this.value?this.value.startSide:0}goto(t,e=-1e9){for(let i of this.heap)i.goto(t,e);for(let t=this.heap.length>>1;t>=0;t--)me(this.heap,t);return this.next(),this}forward(t,e){for(let i of this.heap)i.forward(t,e);for(let t=this.heap.length>>1;t>=0;t--)me(this.heap,t);(this.to-t||this.value.endSide-e)<0&&this.next()}next(){if(0==this.heap.length)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let t=this.heap[0];this.from=t.from,this.to=t.to,this.value=t.value,this.rank=t.rank,t.value&&t.next(),me(this.heap,0)}}}function me(t,e){for(let i=t[e];;){let n=1+(e<<1);if(n>=t.length)break;let o=t[n];if(n+1=0&&(o=t[n+1],n++),i.compare(o)<0)break;t[n]=i,t[e]=o,e=n}}class ge{constructor(t,e,i){this.minPoint=i,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=pe.from(t,e,i)}goto(t,e=-1e9){return this.cursor.goto(t,e),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=t,this.endSide=e,this.openStart=-1,this.next(),this}forward(t,e){for(;this.minActive>-1&&(this.activeTo[this.minActive]-t||this.active[this.minActive].endSide-e)<0;)this.removeActive(this.minActive);this.cursor.forward(t,e)}removeActive(t){ve(this.active,t),ve(this.activeTo,t),ve(this.activeRank,t),this.minActive=we(this.active,this.activeTo)}addActive(t){let e=0,{value:i,to:n,rank:o}=this.cursor;for(;e0;)e++;ye(this.active,e,i),ye(this.activeTo,e,n),ye(this.activeRank,e,o),t&&ye(t,e,this.cursor.from),this.minActive=we(this.active,this.activeTo)}next(){let t=this.to,e=this.point;this.point=null;let i=this.openStart<0?[]:null;for(;;){let n=this.minActive;if(n>-1&&(this.activeTo[n]-this.cursor.from||this.active[n].endSide-this.cursor.startSide)<0){if(this.activeTo[n]>t){this.to=this.activeTo[n],this.endSide=this.active[n].endSide;break}this.removeActive(n),i&&ve(i,n)}else{if(!this.cursor.value){this.to=this.endSide=1e9;break}if(this.cursor.from>t){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}{let t=this.cursor.value;if(t.point){if(!(e&&this.cursor.to==this.to&&this.cursor.from=0&&i[e]=0&&!(this.activeRank[i]t||this.activeTo[i]==t&&this.active[i].endSide>=this.point.endSide)&&e.push(this.active[i]);return e.reverse()}openEnd(t){let e=0;for(let i=this.activeTo.length-1;i>=0&&this.activeTo[i]>t;i--)e++;return e}}function fe(t,e,i,n,o,s){t.goto(e),i.goto(n);let r=n+o,l=n,a=n-e;for(;;){let e=t.to+a-i.to,n=e||t.endSide-i.endSide,o=n<0?t.to+a:i.to,c=Math.min(o,r);if(t.point||i.point?t.point&&i.point&&(t.point==i.point||t.point.eq(i.point))&&be(t.activeForPoint(t.to),i.activeForPoint(i.to))||s.comparePoint(l,c,t.point,i.point):c>l&&!be(t.active,i.active)&&s.compareRange(l,c,t.active,i.active),o>r)break;(e||t.openEnd!=i.openEnd)&&s.boundChange&&s.boundChange(o),l=o,n<=0&&t.next(),n>=0&&i.next()}}function be(t,e){if(t.length!=e.length)return!1;for(let i=0;i=e;i--)t[i+1]=t[i];t[e]=i}function we(t,e){let i=-1,n=1e9;for(let o=0;ot.map((t=>e.replace(/&/,t))))).reduce(((t,e)=>t.concat(e))),r,s);else if(r&&"object"==typeof r){if(!a)throw new RangeError("The value of a property ("+i+") should be a primitive value.");o(n(i),r,l,c)}else null!=r&&l.push(i.replace(/_.*/,"").replace(/[A-Z]/g,(t=>"-"+t.toLowerCase()))+": "+r+";")}(l.length||c)&&s.push((!i||a||r?t:t.map(i)).join(", ")+" {"+l.join(" ")+"}")}for(let e in t)o(n(e),t[e],this.rules)}getRules(){return this.rules.join("\n")}static newName(){let t=ke[Ce]||1;return ke[Ce]=t+1,"ͼ"+t.toString(36)}static mount(t,e,i){let n=t[xe],o=i&&i.nonce;n?o&&n.setNonce(o):n=new Ee(t,o),n.mount(Array.isArray(e)?e:[e],t)}}let Te=new Map;class Ee{constructor(t,e){let i=t.ownerDocument||t,n=i.defaultView;if(!t.head&&t.adoptedStyleSheets&&n.CSSStyleSheet){let e=Te.get(i);if(e)return t[xe]=e;this.sheet=new n.CSSStyleSheet,Te.set(i,this)}else this.styleTag=i.createElement("style"),e&&this.styleTag.setAttribute("nonce",e);this.modules=[],t[xe]=this}mount(t,e){let i=this.sheet,n=0,o=0;for(let e=0;e-1&&(this.modules.splice(r,1),o--,r=-1),-1==r){if(this.modules.splice(o++,0,s),i)for(let t=0;t",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'};"undefined"!=typeof navigator&&/Mac/.test(navigator.platform),"undefined"!=typeof navigator&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var De=0;De<10;De++)Me[48+De]=Me[96+De]=String(De);for(De=1;De<=24;De++)Me[De+111]="F"+De;for(De=65;De<=90;De++)Me[De]=String.fromCharCode(De+32),Ae[De]=String.fromCharCode(De);for(var Ie in Me)Ae.hasOwnProperty(Ie)||(Ae[Ie]=Me[Ie]);function Oe(t){let e;return e=11==t.nodeType?t.getSelection?t:t.ownerDocument:t,e.getSelection()}function Be(t,e){return!!e&&(t==e||t.contains(1!=e.nodeType?e.parentNode:e))}function qe(t,e){if(!e.anchorNode)return!1;try{return Be(t,e.anchorNode)}catch(t){return!1}}function Ne(t){return 3==t.nodeType?Ye(t,0,t.nodeValue.length).getClientRects():1==t.nodeType?t.getClientRects():[]}function Le(t,e,i,n){return!!i&&(_e(t,e,i,n,-1)||_e(t,e,i,n,1))}function Re(t){for(var e=0;;e++)if(!(t=t.previousSibling))return e}function Pe(t){return 1==t.nodeType&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(t.nodeName)}function _e(t,e,i,n,o){for(;;){if(t==i&&e==n)return!0;if(e==(o<0?0:Fe(t))){if("DIV"==t.nodeName)return!1;let i=t.parentNode;if(!i||1!=i.nodeType)return!1;e=Re(t)+(o<0?0:1),t=i}else{if(1!=t.nodeType)return!1;if(1==(t=t.childNodes[e+(o<0?-1:0)]).nodeType&&"false"==t.contentEditable)return!1;e=o<0?Fe(t):0}}}function Fe(t){return 3==t.nodeType?t.nodeValue.length:t.childNodes.length}function Ve(t,e){let i=e?t.left:t.right;return{left:i,right:i,top:t.top,bottom:t.bottom}}function He(t){let e=t.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.innerWidth,top:0,bottom:t.innerHeight}}function ze(t,e){let i=e.width/t.offsetWidth,n=e.height/t.offsetHeight;return(i>.995&&i<1.005||!isFinite(i)||Math.abs(e.width-t.offsetWidth)<1)&&(i=1),(n>.995&&n<1.005||!isFinite(n)||Math.abs(e.height-t.offsetHeight)<1)&&(n=1),{scaleX:i,scaleY:n}}class $e{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(t){return this.anchorNode==t.anchorNode&&this.anchorOffset==t.anchorOffset&&this.focusNode==t.focusNode&&this.focusOffset==t.focusOffset}setRange(t){let{anchorNode:e,focusNode:i}=t;this.set(e,Math.min(t.anchorOffset,e?Fe(e):0),i,Math.min(t.focusOffset,i?Fe(i):0))}set(t,e,i,n){this.anchorNode=t,this.anchorOffset=e,this.focusNode=i,this.focusOffset=n}}let We,Ue=null;function je(t){if(t.setActive)return t.setActive();if(Ue)return t.focus(Ue);let e=[];for(let i=t;i&&(e.push(i,i.scrollTop,i.scrollLeft),i!=i.ownerDocument);i=i.parentNode);if(t.focus(null==Ue?{get preventScroll(){return Ue={preventScroll:!0},!0}}:void 0),!Ue){Ue=!1;for(let t=0;tMath.max(1,t.scrollHeight-t.clientHeight-4)}function Xe(t,e){for(let i=t,n=e;;){if(3==i.nodeType&&n>0)return{node:i,offset:n};if(1==i.nodeType&&n>0){if("false"==i.contentEditable)return null;i=i.childNodes[n-1],n=Fe(i)}else{if(!i.parentNode||Pe(i))return null;n=Re(i),i=i.parentNode}}}function Je(t,e){for(let i=t,n=e;;){if(3==i.nodeType&&ne)return i.domBoundsAround(t,e,a);if(h>=t&&-1==n&&(n=l,o=a),a>e&&i.dom.parentNode==this.dom){s=l,r=c;break}c=h,a=h+i.breakAfter}return{from:o,to:r<0?i+this.length:r,startDOM:(n?this.children[n-1].dom.nextSibling:null)||this.dom.firstChild,endDOM:s=0?this.children[s].dom:null}}markDirty(t=!1){this.flags|=2,this.markParentsDirty(t)}markParentsDirty(t){for(let e=this.parent;e;e=e.parent){if(t&&(e.flags|=2),1&e.flags)return;e.flags|=1,t=!1}}setParent(t){this.parent!=t&&(this.parent=t,7&this.flags&&this.markParentsDirty(!0))}setDOM(t){this.dom!=t&&(this.dom&&(this.dom.cmView=null),this.dom=t,t.cmView=this)}get rootView(){for(let t=this;;){let e=t.parent;if(!e)return t;t=e}}replaceChildren(t,e,i=ti){this.markDirty();for(let n=t;nthis.pos||t==this.pos&&(e>0||0==this.i||this.children[this.i-1].breakAfter))return this.off=t-this.pos,this;let i=this.children[--this.i];this.pos-=i.length+i.breakAfter}}}function oi(t,e,i,n,o,s,r,l,a){let{children:c}=t,h=c.length?c[e]:null,d=s.length?s[s.length-1]:null,u=d?d.breakAfter:r;if(!(e==n&&h&&!r&&!u&&s.length<2&&h.merge(i,o,s.length?d:null,0==i,l,a))){if(n0&&(!r&&s.length&&h.merge(i,h.length,s[0],!1,l,0)?h.breakAfter=s.shift().breakAfter:(i2);var bi={mac:fi||/Mac/.test(ri.platform),windows:/Win/.test(ri.platform),linux:/Linux|X11/.test(ri.platform),ie:di,ie_version:ci?li.documentMode||6:hi?+hi[1]:ai?+ai[1]:0,gecko:ui,gecko_version:ui?+(/Firefox\/(\d+)/.exec(ri.userAgent)||[0,0])[1]:0,chrome:!!pi,chrome_version:pi?+pi[1]:0,ios:fi,android:/Android\b/.test(ri.userAgent),webkit:mi,safari:gi,webkit_version:mi?+(/\bAppleWebKit\/(\d+)/.exec(ri.userAgent)||[0,0])[1]:0,tabSize:null!=li.documentElement.style.tabSize?"tab-size":"-moz-tab-size"};class vi extends ei{constructor(t){super(),this.text=t}get length(){return this.text.length}createDOM(t){this.setDOM(t||document.createTextNode(this.text))}sync(t,e){this.dom||this.createDOM(),this.dom.nodeValue!=this.text&&(e&&e.node==this.dom&&(e.written=!0),this.dom.nodeValue=this.text)}reuseDOM(t){3==t.nodeType&&this.createDOM(t)}merge(t,e,i){return!(8&this.flags||i&&(!(i instanceof vi)||this.length-(e-t)+i.length>256||8&i.flags))&&(this.text=this.text.slice(0,t)+(i?i.text:"")+this.text.slice(e),this.markDirty(),!0)}split(t){let e=new vi(this.text.slice(t));return this.text=this.text.slice(0,t),this.markDirty(),e.flags|=8&this.flags,e}localPosFromDOM(t,e){return t==this.dom?e:e?this.text.length:0}domAtPos(t){return new Qe(this.dom,t)}domBoundsAround(t,e,i){return{from:i,to:i+this.length,startDOM:this.dom,endDOM:this.dom.nextSibling}}coordsAt(t,e){return function(t,e,i){let n=t.nodeValue.length;e>n&&(e=n);let o=e,s=e,r=0;0==e&&i<0||e==n&&i>=0?bi.chrome||bi.gecko||(e?(o--,r=1):s=0)?0:l.length-1];bi.safari&&!r&&0==a.width&&(a=Array.prototype.find.call(l,(t=>t.width))||a);return r?Ve(a,r<0):a||null}(this.dom,t,e)}}class yi extends ei{constructor(t,e=[],i=0){super(),this.mark=t,this.children=e,this.length=i;for(let t of e)t.setParent(this)}setAttrs(t){if(Ze(t),this.mark.class&&(t.className=this.mark.class),this.mark.attrs)for(let e in this.mark.attrs)t.setAttribute(e,this.mark.attrs[e]);return t}canReuseDOM(t){return super.canReuseDOM(t)&&!(8&(this.flags|t.flags))}reuseDOM(t){t.nodeName==this.mark.tagName.toUpperCase()&&(this.setDOM(t),this.flags|=6)}sync(t,e){this.dom?4&this.flags&&this.setAttrs(this.dom):this.setDOM(this.setAttrs(document.createElement(this.mark.tagName))),super.sync(t,e)}merge(t,e,i,n,o,s){return(!i||!(!(i instanceof yi&&i.mark.eq(this.mark))||t&&o<=0||et&&e.push(i=t&&(n=o),i=r,o++}let s=this.length-t;return this.length=t,n>-1&&(this.children.length=n,this.markDirty()),new yi(this.mark,e,s)}domAtPos(t){return xi(this,t)}coordsAt(t,e){return Si(this,t,e)}}class wi extends ei{static create(t,e,i){return new wi(t,e,i)}constructor(t,e,i){super(),this.widget=t,this.length=e,this.side=i,this.prevWidget=null}split(t){let e=wi.create(this.widget,this.length-t,this.side);return this.length-=t,e}sync(t){this.dom&&this.widget.updateDOM(this.dom,t)||(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(t)),this.widget.editable||(this.dom.contentEditable="false"))}getSide(){return this.side}merge(t,e,i,n,o,s){return!(i&&(!(i instanceof wi&&this.widget.compare(i.widget))||t>0&&o<=0||e0)?Qe.before(this.dom):Qe.after(this.dom,t==this.length)}domBoundsAround(){return null}coordsAt(t,e){let i=this.widget.coordsAt(this.dom,t,e);if(i)return i;let n=this.dom.getClientRects(),o=null;if(!n.length)return null;let s=this.side?this.side<0:t>0;for(let e=s?n.length-1:0;o=n[e],!(t>0?0==e:e==n.length-1||o.top0?Qe.before(this.dom):Qe.after(this.dom)}localPosFromDOM(){return 0}domBoundsAround(){return null}coordsAt(t){return this.dom.getBoundingClientRect()}get overrideDOMText(){return U.empty}get isHidden(){return!0}}function xi(t,e){let i=t.dom,{children:n}=t,o=0;for(let t=0;ot&&e0;t--){let e=n[t-1];if(e.dom.parentNode==i)return e.domAtPos(e.length)}for(let t=o;t0&&e instanceof yi&&o.length&&(n=o[o.length-1])instanceof yi&&n.mark.eq(e.mark)?ki(n,e.children[0],i-1):(o.push(e),e.setParent(t)),t.length+=e.length}function Si(t,e,i){let n=null,o=-1,s=null,r=-1;!function t(e,l){for(let a=0,c=0;a=l&&(h.children.length?t(h,l-c):(!s||s.isHidden&&(i>0||Ti(s,h)))&&(d>l||c==d&&h.getSide()>0)?(s=h,r=l-c):(c-1?1:0)!=o.length-(i&&o.indexOf(i)>-1?1:0))return!1;for(let s of n)if(s!=i&&(-1==o.indexOf(s)||t[s]!==e[s]))return!1;return!0}function Di(t,e,i){let n=!1;if(e)for(let o in e)i&&o in i||(n=!0,"style"==o?t.style.cssText="":t.removeAttribute(o));if(i)for(let o in i)e&&e[o]==i[o]||(n=!0,"style"==o?t.style.cssText=i[o]:t.setAttribute(o,i[o]));return n}function Ii(t){let e=Object.create(null);for(let i=0;i0?3e8:-4e8:e>0?1e8:-1e8,new Ri(t,e,e,i,t.widget||null,!1)}static replace(t){let e,i,n=!!t.block;if(t.isBlockGap)e=-5e8,i=4e8;else{let{start:o,end:s}=Pi(t,n);e=(o?n?-3e8:-1:5e8)-1,i=1+(s?n?2e8:1:-6e8)}return new Ri(t,e,i,n,t.widget||null,!0)}static line(t){return new Li(t)}static set(t,e=!1){return ce.of(t,e)}hasHeight(){return!!this.widget&&this.widget.estimatedHeight>-1}}qi.none=ce.empty;class Ni extends qi{constructor(t){let{start:e,end:i}=Pi(t);super(e?-1:5e8,i?1:-6e8,null,t),this.tagName=t.tagName||"span",this.class=t.class||"",this.attrs=t.attributes||null}eq(t){var e,i;return this==t||t instanceof Ni&&this.tagName==t.tagName&&(this.class||(null===(e=this.attrs)||void 0===e?void 0:e.class))==(t.class||(null===(i=t.attrs)||void 0===i?void 0:i.class))&&Ai(this.attrs,t.attrs,"class")}range(t,e=t){if(t>=e)throw new RangeError("Mark decorations may not be empty");return super.range(t,e)}}Ni.prototype.point=!1;class Li extends qi{constructor(t){super(-2e8,-2e8,null,t)}eq(t){return t instanceof Li&&this.spec.class==t.spec.class&&Ai(this.spec.attributes,t.spec.attributes)}range(t,e=t){if(e!=t)throw new RangeError("Line decoration ranges must be zero-length");return super.range(t,e)}}Li.prototype.mapMode=nt.TrackBefore,Li.prototype.point=!0;class Ri extends qi{constructor(t,e,i,n,o,s){super(e,i,o,t),this.block=n,this.isReplace=s,this.mapMode=n?e<=0?nt.TrackBefore:nt.TrackAfter:nt.TrackDel}get type(){return this.startSide!=this.endSide?Bi.WidgetRange:this.startSide<=0?Bi.WidgetBefore:Bi.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(t){return t instanceof Ri&&(e=this.widget,i=t.widget,e==i||!!(e&&i&&e.compare(i)))&&this.block==t.block&&this.startSide==t.startSide&&this.endSide==t.endSide;var e,i}range(t,e=t){if(this.isReplace&&(t>e||t==e&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&e!=t)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(t,e)}}function Pi(t,e=!1){let{inclusiveStart:i,inclusiveEnd:n}=t;return null==i&&(i=t.inclusive),null==n&&(n=t.inclusive),{start:null!=i?i:e,end:null!=n?n:e}}function _i(t,e,i,n=0){let o=i.length-1;o>=0&&i[o]+n>=t?i[o]=Math.max(i[o],e):i.push(t,e)}Ri.prototype.point=!0;class Fi extends ei{constructor(){super(...arguments),this.children=[],this.length=0,this.prevAttrs=void 0,this.attrs=null,this.breakAfter=0}merge(t,e,i,n,o,s){if(i){if(!(i instanceof Fi))return!1;this.dom||i.transferDOM(this)}return n&&this.setDeco(i?i.attrs:null),si(this,t,e,i?i.children.slice():[],o,s),!0}split(t){let e=new Fi;if(e.breakAfter=this.breakAfter,0==this.length)return e;let{i:i,off:n}=this.childPos(t);n&&(e.append(this.children[i].split(n),0),this.children[i].merge(n,this.children[i].length,null,!1,0,0),i++);for(let t=i;t0&&0==this.children[i-1].length;)this.children[--i].destroy();return this.children.length=i,this.markDirty(),this.length=t,e}transferDOM(t){this.dom&&(this.markDirty(),t.setDOM(this.dom),t.prevAttrs=void 0===this.prevAttrs?this.attrs:this.prevAttrs,this.prevAttrs=void 0,this.dom=null)}setDeco(t){Ai(this.attrs,t)||(this.dom&&(this.prevAttrs=this.attrs,this.markDirty()),this.attrs=t)}append(t,e){ki(this,t,e)}addLineDeco(t){let e=t.spec.attributes,i=t.spec.class;e&&(this.attrs=Ei(e,this.attrs||{})),i&&(this.attrs=Ei({class:i},this.attrs||{}))}domAtPos(t){return xi(this,t)}reuseDOM(t){"DIV"==t.nodeName&&(this.setDOM(t),this.flags|=6)}sync(t,e){var i;this.dom?4&this.flags&&(Ze(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),void 0!==this.prevAttrs&&(Di(this.dom,this.prevAttrs,this.attrs),this.dom.classList.add("cm-line"),this.prevAttrs=void 0),super.sync(t,e);let n=this.dom.lastChild;for(;n&&ei.get(n)instanceof yi;)n=n.lastChild;if(!(n&&this.length&&("BR"==n.nodeName||0!=(null===(i=ei.get(n))||void 0===i?void 0:i.isEditable)||bi.ios&&this.children.some((t=>t instanceof vi))))){let t=document.createElement("BR");t.cmIgnore=!0,this.dom.appendChild(t)}}measureTextSize(){if(0==this.children.length||this.length>20)return null;let t,e=0;for(let i of this.children){if(!(i instanceof vi)||/[^ -~]/.test(i.text))return null;let n=Ne(i.dom);if(1!=n.length)return null;e+=n[0].width,t=n[0].height}return e?{lineHeight:this.dom.getBoundingClientRect().height,charWidth:e/this.length,textHeight:t}:null}coordsAt(t,e){let i=Si(this,t,e);if(!this.children.length&&i&&this.parent){let{heightOracle:t}=this.parent.view.viewState,e=i.bottom-i.top;if(Math.abs(e-t.lineHeight)<2&&t.textHeight=e){if(o instanceof Fi)return o;if(s>e)break}n=s+o.breakAfter}return null}}class Vi extends ei{constructor(t,e,i){super(),this.widget=t,this.length=e,this.deco=i,this.breakAfter=0,this.prevWidget=null}merge(t,e,i,n,o,s){return!(i&&(!(i instanceof Vi&&this.widget.compare(i.widget))||t>0&&o<=0||e0)}}class Hi extends Oi{constructor(t){super(),this.height=t}toDOM(){let t=document.createElement("div");return t.className="cm-gap",this.updateDOM(t),t}eq(t){return t.height==this.height}updateDOM(t){return t.style.height=this.height+"px",!0}get editable(){return!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}}class zi{constructor(t,e,i,n){this.doc=t,this.pos=e,this.end=i,this.disallowBlockEffectsFor=n,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=t.iter(),this.skip=e}posCovered(){if(0==this.content.length)return!this.breakAtStart&&this.doc.lineAt(this.pos).from!=this.pos;let t=this.content[this.content.length-1];return!(t.breakAfter||t instanceof Vi&&t.deco.endSide<0)}getLine(){return this.curLine||(this.content.push(this.curLine=new Fi),this.atCursorPos=!0),this.curLine}flushBuffer(t=this.bufferMarks){this.pendingBuffer&&(this.curLine.append($i(new Ci(-1),t),t.length),this.pendingBuffer=0)}addBlockWidget(t){this.flushBuffer(),this.curLine=null,this.content.push(t)}finish(t){this.pendingBuffer&&t<=this.bufferMarks.length?this.flushBuffer():this.pendingBuffer=0,this.posCovered()||t&&this.content.length&&this.content[this.content.length-1]instanceof Vi||this.getLine()}buildText(t,e,i){for(;t>0;){if(this.textOff==this.text.length){let{value:e,lineBreak:i,done:n}=this.cursor.next(this.skip);if(this.skip=0,n)throw new Error("Ran out of text content when drawing inline views");if(i){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,t--;continue}this.text=e,this.textOff=0}let n=Math.min(this.text.length-this.textOff,t,512);this.flushBuffer(e.slice(e.length-i)),this.getLine().append($i(new vi(this.text.slice(this.textOff,this.textOff+n)),e),i),this.atCursorPos=!0,this.textOff+=n,t-=n,i=0}}span(t,e,i,n){this.buildText(e-t,i,n),this.pos=e,this.openStart<0&&(this.openStart=n)}point(t,e,i,n,o,s){if(this.disallowBlockEffectsFor[s]&&i instanceof Ri){if(i.block)throw new RangeError("Block decorations may not be specified via plugins");if(e>this.doc.lineAt(this.pos).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}let r=e-t;if(i instanceof Ri)if(i.block)i.startSide>0&&!this.posCovered()&&this.getLine(),this.addBlockWidget(new Vi(i.widget||Wi.block,r,i));else{let s=wi.create(i.widget||Wi.inline,r,r?0:i.startSide),l=this.atCursorPos&&!s.isEditable&&o<=n.length&&(t0),a=!s.isEditable&&(tn.length||i.startSide<=0),c=this.getLine();2!=this.pendingBuffer||l||s.isEditable||(this.pendingBuffer=0),this.flushBuffer(n),l&&(c.append($i(new Ci(1),n),o),o=n.length+Math.max(0,o-n.length)),c.append($i(s,n),o),this.atCursorPos=a,this.pendingBuffer=a?tn.length?1:2:0,this.pendingBuffer&&(this.bufferMarks=n.slice())}else this.doc.lineAt(this.pos).from==this.pos&&this.getLine().addLineDeco(i);r&&(this.textOff+r<=this.text.length?this.textOff+=r:(this.skip+=r-(this.text.length-this.textOff),this.text="",this.textOff=0),this.pos=e),this.openStart<0&&(this.openStart=o)}static build(t,e,i,n,o){let s=new zi(t,e,i,o);return s.openEnd=ce.spans(n,e,i,s),s.openStart<0&&(s.openStart=s.openEnd),s.finish(s.openEnd),s}}function $i(t,e){for(let i of e)t=new yi(i,[t],t.length);return t}class Wi extends Oi{constructor(t){super(),this.tag=t}eq(t){return t.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(t){return t.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}}Wi.inline=new Wi("span"),Wi.block=new Wi("div");var Ui=function(t){return t[t.LTR=0]="LTR",t[t.RTL=1]="RTL",t}(Ui||(Ui={}));const ji=Ui.LTR,Yi=Ui.RTL;function Gi(t){let e=[];for(let i=0;i=e){if(r.level==i)return s;(o<0||(0!=n?n<0?r.frome:t[o].level>r.level))&&(o=s)}}if(o<0)throw new RangeError("Index out of range");return o}}function nn(t,e){if(t.length!=e.length)return!1;for(let i=0;ia&&r.push(new en(a,m.from,u)),rn(t,m.direction==ji!=!(u%2)?n+1:n,o,m.inner,m.from,m.to,r),a=m.to}p=m.to}else{if(p==i||(e?on[p]!=l:on[p]==l))break;p++}d?sn(t,a,p,n+1,o,d,r):ae;){let i=!0,h=!1;if(!c||a>s[c-1].to){let t=on[a-1];t!=l&&(i=!1,h=16==t)}let d=i||1!=l?null:[],u=i?n:n+1,p=a;t:for(;;)if(c&&p==s[c-1].to){if(h)break t;let m=s[--c];if(!i)for(let t=m.from,i=c;;){if(t==e)break t;if(!i||s[i-1].to!=t){if(on[t-1]==l)break t;break}t=s[--i].from}if(d)d.push(m);else{m.to=0;t-=3)if(Ji[t+1]==-i){let e=Ji[t+2],i=2&e?o:4&e?1&e?s:o:0;i&&(on[r]=on[Ji[t]]=i),l=t;break}}else{if(189==Ji.length)break;Ji[l++]=r,Ji[l++]=e,Ji[l++]=a}else if(2==(n=on[r])||1==n){let t=n==o;a=t?0:1;for(let e=l-3;e>=0;e-=3){let i=Ji[e+2];if(2&i)break;if(t)Ji[e+2]|=2;else{if(4&i)break;Ji[e+2]|=4}}}}}(t,o,s,n,l),function(t,e,i,n){for(let o=0,s=n;o<=i.length;o++){let r=o?i[o-1].to:t,l=oa;)e==s&&(e=i[--n].from,s=n?i[n-1].to:t),on[--e]=h;a=r}else s=r,a++}}}(o,s,n,l),sn(t,o,s,e,i,n,r)}function ln(t){return[new en(0,t,0)]}let an="";function cn(t,e,i,n,o){var s;let r=n.head-t.from,l=en.find(e,r,null!==(s=n.bidiLevel)&&void 0!==s?s:-1,n.assoc),a=e[l],c=a.side(o,i);if(r==c){let t=l+=o?1:-1;if(t<0||t>=e.length)return null;a=e[l=t],r=a.side(!o,i),c=a.side(o,i)}let h=et(t.text,r,a.forward(o,i));(ha.to)&&(h=c),an=t.text.slice(Math.min(r,h),Math.max(r,h));let d=l==(o?e.length-1:0)?null:e[l+(o?1:-1)];return d&&h==c&&d.level+(o?0:1)t.some((t=>t))}),Cn=ft.define({combine:t=>t.some((t=>t))}),xn=ft.define();class kn{constructor(t,e="nearest",i="nearest",n=5,o=5,s=!1){this.range=t,this.y=e,this.x=i,this.yMargin=n,this.xMargin=o,this.isSnapshot=s}map(t){return t.empty?this:new kn(this.range.map(t),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(t){return this.range.to<=t.doc.length?this:new kn(pt.cursor(t.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const Sn=jt.define({map:(t,e)=>t.map(e)}),Tn=jt.define();function En(t,e,i){let n=t.facet(mn);n.length?n[0](e):window.onerror&&window.onerror(String(e),i,void 0,void 0,e)||(i?console.error(i+":",e):console.error(e))}const Mn=ft.define({combine:t=>!t.length||t[0]});let An=0;const Dn=ft.define();class In{constructor(t,e,i,n,o){this.id=t,this.create=e,this.domEventHandlers=i,this.domEventObservers=n,this.extension=o(this)}static define(t,e){const{eventHandlers:i,eventObservers:n,provide:o,decorations:s}=e||{};return new In(An++,t,i,n,(t=>{let e=[Dn.of(t)];return s&&e.push(Nn.of((e=>{let i=e.plugin(t);return i?s(i):qi.none}))),o&&e.push(o(t)),e}))}static fromClass(t,e){return In.define((e=>new t(e)),e)}}class On{constructor(t){this.spec=t,this.mustUpdate=null,this.value=null}update(t){if(this.value){if(this.mustUpdate){let t=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(t)}catch(e){if(En(t.state,e,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch(t){}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.create(t)}catch(e){En(t.state,e,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(t){var e;if(null===(e=this.value)||void 0===e?void 0:e.destroy)try{this.value.destroy()}catch(e){En(t.state,e,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const Bn=ft.define(),qn=ft.define(),Nn=ft.define(),Ln=ft.define(),Rn=ft.define(),Pn=ft.define();function _n(t,e){let i=t.state.facet(Pn);if(!i.length)return i;let n=i.map((e=>e instanceof Function?e(t):e)),o=[];return ce.spans(n,e.from,e.to,{point(){},span(t,i,n,s){let r=t-e.from,l=i-e.from,a=o;for(let t=n.length-1;t>=0;t--,s--){let i,o=n[t].spec.bidiIsolate;if(null==o&&(o=hn(e.text,r,l)),s>0&&a.length&&(i=a[a.length-1]).to==r&&i.direction==o)i.to=l,a=i.inner;else{let t={from:r,to:l,direction:o,inner:[]};a.push(t),a=t.inner}}}}),o}const Fn=ft.define();function Vn(t){let e=0,i=0,n=0,o=0;for(let s of t.state.facet(Fn)){let r=s(t);r&&(null!=r.left&&(e=Math.max(e,r.left)),null!=r.right&&(i=Math.max(i,r.right)),null!=r.top&&(n=Math.max(n,r.top)),null!=r.bottom&&(o=Math.max(o,r.bottom)))}return{left:e,right:i,top:n,bottom:o}}const Hn=ft.define();class zn{constructor(t,e,i,n){this.fromA=t,this.toA=e,this.fromB=i,this.toB=n}join(t){return new zn(Math.min(this.fromA,t.fromA),Math.max(this.toA,t.toA),Math.min(this.fromB,t.fromB),Math.max(this.toB,t.toB))}addToSet(t){let e=t.length,i=this;for(;e>0;e--){let n=t[e-1];if(!(n.fromA>i.toA)){if(n.toAc)break;o+=2}if(!l)return i;new zn(l.fromA,l.toA,l.fromB,l.toB).addToSet(i),s=l.toA,r=l.toB}}}class $n{constructor(t,e,i){this.view=t,this.state=e,this.transactions=i,this.flags=0,this.startState=t.state,this.changes=st.empty(this.startState.doc.length);for(let t of i)this.changes=this.changes.compose(t.changes);let n=[];this.changes.iterChangedRanges(((t,e,i,o)=>n.push(new zn(t,e,i,o)))),this.changedRanges=n}static create(t,e,i){return new $n(t,e,i)}get viewportChanged(){return(4&this.flags)>0}get viewportMoved(){return(8&this.flags)>0}get heightChanged(){return(2&this.flags)>0}get geometryChanged(){return this.docChanged||(18&this.flags)>0}get focusChanged(){return(1&this.flags)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some((t=>t.selection))}get empty(){return 0==this.flags&&0==this.transactions.length}}class Wn extends ei{get length(){return this.view.state.doc.length}constructor(t){super(),this.view=t,this.decorations=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.markedForComposition=new Set,this.editContextFormatting=qi.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(t.contentDOM),this.children=[new Fi],this.children[0].setParent(this),this.updateDeco(),this.updateInner([new zn(0,0,0,t.state.doc.length)],0,null)}update(t){var e;let i=t.changedRanges;this.minWidth>0&&i.length&&(i.every((({fromA:t,toA:e})=>ethis.minWidthTo))?(this.minWidthFrom=t.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=t.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0),this.updateEditContextFormatting(t);let n=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&((null===(e=this.domChanged)||void 0===e?void 0:e.newSel)?n=this.domChanged.newSel.head:function(t,e){let i=!1;e&&t.iterChangedRanges(((t,n)=>{te.from&&(i=!0)}));return i}(t.changes,this.hasComposition)||t.selectionSet||(n=t.state.selection.main.head));let o=n>-1?function(t,e,i){let n=Un(t,i);if(!n)return null;let{node:o,from:s,to:r}=n,l=o.nodeValue;if(/[\n\r]/.test(l))return null;if(t.state.doc.sliceString(n.from,n.to)!=l)return null;let a=e.invertedDesc,c=new zn(a.mapPos(s),a.mapPos(r),s,r),h=[];for(let e=o.parentNode;;e=e.parentNode){let i=ei.get(e);if(i instanceof yi)h.push({node:e,deco:i.mark});else{if(i instanceof Fi||"DIV"==e.nodeName&&e.parentNode==t.contentDOM)return{range:c,text:o,marks:h,line:e};if(e==t.contentDOM)return null;h.push({node:e,deco:new Ni({inclusive:!0,attributes:Ii(e),tagName:e.tagName.toLowerCase()})})}}}(this.view,t.changes,n):null;if(this.domChanged=null,this.hasComposition){this.markedForComposition.clear();let{from:e,to:n}=this.hasComposition;i=new zn(e,n,t.changes.mapPos(e,-1),t.changes.mapPos(n,1)).addToSet(i.slice())}this.hasComposition=o?{from:o.range.fromB,to:o.range.toB}:null,(bi.ie||bi.chrome)&&!o&&t&&t.state.doc.lines!=t.startState.doc.lines&&(this.forceSelection=!0);let s=function(t,e,i){let n=new jn;return ce.compare(t,e,i,n),n.changes}(this.decorations,this.updateDeco(),t.changes);return i=zn.extendWithRanges(i,s),!!(7&this.flags||0!=i.length)&&(this.updateInner(i,t.startState.doc.length,o),t.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(t,e,i){this.view.viewState.mustMeasureContent=!0,this.updateChildren(t,e,i);let{observer:n}=this.view;n.ignore((()=>{this.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let t=bi.chrome||bi.ios?{node:n.selectionRange.focusNode,written:!1}:void 0;this.sync(this.view,t),this.flags&=-8,t&&(t.written||n.selectionRange.focusNode!=t.node)&&(this.forceSelection=!0),this.dom.style.height=""})),this.markedForComposition.forEach((t=>t.flags&=-9));let o=[];if(this.view.viewport.from||this.view.viewport.to=0?n[t]:null;if(!e)break;let s,r,l,a,{fromA:c,toA:h,fromB:d,toB:u}=e;if(i&&i.range.fromBd){let t=zi.build(this.view.state.doc,d,i.range.fromB,this.decorations,this.dynamicDecorationMap),e=zi.build(this.view.state.doc,i.range.toB,u,this.decorations,this.dynamicDecorationMap);r=t.breakAtStart,l=t.openStart,a=e.openEnd;let n=this.compositionView(i);e.breakAtStart?n.breakAfter=1:e.content.length&&n.merge(n.length,n.length,e.content[0],!1,e.openStart,0)&&(n.breakAfter=e.content[0].breakAfter,e.content.shift()),t.content.length&&n.merge(0,0,t.content[t.content.length-1],!0,0,t.openEnd)&&t.content.pop(),s=t.content.concat(n).concat(e.content)}else({content:s,breakAtStart:r,openStart:l,openEnd:a}=zi.build(this.view.state.doc,d,u,this.decorations,this.dynamicDecorationMap));let{i:p,off:m}=o.findPos(h,1),{i:g,off:f}=o.findPos(c,-1);oi(this,g,f,p,m,s,r,l,a)}i&&this.fixCompositionDOM(i)}updateEditContextFormatting(t){this.editContextFormatting=this.editContextFormatting.map(t.changes);for(let e of t.transactions)for(let t of e.effects)t.is(Tn)&&(this.editContextFormatting=t.value)}compositionView(t){let e=new vi(t.text.nodeValue);e.flags|=8;for(let{deco:i}of t.marks)e=new yi(i,[e],e.length);let i=new Fi;return i.append(e,0),i}fixCompositionDOM(t){let e=(t,e)=>{e.flags|=8|(e.children.some((t=>7&t.flags))?1:0),this.markedForComposition.add(e);let i=ei.get(t);i&&i!=e&&(i.dom=null),e.setDOM(t)},i=this.childPos(t.range.fromB,1),n=this.children[i.i];e(t.line,n);for(let o=t.marks.length-1;o>=-1;o--)i=n.childPos(i.off,1),n=n.children[i.i],e(o>=0?t.marks[o].node:t.text,n)}updateSelection(t=!1,e=!1){!t&&this.view.observer.selectionRange.focusNode||this.view.observer.readSelectionRange();let i=this.view.root.activeElement,n=i==this.dom,o=!n&&!(this.view.state.facet(Mn)||this.dom.tabIndex>-1)&&qe(this.dom,this.view.observer.selectionRange)&&!(i&&this.dom.contains(i));if(!(n||e||o))return;let s=this.forceSelection;this.forceSelection=!1;let r=this.view.state.selection.main,l=this.moveToLine(this.domAtPos(r.anchor)),a=r.empty?l:this.moveToLine(this.domAtPos(r.head));if(bi.gecko&&r.empty&&!this.hasComposition&&(1==(c=l).node.nodeType&&c.node.firstChild&&(0==c.offset||"false"==c.node.childNodes[c.offset-1].contentEditable)&&(c.offset==c.node.childNodes.length||"false"==c.node.childNodes[c.offset].contentEditable))){let t=document.createTextNode("");this.view.observer.ignore((()=>l.node.insertBefore(t,l.node.childNodes[l.offset]||null))),l=a=new Qe(t,0),s=!0}var c;let h=this.view.observer.selectionRange;!s&&h.focusNode&&(Le(l.node,l.offset,h.anchorNode,h.anchorOffset)&&Le(a.node,a.offset,h.focusNode,h.focusOffset)||this.suppressWidgetCursorChange(h,r))||(this.view.observer.ignore((()=>{bi.android&&bi.chrome&&this.dom.contains(h.focusNode)&&function(t,e){for(let i=t;i&&i!=e;i=i.assignedSlot||i.parentNode)if(1==i.nodeType&&"false"==i.contentEditable)return!0;return!1}(h.focusNode,this.dom)&&(this.dom.blur(),this.dom.focus({preventScroll:!0}));let t=Oe(this.view.root);if(t)if(r.empty){if(bi.gecko){let t=(e=l.node,n=l.offset,1!=e.nodeType?0:(n&&"false"==e.childNodes[n-1].contentEditable?1:0)|(nr.head&&([l,a]=[a,l]),e.setEnd(a.node,a.offset),e.setStart(l.node,l.offset),t.removeAllRanges(),t.addRange(e)}else;var e,n;o&&this.view.root.activeElement==this.dom&&(this.dom.blur(),i&&i.focus())})),this.view.observer.setSelectionRange(l,a)),this.impreciseAnchor=l.precise?null:new Qe(h.anchorNode,h.anchorOffset),this.impreciseHead=a.precise?null:new Qe(h.focusNode,h.focusOffset)}suppressWidgetCursorChange(t,e){return this.hasComposition&&e.empty&&Le(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)&&this.posFromDOM(t.focusNode,t.focusOffset)==e.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:t}=this,e=t.state.selection.main,i=Oe(t.root),{anchorNode:n,anchorOffset:o}=t.observer.selectionRange;if(!(i&&e.empty&&e.assoc&&i.modify))return;let s=Fi.find(this,e.head);if(!s)return;let r=s.posAtStart;if(e.head==r||e.head==r+s.length)return;let l=this.coordsAt(e.head,-1),a=this.coordsAt(e.head,1);if(!l||!a||l.bottom>a.top)return;let c=this.domAtPos(e.head+e.assoc);i.collapse(c.node,c.offset),i.modify("move",e.assoc<0?"forward":"backward","lineboundary"),t.observer.readSelectionRange();let h=t.observer.selectionRange;t.docView.posFromDOM(h.anchorNode,h.anchorOffset)!=e.from&&i.collapse(n,o)}moveToLine(t){let e,i=this.dom;if(t.node!=i)return t;for(let n=t.offset;!e&&n=0;n--){let t=ei.get(i.childNodes[n]);t instanceof Fi&&(e=t.domAtPos(t.length))}return e?new Qe(e.node,e.offset,!0):t}nearest(t){for(let e=t;e;){let t=ei.get(e);if(t&&t.rootView==this)return t;e=e.parentNode}return null}posFromDOM(t,e){let i=this.nearest(t);if(!i)throw new RangeError("Trying to find position for a DOM position outside of the document");return i.localPosFromDOM(t,e)+i.posAtStart}domAtPos(t){let{i:e,off:i}=this.childCursor().findPos(t,-1);for(;e=0;s--){let r=this.children[s],l=o-r.breakAfter,a=l-r.length;if(lt||r.covers(1))&&(!i||r instanceof Fi&&!(i instanceof Fi&&e>=0)))i=r,n=a;else if(i&&a==t&&l==t&&r instanceof Vi&&Math.abs(e)<2){if(r.deco.startSide<0)break;s&&(i=null)}o=a}return i?i.coordsAt(t-n,e):null}coordsForChar(t){let{i:e,off:i}=this.childPos(t,1),n=this.children[e];if(!(n instanceof Fi))return null;for(;n.children.length;){let{i:t,off:e}=n.childPos(i,1);for(;;t++){if(t==n.children.length)return null;if((n=n.children[t]).length)break}i=e}if(!(n instanceof vi))return null;let o=et(n.text,i);if(o==i)return null;let s=Ye(n.dom,i,o).getClientRects();for(let t=0;tMath.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,r=-1,l=this.view.textDirection==Ui.LTR;for(let t=0,a=0;an)break;if(t>=i){let i=c.dom.getBoundingClientRect();if(e.push(i.height),s){let e=c.dom.lastChild,n=e?Ne(e):[];if(n.length){let e=n[n.length-1],s=l?e.right-i.left:i.right-e.left;s>r&&(r=s,this.minWidth=o,this.minWidthFrom=t,this.minWidthTo=h)}}}t=h+c.breakAfter}return e}textDirectionAt(t){let{i:e}=this.childPos(t,1);return"rtl"==getComputedStyle(this.children[e].dom).direction?Ui.RTL:Ui.LTR}measureTextSize(){for(let t of this.children)if(t instanceof Fi){let e=t.measureTextSize();if(e)return e}let t,e,i,n=document.createElement("div");return n.className="cm-line",n.style.width="99999px",n.style.position="absolute",n.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore((()=>{this.dom.appendChild(n);let o=Ne(n.firstChild)[0];t=n.getBoundingClientRect().height,e=o?o.width/27:7,i=o?o.height:t,n.remove()})),{lineHeight:t,charWidth:e,textHeight:i}}childCursor(t=this.length){let e=this.children.length;return e&&(t-=this.children[--e].length),new ni(this.children,t,e)}computeBlockGapDeco(){let t=[],e=this.view.viewState;for(let i=0,n=0;;n++){let o=n==e.viewports.length?null:e.viewports[n],s=o?o.from-1:this.length;if(s>i){let n=(e.lineBlockAt(s).bottom-e.lineBlockAt(i).top)/this.view.scaleY;t.push(qi.replace({widget:new Hi(n),block:!0,inclusive:!0,isBlockGap:!0}).range(i,s))}if(!o)break;i=o.to+1}return qi.set(t)}updateDeco(){let t=1,e=this.view.state.facet(Nn).map((e=>(this.dynamicDecorationMap[t++]="function"==typeof e)?e(this.view):e)),i=!1,n=this.view.state.facet(Ln).map(((t,e)=>{let n="function"==typeof t;return n&&(i=!0),n?t(this.view):t}));for(n.length&&(this.dynamicDecorationMap[t++]=i,e.push(ce.join(n))),this.decorations=[this.editContextFormatting,...e,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];ti.anchor?-1:1);if(!n)return;!i.empty&&(e=this.coordsAt(i.anchor,i.anchor>i.head?-1:1))&&(n={left:Math.min(n.left,e.left),top:Math.min(n.top,e.top),right:Math.max(n.right,e.right),bottom:Math.max(n.bottom,e.bottom)});let o=Vn(this.view),s={left:n.left-o.left,top:n.top-o.top,right:n.right+o.right,bottom:n.bottom+o.bottom},{offsetWidth:r,offsetHeight:l}=this.view.scrollDOM;!function(t,e,i,n,o,s,r,l){let a=t.ownerDocument,c=a.defaultView||window;for(let h=t,d=!1;h&&!d;)if(1==h.nodeType){let t,u=h==a.body,p=1,m=1;if(u)t=He(c);else{if(/^(fixed|sticky)$/.test(getComputedStyle(h).position)&&(d=!0),h.scrollHeight<=h.clientHeight&&h.scrollWidth<=h.clientWidth){h=h.assignedSlot||h.parentNode;continue}let e=h.getBoundingClientRect();({scaleX:p,scaleY:m}=ze(h,e)),t={left:e.left,right:e.left+h.clientWidth*p,top:e.top,bottom:e.top+h.clientHeight*m}}let g=0,f=0;if("nearest"==o)e.top0&&e.bottom>t.bottom+f&&(f=e.bottom-t.bottom+r)):e.bottom>t.bottom&&(f=e.bottom-t.bottom+r,i<0&&e.top-f0&&e.right>t.right+g&&(g=e.right-t.right+s)):e.right>t.right&&(g=e.right-t.right+s,i<0&&e.leftt.bottom||e.leftt.right)&&(e={left:Math.max(e.left,t.left),right:Math.min(e.right,t.right),top:Math.max(e.top,t.top),bottom:Math.min(e.bottom,t.bottom)}),h=h.assignedSlot||h.parentNode}else{if(11!=h.nodeType)break;h=h.host}}(this.view.scrollDOM,s,i.headt?e.left-t:Math.max(0,t-e.right)}function Gn(t,e){return e.top>t?e.top-t:Math.max(0,t-e.bottom)}function Zn(t,e){return t.tope.top+1}function Kn(t,e){return et.bottom?{top:t.top,left:t.left,right:t.right,bottom:e}:t}function Jn(t,e,i){let n,o,s,r,l,a,c,h,d=!1;for(let u=t.firstChild;u;u=u.nextSibling){let t=Ne(u);for(let p=0;pf||r==f&&s>g){n=u,o=m,s=g,r=f;let l=f?i0?p0)}0==g?i>m.bottom&&(!c||c.bottomm.top)&&(a=u,h=m):c&&Zn(c,m)?c=Xn(c,m.bottom):h&&Zn(h,m)&&(h=Kn(h,m.top))}}if(c&&c.bottom>=i?(n=l,o=c):h&&h.top<=i&&(n=a,o=h),!n)return{node:t,offset:0};let u=Math.max(o.left,Math.min(o.right,e));return 3==n.nodeType?Qn(n,u,i):d&&"false"!=n.contentEditable?Jn(n,u,i):{node:t,offset:Array.prototype.indexOf.call(t.childNodes,n)+(e>=(o.left+o.right)/2?1:0)}}function Qn(t,e,i){let n=t.nodeValue.length,o=-1,s=1e9,r=0;for(let l=0;li?c.top-i:i-c.bottom)-1;if(c.left-1<=e&&c.right+1>=e&&h=(c.left+c.right)/2,n=i;if(bi.chrome||bi.gecko){Ye(t,l).getBoundingClientRect().left==c.right&&(n=!i)}if(h<=0)return{node:t,offset:l+(n?1:0)};o=l+(n?1:0),s=h}}}return{node:t,offset:o>-1?o:r>0?t.nodeValue.length:0}}function to(t,e,i,n=-1){var o,s;let r,l=t.contentDOM.getBoundingClientRect(),a=l.top+t.viewState.paddingTop,{docHeight:c}=t.viewState,{x:h,y:d}=e,u=d-a;if(u<0)return 0;if(u>c)return t.state.doc.length;for(let e=t.viewState.heightOracle.textHeight/2,o=!1;r=t.elementAtHeight(u),r.type!=Bi.Text;)for(;u=n>0?r.bottom+e:r.top-e,!(u>=0&&u<=c);){if(o)return i?null:0;o=!0,n=-n}d=a+u;let p=r.from;if(pt.viewport.to)return t.viewport.to==t.state.doc.length?t.state.doc.length:i?null:eo(t,l,r,h,d);let m=t.dom.ownerDocument,g=t.root.elementFromPoint?t.root:m,f=g.elementFromPoint(h,d);f&&!t.contentDOM.contains(f)&&(f=null),f||(h=Math.max(l.left+1,Math.min(l.right-1,h)),f=g.elementFromPoint(h,d),f&&!t.contentDOM.contains(f)&&(f=null));let b,v=-1;if(f&&0!=(null===(o=t.docView.nearest(f))||void 0===o?void 0:o.isEditable)){if(m.caretPositionFromPoint){let t=m.caretPositionFromPoint(h,d);t&&({offsetNode:b,offset:v}=t)}else if(m.caretRangeFromPoint){let e=m.caretRangeFromPoint(h,d);e&&(({startContainer:b,startOffset:v}=e),(!t.contentDOM.contains(b)||bi.safari&&function(t,e,i){let n;if(3!=t.nodeType||e!=(n=t.nodeValue.length))return!1;for(let e=t.nextSibling;e;e=e.nextSibling)if(1!=e.nodeType||"BR"!=e.nodeName)return!1;return Ye(t,n-1,n).getBoundingClientRect().left>i}(b,v,h)||bi.chrome&&function(t,e,i){if(0!=e)return!1;for(let e=t;;){let t=e.parentNode;if(!t||1!=t.nodeType||t.firstChild!=e)return!1;if(t.classList.contains("cm-line"))break;e=t}let n=1==t.nodeType?t.getBoundingClientRect():Ye(t,0,Math.max(t.nodeValue.length,1)).getBoundingClientRect();return i-n.left>5}(b,v,h))&&(b=void 0))}b&&(v=Math.min(Fe(b),v))}if(!b||!t.docView.dom.contains(b)){let e=Fi.find(t.docView,p);if(!e)return u>r.top+r.height/2?r.to:r.from;({node:b,offset:v}=Jn(e.dom,h,d))}let y=t.docView.nearest(b);if(!y)return null;if(y.isWidget&&1==(null===(s=y.dom)||void 0===s?void 0:s.nodeType)){let t=y.dom.getBoundingClientRect();return e.y1.5*t.defaultLineHeight){let e=t.viewState.heightOracle.textHeight;s+=Math.floor((o-i.top-.5*(t.defaultLineHeight-e))/e)*t.viewState.heightOracle.lineLength}let r=t.state.sliceDoc(i.from,i.to);return i.from+function(t,e,i,n){for(let n=0,o=0;;){if(o>=e)return n;if(n==t.length)break;o+=9==t.charCodeAt(n)?i-o%i:1,n=et(t,n)}return!0===n?-1:t.length}(r,s,t.state.tabSize)}function io(t,e,i,n){let o=function(t,e,i){let n=t.lineBlockAt(e);if(Array.isArray(n.type)){let t;for(let o of n.type){if(o.from>e)break;if(!(o.toe)return o;t&&(o.type!=Bi.Text||t.type==o.type&&!(i<0?o.frome))||(t=o)}}return t||n}return n}(t,e.head,e.assoc||-1),s=n&&o.type==Bi.Text&&(t.lineWrapping||o.widgetLineBreaks)?t.coordsAtPos(e.assoc<0&&e.head>o.from?e.head-1:e.head):null;if(s){let e=t.dom.getBoundingClientRect(),n=t.textDirectionAt(o.from),r=t.posAtCoords({x:i==(n==Ui.LTR)?e.right-1:e.left+1,y:(s.top+s.bottom)/2});if(null!=r)return pt.cursor(r,i?-1:1)}return pt.cursor(i?o.to:o.from,i?-1:1)}function no(t,e,i,n){let o=t.state.doc.lineAt(e.head),s=t.bidiSpans(o),r=t.textDirectionAt(o.from);for(let l=e,a=null;;){let e=cn(o,s,r,l,i),c=an;if(!e){if(o.number==(i?t.state.doc.lines:1))return l;c="\n",o=t.state.doc.line(o.number+(i?1:-1)),s=t.bidiSpans(o),e=t.visualLineSide(o,!i)}if(a){if(!a(c))return l}else{if(!n)return e;a=n(c)}l=e}}function oo(t,e,i){for(;;){let n=0;for(let o of t)o.between(e-1,e+1,((t,o,s)=>{if(e>t&&ee(t))),i.from,e.head>i.from?-1:1);return n==i.from?i:pt.cursor(n,nt)&&this.lineBreak(),n=o}return this.findPointBefore(i,e),this}readTextNode(t){let e=t.nodeValue;for(let i of this.points)i.node==t&&(i.pos=this.text.length+Math.min(i.offset,e.length));for(let i=0,n=this.lineSeparator?null:/\r\n?|\n/g;;){let o,s=-1,r=1;if(this.lineSeparator?(s=e.indexOf(this.lineSeparator,i),r=this.lineSeparator.length):(o=n.exec(e))&&(s=o.index,r=o[0].length),this.append(e.slice(i,s<0?e.length:s)),s<0)break;if(this.lineBreak(),r>1)for(let e of this.points)e.node==t&&e.pos>this.text.length&&(e.pos-=r-1);i=s+r}}readNode(t){if(t.cmIgnore)return;let e=ei.get(t),i=e&&e.overrideDOMText;if(null!=i){this.findPointInside(t,i.length);for(let t=i.iter();!t.next().done;)t.lineBreak?this.lineBreak():this.append(t.value)}else 3==t.nodeType?this.readTextNode(t):"BR"==t.nodeName?t.nextSibling&&this.lineBreak():1==t.nodeType&&this.readRange(t.firstChild,null)}findPointBefore(t,e){for(let i of this.points)i.node==t&&t.childNodes[i.offset]==e&&(i.pos=this.text.length)}findPointInside(t,e){for(let i of this.points)(3==t.nodeType?i.node==t:t.contains(i.node))&&(i.pos=this.text.length+(ao(t,i.node,i.offset)?e:0))}}function ao(t,e,i){for(;;){if(!e||i-1;let{impreciseHead:o,impreciseAnchor:s}=t.docView;if(t.state.readOnly&&e>-1)this.newSel=null;else if(e>-1&&(this.bounds=t.docView.domBoundsAround(e,i,0))){let e=o||s?[]:function(t){let e=[];if(t.root.activeElement!=t.contentDOM)return e;let{anchorNode:i,anchorOffset:n,focusNode:o,focusOffset:s}=t.observer.selectionRange;i&&(e.push(new co(i,n)),o==i&&s==n||e.push(new co(o,s)));return e}(t),i=new lo(e,t.state);i.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=i.text,this.newSel=function(t,e){if(0==t.length)return null;let i=t[0].pos,n=2==t.length?t[1].pos:i;return i>-1&&n>-1?pt.single(i+e,n+e):null}(e,this.bounds.from)}else{let e=t.observer.selectionRange,i=o&&o.node==e.focusNode&&o.offset==e.focusOffset||!Be(t.contentDOM,e.focusNode)?t.state.selection.main.head:t.docView.posFromDOM(e.focusNode,e.focusOffset),n=s&&s.node==e.anchorNode&&s.offset==e.anchorOffset||!Be(t.contentDOM,e.anchorNode)?t.state.selection.main.anchor:t.docView.posFromDOM(e.anchorNode,e.anchorOffset),r=t.viewport;if((bi.ios||bi.chrome)&&t.state.selection.main.empty&&i!=n&&(r.from>0||r.toDate.now()-100?t.inputState.lastKeyCode:-1;if(e.bounds){let{from:n,to:r}=e.bounds,l=o.from,a=null;(8===s||bi.android&&e.text.length0&&l>0&&t.charCodeAt(r-1)==e.charCodeAt(l-1);)r--,l--;if("end"==n){i-=r+Math.max(0,s-Math.min(r,l))-s}if(r=r?s-i:0,l=s+(l-r),r=s}else if(l=l?s-i:0,r=s+(r-l),l=s}return{from:s,toA:r,toB:l}}(t.state.doc.sliceString(n,r,ro),e.text,l-n,a);c&&(bi.chrome&&13==s&&c.toB==c.from+2&&e.text.slice(c.from,c.toB)==ro+ro&&c.toB--,i={from:n+c.from,to:n+c.toA,insert:U.of(e.text.slice(c.from,c.toB).split(ro))})}else n&&(!t.hasFocus&&t.state.facet(Mn)||n.main.eq(o))&&(n=null);if(!i&&!n)return!1;if(!i&&e.typeOver&&!o.empty&&n&&n.main.empty?i={from:o.from,to:o.to,insert:t.state.doc.slice(o.from,o.to)}:(bi.mac||bi.android)&&i&&i.from==i.to&&i.from==o.head-1&&/^\. ?$/.test(i.insert.toString())&&"off"==t.contentDOM.getAttribute("autocorrect")?(n&&2==i.insert.length&&(n=pt.single(n.main.anchor-1,n.main.head-1)),i={from:i.from,to:i.to,insert:U.of([i.insert.toString().replace("."," ")])}):i&&i.from>=o.from&&i.to<=o.to&&(i.from!=o.from||i.to!=o.to)&&o.to-o.from-(i.to-i.from)<=4?i={from:o.from,to:o.to,insert:t.state.doc.slice(o.from,i.from).append(i.insert).append(t.state.doc.slice(i.to,o.to))}:bi.chrome&&i&&i.from==i.to&&i.from==o.head&&"\n "==i.insert.toString()&&t.lineWrapping&&(n&&(n=pt.single(n.main.anchor-1,n.main.head-1)),i={from:o.from,to:o.to,insert:U.of([" "])}),i)return po(t,i,n,s);if(n&&!n.main.eq(o)){let e=!1,i="select";return t.inputState.lastSelectionTime>Date.now()-50&&("select"==t.inputState.lastSelectionOrigin&&(e=!0),i=t.inputState.lastSelectionOrigin),t.dispatch({selection:n,scrollIntoView:e,userEvent:i}),!0}return!1}function po(t,e,i,n=-1){if(bi.ios&&t.inputState.flushIOSKey(e))return!0;let o=t.state.selection.main;if(bi.android&&(e.to==o.to&&(e.from==o.from||e.from==o.from-1&&" "==t.state.sliceDoc(e.from,o.from))&&1==e.insert.length&&2==e.insert.lines&&Ge(t.contentDOM,"Enter",13)||(e.from==o.from-1&&e.to==o.to&&0==e.insert.length||8==n&&e.insert.lengtho.head)&&Ge(t.contentDOM,"Backspace",8)||e.from==o.from&&e.to==o.to+1&&0==e.insert.length&&Ge(t.contentDOM,"Delete",46)))return!0;let s,r=e.insert.toString();t.inputState.composing>=0&&t.inputState.composing++;let l=()=>s||(s=function(t,e,i){let n,o=t.state,s=o.selection.main;if(e.from>=s.from&&e.to<=s.to&&e.to-e.from>=(s.to-s.from)/3&&(!i||i.main.empty&&i.main.from==e.from+e.insert.length)&&t.inputState.composing<0){let i=s.frome.to?o.sliceDoc(e.to,s.to):"";n=o.replaceSelection(t.state.toText(i+e.insert.sliceString(0,void 0,t.state.lineBreak)+r))}else{let r=o.changes(e),l=i&&i.main.to<=r.newLength?i.main:void 0;if(o.selection.ranges.length>1&&t.inputState.composing>=0&&e.to<=s.to&&e.to>=s.to-10){let a,c=t.state.sliceDoc(e.from,e.to),h=i&&Un(t,i.main.head);if(h){let t=e.insert.length-(e.to-e.from);a={from:h.from,to:h.to-t}}else a=t.state.doc.lineAt(s.head);let d=s.to-e.to,u=s.to-s.from;n=o.changeByRange((i=>{if(i.from==s.from&&i.to==s.to)return{changes:r,range:l||i.map(r)};let n=i.to-d,h=n-c.length;if(i.to-i.from!=u||t.state.sliceDoc(h,n)!=c||i.to>=a.from&&i.from<=a.to)return{range:i};let p=o.changes({from:h,to:n,insert:e.insert}),m=i.to-s.to;return{changes:p,range:l?pt.range(Math.max(0,l.anchor+m),Math.max(0,l.head+m)):i.map(p)}}))}else n={changes:r,selection:l&&o.selection.replaceRange(l)}}let r="input.type";(t.composing||t.inputState.compositionPendingChange&&t.inputState.compositionEndedAt>Date.now()-50)&&(t.inputState.compositionPendingChange=!1,r+=".compose",t.inputState.compositionFirstChange&&(r+=".start",t.inputState.compositionFirstChange=!1));return o.update(n,{userEvent:r,scrollIntoView:!0})}(t,e,i));return t.state.facet(fn).some((i=>i(t,e.from,e.to,r,l)))||t.dispatch(l()),!0}class mo{setSelectionOrigin(t){this.lastSelectionOrigin=t,this.lastSelectionTime=Date.now()}constructor(t){this.view=t,this.lastKeyCode=0,this.lastKeyTime=0,this.lastTouchTime=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.pendingIOSKey=void 0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=t.hasFocus,bi.safari&&t.contentDOM.addEventListener("input",(()=>null)),bi.gecko&&function(t){Ho.has(t)||(Ho.add(t),t.addEventListener("copy",(()=>{})),t.addEventListener("cut",(()=>{})))}(t.contentDOM.ownerDocument)}handleEvent(t){(function(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let i,n=e.target;n!=t.contentDOM;n=n.parentNode)if(!n||11==n.nodeType||(i=ei.get(n))&&i.ignoreEvent(e))return!1;return!0})(this.view,t)&&!this.ignoreDuringComposition(t)&&("keydown"==t.type&&this.keydown(t)||(0!=this.view.updateState?Promise.resolve().then((()=>this.runHandlers(t.type,t))):this.runHandlers(t.type,t)))}runHandlers(t,e){let i=this.handlers[t];if(i){for(let t of i.observers)t(this.view,e);for(let t of i.handlers){if(e.defaultPrevented)break;if(t(this.view,e)){e.preventDefault();break}}}}ensureHandlers(t){let e=fo(t),i=this.handlers,n=this.view.contentDOM;for(let t in e)if("scroll"!=t){let o=!e[t].handlers.length,s=i[t];s&&o!=!s.handlers.length&&(n.removeEventListener(t,this.handleEvent),s=null),s||n.addEventListener(t,this.handleEvent,{passive:o})}for(let t in i)"scroll"==t||e[t]||n.removeEventListener(t,this.handleEvent);this.handlers=e}keydown(t){if(this.lastKeyCode=t.keyCode,this.lastKeyTime=Date.now(),9==t.keyCode&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&27!=t.keyCode&&yo.indexOf(t.keyCode)<0&&(this.tabFocusMode=-1),bi.android&&bi.chrome&&!t.synthetic&&(13==t.keyCode||8==t.keyCode))return this.view.observer.delayAndroidKey(t.key,t.keyCode),!0;let e;return!bi.ios||t.synthetic||t.altKey||t.metaKey||!((e=bo.find((e=>e.keyCode==t.keyCode)))&&!t.ctrlKey||vo.indexOf(t.key)>-1&&t.ctrlKey&&!t.shiftKey)?(229!=t.keyCode&&this.view.observer.forceFlush(),!1):(this.pendingIOSKey=e||t,setTimeout((()=>this.flushIOSKey()),250),!0)}flushIOSKey(t){let e=this.pendingIOSKey;return!!e&&(!("Enter"==e.key&&t&&t.from0||!!(bi.safari&&!bi.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100)&&(this.compositionPendingKey=!1,!0))}startMouseSelection(t){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=t}update(t){this.view.observer.update(t),this.mouseSelection&&this.mouseSelection.update(t),this.draggedContent&&t.docChanged&&(this.draggedContent=this.draggedContent.map(t.changes)),t.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}}function go(t,e){return(i,n)=>{try{return e.call(t,n,i)}catch(t){En(i.state,t)}}}function fo(t){let e=Object.create(null);function i(t){return e[t]||(e[t]={observers:[],handlers:[]})}for(let e of t){let t=e.spec;if(t&&t.domEventHandlers)for(let n in t.domEventHandlers){let o=t.domEventHandlers[n];o&&i(n).handlers.push(go(e.value,o))}if(t&&t.domEventObservers)for(let n in t.domEventObservers){let o=t.domEventObservers[n];o&&i(n).observers.push(go(e.value,o))}}for(let t in xo)i(t).handlers.push(xo[t]);for(let t in ko)i(t).observers.push(ko[t]);return e}const bo=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],vo="dthko",yo=[16,17,18,20,91,92,224,225];function wo(t){return.7*Math.max(0,t)+8}class Co{constructor(t,e,i,n){this.view=t,this.startEvent=e,this.style=i,this.mustSelect=n,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=e,this.scrollParents=function(t){let e,i,n=t.ownerDocument;for(let o=t.parentNode;o&&!(o==n.body||e&&i);)if(1==o.nodeType)!i&&o.scrollHeight>o.clientHeight&&(i=o),!e&&o.scrollWidth>o.clientWidth&&(e=o),o=o.assignedSlot||o.parentNode;else{if(11!=o.nodeType)break;o=o.host}return{x:e,y:i}}(t.contentDOM),this.atoms=t.state.facet(Rn).map((e=>e(t)));let o=t.contentDOM.ownerDocument;o.addEventListener("mousemove",this.move=this.move.bind(this)),o.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=e.shiftKey,this.multiple=t.state.facet(oe.allowMultipleSelections)&&function(t,e){let i=t.state.facet(dn);return i.length?i[0](e):bi.mac?e.metaKey:e.ctrlKey}(t,e),this.dragging=!(!function(t,e){let{main:i}=t.state.selection;if(i.empty)return!1;let n=Oe(t.root);if(!n||0==n.rangeCount)return!0;let o=n.getRangeAt(0).getClientRects();for(let t=0;t=e.clientX&&i.top<=e.clientY&&i.bottom>=e.clientY)return!0}return!1}(t,e)||1!=Lo(e))&&null}start(t){!1===this.dragging&&this.select(t)}move(t){if(0==t.buttons)return this.destroy();if(this.dragging||null==this.dragging&&(e=this.startEvent,i=t,Math.max(Math.abs(e.clientX-i.clientX),Math.abs(e.clientY-i.clientY))<10))return;var e,i;this.select(this.lastEvent=t);let n=0,o=0,s=0,r=0,l=this.view.win.innerWidth,a=this.view.win.innerHeight;this.scrollParents.x&&({left:s,right:l}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:r,bottom:a}=this.scrollParents.y.getBoundingClientRect());let c=Vn(this.view);t.clientX-c.left<=s+6?n=-wo(s-t.clientX):t.clientX+c.right>=l-6&&(n=wo(t.clientX-l)),t.clientY-c.top<=r+6?o=-wo(r-t.clientY):t.clientY+c.bottom>=a-6&&(o=wo(t.clientY-a)),this.setScrollSpeed(n,o)}up(t){null==this.dragging&&this.select(this.lastEvent),this.dragging||t.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let t=this.view.contentDOM.ownerDocument;t.removeEventListener("mousemove",this.move),t.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(t,e){this.scrollSpeed={x:t,y:e},t||e?this.scrolling<0&&(this.scrolling=setInterval((()=>this.scroll()),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:t,y:e}=this.scrollSpeed;t&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=t,t=0),e&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=e,e=0),(t||e)&&this.view.win.scrollBy(t,e),!1===this.dragging&&this.select(this.lastEvent)}skipAtoms(t){let e=null;for(let i=0;it.isUserEvent("input.type")))?this.destroy():this.style.update(t)&&setTimeout((()=>this.select(this.lastEvent)),20)}}const xo=Object.create(null),ko=Object.create(null),So=bi.ie&&bi.ie_version<15||bi.ios&&bi.webkit_version<604;function To(t,e,i){for(let n of t.facet(e))i=n(i,t);return i}function Eo(t,e){e=To(t.state,vn,e);let i,{state:n}=t,o=1,s=n.toText(e),r=s.lines==n.selection.ranges.length;if(null!=Po&&n.selection.ranges.every((t=>t.empty))&&Po==s.toString()){let t=-1;i=n.changeByRange((i=>{let l=n.doc.lineAt(i.from);if(l.from==t)return{range:i};t=l.from;let a=n.toText((r?s.line(o++).text:e)+n.lineBreak);return{changes:{from:l.from,insert:a},range:pt.cursor(i.from+a.length)}}))}else i=r?n.changeByRange((t=>{let e=s.line(o++);return{changes:{from:t.from,to:t.to,insert:e.text},range:pt.cursor(t.from+e.length)}})):n.replaceSelection(s);t.dispatch(i,{userEvent:"input.paste",scrollIntoView:!0})}function Mo(t,e,i,n){if(1==n)return pt.cursor(e,i);if(2==n)return function(t,e,i=1){let n=t.charCategorizer(e),o=t.doc.lineAt(e),s=e-o.from;if(0==o.length)return pt.cursor(e);0==s?i=1:s==o.length&&(i=-1);let r=s,l=s;i<0?r=et(o.text,s,!1):l=et(o.text,s);let a=n(o.text.slice(r,l));for(;r>0;){let t=et(o.text,r,!1);if(n(o.text.slice(t,r))!=a)break;r=t}for(;l{t.inputState.lastScrollTop=t.scrollDOM.scrollTop,t.inputState.lastScrollLeft=t.scrollDOM.scrollLeft},xo.keydown=(t,e)=>(t.inputState.setSelectionOrigin("select"),27==e.keyCode&&0!=t.inputState.tabFocusMode&&(t.inputState.tabFocusMode=Date.now()+2e3),!1),ko.touchstart=(t,e)=>{t.inputState.lastTouchTime=Date.now(),t.inputState.setSelectionOrigin("select.pointer")},ko.touchmove=t=>{t.inputState.setSelectionOrigin("select.pointer")},xo.mousedown=(t,e)=>{if(t.observer.flush(),t.inputState.lastTouchTime>Date.now()-2e3)return!1;let i=null;for(let n of t.state.facet(pn))if(i=n(t,e),i)break;if(i||0!=e.button||(i=function(t,e){let i=Io(t,e),n=Lo(e),o=t.state.selection;return{update(t){t.docChanged&&(i.pos=t.changes.mapPos(i.pos),o=o.map(t.changes))},get(e,s,r){let l,a=Io(t,e),c=Mo(t,a.pos,a.bias,n);if(i.pos!=a.pos&&!s){let e=Mo(t,i.pos,i.bias,n),o=Math.min(e.from,c.from),s=Math.max(e.to,c.to);c=o1&&(l=function(t,e){for(let i=0;i=e)return pt.create(t.ranges.slice(0,i).concat(t.ranges.slice(i+1)),t.mainIndex==i?0:t.mainIndex-(t.mainIndex>i?1:0))}return null}(o,a.pos))?l:r?o.addRange(c):pt.create([c])}}}(t,e)),i){let n=!t.hasFocus;t.inputState.startMouseSelection(new Co(t,e,i,n)),n&&t.observer.ignore((()=>{je(t.contentDOM);let e=t.root.activeElement;e&&!e.contains(t.contentDOM)&&e.blur()}));let o=t.inputState.mouseSelection;if(o)return o.start(e),!1===o.dragging}return!1};let Ao=(t,e,i)=>e>=i.top&&e<=i.bottom&&t>=i.left&&t<=i.right;function Do(t,e,i,n){let o=Fi.find(t.docView,e);if(!o)return 1;let s=e-o.posAtStart;if(0==s)return 1;if(s==o.length)return-1;let r=o.coordsAt(s,-1);if(r&&Ao(i,n,r))return-1;let l=o.coordsAt(s,1);return l&&Ao(i,n,l)?1:r&&r.bottom>=n?-1:1}function Io(t,e){let i=t.posAtCoords({x:e.clientX,y:e.clientY},!1);return{pos:i,bias:Do(t,i,e.clientX,e.clientY)}}const Oo=bi.ie&&bi.ie_version<=11;let Bo=null,qo=0,No=0;function Lo(t){if(!Oo)return t.detail;let e=Bo,i=No;return Bo=t,No=Date.now(),qo=!e||i>Date.now()-400&&Math.abs(e.clientX-t.clientX)<2&&Math.abs(e.clientY-t.clientY)<2?(qo+1)%3:1}function Ro(t,e,i,n){if(!(i=To(t.state,vn,i)))return;let o=t.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:s}=t.inputState,r=n&&s&&function(t,e){let i=t.state.facet(un);return i.length?i[0](e):bi.mac?!e.altKey:!e.ctrlKey}(t,e)?{from:s.from,to:s.to}:null,l={from:o,insert:i},a=t.state.changes(r?[r,l]:l);t.focus(),t.dispatch({changes:a,selection:{anchor:a.mapPos(o,-1),head:a.mapPos(o,1)},userEvent:r?"move.drop":"input.drop"}),t.inputState.draggedContent=null}xo.dragstart=(t,e)=>{let{selection:{main:i}}=t.state;if(e.target.draggable){let n=t.docView.nearest(e.target);if(n&&n.isWidget){let t=n.posAtStart,e=t+n.length;(t>=i.to||e<=i.from)&&(i=pt.range(t,e))}}let{inputState:n}=t;return n.mouseSelection&&(n.mouseSelection.dragging=!0),n.draggedContent=i,e.dataTransfer&&(e.dataTransfer.setData("Text",To(t.state,yn,t.state.sliceDoc(i.from,i.to))),e.dataTransfer.effectAllowed="copyMove"),!1},xo.dragend=t=>(t.inputState.draggedContent=null,!1),xo.drop=(t,e)=>{if(!e.dataTransfer)return!1;if(t.state.readOnly)return!0;let i=e.dataTransfer.files;if(i&&i.length){let n=Array(i.length),o=0,s=()=>{++o==i.length&&Ro(t,e,n.filter((t=>null!=t)).join(t.state.lineBreak),!1)};for(let t=0;t{/[\x00-\x08\x0e-\x1f]{2}/.test(e.result)||(n[t]=e.result),s()},e.readAsText(i[t])}return!0}{let i=e.dataTransfer.getData("Text");if(i)return Ro(t,e,i,!0),!0}return!1},xo.paste=(t,e)=>{if(t.state.readOnly)return!0;t.observer.flush();let i=So?null:e.clipboardData;return i?(Eo(t,i.getData("text/plain")||i.getData("text/uri-list")),!0):(function(t){let e=t.dom.parentNode;if(!e)return;let i=e.appendChild(document.createElement("textarea"));i.style.cssText="position: fixed; left: -10000px; top: 10px",i.focus(),setTimeout((()=>{t.focus(),i.remove(),Eo(t,i.value)}),50)}(t),!1)};let Po=null;xo.copy=xo.cut=(t,e)=>{let{text:i,ranges:n,linewise:o}=function(t){let e=[],i=[],n=!1;for(let n of t.selection.ranges)n.empty||(e.push(t.sliceDoc(n.from,n.to)),i.push(n));if(!e.length){let o=-1;for(let{from:n}of t.selection.ranges){let s=t.doc.lineAt(n);s.number>o&&(e.push(s.text),i.push({from:s.from,to:Math.min(t.doc.length,s.to+1)})),o=s.number}n=!0}return{text:To(t,yn,e.join(t.lineBreak)),ranges:i,linewise:n}}(t.state);if(!i&&!o)return!1;Po=o?i:null,"cut"!=e.type||t.state.readOnly||t.dispatch({changes:n,scrollIntoView:!0,userEvent:"delete.cut"});let s=So?null:e.clipboardData;return s?(s.clearData(),s.setData("text/plain",i),!0):(function(t,e){let i=t.dom.parentNode;if(!i)return;let n=i.appendChild(document.createElement("textarea"));n.style.cssText="position: fixed; left: -10000px; top: 10px",n.value=e,n.focus(),n.selectionEnd=e.length,n.selectionStart=0,setTimeout((()=>{n.remove(),t.focus()}),50)}(t,i),!1)};const _o=$t.define();function Fo(t,e){let i=[];for(let n of t.facet(bn)){let o=n(t,e);o&&i.push(o)}return i.length?t.update({effects:i,annotations:_o.of(!0)}):null}function Vo(t){setTimeout((()=>{let e=t.hasFocus;if(e!=t.inputState.notifiedFocused){let i=Fo(t.state,e);i?t.dispatch(i):t.update([])}}),10)}ko.focus=t=>{t.inputState.lastFocusTime=Date.now(),t.scrollDOM.scrollTop||!t.inputState.lastScrollTop&&!t.inputState.lastScrollLeft||(t.scrollDOM.scrollTop=t.inputState.lastScrollTop,t.scrollDOM.scrollLeft=t.inputState.lastScrollLeft),Vo(t)},ko.blur=t=>{t.observer.clearSelectionRange(),Vo(t)},ko.compositionstart=ko.compositionupdate=t=>{t.observer.editContext||(null==t.inputState.compositionFirstChange&&(t.inputState.compositionFirstChange=!0),t.inputState.composing<0&&(t.inputState.composing=0))},ko.compositionend=t=>{t.observer.editContext||(t.inputState.composing=-1,t.inputState.compositionEndedAt=Date.now(),t.inputState.compositionPendingKey=!0,t.inputState.compositionPendingChange=t.observer.pendingRecords().length>0,t.inputState.compositionFirstChange=null,bi.chrome&&bi.android?t.observer.flushSoon():t.inputState.compositionPendingChange?Promise.resolve().then((()=>t.observer.flush())):setTimeout((()=>{t.inputState.composing<0&&t.docView.hasComposition&&t.update([])}),50))},ko.contextmenu=t=>{t.inputState.lastContextMenu=Date.now()},xo.beforeinput=(t,e)=>{var i,n;if("insertReplacementText"==e.inputType&&t.observer.editContext){let n=null===(i=e.dataTransfer)||void 0===i?void 0:i.getData("text/plain"),o=e.getTargetRanges();if(n&&o.length){let e=o[0],i=t.posAtDOM(e.startContainer,e.startOffset),s=t.posAtDOM(e.endContainer,e.endOffset);return po(t,{from:i,to:s,insert:t.state.toText(n)},null),!0}}let o;if(bi.chrome&&bi.android&&(o=bo.find((t=>t.inputType==e.inputType)))&&(t.observer.delayAndroidKey(o.key,o.keyCode),"Backspace"==o.key||"Delete"==o.key)){let e=(null===(n=window.visualViewport)||void 0===n?void 0:n.height)||0;setTimeout((()=>{var i;((null===(i=window.visualViewport)||void 0===i?void 0:i.height)||0)>e+10&&t.hasFocus&&(t.contentDOM.blur(),t.focus())}),100)}return bi.ios&&"deleteContentForward"==e.inputType&&t.observer.flushSoon(),bi.safari&&"insertText"==e.inputType&&t.inputState.composing>=0&&setTimeout((()=>ko.compositionend(t,e)),20),!1};const Ho=new Set;const zo=["pre-wrap","normal","pre-line","break-spaces"];let $o=!1;function Wo(){$o=!1}class Uo{constructor(t){this.lineWrapping=t,this.doc=U.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(t,e){let i=this.doc.lineAt(e).number-this.doc.lineAt(t).number+1;return this.lineWrapping&&(i+=Math.max(0,Math.ceil((e-t-i*this.lineLength*.5)/this.lineLength))),this.lineHeight*i}heightForLine(t){if(!this.lineWrapping)return this.lineHeight;return(1+Math.max(0,Math.ceil((t-this.lineLength)/(this.lineLength-5))))*this.lineHeight}setDoc(t){return this.doc=t,this}mustRefreshForWrapping(t){return zo.indexOf(t)>-1!=this.lineWrapping}mustRefreshForHeights(t){let e=!1;for(let i=0;i-1,l=Math.round(e)!=Math.round(this.lineHeight)||this.lineWrapping!=r;if(this.lineWrapping=r,this.lineHeight=e,this.charWidth=i,this.textHeight=n,this.lineLength=o,l){this.heightSamples={};for(let t=0;t0}set outdated(t){this.flags=(t?2:0)|-3&this.flags}setHeight(t){this.height!=t&&(Math.abs(this.height-t)>Zo&&($o=!0),this.height=t)}replace(t,e,i){return Ko.of(i)}decomposeLeft(t,e){e.push(this)}decomposeRight(t,e){e.push(this)}applyChanges(t,e,i,n){let o=this,s=i.doc;for(let r=n.length-1;r>=0;r--){let{fromA:l,toA:a,fromB:c,toB:h}=n[r],d=o.lineAt(l,Go.ByPosNoHeight,i.setDoc(e),0,0),u=d.to>=a?d:o.lineAt(a,Go.ByPosNoHeight,i,0,0);for(h+=u.to-a,a=u.to;r>0&&d.from<=n[r-1].toA;)l=n[r-1].fromA,c=n[r-1].fromB,r--,l2*o){let o=t[e-1];o.break?t.splice(--e,1,o.left,null,o.right):t.splice(--e,1,o.left,o.right),i+=1+o.break,n-=o.size}else{if(!(o>2*n))break;{let e=t[i];e.break?t.splice(i,1,e.left,null,e.right):t.splice(i,1,e.left,e.right),i+=2+e.break,o-=e.size}}else if(n=o&&s(this.blockAt(0,i,n,o))}updateHeight(t,e=0,i=!1,n){return n&&n.from<=e&&n.more&&this.setHeight(n.heights[n.index++]),this.outdated=!1,this}toString(){return`block(${this.length})`}}class Qo extends Jo{constructor(t,e){super(t,e,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0}blockAt(t,e,i,n){return new Yo(n,this.length,i,this.height,this.breaks)}replace(t,e,i){let n=i[0];return 1==i.length&&(n instanceof Qo||n instanceof ts&&4&n.flags)&&Math.abs(this.length-n.length)<10?(n instanceof ts?n=new Qo(n.length,this.height):n.height=this.height,this.outdated||(n.outdated=!1),n):Ko.of(i)}updateHeight(t,e=0,i=!1,n){return n&&n.from<=e&&n.more?this.setHeight(n.heights[n.index++]):(i||this.outdated)&&this.setHeight(Math.max(this.widgetHeight,t.heightForLine(this.length-this.collapsed))+this.breaks*t.lineHeight),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}}class ts extends Ko{constructor(t){super(t,0)}heightMetrics(t,e){let i,n=t.doc.lineAt(e).number,o=t.doc.lineAt(e+this.length).number,s=o-n+1,r=0;if(t.lineWrapping){let e=Math.min(this.height,t.lineHeight*s);i=e/s,this.length>s+1&&(r=(this.height-e)/(this.length-s-1))}else i=this.height/s;return{firstLine:n,lastLine:o,perLine:i,perChar:r}}blockAt(t,e,i,n){let{firstLine:o,lastLine:s,perLine:r,perChar:l}=this.heightMetrics(e,n);if(e.lineWrapping){let o=n+(t0){let t=i[i.length-1];t instanceof ts?i[i.length-1]=new ts(t.length+n):i.push(null,new ts(n-1))}if(t>0){let e=i[0];e instanceof ts?i[0]=new ts(t+e.length):i.unshift(new ts(t-1),null)}return Ko.of(i)}decomposeLeft(t,e){e.push(new ts(t-1),null)}decomposeRight(t,e){e.push(null,new ts(this.length-t-1))}updateHeight(t,e=0,i=!1,n){let o=e+this.length;if(n&&n.from<=e+this.length&&n.more){let i=[],s=Math.max(e,n.from),r=-1;for(n.from>e&&i.push(new ts(n.from-e-1).updateHeight(t,e));s<=o&&n.more;){let e=t.doc.lineAt(s).length;i.length&&i.push(null);let o=n.heights[n.index++];-1==r?r=o:Math.abs(o-r)>=Zo&&(r=-2);let l=new Qo(e,o);l.outdated=!1,i.push(l),s+=e+1}s<=o&&i.push(null,new ts(o-s).updateHeight(t,s));let l=Ko.of(i);return(r<0||Math.abs(l.height-this.height)>=Zo||Math.abs(r-this.heightMetrics(t,e).perLine)>=Zo)&&($o=!0),Xo(this,l)}return(i||this.outdated)&&(this.setHeight(t.heightForGap(e,e+this.length)),this.outdated=!1),this}toString(){return`gap(${this.length})`}}class es extends Ko{constructor(t,e,i){super(t.length+e+i.length,t.height+i.height,e|(t.outdated||i.outdated?2:0)),this.left=t,this.right=i,this.size=t.size+i.size}get break(){return 1&this.flags}blockAt(t,e,i,n){let o=i+this.left.height;return tr))return a;let c=e==Go.ByPosNoHeight?Go.ByPosNoHeight:Go.ByPos;return l?a.join(this.right.lineAt(r,c,i,s,r)):this.left.lineAt(r,c,i,n,o).join(a)}forEachLine(t,e,i,n,o,s){let r=n+this.left.height,l=o+this.left.length+this.break;if(this.break)t=l&&this.right.forEachLine(t,e,i,r,l,s);else{let a=this.lineAt(l,Go.ByPos,i,n,o);t=t&&a.from<=e&&s(a),e>a.to&&this.right.forEachLine(a.to+1,e,i,r,l,s)}}replace(t,e,i){let n=this.left.length+this.break;if(ethis.left.length)return this.balanced(this.left,this.right.replace(t-n,e-n,i));let o=[];t>0&&this.decomposeLeft(t,o);let s=o.length;for(let t of i)o.push(t);if(t>0&&is(o,s-1),e=i&&e.push(null)),t>i&&this.right.decomposeLeft(t-i,e)}decomposeRight(t,e){let i=this.left.length,n=i+this.break;if(t>=n)return this.right.decomposeRight(t-n,e);t2*e.size||e.size>2*t.size?Ko.of(this.break?[t,null,e]:[t,e]):(this.left=Xo(this.left,t),this.right=Xo(this.right,e),this.setHeight(t.height+e.height),this.outdated=t.outdated||e.outdated,this.size=t.size+e.size,this.length=t.length+this.break+e.length,this)}updateHeight(t,e=0,i=!1,n){let{left:o,right:s}=this,r=e+o.length+this.break,l=null;return n&&n.from<=e+o.length&&n.more?l=o=o.updateHeight(t,e,i,n):o.updateHeight(t,e,i),n&&n.from<=r+s.length&&n.more?l=s=s.updateHeight(t,r,i,n):s.updateHeight(t,r,i),l?this.balanced(o,s):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function is(t,e){let i,n;null==t[e]&&(i=t[e-1])instanceof ts&&(n=t[e+1])instanceof ts&&t.splice(e-1,3,new ts(i.length+1+n.length))}class ns{constructor(t,e){this.pos=t,this.oracle=e,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=t}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(t,e){if(this.lineStart>-1){let t=Math.min(e,this.lineEnd),i=this.nodes[this.nodes.length-1];i instanceof Qo?i.length+=t-this.pos:(t>this.pos||!this.isCovered)&&this.nodes.push(new Qo(t-this.pos,-1)),this.writtenTo=t,e>t&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=e}point(t,e,i){if(t=5)&&this.addLineDeco(n,o,s)}else e>t&&this.span(t,e);this.lineEnd>-1&&this.lineEnd-1)return;let{from:t,to:e}=this.oracle.doc.lineAt(this.pos);this.lineStart=t,this.lineEnd=e,this.writtenTot&&this.nodes.push(new Qo(this.pos-t,-1)),this.writtenTo=this.pos}blankContent(t,e){let i=new ts(e-t);return this.oracle.doc.lineAt(t).to==e&&(i.flags|=4),i}ensureLine(){this.enterLine();let t=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(t instanceof Qo)return t;let e=new Qo(0,-1);return this.nodes.push(e),e}addBlock(t){this.enterLine();let e=t.deco;e&&e.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(t),this.writtenTo=this.pos=this.pos+t.length,e&&e.endSide>0&&(this.covering=t)}addLineDeco(t,e,i){let n=this.ensureLine();n.length+=i,n.collapsed+=i,n.widgetHeight=Math.max(n.widgetHeight,t),n.breaks+=e,this.writtenTo=this.pos=this.pos+i}finish(t){let e=0==this.nodes.length?null:this.nodes[this.nodes.length-1];!(this.lineStart>-1)||e instanceof Qo||this.isCovered?(this.writtenToi.clientHeight||i.scrollWidth>i.clientWidth)&&"visible"!=n.overflow){let n=i.getBoundingClientRect();s=Math.max(s,n.left),r=Math.min(r,n.right),l=Math.max(l,n.top),a=Math.min(e==t.parentNode?o.innerHeight:a,n.bottom)}e="absolute"==n.position||"fixed"==n.position?i.offsetParent:i.parentNode}else{if(11!=e.nodeType)break;e=e.host}return{left:s-i.left,right:Math.max(s,r)-i.left,top:l-(i.top+e),bottom:Math.max(l,a)-(i.top+e)}}function rs(t,e){let i=t.getBoundingClientRect();return{left:0,right:i.right-i.left,top:e,bottom:i.bottom-(i.top+e)}}class ls{constructor(t,e,i,n){this.from=t,this.to=e,this.size=i,this.displaySize=n}static same(t,e){if(t.length!=e.length)return!1;for(let i=0;i"function"!=typeof t&&"cm-lineWrapping"==t.class));this.heightOracle=new Uo(e),this.stateDeco=t.facet(Nn).filter((t=>"function"!=typeof t)),this.heightMap=Ko.empty().applyChanges(this.stateDeco,U.empty,this.heightOracle.setDoc(t.doc),[new zn(0,0,0,t.doc.length)]);for(let t=0;t<2&&(this.viewport=this.getViewport(0,null),this.updateForViewport());t++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=qi.set(this.lineGaps.map((t=>t.draw(this,!1)))),this.computeVisibleRanges()}updateForViewport(){let t=[this.viewport],{main:e}=this.state.selection;for(let i=0;i<=1;i++){let n=i?e.head:e.anchor;if(!t.some((({from:t,to:e})=>n>=t&&n<=e))){let{from:e,to:i}=this.lineBlockAt(n);t.push(new hs(e,i))}}return this.viewports=t.sort(((t,e)=>t.from-e.from)),this.updateScaler()}updateScaler(){let t=this.scaler;return this.scaler=this.heightMap.height<=7e6?ps:new ms(this.heightOracle,this.heightMap,this.viewports),t.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,(t=>{this.viewportLines.push(gs(t,this.scaler))}))}update(t,e=null){this.state=t.state;let i=this.stateDeco;this.stateDeco=this.state.facet(Nn).filter((t=>"function"!=typeof t));let n=t.changedRanges,o=zn.extendWithRanges(n,function(t,e,i){let n=new os;return ce.compare(t,e,i,n,0),n.changes}(i,this.stateDeco,t?t.changes:st.empty(this.state.doc.length))),s=this.heightMap.height,r=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollTop);Wo(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,t.startState.doc,this.heightOracle.setDoc(this.state.doc),o),(this.heightMap.height!=s||$o)&&(t.flags|=2),r?(this.scrollAnchorPos=t.changes.mapPos(r.from,-1),this.scrollAnchorHeight=r.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=s);let l=o.length?this.mapViewport(this.viewport,t.changes):this.viewport;(e&&(e.range.headl.to)||!this.viewportIsAppropriate(l))&&(l=this.getViewport(0,e));let a=l.from!=this.viewport.from||l.to!=this.viewport.to;this.viewport=l,t.flags|=this.updateForViewport(),(a||!t.changes.empty||2&t.flags)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,t.changes))),t.flags|=this.computeVisibleRanges(t.changes),e&&(this.scrollTarget=e),!this.mustEnforceCursorAssoc&&t.selectionSet&&t.view.lineWrapping&&t.state.selection.main.empty&&t.state.selection.main.assoc&&!t.state.facet(Cn)&&(this.mustEnforceCursorAssoc=!0)}measure(t){let e=t.contentDOM,i=window.getComputedStyle(e),n=this.heightOracle,o=i.whiteSpace;this.defaultTextDirection="rtl"==i.direction?Ui.RTL:Ui.LTR;let s=this.heightOracle.mustRefreshForWrapping(o),r=e.getBoundingClientRect(),l=s||this.mustMeasureContent||this.contentDOMHeight!=r.height;this.contentDOMHeight=r.height,this.mustMeasureContent=!1;let a=0,c=0;if(r.width&&r.height){let{scaleX:t,scaleY:i}=ze(e,r);(t>.005&&Math.abs(this.scaleX-t)>.005||i>.005&&Math.abs(this.scaleY-i)>.005)&&(this.scaleX=t,this.scaleY=i,a|=16,s=l=!0)}let h=(parseInt(i.paddingTop)||0)*this.scaleY,d=(parseInt(i.paddingBottom)||0)*this.scaleY;this.paddingTop==h&&this.paddingBottom==d||(this.paddingTop=h,this.paddingBottom=d,a|=18),this.editorWidth!=t.scrollDOM.clientWidth&&(n.lineWrapping&&(l=!0),this.editorWidth=t.scrollDOM.clientWidth,a|=16);let u=t.scrollDOM.scrollTop*this.scaleY;this.scrollTop!=u&&(this.scrollAnchorHeight=-1,this.scrollTop=u),this.scrolledToBottom=Ke(t.scrollDOM);let p=(this.printing?rs:ss)(e,this.paddingTop),m=p.top-this.pixelViewport.top,g=p.bottom-this.pixelViewport.bottom;this.pixelViewport=p;let f=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(f!=this.inView&&(this.inView=f,f&&(l=!0)),!this.inView&&!this.scrollTarget&&!function(t){let e=t.getBoundingClientRect(),i=t.ownerDocument.defaultView||window;return e.left0&&e.top0}(t.dom))return 0;let b=r.width;if(this.contentDOMWidth==b&&this.editorHeight==t.scrollDOM.clientHeight||(this.contentDOMWidth=r.width,this.editorHeight=t.scrollDOM.clientHeight,a|=16),l){let e=t.docView.measureVisibleLineHeights(this.viewport);if(n.mustRefreshForHeights(e)&&(s=!0),s||n.lineWrapping&&Math.abs(b-this.contentDOMWidth)>n.charWidth){let{lineHeight:i,charWidth:r,textHeight:l}=t.docView.measureTextSize();s=i>0&&n.refresh(o,i,r,l,b/r,e),s&&(t.docView.minWidth=0,a|=16)}m>0&&g>0?c=Math.max(m,g):m<0&&g<0&&(c=Math.min(m,g)),Wo();for(let i of this.viewports){let o=i.from==this.viewport.from?e:t.docView.measureVisibleLineHeights(i);this.heightMap=(s?Ko.empty().applyChanges(this.stateDeco,U.empty,this.heightOracle,[new zn(0,0,0,t.state.doc.length)]):this.heightMap).updateHeight(n,0,s,new jo(i.from,o))}$o&&(a|=2)}let v=!this.viewportIsAppropriate(this.viewport,c)||this.scrollTarget&&(this.scrollTarget.range.headthis.viewport.to);return v&&(2&a&&(a|=this.updateScaler()),this.viewport=this.getViewport(c,this.scrollTarget),a|=this.updateForViewport()),(2&a||v)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(s?[]:this.lineGaps,t)),a|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,t.docView.enforceCursorAssoc()),a}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(t,e){let i=.5-Math.max(-.5,Math.min(.5,t/1e3/2)),n=this.heightMap,o=this.heightOracle,{visibleTop:s,visibleBottom:r}=this,l=new hs(n.lineAt(s-1e3*i,Go.ByHeight,o,0,0).from,n.lineAt(r+1e3*(1-i),Go.ByHeight,o,0,0).to);if(e){let{head:t}=e.range;if(tl.to){let i,s=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),r=n.lineAt(t,Go.ByPos,o,0,0);i="center"==e.y?(r.top+r.bottom)/2-s/2:"start"==e.y||"nearest"==e.y&&t=r+Math.max(10,Math.min(i,250)))&&n>s-2e3&&o>1,s=n<<1;if(this.defaultTextDirection!=Ui.LTR&&!i)return[];let r=[],l=(n,s,a,c)=>{if(s-nn&&tt.from>=a.from&&t.to<=a.to&&Math.abs(t.from-n)t.frome))));if(!u){if(st.from<=s&&t.to>=s))){let t=e.moveToLineBoundary(pt.cursor(s),!1,!0).head;t>n&&(s=t)}let t=this.gapSize(a,n,s,c);u=new ls(n,s,t,i||t<2e6?t:2e6)}r.push(u)},a=e=>{if(e.lengtho&&(n.push({from:o,to:t}),s+=t-o),o=e}},20),o2e6)for(let i of t)i.from>=e.from&&i.frome.from&&l(e.from,r,e,o),at.draw(this,this.heightOracle.lineWrapping)))))}computeVisibleRanges(t){let e=this.stateDeco;this.lineGaps.length&&(e=e.concat(this.lineGapDeco));let i=[];ce.spans(e,this.viewport.from,this.viewport.to,{span(t,e){i.push({from:t,to:e})},point(){}},20);let n=0;if(i.length!=this.visibleRanges.length)n=12;else for(let e=0;e=this.viewport.from&&t<=this.viewport.to&&this.viewportLines.find((e=>e.from<=t&&e.to>=t))||gs(this.heightMap.lineAt(t,Go.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(t){return t>=this.viewportLines[0].top&&t<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find((e=>e.top<=t&&e.bottom>=t))||gs(this.heightMap.lineAt(this.scaler.fromDOM(t),Go.ByHeight,this.heightOracle,0,0),this.scaler)}scrollAnchorAt(t){let e=this.lineBlockAtHeight(t+8);return e.from>=this.viewport.from||this.viewportLines[0].top-t>200?e:this.viewportLines[0]}elementAtHeight(t){return gs(this.heightMap.blockAt(this.scaler.fromDOM(t),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 hs{constructor(t,e){this.from=t,this.to=e}}function ds({total:t,ranges:e},i){if(i<=0)return e[0].from;if(i>=1)return e[e.length-1].to;let n=Math.floor(t*i);for(let t=0;;t++){let{from:i,to:o}=e[t],s=o-i;if(n<=s)return i+n;n-=s}}function us(t,e){let i=0;for(let{from:n,to:o}of t.ranges){if(e<=o){i+=e-n;break}i+=o-n}return i/t.total}const ps={toDOM:t=>t,fromDOM:t=>t,scale:1,eq(t){return t==this}};class ms{constructor(t,e,i){let n=0,o=0,s=0;this.viewports=i.map((({from:i,to:o})=>{let s=e.lineAt(i,Go.ByPos,t,0,0).top,r=e.lineAt(o,Go.ByPos,t,0,0).bottom;return n+=r-s,{from:i,to:o,top:s,bottom:r,domTop:0,domBottom:0}})),this.scale=(7e6-n)/(e.height-n);for(let t of this.viewports)t.domTop=s+(t.top-o)*this.scale,s=t.domBottom=t.domTop+(t.bottom-t.top),o=t.bottom}toDOM(t){for(let e=0,i=0,n=0;;e++){let o=ee.from==t.viewports[i].from&&e.to==t.viewports[i].to)))}}function gs(t,e){if(1==e.scale)return t;let i=e.toDOM(t.top),n=e.toDOM(t.bottom);return new Yo(t.from,t.length,i,n-i,Array.isArray(t._content)?t._content.map((t=>gs(t,e))):t._content)}const fs=ft.define({combine:t=>t.join(" ")}),bs=ft.define({combine:t=>t.indexOf(!0)>-1}),vs=Se.newName(),ys=Se.newName(),ws=Se.newName(),Cs={"&light":"."+ys,"&dark":"."+ws};function xs(t,e,i){return new Se(e,{finish:e=>/&/.test(e)?e.replace(/&\w*/,(e=>{if("&"==e)return t;if(!i||!i[e])throw new RangeError(`Unsupported selector: ${e}`);return i[e]})):t+" "+e})}const ks=xs("."+vs,{"&":{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,overflowAnchor:"none"},".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:"#ddd"},".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,zIndex:300},"&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",userSelect:"none"},".cm-highlightSpace":{backgroundImage:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 5%)",backgroundPosition:"center"},".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"}},Cs),Ss={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},Ts=bi.ie&&bi.ie_version<=11;class Es{constructor(t){this.view=t,this.active=!1,this.editContext=null,this.selectionRange=new $e,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=t.contentDOM,this.observer=new MutationObserver((e=>{for(let t of e)this.queue.push(t);(bi.ie&&bi.ie_version<=11||bi.ios&&t.composing)&&e.some((t=>"childList"==t.type&&t.removedNodes.length||"characterData"==t.type&&t.oldValue.length>t.target.nodeValue.length))?this.flushSoon():this.flush()})),!window.EditContext||!1===t.constructor.EDIT_CONTEXT||bi.chrome&&bi.chrome_version<126||(this.editContext=new Ds(t),t.state.facet(Mn)&&(t.contentDOM.editContext=this.editContext.editContext)),Ts&&(this.onCharData=t=>{this.queue.push({target:t.target,type:"characterData",oldValue:t.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")),"function"==typeof ResizeObserver&&(this.resizeScroll=new ResizeObserver((()=>{var t;(null===(t=this.view.docView)||void 0===t?void 0:t.lastUpdate){this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),t.length>0&&t[t.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((t=>{t.length>0&&t[t.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))}),{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(t){this.view.inputState.runHandlers("scroll",t),this.intersecting&&this.view.measure()}onScroll(t){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(t)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout((()=>{this.resizeTimeout=-1,this.view.requestMeasure()}),50))}onPrint(t){("change"!=t.type&&t.type||t.matches)&&(this.view.viewState.printing=!0,this.view.measure(),setTimeout((()=>{this.view.viewState.printing=!1,this.view.requestMeasure()}),500))}updateGaps(t){if(this.gapIntersection&&(t.length!=this.gaps.length||this.gaps.some(((e,i)=>e!=t[i])))){this.gapIntersection.disconnect();for(let e of t)this.gapIntersection.observe(e);this.gaps=t}}onSelectionChange(t){let e=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:i}=this,n=this.selectionRange;if(i.state.facet(Mn)?i.root.activeElement!=this.dom:!qe(this.dom,n))return;let o=n.anchorNode&&i.docView.nearest(n.anchorNode);o&&o.ignoreEvent(t)?e||(this.selectionChanged=!1):(bi.ie&&bi.ie_version<=11||bi.android&&bi.chrome)&&!i.state.selection.main.empty&&n.focusNode&&Le(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:t}=this,e=Oe(t.root);if(!e)return!1;let i=bi.safari&&11==t.root.nodeType&&t.root.activeElement==this.dom&&function(t,e){if(e.getComposedRanges){let i=e.getComposedRanges(t.root)[0];if(i)return As(t,i)}let i=null;function n(t){t.preventDefault(),t.stopImmediatePropagation(),i=t.getTargetRanges()[0]}return t.contentDOM.addEventListener("beforeinput",n,!0),t.dom.ownerDocument.execCommand("indent"),t.contentDOM.removeEventListener("beforeinput",n,!0),i?As(t,i):null}(this.view,e)||e;if(!i||this.selectionRange.eq(i))return!1;let n=qe(this.dom,i);return n&&!this.selectionChanged&&t.inputState.lastFocusTime>Date.now()-200&&t.inputState.lastTouchTime{let t=this.delayedAndroidKey;if(t){this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=t.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&t.force&&Ge(this.dom,t.key,t.keyCode)}};this.flushingAndroidKey=this.view.win.requestAnimationFrame(t)}this.delayedAndroidKey&&"Enter"!=t||(this.delayedAndroidKey={key:t,keyCode:e,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 t of this.observer.takeRecords())this.queue.push(t);return this.queue}processRecords(){let t=this.pendingRecords();t.length&&(this.queue=[]);let e=-1,i=-1,n=!1;for(let o of t){let t=this.readMutation(o);t&&(t.typeOver&&(n=!0),-1==e?({from:e,to:i}=t):(e=Math.min(t.from,e),i=Math.max(t.to,i)))}return{from:e,to:i,typeOver:n}}readChange(){let{from:t,to:e,typeOver:i}=this.processRecords(),n=this.selectionChanged&&qe(this.dom,this.selectionRange);if(t<0&&!n)return null;t>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let o=new ho(this.view,t,e,i);return this.view.docView.domChanged={newSel:o.newSel?o.newSel.main:null},o}flush(t=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;t&&this.readSelectionRange();let e=this.readChange();if(!e)return this.view.requestMeasure(),!1;let i=this.view.state,n=uo(this.view,e);return this.view.state==i&&(e.domChanged||e.newSel&&!e.newSel.main.eq(this.view.state.selection.main))&&this.view.update([]),n}readMutation(t){let e=this.view.docView.nearest(t.target);if(!e||e.ignoreMutation(t))return null;if(e.markDirty("attributes"==t.type),"attributes"==t.type&&(e.flags|=4),"childList"==t.type){let i=Ms(e,t.previousSibling||t.target.previousSibling,-1),n=Ms(e,t.nextSibling||t.target.nextSibling,1);return{from:i?e.posAfter(i):e.posAtStart,to:n?e.posBefore(n):e.posAtEnd,typeOver:!1}}return"characterData"==t.type?{from:e.posAtStart,to:e.posAtEnd,typeOver:t.target.nodeValue==t.oldValue}:null}setWindow(t){t!=this.win&&(this.removeWindowListeners(this.win),this.win=t,this.addWindowListeners(this.win))}addWindowListeners(t){t.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):t.addEventListener("beforeprint",this.onPrint),t.addEventListener("scroll",this.onScroll),t.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(t){t.removeEventListener("scroll",this.onScroll),t.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):t.removeEventListener("beforeprint",this.onPrint),t.document.removeEventListener("selectionchange",this.onSelectionChange)}update(t){this.editContext&&(this.editContext.update(t),t.startState.facet(Mn)!=t.state.facet(Mn)&&(t.view.contentDOM.editContext=t.state.facet(Mn)?this.editContext.editContext:null))}destroy(){var t,e,i;this.stop(),null===(t=this.intersection)||void 0===t||t.disconnect(),null===(e=this.gapIntersection)||void 0===e||e.disconnect(),null===(i=this.resizeScroll)||void 0===i||i.disconnect();for(let t of this.scrollTargets)t.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey),this.editContext&&(this.view.contentDOM.editContext=null,this.editContext.destroy())}}function Ms(t,e,i){for(;e;){let n=ei.get(e);if(n&&n.parent==t)return n;let o=e.parentNode;e=o!=t.dom?o:i>0?e.nextSibling:e.previousSibling}return null}function As(t,e){let i=e.startContainer,n=e.startOffset,o=e.endContainer,s=e.endOffset,r=t.docView.domAtPos(t.state.selection.main.anchor);return Le(r.node,r.offset,o,s)&&([i,n,o,s]=[o,s,i,n]),{anchorNode:i,anchorOffset:n,focusNode:o,focusOffset:s}}class Ds{constructor(t){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(t.state);let e=this.editContext=new window.EditContext({text:t.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,t.state.selection.main.anchor))),selectionEnd:this.toContextPos(t.state.selection.main.head)});this.handlers.textupdate=e=>{let i=t.state.selection.main,{anchor:n,head:o}=i,s=this.toEditorPos(e.updateRangeStart),r=this.toEditorPos(e.updateRangeEnd);t.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:e.updateRangeStart,editorBase:s,drifted:!1});let l={from:s,to:r,insert:U.of(e.text.split("\n"))};if(l.from==this.from&&nthis.to&&(l.to=n),l.from!=l.to||l.insert.length){if((bi.mac||bi.android)&&l.from==o-1&&/^\. ?$/.test(e.text)&&"off"==t.contentDOM.getAttribute("autocorrect")&&(l={from:s,to:r,insert:U.of([e.text.replace("."," ")])}),this.pendingContextChange=l,!t.state.readOnly){let i=this.to-this.from+(l.to-l.from+l.insert.length);po(t,l,pt.single(this.toEditorPos(e.selectionStart,i),this.toEditorPos(e.selectionEnd,i)))}this.pendingContextChange&&(this.revertPending(t.state),this.setSelection(t.state))}else{let n=pt.single(this.toEditorPos(e.selectionStart),this.toEditorPos(e.selectionEnd));n.main.eq(i)||t.dispatch({selection:n,userEvent:"select"})}},this.handlers.characterboundsupdate=i=>{let n=[],o=null;for(let e=this.toEditorPos(i.rangeStart),s=this.toEditorPos(i.rangeEnd);e{let i=[];for(let t of e.getTextFormats()){let e=t.underlineStyle,n=t.underlineThickness;if("None"!=e&&"None"!=n){let o=this.toEditorPos(t.rangeStart),s=this.toEditorPos(t.rangeEnd);if(o{t.inputState.composing<0&&(t.inputState.composing=0,t.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(t.inputState.composing=-1,t.inputState.compositionFirstChange=null,this.composing){let{drifted:e}=this.composing;this.composing=null,e&&this.reset(t.state)}};for(let t in this.handlers)e.addEventListener(t,this.handlers[t]);this.measureReq={read:t=>{this.editContext.updateControlBounds(t.contentDOM.getBoundingClientRect());let e=Oe(t.root);e&&e.rangeCount&&this.editContext.updateSelectionBounds(e.getRangeAt(0).getBoundingClientRect())}}}applyEdits(t){let e=0,i=!1,n=this.pendingContextChange;return t.changes.iterChanges(((o,s,r,l,a)=>{if(i)return;let c=a.length-(s-o);if(n&&s>=n.to){if(n.from==o&&n.to==s&&n.insert.eq(a))return n=this.pendingContextChange=null,e+=c,void(this.to+=c);n=null,this.revertPending(t.state)}if(o+=e,(s+=e)<=this.from)this.from+=c,this.to+=c;else if(othis.to||this.to-this.from+a.length>3e4)return void(i=!0);this.editContext.updateText(this.toContextPos(o),this.toContextPos(s),a.toString()),this.to+=c}e+=c})),n&&!i&&this.revertPending(t.state),!i}update(t){let e=this.pendingContextChange,i=t.startState.selection.main;this.composing&&(this.composing.drifted||!t.changes.touchesRange(i.from,i.to)&&t.transactions.some((t=>!t.isUserEvent("input.type")&&t.changes.touchesRange(this.from,this.to))))?(this.composing.drifted=!0,this.composing.editorBase=t.changes.mapPos(this.composing.editorBase)):this.applyEdits(t)&&this.rangeIsValid(t.state)?(t.docChanged||t.selectionSet||e)&&this.setSelection(t.state):(this.pendingContextChange=null,this.reset(t.state)),(t.geometryChanged||t.docChanged||t.selectionSet)&&t.view.requestMeasure(this.measureReq)}resetRange(t){let{head:e}=t.selection.main;this.from=Math.max(0,e-1e4),this.to=Math.min(t.doc.length,e+1e4)}reset(t){this.resetRange(t),this.editContext.updateText(0,this.editContext.text.length,t.doc.sliceString(this.from,this.to)),this.setSelection(t)}revertPending(t){let e=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(e.from),this.toContextPos(e.from+e.insert.length),t.doc.sliceString(e.from,e.to))}setSelection(t){let{main:e}=t.selection,i=this.toContextPos(Math.max(this.from,Math.min(this.to,e.anchor))),n=this.toContextPos(e.head);this.editContext.selectionStart==i&&this.editContext.selectionEnd==n||this.editContext.updateSelection(i,n)}rangeIsValid(t){let{head:e}=t.selection.main;return!(this.from>0&&e-this.from<500||this.to3e4)}toEditorPos(t,e=this.to-this.from){t=Math.min(t,e);let i=this.composing;return i&&i.drifted?i.editorBase+(t-i.contextBase):t+this.from}toContextPos(t){let e=this.composing;return e&&e.drifted?e.contextBase+(t-e.editorBase):t-this.from}destroy(){for(let t in this.handlers)this.editContext.removeEventListener(t,this.handlers[t])}}class Is{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&&this.inputState.composing>0}get compositionStarted(){return!!this.inputState&&this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(t={}){var 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),t.parent&&t.parent.appendChild(this.dom);let{dispatch:i}=t;this.dispatchTransactions=t.dispatchTransactions||i&&(t=>t.forEach((t=>i(t,this))))||(t=>this.update(t)),this.dispatch=this.dispatch.bind(this),this._root=t.root||function(t){for(;t;){if(t&&(9==t.nodeType||11==t.nodeType&&t.host))return t;t=t.assignedSlot||t.parentNode}return null}(t.parent)||document,this.viewState=new cs(t.state||oe.create(t)),t.scrollTo&&t.scrollTo.is(Sn)&&(this.viewState.scrollTarget=t.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(Dn).map((t=>new On(t)));for(let t of this.plugins)t.update(this);this.observer=new Es(this),this.inputState=new mo(this),this.inputState.ensureHandlers(this.plugins),this.docView=new Wn(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),(null===(e=document.fonts)||void 0===e?void 0:e.ready)&&document.fonts.ready.then((()=>this.requestMeasure()))}dispatch(...t){let e=1==t.length&&t[0]instanceof Yt?t:1==t.length&&Array.isArray(t[0])?t[0]:[this.state.update(...t)];this.dispatchTransactions(e,this)}update(t){if(0!=this.updateState)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let e,i=!1,n=!1,o=this.state;for(let e of t){if(e.startState!=o)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");o=e.state}if(this.destroyed)return void(this.viewState.state=o);let s=this.hasFocus,r=0,l=null;t.some((t=>t.annotation(_o)))?(this.inputState.notifiedFocused=s,r=1):s!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=s,l=Fo(o,s),l||(r=1));let a=this.observer.delayedAndroidKey,c=null;if(a?(this.observer.clearDelayedAndroidKey(),c=this.observer.readChange(),(c&&!this.state.doc.eq(o.doc)||!this.state.selection.eq(o.selection))&&(c=null)):this.observer.clear(),o.facet(oe.phrases)!=this.state.facet(oe.phrases))return this.setState(o);e=$n.create(this,o,t),e.flags|=r;let h=this.viewState.scrollTarget;try{this.updateState=2;for(let e of t){if(h&&(h=h.map(e.changes)),e.scrollIntoView){let{main:t}=e.state.selection;h=new kn(t.empty?t:pt.cursor(t.head,t.head>t.anchor?-1:1))}for(let t of e.effects)t.is(Sn)&&(h=t.value.clip(this.state))}this.viewState.update(e,h),this.bidiCache=qs.update(this.bidiCache,e.changes),e.empty||(this.updatePlugins(e),this.inputState.update(e)),i=this.docView.update(e),this.state.facet(Hn)!=this.styleModules&&this.mountStyles(),n=this.updateAttrs(),this.showAnnouncements(t),this.docView.updateSelection(i,t.some((t=>t.isUserEvent("select.pointer"))))}finally{this.updateState=0}if(e.startState.facet(fs)!=e.state.facet(fs)&&(this.viewState.mustMeasureContent=!0),(i||n||h||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),i&&this.docViewUpdate(),!e.empty)for(let t of this.state.facet(gn))try{t(e)}catch(t){En(this.state,t,"update listener")}(l||c)&&Promise.resolve().then((()=>{l&&this.state==l.startState&&this.dispatch(l),c&&!uo(this,c)&&a.force&&Ge(this.contentDOM,a.key,a.keyCode)}))}setState(t){if(0!=this.updateState)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed)return void(this.viewState.state=t);this.updateState=2;let e=this.hasFocus;try{for(let t of this.plugins)t.destroy(this);this.viewState=new cs(t),this.plugins=t.facet(Dn).map((t=>new On(t))),this.pluginMap.clear();for(let t of this.plugins)t.update(this);this.docView.destroy(),this.docView=new Wn(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}e&&this.focus(),this.requestMeasure()}updatePlugins(t){let e=t.startState.facet(Dn),i=t.state.facet(Dn);if(e!=i){let n=[];for(let o of i){let i=e.indexOf(o);if(i<0)n.push(new On(o));else{let e=this.plugins[i];e.mustUpdate=t,n.push(e)}}for(let e of this.plugins)e.mustUpdate!=t&&e.destroy(this);this.plugins=n,this.pluginMap.clear()}else for(let e of this.plugins)e.mustUpdate=t;for(let t=0;t-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey)return this.measureScheduled=-1,void this.requestMeasure();this.measureScheduled=0,t&&this.observer.forceFlush();let e=null,i=this.scrollDOM,n=i.scrollTop*this.scaleY,{scrollAnchorPos:o,scrollAnchorHeight:s}=this.viewState;Math.abs(n-this.viewState.scrollTop)>1&&(s=-1),this.viewState.scrollAnchorHeight=-1;try{for(let t=0;;t++){if(s<0)if(Ke(i))o=-1,s=this.viewState.heightMap.height;else{let t=this.viewState.scrollAnchorAt(n);o=t.from,s=t.top}this.updateState=1;let r=this.viewState.measure(this);if(!r&&!this.measureRequests.length&&null==this.viewState.scrollTarget)break;if(t>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let l=[];4&r||([this.measureRequests,l]=[l,this.measureRequests]);let a=l.map((t=>{try{return t.read(this)}catch(t){return En(this.state,t),Bs}})),c=$n.create(this,this.state,[]),h=!1;c.flags|=r,e?e.flags|=r:e=c,this.updateState=2,c.empty||(this.updatePlugins(c),this.inputState.update(c),this.updateAttrs(),h=this.docView.update(c),h&&this.docViewUpdate());for(let t=0;t1||t<-1){n+=t,i.scrollTop=n/this.scaleY,s=-1;continue}}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(e&&!e.empty)for(let t of this.state.facet(gn))t(e)}get themeClasses(){return vs+" "+(this.state.facet(bs)?ws:ys)+" "+this.state.facet(fs)}updateAttrs(){let t=Ns(this,Bn,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),e={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(Mn)?"true":"false",class:"cm-content",style:`${bi.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(e["aria-readonly"]="true"),Ns(this,qn,e);let i=this.observer.ignore((()=>{let i=Di(this.contentDOM,this.contentAttrs,e),n=Di(this.dom,this.editorAttrs,t);return i||n}));return this.editorAttrs=t,this.contentAttrs=e,i}showAnnouncements(t){let e=!0;for(let i of t)for(let t of i.effects)if(t.is(Is.announce)){e&&(this.announceDOM.textContent=""),e=!1,this.announceDOM.appendChild(document.createElement("div")).textContent=t.value}}mountStyles(){this.styleModules=this.state.facet(Hn);let t=this.state.facet(Is.cspNonce);Se.mount(this.root,this.styleModules.concat(ks).reverse(),t?{nonce:t}:void 0)}readMeasured(){if(2==this.updateState)throw new Error("Reading the editor layout isn't allowed during an update");0==this.updateState&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(t){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame((()=>this.measure()))),t){if(this.measureRequests.indexOf(t)>-1)return;if(null!=t.key)for(let e=0;ee.spec==t))||null),e&&e.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(t){return this.readMeasured(),this.viewState.elementAtHeight(t)}lineBlockAtHeight(t){return this.readMeasured(),this.viewState.lineBlockAtHeight(t)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(t){return this.viewState.lineBlockAt(t)}get contentHeight(){return this.viewState.contentHeight}moveByChar(t,e,i){return so(this,t,no(this,t,e,i))}moveByGroup(t,e){return so(this,t,no(this,t,e,(e=>function(t,e,i){let n=t.state.charCategorizer(e),o=n(i);return t=>{let e=n(t);return o==te.Space&&(o=e),o==e}}(this,t.head,e))))}visualLineSide(t,e){let i=this.bidiSpans(t),n=this.textDirectionAt(t.from),o=i[e?i.length-1:0];return pt.cursor(o.side(e,n)+t.from,o.forward(!e,n)?1:-1)}moveToLineBoundary(t,e,i=!0){return io(this,t,e,i)}moveVertically(t,e,i){return so(this,t,function(t,e,i,n){let o=e.head,s=i?1:-1;if(o==(i?t.state.doc.length:0))return pt.cursor(o,e.assoc);let r,l=e.goalColumn,a=t.contentDOM.getBoundingClientRect(),c=t.coordsAtPos(o,e.assoc||-1),h=t.documentTop;if(c)null==l&&(l=c.left-a.left),r=s<0?c.top:c.bottom;else{let e=t.viewState.lineBlockAt(o);null==l&&(l=Math.min(a.right-a.left,t.defaultCharacterWidth*(o-e.from))),r=(s<0?e.top:e.bottom)+h}let d=a.left+l,u=null!=n?n:t.viewState.heightOracle.textHeight>>1;for(let e=0;;e+=10){let i=r+(u+e)*s,n=to(t,{x:d,y:i},!1,s);if(ia.bottom||(s<0?no)){let e=t.docView.coordsForChar(n),o=!e||i0)}coordsForChar(t){return this.readMeasured(),this.docView.coordsForChar(t)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(t){return!this.state.facet(wn)||tthis.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(t))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(t){if(t.length>Os)return ln(t.length);let e,i=this.textDirectionAt(t.from);for(let n of this.bidiCache)if(n.from==t.from&&n.dir==i&&(n.fresh||nn(n.isolates,e=_n(this,t))))return n.order;e||(e=_n(this,t));let n=function(t,e,i){if(!t)return[new en(0,0,e==Yi?1:0)];if(e==ji&&!i.length&&!tn.test(t))return ln(t.length);if(i.length)for(;t.length>on.length;)on[on.length]=256;let n=[],o=e==ji?0:1;return rn(t,o,o,i,0,t.length,n),n}(t.text,i,e);return this.bidiCache.push(new qs(t.from,t.to,i,e,!0,n)),n}get hasFocus(){var t;return(this.dom.ownerDocument.hasFocus()||bi.safari&&(null===(t=this.inputState)||void 0===t?void 0:t.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore((()=>{je(this.contentDOM),this.docView.updateSelection()}))}setRoot(t){this._root!=t&&(this._root=t,this.observer.setWindow((9==t.nodeType?t:t.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let t of this.plugins)t.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(t,e={}){return Sn.of(new kn("number"==typeof t?pt.cursor(t):t,e.y,e.x,e.yMargin,e.xMargin))}scrollSnapshot(){let{scrollTop:t,scrollLeft:e}=this.scrollDOM,i=this.viewState.scrollAnchorAt(t);return Sn.of(new kn(pt.cursor(i.from),"start","start",i.top-t,e,!0))}setTabFocusMode(t){null==t?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:"boolean"==typeof t?this.inputState.tabFocusMode=t?0:-1:0!=this.inputState.tabFocusMode&&(this.inputState.tabFocusMode=Date.now()+t)}static domEventHandlers(t){return In.define((()=>({})),{eventHandlers:t})}static domEventObservers(t){return In.define((()=>({})),{eventObservers:t})}static theme(t,e){let i=Se.newName(),n=[fs.of(i),Hn.of(xs(`.${i}`,t))];return e&&e.dark&&n.push(bs.of(!0)),n}static baseTheme(t){return Dt.lowest(Hn.of(xs("."+vs,t,Cs)))}static findFromDOM(t){var e;let i=t.querySelector(".cm-content"),n=i&&ei.get(i)||ei.get(t);return(null===(e=null==n?void 0:n.rootView)||void 0===e?void 0:e.view)||null}}Is.styleModule=Hn,Is.inputHandler=fn,Is.clipboardInputFilter=vn,Is.clipboardOutputFilter=yn,Is.scrollHandler=xn,Is.focusChangeEffect=bn,Is.perLineTextDirection=wn,Is.exceptionSink=mn,Is.updateListener=gn,Is.editable=Mn,Is.mouseSelectionStyle=pn,Is.dragMovesSelection=un,Is.clickAddsSelectionRange=dn,Is.decorations=Nn,Is.outerDecorations=Ln,Is.atomicRanges=Rn,Is.bidiIsolatedRanges=Pn,Is.scrollMargins=Fn,Is.darkTheme=bs,Is.cspNonce=ft.define({combine:t=>t.length?t[0]:""}),Is.contentAttributes=qn,Is.editorAttributes=Bn,Is.lineWrapping=Is.contentAttributes.of({class:"cm-lineWrapping"}),Is.announce=jt.define();const Os=4096,Bs={};class qs{constructor(t,e,i,n,o,s){this.from=t,this.to=e,this.dir=i,this.isolates=n,this.fresh=o,this.order=s}static update(t,e){if(e.empty&&!t.some((t=>t.fresh)))return t;let i=[],n=t.length?t[t.length-1].dir:Ui.LTR;for(let o=Math.max(0,t.length-10);o=0;o--){let e=n[o],s="function"==typeof e?e(t):e;s&&Ei(s,i)}return i}class Ls extends se{compare(t){return this==t||this.constructor==t.constructor&&this.eq(t)}eq(t){return!1}destroy(t){}}Ls.prototype.elementClass="",Ls.prototype.toDOM=void 0,Ls.prototype.mapMode=nt.TrackBefore,Ls.prototype.startSide=Ls.prototype.endSide=-1,Ls.prototype.point=!0;let Rs=0;class Ps{constructor(t,e,i,n){this.name=t,this.set=e,this.base=i,this.modified=n,this.id=Rs++}toString(){let{name:t}=this;for(let e of this.modified)e.name&&(t=`${e.name}(${t})`);return t}static define(t,e){let i="string"==typeof t?t:"?";if(t instanceof Ps&&(e=t),null==e?void 0:e.base)throw new Error("Can not derive from a modified tag");let n=new Ps(i,[],null,[]);if(n.set.push(n),e)for(let t of e.set)n.set.push(t);return n}static defineModifier(t){let e=new Fs(t);return t=>t.modified.indexOf(e)>-1?t:Fs.get(t.base||t,t.modified.concat(e).sort(((t,e)=>t.id-e.id)))}}let _s=0;class Fs{constructor(t){this.name=t,this.instances=[],this.id=_s++}static get(t,e){if(!e.length)return t;let i=e[0].instances.find((i=>{return i.base==t&&(n=e,o=i.modified,n.length==o.length&&n.every(((t,e)=>t==o[e])));var n,o}));if(i)return i;let n=[],o=new Ps(t.name,n,t,e);for(let t of e)t.instances.push(o);let s=function(t){let e=[[]];for(let i=0;ie.length-t.length))}(e);for(let e of t.set)if(!e.modified.length)for(let t of s)n.push(Fs.get(e,t));return o}}function Vs(t){let e=Object.create(null);for(let i in t){let n=t[i];Array.isArray(n)||(n=[n]);for(let t of i.split(" "))if(t){let i=[],o=2,s=t;for(let e=0;;){if("..."==s&&e>0&&e+3==t.length){o=1;break}let n=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(s);if(!n)throw new RangeError("Invalid path: "+t);if(i.push("*"==n[0]?"":'"'==n[0][0]?JSON.parse(n[0]):n[0]),e+=n[0].length,e==t.length)break;let r=t[e++];if(e==t.length&&"!"==r){o=0;break}if("/"!=r)throw new RangeError("Invalid path: "+t);s=t.slice(e)}let r=i.length-1,l=i[r];if(!l)throw new RangeError("Invalid path: "+t);let a=new zs(n,o,r>0?i.slice(0,r):null);e[l]=a.sort(e[l])}}return Hs.add(e)}const Hs=new r;class zs{constructor(t,e,i,n){this.tags=t,this.mode=e,this.context=i,this.next=n}get opaque(){return 0==this.mode}get inherit(){return 1==this.mode}sort(t){return!t||t.depth{let e=o;for(let n of t)for(let t of n.set){let n=i[t.id];if(n){e=e?e+" "+n:n;break}}return e},scope:n}}zs.empty=new zs([],2,null);const Ws=Ps.define,Us=Ws(),js=Ws(),Ys=Ws(js),Gs=Ws(js),Zs=Ws(),Ks=Ws(Zs),Xs=Ws(Zs),Js=Ws(),Qs=Ws(Js),tr=Ws(),er=Ws(),ir=Ws(),nr=Ws(ir),or=Ws(),sr={comment:Us,lineComment:Ws(Us),blockComment:Ws(Us),docComment:Ws(Us),name:js,variableName:Ws(js),typeName:Ys,tagName:Ws(Ys),propertyName:Gs,attributeName:Ws(Gs),className:Ws(js),labelName:Ws(js),namespace:Ws(js),macroName:Ws(js),literal:Zs,string:Ks,docString:Ws(Ks),character:Ws(Ks),attributeValue:Ws(Ks),number:Xs,integer:Ws(Xs),float:Ws(Xs),bool:Ws(Zs),regexp:Ws(Zs),escape:Ws(Zs),color:Ws(Zs),url:Ws(Zs),keyword:tr,self:Ws(tr),null:Ws(tr),atom:Ws(tr),unit:Ws(tr),modifier:Ws(tr),operatorKeyword:Ws(tr),controlKeyword:Ws(tr),definitionKeyword:Ws(tr),moduleKeyword:Ws(tr),operator:er,derefOperator:Ws(er),arithmeticOperator:Ws(er),logicOperator:Ws(er),bitwiseOperator:Ws(er),compareOperator:Ws(er),updateOperator:Ws(er),definitionOperator:Ws(er),typeOperator:Ws(er),controlOperator:Ws(er),punctuation:ir,separator:Ws(ir),bracket:nr,angleBracket:Ws(nr),squareBracket:Ws(nr),paren:Ws(nr),brace:Ws(nr),content:Js,heading:Qs,heading1:Ws(Qs),heading2:Ws(Qs),heading3:Ws(Qs),heading4:Ws(Qs),heading5:Ws(Qs),heading6:Ws(Qs),contentSeparator:Ws(Js),list:Ws(Js),quote:Ws(Js),emphasis:Ws(Js),strong:Ws(Js),link:Ws(Js),monospace:Ws(Js),strikethrough:Ws(Js),inserted:Ws(),deleted:Ws(),changed:Ws(),invalid:Ws(),meta:or,documentMeta:Ws(or),annotation:Ws(or),processingInstruction:Ws(or),definition:Ps.defineModifier("definition"),constant:Ps.defineModifier("constant"),function:Ps.defineModifier("function"),standard:Ps.defineModifier("standard"),local:Ps.defineModifier("local"),special:Ps.defineModifier("special")};for(let t in sr){let e=sr[t];e instanceof Ps&&(e.name=t)}var rr;$s([{tag:sr.link,class:"tok-link"},{tag:sr.heading,class:"tok-heading"},{tag:sr.emphasis,class:"tok-emphasis"},{tag:sr.strong,class:"tok-strong"},{tag:sr.keyword,class:"tok-keyword"},{tag:sr.atom,class:"tok-atom"},{tag:sr.bool,class:"tok-bool"},{tag:sr.url,class:"tok-url"},{tag:sr.labelName,class:"tok-labelName"},{tag:sr.inserted,class:"tok-inserted"},{tag:sr.deleted,class:"tok-deleted"},{tag:sr.literal,class:"tok-literal"},{tag:sr.string,class:"tok-string"},{tag:sr.number,class:"tok-number"},{tag:[sr.regexp,sr.escape,sr.special(sr.string)],class:"tok-string2"},{tag:sr.variableName,class:"tok-variableName"},{tag:sr.local(sr.variableName),class:"tok-variableName tok-local"},{tag:sr.definition(sr.variableName),class:"tok-variableName tok-definition"},{tag:sr.special(sr.variableName),class:"tok-variableName2"},{tag:sr.definition(sr.propertyName),class:"tok-propertyName tok-definition"},{tag:sr.typeName,class:"tok-typeName"},{tag:sr.namespace,class:"tok-namespace"},{tag:sr.className,class:"tok-className"},{tag:sr.macroName,class:"tok-macroName"},{tag:sr.propertyName,class:"tok-propertyName"},{tag:sr.operator,class:"tok-operator"},{tag:sr.comment,class:"tok-comment"},{tag:sr.meta,class:"tok-meta"},{tag:sr.invalid,class:"tok-invalid"},{tag:sr.punctuation,class:"tok-punctuation"}]);const lr=new r,ar=new r;class cr{constructor(t,e,i=[],n=""){this.data=t,this.name=n,oe.prototype.hasOwnProperty("tree")||Object.defineProperty(oe.prototype,"tree",{get(){return dr(this)}}),this.parser=e,this.extension=[wr.of(this),oe.languageData.of(((t,e,i)=>{let n=hr(t,e,i),o=n.type.prop(lr);if(!o)return[];let s=t.facet(o),r=n.type.prop(ar);if(r){let o=n.resolve(e-n.from,i);for(let e of r)if(e.test(o,t)){let i=t.facet(e.facet);return"replace"==e.type?i:i.concat(s)}}return s}))].concat(i)}isActiveAt(t,e,i=-1){return hr(t,e,i).type.prop(lr)==this.data}findRegions(t){let e=t.facet(wr);if((null==e?void 0:e.data)==this.data)return[{from:0,to:t.doc.length}];if(!e||!e.allowsNesting)return[];let i=[],n=(t,e)=>{if(t.prop(lr)==this.data)return void i.push({from:e,to:e+t.length});let o=t.prop(r.mounted);if(o){if(o.tree.prop(lr)==this.data){if(o.overlay)for(let t of o.overlay)i.push({from:t.from+e,to:t.to+e});else i.push({from:e,to:e+t.length});return}if(o.overlay){let t=i.length;if(n(o.tree,o.overlay[0].from+e),i.length>t)return}}for(let i=0;i=this.cursorPos?this.doc.sliceString(t,e):this.string.slice(t-i,e-i)}}let pr=null;class mr{constructor(t,e,i=[],n,o,s,r,l){this.parser=t,this.state=e,this.fragments=i,this.tree=n,this.treeLen=o,this.viewport=s,this.skipped=r,this.scheduleOn=l,this.parse=null,this.tempSkipped=[]}static create(t,e,i){return new mr(t,e,[],p.empty,0,i,[],null)}startParse(){return this.parser.startParse(new ur(this.state.doc),this.fragments)}work(t,e){return null!=e&&e>=this.state.doc.length&&(e=void 0),this.tree!=p.empty&&this.isDone(null!=e?e:this.state.doc.length)?(this.takeTree(),!0):this.withContext((()=>{var i;if("number"==typeof t){let e=Date.now()+t;t=()=>Date.now()>e}for(this.parse||(this.parse=this.startParse()),null!=e&&(null==this.parse.stoppedAt||this.parse.stoppedAt>e)&&e=this.treeLen&&((null==this.parse.stoppedAt||this.parse.stoppedAt>t)&&this.parse.stopAt(t),this.withContext((()=>{for(;!(e=this.parse.advance()););})),this.treeLen=t,this.tree=e,this.fragments=this.withoutTempSkipped(O.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(t){let e=pr;pr=this;try{return t()}finally{pr=e}}withoutTempSkipped(t){for(let e;e=this.tempSkipped.pop();)t=gr(t,e.from,e.to);return t}changes(t,e){let{fragments:i,tree:n,treeLen:o,viewport:s,skipped:r}=this;if(this.takeTree(),!t.empty){let e=[];if(t.iterChangedRanges(((t,i,n,o)=>e.push({fromA:t,toA:i,fromB:n,toB:o}))),i=O.applyChanges(i,e),n=p.empty,o=0,s={from:t.mapPos(s.from,-1),to:t.mapPos(s.to,1)},this.skipped.length){r=[];for(let e of this.skipped){let i=t.mapPos(e.from,1),n=t.mapPos(e.to,-1);it.from&&(this.fragments=gr(this.fragments,i,n),this.skipped.splice(e--,1))}return!(this.skipped.length>=e)&&(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(t,e){this.skipped.push({from:t,to:e})}static getSkippingParser(t){return new class extends B{createParse(e,i,n){let o=n[0].from,s=n[n.length-1].to;return{parsedPos:o,advance(){let e=pr;if(e){for(let t of n)e.tempSkipped.push(t);t&&(e.scheduleOn=e.scheduleOn?Promise.all([e.scheduleOn,t]):t)}return this.parsedPos=s,new p(c.none,[],[],s-o)},stoppedAt:null,stopAt(){}}}}}isDone(t){t=Math.min(t,this.state.doc.length);let e=this.fragments;return this.treeLen>=t&&e.length&&0==e[0].from&&e[0].to>=t}static get(){return pr}}function gr(t,e,i){return O.applyChanges(t,[{fromA:e,toA:i,fromB:e,toB:i}])}class fr{constructor(t){this.context=t,this.tree=t.tree}apply(t){if(!t.docChanged&&this.tree==this.context.tree)return this;let e=this.context.changes(t.changes,t.state),i=this.context.treeLen==t.startState.doc.length?void 0:Math.max(t.changes.mapPos(this.context.treeLen),e.viewport.to);return e.work(20,i)||e.takeTree(),new fr(e)}static init(t){let e=Math.min(3e3,t.doc.length),i=mr.create(t.facet(wr).parser,t,{from:0,to:e});return i.work(20,e)||i.takeTree(),new fr(i)}}cr.state=kt.define({create:fr.init,update(t,e){for(let t of e.effects)if(t.is(cr.setState))return t.value;return e.startState.facet(wr)!=e.state.facet(wr)?fr.init(e.state):t.apply(e)}});let br=t=>{let e=setTimeout((()=>t()),500);return()=>clearTimeout(e)};"undefined"!=typeof requestIdleCallback&&(br=t=>{let e=-1,i=setTimeout((()=>{e=requestIdleCallback(t,{timeout:400})}),100);return()=>e<0?clearTimeout(i):cancelIdleCallback(e)});const vr="undefined"!=typeof navigator&&(null===(rr=navigator.scheduling)||void 0===rr?void 0:rr.isInputPending)?()=>navigator.scheduling.isInputPending():null,yr=In.fromClass(class{constructor(t){this.view=t,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(t){let e=this.view.state.field(cr.state).context;(e.updateViewport(t.view.viewport)||this.view.viewport.to>e.treeLen)&&this.scheduleWork(),(t.docChanged||t.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(e)}scheduleWork(){if(this.working)return;let{state:t}=this.view,e=t.field(cr.state);e.tree==e.context.tree&&e.context.isDone(t.doc.length)||(this.working=br(this.work))}work(t){this.working=null;let e=Date.now();if(this.chunkEndn+1e3,l=o.context.work((()=>vr&&vr()||Date.now()>s),n+(r?0:1e5));this.chunkBudget-=Date.now()-e,(l||this.chunkBudget<=0)&&(o.context.takeTree(),this.view.dispatch({effects:cr.setState.of(new fr(o.context))})),this.chunkBudget>0&&(!l||r)&&this.scheduleWork(),this.checkAsyncSchedule(o.context)}checkAsyncSchedule(t){t.scheduleOn&&(this.workScheduled++,t.scheduleOn.then((()=>this.scheduleWork())).catch((t=>En(this.view.state,t))).then((()=>this.workScheduled--)),t.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),wr=ft.define({combine:t=>t.length?t[0]:null,enables:t=>[cr.state,yr,Is.contentAttributes.compute([t],(e=>{let i=e.facet(t);return i&&i.name?{"data-language":i.name}:{}}))]});sr.meta,sr.link,sr.heading,sr.emphasis,sr.strong,sr.strikethrough,sr.keyword,sr.atom,sr.bool,sr.url,sr.contentSeparator,sr.labelName,sr.literal,sr.inserted,sr.string,sr.deleted,sr.regexp,sr.escape,sr.string,sr.variableName,sr.variableName,sr.typeName,sr.namespace,sr.className,sr.variableName,sr.macroName,sr.propertyName,sr.comment,sr.invalid;const Cr=Object.create(null),xr=[c.none],kr=[],Sr=Object.create(null),Tr=Object.create(null);for(let[t,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"]])Tr[t]=Mr(Cr,e);function Er(t,e){kr.indexOf(t)>-1||(kr.push(t),console.warn(e))}function Mr(t,e){let i=[];for(let n of e.split(" ")){let e=[];for(let i of n.split(".")){let n=t[i]||sr[i];n?"function"==typeof n?e.length?e=e.map(n):Er(i,`Modifier ${i} used at start of tag`):e.length?Er(i,`Tag ${i} used as modifier`):e=Array.isArray(n)?n:[n]:Er(i,`Unknown highlighting tag ${i}`)}for(let t of e)i.push(t)}if(!i.length)return 0;let n=e.replace(/ /g,"_"),o=n+" "+i.map((t=>t.id)),s=Sr[o];if(s)return s.id;let r=Sr[o]=c.define({id:xr.length,name:n,props:[Vs({[n]:i})]});return xr.push(r),r.id}function Ar(t){let e=Date.now().toString(36);return e+=Math.random().toString(36).substr(3,t),e}function Dr(t,e,i,n){let o,s={index:-1,subindex:-1},r=n;return i?r.forEach(((t,i)=>{if("SubmenuCommands"in t&&(o=t.SubmenuCommands.findIndex((t=>t.id==e.id)),o>=0))return s={index:i,subindex:o},s})):(o=r.findIndex((t=>t.id==e.id)),s={index:o,subindex:-1}),s}function Ir(t,e){let i,n=e.getLine(e.getCursor().line),o="";const s=/^(\>*(\[[!\w]+\])?\s*)#+\s/;let r;const l=n.match(s);l&&(r=l[0].trim()),t==r||""==t?i=n.replace(s,"$1"):(i=n.replace(/^\s*(#*|\>|\-|\d+\.)\s*/m,""),i=t+" "+i),o=""!=i?e.getRange(e.getCursor(),{line:e.getCursor().line,ch:n.length}):e.getRange(e.getCursor(),{line:e.getCursor().line,ch:0}),e.setLine(e.getCursor().line,i),e.setCursor({line:e.getCursor().line,ch:Number(i.length-o.length)})}function Or(t,e){if(!e)return;const i=e.getSelection();if(!i||""===i.trim())return void this.plugin.setLastExecutedCommand("editing-toolbar:change-font-color");const n=/]+["']?>(.*?)<\/font>/gms,o=n.test(i);if(s=i,new RegExp(`^(.+)<\\/font>$`,"ms").test(s.trim()))return;var s;const r=i.replace(n,((e,i)=>i.split("\n").map((e=>e.trim()?`${e}`:e)).join("\n"))),l=r===i?i.split("\n").map((e=>e.trim()?`${e}`:e)).join("\n"):r,a=e.listSelections().map((e=>{const i=o?0:``.length;return e.anchor.line([\s\S]*?)<\/span>/g.test(i);if(((t,e)=>{const i=e.replace(/([()[{*+.$^\\|?])/g,"\\$1");return new RegExp(`^([sS]+)<\\/span>$`).test(t.trim())})(i,t))return;let o;o=n?i.replace(/(background:)(?:#[0-9a-fA-F]{3,6}|rgba?\([^)]+\))/gi,`$1${t}`):i.split("\n").map((e=>e.trim()?`${e}`:e)).join("\n");const s=e.listSelections().map((e=>{const i=n?0:``.length;return e.anchor.line=0?t.getLine(s).trim():"";if(s<0||!/^\s*\d+\.\s/.test(r)||((null===(i=r.match(/^\s*/))||void 0===i?void 0:i[0].length)||0)0;){const e=t.getLine(i-1);if(!/^\s*\d+\.\s/.test(e.trim()))break;i--}for(;n{"OrderedList"===t.name&&(d=t.to)}}),d>=0){const t=n.offsetToPos(d).line+1;t=0?n.getLine(f).trim():"";if(b&&!/^\s*$/.test(b)&&!b.includes("ㅤ")&&(g.push(""),g.push("ㅤ")),u)g.push(...e);else{let t={},i=-1;for(const n of e){const e=n.trim(),o=/^\d+\.\s/.test(e),s=(null===(r=n.match(/^\s*/))||void 0===r?void 0:r[0])||"";if(o){const n=s.length;t[n]=n!==i?1:(t[n]||1)+1,g.push(`${s}${t[n]}. ${e.replace(/^\d+\.\s/,"")}`),i=n}else g.push(n),i=-1}}n.replaceRange(g.join("\n"),{line:i,ch:0},{line:i+e.length-1,ch:n.getLine(i+e.length-1).length})}function Lr(t,e,i){const n=[];for(let o=e;o<=i;o++)n.push(t.getLine(o));Nr(n,e,t)}let Rr;Ui.RTL,Ui.LTR;const Pr=e=>{Rr=t.requireApiVersion("0.15.0")?activeWindow.document:window.document;let i=Rr.getElementById("editingToolbarModalBar");i&&(i.style.visibility=0==e?"hidden":"visible")},_r=e=>{Rr=t.requireApiVersion("0.15.0")?activeWindow.document:window.document,Rr.documentElement.style.setProperty("--toolbar-vertical-offset",`${e.verticalPosition}px`)},Fr=e=>{Rr=t.requireApiVersion("0.15.0")?activeWindow.document:window.document,Rr.documentElement.style.setProperty("--toolbar-horizontal-offset",`${e.horizontalPosition}px`)};var Vr={"Editing Toolbar append method":"Editing Toolbar append method","Choose where Editing Toolbar will append upon regeneration. To see the change, hit the refresh button below, or in the status bar menu.":"Choose where Editing Toolbar will append upon regeneration. To see the change, hit the refresh button below, or in the status bar menu.","Editing Toolbar aesthetic":"Editing Toolbar aesthetic","Choose between a glass morphism ,tiny and default style for Editing Toolbar. To see the change, hit the refresh button below, or in the status bar menu.":"Choose between a glass morphism ,tiny and default style for Editing Toolbar. To see the change, hit the refresh button below, or in the status bar menu.","Editing Toolbar position":"Editing Toolbar position","Choose between fixed position or cursor following mode.":"Choose between fixed position , cursor following or Top mode .","Editing Toolbar columns":"Editing Toolbar columns","Choose the number of columns per row to display on Editing Toolbar.":"Choose the number of columns per row to display on Editing Toolbar.","Editing Toolbar refresh":"Editing Toolbar refresh","Editing Toolbar commands":"Editing Toolbar commands","Add a command onto Editing Toolbar from Obsidian's commands library. To reorder the commands, drag and drop the command items. To delete them, use the delete buttom to the right of the command item. Editing Toolbar will not automaticaly refresh after reordering commands. Use the refresh button above.":"Add a command onto Editing Toolbar from Obsidian's commands library. To reorder the commands, drag and drop the command items. To delete them, use the delete buttom to the right of the command item. Editing Toolbar will not automaticaly refresh after reordering commands. Use the refresh button above.","Format Brush Off!":"Format Brush Off!","Hide & Show":"Hide & Show","Editing Toolbar will only refresh automatically after you have either added or deleted a command from it. To see UI changes to editingToolbar (above settings changes) use the refresh button. If you forget to refresh in settings, no worries. There is also a refresh button in the editingToolbar status bar menu.":"Editing Toolbar will only refresh automatically after you have either added or deleted a command from it. To see UI changes to editingToolbar (above settings changes) use the refresh button. If you forget to refresh in settings, no worries. There is also a refresh button in the editingToolbar status bar menu.","Font-Color formatting brush ON!":"Font-Color formatting brush ON!",More:"More","Font Colors":"Font Colors","Format Brush":"Format Brush","Background color":"Background color",Refresh:"Refresh",Add:"Add",Delete:"Delete","Change Command name":"Change Command name","Add submenu":"Add submenu","add hr":"add hr","Enter the icon code, it looks like .... format":"Enter the icon code, it looks like .... format","Please enter a new name:":"Please enter a new name:","Drag the slider to move the position":"Drag the slider to move the position","Plugin Settings":"Plugin Settings","Background-color formatting brush ON!":"Background-color formatting brush ON!\nClick the mouse middle or right key to close the formatting-brush","Clear formatting brush ON!":"Clear formatting brush ON!","Clear formatting brush ON!\nClick the mouse middle or right key to close the formatting-brush":"Clear formatting brush ON!\nClick the mouse middle or right key to close the formatting-brush","The toolbar is displayed when the mouse moves over it, otherwise it is automatically hidden":"The toolbar is displayed when the mouse moves over it, otherwise it is automatically hidden","Editing Toolbar Auto-hide":"Editing Toolbar Auto-hide","Editing Toolbar Centred Display":"Editing Toolbar Centred Display","Whether the toolbar is centred or full-width, the default is full-width.":"Whether the toolbar is centred or full-width, the default is full-width.","Custom Backgroud Color":"Custom Backgroud Color","Custom Font Color":"Custom Font Color","🎨 Set custom background":"🎨 Set custom background","🖌️ Set custom font color":"🖌️ Set custom font color","Click on the picker to adjust the colour":"Click on the picker to adjust the colour","Mobile enabled or not":"Mobile enabled or not","Whether to enable the plugin for the mobile client, the default is enabled.":"Whether to enable the plugin for the mobile client, the default is enabled.","Whether to enable on mobile devices with device width less than 768px, the default is disable.":"Whether to enable on mobile devices with device width less than 768px, the default is disable.",Reset:"Reset",Fix:"Fix","Fix Editing Toolbar":"Fix Editing Toolbar",General:"General",Appearance:"Appearance",Commands:"Commands","Choose between fixed position or cursor following mode":"Choose between fixed position , cursor following or Top mode .","Add and manage commands":"Add and manage commands","Choose where Editing Toolbar will append upon regeneration.":"Choose where Editing Toolbar will append upon regeneration.","Whether to enable on mobile devices with device width less than 768px":"Whether to enable on mobile devices with device width less than 768px","Choose between a glass morphism, tiny and default style":"Choose between a glass morphism, tiny and default style","Refresh Toolbar":"Refresh Toolbar","Add Command":"Add Command",Settings:"Settings","Position Style":"Position Style",Columns:"Columns","Drag to Adjust Position":"Drag to Adjust Position","Vertical Position":"Vertical Position","Horizontal Position":"Horizontal Position","Toolbar Position":"Toolbar Position","Choose an icon":"Choose an icon","Search for an icon...":"Search for an icon...",All:"All",Obsidian:"Obsidian",Glyph:"Glyph",Custom:"Custom","Choose a command":"Choose a command","The command":"The command","already exists":"already exists","Enter the icon code, format as .... ":"Enter the icon code, format as .... ","No matching icons found":"No matching icons found","Custom Commands":"Custom Commands","Toolbar Commands":"Toolbar Commands",ID:"ID",Prefix:"Prefix",Suffix:"Suffix",Pattern:"Pattern","Custom Format Commands":"Custom Format Commands","Add, edit or delete custom format commands":"Add, edit or delete custom format commands",Edit:"Edit","Command ID":"Command ID",'Unique identifier, no spaces, e.g.: "my-custom-format"':'Unique identifier, no spaces, e.g.: "my-custom-format"',"Displayed name in toolbar and menu":"Displayed name in toolbar and menu","Add content before selected text":"Add content before selected text","Add content after selected text":"Add content after selected text","Character offset of cursor after formatting":"Character offset of cursor after formatting","Line offset of cursor after formatting":"Line offset of cursor after formatting","Whether to insert at the beginning of the next line":"Whether to insert at the beginning of the next line","Command icon (click to select)":"Command icon (click to select)","Choose Icon":"Choose Icon",Save:"Save",Cancel:"Cancel","Edit Custom Command":"Edit Custom Command","Add Custom Command":"Add Custom Command","Command ID and command name cannot be empty":"Command ID and command name cannot be empty","Command ID cannot contain spaces":"Command ID cannot contain spaces",'Command ID "${this.commandId}" already exists':'Command ID "${this.commandId}" already exists',"Cursor Position Offset":"Cursor Position Offset","Line Offset":"Line Offset","Line Head Format":"Line Head Format",Icon:"Icon","Command Name":"Command Name","Are you sure you want to restore all settings to default? This will lose all your custom configurations.":"Are you sure you want to restore all settings to default? This will lose all your custom configurations.","Restore default":"Restore default","Restore default settings":"Restore default settings","🔄Restore default settings":"🔄Restore default settings","🔧Data repair":"🔧Data repair","Command IDs have been successfully repaired!":"Command IDs have been successfully repaired!","No command IDs need to be repaired":"No command IDs need to be repaired","Error repairing command IDs, please check the console for details":"Error repairing command IDs, please check the console for details","Error restoring default settings, please check the console for details":"Error restoring default settings, please check the console for details","Successfully restored default settings!":"Successfully restored default settings!",Close:"Close",Tips:"Tips","This update changed the ID of some commands, please click this button to repair the commands to ensure the toolbar works properly":"This update changed the ID of some commands, please click this button to repair the commands to ensure the toolbar works properly","Repair command ID":"Repair command ID","This will reset all your custom configurations":"This will reset all your custom configurations","Notice:":"Notice:","This update rebuilds the entire code, reducing resource consumption":"This update rebuilds the entire code, reducing resource consumption","Optimized mobile usage, added canvas support, and added custom commands":"Optimized mobile usage, added canvas support, and added custom commands","⚠️This update is not compatible with 2.x version command ids, please click [Repair command] to be compatible":"⚠️This update is not compatible with 2.x version command ids, please click [Repair command] to be compatible","⚠️If you want to restore the default settings, please click [Restore default settings]":"⚠️If you want to restore the default settings, please click [Restore default settings]","Please execute a editingToolbar format command first, then enable the format brush":"Please execute a editingToolbar format command first, then enable the format brush","Format brush ON! Select text to apply【":"Format brush ON! Select text to apply【","】format":"】format\nClick the mouse middle or right key to close the formatting-brush","Add to Toolbar":"Add to Toolbar","This command is already in the toolbar":"This command is already in the toolbar","Command added to toolbar":"Command added to toolbar","Add this command to the toolbar":"Add this command to the toolbar","Callout Type":"Callout Type",Title:"Title","Optional, leave blank for default title":"Optional, leave blank for default title","Input title":"Input title","Collapse State":"Collapse State",Open:"Open",Closed:"Closed",Content:"Content",Insert:"Insert",Default:"Default","Input content":"Input content","Link Text":"Link Text","Link Alias":"Link Alias","Link URL":"Link URL","Embed Content":"Embed Content","Image Size":"Image Size","Insert New Line":"Insert New Line","Paste and Parse":"Paste and Parse","URL Format Error":"URL Format Error","Image Width":"Image Width","Image Height":"Image Height","If it is an image, turn on":"If it is an image, turn on","Insert a link on the next line":"Insert a link on the next line","Link Title(optional)":"Link Title(optional)",Alias:"Alias",Optional:"Optional","Default 0, format will keep the text selected":"Default 0, format will keep the text selected","to insert":"to insert","Latest Changes":"Latest Changes","📋View full changelog":"📋View full changelog","Open changelog":"Open changelog","Loading changelog...":"Loading changelog...","Open the complete changelog in your browser":"Open the complete changelog in your browser","Enable multiple configurations":"Enable multiple configurations","Enable different command configurations for each position style (following, top, fixed)":"Enable different command configurations for each position style (following, top, fixed)","Currently editing commands for":"Currently editing commands for","position style":"position style","Current Configuration":"Current Configuration","Switch between different command configurations":"Switch between different command configurations","Following Style":"Following Style","Top Style":"Top Style","Fixed Style":"Fixed Style","Mobile Style":"Mobile Style",configuration:"configuration","Deploy command to configurations":"Deploy command to configurations","All Configurations":"All Configurations",Deploy:"Deploy","Command deployed to selected configurations":"Command deployed to selected configurations","No configuration selected for deployment":"No configuration selected for deployment","Command already exists in selected configurations":"Command already exists in selected configurations","Command deployed to: ":"Command deployed to: ","Command deleted":"Command deleted","Confirm delete?":"Confirm delete?",Confirm:"Confirm","Are you sure you want to restore all settings to default? But custom commands will be preserved.":"Are you sure you want to restore all settings to default? But custom commands will be preserved.","Successfully restored default settings! (Custom commands preserved)":"Successfully restored default settings! (Custom commands preserved)","This will reset all your custom configurations, but custom commands will be preserved":"This will reset all your custom configurations, but custom commands will be preserved","Import/Export":"Import/Export","Export Configuration":"Export Configuration","Export your toolbar configuration to share with others":"Export your toolbar configuration to share with others",Export:"Export","Import Configuration":"Import Configuration","Import toolbar configuration from JSON":"Import toolbar configuration from JSON",Import:"Import","Usage Instructions":"Usage Instructions","Export: Generate a JSON configuration that you can save or share":"Export: Generate a JSON configuration that you can save or share","Import: Paste a previously exported JSON configuration":"Import: Paste a previously exported JSON configuration","You can choose to export all settings, only toolbar commands, or only custom commands":"You can choose to export all settings, only toolbar commands, or only custom commands","When importing, the plugin will only update the settings included in the import data":"When importing, the plugin will only update the settings included in the import data","Warning: Importing configuration will overwrite your current settings. Consider exporting your current configuration first as a backup.":"Warning: Importing configuration will overwrite your current settings. Consider exporting your current configuration first as a backup.","Export Type":"Export Type","Choose what to export":"Choose what to export","All Settings":"All Settings","Toolbar Commands Only":"Toolbar Commands Only","Custom Commands Only":"Custom Commands Only","Export Content":"Export Content","Copy this content to share with others":"Copy this content to share with others","Loading...":"Loading...","Copy to Clipboard":"Copy to Clipboard","Configuration copied to clipboard":"Configuration copied to clipboard","Failed to copy configuration":"Failed to copy configuration","Paste the configuration JSON here":"Paste the configuration JSON here","Paste configuration here...":"Paste configuration here...","Invalid import data":"Invalid import data","Configuration imported successfully":"Configuration imported successfully","No valid configuration found in import data":"No valid configuration found in import data","Failed to import configuration. Invalid format.":"Failed to import configuration. Invalid format.","Import Mode":"Import Mode","Choose how to import the configuration":"Choose how to import the configuration","Update Mode (Add new items and update existing ones)":"Update Mode (Add new items and update existing ones)","Overwrite Mode (Replace all settings with imported ones)":"Overwrite Mode (Replace all settings with imported ones)","Configuration imported successfully (Overwrite mode)":"Configuration imported successfully (Overwrite mode)","Configuration imported successfully (Update mode)":"Configuration imported successfully (Update mode)","Warning: Overwrite mode will completely replace your current settings with the imported ones. Consider exporting your current configuration first as a backup.":"Warning: Overwrite mode will completely replace your current settings with the imported ones. Consider exporting your current configuration first as a backup.","Warning: Update mode will add new items and update existing ones based on the imported configuration.":"Warning: Update mode will add new items and update existing ones based on the imported configuration.","Add Format Command":"Add Format Command",Regex:"Regex","Prefix/Suffix":"Prefix/Suffix","Insert Special Char":"Insert Special Char","Add Regex Command":"Add Regex Command","Switch Regex Command Window":"Switch Regex Command Window","Please select text first":"Please select text first","The selected text does not meet the condition requirements":"The selected text does not meet the condition requirements","Regex command execution error:":"Regex command execution error:","Copy code":"Copy code","Copied!":"Copied!","Explain the syntax of JavaScript regular expressions":"Explain the syntax of JavaScript regular expressions","Apply regular expression replacement":"Apply regular expression replacement","Conditional matching":"Conditional matching","Complete regular expression code (copy to AI for explanation)":"Complete regular expression code (copy to AI for explanation)","Error:":"Error:","Regex pattern cannot be empty":"Regex pattern cannot be empty","Command already exists":"Command already exists","Choose icon":"Choose icon","URL to Markdown link":"URL to Markdown link","Convert MM/DD/YYYY to YYYY-MM-DD":"Convert MM/DD/YYYY to YYYY-MM-DD","Add bold to keywords":"Add bold to keywords","Format phone number":"Format phone number","Remove extra spaces":"Remove extra spaces","Convert HTML bold tags to Markdown format":"Convert HTML bold tags to Markdown format","Convert quoted text to quote block":"Convert quoted text to quote block","Convert CSV to Markdown table row":"Convert CSV to Markdown table row","Add uniform alias to Markdown links":"Add uniform alias to Markdown links","Delete empty lines (multiline mode)":"Delete empty lines (multiline mode)","Add list symbol to each line (multiline mode)":"Add list symbol to each line (multiline mode)","If the text contains important, set the text highlight (conditional format)":"If the text contains important, set the text highlight (conditional format)","Matching pattern":"Matching pattern","Regex pattern to match":"Regex pattern to match","Replacement pattern (use $1, $2, etc. to reference capture groups)":"Replacement pattern (use $1, $2, etc. to reference capture groups)","Ignore case":"Ignore case","Global replace":"Global replace","Multiline mode":"Multiline mode","Use condition":"Use condition","Condition pattern":"Condition pattern","Only apply custom command when text matches the condition":"Only apply custom command when text matches the condition","Must exist regular expression or text":"Must exist regular expression or text","Replacement pattern":"Replacement pattern","Match case-insensitive":"Match case-insensitive","^ and $ match the start and end of each line":"^ and $ match the start and end of each line","Replace all matches":"Replace all matches",Command:"Command","Error: ":"Error:","Input example text to view the formatting effect of the command...":"Input example text to view the formatting effect of the command...",Description:"Description","[Example]":"[Example]","[Requirements]":"[Requirements]","[Output]":"[Output]","AI question template:":"AI question template:","I need to convert the url to a markdown format link":"I need to convert the url to a markdown format link","For example, convert https://example.com to [https://example.com](https://example.com)":"For example, convert https://example.com to [https://example.com](https://example.com)","Use js regular expression to implement, and output the parameters in the following format (the result does not need to be escaped with json)":"Use js regular expression to implement, and output the parameters in the following format (the result does not need to be escaped with json)","[Description]":"[Description]","How to use AI to get regular expressions?":"How to use AI to get regular expressions?","Regular expression examples":"Regular expression examples","Edit regular expression command":"Edit regular expression command","Add regular expression command":"Add regular expression command","Result:":"Result:","Example text:":"Example text:",Preview:"Preview",Result:"Result","Please select text or copy text to clipboard first":"Please select text or copy text to clipboard first","Overwrite Import":"Overwrite Import","Update Import":"Update Import","Importing configuration...":"Importing configuration...","Following Style Only":"Following Style Only","Top Style Only":"Top Style Only","Fixed Style Only":"Fixed Style Only","Mobile Style Only":"Mobile Style Only","Unknown import type":"Unknown import type","All Toolbar Commands":"All Toolbar Commands","Initialize Commands":"Initialize Commands","Copy commands from the main menu configuration":"Copy commands from the main menu configuration","Initialize commands to default settings":"Initialize commands to default settings","Reset Commands":"Reset Commands","Commands reset successfully":"Commands reset successfully","Following style commands initialized from current menu commands":"Following style commands initialized from current menu commands","Commands initialized successfully":"Commands initialized successfully","Reset to Menu Commands":"Reset to Menu Commands","Are you sure you want to reset the current configuration?":"Are you sure you want to reset the current configuration?","Following style commands successfully initialized":"Following style commands successfully initialized","Top style commands successfully initialized":"Top style commands successfully initialized","Fixed style commands successfully initialized":"Fixed style commands successfully initialized","Mobile style commands successfully initialized":"Mobile style commands successfully initialized","Reset commands to default settings":"Reset commands to default settings",Clear:"Clear","Remove all commands from this configuration":"Remove all commands from this configuration","Are you sure you want to clear all commands under the current style?":"Are you sure you want to clear all commands under the current style?","Current style commands have been cleared":"Current style commands have been cleared","Manage Commands":"Manage Commands","Reset or clear all commands in this configuration":"Reset or clear all commands in this configuration","One-click clear":"One-click clear","Import Commands from Other Styles":"Import Commands from Other Styles","Copy commands from another style configuration":"Copy commands from another style configuration","Main menu only":"Main menu only","This import will update:":"This import will update:","Custom commands":"Custom commands","Toolbar commands":"Toolbar commands","General settings":"General settings","Please paste configuration data first":"Please paste configuration data first","Invalid import data format":"Invalid import data format","Import From":"Import From","This import will:":"This import will:","Update general settings":"Update general settings","Update Main Menu Commands":"Update Main Menu Commands","Update Custom Commands":"Update Custom Commands","Update Following Style Commands":"Update Following Style Commands","Update Top Style Commands":"Update Top Style Commands","Update Fixed Style Commands":"Update Fixed Style Commands","Update Mobile Style Commands":"Update Mobile Style Commands","Clear all Main Menu Commands":"Clear all Main Menu Commands","Clear all Custom Commands":"Clear all Custom Commands","Clear all Following Style Commands":"Clear all Following Style Commands","Clear all Top Style Commands":"Clear all Top Style Commands","Clear all Fixed Style Commands":"Clear all Fixed Style Commands","Clear all Mobile Style Commands":"Clear all Mobile Style Commands","Overwrite Mode (Replace settings with imported ones)":"Overwrite Mode (Replace settings with imported ones)","Warning: Overwrite mode will replace existing settings with imported ones.":"Warning: Overwrite mode will replace existing settings with imported ones.","Warning: Update mode will add new items and update existing ones.":"Warning: Update mode will add new items and update existing ones.","Enable Multiple Config":"Enable Multiple Config","Set Multiple Config to:":"Set Multiple Config to:",Enable:"Enable",Disable:"Disable","Set Position Style to:":"Set Position Style to:",Following:"Following",Top:"Top",Fixed:"Fixed",Mobile:"Mobile","All commands":"All commands","⚠️ Overwrite mode will replace existing settings with imported ones.":"⚠️ Overwrite mode will replace existing settings with imported ones.","ℹ️ Update mode will merge imported settings with existing ones.":"ℹ️ Update mode will merge imported settings with existing ones.","Do you want to continue?":"Do you want to continue?","Imported settings:":"Imported settings:","Imported commands:":"Imported commands:","Disable toolbar for this view":"Disable toolbar for this view","Enable toolbar for this view":"Enable toolbar for this view","Manage all view types":"Manage all view types","Current View: ":"Current View: ","Appearance Style":"Appearance Style","Position Settings":"Position Settings","All commands have been removed":"All commands have been removed","Join the Community":"Join the Community","Share your toolbar settings and styles in our":"Share your toolbar settings and styles in our","Get inspired by what others have created or showcase your own customizations.":"Get inspired by what others have created or showcase your own customizations.","Toolbar preview":"Toolbar preview (for example only)","Toolbar theme":"Toolbar theme","Select a preset toolbar theme, automatically setting the background color, icon color, and size":"Select a preset toolbar theme, automatically setting the background color, icon color, and size","Toolbar background color":"Toolbar background color","Set the background color of the toolbar":"Set the background color of the toolbar","Toolbar icon color":"Toolbar icon color","Set the color of the toolbar icon":"Set the color of the toolbar icon","Toolbar icon size":"Toolbar icon size","Set the size of the toolbar icon (px) default 18px":"Set the size of the toolbar icon (px) default 18px","Custom theme":"Custom theme","Fixed position offset":"Fixed position offset","Choose the offset of the Editing Toolbar in the fixed position.":"Choose the offset of the Editing Toolbar in the fixed position.","Renumber List":"Renumber List","Fetch Remote Title":"Fetch Remote Title","Please enter a URL first":"Please enter a URL first","Failed to fetch title for":"Failed to fetch title for","Link Title (optional)":"Link Title (optional)","Unable to detect editor width":"Unable to detect editor width","Fit Editor Width":"Fit Editor Width","Please execute a format command or select format text first, then enable the format brush":"Please execute a format command or select format text first, then enable the format brush"},Hr={"Editing Toolbar append method":"工具栏的附加方法。","Choose where Editing Toolbar will append upon regeneration. To see the change, hit the refresh button below, or in the status bar menu.":"工具栏在Obsidian中的追加的位置,只对固定和跟随模式有效。如果你遇到工具栏显示问题,可以选择body试试。请点击下面或者状态栏菜单中的刷新按钮生效。","Editing Toolbar aesthetic":"工具栏样式","Choose between a glass morphism ,tiny and default style for Editing Toolbar. To see the change, hit the refresh button below, or in the status bar menu.":"样式有毛玻璃,简约和默认风格选择。请点击下面或者状态栏菜单中的刷新按钮生效。","Editing Toolbar position":"工具栏位置","Choose between fixed position or cursor following mode.":"在固定位置,光标跟随模式或者置顶模式之间进行选择。","Editing Toolbar columns":"工具栏栏目数","Choose the number of columns per row to display on Editing Toolbar.":"选择在Editing Toolbar上显示的每行的列数。","Editing Toolbar refresh":"刷新工具栏","Editing Toolbar commands":"在工具栏中添加命令","Add a command onto Editing Toolbar from Obsidian's commands library. To reorder the commands, drag and drop the command items. To delete them, use the delete buttom to the right of the command item. Editing Toolbar will not automaticaly refresh after reordering commands. Use the refresh button above.":"从Obsidian的命令库中添加一个命令到工具栏。要重新排列命令,可以拖放命令项。要删除它们,请使用命令项右边的删除按钮。图标选择Custom可以自定义图标","Format Brush Off!":"关闭格式刷!","Hide & Show":"隐藏 & 显示","Editing Toolbar will only refresh automatically after you have either added or deleted a command from it. To see UI changes to editingToolbar (above settings changes) use the refresh button. If you forget to refresh in settings, no worries. There is also a refresh button in the editingToolbar status bar menu.":"对外观的更改生效需要使用刷新按钮。如果你忘记在设置中刷新,在状态栏菜单中也有一个刷新按钮。","Font-Color formatting brush ON!":"字体颜色格式刷开启\n点击鼠标中键或者右键关闭格式刷",More:"更多","Font Colors":"字体颜色","Format Brush":"格式刷","Background color":"背景颜色",Refresh:"刷新",Add:"添加",Delete:"删除","Change Command name":"更改命令名称","Add submenu":"添加子菜单","add hr":"添加分割线","Enter the icon code, it looks like .... format":"输入图标代码,类似.... 格式","Please enter a new name:":"请输入新名称:","Drag the slider to move the position":"拖动滑块来移动位置","Plugin Settings":"插件设置","Background-color formatting brush ON!":"开启背景色格式刷","Clear formatting brush ON!":"清除格式刷已开启","Clear formatting brush ON!\nClick the mouse middle or right key to close the formatting-brush":"清除格式刷已开启\n点击鼠标中键或者右键关闭格式刷","The toolbar is displayed when the mouse moves over it, otherwise it is automatically hidden":"当鼠标移到工具栏上方时,工具栏显示,否则自动隐藏","Editing Toolbar Auto-hide":"工具栏是否自动隐藏","Editing Toolbar Centred Display":"工具栏是否居中显示","Whether the toolbar is centred or full-width, the default is full-width.":"工具栏居中还是全宽显示,默认全宽显示","Custom Backgroud Color":"设置自定义背景色","Custom Font Color":"设置自定义字体颜色","🎨 Set custom background":"🎨 设置自定义背景","🖌️ Set custom font color":"🖌️ 设置自定义字体颜色","Click on the picker to adjust the colour":"点击选取器来调整颜色","Mobile enabled or not":"是否在移动端启用","Whether to enable on mobile devices with device width less than 768px, the default is disable.":"是否在设备宽度小于768的移动设备启用。默认不启用",Reset:"重置",Fix:"修复","Fix Editing Toolbar":"修复工具栏",General:"常规",Appearance:"外观",Commands:"命令","Choose between fixed position or cursor following mode":"选择固定位置或者光标跟随模式","Add and manage commands":"添加和管理命令","Choose where Editing Toolbar will append upon regeneration.":"选择工具栏在Obsidian中的追加的位置。","Whether to enable on mobile devices with device width less than 768px":"是否在移动设备中启用。默认不启用","Choose between a glass morphism, tiny and default style":"选择毛玻璃,简约和默认风格","Refresh Toolbar":"刷新工具栏","Add Command":"添加命令",Settings:"设置","Adjust Toolbar Position[Fixed mode]":"调整工具栏位置[固定模式]","Position Style":"位置样式",Columns:"列数","Drag to Adjust Position":"拖动调整位置","Vertical Position":"垂直位置","Horizontal Position":"水平位置","Toolbar Position":"工具栏位置","Choose an icon":"选择一个图标","Search for an icon...":"搜索图标...",All:"全部",Obsidian:"Obsidian",Glyph:"Glyph",Custom:"自定义","Choose a command":"选择一个命令","The command":"命令","already exists":"已存在","Enter the icon code, format as .... ":"输入图标代码,格式为 .... ","No matching icons found":"没有找到匹配的图标","Custom Commands":"自定义命令","Toolbar Commands":"工具栏命令",ID:"ID",Prefix:"前缀",Suffix:"后缀","Custom Format Commands":"自定义格式命令","Add, edit or delete custom format commands":"添加、编辑或删除自定义格式命令",Edit:"编辑","Command ID":"命令ID",'Unique identifier, no spaces, e.g.: "my-custom-format"':'唯一标识符,不包含空格,例如:"my-custom-format"',"Displayed name in toolbar and menu":"在工具栏和菜单中显示的名称","Add content before selected text":"在选中的文本前添加内容","Add content after selected text":"在选中的文本后添加内容","Character offset of cursor after formatting":"格式化后光标的字符偏移量","Line offset of cursor after formatting":"格式化后光标的行偏移量","Whether to insert at the beginning of the next line":"是否在下一行首插入","Command icon (click to select)":"命令图标(点击选择)","Choose Icon":"选择图标",Save:"保存",Cancel:"取消","Edit Custom Command":"编辑自定义命令","Add Custom Command":"添加自定义命令","Command ID and command name cannot be empty":"命令ID和命令名称不能为空","Command ID cannot contain spaces":"命令ID不能包含空格",'Command ID "${this.commandId}" already exists':'命令ID "${this.commandId}" 已存在',"Command Name":"命令名称","Cursor Position Offset":"光标位置偏移量","Line Offset":"行偏移量","Line Head Format":"行首格式",Icon:"图标","Are you sure you want to restore all settings to default? This will lose all your custom configurations.":"确定要恢复所有设置为默认值吗?这将丢失您的所有自定义配置。","Restore default":"恢复默认值","Restore default settings":"恢复默认设置","🔄Restore default settings":"🔄恢复默认设置","🔧Data repair":"🔧数据修复","Command IDs have been successfully repaired!":"命令ID已成功修复!","No command IDs need to be repaired":"没有命令ID需要修复","Error repairing command IDs, please check the console for details":"修复命令ID时出错,请查看控制台了解详情","Error restoring default settings, please check the console for details":"恢复默认设置时出错,请查看控制台了解详情","Successfully restored default settings!":"已成功恢复默认设置!",Close:"关闭",Tips:"提示","This update changed the ID of some commands, please click this button to repair the commands to ensure the toolbar works properly":"此次更新更改了部分命令的ID,请点击此按钮修复命令以确保工具栏正常工作","Repair command ID":"修复命令ID","This will reset all your custom configurations":"这将重置您的所有自定义配置","Notice:":"注意","This update rebuilds the entire code, reducing resource consumption":"此次更新重构了全部代码,降低了资源占用","Optimized mobile usage, added canvas support, and added custom commands":"优化了移动端,增加了对canvas支持,增加了自定义命令","⚠️This update is not compatible with 2.x version command ids, please click [Repair command] to be compatible":"⚠️此次更新不兼容2.x旧版本命令id,请点击【修复命令】进行兼容","⚠️If you want to restore the default settings, please click [Restore default settings]":"⚠️如果想恢复默认设置,请点击【恢复默认设置】","Please execute a editingToolbar format command first, then enable the format brush":"请先执行一个格式命令,然后再启用格式刷","Format brush ON! Select text to apply【":"格式刷已开启\n选中文本应用【","】format":"】格式\n点击鼠标中键或者右键关闭格式刷","Add to Toolbar":"添加到工具栏","This command is already in the toolbar":"该命令已存在于工具栏中","Command added to toolbar":"命令已添加到工具栏","Add this command to the toolbar":"添加该命令到工具栏","Callout Type":"Callout 类型",Title:"标题","Optional, leave blank for default title":"可选,留空则使用默认标题","Input title":"输入标题","Collapse State":"折叠状态",Open:"展开",Closed:"折叠",Content:"内容",Insert:"插入",Default:"默认","Input content":"输入内容","Link Text":"链接文本","Link Alias":"链接别名","Link URL":"链接地址","Embed Content":"嵌入内容","Image Size":"图片尺寸","Insert New Line":"插入新行","Paste and Parse":"粘贴并解析","URL Format Error":"URL格式错误","Image Width":"图片宽度","Image Height":"图片高度","Insert a link on the next line":"在下一行插入链接","If it is an image, turn on":"如果是图片,请开启","Link Title(optional)":"链接标题(可选)",Alias:"别名",Optional:"可选","Default 0, format will keep the text selected":"默认0,格式化将保持文本选中","to insert":"插入","Latest Changes":"最新更新","📋View full changelog":"📋查看完整更新日志","Open changelog":"打开更新日志","Loading changelog...":"加载更新日志...","Open the complete changelog in your browser":"在浏览器中打开完整更新日志","Enable multiple configurations":"启用多配置","Enable different command configurations for each position style (following, top, fixed)":"启用每个位置样式的不同命令配置(following,top,fixed)","Currently editing commands for":"当前编辑的命令配置为:","position style":"样式","Current Configuration":"当前配置","Switch between different command configurations":"切换不同的命令配置","Following Style":"跟随样式","Top Style":"顶部样式","Fixed Style":"固定样式","Mobile Style":"移动端样式",configuration:"配置","Deploy command to configurations":"部署命令到配置","All Configurations":"所有配置",Deploy:"部署","Command deployed to selected configurations":"命令已部署到选中的配置","No configuration selected for deployment":"没有选中的配置","Command already exists in selected configurations":"命令已存在于选中的配置","Command deployed to: ":"命令已部署到:","Command deleted":"命令已删除","Confirm delete?":"确认删除?","Are you sure you want to restore all settings to default? But custom commands will be preserved.":"您确定要将所有设置恢复为默认值吗?但自定义命令将被保留。","Successfully restored default settings! (Custom commands preserved)":"成功恢复默认设置!(自定义命令已保留)","This will reset all your custom configurations, but custom commands will be preserved":"这将重置您的所有自定义配置,但自定义命令将被保留","Import/Export":"导入/导出","Export Configuration":"导出配置","Export your toolbar configuration to share with others":"导出您的工具栏配置以与他人共享",Export:"导出","Import Configuration":"导入配置","Import toolbar configuration from JSON":"从JSON导入工具栏配置",Import:"导入","Usage Instructions":"使用说明","Export: Generate a JSON configuration that you can save or share":"导出:生成可保存或共享的JSON配置","Import: Paste a previously exported JSON configuration":"导入:粘贴先前导出的JSON配置","You can choose to export all settings, only toolbar commands, or only custom commands":"您可以选择导出所有设置、仅工具栏命令或仅自定义命令","When importing, the plugin will only update the settings included in the import data":"导入时,插件将仅更新导入数据中包含的设置","Warning: Importing configuration will overwrite your current settings. Consider exporting your current configuration first as a backup.":"警告:导入配置将覆盖您当前的设置。建议先导出当前配置作为备份。","Export Type":"导出类型","Choose what to export":"选择要导出的内容","All Settings":"所有设置","Toolbar Commands Only":"仅工具栏命令","Custom Commands Only":"仅自定义命令","Export Content":"导出内容","Copy this content to share with others":"复制此内容以与他人共享","Loading...":"加载中...","Copy to Clipboard":"复制到剪贴板","Configuration copied to clipboard":"配置已复制到剪贴板","Failed to copy configuration":"复制配置失败","Paste the configuration JSON here":"在此处粘贴配置JSON","Paste configuration here...":"在此处粘贴配置...","Invalid import data":"无效的导入数据","Configuration imported successfully":"配置导入成功","No valid configuration found in import data":"导入数据中未找到有效配置","Failed to import configuration. Invalid format.":"导入配置失败。格式无效。","Import Mode":"导入模式","Choose how to import the configuration":"选择如何导入配置","Update Mode (Add new items and update existing ones)":"更新模式(添加新项目并更新现有项目)","Overwrite Mode (Replace all settings with imported ones)":"覆盖模式(用导入的配置替换所有设置)","Configuration imported successfully (Overwrite mode)":"配置导入成功(覆盖模式)","Configuration imported successfully (Update mode)":"配置导入成功(更新模式)","Warning: Overwrite mode will completely replace your current settings with the imported ones. Consider exporting your current configuration first as a backup.":"警告:覆盖模式将完全替换您当前的设置与导入的设置。建议先导出当前配置作为备份。","Warning: Update mode will add new items and update existing ones based on the imported configuration.":"警告:更新模式将根据导入的配置添加新项目并更新现有项目。","Add Format Command":"添加格式命令",Regex:"正则","Prefix/Suffix":"前缀/后缀","Insert Special Char":"增加特殊符号","Add Regex Command":"添加正则表达式命令","Switch Regex Command Window":"切换到正则命令窗口","Please select text first":"请先选中文本","The selected text does not meet the condition requirements":"选中的文本不满足条件要求","Regex command execution error:":"正则表达式命令执行错误:","Copy code":"复制代码","Copied!":"已复制!","Explain the syntax of JavaScript regular expressions":"解释JavaScript正则表达式的语法","Apply regular expression replacement":"应用正则表达式替换","Conditional matching":"条件匹配","Complete regular expression code (copy to AI for explanation)":"完整正则表达式代码(复制到AI解释)","Error:":"错误:","Regex pattern cannot be empty":"正则表达式不能为空","Command already exists":"命令已存在","Choose icon":"选择图标","URL to Markdown link":"URL转Markdown链接","Convert MM/DD/YYYY to YYYY-MM-DD":"将MM/DD/YYYY日期格式转换为YYYY-MM-DD","Add bold to keywords":"添加粗体到关键词","Format phone number":"格式化电话号码","Remove extra spaces":"删除多余空格","Convert HTML bold tags to Markdown format":"将HTML粗体标签转换为Markdown格式","Convert quoted text to quote block":"将引用的文本转换为引用块","Convert CSV to Markdown table row":"将CSV转换为Markdown表格行","Add uniform alias to Markdown links":"添加统一别名到Markdown链接","Delete empty lines (multiline mode)":"删除空行(多行模式)","Add list symbol to each line (multiline mode)":"添加列表符号到每行(多行模式)","If the text contains important, set the text highlight (conditional format)":"如果文本包含重要内容,设置文本高亮(条件格式)","Matching pattern":"匹配模式","Regex pattern to match":"正则表达式匹配","Replacement pattern (use $1, $2, etc. to reference capture groups)":"替换模式(使用$1, $2等引用捕获组)","Ignore case":"忽略大小写","Global replace":"全局替换","Multiline mode":"多行模式","Use condition":"使用条件","Condition pattern":"条件模式","Only apply custom command when text matches the condition":"仅在文本匹配条件时应用自定义命令","Must exist regular expression or text":"必须存在正则表达式或文本","Replacement pattern":"替换模式","Match case-insensitive":"匹配不区分大小写","^ and $ match the start and end of each line":"^ 和 $ 匹配每行的开始和结束","Replace all matches":"替换所有匹配",Command:"命令","Error: ":"错误:","Input example text to view the formatting effect of the command...":"输入示例文本以查看命令的格式化效果...",Description:"描述","[Example]":"[示例]","[Requirements]":"[要求]","[Output]":"[输出]","AI question template:":"AI问题模板:","I need to convert the url to a markdown format link":"我需要将URL转换为Markdown格式链接","For example, convert https://example.com to [https://example.com](https://example.com)":"例如,将https://example.com转换为[https://example.com](https://example.com)","Use js regular expression to implement, and output the parameters in the following format (the result does not need to be escaped with json)":"使用js正则表达式实现,并输出以下格式的参数(结果不需要用json转义)","[Description]":"[描述]","How to use AI to get regular expressions?":"如何使用AI获取正则表达式?","Regular expression examples":"正则表达式示例","Edit regular expression command":"编辑正则表达式命令","Add regular expression command":"添加正则表达式命令","Result:":"结果:","Example text:":"示例文本:",Preview:"预览",Result:"结果","Update Import":"增量导入","Overwrite Import":"覆盖导入","Importing configuration...":"正在导入配置...","Following Style Only":"仅Following样式","Top Style Only":"仅Top样式","Fixed Style Only":"仅Fixed样式","Mobile Style Only":"仅Mobile样式","Unknown import type":"未知导入类型","All Toolbar Commands":"所有工具栏命令","Following style commands successfully initialized":"Following样式初始化成功","Top style commands successfully initialized":"Top样式初始化成功","Fixed style commands successfully initialized":"Fixed样式初始化成功","Mobile style commands successfully initialized":"Mobile样式初始化成功","Commands initialized successfully":"命令初始化成功","Reset Commands":"重置命令","Are you sure you want to reset the current configuration?":"您确定要将当前配置进行重置吗?","Commands reset successfully":"命令重置成功","Initialize Commands":"初始化命令","Initialize commands to default settings":"初始化命令到默认设置","Reset commands to default settings":"重置命令到默认设置",Clear:"清除","Remove all commands from this configuration":"清除当前样式下的所有命令","Are you sure you want to clear all commands under the current style?":"您确定要清除当前样式下的所有命令吗?","Current style commands have been cleared":"当前样式下的命令已清除","Manage Commands":"管理命令","Reset or clear all commands in this configuration":"重置或清除当前样式下的所有命令","Import Commands from Other Styles":"从其他样式导入命令","Copy commands from another style configuration":"从另一个样式配置复制命令","Main menu only":"Main menu only","This import will update:":"此次导入将更新:","Custom commands":"自定义命令","Toolbar commands":"工具栏命令","All settings":"所有设置","Following style only":"跟随样式","Top style only":"顶部样式","Fixed style only":"固定样式","Mobile style only":"移动端样式","Main Menu Commands":"主菜单命令","Following Style Commands":"跟随样式命令","Top Style Commands":"顶部样式命令","Fixed Style Commands":"固定样式命令","Mobile Style Commands":"移动端样式命令","General settings":"常规设置","Please paste configuration data first":"请先粘贴配置数据","Invalid import data format":"无效的导入数据格式","Do you want to continue?":"您确定要继续吗?","Warning: Update mode will add new items and update existing ones.":"警告:更新模式将添加新项目并更新现有项目。","Warning: Overwrite mode will completely replace your current settings with the imported ones.":"警告:覆盖模式将完全替换您当前的设置与导入的设置。","Overwrite Mode (Replace settings with imported ones)":"覆盖模式(用导入的配置替换所有设置)","Warning: Overwrite mode will replace existing settings with imported ones.":"警告:覆盖模式将用导入的配置替换所有设置。","Enable Multiple Config":"启用多配置","One-click clear":"一键清除","This import will:":"此次导入将:","Update general settings":"更新常规设置","Update Main Menu Commands":"更新主菜单命令","Update Custom Commands":"更新自定义命令","Update Following Style Commands":"更新跟随样式命令","Update Top Style Commands":"更新顶部样式命令","Update Fixed Style Commands":"更新固定样式命令","Clear all Main Menu Commands":"清除所有主菜单命令","Clear all Custom Commands":"清除所有自定义命令","Clear all Following Style Commands":"清除所有跟随样式命令","Clear all Top Style Commands":"清除所有顶部样式命令","Clear all Fixed Style Commands":"清除所有固定样式命令","Clear all Mobile Style Commands":"清除所有移动端样式命令","Set Multiple Config to:":"设置多配置为:",Enable:"启用",Disable:"禁用","Set Position Style to:":"设置位置样式为:",Following:"跟随",Top:"顶部",Fixed:"固定",Mobile:"移动端","All commands":"所有命令","⚠️ Overwrite mode will replace existing settings with imported ones.":"⚠️ 覆盖模式将用导入的配置替换所有设置。","ℹ️ Update mode will merge imported settings with existing ones.":"ℹ️ 更新模式将合并导入的设置与现有的设置。","Imported settings:":"导入的设置:","Imported commands:":"导入的命令:","Disable toolbar for this view":"禁用此视图的工具栏","Enable toolbar for this view":"启用此视图的工具栏","Manage all view types":"管理所有视图类型","Current View: ":"当前视图:","Appearance Style":"外观样式","Position Settings":"位置设置","Join the Community":"加入社区","Share your toolbar settings and styles in our":"分享您的工具栏设置和样式:","section!":"社区!","Get inspired by what others have created or showcase your own customizations.":"获取灵感或展示您的自定义设置。","Toolbar preview":"工具栏预览(按钮仅供参考)","Toolbar theme":"工具栏主题","Select a preset toolbar theme, automatically setting the background color, icon color, and size":"选择预设的工具栏主题,自动设置背景颜色、图标颜色和大小","Toolbar background color":"工具栏背景颜色","Set the background color of the toolbar":"设置工具栏的背景颜色","Toolbar icon color":"工具栏图标颜色","Set the color of the toolbar icon":"设置工具栏图标颜色","Toolbar icon size":"工具栏图标大小","Set the size of the toolbar icon (px) default 18px":"设置工具栏图标大小(px)默认18px","Custom theme":"自定义主题","Fixed position offset":"固定位置偏移","Choose the offset of the Editing Toolbar in the fixed position.":"选择固定位置工具栏的偏移量。","Renumber List":"列表重新编号","Insert link":"插入链接","Please enter a URL first":"请先输入一个URL","Failed to fetch title for":"获取标题失败","Link Title (optional)":"链接标题(可选)","Unable to detect editor width":"无法检测编辑器宽度","Fit Editor Width":"自适应宽度","Fetch Remote Title":"获取URL标题","Please execute a format command or select format text first, then enable the format brush":"请先执行一个格式命令或选中带格式的文本,然后启用格式刷",Confirm:"确认"},zr=Object.assign({},Hr);const $r={ar:{},cs:{},da:{},de:{},en:Vr,"en-gb":{},es:{},fr:{},hi:{},id:{},it:{},ja:{},ko:{},nl:{},nn:{},pl:{},pt:{},"pt-br":{},ro:{},ru:{},tr:{},"zh-cn":Hr,"zh-tw":zr}[t.moment.locale()];function Wr(t){return $r&&$r[t]||Vr[t]}class Ur extends t.FuzzySuggestModal{constructor(t,e,i=!1,n,o){super(t.app),this.customCallback=null,this.plugin=t,this.command=e,this.issub=i,this.customCallback=n||null,this.setPlaceholder(Wr("Choose an icon")),this.currentEditingConfig=o||""}capitalJoin(t){return t.split(" ").map((t=>t[0].toUpperCase()+t.substring(1))).join(" ")}getItems(){return i}getItemText(t){return this.capitalJoin(t.replace("feather-","").replace("remix-","").replace("bx-","").replace(/([A-Z])/g," $1").trim().replace(/-/gi," "))}renderSuggestion(e,i){const n=createSpan({cls:"editingToolbarIconPick"});i.appendChild(n),t.setIcon(n,e.item),super.renderSuggestion(e,i)}onChooseItem(t){return e(this,void 0,void 0,(function*(){if("Custom"===t)return this.customCallback?void new jr(this.app,this.plugin,{id:this.command.id,name:this.command.name,icon:""},this.issub,(t=>{this.customCallback(t)})).open():void new jr(this.app,this.plugin,this.command,this.issub,null,this.currentEditingConfig).open();if(this.customCallback)return void this.customCallback(t);const e=this.plugin.getCurrentCommands(this.currentEditingConfig);if(this.command.icon){let i=Dr(this.plugin,this.command,this.issub,e);this.issub?e[i.index].SubmenuCommands[i.subindex].icon=t:e[i.index].icon=t,this.plugin.updateCurrentCommands(e)}else this.command.icon=t,e.push(this.command),this.plugin.updateCurrentCommands(e);yield this.plugin.saveSettings(),setTimeout((()=>{dispatchEvent(new Event("editingToolbar-NewCommand"))}),100),console.log(`%c命令 '${this.command.name}' 已添加到编辑工具栏`,"color: Violet")}))}}class jr extends t.Modal{constructor(t,e,i,n,o,s){super(t),this.customCallback=null,this.plugin=e,this.item=i,this.issub=n,this.customCallback=o||null,this.currentEditingConfig=s||"",this.containerEl.addClass("editingToolbar-Modal"),this.containerEl.addClass("customicon")}onOpen(){const{contentEl:t}=this;t.createEl("b",{text:Wr("Enter the icon code, format as .... ")});const i=document.createElement("textarea");i.className="wideInputPromptInputEl",i.placeholder="",i.value=this.item.icon||"",i.style.width="100%",i.style.height="200px",t.appendChild(i),i.addEventListener("input",(()=>e(this,void 0,void 0,(function*(){const t=i.value;if(this.customCallback)return void(this.item.icon=t);this.item.icon=t;const e=this.plugin.getCurrentCommands(this.currentEditingConfig),n=Dr(this.plugin,this.item,this.issub,e);if(this.issub){let e=n.subindex;-1===e?this.plugin.settings.menuCommands[n.index].SubmenuCommands.push(this.item):this.plugin.settings.menuCommands[n.index].SubmenuCommands[e].icon=t}else{let t=n.index;-1===t?this.plugin.settings.menuCommands.push(this.item):this.plugin.settings.menuCommands[t].icon=this.item.icon}yield this.plugin.saveSettings()})))),this.submitEnterCallback&&i.addEventListener("keydown",this.submitEnterCallback)}onClose(){const{contentEl:t}=this;t.empty(),this.customCallback?this.customCallback(this.item.icon||""):setTimeout((()=>{dispatchEvent(new Event("editingToolbar-NewCommand"))}),100)}}class Yr extends t.FuzzySuggestModal{constructor(t,e){super(t.app),this.plugin=t,this.app,this.setPlaceholder(Wr("Choose a command")),this.currentEditingConfig=e||""}getItems(){return app.commands.listCommands()}getItemText(t){return t.name}onChooseItem(i){return e(this,void 0,void 0,(function*(){const e=this.plugin.getCurrentCommands(this.currentEditingConfig);e.findIndex((t=>t.id==i.id))>-1?new t.Notice(Wr("The command")+i.name+Wr("already exists"),3e3):i.icon?(e.push(i),this.plugin.updateCurrentCommands(e),yield this.plugin.saveSettings(),setTimeout((()=>{dispatchEvent(new Event("editingToolbar-NewCommand"))}),100),console.log(`%c命令 '${i.name}' 已添加到编辑工具栏`,"color: Violet")):new Ur(this.plugin,i,!1).open()}))}}class Gr extends t.Modal{constructor(t,e,i,n,o){super(e.app),this.plugin=e,this.item=i,this.issub=n,this.currentEditingConfig=o||"",this.containerEl.addClass("editingToolbar-Modal"),this.containerEl.addClass("changename")}onOpen(){var i;const{contentEl:n}=this;n.createEl("b",{text:Wr("Please enter a new name:")});const o=new t.TextComponent(n);o.inputEl.classList.add("InputPromptInputEl"),o.setPlaceholder("").setValue(null!==(i=this.item.name)&&void 0!==i?i:"").onChange(t.debounce((t=>e(this,void 0,void 0,(function*(){const e=this.plugin.getCurrentCommands(this.currentEditingConfig);let i=Dr(this.plugin,this.item,this.issub,e);if(this.item.name=t,this.issub){let n=i.subindex;-1===n?e[i.index].SubmenuCommands.push(this.item):e[i.index].SubmenuCommands[n].name=t}else{let t=i.index;-1===t?e.push(this.item):e[t].name=this.item.name}this.plugin.updateCurrentCommands(e),yield this.plugin.saveSettings()}))),100,!0)).inputEl.addEventListener("keydown",this.submitEnterCallback)}onClose(){const{contentEl:t}=this;t.empty(),setTimeout((()=>{dispatchEvent(new Event("editingToolbar-NewCommand"))}),100)}}class Zr extends t.Modal{constructor(t,e){super(e.app),this.needSave=!1,this.plugin=e,this.containerEl.addClass("editingToolbar-Modal")}onOpen(){const{contentEl:i}=this;i.createEl("p",{text:Wr("Drag the slider to move the position")});const n=i.createDiv({cls:"slider-container"}),o=n.createDiv({cls:"vertical-slider-container"});o.createEl("p",{text:Wr("Vertical Position")});const s=n.createDiv({cls:"horizontal-slider-container"});s.createEl("p",{text:Wr("Horizontal Position")});const r=n.createDiv({cls:"columns-slider-container"});r.createEl("p",{text:Wr("Editing Toolbar columns")});const l=document.body.clientHeight,a=document.body.clientWidth,c=Math.floor(l/3),h=-Math.floor(l),d=Math.floor(a/2),u=-Math.floor(a/2),p=new t.SliderComponent(o).setLimits(h,c,5).setValue(this.plugin.settings.verticalPosition||0).onChange(t.debounce((t=>{this.needSave=!0,this.plugin.settings.verticalPosition=t,_r(this.plugin.settings)}),100,!0)).setDynamicTooltip(),m=new t.SliderComponent(s).setLimits(u,d,10).setValue(this.plugin.settings.horizontalPosition||0).onChange(t.debounce((t=>{this.needSave=!0,this.plugin.settings.horizontalPosition=t,Fr(this.plugin.settings)}),100,!0)).setDynamicTooltip(),g=new t.SliderComponent(r).setLimits(1,32,1).setValue(this.plugin.settings.cMenuNumRows||12).onChange(t.debounce((t=>e(this,void 0,void 0,(function*(){this.needSave=!0,this.plugin.settings.cMenuNumRows=t,yield this.plugin.saveSettings(),setTimeout((()=>{dispatchEvent(new Event("editingToolbar-NewCommand"))}),100)}))),100,!0)).setDynamicTooltip();n.createDiv({cls:"reset-container"}).createEl("button",{text:Wr("Reset"),cls:"reset-button"}).addEventListener("click",(()=>{this.needSave=!0,p.setValue(0),m.setValue(0),g.setValue(12),this.plugin.settings.verticalPosition=0,this.plugin.settings.horizontalPosition=0,this.plugin.settings.cMenuNumRows=12,_r(this.plugin.settings),Fr(this.plugin.settings)}))}onClose(){return e(this,void 0,void 0,(function*(){const{contentEl:t}=this;t.empty(),this.needSave&&(yield this.plugin.saveSettings())}))}}const Kr=["body","workspace"],Xr=["default","tiny","glass","custom"],Jr=["following","top","fixed"],Qr={lastVersion:"0.0.0",aestheticStyle:"default",positionStyle:"top",menuCommands:[{id:"editing-toolbar:editor-undo",name:"Undo editor",icon:"undo-glyph"},{id:"editing-toolbar:editor-redo",name:"Redo editor",icon:"redo-glyph"},{id:"editing-toolbar:toggle-format-brush",name:"Format Brush",icon:"paintbrush"},{id:"editing-toolbar:format-eraser",name:"Clear text formatting",icon:"eraser"},{id:"editing-toolbar:header2-text",name:"Header 2",icon:"header-2"},{id:"editing-toolbar:header3-text",name:"Header 3",icon:"header-3"},{id:"SubmenuCommands-header",name:"submenu",icon:"header-n",SubmenuCommands:[{id:"editing-toolbar:header1-text",name:"Header 1",icon:"header-1"},{id:"editing-toolbar:header4-text",name:"Header 4",icon:"header-4"},{id:"editing-toolbar:header5-text",name:"Header 5",icon:"header-5"},{id:"editing-toolbar:header6-text",name:"Header 6",icon:"header-6"}]},{id:"editing-toolbar:toggle-bold",name:"Bold",icon:"bold-glyph"},{id:"editing-toolbar:toggle-italics",name:"Italics",icon:"italic-glyph"},{id:"editing-toolbar:toggle-strikethrough",name:"Strikethrough",icon:"strikethrough-glyph"},{id:"editing-toolbar:underline",name:"Underline",icon:"underline-glyph"},{id:"editing-toolbar:toggle-highlight",name:"==Highlight==",icon:"highlight-glyph"},{id:"SubmenuCommands-lucdf3en5",name:"submenu",icon:"edit",SubmenuCommands:[{id:"editing-toolbar:editor-copy",name:"Copy",icon:"lucide-copy"},{id:"editing-toolbar:editor-cut",name:"Cut",icon:"lucide-scissors"},{id:"editing-toolbar:editor-paste",name:"Paste",icon:"lucide-clipboard-type"},{id:"editing-toolbar:editor:swap-line-down",name:"Swap line down",icon:"lucide-corner-right-down"},{id:"editing-toolbar:editor:swap-line-up",name:"Swap line up",icon:"lucide-corner-right-up"}]},{id:"editing-toolbar:editor:attach-file",name:"Attach file",icon:"lucide-paperclip"},{id:"editing-toolbar:editor:insert-table",name:"Insert Table",icon:"lucide-table"},{id:"editing-toolbar:editor:cycle-list-checklist",name:"Cycle list checklist",icon:"check-circle"},{id:"SubmenuCommands-luc8efull",name:"submenu",icon:"message-square",SubmenuCommands:[{id:"editing-toolbar:editor:toggle-blockquote",name:"Blockquote",icon:"lucide-text-quote"},{id:"editing-toolbar:insert-callout",name:"Insert Callout ",icon:"lucide-quote"}]},{id:"SubmenuCommands-mdcmder",name:"submenu",icon:'',SubmenuCommands:[{id:"editing-toolbar:superscript",name:"Superscript",icon:"superscript-glyph"},{id:"editing-toolbar:subscript",name:"Subscript",icon:"subscript-glyph"},{id:"editing-toolbar:editor:toggle-code",name:"Inline code",icon:"code-glyph"},{id:"editing-toolbar:codeblock",name:"Code block",icon:"codeblock-glyph"},{id:"editing-toolbar:editor:insert-wikilink",name:"Insert wikilink [[]]",icon:''},{id:"editing-toolbar:editor:insert-embed",name:"Insert embed ![[]]",icon:"note-glyph"},{id:"editing-toolbar:insert-link",name:"Insert link []()",icon:"link-glyph"},{id:"editing-toolbar:hrline",name:"Horizontal divider",icon:''},{id:"editing-toolbar:toggle-inline-math",name:"Inline math",icon:"lucide-sigma"},{id:"editing-toolbar:editor:insert-mathblock",name:"MathBlock",icon:"lucide-sigma-square"}]},{id:"SubmenuCommands-list",name:"submenu-list",icon:"bullet-list-glyph",SubmenuCommands:[{id:"editing-toolbar:editor:toggle-checklist-status",name:"Checklist",icon:"checkbox-glyph"},{id:"editing-toolbar:renumber-ordered-list",name:"Renumber ordered list",icon:"list-restart"},{id:"editing-toolbar:toggle-numbered-list",name:"Numbered list",icon:''},{id:"editing-toolbar:toggle-bullet-list",name:"Bullet list",icon:''},{id:"editing-toolbar:undent-list",name:"Unindent-list",icon:''},{id:"editing-toolbar:indent-list",name:"Indent list",icon:''}]},{id:"SubmenuCommands-aligin",name:"submenu-aligin",icon:'',SubmenuCommands:[{id:"editing-toolbar:justify",name:'

',icon:''},{id:"editing-toolbar:left",name:'

',icon:''},{id:"editing-toolbar:center",name:"
",icon:''},{id:"editing-toolbar:right",name:'

',icon:''}]},{id:"editing-toolbar:change-font-color",name:"Change font color[html]",icon:''},{id:"editing-toolbar:change-background-color",name:"Change Backgroundcolor[html]",icon:''},{id:"editing-toolbar:fullscreen-focus",name:"Fullscreen focus mode",icon:"fullscreen"},{id:"editing-toolbar:workplace-fullscreen-focus",name:"Workplace-Fullscreen ",icon:"exit-fullscreen"}],followingCommands:[],topCommands:[],fixedCommands:[],mobileCommands:[],enableMultipleConfig:!1,appendMethod:"workspace",shouldShowMenuOnSelect:!1,cMenuVisibility:!0,cMenuBottomValue:4.25,cMenuNumRows:12,cMenuWidth:610,cMenuFontColor:"#2DC26B",cMenuBackgroundColor:"#d3f8b6",autohide:!1,Iscentered:!1,custom_bg1:"#FFB78B8C",custom_bg2:"#CDF4698C",custom_bg3:"#A0CCF68C",custom_bg4:"#F0A7D88C",custom_bg5:"#ADEFEF8C",custom_fc1:"#D83931",custom_fc2:"#DE7802",custom_fc3:"#245BDB",custom_fc4:"#6425D0",custom_fc5:"#646A73",isLoadOnMobile:!1,horizontalPosition:0,verticalPosition:0,formatBrushes:{},customCommands:[],viewTypeSettings:{},toolbarBackgroundColor:"rgba(var(--background-secondary-rgb), 0.7)",toolbarIconColor:"var(--text-normal)",toolbarIconSize:18};class tl{static isAllowedViewType(t,e){var i,n,o,s;if(!t)return!1;const r=t.getViewType(),l=null===(o=null===(n=null===(i=window.app)||void 0===i?void 0:i.plugins)||void 0===n?void 0:n.plugins)||void 0===o?void 0:o["editing-toolbar"];if((null===(s=null==l?void 0:l.settings)||void 0===s?void 0:s.viewTypeSettings)&&void 0!==l.settings.viewTypeSettings[r])return l.settings.viewTypeSettings[r];return(e||["markdown","canvas","thino_view","meld-encrypted-view"]).includes(r)}static isSourceMode(t){var e;return!!t&&"source"===(null===(e=t.getMode)||void 0===e?void 0:e.call(t))}}let el;const il={markdown:".markdown-source-view",thino_view:".markdown-source-view",canvas:".canvas-wrapper",excalidraw:".view-header",image:".image-container",pdf:".view-content",meld_encrypted_view:".markdown-source-view"};function nl(){el=t.requireApiVersion("0.15.0")?activeWindow.document:window.document;const e=el.getElementById("editingToolbarModalBar");e&&e.remove();const i=function(){const e=[];e.push(app.workspace.rootSplit);const i=app.workspace.floatingSplit;return null==i||i.children.forEach((i=>{i instanceof t.WorkspaceWindow&&e.push(i)})),e}();i&&i.forEach((t=>{(null==t?void 0:t.containerEl)&&(t=>{let e=t.querySelectorAll("#editingToolbarModalBar"),i=t.querySelectorAll("#editingToolbarPopoverBar");e.forEach((t=>{t&&(t.firstChild&&t.removeChild(t.firstChild),t.remove())})),i.forEach((t=>{t&&(t.firstChild&&t.removeChild(t.firstChild),t.remove())}))})(null==t?void 0:t.containerEl)}))}function ol(e,i){var n,o;el=t.requireApiVersion("0.15.0")?activeWindow.document:window.document;let s="top"==i.positionStyle?null===(o=null===(n=e.workspace.activeLeaf)||void 0===n?void 0:n.view.containerEl)||void 0===o?void 0:o.querySelector("#editingToolbarModalBar"):el.getElementById("editingToolbarModalBar");return s||null}const sl=(t,e)=>e.reduce(((t,e)=>t&&"undefined"!==t[e]?t[e]:void 0),t);function rl(t,e){return t&&void 0!==t[1][0]?e+t.flat(2).join("+").replace("Mod","Ctrl")+e:e+"–"+e}function ll(t,e,i=!0){let n=t.commands.findCommand(e),o=i?"*":"";if(n){let e=n.hotkeys?[[sl(n.hotkeys,[0,"modifiers"])],[sl(n.hotkeys,[0,"key"])]]:void 0,i=t.hotkeyManager.customKeys[n.id];var s=i?[[sl(i,[0,"modifiers"])],[sl(i,[0,"key"])]]:void 0;return s?rl(s,o):rl(e,"")}return"–"}function al(t){return/<[^>]+>/g.test(t)}function cl(e,i,n){el=t.requireApiVersion("0.15.0")?activeWindow.document:window.document;const o=i.commandsManager.getActiveEditor();let s=ol(e,i),r=null==s?void 0:s.querySelector("#"+n);if(r){let t=r.rows,e=t.length;for(let s=1;s{e.style.fill=t}))}else if("x-backgroundcolor-picker-table"==n){i.settings.cMenuBackgroundColor=t,Br(t,o),el.querySelectorAll("#change-background-color-icon").forEach((e=>{e.style.fill=t}))}i.saveSettings()}}}}}const hl=function(t){let e=t;if(/^(rgb|RGB)/.test(e)){let t=e.replace(/(?:\(|\)|rgb|RGB)*/g,"").split(","),i="#";for(let e=0;e\s*\[\![\w\s]*\]/m)){let t=i.split("\n"),n=[],o=!1,s=0,r=!1;for(let e=0;e+)\s*\[\!([\w\s]*)\]\s*(.*?)$/);if(!l||r)if(o){let t=i.match(/^(>+)\s*/);if(t&&t[1].length>=s){let t=i.replace(new RegExp(`^>{${s}}\\s*`),"");n.push(t)}else o=!1,n.push(i)}else n.push(i);else s=l[1].length,r=!0,l[3].trim()&&n.push(l[3].trim()),o=!0}return void e.replaceSelection(n.join("\n"))}i=i.replace(/(^#+\s|^#(?=\s)|^\>|^\- \[( |x)\]|^\+ |\<[^\<\>]+?\>|^1\. |^\s*\- |^\-+$|^\*+$)/gm,""),i=i.replace(/^[ ]+|[ ]+$/gm,""),i=i.replace(/\!?\[\[([^\[\]\|]*\|)*([^\(\)\[\]]+)\]\]/g,"$2"),i=i.replace(/\!?\[+([^\[\]\(\)]+)\]+\(([^\(\)]+)\)/g,"$1"),i=i.replace(/`([^`]+)`/g,"$1"),i=i.replace(/_([^_]+)_/g,"$1"),i=i.replace(/==([^=]+)==/g,"$1"),i=i.replace(/\*\*\*([^\*]+)\*\*\*/g,"$1"),i=i.replace(/\*\*?([^\*]+)\*\*?/g,"$1"),i=i.replace(/~~([^~]+)~~/g,"$1"),e.replaceSelection(i)}function pl(e,i,n,o,s=!1){let r=ol(e,n);const l=e.workspace.getActiveViewOfType(t.ItemView);if(!tl.isAllowedViewType(l))return void(r&&(r.style.visibility="hidden"));if("following"!==n.positionStyle)return;const a="markdown"===(null==l?void 0:l.getViewType());let c=30;if(c="tiny"===n.settings.aestheticStyle?30:i+14,a)if(tl.isSourceMode(l)){if(r){const t=s||o.somethingSelected();r.style.visibility=t?"visible":"hidden","visible"===r.style.visibility&&(r.style.height=c+"px",r.addClass("editingToolbarFlex"),r.removeClass("editingToolbarGrid"),function(t,e){var i,n,o,s;const r=e.containerEl.getBoundingClientRect(),l=t.offsetWidth,a=t.offsetHeight,c=12,h=window.innerWidth,d=e.getCursor("from");e.getCursor("to");const u=e.coordsAtPos(d),p=null!==(n=null===(i=el.getElementsByClassName("mod-left-split")[0])||void 0===i?void 0:i.clientWidth)&&void 0!==n?n:0,m=null!==(s=null===(o=el.getElementsByClassName("side-dock-ribbon mod-left")[0])||void 0===o?void 0:o.clientWidth)&&void 0!==s?s:0,g=p+m;let f=u.left-g-28;f+l>h-g&&(f=h-g-l-c);f=Math.max(0,f);let b=function(t,e,i,n){const o=t.getCursor("from"),s=t.getCursor("to"),r=t.coordsAtPos(s),l=o.line===s.line;let a=e.top-n-10;if(l)a<=i.top&&(a=r.bottom+10);else{if(t.getCursor("head").ch==t.getCursor("from").ch)a=e.top-n-10,a<=i.top&&(a=i.top+2*n);else{const e=(t=>{var e,i,n;let o,s=t.getCursor("head");if(t.getCursor("head").ch!==t.getCursor("from").ch&&(s.ch=Math.max(0,s.ch-1)),t.cursorCoords)o=t.cursorCoords(!0,"window");else{if(!t.coordsAtPos)return;{const r=t.posToOffset(s);o=null!==(n=null===(i=(e=t.cm).coordsAtPos)||void 0===i?void 0:i.call(e,r))&&void 0!==n?n:t.coordsAtPos(r)}}return o})(t);a=e.bottom+10,a>=i.bottom-n&&(a=i.bottom-2*n)}}return a}(e,u,r,a);b=Math.max(0,b),t.style.left=`${f}px`,t.style.top=`${b}px`}(r,o))}}else r&&(r.style.visibility="hidden");else r&&(r.style.visibility="visible",r.style.height=c+"px",r.addClass("editingToolbarFlex"),r.removeClass("editingToolbarGrid"))}function ml(e,i){let n=i.settings;el=t.requireApiVersion("0.15.0")?activeWindow.document:window.document;const o={default:"editingToolbarDefaultAesthetic",tiny:"editingToolbarTinyAesthetic",glass:"editingToolbarGlassAesthetic",custom:"editingToolbarCustomAesthetic"};!function(){function s(t,e){Object.values(o).forEach((e=>{t.removeClass(e)}));const i=o[e]||o.default;t.addClass(i)}const r=()=>{var o,r;let l=0,a=0,c=26;i.toolbarIconSize&&(c=i.toolbarIconSize+8);let h=createEl("div");if(h)if("top"==i.positionStyle)h.className+=" top",n.autohide&&(h.className+=" autohide"),n.Iscentered&&(h.className+=" centered");else if("following"==i.positionStyle)h.style.visibility="hidden";else if("fixed"==i.positionStyle){let t=n.toolbarIconSize||18;h.setAttribute("style",`left: calc(50% - calc(${n.cMenuNumRows*(t+10)}px / 2));\n bottom: 4.25em; \n grid-template-columns: repeat(${n.cMenuNumRows}, ${t+10}px);\n gap: ${(t-18)/4}px`)}h.setAttribute("id","editingToolbarModalBar");let d=createEl("div");if(d.addClass("editingToolbarpopover"),d.addClass("editingToolbarTinyAesthetic"),d.setAttribute("id","editingToolbarPopoverBar"),d.style.visibility="hidden",d.style.height="0",s(h,n.aestheticStyle),s(d,n.aestheticStyle),"top"==i.positionStyle){let t=e.workspace.activeLeaf.view.containerEl,i=null;const n=e.workspace.activeLeaf.view.getViewType(),o=il[n];if(o&&(i=null==t?void 0:t.querySelector(o)),!i){const e=null==t?void 0:t.querySelector(".view-content");if(e){const t=e.querySelectorAll(":scope > div");i=t.length>0?t[0]:e}}if(!i)return void console.log("Editing Toolbar: Failed to find target DOM element for toolbar insertion");(null==t?void 0:t.querySelector("#editingToolbarPopoverBar"))||("excalidraw"==n?i.insertAdjacentElement("afterend",d):i.insertAdjacentElement("afterbegin",d)),"excalidraw"==n?i.insertAdjacentElement("afterend",h):i.insertAdjacentElement("afterbegin",h),a=null==i?void 0:i.offsetWidth}else"body"==n.appendMethod?el.body.appendChild(h):"workspace"==n.appendMethod&&(null===(o=el.body)||void 0===o||o.querySelector(".mod-vertical.mod-root").insertAdjacentElement("afterbegin",h));let u=null===(r=e.workspace.activeLeaf.view.containerEl)||void 0===r?void 0:r.querySelector("#editingToolbarPopoverBar");i.getCurrentCommands().forEach(((o,s)=>{let r;if("SubmenuCommands"in o){let d;l>=a-4*c&&a>100?(i.setIS_MORE_Button(!0),d=new t.ButtonComponent(u)):d=new t.ButtonComponent(h),d.setClass("editingToolbarCommandsubItem"+s),s>=n.cMenuNumRows?d.setClass("editingToolbarSecond"):"top"!=i.positionStyle&&d.buttonEl.setAttribute("aria-label-position","top"),al(o.icon)?d.buttonEl.innerHTML=o.icon:d.setIcon(o.icon),l+=c+2;let p=function(t){let e=createEl("div");return e.addClass(t),e}("subitem");p&&o.SubmenuCommands.forEach((o=>{let l=ll(e,o.id);r="–"==l?o.name:o.name+"("+l+")";let a=new t.ButtonComponent(p).setTooltip(r).setClass("menu-item").onClick((()=>{e.commands.executeCommandById(o.id);const t=i.commandsManager.getActiveEditor(),s=t&&t.somethingSelected();0==n.cMenuVisibility?h.style.visibility="hidden":"following"==i.positionStyle?s||(h.style.visibility="hidden"):h.style.visibility="visible"}));s{e.commands.executeCommandById(o.id);const t=i.commandsManager.getActiveEditor(),s=t&&t.somethingSelected();0==n.cMenuVisibility?h.style.visibility="hidden":"following"==i.positionStyle?s||(h.style.visibility="hidden"):h.style.visibility="visible"})),al(o.icon)?s.buttonEl.innerHTML=o.icon:s.setIcon(o.icon),l+=c;let r=createEl("div");if(r.addClass("subitem"),r){r.innerHTML=function(t){return`
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
Theme Colors
Standard Colors
Custom Font Colors
\n
\n
`}(i),s.buttonEl.insertAdjacentElement("afterbegin",r),cl(e,i,"x-color-picker-table");let n=r.querySelector(".x-color-picker-wrapper");new t.ButtonComponent(n).setIcon("paintbrush").setTooltip(Wr("Format Brush")).onClick((()=>{dl(i),i.setEN_FontColor_Format_Brush(!0),i.Temp_Notice=new t.Notice(Wr("Font-Color formatting brush ON!"),0)})),new t.ButtonComponent(n).setIcon("palette").setTooltip(Wr("Custom Font Color")).onClick((()=>{e.setting.open(),e.setting.openTabById("editing-toolbar"),setTimeout((()=>{const t=e.setting.activeTab.containerEl.querySelector(".editing-toolbar-tabs");if(t){const i=t.children[1];null==i||i.click(),setTimeout((()=>{var t;let i=e.setting.activeTab.containerEl.querySelector(".custom_font");i&&(null===(t=i.addClass)||void 0===t||t.call(i,"toolbar-cta"))}),100)}}),200)}))}}else if("editing-toolbar:change-background-color"==o.id){let s=new t.ButtonComponent(h);s.setClass("editingToolbarCommandsubItem-font-color").setTooltip(Wr("Background color")).onClick((()=>{e.commands.executeCommandById(o.id);const t=i.commandsManager.getActiveEditor(),s=t&&t.somethingSelected();0==n.cMenuVisibility?h.style.visibility="hidden":"following"==i.positionStyle?s||(h.style.visibility="hidden"):h.style.visibility="visible"})),al(o.icon)?s.buttonEl.innerHTML=o.icon:s.setIcon(o.icon),l+=c;let r=createEl("div");if(r.addClass("subitem"),r){r.innerHTML=function(t){return`
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
Translucent Colors
Highlighter Colors
Custom Colors
\n
\n
`}(i),s.buttonEl.insertAdjacentElement("afterbegin",r),cl(e,i,"x-backgroundcolor-picker-table");let n=r.querySelector(".x-color-picker-wrapper");new t.ButtonComponent(n).setIcon("paintbrush").setTooltip(Wr("Format Brush")).onClick((()=>{dl(i),i.setEN_BG_Format_Brush(!0),i.Temp_Notice=new t.Notice(Wr("Font-Color formatting brush ON!"),0)})),new t.ButtonComponent(n).setIcon("palette").setTooltip(Wr("Custom Backgroud Color")).onClick((()=>{e.setting.open(),e.setting.openTabById("editing-toolbar"),setTimeout((()=>{const t=e.setting.activeTab.containerEl.querySelector(".editing-toolbar-tabs");if(t){const i=t.children[1];null==i||i.click(),setTimeout((()=>{var t;let i=e.setting.activeTab.containerEl.querySelector(".custom_bg");i&&(null===(t=i.addClass)||void 0===t||t.call(i,"toolbar-cta"))}),100)}}),200)}))}}else{let d;l>=a-4*c&&a>100?(i.setIS_MORE_Button(!0),d=new t.ButtonComponent(u)):d=new t.ButtonComponent(h);let p=ll(e,o.id);r="–"==p?o.name:o.name+"("+p+")",d.setTooltip(r).onClick((()=>{e.commands.executeCommandById(o.id);const t=i.commandsManager.getActiveEditor(),s=t&&t.somethingSelected();0==n.cMenuVisibility?h.style.visibility="hidden":"following"==i.positionStyle?s||(h.style.visibility="hidden"):h.style.visibility="visible"})),d.setClass("editingToolbarCommandItem"),s>=n.cMenuNumRows?d.setClass("editingToolbarSecond"):"top"!=i.positionStyle&&d.buttonEl.setAttribute("aria-label-position","top"),"editingToolbar-Divider-Line"==o.id&&d.setClass("editingToolbar-Divider-Line"),al(o.icon)?d.buttonEl.innerHTML=o.icon:d.setIcon(o.icon),l+=c}})),function(e,i,n){const o=e.workspace.getActiveViewOfType(t.ItemView);if(!tl.isAllowedViewType(o))return;let s=o.containerEl.querySelector("#editingToolbarPopoverBar");if(!i.IS_MORE_Button)return;let r=n.createEl("span");r.addClass("more-menu");let l=new t.ButtonComponent(r);l.setClass("editingToolbarCommandItem").setTooltip(Wr("More")).onClick((()=>{"hidden"==s.style.visibility?(s.style.visibility="visible",s.style.height="32px"):(s.style.visibility="hidden",s.style.height="0")})),l.buttonEl.innerHTML='',i.setIS_MORE_Button(!1)}(e,i,h),Math.abs(i.settings.cMenuWidth-Number(l))>l+4&&(i.settings.cMenuWidth=Number(l),setTimeout((()=>{i.saveSettings()}),100))};if(!i.isLoadMobile())return;const l=e.workspace.getActiveViewOfType(t.ItemView);tl.isAllowedViewType(l)&&(ol(e,i)||(r(),Fr(i.settings),_r(i.settings),function(e,i){el=t.requireApiVersion("0.15.0")?activeWindow.document:window.document;let n=el.querySelectorAll("#change-font-color-icon");n&&n.forEach((t=>{t.style.fill=e}));let o=el.querySelectorAll("#change-background-color-icon");o&&o.forEach((t=>{t.style.fill=i}))} /**! * Sortable 1.15.6 * @author RubaXa * @author owenm * @license MIT */(n.cMenuFontColor,n.cMenuBackgroundColor)))}()}function gl(t,e){var i=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),i.push.apply(i,n)}return i}function fl(t){for(var e=1;e=0||(o[i]=t[i]);return o}(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(t,i)&&(o[i]=t[i])}return o}function Cl(t){if("undefined"!=typeof window&&window.navigator)return!!navigator.userAgent.match(t)}var xl=Cl(/(?:Trident.*rv[ :]?11\.|msie|iemobile|Windows Phone)/i),kl=Cl(/Edge/i),Sl=Cl(/firefox/i),Tl=Cl(/safari/i)&&!Cl(/chrome/i)&&!Cl(/android/i),El=Cl(/iP(ad|od|hone)/i),Ml=Cl(/chrome/i)&&Cl(/android/i),Al={capture:!1,passive:!1};function Dl(t,e,i){t.addEventListener(e,i,!xl&&Al)}function Il(t,e,i){t.removeEventListener(e,i,!xl&&Al)}function Ol(t,e){if(e){if(">"===e[0]&&(e=e.substring(1)),t)try{if(t.matches)return t.matches(e);if(t.msMatchesSelector)return t.msMatchesSelector(e);if(t.webkitMatchesSelector)return t.webkitMatchesSelector(e)}catch(t){return!1}return!1}}function Bl(t){return t.host&&t!==document&&t.host.nodeType?t.host:t.parentNode}function ql(t,e,i,n){if(t){i=i||document;do{if(null!=e&&(">"===e[0]?t.parentNode===i&&Ol(t,e):Ol(t,e))||n&&t===i)return t;if(t===i)break}while(t=Bl(t))}return null}var Nl,Ll=/\s+/g;function Rl(t,e,i){if(t&&e)if(t.classList)t.classList[i?"add":"remove"](e);else{var n=(" "+t.className+" ").replace(Ll," ").replace(" "+e+" "," ");t.className=(n+(i?" "+e:"")).replace(Ll," ")}}function Pl(t,e,i){var n=t&&t.style;if(n){if(void 0===i)return document.defaultView&&document.defaultView.getComputedStyle?i=document.defaultView.getComputedStyle(t,""):t.currentStyle&&(i=t.currentStyle),void 0===e?i:i[e];e in n||-1!==e.indexOf("webkit")||(e="-webkit-"+e),n[e]=i+("string"==typeof i?"":"px")}}function _l(t,e){var i="";if("string"==typeof t)i=t;else do{var n=Pl(t,"transform");n&&"none"!==n&&(i=n+" "+i)}while(!e&&(t=t.parentNode));var o=window.DOMMatrix||window.WebKitCSSMatrix||window.CSSMatrix||window.MSCSSMatrix;return o&&new o(i)}function Fl(t,e,i){if(t){var n=t.getElementsByTagName(e),o=0,s=n.length;if(i)for(;o=s:o<=s))return n;if(n===Vl())break;n=Yl(n,!1)}return!1}function $l(t,e,i,n){for(var o=0,s=0,r=t.children;s2&&void 0!==arguments[2]?arguments[2]:{},n=i.evt,o=wl(i,oa);na.pluginEvent.bind(Xa)(t,e,fl({dragEl:la,parentEl:aa,ghostEl:ca,rootEl:ha,nextEl:da,lastDownEl:ua,cloneEl:pa,cloneHidden:ma,dragStarted:Ma,putSortable:wa,activeSortable:Xa.active,originalEvent:n,oldIndex:ga,oldDraggableIndex:ba,newIndex:fa,newDraggableIndex:va,hideGhostForTarget:Ya,unhideGhostForTarget:Ga,cloneNowHidden:function(){ma=!0},cloneNowShown:function(){ma=!1},dispatchSortableEvent:function(t){ra({sortable:e,name:t,originalEvent:n})}},o))};function ra(t){!function(t){var e=t.sortable,i=t.rootEl,n=t.name,o=t.targetEl,s=t.cloneEl,r=t.toEl,l=t.fromEl,a=t.oldIndex,c=t.newIndex,h=t.oldDraggableIndex,d=t.newDraggableIndex,u=t.originalEvent,p=t.putSortable,m=t.extraEventProperties;if(e=e||i&&i[Ql]){var g,f=e.options,b="on"+n.charAt(0).toUpperCase()+n.substr(1);!window.CustomEvent||xl||kl?(g=document.createEvent("Event")).initEvent(n,!0,!0):g=new CustomEvent(n,{bubbles:!0,cancelable:!0}),g.to=r||i,g.from=l||i,g.item=o||i,g.clone=s,g.oldIndex=a,g.newIndex=c,g.oldDraggableIndex=h,g.newDraggableIndex=d,g.originalEvent=u,g.pullMode=p?p.lastPutMode:void 0;var v=fl(fl({},m),na.getEventProperties(n,e));for(var y in v)g[y]=v[y];i&&i.dispatchEvent(g),f[b]&&f[b].call(e,g)}}(fl({putSortable:wa,cloneEl:pa,targetEl:la,rootEl:ha,oldIndex:ga,oldDraggableIndex:ba,newIndex:fa,newDraggableIndex:va},t))}var la,aa,ca,ha,da,ua,pa,ma,ga,fa,ba,va,ya,wa,Ca,xa,ka,Sa,Ta,Ea,Ma,Aa,Da,Ia,Oa,Ba=!1,qa=!1,Na=[],La=!1,Ra=!1,Pa=[],_a=!1,Fa=[],Va="undefined"!=typeof document,Ha=El,za=kl||xl?"cssFloat":"float",$a=Va&&!Ml&&!El&&"draggable"in document.createElement("div"),Wa=function(){if(Va){if(xl)return!1;var t=document.createElement("x");return t.style.cssText="pointer-events:auto","auto"===t.style.pointerEvents}}(),Ua=function(t,e){var i=Pl(t),n=parseInt(i.width)-parseInt(i.paddingLeft)-parseInt(i.paddingRight)-parseInt(i.borderLeftWidth)-parseInt(i.borderRightWidth),o=$l(t,0,e),s=$l(t,1,e),r=o&&Pl(o),l=s&&Pl(s),a=r&&parseInt(r.marginLeft)+parseInt(r.marginRight)+Hl(o).width,c=l&&parseInt(l.marginLeft)+parseInt(l.marginRight)+Hl(s).width;if("flex"===i.display)return"column"===i.flexDirection||"column-reverse"===i.flexDirection?"vertical":"horizontal";if("grid"===i.display)return i.gridTemplateColumns.split(" ").length<=1?"vertical":"horizontal";if(o&&r.float&&"none"!==r.float){var h="left"===r.float?"left":"right";return!s||"both"!==l.clear&&l.clear!==h?"horizontal":"vertical"}return o&&("block"===r.display||"flex"===r.display||"table"===r.display||"grid"===r.display||a>=n&&"none"===i[za]||s&&"none"===i[za]&&a+c>n)?"vertical":"horizontal"},ja=function(t){function e(t,i){return function(n,o,s,r){var l=n.options.group.name&&o.options.group.name&&n.options.group.name===o.options.group.name;if(null==t&&(i||l))return!0;if(null==t||!1===t)return!1;if(i&&"clone"===t)return t;if("function"==typeof t)return e(t(n,o,s,r),i)(n,o,s,r);var a=(i?n:o).options.group.name;return!0===t||"string"==typeof t&&t===a||t.join&&t.indexOf(a)>-1}}var i={},n=t.group;n&&"object"==bl(n)||(n={name:n}),i.name=n.name,i.checkPull=e(n.pull,!0),i.checkPut=e(n.put),i.revertClone=n.revertClone,t.group=i},Ya=function(){!Wa&&ca&&Pl(ca,"display","none")},Ga=function(){!Wa&&ca&&Pl(ca,"display","")};Va&&!Ml&&document.addEventListener("click",(function(t){if(qa)return t.preventDefault(),t.stopPropagation&&t.stopPropagation(),t.stopImmediatePropagation&&t.stopImmediatePropagation(),qa=!1,!1}),!0);var Za=function(t){if(la){t=t.touches?t.touches[0]:t;var e=(o=t.clientX,s=t.clientY,Na.some((function(t){var e=t[Ql].options.emptyInsertThreshold;if(e&&!Wl(t)){var i=Hl(t),n=o>=i.left-e&&o<=i.right+e,l=s>=i.top-e&&s<=i.bottom+e;return n&&l?r=t:void 0}})),r);if(e){var i={};for(var n in t)t.hasOwnProperty(n)&&(i[n]=t[n]);i.target=i.rootEl=e,i.preventDefault=void 0,i.stopPropagation=void 0,e[Ql]._onDragOver(i)}}var o,s,r},Ka=function(t){la&&la.parentNode[Ql]._isOutsideThisEl(t.target)};function Xa(t,e){if(!t||!t.nodeType||1!==t.nodeType)throw"Sortable: `el` must be an HTMLElement, not ".concat({}.toString.call(t));this.el=t,this.options=e=yl({},e),t[Ql]=this;var i={group:null,sort:!0,disabled:!1,store:null,handle:null,draggable:/^[uo]l$/i.test(t.nodeName)?">li":">*",swapThreshold:1,invertSwap:!1,invertedSwapThreshold:null,removeCloneOnHide:!0,direction:function(){return Ua(t,this.options)},ghostClass:"sortable-ghost",chosenClass:"sortable-chosen",dragClass:"sortable-drag",ignore:"a, img",filter:null,preventOnFilter:!0,animation:0,easing:null,setData:function(t,e){t.setData("Text",e.textContent)},dropBubble:!1,dragoverBubble:!1,dataIdAttr:"data-id",delay:0,delayOnTouchOnly:!1,touchStartThreshold:(Number.parseInt?Number:window).parseInt(window.devicePixelRatio,10)||1,forceFallback:!1,fallbackClass:"sortable-fallback",fallbackOnBody:!1,fallbackTolerance:0,fallbackOffset:{x:0,y:0},supportPointer:!1!==Xa.supportPointer&&"PointerEvent"in window&&(!Tl||El),emptyInsertThreshold:5};for(var n in na.initializePlugins(this,t,i),i)!(n in e)&&(e[n]=i[n]);for(var o in ja(e),this)"_"===o.charAt(0)&&"function"==typeof this[o]&&(this[o]=this[o].bind(this));this.nativeDraggable=!e.forceFallback&&$a,this.nativeDraggable&&(this.options.touchStartThreshold=1),e.supportPointer?Dl(t,"pointerdown",this._onTapStart):(Dl(t,"mousedown",this._onTapStart),Dl(t,"touchstart",this._onTapStart)),this.nativeDraggable&&(Dl(t,"dragover",this),Dl(t,"dragenter",this)),Na.push(this.el),e.store&&e.store.get&&this.sort(e.store.get(this)||[]),yl(this,ta())}function Ja(t,e,i,n,o,s,r,l){var a,c,h=t[Ql],d=h.options.onMove;return!window.CustomEvent||xl||kl?(a=document.createEvent("Event")).initEvent("move",!0,!0):a=new CustomEvent("move",{bubbles:!0,cancelable:!0}),a.to=e,a.from=t,a.dragged=i,a.draggedRect=n,a.related=o||e,a.relatedRect=s||Hl(e),a.willInsertAfter=l,a.originalEvent=r,t.dispatchEvent(a),d&&(c=d.call(h,a,r)),c}function Qa(t){t.draggable=!1}function tc(){_a=!1}function ec(t){for(var e=t.tagName+t.className+t.src+t.href+t.textContent,i=e.length,n=0;i--;)n+=e.charCodeAt(i);return n.toString(36)}function ic(t){return setTimeout(t,0)}function nc(t){return clearTimeout(t)}Xa.prototype={constructor:Xa,_isOutsideThisEl:function(t){this.el.contains(t)||t===this.el||(Aa=null)},_getDirection:function(t,e){return"function"==typeof this.options.direction?this.options.direction.call(this,t,e,la):this.options.direction},_onTapStart:function(t){if(t.cancelable){var e=this,i=this.el,n=this.options,o=n.preventOnFilter,s=t.type,r=t.touches&&t.touches[0]||t.pointerType&&"touch"===t.pointerType&&t,l=(r||t).target,a=t.target.shadowRoot&&(t.path&&t.path[0]||t.composedPath&&t.composedPath()[0])||l,c=n.filter;if(function(t){Fa.length=0;var e=t.getElementsByTagName("input"),i=e.length;for(;i--;){var n=e[i];n.checked&&Fa.push(n)}}(i),!la&&!(/mousedown|pointerdown/.test(s)&&0!==t.button||n.disabled)&&!a.isContentEditable&&(this.nativeDraggable||!Tl||!l||"SELECT"!==l.tagName.toUpperCase())&&!((l=ql(l,n.draggable,i,!1))&&l.animated||ua===l)){if(ga=Ul(l),ba=Ul(l,n.draggable),"function"==typeof c){if(c.call(this,t,l,this))return ra({sortable:e,rootEl:a,name:"filter",targetEl:l,toEl:i,fromEl:i}),sa("filter",e,{evt:t}),void(o&&t.preventDefault())}else if(c&&(c=c.split(",").some((function(n){if(n=ql(a,n.trim(),i,!1))return ra({sortable:e,rootEl:n,name:"filter",targetEl:l,fromEl:i,toEl:i}),sa("filter",e,{evt:t}),!0}))))return void(o&&t.preventDefault());n.handle&&!ql(a,n.handle,i,!1)||this._prepareDragStart(t,r,l)}}},_prepareDragStart:function(t,e,i){var n,o=this,s=o.el,r=o.options,l=s.ownerDocument;if(i&&!la&&i.parentNode===s){var a=Hl(i);if(ha=s,aa=(la=i).parentNode,da=la.nextSibling,ua=i,ya=r.group,Xa.dragged=la,Ca={target:la,clientX:(e||t).clientX,clientY:(e||t).clientY},Ta=Ca.clientX-a.left,Ea=Ca.clientY-a.top,this._lastX=(e||t).clientX,this._lastY=(e||t).clientY,la.style["will-change"]="all",n=function(){sa("delayEnded",o,{evt:t}),Xa.eventCanceled?o._onDrop():(o._disableDelayedDragEvents(),!Sl&&o.nativeDraggable&&(la.draggable=!0),o._triggerDragStart(t,e),ra({sortable:o,name:"choose",originalEvent:t}),Rl(la,r.chosenClass,!0))},r.ignore.split(",").forEach((function(t){Fl(la,t.trim(),Qa)})),Dl(l,"dragover",Za),Dl(l,"mousemove",Za),Dl(l,"touchmove",Za),r.supportPointer?(Dl(l,"pointerup",o._onDrop),!this.nativeDraggable&&Dl(l,"pointercancel",o._onDrop)):(Dl(l,"mouseup",o._onDrop),Dl(l,"touchend",o._onDrop),Dl(l,"touchcancel",o._onDrop)),Sl&&this.nativeDraggable&&(this.options.touchStartThreshold=4,la.draggable=!0),sa("delayStart",this,{evt:t}),!r.delay||r.delayOnTouchOnly&&!e||this.nativeDraggable&&(kl||xl))n();else{if(Xa.eventCanceled)return void this._onDrop();r.supportPointer?(Dl(l,"pointerup",o._disableDelayedDrag),Dl(l,"pointercancel",o._disableDelayedDrag)):(Dl(l,"mouseup",o._disableDelayedDrag),Dl(l,"touchend",o._disableDelayedDrag),Dl(l,"touchcancel",o._disableDelayedDrag)),Dl(l,"mousemove",o._delayedDragTouchMoveHandler),Dl(l,"touchmove",o._delayedDragTouchMoveHandler),r.supportPointer&&Dl(l,"pointermove",o._delayedDragTouchMoveHandler),o._dragStartTimer=setTimeout(n,r.delay)}}},_delayedDragTouchMoveHandler:function(t){var e=t.touches?t.touches[0]:t;Math.max(Math.abs(e.clientX-this._lastX),Math.abs(e.clientY-this._lastY))>=Math.floor(this.options.touchStartThreshold/(this.nativeDraggable&&window.devicePixelRatio||1))&&this._disableDelayedDrag()},_disableDelayedDrag:function(){la&&Qa(la),clearTimeout(this._dragStartTimer),this._disableDelayedDragEvents()},_disableDelayedDragEvents:function(){var t=this.el.ownerDocument;Il(t,"mouseup",this._disableDelayedDrag),Il(t,"touchend",this._disableDelayedDrag),Il(t,"touchcancel",this._disableDelayedDrag),Il(t,"pointerup",this._disableDelayedDrag),Il(t,"pointercancel",this._disableDelayedDrag),Il(t,"mousemove",this._delayedDragTouchMoveHandler),Il(t,"touchmove",this._delayedDragTouchMoveHandler),Il(t,"pointermove",this._delayedDragTouchMoveHandler)},_triggerDragStart:function(t,e){e=e||"touch"==t.pointerType&&t,!this.nativeDraggable||e?this.options.supportPointer?Dl(document,"pointermove",this._onTouchMove):Dl(document,e?"touchmove":"mousemove",this._onTouchMove):(Dl(la,"dragend",this),Dl(ha,"dragstart",this._onDragStart));try{document.selection?ic((function(){document.selection.empty()})):window.getSelection().removeAllRanges()}catch(t){}},_dragStarted:function(t,e){if(Ba=!1,ha&&la){sa("dragStarted",this,{evt:e}),this.nativeDraggable&&Dl(document,"dragover",Ka);var i=this.options;!t&&Rl(la,i.dragClass,!1),Rl(la,i.ghostClass,!0),Xa.active=this,t&&this._appendGhost(),ra({sortable:this,name:"start",originalEvent:e})}else this._nulling()},_emulateDragOver:function(){if(xa){this._lastX=xa.clientX,this._lastY=xa.clientY,Ya();for(var t=document.elementFromPoint(xa.clientX,xa.clientY),e=t;t&&t.shadowRoot&&(t=t.shadowRoot.elementFromPoint(xa.clientX,xa.clientY))!==e;)e=t;if(la.parentNode[Ql]._isOutsideThisEl(t),e)do{if(e[Ql]){if(e[Ql]._onDragOver({clientX:xa.clientX,clientY:xa.clientY,target:t,rootEl:e})&&!this.options.dragoverBubble)break}t=e}while(e=Bl(e));Ga()}},_onTouchMove:function(t){if(Ca){var e=this.options,i=e.fallbackTolerance,n=e.fallbackOffset,o=t.touches?t.touches[0]:t,s=ca&&_l(ca,!0),r=ca&&s&&s.a,l=ca&&s&&s.d,a=Ha&&Oa&&jl(Oa),c=(o.clientX-Ca.clientX+n.x)/(r||1)+(a?a[0]-Pa[0]:0)/(r||1),h=(o.clientY-Ca.clientY+n.y)/(l||1)+(a?a[1]-Pa[1]:0)/(l||1);if(!Xa.active&&!Ba){if(i&&Math.max(Math.abs(o.clientX-this._lastX),Math.abs(o.clientY-this._lastY))o.right+s||t.clientY>n.bottom&&t.clientX>n.left:t.clientY>o.bottom+s||t.clientX>n.right&&t.clientY>n.top}(t,o,this)&&!g.animated){if(g===la)return O(!1);if(g&&s===t.target&&(r=g),r&&(i=Hl(r)),!1!==Ja(ha,s,la,e,r,i,t,!!r))return I(),g&&g.nextSibling?s.insertBefore(la,g.nextSibling):s.appendChild(la),aa=s,B(),O(!0)}else if(g&&function(t,e,i){var n=Hl($l(i.el,0,i.options,!0)),o=Jl(i.el,i.options,ca),s=10;return e?t.clientXh+c*s/2:ad-Ia)return-Da}else if(a>h+c*(1-o)/2&&ad-c*s/2))return a>h+c/2?1:-1;return 0}(t,r,i,o,C?1:l.swapThreshold,null==l.invertedSwapThreshold?l.swapThreshold:l.invertedSwapThreshold,Ra,Aa===r),0!==b){var T=Ul(la);do{T-=b,y=aa.children[T]}while(y&&("none"===Pl(y,"display")||y===ca))}if(0===b||y===r)return O(!1);Aa=r,Da=b;var E=r.nextElementSibling,M=!1,A=Ja(ha,s,la,e,r,i,t,M=1===b);if(!1!==A)return 1!==A&&-1!==A||(M=1===A),_a=!0,setTimeout(tc,30),I(),M&&!E?s.appendChild(la):r.parentNode.insertBefore(la,M?E:r),k&&Kl(k,0,S-k.scrollTop),aa=la.parentNode,void 0===v||Ra||(Ia=Math.abs(v-Hl(r)[x])),B(),O(!0)}if(s.contains(la))return O(!1)}return!1}function D(l,a){sa(l,p,fl({evt:t,isOwner:h,axis:o?"vertical":"horizontal",revert:n,dragRect:e,targetRect:i,canSort:d,fromSortable:u,target:r,completed:O,onMove:function(i,n){return Ja(ha,s,la,e,i,Hl(i),t,n)},changed:B},a))}function I(){D("dragOverAnimationCapture"),p.captureAnimationState(),p!==u&&u.captureAnimationState()}function O(e){return D("dragOverCompleted",{insertion:e}),e&&(h?c._hideClone():c._showClone(p),p!==u&&(Rl(la,wa?wa.options.ghostClass:c.options.ghostClass,!1),Rl(la,l.ghostClass,!0)),wa!==p&&p!==Xa.active?wa=p:p===Xa.active&&wa&&(wa=null),u===p&&(p._ignoreWhileAnimating=r),p.animateAll((function(){D("dragOverAnimationComplete"),p._ignoreWhileAnimating=null})),p!==u&&(u.animateAll(),u._ignoreWhileAnimating=null)),(r===la&&!la.animated||r===s&&!r.animated)&&(Aa=null),l.dragoverBubble||t.rootEl||r===document||(la.parentNode[Ql]._isOutsideThisEl(t.target),!e&&Za(t)),!l.dragoverBubble&&t.stopPropagation&&t.stopPropagation(),m=!0}function B(){fa=Ul(la),va=Ul(la,l.draggable),ra({sortable:p,name:"change",toEl:s,newIndex:fa,newDraggableIndex:va,originalEvent:t})}},_ignoreWhileAnimating:null,_offMoveEvents:function(){Il(document,"mousemove",this._onTouchMove),Il(document,"touchmove",this._onTouchMove),Il(document,"pointermove",this._onTouchMove),Il(document,"dragover",Za),Il(document,"mousemove",Za),Il(document,"touchmove",Za)},_offUpEvents:function(){var t=this.el.ownerDocument;Il(t,"mouseup",this._onDrop),Il(t,"touchend",this._onDrop),Il(t,"pointerup",this._onDrop),Il(t,"pointercancel",this._onDrop),Il(t,"touchcancel",this._onDrop),Il(document,"selectstart",this)},_onDrop:function(t){var e=this.el,i=this.options;fa=Ul(la),va=Ul(la,i.draggable),sa("drop",this,{evt:t}),aa=la&&la.parentNode,fa=Ul(la),va=Ul(la,i.draggable),Xa.eventCanceled||(Ba=!1,Ra=!1,La=!1,clearInterval(this._loopId),clearTimeout(this._dragStartTimer),nc(this.cloneId),nc(this._dragStartId),this.nativeDraggable&&(Il(document,"drop",this),Il(e,"dragstart",this._onDragStart)),this._offMoveEvents(),this._offUpEvents(),Tl&&Pl(document.body,"user-select",""),Pl(la,"transform",""),t&&(Ma&&(t.cancelable&&t.preventDefault(),!i.dropBubble&&t.stopPropagation()),ca&&ca.parentNode&&ca.parentNode.removeChild(ca),(ha===aa||wa&&"clone"!==wa.lastPutMode)&&pa&&pa.parentNode&&pa.parentNode.removeChild(pa),la&&(this.nativeDraggable&&Il(la,"dragend",this),Qa(la),la.style["will-change"]="",Ma&&!Ba&&Rl(la,wa?wa.options.ghostClass:this.options.ghostClass,!1),Rl(la,this.options.chosenClass,!1),ra({sortable:this,name:"unchoose",toEl:aa,newIndex:null,newDraggableIndex:null,originalEvent:t}),ha!==aa?(fa>=0&&(ra({rootEl:aa,name:"add",toEl:aa,fromEl:ha,originalEvent:t}),ra({sortable:this,name:"remove",toEl:aa,originalEvent:t}),ra({rootEl:aa,name:"sort",toEl:aa,fromEl:ha,originalEvent:t}),ra({sortable:this,name:"sort",toEl:aa,originalEvent:t})),wa&&wa.save()):fa!==ga&&fa>=0&&(ra({sortable:this,name:"update",toEl:aa,originalEvent:t}),ra({sortable:this,name:"sort",toEl:aa,originalEvent:t})),Xa.active&&(null!=fa&&-1!==fa||(fa=ga,va=ba),ra({sortable:this,name:"end",toEl:aa,originalEvent:t}),this.save())))),this._nulling()},_nulling:function(){sa("nulling",this),ha=la=aa=ca=da=pa=ua=ma=Ca=xa=Ma=fa=va=ga=ba=Aa=Da=wa=ya=Xa.dragged=Xa.ghost=Xa.clone=Xa.active=null,Fa.forEach((function(t){t.checked=!0})),Fa.length=ka=Sa=0},handleEvent:function(t){switch(t.type){case"drop":case"dragend":this._onDrop(t);break;case"dragenter":case"dragover":la&&(this._onDragOver(t),function(t){t.dataTransfer&&(t.dataTransfer.dropEffect="move");t.cancelable&&t.preventDefault()}(t));break;case"selectstart":t.preventDefault()}},toArray:function(){for(var t,e=[],i=this.el.children,n=0,o=i.length,s=this.options;n{i.createEl("p",{text:t})}));const n=i.createDiv("confirm-modal-buttons");new t.ButtonComponent(n).setButtonText(this.options.cancelText).onClick((()=>this.close())),new t.ButtonComponent(n).setButtonText(this.options.confirmText).setCta().onClick((()=>e(this,void 0,void 0,(function*(){yield this.options.onConfirm(),this.close()}))))}onClose(){const{contentEl:t}=this;t.empty()}static show(t,e){new vc(t,e).open()}}class yc extends t.Modal{constructor(t,e){super(t),this.changelogContent="",this.changelogLoaded=!1,this.plugin=e}loadChangelog(){return e(this,void 0,void 0,(function*(){try{const e=yield t.request({url:"https://raw.githubusercontent.com/PKM-er/obsidian-editing-toolbar/master/CHANGELOG.md",method:"GET"});if(!e)throw new Error("无法获取 Changelog 内容");{const t=e.split("\n");let i="",n=[],o=!1;for(const e of t)if(e.startsWith("## ")&&!i)i=e.substring(3).trim(),o=!0,n.push(e);else{if(e.startsWith("## ")&&o)break;o&&n.push(e)}this.changelogContent=n.join("\n")}}catch(t){console.error("加载 Changelog 时出错:",t),this.changelogContent="### 无法加载更新说明\n\n请[点击此处查看最新更新说明](https://github.com/PKM-er/obsidian-editing-toolbar/blob/master/CHANGELOG.md)"}this.changelogLoaded=!0,this.updateChangelogDisplay()}))}updateChangelogDisplay(){this.changelogContainer&&this.changelogContentEl&&this.changelogLoaded&&(this.changelogContentEl.empty(),t.MarkdownRenderer.renderMarkdown(this.changelogContent,this.changelogContentEl,"",this.plugin))}fixCommandIds(){return e(this,void 0,void 0,(function*(){try{const e={"editor:toggle-numbered-list":"editing-toolbar:toggle-numbered-list","editor:toggle-bullet-list":"editing-toolbar:toggle-bullet-list","editor:toggle-highlight":"editing-toolbar:toggle-highlight","toggle-highlight":"editing-toolbar:toggle-highlight","editing-toolbar:editor:toggle-bold":"editing-toolbar:toggle-bold","editing-toolbar:editor:toggle-italics":"editing-toolbar:toggle-italics","editing-toolbar:editor:toggle-strikethrough":"editing-toolbar:toggle-strikethrough","editing-toolbar:editor:toggle-inline-math":"editing-toolbar:toggle-inline-math","editing-toolbar:editor:insert-callout":"editing-toolbar:insert-callout","editing-toolbar:editor:insert-link":"editing-toolbar:insert-link","cMenuToolbar-Divider-Line":"editingToolbar-Divider-Line"};let i=!1;const n=this.plugin.settings,o=t=>{t&&Array.isArray(t)&&t.forEach((t=>{t.id&&e[t.id]&&(t.id=e[t.id],i=!0),"editing-toolbar:format-eraser"===t.id&&(t.icon="eraser",i=!0),"editing-toolbar:change-font-color"===t.id&&(t.icon='',i=!0),t.SubmenuCommands&&o(t.SubmenuCommands)}))},s=t=>{if(!t||!Array.isArray(t))return!1;for(const e of t){if("editing-toolbar:toggle-format-brush"===e.id)return!0;if(e.SubmenuCommands){if(s(e.SubmenuCommands))return!0}}return!1},r=t=>{if(!t||!Array.isArray(t))return!1;if(!s(t)&&t.length>=2){const e={id:"editing-toolbar:toggle-format-brush",name:"Format Brush",icon:"paintbrush"};return t.splice(2,0,e),!0}return!1};n.menuCommands&&(o(n.menuCommands),r(n.menuCommands)&&(i=!0)),n.enableMultipleConfig&&(n.followingCommands&&(o(n.followingCommands),r(n.followingCommands)&&(i=!0)),n.topCommands&&(o(n.topCommands),r(n.topCommands)&&(i=!0)),n.fixedCommands&&(o(n.fixedCommands),r(n.fixedCommands)&&(i=!0)),n.mobileCommands&&(o(n.mobileCommands),r(n.mobileCommands)&&(i=!0))),i?(yield this.plugin.saveSettings(),new t.Notice(Wr("Command IDs have been successfully repaired!")),dispatchEvent(new Event("editingToolbar-NewCommand"))):new t.Notice(Wr("No command IDs need to be repaired"))}catch(e){console.error("修复命令ID时出错:",e),new t.Notice(Wr("Error repairing command IDs, please check the console for details"))}}))}reloadPlugin(t){return e(this,void 0,void 0,(function*(){const{plugins:e}=this.app;try{yield e.disablePlugin(t),yield e.enablePlugin(t)}catch(t){console.error(t)}}))}restoreDefaultSettings(){return e(this,void 0,void 0,(function*(){try{const e=this.plugin.settings.lastVersion,i=this.plugin.settings.customCommands;this.plugin.settings=Object.assign(Object.assign({},Qr),{lastVersion:e,customCommands:i}),yield this.plugin.saveSettings(),new t.Notice(Wr("Successfully restored default settings! (Custom commands preserved)")),this.reloadPlugin(this.plugin.manifest.id),this.close()}catch(e){console.error("恢复默认设置时出错:",e),new t.Notice(Wr("Error restoring default settings, please check the console for details"))}}))}onOpen(){const{contentEl:i}=this;i.createEl("h2",{text:this.plugin.manifest.version+"⚡Tips"}),i.createEl("p",{text:Wr("Notice:")});const n=i.createEl("ul");n.createEl("li",{text:Wr("⚠️This update is not compatible with 2.x version command ids, please click [Repair command] to be compatible")}),n.createEl("li",{text:Wr("⚠️If you want to restore the default settings, please click [Restore default settings]")}),this.changelogContainer=i.createDiv({cls:"changelog-container"}),this.changelogContainer.createEl("h3",{text:Wr("Latest Changes")}),this.changelogContentEl=this.changelogContainer.createDiv({cls:"changelog-content"}),this.changelogContentEl.setText(Wr("Loading changelog...")),setTimeout((()=>{this.loadChangelog()}),100),new t.Setting(i).setName(Wr("🔧Data repair")).setDesc(Wr("This update changed the ID of some commands, please click this button to repair the commands to ensure the toolbar works properly")).addButton((t=>t.setButtonText(Wr("Repair command ID")).onClick((()=>e(this,void 0,void 0,(function*(){yield this.fixCommandIds()})))))),new t.Setting(i).setName(Wr("🔄Restore default settings")).setDesc(Wr("This will reset all your custom configurations, but custom commands will be preserved")).addButton((t=>t.setButtonText(Wr("Restore default")).onClick((()=>e(this,void 0,void 0,(function*(){vc.show(this.app,{message:Wr("Are you sure you want to restore all settings to default? But custom commands will be preserved."),onConfirm:()=>e(this,void 0,void 0,(function*(){yield this.restoreDefaultSettings()}))})})))))),new t.Setting(i).setName(Wr("📋View full changelog")).setDesc(Wr("Open the complete changelog in your browser")).addButton((t=>t.setButtonText(Wr("Open changelog")).onClick((()=>{window.open("https://github.com/PKM-er/obsidian-editing-toolbar/blob/master/CHANGELOG.md","_blank")})))),new t.Setting(i).addButton((t=>t.setButtonText(Wr("Close")).onClick((()=>{this.close()})))),i.createEl("style",{text:"\n .changelog-container {\n margin-top: 20px;\n margin-bottom: 20px;\n padding: 10px;\n border: 1px solid var(--background-modifier-border);\n border-radius: 5px;\n max-height: 200px;\n overflow-y: auto;\n }\n .changelog-content {\n padding: 0 10px;\n }\n .changelog-content a {\n text-decoration: underline;\n }\n "})}onClose(){const{contentEl:t}=this;t.empty()}}function wc(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t} /*! Pickr 1.8.4 MIT | https://github.com/Simonwep/pickr */ var Cc=function(t){var e={exports:{}};return t(e,e.exports),e.exports}((function(t,e){self,t.exports=(()=>{var t={d:(e,i)=>{for(var n in i)t.o(i,n)&&!t.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:i[n]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.d(e,{default:()=>O});var i={};function n(t,e,i,n){let o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};e instanceof HTMLCollection||e instanceof NodeList?e=Array.from(e):Array.isArray(e)||(e=[e]),Array.isArray(i)||(i=[i]);for(const s of e)for(const e of i)s[t](e,n,{capture:!1,...o});return Array.prototype.slice.call(arguments,1)}t.r(i),t.d(i,{adjustableInputNumbers:()=>h,createElementFromString:()=>r,createFromTemplate:()=>l,eventPath:()=>a,off:()=>s,on:()=>o,resolveElement:()=>c});const o=n.bind(null,"addEventListener"),s=n.bind(null,"removeEventListener");function r(t){const e=document.createElement("div");return e.innerHTML=t.trim(),e.firstElementChild}function l(t){const e=(t,e)=>{const i=t.getAttribute(e);return t.removeAttribute(e),i},i=function(t){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const o=e(t,":obj"),s=e(t,":ref"),r=o?n[o]={}:n;s&&(n[s]=t);for(const n of Array.from(t.children)){const t=e(n,":arr"),o=i(n,t?{}:r);t&&(r[t]||(r[t]=[])).push(Object.keys(o).length?o:n)}return n};return i(r(t))}function a(t){let e=t.path||t.composedPath&&t.composedPath();if(e)return e;let i=t.target.parentElement;for(e=[t.target,i];i=i.parentElement;)e.push(i);return e.push(document,window),e}function c(t){return t instanceof Element?t:"string"==typeof t?t.split(/>>/g).reduce(((t,e,i,n)=>(t=t.querySelector(e),i1&&void 0!==arguments[1]?arguments[1]:t=>t;function i(i){const n=[.001,.01,.1][Number(i.shiftKey||2*i.ctrlKey)]*(i.deltaY<0?1:-1);let o=0,s=t.selectionStart;t.value=t.value.replace(/[\d.]+/g,((t,i)=>i<=s&&i+t.length>=s?(s=i,e(Number(t),n,o)):(o++,t))),t.focus(),t.setSelectionRange(s,s),i.preventDefault(),t.dispatchEvent(new Event("input"))}o(t,"focus",(()=>o(window,"wheel",i,{passive:!1}))),o(t,"blur",(()=>s(window,"wheel",i)))}const{min:d,max:u,floor:p,round:m}=Math;function g(t,e,i){e/=100,i/=100;const n=p(t=t/360*6),o=t-n,s=i*(1-e),r=i*(1-o*e),l=i*(1-(1-o)*e),a=n%6;return[255*[i,r,s,s,l,i][a],255*[l,i,i,r,s,s][a],255*[s,s,l,i,i,r][a]]}function f(t,e,i){return g(t,e,i).map((t=>m(t).toString(16).padStart(2,"0")))}function b(t,e,i){const n=g(t,e,i),o=n[0]/255,s=n[1]/255,r=n[2]/255,l=d(1-o,1-s,1-r);return[100*(1===l?0:(1-o-l)/(1-l)),100*(1===l?0:(1-s-l)/(1-l)),100*(1===l?0:(1-r-l)/(1-l)),100*l]}function v(t,e,i){const n=(2-(e/=100))*(i/=100)/2;return 0!==n&&(e=1===n?0:n<.5?e*i/(2*n):e*i/(2-2*n)),[t,100*e,100*n]}function y(t,e,i){const n=d(t/=255,e/=255,i/=255),o=u(t,e,i),s=o-n;let r,l;if(0===s)r=l=0;else{l=s/o;const n=((o-t)/6+s/2)/s,a=((o-e)/6+s/2)/s,c=((o-i)/6+s/2)/s;t===o?r=c-a:e===o?r=1/3+n-c:i===o&&(r=2/3+a-n),r<0?r+=1:r>1&&(r-=1)}return[360*r,100*l,100*o]}function w(t,e,i,n){return e/=100,i/=100,[...y(255*(1-d(1,(t/=100)*(1-(n/=100))+n)),255*(1-d(1,e*(1-n)+n)),255*(1-d(1,i*(1-n)+n)))]}function C(t,e,i){e/=100;const n=2*(e*=(i/=100)<.5?i:1-i)/(i+e)*100,o=100*(i+e);return[t,isNaN(n)?0:n,o]}function x(t){return y(...t.match(/.{2}/g).map((t=>parseInt(t,16))))}function k(t){t=t.match(/^[a-zA-Z]+$/)?function(t){if("black"===t.toLowerCase())return"#000";const e=document.createElement("canvas").getContext("2d");return e.fillStyle=t,"#000"===e.fillStyle?null:e.fillStyle}(t):t;const e={cmyk:/^cmyk[\D]+([\d.]+)[\D]+([\d.]+)[\D]+([\d.]+)[\D]+([\d.]+)/i,rgba:/^((rgba)|rgb)[\D]+([\d.]+)[\D]+([\d.]+)[\D]+([\d.]+)[\D]*?([\d.]+|$)/i,hsla:/^((hsla)|hsl)[\D]+([\d.]+)[\D]+([\d.]+)[\D]+([\d.]+)[\D]*?([\d.]+|$)/i,hsva:/^((hsva)|hsv)[\D]+([\d.]+)[\D]+([\d.]+)[\D]+([\d.]+)[\D]*?([\d.]+|$)/i,hexa:/^#?(([\dA-Fa-f]{3,4})|([\dA-Fa-f]{6})|([\dA-Fa-f]{8}))$/i},i=t=>t.map((t=>/^(|\d+)\.\d+|\d+$/.test(t)?Number(t):void 0));let n;t:for(const o in e){if(!(n=e[o].exec(t)))continue;const s=t=>!!n[2]==("number"==typeof t);switch(o){case"cmyk":{const[,t,e,s,r]=i(n);if(t>100||e>100||s>100||r>100)break t;return{values:w(t,e,s,r),type:o}}case"rgba":{const[,,,t,e,r,l]=i(n);if(t>255||e>255||r>255||l<0||l>1||!s(l))break t;return{values:[...y(t,e,r),l],a:l,type:o}}case"hexa":{let[,t]=n;4!==t.length&&3!==t.length||(t=t.split("").map((t=>t+t)).join(""));const e=t.substring(0,6);let i=t.substring(6);return i=i?parseInt(i,16)/255:void 0,{values:[...x(e),i],a:i,type:o}}case"hsla":{const[,,,t,e,r,l]=i(n);if(t>360||e>100||r>100||l<0||l>1||!s(l))break t;return{values:[...C(t,e,r),l],a:l,type:o}}case"hsva":{const[,,,t,e,r,l]=i(n);if(t>360||e>100||r>100||l<0||l>1||!s(l))break t;return{values:[t,e,r,l],a:l,type:o}}}}return{values:null,type:null}}function S(){const t=(t,e)=>function(){let i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:-1;return e(~i?t.map((t=>Number(t.toFixed(i)))):t)},e={h:arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,s:arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,v:arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,a:arguments.length>3&&void 0!==arguments[3]?arguments[3]:1,toHSVA(){const i=[e.h,e.s,e.v,e.a];return i.toString=t(i,(t=>`hsva(${t[0]}, ${t[1]}%, ${t[2]}%, ${e.a})`)),i},toHSLA(){const i=[...v(e.h,e.s,e.v),e.a];return i.toString=t(i,(t=>`hsla(${t[0]}, ${t[1]}%, ${t[2]}%, ${e.a})`)),i},toRGBA(){const i=[...g(e.h,e.s,e.v),e.a];return i.toString=t(i,(t=>`rgba(${t[0]}, ${t[1]}, ${t[2]}, ${e.a})`)),i},toCMYK(){const i=b(e.h,e.s,e.v);return i.toString=t(i,(t=>`cmyk(${t[0]}%, ${t[1]}%, ${t[2]}%, ${t[3]}%)`)),i},toHEXA(){const t=f(e.h,e.s,e.v),i=e.a>=1?"":Number((255*e.a).toFixed(0)).toString(16).toUpperCase().padStart(2,"0");return i&&t.push(i),t.toString=()=>`#${t.join("").toUpperCase()}`,t},clone:()=>S(e.h,e.s,e.v,e.a)};return e}const T=t=>Math.max(Math.min(t,1),0);function E(t){const e={options:Object.assign({lock:null,onchange:()=>0,onstop:()=>0},t),_keyboard(t){const{options:i}=e,{type:n,key:o}=t;if(document.activeElement===i.wrapper){const{lock:i}=e.options,s="ArrowUp"===o,r="ArrowRight"===o,l="ArrowDown"===o,a="ArrowLeft"===o;if("keydown"===n&&(s||r||l||a)){let n=0,o=0;"v"===i?n=s||r?1:-1:"h"===i?n=s||r?-1:1:(o=s?-1:l?1:0,n=a?-1:r?1:0),e.update(T(e.cache.x+.01*n),T(e.cache.y+.01*o)),t.preventDefault()}else o.startsWith("Arrow")&&(e.options.onstop(),t.preventDefault())}},_tapstart(t){o(document,["mouseup","touchend","touchcancel"],e._tapstop),o(document,["mousemove","touchmove"],e._tapmove),t.cancelable&&t.preventDefault(),e._tapmove(t)},_tapmove(t){const{options:i,cache:n}=e,{lock:o,element:s,wrapper:r}=i,l=r.getBoundingClientRect();let a=0,c=0;if(t){const e=t&&t.touches&&t.touches[0];a=t?(e||t).clientX:0,c=t?(e||t).clientY:0,al.left+l.width&&(a=l.left+l.width),cl.top+l.height&&(c=l.top+l.height),a-=l.left,c-=l.top}else n&&(a=n.x*l.width,c=n.y*l.height);"h"!==o&&(s.style.left=`calc(${a/l.width*100}% - ${s.offsetWidth/2}px)`),"v"!==o&&(s.style.top=`calc(${c/l.height*100}% - ${s.offsetHeight/2}px)`),e.cache={x:a/l.width,y:c/l.height};const h=T(a/l.width),d=T(c/l.height);switch(o){case"v":return i.onchange(h);case"h":return i.onchange(d);default:return i.onchange(h,d)}},_tapstop(){e.options.onstop(),s(document,["mouseup","touchend","touchcancel"],e._tapstop),s(document,["mousemove","touchmove"],e._tapmove)},trigger(){e._tapmove()},update(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;const{left:n,top:o,width:s,height:r}=e.options.wrapper.getBoundingClientRect();"h"===e.options.lock&&(i=t),e._tapmove({clientX:n+s*t,clientY:o+r*i})},destroy(){const{options:t,_tapstart:i,_keyboard:n}=e;s(document,["keydown","keyup"],n),s([t.wrapper,t.element],"mousedown",i),s([t.wrapper,t.element],"touchstart",i,{passive:!1})}},{options:i,_tapstart:n,_keyboard:r}=e;return o([i.wrapper,i.element],"mousedown",n),o([i.wrapper,i.element],"touchstart",n,{passive:!1}),o(document,["keydown","keyup"],r),e}function M(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};t=Object.assign({onchange:()=>0,className:"",elements:[]},t);const e=o(t.elements,"click",(e=>{t.elements.forEach((i=>i.classList[e.target===i?"add":"remove"](t.className))),t.onchange(e),e.stopPropagation()}));return{destroy:()=>s(...e)}}const A={variantFlipOrder:{start:"sme",middle:"mse",end:"ems"},positionFlipOrder:{top:"tbrl",right:"rltb",bottom:"btrl",left:"lrbt"},position:"bottom",margin:8},D=(t,e,i)=>{const{container:n,margin:o,position:s,variantFlipOrder:r,positionFlipOrder:l}={container:document.documentElement.getBoundingClientRect(),...A,...i},{left:a,top:c}=e.style;e.style.left="0",e.style.top="0";const h=t.getBoundingClientRect(),d=e.getBoundingClientRect(),u={t:h.top-d.height-o,b:h.bottom+o,r:h.right+o,l:h.left-d.width-o},p={vs:h.left,vm:h.left+h.width/2+-d.width/2,ve:h.left+h.width-d.width,hs:h.top,hm:h.bottom-h.height/2-d.height/2,he:h.bottom-d.height},[m,g="middle"]=s.split("-"),f=l[m],b=r[g],{top:v,left:y,bottom:w,right:C}=n;for(const t of f){const i="t"===t||"b"===t,n=u[t],[o,s]=i?["top","left"]:["left","top"],[r,l]=i?[d.height,d.width]:[d.width,d.height],[a,c]=i?[w,C]:[C,w],[h,m]=i?[v,y]:[y,v];if(!(na))for(const r of b){const a=p[(i?"v":"h")+r];if(!(ac))return e.style[s]=a-d[s]+"px",e.style[o]=n-d[o]+"px",t+r}}return e.style.left=a,e.style.top=c,null};function I(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class O{constructor(t){I(this,"_initializingActive",!0),I(this,"_recalc",!0),I(this,"_nanopop",null),I(this,"_root",null),I(this,"_color",S()),I(this,"_lastColor",S()),I(this,"_swatchColors",[]),I(this,"_setupAnimationFrame",null),I(this,"_eventListener",{init:[],save:[],hide:[],show:[],clear:[],change:[],changestop:[],cancel:[],swatchselect:[]}),this.options=t=Object.assign({...O.DEFAULT_OPTIONS},t);const{swatches:e,components:i,theme:n,sliders:o,lockOpacity:s,padding:r}=t;["nano","monolith"].includes(n)&&!o&&(t.sliders="h"),i.interaction||(i.interaction={});const{preview:l,opacity:a,hue:c,palette:h}=i;i.opacity=!s&&a,i.palette=h||l||a||c,this._preBuild(),this._buildComponents(),this._bindEvents(),this._finalBuild(),e&&e.length&&e.forEach((t=>this.addSwatch(t)));const{button:d,app:u}=this._root;this._nanopop=((t,e,i)=>{const n="object"!=typeof t||t instanceof HTMLElement?{reference:t,popper:e,...i}:t;return{update(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:n;const{reference:e,popper:i}=Object.assign(n,t);if(!i||!e)throw new Error("Popper- or reference-element missing.");return D(e,i,n)}}})(d,u,{margin:r}),d.setAttribute("role","button"),d.setAttribute("aria-label",this._t("btn:toggle"));const p=this;this._setupAnimationFrame=requestAnimationFrame((function e(){if(!u.offsetWidth)return p._setupAnimationFrame=requestAnimationFrame(e);p.setColor(t.default),p._rePositioningPicker(),t.defaultRepresentation&&(p._representation=t.defaultRepresentation,p.setColorRepresentation(p._representation)),t.showAlways&&p.show(),p._initializingActive=!1,p._emit("init")}))}_preBuild(){const{options:t}=this;for(const e of["el","container"])t[e]=c(t[e]);this._root=(t=>{const{components:e,useAsButton:i,inline:n,appClass:o,theme:s,lockOpacity:r}=t.options,a=t=>t?"":'style="display:none" hidden',c=e=>t._t(e),h=l(`\n
\n\n ${i?"":''}\n\n
\n
\n
\n \n
\n
\n\n
\n
\n
\n
\n\n
\n
\n
\n
\n\n
\n
\n
\n
\n
\n\n
\n\n
\n \n\n \n \n \n \n \n\n \n \n \n
\n
\n
\n `),d=h.interaction;return d.options.find((t=>!t.hidden&&!t.classList.add("active"))),d.type=()=>d.options.find((t=>t.classList.contains("active"))),h})(this),t.useAsButton&&(this._root.button=t.el),t.container.appendChild(this._root.root)}_finalBuild(){const t=this.options,e=this._root;if(t.container.removeChild(e.root),t.inline){const i=t.el.parentElement;t.el.nextSibling?i.insertBefore(e.app,t.el.nextSibling):i.appendChild(e.app)}else t.container.appendChild(e.app);t.useAsButton?t.inline&&t.el.remove():t.el.parentNode.replaceChild(e.root,t.el),t.disabled&&this.disable(),t.comparison||(e.button.style.transition="none",t.useAsButton||(e.preview.lastColor.style.transition="none")),this.hide()}_buildComponents(){const t=this,e=this.options.components,i=(t.options.sliders||"v").repeat(2),[n,o]=i.match(/^[vh]+$/g)?i:[],s=()=>this._color||(this._color=this._lastColor.clone()),r={palette:E({element:t._root.palette.picker,wrapper:t._root.palette.palette,onstop:()=>t._emit("changestop","slider",t),onchange(i,n){if(!e.palette)return;const o=s(),{_root:r,options:l}=t,{lastColor:a,currentColor:c}=r.preview;t._recalc&&(o.s=100*i,o.v=100-100*n,o.v<0&&(o.v=0),t._updateOutput("slider"));const h=o.toRGBA().toString(0);this.element.style.background=h,this.wrapper.style.background=`\n linear-gradient(to top, rgba(0, 0, 0, ${o.a}), transparent),\n linear-gradient(to left, hsla(${o.h}, 100%, 50%, ${o.a}), rgba(255, 255, 255, ${o.a}))\n `,l.comparison?l.useAsButton||t._lastColor||a.style.setProperty("--pcr-color",h):(r.button.style.setProperty("--pcr-color",h),r.button.classList.remove("clear"));const d=o.toHEXA().toString();for(const{el:e,color:i}of t._swatchColors)e.classList[d===i.toHEXA().toString()?"add":"remove"]("pcr-active");c.style.setProperty("--pcr-color",h)}}),hue:E({lock:"v"===o?"h":"v",element:t._root.hue.picker,wrapper:t._root.hue.slider,onstop:()=>t._emit("changestop","slider",t),onchange(i){if(!e.hue||!e.palette)return;const n=s();t._recalc&&(n.h=360*i),this.element.style.backgroundColor=`hsl(${n.h}, 100%, 50%)`,r.palette.trigger()}}),opacity:E({lock:"v"===n?"h":"v",element:t._root.opacity.picker,wrapper:t._root.opacity.slider,onstop:()=>t._emit("changestop","slider",t),onchange(i){if(!e.opacity||!e.palette)return;const n=s();t._recalc&&(n.a=Math.round(100*i)/100),this.element.style.background=`rgba(0, 0, 0, ${n.a})`,r.palette.trigger()}}),selectable:M({elements:t._root.interaction.options,className:"active",onchange(e){t._representation=e.target.getAttribute("data-type").toUpperCase(),t._recalc&&t._updateOutput("swatch")}})};this._components=r}_bindEvents(){const{_root:t,options:e}=this,i=[o(t.interaction.clear,"click",(()=>this._clearColor())),o([t.interaction.cancel,t.preview.lastColor],"click",(()=>{this.setHSVA(...(this._lastColor||this._color).toHSVA(),!0),this._emit("cancel")})),o(t.interaction.save,"click",(()=>{!this.applyColor()&&!e.showAlways&&this.hide()})),o(t.interaction.result,["keyup","input"],(t=>{this.setColor(t.target.value,!0)&&!this._initializingActive&&(this._emit("change",this._color,"input",this),this._emit("changestop","input",this)),t.stopImmediatePropagation()})),o(t.interaction.result,["focus","blur"],(t=>{this._recalc="blur"===t.type,this._recalc&&this._updateOutput(null)})),o([t.palette.palette,t.palette.picker,t.hue.slider,t.hue.picker,t.opacity.slider,t.opacity.picker],["mousedown","touchstart"],(()=>this._recalc=!0),{passive:!0})];if(!e.showAlways){const n=e.closeWithKey;i.push(o(t.button,"click",(()=>this.isOpen()?this.hide():this.show())),o(document,"keyup",(t=>this.isOpen()&&(t.key===n||t.code===n)&&this.hide())),o(document,["touchstart","mousedown"],(e=>{this.isOpen()&&!a(e).some((e=>e===t.app||e===t.button))&&this.hide()}),{capture:!0}))}if(e.adjustableNumbers){const e={rgba:[255,255,255,1],hsva:[360,100,100,1],hsla:[360,100,100,1],cmyk:[100,100,100,100]};h(t.interaction.result,((t,i,n)=>{const o=e[this.getColorRepresentation().toLowerCase()];if(o){const e=o[n],s=t+(e>=100?1e3*i:i);return s<=0?0:Number((s{n.isOpen()&&(e.closeOnScroll&&n.hide(),null===t?(t=setTimeout((()=>t=null),100),requestAnimationFrame((function e(){n._rePositioningPicker(),null!==t&&requestAnimationFrame(e)}))):(clearTimeout(t),t=setTimeout((()=>t=null),100)))}),{capture:!0}))}this._eventBindings=i}_rePositioningPicker(){const{options:t}=this;if(!t.inline&&!this._nanopop.update({container:document.body.getBoundingClientRect(),position:t.position})){const t=this._root.app,e=t.getBoundingClientRect();t.style.top=(window.innerHeight-e.height)/2+"px",t.style.left=(window.innerWidth-e.width)/2+"px"}}_updateOutput(t){const{_root:e,_color:i,options:n}=this;if(e.interaction.type()){const t=`to${e.interaction.type().getAttribute("data-type")}`;e.interaction.result.value="function"==typeof i[t]?i[t]().toString(n.outputPrecision):""}!this._initializingActive&&this._recalc&&this._emit("change",i,t,this)}_clearColor(){let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];const{_root:e,options:i}=this;i.useAsButton||e.button.style.setProperty("--pcr-color","rgba(0, 0, 0, 0.15)"),e.button.classList.add("clear"),i.showAlways||this.hide(),this._lastColor=null,this._initializingActive||t||(this._emit("save",null),this._emit("clear"))}_parseLocalColor(t){const{values:e,type:i,a:n}=k(t),{lockOpacity:o}=this.options,s=void 0!==n&&1!==n;return e&&3===e.length&&(e[3]=void 0),{values:!e||o&&s?null:e,type:i}}_t(t){return this.options.i18n[t]||O.I18N_DEFAULTS[t]}_emit(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),n=1;nt(...i,this)))}on(t,e){return this._eventListener[t].push(e),this}off(t,e){const i=this._eventListener[t]||[],n=i.indexOf(e);return~n&&i.splice(n,1),this}addSwatch(t){const{values:e}=this._parseLocalColor(t);if(e){const{_swatchColors:t,_root:i}=this,n=S(...e),s=r(`