import{t as e}from"./chunk-6hGRweTZ.js";import{t}from"./codemirror-mxAyinHX.js";var n=e(((e,n)=>{(function(r){typeof e==`object`&&typeof n==`object`?r(t()):typeof define==`function`&&define.amd?define([`../../lib/codemirror`],r):r(CodeMirror)})(function(e){var t={},n=/[^\s\u00a0]/,r=e.Pos,i=e.cmpPos;function a(e){var t=e.search(n);return t==-1?0:t}e.commands.toggleComment=function(e){e.toggleComment()},e.defineExtension(`toggleComment`,function(e){e||=t;for(var n=this,i=1/0,a=this.listSelections(),o=null,s=a.length-1;s>=0;s--){var c=a[s].from(),l=a[s].to();c.line>=i||(l.line>=i&&(l=r(i,0)),i=c.line,o==null?n.uncomment(c,l,e)?o=`un`:(n.lineComment(c,l,e),o=`line`):o==`un`?n.uncomment(c,l,e):n.lineComment(c,l,e))}});function o(e,t,n){return/\bstring\b/.test(e.getTokenTypeAt(r(t.line,0)))&&!/^[\'\"\`]/.test(n)}function s(e,t){var n=e.getMode();return n.useInnerComments===!1||!n.innerMode?n:e.getModeAt(t)}e.defineExtension(`lineComment`,function(e,i,c){c||=t;var l=this,u=s(l,e),d=l.getLine(e.line);if(!(d==null||o(l,e,d))){var f=c.lineComment||u.lineComment;if(!f){(c.blockCommentStart||u.blockCommentStart)&&(c.fullLines=!0,l.blockComment(e,i,c));return}var p=Math.min(i.ch!=0||i.line==e.line?i.line+1:i.line,l.lastLine()+1),m=c.padding==null?` `:c.padding,h=c.commentBlankLines||e.line==i.line;l.operation(function(){if(c.indent){for(var t=null,i=e.line;i<p;++i){var o=l.getLine(i),s=o.search(n)===-1?o:o.slice(0,a(o));(t==null||t.length>s.length)&&(t=s)}for(var i=e.line;i<p;++i){var o=l.getLine(i),u=t.length;!h&&!n.test(o)||(o.slice(0,u)!=t&&(u=a(o)),l.replaceRange(t+f+m,r(i,0),r(i,u)))}}else for(var i=e.line;i<p;++i)(h||n.test(l.getLine(i)))&&l.replaceRange(f+m,r(i,0))})}}),e.defineExtension(`blockComment`,function(e,a,o){o||=t;var c=this,l=s(c,e),u=o.blockCommentStart||l.blockCommentStart,d=o.blockCommentEnd||l.blockCommentEnd;if(!u||!d){(o.lineComment||l.lineComment)&&o.fullLines!=0&&c.lineComment(e,a,o);return}if(!/\bcomment\b/.test(c.getTokenTypeAt(r(e.line,0)))){var f=Math.min(a.line,c.lastLine());f!=e.line&&a.ch==0&&n.test(c.getLine(f))&&--f;var p=o.padding==null?` `:o.padding;e.line>f||c.operation(function(){if(o.fullLines!=0){var t=n.test(c.getLine(f));c.replaceRange(p+d,r(f)),c.replaceRange(u+p,r(e.line,0));var s=o.blockCommentLead||l.blockCommentLead;if(s!=null)for(var m=e.line+1;m<=f;++m)(m!=f||t)&&c.replaceRange(s+p,r(m,0))}else{var h=i(c.getCursor(`to`),a)==0,g=!c.somethingSelected();c.replaceRange(d,a),h&&c.setSelection(g?a:c.getCursor(`from`),a),c.replaceRange(u,e)}})}}),e.defineExtension(`uncomment`,function(e,i,a){a||=t;var o=this,c=s(o,e),l=Math.min(i.ch!=0||i.line==e.line?i.line:i.line-1,o.lastLine()),u=Math.min(e.line,l),d=a.lineComment||c.lineComment,f=[],p=a.padding==null?` `:a.padding,m;lineComment:{if(!d)break lineComment;for(var h=u;h<=l;++h){var g=o.getLine(h),_=g.indexOf(d);if(_>-1&&!/comment/.test(o.getTokenTypeAt(r(h,_+1)))&&(_=-1),_==-1&&n.test(g)||_>-1&&n.test(g.slice(0,_)))break lineComment;f.push(g)}if(o.operation(function(){for(var e=u;e<=l;++e){var t=f[e-u],n=t.indexOf(d),i=n+d.length;n<0||(t.slice(i,i+p.length)==p&&(i+=p.length),m=!0,o.replaceRange(``,r(e,n),r(e,i)))}}),m)return!0}var v=a.blockCommentStart||c.blockCommentStart,y=a.blockCommentEnd||c.blockCommentEnd;if(!v||!y)return!1;var b=a.blockCommentLead||c.blockCommentLead,x=o.getLine(u),S=x.indexOf(v);if(S==-1)return!1;var C=l==u?x:o.getLine(l),w=C.indexOf(y,l==u?S+v.length:0),T=r(u,S+1),E=r(l,w+1);if(w==-1||!/comment/.test(o.getTokenTypeAt(T))||!/comment/.test(o.getTokenTypeAt(E))||o.getRange(T,E,`
`).indexOf(y)>-1)return!1;var D=x.lastIndexOf(v,e.ch),O=D==-1?-1:x.slice(0,e.ch).indexOf(y,D+v.length);if(D!=-1&&O!=-1&&O+y.length!=e.ch)return!1;O=C.indexOf(y,i.ch);var k=C.slice(i.ch).lastIndexOf(v,O-i.ch);return D=O==-1||k==-1?-1:i.ch+k,O!=-1&&D!=-1&&D!=i.ch?!1:(o.operation(function(){o.replaceRange(``,r(l,w-(p&&C.slice(w-p.length,w)==p?p.length:0)),r(l,w+y.length));var e=S+v.length;if(p&&x.slice(e,e+p.length)==p&&(e+=p.length),o.replaceRange(``,r(u,S),r(u,e)),b)for(var t=u+1;t<=l;++t){var i=o.getLine(t),a=i.indexOf(b);if(!(a==-1||n.test(i.slice(0,a)))){var s=a+b.length;p&&i.slice(s,s+p.length)==p&&(s+=p.length),o.replaceRange(``,r(t,a),r(t,s))}}}),!0)})})}));export default n();
//# sourceMappingURL=comment-BjXTrwsC.js.map