Affected files: .obsidian/plugins/colored-tags/main.js .obsidian/plugins/colored-tags/manifest.json .obsidian/plugins/colored-tags/styles.css .obsidian/plugins/copy-url-in-preview/main.js .obsidian/plugins/copy-url-in-preview/manifest.json .obsidian/plugins/dataview/main.js .obsidian/plugins/dataview/manifest.json .obsidian/plugins/dataview/styles.css .obsidian/plugins/editing-toolbar/data.json .obsidian/plugins/editing-toolbar/main.js .obsidian/plugins/editing-toolbar/manifest.json .obsidian/plugins/editing-toolbar/styles.css .obsidian/plugins/file-explorer-note-count/main.js .obsidian/plugins/file-explorer-note-count/manifest.json .obsidian/plugins/file-explorer-note-count/styles.css .obsidian/plugins/mermaid-tools/main.js .obsidian/plugins/mermaid-tools/manifest.json .obsidian/plugins/mermaid-tools/styles.css .obsidian/plugins/obsidian-advanced-uri/main.js .obsidian/plugins/obsidian-advanced-uri/manifest.json .obsidian/plugins/obsidian-auto-link-title/main.js .obsidian/plugins/obsidian-auto-link-title/manifest.json .obsidian/plugins/obsidian-excalidraw-plugin/main.js .obsidian/plugins/obsidian-excalidraw-plugin/manifest.json .obsidian/plugins/obsidian-excalidraw-plugin/styles.css .obsidian/plugins/obsidian-git/main.js .obsidian/plugins/obsidian-git/manifest.json .obsidian/plugins/obsidian-git/styles.css .obsidian/plugins/obsidian-icon-folder/main.js .obsidian/plugins/obsidian-icon-folder/manifest.json .obsidian/plugins/obsidian-icon-folder/styles.css .obsidian/plugins/obsidian-importer/main.js .obsidian/plugins/obsidian-importer/manifest.json .obsidian/plugins/obsidian-importer/styles.css .obsidian/plugins/table-editor-obsidian/main.js .obsidian/plugins/table-editor-obsidian/manifest.json .obsidian/workspace.json 2 Personal/Home Lab/Drawing 2026-01-09 15.01.17.excalidraw.md
12 lines
604 KiB
JavaScript
12 lines
604 KiB
JavaScript
"use strict";var t=require("obsidian");function e(t,e,i,o){return new(i||(i=Promise))(function(n,s){function r(t){try{l(o.next(t))}catch(t){s(t)}}function a(t){try{l(o.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i(function(t){t(e)})).then(r,a)}l((o=o.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"],o=1024;let n=0;class s{constructor(t,e){this.from=t,this.to=e}}class r{constructor(t={}){this.id=n++,this.perNode=!!t.perNode,this.deserialize=t.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")}),this.combine=t.combine||null}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 a{constructor(t,e,i,o=!1){this.tree=t,this.overlay=e,this.parser=i,this.bracketed=o}static get(t){return t&&t.props&&t.props[r.mounted.id]}}const l=Object.create(null);class c{constructor(t,e,i,o=0){this.name=t,this.props=e,this.id=i,this.flags=o}static define(t){let e=t.props&&t.props.length?Object.create(null):l,i=(t.top?1:0)|(t.skipped?2:0)|(t.error?4:0)|(null==t.name?8:0),o=new c(t.name||"",e,t.id,i);if(t.props)for(let i of t.props)if(Array.isArray(i)||(i=i(o)),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 o}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 o of i.split(" "))e[o]=t[i];return t=>{for(let i=t.prop(r.group),o=-1;o<(i?i.length:0);o++){let n=e[o<0?t.name:i[o]];if(n)return n}}}}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",t[t.EnterBracketed=16]="EnterBracketed"}(u||(u={}));class p{constructor(t,e,i,o,n){if(this.type=t,this.children=e,this.positions=i,this.length=o,this.props=null,n&&n.length){this.props=Object.create(null);for(let[t,e]of n)this.props["number"==typeof t?t:t.id]=e}}toString(){let t=a.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 o=h.get(this)||this.topNode,n=new E(o);return n.moveTo(t,e),h.set(this,n._tree),n}get topNode(){return new v(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 o=t.resolveInner(e,i),n=null;for(let t=o instanceof v?o:o.context.parent;t;t=t.parent)if(t.index<0){let s=t.parent;(n||(n=[o])).push(s.resolve(e,i)),t=s}else{let s=a.get(t.tree);if(s&&s.overlay&&s.overlay[0].from<=e&&s.overlay[s.overlay.length-1].to>=e){let r=new v(s.tree,s.overlay[0].from+t.from,-1,t);(n||(n=[o])).push(b(r,e,i,!1))}}return n?S(n):o}(this,t,e)}iterate(t){let{enter:e,leave:i,from:o=0,to:n=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<=n&&t.to>=o&&(!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:D(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:n,maxBufferLength:s=o,reused:a=[],minRepeatType:l=n.types.length}=t,c=Array.isArray(i)?new m(i,i.length):i,h=n.types,d=0,u=0;function f(t,e,i,o,r,p){let{id:m,start:k,end:S,size:T}=c,E=u,M=d;if(T<0){if(c.next(),-1==T){let e=a[m];return i.push(e),void o.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,I,O=h[m],B=k-t;if(S-k<=s&&(I=C(c.pos-e,r))){let e=new Uint16Array(I.size-I.skip),i=c.pos-I.size,o=e.length;for(;c.pos>i;)o=x(I.start,e,o);A=new g(e,S-I.start,n),B=I.start-t}else{let t=c.pos-T;c.next();let e=[],i=[],o=m>=l?m:-1,n=0,r=S;for(;c.pos>t;)o>=0&&c.id==o&&c.size>=0?(c.end<=r-s&&(v(e,i,k,n,c.end,r,o,E,M),n=e.length,r=c.end),c.next()):p>2500?b(k,t,e,i):f(k,t,e,i,o,p+1);if(o>=0&&n>0&&n<e.length&&v(e,i,k,n,k,r,o,E,M),e.reverse(),i.reverse(),o>-1&&n>0){let t=y(O,M);A=D(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),o.push(B)}function b(t,e,i,o){let r=[],a=0,l=-1;for(;c.pos>e;){let{id:t,start:e,end:i,size:o}=c;if(o>4)c.next();else{if(l>-1&&e<l)break;l<0&&(l=i-s),r.push(t,e,i),a++,c.next()}}if(a){let e=new Uint16Array(4*a),s=r[r.length-2];for(let t=r.length-3,i=0;t>=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,n)),o.push(s-t)}}function y(t,e){return(i,o,n)=>{let s,a,l=0,c=i.length-1;if(c>=0&&(s=i[c])instanceof p){if(!c&&s.type==t&&s.length==n)return s;(a=s.prop(r.lookAhead))&&(l=o[c]+s.length+a)}return w(t,i,o,n,l,e)}}function v(t,e,i,o,s,r,a,l,c){let h=[],d=[];for(;t.length>o;)h.push(t.pop()),d.push(e.pop()+i-s);t.push(w(n.types[a],h,d,r-s,l-r,c)),e.push(s-i)}function w(t,e,i,o,n,s,a){if(s){let t=[r.contextHash,s];a=a?[t].concat(a):[t]}if(n>25){let t=[r.lookAhead,n];a=a?[t].concat(a):[t]}return new p(t,e,i,o,a)}function C(t,e){let i=c.fork(),o=0,n=0,r=0,a=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=o,h.start=n,h.skip=r,r+=4,o+=4,i.next();continue}let c=i.pos-t;if(t<0||c<s||i.start<a)break;let d=i.id>=l?4:0,u=i.start;for(i.next();i.pos>c;){if(i.size<0){if(-3!=i.size&&-4!=i.size)break t;d+=4}else i.id>=l&&(d+=4);i.next()}n=u,o+=t,r+=d}return(e<0||o==t)&&(h.size=o,h.start=n,h.skip=r),h.size>4?h:void 0}function x(t,e,i){let{id:o,start:n,end:s,size:r}=c;if(c.next(),r>=0&&o<l){let a=i;if(r>4){let o=c.pos-(r-4);for(;c.pos>o;)i=x(t,e,i)}e[--i]=a,e[--i]=s-t,e[--i]=n-t,e[--i]=o}else-3==r?d=o:-4==r&&(u=o);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;e<this.buffer.length;)t.push(this.childString(e)),e=this.buffer[e+3];return t.join(",")}childString(t){let e=this.buffer[t],i=this.buffer[t+3],o=this.set.types[e],n=o.name;if(/\W/.test(n)&&!o.isError&&(n=JSON.stringify(n)),i==(t+=4))return n;let s=[];for(;t<i;)s.push(this.childString(t)),t=this.buffer[t+3];return n+"("+s.join(",")+")"}findChild(t,e,i,o,n){let{buffer:s}=this,r=-1;for(let a=t;a!=e&&!(f(n,o,s[a+1],s[a+2])&&(r=a,i>0));a=s[a+3]);return r}slice(t,e,i){let o=this.buffer,n=new Uint16Array(e-t),s=0;for(let r=t,a=0;r<e;){n[a++]=o[r++],n[a++]=o[r++]-i;let e=n[a++]=o[r++]-i;n[a++]=o[r++]-t,s=Math.max(s,e)}return new g(n,s,this.set)}}function f(t,e,i,o){switch(t){case-2:return i<e;case-1:return o>=e&&i<e;case 0:return i<e&&o>e;case 1:return i<=e&&o>e;case 2:return o>e;case 4:return!0}}function b(t,e,i,o){for(var n;t.from==t.to||(i<1?t.from>=e:t.from>e)||(i>-1?t.to<=e:t.to<e);){let e=!o&&t instanceof v&&t.index<0?null:t.parent;if(!e)return t;t=e}let s=o?0:u.IgnoreOverlays;if(o)for(let o=t,r=o.parent;r;o=r,r=o.parent)o instanceof v&&o.index<0&&(null===(n=r.enter(e,i,s))||void 0===n?void 0:n.from)!=o.from&&(t=r);for(;;){let o=t.enter(e,i,s);if(!o)return t;t=o}}class y{cursor(t=0){return new E(this,t)}getChild(t,e=null,i=null){let o=w(this,t,e,i);return o.length?o[0]:null}getChildren(t,e=null,i=null){return w(this,t,e,i)}resolve(t,e=0){return b(this,t,e,!1)}resolveInner(t,e=0){return b(this,t,e,!0)}matchContext(t){return C(this.parent,t)}enterUnfinishedNodesBefore(t){let e=this.childBefore(t),i=this;for(;e;){let t=e.lastChild;if(!t||t.to!=e.to)break;t.type.isError&&t.from==t.to?(i=e,e=t.prevSibling):e=t}return i}get node(){return this}get next(){return this.parent}}class v extends y{constructor(t,e,i,o){super(),this._tree=t,this.from=e,this.index=i,this._parent=o}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(t,e,i,o,n=0){var s;for(let r=this;;){for(let{children:l,positions:c}=r._tree,h=e>0?l.length:-1;t!=h;t+=e){let h=l[t],d=c[t]+r.from;if(n&u.EnterBracketed&&h instanceof p&&null===(null===(s=a.get(h))||void 0===s?void 0:s.overlay)&&(d>=i||d+h.length<=i)||f(o,i,d,d+h.length))if(h instanceof g){if(n&u.ExcludeBuffers)continue;let s=h.findChild(0,h.buffer.length,e,i-d,o);if(s>-1)return new k(new x(r,h,t,d),null,s)}else if(n&u.IncludeAnonymous||!h.type.isAnonymous||M(h)){let s;if(!(n&u.IgnoreMounts)&&(s=a.get(h))&&!s.overlay)return new v(s.tree,d,t,r);let l=new v(h,d,t,r);return n&u.IncludeAnonymous||!l.type.isAnonymous?l:l.nextChild(e<0?h.children.length-1:0,e,i,o,n)}}if(n&u.IncludeAnonymous||!r.type.isAnonymous)return null;if(t=r.index>=0?r.index+e:e<0?-1:r._parent._tree.children.length,r=r._parent,!r)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)}prop(t){return this._tree.prop(t)}enter(t,e,i=0){let o;if(!(i&u.IgnoreOverlays)&&(o=a.get(this._tree))&&o.overlay){let n=t-this.from,s=i&u.EnterBracketed&&o.bracketed;for(let{from:t,to:i}of o.overlay)if((e>0||s?t<=n:t<n)&&(e<0||s?i>=n:i>n))return new v(o.tree,o.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,o){let n=t.cursor(),s=[];if(!n.firstChild())return s;if(null!=i)for(let t=!1;!t;)if(t=n.type.is(i),!n.nextSibling())return s;for(;;){if(null!=o&&n.type.is(o))return s;if(n.type.is(e)&&s.push(n.node),!n.nextSibling())return null==o?s:[]}}function C(t,e,i=e.length-1){for(let o=t;i>=0;o=o.parent){if(!o)return!1;if(!o.type.isAnonymous){if(e[i]&&e[i]!=o.name)return!1;i--}}return!0}class x{constructor(t,e,i,o){this.parent=t,this.buffer=e,this.index=i,this.start=o}}class k extends y{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:o}=this.context,n=o.findChild(this.index+4,o.buffer[this.index+3],t,e-this.context.start,i);return n<0?null:new k(this.context,this,n)}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)}prop(t){return this.type.prop(t)}enter(t,e,i=0){if(i&u.ExcludeBuffers)return null;let{buffer:o}=this.context,n=o.findChild(this.index+4,o.buffer[this.index+3],e>0?1:-1,t-this.context.start,e);return n<0?null:new k(this.context,this,n)}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,o=this.index+4,n=i.buffer[this.index+3];if(n>o){let s=i.buffer[this.index+1];t.push(i.slice(o,n,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 o=1;o<t.length;o++){let n=t[o];(n.from>i.from||n.to<i.to)&&(i=n,e=o)}let o=i instanceof v&&i.index<0?null:i.parent,n=t.slice();return o?n[e]=o:n.splice(e,1),new T(n,i)}class T{constructor(t,e){this.heads=t,this.node=e}get next(){return S(this.heads)}}class E{get name(){return this.type.name}constructor(t,e=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=e&~u.EnterBracketed,t instanceof v)this.yieldNode(t);else{this._tree=t.context.parent,this.buffer=t.context;for(let e=t._parent;e;e=e._parent)this.stack.unshift(e.index);this.bufferNode=t,this.yieldBuf(t.index)}}yieldNode(t){return!!t&&(this._tree=t,this.type=t.type,this.from=t.from,this.to=t.to,!0)}yieldBuf(t,e){this.index=t;let{start:i,buffer:o}=this.buffer;return this.type=e||o.set.types[o.buffer[t]],this.from=i+o.buffer[t+1],this.to=i+o.buffer[t+2],!0}yield(t){return!!t&&(t instanceof v?(this.buffer=null,this.yieldNode(t)):(this.buffer=t.context,this.yieldBuf(t.index,t.type)))}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(t,e,i){if(!this.buffer)return this.yield(this._tree.nextChild(t<0?this._tree._tree.children.length-1:0,t,e,i,this.mode));let{buffer:o}=this.buffer,n=o.findChild(this.index+4,o.buffer[this.index+3],t,e-this.buffer.start,i);return!(n<0)&&(this.stack.push(this.index),this.yieldBuf(n))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(t){return this.enterChild(1,t,2)}childBefore(t){return this.enterChild(-1,t,-2)}enter(t,e,i=this.mode){return this.buffer?!(i&u.ExcludeBuffers)&&this.enterChild(1,t,e):this.yield(this._tree.enter(t,e,i))}parent(){if(!this.buffer)return this.yieldNode(this.mode&u.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let t=this.mode&u.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(t)}sibling(t){if(!this.buffer)return!!this._tree._parent&&this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+t,t,0,4,this.mode));let{buffer:e}=this.buffer,i=this.stack.length-1;if(t<0){let t=i<0?0:this.stack[i]+4;if(this.index!=t)return this.yieldBuf(e.findChild(t,this.index,-1,0,4))}else{let t=e.buffer[this.index+3];if(t<(i<0?e.buffer.length:e.buffer[this.stack[i]+3]))return this.yieldBuf(t)}return i<0&&this.yield(this.buffer.parent.nextChild(this.buffer.index+t,t,0,4,this.mode))}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(t){let e,i,{buffer:o}=this;if(o){if(t>0){if(this.index<o.buffer.buffer.length)return!1}else for(let t=0;t<this.index;t++)if(o.buffer.buffer[t+3]<this.index)return!1;({index:e,parent:i}=o)}else({index:e,_parent:i}=this._tree);for(;i;({index:e,_parent:i}=i))if(e>-1)for(let o=e+t,n=t<0?-1:i._tree.children.length;o!=n;o+=t){let t=i._tree.children[o];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<t))&&this.parent(););for(;this.enterChild(1,t,e););return this}get node(){if(!this.buffer)return this._tree;let t=this.bufferNode,e=null,i=0;if(t&&t.context==this.buffer)t:for(let o=this.index,n=this.stack.length;n>=0;){for(let s=t;s;s=s._parent)if(s.index==o){if(o==this.index)return s;e=s,i=n+1;break t}o=this.stack[--n]}for(let t=i;t<this.stack.length;t++)e=new k(this.buffer,e,this.stack[t]);return this.bufferNode=new k(this.buffer,e,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(t,e){for(let i=0;;){let o=!1;if(this.type.isAnonymous||!1!==t(this)){if(this.firstChild()){i++;continue}this.type.isAnonymous||(o=!0)}for(;;){if(o&&e&&e(this),o=this.type.isAnonymous,!i)return;if(this.nextSibling())break;this.parent(),i--,o=!0}}}matchContext(t){if(!this.buffer)return C(this.node.parent,t);let{buffer:e}=this.buffer,{types:i}=e.set;for(let o=t.length-1,n=this.stack.length-1;o>=0;n--){if(n<0)return C(this._tree,t,o);let s=i[e.buffer[this.stack[n]]];if(!s.isAnonymous){if(t[o]&&t[o]!=s.name)return!1;o--}}return!0}}function M(t){return t.children.some(t=>t instanceof g||!t.type.isAnonymous||M(t))}const A=new WeakMap;function I(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 o of e.children){if(o.type!=t||!(o instanceof p)){i=1;break}i+=I(t,o)}A.set(e,i)}return i}function D(t,e,i,o,n,s,r,a,l){let c=0;for(let i=o;i<n;i++)c+=I(t,e[i]);let h=Math.ceil(1.5*c/8),d=[],u=[];return function e(i,o,n,r,a){for(let c=n;c<r;){let n=c,p=o[c],m=I(t,i[c]);for(c++;c<r;c++){let e=I(t,i[c]);if(m+e>=h)break;m+=e}if(c==n+1){if(m>h){let t=i[n];e(t.children,t.positions,0,t.children.length,o[n]+a);continue}d.push(i[n])}else{let e=o[c-1]+i[c-1].length-p;d.push(D(t,i,o,n,c,p,e,null,l))}u.push(p+a-s)}}(e,i,o,n,0),(a||l)(d,u,r)}class O{constructor(t,e,i,o,n=!1,s=!1){this.from=t,this.to=e,this.tree=i,this.offset=o,this.open=(n?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 o=[new O(0,t.length,t,0,!1,i)];for(let i of e)i.to>t.length&&o.push(i);return o}static applyChanges(t,e,i=128){if(!e.length)return t;let o=[],n=1,s=t.length?t[0]:null;for(let r=0,a=0,l=0;;r++){let c=r<e.length?e[r]:null,h=c?c.fromA:1e9;if(h-a>=i)for(;s&&s.from<h;){let e=s;if(a>=e.from||h<=e.to||l){let t=Math.max(e.from,a)-l,i=Math.min(e.to,h)-l;e=t>=i?null:new O(t,i,e.tree,e.offset+l,r>0,!!c)}if(e&&o.push(e),s.to>h)break;s=n<t.length?t[n++]:null}if(!c)break;a=c.toA,l=c.toA-c.toB}return o}}class B{startParse(t,e,i){return"string"==typeof t&&(t=new L(t)),i=i?i.length?i.map(t=>new s(t.from,t.to)):[new s(0,0)]:[new s(0,t.length)],this.createParse(t,e||[],i)}parse(t,e,i){let o=this.startParse(t,e,i);for(;;){let t=o.advance();if(t)return t}}}class L{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=[],q=[];function R(t){if(t<768)return!1;for(let e=0,i=N.length;;){let o=e+i>>1;if(t<N[o])i=o;else{if(!(t>=q[o]))return!0;e=o+1}if(e==i)return!1}}function F(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<t.length;e++)(e%2?q:N).push(i+=t[e])})();function P(t,e,i=!0,o=!0){return(i?_:V)(t,e,o)}function _(t,e,i){if(e==t.length)return e;e&&H(t.charCodeAt(e))&&W(t.charCodeAt(e-1))&&e--;let o=z(t,e);for(e+=$(o);e<t.length;){let n=z(t,e);if(8205==o||8205==n||i&&R(n))e+=$(n),o=n;else{if(!F(n))break;{let i=0,o=e-2;for(;o>=0&&F(z(t,o));)i++,o-=2;if(i%2==0)break;e+=2}}}return e}function V(t,e,i){for(;e>0;){let o=_(t,e-2,i);if(o<e)return o;e--}return 0}function z(t,e){let i=t.charCodeAt(e);if(!W(i)||e+1==t.length)return i;let o=t.charCodeAt(e+1);return H(o)?o-56320+(i-55296<<10)+65536:i}function H(t){return t>=56320&&t<57344}function W(t){return t>=55296&&t<56320}function $(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 o=[];return this.decompose(0,t,o,2),i.length&&i.decompose(0,i.length,o,3),this.decompose(e,this.length,o,1),Y.from(o,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),o=new K(this),n=new K(t);for(let t=e,s=e;;){if(o.next(t),n.next(t),t=0,o.lineBreak!=n.lineBreak||o.done!=n.done||o.value!=n.value)return!1;if(s+=o.value.length,o.done||s>=i)return!0}}iter(t=1){return new K(this,t)}iterRange(t,e=this.length){return new J(this,t,e)}iterLines(t,e){let i;if(null==t)i=this.iter();else{null==e&&(e=this.lines+1);let o=this.line(t).from;i=this.iterRange(o,Math.max(o,e==this.lines+1?this.length:e<=1?0:this.line(e-1).to))}return new X(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,o){for(let n=0;;n++){let s=this.text[n],r=o+s.length;if((e?i:r)>=t)return new Q(o,r,i,s);o=r+1,i++}}decompose(t,e,i,o){let n=t<=0&&e>=this.length?this:new j(Z(this.text,t,e),Math.min(e,this.length)-Math.max(0,t));if(1&o){let t=i.pop(),e=G(n.text,t.text.slice(),0,n.length);if(e.length<=32)i.push(new j(e,t.length+n.length));else{let t=e.length>>1;i.push(new j(e.slice(0,t)),new j(e.slice(t)))}}else i.push(n)}replace(t,e,i){if(!(i instanceof j))return super.replace(t,e,i);[t,e]=tt(this,t,e);let o=G(this.text,G(i.text,Z(this.text,0,t)),e),n=this.length+i.length-(e-t);return o.length<=32?new j(o,n):Y.from(j.split(o,[]),n)}sliceString(t,e=this.length,i="\n"){[t,e]=tt(this,t,e);let o="";for(let n=0,s=0;n<=e&&s<this.text.length;s++){let r=this.text[s],a=n+r.length;n>t&&s&&(o+=i),t<a&&e>n&&(o+=r.slice(Math.max(0,t-n),e-n)),n=a+1}return o}flatten(t){for(let e of this.text)t.push(e)}scanIdentical(){return 0}static split(t,e){let i=[],o=-1;for(let n of t)i.push(n),o+=n.length+1,32==i.length&&(e.push(new j(i,o)),i=[],o=-1);return o>-1&&e.push(new j(i,o)),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,o){for(let n=0;;n++){let s=this.children[n],r=o+s.length,a=i+s.lines-1;if((e?a:r)>=t)return s.lineInner(t,e,i,o);o=r+1,i=a+1}}decompose(t,e,i,o){for(let n=0,s=0;s<=e&&n<this.children.length;n++){let r=this.children[n],a=s+r.length;if(t<=a&&e>=s){let n=o&((s<=t?1:0)|(a>=e?2:0));s>=t&&a<=e&&!n?i.push(r):r.decompose(t-s,e-s,i,n)}s=a+1}}replace(t,e,i){if([t,e]=tt(this,t,e),i.lines<this.lines)for(let o=0,n=0;o<this.children.length;o++){let s=this.children[o],r=n+s.length;if(t>=n&&e<=r){let a=s.replace(t-n,e-n,i),l=this.lines-s.lines+a.lines;if(a.lines<l>>4&&a.lines>l>>6){let n=this.children.slice();return n[o]=a,new Y(n,this.length-(e-t)+i.length)}return super.replace(n,r,a)}n=r+1}return super.replace(t,e,i)}sliceString(t,e=this.length,i="\n"){[t,e]=tt(this,t,e);let o="";for(let n=0,s=0;n<this.children.length&&s<=e;n++){let r=this.children[n],a=s+r.length;s>t&&n&&(o+=i),t<a&&e>s&&(o+=r.sliceString(t-s,e-s,i)),s=a+1}return o}flatten(t){for(let e of this.children)e.flatten(t)}scanIdentical(t,e){if(!(t instanceof Y))return 0;let i=0,[o,n,s,r]=e>0?[0,0,this.children.length,t.children.length]:[this.children.length-1,t.children.length-1,-1,-1];for(;;o+=e,n+=e){if(o==s||n==r)return i;let a=this.children[o],l=t.children[n];if(a!=l)return i+a.scanIdentical(l,e);i+=a.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 o=Math.max(32,i>>5),n=o<<1,s=o>>1,r=[],a=0,l=-1,c=[];function h(t){let e;if(t.lines>n&&t instanceof Y)for(let e of t.children)h(e);else t.lines>s&&(a>s||!a)?(d(),r.push(t)):t instanceof j&&a&&(e=c[c.length-1])instanceof j&&t.lines+e.lines<=32?(a+=t.lines,l+=t.length+1,c[c.length-1]=new j(e.text.concat(t.text),e.length+1+t.length)):(a+t.lines>o&&d(),a+=t.lines,l+=t.length+1,c.push(t))}function d(){0!=a&&(r.push(1==c.length?c[0]:Y.from(c,l)),l=-1,a=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,o=1e9){for(let n=0,s=0,r=!0;s<t.length&&n<=o;s++){let a=t[s],l=n+a.length;l>=i&&(l>o&&(a=a.slice(0,o-n)),n<i&&(a=a.slice(i-n)),r?(e[e.length-1]+=a,r=!1):e.push(a)),n=l+1}return e}function Z(t,e,i){return G(t,[""],e,i)}U.empty=new j([""],0);class K{constructor(t,e=1){this.dir=e,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[t],this.offsets=[e>0?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,o=this.nodes[i],n=this.offsets[i],s=n>>1,r=o instanceof j?o.text.length:o.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&n)==(e>0?0:1)){if(this.offsets[i]+=e,0==t)return this.lineBreak=!0,this.value="\n",this;t--}else if(o instanceof j){let n=o.text[s+(e<0?-1:0)];if(this.offsets[i]+=e,n.length>Math.max(0,t))return this.value=0==t?n:e>0?n.slice(t):n.slice(0,n.length-t),this;t-=n.length}else{let n=o.children[s+(e<0?-1:0)];t>n.length?(t-=n.length,this.offsets[i]+=e):(e<0&&this.offsets[i]--,this.nodes.push(n),this.offsets.push(e>0?1:(n instanceof j?n.text.length:n.children.length)<<1))}}}next(t=0){return t<0&&(this.nextInner(-t,-this.dir),t=this.value.length),this.nextInner(t,this.dir)}}class J{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:o}=this.cursor.next(t);return this.pos+=(o.length+t)*e,this.value=o.length<=i?o:e<0?o.slice(o.length-i):o.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 X{constructor(t){this.inner=t,this.afterBreak=!0,this.value="",this.done=!1}next(t=0){let{done:e,lineBreak:i,value:o}=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=o,this.afterBreak=!1),this}get lineBreak(){return!1}}"undefined"!=typeof Symbol&&(U.prototype[Symbol.iterator]=function(){return this.iter()},K.prototype[Symbol.iterator]=J.prototype[Symbol.iterator]=X.prototype[Symbol.iterator]=function(){return this});class Q{constructor(t,e,i,o){this.from=t,this.to=e,this.number=i,this.text=o}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,o=!0){return P(t,e,i,o)}const it=/\r\n?|\n/;var ot=function(t){return t[t.Simple=0]="Simple",t[t.TrackDel=1]="TrackDel",t[t.TrackBefore=2]="TrackBefore",t[t.TrackAfter=3]="TrackAfter",t}(ot||(ot={}));class nt{constructor(t){this.sections=t}get length(){let t=0;for(let e=0;e<this.sections.length;e+=2)t+=this.sections[e];return t}get newLength(){let t=0;for(let e=0;e<this.sections.length;e+=2){let i=this.sections[e+1];t+=i<0?this.sections[e]:i}return t}get empty(){return 0==this.sections.length||2==this.sections.length&&this.sections[1]<0}iterGaps(t){for(let e=0,i=0,o=0;e<this.sections.length;){let n=this.sections[e++],s=this.sections[e++];s<0?(t(i,o,n),o+=n):o+=s,i+=n}}iterChangedRanges(t,e=!1){lt(this,t,e)}get invertedDesc(){let t=[];for(let e=0;e<this.sections.length;){let i=this.sections[e++],o=this.sections[e++];o<0?t.push(i,o):t.push(o,i)}return new nt(t)}composeDesc(t){return this.empty?t:t.empty?this:ht(this,t)}mapDesc(t,e=!1){return t.empty?this:ct(this,t,e)}mapPos(t,e=-1,i=ot.Simple){let o=0,n=0;for(let s=0;s<this.sections.length;){let r=this.sections[s++],a=this.sections[s++],l=o+r;if(a<0){if(l>t)return n+(t-o);n+=r}else{if(i!=ot.Simple&&l>=t&&(i==ot.TrackDel&&o<t&&l>t||i==ot.TrackBefore&&o<t||i==ot.TrackAfter&&l>t))return null;if(l>t||l==t&&e<0&&!r)return t==o||e<0?n:n+a;n+=a}o=l}if(t>o)throw new RangeError(`Position ${t} is out of range for changeset of length ${o}`);return n}touchesRange(t,e=t){for(let i=0,o=0;i<this.sections.length&&o<=e;){let n=o+this.sections[i++];if(this.sections[i++]>=0&&o<=e&&n>=t)return!(o<t&&n>e)||"cover";o=n}return!1}toString(){let t="";for(let e=0;e<this.sections.length;){let i=this.sections[e++],o=this.sections[e++];t+=(t?" ":"")+i+(o>=0?":"+o:"")}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 nt(t)}static create(t){return new nt(t)}}class st extends nt{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 lt(this,(e,i,o,n,s)=>t=t.replace(o,o+(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 o=0,n=0;o<e.length;o+=2){let s=e[o],r=e[o+1];if(r>=0){e[o]=r,e[o+1]=s;let a=o>>1;for(;i.length<a;)i.push(U.empty);i.push(s?t.slice(n,n+s):U.empty)}n+=s}return new st(e,i)}compose(t){return this.empty?t:t.empty?this:ht(this,t,!0)}map(t,e=!1){return t.empty?this:ct(this,t,e,!0)}iterChanges(t,e=!1){lt(this,t,e)}get desc(){return nt.create(this.sections)}filter(t){let e=[],i=[],o=[],n=new dt(this);t:for(let s=0,r=0;;){let a=s==t.length?1e9:t[s++];for(;r<a||r==a&&0==n.len;){if(n.done)break t;let t=Math.min(n.len,a-r);rt(o,t,-1);let s=-1==n.ins?-1:0==n.off?n.ins:0;rt(e,t,s),s>0&&at(i,e,n.text),n.forward(t),r+=t}let l=t[s++];for(;r<l;){if(n.done)break t;let t=Math.min(n.len,l-r);rt(e,t,-1),rt(o,t,-1==n.ins?-1:0==n.off?n.ins:0),n.forward(t),r+=t}}return{changes:new st(e,i),filtered:nt.create(o)}}toJSON(){let t=[];for(let e=0;e<this.sections.length;e+=2){let i=this.sections[e],o=this.sections[e+1];o<0?t.push(i):0==o?t.push([i]):t.push([i].concat(this.inserted[e>>1].toJSON()))}return t}static of(t,e,i){let o=[],n=[],s=0,r=null;function a(t=!1){if(!t&&!o.length)return;s<e&&rt(o,e-s,-1);let i=new st(o,n);r=r?r.compose(i.map(r)):i,o=[],n=[],s=0}return function t(l){if(Array.isArray(l))for(let e of l)t(e);else if(l instanceof st){if(l.length!=e)throw new RangeError(`Mismatched change set length (got ${l.length}, expected ${e})`);a(),r=r?r.compose(l.map(r)):l}else{let{from:t,to:r=t,insert:c}=l;if(t>r||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;t<s&&a(),t>s&&rt(o,t-s,-1),rt(o,r-t,d),at(n,o,h),s=r}}(t),a(!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 o=0;o<t.length;o++){let n=t[o];if("number"==typeof n)e.push(n,-1);else{if(!Array.isArray(n)||"number"!=typeof n[0]||n.some((t,e)=>e&&"string"!=typeof t))throw new RangeError("Invalid JSON representation of ChangeSet");if(1==n.length)e.push(n[0],0);else{for(;i.length<o;)i.push(U.empty);i[o]=U.of(n.slice(1)),e.push(n[0],i[o].length)}}}return new st(e,i)}static createSet(t,e){return new st(t,e)}}function rt(t,e,i,o=!1){if(0==e&&i<=0)return;let n=t.length-2;n>=0&&i<=0&&i==t[n+1]?t[n]+=e:n>=0&&0==e&&0==t[n]?t[n+1]+=i:o?(t[n]+=e,t[n+1]+=i):t.push(e,i)}function at(t,e,i){if(0==i.length)return;let o=e.length-2>>1;if(o<t.length)t[t.length-1]=t[t.length-1].append(i);else{for(;t.length<o;)t.push(U.empty);t.push(i)}}function lt(t,e,i){let o=t.inserted;for(let n=0,s=0,r=0;r<t.sections.length;){let a=t.sections[r++],l=t.sections[r++];if(l<0)n+=a,s+=a;else{let c=n,h=s,d=U.empty;for(;c+=a,h+=l,l&&o&&(d=d.append(o[r-2>>1])),!(i||r==t.sections.length||t.sections[r+1]<0);)a=t.sections[r++],l=t.sections[r++];e(n,c,s,h,d),n=c,s=h}}}function ct(t,e,i,o=!1){let n=[],s=o?[]:null,r=new dt(t),a=new dt(e);for(let t=-1;;){if(r.done&&a.len||a.done&&r.len)throw new Error("Mismatched change set lengths");if(-1==r.ins&&-1==a.ins){let t=Math.min(r.len,a.len);rt(n,t,-1),r.forward(t),a.forward(t)}else if(a.ins>=0&&(r.ins<0||t==r.i||0==r.off&&(a.len<r.len||a.len==r.len&&!i))){let e=a.len;for(rt(n,a.ins,-1);e;){let i=Math.min(r.len,e);r.ins>=0&&t<r.i&&r.len<=i&&(rt(n,0,r.ins),s&&at(s,n,r.text),t=r.i),r.forward(i),e-=i}a.next()}else{if(!(r.ins>=0)){if(r.done&&a.done)return s?st.createSet(n,s):nt.create(n);throw new Error("Mismatched change set lengths")}{let e=0,i=r.len;for(;i;)if(-1==a.ins){let t=Math.min(i,a.len);e+=t,i-=t,a.forward(t)}else{if(!(0==a.ins&&a.len<i))break;i-=a.len,a.next()}rt(n,e,t<r.i?r.ins:0),s&&t<r.i&&at(s,n,r.text),t=r.i,r.forward(r.len-i)}}}}function ht(t,e,i=!1){let o=[],n=i?[]:null,s=new dt(t),r=new dt(e);for(let t=!1;;){if(s.done&&r.done)return n?st.createSet(o,n):nt.create(o);if(0==s.ins)rt(o,s.len,0,t),s.next();else if(0!=r.len||r.done){if(s.done||r.done)throw new Error("Mismatched change set lengths");{let e=Math.min(s.len2,r.len),i=o.length;if(-1==s.ins){let i=-1==r.ins?-1:r.off?0:r.ins;rt(o,e,i,t),n&&i&&at(n,o,r.text)}else-1==r.ins?(rt(o,s.off?0:s.len,e,t),n&&at(n,o,s.textBit(e))):(rt(o,s.off?0:s.len,r.off?0:r.ins,t),n&&!r.off&&at(n,o,r.text));t=(s.ins>e||r.ins>=0&&r.len>e)&&(t||o.length>i),s.forward2(e),r.forward(e)}}else rt(o,0,r.ins,t),n&&at(n,o,r.text),r.next()}}class dt{constructor(t){this.set=t,this.i=0,this.next()}next(){let{sections:t}=this.set;this.i<t.length?(this.len=t[this.i++],this.ins=t[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return-2==this.ins}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:t}=this.set,e=this.i-2>>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,o;return this.empty?i=o=t.mapPos(this.from,e):(i=t.mapPos(this.from,1),o=t.mapPos(this.to,-1)),i==this.from&&o==this.to?this:new ut(i,o,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;i<this.ranges.length;i++)if(!this.ranges[i].eq(t.ranges[i],e))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return 1==this.ranges.length?this:new pt([this.main],0)}addRange(t,e=!0){return pt.create([t].concat(this.ranges),e?0:this.mainIndex+1)}replaceRange(t,e=this.mainIndex){let i=this.ranges.slice();return i[e]=t,pt.create(i,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(t=>t.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,o=0;o<t.length;o++){let n=t[o];if(n.empty?n.from<=i:n.from<i)return pt.normalized(t.slice(),e);i=n.to}return new pt(t,e)}static cursor(t,e=0,i,o){return ut.create(t,t,(0==e?0:e<0?8:16)|(null==i?7:Math.min(6,i))|(null!=o?o:16777215)<<6)}static range(t,e,i,o){let n=(null!=i?i:16777215)<<6|(null==o?7:Math.min(6,o));return e<t?ut.create(e,t,48|n):ut.create(t,e,(e>t?8:0)|n)}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;i<t.length;i++){let o=t[i],n=t[i-1];if(o.empty?o.from<=n.to:o.from<n.to){let s=n.from,r=Math.max(o.to,n.to);i<=e&&e--,t.splice(--i,2,o.anchor>o.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,o,n){this.combine=t,this.compareInput=e,this.compare=i,this.isStatic=o,this.id=gt++,this.default=t([]),this.extensions="function"==typeof n?n(this):n}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 yt([],this,0,t)}compute(t,e){if(this.isStatic)throw new Error("Can't compute a static facet");return new yt(t,this,1,e)}computeN(t,e){if(this.isStatic)throw new Error("Can't compute a static facet");return new yt(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 yt{constructor(t,e,i,o){this.dependencies=t,this.facet=e,this.type=i,this.value=o,this.id=gt++}dynamicSlot(t){var e;let i=this.value,o=this.facet.compareInput,n=this.id,s=t[n]>>1,r=2==this.type,a=!1,l=!1,c=[];for(let i of this.dependencies)"doc"==i?a=!0:"selection"==i?l=!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(a&&e.docChanged||l&&(e.docChanged||e.selection)||wt(t,c)){let e=i(t);if(r?!vt(e,t.values[s],o):!o(e,t.values[s]))return t.values[s]=e,1}return 0},reconfigure:(t,e)=>{let a,l=e.config.address[n];if(null!=l){let n=qt(e,l);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?vt(a=i(t),n,o):o(a=i(t),n)))return t.values[s]=n,0}else a=i(t);return t.values[s]=a,1}}}}function vt(t,e,i){if(t.length!=e.length)return!1;for(let o=0;o<t.length;o++)if(!i(t[o],e[o]))return!1;return!0}function wt(t,e){let i=!1;for(let o of e)1&Nt(t,o)&&(i=!0);return i}function Ct(t,e,i){let o=i.map(e=>t[e.id]),n=i.map(t=>t.type),s=o.filter(t=>!(1&t)),r=t[e.id]>>1;function a(t){let i=[];for(let e=0;e<o.length;e++){let s=qt(t,o[e]);if(2==n[e])for(let t of s)i.push(t);else i.push(s)}return e.combine(i)}return{create(t){for(let e of o)Nt(t,e);return t.values[r]=a(t),1},update(t,i){if(!wt(t,s))return 0;let o=a(t);return e.compare(o,t.values[r])?0:(t.values[r]=o,1)},reconfigure(t,n){let s=wt(t,o),l=n.config.facets[e.id],c=n.facet(e);if(l&&!s&&bt(i,l))return t.values[r]=c,0;let h=a(t);return e.compare(h,c)?(t.values[r]=c,0):(t.values[r]=h,1)}}}const xt=ft.define({static:!0});class kt{constructor(t,e,i,o,n){this.id=t,this.createF=e,this.updateF=i,this.compareF=o,this.spec=n,this.provides=void 0}static define(t){let e=new kt(gt++,t.create,t.update,t.compare||((t,e)=>t===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 o=t.values[e],n=this.updateF(o,i);return this.compareF(o,n)?0:(t.values[e]=n,1)},reconfigure:(t,i)=>{let o,n=t.facet(xt),s=i.facet(xt);return(o=n.find(t=>t.field==this))&&o!=s.find(t=>t.field==this)?(t.values[e]=o.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 Dt(e,t)}const It={highest:At(0),high:At(Mt),default:At(Et),low:At(Tt),lowest:At(St)};class Dt{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 Lt{constructor(t,e,i,o,n,s){for(this.base=t,this.compartments=e,this.dynamicSlots=i,this.address=o,this.staticValues=n,this.facets=s,this.statusTemplate=[];this.statusTemplate.length<i.length;)this.statusTemplate.push(0)}staticFacet(t){let e=this.address[t.id];return null==e?t.default:this.staticValues[e>>1]}static resolve(t,e,i){let o=[],n=Object.create(null),s=new Map;for(let i of function(t,e,i){let o=[[],[],[],[],[]],n=new Map;function s(t,r){let a=n.get(t);if(null!=a){if(a<=r)return;let e=o[a].indexOf(t);e>-1&&o[a].splice(e,1),t instanceof Bt&&i.delete(t.compartment)}if(n.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 o=e.get(t.compartment)||t.inner;i.set(t.compartment,o),s(o,r)}else if(t instanceof Dt)s(t.inner,t.prec);else if(t instanceof kt)o[r].push(t),t.provides&&s(t.provides,r);else if(t instanceof yt)o[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),o.reduce((t,e)=>t.concat(e))}(t,e,s))i instanceof kt?o.push(i):(n[i.facet.id]||(n[i.facet.id]=[])).push(i);let r=Object.create(null),a=[],l=[];for(let t of o)r[t.id]=l.length<<1,l.push(e=>t.slot(e));let c=null==i?void 0:i.config.facets;for(let t in n){let e=n[t],o=e[0].facet,s=c&&c[t]||[];if(e.every(t=>0==t.type))if(r[o.id]=a.length<<1|1,bt(s,e))a.push(i.facet(o));else{let t=o.combine(e.map(t=>t.value));a.push(i&&o.compare(t,i.facet(o))?i.facet(o):t)}else{for(let t of e)0==t.type?(r[t.id]=a.length<<1|1,a.push(t.value)):(r[t.id]=l.length<<1,l.push(e=>t.dynamicSlot(e)));r[o.id]=l.length<<1,l.push(t=>Ct(t,o,e))}}let h=l.map(t=>t(r));return new Lt(t,s,h,r,a,n)}}function Nt(t,e){if(1&e)return 2;let i=e>>1,o=t.status[i];if(4==o)throw new Error("Cyclic dependency between fields and/or facets");if(2&o)return o;t.status[i]=4;let n=t.computeSlot(t,t.config.dynamicSlots[i]);return t.status[i]=2|n}function qt(t,e){return 1&e?t.config.staticValues[e>>1]:t.values[e>>1]}const Rt=ft.define(),Ft=ft.define({combine:t=>t.some(t=>t),static:!0}),Pt=ft.define({combine:t=>t.length?t[0]:void 0,static:!0}),_t=ft.define(),Vt=ft.define(),zt=ft.define(),Ht=ft.define({combine:t=>!!t.length&&t[0]});class Wt{constructor(t,e){this.type=t,this.value=e}static define(){return new $t}}class $t{of(t){return new Wt(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 o of t){let t=o.map(e);t&&i.push(t)}return i}}jt.reconfigure=jt.define(),jt.appendConfig=jt.define();class Yt{constructor(t,e,i,o,n,s){this.startState=t,this.changes=e,this.selection=i,this.effects=o,this.annotations=n,this.scrollIntoView=s,this._doc=null,this._state=null,i&&mt(i,e.newLength),n.some(t=>t.type==Yt.time)||(this.annotations=n.concat(Yt.time.of(Date.now())))}static create(t,e,i,o,n,s){return new Yt(t,e,i,o,n,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 o=0,n=0;;){let s,r;if(o<t.length&&(n==e.length||e[n]>=t[o]))s=t[o++],r=t[o++];else{if(!(n<e.length))return i;s=e[n++],r=e[n++]}!i.length||i[i.length-1]<s?i.push(s,r):i[i.length-1]<r&&(i[i.length-1]=r)}}function Zt(t,e,i){var o;let n,s,r;return i?(n=e.changes,s=st.empty(e.changes.length),r=t.changes.compose(e.changes)):(n=e.changes.map(t.changes),s=t.changes.mapDesc(e.changes,!0),r=t.changes.compose(n)),{changes:r,selection:e.selection?e.selection.map(s):null===(o=t.selection)||void 0===o?void 0:o.map(n),effects:jt.mapEffects(t.effects,n).concat(jt.mapEffects(e.effects,s)),annotations:t.annotations.length?t.annotations.concat(e.annotations):e.annotations,scrollIntoView:t.scrollIntoView||e.scrollIntoView}}function Kt(t,e,i){let o=e.selection,n=Qt(e.annotations);return e.userEvent&&(n=n.concat(Yt.userEvent.of(e.userEvent))),{changes:e.changes instanceof st?e.changes:st.of(e.changes||[],i,t.facet(Pt)),selection:o&&(o instanceof pt?o:pt.single(o.anchor,o.head)),effects:Qt(e.effects),annotations:n,scrollIntoView:!!e.scrollIntoView}}function Jt(t,e,i){let o=Kt(t,e.length?e[0]:{},t.doc.length);e.length&&!1===e[0].filter&&(i=!1);for(let n=1;n<e.length;n++){!1===e[n].filter&&(i=!1);let s=!!e[n].sequential;o=Zt(o,Kt(t,e[n],s?o.changes.newLength:t.doc.length),s)}let n=Yt.create(t,o.changes,o.selection,o.effects,o.annotations,o.scrollIntoView);return function(t){let e=t.startState,i=e.facet(zt),o=t;for(let n=i.length-1;n>=0;n--){let s=i[n](t);s&&Object.keys(s).length&&(o=Zt(o,Kt(e,s,t.changes.newLength),!0))}return o==t?t:Yt.create(e,t.changes,t.selection,o.effects,o.annotations,o.scrollIntoView)}(i?function(t){let e=t.startState,i=!0;for(let o of e.facet(_t)){let e=o(t);if(!1===e){i=!1;break}Array.isArray(e)&&(i=!0===i?e:Gt(i,e))}if(!0!==i){let o,n;if(!1===i)n=t.changes.invertedDesc,o=st.empty(e.doc.length);else{let e=t.changes.filter(i);o=e.changes,n=e.filtered.mapDesc(e.changes).invertedDesc}t=Yt.create(e,o,t.selection&&t.selection.map(n),jt.mapEffects(t.effects,n),t.annotations,t.scrollIntoView)}let o=e.facet(Vt);for(let i=o.length-1;i>=0;i--){let n=o[i](t);t=n instanceof Yt?n:Array.isArray(n)&&1==n.length&&n[0]instanceof Yt?n[0]:Jt(e,Qt(n),!1)}return t}(n):n)}Yt.time=Wt.define(),Yt.userEvent=Wt.define(),Yt.addToHistory=Wt.define(),Yt.remote=Wt.define();const Xt=[];function Qt(t){return null==t?Xt: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 oe(t){return e=>{if(!/\S/.test(e))return te.Space;if(function(t){if(ie)return ie.test(t);for(let e=0;e<t.length;e++){let i=t[e];if(/\w/.test(i)||i>""&&(i.toUpperCase()!=i.toLowerCase()||ee.test(i)))return!0}return!1}(e))return te.Word;for(let i=0;i<t.length;i++)if(e.indexOf(t[i])>-1)return te.Word;return te.Other}}class ne{constructor(t,e,i,o,n,s){this.config=t,this.doc=e,this.selection=i,this.values=o,this.status=t.statusTemplate.slice(),this.computeSlot=n,s&&(s._state=this);for(let t=0;t<this.config.dynamicSlots.length;t++)Nt(this,t<<1);this.computeSlot=null}field(t,e=!0){let i=this.config.address[t.id];if(null!=i)return Nt(this,i),qt(this,i);if(e)throw new RangeError("Field is not present in this state")}update(...t){return Jt(this,t,!0)}applyTransaction(t){let e,i=this.config,{base:o,compartments:n}=i;for(let e of t.effects)e.is(Ot.reconfigure)?(i&&(n=new Map,i.compartments.forEach((t,e)=>n.set(e,t)),i=null),n.set(e.value.compartment,e.value.extension)):e.is(jt.reconfigure)?(i=null,o=e.value):e.is(jt.appendConfig)&&(i=null,o=Qt(o).concat(e.value));if(i)e=t.startState.values.slice();else{i=Lt.resolve(o,n,this),e=new ne(i,this.doc,this.selection,i.dynamicSlots.map(()=>null),(t,e)=>e.reconfigure(t,this),null).values}let s=t.startState.facet(Ft)?t.newSelection:t.newSelection.asSingle();new ne(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]),o=this.changes(i.changes),n=[i.range],s=Qt(i.effects);for(let i=1;i<e.ranges.length;i++){let r=t(e.ranges[i]),a=this.changes(r.changes),l=a.map(o);for(let t=0;t<i;t++)n[t]=n[t].map(l);let c=o.mapDesc(a,!0);n.push(r.range.map(c)),o=o.compose(l),s=jt.mapEffects(s,l).concat(jt.mapEffects(Qt(r.effects),c))}return{changes:o,selection:pt.create(n,e.mainIndex),effects:s}}changes(t=[]){return t instanceof st?t:st.of(t,this.doc.length,this.facet(ne.lineSeparator))}toText(t){return U.of(t.split(this.facet(ne.lineSeparator)||it))}sliceDoc(t=0,e=this.doc.length){return this.doc.sliceString(t,e,this.lineBreak)}facet(t){let e=this.config.address[t.id];return null==e?t.default:(Nt(this,e),qt(this,e))}toJSON(t){let e={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(t)for(let i in t){let o=t[i];o instanceof kt&&null!=this.config.address[o.id]&&(e[i]=o.spec.toJSON(this.field(t[i]),this))}return e}static fromJSON(t,e={},i){if(!t||"string"!=typeof t.doc)throw new RangeError("Invalid JSON representation for EditorState");let o=[];if(i)for(let e in i)if(Object.prototype.hasOwnProperty.call(t,e)){let n=i[e],s=t[e];o.push(n.init(t=>n.spec.fromJSON(s,t)))}return ne.create({doc:t.doc,selection:pt.fromJSON(t.selection),extensions:e.extensions?o.concat([e.extensions]):o})}static create(t={}){let e=Lt.resolve(t.extensions||[],new Map),i=t.doc instanceof U?t.doc:U.of((t.doc||"").split(e.staticFacet(ne.lineSeparator)||it)),o=t.selection?t.selection instanceof pt?t.selection:pt.single(t.selection.anchor,t.selection.head):pt.single(0);return mt(o,i.length),e.staticFacet(Ft)||(o=o.asSingle()),new ne(e,i,o,e.dynamicSlots.map(()=>null),(t,e)=>e.create(t),null)}get tabSize(){return this.facet(ne.tabSize)}get lineBreak(){return this.facet(ne.lineSeparator)||"\n"}get readOnly(){return this.facet(Ht)}phrase(t,...e){for(let e of this.facet(ne.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 o=+(i||1);return!o||o>e.length?t:e[o-1]})),t}languageDataAt(t,e,i=-1){let o=[];for(let n of this.facet(Rt))for(let s of n(this,e,i))Object.prototype.hasOwnProperty.call(s,t)&&o.push(s[t]);return o}charCategorizer(t){let e=this.languageDataAt("wordChars",t);return oe(e.length?e[0]:"")}wordAt(t){let{text:e,from:i,length:o}=this.doc.lineAt(t),n=this.charCategorizer(t),s=t-i,r=t-i;for(;s>0;){let t=et(e,s,!1);if(n(e.slice(t,s))!=te.Word)break;s=t}for(;r<o;){let t=et(e,r);if(n(e.slice(r,t))!=te.Word)break;r=t}return s==r?null:pt.range(s+i,r+i)}}ne.allowMultipleSelections=Ft,ne.tabSize=ft.define({combine:t=>t.length?t[0]:4}),ne.lineSeparator=Pt,ne.readOnly=Ht,ne.phrases=ft.define({compare(t,e){let i=Object.keys(t),o=Object.keys(e);return i.length==o.length&&i.every(i=>t[i]==e[i])}}),ne.languageData=Rt,ne.changeFilter=_t,ne.transactionFilter=Vt,ne.transactionExtender=zt,Ot.reconfigure=jt.define();class se{eq(t){return this==t}range(t,e=t){return ae.create(t,e,this)}}function re(t,e){return t==e||t.constructor==e.constructor&&t.eq(e)}se.prototype.startSide=se.prototype.endSide=0,se.prototype.point=!1,se.prototype.mapMode=ot.TrackDel;class ae{constructor(t,e,i){this.from=t,this.to=e,this.value=i}static create(t,e,i){return new ae(t,e,i)}}function le(t,e){return t.from-e.from||t.value.startSide-e.value.startSide}class ce{constructor(t,e,i,o){this.from=t,this.to=e,this.value=i,this.maxPoint=o}get length(){return this.to[this.to.length-1]}findIndex(t,e,i,o=0){let n=i?this.to:this.from;for(let s=o,r=n.length;;){if(s==r)return s;let o=s+r>>1,a=n[o]-t||(i?this.value[o].endSide:this.value[o].startSide)-e;if(o==s)return a>=0?s:r;a>=0?r=o:s=o+1}}between(t,e,i,o){for(let n=this.findIndex(e,-1e9,!0),s=this.findIndex(i,1e9,!1,n);n<s;n++)if(!1===o(this.from[n]+t,this.to[n]+t,this.value[n]))return!1}map(t,e){let i=[],o=[],n=[],s=-1,r=-1;for(let a=0;a<this.value.length;a++){let l,c,h=this.value[a],d=this.from[a]+t,u=this.to[a]+t;if(d==u){let t=e.mapPos(d,h.startSide,h.mapMode);if(null==t)continue;if(l=c=t,h.startSide!=h.endSide&&(c=e.mapPos(d,h.endSide),c<l))continue}else if(l=e.mapPos(d,h.startSide),c=e.mapPos(u,h.endSide),l>c||l==c&&h.startSide>0&&h.endSide<=0)continue;(c-l||h.endSide-h.startSide)<0||(s<0&&(s=l),h.point&&(r=Math.max(r,c-l)),i.push(h),o.push(l-s),n.push(c-s))}return{mapped:i.length?new ce(o,n,i,r):null,pos:s}}}class he{constructor(t,e,i,o){this.chunkPos=t,this.chunk=e,this.nextLayer=i,this.maxPoint=o}static create(t,e,i,o){return new he(t,e,i,o)}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:o=0,filterTo:n=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?he.of(e):this;let r=new pe(this,null,-1).goto(0),a=0,l=[],c=new de;for(;r.value||a<e.length;)if(a<e.length&&(r.from-e[a].from||r.startSide-e[a].value.startSide)>=0){let t=e[a++];c.addInner(t.from,t.to,t.value)||l.push(t)}else 1==r.rangeIndex&&r.chunkIndex<this.chunk.length&&(a==e.length||this.chunkEnd(r.chunkIndex)<e[a].from)&&(!s||o>this.chunkEnd(r.chunkIndex)||n<this.chunkPos[r.chunkIndex])&&c.addChunk(this.chunkPos[r.chunkIndex],this.chunk[r.chunkIndex])?r.nextChunk():((!s||o>r.to||n<r.from||s(r.from,r.to,r.value))&&(c.addInner(r.from,r.to,r.value)||l.push(ae.create(r.from,r.to,r.value))),r.next());return c.finishInner(this.nextLayer.isEmpty&&!l.length?he.empty:this.nextLayer.update({add:l,filter:s,filterFrom:o,filterTo:n}))}map(t){if(t.empty||this.isEmpty)return this;let e=[],i=[],o=-1;for(let n=0;n<this.chunk.length;n++){let s=this.chunkPos[n],r=this.chunk[n],a=t.touchesRange(s,s+r.length);if(!1===a)o=Math.max(o,r.maxPoint),e.push(r),i.push(t.mapPos(s));else if(!0===a){let{mapped:n,pos:a}=r.map(s,t);n&&(o=Math.max(o,n.maxPoint),e.push(n),i.push(a))}}let n=this.nextLayer.map(t);return 0==e.length?n:new he(i,e,n||he.empty,o)}between(t,e,i){if(!this.isEmpty){for(let o=0;o<this.chunk.length;o++){let n=this.chunkPos[o],s=this.chunk[o];if(e>=n&&t<=n+s.length&&!1===s.between(n,t-n,e-n,i))return}this.nextLayer.between(t,e,i)}}iter(t=0){return me.from([this]).goto(t)}get isEmpty(){return this.nextLayer==this}static iter(t,e=0){return me.from(t).goto(e)}static compare(t,e,i,o,n=-1){let s=t.filter(t=>t.maxPoint>0||!t.isEmpty&&t.maxPoint>=n),r=e.filter(t=>t.maxPoint>0||!t.isEmpty&&t.maxPoint>=n),a=ue(s,r,i),l=new fe(s,a,n),c=new fe(r,a,n);i.iterGaps((t,e,i)=>be(l,t,c,e,i,o)),i.empty&&0==i.length&&be(l,0,c,0,0,o)}static eq(t,e,i=0,o){null==o&&(o=999999999);let n=t.filter(t=>!t.isEmpty&&e.indexOf(t)<0),s=e.filter(e=>!e.isEmpty&&t.indexOf(e)<0);if(n.length!=s.length)return!1;if(!n.length)return!0;let r=ue(n,s),a=new fe(n,r,0).goto(i),l=new fe(s,r,0).goto(i);for(;;){if(a.to!=l.to||!ye(a.active,l.active)||a.point&&(!l.point||!re(a.point,l.point)))return!1;if(a.to>o)return!0;a.next(),l.next()}}static spans(t,e,i,o,n=-1){let s=new fe(t,null,n).goto(e),r=e,a=s.openStart;for(;;){let t=Math.min(s.to,i);if(s.point){let i=s.activeForPoint(s.to),n=s.pointFrom<e?i.length+1:s.point.startSide<0?i.length:Math.min(i.length,a);o.point(r,t,s.point,i,n,s.pointRank),a=Math.min(s.openEnd(t),i.length)}else t>r&&(o.span(r,t,s.active,a),a=s.openEnd(t));if(s.to>i)return a+(s.point&&s.to>i?1:0);r=s.to,s.next()}}static of(t,e=!1){let i=new de;for(let o of t instanceof ae?[t]:e?function(t){if(t.length>1)for(let e=t[0],i=1;i<t.length;i++){let o=t[i];if(le(e,o)>0)return t.slice().sort(le);e=o}return t}(t):t)i.add(o.from,o.to,o.value);return i.finish()}static join(t){if(!t.length)return he.empty;let e=t[t.length-1];for(let i=t.length-2;i>=0;i--)for(let o=t[i];o!=he.empty;o=o.nextLayer)e=new he(o.chunkPos,o.chunk,e,Math.max(o.maxPoint,e.maxPoint));return e}}he.empty=new he([],[],null,-1),he.empty.nextLayer=he.empty;class de{finishChunk(t){this.chunks.push(new ce(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 de)).add(t,e,i)}addInner(t,e,i){let o=t-this.lastTo||i.startSide-this.last.endSide;if(o<=0&&(t-this.lastFrom||i.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return!(o<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(he.empty)}finishInner(t){if(this.from.length&&this.finishChunk(!1),0==this.chunks.length)return t;let e=he.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(t):t,this.setMaxPoint);return this.from=null,e}}function ue(t,e,i){let o=new Map;for(let e of t)for(let t=0;t<e.chunk.length;t++)e.chunk[t].maxPoint<=0&&o.set(e.chunk[t],e.chunkPos[t]);let n=new Set;for(let t of e)for(let e=0;e<t.chunk.length;e++){let s=o.get(t.chunk[e]);null==s||(i?i.mapPos(s):s)!=t.chunkPos[e]||(null==i?void 0:i.touchesRange(s,s+t.chunk[e].length))||n.add(t.chunk[e])}return n}class pe{constructor(t,e,i,o=0){this.layer=t,this.skip=e,this.minPoint=i,this.rank=o}get startSide(){return this.value?this.value.startSide:0}get endSide(){return this.value?this.value.endSide:0}goto(t,e=-1e9){return this.chunkIndex=this.rangeIndex=0,this.gotoInner(t,e,!1),this}gotoInner(t,e,i){for(;this.chunkIndex<this.layer.chunk.length;){let e=this.layer.chunk[this.chunkIndex];if(!(this.skip&&this.skip.has(e)||this.layer.chunkEnd(this.chunkIndex)<t||e.maxPoint<this.minPoint))break;this.chunkIndex++,i=!1}if(this.chunkIndex<this.layer.chunk.length){let o=this.layer.chunk[this.chunkIndex].findIndex(t-this.layer.chunkPos[this.chunkIndex],e,!0);(!i||this.rangeIndex<o)&&this.setRangeIndex(o)}this.next()}forward(t,e){(this.to-t||this.endSide-e)<0&&this.gotoInner(t,e,!0)}next(){for(;;){if(this.chunkIndex==this.layer.chunk.length){this.from=this.to=1e9,this.value=null;break}{let t=this.layer.chunkPos[this.chunkIndex],e=this.layer.chunk[this.chunkIndex],i=t+e.from[this.rangeIndex];if(this.from=i,this.to=t+e.to[this.rangeIndex],this.value=e.value[this.rangeIndex],this.setRangeIndex(this.rangeIndex+1),this.minPoint<0||this.value.point&&this.to-this.from>=this.minPoint)break}}}setRangeIndex(t){if(t==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex<this.layer.chunk.length&&this.skip.has(this.layer.chunk[this.chunkIndex]);)this.chunkIndex++;this.rangeIndex=0}else this.rangeIndex=t}nextChunk(){this.chunkIndex++,this.rangeIndex=0,this.next()}compare(t){return this.from-t.from||this.startSide-t.startSide||this.rank-t.rank||this.to-t.to||this.endSide-t.endSide}}class me{constructor(t){this.heap=t}static from(t,e=null,i=-1){let o=[];for(let n=0;n<t.length;n++)for(let s=t[n];!s.isEmpty;s=s.nextLayer)s.maxPoint>=i&&o.push(new pe(s,e,i,n));return 1==o.length?o[0]:new me(o)}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--)ge(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--)ge(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(),ge(this.heap,0)}}}function ge(t,e){for(let i=t[e];;){let o=1+(e<<1);if(o>=t.length)break;let n=t[o];if(o+1<t.length&&n.compare(t[o+1])>=0&&(n=t[o+1],o++),i.compare(n)<0)break;t[o]=i,t[e]=n,e=o}}class fe{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=me.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=Ce(this.active,this.activeTo)}addActive(t){let e=0,{value:i,to:o,rank:n}=this.cursor;for(;e<this.activeRank.length&&(n-this.activeRank[e]||o-this.activeTo[e])>0;)e++;we(this.active,e,i),we(this.activeTo,e,o),we(this.activeRank,e,n),t&&we(t,e,this.cursor.from),this.minActive=Ce(this.active,this.activeTo)}next(){let t=this.to,e=this.point;this.point=null;let i=this.openStart<0?[]:null;for(;;){let o=this.minActive;if(o>-1&&(this.activeTo[o]-this.cursor.from||this.active[o].endSide-this.cursor.startSide)<0){if(this.activeTo[o]>t){this.to=this.activeTo[o],this.endSide=this.active[o].endSide;break}this.removeActive(o),i&&ve(i,o)}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<this.cursor.to)){this.point=t,this.pointFrom=this.cursor.from,this.pointRank=this.cursor.rank,this.to=this.cursor.to,this.endSide=t.endSide,this.cursor.next(),this.forward(this.to,this.endSide);break}this.cursor.next()}else this.addActive(i),this.cursor.next()}}}if(i){this.openStart=0;for(let e=i.length-1;e>=0&&i[e]<t;e--)this.openStart++}}activeForPoint(t){if(!this.active.length)return this.active;let e=[];for(let i=this.active.length-1;i>=0&&!(this.activeRank[i]<this.pointRank);i--)(this.activeTo[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 be(t,e,i,o,n,s){t.goto(e),i.goto(o);let r=o+n,a=o,l=o-e,c=!!s.boundChange;for(let e=!1;;){let o=t.to+l-i.to,n=o||t.endSide-i.endSide,h=n<0?t.to+l:i.to,d=Math.min(h,r);if(t.point||i.point?(t.point&&i.point&&re(t.point,i.point)&&ye(t.activeForPoint(t.to),i.activeForPoint(i.to))||s.comparePoint(a,d,t.point,i.point),e=!1):(e&&s.boundChange(a),d>a&&!ye(t.active,i.active)&&s.compareRange(a,d,t.active,i.active),c&&d<r&&(o||t.openEnd(h)!=i.openEnd(h))&&(e=!0)),h>r)break;a=h,n<=0&&t.next(),n>=0&&i.next()}}function ye(t,e){if(t.length!=e.length)return!1;for(let i=0;i<t.length;i++)if(t[i]!=e[i]&&!re(t[i],e[i]))return!1;return!0}function ve(t,e){for(let i=e,o=t.length-1;i<o;i++)t[i]=t[i+1];t.pop()}function we(t,e,i){for(let i=t.length-1;i>=e;i--)t[i+1]=t[i];t[e]=i}function Ce(t,e){let i=-1,o=1e9;for(let n=0;n<e.length;n++)(e[n]-o||t[n].endSide-t[i].endSide)<0&&(i=n,o=e[n]);return i}const xe="undefined"==typeof Symbol?"__ͼ":Symbol.for("ͼ"),ke="undefined"==typeof Symbol?"__styleSet"+Math.floor(1e8*Math.random()):Symbol("styleSet"),Se="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:{};class Te{constructor(t,e){this.rules=[];let{finish:i}=e||{};function o(t){return/^@/.test(t)?[t]:t.split(/,\s*/)}function n(t,e,s,r){let a=[],l=/^@(\w+)\b/.exec(t[0]),c=l&&"keyframes"==l[1];if(l&&null==e)return s.push(t[0]+";");for(let i in e){let r=e[i];if(/&/.test(i))n(i.split(/,\s*/).map(e=>t.map(t=>e.replace(/&/,t))).reduce((t,e)=>t.concat(e)),r,s);else if(r&&"object"==typeof r){if(!l)throw new RangeError("The value of a property ("+i+") should be a primitive value.");n(o(i),r,a,c)}else null!=r&&a.push(i.replace(/_.*/,"").replace(/[A-Z]/g,t=>"-"+t.toLowerCase())+": "+r+";")}(a.length||c)&&s.push((!i||l||r?t:t.map(i)).join(", ")+" {"+a.join(" ")+"}")}for(let e in t)n(o(e),t[e],this.rules)}getRules(){return this.rules.join("\n")}static newName(){let t=Se[xe]||1;return Se[xe]=t+1,"ͼ"+t.toString(36)}static mount(t,e,i){let o=t[ke],n=i&&i.nonce;o?n&&o.setNonce(n):o=new Me(t,n),o.mount(Array.isArray(e)?e:[e],t)}}let Ee=new Map;class Me{constructor(t,e){let i=t.ownerDocument||t,o=i.defaultView;if(!t.head&&t.adoptedStyleSheets&&o.CSSStyleSheet){let e=Ee.get(i);if(e)return t[ke]=e;this.sheet=new o.CSSStyleSheet,Ee.set(i,this)}else this.styleTag=i.createElement("style"),e&&this.styleTag.setAttribute("nonce",e);this.modules=[],t[ke]=this}mount(t,e){let i=this.sheet,o=0,n=0;for(let e=0;e<t.length;e++){let s=t[e],r=this.modules.indexOf(s);if(r<n&&r>-1&&(this.modules.splice(r,1),n--,r=-1),-1==r){if(this.modules.splice(n++,0,s),i)for(let t=0;t<s.rules.length;t++)i.insertRule(s.rules[t],o++)}else{for(;n<r;)o+=this.modules[n++].rules.length;o+=s.rules.length,n++}}if(i)e.adoptedStyleSheets.indexOf(this.sheet)<0&&(e.adoptedStyleSheets=[this.sheet,...e.adoptedStyleSheets]);else{let t="";for(let e=0;e<this.modules.length;e++)t+=this.modules[e].getRules()+"\n";this.styleTag.textContent=t;let i=e.head||e;this.styleTag.parentNode!=i&&i.insertBefore(this.styleTag,i.firstChild)}}setNonce(t){this.styleTag&&this.styleTag.getAttribute("nonce")!=t&&this.styleTag.setAttribute("nonce",t)}}var Ae={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},Ie={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",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++)Ae[48+De]=Ae[96+De]=String(De);for(De=1;De<=24;De++)Ae[De+111]="F"+De;for(De=65;De<=90;De++)Ae[De]=String.fromCharCode(De+32),Ie[De]=String.fromCharCode(De);for(var Oe in Ae)Ie.hasOwnProperty(Oe)||(Ie[Oe]=Ae[Oe]);let Be="undefined"!=typeof navigator?navigator:{userAgent:"",vendor:"",platform:""},Le="undefined"!=typeof document?document:{documentElement:{style:{}}};const Ne=/Edge\/(\d+)/.exec(Be.userAgent),qe=/MSIE \d/.test(Be.userAgent),Re=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Be.userAgent),Fe=!!(qe||Re||Ne),Pe=!Fe&&/gecko\/(\d+)/i.test(Be.userAgent),_e=!Fe&&/Chrome\/(\d+)/.exec(Be.userAgent),Ve="webkitFontSmoothing"in Le.documentElement.style,ze=!Fe&&/Apple Computer/.test(Be.vendor),He=ze&&(/Mobile\/\w+/.test(Be.userAgent)||Be.maxTouchPoints>2);var We={mac:He||/Mac/.test(Be.platform),windows:/Win/.test(Be.platform),linux:/Linux|X11/.test(Be.platform),ie:Fe,ie_version:qe?Le.documentMode||6:Re?+Re[1]:Ne?+Ne[1]:0,gecko:Pe,gecko_version:Pe?+(/Firefox\/(\d+)/.exec(Be.userAgent)||[0,0])[1]:0,chrome:!!_e,chrome_version:_e?+_e[1]:0,ios:He,android:/Android\b/.test(Be.userAgent),webkit:Ve,webkit_version:Ve?+(/\bAppleWebKit\/(\d+)/.exec(Be.userAgent)||[0,0])[1]:0,safari:ze,safari_version:ze?+(/\bVersion\/(\d+(\.\d+)?)/.exec(Be.userAgent)||[0,0])[1]:0,tabSize:null!=Le.documentElement.style.tabSize?"tab-size":"-moz-tab-size"};function $e(t,e){for(let i in t)"class"==i&&e.class?e.class+=" "+t.class:"style"==i&&e.style?e.style+=";"+t.style:e[i]=t[i];return e}const Ue=Object.create(null);function je(t,e,i){if(t==e)return!0;t||(t=Ue),e||(e=Ue);let o=Object.keys(t),n=Object.keys(e);if(o.length-(i&&o.indexOf(i)>-1?1:0)!=n.length-(i&&n.indexOf(i)>-1?1:0))return!1;for(let s of o)if(s!=i&&(-1==n.indexOf(s)||t[s]!==e[s]))return!1;return!0}function Ye(t,e,i){let o=!1;if(e)for(let n in e)i&&n in i||(o=!0,"style"==n?t.style.cssText="":t.removeAttribute(n));if(i)for(let n in i)e&&e[n]==i[n]||(o=!0,"style"==n?t.style.cssText=i[n]:t.setAttribute(n,i[n]));return o}function Ge(t){let e=Object.create(null);for(let i=0;i<t.attributes.length;i++){let o=t.attributes[i];e[o.name]=o.value}return e}class Ze{eq(t){return!1}updateDOM(t,e){return!1}compare(t){return this==t||this.constructor==t.constructor&&this.eq(t)}get estimatedHeight(){return-1}get lineBreaks(){return 0}ignoreEvent(t){return!0}coordsAt(t,e,i){return null}get isHidden(){return!1}get editable(){return!1}destroy(t){}}var Ke=function(t){return t[t.Text=0]="Text",t[t.WidgetBefore=1]="WidgetBefore",t[t.WidgetAfter=2]="WidgetAfter",t[t.WidgetRange=3]="WidgetRange",t}(Ke||(Ke={}));class Je extends se{constructor(t,e,i,o){super(),this.startSide=t,this.endSide=e,this.widget=i,this.spec=o}get heightRelevant(){return!1}static mark(t){return new Xe(t)}static widget(t){let e=Math.max(-1e4,Math.min(1e4,t.side||0)),i=!!t.block;return e+=i&&!t.inlineOrder?e>0?3e8:-4e8:e>0?1e8:-1e8,new ti(t,e,e,i,t.widget||null,!1)}static replace(t){let e,i,o=!!t.block;if(t.isBlockGap)e=-5e8,i=4e8;else{let{start:n,end:s}=ei(t,o);e=(n?o?-3e8:-1:5e8)-1,i=1+(s?o?2e8:1:-6e8)}return new ti(t,e,i,o,t.widget||null,!0)}static line(t){return new Qe(t)}static set(t,e=!1){return he.of(t,e)}hasHeight(){return!!this.widget&&this.widget.estimatedHeight>-1}}Je.none=he.empty;class Xe extends Je{constructor(t){let{start:e,end:i}=ei(t);super(e?-1:5e8,i?1:-6e8,null,t),this.tagName=t.tagName||"span",this.attrs=t.class&&t.attributes?$e(t.attributes,{class:t.class}):t.class?{class:t.class}:t.attributes||Ue}eq(t){return this==t||t instanceof Xe&&this.tagName==t.tagName&&je(this.attrs,t.attrs)}range(t,e=t){if(t>=e)throw new RangeError("Mark decorations may not be empty");return super.range(t,e)}}Xe.prototype.point=!1;class Qe extends Je{constructor(t){super(-2e8,-2e8,null,t)}eq(t){return t instanceof Qe&&this.spec.class==t.spec.class&&je(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)}}Qe.prototype.mapMode=ot.TrackBefore,Qe.prototype.point=!0;class ti extends Je{constructor(t,e,i,o,n,s){super(e,i,n,t),this.block=o,this.isReplace=s,this.mapMode=o?e<=0?ot.TrackBefore:ot.TrackAfter:ot.TrackDel}get type(){return this.startSide!=this.endSide?Ke.WidgetRange:this.startSide<=0?Ke.WidgetBefore:Ke.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(t){return t instanceof ti&&(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 ei(t,e=!1){let{inclusiveStart:i,inclusiveEnd:o}=t;return null==i&&(i=t.inclusive),null==o&&(o=t.inclusive),{start:null!=i?i:e,end:null!=o?o:e}}function ii(t,e,i,o=0){let n=i.length-1;n>=0&&i[n]+o>=t?i[n]=Math.max(i[n],e):i.push(t,e)}ti.prototype.point=!0;class oi extends se{constructor(t,e){super(),this.tagName=t,this.attributes=e}eq(t){return t==this||t instanceof oi&&this.tagName==t.tagName&&je(this.attributes,t.attributes)}static create(t){return new oi(t.tagName,t.attributes||Ue)}static set(t,e=!1){return he.of(t,e)}}function ni(t){let e;return e=11==t.nodeType?t.getSelection?t:t.ownerDocument:t,e.getSelection()}function si(t,e){return!!e&&(t==e||t.contains(1!=e.nodeType?e.parentNode:e))}function ri(t,e){if(!e.anchorNode)return!1;try{return si(t,e.anchorNode)}catch(t){return!1}}function ai(t){return 3==t.nodeType?wi(t,0,t.nodeValue.length).getClientRects():1==t.nodeType?t.getClientRects():[]}function li(t,e,i,o){return!!i&&(di(t,e,i,o,-1)||di(t,e,i,o,1))}function ci(t){for(var e=0;;e++)if(!(t=t.previousSibling))return e}function hi(t){return 1==t.nodeType&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(t.nodeName)}function di(t,e,i,o,n){for(;;){if(t==i&&e==o)return!0;if(e==(n<0?0:ui(t))){if("DIV"==t.nodeName)return!1;let i=t.parentNode;if(!i||1!=i.nodeType)return!1;e=ci(t)+(n<0?0:1),t=i}else{if(1!=t.nodeType)return!1;if(1==(t=t.childNodes[e+(n<0?-1:0)]).nodeType&&"false"==t.contentEditable)return!1;e=n<0?ui(t):0}}}function ui(t){return 3==t.nodeType?t.nodeValue.length:t.childNodes.length}function pi(t,e){let i=e?t.left:t.right;return{left:i,right:i,top:t.top,bottom:t.bottom}}function mi(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 gi(t,e){let i=e.width/t.offsetWidth,o=e.height/t.offsetHeight;return(i>.995&&i<1.005||!isFinite(i)||Math.abs(e.width-t.offsetWidth)<1)&&(i=1),(o>.995&&o<1.005||!isFinite(o)||Math.abs(e.height-t.offsetHeight)<1)&&(o=1),{scaleX:i,scaleY:o}}oi.prototype.startSide=oi.prototype.endSide=-1;class fi{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?ui(e):0),i,Math.min(t.focusOffset,i?ui(i):0))}set(t,e,i,o){this.anchorNode=t,this.anchorOffset=e,this.focusNode=i,this.focusOffset=o}}let bi,yi=null;function vi(t){if(t.setActive)return t.setActive();if(yi)return t.focus(yi);let e=[];for(let i=t;i&&(e.push(i,i.scrollTop,i.scrollLeft),i!=i.ownerDocument);i=i.parentNode);if(t.focus(null==yi?{get preventScroll(){return yi={preventScroll:!0},!0}}:void 0),!yi){yi=!1;for(let t=0;t<e.length;){let i=e[t++],o=e[t++],n=e[t++];i.scrollTop!=o&&(i.scrollTop=o),i.scrollLeft!=n&&(i.scrollLeft=n)}}}function wi(t,e,i=e){let o=bi||(bi=document.createRange());return o.setEnd(t,i),o.setStart(t,e),o}function Ci(t,e,i,o){let n={key:e,code:e,keyCode:i,which:i,cancelable:!0};o&&({altKey:n.altKey,ctrlKey:n.ctrlKey,shiftKey:n.shiftKey,metaKey:n.metaKey}=o);let s=new KeyboardEvent("keydown",n);s.synthetic=!0,t.dispatchEvent(s);let r=new KeyboardEvent("keyup",n);return r.synthetic=!0,t.dispatchEvent(r),s.defaultPrevented||r.defaultPrevented}function xi(t){return t.scrollTop>Math.max(1,t.scrollHeight-t.clientHeight-4)}function ki(t,e){for(let i=t,o=e;;){if(3==i.nodeType&&o>0)return{node:i,offset:o};if(1==i.nodeType&&o>0){if("false"==i.contentEditable)return null;i=i.childNodes[o-1],o=ui(i)}else{if(!i.parentNode||hi(i))return null;o=ci(i),i=i.parentNode}}}function Si(t,e){for(let i=t,o=e;;){if(3==i.nodeType&&o<i.nodeValue.length)return{node:i,offset:o};if(1==i.nodeType&&o<i.childNodes.length){if("false"==i.contentEditable)return null;i=i.childNodes[o],o=0}else{if(!i.parentNode||hi(i))return null;o=ci(i)+1,i=i.parentNode}}}We.safari&&We.safari_version>=26&&(yi=!1);class Ti{constructor(t,e,i=!0){this.node=t,this.offset=e,this.precise=i}static before(t,e){return new Ti(t.parentNode,ci(t),e)}static after(t,e){return new Ti(t.parentNode,ci(t)+1,e)}}var Ei=function(t){return t[t.LTR=0]="LTR",t[t.RTL=1]="RTL",t}(Ei||(Ei={}));const Mi=Ei.LTR,Ai=Ei.RTL;function Ii(t){let e=[];for(let i=0;i<t.length;i++)e.push(1<<+t[i]);return e}const Di=Ii("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),Oi=Ii("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),Bi=Object.create(null),Li=[];for(let t of["()","[]","{}"]){let e=t.charCodeAt(0),i=t.charCodeAt(1);Bi[e]=i,Bi[i]=-e}function Ni(t){return t<=247?Di[t]:1424<=t&&t<=1524?2:1536<=t&&t<=1785?Oi[t-1536]:1774<=t&&t<=2220?4:8192<=t&&t<=8204?256:64336<=t&&t<=65023?4:1}const qi=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/;class Ri{get dir(){return this.level%2?Ai:Mi}constructor(t,e,i){this.from=t,this.to=e,this.level=i}side(t,e){return this.dir==e==t?this.to:this.from}forward(t,e){return t==(this.dir==e)}static find(t,e,i,o){let n=-1;for(let s=0;s<t.length;s++){let r=t[s];if(r.from<=e&&r.to>=e){if(r.level==i)return s;(n<0||(0!=o?o<0?r.from<e:r.to>e:t[n].level>r.level))&&(n=s)}}if(n<0)throw new RangeError("Index out of range");return n}}function Fi(t,e){if(t.length!=e.length)return!1;for(let i=0;i<t.length;i++){let o=t[i],n=e[i];if(o.from!=n.from||o.to!=n.to||o.direction!=n.direction||!Fi(o.inner,n.inner))return!1}return!0}const Pi=[];function _i(t,e,i,o,n,s,r){let a=o%2?2:1;if(o%2==n%2)for(let l=e,c=0;l<i;){let e=!0,h=!1;if(c==s.length||l<s[c].from){let t=Pi[l];t!=a&&(e=!1,h=16==t)}let d=e||1!=a?null:[],u=e?o:o+1,p=l;t:for(;;)if(c<s.length&&p==s[c].from){if(h)break t;let m=s[c];if(!e)for(let t=m.to,e=c+1;;){if(t==i)break t;if(!(e<s.length&&s[e].from==t)){if(Pi[t]==a)break t;break}t=s[e++].to}if(c++,d)d.push(m);else{m.from>l&&r.push(new Ri(l,m.from,u)),Vi(t,m.direction==Mi!=!(u%2)?o+1:o,n,m.inner,m.from,m.to,r),l=m.to}p=m.to}else{if(p==i||(e?Pi[p]!=a:Pi[p]==a))break;p++}d?_i(t,l,p,o+1,n,d,r):l<p&&r.push(new Ri(l,p,u)),l=p}else for(let l=i,c=s.length;l>e;){let i=!0,h=!1;if(!c||l>s[c-1].to){let t=Pi[l-1];t!=a&&(i=!1,h=16==t)}let d=i||1!=a?null:[],u=i?o:o+1,p=l;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(Pi[t-1]==a)break t;break}t=s[--i].from}if(d)d.push(m);else{m.to<l&&r.push(new Ri(m.to,l,u)),Vi(t,m.direction==Mi!=!(u%2)?o+1:o,n,m.inner,m.from,m.to,r),l=m.from}p=m.from}else{if(p==e||(i?Pi[p-1]!=a:Pi[p-1]==a))break;p--}d?_i(t,p,l,o+1,n,d,r):p<l&&r.push(new Ri(p,l,u)),l=p}}function Vi(t,e,i,o,n,s,r){let a=e%2?2:1;!function(t,e,i,o,n){for(let s=0;s<=o.length;s++){let r=s?o[s-1].to:e,a=s<o.length?o[s].from:i,l=s?256:n;for(let e=r,i=l,o=l;e<a;e++){let n=Ni(t.charCodeAt(e));512==n?n=i:8==n&&4==o&&(n=16),Pi[e]=4==n?2:n,7&n&&(o=n),i=n}for(let t=r,e=l,o=l;t<a;t++){let n=Pi[t];if(128==n)t<a-1&&e==Pi[t+1]&&24&e?n=Pi[t]=e:Pi[t]=256;else if(64==n){let n=t+1;for(;n<a&&64==Pi[n];)n++;let s=t&&8==e||n<i&&8==Pi[n]?1==o?1:8:256;for(let e=t;e<n;e++)Pi[e]=s;t=n-1}else 8==n&&1==o&&(Pi[t]=1);e=n,7&n&&(o=n)}}}(t,n,s,o,a),function(t,e,i,o,n){let s=1==n?2:1;for(let r=0,a=0,l=0;r<=o.length;r++){let c=r?o[r-1].to:e,h=r<o.length?o[r].from:i;for(let e,i,o,r=c;r<h;r++)if(i=Bi[e=t.charCodeAt(r)])if(i<0){for(let t=a-3;t>=0;t-=3)if(Li[t+1]==-i){let e=Li[t+2],i=2&e?n:4&e?1&e?s:n:0;i&&(Pi[r]=Pi[Li[t]]=i),a=t;break}}else{if(189==Li.length)break;Li[a++]=r,Li[a++]=e,Li[a++]=l}else if(2==(o=Pi[r])||1==o){let t=o==n;l=t?0:1;for(let e=a-3;e>=0;e-=3){let i=Li[e+2];if(2&i)break;if(t)Li[e+2]|=2;else{if(4&i)break;Li[e+2]|=4}}}}}(t,n,s,o,a),function(t,e,i,o){for(let n=0,s=o;n<=i.length;n++){let r=n?i[n-1].to:t,a=n<i.length?i[n].from:e;for(let l=r;l<a;){let r=Pi[l];if(256==r){let r=l+1;for(;;)if(r==a){if(n==i.length)break;r=i[n++].to,a=n<i.length?i[n].from:e}else{if(256!=Pi[r])break;r++}let c=1==s,h=c==(1==(r<e?Pi[r]:o))?c?1:2:o;for(let e=r,o=n,s=o?i[o-1].to:t;e>l;)e==s&&(e=i[--o].from,s=o?i[o-1].to:t),Pi[--e]=h;l=r}else s=r,l++}}}(n,s,o,a),_i(t,n,s,e,i,o,r)}function zi(t){return[new Ri(0,t,0)]}let Hi="";function Wi(t,e,i,o,n){var s;let r=o.head-t.from,a=Ri.find(e,r,null!==(s=o.bidiLevel)&&void 0!==s?s:-1,o.assoc),l=e[a],c=l.side(n,i);if(r==c){let t=a+=n?1:-1;if(t<0||t>=e.length)return null;l=e[a=t],r=l.side(!n,i),c=l.side(n,i)}let h=et(t.text,r,l.forward(n,i));(h<l.from||h>l.to)&&(h=c),Hi=t.text.slice(Math.min(r,h),Math.max(r,h));let d=a==(n?e.length-1:0)?null:e[a+(n?1:-1)];return d&&h==c&&d.level+(n?0:1)<l.level?pt.cursor(d.side(!n,i)+t.from,d.forward(n,i)?1:-1,d.level):pt.cursor(h+t.from,l.forward(n,i)?-1:1,l.level)}function $i(t,e,i){for(let o=e;o<i;o++){let e=Ni(t.charCodeAt(o));if(1==e)return Mi;if(2==e||4==e)return Ai}return Mi}const Ui=ft.define(),ji=ft.define(),Yi=ft.define(),Gi=ft.define(),Zi=ft.define(),Ki=ft.define(),Ji=ft.define(),Xi=ft.define(),Qi=ft.define(),to=ft.define({combine:t=>t.some(t=>t)}),eo=ft.define({combine:t=>t.some(t=>t)}),io=ft.define();class oo{constructor(t,e="nearest",i="nearest",o=5,n=5,s=!1){this.range=t,this.y=e,this.x=i,this.yMargin=o,this.xMargin=n,this.isSnapshot=s}map(t){return t.empty?this:new oo(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 oo(pt.cursor(t.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const no=jt.define({map:(t,e)=>t.map(e)}),so=jt.define();function ro(t,e,i){let o=t.facet(Gi);o.length?o[0](e):window.onerror&&window.onerror(String(e),i,void 0,void 0,e)||(i?console.error(i+":",e):console.error(e))}const ao=ft.define({combine:t=>!t.length||t[0]});let lo=0;const co=ft.define({combine:t=>t.filter((e,i)=>{for(let o=0;o<i;o++)if(t[o].plugin==e.plugin)return!1;return!0})});class ho{constructor(t,e,i,o,n){this.id=t,this.create=e,this.domEventHandlers=i,this.domEventObservers=o,this.baseExtensions=n(this),this.extension=this.baseExtensions.concat(co.of({plugin:this,arg:void 0}))}of(t){return this.baseExtensions.concat(co.of({plugin:this,arg:t}))}static define(t,e){const{eventHandlers:i,eventObservers:o,provide:n,decorations:s}=e||{};return new ho(lo++,t,i,o,t=>{let e=[];return s&&e.push(go.of(e=>{let i=e.plugin(t);return i?s(i):Je.none})),n&&e.push(n(t)),e})}static fromClass(t,e){return ho.define((e,i)=>new t(e,i),e)}}class uo{constructor(t){this.spec=t,this.mustUpdate=null,this.value=null}get plugin(){return this.spec&&this.spec.plugin}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(ro(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.plugin.create(t,this.spec.arg)}catch(e){ro(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){ro(t.state,e,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const po=ft.define(),mo=ft.define(),go=ft.define(),fo=ft.define(),bo=ft.define(),yo=ft.define(),vo=ft.define();function wo(t,e){let i=t.state.facet(vo);if(!i.length)return i;let o=i.map(e=>e instanceof Function?e(t):e),n=[];return he.spans(o,e.from,e.to,{point(){},span(t,i,o,s){let r=t-e.from,a=i-e.from,l=n;for(let t=o.length-1;t>=0;t--,s--){let i,n=o[t].spec.bidiIsolate;if(null==n&&(n=$i(e.text,r,a)),s>0&&l.length&&(i=l[l.length-1]).to==r&&i.direction==n)i.to=a,l=i.inner;else{let t={from:r,to:a,direction:n,inner:[]};l.push(t),l=t.inner}}}}),n}const Co=ft.define();function xo(t){let e=0,i=0,o=0,n=0;for(let s of t.state.facet(Co)){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&&(o=Math.max(o,r.top)),null!=r.bottom&&(n=Math.max(n,r.bottom)))}return{left:e,right:i,top:o,bottom:n}}const ko=ft.define();class So{constructor(t,e,i,o){this.fromA=t,this.toA=e,this.fromB=i,this.toB=o}join(t){return new So(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 o=t[e-1];if(!(o.fromA>i.toA)){if(o.toA<i.fromA)break;i=i.join(o),t.splice(e-1,1)}}return t.splice(e,0,i),t}static extendWithRanges(t,e){if(0==e.length)return t;let i=[];for(let o=0,n=0,s=0;;){let r=o<t.length?t[o].fromB:1e9,a=n<e.length?e[n]:1e9,l=Math.min(r,a);if(1e9==l)break;let c=l+s,h=l,d=c;for(;;)if(n<e.length&&e[n]<=h){let i=e[n+1];n+=2,h=Math.max(h,i);for(let e=o;e<t.length&&t[e].fromB<=h;e++)s=t[e].toA-t[e].toB;d=Math.max(d,i+s)}else{if(!(o<t.length&&t[o].fromB<=h))break;{let e=t[o++];h=Math.max(h,e.toB),d=Math.max(d,e.toA),s=e.toA-e.toB}}i.push(new So(c,d,l,h))}return i}}class To{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 o=[];this.changes.iterChangedRanges((t,e,i,n)=>o.push(new So(t,e,i,n))),this.changedRanges=o}static create(t,e,i){return new To(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}}const Eo=[];class Mo{constructor(t,e,i=0){this.dom=t,this.length=e,this.flags=i,this.parent=null,t.cmTile=this}get breakAfter(){return 1&this.flags}get children(){return Eo}isWidget(){return!1}get isHidden(){return!1}isComposite(){return!1}isLine(){return!1}isText(){return!1}isBlock(){return!1}get domAttrs(){return null}sync(t){if(this.flags|=2,4&this.flags){this.flags&=-5;let t=this.domAttrs;t&&function(t,e){for(let i=t.attributes.length-1;i>=0;i--){let o=t.attributes[i].name;null==e[o]&&t.removeAttribute(o)}for(let i in e){let o=e[i];"style"==i?t.style.cssText=o:t.getAttribute(i)!=o&&t.setAttribute(i,o)}}(this.dom,t)}}toString(){return this.constructor.name+(this.children.length?`(${this.children})`:"")+(this.breakAfter?"#":"")}destroy(){this.parent=null}setDOM(t){this.dom=t,t.cmTile=this}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(t,e=this.posAtStart){let i=e;for(let e of this.children){if(e==t)return i;i+=e.length+e.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(t){return this.posBefore(t)+t.length}covers(t){return!0}coordsIn(t,e){return null}domPosFor(t,e){let i=ci(this.dom),o=this.length?t>0:e>0;return new Ti(this.parent.dom,i+(o?1:0),0==t||t==this.length)}markDirty(t){this.flags&=-3,t&&(this.flags|=4),this.parent&&2&this.parent.flags&&this.parent.markDirty(!1)}get overrideDOMText(){return null}get root(){for(let t=this;t;t=t.parent)if(t instanceof Do)return t;return null}static get(t){return t.cmTile}}class Ao extends Mo{constructor(t){super(t,0),this._children=[]}isComposite(){return!0}get children(){return this._children}get lastChild(){return this.children.length?this.children[this.children.length-1]:null}append(t){this.children.push(t),t.parent=this}sync(t){if(2&this.flags)return;super.sync(t);let e,i=this.dom,o=null,n=(null==t?void 0:t.node)==i?t:null,s=0;for(let r of this.children){if(r.sync(t),s+=r.length+r.breakAfter,e=o?o.nextSibling:i.firstChild,n&&e!=r.dom&&(n.written=!0),r.dom.parentNode==i)for(;e&&e!=r.dom;)e=Io(e);else i.insertBefore(r.dom,e);o=r.dom}for(e=o?o.nextSibling:i.firstChild,n&&e&&(n.written=!0);e;)e=Io(e);this.length=s}}function Io(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class Do extends Ao{constructor(t,e){super(e),this.view=t}owns(t){for(;t;t=t.parent)if(t==this)return!0;return!1}isBlock(){return!0}nearest(t){for(;;){if(!t)return null;let e=Mo.get(t);if(e&&this.owns(e))return e;t=t.parentNode}}blockTiles(t){for(let e=[],i=this,o=0,n=0;;)if(o==i.children.length){if(!e.length)return;i=i.parent,i.breakAfter&&n++,o=e.pop()}else{let s=i.children[o++];if(s instanceof Oo)e.push(o),i=s,o=0;else{let e=n+s.length,i=t(s,n);if(void 0!==i)return i;n=e+s.breakAfter}}}resolveBlock(t,e){let i,o,n=-1,s=-1;if(this.blockTiles((r,a)=>{let l=a+r.length;if(t>=a&&t<=l){if(r.isWidget()&&e>=-1&&e<=1){if(32&r.flags)return!0;16&r.flags&&(i=void 0)}(a<t||t==l&&(e<-1?r.length:r.covers(1)))&&(!i||!r.isWidget()&&i.isWidget())&&(i=r,n=t-a),(l>t||t==a&&(e>1?r.length:r.covers(-1)))&&(!o||!r.isWidget()&&o.isWidget())&&(o=r,s=t-a)}}),!i&&!o)throw new Error("No tile at position "+t);return i&&e<0||!o?{tile:i,offset:n}:{tile:o,offset:s}}}class Oo extends Ao{constructor(t,e){super(t),this.wrapper=e}isBlock(){return!0}covers(t){return!!this.children.length&&(t<0?this.children[0].covers(-1):this.lastChild.covers(1))}get domAttrs(){return this.wrapper.attributes}static of(t,e){let i=new Oo(e||document.createElement(t.tagName),t);return e||(i.flags|=4),i}}class Bo extends Ao{constructor(t,e){super(t),this.attrs=e}isLine(){return!0}static start(t,e,i){let o=new Bo(e||document.createElement("div"),t);return e&&i||(o.flags|=4),o}get domAttrs(){return this.attrs}resolveInline(t,e,i){let o=null,n=-1,s=null,r=-1;!function t(a,l){for(let c=0,h=0;c<a.children.length&&h<=l;c++){let d=a.children[c],u=h+d.length;u>=l&&(d.isComposite()?t(d,l-h):(!s||s.isHidden&&(e>0||i&&Lo(s,d)))&&(u>l||32&d.flags)?(s=d,r=l-h):(h<l||16&d.flags&&!d.isHidden)&&(o=d,n=l-h)),h=u}}(this,t);let a=(e<0?o:s)||o||s;return a?{tile:a,offset:a==o?n:r}:null}coordsIn(t,e){let i=this.resolveInline(t,e,!0);return i?i.tile.coordsIn(Math.max(0,i.offset),e):function(t){let e=t.dom.lastChild;if(!e)return t.dom.getBoundingClientRect();let i=ai(e);return i[i.length-1]||null}(this)}domIn(t,e){let i=this.resolveInline(t,e);if(i){let{tile:t,offset:o}=i;if(this.dom.contains(t.dom))return t.isText()?new Ti(t.dom,Math.min(t.dom.nodeValue.length,o)):t.domPosFor(o,16&t.flags?1:32&t.flags?-1:e);let n=i.tile.parent,s=!1;for(let t of n.children){if(s)return new Ti(t.dom,0);t==i.tile&&(s=!0)}}return new Ti(this.dom,0)}}function Lo(t,e){let i=t.coordsIn(0,1),o=e.coordsIn(0,1);return i&&o&&o.top<i.bottom}class No extends Ao{constructor(t,e){super(t),this.mark=e}get domAttrs(){return this.mark.attrs}static of(t,e){let i=new No(e||document.createElement(t.tagName),t);return e||(i.flags|=4),i}}class qo extends Mo{constructor(t,e){super(t,e.length),this.text=e}sync(t){2&this.flags||(super.sync(t),this.dom.nodeValue!=this.text&&(t&&t.node==this.dom&&(t.written=!0),this.dom.nodeValue=this.text))}isText(){return!0}toString(){return JSON.stringify(this.text)}coordsIn(t,e){let i=this.dom.nodeValue.length;t>i&&(t=i);let o=t,n=t,s=0;0==t&&e<0||t==i&&e>=0?We.chrome||We.gecko||(t?(o--,s=1):n<i&&(n++,s=-1)):e<0?o--:n<i&&n++;let r=wi(this.dom,o,n).getClientRects();if(!r.length)return null;let a=r[(s?s<0:e>=0)?0:r.length-1];return We.safari&&!s&&0==a.width&&(a=Array.prototype.find.call(r,t=>t.width)||a),s?pi(a,s<0):a||null}static of(t,e){let i=new qo(e||document.createTextNode(t),t);return e||(i.flags|=2),i}}class Ro extends Mo{constructor(t,e,i,o){super(t,e,o),this.widget=i}isWidget(){return!0}get isHidden(){return this.widget.isHidden}covers(t){return!(48&this.flags)&&(this.flags&(t<0?64:128))>0}coordsIn(t,e){return this.coordsInWidget(t,e,!1)}coordsInWidget(t,e,i){let o=this.widget.coordsAt(this.dom,t,e);if(o)return o;if(i)return pi(this.dom.getBoundingClientRect(),this.length?0==t:e<=0);{let e=this.dom.getClientRects(),i=null;if(!e.length)return null;let o=!!(16&this.flags)||!(32&this.flags)&&t>0;for(let n=o?e.length-1:0;i=e[n],!(t>0?0==n:n==e.length-1||i.top<i.bottom);n+=o?-1:1);return pi(i,!o)}}get overrideDOMText(){if(!this.length)return U.empty;let{root:t}=this;if(!t)return U.empty;let e=this.posAtStart;return t.view.state.doc.slice(e,e+this.length)}destroy(){super.destroy(),this.widget.destroy(this.dom)}static of(t,e,i,o,n){return n||(n=t.toDOM(e),t.editable||(n.contentEditable="false")),new Ro(n,i,t,o)}}class Fo extends Mo{constructor(t){let e=document.createElement("img");e.className="cm-widgetBuffer",e.setAttribute("aria-hidden","true"),super(e,0,t)}get isHidden(){return!0}get overrideDOMText(){return U.empty}coordsIn(t){return this.dom.getBoundingClientRect()}}class Po{constructor(t){this.index=0,this.beforeBreak=!1,this.parents=[],this.tile=t}advance(t,e,i){let{tile:o,index:n,beforeBreak:s,parents:r}=this;for(;t||e>0;)if(o.isComposite())if(s){if(!t)break;i&&i.break(),t--,s=!1}else if(n==o.children.length){if(!t&&!r.length)break;i&&i.leave(o),s=!!o.breakAfter,({tile:o,index:n}=r.pop()),n++}else{let a=o.children[n],l=a.breakAfter;!(e>0?a.length<=t:a.length<t)||i&&!1===i.skip(a,0,a.length)&&a.isComposite?(r.push({tile:o,index:n}),o=a,n=0,i&&a.isComposite()&&i.enter(a)):(s=!!l,n++,t-=a.length)}else if(n==o.length)s=!!o.breakAfter,({tile:o,index:n}=r.pop()),n++;else{if(!t)break;{let e=Math.min(t,o.length-n);i&&i.skip(o,n,n+e),t-=e,n+=e}}return this.tile=o,this.index=n,this.beforeBreak=s,this}get root(){return this.parents.length?this.parents[0].tile:this.tile}}class _o{constructor(t,e,i,o){this.from=t,this.to=e,this.wrapper=i,this.rank=o}}class Vo{constructor(t,e,i){this.cache=t,this.root=e,this.blockWrappers=i,this.curLine=null,this.lastBlock=null,this.afterWidget=null,this.pos=0,this.wrappers=[],this.wrapperPos=0}addText(t,e,i,o){var n;this.flushBuffer();let s=this.ensureMarks(e,i),r=s.lastChild;if(!r||!r.isText()||8&r.flags)s.append(o||qo.of(t,null===(n=this.cache.find(qo))||void 0===n?void 0:n.dom));else{this.cache.reused.set(r,2),(s.children[s.children.length-1]=new qo(r.dom,r.text+t)).parent=s}this.pos+=t.length,this.afterWidget=null}addComposition(t,e){let i=this.curLine;i.dom!=e.line.dom&&(i.setDOM(this.cache.reused.has(e.line)?Yo(e.line.dom):e.line.dom),this.cache.reused.set(e.line,2));let o=i;for(let t=e.marks.length-1;t>=0;t--){let i=e.marks[t],n=o.lastChild;if(n instanceof No&&n.mark.eq(i.mark))n.dom!=i.dom&&n.setDOM(Yo(i.dom)),o=n;else{if(this.cache.reused.get(i)){let t=Mo.get(i.dom);t&&t.setDOM(Yo(i.dom))}let t=No.of(i.mark,i.dom);o.append(t),o=t}this.cache.reused.set(i,2)}let n=Mo.get(t.text);n&&this.cache.reused.set(n,2);let s=new qo(t.text,t.text.nodeValue);s.flags|=8,o.append(s)}addInlineWidget(t,e,i){let o=this.afterWidget&&48&t.flags&&(48&this.afterWidget.flags)==(48&t.flags);o||this.flushBuffer();let n=this.ensureMarks(e,i);o||16&t.flags||n.append(this.getBuffer(1)),n.append(t),this.pos+=t.length,this.afterWidget=t}addMark(t,e,i){this.flushBuffer(),this.ensureMarks(e,i).append(t),this.pos+=t.length,this.afterWidget=null}addBlockWidget(t){this.getBlockPos().append(t),this.pos+=t.length,this.lastBlock=t,this.endLine()}continueWidget(t){(this.afterWidget||this.lastBlock).length+=t,this.pos+=t}addLineStart(t,e){var i;t||(t=jo);let o=Bo.start(t,e||(null===(i=this.cache.find(Bo))||void 0===i?void 0:i.dom),!!e);this.getBlockPos().append(this.lastBlock=this.curLine=o)}addLine(t){this.getBlockPos().append(t),this.pos+=t.length,this.lastBlock=t,this.endLine()}addBreak(){this.lastBlock.flags|=1,this.endLine(),this.pos++}addLineStartIfNotCovered(t){this.blockPosCovered()||this.addLineStart(t)}ensureLine(t){this.curLine||this.addLineStart(t)}ensureMarks(t,e){var i;let o=this.curLine;for(let n=t.length-1;n>=0;n--){let s,r=t[n];if(e>0&&(s=o.lastChild)&&s instanceof No&&s.mark.eq(r))o=s,e--;else{let t=No.of(r,null===(i=this.cache.find(No,t=>t.mark.eq(r)))||void 0===i?void 0:i.dom);o.append(t),o=t,e=0}}return o}endLine(){if(this.curLine){this.flushBuffer();let t=this.curLine.lastChild;t&&Uo(this.curLine,!1)&&("BR"==t.dom.nodeName||!t.isWidget()||We.ios&&Uo(this.curLine,!0))||this.curLine.append(this.cache.findWidget(Zo,0,32)||new Ro(Zo.toDOM(),0,Zo,32)),this.curLine=this.afterWidget=null}}updateBlockWrappers(){this.wrapperPos>this.pos+1e4&&(this.blockWrappers.goto(this.pos),this.wrappers.length=0);for(let t=this.wrappers.length-1;t>=0;t--)this.wrappers[t].to<this.pos&&this.wrappers.splice(t,1);for(let t=this.blockWrappers;t.value&&t.from<=this.pos;t.next())if(t.to>=this.pos){let e=new _o(t.from,t.to,t.value,t.rank),i=this.wrappers.length;for(;i>0&&(this.wrappers[i-1].rank-e.rank||this.wrappers[i-1].to-e.to)<0;)i--;this.wrappers.splice(i,0,e)}this.wrapperPos=this.pos}getBlockPos(){var t;this.updateBlockWrappers();let e=this.root;for(let i of this.wrappers){let o=e.lastChild;if(i.from<this.pos&&o instanceof Oo&&o.wrapper.eq(i.wrapper))e=o;else{let o=Oo.of(i.wrapper,null===(t=this.cache.find(Oo,t=>t.wrapper.eq(i.wrapper)))||void 0===t?void 0:t.dom);e.append(o),e=o}}return e}blockPosCovered(){let t=this.lastBlock;return null!=t&&!t.breakAfter&&(!t.isWidget()||(160&t.flags)>0)}getBuffer(t){let e=2|(t<0?16:32),i=this.cache.find(Fo,void 0,1);return i&&(i.flags=e),i||new Fo(e)}flushBuffer(){!this.afterWidget||32&this.afterWidget.flags||(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}}class zo{constructor(t){this.skipCount=0,this.text="",this.textOff=0,this.cursor=t.iter()}skip(t){this.textOff+t<=this.text.length?this.textOff+=t:(this.skipCount+=t-(this.text.length-this.textOff),this.text="",this.textOff=0)}next(t){if(this.textOff==this.text.length){let{value:e,lineBreak:i,done:o}=this.cursor.next(this.skipCount);if(this.skipCount=0,o)throw new Error("Ran out of text content when drawing inline views");this.text=e;let n=this.textOff=Math.min(t,e.length);return i?null:e.slice(0,n)}let e=Math.min(this.text.length,this.textOff+t),i=this.text.slice(this.textOff,e);return this.textOff=e,i}}const Ho=[Ro,Bo,qo,No,Fo,Oo,Do];for(let t=0;t<Ho.length;t++)Ho[t].bucket=t;class Wo{constructor(t){this.view=t,this.buckets=Ho.map(()=>[]),this.index=Ho.map(()=>0),this.reused=new Map}add(t){let e=t.constructor.bucket,i=this.buckets[e];i.length<6?i.push(t):i[this.index[e]=(this.index[e]+1)%6]=t}find(t,e,i=2){let o=t.bucket,n=this.buckets[o],s=this.index[o];for(let t=n.length-1;t>=0;t--){let r=(t+s)%n.length,a=n[r];if((!e||e(a))&&!this.reused.has(a))return n.splice(r,1),r<s&&this.index[o]--,this.reused.set(a,i),a}return null}findWidget(t,e,i){let o=this.buckets[0];if(o.length)for(let n=0,s=0;;n++){if(n==o.length){if(s)return null;s=1,n=0}let r=o[n];if(!this.reused.has(r)&&(0==s?r.widget.compare(t):r.widget.constructor==t.constructor&&t.updateDOM(r.dom,this.view)))return o.splice(n,1),n<this.index[0]&&this.index[0]--,r.length==e&&(497&r.flags)==i?(this.reused.set(r,1),r):(this.reused.set(r,2),new Ro(r.dom,e,t,-498&r.flags|i))}}reuse(t){return this.reused.set(t,1),t}maybeReuse(t,e=2){if(!this.reused.has(t))return this.reused.set(t,e),t.dom}}class $o{constructor(t,e,i,o,n){this.view=t,this.decorations=o,this.disallowBlockEffectsFor=n,this.openWidget=!1,this.openMarks=0,this.cache=new Wo(t),this.text=new zo(t.state.doc),this.builder=new Vo(this.cache,new Do(t,t.contentDOM),he.iter(i)),this.cache.reused.set(e,2),this.old=new Po(e),this.reuseWalker={skip:(t,e,i)=>{if(this.cache.add(t),t.isComposite())return!1},enter:t=>this.cache.add(t),leave:()=>{},break:()=>{}}}run(t,e){let i=e&&this.getCompositionContext(e.text);for(let o=0,n=0,s=0;;){let r=s<t.length?t[s++]:null,a=r?r.fromA:this.old.root.length;if(a>o){let t=a-o;this.preserve(t,!s,!r),o=a,n+=t}if(!r)break;this.forward(r.fromA,r.toA),e&&r.fromA<=e.range.fromA&&r.toA>=e.range.toA?(this.emit(n,e.range.fromB),this.builder.addComposition(e,i),this.text.skip(e.range.toB-e.range.fromB),this.emit(e.range.toB,r.toB)):this.emit(n,r.toB),n=r.toB,o=r.toA}return this.builder.curLine&&this.builder.endLine(),this.builder.root}preserve(t,e,i){let o=function(t){let e=[];for(let i=t.parents.length;i>1;i--){let o=i==t.parents.length?t.tile:t.parents[i].tile;o instanceof No&&e.push(o.mark)}return e}(this.old),n=this.openMarks;this.old.advance(t,i?1:-1,{skip:(t,e,i)=>{if(t.isWidget())if(this.openWidget)this.builder.continueWidget(i-e);else{let s=i>0||e<t.length?Ro.of(t.widget,this.view,i-e,496&t.flags,this.cache.maybeReuse(t)):this.cache.reuse(t);256&s.flags?(s.flags&=-2,this.builder.addBlockWidget(s)):(this.builder.ensureLine(null),this.builder.addInlineWidget(s,o,n),n=o.length)}else if(t.isText())this.builder.ensureLine(null),e||i!=t.length?(this.cache.add(t),this.builder.addText(t.text.slice(e,i),o,n)):this.builder.addText(t.text,o,n,this.cache.reuse(t)),n=o.length;else if(t.isLine())t.flags&=-2,this.cache.reused.set(t,1),this.builder.addLine(t);else if(t instanceof Fo)this.cache.add(t);else{if(!(t instanceof No))return!1;this.builder.ensureLine(null),this.builder.addMark(t,o,n),this.cache.reused.set(t,1),n=o.length}this.openWidget=!1},enter:t=>{t.isLine()?this.builder.addLineStart(t.attrs,this.cache.maybeReuse(t)):(this.cache.add(t),t instanceof No&&o.unshift(t.mark)),this.openWidget=!1},leave:t=>{t.isLine()?o.length&&(o.length=n=0):t instanceof No&&(o.shift(),n=Math.min(n,o.length))},break:()=>{this.builder.addBreak(),this.openWidget=!1}}),this.text.skip(t)}emit(t,e){let i=null,o=this.builder,n=0,s=he.spans(this.decorations,t,e,{point:(t,e,s,r,a,l)=>{if(s instanceof ti){if(this.disallowBlockEffectsFor[l]){if(s.block)throw new RangeError("Block decorations may not be specified via plugins");if(e>this.view.state.doc.lineAt(t).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}if(n=r.length,a>r.length)o.continueWidget(e-t);else{let n=s.widget||(s.block?Go.block:Go.inline),l=function(t){let e=t.isReplace?(t.startSide<0?64:0)|(t.endSide>0?128:0):t.startSide>0?32:16;t.block&&(e|=256);return e}(s),c=this.cache.findWidget(n,e-t,l)||Ro.of(n,this.view,e-t,l);s.block?(s.startSide>0&&o.addLineStartIfNotCovered(i),o.addBlockWidget(c)):(o.ensureLine(i),o.addInlineWidget(c,r,a))}i=null}else i=function(t,e){let i=e.spec.attributes,o=e.spec.class;if(!i&&!o)return t;t||(t={class:"cm-line"});i&&$e(i,t);o&&(t.class+=" "+o);return t}(i,s);e>t&&this.text.skip(e-t)},span:(t,e,n,s)=>{for(let r=t;r<e;){let t=this.text.next(Math.min(512,e-r));null==t?(o.addLineStartIfNotCovered(i),o.addBreak(),r++):(o.ensureLine(i),o.addText(t,n,s),r+=t.length),i=null}}});o.addLineStartIfNotCovered(i),this.openWidget=s>n,this.openMarks=s}forward(t,e){e-t<=10?this.old.advance(e-t,1,this.reuseWalker):(this.old.advance(5,-1,this.reuseWalker),this.old.advance(e-t-10,-1),this.old.advance(5,1,this.reuseWalker))}getCompositionContext(t){let e=[],i=null;for(let o=t.parentNode;;o=o.parentNode){let t=Mo.get(o);if(o==this.view.contentDOM)break;t instanceof No?e.push(t):(null==t?void 0:t.isLine())?i=t:"DIV"!=o.nodeName||i||o==this.view.contentDOM?e.push(No.of(new Xe({tagName:o.nodeName.toLowerCase(),attributes:Ge(o)}),o)):i=new Bo(o,jo)}return{line:i,marks:e}}}function Uo(t,e){let i=t=>{for(let o of t.children)if((e?o.isText():o.length)||i(o))return!0;return!1};return i(t)}const jo={class:"cm-line"};function Yo(t){let e=Mo.get(t);return e&&e.setDOM(t.cloneNode()),t}class Go extends Ze{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}}Go.inline=new Go("span"),Go.block=new Go("div");const Zo=new class extends Ze{toDOM(){return document.createElement("br")}get isHidden(){return!0}get editable(){return!0}};class Ko{constructor(t){this.view=t,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=Je.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.updateDeco(),this.tile=new Do(t,t.contentDOM),this.updateInner([new So(0,0,0,t.state.doc.length)],null)}update(t){var e;let i=t.changedRanges;this.minWidth>0&&i.length&&(i.every(({fromA:t,toA:e})=>e<this.minWidthFrom||t>this.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 o=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&((null===(e=this.domChanged)||void 0===e?void 0:e.newSel)?o=this.domChanged.newSel.head:function(t,e){let i=!1;e&&t.iterChangedRanges((t,o)=>{t<e.to&&o>e.from&&(i=!0)});return i}(t.changes,this.hasComposition)||t.selectionSet||(o=t.state.selection.main.head));let n=o>-1?function(t,e,i){let o=Xo(t,i);if(!o)return null;let{node:n,from:s,to:r}=o,a=n.nodeValue;if(/[\n\r]/.test(a))return null;if(t.state.doc.sliceString(o.from,o.to)!=a)return null;let l=e.invertedDesc;return{range:new So(l.mapPos(s),l.mapPos(r),s,r),text:n}}(this.view,t.changes,o):null;if(this.domChanged=null,this.hasComposition){let{from:e,to:o}=this.hasComposition;i=new So(e,o,t.changes.mapPos(e,-1),t.changes.mapPos(o,1)).addToSet(i.slice())}this.hasComposition=n?{from:n.range.fromB,to:n.range.toB}:null,(We.ie||We.chrome)&&!n&&t&&t.state.doc.lines!=t.startState.doc.lines&&(this.forceSelection=!0);let s=this.decorations,r=this.blockWrappers;this.updateDeco();let a=function(t,e,i){let o=new Qo;return he.compare(t,e,i,o),o.changes}(s,this.decorations,t.changes);a.length&&(i=So.extendWithRanges(i,a));let l=function(t,e,i){let o=new tn;return he.compare(t,e,i,o),o.changes}(r,this.blockWrappers,t.changes);return l.length&&(i=So.extendWithRanges(i,l)),n&&!i.some(t=>t.fromA<=n.range.fromA&&t.toA>=n.range.toA)&&(i=n.range.addToSet(i.slice())),!(2&this.tile.flags&&0==i.length)&&(this.updateInner(i,n),t.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(t,e){this.view.viewState.mustMeasureContent=!0;let{observer:i}=this.view;i.ignore(()=>{if(e||t.length){let i=this.tile,o=new $o(this.view,i,this.blockWrappers,this.decorations,this.dynamicDecorationMap);this.tile=o.run(t,e),Jo(i,o.cache.reused)}this.tile.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.tile.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let o=We.chrome||We.ios?{node:i.selectionRange.focusNode,written:!1}:void 0;this.tile.sync(o),!o||!o.written&&i.selectionRange.focusNode==o.node&&this.tile.dom.contains(o.node)||(this.forceSelection=!0),this.tile.dom.style.height=""});let o=[];if(this.view.viewport.from||this.view.viewport.to<this.view.state.doc.length)for(let t of this.tile.children)t.isWidget()&&t.widget instanceof en&&o.push(t.dom);i.updateGaps(o)}updateEditContextFormatting(t){this.editContextFormatting=this.editContextFormatting.map(t.changes);for(let e of t.transactions)for(let t of e.effects)t.is(so)&&(this.editContextFormatting=t.value)}updateSelection(t=!1,e=!1){!t&&this.view.observer.selectionRange.focusNode||this.view.observer.readSelectionRange();let{dom:i}=this.tile,o=this.view.root.activeElement,n=o==i,s=!n&&!(this.view.state.facet(ao)||i.tabIndex>-1)&&ri(i,this.view.observer.selectionRange)&&!(o&&i.contains(o));if(!(n||e||s))return;let r=this.forceSelection;this.forceSelection=!1;let a,l,c=this.view.state.selection.main;if(c.empty?l=a=this.inlineDOMNearPos(c.anchor,c.assoc||1):(l=this.inlineDOMNearPos(c.head,c.head==c.from?1:-1),a=this.inlineDOMNearPos(c.anchor,c.anchor==c.from?1:-1)),We.gecko&&c.empty&&!this.hasComposition&&(1==(h=a).node.nodeType&&h.node.firstChild&&(0==h.offset||"false"==h.node.childNodes[h.offset-1].contentEditable)&&(h.offset==h.node.childNodes.length||"false"==h.node.childNodes[h.offset].contentEditable))){let t=document.createTextNode("");this.view.observer.ignore(()=>a.node.insertBefore(t,a.node.childNodes[a.offset]||null)),a=l=new Ti(t,0),r=!0}var h;let d=this.view.observer.selectionRange;!r&&d.focusNode&&(li(a.node,a.offset,d.anchorNode,d.anchorOffset)&&li(l.node,l.offset,d.focusNode,d.focusOffset)||this.suppressWidgetCursorChange(d,c))||(this.view.observer.ignore(()=>{We.android&&We.chrome&&i.contains(d.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}(d.focusNode,i)&&(i.blur(),i.focus({preventScroll:!0}));let t=ni(this.view.root);if(t)if(c.empty){if(We.gecko){let t=(e=a.node,n=a.offset,1!=e.nodeType?0:(n&&"false"==e.childNodes[n-1].contentEditable?1:0)|(n<e.childNodes.length&&"false"==e.childNodes[n].contentEditable?2:0));if(t&&3!=t){let e=(1==t?ki:Si)(a.node,a.offset);e&&(a=new Ti(e.node,e.offset))}}t.collapse(a.node,a.offset),null!=c.bidiLevel&&void 0!==t.caretBidiLevel&&(t.caretBidiLevel=c.bidiLevel)}else if(t.extend){t.collapse(a.node,a.offset);try{t.extend(l.node,l.offset)}catch(t){}}else{let e=document.createRange();c.anchor>c.head&&([a,l]=[l,a]),e.setEnd(l.node,l.offset),e.setStart(a.node,a.offset),t.removeAllRanges(),t.addRange(e)}else;var e,n;s&&this.view.root.activeElement==i&&(i.blur(),o&&o.focus())}),this.view.observer.setSelectionRange(a,l)),this.impreciseAnchor=a.precise?null:new Ti(d.anchorNode,d.anchorOffset),this.impreciseHead=l.precise?null:new Ti(d.focusNode,d.focusOffset)}suppressWidgetCursorChange(t,e){return this.hasComposition&&e.empty&&li(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=ni(t.root),{anchorNode:o,anchorOffset:n}=t.observer.selectionRange;if(!(i&&e.empty&&e.assoc&&i.modify))return;let s=this.lineAt(e.head,e.assoc);if(!s)return;let r=s.posAtStart;if(e.head==r||e.head==r+s.length)return;let a=this.coordsAt(e.head,-1),l=this.coordsAt(e.head,1);if(!a||!l||a.bottom>l.top)return;let c=this.domAtPos(e.head+e.assoc,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(o,n)}posFromDOM(t,e){let i=this.tile.nearest(t);if(!i)return 2&this.tile.dom.compareDocumentPosition(t)?0:this.view.state.doc.length;let o=i.posAtStart;if(!i.isComposite())return i.isText()?t==i.dom?o+e:o+(e?i.length:0):o;{let n;if(t==i.dom)n=i.dom.childNodes[e];else{let o=0==ui(t)?0:0==e?-1:1;for(;;){let e=t.parentNode;if(e==i.dom)break;0==o&&e.firstChild!=e.lastChild&&(o=t==e.firstChild?-1:1),t=e}n=o<0?t:t.nextSibling}if(n==i.dom.firstChild)return o;for(;n&&!Mo.get(n);)n=n.nextSibling;if(!n)return o+i.length;for(let t=0,e=o;;t++){let o=i.children[t];if(o.dom==n)return e;e+=o.length+o.breakAfter}}}domAtPos(t,e){let{tile:i,offset:o}=this.tile.resolveBlock(t,e);return i.isWidget()?i.domPosFor(t,e):i.domIn(o,e)}inlineDOMNearPos(t,e){let i,o,n=-1,s=!1,r=-1,a=!1;return this.tile.blockTiles((e,l)=>{if(e.isWidget()){if(32&e.flags&&l>=t)return!0;16&e.flags&&(s=!0)}else{let c=l+e.length;if(l<=t&&(i=e,n=t-l,s=c<t),c>=t&&!o&&(o=e,r=t-l,a=l>t),l>t&&o)return!0}}),i||o?(s&&o?i=null:a&&i&&(o=null),i&&e<0||!o?i.domIn(n,e):o.domIn(r,e)):this.domAtPos(t,e)}coordsAt(t,e){let{tile:i,offset:o}=this.tile.resolveBlock(t,e);return i.isWidget()?i.widget instanceof en?null:i.coordsInWidget(o,e,!0):i.coordsIn(o,e)}lineAt(t,e){let{tile:i}=this.tile.resolveBlock(t,e);return i.isLine()?i:null}coordsForChar(t){let{tile:e,offset:i}=this.tile.resolveBlock(t,1);if(!e.isLine())return null;return function t(e,i){if(e.isComposite())for(let o of e.children){if(o.length>=i){let e=t(o,i);if(e)return e}if((i-=o.length)<0)break}else if(e.isText()&&i<e.length){let t=et(e.text,i);if(t==i)return null;let o=wi(e.dom,i,t).getClientRects();for(let t=0;t<o.length;t++){let e=o[t];if(t==o.length-1||e.top<e.bottom&&e.left<e.right)return e}}return null}(e,i)}measureVisibleLineHeights(t){let e=[],{from:i,to:o}=t,n=this.view.contentDOM.clientWidth,s=n>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,r=-1,a=this.view.textDirection==Ei.LTR,l=0,c=(t,h,d)=>{for(let u=0;u<t.children.length&&!(h>o);u++){let o=t.children[u],p=h+o.length,m=o.dom.getBoundingClientRect(),{height:g}=m;if(d&&!u&&(l+=m.top-d.top),o instanceof Oo)p>i&&c(o,h,m);else if(h>=i&&(l>0&&e.push(-l),e.push(g+l),l=0,s)){let t=o.dom.lastChild,e=t?ai(t):[];if(e.length){let t=e[e.length-1],i=a?t.right-m.left:m.right-t.left;i>r&&(r=i,this.minWidth=n,this.minWidthFrom=h,this.minWidthTo=p)}}d&&u==t.children.length-1&&(l+=d.bottom-m.bottom),h=p+o.breakAfter}};return c(this.tile,0,null),e}textDirectionAt(t){let{tile:e}=this.tile.resolveBlock(t,1);return"rtl"==getComputedStyle(e.dom).direction?Ei.RTL:Ei.LTR}measureTextSize(){let t=this.tile.blockTiles(t=>{if(t.isLine()&&t.children.length&&t.length<=20){let e,i=0;for(let o of t.children){if(!o.isText()||/[^ -~]/.test(o.text))return;let t=ai(o.dom);if(1!=t.length)return;i+=t[0].width,e=t[0].height}if(i)return{lineHeight:t.dom.getBoundingClientRect().height,charWidth:i/t.length,textHeight:e}}});if(t)return t;let e,i,o,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.tile.dom.appendChild(n);let t=ai(n.firstChild)[0];e=n.getBoundingClientRect().height,i=t&&t.width?t.width/27:7,o=t&&t.height?t.height:e,n.remove()}),{lineHeight:e,charWidth:i,textHeight:o}}computeBlockGapDeco(){let t=[],e=this.view.viewState;for(let i=0,o=0;;o++){let n=o==e.viewports.length?null:e.viewports[o],s=n?n.from-1:this.view.state.doc.length;if(s>i){let o=(e.lineBlockAt(s).bottom-e.lineBlockAt(i).top)/this.view.scaleY;t.push(Je.replace({widget:new en(o),block:!0,inclusive:!0,isBlockGap:!0}).range(i,s))}if(!n)break;i=n.to+1}return Je.set(t)}updateDeco(){let t=1,e=this.view.state.facet(go).map(e=>(this.dynamicDecorationMap[t++]="function"==typeof e)?e(this.view):e),i=!1,o=this.view.state.facet(bo).map((t,e)=>{let o="function"==typeof t;return o&&(i=!0),o?t(this.view):t});for(o.length&&(this.dynamicDecorationMap[t++]=i,e.push(he.join(o))),this.decorations=[this.editContextFormatting,...e,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];t<this.decorations.length;)this.dynamicDecorationMap[t++]=!1;this.blockWrappers=this.view.state.facet(fo).map(t=>"function"==typeof t?t(this.view):t)}scrollIntoView(t){if(t.isSnapshot){let e=this.view.viewState.lineBlockAt(t.range.head);return this.view.scrollDOM.scrollTop=e.top-t.yMargin,void(this.view.scrollDOM.scrollLeft=t.xMargin)}for(let e of this.view.state.facet(io))try{if(e(this.view,t.range,t))return!0}catch(t){ro(this.view.state,t,"scroll handler")}let e,{range:i}=t,o=this.coordsAt(i.head,i.empty?i.assoc:i.head>i.anchor?-1:1);if(!o)return;!i.empty&&(e=this.coordsAt(i.anchor,i.anchor>i.head?-1:1))&&(o={left:Math.min(o.left,e.left),top:Math.min(o.top,e.top),right:Math.max(o.right,e.right),bottom:Math.max(o.bottom,e.bottom)});let n=xo(this.view),s={left:o.left-n.left,top:o.top-n.top,right:o.right+n.right,bottom:o.bottom+n.bottom},{offsetWidth:r,offsetHeight:a}=this.view.scrollDOM;!function(t,e,i,o,n,s,r,a){let l=t.ownerDocument,c=l.defaultView||window;for(let h=t,d=!1;h&&!d;)if(1==h.nodeType){let t,u=h==l.body,p=1,m=1;if(u)t=mi(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}=gi(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"==n)e.top<t.top?(f=e.top-(t.top+r),i>0&&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-f<t.top&&(f=e.top-(t.top+r)));else{let o=e.bottom-e.top,s=t.bottom-t.top;f=("center"==n&&o<=s?e.top+o/2-s/2:"start"==n||"center"==n&&i<0?e.top-r:e.bottom-s+r)-t.top}if("nearest"==o?e.left<t.left?(g=e.left-(t.left+s),i>0&&e.right>t.right+g&&(g=e.right-t.right+s)):e.right>t.right&&(g=e.right-t.right+s,i<0&&e.left<t.left+g&&(g=e.left-(t.left+s))):g=("center"==o?e.left+(e.right-e.left)/2-(t.right-t.left)/2:"start"==o==a?e.left-s:e.right-(t.right-t.left)+s)-t.left,g||f)if(u)c.scrollBy(g,f);else{let t=0,i=0;if(f){let t=h.scrollTop;h.scrollTop+=f/m,i=(h.scrollTop-t)*m}if(g){let e=h.scrollLeft;h.scrollLeft+=g/p,t=(h.scrollLeft-e)*p}e={left:e.left-t,top:e.top-i,right:e.right-t,bottom:e.bottom-i},t&&Math.abs(t-g)<1&&(o="nearest"),i&&Math.abs(i-f)<1&&(n="nearest")}if(u)break;(e.top<t.top||e.bottom>t.bottom||e.left<t.left||e.right>t.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.head<i.anchor?-1:1,t.x,t.y,Math.max(Math.min(t.xMargin,r),-r),Math.max(Math.min(t.yMargin,a),-a),this.view.textDirection==Ei.LTR)}lineHasWidget(t){let e=t=>t.isWidget()||t.children.some(e);return e(this.tile.resolveBlock(t,1).tile)}destroy(){Jo(this.tile)}}function Jo(t,e){let i=null==e?void 0:e.get(t);if(1!=i){null==i&&t.destroy();for(let i of t.children)Jo(i,e)}}function Xo(t,e){let i=t.observer.selectionRange;if(!i.focusNode)return null;let o=ki(i.focusNode,i.focusOffset),n=Si(i.focusNode,i.focusOffset),s=o||n;if(n&&o&&n.node!=o.node){let e=Mo.get(n.node);if(!e||e.isText()&&e.text!=n.node.nodeValue)s=n;else if(t.docView.lastCompositionAfterCursor){let t=Mo.get(o.node);!t||t.isText()&&t.text!=o.node.nodeValue||(s=n)}}if(t.docView.lastCompositionAfterCursor=s!=o,!s)return null;let r=e-s.offset;return{from:r,to:r+s.node.nodeValue.length,node:s.node}}let Qo=class{constructor(){this.changes=[]}compareRange(t,e){ii(t,e,this.changes)}comparePoint(t,e){ii(t,e,this.changes)}boundChange(t){ii(t,t,this.changes)}};class tn{constructor(){this.changes=[]}compareRange(t,e){ii(t,e,this.changes)}comparePoint(){}boundChange(t){ii(t,t,this.changes)}}class en extends Ze{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}}function on(t,e,i,o,n){let s=Math.round((o-e.left)*t.defaultCharacterWidth);if(t.lineWrapping&&i.height>1.5*t.defaultLineHeight){let e=t.viewState.heightOracle.textHeight;s+=Math.floor((n-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,o){for(let o=0,n=0;;){if(n>=e)return o;if(o==t.length)break;n+=9==t.charCodeAt(o)?i-n%i:1,o=et(t,o)}return!0===o?-1:t.length}(r,s,t.state.tabSize)}function nn(t,e,i,o){let n=function(t,e,i){let o=t.lineBlockAt(e);if(Array.isArray(o.type)){let t;for(let n of o.type){if(n.from>e)break;if(!(n.to<e)){if(n.from<e&&n.to>e)return n;t&&(n.type!=Ke.Text||t.type==n.type&&!(i<0?n.from<e:n.to>e))||(t=n)}}return t||o}return o}(t,e.head,e.assoc||-1),s=o&&n.type==Ke.Text&&(t.lineWrapping||n.widgetLineBreaks)?t.coordsAtPos(e.assoc<0&&e.head>n.from?e.head-1:e.head):null;if(s){let e=t.dom.getBoundingClientRect(),o=t.textDirectionAt(n.from),r=t.posAtCoords({x:i==(o==Ei.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?n.to:n.from,i?-1:1)}function sn(t,e,i,o){let n=t.state.doc.lineAt(e.head),s=t.bidiSpans(n),r=t.textDirectionAt(n.from);for(let a=e,l=null;;){let e=Wi(n,s,r,a,i),c=Hi;if(!e){if(n.number==(i?t.state.doc.lines:1))return a;c="\n",n=t.state.doc.line(n.number+(i?1:-1)),s=t.bidiSpans(n),e=t.visualLineSide(n,!i)}if(l){if(!l(c))return a}else{if(!o)return e;l=o(c)}a=e}}function rn(t,e,i){for(;;){let o=0;for(let n of t)n.between(e-1,e+1,(t,n,s)=>{if(e>t&&e<n){let s=o||i||(e-t<n-e?-1:1);e=s<0?t:n,o=s}});if(!o)return e}}function an(t,e){let i=null;for(let o=0;o<e.ranges.length;o++){let n=e.ranges[o],s=null;if(n.empty){let e=rn(t,n.from,0);e!=n.from&&(s=pt.cursor(e,-1))}else{let e=rn(t,n.from,-1),i=rn(t,n.to,1);e==n.from&&i==n.to||(s=pt.range(n.from==n.anchor?e:i,n.from==n.head?e:i))}s&&(i||(i=e.ranges.slice()),i[o]=s)}return i?pt.create(i,e.mainIndex):e}function ln(t,e,i){let o=rn(t.state.facet(yo).map(e=>e(t)),i.from,e.head>i.from?-1:1);return o==i.from?i:pt.cursor(o,o<i.from?1:-1)}class cn{constructor(t,e){this.pos=t,this.assoc=e}}function hn(t,e,i,o){let n,s=t.contentDOM.getBoundingClientRect(),r=s.top+t.viewState.paddingTop,{x:a,y:l}=e,c=l-r;for(;;){if(c<0)return new cn(0,1);if(c>t.viewState.docHeight)return new cn(t.state.doc.length,-1);if(n=t.elementAtHeight(c),null==o)break;if(n.type==Ke.Text){let e=t.docView.coordsAt(o<0?n.from:n.to,o);if(e&&(o<0?e.top<=c+r:e.bottom>=c+r))break}let e=t.viewState.heightOracle.textHeight/2;c=o>0?n.bottom+e:n.top-e}if(t.viewport.from>=n.to||t.viewport.to<=n.from){if(i)return null;if(n.type==Ke.Text){let e=on(t,s,n,a,l);return new cn(e,e==n.from?1:-1)}}if(n.type!=Ke.Text)return c<(n.top+n.bottom)/2?new cn(n.from,1):new cn(n.to,-1);let h=t.docView.lineAt(n.from,2);return h&&h.length==n.length||(h=t.docView.lineAt(n.from,-2)),dn(t,h,n.from,a,l)}function dn(t,e,i,o,n){let s=-1,r=null,a=1e9,l=1e9,c=n,h=n,d=(t,e)=>{for(let i=0;i<t.length;i++){let d=t[i];if(d.top==d.bottom)continue;let u=d.left>o?d.left-o:d.right<o?o-d.right:0,p=d.top>n?d.top-n:d.bottom<n?n-d.bottom:0;d.top<=h&&d.bottom>=c&&(c=Math.min(d.top,c),h=Math.max(d.bottom,h),p=0),(s<0||(p-l||u-a)<0)&&(s>=0&&l&&a<u&&r.top<=h-2&&r.bottom>=c+2?l=0:(s=e,a=u,l=p,r=d))}};if(e.isText()){for(let t=0;t<e.length;){let i=et(e.text,t);if(d(wi(e.dom,t,i).getClientRects(),t),!a&&!l)break;t=i}return o>(r.left+r.right)/2==(un(t,s+i)==Ei.LTR)?new cn(i+et(e.text,s),-1):new cn(i+s,1)}{if(!e.length)return new cn(i,1);for(let t=0;t<e.children.length;t++){let i=e.children[t];if(!(48&i.flags)&&(d((1==i.dom.nodeType?i.dom:wi(i.dom,0,i.length)).getClientRects(),t),!a&&!l))break}let c=e.children[s],h=e.posBefore(c,i);return c.isComposite()||c.isText()?dn(t,c,h,Math.max(r.left,Math.min(r.right,o)),n):o>(r.left+r.right)/2==(un(t,s+i)==Ei.LTR)?new cn(h+c.length,-1):new cn(h,1)}}function un(t,e){let i=t.state.doc.lineAt(e);return t.bidiSpans(i)[Ri.find(t.bidiSpans(i),e-i.from,-1,1)].dir}const pn="";class mn{constructor(t,e){this.points=t,this.view=e,this.text="",this.lineSeparator=e.state.facet(ne.lineSeparator)}append(t){this.text+=t}lineBreak(){this.text+=pn}readRange(t,e){if(!t)return this;let i=t.parentNode;for(let o=t;;){this.findPointBefore(i,o);let t=this.text.length;this.readNode(o);let n=Mo.get(o),s=o.nextSibling;if(s==e){(null==n?void 0:n.breakAfter)&&!s&&i!=this.view.contentDOM&&this.lineBreak();break}let r=Mo.get(s);(n&&r?n.breakAfter:(n?n.breakAfter:hi(o))||hi(s)&&("BR"!=o.nodeName||(null==n?void 0:n.isWidget()))&&this.text.length>t)&&!fn(s,e)&&this.lineBreak(),o=s}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,o=this.lineSeparator?null:/\r\n?|\n/g;;){let n,s=-1,r=1;if(this.lineSeparator?(s=e.indexOf(this.lineSeparator,i),r=this.lineSeparator.length):(n=o.exec(e))&&(s=n.index,r=n[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){let e=Mo.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+(gn(t,i.node,i.offset)?e:0))}}function gn(t,e,i){for(;;){if(!e||i<ui(e))return!1;if(e==t)return!0;i=ci(e)+1,e=e.parentNode}}function fn(t,e){let i;for(;t!=e&&t;t=t.nextSibling){let e=Mo.get(t);if(!(null==e?void 0:e.isWidget()))return!1;e&&(i||(i=[])).push(e)}if(i)for(let t of i){let e=t.overrideDOMText;if(null==e?void 0:e.length)return!1}return!0}class bn{constructor(t,e){this.node=t,this.offset=e,this.pos=-1}}class yn{constructor(t,e,i,o){this.typeOver=o,this.bounds=null,this.text="",this.domChanged=e>-1;let{impreciseHead:n,impreciseAnchor:s}=t.docView;if(t.state.readOnly&&e>-1)this.newSel=null;else if(e>-1&&(this.bounds=vn(t.docView.tile,e,i,0))){let e=n||s?[]:function(t){let e=[];if(t.root.activeElement!=t.contentDOM)return e;let{anchorNode:i,anchorOffset:o,focusNode:n,focusOffset:s}=t.observer.selectionRange;i&&(e.push(new bn(i,o)),n==i&&s==o||e.push(new bn(n,s)));return e}(t),i=new mn(e,t);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,o=2==t.length?t[1].pos:i;return i>-1&&o>-1?pt.single(i+e,o+e):null}(e,this.bounds.from)}else{let e=t.observer.selectionRange,i=n&&n.node==e.focusNode&&n.offset==e.focusOffset||!si(t.contentDOM,e.focusNode)?t.state.selection.main.head:t.docView.posFromDOM(e.focusNode,e.focusOffset),o=s&&s.node==e.anchorNode&&s.offset==e.anchorOffset||!si(t.contentDOM,e.anchorNode)?t.state.selection.main.anchor:t.docView.posFromDOM(e.anchorNode,e.anchorOffset),r=t.viewport;if((We.ios||We.chrome)&&t.state.selection.main.empty&&i!=o&&(r.from>0||r.to<t.state.doc.length)){let e=Math.min(i,o),n=Math.max(i,o),s=r.from-e,a=r.to-n;0!=s&&1!=s&&0!=e||0!=a&&-1!=a&&n!=t.state.doc.length||(i=0,o=t.state.doc.length)}t.inputState.composing>-1&&t.state.selection.ranges.length>1?this.newSel=t.state.selection.replaceRange(pt.range(o,i)):this.newSel=pt.single(o,i)}}}function vn(t,e,i,o){if(t.isComposite()){let n=-1,s=-1,r=-1,a=-1;for(let l=0,c=o,h=o;l<t.children.length;l++){let o=t.children[l],d=c+o.length;if(c<e&&d>i)return vn(o,e,i,c);if(d>=e&&-1==n&&(n=l,s=c),c>i&&o.dom.parentNode==t.dom){r=l,a=h;break}h=d,c=d+o.breakAfter}return{from:s,to:a<0?o+t.length:a,startDOM:(n?t.children[n-1].dom.nextSibling:null)||t.dom.firstChild,endDOM:r<t.children.length&&r>=0?t.children[r].dom:null}}return t.isText()?{from:o,to:o+t.length,startDOM:t.dom,endDOM:t.dom.nextSibling}:null}function wn(t,e){let i,{newSel:o}=e,n=t.state.selection.main,s=t.inputState.lastKeyTime>Date.now()-100?t.inputState.lastKeyCode:-1;if(e.bounds){let{from:o,to:r}=e.bounds,a=n.from,l=null;(8===s||We.android&&e.text.length<r-o)&&(a=n.to,l="end");let c=xn(t.state.doc.sliceString(o,r,pn),e.text,a-o,l);c&&(We.chrome&&13==s&&c.toB==c.from+2&&e.text.slice(c.from,c.toB)==pn+pn&&c.toB--,i={from:o+c.from,to:o+c.toA,insert:U.of(e.text.slice(c.from,c.toB).split(pn))})}else o&&(!t.hasFocus&&t.state.facet(ao)||o.main.eq(n))&&(o=null);if(!i&&!o)return!1;if(!i&&e.typeOver&&!n.empty&&o&&o.main.empty?i={from:n.from,to:n.to,insert:t.state.doc.slice(n.from,n.to)}:(We.mac||We.android)&&i&&i.from==i.to&&i.from==n.head-1&&/^\. ?$/.test(i.insert.toString())&&"off"==t.contentDOM.getAttribute("autocorrect")?(o&&2==i.insert.length&&(o=pt.single(o.main.anchor-1,o.main.head-1)),i={from:i.from,to:i.to,insert:U.of([i.insert.toString().replace("."," ")])}):i&&i.from>=n.from&&i.to<=n.to&&(i.from!=n.from||i.to!=n.to)&&n.to-n.from-(i.to-i.from)<=4?i={from:n.from,to:n.to,insert:t.state.doc.slice(n.from,i.from).append(i.insert).append(t.state.doc.slice(i.to,n.to))}:t.state.doc.lineAt(n.from).to<n.to&&t.docView.lineHasWidget(n.to)&&t.inputState.insertingTextAt>Date.now()-50?i={from:n.from,to:n.to,insert:t.state.toText(t.inputState.insertingText)}:We.chrome&&i&&i.from==i.to&&i.from==n.head&&"\n "==i.insert.toString()&&t.lineWrapping&&(o&&(o=pt.single(o.main.anchor-1,o.main.head-1)),i={from:n.from,to:n.to,insert:U.of([" "])}),i)return Cn(t,i,o,s);if(o&&!o.main.eq(n)){let e=!1,i="select";return t.inputState.lastSelectionTime>Date.now()-50&&("select"==t.inputState.lastSelectionOrigin&&(e=!0),i=t.inputState.lastSelectionOrigin,"select.pointer"==i&&(o=an(t.state.facet(yo).map(e=>e(t)),o))),t.dispatch({selection:o,scrollIntoView:e,userEvent:i}),!0}return!1}function Cn(t,e,i,o=-1){if(We.ios&&t.inputState.flushIOSKey(e))return!0;let n=t.state.selection.main;if(We.android&&(e.to==n.to&&(e.from==n.from||e.from==n.from-1&&" "==t.state.sliceDoc(e.from,n.from))&&1==e.insert.length&&2==e.insert.lines&&Ci(t.contentDOM,"Enter",13)||(e.from==n.from-1&&e.to==n.to&&0==e.insert.length||8==o&&e.insert.length<e.to-e.from&&e.to>n.head)&&Ci(t.contentDOM,"Backspace",8)||e.from==n.from&&e.to==n.to+1&&0==e.insert.length&&Ci(t.contentDOM,"Delete",46)))return!0;let s,r=e.insert.toString();t.inputState.composing>=0&&t.inputState.composing++;let a=()=>s||(s=function(t,e,i){let o,n=t.state,s=n.selection.main,r=-1;if(e.from==e.to&&e.from<s.from||e.from>s.to){let i=e.from<s.from?-1:1,o=i<0?s.from:s.to,a=rn(n.facet(yo).map(e=>e(t)),o,i);e.from==a&&(r=a)}if(r>-1)o={changes:e,selection:pt.cursor(e.from+e.insert.length,-1)};else 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.from<e.from?n.sliceDoc(s.from,e.from):"",r=s.to>e.to?n.sliceDoc(e.to,s.to):"";o=n.replaceSelection(t.state.toText(i+e.insert.sliceString(0,void 0,t.state.lineBreak)+r))}else{let r=n.changes(e),a=i&&i.main.to<=r.newLength?i.main:void 0;if(n.selection.ranges.length>1&&(t.inputState.composing>=0||t.inputState.compositionPendingChange)&&e.to<=s.to+10&&e.to>=s.to-10){let l,c=t.state.sliceDoc(e.from,e.to),h=i&&Xo(t,i.main.head);if(h){let t=e.insert.length-(e.to-e.from);l={from:h.from,to:h.to-t}}else l=t.state.doc.lineAt(s.head);let d=s.to-e.to;o=n.changeByRange(i=>{if(i.from==s.from&&i.to==s.to)return{changes:r,range:a||i.map(r)};let o=i.to-d,h=o-c.length;if(t.state.sliceDoc(h,o)!=c||o>=l.from&&h<=l.to)return{range:i};let u=n.changes({from:h,to:o,insert:e.insert}),p=i.to-s.to;return{changes:u,range:a?pt.range(Math.max(0,a.anchor+p),Math.max(0,a.head+p)):i.map(u)}})}else o={changes:r,selection:a&&n.selection.replaceRange(a)}}let a="input.type";(t.composing||t.inputState.compositionPendingChange&&t.inputState.compositionEndedAt>Date.now()-50)&&(t.inputState.compositionPendingChange=!1,a+=".compose",t.inputState.compositionFirstChange&&(a+=".start",t.inputState.compositionFirstChange=!1));return n.update(o,{userEvent:a,scrollIntoView:!0})}(t,e,i));return t.state.facet(Ki).some(i=>i(t,e.from,e.to,r,a))||t.dispatch(a()),!0}function xn(t,e,i,o){let n=Math.min(t.length,e.length),s=0;for(;s<n&&t.charCodeAt(s)==e.charCodeAt(s);)s++;if(s==n&&t.length==e.length)return null;let r=t.length,a=e.length;for(;r>0&&a>0&&t.charCodeAt(r-1)==e.charCodeAt(a-1);)r--,a--;if("end"==o){i-=r+Math.max(0,s-Math.min(r,a))-s}if(r<s&&t.length<e.length){s-=i<=s&&i>=r?s-i:0,a=s+(a-r),r=s}else if(a<s){s-=i<=s&&i>=a?s-i:0,r=s+(r-a),a=s}return{from:s,toA:r,toB:a}}class kn{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.insertingText="",this.insertingTextAt=0,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=t.hasFocus,We.safari&&t.contentDOM.addEventListener("input",()=>null),We.gecko&&function(t){Yn.has(t)||(Yn.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,o=e.target;o!=t.contentDOM;o=o.parentNode)if(!o||11==o.nodeType||(i=Mo.get(o))&&i.isWidget()&&!i.isHidden&&i.widget.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=Tn(t),i=this.handlers,o=this.view.contentDOM;for(let t in e)if("scroll"!=t){let n=!e[t].handlers.length,s=i[t];s&&n!=!s.handlers.length&&(o.removeEventListener(t,this.handleEvent),s=null),s||o.addEventListener(t,this.handleEvent,{passive:n})}for(let t in i)"scroll"==t||e[t]||o.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&&An.indexOf(t.keyCode)<0&&(this.tabFocusMode=-1),We.android&&We.chrome&&!t.synthetic&&(13==t.keyCode||8==t.keyCode))return this.view.observer.delayAndroidKey(t.key,t.keyCode),!0;let e;return!We.ios||t.synthetic||t.altKey||t.metaKey||!((e=En.find(e=>e.keyCode==t.keyCode))&&!t.ctrlKey||Mn.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.from<t.to&&/^\S+$/.test(t.insert.toString()))&&(this.pendingIOSKey=void 0,Ci(this.view.contentDOM,e.key,e.keyCode,e instanceof KeyboardEvent?e:void 0)))}ignoreDuringComposition(t){return!(!/^key/.test(t.type)||t.synthetic)&&(this.composing>0||!!(We.safari&&!We.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 Sn(t,e){return(i,o)=>{try{return e.call(t,o,i)}catch(t){ro(i.state,t)}}}function Tn(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,o=t&&t.plugin.domEventHandlers,n=t&&t.plugin.domEventObservers;if(o)for(let t in o){let n=o[t];n&&i(t).handlers.push(Sn(e.value,n))}if(n)for(let t in n){let o=n[t];o&&i(t).observers.push(Sn(e.value,o))}}for(let t in On)i(t).handlers.push(On[t]);for(let t in Bn)i(t).observers.push(Bn[t]);return e}const En=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],Mn="dthko",An=[16,17,18,20,91,92,224,225];function In(t){return.7*Math.max(0,t)+8}class Dn{constructor(t,e,i,o){this.view=t,this.startEvent=e,this.style=i,this.mustSelect=o,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=e,this.scrollParents=function(t){let e,i,o=t.ownerDocument;for(let n=t.parentNode;n&&!(n==o.body||e&&i);)if(1==n.nodeType)!i&&n.scrollHeight>n.clientHeight&&(i=n),!e&&n.scrollWidth>n.clientWidth&&(e=n),n=n.assignedSlot||n.parentNode;else{if(11!=n.nodeType)break;n=n.host}return{x:e,y:i}}(t.contentDOM),this.atoms=t.state.facet(yo).map(e=>e(t));let n=t.contentDOM.ownerDocument;n.addEventListener("mousemove",this.move=this.move.bind(this)),n.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=e.shiftKey,this.multiple=t.state.facet(ne.allowMultipleSelections)&&function(t,e){let i=t.state.facet(Ui);return i.length?i[0](e):We.mac?e.metaKey:e.ctrlKey}(t,e),this.dragging=!(!function(t,e){let{main:i}=t.state.selection;if(i.empty)return!1;let o=ni(t.root);if(!o||0==o.rangeCount)return!0;let n=o.getRangeAt(0).getClientRects();for(let t=0;t<n.length;t++){let i=n[t];if(i.left<=e.clientX&&i.right>=e.clientX&&i.top<=e.clientY&&i.bottom>=e.clientY)return!0}return!1}(t,e)||1!=zn(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 o=0,n=0,s=0,r=0,a=this.view.win.innerWidth,l=this.view.win.innerHeight;this.scrollParents.x&&({left:s,right:a}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:r,bottom:l}=this.scrollParents.y.getBoundingClientRect());let c=xo(this.view);t.clientX-c.left<=s+6?o=-In(s-t.clientX):t.clientX+c.right>=a-6&&(o=In(t.clientX-a)),t.clientY-c.top<=r+6?n=-In(r-t.clientY):t.clientY+c.bottom>=l-6&&(n=In(t.clientY-l)),this.setScrollSpeed(o,n)}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)}select(t){let{view:e}=this,i=an(this.atoms,this.style.get(t,this.extend,this.multiple));!this.mustSelect&&i.eq(e.state.selection,!1===this.dragging)||this.view.dispatch({selection:i,userEvent:"select.pointer"}),this.mustSelect=!1}update(t){t.transactions.some(t=>t.isUserEvent("input.type"))?this.destroy():this.style.update(t)&&setTimeout(()=>this.select(this.lastEvent),20)}}const On=Object.create(null),Bn=Object.create(null),Ln=We.ie&&We.ie_version<15||We.ios&&We.webkit_version<604;function Nn(t,e,i){for(let o of t.facet(e))i=o(i,t);return i}function qn(t,e){e=Nn(t.state,Xi,e);let i,{state:o}=t,n=1,s=o.toText(e),r=s.lines==o.selection.ranges.length;if(null!=Wn&&o.selection.ranges.every(t=>t.empty)&&Wn==s.toString()){let t=-1;i=o.changeByRange(i=>{let a=o.doc.lineAt(i.from);if(a.from==t)return{range:i};t=a.from;let l=o.toText((r?s.line(n++).text:e)+o.lineBreak);return{changes:{from:a.from,insert:l},range:pt.cursor(i.from+l.length)}})}else i=r?o.changeByRange(t=>{let e=s.line(n++);return{changes:{from:t.from,to:t.to,insert:e.text},range:pt.cursor(t.from+e.length)}}):o.replaceSelection(s);t.dispatch(i,{userEvent:"input.paste",scrollIntoView:!0})}function Rn(t,e,i,o){if(1==o)return pt.cursor(e,i);if(2==o)return function(t,e,i=1){let o=t.charCategorizer(e),n=t.doc.lineAt(e),s=e-n.from;if(0==n.length)return pt.cursor(e);0==s?i=1:s==n.length&&(i=-1);let r=s,a=s;i<0?r=et(n.text,s,!1):a=et(n.text,s);let l=o(n.text.slice(r,a));for(;r>0;){let t=et(n.text,r,!1);if(o(n.text.slice(t,r))!=l)break;r=t}for(;a<n.length;){let t=et(n.text,a);if(o(n.text.slice(a,t))!=l)break;a=t}return pt.range(r+n.from,a+n.from)}(t.state,e,i);{let o=t.docView.lineAt(e,i),n=t.state.doc.lineAt(o?o.posAtEnd:e),s=o?o.posAtStart:n.from,r=o?o.posAtEnd:n.to;return r<t.state.doc.length&&r==n.to&&r++,pt.range(s,r)}}Bn.scroll=t=>{t.inputState.lastScrollTop=t.scrollDOM.scrollTop,t.inputState.lastScrollLeft=t.scrollDOM.scrollLeft},On.keydown=(t,e)=>(t.inputState.setSelectionOrigin("select"),27==e.keyCode&&0!=t.inputState.tabFocusMode&&(t.inputState.tabFocusMode=Date.now()+2e3),!1),Bn.touchstart=(t,e)=>{t.inputState.lastTouchTime=Date.now(),t.inputState.setSelectionOrigin("select.pointer")},Bn.touchmove=t=>{t.inputState.setSelectionOrigin("select.pointer")},On.mousedown=(t,e)=>{if(t.observer.flush(),t.inputState.lastTouchTime>Date.now()-2e3)return!1;let i=null;for(let o of t.state.facet(Yi))if(i=o(t,e),i)break;if(i||0!=e.button||(i=function(t,e){let i=t.posAndSideAtCoords({x:e.clientX,y:e.clientY},!1),o=zn(e),n=t.state.selection;return{update(t){t.docChanged&&(i.pos=t.changes.mapPos(i.pos),n=n.map(t.changes))},get(e,s,r){let a,l=t.posAndSideAtCoords({x:e.clientX,y:e.clientY},!1),c=Rn(t,l.pos,l.assoc,o);if(i.pos!=l.pos&&!s){let e=Rn(t,i.pos,i.assoc,o),n=Math.min(e.from,c.from),s=Math.max(e.to,c.to);c=n<c.from?pt.range(n,s):pt.range(s,n)}return s?n.replaceRange(n.main.extend(c.from,c.to)):r&&1==o&&n.ranges.length>1&&(a=function(t,e){for(let i=0;i<t.ranges.length;i++){let{from:o,to:n}=t.ranges[i];if(o<=e&&n>=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}(n,l.pos))?a:r?n.addRange(c):pt.create([c])}}}(t,e)),i){let o=!t.hasFocus;t.inputState.startMouseSelection(new Dn(t,e,i,o)),o&&t.observer.ignore(()=>{vi(t.contentDOM);let e=t.root.activeElement;e&&!e.contains(t.contentDOM)&&e.blur()});let n=t.inputState.mouseSelection;if(n)return n.start(e),!1===n.dragging}else t.inputState.setSelectionOrigin("select.pointer");return!1};const Fn=We.ie&&We.ie_version<=11;let Pn=null,_n=0,Vn=0;function zn(t){if(!Fn)return t.detail;let e=Pn,i=Vn;return Pn=t,Vn=Date.now(),_n=!e||i>Date.now()-400&&Math.abs(e.clientX-t.clientX)<2&&Math.abs(e.clientY-t.clientY)<2?(_n+1)%3:1}function Hn(t,e,i,o){if(!(i=Nn(t.state,Xi,i)))return;let n=t.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:s}=t.inputState,r=o&&s&&function(t,e){let i=t.state.facet(ji);return i.length?i[0](e):We.mac?!e.altKey:!e.ctrlKey}(t,e)?{from:s.from,to:s.to}:null,a={from:n,insert:i},l=t.state.changes(r?[r,a]:a);t.focus(),t.dispatch({changes:l,selection:{anchor:l.mapPos(n,-1),head:l.mapPos(n,1)},userEvent:r?"move.drop":"input.drop"}),t.inputState.draggedContent=null}On.dragstart=(t,e)=>{let{selection:{main:i}}=t.state;if(e.target.draggable){let o=t.docView.tile.nearest(e.target);if(o&&o.isWidget()){let t=o.posAtStart,e=t+o.length;(t>=i.to||e<=i.from)&&(i=pt.range(t,e))}}let{inputState:o}=t;return o.mouseSelection&&(o.mouseSelection.dragging=!0),o.draggedContent=i,e.dataTransfer&&(e.dataTransfer.setData("Text",Nn(t.state,Qi,t.state.sliceDoc(i.from,i.to))),e.dataTransfer.effectAllowed="copyMove"),!1},On.dragend=t=>(t.inputState.draggedContent=null,!1),On.drop=(t,e)=>{if(!e.dataTransfer)return!1;if(t.state.readOnly)return!0;let i=e.dataTransfer.files;if(i&&i.length){let o=Array(i.length),n=0,s=()=>{++n==i.length&&Hn(t,e,o.filter(t=>null!=t).join(t.state.lineBreak),!1)};for(let t=0;t<i.length;t++){let e=new FileReader;e.onerror=s,e.onload=()=>{/[\x00-\x08\x0e-\x1f]{2}/.test(e.result)||(o[t]=e.result),s()},e.readAsText(i[t])}return!0}{let i=e.dataTransfer.getData("Text");if(i)return Hn(t,e,i,!0),!0}return!1},On.paste=(t,e)=>{if(t.state.readOnly)return!0;t.observer.flush();let i=Ln?null:e.clipboardData;return i?(qn(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(),qn(t,i.value)},50)}(t),!1)};let Wn=null;On.copy=On.cut=(t,e)=>{let{text:i,ranges:o,linewise:n}=function(t){let e=[],i=[],o=!1;for(let o of t.selection.ranges)o.empty||(e.push(t.sliceDoc(o.from,o.to)),i.push(o));if(!e.length){let n=-1;for(let{from:o}of t.selection.ranges){let s=t.doc.lineAt(o);s.number>n&&(e.push(s.text),i.push({from:s.from,to:Math.min(t.doc.length,s.to+1)})),n=s.number}o=!0}return{text:Nn(t,Qi,e.join(t.lineBreak)),ranges:i,linewise:o}}(t.state);if(!i&&!n)return!1;Wn=n?i:null,"cut"!=e.type||t.state.readOnly||t.dispatch({changes:o,scrollIntoView:!0,userEvent:"delete.cut"});let s=Ln?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 o=i.appendChild(document.createElement("textarea"));o.style.cssText="position: fixed; left: -10000px; top: 10px",o.value=e,o.focus(),o.selectionEnd=e.length,o.selectionStart=0,setTimeout(()=>{o.remove(),t.focus()},50)}(t,i),!1)};const $n=Wt.define();function Un(t,e){let i=[];for(let o of t.facet(Ji)){let n=o(t,e);n&&i.push(n)}return i.length?t.update({effects:i,annotations:$n.of(!0)}):null}function jn(t){setTimeout(()=>{let e=t.hasFocus;if(e!=t.inputState.notifiedFocused){let i=Un(t.state,e);i?t.dispatch(i):t.update([])}},10)}Bn.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),jn(t)},Bn.blur=t=>{t.observer.clearSelectionRange(),jn(t)},Bn.compositionstart=Bn.compositionupdate=t=>{t.observer.editContext||(null==t.inputState.compositionFirstChange&&(t.inputState.compositionFirstChange=!0),t.inputState.composing<0&&(t.inputState.composing=0))},Bn.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,We.chrome&&We.android?t.observer.flushSoon():t.inputState.compositionPendingChange?Promise.resolve().then(()=>t.observer.flush()):setTimeout(()=>{t.inputState.composing<0&&t.docView.hasComposition&&t.update([])},50))},Bn.contextmenu=t=>{t.inputState.lastContextMenu=Date.now()},On.beforeinput=(t,e)=>{var i,o;if("insertText"!=e.inputType&&"insertCompositionText"!=e.inputType||(t.inputState.insertingText=e.data,t.inputState.insertingTextAt=Date.now()),"insertReplacementText"==e.inputType&&t.observer.editContext){let o=null===(i=e.dataTransfer)||void 0===i?void 0:i.getData("text/plain"),n=e.getTargetRanges();if(o&&n.length){let e=n[0],i=t.posAtDOM(e.startContainer,e.startOffset),s=t.posAtDOM(e.endContainer,e.endOffset);return Cn(t,{from:i,to:s,insert:t.state.toText(o)},null),!0}}let n;if(We.chrome&&We.android&&(n=En.find(t=>t.inputType==e.inputType))&&(t.observer.delayAndroidKey(n.key,n.keyCode),"Backspace"==n.key||"Delete"==n.key)){let e=(null===(o=window.visualViewport)||void 0===o?void 0:o.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 We.ios&&"deleteContentForward"==e.inputType&&t.observer.flushSoon(),We.safari&&"insertText"==e.inputType&&t.inputState.composing>=0&&setTimeout(()=>Bn.compositionend(t,e),20),!1};const Yn=new Set;const Gn=["pre-wrap","normal","pre-line","break-spaces"];let Zn=!1;function Kn(){Zn=!1}class Jn{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)/Math.max(1,this.lineLength-5))))*this.lineHeight}setDoc(t){return this.doc=t,this}mustRefreshForWrapping(t){return Gn.indexOf(t)>-1!=this.lineWrapping}mustRefreshForHeights(t){let e=!1;for(let i=0;i<t.length;i++){let o=t[i];o<0?i++:this.heightSamples[Math.floor(10*o)]||(e=!0,this.heightSamples[Math.floor(10*o)]=!0)}return e}refresh(t,e,i,o,n,s){let r=Gn.indexOf(t)>-1,a=Math.round(e)!=Math.round(this.lineHeight)||this.lineWrapping!=r;if(this.lineWrapping=r,this.lineHeight=e,this.charWidth=i,this.textHeight=o,this.lineLength=n,a){this.heightSamples={};for(let t=0;t<s.length;t++){let e=s[t];e<0?t++:this.heightSamples[Math.floor(10*e)]=!0}}return a}}class Xn{constructor(t,e){this.from=t,this.heights=e,this.index=0}get more(){return this.index<this.heights.length}}class Qn{constructor(t,e,i,o,n){this.from=t,this.length=e,this.top=i,this.height=o,this._content=n}get type(){return"number"==typeof this._content?Ke.Text:Array.isArray(this._content)?this._content:this._content.type}get to(){return this.from+this.length}get bottom(){return this.top+this.height}get widget(){return this._content instanceof ti?this._content.widget:null}get widgetLineBreaks(){return"number"==typeof this._content?this._content:0}join(t){let e=(Array.isArray(this._content)?this._content:[this]).concat(Array.isArray(t._content)?t._content:[t]);return new Qn(this.from,this.length+t.length,this.top,this.height+t.height,e)}}var ts=function(t){return t[t.ByPos=0]="ByPos",t[t.ByHeight=1]="ByHeight",t[t.ByPosNoHeight=2]="ByPosNoHeight",t}(ts||(ts={}));const es=.001;class is{constructor(t,e,i=2){this.length=t,this.height=e,this.flags=i}get outdated(){return(2&this.flags)>0}set outdated(t){this.flags=(t?2:0)|-3&this.flags}setHeight(t){this.height!=t&&(Math.abs(this.height-t)>es&&(Zn=!0),this.height=t)}replace(t,e,i){return is.of(i)}decomposeLeft(t,e){e.push(this)}decomposeRight(t,e){e.push(this)}applyChanges(t,e,i,o){let n=this,s=i.doc;for(let r=o.length-1;r>=0;r--){let{fromA:a,toA:l,fromB:c,toB:h}=o[r],d=n.lineAt(a,ts.ByPosNoHeight,i.setDoc(e),0,0),u=d.to>=l?d:n.lineAt(l,ts.ByPosNoHeight,i,0,0);for(h+=u.to-l,l=u.to;r>0&&d.from<=o[r-1].toA;)a=o[r-1].fromA,c=o[r-1].fromB,r--,a<d.from&&(d=n.lineAt(a,ts.ByPosNoHeight,i,0,0));c+=d.from-a,a=d.from;let p=hs.build(i.setDoc(s),t,c,h);n=os(n,n.replace(a,l,p))}return n.updateHeight(i,0)}static empty(){return new rs(0,0,0)}static of(t){if(1==t.length)return t[0];let e=0,i=t.length,o=0,n=0;for(;;)if(e==i)if(o>2*n){let n=t[e-1];n.break?t.splice(--e,1,n.left,null,n.right):t.splice(--e,1,n.left,n.right),i+=1+n.break,o-=n.size}else{if(!(n>2*o))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,n-=e.size}}else if(o<n){let i=t[e++];i&&(o+=i.size)}else{let e=t[--i];e&&(n+=e.size)}let s=0;return null==t[e-1]?(s=1,e--):null==t[e]&&(s=1,i++),new ls(is.of(t.slice(0,e)),s,is.of(t.slice(i)))}}function os(t,e){return t==e?t:(t.constructor!=e.constructor&&(Zn=!0),e)}is.prototype.size=1;const ns=Je.replace({});class ss extends is{constructor(t,e,i){super(t,e),this.deco=i,this.spaceAbove=0}mainBlock(t,e){return new Qn(e,this.length,t+this.spaceAbove,this.height-this.spaceAbove,this.deco||0)}blockAt(t,e,i,o){return this.spaceAbove&&t<i+this.spaceAbove?new Qn(o,0,i,this.spaceAbove,ns):this.mainBlock(i,o)}lineAt(t,e,i,o,n){let s=this.mainBlock(o,n);return this.spaceAbove?this.blockAt(0,i,o,n).join(s):s}forEachLine(t,e,i,o,n,s){t<=n+this.length&&e>=n&&s(this.lineAt(0,ts.ByPos,i,o,n))}setMeasuredHeight(t){let e=t.heights[t.index++];e<0?(this.spaceAbove=-e,e=t.heights[t.index++]):this.spaceAbove=0,this.setHeight(e)}updateHeight(t,e=0,i=!1,o){return o&&o.from<=e&&o.more&&this.setMeasuredHeight(o),this.outdated=!1,this}toString(){return`block(${this.length})`}}class rs extends ss{constructor(t,e,i){super(t,e,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0,this.spaceAbove=i}mainBlock(t,e){return new Qn(e,this.length,t+this.spaceAbove,this.height-this.spaceAbove,this.breaks)}replace(t,e,i){let o=i[0];return 1==i.length&&(o instanceof rs||o instanceof as&&4&o.flags)&&Math.abs(this.length-o.length)<10?(o instanceof as?o=new rs(o.length,this.height,this.spaceAbove):o.height=this.height,this.outdated||(o.outdated=!1),o):is.of(i)}updateHeight(t,e=0,i=!1,o){return o&&o.from<=e&&o.more?this.setMeasuredHeight(o):(i||this.outdated)&&(this.spaceAbove=0,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 as extends is{constructor(t){super(t,0)}heightMetrics(t,e){let i,o=t.doc.lineAt(e).number,n=t.doc.lineAt(e+this.length).number,s=n-o+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:o,lastLine:n,perLine:i,perChar:r}}blockAt(t,e,i,o){let{firstLine:n,lastLine:s,perLine:r,perChar:a}=this.heightMetrics(e,o);if(e.lineWrapping){let n=o+(t<e.lineHeight?0:Math.round(Math.max(0,Math.min(1,(t-i)/this.height))*this.length)),s=e.doc.lineAt(n),l=r+s.length*a,c=Math.max(i,t-l/2);return new Qn(s.from,s.length,c,l,0)}{let o=Math.max(0,Math.min(s-n,Math.floor((t-i)/r))),{from:a,length:l}=e.doc.line(n+o);return new Qn(a,l,i+r*o,r,0)}}lineAt(t,e,i,o,n){if(e==ts.ByHeight)return this.blockAt(t,i,o,n);if(e==ts.ByPosNoHeight){let{from:e,to:o}=i.doc.lineAt(t);return new Qn(e,o-e,0,0,0)}let{firstLine:s,perLine:r,perChar:a}=this.heightMetrics(i,n),l=i.doc.lineAt(t),c=r+l.length*a,h=l.number-s,d=o+r*h+a*(l.from-n-h);return new Qn(l.from,l.length,Math.max(o,Math.min(d,o+this.height-c)),c,0)}forEachLine(t,e,i,o,n,s){t=Math.max(t,n),e=Math.min(e,n+this.length);let{firstLine:r,perLine:a,perChar:l}=this.heightMetrics(i,n);for(let c=t,h=o;c<=e;){let e=i.doc.lineAt(c);if(c==t){let i=e.number-r;h+=a*i+l*(t-n-i)}let o=a+l*e.length;s(new Qn(e.from,e.length,h,o,0)),h+=o,c=e.to+1}}replace(t,e,i){let o=this.length-e;if(o>0){let t=i[i.length-1];t instanceof as?i[i.length-1]=new as(t.length+o):i.push(null,new as(o-1))}if(t>0){let e=i[0];e instanceof as?i[0]=new as(t+e.length):i.unshift(new as(t-1),null)}return is.of(i)}decomposeLeft(t,e){e.push(new as(t-1),null)}decomposeRight(t,e){e.push(null,new as(this.length-t-1))}updateHeight(t,e=0,i=!1,o){let n=e+this.length;if(o&&o.from<=e+this.length&&o.more){let i=[],s=Math.max(e,o.from),r=-1;for(o.from>e&&i.push(new as(o.from-e-1).updateHeight(t,e));s<=n&&o.more;){let e=t.doc.lineAt(s).length;i.length&&i.push(null);let n=o.heights[o.index++],a=0;n<0&&(a=-n,n=o.heights[o.index++]),-1==r?r=n:Math.abs(n-r)>=es&&(r=-2);let l=new rs(e,n,a);l.outdated=!1,i.push(l),s+=e+1}s<=n&&i.push(null,new as(n-s).updateHeight(t,s));let a=is.of(i);return(r<0||Math.abs(a.height-this.height)>=es||Math.abs(r-this.heightMetrics(t,e).perLine)>=es)&&(Zn=!0),os(this,a)}return(i||this.outdated)&&(this.setHeight(t.heightForGap(e,e+this.length)),this.outdated=!1),this}toString(){return`gap(${this.length})`}}class ls extends is{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,o){let n=i+this.left.height;return t<n?this.left.blockAt(t,e,i,o):this.right.blockAt(t,e,n,o+this.left.length+this.break)}lineAt(t,e,i,o,n){let s=o+this.left.height,r=n+this.left.length+this.break,a=e==ts.ByHeight?t<s:t<r,l=a?this.left.lineAt(t,e,i,o,n):this.right.lineAt(t,e,i,s,r);if(this.break||(a?l.to<r:l.from>r))return l;let c=e==ts.ByPosNoHeight?ts.ByPosNoHeight:ts.ByPos;return a?l.join(this.right.lineAt(r,c,i,s,r)):this.left.lineAt(r,c,i,o,n).join(l)}forEachLine(t,e,i,o,n,s){let r=o+this.left.height,a=n+this.left.length+this.break;if(this.break)t<a&&this.left.forEachLine(t,e,i,o,n,s),e>=a&&this.right.forEachLine(t,e,i,r,a,s);else{let l=this.lineAt(a,ts.ByPos,i,o,n);t<l.from&&this.left.forEachLine(t,l.from-1,i,o,n,s),l.to>=t&&l.from<=e&&s(l),e>l.to&&this.right.forEachLine(l.to+1,e,i,r,a,s)}}replace(t,e,i){let o=this.left.length+this.break;if(e<o)return this.balanced(this.left.replace(t,e,i),this.right);if(t>this.left.length)return this.balanced(this.left,this.right.replace(t-o,e-o,i));let n=[];t>0&&this.decomposeLeft(t,n);let s=n.length;for(let t of i)n.push(t);if(t>0&&cs(n,s-1),e<this.length){let t=n.length;this.decomposeRight(e,n),cs(n,t)}return is.of(n)}decomposeLeft(t,e){let i=this.left.length;if(t<=i)return this.left.decomposeLeft(t,e);e.push(this.left),this.break&&(i++,t>=i&&e.push(null)),t>i&&this.right.decomposeLeft(t-i,e)}decomposeRight(t,e){let i=this.left.length,o=i+this.break;if(t>=o)return this.right.decomposeRight(t-o,e);t<i&&this.left.decomposeRight(t,e),this.break&&t<o&&e.push(null),e.push(this.right)}balanced(t,e){return t.size>2*e.size||e.size>2*t.size?is.of(this.break?[t,null,e]:[t,e]):(this.left=os(this.left,t),this.right=os(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,o){let{left:n,right:s}=this,r=e+n.length+this.break,a=null;return o&&o.from<=e+n.length&&o.more?a=n=n.updateHeight(t,e,i,o):n.updateHeight(t,e,i),o&&o.from<=r+s.length&&o.more?a=s=s.updateHeight(t,r,i,o):s.updateHeight(t,r,i),a?this.balanced(n,s):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function cs(t,e){let i,o;null==t[e]&&(i=t[e-1])instanceof as&&(o=t[e+1])instanceof as&&t.splice(e-1,3,new as(i.length+1+o.length))}class hs{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 rs?i.length+=t-this.pos:(t>this.pos||!this.isCovered)&&this.nodes.push(new rs(t-this.pos,-1,0)),this.writtenTo=t,e>t&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=e}point(t,e,i){if(t<e||i.heightRelevant){let o=i.widget?i.widget.estimatedHeight:0,n=i.widget?i.widget.lineBreaks:0;o<0&&(o=this.oracle.lineHeight);let s=e-t;i.block?this.addBlock(new ss(s,o,i)):(s||n||o>=5)&&this.addLineDeco(o,n,s)}else e>t&&this.span(t,e);this.lineEnd>-1&&this.lineEnd<this.pos&&(this.lineEnd=this.oracle.doc.lineAt(this.pos).to)}enterLine(){if(this.lineStart>-1)return;let{from:t,to:e}=this.oracle.doc.lineAt(this.pos);this.lineStart=t,this.lineEnd=e,this.writtenTo<t&&((this.writtenTo<t-1||null==this.nodes[this.nodes.length-1])&&this.nodes.push(this.blankContent(this.writtenTo,t-1)),this.nodes.push(null)),this.pos>t&&this.nodes.push(new rs(this.pos-t,-1,0)),this.writtenTo=this.pos}blankContent(t,e){let i=new as(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 rs)return t;let e=new rs(0,-1,0);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 o=this.ensureLine();o.length+=i,o.collapsed+=i,o.widgetHeight=Math.max(o.widgetHeight,t),o.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 rs||this.isCovered?(this.writtenTo<this.pos||null==e)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos)):this.nodes.push(new rs(0,-1,0));let i=t;for(let t of this.nodes)t instanceof rs&&t.updateHeight(this.oracle,i),i+=t?t.length:1;return this.nodes}static build(t,e,i,o){let n=new hs(i,t);return he.spans(e,i,o,n,0),n.finish(i)}}class ds{constructor(){this.changes=[]}compareRange(){}comparePoint(t,e,i,o){(t<e||i&&i.heightRelevant||o&&o.heightRelevant)&&ii(t,e,this.changes,5)}}function us(t,e){let i=t.getBoundingClientRect(),o=t.ownerDocument,n=o.defaultView||window,s=Math.max(0,i.left),r=Math.min(n.innerWidth,i.right),a=Math.max(0,i.top),l=Math.min(n.innerHeight,i.bottom);for(let e=t.parentNode;e&&e!=o.body;)if(1==e.nodeType){let i=e,o=window.getComputedStyle(i);if((i.scrollHeight>i.clientHeight||i.scrollWidth>i.clientWidth)&&"visible"!=o.overflow){let o=i.getBoundingClientRect();s=Math.max(s,o.left),r=Math.min(r,o.right),a=Math.max(a,o.top),l=Math.min(e==t.parentNode?n.innerHeight:l,o.bottom)}e="absolute"==o.position||"fixed"==o.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:a-(i.top+e),bottom:Math.max(a,l)-(i.top+e)}}function ps(t,e){let i=t.getBoundingClientRect();return{left:0,right:i.right-i.left,top:e,bottom:i.bottom-(i.top+e)}}class ms{constructor(t,e,i,o){this.from=t,this.to=e,this.size=i,this.displaySize=o}static same(t,e){if(t.length!=e.length)return!1;for(let i=0;i<t.length;i++){let o=t[i],n=e[i];if(o.from!=n.from||o.to!=n.to||o.size!=n.size)return!1}return!0}draw(t,e){return Je.replace({widget:new gs(this.displaySize*(e?t.scaleY:t.scaleX),e)}).range(this.from,this.to)}}class gs extends Ze{constructor(t,e){super(),this.size=t,this.vertical=e}eq(t){return t.size==this.size&&t.vertical==this.vertical}toDOM(){let t=document.createElement("div");return this.vertical?t.style.height=this.size+"px":(t.style.width=this.size+"px",t.style.height="2px",t.style.display="inline-block"),t}get estimatedHeight(){return this.vertical?this.size:-1}}class fs{constructor(t){this.state=t,this.pixelViewport={left:0,right:window.innerWidth,top:0,bottom:0},this.inView=!0,this.paddingTop=0,this.paddingBottom=0,this.contentDOMWidth=0,this.contentDOMHeight=0,this.editorHeight=0,this.editorWidth=0,this.scrollTop=0,this.scrolledToBottom=!1,this.scaleX=1,this.scaleY=1,this.scrollAnchorPos=0,this.scrollAnchorHeight=-1,this.scaler=ws,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=Ei.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let e=t.facet(mo).some(t=>"function"!=typeof t&&"cm-lineWrapping"==t.class);this.heightOracle=new Jn(e),this.stateDeco=t.facet(go).filter(t=>"function"!=typeof t),this.heightMap=is.empty().applyChanges(this.stateDeco,U.empty,this.heightOracle.setDoc(t.doc),[new So(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=Je.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 o=i?e.head:e.anchor;if(!t.some(({from:t,to:e})=>o>=t&&o<=e)){let{from:e,to:i}=this.lineBlockAt(o);t.push(new bs(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?ws:new Cs(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(xs(t,this.scaler))})}update(t,e=null){this.state=t.state;let i=this.stateDeco;this.stateDeco=this.state.facet(go).filter(t=>"function"!=typeof t);let o=t.changedRanges,n=So.extendWithRanges(o,function(t,e,i){let o=new ds;return he.compare(t,e,i,o,0),o.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);Kn(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,t.startState.doc,this.heightOracle.setDoc(this.state.doc),n),(this.heightMap.height!=s||Zn)&&(t.flags|=2),r?(this.scrollAnchorPos=t.changes.mapPos(r.from,-1),this.scrollAnchorHeight=r.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=s);let a=n.length?this.mapViewport(this.viewport,t.changes):this.viewport;(e&&(e.range.head<a.from||e.range.head>a.to)||!this.viewportIsAppropriate(a))&&(a=this.getViewport(0,e));let l=a.from!=this.viewport.from||a.to!=this.viewport.to;this.viewport=a,t.flags|=this.updateForViewport(),(l||!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(eo)&&(this.mustEnforceCursorAssoc=!0)}measure(t){let e=t.contentDOM,i=window.getComputedStyle(e),o=this.heightOracle,n=i.whiteSpace;this.defaultTextDirection="rtl"==i.direction?Ei.RTL:Ei.LTR;let s=this.heightOracle.mustRefreshForWrapping(n),r=e.getBoundingClientRect(),a=s||this.mustMeasureContent||this.contentDOMHeight!=r.height;this.contentDOMHeight=r.height,this.mustMeasureContent=!1;let l=0,c=0;if(r.width&&r.height){let{scaleX:t,scaleY:i}=gi(e,r);(t>.005&&Math.abs(this.scaleX-t)>.005||i>.005&&Math.abs(this.scaleY-i)>.005)&&(this.scaleX=t,this.scaleY=i,l|=16,s=a=!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,l|=18),this.editorWidth!=t.scrollDOM.clientWidth&&(o.lineWrapping&&(a=!0),this.editorWidth=t.scrollDOM.clientWidth,l|=16);let u=t.scrollDOM.scrollTop*this.scaleY;this.scrollTop!=u&&(this.scrollAnchorHeight=-1,this.scrollTop=u),this.scrolledToBottom=xi(t.scrollDOM);let p=(this.printing?ps:us)(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&&(a=!0)),!this.inView&&!this.scrollTarget&&!function(t){let e=t.getBoundingClientRect(),i=t.ownerDocument.defaultView||window;return e.left<i.innerWidth&&e.right>0&&e.top<i.innerHeight&&e.bottom>0}(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,l|=16),a){let e=t.docView.measureVisibleLineHeights(this.viewport);if(o.mustRefreshForHeights(e)&&(s=!0),s||o.lineWrapping&&Math.abs(b-this.contentDOMWidth)>o.charWidth){let{lineHeight:i,charWidth:r,textHeight:a}=t.docView.measureTextSize();s=i>0&&o.refresh(n,i,r,a,Math.max(5,b/r),e),s&&(t.docView.minWidth=0,l|=16)}m>0&&g>0?c=Math.max(m,g):m<0&&g<0&&(c=Math.min(m,g)),Kn();for(let i of this.viewports){let n=i.from==this.viewport.from?e:t.docView.measureVisibleLineHeights(i);this.heightMap=(s?is.empty().applyChanges(this.stateDeco,U.empty,this.heightOracle,[new So(0,0,0,t.state.doc.length)]):this.heightMap).updateHeight(o,0,s,new Xn(i.from,n))}Zn&&(l|=2)}let y=!this.viewportIsAppropriate(this.viewport,c)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return y&&(2&l&&(l|=this.updateScaler()),this.viewport=this.getViewport(c,this.scrollTarget),l|=this.updateForViewport()),(2&l||y)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(s?[]:this.lineGaps,t)),l|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,t.docView.enforceCursorAssoc()),l}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)),o=this.heightMap,n=this.heightOracle,{visibleTop:s,visibleBottom:r}=this,a=new bs(o.lineAt(s-1e3*i,ts.ByHeight,n,0,0).from,o.lineAt(r+1e3*(1-i),ts.ByHeight,n,0,0).to);if(e){let{head:t}=e.range;if(t<a.from||t>a.to){let i,s=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),r=o.lineAt(t,ts.ByPos,n,0,0);i="center"==e.y?(r.top+r.bottom)/2-s/2:"start"==e.y||"nearest"==e.y&&t<a.from?r.top:r.bottom-s,a=new bs(o.lineAt(i-500,ts.ByHeight,n,0,0).from,o.lineAt(i+s+500,ts.ByHeight,n,0,0).to)}}return a}mapViewport(t,e){let i=e.mapPos(t.from,-1),o=e.mapPos(t.to,1);return new bs(this.heightMap.lineAt(i,ts.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(o,ts.ByPos,this.heightOracle,0,0).to)}viewportIsAppropriate({from:t,to:e},i=0){if(!this.inView)return!0;let{top:o}=this.heightMap.lineAt(t,ts.ByPos,this.heightOracle,0,0),{bottom:n}=this.heightMap.lineAt(e,ts.ByPos,this.heightOracle,0,0),{visibleTop:s,visibleBottom:r}=this;return(0==t||o<=s-Math.max(10,Math.min(-i,250)))&&(e==this.state.doc.length||n>=r+Math.max(10,Math.min(i,250)))&&o>s-2e3&&n<r+2e3}mapLineGaps(t,e){if(!t.length||e.empty)return t;let i=[];for(let o of t)e.touchesRange(o.from,o.to)||i.push(new ms(e.mapPos(o.from),e.mapPos(o.to),o.size,o.displaySize));return i}ensureLineGaps(t,e){let i=this.heightOracle.lineWrapping,o=i?1e4:2e3,n=o>>1,s=o<<1;if(this.defaultTextDirection!=Ei.LTR&&!i)return[];let r=[],a=(o,s,l,c)=>{if(s-o<n)return;let h=this.state.selection.main,d=[h.from];h.empty||d.push(h.to);for(let t of d)if(t>o&&t<s)return a(o,t-10,l,c),void a(t+10,s,l,c);let u=function(t,e){for(let i of t)if(e(i))return i;return}(t,t=>t.from>=l.from&&t.to<=l.to&&Math.abs(t.from-o)<n&&Math.abs(t.to-s)<n&&!d.some(e=>t.from<e&&t.to>e));if(!u){if(s<l.to&&e&&i&&e.visibleRanges.some(t=>t.from<=s&&t.to>=s)){let t=e.moveToLineBoundary(pt.cursor(s),!1,!0).head;t>o&&(s=t)}let t=this.gapSize(l,o,s,c);u=new ms(o,s,t,i||t<2e6?t:2e6)}r.push(u)},l=e=>{if(e.length<s||e.type!=Ke.Text)return;let n=function(t,e,i){let o=[],n=t,s=0;he.spans(i,t,e,{span(){},point(t,e){t>n&&(o.push({from:n,to:t}),s+=t-n),n=e}},20),n<e&&(o.push({from:n,to:e}),s+=e-n);return{total:s,ranges:o}}(e.from,e.to,this.stateDeco);if(n.total<s)return;let r,l,c=this.scrollTarget?this.scrollTarget.range.head:null;if(i){let t,i,s=o/this.heightOracle.lineLength*this.heightOracle.lineHeight;if(null!=c){let o=vs(n,c),r=((this.visibleBottom-this.visibleTop)/2+s)/e.height;t=o-r,i=o+r}else t=(this.visibleTop-e.top-s)/e.height,i=(this.visibleBottom-e.top+s)/e.height;r=ys(n,t),l=ys(n,i)}else{let i=n.total*this.heightOracle.charWidth,s=o*this.heightOracle.charWidth,a=0;if(i>2e6)for(let i of t)i.from>=e.from&&i.from<e.to&&i.size!=i.displaySize&&i.from*this.heightOracle.charWidth+a<this.pixelViewport.left&&(a=i.size-i.displaySize);let h,d,u=this.pixelViewport.left+a,p=this.pixelViewport.right+a;if(null!=c){let t=vs(n,c),e=((p-u)/2+s)/i;h=t-e,d=t+e}else h=(u-s)/i,d=(p+s)/i;r=ys(n,h),l=ys(n,d)}r>e.from&&a(e.from,r,e,n),l<e.to&&a(l,e.to,e,n)};for(let t of this.viewportLines)Array.isArray(t.type)?t.type.forEach(l):l(t);return r}gapSize(t,e,i,o){let n=vs(o,i)-vs(o,e);return this.heightOracle.lineWrapping?t.height*n:o.total*this.heightOracle.charWidth*n}updateLineGaps(t){ms.same(t,this.lineGaps)||(this.lineGaps=t,this.lineGapDeco=Je.set(t.map(t=>t.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(t){let e=this.stateDeco;this.lineGaps.length&&(e=e.concat(this.lineGapDeco));let i=[];he.spans(e,this.viewport.from,this.viewport.to,{span(t,e){i.push({from:t,to:e})},point(){}},20);let o=0;if(i.length!=this.visibleRanges.length)o=12;else for(let e=0;e<i.length&&!(8&o);e++){let n=this.visibleRanges[e],s=i[e];n.from==s.from&&n.to==s.to||(o|=4,t&&t.mapPos(n.from,-1)==s.from&&t.mapPos(n.to,1)==s.to||(o|=8))}return this.visibleRanges=i,o}lineBlockAt(t){return t>=this.viewport.from&&t<=this.viewport.to&&this.viewportLines.find(e=>e.from<=t&&e.to>=t)||xs(this.heightMap.lineAt(t,ts.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)||xs(this.heightMap.lineAt(this.scaler.fromDOM(t),ts.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 xs(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 bs{constructor(t,e){this.from=t,this.to=e}}function ys({total:t,ranges:e},i){if(i<=0)return e[0].from;if(i>=1)return e[e.length-1].to;let o=Math.floor(t*i);for(let t=0;;t++){let{from:i,to:n}=e[t],s=n-i;if(o<=s)return i+o;o-=s}}function vs(t,e){let i=0;for(let{from:o,to:n}of t.ranges){if(e<=n){i+=e-o;break}i+=n-o}return i/t.total}const ws={toDOM:t=>t,fromDOM:t=>t,scale:1,eq(t){return t==this}};class Cs{constructor(t,e,i){let o=0,n=0,s=0;this.viewports=i.map(({from:i,to:n})=>{let s=e.lineAt(i,ts.ByPos,t,0,0).top,r=e.lineAt(n,ts.ByPos,t,0,0).bottom;return o+=r-s,{from:i,to:n,top:s,bottom:r,domTop:0,domBottom:0}}),this.scale=(7e6-o)/(e.height-o);for(let t of this.viewports)t.domTop=s+(t.top-n)*this.scale,s=t.domBottom=t.domTop+(t.bottom-t.top),n=t.bottom}toDOM(t){for(let e=0,i=0,o=0;;e++){let n=e<this.viewports.length?this.viewports[e]:null;if(!n||t<n.top)return o+(t-i)*this.scale;if(t<=n.bottom)return n.domTop+(t-n.top);i=n.bottom,o=n.domBottom}}fromDOM(t){for(let e=0,i=0,o=0;;e++){let n=e<this.viewports.length?this.viewports[e]:null;if(!n||t<n.domTop)return i+(t-o)/this.scale;if(t<=n.domBottom)return n.top+(t-n.domTop);i=n.bottom,o=n.domBottom}}eq(t){return t instanceof Cs&&(this.scale==t.scale&&this.viewports.length==t.viewports.length&&this.viewports.every((e,i)=>e.from==t.viewports[i].from&&e.to==t.viewports[i].to))}}function xs(t,e){if(1==e.scale)return t;let i=e.toDOM(t.top),o=e.toDOM(t.bottom);return new Qn(t.from,t.length,i,o-i,Array.isArray(t._content)?t._content.map(t=>xs(t,e)):t._content)}const ks=ft.define({combine:t=>t.join(" ")}),Ss=ft.define({combine:t=>t.indexOf(!0)>-1}),Ts=Te.newName(),Es=Te.newName(),Ms=Te.newName(),As={"&light":"."+Es,"&dark":"."+Ms};function Is(t,e,i){return new Te(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 Ds=Is("."+Ts,{"&":{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",zIndex:200},".cm-gutters-before":{insetInlineStart:0},".cm-gutters-after":{insetInlineEnd:0},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",border:"0px solid #ddd","&.cm-gutters-before":{borderRightWidth:"1px"},"&.cm-gutters-after":{borderLeftWidth:"1px"}},"&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-dialog":{padding:"2px 19px 4px 6px",position:"relative","& label":{fontSize:"80%"}},".cm-dialog-close":{position:"absolute",top:"3px",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",fontSize:"14px",padding:"0"},".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,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="20"><path stroke="%23888" stroke-width="1" fill="none" d="M1 10H196L190 5M190 15L196 10M197 4L197 16"/></svg>\')',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"}},As),Os={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},Bs=We.ie&&We.ie_version<=11;class Ls{constructor(t){this.view=t,this.active=!1,this.editContext=null,this.selectionRange=new fi,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);(We.ie&&We.ie_version<=11||We.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||!We.android||!1===t.constructor.EDIT_CONTEXT||We.chrome&&We.chrome_version<126||(this.editContext=new Rs(t),t.state.facet(ao)&&(t.contentDOM.editContext=this.editContext.editContext)),Bs&&(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)<Date.now()-75&&this.onResize()}),this.resizeScroll.observe(t.scrollDOM)),this.addWindowListeners(this.win=t.win),this.start(),"function"==typeof IntersectionObserver&&(this.intersection=new IntersectionObserver(t=>{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,o=this.selectionRange;if(i.state.facet(ao)?i.root.activeElement!=this.dom:!ri(this.dom,o))return;let n=o.anchorNode&&i.docView.tile.nearest(o.anchorNode);n&&n.isWidget()&&n.widget.ignoreEvent(t)?e||(this.selectionChanged=!1):(We.ie&&We.ie_version<=11||We.android&&We.chrome)&&!i.state.selection.main.empty&&o.focusNode&&li(o.focusNode,o.focusOffset,o.anchorNode,o.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:t}=this,e=ni(t.root);if(!e)return!1;let i=We.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 qs(t,i)}let i=null;function o(t){t.preventDefault(),t.stopImmediatePropagation(),i=t.getTargetRanges()[0]}return t.contentDOM.addEventListener("beforeinput",o,!0),t.dom.ownerDocument.execCommand("indent"),t.contentDOM.removeEventListener("beforeinput",o,!0),i?qs(t,i):null}(this.view,e)||e;if(!i||this.selectionRange.eq(i))return!1;let o=ri(this.dom,i);return o&&!this.selectionChanged&&t.inputState.lastFocusTime>Date.now()-200&&t.inputState.lastTouchTime<Date.now()-300&&function(t,e){let i=e.focusNode,o=e.focusOffset;if(!i||e.anchorNode!=i||e.anchorOffset!=o)return!1;for(o=Math.min(o,ui(i));;)if(o){if(1!=i.nodeType)return!1;let t=i.childNodes[o-1];"false"==t.contentEditable?o--:(i=t,o=ui(i))}else{if(i==t)return!0;o=ci(i),i=i.parentNode}}(this.dom,i)?(this.view.inputState.lastFocusTime=0,t.docView.updateSelection(),!1):(this.selectionRange.setRange(i),o&&(this.selectionChanged=!0),!0)}setSelectionRange(t,e){this.selectionRange.set(t.node,t.offset,e.node,e.offset),this.selectionChanged=!1}clearSelectionRange(){this.selectionRange.set(null,0,null,0)}listenForScroll(){this.parentCheck=-1;let t=0,e=null;for(let i=this.dom;i;)if(1==i.nodeType)!e&&t<this.scrollTargets.length&&this.scrollTargets[t]==i?t++:e||(e=this.scrollTargets.slice(0,t)),e&&e.push(i),i=i.assignedSlot||i.parentNode;else{if(11!=i.nodeType)break;i=i.host}if(t<this.scrollTargets.length&&!e&&(e=this.scrollTargets.slice(0,t)),e){for(let t of this.scrollTargets)t.removeEventListener("scroll",this.onScroll);for(let t of this.scrollTargets=e)t.addEventListener("scroll",this.onScroll)}}ignore(t){if(!this.active)return t();try{return this.stop(),t()}finally{this.start(),this.clear()}}start(){this.active||(this.observer.observe(this.dom,Os),Bs&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),Bs&&this.dom.removeEventListener("DOMCharacterDataModified",this.onCharData))}clear(){this.processRecords(),this.queue.length=0,this.selectionChanged=!1}delayAndroidKey(t,e){var i;if(!this.delayedAndroidKey){let t=()=>{let t=this.delayedAndroidKey;if(t){this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=t.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&t.force&&Ci(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<Date.now()-50||!!(null===(i=this.delayedAndroidKey)||void 0===i?void 0:i.force)})}clearDelayedAndroidKey(){this.win.cancelAnimationFrame(this.flushingAndroidKey),this.delayedAndroidKey=null,this.flushingAndroidKey=-1}flushSoon(){this.delayedFlush<0&&(this.delayedFlush=this.view.win.requestAnimationFrame(()=>{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,o=!1;for(let n of t){let t=this.readMutation(n);t&&(t.typeOver&&(o=!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:o}}readChange(){let{from:t,to:e,typeOver:i}=this.processRecords(),o=this.selectionChanged&&ri(this.dom,this.selectionRange);if(t<0&&!o)return null;t>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let n=new yn(this.view,t,e,i);return this.view.docView.domChanged={newSel:n.newSel?n.newSel.main:null},n}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,o=wn(this.view,e);return this.view.state==i&&(e.domChanged||e.newSel&&!e.newSel.main.eq(this.view.state.selection.main))&&this.view.update([]),o}readMutation(t){let e=this.view.docView.tile.nearest(t.target);if(!e||e.isWidget())return null;if(e.markDirty("attributes"==t.type),"childList"==t.type){let i=Ns(e,t.previousSibling||t.target.previousSibling,-1),o=Ns(e,t.nextSibling||t.target.nextSibling,1);return{from:i?e.posAfter(i):e.posAtStart,to:o?e.posBefore(o):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(ao)!=t.state.facet(ao)&&(t.view.contentDOM.editContext=t.state.facet(ao)?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 Ns(t,e,i){for(;e;){let o=Mo.get(e);if(o&&o.parent==t)return o;let n=e.parentNode;e=n!=t.dom?n:i>0?e.nextSibling:e.previousSibling}return null}function qs(t,e){let i=e.startContainer,o=e.startOffset,n=e.endContainer,s=e.endOffset,r=t.docView.domAtPos(t.state.selection.main.anchor,1);return li(r.node,r.offset,n,s)&&([i,o,n,s]=[n,s,i,o]),{anchorNode:i,anchorOffset:o,focusNode:n,focusOffset:s}}class Rs{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=i=>{let o=t.state.selection.main,{anchor:n,head:s}=o,r=this.toEditorPos(i.updateRangeStart),a=this.toEditorPos(i.updateRangeEnd);t.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:i.updateRangeStart,editorBase:r,drifted:!1});let l=a-r>i.text.length;r==this.from&&n<this.from?r=n:a==this.to&&n>this.to&&(a=n);let c=xn(t.state.sliceDoc(r,a),i.text,(l?o.from:o.to)-r,l?"end":null);if(!c){let e=pt.single(this.toEditorPos(i.selectionStart),this.toEditorPos(i.selectionEnd));return void(e.main.eq(o)||t.dispatch({selection:e,userEvent:"select"}))}let h={from:c.from+r,to:c.toA+r,insert:U.of(i.text.slice(c.from,c.toB).split("\n"))};if((We.mac||We.android)&&h.from==s-1&&/^\. ?$/.test(i.text)&&"off"==t.contentDOM.getAttribute("autocorrect")&&(h={from:r,to:a,insert:U.of([i.text.replace("."," ")])}),this.pendingContextChange=h,!t.state.readOnly){let e=this.to-this.from+(h.to-h.from+h.insert.length);Cn(t,h,pt.single(this.toEditorPos(i.selectionStart,e),this.toEditorPos(i.selectionEnd,e)))}this.pendingContextChange&&(this.revertPending(t.state),this.setSelection(t.state)),h.from<h.to&&!h.insert.length&&t.inputState.composing>=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(e.text.slice(Math.max(0,i.updateRangeStart-1),Math.min(e.text.length,i.updateRangeStart+1)))&&this.handlers.compositionend(i)},this.handlers.characterboundsupdate=i=>{let o=[],n=null;for(let e=this.toEditorPos(i.rangeStart),s=this.toEditorPos(i.rangeEnd);e<s;e++){let i=t.coordsForChar(e);n=i&&new DOMRect(i.left,i.top,i.right-i.left,i.bottom-i.top)||n||new DOMRect,o.push(n)}e.updateCharacterBounds(i.rangeStart,o)},this.handlers.textformatupdate=e=>{let i=[];for(let t of e.getTextFormats()){let e=t.underlineStyle,o=t.underlineThickness;if(!/none/i.test(e)&&!/none/i.test(o)){let n=this.toEditorPos(t.rangeStart),s=this.toEditorPos(t.rangeEnd);if(n<s){let t=`text-decoration: underline ${/^[a-z]/.test(e)?e+" ":"Dashed"==e?"dashed ":"Squiggle"==e?"wavy ":""}${/thin/i.test(o)?1:2}px`;i.push(Je.mark({attributes:{style:t}}).range(n,s))}}}t.dispatch({effects:so.of(Je.set(i))})},this.handlers.compositionstart=()=>{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=ni(t.root);e&&e.rangeCount&&this.editContext.updateSelectionBounds(e.getRangeAt(0).getBoundingClientRect())}}}applyEdits(t){let e=0,i=!1,o=this.pendingContextChange;return t.changes.iterChanges((n,s,r,a,l)=>{if(i)return;let c=l.length-(s-n);if(o&&s>=o.to){if(o.from==n&&o.to==s&&o.insert.eq(l))return o=this.pendingContextChange=null,e+=c,void(this.to+=c);o=null,this.revertPending(t.state)}if(n+=e,(s+=e)<=this.from)this.from+=c,this.to+=c;else if(n<this.to){if(n<this.from||s>this.to||this.to-this.from+l.length>3e4)return void(i=!0);this.editContext.updateText(this.toContextPos(n),this.toContextPos(s),l.toString()),this.to+=c}e+=c}),o&&!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))),o=this.toContextPos(e.head);this.editContext.selectionStart==i&&this.editContext.selectionEnd==o||this.editContext.updateSelection(i,o)}rangeIsValid(t){let{head:e}=t.selection.main;return!(this.from>0&&e-this.from<500||this.to<t.doc.length&&this.to-e<500||this.to-this.from>3e4)}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 Fs{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 fs(t.state||ne.create(t)),t.scrollTo&&t.scrollTo.is(no)&&(this.viewState.scrollTarget=t.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(co).map(t=>new uo(t));for(let t of this.plugins)t.update(this);this.observer=new Ls(this),this.inputState=new kn(this),this.inputState.ensureHandlers(this.plugins),this.docView=new Ko(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,o=!1,n=this.state;for(let e of t){if(e.startState!=n)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");n=e.state}if(this.destroyed)return void(this.viewState.state=n);let s=this.hasFocus,r=0,a=null;t.some(t=>t.annotation($n))?(this.inputState.notifiedFocused=s,r=1):s!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=s,a=Un(n,s),a||(r=1));let l=this.observer.delayedAndroidKey,c=null;if(l?(this.observer.clearDelayedAndroidKey(),c=this.observer.readChange(),(c&&!this.state.doc.eq(n.doc)||!this.state.selection.eq(n.selection))&&(c=null)):this.observer.clear(),n.facet(ne.phrases)!=this.state.facet(ne.phrases))return this.setState(n);e=To.create(this,n,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 oo(t.empty?t:pt.cursor(t.head,t.head>t.anchor?-1:1))}for(let t of e.effects)t.is(no)&&(h=t.value.clip(this.state))}this.viewState.update(e,h),this.bidiCache=Vs.update(this.bidiCache,e.changes),e.empty||(this.updatePlugins(e),this.inputState.update(e)),i=this.docView.update(e),this.state.facet(ko)!=this.styleModules&&this.mountStyles(),o=this.updateAttrs(),this.showAnnouncements(t),this.docView.updateSelection(i,t.some(t=>t.isUserEvent("select.pointer")))}finally{this.updateState=0}if(e.startState.facet(ks)!=e.state.facet(ks)&&(this.viewState.mustMeasureContent=!0),(i||o||h||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),i&&this.docViewUpdate(),!e.empty)for(let t of this.state.facet(Zi))try{t(e)}catch(t){ro(this.state,t,"update listener")}(a||c)&&Promise.resolve().then(()=>{a&&this.state==a.startState&&this.dispatch(a),c&&!wn(this,c)&&l.force&&Ci(this.contentDOM,l.key,l.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 fs(t),this.plugins=t.facet(co).map(t=>new uo(t)),this.pluginMap.clear();for(let t of this.plugins)t.update(this);this.docView.destroy(),this.docView=new Ko(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(co),i=t.state.facet(co);if(e!=i){let o=[];for(let n of i){let i=e.indexOf(n);if(i<0)o.push(new uo(n));else{let e=this.plugins[i];e.mustUpdate=t,o.push(e)}}for(let e of this.plugins)e.mustUpdate!=t&&e.destroy(this);this.plugins=o,this.pluginMap.clear()}else for(let e of this.plugins)e.mustUpdate=t;for(let t=0;t<this.plugins.length;t++)this.plugins[t].update(this);e!=i&&this.inputState.ensureHandlers(this.plugins)}docViewUpdate(){for(let t of this.plugins){let e=t.value;if(e&&e.docViewUpdate)try{e.docViewUpdate(this)}catch(t){ro(this.state,t,"doc view update listener")}}}measure(t=!0){if(this.destroyed)return;if(this.measureScheduled>-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,o=i.scrollTop*this.scaleY,{scrollAnchorPos:n,scrollAnchorHeight:s}=this.viewState;Math.abs(o-this.viewState.scrollTop)>1&&(s=-1),this.viewState.scrollAnchorHeight=-1;try{for(let t=0;;t++){if(s<0)if(xi(i))n=-1,s=this.viewState.heightMap.height;else{let t=this.viewState.scrollAnchorAt(o);n=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 a=[];4&r||([this.measureRequests,a]=[a,this.measureRequests]);let l=a.map(t=>{try{return t.read(this)}catch(t){return ro(this.state,t),_s}}),c=To.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;t<a.length;t++)if(l[t]!=_s)try{let e=a[t];e.write&&e.write(l[t],this)}catch(t){ro(this.state,t)}if(h&&this.docView.updateSelection(!0),!c.viewportChanged&&0==this.measureRequests.length){if(this.viewState.editorHeight){if(this.viewState.scrollTarget){this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,s=-1;continue}{let t=(n<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(n).top)-s;if(t>1||t<-1){o+=t,i.scrollTop=o/this.scaleY,s=-1;continue}}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(e&&!e.empty)for(let t of this.state.facet(Zi))t(e)}get themeClasses(){return Ts+" "+(this.state.facet(Ss)?Ms:Es)+" "+this.state.facet(ks)}updateAttrs(){let t=zs(this,po,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),e={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(ao)?"true":"false",class:"cm-content",style:`${We.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(e["aria-readonly"]="true"),zs(this,mo,e);let i=this.observer.ignore(()=>{let i=Ye(this.contentDOM,this.contentAttrs,e),o=Ye(this.dom,this.editorAttrs,t);return i||o});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(Fs.announce)){e&&(this.announceDOM.textContent=""),e=!1,this.announceDOM.appendChild(document.createElement("div")).textContent=t.value}}mountStyles(){this.styleModules=this.state.facet(ko);let t=this.state.facet(Fs.cspNonce);Te.mount(this.root,this.styleModules.concat(Ds).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;e<this.measureRequests.length;e++)if(this.measureRequests[e].key===t.key)return void(this.measureRequests[e]=t);this.measureRequests.push(t)}}plugin(t){let e=this.pluginMap.get(t);return(void 0===e||e&&e.plugin!=t)&&this.pluginMap.set(t,e=this.plugins.find(e=>e.plugin==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 ln(this,t,sn(this,t,e,i))}moveByGroup(t,e){return ln(this,t,sn(this,t,e,e=>function(t,e,i){let o=t.state.charCategorizer(e),n=o(i);return t=>{let e=o(t);return n==te.Space&&(n=e),n==e}}(this,t.head,e)))}visualLineSide(t,e){let i=this.bidiSpans(t),o=this.textDirectionAt(t.from),n=i[e?i.length-1:0];return pt.cursor(n.side(e,o)+t.from,n.forward(!e,o)?1:-1)}moveToLineBoundary(t,e,i=!0){return nn(this,t,e,i)}moveVertically(t,e,i){return ln(this,t,function(t,e,i,o){let n=e.head,s=i?1:-1;if(n==(i?t.state.doc.length:0))return pt.cursor(n,e.assoc);let r,a=e.goalColumn,l=t.contentDOM.getBoundingClientRect(),c=t.coordsAtPos(n,e.assoc||-1),h=t.documentTop;if(c)null==a&&(a=c.left-l.left),r=s<0?c.top:c.bottom;else{let e=t.viewState.lineBlockAt(n);null==a&&(a=Math.min(l.right-l.left,t.defaultCharacterWidth*(n-e.from))),r=(s<0?e.top:e.bottom)+h}let d=l.left+a,u=null!=o?o:t.viewState.heightOracle.textHeight>>1;for(let e=0;;e+=10){let i=hn(t,{x:d,y:r+(u+e)*s},!1,s);return pt.cursor(i.pos,i.assoc,void 0,a)}}(this,t,e,i))}domAtPos(t,e=1){return this.docView.domAtPos(t,e)}posAtDOM(t,e=0){return this.docView.posFromDOM(t,e)}posAtCoords(t,e=!0){this.readMeasured();let i=hn(this,t,e);return i&&i.pos}posAndSideAtCoords(t,e=!0){return this.readMeasured(),hn(this,t,e)}coordsAtPos(t,e=1){this.readMeasured();let i=this.docView.coordsAt(t,e);if(!i||i.left==i.right)return i;let o=this.state.doc.lineAt(t),n=this.bidiSpans(o);return pi(i,n[Ri.find(n,t-o.from,-1,e)].dir==Ei.LTR==e>0)}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(to)||t<this.viewport.from||t>this.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(t))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(t){if(t.length>Ps)return zi(t.length);let e,i=this.textDirectionAt(t.from);for(let o of this.bidiCache)if(o.from==t.from&&o.dir==i&&(o.fresh||Fi(o.isolates,e=wo(this,t))))return o.order;e||(e=wo(this,t));let o=function(t,e,i){if(!t)return[new Ri(0,0,e==Ai?1:0)];if(e==Mi&&!i.length&&!qi.test(t))return zi(t.length);if(i.length)for(;t.length>Pi.length;)Pi[Pi.length]=256;let o=[],n=e==Mi?0:1;return Vi(t,n,n,i,0,t.length,o),o}(t.text,i,e);return this.bidiCache.push(new Vs(t.from,t.to,i,e,!0,o)),o}get hasFocus(){var t;return(this.dom.ownerDocument.hasFocus()||We.safari&&(null===(t=this.inputState)||void 0===t?void 0:t.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{vi(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 no.of(new oo("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 no.of(new oo(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 ho.define(()=>({}),{eventHandlers:t})}static domEventObservers(t){return ho.define(()=>({}),{eventObservers:t})}static theme(t,e){let i=Te.newName(),o=[ks.of(i),ko.of(Is(`.${i}`,t))];return e&&e.dark&&o.push(Ss.of(!0)),o}static baseTheme(t){return It.lowest(ko.of(Is("."+Ts,t,As)))}static findFromDOM(t){var e;let i=t.querySelector(".cm-content"),o=i&&Mo.get(i)||Mo.get(t);return(null===(e=null==o?void 0:o.root)||void 0===e?void 0:e.view)||null}}Fs.styleModule=ko,Fs.inputHandler=Ki,Fs.clipboardInputFilter=Xi,Fs.clipboardOutputFilter=Qi,Fs.scrollHandler=io,Fs.focusChangeEffect=Ji,Fs.perLineTextDirection=to,Fs.exceptionSink=Gi,Fs.updateListener=Zi,Fs.editable=ao,Fs.mouseSelectionStyle=Yi,Fs.dragMovesSelection=ji,Fs.clickAddsSelectionRange=Ui,Fs.decorations=go,Fs.blockWrappers=fo,Fs.outerDecorations=bo,Fs.atomicRanges=yo,Fs.bidiIsolatedRanges=vo,Fs.scrollMargins=Co,Fs.darkTheme=Ss,Fs.cspNonce=ft.define({combine:t=>t.length?t[0]:""}),Fs.contentAttributes=mo,Fs.editorAttributes=po,Fs.lineWrapping=Fs.contentAttributes.of({class:"cm-lineWrapping"}),Fs.announce=jt.define();const Ps=4096,_s={};class Vs{constructor(t,e,i,o,n,s){this.from=t,this.to=e,this.dir=i,this.isolates=o,this.fresh=n,this.order=s}static update(t,e){if(e.empty&&!t.some(t=>t.fresh))return t;let i=[],o=t.length?t[t.length-1].dir:Ei.LTR;for(let n=Math.max(0,t.length-10);n<t.length;n++){let s=t[n];s.dir!=o||e.touchesRange(s.from,s.to)||i.push(new Vs(e.mapPos(s.from,1),e.mapPos(s.to,-1),s.dir,s.isolates,!1,s.order))}return i}}function zs(t,e,i){for(let o=t.state.facet(e),n=o.length-1;n>=0;n--){let e=o[n],s="function"==typeof e?e(t):e;s&&$e(s,i)}return i}class Hs extends se{compare(t){return this==t||this.constructor==t.constructor&&this.eq(t)}eq(t){return!1}destroy(t){}}Hs.prototype.elementClass="",Hs.prototype.toDOM=void 0,Hs.prototype.mapMode=ot.TrackBefore,Hs.prototype.startSide=Hs.prototype.endSide=-1,Hs.prototype.point=!0;let Ws=0;class $s{constructor(t,e,i,o){this.name=t,this.set=e,this.base=i,this.modified=o,this.id=Ws++}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 $s&&(e=t),null==e?void 0:e.base)throw new Error("Can not derive from a modified tag");let o=new $s(i,[],null,[]);if(o.set.push(o),e)for(let t of e.set)o.set.push(t);return o}static defineModifier(t){let e=new js(t);return t=>t.modified.indexOf(e)>-1?t:js.get(t.base||t,t.modified.concat(e).sort((t,e)=>t.id-e.id))}}let Us=0;class js{constructor(t){this.name=t,this.instances=[],this.id=Us++}static get(t,e){if(!e.length)return t;let i=e[0].instances.find(i=>{return i.base==t&&(o=e,n=i.modified,o.length==n.length&&o.every((t,e)=>t==n[e]));var o,n});if(i)return i;let o=[],n=new $s(t.name,o,t,e);for(let t of e)t.instances.push(n);let s=function(t){let e=[[]];for(let i=0;i<t.length;i++)for(let o=0,n=e.length;o<n;o++)e.push(e[o].concat(t[i]));return e.sort((t,e)=>e.length-t.length)}(e);for(let e of t.set)if(!e.modified.length)for(let t of s)o.push(js.get(e,t));return n}}function Ys(t){let e=Object.create(null);for(let i in t){let o=t[i];Array.isArray(o)||(o=[o]);for(let t of i.split(" "))if(t){let i=[],n=2,s=t;for(let e=0;;){if("..."==s&&e>0&&e+3==t.length){n=1;break}let o=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(s);if(!o)throw new RangeError("Invalid path: "+t);if(i.push("*"==o[0]?"":'"'==o[0][0]?JSON.parse(o[0]):o[0]),e+=o[0].length,e==t.length)break;let r=t[e++];if(e==t.length&&"!"==r){n=0;break}if("/"!=r)throw new RangeError("Invalid path: "+t);s=t.slice(e)}let r=i.length-1,a=i[r];if(!a)throw new RangeError("Invalid path: "+t);let l=new Zs(o,n,r>0?i.slice(0,r):null);e[a]=l.sort(e[a])}}return Gs.add(e)}const Gs=new r({combine(t,e){let i,o,n;for(;t||e;){if(!t||e&&t.depth>=e.depth?(n=e,e=e.next):(n=t,t=t.next),i&&i.mode==n.mode&&!n.context&&!i.context)continue;let s=new Zs(n.tags,n.mode,n.context);i?i.next=s:o=s,i=s}return o}});class Zs{constructor(t,e,i,o){this.tags=t,this.mode=e,this.context=i,this.next=o}get opaque(){return 0==this.mode}get inherit(){return 1==this.mode}sort(t){return!t||t.depth<this.depth?(this.next=t,this):(t.next=this.sort(t.next),t)}get depth(){return this.context?this.context.length:0}}function Ks(t,e){let i=Object.create(null);for(let e of t)if(Array.isArray(e.tag))for(let t of e.tag)i[t.id]=e.class;else i[e.tag.id]=e.class;let{scope:o,all:n=null}=e||{};return{style:t=>{let e=n;for(let o of t)for(let t of o.set){let o=i[t.id];if(o){e=e?e+" "+o:o;break}}return e},scope:o}}Zs.empty=new Zs([],2,null);const Js=$s.define,Xs=Js(),Qs=Js(),tr=Js(Qs),er=Js(Qs),ir=Js(),or=Js(ir),nr=Js(ir),sr=Js(),rr=Js(sr),ar=Js(),lr=Js(),cr=Js(),hr=Js(cr),dr=Js(),ur={comment:Xs,lineComment:Js(Xs),blockComment:Js(Xs),docComment:Js(Xs),name:Qs,variableName:Js(Qs),typeName:tr,tagName:Js(tr),propertyName:er,attributeName:Js(er),className:Js(Qs),labelName:Js(Qs),namespace:Js(Qs),macroName:Js(Qs),literal:ir,string:or,docString:Js(or),character:Js(or),attributeValue:Js(or),number:nr,integer:Js(nr),float:Js(nr),bool:Js(ir),regexp:Js(ir),escape:Js(ir),color:Js(ir),url:Js(ir),keyword:ar,self:Js(ar),null:Js(ar),atom:Js(ar),unit:Js(ar),modifier:Js(ar),operatorKeyword:Js(ar),controlKeyword:Js(ar),definitionKeyword:Js(ar),moduleKeyword:Js(ar),operator:lr,derefOperator:Js(lr),arithmeticOperator:Js(lr),logicOperator:Js(lr),bitwiseOperator:Js(lr),compareOperator:Js(lr),updateOperator:Js(lr),definitionOperator:Js(lr),typeOperator:Js(lr),controlOperator:Js(lr),punctuation:cr,separator:Js(cr),bracket:hr,angleBracket:Js(hr),squareBracket:Js(hr),paren:Js(hr),brace:Js(hr),content:sr,heading:rr,heading1:Js(rr),heading2:Js(rr),heading3:Js(rr),heading4:Js(rr),heading5:Js(rr),heading6:Js(rr),contentSeparator:Js(sr),list:Js(sr),quote:Js(sr),emphasis:Js(sr),strong:Js(sr),link:Js(sr),monospace:Js(sr),strikethrough:Js(sr),inserted:Js(),deleted:Js(),changed:Js(),invalid:Js(),meta:dr,documentMeta:Js(dr),annotation:Js(dr),processingInstruction:Js(dr),definition:$s.defineModifier("definition"),constant:$s.defineModifier("constant"),function:$s.defineModifier("function"),standard:$s.defineModifier("standard"),local:$s.defineModifier("local"),special:$s.defineModifier("special")};for(let t in ur){let e=ur[t];e instanceof $s&&(e.name=t)}var pr;Ks([{tag:ur.link,class:"tok-link"},{tag:ur.heading,class:"tok-heading"},{tag:ur.emphasis,class:"tok-emphasis"},{tag:ur.strong,class:"tok-strong"},{tag:ur.keyword,class:"tok-keyword"},{tag:ur.atom,class:"tok-atom"},{tag:ur.bool,class:"tok-bool"},{tag:ur.url,class:"tok-url"},{tag:ur.labelName,class:"tok-labelName"},{tag:ur.inserted,class:"tok-inserted"},{tag:ur.deleted,class:"tok-deleted"},{tag:ur.literal,class:"tok-literal"},{tag:ur.string,class:"tok-string"},{tag:ur.number,class:"tok-number"},{tag:[ur.regexp,ur.escape,ur.special(ur.string)],class:"tok-string2"},{tag:ur.variableName,class:"tok-variableName"},{tag:ur.local(ur.variableName),class:"tok-variableName tok-local"},{tag:ur.definition(ur.variableName),class:"tok-variableName tok-definition"},{tag:ur.special(ur.variableName),class:"tok-variableName2"},{tag:ur.definition(ur.propertyName),class:"tok-propertyName tok-definition"},{tag:ur.typeName,class:"tok-typeName"},{tag:ur.namespace,class:"tok-namespace"},{tag:ur.className,class:"tok-className"},{tag:ur.macroName,class:"tok-macroName"},{tag:ur.propertyName,class:"tok-propertyName"},{tag:ur.operator,class:"tok-operator"},{tag:ur.comment,class:"tok-comment"},{tag:ur.meta,class:"tok-meta"},{tag:ur.invalid,class:"tok-invalid"},{tag:ur.punctuation,class:"tok-punctuation"}]);const mr=new r,gr=new r;class fr{constructor(t,e,i=[],o=""){this.data=t,this.name=o,ne.prototype.hasOwnProperty("tree")||Object.defineProperty(ne.prototype,"tree",{get(){return yr(this)}}),this.parser=e,this.extension=[Mr.of(this),ne.languageData.of((t,e,i)=>{let o=br(t,e,i),n=o.type.prop(mr);if(!n)return[];let s=t.facet(n),r=o.type.prop(gr);if(r){let n=o.resolve(e-o.from,i);for(let e of r)if(e.test(n,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 br(t,e,i).type.prop(mr)==this.data}findRegions(t){let e=t.facet(Mr);if((null==e?void 0:e.data)==this.data)return[{from:0,to:t.doc.length}];if(!e||!e.allowsNesting)return[];let i=[],o=(t,e)=>{if(t.prop(mr)==this.data)return void i.push({from:e,to:e+t.length});let n=t.prop(r.mounted);if(n){if(n.tree.prop(mr)==this.data){if(n.overlay)for(let t of n.overlay)i.push({from:t.from+e,to:t.to+e});else i.push({from:e,to:e+t.length});return}if(n.overlay){let t=i.length;if(o(n.tree,n.overlay[0].from+e),i.length>t)return}}for(let i=0;i<t.children.length;i++){let n=t.children[i];n instanceof p&&o(n,t.positions[i]+e)}};return o(yr(t),0),i}get allowsNesting(){return!0}}function br(t,e,i){let o=t.facet(Mr),n=yr(t).topNode;if(!o||o.allowsNesting)for(let t=n;t;t=t.enter(e,i,u.ExcludeBuffers|u.EnterBracketed))t.type.isTop&&(n=t);return n}function yr(t){let e=t.field(fr.state,!1);return e?e.tree:p.empty}fr.setState=jt.define();class vr{constructor(t){this.doc=t,this.cursorPos=0,this.string="",this.cursor=t.iter()}get length(){return this.doc.length}syncTo(t){return this.string=this.cursor.next(t-this.cursorPos).value,this.cursorPos=t+this.string.length,this.cursorPos-this.string.length}chunk(t){return this.syncTo(t),this.string}get lineChunks(){return!0}read(t,e){let i=this.cursorPos-this.string.length;return t<i||e>=this.cursorPos?this.doc.sliceString(t,e):this.string.slice(t-i,e-i)}}let wr=null;class Cr{constructor(t,e,i=[],o,n,s,r,a){this.parser=t,this.state=e,this.fragments=i,this.tree=o,this.treeLen=n,this.viewport=s,this.skipped=r,this.scheduleOn=a,this.parse=null,this.tempSkipped=[]}static create(t,e,i){return new Cr(t,e,[],p.empty,0,i,[],null)}startParse(){return this.parser.startParse(new vr(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.state.doc.length&&this.parse.stopAt(e);;){let o=this.parse.advance();if(o){if(this.fragments=this.withoutTempSkipped(O.addTree(o,this.fragments,null!=this.parse.stoppedAt)),this.treeLen=null!==(i=this.parse.stoppedAt)&&void 0!==i?i:this.state.doc.length,this.tree=o,this.parse=null,!(this.treeLen<(null!=e?e:this.state.doc.length)))return!0;this.parse=this.startParse()}if(t())return!1}})}takeTree(){let t,e;this.parse&&(t=this.parse.parsedPos)>=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=wr;wr=this;try{return t()}finally{wr=e}}withoutTempSkipped(t){for(let e;e=this.tempSkipped.pop();)t=xr(t,e.from,e.to);return t}changes(t,e){let{fragments:i,tree:o,treeLen:n,viewport:s,skipped:r}=this;if(this.takeTree(),!t.empty){let e=[];if(t.iterChangedRanges((t,i,o,n)=>e.push({fromA:t,toA:i,fromB:o,toB:n})),i=O.applyChanges(i,e),o=p.empty,n=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),o=t.mapPos(e.to,-1);i<o&&r.push({from:i,to:o})}}}return new Cr(this.parser,e,i,o,n,s,r,this.scheduleOn)}updateViewport(t){if(this.viewport.from==t.from&&this.viewport.to==t.to)return!1;this.viewport=t;let e=this.skipped.length;for(let e=0;e<this.skipped.length;e++){let{from:i,to:o}=this.skipped[e];i<t.to&&o>t.from&&(this.fragments=xr(this.fragments,i,o),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,o){let n=o[0].from,s=o[o.length-1].to;return{parsedPos:n,advance(){let e=wr;if(e){for(let t of o)e.tempSkipped.push(t);t&&(e.scheduleOn=e.scheduleOn?Promise.all([e.scheduleOn,t]):t)}return this.parsedPos=s,new p(c.none,[],[],s-n)},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 wr}}function xr(t,e,i){return O.applyChanges(t,[{fromA:e,toA:i,fromB:e,toB:i}])}class kr{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 kr(e)}static init(t){let e=Math.min(3e3,t.doc.length),i=Cr.create(t.facet(Mr).parser,t,{from:0,to:e});return i.work(20,e)||i.takeTree(),new kr(i)}}fr.state=kt.define({create:kr.init,update(t,e){for(let t of e.effects)if(t.is(fr.setState))return t.value;return e.startState.facet(Mr)!=e.state.facet(Mr)?kr.init(e.state):t.apply(e)}});let Sr=t=>{let e=setTimeout(()=>t(),500);return()=>clearTimeout(e)};"undefined"!=typeof requestIdleCallback&&(Sr=t=>{let e=-1,i=setTimeout(()=>{e=requestIdleCallback(t,{timeout:400})},100);return()=>e<0?clearTimeout(i):cancelIdleCallback(e)});const Tr="undefined"!=typeof navigator&&(null===(pr=navigator.scheduling)||void 0===pr?void 0:pr.isInputPending)?()=>navigator.scheduling.isInputPending():null,Er=ho.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(fr.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(fr.state);e.tree==e.context.tree&&e.context.isDone(t.doc.length)||(this.working=Sr(this.work))}work(t){this.working=null;let e=Date.now();if(this.chunkEnd<e&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=e+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:i,viewport:{to:o}}=this.view,n=i.field(fr.state);if(n.tree==n.context.tree&&n.context.isDone(o+1e5))return;let s=Date.now()+Math.min(this.chunkBudget,100,t&&!Tr?Math.max(25,t.timeRemaining()-5):1e9),r=n.context.treeLen<o&&i.doc.length>o+1e3,a=n.context.work(()=>Tr&&Tr()||Date.now()>s,o+(r?0:1e5));this.chunkBudget-=Date.now()-e,(a||this.chunkBudget<=0)&&(n.context.takeTree(),this.view.dispatch({effects:fr.setState.of(new kr(n.context))})),this.chunkBudget>0&&(!a||r)&&this.scheduleWork(),this.checkAsyncSchedule(n.context)}checkAsyncSchedule(t){t.scheduleOn&&(this.workScheduled++,t.scheduleOn.then(()=>this.scheduleWork()).catch(t=>ro(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()}}}),Mr=ft.define({combine:t=>t.length?t[0]:null,enables:t=>[fr.state,Er,Fs.contentAttributes.compute([t],e=>{let i=e.facet(t);return i&&i.name?{"data-language":i.name}:{}})]});ur.meta,ur.link,ur.heading,ur.emphasis,ur.strong,ur.strikethrough,ur.keyword,ur.atom,ur.bool,ur.url,ur.contentSeparator,ur.labelName,ur.literal,ur.inserted,ur.string,ur.deleted,ur.regexp,ur.escape,ur.string,ur.variableName,ur.variableName,ur.typeName,ur.namespace,ur.className,ur.variableName,ur.macroName,ur.propertyName,ur.comment,ur.invalid;const Ar=Object.create(null),Ir=[c.none],Dr=[],Or=Object.create(null),Br=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"]])Br[t]=Nr(Ar,e);function Lr(t,e){Dr.indexOf(t)>-1||(Dr.push(t),console.warn(e))}function Nr(t,e){let i=[];for(let o of e.split(" ")){let e=[];for(let i of o.split(".")){let o=t[i]||ur[i];o?"function"==typeof o?e.length?e=e.map(o):Lr(i,`Modifier ${i} used at start of tag`):e.length?Lr(i,`Tag ${i} used as modifier`):e=Array.isArray(o)?o:[o]:Lr(i,`Unknown highlighting tag ${i}`)}for(let t of e)i.push(t)}if(!i.length)return 0;let o=e.replace(/ /g,"_"),n=o+" "+i.map(t=>t.id),s=Or[n];if(s)return s.id;let r=Or[n]=c.define({id:Ir.length,name:o,props:[Ys({[o]:i})]});return Ir.push(r),r.id}function qr(t){let e=Date.now().toString(36);return e+=Math.random().toString(36).substr(3,t),e}function Rr(t,e,i,o){let n,s={index:-1,subindex:-1},r=o;return i?r.forEach((t,i)=>{if("SubmenuCommands"in t&&(n=t.SubmenuCommands.findIndex(t=>t.id==e.id),n>=0))return s={index:i,subindex:n},s}):(n=r.findIndex(t=>t.id==e.id),s={index:n,subindex:-1}),s}function Fr(t,e){let i,o=e.getLine(e.getCursor().line),n="";const s=/^(\>*(\[[!\w]+\])?\s*)#+\s/;let r;const a=o.match(s);a&&(r=a[0].trim()),t==r||""==t?i=o.replace(s,"$1"):(i=o.replace(/^\s*(#*|\>|\-|\d+\.)\s*/m,""),i=t+" "+i),n=""!=i?e.getRange(e.getCursor(),{line:e.getCursor().line,ch:o.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-n.length)})}function Pr(t,e){if(!e)return;const i=e.getSelection();if(!i||""===i.trim())return void this.plugin.setLastExecutedCommand("editing-toolbar:change-font-color");const o=/<font\s+color=["']?[^"'>]+["']?>(.*?)<\/font>/gms,n=o.test(i);if(s=i,new RegExp(`^<font\\s+color=["']?${t}["']?>(.+)<\\/font>$`,"ms").test(s.trim()))return;var s;const r=i.replace(o,(e,i)=>i.split("\n").map(e=>e.trim()?`<font color="${t}">${e}</font>`:e).join("\n")),a=r===i?i.split("\n").map(e=>e.trim()?`<font color="${t}">${e}</font>`:e).join("\n"):r,l=e.listSelections().map(e=>{const i=n?0:`<font color="${t}"></font>`.length;return e.anchor.line<e.head.line||e.anchor.line===e.head.line&&e.anchor.ch<e.head.ch?{anchor:{line:e.anchor.line,ch:e.anchor.ch},head:{line:e.head.line,ch:e.head.ch+i}}:{anchor:{line:e.anchor.line,ch:e.anchor.ch+i},head:{line:e.head.line,ch:e.head.ch}}});e.replaceSelection(a),e.setSelections(l)}function _r(t,e){if(!e)return;const i=e.getSelection();if(!i||""===i.trim())return;const o=/<mark\s+style=["']?background:(?:#[0-9a-fA-F]{3,6}|rgba?\([^)]+\))["']?>([\s\S]*?)<\/mark>/g.test(i);if(((t,e)=>{const i=e.replace(/([()[{*+.$^\\|?])/g,"\\$1");return new RegExp(`^<mark\\s+style=["']?background:${i}["']?>([sS]+)<\\/mark>$`).test(t.trim())})(i,t))return;let n;n=o?i.replace(/(background:)(?:#[0-9a-fA-F]{3,6}|rgba?\([^)]+\))/gi,`$1${t}`):i.split("\n").map(e=>e.trim()?`<mark style="background:${t}">${e}</mark>`:e).join("\n");const s=e.listSelections().map(e=>{const i=o?0:`<mark style="background:${t}"></mark>`.length;return e.anchor.line<e.head.line||e.anchor.line===e.head.line&&e.anchor.ch<e.head.ch?{anchor:{line:e.anchor.line,ch:e.anchor.ch},head:{line:e.head.line,ch:e.head.ch+i}}:{anchor:{line:e.anchor.line,ch:e.anchor.ch+i},head:{line:e.head.line,ch:e.head.ch}}});e.replaceSelection(n),e.setSelections(s)}function Vr(t){var e,i;if(!t.getSelection()){const o=t.getCursor(),n=t.getLine(o.line);if(/^\s*\d+\.\s/.test(n)){const n=(null===(e=t.getLine(o.line).match(/^\s*/))||void 0===e?void 0:e[0].length)||0,s=o.line-1,r=s>=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)<n){const{startLine:e,endLine:i}=function(t,e){let i=e,o=e;for(;i>0;){const e=t.getLine(i-1);if(!/^\s*\d+\.\s/.test(e.trim()))break;i--}for(;o<t.lineCount()-1;){const e=t.getLine(o+1);if(!/^\s*\d+\.\s/.test(e.trim()))break;o++}return{startLine:i,endLine:o}}(t,o.line);Hr(t,e,i)}else{const{startLine:e,endLine:i}=function(t,e){var i,o;let n=e,s=e;const r=(null===(i=t.getLine(e).match(/^\s*/))||void 0===i?void 0:i[0].length)||0;for(;s<t.lineCount()-1;){const e=t.getLine(s+1),i=(null===(o=e.match(/^\s*/))||void 0===o?void 0:o[0].length)||0;if(!/^\s*\d+\.\s/.test(e.trim())||i<r)break;s++}return{startLine:n,endLine:s}}(t,o.line);Hr(t,e,i)}}return}const{lines:o,startLine:n}=function(t){const e=t.getSelection(),i=t.getCursor("from");return{lines:e.split("\n"),startLine:i.line}}(t);zr(o,n,t)}function zr(e,i,o){var n,s,r;let a=!1;for(const t of e)if(/^\s*\d+\.\s/.test(t.trim())){a=!0;break}if(!a)return;const l=null===(n=app.workspace.getActiveViewOfType(t.MarkdownView))||void 0===n?void 0:n.editor.cm;if(!l)return;const c=yr(l.state),h=o.posToOffset({line:i,ch:0});let d=-1;if(c.iterate({from:0,to:h,enter:t=>{"OrderedList"===t.name&&(d=t.to)}}),d>=0){const t=o.offsetToPos(d).line+1;t<i&&!/^\s*$/.test(o.getLine(t).trim())&&(o.replaceRange("\n",{line:t,ch:0},{line:t,ch:0}),i++)}let u=!0,p=[],m=-1;for(const t of e){const e=t.trim();if(/^\d+\.\s/.test(e)){const i=(null===(s=t.match(/^\s*/))||void 0===s?void 0:s[0].length)||0,o=parseInt(e.match(/^\d+/)[0],10);if(p[i]=i!==m?1:(p[i]||1)+1,o!==p[i]){u=!1;break}m=i}}let g=[];const f=i-1,b=f>=0?o.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 o of e){const e=o.trim(),n=/^\d+\.\s/.test(e),s=(null===(r=o.match(/^\s*/))||void 0===r?void 0:r[0])||"";if(n){const o=s.length;t[o]=o!==i?1:(t[o]||1)+1,g.push(`${s}${t[o]}. ${e.replace(/^\d+\.\s/,"")}`),i=o}else g.push(o),i=-1}}o.replaceRange(g.join("\n"),{line:i,ch:0},{line:i+e.length-1,ch:o.getLine(i+e.length-1).length})}function Hr(t,e,i){const o=[];for(let n=e;n<=i;n++)o.push(t.getLine(n));zr(o,e,t)}let Wr;Ei.RTL,Ei.LTR;const $r=e=>{Wr=t.requireApiVersion("0.15.0")?activeWindow.document:window.document;["top","following","fixed"].forEach(t=>{Wr.querySelectorAll(`.editingToolbarModalBar[data-toolbar-style="${t}"]`).forEach(t=>{e?(t.style.display="",t.style.visibility="visible"):t.style.display="none"})});const i=Wr.getElementById("editingToolbarModalBar");i&&(e?(i.style.display="",i.style.visibility="visible"):i.style.display="none")},Ur=e=>{Wr=t.requireApiVersion("0.15.0")?activeWindow.document:window.document,Wr.documentElement.style.setProperty("--toolbar-vertical-offset",`${e.verticalPosition}px`)},jr=e=>{Wr=t.requireApiVersion("0.15.0")?activeWindow.document:window.document,Wr.documentElement.style.setProperty("--toolbar-horizontal-offset",`${e.horizontalPosition}px`)};var Yr={"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 Separator":"Add Separator","Enter the icon code, it looks like <svg>.... </svg> format":"Enter the icon code, it looks like <svg>.... </svg> 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 color":"Click on the picker to adjust the color","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.":"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 <svg>.... </svg>":"Enter the icon code, format as <svg>.... </svg>","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 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","Current line is empty, please select text or move to a non-empty line":"Current line is empty, please select text or move to a non-empty line","Use current line for regex commands":"Use current line for regex commands","When no text is selected, regex commands will use the current line instead of clipboard content":"When no text is selected, regex commands will use the current line instead of clipboard content","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","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 (With a hypothetical command configuration.)":"Toolbar Preview (With a hypothetical command configuration.)","Toolbar Theme":"Toolbar Theme","Select a preset toolbar theme, automatically setting the background color, icon color, and size for the selected style.":"Select a preset toolbar theme, automatically setting the background color, icon color, and size for the selected style.","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","Use \\n to represent line breaks":"Use \\n to represent line breaks","Use ↵ to represent line breaks":"Use ↵ to represent line breaks","Top Toolbar":"Top Toolbar","Enable the toolbar positioned at the top.":"Enable the toolbar positioned at the top.","Following Toolbar":"Following Toolbar","Enable the toolbar that appears upon text selection.":"Enable the toolbar that appears upon text selection.","Fixed Toolbar":"Fixed Toolbar","Enable the toolbar whose position may be fixed where you please.":"Enable the toolbar whose position may be fixed where you please.","Toolbar Settings":"Toolbar Settings","Choose which toolbar style's appearance you want to edit.":"Choose which toolbar style's appearance you want to edit.","Vertical Split":"Vertical Split"},Gr={"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 Separator":"添加分割线","Enter the icon code, it looks like <svg>.... </svg> format":"输入图标代码,类似<svg>.... </svg>格式","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 color":"点击选取器来调整颜色","Mobile Enabled or Not":"是否在移动端启用","Whether to enable on mobile devices with device width less than 768px.":"是否在设备宽度小于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 <svg>.... </svg>":"输入图标代码,格式为 <svg>.... </svg>","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":"请先选中文本","Current line is empty, please select text or move to a non-empty line":"当前行为空,请选中文本或移动到非空行","Use current line for regex commands":"正则命令使用当前行","When no text is selected, regex commands will use the current line instead of clipboard content":"当没有选中文本时,正则命令将使用当前行内容而不是剪贴板内容","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:"命令","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 (With a hypothetical command configuration.)":"工具栏预览(按钮仅供参考)","Toolbar Theme":"工具栏主题","Select a preset toolbar theme, automatically setting the background color, icon color, and size for the selected style.":"选择预设的工具栏主题,自动设置背景颜色、图标颜色和大小","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:"确认","Use \\n to represent line breaks":"使用\\n表示换行符","Use ↵ to represent line breaks":"使用↵表示换行符","All commands have been removed.":"所有命令已被清除。","Top Toolbar":"顶部工具栏","Enable the toolbar positioned at the top.":"启用位于顶部的工具栏。","Following Toolbar":"跟随工具栏","Enable the toolbar that appears upon text selection.":"启用在选中文本时出现的工具栏。","Fixed Toolbar":"固定工具栏","Enable the toolbar whose position may be fixed where you please.":"启用可以固定在任意位置的工具栏。","Toolbar Settings":"工具栏设置","Choose which toolbar style's appearance you want to edit.":"选择要编辑外观的工具栏样式。","Vertical Split":"垂直分割"},Zr=Object.assign({},Gr);const Kr={ar:{},cs:{},da:{},de:{},en:Yr,"en-gb":{"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-Colour formatting brush ON!",More:"More","Font Colors":"Font Colours","Format Brush":"Format Brush","Background color":"Background colour",Refresh:"Refresh",Add:"Add",Delete:"Delete","Change Command Name":"Change Command Name","Add Submenu":"Add Submenu","Add Separator":"Add Separator","Enter the icon code, it looks like <svg>.... </svg> format":"Enter the icon code, it looks like <svg>.... </svg> 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-colour 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 Colour","Custom Font Color":"Custom Font Colour","🎨 Set Custom Background":"🎨 Set Custom Background","🖌️ Set Custom Font Color":"🖌️ Set Custom Font Colour","Click on the picker to adjust the color":"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.":"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 <svg>.... </svg>":"Enter the icon code, format as <svg>.... </svg>","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","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 customisations.","Toolbar Preview (With a hypothetical command configuration.)":"Toolbar Preview (With a hypothetical command configuration.)","Toolbar Theme":"Toolbar Theme","Select a preset toolbar theme, automatically setting the background color, icon color, and size for the selected style.":"Select a preset toolbar theme, automatically setting the background colour, icon colour, and size for the selected style.","Toolbar Background Color":"Toolbar Background Colour","Set the background color of the toolbar.":"Set the background colour of the toolbar.","Toolbar Icon Color":"Toolbar Icon Colour","Set the color of the toolbar icon.":"Set the colour 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","Use \\n to represent line breaks":"Use \\n to represent line breaks","Use ↵ to represent line breaks":"Use ↵ to represent line breaks","Top Toolbar":"Top Toolbar","Enable the toolbar positioned at the top.":"Enable the toolbar positioned at the top.","Following Toolbar":"Following Toolbar","Enable the toolbar that appears upon text selection.":"Enable the toolbar that appears upon text selection.","Fixed Toolbar":"Fixed Toolbar","Enable the toolbar whose position may be fixed where you please.":"Enable the toolbar whose position may be fixed where you please.","Toolbar Settings":"Toolbar Settings","Choose which toolbar style's appearance you want to edit.":"Choose which toolbar style's appearance you want to edit.","Vertical Split":"Vertical Split"},es:{},fr:{},hi:{},id:{},it:{},ja:{},ko:{},nl:{},nn:{},pl:{},pt:{},"pt-br":{},ro:{},ru:{},tr:{},"zh-cn":Gr,"zh-tw":Zr}[t.moment.locale()];function Jr(t){return Kr&&Kr[t]||Yr[t]}class Xr extends t.FuzzySuggestModal{constructor(t,e,i=!1,o,n){super(t.app),this.customCallback=null,this.plugin=t,this.command=e,this.issub=i,this.customCallback=o||null,this.setPlaceholder(Jr("Choose an icon")),this.currentEditingConfig=n||""}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 o=createSpan({cls:"editingToolbarIconPick"});i.appendChild(o),t.setIcon(o,e.item),super.renderSuggestion(e,i)}onChooseItem(t){return e(this,void 0,void 0,function*(){if("Custom"===t)return this.customCallback?void new Qr(this.app,this.plugin,{id:this.command.id,name:this.command.name,icon:""},this.issub,t=>{this.customCallback(t)}).open():void new Qr(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=Rr(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 Qr extends t.Modal{constructor(t,e,i,o,n,s){super(t),this.customCallback=null,this.plugin=e,this.item=i,this.issub=o,this.customCallback=n||null,this.currentEditingConfig=s||"",this.containerEl.addClass("editingToolbar-Modal"),this.containerEl.addClass("customicon")}onOpen(){const{contentEl:t}=this;t.createEl("b",{text:Jr("Enter the icon code, format as <svg>.... </svg>")});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),o=Rr(this.plugin,this.item,this.issub,e);if(this.issub){let e=o.subindex;-1===e?this.plugin.settings.menuCommands[o.index].SubmenuCommands.push(this.item):this.plugin.settings.menuCommands[o.index].SubmenuCommands[e].icon=t}else{let t=o.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 ta extends t.FuzzySuggestModal{constructor(t,e){super(t.app),this.plugin=t,this.app,this.setPlaceholder(Jr("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(Jr("The command")+i.name+Jr("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 Xr(this.plugin,i,!1).open()})}}class ea extends t.Modal{constructor(t,e,i,o,n){super(e.app),this.plugin=e,this.item=i,this.issub=o,this.currentEditingConfig=n||"",this.containerEl.addClass("editingToolbar-Modal"),this.containerEl.addClass("changename")}onOpen(){var i;const{contentEl:o}=this;o.createEl("b",{text:Jr("Please enter a new name: ")});const n=new t.TextComponent(o);n.inputEl.classList.add("InputPromptInputEl"),n.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=Rr(this.plugin,this.item,this.issub,e);if(this.item.name=t,this.issub){let o=i.subindex;-1===o?e[i.index].SubmenuCommands.push(this.item):e[i.index].SubmenuCommands[o].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 ia 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:Jr("Drag the slider to move the position")});const o=i.createDiv({cls:"slider-container"}),n=o.createDiv({cls:"vertical-slider-container"});n.createEl("p",{text:Jr("Vertical Position")});const s=o.createDiv({cls:"horizontal-slider-container"});s.createEl("p",{text:Jr("Horizontal Position")});const r=o.createDiv({cls:"columns-slider-container"});r.createEl("p",{text:Jr("Editing Toolbar Columns")});const a=document.body.clientHeight,l=document.body.clientWidth,c=Math.floor(a/3),h=-Math.floor(a),d=Math.floor(l/2),u=-Math.floor(l/2),p=new t.SliderComponent(n).setLimits(h,c,5).setValue(this.plugin.settings.verticalPosition||0).onChange(t.debounce(t=>{this.needSave=!0,this.plugin.settings.verticalPosition=t,Ur(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,jr(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();o.createDiv({cls:"reset-container"}).createEl("button",{text:Jr("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,Ur(this.plugin.settings),jr(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 oa=["body","workspace"],na=["default","tiny","glass","custom"],sa=["following","top","fixed"],ra={lastVersion:"0.0.0",aestheticStyle:"default",positionStyle:"top",menuCommands:[{id:"editing-toolbar:editor-undo",name:"Undo Edit",icon:"undo-glyph"},{id:"editing-toolbar:editor-redo",name:"Redo Edit",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:"Italic",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-cut",name:"Cut",icon:"lucide-scissors"},{id:"editing-toolbar:editor-copy",name:"Copy",icon:"lucide-copy"},{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 and 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:"Callout",icon:"lucide-quote"}]},{id:"SubmenuCommands-mdcmder",name:"submenu",icon:'<svg width="18" height="18" focusable="false" fill="currentColor" viewBox="0 0 1024 1024"><g transform="scale(1, -1) translate(0, -896) scale(0.9, 0.9) "><path class="path" d="M464 608 l0 -568 q0 -3 -2.5 -5.5 q-2.5 -2.5 -5.5 -2.5 l-80 0 q-3 0 -5.5 2.5 q-2.5 2.5 -2.5 5.5 l0 568 l-232 0 q-3 0 -5.5 2.5 q-2.5 2.5 -2.5 5.5 l0 80 q0 3 2.5 5.5 q2.5 2.5 5.5 2.5 l560 0 q3 0 5.5 -2.5 q2.5 -2.5 2.5 -5.5 l0 -80 q0 -3 -2.5 -5.5 q-2.5 -2.5 -5.5 -2.5 l-232 0 ZM864 696 q17 0 28.5 11.5 q11.5 11.5 11.5 28.5 q0 17 -11.5 28.5 q-11.5 11.5 -28.5 11.5 q-17 0 -28.5 -11.5 q-11.5 -11.5 -11.5 -28.5 q0 -17 11.5 -28.5 q11.5 -11.5 28.5 -11.5 ZM864 640 q-40 0 -68 28 q-28 28 -28 68 q0 40 28 68 q28 28 68 28 q40 0 68 -28 q28 -28 28 -68 q0 -40 -28 -68 q-28 -28 -68 -28 ZM576 322 l0 -63 q0 -3 2 -5 l89 -70 l-89 -70 q-2 -2 -2 -5 l0 -63 q0 -4 3.5 -5.5 q3.5 -1.5 6.5 0.5 l170 133 q4 3 4.5 8.5 q0.5 5.5 -2.5 9.5 l-2 2 l-170 133 q-3 2 -6.5 0.5 q-3.5 -1.5 -3.5 -5.5 ZM256 322 l0 -63 q0 -3 -2 -5 l-89 -70 l89 -70 q2 -2 2 -5 l0 -63 q0 -4 -3.5 -5.5 q-3.5 -1.5 -6.5 0.5 l-170 133 q-4 3 -4.5 8.5 q-0.5 5.5 2.5 9.5 l2 2 l170 133 q3 2 6.5 0.5 q3.5 -1.5 3.5 -5.5 Z"></path></g></svg>',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:"Wikilink",icon:'<svg width="15" height="15" focusable="false" fill="currentColor" viewBox="0 0 1024 1024"><g transform="scale(1, -1) translate(0, -896) scale(0.9, 0.9) "><path class="path" d="M306 134 l91 0 q1 0 1 -8 l0 -80 q0 -8 -1 -8 l-91 0 q-1 0 -1 7 q0 -8 -5 -8 l-45 0 q-5 0 -5 8 l0 784 q0 8 5 8 l45 0 q5 0 5 -8 q0 8 1 8 l91 0 q1 0 1 -8 l0 -80 q0 -8 -1 -8 l-91 0 q-1 0 -1 8 l0 -623 q0 8 1 8 ZM139 134 l91 0 q1 0 1 -8 l0 -80 q0 -8 -1 -8 l-91 0 q-1 0 -1 7 q0 -8 -5 -8 l-45 0 q-5 0 -5 8 l0 784 q0 8 5 8 l45 0 q5 0 5 -8 q0 8 1 8 l91 0 q1 0 1 -8 l0 -80 q0 -8 -1 -8 l-91 0 q-1 0 -1 8 l0 -623 q0 8 1 8 ZM711 134 q1 0 1 -8 l0 623 q0 -8 -1 -8 l-91 0 q-1 0 -1 8 l0 80 q0 8 1 8 l91 0 q1 0 1 -8 q0 8 4 8 l46 0 q4 0 4 -8 l0 -784 q0 -8 -4 -8 l-46 0 q-4 0 -4 8 q0 -7 -1 -7 l-91 0 q-1 0 -1 8 l0 80 q0 8 1 8 l91 0 ZM878 134 q1 0 1 -8 l0 623 q0 -8 -1 -8 l-91 0 q-1 0 -1 8 l0 80 q0 8 1 8 l91 0 q1 0 1 -8 q0 8 5 8 l45 0 q4 0 4 -8 l0 -784 q0 -8 -4 -8 l-45 0 q-5 0 -5 8 q0 -7 -1 -7 l-91 0 q-1 0 -1 8 l0 80 q0 8 1 8 l91 0 Z"></path></g></svg>'},{id:"editing-toolbar:editor:insert-embed",name:"Embed",icon:"note-glyph"},{id:"editing-toolbar:insert-link",name:"Link",icon:"link-glyph"},{id:"editing-toolbar:hrline",name:"Horizontal Divider",icon:'<svg width="18" height="18" focusable="false" fill="currentColor" viewBox="0 0 1024 1024"><g transform="scale(1, -1) translate(0, -896) scale(0.9, 0.9) "><path class="path" d="M912 424 l0 -80 q0 -3 -2.5 -5.5 q-2.5 -2.5 -5.5 -2.5 l-784 0 q-3 0 -5.5 2.5 q-2.5 2.5 -2.5 5.5 l0 80 q0 3 2.5 5.5 q2.5 2.5 5.5 2.5 l784 0 q3 0 5.5 -2.5 q2.5 -2.5 2.5 -5.5 Z"></path></g></svg>'},{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:"Ordered List",icon:'<svg width="18" height="18" focusable="false" fill="currentColor" viewBox="0 0 1024 1024"><g transform="scale(1, -1) translate(0, -896) scale(0.9, 0.9) "><path class="path" d="M860 424 q17 0 28.5 -11.5 q11.5 -11.5 11.5 -28 q0 -16.5 -11.5 -28.5 q-11.5 -12 -27.5 -12 l-457 0 q-17 0 -28.5 11.5 q-11.5 11.5 -11.5 28 q0 16.5 11.5 28.5 q11.5 12 27.5 12 l457 0 ZM860 756 q17 0 28.5 -11.5 q11.5 -11.5 11.5 -28 q0 -16.5 -11.5 -28.5 q-11.5 -12 -27.5 -12 l-457 0 q-17 0 -28.5 11.5 q-11.5 11.5 -11.5 28 q0 16.5 11.5 28.5 q11.5 12 27.5 12 l457 0 ZM860 92 q17 0 28.5 -11.5 q11.5 -11.5 11.5 -28 q0 -16.5 -11.5 -28.5 q-11.5 -12 -27.5 -12 l-457 0 q-17 0 -28.5 11.5 q-11.5 11.5 -11.5 28 q0 16.5 11.5 28.5 q11.5 12 27.5 12 l457 0 ZM264 136 l-3 -3 l-51 -57 l56 0 q14 0 24.5 -10 q10.5 -10 11.5 -25 l0 -1 q0 -15 -10.5 -25.5 q-10.5 -10.5 -24.5 -10.5 l-137 0 q-15 0 -25 10 q-10 10 -11 24.5 q-1 14.5 9 25.5 l63 70 l49 54 q7 7 7 16.5 q0 9.5 -7.5 16.5 q-7.5 7 -18.5 7 q-11 0 -18.5 -6.5 q-7.5 -6.5 -8.5 -16.5 l0 0 q0 -15 -10.5 -25.5 q-10.5 -10.5 -25.5 -10.5 q-15 0 -25.5 10.5 q-10.5 10.5 -10.5 25.5 q0 26 13.5 47.5 q13.5 21.5 36 34.5 q22.5 13 49 13 q26.5 0 49.5 -13 q23 -13 36 -34.5 q13 -21.5 13 -47.5 q0 -20 -7.5 -37.5 q-7.5 -17.5 -21.5 -30.5 l-1 -1 ZM173 794 q11 11 25 10.5 q14 -0.5 24.5 -10.5 q10.5 -10 10.5 -25 l0 -293 q0 -15 -10 -25.5 q-10 -10.5 -25 -10.5 q-15 0 -25.5 10 q-10.5 10 -11.5 25 l0 211 q-10 -8 -23.5 -7 q-13.5 1 -22.5 11 l-1 0 q-10 11 -9.5 25.5 q0.5 14.5 10.5 24.5 l58 54 Z"></path></g></svg>'},{id:"editing-toolbar:toggle-bullet-list",name:"Unordered List",icon:'<svg width="18" height="18" focusable="false" fill="currentColor" viewBox="0 0 1024 1024"><g transform="scale(1, -1) translate(0, -896) scale(0.9, 0.9) "><path class="path" d="M860 424 q17 0 28.5 -11.5 q11.5 -11.5 11.5 -28 q0 -16.5 -11.5 -28.5 q-11.5 -12 -27.5 -12 l-477 0 q-17 0 -28.5 11.5 q-11.5 11.5 -11.5 28 q0 16.5 11.5 28.5 q11.5 12 27.5 12 l477 0 ZM860 756 q17 0 28.5 -11.5 q11.5 -11.5 11.5 -28 q0 -16.5 -11.5 -28.5 q-11.5 -12 -27.5 -12 l-477 0 q-17 0 -28.5 11.5 q-11.5 11.5 -11.5 28 q0 16.5 11.5 28.5 q11.5 12 27.5 12 l477 0 ZM860 92 q17 0 28.5 -11.5 q11.5 -11.5 11.5 -28 q0 -16.5 -11.5 -28.5 q-11.5 -12 -27.5 -12 l-477 0 q-17 0 -28.5 11.5 q-11.5 11.5 -11.5 28 q0 16.5 11.5 28.5 q11.5 12 27.5 12 l477 0 ZM176 716 l0 0 ZM112 716 q0 -27 18.5 -45.5 q18.5 -18.5 45.5 -18.5 q27 0 45.5 18.5 q18.5 18.5 18.5 45.5 q0 27 -18.5 45.5 q-18.5 18.5 -45.5 18.5 q-27 0 -45.5 -18.5 q-18.5 -18.5 -18.5 -45.5 ZM176 384 l0 0 ZM112 384 q0 -27 18.5 -45.5 q18.5 -18.5 45.5 -18.5 q27 0 45.5 18.5 q18.5 18.5 18.5 45.5 q0 27 -18.5 45.5 q-18.5 18.5 -45.5 18.5 q-27 0 -45.5 -18.5 q-18.5 -18.5 -18.5 -45.5 ZM176 52 l0 0 ZM112 52 q0 -27 18.5 -45.5 q18.5 -18.5 45.5 -18.5 q27 0 45.5 18.5 q18.5 18.5 18.5 45.5 q0 27 -18.5 45.5 q-18.5 18.5 -45.5 18.5 q-27 0 -45.5 -18.5 q-18.5 -18.5 -18.5 -45.5 Z"></path></g></svg>'},{id:"editing-toolbar:undent-list",name:"Unindent List",icon:'<svg width="18" height="18" focusable="false" fill="currentColor" viewBox="0 0 1024 1024"><g transform="scale(1, -1) translate(0, -896) scale(0.9, 0.9) "><path class="path" d="M872 302 q17 0 28.5 -11.5 q11.5 -11.5 11.5 -28 q0 -16.5 -11.5 -28.5 q-11.5 -12 -27.5 -12 l-429 0 q-17 0 -28.5 11.5 q-11.5 11.5 -11.5 28 q0 16.5 11.5 28.5 q11.5 12 27.5 12 l429 0 ZM872 542 q17 0 28.5 -11.5 q11.5 -11.5 11.5 -28 q0 -16.5 -11.5 -28.5 q-11.5 -12 -27.5 -12 l-429 0 q-17 0 -28.5 11.5 q-11.5 11.5 -11.5 28 q0 16.5 11.5 28.5 q11.5 12 27.5 12 l429 0 ZM872 784 q17 0 28.5 -11.5 q11.5 -11.5 11.5 -28 q0 -16.5 -11.5 -28.5 q-11.5 -12 -27.5 -12 l-721 0 q-17 0 -28.5 11.5 q-11.5 11.5 -11.5 28 q0 16.5 11.5 28.5 q11.5 12 27.5 12 l721 0 ZM872 62 q17 0 28.5 -11.5 q11.5 -11.5 11.5 -28 q0 -16.5 -11.5 -28.5 q-11.5 -12 -27.5 -12 l-721 0 q-17 0 -28.5 11.5 q-11.5 11.5 -11.5 28 q0 16.5 11.5 28.5 q11.5 12 27.5 12 l721 0 ZM244 534 l-123 -122 q-8 -7 -8 -18 q0 -11 8 -18 l123 -122 q8 -7 19 -7 q11 0 18.5 7.5 q7.5 7.5 7.5 18.5 l0 242 q0 11 -7.5 18.5 q-7.5 7.5 -18.5 7.5 q-11 0 -19 -7 Z"></path></g></svg>'},{id:"editing-toolbar:indent-list",name:"Indent list",icon:'<svg width="18" height="18" focusable="false" fill="currentColor" viewBox="0 0 1024 1024"><g transform="scale(1, -1) translate(0, -896) scale(0.9, 0.9) "><path class="path" d="M872 302 q17 0 28.5 -11.5 q11.5 -11.5 11.5 -28 q0 -16.5 -11.5 -28.5 q-11.5 -12 -27.5 -12 l-429 0 q-17 0 -28.5 11.5 q-11.5 11.5 -11.5 28 q0 16.5 11.5 28.5 q11.5 12 27.5 12 l429 0 ZM872 542 q17 0 28.5 -11.5 q11.5 -11.5 11.5 -28 q0 -16.5 -11.5 -28.5 q-11.5 -12 -27.5 -12 l-429 0 q-17 0 -28.5 11.5 q-11.5 11.5 -11.5 28 q0 16.5 11.5 28.5 q11.5 12 27.5 12 l429 0 ZM872 784 q17 0 28.5 -11.5 q11.5 -11.5 11.5 -28 q0 -16.5 -11.5 -28.5 q-11.5 -12 -27.5 -12 l-721 0 q-17 0 -28.5 11.5 q-11.5 11.5 -11.5 28 q0 16.5 11.5 28.5 q11.5 12 27.5 12 l721 0 ZM872 62 q17 0 28.5 -11.5 q11.5 -11.5 11.5 -28 q0 -16.5 -11.5 -28.5 q-11.5 -12 -27.5 -12 l-721 0 q-17 0 -28.5 11.5 q-11.5 11.5 -11.5 28 q0 16.5 11.5 28.5 q11.5 12 27.5 12 l721 0 ZM158 534 l124 -122 q7 -7 7 -18 q0 -11 -7 -18 l-124 -122 q-7 -7 -18 -7 q-11 0 -19 7.5 q-8 7.5 -8 18.5 l0 242 q0 11 8 18.5 q8 7.5 19 7.5 q11 0 18 -7 Z"></path></g></svg>'}]},{id:"SubmenuCommands-aligin",name:"submenu-aligin",icon:'<svg width="18" height="18" focusable="false" fill="currentColor" viewBox="0 0 1024 1024"><g transform="scale(1, -1) translate(0, -896) scale(0.9, 0.9) "><path class="path" d="M724 304 q17 0 28.5 -11.5 q11.5 -11.5 11.5 -28 q0 -16.5 -11.5 -28.5 q-11.5 -12 -27.5 -12 l-421 0 q-17 0 -28.5 11.5 q-11.5 11.5 -11.5 28 q0 16.5 11.5 28.5 q11.5 12 27.5 12 l421 0 ZM872 540 q17 0 28.5 -11.5 q11.5 -11.5 11.5 -28 q0 -16.5 -11.5 -28.5 q-11.5 -12 -27.5 -12 l-721 0 q-17 0 -28.5 11.5 q-11.5 11.5 -11.5 28 q0 16.5 11.5 28.5 q11.5 12 27.5 12 l721 0 ZM724 776 q17 0 28.5 -11.5 q11.5 -11.5 11.5 -28 q0 -16.5 -11.5 -28.5 q-11.5 -12 -27.5 -12 l-421 0 q-17 0 -28.5 11.5 q-11.5 11.5 -11.5 28 q0 16.5 11.5 28.5 q11.5 12 27.5 12 l421 0 ZM872 68 q17 0 28.5 -11.5 q11.5 -11.5 11.5 -28 q0 -16.5 -11.5 -28.5 q-11.5 -12 -27.5 -12 l-721 0 q-17 0 -28.5 11.5 q-11.5 11.5 -11.5 28 q0 16.5 11.5 28.5 q11.5 12 27.5 12 l721 0 Z"></path></g></svg>',SubmenuCommands:[{id:"editing-toolbar:justify",name:"Justify Text",icon:'<svg width="18" height="18" focusable="false" fill="currentColor" viewBox="0 0 1024 1024"><g transform="scale(1, -1) translate(0, -896) scale(0.9, 0.9) "><path class="path" d="M112 736 l0 0 ZM120 736 l784 0 q8 0 8 -8 l0 -80 q0 -8 -8 -8 l-784 0 q-8 0 -8 8 l0 80 q0 8 8 8 ZM112 331 l0 0 ZM120 331 l784 0 q8 0 8 -8 l0 -80 q0 -8 -8 -8 l-784 0 q-8 0 -8 8 l0 80 q0 8 8 8 ZM112 128 l0 0 ZM120 128 l784 0 q8 0 8 -8 l0 -80 q0 -8 -8 -8 l-784 0 q-8 0 -8 8 l0 80 q0 8 8 8 ZM112 533 l0 0 ZM120 533 l784 0 q8 0 8 -8 l0 -80 q0 -8 -8 -8 l-784 0 q-8 0 -8 8 l0 80 q0 8 8 8 Z"></path></g></svg>'},{id:"editing-toolbar:left",name:"Align Text Left",icon:'<svg width="18" height="18" focusable="false" fill="currentColor" viewBox="0 0 1024 1024"><g transform="scale(1, -1) translate(0, -896) scale(0.9, 0.9) "><path class="path" d="M572 304 q17 0 28.5 -11.5 q11.5 -11.5 11.5 -28 q0 -16.5 -11.5 -28.5 q-11.5 -12 -27.5 -12 l-421 0 q-17 0 -28.5 11.5 q-11.5 11.5 -11.5 28 q0 16.5 11.5 28.5 q11.5 12 27.5 12 l421 0 ZM872 540 q17 0 28.5 -11.5 q11.5 -11.5 11.5 -28 q0 -16.5 -11.5 -28.5 q-11.5 -12 -27.5 -12 l-721 0 q-17 0 -28.5 11.5 q-11.5 11.5 -11.5 28 q0 16.5 11.5 28.5 q11.5 12 27.5 12 l721 0 ZM572 776 q17 0 28.5 -11.5 q11.5 -11.5 11.5 -28 q0 -16.5 -11.5 -28.5 q-11.5 -12 -27.5 -12 l-421 0 q-17 0 -28.5 11.5 q-11.5 11.5 -11.5 28 q0 16.5 11.5 28.5 q11.5 12 27.5 12 l421 0 ZM872 68 q17 0 28.5 -11.5 q11.5 -11.5 11.5 -28 q0 -16.5 -11.5 -28.5 q-11.5 -12 -27.5 -12 l-721 0 q-17 0 -28.5 11.5 q-11.5 11.5 -11.5 28 q0 16.5 11.5 28.5 q11.5 12 27.5 12 l721 0 Z"></path></g></svg>'},{id:"editing-toolbar:center",name:"Center Text",icon:'<svg width="18" height="18" focusable="false" fill="currentColor" viewBox="0 0 1024 1024"><g transform="scale(1, -1) translate(0, -896) scale(0.9, 0.9) "><path class="path" d="M724 304 q17 0 28.5 -11.5 q11.5 -11.5 11.5 -28 q0 -16.5 -11.5 -28.5 q-11.5 -12 -27.5 -12 l-421 0 q-17 0 -28.5 11.5 q-11.5 11.5 -11.5 28 q0 16.5 11.5 28.5 q11.5 12 27.5 12 l421 0 ZM872 540 q17 0 28.5 -11.5 q11.5 -11.5 11.5 -28 q0 -16.5 -11.5 -28.5 q-11.5 -12 -27.5 -12 l-721 0 q-17 0 -28.5 11.5 q-11.5 11.5 -11.5 28 q0 16.5 11.5 28.5 q11.5 12 27.5 12 l721 0 ZM724 776 q17 0 28.5 -11.5 q11.5 -11.5 11.5 -28 q0 -16.5 -11.5 -28.5 q-11.5 -12 -27.5 -12 l-421 0 q-17 0 -28.5 11.5 q-11.5 11.5 -11.5 28 q0 16.5 11.5 28.5 q11.5 12 27.5 12 l421 0 ZM872 68 q17 0 28.5 -11.5 q11.5 -11.5 11.5 -28 q0 -16.5 -11.5 -28.5 q-11.5 -12 -27.5 -12 l-721 0 q-17 0 -28.5 11.5 q-11.5 11.5 -11.5 28 q0 16.5 11.5 28.5 q11.5 12 27.5 12 l721 0 Z"></path></g></svg>'},{id:"editing-toolbar:right",name:"Align Text Right",icon:'<svg width="18" height="18" focusable="false" fill="currentColor" viewBox="0 0 1024 1024"><g transform="scale(1, -1) translate(0, -896) scale(0.9, 0.9) "><path class="path" d="M872 304 q17 0 28.5 -11.5 q11.5 -11.5 11.5 -28 q0 -16.5 -11.5 -28.5 q-11.5 -12 -27.5 -12 l-421 0 q-17 0 -28.5 11.5 q-11.5 11.5 -11.5 28 q0 16.5 11.5 28.5 q11.5 12 27.5 12 l421 0 ZM872 540 q17 0 28.5 -11.5 q11.5 -11.5 11.5 -28 q0 -16.5 -11.5 -28.5 q-11.5 -12 -27.5 -12 l-721 0 q-17 0 -28.5 11.5 q-11.5 11.5 -11.5 28 q0 16.5 11.5 28.5 q11.5 12 27.5 12 l721 0 ZM872 776 q17 0 28.5 -11.5 q11.5 -11.5 11.5 -28 q0 -16.5 -11.5 -28.5 q-11.5 -12 -27.5 -12 l-421 0 q-17 0 -28.5 11.5 q-11.5 11.5 -11.5 28 q0 16.5 11.5 28.5 q11.5 12 27.5 12 l421 0 ZM872 68 q17 0 28.5 -11.5 q11.5 -11.5 11.5 -28 q0 -16.5 -11.5 -28.5 q-11.5 -12 -27.5 -12 l-721 0 q-17 0 -28.5 11.5 q-11.5 11.5 -11.5 28 q0 16.5 11.5 28.5 q11.5 12 27.5 12 l721 0 Z"></path></g></svg>'}]},{id:"editing-toolbar:change-font-color",name:"Change Font Color",icon:'<svg width="24" height="24" viewBox="0 0 24 24" focusable="false" fill="currentColor"><g fill-rule="evenodd"><path id="change-font-color-icon" d="M3 18h18v3H3z" style="fill:#2DC26B"></path><path d="M8.7 16h-.8a.5.5 0 01-.5-.6l2.7-9c.1-.3.3-.4.5-.4h2.8c.2 0 .4.1.5.4l2.7 9a.5.5 0 01-.5.6h-.8a.5.5 0 01-.4-.4l-.7-2.2c0-.3-.3-.4-.5-.4h-3.4c-.2 0-.4.1-.5.4l-.7 2.2c0 .3-.2.4-.4.4zm2.6-7.6l-.6 2a.5.5 0 00.5.6h1.6a.5.5 0 00.5-.6l-.6-2c0-.3-.3-.4-.5-.4h-.4c-.2 0-.4.1-.5.4z"></path></g></svg>'},{id:"editing-toolbar:change-background-color",name:"Change Background Color",icon:'<svg width="18" height="24" viewBox="0 0 256 256" version="1.1" xmlns="http://www.w3.org/2000/svg"><g stroke="none" stroke-width="1" fill="currentColor" fill-rule="evenodd"><g ><g fill="currentColor"><g transform="translate(119.502295, 137.878331) rotate(-135.000000) translate(-119.502295, -137.878331) translate(48.002295, 31.757731)" ><path d="M100.946943,60.8084699 L43.7469427,60.8084699 C37.2852111,60.8084699 32.0469427,66.0467383 32.0469427,72.5084699 L32.0469427,118.70847 C32.0469427,125.170201 37.2852111,130.40847 43.7469427,130.40847 L100.946943,130.40847 C107.408674,130.40847 112.646943,125.170201 112.646943,118.70847 L112.646943,72.5084699 C112.646943,66.0467383 107.408674,60.8084699 100.946943,60.8084699 Z M93.646,79.808 L93.646,111.408 L51.046,111.408 L51.046,79.808 L93.646,79.808 Z" fill-rule="nonzero"></path><path d="M87.9366521,16.90916 L87.9194966,68.2000001 C87.9183543,69.4147389 86.9334998,70.399264 85.7187607,70.4 L56.9423078,70.4 C55.7272813,70.4 54.7423078,69.4150264 54.7423078,68.2 L54.7423078,39.4621057 C54.7423078,37.2523513 55.5736632,35.1234748 57.0711706,33.4985176 L76.4832996,12.4342613 C78.9534987,9.75382857 83.1289108,9.5834005 85.8093436,12.0535996 C87.1658473,13.303709 87.9372691,15.0644715 87.9366521,16.90916 Z" fill-rule="evenodd"></path><path d="M131.3,111.241199 L11.7,111.241199 C5.23826843,111.241199 0,116.479467 0,122.941199 L0,200.541199 C0,207.002931 5.23826843,212.241199 11.7,212.241199 L131.3,212.241199 C137.761732,212.241199 143,207.002931 143,200.541199 L143,122.941199 C143,116.479467 137.761732,111.241199 131.3,111.241199 Z M124,130.241 L124,193.241 L19,193.241 L19,130.241 L124,130.241 Z" fill-rule="nonzero"></path></g></g><path d="M51,218 L205,218 C211.075132,218 216,222.924868 216,229 C216,235.075132 211.075132,240 205,240 L51,240 C44.9248678,240 40,235.075132 40,229 C40,222.924868 44.9248678,218 51,218 Z" id="change-background-color-icon" style="fill:#FA541C"></path></g></g></svg>'},{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,enableTopToolbar:!1,enableFollowingToolbar:!1,enableFixedToolbar:!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:{},appearanceByStyle:{top:{toolbarBackgroundColor:"rgba(var(--background-secondary-rgb), 0.7)",toolbarIconColor:"var(--text-normal)",toolbarIconSize:18,aestheticStyle:"default"},following:{toolbarBackgroundColor:"rgba(var(--background-secondary-rgb), 0.7)",toolbarIconColor:"var(--text-normal)",toolbarIconSize:18,aestheticStyle:"default"},fixed:{toolbarBackgroundColor:"rgba(var(--background-secondary-rgb), 0.7)",toolbarIconColor:"var(--text-normal)",toolbarIconSize:18,aestheticStyle:"default"},mobile:{toolbarBackgroundColor:"rgba(var(--background-secondary-rgb), 0.7)",toolbarIconColor:"var(--text-normal)",toolbarIconSize:18,aestheticStyle:"default"}},toolbarBackgroundColor:"rgba(var(--background-secondary-rgb), 0.7)",toolbarIconColor:"var(--text-normal)",toolbarIconSize:18,useCurrentLineForRegex:!1};class aa{static isAllowedViewType(t,e){var i,o,n,s;if(!t)return!1;const r=t.getViewType(),a=null===(n=null===(o=null===(i=window.app)||void 0===i?void 0:i.plugins)||void 0===o?void 0:o.plugins)||void 0===n?void 0:n["editing-toolbar"];if((null===(s=null==a?void 0:a.settings)||void 0===s?void 0:s.viewTypeSettings)&&void 0!==a.settings.viewTypeSettings[r])return a.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 la;const ca={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 ha(e){la=t.requireApiVersion("0.15.0")?activeWindow.document:window.document;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}(),o=t=>{const e=t.querySelectorAll(".editingToolbarModalBar"),i=t.querySelectorAll(".editingToolbarPopoverBar");e.forEach(t=>{t.firstChild&&t.removeChild(t.firstChild),t.remove()}),i.forEach(t=>{t.firstChild&&t.removeChild(t.firstChild),t.remove()})};o(la),i&&i.forEach(t=>{(null==t?void 0:t.containerEl)&&o(t.containerEl)}),e&&e.clearToolbarCache()}function da(e,i,o){var n,s;la=t.requireApiVersion("0.15.0")?activeWindow.document:window.document;const r=o||i.positionStyle||i.settings.positionStyle||"top";if("top"!==r){const t=i.getCachedToolbar(r);if(t)return t}const a=`.editingToolbarModalBar[data-toolbar-style="${r}"]`;let l=null;return l="top"===r?(null===(s=null===(n=e.workspace.activeLeaf)||void 0===n?void 0:n.view.containerEl)||void 0===s?void 0:s.querySelector(a))||null:la.querySelector(a),l&&"top"!==r&&i.setCachedToolbar(r,l),l||null}const ua=(t,e)=>e.reduce((t,e)=>t&&"undefined"!==t[e]?t[e]:void 0,t);function pa(t,e){return t&&void 0!==t[1][0]?e+t.flat(2).join("+").replace("Mod","Ctrl")+e:e+"–"+e}function ma(t,e,i=!0){let o=t.commands.findCommand(e),n=i?"*":"";if(o){let e=o.hotkeys?[[ua(o.hotkeys,[0,"modifiers"])],[ua(o.hotkeys,[0,"key"])]]:void 0,i=t.hotkeyManager.customKeys[o.id];var s=i?[[ua(i,[0,"modifiers"])],[ua(i,[0,"key"])]]:void 0;return s?pa(s,n):pa(e,"")}return"–"}function ga(t){return/<[^>]+>/g.test(t)}function fa(e,i,o){la=t.requireApiVersion("0.15.0")?activeWindow.document:window.document;const n=i.commandsManager.getActiveEditor();let s=da(e,i),r=null==s?void 0:s.querySelector("#"+o);if(r){let t=r.rows,e=t.length;for(let s=1;s<e;s++){let e=t[s].cells;for(let t=0;t<e.length;t++)e[t].onclick=function(){let t=this.style.backgroundColor;if(""!=t){if(t=ba(t),"x-color-picker-table"==o){i.settings.cMenuFontColor=t,Pr(t,n),la.querySelectorAll("#change-font-color-icon").forEach(e=>{e.style.fill=t})}else if("x-backgroundcolor-picker-table"==o){i.settings.cMenuBackgroundColor=t,_r(t,n),la.querySelectorAll("#change-background-color-icon").forEach(e=>{e.style.fill=t})}i.saveSettings()}}}}}const ba=function(t){let e=t;if(/^(rgb|RGB)/.test(e)){let t=e.replace(/(?:\(|\)|rgb|RGB)*/g,"").split(","),i="#";for(let e=0;e<t.length;e++){let o=Number(t[e]).toString(16);"0"===o&&(o+=o),1==o.length&&(o="0"+o),i+=o}return 7!==i.length&&(i=e),i}if(!/^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/.test(e))return e;{let t=e.replace(/#/,"").split("");if(6===t.length)return e;if(3===t.length){let e="#";for(let i=0;i<t.length;i+=1)e+=t[i]+t[i];return e}}};function ya(t){t.quiteAllFormatBrushes()}function va(t,e){let i=e.getSelection();if(!i||""===i.trim())return;if(i.match(/^>\s*\[\![\w\s]*\]/m)){let t=i.split("\n"),o=[],n=!1,s=0,r=!1;for(let e=0;e<t.length;e++){let i=t[e],a=i.match(/^(>+)\s*\[\!([\w\s]*)\]\s*(.*?)$/);if(!a||r)if(n){let t=i.match(/^(>+)\s*/);if(t&&t[1].length>=s){let t=i.replace(new RegExp(`^>{${s}}\\s*`),"");o.push(t)}else n=!1,o.push(i)}else o.push(i);else s=a[1].length,r=!0,a[3].trim()&&o.push(a[3].trim()),n=!0}return void e.replaceSelection(o.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 wa(e,i,o,n,s=!1){let r=da(e,o,"following");const a=e.workspace.getActiveViewOfType(t.ItemView);if(!aa.isAllowedViewType(a))return void(r&&(r.style.visibility="hidden"));if(!(o.settings.enableFollowingToolbar||!o.settings.enableTopToolbar&&!o.settings.enableFixedToolbar&&"following"===o.positionStyle))return;const l="markdown"===(null==a?void 0:a.getViewType());let c=30;if(c="tiny"===o.settings.aestheticStyle?30:i+14,l)if(aa.isSourceMode(a)){if(r){const t=s||n.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,o,n,s;const r=e.containerEl.getBoundingClientRect(),a=t.offsetWidth,l=t.offsetHeight,c=12,h=window.innerWidth,d=e.getCursor("from");e.getCursor("to");const u=e.coordsAtPos(d),p=null!==(o=null===(i=la.getElementsByClassName("mod-left-split")[0])||void 0===i?void 0:i.clientWidth)&&void 0!==o?o:0,m=null!==(s=null===(n=la.getElementsByClassName("side-dock-ribbon mod-left")[0])||void 0===n?void 0:n.clientWidth)&&void 0!==s?s:0,g=p+m;let f=u.left-g-28;f+a>h-g&&(f=h-g-a-c);f=Math.max(0,f);let b=function(t,e,i,o){const n=t.getCursor("from"),s=t.getCursor("to"),r=t.coordsAtPos(s),a=n.line===s.line;let l=e.top-o-10;if(a)l<=i.top&&(l=r.bottom+10);else{if(t.getCursor("head").ch==t.getCursor("from").ch)l=e.top-o-10,l<=i.top&&(l=i.top+2*o);else{const e=(t=>{var e,i,o;let n,s=t.getCursor("head");if(t.getCursor("head").ch!==t.getCursor("from").ch&&(s.ch=Math.max(0,s.ch-1)),t.cursorCoords)n=t.cursorCoords(!0,"window");else{if(!t.coordsAtPos)return;{const r=t.posToOffset(s);n=null!==(o=null===(i=(e=t.cm).coordsAtPos)||void 0===i?void 0:i.call(e,r))&&void 0!==o?o:t.coordsAtPos(r)}}return n})(t);l=e.bottom+10,l>=i.bottom-o&&(l=i.bottom-2*o)}}return l}(e,u,r,l);b=Math.max(0,b),t.style.left=`${f}px`,t.style.top=`${b}px`}(r,n))}}else r&&(r.style.visibility="hidden");else r&&(r.style.visibility="visible",r.style.height=c+"px",r.addClass("editingToolbarFlex"),r.removeClass("editingToolbarGrid"))}function Ca(e,i,o){var n,s,r,a,l,c;const h=i.settings;if(la=t.requireApiVersion("0.15.0")?activeWindow.document:window.document,!o){const t=[];if(h.enableTopToolbar&&t.push("top"),h.enableFollowingToolbar&&t.push("following"),h.enableFixedToolbar&&t.push("fixed"),0===t.length){const e=i.positionStyle||i.settings.positionStyle||"top";t.push(e)}return void t.forEach(t=>{Ca(e,i,t)})}const d=o;if(!h.cMenuVisibility){const t=da(e,i,d);return void(t&&(t.style.display="none"))}const u=(h.appearanceByStyle||{})[d]||{},p=null!==(s=null!==(n=u.toolbarIconSize)&&void 0!==n?n:i.toolbarIconSize)&&void 0!==s?s:18,m=null!==(a=null!==(r=u.aestheticStyle)&&void 0!==r?r:h.aestheticStyle)&&void 0!==a?a:"default",g="custom"===m?null!==(l=u.toolbarBackgroundColor)&&void 0!==l?l:h.toolbarBackgroundColor:void 0,f="custom"===m?null!==(c=u.toolbarIconColor)&&void 0!==c?c:h.toolbarIconColor:void 0,b={default:"editingToolbarDefaultAesthetic",tiny:"editingToolbarTinyAesthetic",glass:"editingToolbarGlassAesthetic",custom:"editingToolbarCustomAesthetic"};!function(){function o(t,e){Object.values(b).forEach(e=>{t.removeClass(e)});const i=b[e]||b.default;t.addClass(i)}const n=()=>{var n,s;let r=0,a=0,l=p+8,c=createEl("div");if(c)if(c.addClass("editingToolbarModalBar"),c.setAttribute("data-toolbar-style",d),"top"===d)c.className+=" top",h.autohide&&(c.className+=" autohide"),h.Iscentered&&(c.className+=" centered");else if("following"===d)c.style.visibility="hidden";else if("fixed"===d){const t=p||18,e=`left: calc(50% - calc(${h.cMenuNumRows*(t+10)}px / 2));\n bottom: 4.25em; \n grid-template-columns: repeat(${h.cMenuNumRows}, ${t+10}px);\n gap: ${(t-18)/4}px`;c.setAttribute("style",e)}c.setAttribute("id","editingToolbarModalBar");let u=createEl("div");if(u.addClass("editingToolbarpopover"),u.addClass("editingToolbarTinyAesthetic"),u.addClass("editingToolbarPopoverBar"),u.setAttribute("data-toolbar-style",d),u.setAttribute("id","editingToolbarPopoverBar"),u.style.visibility="hidden",u.style.height="0",o(c,m),o(u,m),g&&(c.style.setProperty("--editing-toolbar-background-color",g),u.style.setProperty("--editing-toolbar-background-color",g)),f&&(c.style.setProperty("--editing-toolbar-icon-color",f),u.style.setProperty("--editing-toolbar-icon-color",f)),p&&(c.style.setProperty("--toolbar-icon-size",`${p}px`),u.style.setProperty("--toolbar-icon-size",`${p}px`)),"top"===d){let t=e.workspace.activeLeaf.view.containerEl,i=null;const o=e.workspace.activeLeaf.view.getViewType(),n=ca[o];if(n&&(i=null==t?void 0:t.querySelector(n)),!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"==o?i.insertAdjacentElement("afterend",u):i.insertAdjacentElement("afterbegin",u)),"excalidraw"==o?i.insertAdjacentElement("afterend",c):i.insertAdjacentElement("afterbegin",c),a=null==i?void 0:i.offsetWidth}else"body"==h.appendMethod?la.body.appendChild(c):"workspace"==h.appendMethod&&(null===(n=la.body)||void 0===n||n.querySelector(".mod-vertical.mod-root").insertAdjacentElement("afterbegin",c));let b=null===(s=e.workspace.activeLeaf.view.containerEl)||void 0===s?void 0:s.querySelector("#editingToolbarPopoverBar");i.getCurrentCommands(d).forEach((o,n)=>{let s;if("SubmenuCommands"in o){let u;r>=a-7*l&&a>100?(i.setIS_MORE_Button(!0),u=new t.ButtonComponent(b)):u=new t.ButtonComponent(c),u.setClass("editingToolbarCommandsubItem"+n),n>=h.cMenuNumRows?u.setClass("editingToolbarSecond"):"top"!==d&&u.buttonEl.setAttribute("aria-label-position","top"),ga(o.icon)?u.buttonEl.innerHTML=o.icon:u.setIcon(o.icon),r+=l+2;let p=function(t){let e=createEl("div");return e.addClass(t),e}("subitem");p&&o.SubmenuCommands.forEach(o=>{let r=ma(e,o.id);s="–"==r?o.name:o.name+"("+r+")";let a=new t.ButtonComponent(p).setTooltip(s).setClass("menu-item").onClick(()=>{e.commands.executeCommandById(o.id);const t=i.commandsManager.getActiveEditor(),n=t&&t.somethingSelected();0==h.cMenuVisibility?c.style.visibility="hidden":"following"===d?n||(c.style.visibility="hidden"):c.style.visibility="visible"});n<h.cMenuNumRows&&"top"!==d&&a.buttonEl.setAttribute("aria-label-position","top"),"editingToolbar-Divider-Line"==o.id&&a.setClass("editingToolbar-Divider-Line"),ga(o.icon)?a.buttonEl.innerHTML=o.icon:a.setIcon(o.icon),u.buttonEl.insertAdjacentElement("afterbegin",p)})}else if("editing-toolbar:change-font-color"==o.id){let n=new t.ButtonComponent(c);n.setClass("editingToolbarCommandsubItem-font-color").setTooltip(Jr("Font Colors")).onClick(()=>{e.commands.executeCommandById(o.id);const t=i.commandsManager.getActiveEditor(),n=t&&t.somethingSelected();0==h.cMenuVisibility?c.style.visibility="hidden":"following"===d?n||(c.style.visibility="hidden"):c.style.visibility="visible"}),ga(o.icon)?n.buttonEl.innerHTML=o.icon:n.setIcon(o.icon),r+=l;let s=createEl("div");if(s.addClass("subitem"),s){s.innerHTML=function(t){return`<div class='x-color-picker-wrapper'>\n<div class='x-color-picker' >\n <table class="x-color-picker-table" id='x-color-picker-table'>\n <tbody>\n <tr>\n <th colspan="10" class="ui-widget-content">Theme Colors</th>\n </tr>\n <tr>\n <td style="background-color:#ffffff"><span></span></td>\n <td style="background-color:#000000"><span></span></td>\n <td style="background-color:#eeece1"><span></span></td>\n <td style="background-color:#1f497d"><span></span></td>\n <td style="background-color:#4f81bd"><span></span></td>\n <td style="background-color:#c0504d"><span></span></td>\n <td style="background-color:#9bbb59"><span></span></td>\n <td style="background-color:#8064a2"><span></span></td>\n <td style="background-color:#4bacc6"><span></span></td>\n <td style="background-color:#f79646"><span></span></td>\n </tr>\n <tr>\n <th colspan="10"></th>\n </tr>\n <tr class="top">\n <td style="background-color:#f2f2f2"><span></span></td>\n <td style="background-color:#7f7f7f"><span></span></td>\n <td style="background-color:#ddd9c3"><span></span></td>\n <td style="background-color:#c6d9f0"><span></span></td>\n <td style="background-color:#dbe5f1"><span></span></td>\n <td style="background-color:#f2dcdb"><span></span></td>\n <td style="background-color:#ebf1dd"><span></span></td>\n <td style="background-color:#e5e0ec"><span></span></td>\n <td style="background-color:#dbeef3"><span></span></td>\n <td style="background-color:#fdeada"><span></span></td>\n </tr>\n <tr class="in">\n <td style="background-color:#d8d8d8"><span></span></td>\n <td style="background-color:#595959"><span></span></td>\n <td style="background-color:#c4bd97"><span></span></td>\n <td style="background-color:#8db3e2"><span></span></td>\n <td style="background-color:#b8cce4"><span></span></td>\n <td style="background-color:#e5b9b7"><span></span></td>\n <td style="background-color:#d7e3bc"><span></span></td>\n <td style="background-color:#ccc1d9"><span></span></td>\n <td style="background-color:#b7dde8"><span></span></td>\n <td style="background-color:#fbd5b5"><span></span></td>\n </tr>\n <tr class="in">\n <td style="background-color:#bfbfbf"><span></span></td>\n <td style="background-color:#3f3f3f"><span></span></td>\n <td style="background-color:#938953"><span></span></td>\n <td style="background-color:#548dd4"><span></span></td>\n <td style="background-color:#95b3d7"><span></span></td>\n <td style="background-color:#d99694"><span></span></td>\n <td style="background-color:#c3d69b"><span></span></td>\n <td style="background-color:#b2a2c7"><span></span></td>\n <td style="background-color:#92cddc"><span></span></td>\n <td style="background-color:#fac08f"><span></span></td>\n </tr>\n <tr class="in">\n <td style="background-color:#a5a5a5"><span></span></td>\n <td style="background-color:#262626"><span></span></td>\n <td style="background-color:#494429"><span></span></td>\n <td style="background-color:#17365d"><span></span></td>\n <td style="background-color:#366092"><span></span></td>\n <td style="background-color:#953734"><span></span></td>\n <td style="background-color:#76923c"><span></span></td>\n <td style="background-color:#5f497a"><span></span></td>\n <td style="background-color:#31859b"><span></span></td>\n <td style="background-color:#e36c09"><span></span></td>\n </tr>\n <tr class="bottom">\n <td style="background-color:#7f7f7f"><span></span></td>\n <td style="background-color:#0c0c0c"><span></span></td>\n <td style="background-color:#1d1b10"><span></span></td>\n <td style="background-color:#0f243e"><span></span></td>\n <td style="background-color:#244061"><span></span></td>\n <td style="background-color:#632423"><span></span></td>\n <td style="background-color:#4f6128"><span></span></td>\n <td style="background-color:#3f3151"><span></span></td>\n <td style="background-color:#205867"><span></span></td>\n <td style="background-color:#974806"><span></span></td>\n </tr>\n <tr>\n <th colspan="10"></th>\n </tr>\n <tr>\n <th colspan="10" class="ui-widget-content">Standard Colors</th>\n </tr>\n <tr>\n <td style="background-color:#c00000"><span></span></td>\n <td style="background-color:#ff0000"><span></span></td>\n <td style="background-color:#ffc000"><span></span></td>\n <td style="background-color:#ffff00"><span></span></td>\n <td style="background-color:#92d050"><span></span></td>\n <td style="background-color:#00b050"><span></span></td>\n <td style="background-color:#00b0f0"><span></span></td>\n <td style="background-color:#0070c0"><span></span></td>\n <td style="background-color:#002060"><span></span></td>\n <td style="background-color:#7030a0"><span></span></td>\n </tr>\n <tr>\n <th colspan="10" class="ui-widget-content">Custom Font Colors</th>\n </tr>\n <tr>\n <td style="background-color:${t.settings.custom_fc1}"><span></span></td>\n <td style="background-color:${t.settings.custom_fc2}"><span></span></td>\n <td style="background-color:${t.settings.custom_fc3}"><span></span></td>\n <td style="background-color:${t.settings.custom_fc4}"><span></span></td>\n <td style="background-color:${t.settings.custom_fc5}"><span></span></td>\n </tr>\n </tbody>\n </table>\n</div>\n</div>`}(i),n.buttonEl.insertAdjacentElement("afterbegin",s),fa(e,i,"x-color-picker-table");let o=s.querySelector(".x-color-picker-wrapper");new t.ButtonComponent(o).setIcon("paintbrush").setTooltip(Jr("Format Brush")).onClick(()=>{ya(i),i.setEN_FontColor_Format_Brush(!0),i.Temp_Notice=new t.Notice(Jr("Font-Color formatting brush ON!"),0)}),new t.ButtonComponent(o).setIcon("palette").setTooltip(Jr("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 n=new t.ButtonComponent(c);n.setClass("editingToolbarCommandsubItem-font-color").setTooltip(Jr("Background Color")).onClick(()=>{e.commands.executeCommandById(o.id);const t=i.commandsManager.getActiveEditor(),n=t&&t.somethingSelected();0==h.cMenuVisibility?c.style.visibility="hidden":"following"===d?n||(c.style.visibility="hidden"):c.style.visibility="visible"}),ga(o.icon)?n.buttonEl.innerHTML=o.icon:n.setIcon(o.icon),r+=l;let s=createEl("div");if(s.addClass("subitem"),s){s.innerHTML=function(t){return`<div class='x-color-picker-wrapper'>\n<div class='x-color-picker' >\n <table class="x-color-picker-table" id='x-backgroundcolor-picker-table'>\n <tbody>\n <tr>\n <th colspan="5" class="ui-widget-content">Translucent Colors</th>\n </tr>\n <tr class="top">\n <td style="background-color:rgba(140, 140, 140, 0.12)"><span></span></td>\n <td style="background-color:rgba(92, 92, 92, 0.2)"><span></span></td>\n <td style="background-color:rgba(163, 67, 31, 0.2)"><span></span></td>\n <td style="background-color:rgba(240, 107, 5, 0.2)"><span></span></td>\n <td style="background-color:rgba(240, 200, 0, 0.2)"><span></span></td>\n </tr>\n <tr class="bottom">\n <td style="background-color:rgba(3, 135, 102, 0.2)"><span></span></td>\n <td style="background-color:rgba(3, 135, 102, 0.2)"><span></span></td>\n <td style="background-color:rgba(5, 117, 197, 0.2)"><span></span></td>\n <td style="background-color:rgba(74, 82, 199, 0.2)"><span></span></td>\n <td style="background-color:rgba(136, 49, 204, 0.2)"><span></span></td>\n </tr>\n\n <tr>\n <th colspan="5" class="ui-widget-content">Highlighter Colors</th>\n </tr>\n \n <tr class="top">\n <td style="background-color:rgb(255, 248, 143)"><span></span></td>\n <td style="background-color:rgb(211, 248, 182)"><span></span></td>\n <td style="background-color:rgb(175, 250, 209)"><span></span></td>\n <td style="background-color:rgb(177, 255, 255)"><span></span></td>\n <td style="background-color:rgb(253, 191, 255)"><span></span></td>\n </tr>\n <tr class="bottom">\n <td style="background-color:rgb(210, 203, 255);"><span></span></td>\n <td style="background-color:rgb(64, 169, 255);"><span></span></td>\n <td style="background-color:rgb(255, 77, 79);"><span></span></td>\n <td style="background-color:rgb(212, 177, 6);"><span></span></td>\n <td style="background-color:rgb(146, 84, 222);"><span></span></td>\n </tr>\n <tr>\n <th colspan="5" class="ui-widget-content">Custom Colors</th>\n </tr>\n <tr class="bottom">\n <td style="background-color: ${t.settings.custom_bg1};"><span></span></td>\n <td style="background-color:${t.settings.custom_bg2};"><span></span></td>\n <td style="background-color:${t.settings.custom_bg3};"><span></span></td>\n <td style="background-color:${t.settings.custom_bg4};"><span></span></td>\n <td style="background-color:${t.settings.custom_bg5};"><span></span></td>\n </tr>\n </tbody>\n </table>\n</div>\n</div>`}(i),n.buttonEl.insertAdjacentElement("afterbegin",s),fa(e,i,"x-backgroundcolor-picker-table");let o=s.querySelector(".x-color-picker-wrapper");new t.ButtonComponent(o).setIcon("paintbrush").setTooltip(Jr("Format Brush")).onClick(()=>{ya(i),i.setEN_BG_Format_Brush(!0),i.Temp_Notice=new t.Notice(Jr("Font-Color formatting brush ON!"),0)}),new t.ButtonComponent(o).setIcon("palette").setTooltip(Jr("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 u;r>=a-7*l&&a>100?(i.setIS_MORE_Button(!0),u=new t.ButtonComponent(b)):u=new t.ButtonComponent(c);let p=ma(e,o.id);s="–"==p?o.name:o.name+"("+p+")",u.setTooltip(s).onClick(()=>{e.commands.executeCommandById(o.id);const t=i.commandsManager.getActiveEditor(),n=t&&t.somethingSelected();0==h.cMenuVisibility?c.style.visibility="hidden":"following"===d?n||(c.style.visibility="hidden"):c.style.visibility="visible"}),u.setClass("editingToolbarCommandItem"),n>=h.cMenuNumRows?u.setClass("editingToolbarSecond"):"top"!==d&&u.buttonEl.setAttribute("aria-label-position","top"),"editingToolbar-Divider-Line"==o.id&&u.setClass("editingToolbar-Divider-Line"),ga(o.icon)?u.buttonEl.innerHTML=o.icon:u.setIcon(o.icon),r+=l}}),function(e,i,o){const n=e.workspace.getActiveViewOfType(t.ItemView);if(!aa.isAllowedViewType(n))return;let s=n.containerEl.querySelector("#editingToolbarPopoverBar");if(!i.IS_MORE_Button)return;let r=o.createEl("span");r.addClass("more-menu");let a=new t.ButtonComponent(r);a.setClass("editingToolbarCommandItem").setTooltip(Jr("More")).onClick(()=>{"hidden"==s.style.visibility?(s.style.visibility="visible",s.style.height="32px"):(s.style.visibility="hidden",s.style.height="0")}),a.buttonEl.innerHTML='<svg width="14" height="14" version="1.1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024" enable-background="new 0 0 1024 1024" xml:space="preserve"><path fill="#666" d="M510.29 14.13 q17.09 -15.07 40.2 -14.07 q23.12 1 39.2 18.08 l334.66 385.92 q25.12 30.15 34.16 66.83 q9.04 36.68 0.5 73.87 q-8.54 37.19 -32.66 67.34 l-335.67 390.94 q-15.07 18.09 -38.69 20.1 q-23.62 2.01 -41.71 -13.07 q-18.08 -15.08 -20.09 -38.19 q-2.01 -23.12 13.06 -41.21 l334.66 -390.94 q11.06 -13.06 11.56 -29.65 q0.5 -16.58 -10.55 -29.64 l-334.67 -386.92 q-15.07 -17.09 -13.56 -40.7 q1.51 -23.62 19.59 -38.7 ZM81.17 14.13 q17.08 -15.07 40.19 -14.07 q23.11 1 39.2 18.08 l334.66 385.92 q25.12 30.15 34.16 66.83 q9.04 36.68 0.5 73.87 q-8.54 37.19 -32.66 67.34 l-335.67 390.94 q-15.07 18.09 -38.69 20.6 q-23.61 2.51 -41.7 -12.57 q-18.09 -15.08 -20.1 -38.69 q-2.01 -23.62 13.06 -41.71 l334.66 -390.94 q11.06 -13.06 11.56 -29.65 q0.5 -16.58 -10.55 -29.64 l-334.66 -386.92 q-15.08 -17.09 -13.57 -40.7 q1.51 -23.62 19.6 -38.7 Z"/></svg>',i.setIS_MORE_Button(!1)}(e,i,c),Math.abs(i.settings.cMenuWidth-Number(r))>r+4&&(i.settings.cMenuWidth=Number(r),setTimeout(()=>{i.saveSettings()},100))};if(!i.isLoadMobile())return;const s=e.workspace.getActiveViewOfType(t.ItemView);if(aa.isAllowedViewType(s)){const o=da(e,i,d);if(o&&"top"!==d)return h.cMenuVisibility?"following"===d?(o.style.visibility="hidden",o.style.display=""):(o.style.visibility="visible",o.style.display=""):o.style.display="none",g&&o.style.setProperty("--editing-toolbar-background-color",g),f&&o.style.setProperty("--editing-toolbar-icon-color",f),void(p&&o.style.setProperty("--toolbar-icon-size",`${p}px`));if(n(),"top"!==d){const t=da(e,i,d);t&&i.setCachedToolbar(d,t)}jr(i.settings),Ur(i.settings),function(e,i){la=t.requireApiVersion("0.15.0")?activeWindow.document:window.document;const o=la.querySelectorAll("#change-font-color-icon"),n=la.querySelectorAll("#change-background-color-icon");o.length>0&&o.forEach(t=>{t.style.fill=e});n.length>0&&n.forEach(t=>{t.style.fill=i})}
|
||
/**!
|
||
* Sortable 1.15.6
|
||
* @author RubaXa <trash@rubaxa.org>
|
||
* @author owenm <owen23355@gmail.com>
|
||
* @license MIT
|
||
*/(h.cMenuFontColor,h.cMenuBackgroundColor)}}()}function xa(t,e){var i=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);e&&(o=o.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),i.push.apply(i,o)}return i}function ka(t){for(var e=1;e<arguments.length;e++){var i=null!=arguments[e]?arguments[e]:{};e%2?xa(Object(i),!0).forEach(function(e){Ta(t,e,i[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(i)):xa(Object(i)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(i,e))})}return t}function Sa(t){return Sa="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Sa(t)}function Ta(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function Ea(){return Ea=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var i=arguments[e];for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(t[o]=i[o])}return t},Ea.apply(this,arguments)}function Ma(t,e){if(null==t)return{};var i,o,n=function(t,e){if(null==t)return{};var i,o,n={},s=Object.keys(t);for(o=0;o<s.length;o++)i=s[o],e.indexOf(i)>=0||(n[i]=t[i]);return n}(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(o=0;o<s.length;o++)i=s[o],e.indexOf(i)>=0||Object.prototype.propertyIsEnumerable.call(t,i)&&(n[i]=t[i])}return n}function Aa(t){if("undefined"!=typeof window&&window.navigator)return!!navigator.userAgent.match(t)}var Ia=Aa(/(?:Trident.*rv[ :]?11\.|msie|iemobile|Windows Phone)/i),Da=Aa(/Edge/i),Oa=Aa(/firefox/i),Ba=Aa(/safari/i)&&!Aa(/chrome/i)&&!Aa(/android/i),La=Aa(/iP(ad|od|hone)/i),Na=Aa(/chrome/i)&&Aa(/android/i),qa={capture:!1,passive:!1};function Ra(t,e,i){t.addEventListener(e,i,!Ia&&qa)}function Fa(t,e,i){t.removeEventListener(e,i,!Ia&&qa)}function Pa(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 _a(t){return t.host&&t!==document&&t.host.nodeType?t.host:t.parentNode}function Va(t,e,i,o){if(t){i=i||document;do{if(null!=e&&(">"===e[0]?t.parentNode===i&&Pa(t,e):Pa(t,e))||o&&t===i)return t;if(t===i)break}while(t=_a(t))}return null}var za,Ha=/\s+/g;function Wa(t,e,i){if(t&&e)if(t.classList)t.classList[i?"add":"remove"](e);else{var o=(" "+t.className+" ").replace(Ha," ").replace(" "+e+" "," ");t.className=(o+(i?" "+e:"")).replace(Ha," ")}}function $a(t,e,i){var o=t&&t.style;if(o){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 o||-1!==e.indexOf("webkit")||(e="-webkit-"+e),o[e]=i+("string"==typeof i?"":"px")}}function Ua(t,e){var i="";if("string"==typeof t)i=t;else do{var o=$a(t,"transform");o&&"none"!==o&&(i=o+" "+i)}while(!e&&(t=t.parentNode));var n=window.DOMMatrix||window.WebKitCSSMatrix||window.CSSMatrix||window.MSCSSMatrix;return n&&new n(i)}function ja(t,e,i){if(t){var o=t.getElementsByTagName(e),n=0,s=o.length;if(i)for(;n<s;n++)i(o[n],n);return o}return[]}function Ya(){var t=document.scrollingElement;return t||document.documentElement}function Ga(t,e,i,o,n){if(t.getBoundingClientRect||t===window){var s,r,a,l,c,h,d;if(t!==window&&t.parentNode&&t!==Ya()?(r=(s=t.getBoundingClientRect()).top,a=s.left,l=s.bottom,c=s.right,h=s.height,d=s.width):(r=0,a=0,l=window.innerHeight,c=window.innerWidth,h=window.innerHeight,d=window.innerWidth),(e||i)&&t!==window&&(n=n||t.parentNode,!Ia))do{if(n&&n.getBoundingClientRect&&("none"!==$a(n,"transform")||i&&"static"!==$a(n,"position"))){var u=n.getBoundingClientRect();r-=u.top+parseInt($a(n,"border-top-width")),a-=u.left+parseInt($a(n,"border-left-width")),l=r+s.height,c=a+s.width;break}}while(n=n.parentNode);if(o&&t!==window){var p=Ua(n||t),m=p&&p.a,g=p&&p.d;p&&(l=(r/=g)+(h/=g),c=(a/=m)+(d/=m))}return{top:r,left:a,bottom:l,right:c,width:d,height:h}}}function Za(t,e,i){for(var o=tl(t,!0),n=Ga(t)[e];o;){var s=Ga(o)[i];if(!("top"===i||"left"===i?n>=s:n<=s))return o;if(o===Ya())break;o=tl(o,!1)}return!1}function Ka(t,e,i,o){for(var n=0,s=0,r=t.children;s<r.length;){if("none"!==r[s].style.display&&r[s]!==nc.ghost&&(o||r[s]!==nc.dragged)&&Va(r[s],i.draggable,t,!1)){if(n===e)return r[s];n++}s++}return null}function Ja(t,e){for(var i=t.lastElementChild;i&&(i===nc.ghost||"none"===$a(i,"display")||e&&!Pa(i,e));)i=i.previousElementSibling;return i||null}function Xa(t,e){var i=0;if(!t||!t.parentNode)return-1;for(;t=t.previousElementSibling;)"TEMPLATE"===t.nodeName.toUpperCase()||t===nc.clone||e&&!Pa(t,e)||i++;return i}function Qa(t){var e=0,i=0,o=Ya();if(t)do{var n=Ua(t),s=n.a,r=n.d;e+=t.scrollLeft*s,i+=t.scrollTop*r}while(t!==o&&(t=t.parentNode));return[e,i]}function tl(t,e){if(!t||!t.getBoundingClientRect)return Ya();var i=t,o=!1;do{if(i.clientWidth<i.scrollWidth||i.clientHeight<i.scrollHeight){var n=$a(i);if(i.clientWidth<i.scrollWidth&&("auto"==n.overflowX||"scroll"==n.overflowX)||i.clientHeight<i.scrollHeight&&("auto"==n.overflowY||"scroll"==n.overflowY)){if(!i.getBoundingClientRect||i===document.body)return Ya();if(o||e)return i;o=!0}}}while(i=i.parentNode);return Ya()}function el(t,e){return Math.round(t.top)===Math.round(e.top)&&Math.round(t.left)===Math.round(e.left)&&Math.round(t.height)===Math.round(e.height)&&Math.round(t.width)===Math.round(e.width)}function il(t,e){return function(){if(!za){var i=arguments;1===i.length?t.call(this,i[0]):t.apply(this,i),za=setTimeout(function(){za=void 0},e)}}}function ol(t,e,i){t.scrollLeft+=e,t.scrollTop+=i}function nl(t){var e=window.Polymer,i=window.jQuery||window.Zepto;return e&&e.dom?e.dom(t).cloneNode(!0):i?i(t).clone(!0)[0]:t.cloneNode(!0)}function sl(t,e,i){var o={};return Array.from(t.children).forEach(function(n){var s,r,a,l;if(Va(n,e.draggable,t,!1)&&!n.animated&&n!==i){var c=Ga(n);o.left=Math.min(null!==(s=o.left)&&void 0!==s?s:1/0,c.left),o.top=Math.min(null!==(r=o.top)&&void 0!==r?r:1/0,c.top),o.right=Math.max(null!==(a=o.right)&&void 0!==a?a:-1/0,c.right),o.bottom=Math.max(null!==(l=o.bottom)&&void 0!==l?l:-1/0,c.bottom)}}),o.width=o.right-o.left,o.height=o.bottom-o.top,o.x=o.left,o.y=o.top,o}var rl="Sortable"+(new Date).getTime();function al(){var t,e=[];return{captureAnimationState:function(){(e=[],this.options.animation)&&[].slice.call(this.el.children).forEach(function(t){if("none"!==$a(t,"display")&&t!==nc.ghost){e.push({target:t,rect:Ga(t)});var i=ka({},e[e.length-1].rect);if(t.thisAnimationDuration){var o=Ua(t,!0);o&&(i.top-=o.f,i.left-=o.e)}t.fromRect=i}})},addAnimationState:function(t){e.push(t)},removeAnimationState:function(t){e.splice(function(t,e){for(var i in t)if(t.hasOwnProperty(i))for(var o in e)if(e.hasOwnProperty(o)&&e[o]===t[i][o])return Number(i);return-1}(e,{target:t}),1)},animateAll:function(i){var o=this;if(!this.options.animation)return clearTimeout(t),void("function"==typeof i&&i());var n=!1,s=0;e.forEach(function(t){var e=0,i=t.target,r=i.fromRect,a=Ga(i),l=i.prevFromRect,c=i.prevToRect,h=t.rect,d=Ua(i,!0);d&&(a.top-=d.f,a.left-=d.e),i.toRect=a,i.thisAnimationDuration&&el(l,a)&&!el(r,a)&&(h.top-a.top)/(h.left-a.left)===(r.top-a.top)/(r.left-a.left)&&(e=function(t,e,i,o){return Math.sqrt(Math.pow(e.top-t.top,2)+Math.pow(e.left-t.left,2))/Math.sqrt(Math.pow(e.top-i.top,2)+Math.pow(e.left-i.left,2))*o.animation}(h,l,c,o.options)),el(a,r)||(i.prevFromRect=r,i.prevToRect=a,e||(e=o.options.animation),o.animate(i,h,a,e)),e&&(n=!0,s=Math.max(s,e),clearTimeout(i.animationResetTimer),i.animationResetTimer=setTimeout(function(){i.animationTime=0,i.prevFromRect=null,i.fromRect=null,i.prevToRect=null,i.thisAnimationDuration=null},e),i.thisAnimationDuration=e)}),clearTimeout(t),n?t=setTimeout(function(){"function"==typeof i&&i()},s):"function"==typeof i&&i(),e=[]},animate:function(t,e,i,o){if(o){$a(t,"transition",""),$a(t,"transform","");var n=Ua(this.el),s=n&&n.a,r=n&&n.d,a=(e.left-i.left)/(s||1),l=(e.top-i.top)/(r||1);t.animatingX=!!a,t.animatingY=!!l,$a(t,"transform","translate3d("+a+"px,"+l+"px,0)"),this.forRepaintDummy=function(t){return t.offsetWidth}(t),$a(t,"transition","transform "+o+"ms"+(this.options.easing?" "+this.options.easing:"")),$a(t,"transform","translate3d(0,0,0)"),"number"==typeof t.animated&&clearTimeout(t.animated),t.animated=setTimeout(function(){$a(t,"transition",""),$a(t,"transform",""),t.animated=!1,t.animatingX=!1,t.animatingY=!1},o)}}}}var ll=[],cl={initializeByDefault:!0},hl={mount:function(t){for(var e in cl)cl.hasOwnProperty(e)&&!(e in t)&&(t[e]=cl[e]);ll.forEach(function(e){if(e.pluginName===t.pluginName)throw"Sortable: Cannot mount plugin ".concat(t.pluginName," more than once")}),ll.push(t)},pluginEvent:function(t,e,i){var o=this;this.eventCanceled=!1,i.cancel=function(){o.eventCanceled=!0};var n=t+"Global";ll.forEach(function(o){e[o.pluginName]&&(e[o.pluginName][n]&&e[o.pluginName][n](ka({sortable:e},i)),e.options[o.pluginName]&&e[o.pluginName][t]&&e[o.pluginName][t](ka({sortable:e},i)))})},initializePlugins:function(t,e,i,o){for(var n in ll.forEach(function(o){var n=o.pluginName;if(t.options[n]||o.initializeByDefault){var s=new o(t,e,t.options);s.sortable=t,s.options=t.options,t[n]=s,Ea(i,s.defaults)}}),t.options)if(t.options.hasOwnProperty(n)){var s=this.modifyOption(t,n,t.options[n]);void 0!==s&&(t.options[n]=s)}},getEventProperties:function(t,e){var i={};return ll.forEach(function(o){"function"==typeof o.eventProperties&&Ea(i,o.eventProperties.call(e[o.pluginName],t))}),i},modifyOption:function(t,e,i){var o;return ll.forEach(function(n){t[n.pluginName]&&n.optionListeners&&"function"==typeof n.optionListeners[e]&&(o=n.optionListeners[e].call(t[n.pluginName],i))}),o}};var dl=["evt"],ul=function(t,e){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o=i.evt,n=Ma(i,dl);hl.pluginEvent.bind(nc)(t,e,ka({dragEl:ml,parentEl:gl,ghostEl:fl,rootEl:bl,nextEl:yl,lastDownEl:vl,cloneEl:wl,cloneHidden:Cl,dragStarted:Nl,putSortable:Ml,activeSortable:nc.active,originalEvent:o,oldIndex:xl,oldDraggableIndex:Sl,newIndex:kl,newDraggableIndex:Tl,hideGhostForTarget:tc,unhideGhostForTarget:ec,cloneNowHidden:function(){Cl=!0},cloneNowShown:function(){Cl=!1},dispatchSortableEvent:function(t){pl({sortable:e,name:t,originalEvent:o})}},n))};function pl(t){!function(t){var e=t.sortable,i=t.rootEl,o=t.name,n=t.targetEl,s=t.cloneEl,r=t.toEl,a=t.fromEl,l=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[rl]){var g,f=e.options,b="on"+o.charAt(0).toUpperCase()+o.substr(1);!window.CustomEvent||Ia||Da?(g=document.createEvent("Event")).initEvent(o,!0,!0):g=new CustomEvent(o,{bubbles:!0,cancelable:!0}),g.to=r||i,g.from=a||i,g.item=n||i,g.clone=s,g.oldIndex=l,g.newIndex=c,g.oldDraggableIndex=h,g.newDraggableIndex=d,g.originalEvent=u,g.pullMode=p?p.lastPutMode:void 0;var y=ka(ka({},m),hl.getEventProperties(o,e));for(var v in y)g[v]=y[v];i&&i.dispatchEvent(g),f[b]&&f[b].call(e,g)}}(ka({putSortable:Ml,cloneEl:wl,targetEl:ml,rootEl:bl,oldIndex:xl,oldDraggableIndex:Sl,newIndex:kl,newDraggableIndex:Tl},t))}var ml,gl,fl,bl,yl,vl,wl,Cl,xl,kl,Sl,Tl,El,Ml,Al,Il,Dl,Ol,Bl,Ll,Nl,ql,Rl,Fl,Pl,_l=!1,Vl=!1,zl=[],Hl=!1,Wl=!1,$l=[],Ul=!1,jl=[],Yl="undefined"!=typeof document,Gl=La,Zl=Da||Ia?"cssFloat":"float",Kl=Yl&&!Na&&!La&&"draggable"in document.createElement("div"),Jl=function(){if(Yl){if(Ia)return!1;var t=document.createElement("x");return t.style.cssText="pointer-events:auto","auto"===t.style.pointerEvents}}(),Xl=function(t,e){var i=$a(t),o=parseInt(i.width)-parseInt(i.paddingLeft)-parseInt(i.paddingRight)-parseInt(i.borderLeftWidth)-parseInt(i.borderRightWidth),n=Ka(t,0,e),s=Ka(t,1,e),r=n&&$a(n),a=s&&$a(s),l=r&&parseInt(r.marginLeft)+parseInt(r.marginRight)+Ga(n).width,c=a&&parseInt(a.marginLeft)+parseInt(a.marginRight)+Ga(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(n&&r.float&&"none"!==r.float){var h="left"===r.float?"left":"right";return!s||"both"!==a.clear&&a.clear!==h?"horizontal":"vertical"}return n&&("block"===r.display||"flex"===r.display||"table"===r.display||"grid"===r.display||l>=o&&"none"===i[Zl]||s&&"none"===i[Zl]&&l+c>o)?"vertical":"horizontal"},Ql=function(t){function e(t,i){return function(o,n,s,r){var a=o.options.group.name&&n.options.group.name&&o.options.group.name===n.options.group.name;if(null==t&&(i||a))return!0;if(null==t||!1===t)return!1;if(i&&"clone"===t)return t;if("function"==typeof t)return e(t(o,n,s,r),i)(o,n,s,r);var l=(i?o:n).options.group.name;return!0===t||"string"==typeof t&&t===l||t.join&&t.indexOf(l)>-1}}var i={},o=t.group;o&&"object"==Sa(o)||(o={name:o}),i.name=o.name,i.checkPull=e(o.pull,!0),i.checkPut=e(o.put),i.revertClone=o.revertClone,t.group=i},tc=function(){!Jl&&fl&&$a(fl,"display","none")},ec=function(){!Jl&&fl&&$a(fl,"display","")};Yl&&!Na&&document.addEventListener("click",function(t){if(Vl)return t.preventDefault(),t.stopPropagation&&t.stopPropagation(),t.stopImmediatePropagation&&t.stopImmediatePropagation(),Vl=!1,!1},!0);var ic=function(t){if(ml){t=t.touches?t.touches[0]:t;var e=(n=t.clientX,s=t.clientY,zl.some(function(t){var e=t[rl].options.emptyInsertThreshold;if(e&&!Ja(t)){var i=Ga(t),o=n>=i.left-e&&n<=i.right+e,a=s>=i.top-e&&s<=i.bottom+e;return o&&a?r=t:void 0}}),r);if(e){var i={};for(var o in t)t.hasOwnProperty(o)&&(i[o]=t[o]);i.target=i.rootEl=e,i.preventDefault=void 0,i.stopPropagation=void 0,e[rl]._onDragOver(i)}}var n,s,r},oc=function(t){ml&&ml.parentNode[rl]._isOutsideThisEl(t.target)};function nc(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=Ea({},e),t[rl]=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 Xl(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!==nc.supportPointer&&"PointerEvent"in window&&(!Ba||La),emptyInsertThreshold:5};for(var o in hl.initializePlugins(this,t,i),i)!(o in e)&&(e[o]=i[o]);for(var n in Ql(e),this)"_"===n.charAt(0)&&"function"==typeof this[n]&&(this[n]=this[n].bind(this));this.nativeDraggable=!e.forceFallback&&Kl,this.nativeDraggable&&(this.options.touchStartThreshold=1),e.supportPointer?Ra(t,"pointerdown",this._onTapStart):(Ra(t,"mousedown",this._onTapStart),Ra(t,"touchstart",this._onTapStart)),this.nativeDraggable&&(Ra(t,"dragover",this),Ra(t,"dragenter",this)),zl.push(this.el),e.store&&e.store.get&&this.sort(e.store.get(this)||[]),Ea(this,al())}function sc(t,e,i,o,n,s,r,a){var l,c,h=t[rl],d=h.options.onMove;return!window.CustomEvent||Ia||Da?(l=document.createEvent("Event")).initEvent("move",!0,!0):l=new CustomEvent("move",{bubbles:!0,cancelable:!0}),l.to=e,l.from=t,l.dragged=i,l.draggedRect=o,l.related=n||e,l.relatedRect=s||Ga(e),l.willInsertAfter=a,l.originalEvent=r,t.dispatchEvent(l),d&&(c=d.call(h,l,r)),c}function rc(t){t.draggable=!1}function ac(){Ul=!1}function lc(t){for(var e=t.tagName+t.className+t.src+t.href+t.textContent,i=e.length,o=0;i--;)o+=e.charCodeAt(i);return o.toString(36)}function cc(t){return setTimeout(t,0)}function hc(t){return clearTimeout(t)}nc.prototype={constructor:nc,_isOutsideThisEl:function(t){this.el.contains(t)||t===this.el||(ql=null)},_getDirection:function(t,e){return"function"==typeof this.options.direction?this.options.direction.call(this,t,e,ml):this.options.direction},_onTapStart:function(t){if(t.cancelable){var e=this,i=this.el,o=this.options,n=o.preventOnFilter,s=t.type,r=t.touches&&t.touches[0]||t.pointerType&&"touch"===t.pointerType&&t,a=(r||t).target,l=t.target.shadowRoot&&(t.path&&t.path[0]||t.composedPath&&t.composedPath()[0])||a,c=o.filter;if(function(t){jl.length=0;var e=t.getElementsByTagName("input"),i=e.length;for(;i--;){var o=e[i];o.checked&&jl.push(o)}}(i),!ml&&!(/mousedown|pointerdown/.test(s)&&0!==t.button||o.disabled)&&!l.isContentEditable&&(this.nativeDraggable||!Ba||!a||"SELECT"!==a.tagName.toUpperCase())&&!((a=Va(a,o.draggable,i,!1))&&a.animated||vl===a)){if(xl=Xa(a),Sl=Xa(a,o.draggable),"function"==typeof c){if(c.call(this,t,a,this))return pl({sortable:e,rootEl:l,name:"filter",targetEl:a,toEl:i,fromEl:i}),ul("filter",e,{evt:t}),void(n&&t.preventDefault())}else if(c&&(c=c.split(",").some(function(o){if(o=Va(l,o.trim(),i,!1))return pl({sortable:e,rootEl:o,name:"filter",targetEl:a,fromEl:i,toEl:i}),ul("filter",e,{evt:t}),!0})))return void(n&&t.preventDefault());o.handle&&!Va(l,o.handle,i,!1)||this._prepareDragStart(t,r,a)}}},_prepareDragStart:function(t,e,i){var o,n=this,s=n.el,r=n.options,a=s.ownerDocument;if(i&&!ml&&i.parentNode===s){var l=Ga(i);if(bl=s,gl=(ml=i).parentNode,yl=ml.nextSibling,vl=i,El=r.group,nc.dragged=ml,Al={target:ml,clientX:(e||t).clientX,clientY:(e||t).clientY},Bl=Al.clientX-l.left,Ll=Al.clientY-l.top,this._lastX=(e||t).clientX,this._lastY=(e||t).clientY,ml.style["will-change"]="all",o=function(){ul("delayEnded",n,{evt:t}),nc.eventCanceled?n._onDrop():(n._disableDelayedDragEvents(),!Oa&&n.nativeDraggable&&(ml.draggable=!0),n._triggerDragStart(t,e),pl({sortable:n,name:"choose",originalEvent:t}),Wa(ml,r.chosenClass,!0))},r.ignore.split(",").forEach(function(t){ja(ml,t.trim(),rc)}),Ra(a,"dragover",ic),Ra(a,"mousemove",ic),Ra(a,"touchmove",ic),r.supportPointer?(Ra(a,"pointerup",n._onDrop),!this.nativeDraggable&&Ra(a,"pointercancel",n._onDrop)):(Ra(a,"mouseup",n._onDrop),Ra(a,"touchend",n._onDrop),Ra(a,"touchcancel",n._onDrop)),Oa&&this.nativeDraggable&&(this.options.touchStartThreshold=4,ml.draggable=!0),ul("delayStart",this,{evt:t}),!r.delay||r.delayOnTouchOnly&&!e||this.nativeDraggable&&(Da||Ia))o();else{if(nc.eventCanceled)return void this._onDrop();r.supportPointer?(Ra(a,"pointerup",n._disableDelayedDrag),Ra(a,"pointercancel",n._disableDelayedDrag)):(Ra(a,"mouseup",n._disableDelayedDrag),Ra(a,"touchend",n._disableDelayedDrag),Ra(a,"touchcancel",n._disableDelayedDrag)),Ra(a,"mousemove",n._delayedDragTouchMoveHandler),Ra(a,"touchmove",n._delayedDragTouchMoveHandler),r.supportPointer&&Ra(a,"pointermove",n._delayedDragTouchMoveHandler),n._dragStartTimer=setTimeout(o,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(){ml&&rc(ml),clearTimeout(this._dragStartTimer),this._disableDelayedDragEvents()},_disableDelayedDragEvents:function(){var t=this.el.ownerDocument;Fa(t,"mouseup",this._disableDelayedDrag),Fa(t,"touchend",this._disableDelayedDrag),Fa(t,"touchcancel",this._disableDelayedDrag),Fa(t,"pointerup",this._disableDelayedDrag),Fa(t,"pointercancel",this._disableDelayedDrag),Fa(t,"mousemove",this._delayedDragTouchMoveHandler),Fa(t,"touchmove",this._delayedDragTouchMoveHandler),Fa(t,"pointermove",this._delayedDragTouchMoveHandler)},_triggerDragStart:function(t,e){e=e||"touch"==t.pointerType&&t,!this.nativeDraggable||e?this.options.supportPointer?Ra(document,"pointermove",this._onTouchMove):Ra(document,e?"touchmove":"mousemove",this._onTouchMove):(Ra(ml,"dragend",this),Ra(bl,"dragstart",this._onDragStart));try{document.selection?cc(function(){document.selection.empty()}):window.getSelection().removeAllRanges()}catch(t){}},_dragStarted:function(t,e){if(_l=!1,bl&&ml){ul("dragStarted",this,{evt:e}),this.nativeDraggable&&Ra(document,"dragover",oc);var i=this.options;!t&&Wa(ml,i.dragClass,!1),Wa(ml,i.ghostClass,!0),nc.active=this,t&&this._appendGhost(),pl({sortable:this,name:"start",originalEvent:e})}else this._nulling()},_emulateDragOver:function(){if(Il){this._lastX=Il.clientX,this._lastY=Il.clientY,tc();for(var t=document.elementFromPoint(Il.clientX,Il.clientY),e=t;t&&t.shadowRoot&&(t=t.shadowRoot.elementFromPoint(Il.clientX,Il.clientY))!==e;)e=t;if(ml.parentNode[rl]._isOutsideThisEl(t),e)do{if(e[rl]){if(e[rl]._onDragOver({clientX:Il.clientX,clientY:Il.clientY,target:t,rootEl:e})&&!this.options.dragoverBubble)break}t=e}while(e=_a(e));ec()}},_onTouchMove:function(t){if(Al){var e=this.options,i=e.fallbackTolerance,o=e.fallbackOffset,n=t.touches?t.touches[0]:t,s=fl&&Ua(fl,!0),r=fl&&s&&s.a,a=fl&&s&&s.d,l=Gl&&Pl&&Qa(Pl),c=(n.clientX-Al.clientX+o.x)/(r||1)+(l?l[0]-$l[0]:0)/(r||1),h=(n.clientY-Al.clientY+o.y)/(a||1)+(l?l[1]-$l[1]:0)/(a||1);if(!nc.active&&!_l){if(i&&Math.max(Math.abs(n.clientX-this._lastX),Math.abs(n.clientY-this._lastY))<i)return;this._onDragStart(t,!0)}if(fl){s?(s.e+=c-(Dl||0),s.f+=h-(Ol||0)):s={a:1,b:0,c:0,d:1,e:c,f:h};var d="matrix(".concat(s.a,",").concat(s.b,",").concat(s.c,",").concat(s.d,",").concat(s.e,",").concat(s.f,")");$a(fl,"webkitTransform",d),$a(fl,"mozTransform",d),$a(fl,"msTransform",d),$a(fl,"transform",d),Dl=c,Ol=h,Il=n}t.cancelable&&t.preventDefault()}},_appendGhost:function(){if(!fl){var t=this.options.fallbackOnBody?document.body:bl,e=Ga(ml,!0,Gl,!0,t),i=this.options;if(Gl){for(Pl=t;"static"===$a(Pl,"position")&&"none"===$a(Pl,"transform")&&Pl!==document;)Pl=Pl.parentNode;Pl!==document.body&&Pl!==document.documentElement?(Pl===document&&(Pl=Ya()),e.top+=Pl.scrollTop,e.left+=Pl.scrollLeft):Pl=Ya(),$l=Qa(Pl)}Wa(fl=ml.cloneNode(!0),i.ghostClass,!1),Wa(fl,i.fallbackClass,!0),Wa(fl,i.dragClass,!0),$a(fl,"transition",""),$a(fl,"transform",""),$a(fl,"box-sizing","border-box"),$a(fl,"margin",0),$a(fl,"top",e.top),$a(fl,"left",e.left),$a(fl,"width",e.width),$a(fl,"height",e.height),$a(fl,"opacity","0.8"),$a(fl,"position",Gl?"absolute":"fixed"),$a(fl,"zIndex","100000"),$a(fl,"pointerEvents","none"),nc.ghost=fl,t.appendChild(fl),$a(fl,"transform-origin",Bl/parseInt(fl.style.width)*100+"% "+Ll/parseInt(fl.style.height)*100+"%")}},_onDragStart:function(t,e){var i=this,o=t.dataTransfer,n=i.options;ul("dragStart",this,{evt:t}),nc.eventCanceled?this._onDrop():(ul("setupClone",this),nc.eventCanceled||((wl=nl(ml)).removeAttribute("id"),wl.draggable=!1,wl.style["will-change"]="",this._hideClone(),Wa(wl,this.options.chosenClass,!1),nc.clone=wl),i.cloneId=cc(function(){ul("clone",i),nc.eventCanceled||(i.options.removeCloneOnHide||bl.insertBefore(wl,ml),i._hideClone(),pl({sortable:i,name:"clone"}))}),!e&&Wa(ml,n.dragClass,!0),e?(Vl=!0,i._loopId=setInterval(i._emulateDragOver,50)):(Fa(document,"mouseup",i._onDrop),Fa(document,"touchend",i._onDrop),Fa(document,"touchcancel",i._onDrop),o&&(o.effectAllowed="move",n.setData&&n.setData.call(i,o,ml)),Ra(document,"drop",i),$a(ml,"transform","translateZ(0)")),_l=!0,i._dragStartId=cc(i._dragStarted.bind(i,e,t)),Ra(document,"selectstart",i),Nl=!0,window.getSelection().removeAllRanges(),Ba&&$a(document.body,"user-select","none"))},_onDragOver:function(t){var e,i,o,n,s=this.el,r=t.target,a=this.options,l=a.group,c=nc.active,h=El===l,d=a.sort,u=Ml||c,p=this,m=!1;if(!Ul){if(void 0!==t.preventDefault&&t.cancelable&&t.preventDefault(),r=Va(r,a.draggable,s,!0),I("dragOver"),nc.eventCanceled)return m;if(ml.contains(t.target)||r.animated&&r.animatingX&&r.animatingY||p._ignoreWhileAnimating===r)return O(!1);if(Vl=!1,c&&!a.disabled&&(h?d||(o=gl!==bl):Ml===this||(this.lastPutMode=El.checkPull(this,c,ml,t))&&l.checkPut(this,c,ml,t))){if(n="vertical"===this._getDirection(t,r),e=Ga(ml),I("dragOverValid"),nc.eventCanceled)return m;if(o)return gl=bl,D(),this._hideClone(),I("revert"),nc.eventCanceled||(yl?bl.insertBefore(ml,yl):bl.appendChild(ml)),O(!0);var g=Ja(s,a.draggable);if(!g||function(t,e,i){var o=Ga(Ja(i.el,i.options.draggable)),n=sl(i.el,i.options,fl),s=10;return e?t.clientX>n.right+s||t.clientY>o.bottom&&t.clientX>o.left:t.clientY>n.bottom+s||t.clientX>o.right&&t.clientY>o.top}(t,n,this)&&!g.animated){if(g===ml)return O(!1);if(g&&s===t.target&&(r=g),r&&(i=Ga(r)),!1!==sc(bl,s,ml,e,r,i,t,!!r))return D(),g&&g.nextSibling?s.insertBefore(ml,g.nextSibling):s.appendChild(ml),gl=s,B(),O(!0)}else if(g&&function(t,e,i){var o=Ga(Ka(i.el,0,i.options,!0)),n=sl(i.el,i.options,fl),s=10;return e?t.clientX<n.left-s||t.clientY<o.top&&t.clientX<o.right:t.clientY<n.top-s||t.clientY<o.bottom&&t.clientX<o.left}(t,n,this)){var f=Ka(s,0,a,!0);if(f===ml)return O(!1);if(i=Ga(r=f),!1!==sc(bl,s,ml,e,r,i,t,!1))return D(),s.insertBefore(ml,f),gl=s,B(),O(!0)}else if(r.parentNode===s){i=Ga(r);var b,y,v,w=ml.parentNode!==s,C=!function(t,e,i){var o=i?t.left:t.top,n=i?t.right:t.bottom,s=i?t.width:t.height,r=i?e.left:e.top,a=i?e.right:e.bottom,l=i?e.width:e.height;return o===r||n===a||o+s/2===r+l/2}(ml.animated&&ml.toRect||e,r.animated&&r.toRect||i,n),x=n?"top":"left",k=Za(r,"top","top")||Za(ml,"top","top"),S=k?k.scrollTop:void 0;if(ql!==r&&(y=i[x],Hl=!1,Wl=!C&&a.invertSwap||w),b=function(t,e,i,o,n,s,r,a){var l=o?t.clientY:t.clientX,c=o?i.height:i.width,h=o?i.top:i.left,d=o?i.bottom:i.right,u=!1;if(!r)if(a&&Fl<c*n){if(!Hl&&(1===Rl?l>h+c*s/2:l<d-c*s/2)&&(Hl=!0),Hl)u=!0;else if(1===Rl?l<h+Fl:l>d-Fl)return-Rl}else if(l>h+c*(1-n)/2&&l<d-c*(1-n)/2)return function(t){return Xa(ml)<Xa(t)?1:-1}(e);if((u=u||r)&&(l<h+c*s/2||l>d-c*s/2))return l>h+c/2?1:-1;return 0}(t,r,i,n,C?1:a.swapThreshold,null==a.invertedSwapThreshold?a.swapThreshold:a.invertedSwapThreshold,Wl,ql===r),0!==b){var T=Xa(ml);do{T-=b,v=gl.children[T]}while(v&&("none"===$a(v,"display")||v===fl))}if(0===b||v===r)return O(!1);ql=r,Rl=b;var E=r.nextElementSibling,M=!1,A=sc(bl,s,ml,e,r,i,t,M=1===b);if(!1!==A)return 1!==A&&-1!==A||(M=1===A),Ul=!0,setTimeout(ac,30),D(),M&&!E?s.appendChild(ml):r.parentNode.insertBefore(ml,M?E:r),k&&ol(k,0,S-k.scrollTop),gl=ml.parentNode,void 0===y||Wl||(Fl=Math.abs(y-Ga(r)[x])),B(),O(!0)}if(s.contains(ml))return O(!1)}return!1}function I(a,l){ul(a,p,ka({evt:t,isOwner:h,axis:n?"vertical":"horizontal",revert:o,dragRect:e,targetRect:i,canSort:d,fromSortable:u,target:r,completed:O,onMove:function(i,o){return sc(bl,s,ml,e,i,Ga(i),t,o)},changed:B},l))}function D(){I("dragOverAnimationCapture"),p.captureAnimationState(),p!==u&&u.captureAnimationState()}function O(e){return I("dragOverCompleted",{insertion:e}),e&&(h?c._hideClone():c._showClone(p),p!==u&&(Wa(ml,Ml?Ml.options.ghostClass:c.options.ghostClass,!1),Wa(ml,a.ghostClass,!0)),Ml!==p&&p!==nc.active?Ml=p:p===nc.active&&Ml&&(Ml=null),u===p&&(p._ignoreWhileAnimating=r),p.animateAll(function(){I("dragOverAnimationComplete"),p._ignoreWhileAnimating=null}),p!==u&&(u.animateAll(),u._ignoreWhileAnimating=null)),(r===ml&&!ml.animated||r===s&&!r.animated)&&(ql=null),a.dragoverBubble||t.rootEl||r===document||(ml.parentNode[rl]._isOutsideThisEl(t.target),!e&&ic(t)),!a.dragoverBubble&&t.stopPropagation&&t.stopPropagation(),m=!0}function B(){kl=Xa(ml),Tl=Xa(ml,a.draggable),pl({sortable:p,name:"change",toEl:s,newIndex:kl,newDraggableIndex:Tl,originalEvent:t})}},_ignoreWhileAnimating:null,_offMoveEvents:function(){Fa(document,"mousemove",this._onTouchMove),Fa(document,"touchmove",this._onTouchMove),Fa(document,"pointermove",this._onTouchMove),Fa(document,"dragover",ic),Fa(document,"mousemove",ic),Fa(document,"touchmove",ic)},_offUpEvents:function(){var t=this.el.ownerDocument;Fa(t,"mouseup",this._onDrop),Fa(t,"touchend",this._onDrop),Fa(t,"pointerup",this._onDrop),Fa(t,"pointercancel",this._onDrop),Fa(t,"touchcancel",this._onDrop),Fa(document,"selectstart",this)},_onDrop:function(t){var e=this.el,i=this.options;kl=Xa(ml),Tl=Xa(ml,i.draggable),ul("drop",this,{evt:t}),gl=ml&&ml.parentNode,kl=Xa(ml),Tl=Xa(ml,i.draggable),nc.eventCanceled||(_l=!1,Wl=!1,Hl=!1,clearInterval(this._loopId),clearTimeout(this._dragStartTimer),hc(this.cloneId),hc(this._dragStartId),this.nativeDraggable&&(Fa(document,"drop",this),Fa(e,"dragstart",this._onDragStart)),this._offMoveEvents(),this._offUpEvents(),Ba&&$a(document.body,"user-select",""),$a(ml,"transform",""),t&&(Nl&&(t.cancelable&&t.preventDefault(),!i.dropBubble&&t.stopPropagation()),fl&&fl.parentNode&&fl.parentNode.removeChild(fl),(bl===gl||Ml&&"clone"!==Ml.lastPutMode)&&wl&&wl.parentNode&&wl.parentNode.removeChild(wl),ml&&(this.nativeDraggable&&Fa(ml,"dragend",this),rc(ml),ml.style["will-change"]="",Nl&&!_l&&Wa(ml,Ml?Ml.options.ghostClass:this.options.ghostClass,!1),Wa(ml,this.options.chosenClass,!1),pl({sortable:this,name:"unchoose",toEl:gl,newIndex:null,newDraggableIndex:null,originalEvent:t}),bl!==gl?(kl>=0&&(pl({rootEl:gl,name:"add",toEl:gl,fromEl:bl,originalEvent:t}),pl({sortable:this,name:"remove",toEl:gl,originalEvent:t}),pl({rootEl:gl,name:"sort",toEl:gl,fromEl:bl,originalEvent:t}),pl({sortable:this,name:"sort",toEl:gl,originalEvent:t})),Ml&&Ml.save()):kl!==xl&&kl>=0&&(pl({sortable:this,name:"update",toEl:gl,originalEvent:t}),pl({sortable:this,name:"sort",toEl:gl,originalEvent:t})),nc.active&&(null!=kl&&-1!==kl||(kl=xl,Tl=Sl),pl({sortable:this,name:"end",toEl:gl,originalEvent:t}),this.save())))),this._nulling()},_nulling:function(){ul("nulling",this),bl=ml=gl=fl=yl=wl=vl=Cl=Al=Il=Nl=kl=Tl=xl=Sl=ql=Rl=Ml=El=nc.dragged=nc.ghost=nc.clone=nc.active=null,jl.forEach(function(t){t.checked=!0}),jl.length=Dl=Ol=0},handleEvent:function(t){switch(t.type){case"drop":case"dragend":this._onDrop(t);break;case"dragenter":case"dragover":ml&&(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,o=0,n=i.length,s=this.options;o<n;o++)Va(t=i[o],s.draggable,this.el,!1)&&e.push(t.getAttribute(s.dataIdAttr)||lc(t));return e},sort:function(t,e){var i={},o=this.el;this.toArray().forEach(function(t,e){var n=o.children[e];Va(n,this.options.draggable,o,!1)&&(i[t]=n)},this),e&&this.captureAnimationState(),t.forEach(function(t){i[t]&&(o.removeChild(i[t]),o.appendChild(i[t]))}),e&&this.animateAll()},save:function(){var t=this.options.store;t&&t.set&&t.set(this)},closest:function(t,e){return Va(t,e||this.options.draggable,this.el,!1)},option:function(t,e){var i=this.options;if(void 0===e)return i[t];var o=hl.modifyOption(this,t,e);i[t]=void 0!==o?o:e,"group"===t&&Ql(i)},destroy:function(){ul("destroy",this);var t=this.el;t[rl]=null,Fa(t,"mousedown",this._onTapStart),Fa(t,"touchstart",this._onTapStart),Fa(t,"pointerdown",this._onTapStart),this.nativeDraggable&&(Fa(t,"dragover",this),Fa(t,"dragenter",this)),Array.prototype.forEach.call(t.querySelectorAll("[draggable]"),function(t){t.removeAttribute("draggable")}),this._onDrop(),this._disableDelayedDragEvents(),zl.splice(zl.indexOf(this.el),1),this.el=t=null},_hideClone:function(){if(!Cl){if(ul("hideClone",this),nc.eventCanceled)return;$a(wl,"display","none"),this.options.removeCloneOnHide&&wl.parentNode&&wl.parentNode.removeChild(wl),Cl=!0}},_showClone:function(t){if("clone"===t.lastPutMode){if(Cl){if(ul("showClone",this),nc.eventCanceled)return;ml.parentNode!=bl||this.options.group.revertClone?yl?bl.insertBefore(wl,yl):bl.appendChild(wl):bl.insertBefore(wl,ml),this.options.group.revertClone&&this.animate(ml,wl),$a(wl,"display",""),Cl=!1}}else this._hideClone()}},Yl&&Ra(document,"touchmove",function(t){(nc.active||_l)&&t.cancelable&&t.preventDefault()}),nc.utils={on:Ra,off:Fa,css:$a,find:ja,is:function(t,e){return!!Va(t,e,t,!1)},extend:function(t,e){if(t&&e)for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i]);return t},throttle:il,closest:Va,toggleClass:Wa,clone:nl,index:Xa,nextTick:cc,cancelNextTick:hc,detectDirection:Xl,getChild:Ka,expando:rl},nc.get=function(t){return t[rl]},nc.mount=function(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];e[0].constructor===Array&&(e=e[0]),e.forEach(function(t){if(!t.prototype||!t.prototype.constructor)throw"Sortable: Mounted plugin must be a constructor function, not ".concat({}.toString.call(t));t.utils&&(nc.utils=ka(ka({},nc.utils),t.utils)),hl.mount(t)})},nc.create=function(t,e){return new nc(t,e)},nc.version="1.15.6";var dc,uc,pc,mc,gc,fc,bc=[],yc=!1;function vc(){bc.forEach(function(t){clearInterval(t.pid)}),bc=[]}function wc(){clearInterval(fc)}var Cc=il(function(t,e,i,o){if(e.scroll){var n,s=(t.touches?t.touches[0]:t).clientX,r=(t.touches?t.touches[0]:t).clientY,a=e.scrollSensitivity,l=e.scrollSpeed,c=Ya(),h=!1;uc!==i&&(uc=i,vc(),dc=e.scroll,n=e.scrollFn,!0===dc&&(dc=tl(i,!0)));var d=0,u=dc;do{var p=u,m=Ga(p),g=m.top,f=m.bottom,b=m.left,y=m.right,v=m.width,w=m.height,C=void 0,x=void 0,k=p.scrollWidth,S=p.scrollHeight,T=$a(p),E=p.scrollLeft,M=p.scrollTop;p===c?(C=v<k&&("auto"===T.overflowX||"scroll"===T.overflowX||"visible"===T.overflowX),x=w<S&&("auto"===T.overflowY||"scroll"===T.overflowY||"visible"===T.overflowY)):(C=v<k&&("auto"===T.overflowX||"scroll"===T.overflowX),x=w<S&&("auto"===T.overflowY||"scroll"===T.overflowY));var A=C&&(Math.abs(y-s)<=a&&E+v<k)-(Math.abs(b-s)<=a&&!!E),I=x&&(Math.abs(f-r)<=a&&M+w<S)-(Math.abs(g-r)<=a&&!!M);if(!bc[d])for(var D=0;D<=d;D++)bc[D]||(bc[D]={});bc[d].vx==A&&bc[d].vy==I&&bc[d].el===p||(bc[d].el=p,bc[d].vx=A,bc[d].vy=I,clearInterval(bc[d].pid),0==A&&0==I||(h=!0,bc[d].pid=setInterval(function(){o&&0===this.layer&&nc.active._onTouchMove(gc);var e=bc[this.layer].vy?bc[this.layer].vy*l:0,i=bc[this.layer].vx?bc[this.layer].vx*l:0;"function"==typeof n&&"continue"!==n.call(nc.dragged.parentNode[rl],i,e,t,gc,bc[this.layer].el)||ol(bc[this.layer].el,i,e)}.bind({layer:d}),24))),d++}while(e.bubbleScroll&&u!==c&&(u=tl(u,!1)));yc=h}},30),xc=function(t){var e=t.originalEvent,i=t.putSortable,o=t.dragEl,n=t.activeSortable,s=t.dispatchSortableEvent,r=t.hideGhostForTarget,a=t.unhideGhostForTarget;if(e){var l=i||n;r();var c=e.changedTouches&&e.changedTouches.length?e.changedTouches[0]:e,h=document.elementFromPoint(c.clientX,c.clientY);a(),l&&!l.el.contains(h)&&(s("spill"),this.onSpill({dragEl:o,putSortable:i}))}};function kc(){}function Sc(){}kc.prototype={startIndex:null,dragStart:function(t){var e=t.oldDraggableIndex;this.startIndex=e},onSpill:function(t){var e=t.dragEl,i=t.putSortable;this.sortable.captureAnimationState(),i&&i.captureAnimationState();var o=Ka(this.sortable.el,this.startIndex,this.options);o?this.sortable.el.insertBefore(e,o):this.sortable.el.appendChild(e),this.sortable.animateAll(),i&&i.animateAll()},drop:xc},Ea(kc,{pluginName:"revertOnSpill"}),Sc.prototype={onSpill:function(t){var e=t.dragEl,i=t.putSortable||this.sortable;i.captureAnimationState(),e.parentNode&&e.parentNode.removeChild(e),i.animateAll()},drop:xc},Ea(Sc,{pluginName:"removeOnSpill"}),nc.mount(new function(){function t(){for(var t in this.defaults={scroll:!0,forceAutoScrollFallback:!1,scrollSensitivity:30,scrollSpeed:10,bubbleScroll:!0},this)"_"===t.charAt(0)&&"function"==typeof this[t]&&(this[t]=this[t].bind(this))}return t.prototype={dragStarted:function(t){var e=t.originalEvent;this.sortable.nativeDraggable?Ra(document,"dragover",this._handleAutoScroll):this.options.supportPointer?Ra(document,"pointermove",this._handleFallbackAutoScroll):e.touches?Ra(document,"touchmove",this._handleFallbackAutoScroll):Ra(document,"mousemove",this._handleFallbackAutoScroll)},dragOverCompleted:function(t){var e=t.originalEvent;this.options.dragOverBubble||e.rootEl||this._handleAutoScroll(e)},drop:function(){this.sortable.nativeDraggable?Fa(document,"dragover",this._handleAutoScroll):(Fa(document,"pointermove",this._handleFallbackAutoScroll),Fa(document,"touchmove",this._handleFallbackAutoScroll),Fa(document,"mousemove",this._handleFallbackAutoScroll)),wc(),vc(),clearTimeout(za),za=void 0},nulling:function(){gc=uc=dc=yc=fc=pc=mc=null,bc.length=0},_handleFallbackAutoScroll:function(t){this._handleAutoScroll(t,!0)},_handleAutoScroll:function(t,e){var i=this,o=(t.touches?t.touches[0]:t).clientX,n=(t.touches?t.touches[0]:t).clientY,s=document.elementFromPoint(o,n);if(gc=t,e||this.options.forceAutoScrollFallback||Da||Ia||Ba){Cc(t,this.options,s,e);var r=tl(s,!0);!yc||fc&&o===pc&&n===mc||(fc&&wc(),fc=setInterval(function(){var s=tl(document.elementFromPoint(o,n),!0);s!==r&&(r=s,vc()),Cc(t,i.options,s,e)},10),pc=o,mc=n)}else{if(!this.options.bubbleScroll||tl(s,!0)===Ya())return void vc();Cc(t,this.options,tl(s,!1),!1)}}},Ea(t,{pluginName:"scroll",initializeByDefault:!0})}),nc.mount(Sc,kc);class Tc extends t.Modal{constructor(t,e){super(t),this.options=Object.assign({title:Jr("Confirm"),confirmText:Jr("Confirm"),cancelText:Jr("Cancel")},e)}onOpen(){const{contentEl:i}=this;i.addClass("confirm-modal"),i.createEl("h2",{text:this.options.title}),this.options.message.split("\n").forEach(t=>{i.createEl("p",{text:t})});const o=i.createDiv("confirm-modal-buttons");new t.ButtonComponent(o).setButtonText(this.options.cancelText).onClick(()=>this.close()),new t.ButtonComponent(o).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 Tc(t,e).open()}}class Ec 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="",o=[],n=!1;for(const e of t)if(e.startsWith("## ")&&!i)i=e.substring(3).trim(),n=!0,o.push(e);else{if(e.startsWith("## ")&&n)break;n&&o.push(e)}this.changelogContent=o.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 o=this.plugin.settings,n=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='<svg width="24" height="24" viewBox="0 0 24 24" focusable="false" fill="currentColor"><g fill-rule="evenodd"><path id="change-font-color-icon" d="M3 18h18v3H3z" style="fill:#2DC26B"></path><path d="M8.7 16h-.8a.5.5 0 01-.5-.6l2.7-9c.1-.3.3-.4.5-.4h2.8c.2 0 .4.1.5.4l2.7 9a.5.5 0 01-.5.6h-.8a.5.5 0 01-.4-.4l-.7-2.2c0-.3-.3-.4-.5-.4h-3.4c-.2 0-.4.1-.5.4l-.7 2.2c0 .3-.2.4-.4.4zm2.6-7.6l-.6 2a.5.5 0 00.5.6h1.6a.5.5 0 00.5-.6l-.6-2c0-.3-.3-.4-.5-.4h-.4c-.2 0-.4.1-.5.4z"></path></g></svg>',i=!0),t.SubmenuCommands&&n(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};o.menuCommands&&(n(o.menuCommands),r(o.menuCommands)&&(i=!0)),o.enableMultipleConfig&&(o.followingCommands&&(n(o.followingCommands),r(o.followingCommands)&&(i=!0)),o.topCommands&&(n(o.topCommands),r(o.topCommands)&&(i=!0)),o.fixedCommands&&(n(o.fixedCommands),r(o.fixedCommands)&&(i=!0)),o.mobileCommands&&(n(o.mobileCommands),r(o.mobileCommands)&&(i=!0))),i?(yield this.plugin.saveSettings(),new t.Notice(Jr("Command IDs have been successfully repaired!")),dispatchEvent(new Event("editingToolbar-NewCommand"))):new t.Notice(Jr("No command IDs need to be repaired"))}catch(e){console.error("修复命令ID时出错:",e),new t.Notice(Jr("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({},ra),{lastVersion:e,customCommands:i}),yield this.plugin.saveSettings(),new t.Notice(Jr("Successfully restored default settings! (Custom commands preserved)")),this.reloadPlugin(this.plugin.manifest.id),this.close()}catch(e){console.error("恢复默认设置时出错:",e),new t.Notice(Jr("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:Jr("Notice:")});const o=i.createEl("ul");o.createEl("li",{text:Jr("⚠️This update is not compatible with 2.x version command ids, please click [Repair command] to be compatible")}),o.createEl("li",{text:Jr("⚠️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:Jr("Latest Changes")}),this.changelogContentEl=this.changelogContainer.createDiv({cls:"changelog-content"}),this.changelogContentEl.setText(Jr("Loading changelog...")),setTimeout(()=>{this.loadChangelog()},100),new t.Setting(i).setName(Jr("🔧Data repair")).setDesc(Jr("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(Jr("Repair command ID")).onClick(()=>e(this,void 0,void 0,function*(){yield this.fixCommandIds()}))),new t.Setting(i).setName(Jr("🔄Restore default settings")).setDesc(Jr("This will reset all your custom configurations, but custom commands will be preserved")).addButton(t=>t.setButtonText(Jr("Restore default")).onClick(()=>e(this,void 0,void 0,function*(){Tc.show(this.app,{message:Jr("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(Jr("📋View full changelog")).setDesc(Jr("Open the complete changelog in your browser")).addButton(t=>t.setButtonText(Jr("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(Jr("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 Mc(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 Ac=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 o in i)t.o(i,o)&&!t.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:i[o]})},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 o(t,e,i,o){let n=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,o,{capture:!1,...n});return Array.prototype.slice.call(arguments,1)}t.r(i),t.d(i,{adjustableInputNumbers:()=>h,createElementFromString:()=>r,createFromTemplate:()=>a,eventPath:()=>l,off:()=>s,on:()=>n,resolveElement:()=>c});const n=o.bind(null,"addEventListener"),s=o.bind(null,"removeEventListener");function r(t){const e=document.createElement("div");return e.innerHTML=t.trim(),e.firstElementChild}function a(t){const e=(t,e)=>{const i=t.getAttribute(e);return t.removeAttribute(e),i},i=function(t){let o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const n=e(t,":obj"),s=e(t,":ref"),r=n?o[n]={}:o;s&&(o[s]=t);for(const o of Array.from(t.children)){const t=e(o,":arr"),n=i(o,t?{}:r);t&&(r[t]||(r[t]=[])).push(Object.keys(n).length?n:o)}return o};return i(r(t))}function l(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,o)=>(t=t.querySelector(e),i<o.length-1?t.shadowRoot:t),document):null}function h(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t=>t;function i(i){const o=[.001,.01,.1][Number(i.shiftKey||2*i.ctrlKey)]*(i.deltaY<0?1:-1);let n=0,s=t.selectionStart;t.value=t.value.replace(/[\d.]+/g,(t,i)=>i<=s&&i+t.length>=s?(s=i,e(Number(t),o,n)):(n++,t)),t.focus(),t.setSelectionRange(s,s),i.preventDefault(),t.dispatchEvent(new Event("input"))}n(t,"focus",()=>n(window,"wheel",i,{passive:!1})),n(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 o=p(t=t/360*6),n=t-o,s=i*(1-e),r=i*(1-n*e),a=i*(1-(1-n)*e),l=o%6;return[255*[i,r,s,s,a,i][l],255*[a,i,i,r,s,s][l],255*[s,s,a,i,i,r][l]]}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 o=g(t,e,i),n=o[0]/255,s=o[1]/255,r=o[2]/255,a=d(1-n,1-s,1-r);return[100*(1===a?0:(1-n-a)/(1-a)),100*(1===a?0:(1-s-a)/(1-a)),100*(1===a?0:(1-r-a)/(1-a)),100*a]}function y(t,e,i){const o=(2-(e/=100))*(i/=100)/2;return 0!==o&&(e=1===o?0:o<.5?e*i/(2*o):e*i/(2-2*o)),[t,100*e,100*o]}function v(t,e,i){const o=d(t/=255,e/=255,i/=255),n=u(t,e,i),s=n-o;let r,a;if(0===s)r=a=0;else{a=s/n;const o=((n-t)/6+s/2)/s,l=((n-e)/6+s/2)/s,c=((n-i)/6+s/2)/s;t===n?r=c-l:e===n?r=1/3+o-c:i===n&&(r=2/3+l-o),r<0?r+=1:r>1&&(r-=1)}return[360*r,100*a,100*n]}function w(t,e,i,o){return e/=100,i/=100,[...v(255*(1-d(1,(t/=100)*(1-(o/=100))+o)),255*(1-d(1,e*(1-o)+o)),255*(1-d(1,i*(1-o)+o)))]}function C(t,e,i){e/=100;const o=2*(e*=(i/=100)<.5?i:1-i)/(i+e)*100,n=100*(i+e);return[t,isNaN(o)?0:o,n]}function x(t){return v(...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 o;t:for(const n in e){if(!(o=e[n].exec(t)))continue;const s=t=>!!o[2]==("number"==typeof t);switch(n){case"cmyk":{const[,t,e,s,r]=i(o);if(t>100||e>100||s>100||r>100)break t;return{values:w(t,e,s,r),type:n}}case"rgba":{const[,,,t,e,r,a]=i(o);if(t>255||e>255||r>255||a<0||a>1||!s(a))break t;return{values:[...v(t,e,r),a],a:a,type:n}}case"hexa":{let[,t]=o;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:n}}case"hsla":{const[,,,t,e,r,a]=i(o);if(t>360||e>100||r>100||a<0||a>1||!s(a))break t;return{values:[...C(t,e,r),a],a:a,type:n}}case"hsva":{const[,,,t,e,r,a]=i(o);if(t>360||e>100||r>100||a<0||a>1||!s(a))break t;return{values:[t,e,r,a],a:a,type:n}}}}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=[...y(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:o,key:n}=t;if(document.activeElement===i.wrapper){const{lock:i}=e.options,s="ArrowUp"===n,r="ArrowRight"===n,a="ArrowDown"===n,l="ArrowLeft"===n;if("keydown"===o&&(s||r||a||l)){let o=0,n=0;"v"===i?o=s||r?1:-1:"h"===i?o=s||r?-1:1:(n=s?-1:a?1:0,o=l?-1:r?1:0),e.update(T(e.cache.x+.01*o),T(e.cache.y+.01*n)),t.preventDefault()}else n.startsWith("Arrow")&&(e.options.onstop(),t.preventDefault())}},_tapstart(t){n(document,["mouseup","touchend","touchcancel"],e._tapstop),n(document,["mousemove","touchmove"],e._tapmove),t.cancelable&&t.preventDefault(),e._tapmove(t)},_tapmove(t){const{options:i,cache:o}=e,{lock:n,element:s,wrapper:r}=i,a=r.getBoundingClientRect();let l=0,c=0;if(t){const e=t&&t.touches&&t.touches[0];l=t?(e||t).clientX:0,c=t?(e||t).clientY:0,l<a.left?l=a.left:l>a.left+a.width&&(l=a.left+a.width),c<a.top?c=a.top:c>a.top+a.height&&(c=a.top+a.height),l-=a.left,c-=a.top}else o&&(l=o.x*a.width,c=o.y*a.height);"h"!==n&&(s.style.left=`calc(${l/a.width*100}% - ${s.offsetWidth/2}px)`),"v"!==n&&(s.style.top=`calc(${c/a.height*100}% - ${s.offsetHeight/2}px)`),e.cache={x:l/a.width,y:c/a.height};const h=T(l/a.width),d=T(c/a.height);switch(n){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:o,top:n,width:s,height:r}=e.options.wrapper.getBoundingClientRect();"h"===e.options.lock&&(i=t),e._tapmove({clientX:o+s*t,clientY:n+r*i})},destroy(){const{options:t,_tapstart:i,_keyboard:o}=e;s(document,["keydown","keyup"],o),s([t.wrapper,t.element],"mousedown",i),s([t.wrapper,t.element],"touchstart",i,{passive:!1})}},{options:i,_tapstart:o,_keyboard:r}=e;return n([i.wrapper,i.element],"mousedown",o),n([i.wrapper,i.element],"touchstart",o,{passive:!1}),n(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=n(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},I=(t,e,i)=>{const{container:o,margin:n,position:s,variantFlipOrder:r,positionFlipOrder:a}={container:document.documentElement.getBoundingClientRect(),...A,...i},{left:l,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-n,b:h.bottom+n,r:h.right+n,l:h.left-d.width-n},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=a[m],b=r[g],{top:y,left:v,bottom:w,right:C}=o;for(const t of f){const i="t"===t||"b"===t,o=u[t],[n,s]=i?["top","left"]:["left","top"],[r,a]=i?[d.height,d.width]:[d.width,d.height],[l,c]=i?[w,C]:[C,w],[h,m]=i?[y,v]:[v,y];if(!(o<h||o+r>l))for(const r of b){const l=p[(i?"v":"h")+r];if(!(l<m||l+a>c))return e.style[s]=l-d[s]+"px",e.style[n]=o-d[n]+"px",t+r}}return e.style.left=l,e.style.top=c,null};function D(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){D(this,"_initializingActive",!0),D(this,"_recalc",!0),D(this,"_nanopop",null),D(this,"_root",null),D(this,"_color",S()),D(this,"_lastColor",S()),D(this,"_swatchColors",[]),D(this,"_setupAnimationFrame",null),D(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:o,sliders:n,lockOpacity:s,padding:r}=t;["nano","monolith"].includes(o)&&!n&&(t.sliders="h"),i.interaction||(i.interaction={});const{preview:a,opacity:l,hue:c,palette:h}=i;i.opacity=!s&&l,i.palette=h||a||l||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 o="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]:o;const{reference:e,popper:i}=Object.assign(o,t);if(!i||!e)throw new Error("Popper- or reference-element missing.");return I(e,i,o)}}})(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:o,appClass:n,theme:s,lockOpacity:r}=t.options,l=t=>t?"":'style="display:none" hidden',c=e=>t._t(e),h=a(`\n <div :ref="root" class="pickr">\n\n ${i?"":'<button type="button" :ref="button" class="pcr-button"></button>'}\n\n <div :ref="app" class="pcr-app ${n||""}" data-theme="${s}" ${o?'style="position: unset"':""} aria-label="${c("ui:dialog")}" role="window">\n <div class="pcr-selection" ${l(e.palette)}>\n <div :obj="preview" class="pcr-color-preview" ${l(e.preview)}>\n <button type="button" :ref="lastColor" class="pcr-last-color" aria-label="${c("btn:last-color")}"></button>\n <div :ref="currentColor" class="pcr-current-color"></div>\n </div>\n\n <div :obj="palette" class="pcr-color-palette">\n <div :ref="picker" class="pcr-picker"></div>\n <div :ref="palette" class="pcr-palette" tabindex="0" aria-label="${c("aria:palette")}" role="listbox"></div>\n </div>\n\n <div :obj="hue" class="pcr-color-chooser" ${l(e.hue)}>\n <div :ref="picker" class="pcr-picker"></div>\n <div :ref="slider" class="pcr-hue pcr-slider" tabindex="0" aria-label="${c("aria:hue")}" role="slider"></div>\n </div>\n\n <div :obj="opacity" class="pcr-color-opacity" ${l(e.opacity)}>\n <div :ref="picker" class="pcr-picker"></div>\n <div :ref="slider" class="pcr-opacity pcr-slider" tabindex="0" aria-label="${c("aria:opacity")}" role="slider"></div>\n </div>\n </div>\n\n <div class="pcr-swatches ${e.palette?"":"pcr-last"}" :ref="swatches"></div>\n\n <div :obj="interaction" class="pcr-interaction" ${l(Object.keys(e.interaction).length)}>\n <input :ref="result" class="pcr-result" type="text" spellcheck="false" ${l(e.interaction.input)} aria-label="${c("aria:input")}">\n\n <input :arr="options" class="pcr-type" data-type="HEXA" value="${r?"HEX":"HEXA"}" type="button" ${l(e.interaction.hex)}>\n <input :arr="options" class="pcr-type" data-type="RGBA" value="${r?"RGB":"RGBA"}" type="button" ${l(e.interaction.rgba)}>\n <input :arr="options" class="pcr-type" data-type="HSLA" value="${r?"HSL":"HSLA"}" type="button" ${l(e.interaction.hsla)}>\n <input :arr="options" class="pcr-type" data-type="HSVA" value="${r?"HSV":"HSVA"}" type="button" ${l(e.interaction.hsva)}>\n <input :arr="options" class="pcr-type" data-type="CMYK" value="CMYK" type="button" ${l(e.interaction.cmyk)}>\n\n <input :ref="save" class="pcr-save" value="${c("btn:save")}" type="button" ${l(e.interaction.save)} aria-label="${c("aria:btn:save")}">\n <input :ref="cancel" class="pcr-cancel" value="${c("btn:cancel")}" type="button" ${l(e.interaction.cancel)} aria-label="${c("aria:btn:cancel")}">\n <input :ref="clear" class="pcr-clear" value="${c("btn:clear")}" type="button" ${l(e.interaction.clear)} aria-label="${c("aria:btn:clear")}">\n </div>\n </div>\n </div>\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),[o,n]=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,o){if(!e.palette)return;const n=s(),{_root:r,options:a}=t,{lastColor:l,currentColor:c}=r.preview;t._recalc&&(n.s=100*i,n.v=100-100*o,n.v<0&&(n.v=0),t._updateOutput("slider"));const h=n.toRGBA().toString(0);this.element.style.background=h,this.wrapper.style.background=`\n linear-gradient(to top, rgba(0, 0, 0, ${n.a}), transparent),\n linear-gradient(to left, hsla(${n.h}, 100%, 50%, ${n.a}), rgba(255, 255, 255, ${n.a}))\n `,a.comparison?a.useAsButton||t._lastColor||l.style.setProperty("--pcr-color",h):(r.button.style.setProperty("--pcr-color",h),r.button.classList.remove("clear"));const d=n.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"===n?"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 o=s();t._recalc&&(o.h=360*i),this.element.style.backgroundColor=`hsl(${o.h}, 100%, 50%)`,r.palette.trigger()}}),opacity:E({lock:"v"===o?"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 o=s();t._recalc&&(o.a=Math.round(100*i)/100),this.element.style.background=`rgba(0, 0, 0, ${o.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=[n(t.interaction.clear,"click",()=>this._clearColor()),n([t.interaction.cancel,t.preview.lastColor],"click",()=>{this.setHSVA(...(this._lastColor||this._color).toHSVA(),!0),this._emit("cancel")}),n(t.interaction.save,"click",()=>{!this.applyColor()&&!e.showAlways&&this.hide()}),n(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()}),n(t.interaction.result,["focus","blur"],t=>{this._recalc="blur"===t.type,this._recalc&&this._updateOutput(null)}),n([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 o=e.closeWithKey;i.push(n(t.button,"click",()=>this.isOpen()?this.hide():this.show()),n(document,"keyup",t=>this.isOpen()&&(t.key===o||t.code===o)&&this.hide()),n(document,["touchstart","mousedown"],e=>{this.isOpen()&&!l(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,o)=>{const n=e[this.getColorRepresentation().toLowerCase()];if(n){const e=n[o],s=t+(e>=100?1e3*i:i);return s<=0?0:Number((s<e?s:e).toPrecision(3))}return t})}if(e.autoReposition&&!e.inline){let t=null;const o=this;i.push(n(window,["scroll","resize"],()=>{o.isOpen()&&(e.closeOnScroll&&o.hide(),null===t?(t=setTimeout(()=>t=null,100),requestAnimationFrame(function e(){o._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:o}=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(o.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:o}=k(t),{lockOpacity:n}=this.options,s=void 0!==o&&1!==o;return e&&3===e.length&&(e[3]=void 0),{values:!e||n&&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),o=1;o<e;o++)i[o-1]=arguments[o];this._eventListener[t].forEach(t=>t(...i,this))}on(t,e){return this._eventListener[t].push(e),this}off(t,e){const i=this._eventListener[t]||[],o=i.indexOf(e);return~o&&i.splice(o,1),this}addSwatch(t){const{values:e}=this._parseLocalColor(t);if(e){const{_swatchColors:t,_root:i}=this,o=S(...e),s=r(`<button type="button" style="--pcr-color: ${o.toRGBA().toString(0)}" aria-label="${this._t("btn:swatch")}"/>`);return i.swatches.appendChild(s),t.push({el:s,color:o}),this._eventBindings.push(n(s,"click",()=>{this.setHSVA(...o.toHSVA(),!0),this._emit("swatchselect",o),this._emit("change",o,"swatch",this)})),!0}return!1}removeSwatch(t){const e=this._swatchColors[t];if(e){const{el:i}=e;return this._root.swatches.removeChild(i),this._swatchColors.splice(t,1),!0}return!1}applyColor(){let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];const{preview:e,button:i}=this._root,o=this._color.toRGBA().toString(0);return e.lastColor.style.setProperty("--pcr-color",o),this.options.useAsButton||i.style.setProperty("--pcr-color",o),i.classList.remove("clear"),this._lastColor=this._color.clone(),this._initializingActive||t||this._emit("save",this._color),this}destroy(){cancelAnimationFrame(this._setupAnimationFrame),this._eventBindings.forEach(t=>s(...t)),Object.keys(this._components).forEach(t=>this._components[t].destroy())}destroyAndRemove(){this.destroy();const{root:t,app:e}=this._root;t.parentElement&&t.parentElement.removeChild(t),e.parentElement.removeChild(e),Object.keys(this).forEach(t=>this[t]=null)}hide(){return!!this.isOpen()&&(this._root.app.classList.remove("visible"),this._emit("hide"),!0)}show(){return!this.options.disabled&&!this.isOpen()&&(this._root.app.classList.add("visible"),this._rePositioningPicker(),this._emit("show",this._color),this)}isOpen(){return this._root.app.classList.contains("visible")}setHSVA(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:360,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1,n=arguments.length>4&&void 0!==arguments[4]&&arguments[4];const s=this._recalc;if(this._recalc=!1,t<0||t>360||e<0||e>100||i<0||i>100||o<0||o>1)return!1;this._color=S(t,e,i,o);const{hue:r,opacity:a,palette:l}=this._components;return r.update(t/360),a.update(o),l.update(e/100,1-i/100),n||this.applyColor(),s&&this._updateOutput(),this._recalc=s,!0}setColor(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(null===t)return this._clearColor(e),!0;const{values:i,type:o}=this._parseLocalColor(t);if(i){const t=o.toUpperCase(),{options:n}=this._root.interaction,s=n.find(e=>e.getAttribute("data-type")===t);if(s&&!s.hidden)for(const t of n)t.classList[t===s?"add":"remove"]("active");return!!this.setHSVA(...i,e)&&this.setColorRepresentation(t)}return!1}setColorRepresentation(t){return t=t.toUpperCase(),!!this._root.interaction.options.find(e=>e.getAttribute("data-type").startsWith(t)&&!e.click())}getColorRepresentation(){return this._representation}getColor(){return this._color}getSelectedColor(){return this._lastColor}getRoot(){return this._root}disable(){return this.hide(),this.options.disabled=!0,this._root.button.classList.add("disabled"),this}enable(){return this.options.disabled=!1,this._root.button.classList.remove("disabled"),this}}return D(O,"utils",i),D(O,"version","1.8.4"),D(O,"I18N_DEFAULTS",{"ui:dialog":"color picker dialog","btn:toggle":"toggle color picker dialog","btn:swatch":"color swatch","btn:last-color":"use previous color","btn:save":"Save","btn:cancel":"Cancel","btn:clear":"Clear","aria:btn:save":"save and close","aria:btn:cancel":"cancel and close","aria:btn:clear":"clear and close","aria:input":"color input field","aria:palette":"color selection area","aria:hue":"hue selection slider","aria:opacity":"selection slider"}),D(O,"DEFAULT_OPTIONS",{appClass:null,theme:"classic",useAsButton:!1,padding:8,disabled:!1,comparison:!0,closeOnScroll:!1,outputPrecision:0,lockOpacity:!1,autoReposition:!0,container:"body",components:{interaction:{}},i18n:{},swatches:null,inline:!1,sliders:null,default:"#42445a",defaultRepresentation:null,position:"bottom-middle",adjustableNumbers:!0,showAlways:!1,closeWithKey:"Escape"}),D(O,"create",t=>new O(t)),e.default})()}),Ic=Mc(Ac),Dc=[],Oc=[];!function(t,e){if(t&&"undefined"!=typeof document){var i,o=!0===e.prepend?"prepend":"append",n=!0===e.singleTag,s="string"==typeof e.container?document.querySelector(e.container):document.getElementsByTagName("head")[0];if(n){var r=Dc.indexOf(s);-1===r&&(r=Dc.push(s)-1,Oc[r]={}),i=Oc[r]&&Oc[r][o]?Oc[r][o]:Oc[r][o]=a()}else i=a();65279===t.charCodeAt(0)&&(t=t.substring(1)),i.styleSheet?i.styleSheet.cssText+=t:i.appendChild(document.createTextNode(t))}function a(){var t=document.createElement("style");if(t.setAttribute("type","text/css"),e.attributes)for(var i=Object.keys(e.attributes),n=0;n<i.length;n++)t.setAttribute(i[n],e.attributes[i[n]]);var r="prepend"===o?"afterbegin":"beforeend";return s.insertAdjacentElement(r,t),t}}('/*! Pickr 1.8.4 MIT | https://github.com/Simonwep/pickr */\n.pickr{position:relative;overflow:visible;transform:translateY(0)}.pickr *{box-sizing:border-box;outline:none;border:none;-webkit-appearance:none}.pickr .pcr-button{position:relative;height:2em;width:2em;padding:0.5em;cursor:pointer;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Roboto","Helvetica Neue",Arial,sans-serif;border-radius:.15em;background:url(\'data:image/svg+xml;utf8, <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 50 50" stroke="%2342445A" stroke-width="5px" stroke-linecap="round"><path d="M45,45L5,5"></path><path d="M45,5L5,45"></path></svg>\') no-repeat center;background-size:0;transition:all 0.3s}.pickr .pcr-button::before{position:absolute;content:\'\';top:0;left:0;width:100%;height:100%;background:url(\'data:image/svg+xml;utf8, <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 2 2"><path fill="white" d="M1,0H2V1H1V0ZM0,1H1V2H0V1Z"/><path fill="gray" d="M0,0H1V1H0V0ZM1,1H2V2H1V1Z"/></svg>\');background-size:.5em;border-radius:.15em;z-index:-1}.pickr .pcr-button::before{z-index:initial}.pickr .pcr-button::after{position:absolute;content:\'\';top:0;left:0;height:100%;width:100%;transition:background 0.3s;background:var(--pcr-color);border-radius:.15em}.pickr .pcr-button.clear{background-size:70%}.pickr .pcr-button.clear::before{opacity:0}.pickr .pcr-button.clear:focus{box-shadow:0 0 0 1px rgba(255,255,255,0.85),0 0 0 3px var(--pcr-color)}.pickr .pcr-button.disabled{cursor:not-allowed}.pickr *,.pcr-app *{box-sizing:border-box;outline:none;border:none;-webkit-appearance:none}.pickr input:focus,.pickr input.pcr-active,.pickr button:focus,.pickr button.pcr-active,.pcr-app input:focus,.pcr-app input.pcr-active,.pcr-app button:focus,.pcr-app button.pcr-active{box-shadow:0 0 0 1px rgba(255,255,255,0.85),0 0 0 3px var(--pcr-color)}.pickr .pcr-palette,.pickr .pcr-slider,.pcr-app .pcr-palette,.pcr-app .pcr-slider{transition:box-shadow 0.3s}.pickr .pcr-palette:focus,.pickr .pcr-slider:focus,.pcr-app .pcr-palette:focus,.pcr-app .pcr-slider:focus{box-shadow:0 0 0 1px rgba(255,255,255,0.85),0 0 0 3px rgba(0,0,0,0.25)}.pcr-app{position:fixed;display:flex;flex-direction:column;z-index:10000;border-radius:0.1em;background:#fff;opacity:0;visibility:hidden;transition:opacity 0.3s, visibility 0s 0.3s;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Roboto","Helvetica Neue",Arial,sans-serif;box-shadow:0 0.15em 1.5em 0 rgba(0,0,0,0.1),0 0 1em 0 rgba(0,0,0,0.03);left:0;top:0}.pcr-app.visible{transition:opacity 0.3s;visibility:visible;opacity:1}.pcr-app .pcr-swatches{display:flex;flex-wrap:wrap;margin-top:0.75em}.pcr-app .pcr-swatches.pcr-last{margin:0}@supports (display: grid){.pcr-app .pcr-swatches{display:grid;align-items:center;grid-template-columns:repeat(auto-fit, 1.75em)}}.pcr-app .pcr-swatches>button{font-size:1em;position:relative;width:calc(1.75em - 5px);height:calc(1.75em - 5px);border-radius:0.15em;cursor:pointer;margin:2.5px;flex-shrink:0;justify-self:center;transition:all 0.15s;overflow:hidden;background:transparent;z-index:1}.pcr-app .pcr-swatches>button::before{position:absolute;content:\'\';top:0;left:0;width:100%;height:100%;background:url(\'data:image/svg+xml;utf8, <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 2 2"><path fill="white" d="M1,0H2V1H1V0ZM0,1H1V2H0V1Z"/><path fill="gray" d="M0,0H1V1H0V0ZM1,1H2V2H1V1Z"/></svg>\');background-size:6px;border-radius:.15em;z-index:-1}.pcr-app .pcr-swatches>button::after{content:\'\';position:absolute;top:0;left:0;width:100%;height:100%;background:var(--pcr-color);border:1px solid rgba(0,0,0,0.05);border-radius:0.15em;box-sizing:border-box}.pcr-app .pcr-swatches>button:hover{filter:brightness(1.05)}.pcr-app .pcr-swatches>button:not(.pcr-active){box-shadow:none}.pcr-app .pcr-interaction{display:flex;flex-wrap:wrap;align-items:center;margin:0 -0.2em 0 -0.2em}.pcr-app .pcr-interaction>*{margin:0 0.2em}.pcr-app .pcr-interaction input{letter-spacing:0.07em;font-size:0.75em;text-align:center;cursor:pointer;color:#75797e;background:#f1f3f4;border-radius:.15em;transition:all 0.15s;padding:0.45em 0.5em;margin-top:0.75em}.pcr-app .pcr-interaction input:hover{filter:brightness(0.975)}.pcr-app .pcr-interaction input:focus{box-shadow:0 0 0 1px rgba(255,255,255,0.85),0 0 0 3px rgba(66,133,244,0.75)}.pcr-app .pcr-interaction .pcr-result{color:#75797e;text-align:left;flex:1 1 8em;min-width:8em;transition:all 0.2s;border-radius:.15em;background:#f1f3f4;cursor:text}.pcr-app .pcr-interaction .pcr-result::-moz-selection{background:#4285f4;color:#fff}.pcr-app .pcr-interaction .pcr-result::selection{background:#4285f4;color:#fff}.pcr-app .pcr-interaction .pcr-type.active{color:#fff;background:#4285f4}.pcr-app .pcr-interaction .pcr-save,.pcr-app .pcr-interaction .pcr-cancel,.pcr-app .pcr-interaction .pcr-clear{color:#fff;width:auto}.pcr-app .pcr-interaction .pcr-save,.pcr-app .pcr-interaction .pcr-cancel,.pcr-app .pcr-interaction .pcr-clear{color:#fff}.pcr-app .pcr-interaction .pcr-save:hover,.pcr-app .pcr-interaction .pcr-cancel:hover,.pcr-app .pcr-interaction .pcr-clear:hover{filter:brightness(0.925)}.pcr-app .pcr-interaction .pcr-save{background:#4285f4}.pcr-app .pcr-interaction .pcr-clear,.pcr-app .pcr-interaction .pcr-cancel{background:#f44250}.pcr-app .pcr-interaction .pcr-clear:focus,.pcr-app .pcr-interaction .pcr-cancel:focus{box-shadow:0 0 0 1px rgba(255,255,255,0.85),0 0 0 3px rgba(244,66,80,0.75)}.pcr-app .pcr-selection .pcr-picker{position:absolute;height:18px;width:18px;border:2px solid #fff;border-radius:100%;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.pcr-app .pcr-selection .pcr-color-palette,.pcr-app .pcr-selection .pcr-color-chooser,.pcr-app .pcr-selection .pcr-color-opacity{position:relative;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;display:flex;flex-direction:column;cursor:grab;cursor:-webkit-grab}.pcr-app .pcr-selection .pcr-color-palette:active,.pcr-app .pcr-selection .pcr-color-chooser:active,.pcr-app .pcr-selection .pcr-color-opacity:active{cursor:grabbing;cursor:-webkit-grabbing}.pcr-app[data-theme=\'nano\']{width:14.25em;max-width:95vw}.pcr-app[data-theme=\'nano\'] .pcr-swatches{margin-top:.6em;padding:0 .6em}.pcr-app[data-theme=\'nano\'] .pcr-interaction{padding:0 .6em .6em .6em}.pcr-app[data-theme=\'nano\'] .pcr-selection{display:grid;grid-gap:.6em;grid-template-columns:1fr 4fr;grid-template-rows:5fr auto auto;align-items:center;height:10.5em;width:100%;align-self:flex-start}.pcr-app[data-theme=\'nano\'] .pcr-selection .pcr-color-preview{grid-area:2 / 1 / 4 / 1;height:100%;width:100%;display:flex;flex-direction:row;justify-content:center;margin-left:.6em}.pcr-app[data-theme=\'nano\'] .pcr-selection .pcr-color-preview .pcr-last-color{display:none}.pcr-app[data-theme=\'nano\'] .pcr-selection .pcr-color-preview .pcr-current-color{position:relative;background:var(--pcr-color);width:2em;height:2em;border-radius:50em;overflow:hidden}.pcr-app[data-theme=\'nano\'] .pcr-selection .pcr-color-preview .pcr-current-color::before{position:absolute;content:\'\';top:0;left:0;width:100%;height:100%;background:url(\'data:image/svg+xml;utf8, <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 2 2"><path fill="white" d="M1,0H2V1H1V0ZM0,1H1V2H0V1Z"/><path fill="gray" d="M0,0H1V1H0V0ZM1,1H2V2H1V1Z"/></svg>\');background-size:.5em;border-radius:.15em;z-index:-1}.pcr-app[data-theme=\'nano\'] .pcr-selection .pcr-color-palette{grid-area:1 / 1 / 2 / 3;width:100%;height:100%;z-index:1}.pcr-app[data-theme=\'nano\'] .pcr-selection .pcr-color-palette .pcr-palette{border-radius:.15em;width:100%;height:100%}.pcr-app[data-theme=\'nano\'] .pcr-selection .pcr-color-palette .pcr-palette::before{position:absolute;content:\'\';top:0;left:0;width:100%;height:100%;background:url(\'data:image/svg+xml;utf8, <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 2 2"><path fill="white" d="M1,0H2V1H1V0ZM0,1H1V2H0V1Z"/><path fill="gray" d="M0,0H1V1H0V0ZM1,1H2V2H1V1Z"/></svg>\');background-size:.5em;border-radius:.15em;z-index:-1}.pcr-app[data-theme=\'nano\'] .pcr-selection .pcr-color-chooser{grid-area:2 / 2 / 2 / 2}.pcr-app[data-theme=\'nano\'] .pcr-selection .pcr-color-opacity{grid-area:3 / 2 / 3 / 2}.pcr-app[data-theme=\'nano\'] .pcr-selection .pcr-color-chooser,.pcr-app[data-theme=\'nano\'] .pcr-selection .pcr-color-opacity{height:0.5em;margin:0 .6em}.pcr-app[data-theme=\'nano\'] .pcr-selection .pcr-color-chooser .pcr-picker,.pcr-app[data-theme=\'nano\'] .pcr-selection .pcr-color-opacity .pcr-picker{top:50%;transform:translateY(-50%)}.pcr-app[data-theme=\'nano\'] .pcr-selection .pcr-color-chooser .pcr-slider,.pcr-app[data-theme=\'nano\'] .pcr-selection .pcr-color-opacity .pcr-slider{flex-grow:1;border-radius:50em}.pcr-app[data-theme=\'nano\'] .pcr-selection .pcr-color-chooser .pcr-slider{background:linear-gradient(to right, red, #ff0, lime, cyan, blue, #f0f, red)}.pcr-app[data-theme=\'nano\'] .pcr-selection .pcr-color-opacity .pcr-slider{background:linear-gradient(to right, transparent, black),url(\'data:image/svg+xml;utf8, <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 2 2"><path fill="white" d="M1,0H2V1H1V0ZM0,1H1V2H0V1Z"/><path fill="gray" d="M0,0H1V1H0V0ZM1,1H2V2H1V1Z"/></svg>\');background-size:100%, 0.25em}\n\n',{});class Bc extends t.Modal{constructor(t,e,i){if(super(t),this.plugin=e,this.commandIndex=i,null!==i){const t=e.settings.customCommands[i];this.commandId=t.id,this.commandName=t.name,this.icon=t.icon||"",this.regexPattern=t.regexPattern||"",this.regexReplacement=t.regexReplacement||"",this.regexCaseInsensitive=t.regexCaseInsensitive||!1,this.regexGlobal=!1!==t.regexGlobal,this.regexMultiline=t.regexMultiline||!1,this.useCondition=t.useCondition||!1,this.conditionPattern=t.conditionPattern||""}else this.commandId="",this.commandName="",this.icon="",this.regexPattern="",this.regexReplacement="",this.regexCaseInsensitive=!1,this.regexGlobal=!0,this.regexMultiline=!1,this.useCondition=!1,this.conditionPattern=""}onOpen(){const{contentEl:e}=this;this.modalEl.addClass("custom-commands-modal"),e.empty(),e.createEl("h2",{text:null!==this.commandIndex?Jr("Edit regular expression command"):Jr("Add regular expression command")});const i=e.createDiv("basic-settings-container");new t.Setting(i).setName(Jr("Command ID")).setDesc(Jr('Unique identifier, no spaces, e.g.: "my-custom-format"')).addText(t=>(t.setValue(this.commandId),null!==this.commandIndex?(t.setDisabled(!0),t.inputEl.addClass("id-is-disabled")):t.onChange(t=>{this.commandId=t;const i=e.querySelector(".setting-item:nth-child(2) input");i instanceof HTMLInputElement&&(i.value=t,this.commandName=t)}),t)),new t.Setting(i).setName(Jr("Command Name")).setDesc(Jr("Displayed name in toolbar and menu")).addText(t=>t.setValue(this.commandName).onChange(t=>this.commandName=t));const o=e.createDiv("regex-settings");o.style.border="1px solid var(--background-modifier-border)",o.style.padding="10px",o.style.borderRadius="5px",o.style.marginBottom="10px";const n=o.createEl("details",{cls:"ai-help-container"});n.style.marginBottom="10px",n.style.borderRadius="5px",n.style.overflow="hidden";const s=n.createEl("summary",{text:Jr("How to use AI to get regular expressions?")});s.style.padding="8px 12px",s.style.backgroundColor="var(--background-secondary)",s.style.cursor="pointer",s.style.fontWeight="bold",s.style.borderRadius="4px",s.style.userSelect="none";const r=n.createDiv("ai-help-content");r.style.padding="6px",r.style.backgroundColor="var(--background-secondary-alt)",r.style.borderBottomLeftRadius="5px",r.style.borderBottomRightRadius="5px",r.style.marginTop="1px",r.setAttribute("contenteditable","false"),r.style.userSelect="text",r.innerHTML=`\n <p><strong>${Jr("AI question template:")}</strong><br>\n ${Jr("[Description]")}:\n ${Jr("I need to convert the url to a markdown format link")}\n <br>\n ${Jr("[Example]")}: \n ${Jr("For example, convert https://example.com to [https://example.com](https://example.com)")}\n <br>\n ${Jr("[Requirements]")}: \n ${Jr("Use js regular expression to implement, and output the parameters in the following format (the result does not need to be escaped with json)")}\n <br>\n ${Jr("[Output]")}:\n <br>\n "name": "[Descriptive Name]", <br>\n "pattern": "[Regex Pattern]", <br>\n "replacement": "[Replacement Pattern, if applicable]", <br>\n "flags": "[Regex Flags]" <br>\n </p>\n `,new t.Setting(o).setName(Jr("Matching pattern")).setDesc(Jr("Regex pattern to match")).addText(t=>this.regexPatternInput=t.setValue(this.regexPattern).onChange(t=>{this.regexPattern=t,this.updatePreview()})),new t.Setting(o).setName(Jr("Replacement pattern")).setDesc(Jr("Replacement pattern (use $1, $2, etc. to reference capture groups)")+Jr("Use \\n to represent line breaks")).addText(t=>this.regexReplacementInput=t.setValue(this.regexReplacement.replace(/\n/g,"\\n")).onChange(t=>{this.regexReplacement=t.replace(/\\n/g,"\n"),this.updatePreview()}));const a=o.createDiv("regex-options");a.style.display="flex",a.style.gap="8px",new t.Setting(a).setName(Jr("Ignore case")).setDesc(Jr("Match case-insensitive")).addToggle(t=>t.setValue(this.regexCaseInsensitive).onChange(t=>{this.regexCaseInsensitive=t,this.updatePreview()})),new t.Setting(a).setName(Jr("Global replace")).setDesc(Jr("Replace all matches")).addToggle(t=>t.setValue(this.regexGlobal).onChange(t=>{this.regexGlobal=t,this.updatePreview()})),new t.Setting(a).setName(Jr("Multiline mode")).setDesc(Jr("^ and $ match the start and end of each line")).addToggle(t=>this.regexMultilineToggle=t.setValue(this.regexMultiline).onChange(t=>{this.regexMultiline=t,this.updatePreview()}));const l=o.createDiv("condition-container");new t.Setting(l).setName(Jr("Use condition")).setDesc(Jr("Only apply custom command when text matches the condition")).addToggle(t=>this.useConditionToggle=t.setValue(this.useCondition).onChange(t=>{this.useCondition=t,c.style.display=t?"block":"none"}));const c=l.createDiv("condition-settings");c.style.display=this.useCondition?"block":"none",c.style.border="1px solid var(--background-modifier-border)",c.style.padding="10px",c.style.borderRadius="5px",c.style.marginBottom="15px",new t.Setting(c).setName(Jr("Condition pattern")).setDesc(Jr("Must exist regular expression or text")).addText(t=>this.conditionPatternInput=t.setValue(this.conditionPattern).onChange(t=>{this.conditionPattern=t}));const h=new t.Setting(o).setName(Jr("Icon")).setDesc(Jr("Command icon (click to select)"));if(this.iconDisplay=h.controlEl.createDiv("editingToolbarSettingsIcon"),this.icon)try{t.setIcon(this.iconDisplay,this.icon)}catch(t){this.iconDisplay.setText(this.icon)}h.addButton(e=>e.setButtonText(Jr("Choose icon")).onClick(()=>{const e={id:this.commandId,name:this.commandName,icon:this.icon};new Xr(this.plugin,e,!1,e=>{if(this.icon=e,this.iconDisplay.empty(),this.icon)try{t.setIcon(this.iconDisplay,this.icon)}catch(t){this.iconDisplay.setText(this.icon)}const i=h.controlEl.querySelector("input");i&&(i.value=this.icon)}).open()})),o.createSpan("regex-help");const d=o.createEl("details",{cls:"regex-examples-container"});d.style.marginTop="15px",d.style.borderRadius="5px",d.style.overflow="hidden";const u=d.createEl("summary",{text:Jr("Regular expression examples")});u.style.padding="8px 12px",u.style.backgroundColor="var(--background-secondary)",u.style.cursor="pointer",u.style.fontWeight="bold",u.style.borderRadius="4px",u.style.userSelect="none";const p=d.createDiv("examples-content");p.style.padding="10px",p.style.backgroundColor="var(--background-secondary-alt)",p.style.borderBottomLeftRadius="5px",p.style.borderBottomRightRadius="5px",p.style.marginTop="1px";const m=p.createEl("ul");m.style.paddingLeft="20px",m.style.margin="0";[{name:Jr("URL to Markdown link"),pattern:"(https?://\\S+)",replacement:"[$1]($1)"},{name:Jr("Convert MM/DD/YYYY to YYYY-MM-DD"),pattern:"(\\d{1,2})/(\\d{1,2})/(\\d{4})",replacement:"$3-$1-$2"},{name:Jr("Add bold to keywords"),pattern:"\\b(important|critical|urgent)\\b",replacement:"**$1**"},{name:Jr("Format phone number"),pattern:"(\\d{3})(\\d{3})(\\d{4})",replacement:"($1) $2-$3"},{name:Jr("Remove extra spaces"),pattern:"\\s{2,}",replacement:" "},{name:Jr("Convert HTML bold tags to Markdown format"),pattern:"<strong>(.*?)</strong>",replacement:"**$1**"},{name:Jr("Convert quoted text to quote block"),pattern:'"([^"]+)"',replacement:"> $1"},{name:Jr("Add uniform alias to Markdown links"),pattern:"\\[([^\\]]+)\\]\\(([^\\)]+)\\)",replacement:"[$1|alias]($2)"},{name:Jr("Delete empty lines (multiline mode)"),pattern:"^\\s*$\\n",replacement:"",toggleMultiline:!0},{name:Jr("Add list symbol to each line (multiline mode)"),pattern:"^(.+)$",replacement:"- $1",toggleMultiline:!0},{name:Jr("If the text contains important, set the text highlight (conditional format)"),pattern:"(.+)",replacement:"==$1==",useCondition:!0,conditionPattern:"important"}].forEach(t=>{const e=m.createEl("li");e.style.marginBottom="8px";const i=e.createEl("a",{text:t.name,href:"#"});i.style.color="var(--text-accent)",i.style.textDecoration="none",i.addEventListener("mouseenter",()=>{i.style.textDecoration="underline"}),i.addEventListener("mouseleave",()=>{i.style.textDecoration="none"}),i.addEventListener("click",e=>{e.preventDefault(),this.regexPattern=t.pattern,this.regexReplacement=t.replacement,this.regexPatternInput.setValue(t.pattern),this.regexReplacementInput.setValue(t.replacement),t.useCondition?(this.useCondition=!0,this.conditionPattern=t.conditionPattern||"",this.useConditionToggle.setValue(!0),this.conditionPatternInput.setValue(this.conditionPattern),c.style.display="block"):(this.useCondition=!1,this.useConditionToggle.setValue(!1),this.conditionPatternInput.setValue(""),c.style.display="none"),t.toggleMultiline?this.regexMultilineToggle.setValue(!0):this.regexMultilineToggle.setValue(!1),this.updatePreview(),d.removeAttribute("open")})});const g=e.createDiv("preview-container");g.style.marginTop="20px",g.style.marginBottom="20px",g.style.border="1px solid var(--background-modifier-border)",g.style.padding="10px",g.style.borderRadius="5px",g.createEl("label",{text:Jr("Preview")});const f=g.createDiv("preview-input-container");f.style.marginBottom="10px";const b=f.createEl("label",{text:Jr("Example text:")});b.style.display="block",b.style.marginBottom="5px",this.previewInput=f.createEl("textarea",{attr:{placeholder:Jr("Input example text to view the formatting effect of the command...")}}),this.previewInput.style.height="auto",this.previewInput.style.width="100%",this.previewInput.style.padding="8px",this.previewInput.style.borderRadius="4px",this.previewInput.style.border="1px solid var(--background-modifier-border)",this.previewInput.value="Sample text https://example.com important text 1234567890",this.previewInput.addEventListener("input",()=>{this.updatePreview()});const y=g.createDiv("preview-output-container"),v=y.createEl("label",{text:Jr("Result: ")});v.style.display="block",v.style.marginBottom="5px",this.previewOutput=y.createDiv("preview-output"),this.previewOutput.style.padding="8px",this.previewOutput.style.borderRadius="4px",this.previewOutput.style.border="1px solid var(--background-modifier-border)",this.previewOutput.style.backgroundColor="var(--background-secondary)",this.previewOutput.style.minHeight="3em",this.updatePreview(),new t.Setting(e).addButton(e=>e.setButtonText("保存").setCta().onClick(()=>{if(!this.commandId||!this.commandName)return void new t.Notice(Jr("Command ID and command name cannot be empty"));if(this.commandId.includes(" "))return void new t.Notice(Jr("Command ID cannot contain spaces"));if(!this.regexPattern)return void new t.Notice(Jr("Regex pattern cannot be empty"));const e=null===this.commandIndex?`custom-${this.commandId}`:this.commandId;if(null===this.commandIndex){if(this.plugin.settings.customCommands.findIndex(t=>t.id===e)>=0)return void new t.Notice(Jr("Command")+" "+this.commandId+" "+Jr("already exists"),8e3)}const i={id:e,name:this.commandName,icon:this.icon,useRegex:!0,regexPattern:this.regexPattern,regexReplacement:this.regexReplacement.replace(/\\n/g,"\n"),regexCaseInsensitive:this.regexCaseInsensitive,regexGlobal:this.regexGlobal,regexMultiline:this.regexMultiline,useCondition:this.useCondition,conditionPattern:this.conditionPattern,prefix:"",suffix:"",char:0,line:0,islinehead:!1};null!==this.commandIndex?this.plugin.settings.customCommands[this.commandIndex]=i:this.plugin.settings.customCommands.push(i),this.plugin.saveSettings().then(()=>{this.close(),setTimeout(()=>{dispatchEvent(new Event("editingToolbar-NewCommand")),this.plugin.reloadCustomCommands()},100)})})).addButton(t=>t.setButtonText(Jr("Cancel")).onClick(()=>this.close()))}onClose(){const{contentEl:t}=this;t.empty()}updatePreview(){var t;const e=this.previewInput.value;let i=e;try{if(this.regexPattern){let t="";this.regexGlobal&&(t+="g"),this.regexCaseInsensitive&&(t+="i"),this.regexMultiline&&(t+="m");const o=new RegExp(this.regexPattern,t),n=this.regexReplacement.replace(/\\n/g,"\n");i=e.replace(o,n),this.showCompleteRegexCode(t)}this.previewOutput.empty(),i.split("\n").forEach((t,e,i)=>{this.previewOutput.createSpan({text:t}),e<i.length-1&&this.previewOutput.createEl("br")}),this.previewOutput.style.color="var(--text-normal)"}catch(e){this.previewOutput.setText(Jr("Error: ")+e.message),this.previewOutput.style.color="var(--text-error)";const i=null===(t=this.previewOutput.parentElement)||void 0===t?void 0:t.querySelector(".regex-code-container");i&&i.remove()}}showCompleteRegexCode(t){const e=this.previewOutput.parentElement;if(!e)return;let i=e.querySelector(".regex-code-container");if(i){i.empty();const t=i.createEl("div",{text:Jr("Complete regular expression code (copy to AI for explanation)")});t.style.marginBottom="5px",t.style.fontWeight="bold"}else{i=e.createDiv("regex-code-container"),i.style.marginTop="15px",i.style.borderTop="1px solid var(--background-modifier-border)",i.style.paddingTop="10px";const t=i.createEl("div",{text:Jr("Complete regular expression code (copy to AI for explanation)")});t.style.marginBottom="5px",t.style.fontWeight="bold"}const o=i.createEl("pre");o.style.backgroundColor="var(--background-code)",o.style.padding="8px",o.style.borderRadius="4px",o.style.overflowX="auto",o.style.fontFamily="monospace",o.style.fontSize="var(--font-smaller)";let n=`//${Jr("Explain the syntax of JavaScript regular expressions")}\n`;n+=`const regex = /${this.escapeRegexForDisplay(this.regexPattern)}/${t};\n`,n+=`const result = text.replace(regex, "${this.escapeStringForDisplay(this.regexReplacement)}");\n`,this.useCondition&&this.conditionPattern&&(n+=`\n//${Jr("Conditional matching")}\n`,n+=`const condition = /${this.escapeRegexForDisplay(this.conditionPattern)}/;\n`,n+="if (condition.test(text)) {\n",n+=` //${Jr("Apply regular expression replacement")}\n`,n+=` const result = text.replace(regex, "${this.escapeStringForDisplay(this.regexReplacement)}");\n`,n+="}"),o.textContent=n;const s=i.createEl("button",{text:Jr("Copy code")});s.style.marginTop="5px",s.style.padding="4px 8px",s.style.borderRadius="4px",s.style.cursor="pointer",s.addEventListener("click",()=>{navigator.clipboard.writeText(n).then(()=>{s.textContent=Jr("Copied!"),setTimeout(()=>{s.textContent=Jr("Copy code")},2e3)}).catch(t=>{console.error("Failed to copy code: ",t)})})}escapeRegexForDisplay(t){return t.replace(/\\/g,"\\\\")}escapeStringForDisplay(t){return t.replace(/"/g,'\\"')}}class Lc extends t.Modal{constructor(t,e,i){if(super(t),this.plugin=e,this.commandIndex=i,null!==i){const t=e.settings.customCommands[i];this.commandId=t.id,this.commandName=t.name,this.prefix=t.prefix,this.suffix=t.suffix,this.char=t.char,this.line=t.line,this.islinehead=t.islinehead,this.icon=t.icon||""}else this.commandId="",this.commandName="",this.prefix="",this.suffix="",this.char=0,this.line=0,this.islinehead=!1,this.icon=""}onOpen(){const{contentEl:e}=this;this.modalEl.addClass("custom-commands-modal"),e.empty(),e.createEl("h2",{text:null!==this.commandIndex?Jr("Edit Custom Command"):Jr("Add Custom Command")});const i=e.createDiv("switch-to-regex-container");i.style.marginBottom="20px",i.style.textAlign="center";const o=i.createEl("button",{text:Jr("Switch Regex Command Window")});o.addClass("mod-cta"),o.addEventListener("click",()=>{this.close(),new Bc(this.app,this.plugin,null).open()}),new t.Setting(e).setName(Jr("Command ID")).setDesc(Jr('Unique identifier, no spaces, e.g.: "my-custom-format"')).addText(t=>(this.commandIdInput=t,t.setValue(this.commandId),null!==this.commandIndex?(t.setDisabled(!0),t.inputEl.addClass("id-is-disabled")):t.onChange(t=>{this.commandId=t,this.commandNameInput&&(this.commandNameInput.setValue(t),this.commandName=t)}),t)),new t.Setting(e).setName(Jr("Command Name")).setDesc(Jr("Displayed name in toolbar and menu")).addText(t=>this.commandNameInput=t.setValue(this.commandName).onChange(t=>this.commandName=t));const n={"\n":"↵","\t":"⇥"},s=Object.fromEntries(Object.entries(n).map(([t,e])=>[e,t]));function r(t){let e=t;for(const[t,i]of Object.entries(n))e=e.replace(new RegExp(t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"g"),i);return e}function a(t){let e=t;for(const[t,i]of Object.entries(s))e=e.replace(new RegExp(t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"g"),i);return e}const l=Object.entries(n).map(([t,e])=>{let i=e;switch(t){case"\n":i+=" (New Line)";break;case"\t":i+=" (Tab)"}return{placeholder:e,label:i}});function c(t,e){e.setAttribute("title","点击可选择并复制文本");const i=t.controlEl.createDiv({cls:"special-char-buttons"});i.style.display="flex",i.style.flexWrap="wrap",i.style.gap="5px",i.style.marginTop="5px",l.forEach(({placeholder:t,label:e})=>{const o=i.createDiv({cls:"char-copy-container"});o.style.position="relative",o.style.display="inline-block";const n=o.createEl("button",{text:e});n.style.padding="2px 6px",n.style.fontSize="12px",n.style.minWidth="auto",n.style.border="1px solid var(--background-modifier-border)",n.style.cursor="pointer",n.setAttribute("data-char",t),n.addEventListener("click",e=>{e.preventDefault(),navigator.clipboard.writeText(t).then(()=>{const t=o.createDiv({cls:"copy-tooltip"});t.style.position="absolute",t.style.bottom="100%",t.style.left="50%",t.style.transform="translateX(-50%)",t.style.backgroundColor="var(--background-modifier-success)",t.style.color="white",t.style.padding="2px 6px",t.style.borderRadius="4px",t.style.fontSize="12px",t.style.pointerEvents="none",t.style.whiteSpace="nowrap",t.style.zIndex="100",t.textContent="已复制!",setTimeout(()=>{t.remove()},2e3)}).catch(t=>{console.error("无法复制文本: ",t)})}),n.addEventListener("mouseenter",()=>{n.style.backgroundColor="var(--interactive-accent)",n.style.color="var(--text-on-accent)"}),n.addEventListener("mouseleave",()=>{n.style.backgroundColor="",n.style.color=""})})}const h=new t.Setting(e).setName(Jr("Prefix")).setDesc(Jr("Add content before selected text")+Jr("Use ↵ to represent line breaks")).addText(t=>t.setValue(r(this.prefix)).onChange(t=>{this.prefix=a(t);const e=this.getMirrorText(t);e&&(this.suffix=a(e),this.suffixInput.setValue(e))}));c(h,h.controlEl.querySelector("input"));const d=new t.Setting(e).setName(Jr("Suffix")).setDesc(Jr("Add content after selected text")).addText(t=>{this.suffixInput=t,t.setValue(r(this.suffix)).onChange(t=>{this.suffix=a(t)})});c(d,d.controlEl.querySelector("input")),new t.Setting(e).setName(Jr("Cursor Position Offset")).setDesc(Jr("Default 0, format will keep the text selected")).addText(t=>t.setValue(this.char.toString()).onChange(t=>this.char=parseInt(t)||0)),new t.Setting(e).setName(Jr("Line Offset")).setDesc(Jr("Line offset of cursor after formatting")).addText(t=>t.setValue(this.line.toString()).onChange(t=>this.line=parseInt(t)||0)),new t.Setting(e).setName(Jr("Line Head Format")).setDesc(Jr("Whether to insert at the beginning of the next line")).addToggle(t=>t.setValue(this.islinehead).onChange(t=>this.islinehead=t));const u=new t.Setting(e).setName(Jr("Icon")).setDesc(Jr("Command icon (click to select)"));if(this.iconDisplay=u.controlEl.createDiv("editingToolbarSettingsIcon"),this.icon)try{t.setIcon(this.iconDisplay,this.icon)}catch(t){this.iconDisplay.setText(this.icon)}u.addButton(e=>e.setButtonText(Jr("Choose Icon")).onClick(()=>{const e={id:this.commandId,name:this.commandName,icon:this.icon};new Xr(this.plugin,e,!1,e=>{if(this.icon=e,this.iconDisplay.empty(),this.icon)try{t.setIcon(this.iconDisplay,this.icon)}catch(t){this.iconDisplay.setText(this.icon)}const i=u.controlEl.querySelector("input");i&&(i.value=this.icon)}).open()})),new t.Setting(e).addButton(e=>e.setButtonText(Jr("Save")).setCta().onClick(()=>{if(!this.commandId||!this.commandName)return void new t.Notice(Jr("Command ID and command name cannot be empty"));if(this.commandId.includes(" "))return void new t.Notice(Jr("Command ID cannot contain spaces"));const e=null===this.commandIndex?`custom-${this.commandId}`:this.commandId;if(null===this.commandIndex){if(this.plugin.settings.customCommands.findIndex(t=>t.id===e)>=0)return void new t.Notice(Jr("The command")+this.commandId+Jr("already exists"),8e3)}const i={id:e,name:this.commandName,prefix:this.prefix,suffix:this.suffix,char:this.char,line:this.line,islinehead:this.islinehead,icon:this.icon};if(null!==this.commandIndex){if(this.plugin.settings.customCommands[this.commandIndex].icon!==this.icon){const t=`editing-toolbar:${e}`;this.updateCommandIcon(this.plugin.settings.menuCommands,t),this.plugin.settings.enableMultipleConfig&&(this.updateCommandIcon(this.plugin.settings.followingCommands,t),this.updateCommandIcon(this.plugin.settings.topCommands,t),this.updateCommandIcon(this.plugin.settings.fixedCommands,t),this.plugin.settings.isLoadOnMobile&&this.updateCommandIcon(this.plugin.settings.mobileCommands,t))}this.plugin.settings.customCommands[this.commandIndex]=i}else this.plugin.settings.customCommands.push(i);this.plugin.saveSettings().then(()=>{this.close(),setTimeout(()=>{dispatchEvent(new Event("editingToolbar-NewCommand")),this.plugin.reloadCustomCommands()},100)})})).addButton(t=>t.setButtonText(Jr("Cancel")).onClick(()=>this.close())),setTimeout(()=>{this.commandIndex?this.commandIdInput.inputEl.focus():this.commandNameInput.inputEl.focus()},10)}updateCommandIcon(t,e){t&&t.forEach(t=>{t.id===e&&(t.icon=this.icon),t.SubmenuCommands&&this.updateCommandIcon(t.SubmenuCommands,e)})}onClose(){const{contentEl:t}=this;t.empty()}getMirrorText(t){const e={"**":"**","*":"*",__:"__",_:"_","~~":"~~","`":"`","```":"```",$:"$",$$:"$$","(":")","[":"]","{":"}","<":">","==":"==","*==":"==*","**==":"==**","***==":"==***"};if(!t)return"";if(t in e)return e[t];const i=t.match(/^<(\w+)([^>]*)>$/);return i?`</${i[1]}>`:""}}class Nc extends t.Modal{constructor(t,e,i){super(t),this.deployOptions=[],this.plugin=e,this.command=i,this.deployOptions=[{id:"following",name:Jr("Following Style"),enabled:!0},{id:"top",name:Jr("Top Style"),enabled:!0},{id:"fixed",name:Jr("Fixed Style"),enabled:!0}],this.plugin.settings.isLoadOnMobile&&this.deployOptions.push({id:"mobile",name:Jr("Mobile Style"),enabled:!0})}onOpen(){const{contentEl:e}=this;e.empty(),e.createEl("h3",{text:Jr("Deploy command to configurations")}),e.createDiv("deploy-option");const i=e.createDiv("deploy-options");this.deployOptions.forEach(e=>{new t.Setting(i).setName(e.name).addToggle(t=>t.setValue(e.enabled).onChange(t=>{e.enabled=t})).settingEl.addClass("deploy-option")});const o=e.createDiv("deploy-buttons");new t.Setting(o).addButton(t=>t.setButtonText(Jr("Deploy")).setCta().onClick(()=>{this.deployCommand(),this.close()})).addButton(t=>t.setButtonText(Jr("Cancel")).onClick(()=>{this.close()}))}deployCommand(){const e={id:`editing-toolbar:${this.command.id}`,name:this.command.name,icon:this.command.icon||"obsidian-new"};this.plugin.settings.menuCommands.some(t=>t.id===e.id)||this.plugin.settings.menuCommands.push(Object.assign({},e));let i=0;this.deployOptions.forEach(t=>{if(t.enabled){let o;switch(t.id){case"mobile":o=this.plugin.settings.mobileCommands;break;case"following":o=this.plugin.settings.followingCommands;break;case"top":o=this.plugin.settings.topCommands;break;case"fixed":o=this.plugin.settings.fixedCommands}o&&!o.some(t=>t.id===e.id)&&(o.push(Object.assign({},e)),i++)}}),this.plugin.saveSettings().then(()=>{let e="";if(i>0){const t=this.deployOptions.filter(t=>t.enabled).map(t=>t.name).join(", ");e=Jr("Command deployed to: ")+t}else e=Jr("Command already exists in selected configurations");new t.Notice(e),dispatchEvent(new Event("editingToolbar-NewCommand")),this.plugin.reloadCustomCommands()})}}class qc extends t.Modal{constructor(t,e,i){super(t),this.plugin=e,this.mode=i,this.exportType="all",this.importMode="update"}onOpen(){const{contentEl:e}=this;if(e.addClass("editing-toolbar-import-export-modal"),e.createEl("h2",{text:"import"===this.mode?Jr("Import Configuration"):Jr("Export Configuration"),cls:"import-export-title"}),"export"===this.mode){new t.Setting(e).setName(Jr("Export Type")).setDesc(Jr("Choose what to export")).addDropdown(t=>{t.addOption("all",Jr("All Settings")).addOption("All commands",Jr("All Toolbar Commands")).addOption("custom",Jr("Custom Commands Only")),this.plugin.settings.enableMultipleConfig&&t.addOption("following",Jr("Following Style Only")).addOption("top",Jr("Top Style Only")).addOption("fixed",Jr("Fixed Style Only")).addOption("mobile",Jr("Mobile Style Only")),t.setValue(this.exportType).onChange(t=>{this.exportType=t,this.updateExportContent()})});const i=e.createDiv("export-container");i.style.border="1px solid var(--background-modifier-border)",i.style.padding="10px",i.style.borderRadius="5px",this.textArea=new t.TextAreaComponent(i),this.textArea.setValue("").setPlaceholder(Jr("Loading...")).then(t=>{t.inputEl.style.width="100%",t.inputEl.style.height="200px",t.inputEl.style.fontFamily="monospace",t.inputEl.style.fontSize="12px",t.inputEl.style.padding="8px",t.inputEl.style.border="1px solid var(--background-modifier-border)",t.inputEl.style.borderRadius="4px"}),this.updateExportContent();const o=e.createDiv("import-export-button-container");o.style.display="flex",o.style.justifyContent="flex-end",o.style.marginTop="16px";o.createEl("button",{text:Jr("Copy to Clipboard"),cls:"mod-cta"}).addEventListener("click",()=>{navigator.clipboard.writeText(this.textArea.getValue()).then(()=>{new t.Notice(Jr("Configuration copied to clipboard"))}).catch(e=>{console.error("Failed to copy: ",e),new t.Notice(Jr("Failed to copy configuration"))})})}else{new t.Setting(e).setName(Jr("Import Mode")).setDesc(Jr("Choose how to import the configuration")).addDropdown(t=>{t.addOption("update",Jr("Update Mode (Add new items and update existing ones)")).addOption("overwrite",Jr("Overwrite Mode (Replace settings with imported ones)")).setValue(this.importMode).onChange(t=>{this.importMode=t,this.importButton.setButtonText("overwrite"===this.importMode?Jr("Overwrite Import"):Jr("Update Import")),this.warningContent.setText("overwrite"===this.importMode?Jr("Warning: Overwrite mode will replace existing settings with imported ones."):Jr("Warning: Update mode will add new items and update existing ones."))})});const i=e.createDiv("import-container");i.style.border="1px solid var(--background-modifier-border)",i.style.padding="10px",i.style.borderRadius="5px",this.textArea=new t.TextAreaComponent(i),this.textArea.setValue("").setPlaceholder(Jr("Paste configuration here...")).then(t=>{t.inputEl.style.width="100%",t.inputEl.style.height="200px",t.inputEl.style.fontFamily="monospace",t.inputEl.style.fontSize="12px",t.inputEl.style.padding="8px",t.inputEl.style.border="1px solid var(--background-modifier-border)",t.inputEl.style.borderRadius="4px"});const o=e.createDiv("import-export-button-container");o.style.display="flex",o.style.justifyContent="flex-end",o.style.marginTop="16px",new t.Setting(o).addButton(t=>{this.importButton=t.setIcon("import").setButtonText(Jr("Import Configuration")).onClick(()=>{this.importConfiguration()})});const n=e.createDiv("import-export-warning");n.style.marginTop="16px",n.style.padding="8px 12px",n.style.backgroundColor="rgba(var(--color-red-rgb), 0.1)",n.style.borderRadius="4px",n.style.border="1px solid rgba(var(--color-red-rgb), 0.3)";const s=n.createEl("p",{text:Jr("Warning: Update mode will add new items and update existing ones."),cls:"warning-text"});s.style.margin="0",this.warningContent=s}}updateExportContent(){let t={_exportInfo:{version:this.plugin.manifest.version,exportType:this.exportType,exportTime:(new Date).toISOString(),pluginId:this.plugin.manifest.id}};switch(this.exportType){case"all":t=Object.assign(Object.assign({},t),{menuCommands:this.plugin.settings.menuCommands||[],followingCommands:this.plugin.settings.followingCommands||[],topCommands:this.plugin.settings.topCommands||[],fixedCommands:this.plugin.settings.fixedCommands||[],mobileCommands:this.plugin.settings.mobileCommands||[],customCommands:this.plugin.settings.customCommands||[],enableMultipleConfig:this.plugin.settings.enableMultipleConfig,positionStyle:this.plugin.settings.positionStyle,aestheticStyle:this.plugin.settings.aestheticStyle,appendMethod:this.plugin.settings.appendMethod,autohide:this.plugin.settings.autohide,isLoadOnMobile:this.plugin.settings.isLoadOnMobile,cMenuNumRows:this.plugin.settings.cMenuNumRows,custom_bg1:this.plugin.settings.custom_bg1,custom_bg2:this.plugin.settings.custom_bg2,custom_bg3:this.plugin.settings.custom_bg3,custom_bg4:this.plugin.settings.custom_bg4,custom_bg5:this.plugin.settings.custom_bg5,custom_fc1:this.plugin.settings.custom_fc1,custom_fc2:this.plugin.settings.custom_fc2,custom_fc3:this.plugin.settings.custom_fc3,custom_fc4:this.plugin.settings.custom_fc4,custom_fc5:this.plugin.settings.custom_fc5,toolbarBackgroundColor:this.plugin.settings.toolbarBackgroundColor,toolbarIconColor:this.plugin.settings.toolbarIconColor,toolbarIconSize:this.plugin.settings.toolbarIconSize});break;case"All commands":t=Object.assign(Object.assign({},t),{menuCommands:this.plugin.settings.menuCommands||[],followingCommands:this.plugin.settings.followingCommands||[],topCommands:this.plugin.settings.topCommands||[],fixedCommands:this.plugin.settings.fixedCommands||[],mobileCommands:this.plugin.settings.mobileCommands||[],enableMultipleConfig:this.plugin.settings.enableMultipleConfig});break;case"custom":t=Object.assign(Object.assign({},t),{customCommands:this.plugin.settings.customCommands||[]});break;case"following":t=Object.assign(Object.assign({},t),{followingCommands:this.plugin.settings.followingCommands||[]});break;case"top":t=Object.assign(Object.assign({},t),{topCommands:this.plugin.settings.topCommands||[]});break;case"fixed":t=Object.assign(Object.assign({},t),{fixedCommands:this.plugin.settings.fixedCommands||[]});break;case"mobile":t=Object.assign(Object.assign({},t),{mobileCommands:this.plugin.settings.mobileCommands||[]})}this.validateExportContent(t),this.textArea.setValue(JSON.stringify(t,null,2))}validateExportContent(t){["menuCommands","followingCommands","topCommands","fixedCommands","mobileCommands","customCommands"].forEach(e=>{e in t&&!t[e]&&(t[e]=[])}),"enableMultipleConfig"in t&&void 0===t.enableMultipleConfig&&(t.enableMultipleConfig=!1),"autohide"in t&&void 0===t.autohide&&(t.autohide=!1),"Iscentered"in t&&void 0===t.Iscentered&&(t.Iscentered=!1),"isLoadOnMobile"in t&&void 0===t.isLoadOnMobile&&(t.isLoadOnMobile=!0),"positionStyle"in t&&!t.positionStyle&&(t.positionStyle="top"),"aestheticStyle"in t&&!t.aestheticStyle&&(t.aestheticStyle="default"),"appendMethod"in t&&!t.appendMethod&&(t.appendMethod="workspace"),"cMenuNumRows"in t&&void 0===t.cMenuNumRows&&(t.cMenuNumRows=1)}importConfiguration(){return e(this,void 0,void 0,function*(){try{const i=this.textArea.getValue();if(!i.trim())return void new t.Notice(Jr("Please paste configuration data first"));const o=JSON.parse(i);if(!o||"object"!=typeof o)return void new t.Notice(Jr("Invalid import data format"));const n="menuCommands"in o,s="customCommands"in o,r="followingCommands"in o,a="topCommands"in o,l="fixedCommands"in o,c="mobileCommands"in o,h="positionStyle"in o||"aestheticStyle"in o,d="enableMultipleConfig"in o,u=o.positionStyle,p=n&&Array.isArray(o.menuCommands)&&o.menuCommands.length>0,m=s&&Array.isArray(o.customCommands)&&o.customCommands.length>0,g=r&&Array.isArray(o.followingCommands)&&o.followingCommands.length>0,f=a&&Array.isArray(o.topCommands)&&o.topCommands.length>0,b=l&&Array.isArray(o.fixedCommands)&&o.fixedCommands.length>0,y=c&&Array.isArray(o.mobileCommands)&&o.mobileCommands.length>0,v=n&&(!Array.isArray(o.menuCommands)||0===o.menuCommands.length),w=s&&(!Array.isArray(o.customCommands)||0===o.customCommands.length),C=r&&(!Array.isArray(o.followingCommands)||0===o.followingCommands.length),x=a&&(!Array.isArray(o.topCommands)||0===o.topCommands.length),k=l&&(!Array.isArray(o.fixedCommands)||0===o.fixedCommands.length),S=c&&(!Array.isArray(o.mobileCommands)||0===o.mobileCommands.length);let T=Jr("This import will:")+"\n";if(h&&(T+="• "+Jr("Update general settings")+"\n"),p&&(T+="• "+Jr("Update Main Menu Commands")+" ("+o.menuCommands.length+" )\n"),m&&(T+="• "+Jr("Update Custom Commands")+" ("+o.customCommands.length+" )\n"),g&&(T+="• "+Jr("Update Following Style Commands")+" ("+o.followingCommands.length+" )\n"),f&&(T+="• "+Jr("Update Top Style Commands")+" ("+o.topCommands.length+" )\n"),b&&(T+="• "+Jr("Update Fixed Style Commands")+" ("+o.fixedCommands.length+" )\n"),y&&(T+="• "+Jr("Update Mobile Style Commands")+" ("+o.mobileCommands.length+" )\n"),"overwrite"===this.importMode&&(v&&(T+="• "+Jr("Clear all Main Menu Commands")+" ⚠️\n"),w&&(T+="• "+Jr("Clear all Custom Commands")+" ⚠️\n"),C&&(T+="• "+Jr("Clear all Following Style Commands")+" ⚠️\n"),x&&(T+="• "+Jr("Clear all Top Style Commands")+" ⚠️\n"),k&&(T+="• "+Jr("Clear all Fixed Style Commands")+" ⚠️\n"),S&&(T+="• "+Jr("Clear all Mobile Style Commands")+" ⚠️\n")),d){const t=o.enableMultipleConfig?Jr("Enable"):Jr("Disable");T+="• "+Jr("Set Multiple Config to:")+" "+t+"\n"}if(u&&(T+="• "+Jr("Set Position Style to:")+" "+this.getPositionStyleName(u)+"\n"),!(p||m||g||f||b||y||v||w||C||x||k||S||h||d))return void new t.Notice(Jr("No valid configuration found in import data"));"overwrite"===this.importMode?T+="\n"+Jr("⚠️ Overwrite mode will replace existing settings with imported ones."):T+="\n"+Jr("ℹ️ Update mode will merge imported settings with existing ones."),Tc.show(this.app,{message:T+"\n"+Jr("Do you want to continue?"),onConfirm:()=>e(this,void 0,void 0,function*(){const e={positionStyle:this.plugin.settings.positionStyle,menuCommands:[...this.plugin.settings.menuCommands],customCommands:[...this.plugin.settings.customCommands],followingCommands:[...this.plugin.settings.followingCommands],topCommands:[...this.plugin.settings.topCommands],fixedCommands:[...this.plugin.settings.fixedCommands],mobileCommands:[...this.plugin.settings.mobileCommands]};try{"overwrite"===this.importMode?this.performOverwriteImport(o):this.performUpdateImport(o),this.fixImportedCommandIds(),yield this.plugin.saveSettings(),this.plugin.reloadCustomCommands(),dispatchEvent(new Event("editingToolbar-NewCommand")),new t.Notice(Jr("Configuration imported successfully")),this.close()}catch(t){throw this.restoreBackup(e),t}})})}catch(e){console.error("Import error: ",e),new t.Notice(Jr("Error: ")+" "+e.message)}})}performOverwriteImport(t){this.importGeneralSettings(t),t.menuCommands&&(this.plugin.settings.menuCommands=t.menuCommands),t.customCommands&&(this.plugin.settings.customCommands=t.customCommands),t.followingCommands&&(this.plugin.settings.followingCommands=t.followingCommands),t.topCommands&&(this.plugin.settings.topCommands=t.topCommands),t.fixedCommands&&(this.plugin.settings.fixedCommands=t.fixedCommands),t.mobileCommands&&(this.plugin.settings.mobileCommands=t.mobileCommands)}performUpdateImport(t){this.importGeneralSettings(t),t.menuCommands&&this.updateCommandArray(this.plugin.settings.menuCommands,t.menuCommands),t.customCommands&&this.updateCommandArray(this.plugin.settings.customCommands,t.customCommands),t.followingCommands&&this.updateCommandArray(this.plugin.settings.followingCommands,t.followingCommands),t.topCommands&&this.updateCommandArray(this.plugin.settings.topCommands,t.topCommands),t.fixedCommands&&this.updateCommandArray(this.plugin.settings.fixedCommands,t.fixedCommands),t.mobileCommands&&this.updateCommandArray(this.plugin.settings.mobileCommands,t.mobileCommands)}updateCommandArray(t,e){return t?(e.forEach(e=>{var i;const o=t.findIndex(t=>t.id===e.id);o>=0?t[o]=e:t.push(e),e.SubmenuCommands&&(null===(i=t[o])||void 0===i?void 0:i.SubmenuCommands)&&this.updateCommandArray(t[o].SubmenuCommands,e.SubmenuCommands)}),t):e.slice()}importGeneralSettings(t){["positionStyle","aestheticStyle","appendMethod","autohide","Iscentered","isLoadOnMobile","cMenuNumRows","enableMultipleConfig","custom_bg1","custom_bg2","custom_bg3","custom_bg4","custom_bg5","custom_fc1","custom_fc2","custom_fc3","custom_fc4","custom_fc5","toolbarBackgroundColor","toolbarIconColor","toolbarIconSize"].forEach(e=>{void 0!==t[e]&&(this.plugin.settings[e]=t[e])})}fixImportedCommandIds(){const t={"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"},e=i=>{i&&Array.isArray(i)&&i.forEach(i=>{i.id&&t[i.id]&&(i.id=t[i.id]),i.SubmenuCommands&&Array.isArray(i.SubmenuCommands)&&e(i.SubmenuCommands)})};e(this.plugin.settings.menuCommands),e(this.plugin.settings.customCommands),e(this.plugin.settings.followingCommands),e(this.plugin.settings.topCommands),e(this.plugin.settings.fixedCommands),e(this.plugin.settings.mobileCommands)}restoreBackup(t){this.plugin.settings.positionStyle=t.positionStyle,this.plugin.settings.menuCommands=t.menuCommands,this.plugin.settings.customCommands=t.customCommands,this.plugin.settings.followingCommands=t.followingCommands,this.plugin.settings.topCommands=t.topCommands,this.plugin.settings.fixedCommands=t.fixedCommands,this.plugin.settings.mobileCommands=t.mobileCommands}onClose(){const{contentEl:t}=this;t.empty()}getPositionStyleName(t){switch(t){case"following":return Jr("Following Style");case"top":return Jr("Top Style");case"fixed":return Jr("Fixed Style");default:return t}}}const Rc=[{id:"general",name:Jr("General"),icon:"gear"},{id:"appearance",name:Jr("Appearance"),icon:"brush"},{id:"customcommands",name:Jr("Custom Commands"),icon:"lucide-rectangle-ellipsis"},{id:"commands",name:Jr("Toolbar Commands"),icon:"lucide-command"},{id:"importexport",name:Jr("Import/Export"),icon:"lucide-import"}];function Fc(t){const{el:e,containerEl:i,swatches:o,opacity:n,defaultColor:s}=t;return{el:e,container:i,theme:"nano",swatches:o,lockOpacity:!n,default:s,position:"left-middle",components:{preview:!0,hue:!0,opacity:!!n,interaction:{hex:!0,rgba:!1,hsla:!1,input:!0,cancel:!0,save:!0}}}}function Pc(t,e){let i;return e.forEach((e,o)=>{e.id===t&&(i=o)}),i}class _c extends t.PluginSettingTab{constructor(t,e){super(t,e),this.pickrs=[],this.activeTab="general",this.aestheticStyleMap={default:"editingToolbarDefaultAesthetic",tiny:"editingToolbarTinyAesthetic",glass:"editingToolbarGlassAesthetic",custom:"editingToolbarCustomAesthetic",top:"top",following:"editingToolbarFlex",fixed:"fixed"},this.plugin=e,this.currentEditingConfig=this.plugin.settings.positionStyle,addEventListener("editingToolbar-NewCommand",()=>{ha(this.plugin),Ca(t,this.plugin),this.display()})}display(){this.destroyPickrs();const{containerEl:e}=this;e.empty(),this.createHeader(e);const i=e.createEl("div",{cls:"editing-toolbar-tabs"});Rc.forEach(e=>{const o=i.createEl("div",{cls:"editing-toolbar-tab "+(this.activeTab===e.id?"active":"")});t.setIcon(o,e.icon),o.createEl("span",{text:e.name}),o.addEventListener("click",()=>{this.activeTab=e.id,this.display()})});const o=e.createEl("div",{cls:"editing-toolbar-content"});switch(this.activeTab){case"general":this.displayGeneralSettings(o);break;case"appearance":this.displayAppearanceSettings(o);break;case"customcommands":this.displayCustomCommandSettings(o);break;case"commands":this.displayCommandSettings(o);break;case"importexport":this.displayImportExportSettings(o)}}createDeleteButton(t,i,o=Jr("Delete")){let n,s=!1;t.setIcon("editingToolbarDelete").setTooltip(o).onClick(()=>e(this,void 0,void 0,function*(){s?(clearTimeout(n),t.setIcon("editingToolbarDelete").setTooltip(o),t.buttonEl.removeClass("mod-warning"),s=!1,yield i()):(s=!0,t.setTooltip(Jr("Confirm Delete?")).setButtonText(Jr("Confirm Delete?")),t.buttonEl.addClass("mod-warning"),n=setTimeout(()=>{t.setIcon("editingToolbarDelete").setTooltip(o),t.buttonEl.removeClass("mod-warning"),s=!1},3500))}))}displayGeneralSettings(i){const o=i.createDiv("generalSetting-container");o.style.padding="16px",o.style.borderRadius="8px",o.style.backgroundColor="var(--background-secondary)",o.style.marginBottom="20px",new t.Setting(o).setName(Jr("Editing Toolbar Append Method")).setDesc(Jr("Choose where Editing Toolbar will append upon regeneration.")).addDropdown(t=>{let e={};oa.map(t=>e[t]=t),t.addOptions(e),t.setValue(this.plugin.settings.appendMethod).onChange(t=>{this.plugin.settings.appendMethod=t,this.plugin.saveSettings()})}),new t.Setting(o).setName(Jr("Enable Multiple Configurations")).setDesc(Jr("Enable different command configurations for each position style (following, top, fixed).")).addToggle(t=>t.setValue(this.plugin.settings.enableMultipleConfig||!1).onChange(t=>e(this,void 0,void 0,function*(){this.plugin.settings.enableMultipleConfig=t,this.plugin.onPositionStyleChange(this.plugin.positionStyle),yield this.plugin.saveSettings(),this.display()}))),new t.Setting(o).setName(Jr("Top Toolbar")).setDesc(Jr("Enable the toolbar positioned at the top.")).addToggle(t=>{t.setValue(this.plugin.settings.enableTopToolbar||!1).onChange(t=>e(this,void 0,void 0,function*(){const e=this.plugin.settings,i=this.plugin.positionStyle;e.enableTopToolbar=t;let o=null;t?o="top":"top"===i&&(o=e.enableFollowingToolbar?"following":e.enableFixedToolbar?"fixed":null),o&&o!==i&&this.plugin.onPositionStyleChange(o),yield this.plugin.saveSettings(),this.plugin.handleeditingToolbar(),this.display()}))}),new t.Setting(o).setName(Jr("Following Toolbar")).setDesc(Jr("Enable the toolbar that appears upon text selection.")).addToggle(t=>{t.setValue(this.plugin.settings.enableFollowingToolbar||!1).onChange(t=>e(this,void 0,void 0,function*(){const e=this.plugin.settings,i=this.plugin.positionStyle;e.enableFollowingToolbar=t;let o=null;t?o="following":"following"===i&&(o=e.enableTopToolbar?"top":e.enableFixedToolbar?"fixed":null),o&&o!==i&&this.plugin.onPositionStyleChange(o),yield this.plugin.saveSettings(),this.plugin.handleeditingToolbar(),this.display()}))}),new t.Setting(o).setName(Jr("Fixed Toolbar")).setDesc(Jr("Enable the toolbar whose position may be fixed where you please.")).addToggle(t=>{t.setValue(this.plugin.settings.enableFixedToolbar||!1).onChange(t=>e(this,void 0,void 0,function*(){const e=this.plugin.settings,i=this.plugin.positionStyle;e.enableFixedToolbar=t;let o=null;t?o="fixed":"fixed"===i&&(o=e.enableTopToolbar?"top":e.enableFollowingToolbar?"following":null),o&&o!==i&&this.plugin.onPositionStyleChange(o),yield this.plugin.saveSettings(),this.plugin.handleeditingToolbar(),this.display()}))}),new t.Setting(o).setName(Jr("Mobile Enabled or Not")).setDesc(Jr("Whether to enable on mobile devices with device width less than 768px.")).addToggle(t=>{var e,i;return t.setValue(null!==(i=null===(e=this.plugin.settings)||void 0===e?void 0:e.isLoadOnMobile)&&void 0!==i&&i).onChange(t=>{this.plugin.settings.isLoadOnMobile=t,this.plugin.saveSettings(),this.triggerRefresh()})})}displayAppearanceSettings(i){const o=i.createDiv("appearanceSetting-container");o.style.padding="16px",o.style.borderRadius="8px",o.style.backgroundColor="var(--background-secondary)",o.style.marginBottom="20px";const n=this.plugin.appearanceEditStyle||this.plugin.settings.positionStyle||"top";this.plugin.appearanceEditStyle=n,new t.Setting(o).setName(Jr("Toolbar Settings")).setDesc(Jr("Choose which toolbar style's appearance you want to edit.")).addDropdown(t=>{const i={};sa.map(t=>i[t]=t),t.addOptions(i).setValue(n).onChange(t=>e(this,void 0,void 0,function*(){const e=t;this.plugin.appearanceEditStyle=e,this.plugin.settings.positionStyle=e,yield this.plugin.saveSettings(),this.display()}))}),"top"===n&&(new t.Setting(o).setName(Jr("Editing Toolbar Auto-hide")).setDesc(Jr("The toolbar is displayed when the mouse moves over it, otherwise it is automatically hidden")).addToggle(t=>{var e;return t.setValue(null===(e=this.plugin.settings)||void 0===e?void 0:e.autohide).onChange(t=>{this.plugin.settings.autohide=t,this.plugin.saveSettings(),this.triggerRefresh()})}),new t.Setting(o).setName(Jr("Editing Toolbar Centred Display")).setDesc(Jr("Whether the toolbar is centred or full-width, the default is full-width.")).addToggle(t=>{var e;return t.setValue(null===(e=this.plugin.settings)||void 0===e?void 0:e.Iscentered).onChange(t=>{this.plugin.settings.Iscentered=t,this.plugin.saveSettings(),this.triggerRefresh()})})),"fixed"===n&&(new t.Setting(o).setName(Jr("Editing Toolbar Columns")).setDesc(Jr("Choose the number of columns per row to display on Editing Toolbar.")).addSlider(i=>{i.setLimits(1,32,1).setValue(this.plugin.settings.cMenuNumRows).onChange(t.debounce(t=>e(this,void 0,void 0,function*(){this.plugin.settings.cMenuNumRows=t,yield this.plugin.saveSettings(),this.triggerRefresh()}),100,!0)).setDynamicTooltip()}),new t.Setting(o).setName(Jr("Fixed Position Offset")).setDesc(Jr("Choose the offset of the Editing Toolbar in the fixed position.")).addButton(t=>t.setButtonText(Jr("Settings")).onClick(()=>{new ia(this.app,this.plugin).open()}))),this.createColorSettings(i)}displayCommandSettings(i){const o=i.createDiv("commandSetting-container");if(o.style.padding="16px",o.style.borderRadius="8px",o.style.backgroundColor="var(--background-secondary)",o.style.marginBottom="20px",this.plugin.settings.enableMultipleConfig&&new t.Setting(o).setName(Jr("Current Configuration")).setDesc(Jr("Switch between different command configurations.")).addDropdown(t=>{t.addOption("top",Jr("Top Style")),t.addOption("fixed",Jr("Fixed Style")),t.addOption("following",Jr("Following Style")),this.plugin.settings.isLoadOnMobile&&t.addOption("mobile",Jr("Mobile Style")),t.setValue(this.currentEditingConfig),t.onChange(t=>e(this,void 0,void 0,function*(){this.currentEditingConfig=t,this.display()}))}),this.plugin.settings.enableMultipleConfig){const o=this.currentEditingConfig;this.getCommandsArrayByType(o);const n=i.createDiv("command-buttons-container");n.style.display="flex",n.style.flexDirection="column",n.style.gap="10px",n.style.padding="16px",n.style.borderRadius="8px",n.style.backgroundColor="var(--background-secondary)";const s=new t.Setting(n).setName(Jr("Import From")).setDesc(Jr("Copy commands from another style configuration."));let r="Main menu";const a=new t.Setting(n);a.addDropdown(t=>{t.addOption("Main menu","Main Menu Commands"),"following"!==o&&this.plugin.settings.followingCommands&&t.addOption("following",Jr("Following Style")),"top"!==o&&this.plugin.settings.topCommands&&t.addOption("top",Jr("Top Style")),"fixed"!==o&&this.plugin.settings.fixedCommands&&t.addOption("fixed",Jr("Fixed Style")),"mobile"!==o&&this.plugin.settings.mobileCommands&&t.addOption("mobile",Jr("Mobile Style")),t.setValue(r).onChange(t=>{r=t})}),a.addExtraButton(t=>t.setIcon("arrow-right")),a.addButton(i=>i.setButtonText(this.currentEditingConfig+" "+Jr("Import")).setTooltip("Copy commands from selected style.").onClick(()=>e(this,void 0,void 0,function*(){const i=this.getCommandsArrayByType(r);if(!i||0===i.length)return void new t.Notice("The selected style has no commands to import.");const n=`Import commands from "${r}" to "${this.currentEditingConfig}" `+Jr("configuration")+"?";Tc.show(this.app,{message:n,onConfirm:()=>e(this,void 0,void 0,function*(){switch(o){case"Main menu":this.plugin.settings.menuCommands=[...i];break;case"following":this.plugin.settings.followingCommands=[...i];break;case"top":this.plugin.settings.topCommands=[...i];break;case"fixed":this.plugin.settings.fixedCommands=[...i];break;case"mobile":this.plugin.settings.mobileCommands=[...i]}yield this.plugin.saveSettings(),new t.Notice(`Commands imported successfully from "${r}" to "${this.currentEditingConfig}" `+Jr("configuration")),this.display()})})}))),s.addButton(i=>i.setButtonText(Jr("Clear")+" "+`${this.currentEditingConfig}`).setTooltip(Jr("Remove all commands from this configuration.")).setWarning().onClick(()=>e(this,void 0,void 0,function*(){Tc.show(this.app,{message:Jr("Are you sure you want to clear all commands under the current style?"),onConfirm:()=>e(this,void 0,void 0,function*(){switch(o){case"following":this.plugin.settings.followingCommands=[];break;case"top":this.plugin.settings.topCommands=[];break;case"fixed":this.plugin.settings.fixedCommands=[];break;case"mobile":this.plugin.settings.mobileCommands=[]}yield this.plugin.saveSettings(),new t.Notice("All commands have been removed."),this.display()})})})))}else{o.createDiv("command-buttons-container").createEl("button",{text:Jr("One-click Clear"),cls:"mod-warning"}).addEventListener("click",()=>e(this,void 0,void 0,function*(){Tc.show(this.app,{message:Jr("Are you sure you want to clear all commands under the current style?"),onConfirm:()=>e(this,void 0,void 0,function*(){this.plugin.settings.menuCommands=[],yield this.plugin.saveSettings(),new t.Notice(Jr("All commands have been removed.")),this.display()})})}))}const n=i.createDiv("command-lists-container");n.style.padding="16px",n.style.borderRadius="8px",n.addClass(`${this.currentEditingConfig}`),this.plugin.settings.enableMultipleConfig&&n.createEl("div",{cls:`position-style-info ${this.currentEditingConfig}`,text:Jr("Currently editing commands for")+` "${this.currentEditingConfig} Style" `+Jr("configuration")}),new t.Setting(n).setName(Jr("Editing Toolbar Commands")).setDesc(Jr("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.")).addButton(t=>{t.setIcon("plus").setTooltip(Jr("Add")).onClick(()=>{new ta(this.plugin,this.currentEditingConfig).open(),this.triggerRefresh()})}),this.createCommandList(n)}displayCustomCommandSettings(i){i.empty();const o=i.createDiv("custom-commands-container");o.createEl("p",{text:Jr("Add, edit or delete custom format commands.")}),new t.Setting(o).setName(Jr("Use current line for regex commands")).setDesc(Jr("When no text is selected, regex commands will use the current line instead of clipboard content")).addToggle(t=>{var i,o;return t.setValue(null!==(o=null===(i=this.plugin.settings)||void 0===i?void 0:i.useCurrentLineForRegex)&&void 0!==o&&o).onChange(t=>e(this,void 0,void 0,function*(){this.plugin.settings.useCurrentLineForRegex=t,yield this.plugin.saveSettings()}))});const n=o.createDiv("command-list-container");n.style.padding="16px",n.style.borderRadius="8px",n.style.backgroundColor="var(--background-secondary)",n.style.marginBottom="20px",n.style.marginTop="20px";const s=o.createDiv("add-command-button-container");s.style.padding="16px",s.style.borderRadius="8px",s.style.backgroundColor="var(--background-secondary)",s.style.marginBottom="20px",s.style.marginTop="20px",s.style.display="flex",s.style.gap="10px";const r=s.createEl("button",{text:Jr("Add Format Command")});r.addClass("mod-cta"),r.addEventListener("click",()=>{new Lc(this.app,this.plugin,null).open()});const a=s.createEl("button",{text:Jr("Add Regex Command")});a.addClass("mod-cta"),a.addEventListener("click",()=>{new Bc(this.app,this.plugin,null).open()}),this.plugin.settings.customCommands.forEach((i,o)=>{const s=new t.Setting(n).setName(i.name),r=createFragment();let a=`${Jr("ID")}: ${i.id}`;i.useRegex?a+=`, ${Jr("Pattern")}: ${i.regexPattern}`:a+=`, ${Jr("Prefix")}: ${i.prefix}, ${Jr("Suffix")}: ${i.suffix}`,r.createSpan({text:a});const l=r.createSpan({cls:"command-type-badge"});if(i.useRegex?(l.addClass("regex"),l.setText(Jr("Regex"))):l.setText(Jr("Prefix/Suffix")),s.descEl.appendChild(r),s.addButton(e=>e.setButtonText(Jr("Add to Toolbar")).setTooltip(Jr("Add this command to the toolbar.")).setButtonText(Jr("Add to Toolbar")).setTooltip(Jr("Add this command to the toolbar.")).onClick(()=>{if(this.plugin.settings.enableMultipleConfig)new Nc(this.app,this.plugin,i).open();else{if(this.plugin.settings.menuCommands.some(t=>t.id===`editing-toolbar:${i.id}`))return void new t.Notice(Jr("This command is already in the toolbar."));const e={id:`editing-toolbar:${i.id}`,name:i.name,icon:i.icon||"obsidian-new"};this.plugin.settings.menuCommands.push(e),this.plugin.saveSettings().then(()=>{new t.Notice(Jr("Command added to toolbar")),dispatchEvent(new Event("editingToolbar-NewCommand")),this.plugin.reloadCustomCommands()})}})).addExtraButton(t=>{t.setIcon("pencil").setTooltip(Jr("Edit")).onClick(()=>{i.useRegex?new Bc(this.app,this.plugin,o).open():new Lc(this.app,this.plugin,o).open()})}).addButton(i=>this.createDeleteButton(i,()=>e(this,void 0,void 0,function*(){const e=`editing-toolbar:${this.plugin.settings.customCommands[o].id}`;this.removeCommandFromConfig(this.plugin.settings.menuCommands,e),this.plugin.settings.enableMultipleConfig&&(this.removeCommandFromConfig(this.plugin.settings.followingCommands,e),this.removeCommandFromConfig(this.plugin.settings.topCommands,e),this.removeCommandFromConfig(this.plugin.settings.fixedCommands,e),this.plugin.settings.isLoadOnMobile&&this.removeCommandFromConfig(this.plugin.settings.mobileCommands,e)),this.plugin.settings.customCommands.splice(o,1),yield this.plugin.saveSettings(),this.plugin.reloadCustomCommands(),this.display(),new t.Notice(Jr("Command Deleted"))}))),i.icon)try{const e=s.nameEl.createSpan({cls:"editingToolbarSettingsIcon"});e.style.marginRight="8px",ga(i.icon)?e.innerHTML=i.icon:t.setIcon(e,i.icon)}catch(t){console.error("Failed to set icon:",t)}})}triggerRefresh(){setTimeout(()=>{dispatchEvent(new Event("editingToolbar-NewCommand"))},100)}createHeader(e){const i=e.createEl("div",{cls:"editing-toolbar-header"});i.createEl("div",{cls:"editing-toolbar-title-container"}).createEl("h1",{text:"Obsidian Editing Toolbar: "+this.plugin.manifest.version,cls:"editing-toolbar-title"});const o=i.createEl("div",{cls:"editing-toolbar-info"});new t.Setting(o).setClass("editing-toolbar-fix-button").addButton(t=>{t.setIcon("wrench").setTooltip(Jr("Fix")).onClick(()=>{new Ec(this.app,this.plugin).open()})})}getAppearanceBucket(t){const e=this.plugin.settings;e.appearanceByStyle&&"object"==typeof e.appearanceByStyle||(e.appearanceByStyle={});const i=e.appearanceByStyle;return i[t]&&"object"==typeof i[t]||(i[t]={}),i[t]}createColorSettings(i){var o,n,s,r,a,l;const c=this.plugin.appearanceEditStyle||this.plugin.settings.positionStyle||"top",h=this.getAppearanceBucket(c),d=i.createDiv("custom-paintbrush-container");d.style.padding="16px",d.style.borderRadius="8px",d.style.backgroundColor="var(--background-secondary)",d.style.marginBottom="20px",new t.Setting(d).setName(Jr("🎨 Set Custom Background")).setDesc(Jr("Click on the picker to adjust the color")).setClass("custom_bg").then(t=>{const e=t.controlEl.createDiv({cls:"pickr-container"});for(let t=0;t<5;t++){const i=e.createDiv({cls:"picker"}),o=Ic.create(Fc({isView:!1,el:i,containerEl:e,swatches:["#FFB78B8C","#CDF4698C","#A0CCF68C","#F0A7D88C","#ADEFEF8C"],opacity:!0,defaultColor:this.plugin.settings[`custom_bg${t+1}`]||"#000000"}));this.setupPickrEvents(o,`custom_bg${t+1}`,"background-color"),this.pickrs.push(o)}}),new t.Setting(d).setName(Jr("🖌️ Set Custom Font Color")).setDesc(Jr("Click on the picker to adjust the color")).setClass("custom_font").then(t=>{const e=t.controlEl.createDiv({cls:"pickr-container"});for(let t=0;t<5;t++){const i=e.createDiv({cls:"picker"}),o=Ic.create(Fc({isView:!1,el:i,containerEl:e,swatches:["#D83931","#DE7802","#245BDB","#6425D0","#646A73"],opacity:!0,defaultColor:this.plugin.settings[`custom_fc${t+1}`]||"#000000"}));this.setupPickrEvents(o,`custom_fc${t+1}`,"color"),this.pickrs.push(o)}});const u=i.createDiv("custom-toolbar-container");u.style.padding="16px",u.style.borderRadius="8px",u.style.backgroundColor="var(--background-secondary)",new t.Setting(u).setName(Jr("Toolbar Theme")).setDesc(Jr("Select a preset toolbar theme, automatically setting the background color, icon color, and size for the selected style.")).addDropdown(t=>{var i;const o={};na.forEach(t=>{o[t]="custom"===t?Jr("Custom Theme"):t}),t.addOptions(o),t.selectEl.options[3].disabled=!0,t.addOption("light","┌ Light"),t.addOption("dark","├ Dark"),t.addOption("vibrant","├ Vibrant"),t.addOption("minimal","├ Minimal"),t.addOption("elegant","└ Elegant"),t.setValue(null!==(i=h.aestheticStyle)&&void 0!==i?i:this.plugin.settings.aestheticStyle),t.onChange(t=>e(this,void 0,void 0,function*(){var e,i,n;const s=this.plugin.appearanceEditStyle||this.plugin.settings.positionStyle||"top",r=this.getAppearanceBucket(s);switch(t in o?(r.aestheticStyle=t,r.toolbarIconSize=18):r.aestheticStyle="custom",t){case"light":r.toolbarBackgroundColor="#F5F8FA",r.toolbarIconColor="#4A5568",r.toolbarIconSize=18;break;case"dark":r.toolbarBackgroundColor="#2D3033",r.toolbarIconColor="#E2E8F0",r.toolbarIconSize=18;break;case"vibrant":r.toolbarBackgroundColor="#7E57C2",r.toolbarIconColor="#FFFFFF",r.toolbarIconSize=20;break;case"minimal":r.toolbarBackgroundColor="#F8F9FA",r.toolbarIconColor="#6B7280",r.toolbarIconSize=16;break;case"elegant":r.toolbarBackgroundColor="#1A2F28",r.toolbarIconColor="#D4AF37",r.toolbarIconSize=19}const a=null!==(e=r.toolbarBackgroundColor)&&void 0!==e?e:this.plugin.settings.toolbarBackgroundColor,l=null!==(i=r.toolbarIconColor)&&void 0!==i?i:this.plugin.settings.toolbarIconColor,c=null!==(n=r.toolbarIconSize)&&void 0!==n?n:18;document.documentElement.style.setProperty("--editing-toolbar-background-color",a),document.documentElement.style.setProperty("--editing-toolbar-icon-color",l),document.documentElement.style.setProperty("--toolbar-icon-size",`${c}px`),this.plugin.toolbarIconSize=c,this.destroyPickrs(),this.display(),yield this.plugin.saveSettings(),this.triggerRefresh()}))}),new t.Setting(u).setName(Jr("Toolbar Background Color")).setDesc(Jr("Set the background color of the toolbar.")).setClass("toolbar_background").then(t=>{var e;const i=t.controlEl.createDiv({cls:"pickr-container"}),o=i.createDiv({cls:"picker"}),n=Ic.create(Fc({isView:!1,el:o,containerEl:i,swatches:["#F5F8FA","#F4F1E8","#2D3033","#1A2F28","#2A1D3B"],opacity:!0,defaultColor:null!==(e=h.toolbarBackgroundColor)&&void 0!==e?e:this.plugin.settings.toolbarBackgroundColor}));this.setupPickrEvents(n,"toolbarBackgroundColor","background-color"),this.pickrs.push(n)}),new t.Setting(u).setName(Jr("Toolbar Icon Color")).setDesc(Jr("Set the color of the toolbar icon.")).setClass("toolbar_icon").then(t=>{const e=t.controlEl.createDiv({cls:"pickr-container"}),i=e.createDiv({cls:"picker"}),o=Ic.create(Fc({isView:!1,el:i,containerEl:e,swatches:["#4A5568","#D4AF37","#2D3033","#6D5846","#4C2A55"],opacity:!1,defaultColor:this.plugin.settings.toolbarIconColor}));this.pickrs.push(o),this.setupPickrEvents(o,"toolbarIconColor","icon-color")}),new t.Setting(u).setName(Jr("Toolbar Icon Size")).setDesc(Jr("Set the size of the toolbar icon (px); default: 18px")).addSlider(t=>{var i;const o=null!==(i=h.toolbarIconSize)&&void 0!==i?i:this.plugin.settings.toolbarIconSize;t.setValue(o).setLimits(12,32,1).setDynamicTooltip().onChange(t=>e(this,void 0,void 0,function*(){const e=this.plugin.positionStyle,i=this.plugin.appearanceEditStyle||this.plugin.settings.positionStyle||"top",o=this.getAppearanceBucket(i);o.toolbarIconSize=t,o.aestheticStyle="custom",e===i&&(this.plugin.toolbarIconSize=t,document.documentElement.style.setProperty("--toolbar-icon-size",`${t}px`)),yield this.plugin.saveSettings(),this.display(),this.triggerRefresh()}))});const p=u.createDiv("toolbar-preview-container");p.addClass("toolbar-preview-section"),p.style.marginTop="20px";p.createEl("h3",{text:Jr("Toolbar Preview (With a hypothetical command configuration.)")}).style.marginBottom="10px";const m=p.createDiv();m.classList.add("preview-toolbar-wrapper"),m.classList.add(`preview-${c}`);const g=m.createDiv();g.classList.add("editing-toolbar-preview"),g.classList.add(`preview-${c}`),g.setAttribute("id","editingToolbarModalBar");const f=null!==(n=null!==(o=h.aestheticStyle)&&void 0!==o?o:this.plugin.settings.aestheticStyle)&&void 0!==n?n:"default";if(this.applyAestheticStyle(g,f,c),"fixed"===c){const t=this.plugin.settings.toolbarIconSize||18,e=this.plugin.settings.cMenuNumRows||6;g.style.display="grid",g.style.gridTemplateColumns=`repeat(${e}, ${t+10}px)`,g.style.gap=`${Math.max((t-18)/4,2)}px`,g.style.margin="0 auto"}[{id:"bold",name:"Bold",icon:"bold"},{id:"italics",name:"Italics",icon:"italic"},{id:"trikethrough",name:"Strikethrough",icon:"strikethrough"},{id:"code",name:"Code",icon:"code"},{id:"blockquote",name:"Blockquote",icon:"quote-glyph"},{id:"insert-link",name:"Link",icon:"link"},{id:"left-sidebar",name:"Left sidebar",icon:"lucide-panel-left"},{id:"editor:insert-embed",name:"Add embed",icon:"note-glyph"},{id:"editor:insert-link",name:"Insert markdown link",icon:"link-glyph"},{id:"editor:insert-tag",name:"Add tag",icon:"price-tag-glyph"},{id:"editor:insert-wikilink",name:"Add internal link",icon:"bracket-glyph"},{id:"editor:toggle-code",name:"Code",icon:"code-glyph"},{id:"editor:toggle-blockquote",name:"Blockquote",icon:"lucide-text-quote"},{id:"editor:toggle-checklist-status",name:"Checklist status",icon:"checkbox-glyph"},{id:"editor:toggle-comments",name:"Comment",icon:"percent-sign-glyph"},{id:"editor:insert-callout",name:"Insert Callout",icon:"lucide-quote"},{id:"editor:insert-mathblock",name:"MathBlock",icon:"lucide-sigma-square"},{id:"editor:insert-table",name:"Insert Table",icon:"lucide-table"}].forEach(e=>{const i=new t.ButtonComponent(g);i.setClass("editingToolbarCommandItem"),i.buttonEl.classList.add("preview-button"),i.setTooltip(e.name),e.icon&&t.setIcon(i.buttonEl,e.icon)});const b="custom"===f,y=null!==(s=h.toolbarBackgroundColor)&&void 0!==s?s:this.plugin.settings.toolbarBackgroundColor,v=null!==(r=h.toolbarIconColor)&&void 0!==r?r:this.plugin.settings.toolbarIconColor,w=null!==(l=null!==(a=h.toolbarIconSize)&&void 0!==a?a:this.plugin.settings.toolbarIconSize)&&void 0!==l?l:18;b&&y?g.style.backgroundColor=y:g.style.removeProperty("background-color");g.querySelectorAll("svg").forEach(t=>{b&&v?t.style.color=v:t.style.removeProperty("color"),t.style.width=`${w}px`,t.style.height=`${w}px`})}createCommandList(i){let o=[];if(this.plugin.settings.enableMultipleConfig)switch(this.currentEditingConfig){case"mobile":o=this.plugin.settings.mobileCommands;break;case"following":o=this.plugin.settings.followingCommands;break;case"top":o=this.plugin.settings.topCommands;break;case"fixed":o=this.plugin.settings.fixedCommands;break;default:o=this.plugin.settings.menuCommands}else o=this.plugin.settings.menuCommands;const n=i.createEl("div",{cls:"editingToolbarSettingsTabsContainer"});let s="";nc.create(n,{group:"item",animation:500,draggable:".setting-item",ghostClass:"sortable-ghost",chosenClass:"sortable-chosen",dragClass:"sortable-drag",dragoverBubble:!1,forceFallback:!0,fallbackOnBody:!0,swapThreshold:.7,fallbackClass:"sortable-fallback",easing:"cubic-bezier(1, 0, 0, 1)",delay:800,delayOnTouchOnly:!0,touchStartThreshold:5,filter:".setting-item-control button",onChoose:function(t){t.item.classList.add("sortable-chosen-feedback")},onUnchoose:function(t){t.item.classList.remove("sortable-chosen-feedback")},onSort:t=>{if(t.from.className===t.to.className){const e=o,[i]=e.splice(t.oldIndex,1);if(e.splice(t.newIndex,0,i),this.plugin.settings.enableMultipleConfig)switch(this.currentEditingConfig){case"mobile":this.plugin.settings.mobileCommands=e;break;case"following":this.plugin.settings.followingCommands=e;break;case"top":this.plugin.settings.topCommands=e;break;case"fixed":this.plugin.settings.fixedCommands=e}else this.plugin.settings.menuCommands=e;this.plugin.saveSettings()}this.triggerRefresh()},onStart:function(t){s=t.item.className}});const r=o;r.forEach((i,a)=>{const l=new t.Setting(n);if("SubmenuCommands"in i){if(l.settingEl.setAttribute("data-id",i.id),l.setClass("editingToolbarCommandItem").setClass("editingToolbarCommandsubItem").setName(i.name).addButton(t=>{t.setClass("editingToolbarSettingsIcon").onClick(()=>e(this,void 0,void 0,function*(){new Xr(this.plugin,i,!1,null,this.currentEditingConfig).open()})),ga(i.icon)?t.buttonEl.innerHTML=i.icon:t.setIcon(i.icon)}).addButton(t=>this.createDeleteButton(t,()=>e(this,void 0,void 0,function*(){r.remove(i),this.plugin.updateCurrentCommands(r,this.currentEditingConfig),yield this.plugin.saveSettings(),this.display(),this.triggerRefresh(),console.log(`%cCommand '${i.name}' was removed from editingToolbar`,"color: #989cab")}))),"editingToolbar-plugin:change-font-color"==i.id)return;if("editingToolbar-plugin:change-background-color"==i.id)return;const n=l.settingEl.createEl("div",{cls:"editingToolbarSettingsTabsContainer_sub"});nc.create(n,{group:{name:"item",pull:!0,put:function(){return!s.includes("editingToolbarCommandsubItem")}},draggable:".setting-item",animation:150,ghostClass:"sortable-ghost",chosenClass:"sortable-chosen",dragClass:"sortable-drag",dragoverBubble:!1,fallbackOnBody:!0,swapThreshold:.7,forceFallback:!0,delay:800,delayOnTouchOnly:!0,touchStartThreshold:5,fallbackClass:"sortable-fallback",easing:"cubic-bezier(1, 0, 0, 1)",onStart:function(){},onSort:t=>{var e,i,n;if(t.from.className===t.to.className){const i=o,n=null===(e=i[a])||void 0===e?void 0:e.SubmenuCommands;if(n){const[e]=n.splice(t.oldIndex,1);n.splice(t.newIndex,0,e),this.plugin.updateCurrentCommands(i,this.currentEditingConfig),this.plugin.saveSettings()}}else if("editingToolbarSettingsTabsContainer"===t.to.className){const e=o;const n=null===(i=e[Pc(t.target.parentElement.dataset.id,e)])||void 0===i?void 0:i.SubmenuCommands;if(n){const[i]=n.splice(t.oldIndex,1);e.splice(t.newIndex,0,i),this.plugin.updateCurrentCommands(e,this.currentEditingConfig),this.plugin.saveSettings()}else console.error("Subresult is undefined.")}else if("editingToolbarSettingsTabsContainer"===t.from.className){const e=o,i=null===(n=e[Pc(t.target.parentElement.dataset.id,e)])||void 0===n?void 0:n.SubmenuCommands;if(i){const[o]=e.splice(t.oldIndex,1);i.splice(t.newIndex,0,o),this.plugin.updateCurrentCommands(e,this.currentEditingConfig),this.plugin.saveSettings()}else console.error("Subresult is undefined.")}this.triggerRefresh()}}),i.SubmenuCommands.forEach(o=>{const s=new t.Setting(n);s.setClass("editingToolbarCommandItem").addButton(t=>{t.setClass("editingToolbarSettingsIcon").onClick(()=>e(this,void 0,void 0,function*(){new Xr(this.plugin,o,!0,null,this.currentEditingConfig).open()})),ga(null==o?void 0:o.icon)?t.buttonEl.innerHTML=o.icon:t.setIcon(o.icon)}).setName(o.name).addButton(t=>{t.setIcon("pencil").setTooltip(Jr("Change Command Name")).setClass("editingToolbarSettingsButton").onClick(()=>e(this,void 0,void 0,function*(){new ea(this.app,this.plugin,o,!0,this.currentEditingConfig).open()}))}).addButton(t=>this.createDeleteButton(t,()=>e(this,void 0,void 0,function*(){i.SubmenuCommands.remove(o),yield this.plugin.saveSettings(),this.display(),this.triggerRefresh(),console.log(`%cCommand '${i.name}' was removed from editingToolbar`,"color: #989cab")}))),s.nameEl})}else l.addButton(t=>{t.setClass("editingToolbarSettingsIcon").onClick(()=>e(this,void 0,void 0,function*(){new Xr(this.plugin,i,!1,null,this.currentEditingConfig).open()})),ga(i.icon)?t.buttonEl.innerHTML=i.icon:t.setIcon(i.icon)}),"editingToolbar-Divider-Line"==i.id&&l.setClass("editingToolbar-Divider-Line"),l.setClass("editingToolbarCommandItem").setName(i.name).addButton(t=>{t.setIcon("pencil").setTooltip(Jr("Change Command Name")).setClass("editingToolbarSettingsButton").onClick(()=>e(this,void 0,void 0,function*(){new ea(this.app,this.plugin,i,!1,this.currentEditingConfig).open()}))}).addButton(t=>{t.setIcon("editingToolbarSub").setTooltip(Jr("Add Submenu")).setClass("editingToolbarSettingsButton").setClass("editingToolbarSettingsButtonaddsub").onClick(()=>e(this,void 0,void 0,function*(){const t={id:"SubmenuCommands-"+qr(1),name:"submenu",icon:"remix-Filter3Line",SubmenuCommands:[]},e=o;e.splice(a+1,0,t),this.plugin.updateCurrentCommands(e,this.currentEditingConfig),yield this.plugin.saveSettings(),this.display(),this.triggerRefresh(),console.log(`%cCommand '${t.id}' add `,"color: #989cab")}))}).addButton(t=>{t.setIcon("vertical-split").setTooltip(Jr("Add Separator")).setClass("editingToolbarSettingsButton").setClass("editingToolbarSettingsButtonaddsub").onClick(()=>e(this,void 0,void 0,function*(){const t={id:"editingToolbar-Divider-Line",name:Jr("Vertical Split"),icon:"vertical-split"},e=o;e.splice(a+1,0,t),this.plugin.updateCurrentCommands(e,this.currentEditingConfig),yield this.plugin.saveSettings(),this.display(),this.triggerRefresh()}))}).addButton(t=>this.createDeleteButton(t,()=>e(this,void 0,void 0,function*(){r.remove(i),this.plugin.updateCurrentCommands(r,this.currentEditingConfig),yield this.plugin.saveSettings(),this.display(),this.triggerRefresh(),console.log(`%cCommand '${i.name}' was removed from editingToolbar`,"color: #989cab")})))})}setupPickrEvents(t,e,i){t.on("save",t=>{const o=t.toHEXA().toString(),n=this.plugin.positionStyle,s=this.plugin.appearanceEditStyle||this.plugin.settings.positionStyle||n||"top";if("toolbarBackgroundColor"===e||"toolbarIconColor"===e){const t=this.getAppearanceBucket(s);t[e]=o,n===s&&document.documentElement.style.setProperty(`--editing-toolbar-${i}`,o),"custom"!==t.aestheticStyle&&(t.aestheticStyle="custom"),this.display(),this.triggerRefresh()}else this.plugin.settings[e]=o;this.plugin.saveSettings()})}destroyPickrs(){this.pickrs.forEach(t=>{t&&t.destroyAndRemove()}),this.pickrs=[]}hide(){this.destroyPickrs(),this.triggerRefresh()}removeCommandFromConfig(t,e){if(t)for(let i=t.length-1;i>=0;i--)t[i].id!==e?t[i].SubmenuCommands&&this.removeCommandFromConfig(t[i].SubmenuCommands,e):t.splice(i,1)}displayImportExportSettings(e){const i=e.createDiv("import-export-container");i.style.padding="16px",i.style.borderRadius="8px",i.style.backgroundColor="var(--background-secondary)",i.style.marginBottom="20px",new t.Setting(i).setName(Jr("Export Configuration")).setDesc(Jr("Export your toolbar configuration to share with others.")).addButton(t=>t.setButtonText(Jr("Export")).setCta().onClick(()=>{new qc(this.app,this.plugin,"export").open()})),new t.Setting(i).setName(Jr("Import Configuration")).setDesc(Jr("Import toolbar configuration from JSON.")).addButton(t=>t.setButtonText(Jr("Import")).setCta().onClick(()=>{new qc(this.app,this.plugin,"import").open()}));const o=e.createDiv("import-export-info");o.style.marginTop="20px",o.style.padding="16px",o.style.borderRadius="8px",o.style.backgroundColor="var(--background-secondary)",o.createEl("h3",{text:Jr("Usage Instructions"),cls:"import-export-heading"}).style.marginTop="0";const n=o.createEl("ul");n.style.paddingLeft="20px",n.createEl("li",{text:Jr("Export: Generate a JSON configuration that you can save or share.")}),n.createEl("li",{text:Jr("Import: Paste a previously exported JSON configuration.")});const s=e.createDiv("community-share-container");s.style.marginTop="20px",s.style.padding="16px",s.style.borderRadius="8px",s.style.backgroundColor="rgba(var(--color-green-rgb), 0.1)",s.style.border="1px solid rgba(var(--color-green-rgb), 0.3)",s.createEl("h3",{text:Jr("Join the Community"),cls:"community-heading"}).style.marginTop="0";s.createEl("p").innerHTML=Jr("Share your toolbar settings and styles in our")+' <a href="https://github.com/PKM-er/obsidian-editing-toolbar/discussions/categories/show-and-tell" target="_blank" rel="noopener noreferrer">Show and Tell</a> ',s.createEl("p",{text:Jr("Get inspired by what others have created or showcase your own customizations.")});const r=e.createDiv("import-export-warning");r.style.marginTop="20px",r.style.padding="16px",r.style.borderRadius="8px",r.style.backgroundColor="rgba(var(--color-red-rgb), 0.1)",r.style.border="1px solid rgba(var(--color-red-rgb), 0.3)",r.createEl("p",{text:Jr("Warning: Importing configuration will overwrite your current settings. Consider exporting your current configuration first as a backup."),cls:"warning-text"}).style.margin="0"}applyAestheticStyle(t,e,i){Object.values(this.aestheticStyleMap).forEach(e=>{t.removeClass(e)});const o=this.aestheticStyleMap[e]||this.aestheticStyleMap.default;t.addClass(o);const n=this.aestheticStyleMap[i]||this.aestheticStyleMap.top;t.addClass(n)}getCommandsArrayByType(t){switch(t){case"following":return this.plugin.settings.followingCommands;case"top":return this.plugin.settings.topCommands;case"fixed":return this.plugin.settings.fixedCommands;case"mobile":return this.plugin.settings.mobileCommands;default:return this.plugin.settings.menuCommands}}}const Vc={editingToolbar:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" stroke-width="0" stroke-linecap="round" stroke-linejoin="round"><path d="M19 10H5c-1.103 0-2 .897-2 2v8c0 1.103.897 2 2 2h14c1.103 0 2-.897 2-2v-8c0-1.103-.897-2-2-2zM5 20v-8h14l.002 8H5zM5 6h14v2H5zm2-4h10v2H7z" fill="currentColor"/></svg>',editingToolbarSub:'<svg t="1661526346488" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="16880" ><path d="M597.333333 85.333333h-341.333333C187.733333 85.333333 128 140.8 128 213.333333v597.333334c0 72.533333 59.733333 128 128 128h426.666667c72.533333 0 128-55.466667 128-128V298.666667l-213.333334-213.333334z m170.666667 725.333334c0 46.933333-38.4 85.333333-85.333333 85.333333H256c-46.933333 0-85.333333-38.4-85.333333-85.333333V213.333333c0-46.933333 38.4-85.333333 85.333333-85.333333h298.666667v213.333333h213.333333v469.333334z m-320-234.666667h128c12.8 0 21.333333 8.533333 21.333333 21.333333s-8.533333 21.333333-21.333333 21.333334h-128v128c0 12.8-8.533333 21.333333-21.333333 21.333333s-21.333333-8.533333-21.333334-21.333333v-128h-128c-12.8 0-21.333333-8.533333-21.333333-21.333334s8.533333-21.333333 21.333333-21.333333h128v-128c0-12.8 8.533333-21.333333 21.333334-21.333333s21.333333 8.533333 21.333333 21.333333v128z" fill="#8a8a8a" p-id="16881"></path></svg>',editingToolbarAdd:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" stroke="white" stroke-width="0" stroke-linecap="round" stroke-linejoin="round"><path d="M13 7h-2v4H7v2h4v4h2v-4h4v-2h-4z" fill="currentColor"/><path d="M12 2C6.486 2 2 6.486 2 12s4.486 10 10 10s10-4.486 10-10S17.514 2 12 2zm0 18c-4.411 0-8-3.589-8-8s3.589-8 8-8s8 3.589 8 8s-3.589 8-8 8z" fill="currentColor"/></svg>',editingToolbarDelete:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" stroke="white" stroke-width="0" stroke-linecap="round" stroke-linejoin="round"><path d="M5 20a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8h2V6h-4V4a2 2 0 0 0-2-2H9a2 2 0 0 0-2 2v2H3v2h2zM9 4h6v2H9zM8 8h9v12H7V8z" fill="var(--text-error)"/><path d="M9 10h2v8H9zm4 0h2v8h-2z" fill="var(--text-error)"/></svg>',editingToolbarReload:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" stroke="white" stroke-width="0" stroke-linecap="round" stroke-linejoin="round"><path d="M19 10H5c-1.103 0-2 .897-2 2v8c0 1.103.897 2 2 2h14c1.103 0 2-.897 2-2v-8c0-1.103-.897-2-2-2zM5 20v-8h14l.002 8H5zM5 6h14v2H5zm2-4h10v2H7z" fill="currentColor"/></svg>',"codeblock-glyph":'<svg xmlns="http://www.w3.org/2000/svg" stroke-linecap="round" stroke-linejoin="round" viewBox="0 0 24 24"><path fill="currentColor" d="M20 3H4c-1.103 0-2 .897-2 2v14c0 1.103.897 2 2 2h16c1.103 0 2-.897 2-2V5c0-1.103-.897-2-2-2zM4 19V7h16l.002 12H4z" fill="currentColor"/><path d="M9.293 9.293L5.586 13l3.707 3.707l1.414-1.414L8.414 13l2.293-2.293zm5.414 0l-1.414 1.414L15.586 13l-2.293 2.293l1.414 1.414L18.414 13z"/></svg>',"underline-glyph":'<svg xmlns="http://www.w3.org/2000/svg" stroke-linecap="round" stroke-linejoin="round" viewBox="0 0 1024 1024"><path fill="currentColor" d="M824 804H200c-4.4 0-8 3.4-8 7.6v60.8c0 4.2 3.6 7.6 8 7.6h624c4.4 0 8-3.4 8-7.6v-60.8c0-4.2-3.6-7.6-8-7.6zm-312-76c69.4 0 134.6-27.1 183.8-76.2C745 602.7 772 537.4 772 468V156c0-6.6-5.4-12-12-12h-60c-6.6 0-12 5.4-12 12v312c0 97-79 176-176 176s-176-79-176-176V156c0-6.6-5.4-12-12-12h-60c-6.6 0-12 5.4-12 12v312c0 69.4 27.1 134.6 76.2 183.8C377.3 701 442.6 728 512 728z"/></svg>',"superscript-glyph":'<svg xmlns="http://www.w3.org/2000/svg" stroke-linecap="round" stroke-linejoin="round" viewBox="0 0 24 24"><path fill="currentColor"d="M16 7.41L11.41 12L16 16.59L14.59 18L10 13.41L5.41 18L4 16.59L8.59 12L4 7.41L5.41 6L10 10.59L14.59 6L16 7.41M21.85 9h-4.88V8l.89-.82c.76-.64 1.32-1.18 1.7-1.63c.37-.44.56-.85.57-1.23a.884.884 0 0 0-.27-.7c-.18-.19-.47-.28-.86-.29c-.31.01-.58.07-.84.17l-.66.39l-.45-1.17c.27-.22.59-.39.98-.53S18.85 2 19.32 2c.78 0 1.38.2 1.78.61c.4.39.62.93.62 1.57c-.01.56-.19 1.08-.54 1.55c-.34.48-.76.93-1.27 1.36l-.64.52v.02h2.58V9z"/></svg>',"subscript-glyph":'<svg xmlns="http://www.w3.org/2000/svg" stroke-linecap="round" stroke-linejoin="round" viewBox="0 0 24 24"><path fill="currentColor" d="M16 7.41L11.41 12L16 16.59L14.59 18L10 13.41L5.41 18L4 16.59L8.59 12L4 7.41L5.41 6L10 10.59L14.59 6L16 7.41m5.85 13.62h-4.88v-1l.89-.8c.76-.65 1.32-1.19 1.7-1.63c.37-.44.56-.85.57-1.24a.898.898 0 0 0-.27-.7c-.18-.16-.47-.28-.86-.28c-.31 0-.58.06-.84.18l-.66.38l-.45-1.17c.27-.21.59-.39.98-.53s.82-.24 1.29-.24c.78.04 1.38.25 1.78.66c.4.41.62.93.62 1.57c-.01.56-.19 1.08-.54 1.55c-.34.47-.76.92-1.27 1.36l-.64.52v.02h2.58v1.35z"/></svg>',"bot-glyph":'<svg xmlns="http://www.w3.org/2000/svg" stroke-linecap="round" stroke-linejoin="round" viewBox="0 0 24 24"><path fill="currentColor" d="M21.928 11.607c-.202-.488-.635-.605-.928-.633V8c0-1.103-.897-2-2-2h-6V4.61c.305-.274.5-.668.5-1.11a1.5 1.5 0 0 0-3 0c0 .442.195.836.5 1.11V6H5c-1.103 0-2 .897-2 2v2.997l-.082.006A1 1 0 0 0 1.99 12v2a1 1 0 0 0 1 1H3v5c0 1.103.897 2 2 2h14c1.103 0 2-.897 2-2v-5a1 1 0 0 0 1-1v-1.938a1.006 1.006 0 0 0-.072-.455zM5 20V8h14l.001 3.996L19 12v2l.001.005l.001 5.995H5z" fill="currentColor"/><ellipse cx="8.5" cy="12" rx="1.5" ry="2" fill="currentColor"/><ellipse cx="15.5" cy="12" rx="1.5" ry="2" fill="currentColor"/><path d="M8 16h8v2H8z" fill="currentColor"/></svg>',"header-1":'<svg class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path fill="currentColor" d="M835.626667 349.397333A42.666667 42.666667 0 0 1 853.333333 384v426.666667a42.666667 42.666667 0 0 1-85.333333 0v-367.488l-71.850667 23.978666a42.666667 42.666667 0 0 1-26.965333-80.981333l128-42.666667a42.666667 42.666667 0 0 1 38.4 5.888zM128 170.666667a42.666667 42.666667 0 0 1 42.666667 42.666666v256h256V213.333333a42.666667 42.666667 0 1 1 85.333333 0v597.333334a42.666667 42.666667 0 1 1-85.333333 0v-256H170.666667v256a42.666667 42.666667 0 1 1-85.333334 0V213.333333a42.666667 42.666667 0 0 1 42.666667-42.666666z" p-id="1635"></path></svg>',"header-2":'<svg class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path d="M768 426.666667a85.333333 85.333333 0 0 0-85.333333 85.333333v21.333333a42.666667 42.666667 0 1 1-85.333334 0V512a170.666667 170.666667 0 0 1 170.666667-170.666667h7.338667a163.328 163.328 0 0 1 115.498666 278.869334L742.997333 768H896a42.666667 42.666667 0 1 1 0 85.333333h-256a42.666667 42.666667 0 0 1-30.165333-72.832l220.672-220.672A77.994667 77.994667 0 0 0 775.338667 426.666667H768zM128 170.666667a42.666667 42.666667 0 0 1 42.666667 42.666666v256h256V213.333333a42.666667 42.666667 0 1 1 85.333333 0v597.333334a42.666667 42.666667 0 1 1-85.333333 0v-256H170.666667v256a42.666667 42.666667 0 1 1-85.333334 0V213.333333a42.666667 42.666667 0 0 1 42.666667-42.666666z" p-id="1791"></path></svg>',"header-3":'<svg class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path d="M597.333333 384a42.666667 42.666667 0 0 1 42.666667-42.666667h256a42.666667 42.666667 0 0 1 30.165333 72.832l-105.941333 105.984A170.752 170.752 0 0 1 768 853.333333a170.666667 170.666667 0 0 1-160.938667-113.877333 42.666667 42.666667 0 0 1 80.469334-28.373333A85.333333 85.333333 0 1 0 768 597.333333h-42.666667a42.666667 42.666667 0 0 1-30.165333-72.832L793.002667 426.666667H640a42.666667 42.666667 0 0 1-42.666667-42.666667zM128 170.666667a42.666667 42.666667 0 0 1 42.666667 42.666666v256h256V213.333333a42.666667 42.666667 0 1 1 85.333333 0v597.333334a42.666667 42.666667 0 1 1-85.333333 0v-256H170.666667v256a42.666667 42.666667 0 1 1-85.333334 0V213.333333a42.666667 42.666667 0 0 1 42.666667-42.666666z" p-id="1949"></path></svg>',"header-4":'<svg class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path d="M780.714667 343.296a42.666667 42.666667 0 0 1 28.032 53.418667L719.36 682.666667H896a42.666667 42.666667 0 1 1 0 85.333333h-234.666667a42.666667 42.666667 0 0 1-40.704-55.381333l106.666667-341.333334a42.666667 42.666667 0 0 1 53.418667-27.989333z" p-id="2107"></path><path d="M853.333333 554.666667a42.666667 42.666667 0 0 1 42.666667 42.666666v213.333334a42.666667 42.666667 0 1 1-85.333333 0v-213.333334a42.666667 42.666667 0 0 1 42.666666-42.666666zM128 170.666667a42.666667 42.666667 0 0 1 42.666667 42.666666v256h256V213.333333a42.666667 42.666667 0 1 1 85.333333 0v597.333334a42.666667 42.666667 0 1 1-85.333333 0v-256H170.666667v256a42.666667 42.666667 0 1 1-85.333334 0V213.333333a42.666667 42.666667 0 0 1 42.666667-42.666666z" p-id="2108"></path></svg>',"header-5":'\n <svg class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path d="M683.946667 373.674667A42.666667 42.666667 0 0 1 725.333333 341.333333h170.666667a42.666667 42.666667 0 1 1 0 85.333334h-137.301333l-22.016 88.234666A170.666667 170.666667 0 1 1 640 795.562667a42.666667 42.666667 0 1 1 64-56.448 85.333333 85.333333 0 1 0 0-112.896 42.666667 42.666667 0 0 1-73.386667-38.528l53.333334-214.016zM128 170.666667a42.666667 42.666667 0 0 1 42.666667 42.666666v256h256V213.333333a42.666667 42.666667 0 1 1 85.333333 0v597.333334a42.666667 42.666667 0 1 1-85.333333 0v-256H170.666667v256a42.666667 42.666667 0 1 1-85.333334 0V213.333333a42.666667 42.666667 0 0 1 42.666667-42.666666z" p-id="2264"></path></svg>',"header-6":'<svg class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path d="M831.274667 303.957333a42.666667 42.666667 0 0 1 16.725333 57.984l-83.498667 151.466667a170.453333 170.453333 0 0 1 88.746667 22.741333 169.557333 169.557333 0 0 1 62.506667 232.277334 171.093333 171.093333 0 0 1-232.96 62.165333 169.557333 169.557333 0 0 1-62.805334-231.850667l153.301334-278.016a42.666667 42.666667 0 0 1 57.984-16.768z m-20.48 306.176a85.76 85.76 0 0 0-116.736 31.018667 84.224 84.224 0 0 0 31.189333 115.456 85.76 85.76 0 0 0 116.736-31.018667 84.224 84.224 0 0 0-31.232-115.456zM128 170.666667a42.666667 42.666667 0 0 1 42.666667 42.666666v256h256V213.333333a42.666667 42.666667 0 1 1 85.333333 0v597.333334a42.666667 42.666667 0 1 1-85.333333 0v-256H170.666667v256a42.666667 42.666667 0 1 1-85.333334 0V213.333333a42.666667 42.666667 0 0 1 42.666667-42.666666z" p-id="2422"></path></svg>',"header-n":'<svg viewBox="0 0 24 24" ><path d="M2 3a1 1 0 0 0-1 1v16a1 1 0 1 0 2 0v-7h9v7a1 1 0 1 0 2 0V4a1 1 0 1 0-2 0v7H3V4a1 1 0 0 0-1-1Zm14 9a1 1 0 0 1 1.984-.177 4.099 4.099 0 0 1 1.757-.576 3.447 3.447 0 0 1 3.759 3.432V20a1 1 0 1 1-2 0v-5.32c0-.851-.73-1.519-1.578-1.442A2.114 2.114 0 0 0 18 15.344V20a1 1 0 1 1-2 0v-8Z" fill="currentColor"></path></svg>',obsidian:'<svg viewBox="0 0 100 100" fill="none" stroke="currentColor" stroke-width="4" stroke-linecap="round" stroke-linejoin="round" class="logo-wireframe"><path d="M 30.91 17.52 L 34.43 35.7 M 61.44 14.41 L 62.61 0 M 34.43 35.7 L 37.57 90.47 M 81 26.39 L 61.44 14.41 L 34.43 35.7 L 65.35 100 M 62.61 0 L 30.91 17.52 L 18 45.45 L 37.57 90.47 L 65.35 100 L 70.44 89.8 L 81 26.39 L 62.61 0 Z"></path></svg>',"obsidian-new":'<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path fill="#A88BFA" d="m6.91927 14.5955c.64053-.1907 1.67255-.4839 2.85923-.5565-.71191-1.7968-.88376-3.3691-.74554-4.76905.15962-1.61678.72977-2.9662 1.28554-4.11442.1186-.24501.2326-.47313.3419-.69198.1549-.30984.3004-.60109.4365-.8953.2266-.48978.3948-.92231.4798-1.32416.0836-.39515.0841-.74806-.0148-1.08657-.099-.338982-.3093-.703864-.7093-1.1038132-.5222-.1353116-1.1017-.0165173-1.53613.3742922l-5.15591 4.638241c-.28758.25871-.47636.60929-.53406.99179l-.44455 2.94723c.69903.6179 2.42435 2.41414 3.47374 4.90644.09364.2224.1819.4505.26358.6838z"></path><path fill="#A88BFA" d="m2.97347 10.3512c-.02431.1037-.05852.205-.10221.3024l-2.724986 6.0735c-.279882.6238-.15095061 1.3552.325357 1.8457l4.288349 4.4163c2.1899-3.2306 1.87062-6.2699.87032-8.6457-.75846-1.8013-1.90801-3.2112-2.65683-3.9922z"></path><path fill="#A88BFA" d="m5.7507 23.5094c.07515.012.15135.0192.2281.0215.81383.0244 2.18251.0952 3.29249.2997.90551.1669 2.70051.6687 4.17761 1.1005 1.1271.3294 2.2886-.5707 2.4522-1.7336.1192-.8481.343-1.8075.7553-2.6869l-.0095.0033c-.6982-1.9471-1.5865-3.2044-2.5178-4.0073-.9284-.8004-1.928-1.1738-2.8932-1.3095-1.60474-.2257-3.07497.1961-4.00103.4682.55465 2.3107.38396 5.0295-1.48417 7.8441z"></path><path fill="#A88BFA" d="m17.3708 19.3102c.9267-1.3985 1.5868-2.4862 1.9352-3.0758.1742-.295.1427-.6648-.0638-.9383-.5377-.7126-1.5666-2.1607-2.1272-3.5015-.5764-1.3785-.6624-3.51876-.6673-4.56119-.0019-.39626-.1275-.78328-.3726-1.09465l-3.3311-4.23183c-.0117.19075-.0392.37998-.0788.56747-.1109.52394-.32 1.04552-.5585 1.56101-.1398.30214-.3014.62583-.4646.95284-.1086.21764-.218.4368-.3222.652-.5385 1.11265-1.0397 2.32011-1.1797 3.73901-.1299 1.31514.0478 2.84484.8484 4.67094.1333.0113.2675.0262.4023.0452 1.1488.1615 2.3546.6115 3.4647 1.5685.9541.8226 1.8163 2.0012 2.5152 3.6463z"></path></svg>'};class zc{constructor(t){this.plugin=t}init(){this.statusBarIcon=this.plugin.addStatusBarItem(),this.statusBarIcon.addClass("editingToolbar-statusbar-button"),t.setIcon(this.statusBarIcon,"editingToolbar"),this.registerClickEvent()}registerClickEvent(){this.plugin.registerDomEvent(this.statusBarIcon,"click",()=>{const t=this.statusBarIcon.parentElement.getBoundingClientRect(),e=this.statusBarIcon.getBoundingClientRect();this.showMenu(e,t)})}showMenu(e,i){const o=new t.Menu;o.addSections(["settings"]),this.addVisibilityToggle(o),this.addAestheticStyleToggle(o),o.addSections(["viewType"]),this.addViewTypeToggle(o),o.addSections(["controls"]),this.addToolbarControls(o);o.dom.addClass("editingToolbar-statusbar-menu"),o.showAtPosition({x:e.right+5,y:i.top-5})}addVisibilityToggle(i){i.addItem(i=>{i.setTitle(Jr("Hide & Show")),!t.requireApiVersion("0.15.0")||i.setSection("settings");const o=i.dom,n=new t.ToggleComponent(o).setValue(this.plugin.settings.cMenuVisibility).setDisabled(!0),s=()=>e(this,void 0,void 0,function*(){this.plugin.settings.cMenuVisibility=!this.plugin.settings.cMenuVisibility,n.setValue(this.plugin.settings.cMenuVisibility),1==this.plugin.settings.cMenuVisibility?setTimeout(()=>{dispatchEvent(new Event("editingToolbar-NewCommand"))},100):$r(this.plugin.settings.cMenuVisibility),ha(this.plugin),yield this.plugin.saveSettings()});i.onClick(t=>{t.preventDefault(),t.stopImmediatePropagation(),s()})}),i.addItem(i=>{i.setTitle(Jr("Toolbar Position")),!t.requireApiVersion("0.15.0")||i.setSection("settings"),i.setIcon("dock");const o=i.setSubmenu();o.addItem(i=>{i.setTitle(Jr("Top Toolbar"));const o=i.dom,n=new t.ToggleComponent(o).setValue(this.plugin.settings.enableTopToolbar||!1).setDisabled(!0);i.onClick(t=>e(this,void 0,void 0,function*(){t.preventDefault(),t.stopPropagation();const e=this.plugin.settings,i=this.plugin.positionStyle;e.enableTopToolbar=!e.enableTopToolbar,n.setValue(e.enableTopToolbar);let o=null;e.enableTopToolbar?o="top":"top"===i&&(o=e.enableFollowingToolbar?"following":e.enableFixedToolbar?"fixed":null),o&&o!==i&&this.plugin.onPositionStyleChange(o),yield this.plugin.saveSettings(),this.plugin.handleeditingToolbar()}))}),o.addItem(i=>{i.setTitle(Jr("Following Toolbar"));const o=i.dom,n=new t.ToggleComponent(o).setValue(this.plugin.settings.enableFollowingToolbar||!1).setDisabled(!0);i.onClick(t=>e(this,void 0,void 0,function*(){t.preventDefault(),t.stopPropagation();const e=this.plugin.settings,i=this.plugin.positionStyle;e.enableFollowingToolbar=!e.enableFollowingToolbar,n.setValue(e.enableFollowingToolbar);let o=null;e.enableFollowingToolbar?o="following":"following"===i&&(o=e.enableTopToolbar?"top":e.enableFixedToolbar?"fixed":null),o&&o!==i&&this.plugin.onPositionStyleChange(o),yield this.plugin.saveSettings(),this.plugin.handleeditingToolbar()}))}),o.addItem(i=>{i.setTitle(Jr("Fixed Toolbar"));const o=i.dom,n=new t.ToggleComponent(o).setValue(this.plugin.settings.enableFixedToolbar||!1).setDisabled(!0);i.onClick(t=>e(this,void 0,void 0,function*(){t.preventDefault(),t.stopPropagation();const e=this.plugin.settings,i=this.plugin.positionStyle;e.enableFixedToolbar=!e.enableFixedToolbar,n.setValue(e.enableFixedToolbar);let o=null;e.enableFixedToolbar?o="fixed":"fixed"===i&&(o=e.enableTopToolbar?"top":e.enableFollowingToolbar?"following":null),o&&o!==i&&this.plugin.onPositionStyleChange(o),yield this.plugin.saveSettings(),this.plugin.handleeditingToolbar()}))})})}addViewTypeToggle(i){const o=this.plugin.app.workspace.getActiveViewOfType(t.ItemView);if(!o)return;const n=o.getViewType();i.addItem(i=>{i.setTitle(Jr("Current View: ")+n),!t.requireApiVersion("0.15.0")||i.setSection("settings"),i.setIcon("layout-template");const s=i.setSubmenu(),r=aa.isAllowedViewType(o);s.addItem(t=>{t.setTitle(Jr(r?"Disable toolbar for this view":"Enable toolbar for this view")),t.setIcon(r?"eye-off":"eye"),t.onClick(()=>e(this,void 0,void 0,function*(){this.plugin.settings.viewTypeSettings||(this.plugin.settings.viewTypeSettings={}),this.plugin.settings.viewTypeSettings[n]=!r,yield this.plugin.saveSettings(),ha(this.plugin),setTimeout(()=>{dispatchEvent(new Event("editingToolbar-NewCommand"))},100)}))}),s.addItem(t=>{t.setTitle(Jr("Manage all view types")),t.setIcon("settings-2");const i=t.setSubmenu(),o=new Set(["markdown","canvas","thino_view","meld-encrypted-view",...Object.keys(this.plugin.settings.viewTypeSettings||{})]);Array.from(o).sort().forEach(t=>{const o=this.isViewTypeAllowed(t);i.addItem(i=>{i.setTitle(t),i.setIcon(o?"check":""),i.onClick(()=>e(this,void 0,void 0,function*(){this.plugin.settings.viewTypeSettings||(this.plugin.settings.viewTypeSettings={}),this.plugin.settings.viewTypeSettings[t]=!o,n===t&&(ha(this.plugin),setTimeout(()=>{dispatchEvent(new Event("editingToolbar-NewCommand"))},100)),yield this.plugin.saveSettings()}))})})})})}isViewTypeAllowed(t){if(!this.plugin.settings.viewTypeSettings||void 0===this.plugin.settings.viewTypeSettings[t]){return["markdown","canvas","thino_view","meld-encrypted-view"].includes(t)}return this.plugin.settings.viewTypeSettings[t]}addToolbarControls(e){const i=[{icon:"plus",title:Jr("Add Command"),click:()=>new ta(this.plugin).open()}];"fixed"===this.plugin.positionStyle&&i.push({icon:"file-sliders",title:Jr("Position Settings"),click:()=>new ia(this.plugin.app,this.plugin).open()}),i.forEach(i=>{e.addItem(e=>{e.setIcon(i.icon),e.setTitle(i.title),e.onClick(i.click),t.requireApiVersion("0.15.0")&&e.setSection("controls")})})}addAestheticStyleToggle(i){i.addItem(i=>{i.setTitle(Jr("Appearance Style")),!t.requireApiVersion("0.15.0")||i.setSection("settings"),i.setIcon("cherry");const o=i.setSubmenu();na.forEach(t=>{o.addItem(i=>{i.setTitle(t),i.setIcon(this.plugin.settings.aestheticStyle===t?"check":""),i.onClick(()=>e(this,void 0,void 0,function*(){this.plugin.settings.aestheticStyle=t,yield this.plugin.saveSettings(),ha(this.plugin),setTimeout(()=>{dispatchEvent(new Event("editingToolbar-NewCommand"))},100)}))})})})}}let Hc,Wc;class $c extends t.Modal{constructor(t){super(t.app),this.plugin=t,this.type="note",this.title="",this.content="",this.collapse="none",this.allCalloutOptions=[],this.builtInCalloutTypes=[{type:"note",aliases:[],icon:"lucide-pencil",label:"Note",color:"var(--callout-default)"},{type:"abstract",aliases:["summary","tldr"],icon:"lucide-clipboard-list",label:"Abstract",color:"var(--callout-summary)"},{type:"info",aliases:[],icon:"lucide-info",label:"Info",color:"var(--callout-info)"},{type:"todo",aliases:[],icon:"lucide-check-circle-2",label:"Todo",color:"var(--callout-todo)"},{type:"important",aliases:[],icon:"lucide-flame",label:"Important",color:"var(--callout-important)"},{type:"tip",aliases:["hint"],icon:"lucide-flame",label:"Tip",color:"var(--callout-tip)"},{type:"success",aliases:["check","done"],icon:"lucide-check",label:"Success",color:"var(--callout-success)"},{type:"question",aliases:["help","faq"],icon:"lucide-help-circle",label:"Question",color:"var(--callout-question)"},{type:"warning",aliases:["caution","attention"],icon:"lucide-alert-triangle",label:"Warning",color:"var(--callout-warning)"},{type:"failure",aliases:["fail","missing"],icon:"lucide-x",label:"Failure",color:"var(--callout-fail)"},{type:"danger",aliases:["error"],icon:"lucide-zap",label:"Danger",color:"var(--callout-error)"},{type:"bug",aliases:[],icon:"lucide-bug",label:"Bug",color:"var(--callout-bug)"},{type:"example",aliases:[],icon:"lucide-list",label:"Example",color:"var(--callout-example)"},{type:"quote",aliases:["cite"],icon:"lucide-quote",label:"Quote",color:"var(--callout-quote)"}],this.containerEl.addClass("insert-callout-modal"),this.prepareCalloutOptions();const e=this.plugin.commandsManager.getActiveEditor();if(e){const t=e.getSelection();t&&(this.content=t)}this.allCalloutOptions.find(t=>t.type===this.type)||(this.type=this.allCalloutOptions.length>0?this.allCalloutOptions[0].type:"note")}prepareCalloutOptions(){if(this.builtInCalloutTypes.forEach(t=>{this.allCalloutOptions.push({type:t.type,label:t.label,icon:t.icon,color:t.color,isAdmonition:!1}),t.aliases.forEach(e=>{this.allCalloutOptions.push({type:e,label:`${t.label} (${e})`,icon:t.icon,color:t.color,isAdmonition:!1})})}),this.plugin.admonitionDefinitions){const t=Object.values(this.plugin.admonitionDefinitions);t.length>0&&t.forEach(t=>{this.allCalloutOptions.some(e=>e.type===t.type)||this.allCalloutOptions.push({type:t.type,label:t.title||t.type.charAt(0).toUpperCase()+t.type.slice(1),icon:t.icon,color:`rgb(${t.color})`,isAdmonition:!0,sourcePlugin:"Admonition"})})}}onOpen(){this.display()}display(){return e(this,void 0,void 0,function*(){const{contentEl:e}=this;e.empty(),e.addEventListener("keydown",t=>{"Enter"===t.key&&(t.ctrlKey||t.metaKey)&&(t.preventDefault(),this.insertButton&&this.insertButton.click())});const i=e.createDiv("callout-type-container");this.iconContainerEl=i.createDiv("callout-icon-container"),new t.Setting(i).setName(Jr("Callout Type")).addDropdown(t=>{const e=this.allCalloutOptions.filter(t=>!t.isAdmonition),i=this.allCalloutOptions.filter(t=>t.isAdmonition);if(e.length>0&&i.length>0){t.addOption("---separator---","---- Admonitions ----");const e=t.selectEl.options[t.selectEl.options.length-1];e&&(e.disabled=!0)}i.forEach(e=>{t.addOption(e.type,`${e.label} (Admonition)`)}),t.addOption("---separator---","---- Default ----"),e.forEach(e=>{t.addOption(e.type,e.label)}),this.allCalloutOptions.some(t=>t.type===this.type)||(this.type=this.allCalloutOptions.length>0?this.allCalloutOptions[0].type:"note"),t.setValue(this.type),t.onChange(e=>{"---separator---"!==e?(this.type=e,this.updateIconAndColor(this.iconContainerEl,e)):t.setValue(this.type)})}),this.updateIconAndColor(this.iconContainerEl,this.type),new t.Setting(e).setName(Jr("Title")).setDesc(Jr("Optional, leave blank for default title")).addText(t=>{t.setPlaceholder(Jr("Input title")).setValue(this.title).onChange(t=>{this.title=t})}),new t.Setting(e).setName(Jr("Collapse State")).addDropdown(t=>{t.addOption("none",Jr("Default")).addOption("open",Jr("Open")).addOption("closed",Jr("Closed")).setValue(this.collapse).onChange(t=>{this.collapse=t})}),new t.Setting(e).setName(Jr("Content")).addTextArea(t=>{t.setPlaceholder(Jr("Input content")).setValue(this.content).onChange(t=>{this.content=t}),t.inputEl.rows=5,t.inputEl.cols=40,this.contentTextArea=t.inputEl});const o=e.createDiv("shortcut-hint");o.setText(`${t.Platform.isMacOS?"⌘":"Ctrl"} + Enter ${Jr("to insert")}`),o.style.textAlign="right",o.style.fontSize="0.8em",o.style.opacity="0.7",o.style.marginTop="5px",new t.Setting(e).addButton(t=>(t.setButtonText(Jr("Insert")).setCta().onClick(()=>{this.insertCallout(),this.close()}),this.insertButton=t.buttonEl,t)).addButton(t=>(t.setButtonText(Jr("Cancel")).setTooltip(Jr("Cancel")).onClick(()=>this.close()),t)),setTimeout(()=>{this.contentTextArea&&this.contentTextArea.focus()},10)})}updateIconAndColor(e,i){if(!e)return;const o=this.allCalloutOptions.find(t=>t.type===i);if(e.empty(),o)if(o.isAdmonition){const i=o.icon;if("custom"===i.type&&i.svg){e.innerHTML=i.svg;const t=e.querySelector("svg");t&&(t.style.fill=o.color,t.style.width="var(--icon-size)",t.style.height="var(--icon-size)")}else i.name.startsWith("lucide-")||"default"===i.type?(t.setIcon(e,i.name),e.style.setProperty("--callout-color",o.color)):(t.setIcon(e,"lucide-box"),e.style.setProperty("--callout-color",o.color))}else t.setIcon(e,o.icon),e.style.setProperty("--callout-color",o.color);else t.setIcon(e,"lucide-alert-circle"),e.style.removeProperty("--callout-color")}insertCallout(){const t=this.plugin.commandsManager.getActiveEditor();if(!t)return;let e=`> [!${this.type}]`;"none"!==this.collapse&&(e+=""+("open"===this.collapse?"+":"-")),this.title&&(e+=` ${this.title}`),e+=`\n> ${this.content.replace(/\n/g,"\n> ")}`;const i=t.getCursor(),o=t.getLine(i.line),n=0===i.ch;let s;if(t.getSelection()){!n&&o.trim().length>0&&(e="\n"+e);const i=t.getCursor("from");t.replaceSelection(e);const r=e.split("\n").length;s={line:i.line+r,ch:0}}else{!n&&o.trim().length>0&&(e="\n"+e),t.replaceRange(e,i);const r=e.split("\n").length;s={line:i.line+r,ch:0}}setTimeout(()=>{t.replaceRange("\n",s),t.setCursor({line:s.line+1,ch:0}),t.focus()},0)}}class Uc{static isValidUrl(t){try{return new URL(t),!0}catch(t){return!1}}static parseTitle(t,e){const i=[t.includes("mp.weixin.qq.com")?this.wxTitlePattern:null,this.htmlTitlePattern,/<title [^>]*>(.*?)<\/title>/i,/<meta name="title" content="([^<]*)" \/>/im].filter(Boolean);for(const t of i){const i=e.match(t);if(i&&"string"==typeof i[1])return i[1].trim()}throw new Error("Unable to parse the title tag")}static getFallbackTitle(t){const e=t.match(/[^/\\]+$/);return e?e[0].replace(/\.[^/.]+$/,"").replace(/[-_]/g," ").trim():t}static fetchRemoteTitle(i){return e(this,void 0,void 0,function*(){if(!this.isValidUrl(i)||!i.match(/^https?:\/\//))return this.getFallbackTitle(i);try{const e=yield t.requestUrl({url:i,method:"GET",headers:{"User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36"},throw:!0});if(200!==e.status)throw new Error(`Status code ${e.status}`);const o=e.text,n=this.parseTitle(i,o);return!n||n.length>100?this.getFallbackTitle(i):n}catch(t){return console.error(`Failed to fetch title for ${i}:`,t),this.getFallbackTitle(i)}})}}Uc.htmlTitlePattern=/<title>([^<]*)<\/title>/im,Uc.wxTitlePattern=/<meta property="og:title" content="([^<]*)" \/>/im;class jc extends t.Modal{constructor(t){super(t.app),this.plugin=t,this.linkText="",this.linkUrl="",this.linkAlias="",this.isEmbed=!1,this.insertNewLine=!1,this.imageWidth="",this.imageHeight="",this.prefixText="",this.suffixText="",this.selectedText="";const e=this.plugin.commandsManager.getActiveEditor();if(e){const t=e.getSelection()||"";t?this.handleSelectedText(e,t):this.handleCursorPosition(e)}else this.parseClipboard();this.updateHeader()}handleSelectedText(t,e){const i=this.tryExpandSelection(t,e);if(i){const e=this.formatTargetText(i);t.setSelection(i.from,i.to),this.selectedText=e,this.parseSelectedText(e)}else this.selectedText=e,this.parseSelectedText(e)}handleCursorPosition(t){const e=t.getCursor(),i=this.findLinkAtCursor(t,e);if(i){const e=this.formatTargetText(i);t.setSelection(i.from,i.to),this.selectedText=e,this.parseSelectedText(e)}else this.parseClipboard()}tryExpandSelection(t,e){const i=t.getCursor("from"),o=t.getLine(i.line),n=i.ch,s=t.getCursor("to").ch;return this.matchLinkInLine(o,n,s,i.line)}findLinkAtCursor(t,e){const i=t.getLine(e.line),o=e.ch;return this.matchLinkInLine(i,o,o,e.line)}matchLinkInLine(t,e,i,o){const n=/(!)?\[([^\]]+)\]\(([^\s)]+)(?:\s+["']([^"']*)["'])?\)/g;let s;for(;null!==(s=n.exec(t));){const t=!!s[1],n=s.index,r=s.index+s[0].length,a=s[2],l=s[3],c=s[4]||"";if(e<=r&&i>=n)return{isImage:t,text:a,url:l,title:c,from:{line:o,ch:n},to:{line:o,ch:r}}}const r=/(?:^|\s)([a-zA-Z][a-zA-Z\d+\-.]*:\/\/\S+|\S+\.[a-zA-Z]{2,}(?:\/\S*)?)/g;for(;null!==(s=r.exec(t));){const t=s[1],n=s.index+(s[0].startsWith(" ")?1:0),r=n+t.length;if(e<=r&&i>=n)return{isImage:/\.(jpg|jpeg|png|gif|webp|bmp)$/i.test(t),text:t,url:t,title:"",from:{line:o,ch:n},to:{line:o,ch:r}}}return null}formatTargetText(t){return t.isImage?``:t.title?`[${t.text}](${t.url} "${t.title}")`:`[${t.text}](${t.url})`}parseSelectedText(t){const e=t.match(/!\[.*?\]\(.*?\)/);if(e){const i=t.substring(0,e.index),o=t.substring(e.index+e[0].length),n=this.parseMarkdownImageLink(t);if(n)return this.linkText=n.title,this.linkUrl=n.url,this.linkAlias=n.quotedTitle||"",this.imageWidth=n.width||"",this.imageHeight=n.height||"",this.isEmbed=!0,this.prefixText=i,void(this.suffixText=o)}const i=t.match(/\[([^\]]+)\]\(([a-zA-Z]+:\/\/[^\s)]+)(?:\s+["']([^"']*)["'])?\)/);if(i){const e=i[0],o=t.substring(0,i.index),n=t.substring(i.index+e.length),s=this.parseMarkdownLink(e);s&&(this.linkText=s.text,this.linkUrl=s.url,this.linkAlias=s.title||"",this.isEmbed=!1),this.prefixText=o,this.suffixText=n}else{const e=this.parseMixedContent(t);e&&(this.linkText=e.title,this.linkUrl=e.url)}}parseMixedContent(t){let e;return(e=t.match(/^\[(.*?)\]\((.*?)\)$/))?{title:e[1].trim(),url:e[2].trim()}:(e=t.match(/<a[^>]+href=["']([^"']+)["'][^>]*>([^<]+)<\/a>/i))?{title:e[2].trim(),url:e[1].trim()}:(e=t.match(/^(.*?)\s*((?:https?:\/\/|www\.)\S+)$/i))&&e[1].trim()?{title:e[1].trim(),url:e[2].trim()}:this.isValidUrl(t.trim())?{title:this.extractTitleFromUrl(t.trim()),url:t.trim()}:{title:t.trim(),url:""}}extractTitleFromUrl(t){const e=t.match(/^([a-zA-Z]+):\/\/(.+)$/);if(e){const[,t,i]=e,o=i.split(/[/\\]/),n=o[o.length-1];return n?decodeURIComponent(n).trim():t.toUpperCase()}const i=t.match(/^\[\[(.*?)\]\]$/);if(i)return i[1];const o=t.match(/[^/\\]+$/);return o?o[0].replace(/\.[^/.]+$/,"").replace(/[-_]/g," ").trim():t}isValidUrl(t){if(!t||t.includes("\n")||/\s/.test(t))return!1;if(["obsidian://","zotero://","evernote://","notion://","bear://","things://","drafts://","x-devonthink-item://","file://","ftp://","ftps://","http://","https://","tel:","mailto:"].some(e=>t.startsWith(e)))return!0;if(t.match(/^\[\[.*?\]\]$/))return!0;if(t.match(/^[./\\]/)||t.match(/^[a-zA-Z]:\\/)||t.match(/^\/[^/]/)||t.match(/^[a-zA-Z]+:\/\//))return!0;try{return new URL(t),!0}catch(t){return!1}}parseMarkdownImageLink(t){const e=t.match(/!\[(.*?)(?:\|(\d+)(?:x(\d+))?)?\]\(\s*([^\s)]+)(?:\s+["']([^"']*)["'])?\s*\)/);if(e){const[,t,i,o,n,s]=e;if(this.isEmbed=!0,this.embedToggle){this.embedToggle.setValue(!0);const t=this.contentEl.querySelector(".image-size-setting");t&&(t.style.display="block")}return{title:t.trim(),url:n.trim(),width:i,height:o,quotedTitle:null==s?void 0:s.trim()}}return null}parseMarkdownLink(t){const e=t.match(/\[([^\]]+)\]\(([a-zA-Z]+:\/\/[^\s)]+)(?:\s+["']([^"']*)["'])?\)/);if(e){const[,t,i,o]=e;return{text:t.trim(),url:i.trim(),title:null==o?void 0:o.trim()}}return null}parseClipboard(){return e(this,void 0,void 0,function*(){try{const t=yield this.readClipboard(),e=t["text/plain"];if(e){const t=this.parseMarkdownImageLink(e);if(t)return this.linkText=t.title,this.linkUrl=t.url,this.linkAlias=t.quotedTitle||"",(t.width||t.height)&&(this.isEmbed=!0,this.imageWidth=t.width||"",this.imageHeight=t.height||""),void this.updateUI();const i=this.parseMarkdownLink(e);if(i)return this.linkText=i.text,this.linkUrl=i.url,this.linkAlias=i.title||"",this.isEmbed=!1,void this.updateUI()}if(t["text/html"]){const e=this.parseHtmlContent(t["text/html"]);e&&(this.linkText=this.linkText||e.title,this.linkUrl=e.url)}else if(t["text/markdown"]){const e=this.parseMarkdownContent(t["text/markdown"]);e&&(this.linkText=this.linkText||e.title,this.linkUrl=e.url)}else if(t["text/plain"]){const e=this.parseMixedContent(t["text/plain"]);e&&(this.linkText=this.linkText||e.title,this.linkUrl=e.url)}this.updateUI()}catch(t){console.error("Failed to read clipboard:",t)}})}readClipboard(){return e(this,void 0,void 0,function*(){const t={};try{const e=yield navigator.clipboard.read();for(const i of e){const e=i.types;for(const o of e)if("text/html"===o||"text/plain"===o||"text/markdown"===o){const e=yield i.getType(o);t[o]=yield e.text()}}}catch(e){try{const e=yield navigator.clipboard.readText();t["text/plain"]=e}catch(t){console.error("Failed to read clipboard:",t)}}return t})}parseHtmlContent(t){var e;const i=(new DOMParser).parseFromString(t,"text/html"),o=i.querySelector("a");if(o)return{title:(null===(e=o.textContent)||void 0===e?void 0:e.trim())||"",url:o.href};const n=i.body.textContent||"";return this.parseMixedContent(n)}parseMarkdownContent(t){const e=t.match(/\[([^\]]+)\]\(([^)]+)\)/);return e?{title:e[1].trim(),url:e[2].trim()}:this.parseMixedContent(t)}onOpen(){this.display()}updateHeader(){const t=this.getPreviewText();this.previewSetting&&(this.previewSetting.controlEl.querySelector("input").value=t)}getPreviewText(){const t=this.linkText||"",e=this.linkUrl;let i=this.isEmbed?"!":"";return i+=`[${t}`,this.isEmbed&&(this.imageWidth||this.imageHeight)&&(i+="|",this.imageWidth&&this.imageHeight?i+=`${this.imageWidth}x${this.imageHeight}`:this.imageWidth?i+=this.imageWidth:this.imageHeight&&(i+=`x${this.imageHeight}`)),i+=`](${e}`,this.linkAlias&&(i+=` "${this.linkAlias}"`),i+=")",i}display(){return e(this,void 0,void 0,function*(){const{contentEl:i}=this;i.empty(),i.addClass("insert-link-modal"),this.titleEl.textContent="",this.titleEl.addClass("insert-link-modal-title"),i.addEventListener("keydown",t=>{"Enter"===t.key&&(t.ctrlKey||t.metaKey)&&(t.preventDefault(),this.insertButton&&this.insertButton.click())});new t.Setting(i).addButton(i=>{i.setIcon("lucide-globe").setTooltip(Jr("Fetch Remote Title")).onClick(()=>e(this,void 0,void 0,function*(){if(this.linkUrl){i.setDisabled(!0),i.setIcon("lucide-loader");const t=yield this.fetchRemoteTitle(this.linkUrl);i.setIcon("lucide-globe"),i.setDisabled(!1),this.linkText=t,this.linkTextInput.setValue(t),this.updateHeader()}else new t.Notice(Jr("Please enter a URL first"))}))}).setName(Jr("Link Text")).addText(t=>{this.linkTextInput=t,t.setPlaceholder(Jr("Link Text")).setValue(this.linkText).onChange(t=>{this.linkText=t,this.updateHeader()})});const o=new t.Setting(i).setName(Jr("Title")).addText(t=>{this.linkAliasInput=t,t.setPlaceholder(Jr("Link Title (optional)")).setValue(this.linkAlias).onChange(t=>{this.linkAlias=t,this.updateHeader()})}),n=new t.Setting(i).setName(Jr("Link URL")).setClass("link-url-setting").addText(t=>{this.linkUrlInput=t,t.setPlaceholder(Jr("Link URL")).setValue(this.linkUrl).onChange(t=>{this.linkUrl=t.trim(),this.validateUrl(this.linkUrl),this.updateHeader()})}).addButton(t=>{t.setIcon("lucide-clipboard").setTooltip(Jr("Paste and Parse")).onClick(()=>e(this,void 0,void 0,function*(){yield this.parseClipboard(),this.updateHeader()}))});this.urlErrorMsg=n.descEl.createDiv("url-error"),this.urlErrorMsg.style.color="var(--text-error)",this.urlErrorMsg.style.display="none";const s=new t.Setting(i).setName(Jr("Embed Content")).setDesc(Jr("If it is an image, turn on"));this.embedToggle=new t.ToggleComponent(s.controlEl),this.embedToggle.setValue(this.isEmbed).onChange(t=>{this.isEmbed=t;const e=i.querySelector(".image-size-setting");o.settingEl,e&&(e.style.display=t?"flex":"none"),this.updateHeader()});const r=new t.Setting(i).addButton(t=>{t.setIcon("lucide-maximize").setTooltip(Jr("Fit Editor Width")).onClick(()=>{var t;const e=this.getImageDimensions();e&&(this.imageWidth=e.width.toString(),this.imageHeight=null===(t=e.height)||void 0===t?void 0:t.toString(),r.components[1].setValue(this.imageWidth),this.imageHeight&&r.components[2].setValue(this.imageHeight),this.updateHeader())})});r.setClass("image-size-setting").setName(Jr("Image Size")).addText(t=>{t.inputEl.addClass("image-width-input"),t.setPlaceholder(Jr("Image Width")).setValue(this.imageWidth).onChange(e=>{this.imageWidth=e.replace(/[^\d]/g,""),t.setValue(this.imageWidth),this.updateHeader()})});const a=r.controlEl.createDiv("image-size-icon");t.setIcon(a,"lucide-x"),r.addText(t=>{t.inputEl.addClass("image-height-input"),t.setPlaceholder(Jr("Image Height")).setValue(this.imageHeight).onChange(e=>{this.imageHeight=e.replace(/[^\d]/g,""),t.setValue(this.imageHeight),this.updateHeader()})}),r.settingEl.style.display=this.isEmbed?"block":"none",new t.Setting(i).setName(Jr("Insert New Line")).setDesc(Jr("Insert a link on the next line")).addToggle(t=>{t.setValue(this.insertNewLine).onChange(t=>{this.insertNewLine=t,this.updateHeader()})}),this.previewSetting=new t.Setting(i).setClass("preview-setting").setTooltip(this.getPreviewText()).addText(t=>{t.setValue(this.getPreviewText()).inputEl.setAttribute("readonly","true")});const l=i.createDiv("shortcut-hint");l.setText(`${t.Platform.isMacOS?"⌘":"Ctrl"} + Enter ${Jr("to insert")}`),l.style.textAlign="right",l.style.fontSize="0.8em",l.style.opacity="0.7",l.style.marginTop="5px",new t.Setting(i).addButton(t=>{t.setButtonText(Jr("Insert")).setCta().onClick(()=>{this.insertLink(),this.close()}),this.insertButton=t.buttonEl}).addButton(t=>t.setButtonText(Jr("Cancel")).onClick(()=>{this.close()})),setTimeout(()=>{this.linkText||this.linkUrl?!this.linkText&&this.linkUrl?this.linkTextInput.inputEl.focus():this.linkText&&!this.linkUrl?this.linkUrlInput.inputEl.focus():this.linkAliasInput.inputEl.focus():this.linkTextInput.inputEl.focus()},10)})}fetchRemoteTitle(t){return e(this,void 0,void 0,function*(){return Uc.fetchRemoteTitle(t)})}getImageDimensions(){const e=this.app.workspace.getActiveViewOfType(t.MarkdownView);if(!e)return null;const i=e.contentEl.querySelector(".markdown-source-view .cm-content"),o=e.contentEl;if(!i||!o)return null;const n=i.offsetWidth,s=o.offsetHeight,r=Math.floor(s/2);if("preview"===e.getMode()||"source"===e.getMode()){const t=i.querySelectorAll("img");if(t.length>0){let e=null;if(this.linkUrl&&t.forEach(t=>{t.src===this.linkUrl&&t.complete&&t.naturalWidth>0&&(e=t)}),e){const t=e.naturalWidth,i=t/e.naturalHeight;let o=Math.min(t,Math.floor(.65*n)),s=Math.floor(o/i);return s>r&&(s=r,o=Math.floor(s*i)),{width:o,height:s}}}}const a=Math.floor(r*(4/3));return{width:Math.min(Math.floor(.65*n),a),height:null}}validateUrl(t){return t?this.isValidUrl(t)?(this.urlErrorMsg.style.display="none",!0):(this.urlErrorMsg.textContent=Jr("URL Format Error"),this.urlErrorMsg.style.display="block",!1):(this.urlErrorMsg.style.display="none",!0)}insertLink(){if(!this.validateUrl(this.linkUrl))return;const t=this.plugin.commandsManager.getActiveEditor();if(!t)return;let e=this.linkText||this.linkUrl;const i=this.linkUrl;let o,n=this.isEmbed?"!":"";n+=`[${e}`,this.isEmbed&&(this.imageWidth||this.imageHeight)&&(n+="|",this.imageWidth&&this.imageHeight?n+=`${this.imageWidth}x${this.imageHeight}`:this.imageWidth?n+=this.imageWidth:this.imageHeight&&(n+=`x${this.imageHeight}`)),n+=`](${i}`,this.linkAlias&&(n+=` "${this.linkAlias}"`),n+=")";if(t.somethingSelected()){const e=t.getCursor("from"),i=t.getCursor("to");if(this.insertNewLine)t.replaceRange("\n"+n,{line:i.line,ch:t.getLine(i.line).length}),o={line:i.line+1,ch:n.length};else{const s=this.prefixText+n+this.suffixText;t.replaceRange(s,{line:e.line,ch:e.ch},i),o={line:e.line,ch:this.prefixText.length+n.length}}}else{const e=t.getCursor(),i=t.getLine(e.line);if(this.insertNewLine){const s=e.line+1;t.replaceRange("\n",{line:e.line,ch:i.length}),t.setCursor({line:s,ch:0}),t.replaceRange(n,{line:s,ch:0}),o={line:s,ch:n.length}}else t.replaceRange(n,e),o={line:e.line,ch:e.ch+n.length}}setTimeout(()=>{o&&t.setCursor(o),t.focus()},0)}updateUI(){this.linkTextInput&&this.linkTextInput.setValue(this.linkText),this.linkUrlInput&&(this.linkUrlInput.setValue(this.linkUrl),this.validateUrl(this.linkUrl));const t=this.contentEl.querySelector(".image-width-input"),e=this.contentEl.querySelector(".image-height-input");t&&(t.value=this.imageWidth),e&&(e.value=this.imageHeight),this.linkAliasInput&&this.linkAliasInput.setValue(this.linkAlias);const i=this.contentEl.querySelector(".setting-item:nth-child(2)");i&&(i.style.display="flex"),this.updateHeader()}}class Yc{constructor(t){this.executeCommandWithoutBlur=(t,i)=>e(this,void 0,void 0,function*(){t&&(yield i(),t.focus())}),this._commandsMap={hrline:{char:5,line:1,prefix:"\n---",suffix:"\n",islinehead:!0},justify:{char:0,line:0,prefix:'<p align="justify">',suffix:"</p>",islinehead:!1},left:{char:0,line:0,prefix:'<p align="left">',suffix:"</p>",islinehead:!1},right:{char:0,line:0,prefix:'<p align="right">',suffix:"</p>",islinehead:!1},center:{char:0,line:0,prefix:"<center>",suffix:"</center>",islinehead:!1},underline:{char:0,line:0,prefix:"<u>",suffix:"</u>",islinehead:!1},superscript:{char:0,line:0,prefix:"<sup>",suffix:"</sup>",islinehead:!1},subscript:{char:0,line:0,prefix:"<sub>",suffix:"</sub>",islinehead:!1},codeblock:{char:4,line:0,prefix:"\n```\n",suffix:"\n```\n",islinehead:!1}},this.modCommands=[{id:"editor:insert-embed",name:"Insert Embed",icon:"note-glyph"},{id:"editor:insert-link",name:"Insert Link",icon:"link-glyph"},{id:"editor:insert-tag",name:"Insert Tag",icon:"price-tag-glyph"},{id:"editor:insert-wikilink",name:"Insert Internal link",icon:"bracket-glyph"},{id:"editor:toggle-code",name:"Insert Code",icon:"code-glyph"},{id:"editor:toggle-blockquote",name:"Insert Blockquote",icon:"lucide-text-quote"},{id:"editor:toggle-checklist-status",name:"Cycle List and Checklist",icon:"checkbox-glyph"},{id:"editor:toggle-comments",name:"Insert Comment",icon:"percent-sign-glyph"},{id:"editor:insert-callout",name:"Insert Callout",icon:"lucide-quote"},{id:"editor:insert-mathblock",name:"Insert MathBlock",icon:"lucide-sigma-square"},{id:"editor:insert-table",name:"Insert Table",icon:"lucide-table"},{id:"editor:swap-line-up",name:"Swap Line Up",icon:"lucide-corner-right-up"},{id:"editor:swap-line-down",name:"Swap Line Down",icon:"lucide-corner-right-down"},{id:"editor:attach-file",name:"Attach File",icon:"lucide-paperclip"},{id:"editor:clear-formatting",name:"Clear Formatting",icon:"lucide-eraser"}],this.applyCommand=(t,e)=>{const i=e.getSelection(),o=e.getCursor("from"),n=e.getCursor("to");let s=t.prefix;t.islinehead&&o.ch>0&&(s="\n"+s);const r=t.suffix,a={line:o.line-t.line,ch:o.ch-s.length};if(e.getRange(a,o)==s){const l={line:o.line+t.line,ch:n.ch+r.length};if(e.getRange(n,l)==r){e.replaceRange(i,a,l),e.setCursor(o.line-t.line,o.ch);const n={line:o.line,ch:o.ch-s.length},r={line:o.line,ch:n.ch+i.length};return void e.setSelection(n,r)}}if(e.replaceSelection(`${s}${i}${r}`),t.char>0)e.setCursor(o.line+t.line,o.ch+t.char+i.length);else{const t=o,n={line:t.line,ch:t.ch+s.length},r={line:t.line,ch:n.ch+i.length};e.setSelection(n,r)}},this.plugin=t}applyRegexCommand(i,o){return e(this,void 0,void 0,function*(){try{let e=i.getSelection(),n=i.getCursor("from"),s=i.getCursor("to");if(!e)if(this.plugin.settings.useCurrentLineForRegex){const o=n.line,r=i.getLine(o);if(!r||""===r.trim())return void new t.Notice(Jr("Current line is empty, please select text or move to a non-empty line"));e=r,n={line:o,ch:0},s={line:o,ch:r.length},i.setSelection(n,s)}else try{const o=yield this.readClipboard();if(e=o["text/html"]?t.htmlToMarkdown(o["text/html"]):o["text/markdown"]||o["text/plain"],!e)return void new t.Notice(Jr("Please select text or copy text to clipboard first"));i.replaceRange(e,n,n);const s=i.offsetToPos(i.posToOffset(n)+e.length);i.setSelection(n,s)}catch(e){return console.error("读取剪贴板失败:",e),void new t.Notice(Jr("Please select text first"))}if(o.useCondition&&o.conditionPattern){if(!new RegExp(o.conditionPattern).test(e))return void new t.Notice(Jr("The selected text does not meet the condition requirements"))}let r="";!1!==o.regexGlobal&&(r+="g"),o.regexCaseInsensitive&&(r+="i"),o.regexMultiline&&(r+="m");const a=new RegExp(o.regexPattern,r),l=i.getCursor("from"),c=i.getCursor("to");i.transaction({changes:[{from:l,to:c,text:e.replace(a,o.regexReplacement)}]});const h=i.getSelection(),d=i.offsetToPos(i.posToOffset(l)),u=i.offsetToPos(i.posToOffset(l)+h.length);i.setSelection(d,u)}catch(e){console.error("正则表达式命令执行错误:",e),new t.Notice(Jr("Regex command execution error: ")+e.message)}})}readClipboard(){return e(this,void 0,void 0,function*(){const t={};try{const e=yield navigator.clipboard.read();for(const i of e){const e=i.types;for(const o of e)if("text/html"===o||"text/plain"===o||"text/markdown"===o){const e=yield i.getType(o);t[o]=yield e.text()}}}catch(e){try{const e=yield navigator.clipboard.readText();t["text/plain"]=e}catch(t){console.error("读取剪贴板失败:",t)}}return t})}getActiveEditor(){var t,e,i;const o=null===(t=this.plugin.app.workspace)||void 0===t?void 0:t.activeEditor;if(o&&o.editor)return o.editor;const n=null===(i=null===(e=this.plugin.app.workspace.activeLeaf)||void 0===e?void 0:e.view)||void 0===i?void 0:i.editor;return n||null}registerCommands(){this.plugin.addCommand({id:"renumber-ordered-list",name:"Renumber Ordered List",editorCallback:t=>{t&&this.executeCommandWithoutBlur(t,()=>Vr(t))}}),this.plugin.addCommand({id:"hide-show-menu",name:"Hide/Show ",icon:"editingToolbar",callback:()=>e(this,void 0,void 0,function*(){this.plugin.settings.cMenuVisibility=!this.plugin.settings.cMenuVisibility,this.plugin.settings.cMenuVisibility?setTimeout(()=>{dispatchEvent(new Event("editingToolbar-NewCommand"))},100):$r(this.plugin.settings.cMenuVisibility),ha(this.plugin),yield this.plugin.saveSettings()})}),this.plugin.addCommand({id:"toggle-top-toolbar",name:"Toggle Top Toolbar",callback:()=>e(this,void 0,void 0,function*(){const t=this.plugin.settings,e=this.plugin.positionStyle;t.enableTopToolbar=!t.enableTopToolbar;let i=null;t.enableTopToolbar?i="top":"top"===e&&(i=t.enableFollowingToolbar?"following":t.enableFixedToolbar?"fixed":null),i&&i!==e&&this.plugin.onPositionStyleChange(i),yield this.plugin.saveSettings(),this.plugin.handleeditingToolbar()})}),this.plugin.addCommand({id:"toggle-following-toolbar",name:"Toggle Following Toolbar",callback:()=>e(this,void 0,void 0,function*(){const t=this.plugin.settings,e=this.plugin.positionStyle;t.enableFollowingToolbar=!t.enableFollowingToolbar;let i=null;t.enableFollowingToolbar?i="following":"following"===e&&(i=t.enableTopToolbar?"top":t.enableFixedToolbar?"fixed":null),i&&i!==e&&this.plugin.onPositionStyleChange(i),yield this.plugin.saveSettings(),this.plugin.handleeditingToolbar()})}),this.plugin.addCommand({id:"toggle-fixed-toolbar",name:"Toggle Fixed Toolbar",callback:()=>e(this,void 0,void 0,function*(){const t=this.plugin.settings,e=this.plugin.positionStyle;t.enableFixedToolbar=!t.enableFixedToolbar;let i=null;t.enableFixedToolbar?i="fixed":"fixed"===e&&(i=t.enableTopToolbar?"top":t.enableFollowingToolbar?"following":null),i&&i!==e&&this.plugin.onPositionStyleChange(i),yield this.plugin.saveSettings(),this.plugin.handleeditingToolbar()})}),this.plugin.addCommand({id:"format-eraser",name:"Format Eraser",callback:()=>{const t=this.getActiveEditor();t&&this.executeCommandWithoutBlur(t,()=>va(this.plugin,t))},icon:"eraser"}),this.plugin.addCommand({id:"change-font-color",name:"Change Font Color",callback:()=>{const t=this.getActiveEditor();t&&this.executeCommandWithoutBlur(t,()=>{var e;return Pr(null!==(e=this.plugin.settings.cMenuFontColor)&&void 0!==e?e:"#2DC26B",t)})},icon:'<svg width="24" height="24" focusable="false" fill="currentColor"><g fill-rule="evenodd"><path id="change-font-color-icon" d="M3 18h18v3H3z" style="fill:#2DC26B"></path><path d="M8.7 16h-.8a.5.5 0 01-.5-.6l2.7-9c.1-.3.3-.4.5-.4h2.8c.2 0 .4.1.5.4l2.7 9a.5.5 0 01-.5.6h-.8a.5.5 0 01-.4-.4l-.7-2.2c0-.3-.3-.4-.5-.4h-3.4c-.2 0-.4.1-.5.4l-.7 2.2c0 .3-.2.4-.4.4zm2.6-7.6l-.6 2a.5.5 0 00.5.6h1.6a.5.5 0 00.5-.6l-.6-2c0-.3-.3-.4-.5-.4h-.4c-.2 0-.4.1-.5.4z"></path></g></svg>'}),this.plugin.addCommand({id:"change-background-color",name:"Change Background Color",callback:()=>{const t=this.getActiveEditor();t&&this.executeCommandWithoutBlur(t,()=>{var e;return _r(null!==(e=this.plugin.settings.cMenuBackgroundColor)&&void 0!==e?e:"#FA541C",t)})},icon:'<svg width="18" height="24" viewBox="0 0 256 256" version="1.1" xmlns="http://www.w3.org/2000/svg"><g stroke="none" stroke-width="1" fill="currentColor" fill-rule="evenodd"><g ><g fill="currentColor"><g transform="translate(119.502295, 137.878331) rotate(-135.000000) translate(-119.502295, -137.878331) translate(48.002295, 31.757731)" ><path d="M100.946943,60.8084699 L43.7469427,60.8084699 C37.2852111,60.8084699 32.0469427,66.0467383 32.0469427,72.5084699 L32.0469427,118.70847 C32.0469427,125.170201 37.2852111,130.40847 43.7469427,130.40847 L100.946943,130.40847 C107.408674,130.40847 112.646943,125.170201 112.646943,118.70847 L112.646943,72.5084699 C112.646943,66.0467383 107.408674,60.8084699 100.946943,60.8084699 Z M93.646,79.808 L93.646,111.408 L51.046,111.408 L51.046,79.808 L93.646,79.808 Z" fill-rule="nonzero"></path><path d="M87.9366521,16.90916 L87.9194966,68.2000001 C87.9183543,69.4147389 86.9334998,70.399264 85.7187607,70.4 L56.9423078,70.4 C55.7272813,70.4 54.7423078,69.4150264 54.7423078,68.2 L54.7423078,39.4621057 C54.7423078,37.2523513 55.5736632,35.1234748 57.0711706,33.4985176 L76.4832996,12.4342613 C78.9534987,9.75382857 83.1289108,9.5834005 85.8093436,12.0535996 C87.1658473,13.303709 87.9372691,15.0644715 87.9366521,16.90916 Z" fill-rule="evenodd"></path><path d="M131.3,111.241199 L11.7,111.241199 C5.23826843,111.241199 0,116.479467 0,122.941199 L0,200.541199 C0,207.002931 5.23826843,212.241199 11.7,212.241199 L131.3,212.241199 C137.761732,212.241199 143,207.002931 143,200.541199 L143,122.941199 C143,116.479467 137.761732,111.241199 131.3,111.241199 Z M124,130.241 L124,193.241 L19,193.241 L19,130.241 L124,130.241 Z" fill-rule="nonzero"></path></g></g><path d="M51,218 L205,218 C211.075132,218 216,222.924868 216,229 C216,235.075132 211.075132,240 205,240 L51,240 C44.9248678,240 40,235.075132 40,229 C40,222.924868 44.9248678,218 51,218 Z" id="change-background-color-icon" style="fill:#FA541C"></path></g></g></svg>'}),this.plugin.addCommand({id:"indent-list",name:"Indent List",callback:()=>{const t=this.getActiveEditor();t&&this.executeCommandWithoutBlur(t,()=>null==t?void 0:t.indentList())},icon:"indent-glyph"}),this.plugin.addCommand({id:"undent-list",name:"Unindent List",callback:()=>{const t=this.getActiveEditor();t&&this.executeCommandWithoutBlur(t,()=>null==t?void 0:t.unindentList())},icon:"unindent-glyph"}),this.plugin.addCommand({id:"toggle-numbered-list",name:"Numbered List",callback:()=>{const t=this.getActiveEditor();t&&this.executeCommandWithoutBlur(t,()=>null==t?void 0:t.toggleNumberList())},icon:"number-list-glyph"}),this.plugin.addCommand({id:"toggle-bullet-list",name:"Unordered List",callback:()=>{const t=this.getActiveEditor();t&&this.executeCommandWithoutBlur(t,()=>null==t?void 0:t.toggleBulletList())},icon:"bullet-list-glyph"}),this.plugin.addCommand({id:"toggle-highlight",name:"Highlight",callback:()=>{const t=this.getActiveEditor();t&&this.executeCommandWithoutBlur(t,()=>null==t?void 0:t.toggleMarkdownFormatting("highlight"))},icon:"highlight-glyph"}),this.plugin.addCommand({id:"toggle-bold",name:"Toggle Bold",callback:()=>{const t=this.getActiveEditor();t&&this.executeCommandWithoutBlur(t,()=>{t.toggleMarkdownFormatting("bold")})},icon:"bold-glyph"}),this.plugin.addCommand({id:"toggle-italics",name:"Toggle Italics",callback:()=>{const t=this.getActiveEditor();t&&this.executeCommandWithoutBlur(t,()=>null==t?void 0:t.toggleMarkdownFormatting("italic"))},icon:"italic-glyph"}),this.plugin.addCommand({id:"toggle-strikethrough",name:"Toggle Strikethrough",callback:()=>{const t=this.getActiveEditor();t&&this.executeCommandWithoutBlur(t,()=>null==t?void 0:t.toggleMarkdownFormatting("strikethrough"))},icon:"strikethrough-glyph"}),this.plugin.addCommand({id:"toggle-inline-math",name:"Toggle Inline Math",callback:()=>{const t=this.getActiveEditor();t&&this.executeCommandWithoutBlur(t,()=>null==t?void 0:t.toggleMarkdownFormatting("math"))},icon:"lucide-sigma"}),this.plugin.addCommand({id:"editor:cycle-list-checklist",name:"Cycle List and Checklist",icon:"lucide-check-square",callback:()=>{const t=this.getActiveEditor();t&&this.executeCommandWithoutBlur(t,()=>null==t?void 0:t.toggleCheckList(!0))}}),this.plugin.addCommand({id:"editor-undo",name:"Undo Edit",callback:()=>{const t=this.getActiveEditor();t&&this.executeCommandWithoutBlur(t,()=>null==t?void 0:t.undo())},icon:"undo-glyph"}),this.plugin.addCommand({id:"editor-redo",name:"Redo Edit",callback:()=>{const t=this.getActiveEditor();t&&this.executeCommandWithoutBlur(t,()=>null==t?void 0:t.redo())},icon:"redo-glyph"}),this.plugin.addCommand({id:"editor-copy",name:"Copy",callback:()=>{const t=this.getActiveEditor();t&&this.executeCommandWithoutBlur(t,()=>e(this,void 0,void 0,function*(){try{yield window.navigator.clipboard.writeText(t.getSelection()),this.plugin.app.commands.executeCommandById("editor:focus")}catch(t){console.error("Copy failed:",t)}}))},icon:"lucide-copy"}),this.plugin.addCommand({id:"editor-paste",name:"Paste",callback:()=>{const t=this.getActiveEditor();t&&this.executeCommandWithoutBlur(t,()=>e(this,void 0,void 0,function*(){try{const e=yield window.navigator.clipboard.readText();e&&t.replaceSelection(e),this.plugin.app.commands.executeCommandById("editor:focus")}catch(t){console.error("Paste failed:",t)}}))},icon:"lucide-clipboard-type"}),this.plugin.addCommand({id:"editor-cut",name:"Cut",callback:()=>{const t=this.getActiveEditor();t&&this.executeCommandWithoutBlur(t,()=>e(this,void 0,void 0,function*(){try{yield window.navigator.clipboard.writeText(t.getSelection()),t.replaceSelection(""),this.plugin.app.commands.executeCommandById("editor:focus")}catch(t){console.error("Cut failed:",t)}}))},icon:"lucide-scissors"}),this.plugin.addCommand({id:"insert-callout",name:"Insert Callout(Modal)",icon:"lucide-quote",callback:()=>{new $c(this.plugin).open()}}),this.plugin.addCommand({id:"insert-link",name:"Insert Link(Modal)",icon:"lucide-link",callback:()=>{new jc(this.plugin).open()}}),this.plugin.addCommand({id:"fullscreen-focus",name:"Toggle Fullscreen Focus Mode",hotkeys:[{modifiers:["Mod","Shift"],key:"F11"}],callback:()=>function(e){var i;Object.defineProperty(exports,"__esModule",{value:!0}),exports.toggleFull=exports.isFull=exports.exitFull=exports.beFull=void 0;let o=document.documentElement,n=o.querySelector("head"),s=document.createElement("style"),r="requestFullscreen",a="exitFullscreen",l="fullscreenElement";"webkitRequestFullScreen"in o?(r="webkitRequestFullScreen",a="webkitExitFullscreen",l="webkitFullscreenElement"):"msRequestFullscreen"in o?(r="msRequestFullscreen",a="msExitFullscreen",l="msFullscreenElement"):"mozRequestFullScreen"in o?(r="mozRequestFullScreen",a="mozCancelFullScreen",l="mozFullScreenElement"):"requestFullscreen"in o||console.log("当前浏览器不支持Fullscreen API !");const c=e.workspace.getActiveViewOfType(t.MarkdownView);if(!c)return;let h,d=c.containerEl,u=null===(i=document.body)||void 0===i?void 0:i.querySelector(".mod-vertical.mod-root .workspace-tab-container");function p(t){return t[r]()}function m(){return o.contains(s)&&(null==n||n.removeChild(s)),document[a]()}function g(t){return t===document[l]}h=new MutationObserver(function(t){t.forEach(function(t){t.addedNodes.forEach(function(t){if(g(u))try{document.body.removeChild(t),d.appendChild(t)}catch(t){console.log(t.message)}})})}),u.addEventListener("fullscreenchange",function(){g(u)||h.disconnect()}),g(u)?(h.disconnect(),m()):(p(u),h.observe(document.body,{childList:!0})),exports.beFull=p,exports.exitFull=m,exports.isFull=g,exports.toggleFull=function(t){return g(t)?(m(),!1):(p(t),!0)}}(app),icon:"fullscreen"}),this.plugin.addCommand({id:"workplace-fullscreen-focus",name:"Toggle Workplace Fullscreen Focus",callback:()=>function(e){Hc=t.requireApiVersion("0.15.0")?activeWindow.document:window.document;let i=Hc;e.workspace.leftSplit.collapsed&&e.workspace.rightSplit.collapsed?(e.commands.executeCommandById("app:toggle-right-sidebar"),e.commands.executeCommandById("app:toggle-left-sidebar"),e.workspace.leftRibbon.show(),i.body.classList.contains("auto-hide-header")&&i.body.classList.remove("auto-hide-header")):(i.body.classList.contains("auto-hide-header")||i.body.classList.add("auto-hide-header"),e.workspace.leftRibbon.hide(),e.workspace.leftSplit.collapsed||e.commands.executeCommandById("app:toggle-left-sidebar"),e.workspace.rightSplit.collapsed||e.commands.executeCommandById("app:toggle-right-sidebar"))}(app),hotkeys:[{modifiers:["Mod"],key:"F11"}],icon:"remix-SplitCellsHorizontal"});for(let t=0;t<=6;t++)this.plugin.addCommand({id:`header${t}-text`,name:0===t?"Remove header level":`Header ${t}`,callback:()=>{const e=this.getActiveEditor();e&&this.executeCommandWithoutBlur(e,()=>Fr("#".repeat(t),e))},icon:0===t?"heading-glyph":`header-${t}`});Object.keys(this._commandsMap).forEach(t=>{this.plugin.addCommand({id:`${t}`,name:`Toggle ${t}`,icon:`${t}-glyph`,callback:()=>{const e=this.getActiveEditor();e&&this.executeCommandWithoutBlur(e,()=>{this.applyCommand(this._commandsMap[t],e)})}})}),this.modCommands.forEach(t=>{this.plugin.addCommand({id:`${t.id}`,name:`${t.name}`,icon:`${t.icon}`,callback:()=>{const i=this.getActiveEditor();i&&this.executeCommandWithoutBlur(i,()=>e(this,void 0,void 0,function*(){const e=i.getCursor("to");let o=this.getCharacterOffset(t.id);yield this.plugin.app.commands.executeCommandById(`${t.id}`),0!=o&&i.setCursor(e.line,e.ch+o)}))}})}),this.plugin.addCommand({id:"toggle-format-brush",name:"Toggle Format Brush",icon:"paintbrush",editorCallback:t=>{this.plugin.toggleFormatBrush()}}),this.registerCustomCommands();["toggle-bold","toggle-italics","toggle-strikethrough","toggle-highlight","toggle-code","toggle-blockquote","header0-text","header1-text","header2-text","header3-text","header4-text","header5-text","header6-text","toggle-numbered-list","toggle-bullet-list","format-eraser","indent-list","undent-list","change-font-color","change-background-color",...this.plugin.settings.customCommands.map(t=>`${t.id}`),...Object.keys(this._commandsMap)].forEach(t=>{const e=this.plugin.app.commands.commands[`editing-toolbar:${t}`];if(e&&e.callback){const i=e.callback;e.callback=()=>{i(),this.plugin.setLastExecutedCommand(`editing-toolbar:${t}`)}}})}getCharacterOffset(t){switch(t){case"editor:insert-tag":return 1;case"editor:insert-callout":return 11;default:return 0}}reloadCustomCommands(){this.plugin.settings.customCommands.forEach(t=>{const e=`${t.id}`;this.plugin.app.commands.commands[`editing-toolbar:${e}`]&&delete this.plugin.app.commands.commands[`editing-toolbar:${e}`]}),this.registerCustomCommands()}registerCustomCommands(){this.plugin.settings.customCommands.forEach(t=>{const e=`${t.id}`;this.plugin.addCommand({id:e,name:t.name,icon:t.icon,editorCallback:i=>{if(t.useRegex&&t.regexPattern)i&&this.executeCommandWithoutBlur(i,()=>{this.applyRegexCommand(i,t),this.plugin.setLastExecutedCommand(`editing-toolbar:${e}`)});else{const o={prefix:t.prefix,suffix:t.suffix,char:t.char,line:t.line,islinehead:t.islinehead};this._commandsMap[t.id]=o,i&&this.executeCommandWithoutBlur(i,()=>{this.applyCommand(o,i),this.plugin.setLastExecutedCommand(`editing-toolbar:${e}`)})}}})})}get commandsMap(){return this._commandsMap}}const Gc=["top","following","fixed","mobile"],Zc=["toolbarBackgroundColor","toolbarIconColor","toolbarIconSize","aestheticStyle"];function Kc(t,e){t.appearanceByStyle&&"object"==typeof t.appearanceByStyle||(t.appearanceByStyle={});const i=t.appearanceByStyle;Gc.forEach(t=>{i[t]&&"object"==typeof i[t]||(i[t]={})}),e&&Zc.forEach(e=>{const o=t[e];void 0!==o&&Gc.forEach(t=>{const n=i[t];e in n||(n[e]=o)})})}class Jc extends t.Plugin{constructor(){super(...arguments),this.appearanceEditStyle=null,this.admonitionDefinitions=null,this.lastExecutedCommand=null,this.formatBrushActive=!1,this.formatBrushNotice=null,this.lastCalloutType=null,this.lastExecutedCommandName=null,this.toolbarCache=new Map,this.popoverCache=new Map,this.handleeditingToolbar=()=>{if(this.formatBrushActive||Wc.body.classList.remove("format-brush-cursor"),!this.settings.cMenuVisibility)return void["top","following","fixed"].forEach(t=>{const e=da(this.app,this,t);e&&(e.style.display="none")});const e=this.app.workspace.getActiveViewOfType(t.ItemView);if(!aa.isAllowedViewType(e))return void["top","following","fixed"].forEach(t=>{const e=da(this.app,this,t);e&&(e.style.visibility="hidden")});const i="markdown"===(null==e?void 0:e.getViewType()),o=i&&aa.isSourceMode(e);if(i&&!o)return void["top","following","fixed"].forEach(t=>{const e=da(this.app,this,t);e&&(e.style.visibility="hidden")});const n=[{key:"top",enabled:"function"==typeof this.isTopToolbarActive?this.isTopToolbarActive():this.settings.enableTopToolbar||!this.settings.enableFollowingToolbar&&!this.settings.enableFixedToolbar&&"top"===this.positionStyle},{key:"following",enabled:"function"==typeof this.isFollowingToolbarActive?this.isFollowingToolbarActive():this.settings.enableFollowingToolbar||!this.settings.enableTopToolbar&&!this.settings.enableFixedToolbar&&"following"===this.positionStyle},{key:"fixed",enabled:this.settings.enableFixedToolbar||!this.settings.enableTopToolbar&&!this.settings.enableFollowingToolbar&&"fixed"===this.positionStyle}];for(const{key:t,enabled:e}of n){const i=da(this.app,this,t);if(!e){i&&(i.style.visibility="hidden");continue}i||Ca(this.app,this,t);const o=da(this.app,this,t);o&&(o.style.visibility="following"===t?"hidden":"visible")}},this.handleeditingToolbar_layout=()=>{this.handleeditingToolbar()},this.handleeditingToolbar_resize=()=>{var e;if(!this.settings.cMenuVisibility||!this.isTopToolbarActive())return!1;const i=app.workspace.getActiveViewOfType(t.ItemView);if(!aa.isSourceMode(i))return!1;const o=null!==(e=this.app.workspace.activeLeaf.view.leaf.width)&&void 0!==e?e:0;if(o<=0||this.Leaf_Width===o)return!1;if(this.Leaf_Width=o,this.settings.cMenuWidth&&o){if(o-this.settings.cMenuWidth<78&&o>this.settings.cMenuWidth)return;setTimeout(()=>{!function(e){la=t.requireApiVersion("0.15.0")?activeWindow.document:window.document;const i=la,o=i.querySelectorAll(".editingToolbarModalBar"),n=i.querySelectorAll(".editingToolbarPopoverBar");o.forEach(t=>{t.firstChild&&t.removeChild(t.firstChild),t.remove()}),n.forEach(t=>{t.firstChild&&t.removeChild(t.firstChild),t.remove()}),e&&e.clearToolbarCache()}(this),Ca(app,this)},200)}},this.handleKeyboardSelection=t=>{this.commandsManager.getActiveEditor(),["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Home","End","PageUp","PageDown","ShiftLeft","ShiftRight"].includes(t.code)||t.shiftKey?this.handleTextSelection():!t.shiftKey&&this.isFollowingToolbarActive()&&this.hideToolbarIfNotSelected()}}initPerStyleAppearance(){const t=this.settings;if(!t)return;const e=!t.appearanceByStyle;Kc(t,e);const i=t.appearanceByStyle,o=()=>{const e=this.appearanceEditStyle||this.positionStyle||t.positionStyle||"top";return Gc.includes(e)?e:"top"};Zc.forEach(e=>{if(!(e in t))return;const n=t[e];Object.defineProperty(t,e,{configurable:!0,enumerable:!0,get(){const t=o(),s=i[t];return s&&Object.prototype.hasOwnProperty.call(s,e)?s[e]:n},set(i){const n=o();Kc(t,!1);t.appearanceByStyle[n][e]=i}})})}onload(){var i;return e(this,void 0,void 0,function*(){const o=this.manifest.version;console.log("editingToolbar v"+o+" loaded"),Wc=t.requireApiVersion("0.15.0")?activeWindow.document:window.document,yield this.loadSettings(),this.initPerStyleAppearance(),this.settingTab=new _c(this.app,this),this.addSettingTab(this.settingTab),this.commandsManager=new Yc(this),this.commandsManager.registerCommands();const n=this.commandsManager.getActiveEditor();this.app.workspace.onLayoutReady(()=>{this.statusBar=new zc(this),this.statusBar.init(),setTimeout(()=>{this.settings.cMenuVisibility||this.handleeditingToolbar()},100)}),this.init_evt(Wc,n),t.requireApiVersion("0.15.0")&&this.app.workspace.on("window-open",t=>{this.init_evt(t.doc,n)});const s=(null===(i=this.settings)||void 0===i?void 0:i.lastVersion)||"0.0.0",r=t=>{const e=t.split(".").map(t=>parseInt(t));return{major:e[0]||0,minor:e[1]||0,patch:e[2]||0}},a=r(s);r(o);const l=new Ec(this.app,this),c="0.0.0"===s;c&&l.fixCommandIds();!c&&(a.major<3||3===a.major&&a.minor<1)&&setTimeout(()=>{l.open()},3e3),this.settings.lastVersion=o,yield this.saveSettings();app.plugins.enabledPlugins.has("obsidian-memos")&&this.registerEvent(this.app.workspace.on("thino-editor-created",this.handleeditingToolbar)),this.registerEvent(this.app.workspace.on("active-leaf-change",this.handleeditingToolbar)),this.registerEvent(this.app.workspace.on("layout-change",this.handleeditingToolbar_layout)),this.registerEvent(this.app.workspace.on("resize",this.handleeditingToolbar_resize)),1==this.settings.cMenuVisibility&&setTimeout(()=>{dispatchEvent(new Event("editingToolbar-NewCommand"))},100),this.registerDomEvent(Wc,"contextmenu",e=>{if(this.settings.isLoadOnMobile&&t.Platform.isMobile&&this.isFollowingToolbarActive()){const{target:t}=e;if(t instanceof HTMLElement){null!==t.closest(".cm-editor")&&e.preventDefault()}}}),this.app.workspace.onLayoutReady(()=>e(this,void 0,void 0,function*(){yield this.tryGetAdmonitionTypes()})),this.registerEvent(this.app.workspace.on("editor-menu",(t,e,i)=>{const o=e.getCursor(),n=e.getLine(o.line);/^\d+\.\s/.test(n)&&t.addItem(t=>t.setSection("info").setTitle(Jr("Renumber List")).setIcon("list-restart").onClick(()=>Vr(e)))})),this.registerEvent(this.app.workspace.on("url-menu",(t,e,i)=>{t.addItem(t=>t.setTitle("Edit Link(Modal)").setSection("info").setIcon("link").onClick(()=>{new jc(this).open()}))})),Object.keys(Vc).forEach(e=>{t.addIcon(e,Vc[e])}),this.toolbarIconSize=this.settings.toolbarIconSize,this.positionStyle=this.settings.positionStyle,Wc.documentElement.style.setProperty("--editing-toolbar-background-color",this.settings.toolbarBackgroundColor),Wc.documentElement.style.setProperty("--editing-toolbar-icon-color",this.settings.toolbarIconColor),Wc.documentElement.style.setProperty("--toolbar-icon-size",`${this.settings.toolbarIconSize}px`)})}tryGetAdmonitionTypes(t=0){var i;return e(this,void 0,void 0,function*(){const t=null===(i=this.app.plugins)||void 0===i?void 0:i.getPlugin("obsidian-admonition");t&&this.processAdmonitionTypes(t)})}processAdmonitionTypes(t){const e=t;e.admonitions&&"object"==typeof e.admonitions&&!Array.isArray(e.admonitions)&&Object.keys(e.admonitions).length>0?(Object.keys(e.admonitions),this.admonitionDefinitions=e.admonitions):(console.warn("未能从 admonitionPlugin.admonitions (作为对象) 获取类型。"),this.admonitionDefinitions=null)}isLoadMobile(){var e;let i=window.innerWidth>0?window.innerWidth:screen.width,o=!!(null===(e=this.settings)||void 0===e?void 0:e.isLoadOnMobile)&&this.settings.isLoadOnMobile;return!(t.Platform.isMobileApp&&!o&&i<=768)||(console.log("editing toolbar disable loading on mobile"),!1)}onunload(){this.app.workspace.off("active-leaf-change",this.handleeditingToolbar),this.app.workspace.off("layout-change",this.handleeditingToolbar_layout),this.app.workspace.off("resize",this.handleeditingToolbar_resize),this.formatBrushNotice&&(this.formatBrushNotice.hide(),this.formatBrushNotice=null),this.quiteAllFormatBrushes(),ha(this),console.log("editingToolbar unloaded")}isView(){const e=this.app.workspace.getActiveViewOfType(t.ItemView);return aa.isAllowedViewType(e)}setIS_MORE_Button(t){this.IS_MORE_Button=t}setEN_BG_Format_Brush(t){this.EN_BG_Format_Brush=t}setEN_FontColor_Format_Brush(t){this.EN_FontColor_Format_Brush=t}setEN_Text_Format_Brush(t){this.EN_Text_Format_Brush=t}setTemp_Notice(t){this.Temp_Notice=t}loadSettings(){return e(this,void 0,void 0,function*(){this.settings=Object.assign({},ra,yield this.loadData());if(!this.settings.enableTopToolbar&&!this.settings.enableFollowingToolbar&&!this.settings.enableFixedToolbar&&this.settings.positionStyle){switch(this.settings.positionStyle){case"top":this.settings.enableTopToolbar=!0;break;case"following":this.settings.enableFollowingToolbar=!0;break;case"fixed":this.settings.enableFixedToolbar=!0}yield this.saveSettings()}})}getCurrentCommands(e){if(!this.settings.enableMultipleConfig)return this.settings.menuCommands;let i=e||this.positionStyle;if(this.settings.isLoadOnMobile&&t.Platform.isMobileApp)return this.settings.mobileCommands;switch(i){case"following":return this.settings.followingCommands;case"top":return this.settings.topCommands;case"fixed":return this.settings.fixedCommands;default:return this.settings.menuCommands}}updateCurrentCommands(e,i){if(!this.settings.enableMultipleConfig)return void(this.settings.menuCommands=e);let o=i;switch(o||(o=this.settings.isLoadOnMobile&&t.Platform.isMobileApp?"mobile":this.positionStyle),o){case"following":this.settings.followingCommands=e;break;case"top":this.settings.topCommands=e;break;case"fixed":this.settings.fixedCommands=e;break;case"mobile":this.settings.mobileCommands=e;break;default:this.settings.menuCommands=e}}saveSettings(){return e(this,void 0,void 0,function*(){yield this.saveData(this.settings)})}setLastExecutedCommand(t){this.lastExecutedCommand=t;const e=this.app.commands.commands[t];if(e&&e.name)this.lastExecutedCommandName=e.name;else{const e=t.split(":");this.lastExecutedCommandName=e[e.length-1].replace(/-/g," ")}}toggleFormatBrush(){const e=this.commandsManager.getActiveEditor();let i=!1,o="";if(e)if(e.somethingSelected()){const t=e.getSelection();if(/^\*\*.*\*\*$/.test(t))this.lastExecutedCommand="editor:toggle-bold",this.lastExecutedCommandName="Bold",i=!0;else if(/^\*.*\*$/.test(t)||/^_.*_$/.test(t))this.lastExecutedCommand="editor:toggle-italics",this.lastExecutedCommandName="Italic",i=!0;else if(/^~~.*~~$/.test(t))this.lastExecutedCommand="editor:toggle-strikethrough",this.lastExecutedCommandName="Strikethrough",i=!0;else if(/^==.*==$/.test(t))this.lastExecutedCommand="editor:toggle-highlight",this.lastExecutedCommandName="Highlight",i=!0;else if(/^`.*`$/.test(t))this.lastExecutedCommand="editor:toggle-code",this.lastExecutedCommandName="Code",i=!0;else if(/^<font color=".*">.*<\/font>$/.test(t))this.lastExecutedCommand="editing-toolbar:change-font-color",this.lastExecutedCommandName="Font Color",i=!0;else if(/^<mark style="background:.*">.*<\/mark>$/.test(t))this.lastExecutedCommand="editing-toolbar:change-background-color",this.lastExecutedCommandName="Background Color",i=!0;else if(/^<u>([^<]+)<\/u>$/.test(t))this.lastExecutedCommand="editor:toggle-underline",this.lastExecutedCommandName="Underline",i=!0;else if(/^<center>([^<]+)<\/center>$/.test(t))this.lastExecutedCommand="editing-toolbar:center",this.lastExecutedCommandName="Center",i=!0;else if(/^<p align="left">(.*?)<\/p>$/.test(t))this.lastExecutedCommand="editing-toolbar:left",this.lastExecutedCommandName="Left Align",i=!0;else if(/^<p align="right">(.*?)<\/p>$/.test(t))this.lastExecutedCommand="editing-toolbar:right",this.lastExecutedCommandName="Right Align",i=!0;else if(/^<p align="justify">(.*?)<\/p>$/.test(t))this.lastExecutedCommand="editing-toolbar:justify",this.lastExecutedCommandName="Justify",i=!0;else if(/^<sup>(.*?)<\/sup>$/.test(t))this.lastExecutedCommand="editing-toolbar:superscript",this.lastExecutedCommandName="Superscript",i=!0;else if(/^<sub>(.*?)<\/sub>$/.test(t))this.lastExecutedCommand="editing-toolbar:subscript",this.lastExecutedCommandName="Subscript",i=!0;else if(/^> \[!(note|tip|warning|danger|info|success|question|quote)\]/i.test(t)){const e=t.match(/^> \[!(note|tip|warning|danger|info|success|question|quote)\]/i);e&&(this.lastExecutedCommand="editor:insert-callout",this.lastExecutedCommandName="Callout-"+e[1].toLowerCase(),i=!0,o=e[1].toLowerCase())}else/^# /.test(t)?(this.lastExecutedCommand="editor:set-heading-1",this.lastExecutedCommandName="Heading 1",i=!0):/^## /.test(t)?(this.lastExecutedCommand="editor:set-heading-2",this.lastExecutedCommandName="Heading 2",i=!0):/^### /.test(t)?(this.lastExecutedCommand="editor:set-heading-3",this.lastExecutedCommandName="Heading 3",i=!0):/^#### /.test(t)?(this.lastExecutedCommand="editor:set-heading-4",this.lastExecutedCommandName="Heading 4",i=!0):/^##### /.test(t)?(this.lastExecutedCommand="editor:set-heading-5",this.lastExecutedCommandName="Heading 5",i=!0):/^###### /.test(t)&&(this.lastExecutedCommand="editor:set-heading-6",this.lastExecutedCommandName="Heading 6",i=!0)}else{const t=e.getCursor(),o=e.getLine(t.line),n=t.ch,s=[],r=/<u>([^<]+)<\/u>/g;let a;for(;null!==(a=r.exec(o));){const t=a.index,e=a.index+a[0].length;n>t&&n<e&&s.push({command:"editing-toolbar:toggle-underline",name:"Underline",distance:Math.min(n-t,e-n)})}const l=/<center>([^<]+)<\/center>/g;for(;null!==(a=l.exec(o));){const t=a.index,e=a.index+a[0].length;n>t&&n<e&&s.push({command:"editing-toolbar:center",name:"Center",distance:Math.min(n-t,e-n)})}const c=/<p align="left">([^<]+)<\/p>/g;for(;null!==(a=c.exec(o));){const t=a.index,e=a.index+a[0].length;n>t&&n<e&&s.push({command:"editing-toolbar:left",name:"Left Align",distance:Math.min(n-t,e-n)})}const h=/<p align="right">([^<]+)<\/p>/g;for(;null!==(a=h.exec(o));){const t=a.index,e=a.index+a[0].length;n>t&&n<e&&s.push({command:"editing-toolbar:right",name:"Right Align",distance:Math.min(n-t,e-n)})}const d=/<p align="justify">([^<]+)<\/p>/g;for(;null!==(a=d.exec(o));){const t=a.index,e=a.index+a[0].length;n>t&&n<e&&s.push({command:"editing-toolbar:justify",name:"Justify",distance:Math.min(n-t,e-n)})}const u=/<sup>([^<]+)<\/sup>/g;for(;null!==(a=u.exec(o));){const t=a.index,e=a.index+a[0].length;n>t&&n<e&&s.push({command:"editing-toolbar:superscript",name:"Superscript",distance:Math.min(n-t,e-n)})}const p=/<sub>([^<]+)<\/sub>/g;for(;null!==(a=p.exec(o));){const t=a.index,e=a.index+a[0].length;n>t&&n<e&&s.push({command:"editing-toolbar:subscript",name:"Subscript",distance:Math.min(n-t,e-n)})}const m=/\*\*([^*]+)\*\*/g;for(;null!==(a=m.exec(o));){const t=a.index,e=a.index+a[0].length;n>t&&n<e&&s.push({command:"editor:toggle-bold",name:"Bold",distance:Math.min(n-t,e-n)})}const g=/~~([^~]+)~~/g;for(;null!==(a=g.exec(o));){const t=a.index,e=a.index+a[0].length;n>t&&n<e&&s.push({command:"editor:toggle-strikethrough",name:"Strikethrough",distance:Math.min(n-t,e-n)})}const f=/==([^=]+)==/g;for(;null!==(a=f.exec(o));){const t=a.index,e=a.index+a[0].length;n>t&&n<e&&s.push({command:"editor:toggle-highlight",name:"Highlight",distance:Math.min(n-t,e-n)})}const b=/`([^`]+)`/g;for(;null!==(a=b.exec(o));){const t=a.index,e=a.index+a[0].length;n>t&&n<e&&s.push({command:"editor:toggle-code",name:"Code",distance:Math.min(n-t,e-n)})}const y=/<font color="([^"]+)">([^<]+)<\/font>/g;for(;null!==(a=y.exec(o));){const t=a.index,e=a.index+a[0].length;n>t&&n<e&&s.push({command:"editing-toolbar:change-font-color",name:"Font Color",distance:Math.min(n-t,e-n)})}const v=/<span style="background:([^"]+)">([^<]+)<\/span>/g;for(;null!==(a=v.exec(o));){const t=a.index,e=a.index+a[0].length;n>t&&n<e&&s.push({command:"editing-toolbar:change-background-color",name:"Background Color",distance:Math.min(n-t,e-n)})}if(s.length>0){s.sort((t,e)=>t.distance-e.distance);const t=s[0];this.lastExecutedCommand=t.command,this.lastExecutedCommandName=t.name,i=!0}if(!i){const t=/(\*|_)([^*_]+)(\*|_)/g;for(;null!==(a=t.exec(o));)this.lastExecutedCommand="editor:toggle-italics",this.lastExecutedCommandName="Italic",i=!0}i||(/^# /.test(o)&&n>0?(this.lastExecutedCommand="editor:set-heading-1",this.lastExecutedCommandName="Heading 1",i=!0):/^## /.test(o)&&n>1?(this.lastExecutedCommand="editor:set-heading-2",this.lastExecutedCommandName="Heading 2",i=!0):/^### /.test(o)&&n>2?(this.lastExecutedCommand="editor:set-heading-3",this.lastExecutedCommandName="Heading 3",i=!0):/^#### /.test(o)&&n>3?(this.lastExecutedCommand="editor:set-heading-4",this.lastExecutedCommandName="Heading 4",i=!0):/^##### /.test(o)&&n>4?(this.lastExecutedCommand="editor:set-heading-5",this.lastExecutedCommandName="Heading 5",i=!0):/^###### /.test(o)&&n>5&&(this.lastExecutedCommand="editor:set-heading-6",this.lastExecutedCommandName="Heading 6",i=!0))}i||this.lastExecutedCommand?(this.formatBrushActive=!this.formatBrushActive,this.formatBrushActive?(Wc.body.classList.add("format-brush-cursor"),this.EN_FontColor_Format_Brush=!1,this.EN_BG_Format_Brush=!1,this.EN_Text_Format_Brush=!1,this.lastCalloutType=o,this.formatBrushNotice&&this.formatBrushNotice.hide(),this.formatBrushNotice=new t.Notice(Jr("Format brush ON! Select text to apply【")+this.lastExecutedCommandName+Jr("】format"),0)):(Wc.body.classList.remove("format-brush-cursor"),this.formatBrushNotice&&(this.formatBrushNotice.hide(),this.formatBrushNotice=null))):new t.Notice(Jr("Please execute a format command or select format text first, then enable the format brush"))}applyCalloutFormat(t,e,i){const o=`> [!${i}]\n> ${e.replace(/^> \[!(note|tip|warning|danger|info|success|question|quote)\] ?/i,"").trim().split("\n").map((t,e)=>t.replace(/^\s*>\s*/,"")).join("\n> ")}`;t.replaceSelection(o)}applyFormatBrush(e){if(!this.lastExecutedCommand||!this.formatBrushActive)return;const i=this.app.commands.commands[this.lastExecutedCommand];i&&i.callback&&i.callback(),i&&i.editorCallback&&i.editorCallback(e,this.app.workspace.getActiveViewOfType(t.MarkdownView))}quiteAllFormatBrushes(){this.EN_FontColor_Format_Brush=!1,this.EN_BG_Format_Brush=!1,this.EN_Text_Format_Brush=!1,Wc.body.classList.remove("format-brush-cursor"),this.formatBrushActive&&(this.formatBrushActive=!1,this.formatBrushNotice&&(this.formatBrushNotice.hide(),this.formatBrushNotice=null)),this.Temp_Notice&&(this.Temp_Notice.hide(),this.Temp_Notice=null)}getCommandsManager(){return this.commandsManager}reloadCustomCommands(){this.commandsManager.reloadCustomCommands()}init_evt(e,i){this.resetFormatBrushStates();const o=t.debounce(()=>{this.handleTextSelection()},100);this.registerDomEvent(e,"mousedown",t=>{if(!this.isView()||!this.commandsManager.getActiveEditor())return;const i=Date.now();1===t.button&&this.registerDomEvent(e,"mouseup",t=>{Date.now()-i<300&&1===t.button&&this.handleMiddleClickToolbar(t)}),this.resetFormatBrushIfActive(e,t)}),t.Platform.isMobileApp?this.registerDomEvent(e,"selectionchange",()=>{o()}):this.registerDomEvent(e,"mouseup",t=>{1!==t.button&&o()}),this.registerDomEvent(e,"keyup",this.handleKeyboardSelection),this.registerScrollAndBlurEvents(e)}resetFormatBrushStates(){this.EN_FontColor_Format_Brush=!1,this.EN_BG_Format_Brush=!1,this.EN_Text_Format_Brush=!1,this.formatBrushActive=!1}getCachedToolbar(t){const e=this.toolbarCache.get(t);return e&&e.isConnected?e:(e&&this.toolbarCache.delete(t),null)}setCachedToolbar(t,e){this.toolbarCache.set(t,e)}getCachedPopover(t){const e=this.popoverCache.get(t);return e&&e.isConnected?e:(e&&this.popoverCache.delete(t),null)}setCachedPopover(t,e){this.popoverCache.set(t,e)}clearToolbarCache(t){t?(this.toolbarCache.delete(t),this.popoverCache.delete(t)):(this.toolbarCache.clear(),this.popoverCache.clear())}isTopToolbarActive(){return!!this.settings.enableTopToolbar||!this.settings.enableFollowingToolbar&&!this.settings.enableFixedToolbar&&"top"===this.positionStyle}isFollowingToolbarActive(){return!!this.settings.enableFollowingToolbar||!this.settings.enableTopToolbar&&!this.settings.enableFixedToolbar&&"following"===this.positionStyle}handleMiddleClickToolbar(t){const e=this.commandsManager.getActiveEditor();this.isFollowingToolbarActive()&&(null==e?void 0:e.hasFocus())&&this.showFollowingToolbar(e)}resetFormatBrushIfActive(t,e){if(2===e.button&&this.isFormatBrushActive()){const e=i=>{i.preventDefault(),i.stopPropagation(),t.removeEventListener("contextmenu",e,{capture:!0})};t.addEventListener("contextmenu",e,{capture:!0}),ya(this)}}isFormatBrushActive(){return this.EN_FontColor_Format_Brush||this.EN_BG_Format_Brush||this.EN_Text_Format_Brush||this.formatBrushActive}registerScrollAndBlurEvents(t){const e=this.throttle(()=>{this.isFollowingToolbarActive()&&this.hideToolbarIfNotSelected()},200);this.registerDomEvent(Wc,"wheel",e),this.registerDomEvent(t,"blur",()=>{this.hideToolbarIfNotSelected()})}hideToolbarIfNotSelected(){const t=da(this.app,this,"following");t&&this.isFollowingToolbarActive()&&(t.style.visibility="hidden")}handleTextSelection(){if(!this.isView())return;const t=this.commandsManager.getActiveEditor();(null==t?void 0:t.hasFocus())&&(t.somethingSelected()?this.handleSelectedText(t):this.hideToolbarIfNotSelected())}handleSelectedText(t){this.EN_FontColor_Format_Brush?Pr(this.settings.cMenuFontColor,t):this.EN_BG_Format_Brush?_r(this.settings.cMenuBackgroundColor,t):this.EN_Text_Format_Brush?va(0,t):this.formatBrushActive&&this.lastCalloutType?this.applyCalloutFormat(t,t.getSelection(),this.lastCalloutType):this.formatBrushActive&&this.lastExecutedCommand?this.applyFormatBrush(t):this.isFollowingToolbarActive()&&this.showFollowingToolbar(t)}throttle(t,e=100){let i;return function(...o){const n=this;i||(t.apply(n,o),i=!0,setTimeout(()=>i=!1,e))}}showFollowingToolbar(t){if(!this.isFollowingToolbarActive())return;const e=da(this.app,this,"following");e?(e.style.visibility="visible",e.classList.add("editingToolbarFlex"),e.classList.remove("editingToolbarGrid"),wa(this.app,this.toolbarIconSize,this,t,!0)):wa(this.app,this.toolbarIconSize,this,t,!0)}onPositionStyleChange(e){const i=this.appearanceEditStyle;if(this.appearanceEditStyle=null,this.positionStyle=e,this.settings.positionStyle=e,this.settings.enableMultipleConfig)switch(e){case"following":this.settings.followingCommands&&0!==this.settings.followingCommands.length||(this.settings.followingCommands=[...this.settings.menuCommands],this.saveSettings(),new t.Notice(Jr("Following style commands successfully initialized")));break;case"top":this.settings.topCommands&&0!==this.settings.topCommands.length||(this.settings.topCommands=[...this.settings.menuCommands],this.saveSettings(),new t.Notice(Jr("Top style commands successfully initialized")));break;case"fixed":this.settings.fixedCommands&&0!==this.settings.fixedCommands.length||(this.settings.fixedCommands=[...this.settings.menuCommands],this.saveSettings(),new t.Notice(Jr("Fixed style commands successfully initialized")));break;case"mobile":this.settings.mobileCommands&&0!==this.settings.mobileCommands.length||(this.settings.mobileCommands=[...this.settings.menuCommands],this.saveSettings(),new t.Notice(Jr("Mobile style commands successfully initialized")))}this.toolbarIconSize=this.settings.toolbarIconSize;const o=null!=Wc?Wc:document;o&&o.documentElement&&(o.documentElement.style.setProperty("--editing-toolbar-background-color",this.settings.toolbarBackgroundColor),o.documentElement.style.setProperty("--editing-toolbar-icon-color",this.settings.toolbarIconColor),o.documentElement.style.setProperty("--toolbar-icon-size",`${this.settings.toolbarIconSize}px`)),dispatchEvent(new Event("editingToolbar-NewCommand")),this.appearanceEditStyle=i}}module.exports=Jc;
|
||
|
||
|
||
/* nosourcemap */ |