import{cD as he,d8 as Vt,ed as O,dP as k,cF as B,eD as zt,fs as Ut,eY as Ee,cc as Wt,ff as Gt,aF as Ae,y as ge,k as $t,bP as Qt,eC as Kt,eA as qt,bp as Xt,E as wt,aS as Jt,r as W,fn as Te,ar as Yt,as as Zt,a0 as De,a8 as en,Z as le,eT as xt,z as tn,fi as J,eJ as nn,a9 as rn,f5 as Ct,d5 as an,al as St,b_ as sn,eE as de,eF as Oe,aO as Fe,fp as ve,co as Pe,ac as ln,m as on,eL as jt,ex as fn,f as cn,eR as un,f0 as hn,c2 as gn,ao as Ie,eH as dn,fq as vn,aE as mn,P as pn,fh as bn,cS as _t,ct as yn,dZ as kn,eB as wn}from"./index-BJCd-jqX.js";import{r as G,C as M}from"./javascript-Bk_sur_c.js";import{P as xn}from"./provisioning-group-row-DYMc8ZIu.js";import{E as Be}from"./eye-SrYybhyh.js";import{S as Cn}from"./switch-CbAGz9pF.js";import{d as Sn,a as jn}from"./acl-gui-utils-umwiOFMz.js";import{M as _n}from"./message-square-more-DhPsni8e.js";const Nn=[["path",{d:"m10 18 3-3-3-3",key:"18f6ys"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M4 11V4a2 2 0 0 1 2-2h9l5 5v13a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2v-3a2 2 0 0 1 2-2h7",key:"50q2rw"}]],Ln=he("file-symlink",Nn);const En=[["line",{x1:"6",x2:"6",y1:"3",y2:"15",key:"17qcm7"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M18 9a9 9 0 0 1-9 9",key:"n2h4wq"}]],An=he("git-branch",En);const Tn=[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1m0v6g"}],["path",{d:"M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z",key:"ohrbg2"}]],Dn=he("square-pen",Tn);const On=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],Fn=he("terminal",On);var He={exports:{}},Ve;function Pn(){return Ve||(Ve=1,(function(i,a){(function(r){r(G())})(function(r){var g={},h=/[^\s\u00a0]/,e=r.Pos,t=r.cmpPos;function n(l){var f=l.search(h);return f==-1?0:f}r.commands.toggleComment=function(l){l.toggleComment()},r.defineExtension("toggleComment",function(l){l||(l=g);for(var f=this,c=1/0,d=this.listSelections(),b=null,w=d.length-1;w>=0;w--){var p=d[w].from(),u=d[w].to();p.line>=c||(u.line>=c&&(u=e(c,0)),c=p.line,b==null?f.uncomment(p,u,l)?b="un":(f.lineComment(p,u,l),b="line"):b=="un"?f.uncomment(p,u,l):f.lineComment(p,u,l))}});function s(l,f,c){return/\bstring\b/.test(l.getTokenTypeAt(e(f.line,0)))&&!/^[\'\"\`]/.test(c)}function o(l,f){var c=l.getMode();return c.useInnerComments===!1||!c.innerMode?c:l.getModeAt(f)}r.defineExtension("lineComment",function(l,f,c){c||(c=g);var d=this,b=o(d,l),w=d.getLine(l.line);if(!(w==null||s(d,l,w))){var p=c.lineComment||b.lineComment;if(!p){(c.blockCommentStart||b.blockCommentStart)&&(c.fullLines=!0,d.blockComment(l,f,c));return}var u=Math.min(f.ch!=0||f.line==l.line?f.line+1:f.line,d.lastLine()+1),m=c.padding==null?" ":c.padding,y=c.commentBlankLines||l.line==f.line;d.operation(function(){if(c.indent){for(var x=null,C=l.line;Cj.length)&&(x=j)}for(var C=l.line;Cu||d.operation(function(){if(c.fullLines!=!1){var y=h.test(d.getLine(u));d.replaceRange(m+p,e(u)),d.replaceRange(w+m,e(l.line,0));var x=c.blockCommentLead||b.blockCommentLead;if(x!=null)for(var C=l.line+1;C<=u;++C)(C!=u||y)&&d.replaceRange(x+m,e(C,0))}else{var _=t(d.getCursor("to"),f)==0,j=!d.somethingSelected();d.replaceRange(p,f),_&&d.setSelection(j?f:d.getCursor("from"),f),d.replaceRange(w,l)}})}}),r.defineExtension("uncomment",function(l,f,c){c||(c=g);var d=this,b=o(d,l),w=Math.min(f.ch!=0||f.line==l.line?f.line:f.line-1,d.lastLine()),p=Math.min(l.line,w),u=c.lineComment||b.lineComment,m=[],y=c.padding==null?" ":c.padding,x;e:{if(!u)break e;for(var C=p;C<=w;++C){var _=d.getLine(C),j=_.indexOf(u);if(j>-1&&!/comment/.test(d.getTokenTypeAt(e(C,j+1)))&&(j=-1),j==-1&&h.test(_)||j>-1&&h.test(_.slice(0,j)))break e;m.push(_)}if(d.operation(function(){for(var P=p;P<=w;++P){var H=m[P-p],q=H.indexOf(u),$=q+u.length;q<0||(H.slice($,$+y.length)==y&&($+=y.length),x=!0,d.replaceRange("",e(P,q),e(P,$)))}}),x)return!0}var v=c.blockCommentStart||b.blockCommentStart,S=c.blockCommentEnd||b.blockCommentEnd;if(!v||!S)return!1;var L=c.blockCommentLead||b.blockCommentLead,N=d.getLine(p),E=N.indexOf(v);if(E==-1)return!1;var T=w==p?N:d.getLine(w),A=T.indexOf(S,w==p?E+v.length:0),D=e(p,E+1),F=e(w,A+1);if(A==-1||!/comment/.test(d.getTokenTypeAt(D))||!/comment/.test(d.getTokenTypeAt(F))||d.getRange(D,F,` `).indexOf(S)>-1)return!1;var I=N.lastIndexOf(v,l.ch),R=I==-1?-1:N.slice(0,l.ch).indexOf(S,I+v.length);if(I!=-1&&R!=-1&&R+S.length!=l.ch)return!1;R=T.indexOf(S,f.ch);var V=T.slice(f.ch).lastIndexOf(v,R-f.ch);return I=R==-1||V==-1?-1:f.ch+V,R!=-1&&I!=-1&&I!=f.ch?!1:(d.operation(function(){d.replaceRange("",e(w,A-(y&&T.slice(A-y.length,A)==y?y.length:0)),e(w,A+S.length));var P=E+v.length;if(y&&N.slice(P,P+y.length)==y&&(P+=y.length),d.replaceRange("",e(p,E),e(p,P)),L)for(var H=p+1;H<=w;++H){var q=d.getLine(H),$=q.indexOf(L);if(!($==-1||h.test(q.slice(0,$)))){var re=$+L.length;y&&q.slice(re,re+y.length)==y&&(re+=y.length),d.replaceRange("",e(H,$),e(H,re))}}}),!0)})})})()),He.exports}Pn();var ze={exports:{}},Ue;function Rn(){return Ue||(Ue=1,(function(i,a){(function(r){r(G())})(function(r){var g=/\S/g,h=String.prototype.repeat||function(s){return Array(s+1).join(this)};function e(s){if(s.getOption("disableInput"))return r.Pass;for(var o=s.listSelections(),l,f=[],c=0;c-1&&/\bcomment\b/.test(s.getTokenTypeAt({line:d.line,ch:u+1}))))if(d.ch>=m.length&&(u=p.lastIndexOf(m,d.ch-m.length))>-1&&u>x)if(t(0,p)>=u)w=p.slice(0,u);else{var C=s.options.tabSize,_;u=r.countColumn(p,u,C),w=s.options.indentWithTabs?h.call(" ",_=Math.floor(u/C))+h.call(" ",u-C*_):h.call(" ",u)}else(u=p.indexOf(l.blockCommentContinue))>-1&&u<=d.ch&&u<=t(0,p)&&(w=p.slice(0,u));w!=null&&(w+=l.blockCommentContinue)}if(w==null&&y&&n(s)){if(p==null&&(p=s.getLine(d.line)),u=p.indexOf(y),!d.ch&&!u)w="";else if(u>-1&&t(0,p)>=u){if(w=t(d.ch,p)>-1,!w){var j=s.getLine(d.line+1)||"",v=j.indexOf(y);w=v>-1&&t(0,j)>=v||null}w&&(w=p.slice(0,u)+y+p.slice(u+y.length).match(/^\s*/)[0])}}if(w==null)return r.Pass;f[c]=` `+w}s.operation(function(){for(var S=o.length-1;S>=0;S--)s.replaceRange(f[S],o[S].from(),o[S].to(),"+insert")})}function t(s,o){g.lastIndex=s;var l=g.exec(o);return l?l.index:-1}function n(s){var o=s.getOption("continueComments");return o&&typeof o=="object"?o.continueLineComment!==!1:!0}r.defineOption("continueComments",null,function(s,o,l){if(l&&l!=r.Init&&s.removeKeyMap("continueComment"),o){var f="Enter";typeof o=="string"?f=o:typeof o=="object"&&o.key&&(f=o.key);var c={name:"continueComment"};c[f]=e,s.addKeyMap(c)}})})})()),ze.exports}Rn();var We={exports:{}},Ge;function Nt(){return Ge||(Ge=1,(function(i,a){(function(r){r(G())})(function(r){function g(e,t,n){var s=e.getWrapperElement(),o;return o=s.appendChild(document.createElement("div")),n?o.className="CodeMirror-dialog CodeMirror-dialog-bottom":o.className="CodeMirror-dialog CodeMirror-dialog-top",typeof t=="string"?o.innerHTML=t:o.appendChild(t),r.addClass(s,"dialog-opened"),o}function h(e,t){e.state.currentNotificationClose&&e.state.currentNotificationClose(),e.state.currentNotificationClose=t}r.defineExtension("openDialog",function(e,t,n){n||(n={}),h(this,null);var s=g(this,e,n.bottom),o=!1,l=this;function f(b){if(typeof b=="string")c.value=b;else{if(o)return;o=!0,r.rmClass(s.parentNode,"dialog-opened"),s.parentNode.removeChild(s),l.focus(),n.onClose&&n.onClose(s)}}var c=s.getElementsByTagName("input")[0],d;return c?(c.focus(),n.value&&(c.value=n.value,n.selectValueOnOpen!==!1&&c.select()),n.onInput&&r.on(c,"input",function(b){n.onInput(b,c.value,f)}),n.onKeyUp&&r.on(c,"keyup",function(b){n.onKeyUp(b,c.value,f)}),r.on(c,"keydown",function(b){n&&n.onKeyDown&&n.onKeyDown(b,c.value,f)||((b.keyCode==27||n.closeOnEnter!==!1&&b.keyCode==13)&&(c.blur(),r.e_stop(b),f()),b.keyCode==13&&t(c.value,b))}),n.closeOnBlur!==!1&&r.on(s,"focusout",function(b){b.relatedTarget!==null&&f()})):(d=s.getElementsByTagName("button")[0])&&(r.on(d,"click",function(){f(),l.focus()}),n.closeOnBlur!==!1&&r.on(d,"blur",f),d.focus()),f}),r.defineExtension("openConfirm",function(e,t,n){h(this,null);var s=g(this,e,n&&n.bottom),o=s.getElementsByTagName("button"),l=!1,f=this,c=1;function d(){l||(l=!0,r.rmClass(s.parentNode,"dialog-opened"),s.parentNode.removeChild(s),f.focus())}o[0].focus();for(var b=0;b`,triples:"",explode:"[]{}"},h=r.Pos;r.defineOption("autoCloseBrackets",!1,function(u,m,y){y&&y!=r.Init&&(u.removeKeyMap(t),u.state.closeBrackets=null),m&&(n(e(m,"pairs")),u.state.closeBrackets=m,u.addKeyMap(t))});function e(u,m){return m=="pairs"&&typeof u=="string"?u:typeof u=="object"&&u[m]!=null?u[m]:g[m]}var t={Backspace:l,Enter:f};function n(u){for(var m=0;m=0;C--){var j=x[C].head;u.replaceRange("",h(j.line,j.ch-1),h(j.line,j.ch+1),"+delete")}}function f(u){var m=o(u),y=m&&e(m,"explode");if(!y||u.getOption("disableInput"))return r.Pass;for(var x=u.listSelections(),C=0;C0?{line:j.head.line,ch:j.head.ch+m}:{line:j.head.line-1};y.push({anchor:v,head:v})}u.setSelections(y,C)}function d(u){var m=r.cmpPos(u.anchor,u.head)>0;return{anchor:new h(u.anchor.line,u.anchor.ch+(m?-1:1)),head:new h(u.head.line,u.head.ch+(m?1:-1))}}function b(u,m){var y=o(u);if(!y||u.getOption("disableInput"))return r.Pass;var x=e(y,"pairs"),C=x.indexOf(m);if(C==-1)return r.Pass;for(var _=e(y,"closeBefore"),j=e(y,"triples"),v=x.charAt(C+1)==m,S=u.listSelections(),L=C%2==0,N,E=0;E=0&&u.getRange(A,h(A.line,A.ch+3))==m+m+m?D="skipThree":D="skip";else if(v&&A.ch>1&&j.indexOf(m)>=0&&u.getRange(h(A.line,A.ch-2),A)==m+m){if(A.ch>2&&/\bstring/.test(u.getTokenTypeAt(h(A.line,A.ch-2))))return r.Pass;D="addFour"}else if(v){var I=A.ch==0?" ":u.getRange(h(A.line,A.ch-1),A);if(!r.isWordChar(F)&&I!=m&&!r.isWordChar(I))D="both";else return r.Pass}else if(L&&(F.length===0||/\s/.test(F)||_.indexOf(F)>-1))D="both";else return r.Pass;if(!N)N=D;else if(N!=D)return r.Pass}var R=C%2?x.charAt(C-1):m,V=C%2?m:x.charAt(C+1);u.operation(function(){if(N=="skip")c(u,1);else if(N=="skipThree")c(u,3);else if(N=="surround"){for(var P=u.getSelections(),H=0;H",")":"(<","[":"]>","]":"[<","{":"}>","}":"{<","<":">>",">":"<<"};function t(c){return c&&c.bracketRegex||/[(){}[\]]/}function n(c,d,b){var w=c.getLineHandle(d.line),p=d.ch-1,u=b&&b.afterCursor;u==null&&(u=/(^| )cm-fat-cursor($| )/.test(c.getWrapperElement().className));var m=t(b),y=!u&&p>=0&&m.test(w.text.charAt(p))&&e[w.text.charAt(p)]||m.test(w.text.charAt(p+1))&&e[w.text.charAt(++p)];if(!y)return null;var x=y.charAt(1)==">"?1:-1;if(b&&b.strict&&x>0!=(p==d.ch))return null;var C=c.getTokenTypeAt(h(d.line,p+1)),_=s(c,h(d.line,p+(x>0?1:0)),x,C,b);return _==null?null:{from:h(d.line,p),to:_&&_.pos,match:_&&_.ch==y.charAt(0),forward:x>0}}function s(c,d,b,w,p){for(var u=p&&p.maxScanLineLength||1e4,m=p&&p.maxScanLines||1e3,y=[],x=t(p),C=b>0?Math.min(d.line+m,c.lastLine()+1):Math.max(c.firstLine()-1,d.line-m),_=d.line;_!=C;_+=b){var j=c.getLine(_);if(j){var v=b>0?0:j.length-1,S=b>0?j.length:-1;if(!(j.length>u))for(_==d.line&&(v=d.ch-(b<0?1:0));v!=S;v+=b){var L=j.charAt(v);if(x.test(L)&&(w===void 0||(c.getTokenTypeAt(h(_,v+1))||"")==(w||""))){var N=e[L];if(N&&N.charAt(1)==">"==b>0)y.push(L);else if(y.length)y.pop();else return{pos:h(_,v),ch:L}}}}}return _-b==(b>0?c.lastLine():c.firstLine())?!1:null}function o(c,d,b){for(var w=c.state.matchBrackets.maxHighlightLineLength||1e3,p=b&&b.highlightNonMatching,u=[],m=c.listSelections(),y=0;yh.lastLine())return null;var d=h.getTokenAt(r.Pos(c,1));if(/\S/.test(d.string)||(d=h.getTokenAt(r.Pos(c,d.end+1))),d.type!="keyword"||d.string!="import")return null;for(var b=c,w=Math.min(h.lastLine(),c+10);b<=w;++b){var p=h.getLine(b),u=p.indexOf(";");if(u!=-1)return{startCh:d.end,end:r.Pos(b,u)}}}var n=e.line,s=t(n),o;if(!s||t(n-1)||(o=t(n-2))&&o.end.line==n-1)return null;for(var l=s.end;;){var f=t(l.line+1);if(f==null)break;l=f.end}return{from:h.clipPos(r.Pos(n,s.startCh+1)),to:l}}),r.registerHelper("fold","include",function(h,e){function t(f){if(fh.lastLine())return null;var c=h.getTokenAt(r.Pos(f,1));if(/\S/.test(c.string)||(c=h.getTokenAt(r.Pos(f,c.end+1))),c.type=="meta"&&c.string.slice(0,8)=="#include")return c.start+8}var n=e.line,s=t(n);if(s==null||t(n-1)!=null)return null;for(var o=n;;){var l=t(o+1);if(l==null)break;++o}return{from:r.Pos(n,s+1),to:h.clipPos(r.Pos(o))}})})})()),Ye.exports}Hn();var et={exports:{}},tt;function Lt(){return tt||(tt=1,(function(i,a){(function(r){r(G())})(function(r){function g(n,s,o,l){if(o&&o.call){var f=o;o=null}else var f=t(n,o,"rangeFinder");typeof s=="number"&&(s=r.Pos(s,0));var c=t(n,o,"minFoldSize");function d(u){var m=f(n,s);if(!m||m.to.line-m.from.linen.firstLine();)s=r.Pos(s.line-1,0),b=d(!1);if(!(!b||b.cleared||l==="unfold")){var w=h(n,o,b);r.on(w,"mousedown",function(u){p.clear(),r.e_preventDefault(u)});var p=n.markText(b.from,b.to,{replacedWith:w,clearOnEnter:t(n,o,"clearOnEnter"),__isFold:!0});p.on("clear",function(u,m){r.signal(n,"unfold",n,u,m)}),r.signal(n,"fold",n,b.from,b.to)}}function h(n,s,o){var l=t(n,s,"widget");if(typeof l=="function"&&(l=l(o.from,o.to)),typeof l=="string"){var f=document.createTextNode(l);l=document.createElement("span"),l.appendChild(f),l.className="CodeMirror-foldmarker"}else l&&(l=l.cloneNode(!0));return l}r.newFoldFunction=function(n,s){return function(o,l){g(o,l,{rangeFinder:n,widget:s})}},r.defineExtension("foldCode",function(n,s,o){g(this,n,s,o)}),r.defineExtension("isFolded",function(n){for(var s=this.findMarksAt(n),o=0;o=C){if(v&&N&&v.test(N.className))return;L=n(y.indicatorOpen)}}!L&&!N||p.setGutterMarker(S,y.gutter,L)})}function o(p){return new RegExp("(^|\\s)"+p+"(?:$|\\s)\\s*")}function l(p){var u=p.getViewport(),m=p.state.foldGutter;m&&(p.operation(function(){s(p,u.from,u.to)}),m.from=u.from,m.to=u.to)}function f(p,u,m){var y=p.state.foldGutter;if(y){var x=y.options;if(m==x.gutter){var C=t(p,u);C?C.clear():p.foldCode(g(u,0),x)}}}function c(p,u){u=="mode"&&d(p)}function d(p){var u=p.state.foldGutter;if(u){var m=u.options;u.from=u.to=0,clearTimeout(u.changeUpdate),u.changeUpdate=setTimeout(function(){l(p)},m.foldOnChangeTimeSpan||600)}}function b(p){var u=p.state.foldGutter;if(u){var m=u.options;clearTimeout(u.changeUpdate),u.changeUpdate=setTimeout(function(){var y=p.getViewport();u.from==u.to||y.from-u.to>20||u.from-y.to>20?l(p):p.operation(function(){y.fromu.to&&(s(p,u.to,y.to),u.to=y.to)})},m.updateViewportTimeSpan||400)}}function w(p,u){var m=p.state.foldGutter;if(m){var y=u.line;y>=m.from&&yv);S++){var L=m.getLine(j++);C=C==null?L:C+` `+L}_=_*2,y.lastIndex=x.ch;var N=y.exec(C);if(N){var E=C.slice(0,N.index).split(` `),T=N[0].split(` `),A=x.line+E.length-1,D=E[E.length-1].length;return{from:g(A,D),to:g(A+T.length-1,T.length==1?D+T[0].length:T[T.length-1].length),match:N}}}}function o(m,y,x){for(var C,_=0;_<=m.length;){y.lastIndex=_;var j=y.exec(m);if(!j)break;var v=j.index+j[0].length;if(v>m.length-x)break;(!C||v>C.index+C[0].length)&&(C=j),_=j.index+1}return C}function l(m,y,x){y=e(y,"g");for(var C=x.line,_=x.ch,j=m.firstLine();C>=j;C--,_=-1){var v=m.getLine(C),S=o(v,y,_<0?0:v.length-_);if(S)return{from:g(C,S.index),to:g(C,S.index+S[0].length),match:S}}}function f(m,y,x){if(!t(y))return l(m,y,x);y=e(y,"gm");for(var C,_=1,j=m.getLine(x.line).length-x.ch,v=x.line,S=m.firstLine();v>=S;){for(var L=0;L<_&&v>=S;L++){var N=m.getLine(v--);C=C==null?N:N+` `+C}_*=2;var E=o(C,y,j);if(E){var T=C.slice(0,E.index).split(` `),A=E[0].split(` `),D=v+T.length,F=T[T.length-1].length;return{from:g(D,F),to:g(D+A.length-1,A.length==1?F+A[0].length:A[A.length-1].length),match:E}}}}var c,d;String.prototype.normalize?(c=function(m){return m.normalize("NFD").toLowerCase()},d=function(m){return m.normalize("NFD")}):(c=function(m){return m.toLowerCase()},d=function(m){return m});function b(m,y,x,C){if(m.length==y.length)return x;for(var _=0,j=x+Math.max(0,m.length-y.length);;){if(_==j)return _;var v=_+j>>1,S=C(m.slice(0,v)).length;if(S==x)return v;S>x?j=v:_=v+1}}function w(m,y,x,C){if(!y.length)return null;var _=C?c:d,j=_(y).split(/\r|\n\r?/);e:for(var v=x.line,S=x.ch,L=m.lastLine()+1-j.length;v<=L;v++,S=0){var N=m.getLine(v).slice(S),E=_(N);if(j.length==1){var T=E.indexOf(j[0]);if(T==-1)continue e;var x=b(N,E,T,_)+S;return{from:g(v,b(N,E,T,_)+S),to:g(v,b(N,E,T+j[0].length,_)+S)}}else{var A=E.length-j[0].length;if(E.slice(A)!=j[0])continue e;for(var D=1;D=L;v--,S=-1){var N=m.getLine(v);S>-1&&(N=N.slice(0,S));var E=_(N);if(j.length==1){var T=E.lastIndexOf(j[0]);if(T==-1)continue e;return{from:g(v,b(N,E,T,_)),to:g(v,b(N,E,T+j[0].length,_))}}else{var A=j[j.length-1];if(E.slice(0,A.length)!=A)continue e;for(var D=1,x=v-j.length+1;D(this.doc.getLine(y.line)||"").length&&(y.ch=0,y.line++)),r.cmpPos(y,this.doc.clipPos(y))!=0))return this.atOccurrence=!1;var x=this.matches(m,y);if(this.afterEmptyMatch=x&&r.cmpPos(x.from,x.to)==0,x)return this.pos=x,this.atOccurrence=!0,this.pos.match||!0;var C=g(m?this.doc.firstLine():this.doc.lastLine()+1,0);return this.pos={from:C,to:C},this.atOccurrence=!1},from:function(){if(this.atOccurrence)return this.pos.from},to:function(){if(this.atOccurrence)return this.pos.to},replace:function(m,y){if(this.atOccurrence){var x=r.splitLines(m);this.doc.replaceRange(x,this.pos.from,this.pos.to,y),this.pos.to=g(this.pos.from.line+x.length-1,x[x.length-1].length+(x.length==1?this.pos.from.ch:0))}}},r.defineExtension("getSearchCursor",function(m,y,x){return new u(this.doc,m,y,x)}),r.defineDocExtension("getSearchCursor",function(m,y,x){return new u(this,m,y,x)}),r.defineExtension("selectMatches",function(m,y){for(var x=[],C=this.getSearchCursor(m,this.getCursor("from"),y);C.findNext()&&!(r.cmpPos(C.to(),this.getCursor("to"))>0);)x.push({anchor:C.from(),head:C.to()});x.length&&this.setSelections(x,0)})})})()),at.exports}var lt;function zn(){return lt||(lt=1,(function(i,a){(function(r){r(G(),Et(),Nt())})(function(r){r.defineOption("search",{bottom:!1});function g(v,S){return typeof v=="string"?v=new RegExp(v.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),S?"gi":"g"):v.global||(v=new RegExp(v.source,v.ignoreCase?"gi":"g")),{token:function(L){v.lastIndex=L.pos;var N=v.exec(L.string);if(N&&N.index==L.pos)return L.pos+=N[0].length||1,"searching";N?L.pos=N.index:L.skipToEnd()}}}function h(){this.posFrom=this.posTo=this.lastQuery=this.query=null,this.overlay=null}function e(v){return v.state.search||(v.state.search=new h)}function t(v){return typeof v=="string"&&v==v.toLowerCase()}function n(v,S,L){return v.getSearchCursor(S,L,{caseFold:t(S),multiline:!0})}function s(v,S,L,N,E){v.openDialog(S,N,{value:L,selectValueOnOpen:!0,closeOnEnter:!1,onClose:function(){p(v)},onKeyDown:E,bottom:v.options.search.bottom})}function o(v,S,L,N,E){v.openDialog?v.openDialog(S,E,{value:N,selectValueOnOpen:!0,bottom:v.options.search.bottom}):E(prompt(L,N))}function l(v,S,L,N){v.openConfirm?v.openConfirm(S,N):confirm(L)&&N[0]()}function f(v){return v.replace(/\\([nrt\\])/g,function(S,L){return L=="n"?` `:L=="r"?"\r":L=="t"?" ":L=="\\"?"\\":S})}function c(v){var S=v.match(/^\/(.*)\/([a-z]*)$/);if(S)try{v=new RegExp(S[1],S[2].indexOf("i")==-1?"":"i")}catch{}else v=f(v);return(typeof v=="string"?v=="":v.test(""))&&(v=/x^/),v}function d(v,S,L){S.queryText=L,S.query=c(L),v.removeOverlay(S.overlay,t(S.query)),S.overlay=g(S.query,t(S.query)),v.addOverlay(S.overlay),v.showMatchesOnScrollbar&&(S.annotate&&(S.annotate.clear(),S.annotate=null),S.annotate=v.showMatchesOnScrollbar(S.query,t(S.query)))}function b(v,S,L,N){var E=e(v);if(E.query)return w(v,S);var T=v.getSelection()||E.lastQuery;if(T instanceof RegExp&&T.source=="x^"&&(T=null),L&&v.openDialog){var A=null,D=function(F,I){r.e_stop(I),F&&(F!=E.queryText&&(d(v,E,F),E.posFrom=E.posTo=v.getCursor()),A&&(A.style.opacity=1),w(v,I.shiftKey,function(R,V){var P;V.line<3&&document.querySelector&&(P=v.display.wrapper.querySelector(".CodeMirror-dialog"))&&P.getBoundingClientRect().bottom-4>v.cursorCoords(V,"window").top&&((A=P).style.opacity=.4)}))};s(v,m(v),T,D,function(F,I){var R=r.keyName(F),V=v.getOption("extraKeys"),P=V&&V[R]||r.keyMap[v.getOption("keyMap")][R];P=="findNext"||P=="findPrev"||P=="findPersistentNext"||P=="findPersistentPrev"?(r.e_stop(F),d(v,e(v),I),v.execCommand(P)):(P=="find"||P=="findPersistent")&&(r.e_stop(F),D(I,F))}),N&&T&&(d(v,E,T),w(v,S))}else o(v,m(v),"Search for:",T,function(F){F&&!E.query&&v.operation(function(){d(v,E,F),E.posFrom=E.posTo=v.getCursor(),w(v,S)})})}function w(v,S,L){v.operation(function(){var N=e(v),E=n(v,N.query,S?N.posFrom:N.posTo);!E.find(S)&&(E=n(v,N.query,S?r.Pos(v.lastLine()):r.Pos(v.firstLine(),0)),!E.find(S))||(v.setSelection(E.from(),E.to()),v.scrollIntoView({from:E.from(),to:E.to()},20),N.posFrom=E.from(),N.posTo=E.to(),L&&L(E.from(),E.to()))})}function p(v){v.operation(function(){var S=e(v);S.lastQuery=S.query,S.query&&(S.query=S.queryText=null,v.removeOverlay(S.overlay),S.annotate&&(S.annotate.clear(),S.annotate=null))})}function u(v,S){var L=v?document.createElement(v):document.createDocumentFragment();for(var N in S)L[N]=S[N];for(var E=2;E"u"&&(this.Diff_Timeout<=0?s=Number.MAX_VALUE:s=new Date().getTime()+this.Diff_Timeout*1e3);var o=s;if(e==null||t==null)throw new Error("Null input. (diff_main)");if(e==t)return e?[new a.Diff(h,e)]:[];typeof n>"u"&&(n=!0);var l=n,f=this.diff_commonPrefix(e,t),c=e.substring(0,f);e=e.substring(f),t=t.substring(f),f=this.diff_commonSuffix(e,t);var d=e.substring(e.length-f);e=e.substring(0,e.length-f),t=t.substring(0,t.length-f);var b=this.diff_compute_(e,t,l,o);return c&&b.unshift(new a.Diff(h,c)),d&&b.push(new a.Diff(h,d)),this.diff_cleanupMerge(b),b},a.prototype.diff_compute_=function(e,t,n,s){var o;if(!e)return[new a.Diff(g,t)];if(!t)return[new a.Diff(r,e)];var l=e.length>t.length?e:t,f=e.length>t.length?t:e,c=l.indexOf(f);if(c!=-1)return o=[new a.Diff(g,l.substring(0,c)),new a.Diff(h,f),new a.Diff(g,l.substring(c+f.length))],e.length>t.length&&(o[0][0]=o[2][0]=r),o;if(f.length==1)return[new a.Diff(r,e),new a.Diff(g,t)];var d=this.diff_halfMatch_(e,t);if(d){var b=d[0],w=d[1],p=d[2],u=d[3],m=d[4],y=this.diff_main(b,p,n,s),x=this.diff_main(w,u,n,s);return y.concat([new a.Diff(h,m)],x)}return n&&e.length>100&&t.length>100?this.diff_lineMode_(e,t,s):this.diff_bisect_(e,t,s)},a.prototype.diff_lineMode_=function(e,t,n){var s=this.diff_linesToChars_(e,t);e=s.chars1,t=s.chars2;var o=s.lineArray,l=this.diff_main(e,t,!1,n);this.diff_charsToLines_(l,o),this.diff_cleanupSemantic(l),l.push(new a.Diff(h,""));for(var f=0,c=0,d=0,b="",w="";f=1&&d>=1){l.splice(f-c-d,c+d),f=f-c-d;for(var p=this.diff_main(b,w,!1,n),u=p.length-1;u>=0;u--)l.splice(f,0,p[u]);f=f+p.length}d=0,c=0,b="",w="";break}f++}return l.pop(),l},a.prototype.diff_bisect_=function(e,t,n){for(var s=e.length,o=t.length,l=Math.ceil((s+o)/2),f=l,c=2*l,d=new Array(c),b=new Array(c),w=0;wn);_++){for(var j=-_+m;j<=_-y;j+=2){var v=f+j,S;j==-_||j!=_&&d[v-1]s)y+=2;else if(L>o)m+=2;else if(u){var N=f+p-j;if(N>=0&&N=E)return this.diff_bisectSplit_(e,t,S,L,n)}}}for(var T=-_+x;T<=_-C;T+=2){var N=f+T,E;T==-_||T!=_&&b[N-1]s)C+=2;else if(A>o)x+=2;else if(!u){var v=f+p-T;if(v>=0&&v=E)return this.diff_bisectSplit_(e,t,S,L,n)}}}}return[new a.Diff(r,e),new a.Diff(g,t)]},a.prototype.diff_bisectSplit_=function(e,t,n,s,o){var l=e.substring(0,n),f=t.substring(0,s),c=e.substring(n),d=t.substring(s),b=this.diff_main(l,f,!1,o),w=this.diff_main(c,d,!1,o);return b.concat(w)},a.prototype.diff_linesToChars_=function(e,t){var n=[],s={};n[0]="";function o(d){for(var b="",w=0,p=-1,u=n.length;ps?e=e.substring(n-s):nt.length?e:t,s=e.length>t.length?t:e;if(n.length<4||s.length*2=y.length?[S,L,N,E,v]:null}var f=l(n,s,Math.ceil(n.length/4)),c=l(n,s,Math.ceil(n.length/2)),d;if(!f&&!c)return null;c?f?d=f[4].length>c[4].length?f:c:d=c:d=f;var b,w,p,u;e.length>t.length?(b=d[0],w=d[1],p=d[2],u=d[3]):(p=d[0],u=d[1],b=d[2],w=d[3]);var m=d[4];return[b,w,p,u,m]},a.prototype.diff_cleanupSemantic=function(e){for(var t=!1,n=[],s=0,o=null,l=0,f=0,c=0,d=0,b=0;l0?n[s-1]:-1,f=0,c=0,d=0,b=0,o=null,t=!0)),l++;for(t&&this.diff_cleanupMerge(e),this.diff_cleanupSemanticLossless(e),l=1;l=m?(u>=w.length/2||u>=p.length/2)&&(e.splice(l,0,new a.Diff(h,p.substring(0,u))),e[l-1][1]=w.substring(0,w.length-u),e[l+1][1]=p.substring(u),l++):(m>=w.length/2||m>=p.length/2)&&(e.splice(l,0,new a.Diff(h,w.substring(0,m))),e[l-1][0]=g,e[l-1][1]=p.substring(0,p.length-m),e[l+1][0]=r,e[l+1][1]=w.substring(m),l++),l++}l++}},a.prototype.diff_cleanupSemanticLossless=function(e){function t(m,y){if(!m||!y)return 6;var x=m.charAt(m.length-1),C=y.charAt(0),_=x.match(a.nonAlphaNumericRegex_),j=C.match(a.nonAlphaNumericRegex_),v=_&&x.match(a.whitespaceRegex_),S=j&&C.match(a.whitespaceRegex_),L=v&&x.match(a.linebreakRegex_),N=S&&C.match(a.linebreakRegex_),E=L&&m.match(a.blanklineEndRegex_),T=N&&y.match(a.blanklineStartRegex_);return E||T?5:L||N?4:_&&!v&&S?3:v||S?2:_||j?1:0}for(var n=1;n=p&&(p=u,d=s,b=o,w=l)}e[n-1][1]!=d&&(d?e[n-1][1]=d:(e.splice(n-1,1),n--),e[n][1]=b,w?e[n+1][1]=w:(e.splice(n+1,1),n--))}n++}},a.nonAlphaNumericRegex_=/[^a-zA-Z0-9]/,a.whitespaceRegex_=/\s/,a.linebreakRegex_=/[\r\n]/,a.blanklineEndRegex_=/\n\r?\n$/,a.blanklineStartRegex_=/^\r?\n\r?\n/,a.prototype.diff_cleanupEfficiency=function(e){for(var t=!1,n=[],s=0,o=null,l=0,f=!1,c=!1,d=!1,b=!1;l0?n[s-1]:-1,d=b=!1),t=!0)),l++;t&&this.diff_cleanupMerge(e)},a.prototype.diff_cleanupMerge=function(e){e.push(new a.Diff(h,""));for(var t=0,n=0,s=0,o="",l="",f;t1?(n!==0&&s!==0&&(f=this.diff_commonPrefix(l,o),f!==0&&(t-n-s>0&&e[t-n-s-1][0]==h?e[t-n-s-1][1]+=l.substring(0,f):(e.splice(0,0,new a.Diff(h,l.substring(0,f))),t++),l=l.substring(f),o=o.substring(f)),f=this.diff_commonSuffix(l,o),f!==0&&(e[t][1]=l.substring(l.length-f)+e[t][1],l=l.substring(0,l.length-f),o=o.substring(0,o.length-f))),t-=n+s,e.splice(t,n+s),o.length&&(e.splice(t,0,new a.Diff(r,o)),t++),l.length&&(e.splice(t,0,new a.Diff(g,l)),t++),t++):t!==0&&e[t-1][0]==h?(e[t-1][1]+=e[t][1],e.splice(t,1)):t++,s=0,n=0,o="",l="";break}e[e.length-1][1]===""&&e.pop();var c=!1;for(t=1;tt));f++)o=n,l=s;return e.length!=f&&e[f][0]===r?l:l+(t-o)},a.prototype.diff_prettyHtml=function(e){for(var t=[],n=/&/g,s=//g,l=/\n/g,f=0;f");switch(c){case g:t[f]=''+b+"";break;case r:t[f]=''+b+"";break;case h:t[f]=""+b+"";break}}return t.join("")},a.prototype.diff_text1=function(e){for(var t=[],n=0;nthis.Match_MaxBits)throw new Error("Pattern too long for this browser.");var s=this.match_alphabet_(t),o=this;function l(S,L){var N=S/t.length,E=Math.abs(n-L);return o.Match_Distance?N+E/o.Match_Distance:E?1:N}var f=this.Match_Threshold,c=e.indexOf(t,n);c!=-1&&(f=Math.min(l(0,c),f),c=e.lastIndexOf(t,n+t.length),c!=-1&&(f=Math.min(l(0,c),f)));var d=1<=y;_--){var j=s[e.charAt(_-1)];if(m===0?C[_]=(C[_+1]<<1|1)&j:C[_]=(C[_+1]<<1|1)&j|((u[_+1]|u[_])<<1|1)|u[_+1],C[_]&d){var v=l(m,_-1);if(v<=f)if(f=v,c=_-1,c>n)y=Math.max(1,2*n-c);else break}}if(l(m+1,n)>f)break;u=C}return c},a.prototype.match_alphabet_=function(e){for(var t={},n=0;n"u")s=e,o=this.diff_main(s,t,!0),o.length>2&&(this.diff_cleanupSemantic(o),this.diff_cleanupEfficiency(o));else if(e&&typeof e=="object"&&typeof t>"u"&&typeof n>"u")o=e,s=this.diff_text1(o);else if(typeof e=="string"&&t&&typeof t=="object"&&typeof n>"u")s=e,o=t;else if(typeof e=="string"&&typeof t=="string"&&n&&typeof n=="object")s=e,o=n;else throw new Error("Unknown call format to patch_make.");if(o.length===0)return[];for(var l=[],f=new a.patch_obj,c=0,d=0,b=0,w=s,p=s,u=0;u=2*this.Patch_Margin&&c&&(this.patch_addContext_(f,w),l.push(f),f=new a.patch_obj,c=0,w=p,d=b);break}m!==g&&(d+=y.length),m!==r&&(b+=y.length)}return c&&(this.patch_addContext_(f,w),l.push(f)),l},a.prototype.patch_deepCopy=function(e){for(var t=[],n=0;nthis.Match_MaxBits?(d=this.match_main(t,c.substring(0,this.Match_MaxBits),f),d!=-1&&(b=this.match_main(t,c.substring(c.length-this.Match_MaxBits),f+c.length-this.Match_MaxBits),(b==-1||d>=b)&&(d=-1))):d=this.match_main(t,c,f),d==-1)o[l]=!1,s-=e[l].length2-e[l].length1;else{o[l]=!0,s=d-f;var w;if(b==-1?w=t.substring(d,d+c.length):w=t.substring(d,b+this.Match_MaxBits),c==w)t=t.substring(0,d)+this.diff_text2(e[l].diffs)+t.substring(d+c.length);else{var p=this.diff_main(c,w,!1);if(c.length>this.Match_MaxBits&&this.diff_levenshtein(p)/c.length>this.Patch_DeleteThreshold)o[l]=!1;else{this.diff_cleanupSemanticLossless(p);for(var u=0,m,y=0;yl[0][1].length){var f=t-l[0][1].length;l[0][1]=n.substring(l[0][1].length)+l[0][1],o.start1-=f,o.start2-=f,o.length1+=f,o.length2+=f}if(o=e[e.length-1],l=o.diffs,l.length==0||l[l.length-1][0]!=h)l.push(new a.Diff(h,n)),o.length1+=t,o.length2+=t;else if(t>l[l.length-1][1].length){var f=t-l[l.length-1][1].length;l[l.length-1][1]+=n.substring(0,f),o.length1+=f,o.length2+=f}return n},a.prototype.patch_splitMax=function(e){for(var t=this.Match_MaxBits,n=0;n2*t?(c.length1+=w.length,o+=w.length,d=!1,c.diffs.push(new a.Diff(b,w)),s.diffs.shift()):(w=w.substring(0,t-c.length1-this.Patch_Margin),c.length1+=w.length,o+=w.length,b===h?(c.length2+=w.length,l+=w.length):d=!1,c.diffs.push(new a.Diff(b,w)),w==s.diffs[0][1]?s.diffs.shift():s.diffs[0][1]=s.diffs[0][1].substring(w.length))}f=this.diff_text2(c.diffs),f=f.substring(f.length-this.Patch_Margin);var p=this.diff_text1(s.diffs).substring(0,this.Patch_Margin);p!==""&&(c.length1+=p.length,c.length2+=p.length,c.diffs.length!==0&&c.diffs[c.diffs.length-1][0]===h?c.diffs[c.diffs.length-1][1]+=p:c.diffs.push(new a.Diff(h,p))),d||e.splice(++n,0,c)}}},a.prototype.patch_toText=function(e){for(var t=[],n=0;nh)return!1;var e=r.getScrollInfo();if(i.mv.options.connect=="align")d=e.top;else{var t=.5*e.clientHeight,n=e.top+t,s=r.lineAtHeight(n,"local"),o=Jn(i.chunks,s,a),l=ft(r,a?o.edit:o.orig),f=ft(g,a?o.orig:o.edit),c=(n-l.top)/(l.bot-l.top),d=f.top-t+c*(f.bot-f.top),b,w;if(d>e.top&&(w=e.top/t)<1)d=d*w+e.top*(1-w);else if((b=e.height-e.clientHeight-e.top)b&&(w=b/t)<1&&(d=d*w+(p.height-p.clientHeight-b)*(1-w))}}return g.scrollTo(e.left,d),g.state.scrollSetAt=h,g.state.scrollSetBy=i,!0}function ft(i,a){var r=a.after;return r==null&&(r=i.lastLine()+1),{top:i.heightAtLine(a.before||0,"local"),bot:i.heightAtLine(r,"local")}}function Se(i,a,r){i.lockScroll=a,a&&r!=!1&&te(i,K.DIFF_INSERT)&&Y(i),(a?M.addClass:M.rmClass)(i.lockButton,"CodeMirror-merge-scrolllock-enabled")}function Qn(i,a,r){for(var g=r.classLocation,h=0;h20||r.from-e.to>20?(je(i,r.marked,h),be(i,a,g,r.marked,e.from,e.to,h),r.from=e.from,r.to=e.to):(e.fromr.to&&(be(i,a,g,r.marked,r.to,e.to,h),r.to=e.to))})}function pe(i,a,r,g,h,e){for(var t=r.classLocation,n=i.getLineHandle(a),s=0;sm&&(d&&(f(c,m),d=!1),c=y)}else if(d=!0,p==r){var x=ue(n,u,!0),C=nr(s,n),_=tr(o,x);rr(C,_)||g.push(i.markText(C,_,{className:l})),n=x}}d&&f(c,n.line+1)}function Y(i){if(i.showDifferences){if(i.svg){ce(i.svg);var a=i.gap.offsetWidth;Pt(i.svg,"width",a,"height",i.gap.offsetHeight)}i.copyButtons&&ce(i.copyButtons);for(var r=i.edit.getViewport(),g=i.orig.getViewport(),h=i.mv.wrap.getBoundingClientRect().top,e=h-i.edit.getScrollerElement().getBoundingClientRect().top+i.edit.getScrollInfo().top,t=h-i.orig.getScrollerElement().getBoundingClientRect().top+i.orig.getScrollInfo().top,n=0;n=r.from&&s.origFrom<=g.to&&s.origTo>=g.from&&Xn(i,s,t,e,a)}}}function ut(i,a){for(var r=0,g=0,h=0;hi&&e.editFrom<=i)return null;if(e.editFrom>i)break;r=e.editTo,g=e.origTo}return g+(i-r)}function ye(i,a,r){for(var g=i.state.trackAlignable,h=i.firstLine(),e=0,t=[],n=0;;n++){for(var s=a[n],o=s?r?s.origFrom:s.editFrom:1e9;ef){e++,h--;continue e}if(c.editTo>l){if(c.editFrom<=l)continue e;break}n+=c.origTo-c.origFrom-(c.editTo-c.editFrom),t++}if(l==f-n)s[g]=f,e++;else if(l1&&g.push(qn(i[t],r[t],s))}}function qn(i,a,r){var g=!0;a>i.lastLine()&&(a--,g=!1);var h=document.createElement("div");return h.className="CodeMirror-merge-spacer",h.style.height=r+"px",h.style.minWidth="1px",i.addLineWidget(a,h,{height:r,above:g,mergeSpacer:!0,handleMouseEvents:!0})}function Xn(i,a,r,g,h){var e=i.type=="left",t=i.orig.heightAtLine(a.origFrom,"local",!0)-r;if(i.svg){var n=t,s=i.edit.heightAtLine(a.editFrom,"local",!0)-g;if(e){var o=n;n=s,s=o}var l=i.orig.heightAtLine(a.origTo,"local",!0)-r,f=i.edit.heightAtLine(a.editTo,"local",!0)-g;if(e){var o=l;l=f,f=o}var c=" C "+h/2+" "+s+" "+h/2+" "+n+" "+(h+2)+" "+n,d=" C "+h/2+" "+l+" "+h/2+" "+f+" -1 "+f;Pt(i.svg.appendChild(document.createElementNS(At,"path")),"d","M -1 "+s+c+" L "+(h+2)+" "+l+d+" z","class",i.classes.connect)}if(i.copyButtons){var b=i.copyButtons.appendChild(U("div",i.type=="left"?"⇝":"⇜","CodeMirror-merge-copy")),w=i.mv.options.allowEditingOriginals;if(b.title=i.edit.phrase(w?"Push to left":"Revert chunk"),b.chunk=a,b.style.top=(a.origTo>a.origFrom?t:i.edit.heightAtLine(a.editFrom,"local")-g)+"px",b.setAttribute("role","button"),b.setAttribute("tabindex","0"),b.setAttribute("aria-label",b.title),w){var p=i.edit.heightAtLine(a.editFrom,"local")-g,u=i.copyButtons.appendChild(U("div",i.type=="right"?"⇝":"⇜","CodeMirror-merge-copy-reverse"));u.title="Push to right",u.chunk={editFrom:a.origFrom,editTo:a.origTo,origFrom:a.editFrom,origTo:a.editTo},u.style.top=p+"px",i.type=="right"?u.style.left="2px":u.style.right="2px",u.setAttribute("role","button"),u.setAttribute("tabindex","0"),u.setAttribute("aria-label",u.title)}}}function dt(i,a,r,g){if(!i.diffOutOfDate){var h=g.origTo>r.lastLine()?z(g.origFrom-1):z(g.origFrom,0),e=z(g.origTo,0),t=g.editTo>a.lastLine()?z(g.editFrom-1):z(g.editFrom,0),n=z(g.editTo,0),s=i.mv.options.revertChunk;s?s(i.mv,r,h,e,a,t,n):a.replaceRange(r.getRange(h,e),t,n)}}var fe=M.MergeView=function(i,a){if(!(this instanceof fe))return new fe(i,a);this.options=a;var r=a.origLeft,g=a.origRight==null?a.orig:a.origRight,h=r!=null,e=g!=null,t=1+(h?1:0)+(e?1:0),n=[],s=this.left=null,o=this.right=null,l=this;if(h){s=this.left=new oe(this,"left");var f=U("div",null,"CodeMirror-merge-pane CodeMirror-merge-left");n.push(f),n.push(vt(s))}var c=U("div",null,"CodeMirror-merge-pane CodeMirror-merge-editor");if(n.push(c),e){o=this.right=new oe(this,"right"),n.push(vt(o));var d=U("div",null,"CodeMirror-merge-pane CodeMirror-merge-right");n.push(d)}(e?d:c).className+=" CodeMirror-merge-pane-rightmost",n.push(U("div",null,null,"height: 0; clear: both;"));var b=this.wrap=i.appendChild(U("div",n,"CodeMirror-merge CodeMirror-merge-"+t+"pane"));this.edit=M(c,_e(a)),s&&s.init(f,r,a),o&&o.init(d,g,a),a.collapseIdentical&&this.editor().operation(function(){er(l,a.collapseIdentical)}),a.connect=="align"&&(this.aligners=[],Re(this.left||this.right,!0)),s&&s.registerEvents(o),o&&o.registerEvents(s);var w=function(){s&&Y(s),o&&Y(o)};M.on(window,"resize",w);var p=setInterval(function(){for(var u=b.parentNode;u&&u!=document.body;u=u.parentNode);u||(clearInterval(p),M.off(window,"resize",w))},5e3)};function vt(i){var a=i.lockButton=U("div",null,"CodeMirror-merge-scrolllock");a.setAttribute("role","button"),a.setAttribute("tabindex","0");var r=U("div",[a],"CodeMirror-merge-scrolllock-wrap");M.on(a,"click",function(){Se(i,!i.lockScroll)}),M.on(a,"keyup",function(t){t.key==="Enter"&&Se(i,!i.lockScroll)});var g=[r];if(i.mv.options.revertButtons!==!1){i.copyButtons=U("div",null,"CodeMirror-merge-copybuttons-"+i.type);var h=function(t){var n=t.target||t.srcElement;if(n.chunk){if(n.className=="CodeMirror-merge-copy-reverse"){dt(i,i.orig,i.edit,n.chunk);return}dt(i,i.edit,i.orig,n.chunk)}};M.on(i.copyButtons,"click",h),M.on(i.copyButtons,"keyup",function(t){t.key==="Enter"&&h(t)}),g.unshift(i.copyButtons)}if(i.mv.options.connect!="align"){var e=document.createElementNS&&document.createElementNS(At,"svg");e&&!e.createSVGRect&&(e=null),i.svg=e,e&&g.push(e)}return i.gap=U("div",g,"CodeMirror-merge-gap")}fe.prototype={constructor:fe,editor:function(){return this.edit},rightOriginal:function(){return this.right&&this.right.orig},leftOriginal:function(){return this.left&&this.left.orig},setShowDifferences:function(i){this.right&&this.right.setShowDifferences(i),this.left&&this.left.setShowDifferences(i)},rightChunks:function(){if(this.right)return ne(this.right),this.right.chunks},leftChunks:function(){if(this.left)return ne(this.left),this.left.chunks}};function mt(i){return typeof i=="string"?i:i.getValue()}var ae;function Tt(i,a,r){ae||(ae=new Wn);var g=ae.diff_main(i,a);ae.diff_cleanupSemantic(g);for(var h=0;hl&&(t&&a.push({origFrom:g,origTo:f,editFrom:r,editTo:l}),r=d,g=b)}else ue(s==K.DIFF_INSERT?h:e,n[1])}return(r<=h.line||g<=e.line)&&a.push({origFrom:g,origTo:e.line+1,editFrom:r,editTo:h.line+1}),a}function Ot(i,a){if(a==i.length-1)return!0;var r=i[a+1][1];return r.length==1&&a1||a==i.length-3)&&r.charCodeAt(0)==10)}function Ft(i,a){if(a==0)return!0;var r=i[a-1][1];return r.charCodeAt(r.length-1)!=10?!1:a==1?!0:(r=i[a-2][1],r.charCodeAt(r.length-1)==10)}function Jn(i,a,r){for(var g,h,e,t,n=0;na?(h=s.editFrom,t=s.origFrom):l>a&&(h=s.editTo,t=s.origTo)),l<=a?(g=s.editTo,e=s.origTo):o<=a&&(g=s.editFrom,e=s.origFrom)}return{edit:{before:g,after:h},orig:{before:e,after:t}}}function Yn(i,a,r){i.addLineClass(a,"wrap","CodeMirror-merge-collapsed-line");var g=document.createElement("span");g.className="CodeMirror-merge-collapsed-widget",g.title=i.phrase("Identical text collapsed. Click to expand.");var h=i.markText(z(a,0),z(r-1),{inclusiveLeft:!0,inclusiveRight:!0,replacedWith:g,clearOnEnter:!0});function e(){h.clear(),i.removeLineClass(a,"wrap","CodeMirror-merge-collapsed-line")}return h.explicitlyCleared&&e(),M.on(g,"click",e),h.on("clear",e),M.on(g,"click",e),{mark:h,clear:e}}function Zn(i,a){var r=[];function g(){for(var n=0;n=0&&na){var l=[{line:s,cm:g}];i.left&&l.push({line:ut(s,i.left.chunks),cm:i.left.orig}),i.right&&l.push({line:ut(s,i.right.chunks),cm:i.right.orig});var f=Zn(o,l);i.options.onCollapse&&i.options.onCollapse(i,s,o,f)}}}function U(i,a,r,g){var h=document.createElement(i);if(r&&(h.className=r),g&&(h.style.cssText=g),typeof a=="string")h.appendChild(document.createTextNode(a));else if(a)for(var e=0;e0;--a)i.removeChild(i.firstChild)}function Pt(i){for(var a=1;a0)break}this.signal(),this.alignable.splice(r,0,i,a)},find:function(i){for(var a=0;a-1){var o=this.alignable[e+1];o==X?this.alignable.splice(e,2):this.alignable[e+1]=o&~X}t>-1&&r&&this.set(i+r,X)}};function tr(i,a){return(i.line-a.line||i.ch-a.ch)<0?i:a}function nr(i,a){return(i.line-a.line||i.ch-a.ch)>0?i:a}function rr(i,a){return i.line==a.line&&i.ch==a.ch}function ir(i,a,r){for(var g=i.length-1;g>=0;g--){var h=i[g],e=(r?h.origTo:h.editTo)-1;if(ea)return e}}function Rt(i,a){var r=null,g=i.state.diffViews,h=i.getCursor().line;if(g)for(var e=0;er:s{g.current===null||h.current||(h.current=M.MergeView(g.current,{mode:{name:"javascript",json:!0},lineNumbers:!0,theme:"tailscale",fixedGutter:!1,origLeft:"",value:"",readOnly:!0,allowEditingOriginals:!1,collapseIdentical:3,revertButtons:!1,connect:"align",lineWrapping:!0}))}),O.useEffect(()=>{if(h.current){const e=h.current.leftOriginal(),t=e.getCursor();e.setValue(r.originalAcl??""),e.setCursor(t);const n=h.current.editor(),s=n.getCursor();n.setValue(r.draft),n.setCursor(s)}},[r]),k.jsx("div",{className:B(a,"ACLDiff ACLWrapper"),children:k.jsx("div",{ref:g})})}function lr(i){const{subject:a}=i,{aclTags:r,error:g}=zt(),{data:h,error:e}=Ut(),[,t]=Ee(),n=O.useRef(null),s=O.useMemo(()=>Wt(h?.users.filter(u=>!!u.loginName)||[],"loginName"),[h?.users]),o=O.useMemo(()=>[...r.all,...Object.keys(s).sort((u,m)=>u.localeCompare(m))],[r.all,s]),{isOpen:l,selectedItem:f,getToggleButtonProps:c,getMenuProps:d,getItemProps:b,highlightedIndex:w}=Gt({items:o,onSelectedItemChange:({selectedItem:u})=>{t(`/admin/acls/preview${u?`?q=${encodeURIComponent(u)}`:""}`)},selectedItem:a}),p=f||"";return e||g?k.jsx(Ae,{intent:"warning",children:"Failed to load users and tags. Please refresh the page to try again."}):k.jsxs("div",{ref:n,children:[k.jsxs("button",{type:"button",className:"picker py-2 px-3 font-medium flex items-center icon-parent",...c(),children:[s[p]?k.jsx(yt,{user:s[p]}):f?k.jsx(kt,{tag:f}):k.jsx("span",{children:"Select a user or tag"}),k.jsx(ge,{className:"ml-2",strokeWidth:"2.2"})]}),k.jsx("div",{className:B("absolute mt-1 picker-menu outline-none bg-bg-base p-0 z-10",{"opacity-0 pointer-events-none":!l}),...d(),children:l&&k.jsx(O.Fragment,{children:k.jsx("ul",{className:"max-w-[300px] max-h-[400px] list-none overflow-y-auto",children:o.map((u,m)=>k.jsx("li",{className:B("py-2 px-3 cursor-pointer",{"border-t":m!==0,"bg-bg-menu-item-hover":w===m}),style:{height:40},...b({item:u,index:m}),children:s[u]?k.jsx(yt,{user:s[u]}):k.jsx(kt,{tag:u})},u))})})})]})}function yt(i){const{className:a,user:r}=i;return k.jsxs("div",{className:B("flex items-center min-w-0 space-x-2",a),children:[r&&k.jsx($t,{sizeClassName:"w-5 h-5 text-sm",user:r}),k.jsx("span",{className:"font-medium truncate",children:r.loginName})]})}function kt(i){const{className:a,tag:r}=i;return k.jsxs("div",{className:B("flex items-center min-w-0 space-x-2",a),children:[k.jsx("div",{className:"bg-yellow-400 text-white w-5 h-5 rounded-full flex items-center justify-center",children:k.jsx(Qt,{className:"relative left-px top-px",size:"13",strokeWidth:2.2})}),k.jsx("span",{className:"font-medium truncate",children:r})]})}function or(i){const{className:a,acl:r,subject:g,onLineNumberClick:h}=i,{data:e,error:t}=Kt({type:"user",previewFor:g,acl:r}),n=O.useMemo(()=>e?.matches.some(o=>o.via&&o.via.length>0)||!1,[e]);function s(o){typeof h=="function"&&h(o)}return k.jsxs("section",{className:B(a,"flex flex-col bg-cm dark:bg-gray-900 border border-cm dark:border-gray-600 rounded rounded-tl-none pt-4 px-4"),style:{height:"35rem"},children:[k.jsxs("header",{className:"mb-4",children:[k.jsx("h3",{className:qt.sectionTitle,children:"Preview Rules"}),k.jsx("p",{children:"Preview which hosts and ports a user’s machines are allowed to access."})]}),k.jsxs("div",{className:"flex items-center space-x-3 mb-3",children:[k.jsx(lr,{subject:g}),g&&!e&&k.jsx(Xt,{size:"sm"})]}),k.jsx("div",{className:"overflow-y-scroll h-auto",children:g!==void 0&&(e?k.jsx(O.Fragment,{children:e.matches.length>0?k.jsxs("table",{className:"tb-auto w-full",children:[k.jsx("thead",{className:"bg-cm dark:bg-gray-900 sticky top-0 drop-shadow-[0_1px_0_var(--color-border-base)]",children:k.jsxs("tr",{children:[k.jsx("th",{className:"w-16",children:"Line"}),k.jsx("th",{children:"Allowed destinations"}),k.jsx("th",{children:"Sources"}),n&&k.jsx("th",{children:"Via"}),e.matches.some(o=>o.postures)?k.jsx("th",{children:"Postures"}):null]})}),k.jsx("tbody",{children:e.matches.map((o,l)=>o.ports?.map((f,c)=>k.jsx(ur,{rule:o,port:f,showViaCol:n,postureRules:e.postures,onClick:s},`${l}-${c}`)))})]}):k.jsxs(Mt,{header:k.jsx("h4",{className:"font-semibold",children:"No ACL rules matched"}),children:[g," cannot access any ports on the network."]})}):t?k.jsx(hr,{error:t}):null)})]})}function fr({postureKeys:i,postureRules:a}){return k.jsx("td",{children:k.jsx(Jt,{asChild:!0,content:k.jsxs("div",{className:"flex flex-col divide-y dark:divide-gray-700 max-w-sm",children:[i.length>1&&k.jsxs("p",{className:"px-4 py-3",children:["This access rule applies to source devices that satisfy"," ",k.jsx("strong",{children:"any"})," of the following posture conditions:"]}),i.map(r=>k.jsx(cr,{postureKey:r,postureRules:a},r))]}),children:k.jsx(W,{variant:"minimal",className:"-ml-1 px-1 py-0 hover:!bg-transparent state-open:opacity-100 hover:opacity-75 font-normal",suffixIcon:k.jsx(ge,{}),"aria-label":"See all addresses for this device.",children:i.join(",")})})})}function cr({postureKey:i,postureRules:a}){const r="px-4 py-3",g=a[i];return g?k.jsxs("div",{className:r,children:[k.jsxs("p",{className:"mb-2",children:[k.jsx(ke,{className:"-ml-1",children:i})," ","matches source devices with all the following attributes:"]}),k.jsx("ul",{className:"list-disc pl-4",children:g.map(h=>k.jsx("li",{className:"my-0.5",children:k.jsx(ke,{children:h})},h))})]},i):k.jsx("div",{className:r,children:k.jsxs("p",{children:[k.jsx(ke,{children:i})," has no rules configured."]})},i)}function ke({className:i,children:a}){return k.jsx("code",{className:B("inline-block text-sm px-1 py-0.5 bg-gray-100 dark:bg-gray-800 rounded-md",i),children:a})}function ur({rule:i,port:a,showViaCol:r,onClick:g,postureRules:h}){return k.jsxs("tr",{className:"font-mono text-code align-top",children:[k.jsx("td",{className:"w-16",children:k.jsx("button",{className:"link",onClick:()=>g(i.lineNumber-1),children:i.lineNumber})}),k.jsx("td",{children:a}),k.jsx("td",{children:i.users.join(", ")}),i.via&&i.via.length>0?k.jsx("td",{children:i.via.join(", ")}):r&&k.jsx("td",{}),i.postures&&h?k.jsx(fr,{postureKeys:i.postures,postureRules:h}):null]},`${i.lineNumber}-${a}`)}function hr(i){const{error:a}=i;return k.jsx(Mt,{header:k.jsxs(O.Fragment,{children:[k.jsx(wt,{className:"mr-2"}),k.jsx("h4",{className:"font-semibold",children:"An error occurred"})]}),children:a})}function Mt(i){return k.jsxs("div",{className:"p-3 border rounded-md max-w-xl",children:[k.jsx("header",{className:"flex items-center mb-2",children:i.header}),k.jsx("p",{children:i.children})]})}function gr(i){const{className:a,onChange:r,editorRef:g,defaultValue:h,gitOpsLock:e,gitOpsUnlock:t,mode:n,onSave:s,aclDraftHasEdits:o,aclHasACLRules:l,syncTextToEditor:f}=i,{data:c}=Te(),d=O.useRef(null),b=O.useRef(null),w=n==="readonly"||n==="locked";return O.useEffect(()=>{if(d.current===null)return;const p=u=>u.toggleComment({indent:!0,lineComment:"//",fullLines:!0});return b.current=M.fromTextArea(d.current,{mode:{name:"javascript",json:!0},lineNumbers:!0,indentWithTabs:!0,indentUnit:4,theme:w?"tailscale readonly":"tailscale",extraKeys:{Tab:"indentMore","Shift-Tab":"indentLess","Cmd-/":p,"Ctrl-/":p,"Cmd-F":"findPersistent","Ctrl-F":"findPersistent","Alt-F":!1,"Cmd-K":u=>u.foldCode(u.getCursor())},fixedGutter:!1,foldGutter:!0,gutters:["CodeMirror-linenumbers","CodeMirror-foldgutter"],matchBrackets:!0,readOnly:w,continueComments:!0}),g.current=b.current,()=>{b.current?.toTextArea()}},[g,w]),O.useEffect(()=>{if(b.current===null)return;function p(m){r(m.getValue())}function u(m,y,x){if(x==="CodeMirror-foldgutter")return;const C=m.lineInfo(y);m.setSelection({line:y,ch:0},{line:y,ch:C.text.length})}return b.current.on("change",p),b.current.on("gutterClick",u),()=>{b.current&&(b.current.off("change",p),b.current.off("gutterClick",u))}},[r]),O.useEffect(()=>{if(b.current!==null)return Le.set(b.current,{onSave:s,readonly:w}),()=>{b.current&&Le.delete(b.current)}},[s,w]),k.jsxs(k.Fragment,{children:[n==="readonly"?k.jsx(Cr,{}):c?.aclsExternallyManagedOn?k.jsx(Sr,{url:c?.aclsExternalLink,mode:n,lock:e,unlock:t}):null,k.jsxs("div",{className:B(a,"ACLEditor relative @md:flex bg-cm dark:bg-gray-900 border border-cm rounded-b rounded-tr overflow-hidden"),children:[k.jsx("div",{className:"w-full flex-grow-0 min-w-0 flex-shrink basis-auto",children:k.jsx("textarea",{className:"font-mono min-h-0 ",ref:d,defaultValue:h})}),k.jsx(mr,{className:"w-full flex-shrink-0",disabled:w||o||!l,syncTextToEditor:f})]})]})}const Q={className:"link",rel:"noopener noreferrer",target:"_blank"};function dr(i){const[a,r]=J(!0,"tailscale/acl-editor-sidebar-open"),[g,h]=O.useState(!1),e=nn("sm"),t=O.useRef(null),n=O.useRef(null),s=280,o=450,[l,f]=J(i,"tailscale/acl-editor-sidebar-width"),c=O.useRef(0),d=O.useRef(0),b=O.useRef(l),w=O.useRef(a);return O.useEffect(()=>{w.current=a},[a]),O.useEffect(()=>{if(!t.current||!n.current)return;const p=n.current,u=t.current;if(!e){p.style.removeProperty("max-width"),u.style.display="none";return}u.style.removeProperty("display"),p.style.maxWidth=b.current+"px";const m=C=>{if(!p)return;const _=C.clientX-c.current,j=d.current-_;let v=vr(j,s,o);w.current?js*1.5&&(r(!0),v=s,c.current=C.clientX),p.style.maxWidth=v+"px",b.current=v},y=()=>{p&&(f(b.current),h(!1),p.style.removeProperty("user-select"),p.style.removeProperty("pointer-events"),p.parentElement&&p.parentElement.style.removeProperty("pointer-events"),document.body.style.removeProperty("cursor"),document.removeEventListener("mousemove",m),document.removeEventListener("mouseup",y))},x=C=>{c.current=C.clientX,d.current=b.current,h(!0),p.style.userSelect="none",p.style.pointerEvents="none",p.parentElement&&(p.parentElement.style.pointerEvents="none"),document.body.style.cursor="col-resize",document.addEventListener("mousemove",m),document.addEventListener("mouseup",y)};return u.addEventListener("mousedown",x),()=>{u.removeEventListener("mousedown",x),document.removeEventListener("mousemove",m),document.removeEventListener("mouseup",y),document.body.style.removeProperty("cursor")}},[f,r,e]),{resizerRef:t,panelRef:n,dragging:g,isDesktop:e,open:a,setOpen:r}}function vr(i,a,r){return Math.max(Math.min(i,r),a)}function mr(i){const{className:a,disabled:r,syncTextToEditor:g}=i,{data:h}=xt(),[e,t]=O.useState(!1),{resizerRef:n,panelRef:s,dragging:o,isDesktop:l,open:f,setOpen:c}=dr(320);return k.jsxs("div",{className:B("relative z-20 overflow-y-auto",{"@md:w-8":!f},a),ref:s,children:[k.jsxs("div",{className:B("absolute top-0 bottom-0 h-full transition-colors ",{"right-0 w-8 border-l border-cm bg-cm cursor-pointer":!f,"w-4":f}),onMouseOver:()=>t(!0),onMouseOut:()=>t(!1),onClick:()=>c(!0),children:[k.jsx("div",{className:B("relative w-1 h-full bg-gray-900/20 dark:bg-gray-100/40 cursor-col-resize z-10 transition-opacity",{"opacity-0":!o&&!e,"opacity-80":o||e}),ref:n}),k.jsx(tn,{className:B("absolute top-2 left-1/2 -translate-x-1/2",{hidden:f}),color:e?"gray":"darkgray"})]}),k.jsxs("div",{className:B("h-full overflow-y-auto overscroll-y-contain border-cm transition-shadow",{"border-l":l,"border-t":!l,"shadow-[0_0_10px_-5px_rgba(0,0,0,0.07)]":!e&&!o,"shadow-[0_0_8px_0px_rgba(0,0,0,0.10)]":e||o,"h-0":!f}),children:[k.jsx(pr,{}),h.provisioningSupported&&k.jsx(br,{}),k.jsx(yr,{}),h.featureIngress&&k.jsx(wr,{}),k.jsx(kr,{}),k.jsx(xr,{disabled:r,syncTextToEditor:g})]})]})}function ee(i){const{id:a,title:r,icon:g,className:h,children:e}=i,[t,n]=J(!0,`tailscale/acl-editor-sidebar-section-open/${a}`);return k.jsxs("div",{className:B(h,"border-cm border-b last:border-b-0 last:@md:border-b"),children:[k.jsxs("button",{className:B("py-4 px-4 w-full flex justify-between border-cm transition-colors hover:bg-gray-500/5",{"border-b":t}),onClick:()=>n(s=>!s),children:[k.jsxs("h3",{className:"flex items-center font-medium",children:[g,r]}),k.jsx(ge,{size:20,className:B("text-text-muted transition-transform",{"-rotate-90":!t})})]}),k.jsx("div",{className:B("p-4",{hidden:!t}),children:e})]})}function pr(){const{data:i}=xt();return k.jsxs(ee,{id:"docs",title:"Docs",icon:k.jsx(rn,{className:"mr-2",size:"1.1em"}),children:[k.jsx("p",{className:"mb-2",children:"Learn how to configure your tailnet policy file."}),k.jsxs("ul",{children:[k.jsx("li",{children:k.jsx("a",{href:"https://tailscale.com/kb/1337/acl-syntax",...Q,children:"Syntax reference"})}),k.jsx("li",{children:k.jsx("a",{href:"https://tailscale.com/kb/1068/acl-tags#define-a-tag",...Q,children:"Tags reference"})}),k.jsx("li",{children:k.jsx("a",{href:"https://tailscale.com/kb/1193/tailscale-ssh/",...Q,children:"SSH reference"})}),i.featureIngress&&k.jsx("li",{children:k.jsx("a",{href:"https://tailscale.com/kb/1223/tailscale-funnel",...Q,children:"Funnel reference"})}),k.jsx("li",{children:k.jsx("a",{href:"https://tailscale.com/kb/1337/policy-syntax#tests",...Q,children:"Tests reference"})}),k.jsx("li",{children:k.jsx("a",{href:"https://tailscale.com/kb/1458/grant-examples",...Q,children:"Examples"})})]})]})}function br(){const{data:i,error:a}=Ct(),r=i?.syncDetails?.syncedGroups;return k.jsx(ee,{id:"provisioning",title:"Group Provisioning",icon:k.jsx(sn,{className:"mr-2",size:"1.1em"}),children:a?"Error loading data.":i?i.provisioningEnabled?k.jsxs(k.Fragment,{children:[k.jsxs("p",{className:"flex items-center justify-between",children:[k.jsxs("span",{className:"font-medium",children:["Provisioning from ",i.provider]}),i.syncDetails.providerGroupsUrl&&k.jsx("a",{href:i.syncDetails.providerGroupsUrl,...Q,children:"Configure"})]}),k.jsx("div",{className:"mt-4 rounded-md",children:r&&r.length>0?r.map(g=>k.jsx(xn,{group:g,showCopyID:!0},g.name)):"No groups synced"}),i.syncDetails.lastSynced&&k.jsxs("p",{className:"text-text-muted mt-4",children:["Last synced"," ",an(new Date(i.syncDetails.lastSynced))]})]}):k.jsxs(k.Fragment,{children:[k.jsxs("p",{className:"mb-2",children:["Sync user groups from ",i.provider," and use them in your ACL policy."]}),k.jsx(St,{to:"/admin/settings/user-management",className:"link",children:"Enable provisioning sync"})]}):"Loading..."})}function yr(){const{data:i,applyPatches:a}=de(),[r,g]=O.useState(!1),[h,e]=O.useState(!1),{access:t}=Oe(Fe.ACLs),n=ve(),s=!!i?.sshEnabled,o=Pe(t),l=O.useCallback(()=>{g(!0),a([{type:"add-default-ssh"}]).catch(()=>{n.show({message:"Error enabling SSH",variant:"danger"})}).finally(()=>{g(!1)})},[a,n]),f=O.useCallback(()=>{g(!0),a([{type:"remove-ssh"}]).catch(()=>{n.show({message:"Error removing SSH rules",variant:"danger"})}).finally(()=>{g(!1),e(!1)})},[a,n]);return k.jsxs(ee,{id:"tailscale-ssh",title:k.jsx(k.Fragment,{children:"Tailscale SSH"}),icon:k.jsx(Fn,{className:"mr-2",size:"1.1em"}),children:[k.jsxs(le,{title:"Disable Tailscale SSH?",open:h,onOpenChange:e,children:[k.jsx("p",{children:"Users of your network will no longer be able to SSH using Tailscale SSH. Ensure you have alternate methods of accessing devices before you disable Tailscale SSH."}),k.jsx(le.Form,{onSubmit:f,loading:r,destructive:!0,cancelButton:!0,submitButton:"Disable Tailscale SSH"})]}),k.jsx("p",{className:"mb-4",children:"SSH into servers using Tailscale & ACLs for authentication and authorization."}),s?k.jsx(W,{disabled:!o,intent:"danger",sizeVariant:"small",onClick:()=>e(!0),children:"Disable Tailscale SSH…"}):k.jsx(W,{disabled:!o,loading:r,onClick:l,sizeVariant:"small",children:"Enable Tailscale SSH"})]})}function kr(){const{data:i}=Te();return k.jsx(ee,{id:"git-ops",title:"GitOps",icon:k.jsx(An,{className:"mr-2",size:"1.1em"}),children:i?.aclsExternallyManagedOn?k.jsx("div",{className:"mb-2",children:k.jsxs("p",{className:"mb-2",children:["This policy file is managed via a"," ",k.jsx("a",{className:"link",href:i?.aclsExternalLink,target:"_blank",rel:"noopener noreferrer",children:"linked repository"}),"."]})}):k.jsxs("p",{className:"mb-1",children:["Manage your policy file using"," ",k.jsx("a",{href:"https://tailscale.com/kb/1204/gitops-acls/",...Q,children:"GitOps for Tailscale ACLs"}),"."]})})}function wr(){const{data:i,applyPatches:a,isPosting:r}=de(),{access:g}=Oe(Fe.ACLs);return k.jsxs(ee,{id:"funnel",title:k.jsxs(k.Fragment,{children:["Funnel",k.jsx(on,{className:"ml-2 text-sm"})]}),icon:k.jsx(ln,{className:"mr-2",size:"1.1em"}),children:[k.jsx("p",{className:"mb-2",children:"Manage which nodes are allowed to accept internet traffic."}),k.jsx(De,{kbTopic:"Funnel ACLs",url:"https://tailscale.com/kb/1223/tailscale-funnel"}),!i?.funnelEnabled&&k.jsx(W,{className:"block mt-4",disabled:!Pe(g),loading:r,onClick:()=>a([{type:"add-default-funnel"}]),sizeVariant:"small",children:"Add Funnel to policy"})]})}function xr({disabled:i,syncTextToEditor:a}){const r=ve(),{aclsToGrants:g,isPosting:h}=de(),{access:e}=Oe(Fe.ACLs);function t(){g().then(n=>{a(n)}).catch(n=>{console.error("Error converting ACLs to grants:",n),r.show({message:"Error converting ACLs to grants",variant:"danger"})})}return k.jsxs(ee,{id:"convert-acls-to-grants",title:k.jsx(k.Fragment,{children:"Convert ACLs to grants"}),icon:k.jsx(Ln,{className:"mr-2",size:"1.1em"}),children:[k.jsxs("p",{className:"mb-2",children:["Convert deprecated ACL rules to the grant syntax. Changes can be reverted via audit"," ",k.jsx(St,{className:"link",href:"/admin/logs",children:"logs"}),"."]}),k.jsx(De,{kbTopic:"Grants migration",url:"https://tailscale.com/kb/1542/grants-migration"}),k.jsx(W,{className:"block mt-4",disabled:!Pe(e)||i,loading:h,onClick:()=>t(),sizeVariant:"small",children:"Convert to grants..."})]})}M.commands.save=function(i){const a=Le.get(i);a&&!a.readonly&&a.onSave()};const Le=new WeakMap;function Cr(){return k.jsxs(It,{children:[k.jsx(wt,{size:14,className:"text-text-muted mr-2"})," You don’t have permission to edit the tailnet policy file."]})}function Sr(i){const{url:a,mode:r,unlock:g,lock:h}=i,[e,t]=O.useState(!1),n=r==="locked";return k.jsxs(k.Fragment,{children:[k.jsx(It,{children:k.jsxs("div",{children:[k.jsxs("div",{className:"flex mb-2",children:[n?k.jsx(Yt,{size:16,className:"text-text-muted mr-2"}):k.jsx(Zt,{size:16,className:"text-text-muted mr-2"}),k.jsxs("span",{children:["This file is managed externally and locked in the editor."," ",k.jsx(De,{kbTopic:"GitOps ACLs",url:"https://tailscale.com/kb/1204/gitops-acls/"})]})]}),k.jsxs("div",{className:"ml-6 space-x-2",children:[a&&k.jsx("a",{href:a,target:"_blank",rel:"noreferrer noopener",children:k.jsx(W,{className:"inline-flex items-center space-x-2",sizeVariant:"small",suffixIcon:k.jsx(en,{size:14,className:"text-text-muted"}),children:"View source"})}),n?k.jsx(W,{sizeVariant:"small",onClick:()=>t(!0),children:"Edit anyway…"}):k.jsx(W,{sizeVariant:"small",onClick:h,children:"Discard and lock"})]})]})}),k.jsxs(le,{title:"Edit anyway",open:e,onOpenChange:t,children:[k.jsx("p",{className:"mb-2",children:"Editing your tailnet policy file lets you make emergency changes without using Git."}),k.jsxs("p",{children:[k.jsx("strong",{children:"Changes made here will be overwritten"})," the next time the linked Git repository is updated."]}),k.jsx(le.Form,{onSubmit:()=>{t(!1),g()},destructive:!0,cancelButton:!0,submitButton:"Edit anyway"})]})]})}function It(i){const{children:a,rounded:r=!0}=i;return k.jsx("div",{className:B("flex items-center bg-cm dark:bg-gray-900 px-4 py-3 border-t border-l border-r",{"rounded-tr":r}),children:a})}function jr(i){const[,a]=Ee(),{value:r}=i,[,g]=J("visual",Sn),[h]=J("general-access-rules",jn),[e]=J("file",Me),{data:t}=jt(),n=()=>{if(!t)return;const o=`https://tailscale.typeform.com/to/WfN7OupL#domain=${t.domainName}`;window.open(o,"_blank","noopener,noreferrer")},s=o=>{fn(cn.ACLSwitchToggled,{aclSwitchToggledProperties:{toggleDirection:o}})};return O.useEffect(()=>{g(r)},[g,r]),k.jsxs("div",{className:"flex justify-between items-center flex-1",children:[k.jsx("div",{className:"flex text-nowrap items-center",children:k.jsx(Cn,{options:[{id:"visual",label:"Visual editor"},{id:"json",label:"JSON editor"}],value:r,onChange:o=>{o==="json"?(s("json"),a(`/admin/acls/${e}`)):(s("visual"),a(`/admin/acls/visual/${h}`))}})}),r==="visual"&&k.jsx(W,{sizeVariant:"medium",className:"ml-4",prefixIcon:k.jsx(_n,{}),onClick:n,children:"Give feedback"})]})}function _r(i,a){O.useEffect(()=>{if(i!==!0)return;function r(g){g.preventDefault(),a&&a()}return window.addEventListener("beforeunload",r),()=>{window.removeEventListener("beforeunload",r)}},[i,a])}const Bt="precondition failed, invalid old hash",Ht="policy file was modified concurrently, retry the operation";function Nr(i){const{data:a,error:r,mutate:g,aclDraft:h,setACLDraft:e,sessionStateError:t}=de(5e3),{data:n,mutate:s}=Ct();let o;r?o=k.jsx(Ie,{error:r}):a?.acl?o=k.jsxs(k.Fragment,{children:[n?.provisioningEnabled&&n?.syncDetails?.unresolvedSyncedGroupsInAcl&&k.jsx(Ar,{className:"my-4",groups:n?.syncDetails?.unresolvedSyncedGroupsInAcl,provider:n.provider}),k.jsx(Er,{remoteAcl:a,aclDraft:h,setACLDraft:e,readonly:i.readonly,revalidate:()=>g().then(()=>{s()}),tab:i.tab,sessionStateError:t})]}):o=k.jsx(Ie,{loadingMessage:"Loading ACLs..."});const{variant:l}=un("replace-learn-more-ctas-with-descriptive-ctas",!0),{grouped:f}=hn();return k.jsx(gn,{title:f?"JSON editor":"Access controls",description:"Control who and which devices are allowed to connect in your network.",learnMoreUrl:"https://tailscale.com/kb/1337/policy-syntax",learnMoreLabel:l==="variant1"?"See how to write access policies":void 0,cta:f?void 0:k.jsx(jr,{value:"json"}),children:o})}const Z={file:"file",diff:"diff",preview:"preview"},Me="tailscale/acl-editor-active-tab";function Lr(i){const{remoteAcl:a,aclDraft:r,setACLDraft:g,readonly:h,revalidate:e}=i,[t,n]=O.useState(!1),{data:s}=Te(),[o,l]=O.useState(s?.aclsExternallyManagedOn),{data:f}=jt(),[c,d]=bn(f?.id||"","tailscale/acl-editor-current-editor"),[b,w]=O.useState(void 0),p=h?"readonly":s?.aclsExternallyManagedOn?o?"locked":"unlocked":"edit",u=O.useRef(null),m=ve(),y=_t(r),x=r.originalHash!==a?.hash,C=r.draft===r.originalAcl||t,_=C||b?.code==="invalid_hash",j=T=>{g(wn(r,T))},v=O.useCallback(T=>{const A=u.current;if(!A)return;const D=A.getCursor(),F=A.getScrollInfo();A.setValue(T),A.setCursor(D),A.scrollTo(F.left,F.top)},[]),S=O.useCallback(()=>{w(void 0),v(a?.acl??""),g({originalAcl:a?.acl,originalHash:a?.hash,draft:a?.acl??""})},[a,v,g]),L=O.useCallback(T=>{n(!0),l(!0),w(void 0),yn.post("/acls",{acl:T.draft,hash:T.originalHash}).then(e).then(()=>{kn(),a?.acl&&v(a.acl),n(!1),m.show({message:"Saved tailnet policy file"})}).catch(A=>{n(!1);const D=A?.response?.data?.error,F=A?.response?.data?.data;if(!D){w({code:"unknown",message:A.message});return}if(D===Bt||D===Ht){w({code:"invalid_hash"});return}w({code:"invalid_acl",message:D,testFailures:F})})},[e,m,a?.acl,v]),N=O.useCallback(()=>l(!1),[]),E=O.useCallback(()=>{l(!0),S()},[S]);return O.useEffect(()=>{c!==f?.id&&(S(),d(f?.id||""))},[c,d,f,S]),O.useEffect(()=>{if(!t&&x){if(y){w({code:"invalid_hash"});return}S()}},[t,r,x,y,w,S]),_r(y,S),{error:b,editorMode:p,editorRef:u,hasLocalChanges:y,hasRemoteChanges:x,isPosting:t,isResetDisabled:C,isSaveDisabled:_,updateLocalAcl:j,reset:S,save:L,syncTextToEditor:v,gitOpsLock:E,gitOpsUnlock:N}}const we="bg-cm text-blue-600 dark:text-blue-300 !border-b-cm-selected",xe="bg-gray-100 dark:bg-gray-700",Ce="border-b border-cm flex items-center cursor-pointer font-medium py-2 px-4 select-none";function Er(i){const{remoteAcl:a,aclDraft:r,setACLDraft:g,readonly:h,revalidate:e,tab:t,sessionStateError:n}=i,{isPosting:s,isResetDisabled:o,isSaveDisabled:l,error:f,editorRef:c,editorMode:d,updateLocalAcl:b,gitOpsLock:w,gitOpsUnlock:p,reset:u,save:m,syncTextToEditor:y}=Lr({remoteAcl:a,aclDraft:r,setACLDraft:g,revalidate:e,readonly:h}),[,x]=Ee(),C=ve(),{query:_}=vn(),j=Z[t]||"file",[,v]=J("file",Me);if(O.useEffect(()=>{v(j)},[v,j]),O.useEffect(()=>{n&&j==="file"&&C.show({key:"policy-file-draft-error",variant:"danger",message:"Failed to track draft policy file changes. Navigating away from this page may discard your draft changes to the policy file if you have made any."})},[n,j,C]),!Z[t])return k.jsx(mn,{});const S=()=>{switch(j){case"file":{const L=r?.originalAcl?.includes('"acls": [')??!1;return k.jsx(gr,{className:"mb-3",onChange:b,onSave:()=>m(r),gitOpsLock:w,gitOpsUnlock:p,defaultValue:r.draft,editorRef:c,mode:d,aclDraftHasEdits:_t(r),aclHasACLRules:L,syncTextToEditor:y})}case"diff":return k.jsx(sr,{className:"mb-3",aclDraft:r});case"preview":return k.jsx(or,{className:"mb-3",acl:r.draft,subject:_,onLineNumberClick:L=>{x(`/admin/acls/${Z.file}`),setTimeout(()=>{const N=c.current;if(!N)return;const E=N.lineInfo(L);N.setSelection({line:L,ch:0},{line:L,ch:E.text.length}),N.scrollIntoView({line:L,ch:0},200)},5)}})}};return k.jsxs("div",{className:"mt-6",children:[k.jsxs("div",{className:"inline-flex relative -bottom-px z-10 rounded-t border-cm overflow-hidden border border-b-0",children:[k.jsxs("button",{role:"tab",className:B(Ce,{[we]:j==="file",[xe]:j!=="file","border-r":j!=="file"}),onClick:()=>x(`/admin/acls/${Z.file}`),children:[!h&&k.jsx(Dn,{className:"hidden @md:inline-block relative -top-px mr-2",size:"1.125em"}),k.jsxs("span",{children:[h?"View":"Edit"," file"]})]}),!h&&k.jsxs("button",{role:"tab",className:B(Ce,{[we]:j==="diff",[xe]:j!=="diff","border-l":j==="file","border-r":j==="preview"}),onClick:()=>x(`/admin/acls/${Z.diff}`),children:[k.jsx(Be,{className:"hidden @md:inline-block mr-2",size:"1.125em"}),k.jsx("span",{children:"Preview changes"})]}),k.jsxs("button",{role:"tab",className:B(Ce,{[we]:j==="preview",[xe]:j!=="preview","border-l":j!=="preview"}),onClick:()=>x(`/admin/acls/${Z.preview}`),children:[!h&&k.jsx(Be,{className:"hidden @md:inline-block mr-2",size:"1.125em"}),k.jsx("span",{children:"Preview rules"})]})]}),S(),f&&k.jsx(Ae,{className:"mb-3",intent:"error",icon:!1,children:f.code==="invalid_hash"?k.jsxs("p",{children:[k.jsx("strong",{children:"Error:"})," The policy file was updated by another session while you were editing it. Please copy your changes elsewhere and"," ",k.jsx("button",{className:"underline",onClick:u,children:"reset to the latest version"}),"."]}):f.code==="invalid_acl"?k.jsxs("div",{className:"whitespace-pre-wrap",children:[k.jsx("strong",{children:"Error: "}),f.message,f.testFailures?.map(L=>k.jsxs("div",{children:["test(s) failed for user: ",L.user,k.jsx("ul",{children:L.errors?.map(N=>k.jsx("li",{className:"pl-4",children:N},`${L.user}-${N}`))})]},L.user))]}):k.jsxs("p",{children:["An unknown error occurred while saving your policy file. Please copy your changes and try again later. If the error persists, please"," ",k.jsx(pn,{type:"acl",children:"contact us for support"}),"."]})}),!h&&k.jsxs("div",{className:"flex items-center space-x-3",children:[k.jsx(W,{disabled:l,intent:"primary",loading:s,onClick:()=>m(r),children:r.draft===""?"Reset to default policy":"Save"}),k.jsx(W,{disabled:o,onClick:u,children:"Discard changes"})]})]})}function Ar(i){const a=dn(!1);return k.jsxs(Ae,{className:i.className,intent:"warning",children:[k.jsxs("p",{children:["Some group(s) used in the policy file ",k.jsx("strong",{children:"are not syncing"})," ","from ",i.provider,"."]}),k.jsx("ul",{className:"text-sm my-4 max-h-24 overflow-auto",children:i.groups.map(r=>k.jsx("li",{children:r},r))}),k.jsx("p",{children:"These groups will be ignored by rules in the policy file."}),k.jsxs("button",{className:"flex items-center cursor-pointer text-sm font-medium mt-4",onClick:a.toggle,children:["To fix this issue",k.jsx(ge,{size:"1.125em",className:B("transition-transform ml-1",{"-rotate-90":!a.value})})]}),k.jsxs("div",{className:B("mt-4 text-sm",{hidden:!a.value}),children:[k.jsxs("p",{children:["If you wrote an access rule for a group you haven’t yet synced, make sure to assign it to the Tailscale app from ",i.provider,"."]}),k.jsxs("p",{className:"my-2",children:["If you modified the name of a group, update the group in the policy file to the new group name.",k.jsx("br",{}),"You can also revert the name change in ",i.provider," if this was unintentional."]}),k.jsx("p",{children:"If you deleted a group and no longer use it, remove the access rule."})]})]})}const Ir=Object.freeze(Object.defineProperty({__proto__:null,ACLConcurrentModificationError:Ht,ACLHashError:Bt,aclActiveTabKey:Me,default:Nr},Symbol.toStringTag,{value:"Module"}));export{Ht as A,jr as a,Bt as b,Ir as c};