1 (function(){function n(n
,t
,i
){var u
=n
.getWrapperElement(),r
;return r
=u
.appendChild(document
.createElement("div")),r
.className
=i
?"CodeMirror-dialog CodeMirror-dialog-bottom":"CodeMirror-dialog CodeMirror-dialog-top",typeof t
=="string"?r
.innerHTML
=t
:r
.appendChild(t
),r
}function t(n
,t
){n
.state
.currentNotificationClose
&&n
.state
.currentNotificationClose(),n
.state
.currentNotificationClose
=t
}CodeMirror
.defineExtension("openDialog",function(i
,r
,u
){function e(){h
||(h
=!0,o
.parentNode
.removeChild(o
))}var f
,s
;t(this,null);var o
=n(this,i
,u
&&u
.bottom
),h
=!1,c
=this;if(f
=o
.getElementsByTagName("input")[0],f
){CodeMirror
.on(f
,"keydown",function(n
){u
&&u
.onKeyDown
&&u
.onKeyDown(n
,f
.value
,e
)||(n
.keyCode
==13||n
.keyCode
==27)&&(CodeMirror
.e_stop(n
),e(),c
.focus(),n
.keyCode
==13&&r(f
.value
))});if(u
&&u
.onKeyUp
)CodeMirror
.on(f
,"keyup",function(n
){u
.onKeyUp(n
,f
.value
,e
)});u
&&u
.value
&&(f
.value
=u
.value
),f
.focus();CodeMirror
.on(f
,"blur",e
)}else if(s
=o
.getElementsByTagName("button")[0]){CodeMirror
.on(s
,"click",function(){e(),c
.focus()});s
.focus();CodeMirror
.on(s
,"blur",e
)}return e
}),CodeMirror
.defineExtension("openConfirm",function(i
,r
,u
){function a(){c
||(c
=!0,o
.parentNode
.removeChild(o
),l
.focus())}var f
,e
;t(this,null);var o
=n(this,i
,u
&&u
.bottom
),s
=o
.getElementsByTagName("button"),c
=!1,l
=this,h
=1;for(s
[0].focus(),f
=0;f
<s
.length
;++f
){e
=s
[f
],function(n
){CodeMirror
.on(e
,"click",function(t
){CodeMirror
.e_preventDefault(t
),a(),n
&&n(l
)})}(r
[f
]);CodeMirror
.on(e
,"blur",function(){--h
,setTimeout(function(){h
<=0&&a()},200)});CodeMirror
.on(e
,"focus",function(){++h
})}}),CodeMirror
.defineExtension("openNotification",function(i
,r
){function f(){e
||(e
=!0,clearTimeout(o
),u
.parentNode
.removeChild(u
))}t(this,f
);var u
=n(this,i
,r
&&r
.bottom
),s
=r
&&(r
.duration
===undefined?5e3
:r
.duration
),e
=!1,o
;CodeMirror
.on(u
,"click",function(n
){CodeMirror
.e_preventDefault(n
),f()});s
&&(o
=setTimeout(f
,r
.duration
))})})(),function(){function s(n
){return typeof n
=="string"?{token:function(t
){if(t
.match(n
))return"searching";t
.next(),t
.skipTo(n
.charAt(0))||t
.skipToEnd()}}:{token:function(t
){if(t
.match(n
))return"searching";while(!t
.eol())if(t
.next(),t
.match(n
,!1))break}}}function h(){this.posFrom
=this.posTo
=this.query
=null,this.overlay
=null}function t(n
){return n
.state
.search
||(n
.state
.search
=new h
)}function n(n
,t
,i
){return n
.getSearchCursor(t
,i
,typeof t
=="string"&&t
==t
.toLowerCase())}function i(n
,t
,i
,r
){n
.openDialog
?n
.openDialog(t
,r
):r(prompt(i
,""))}function c(n
,t
,i
,r
){n
.openConfirm
?n
.openConfirm(t
,r
):confirm(i
)&&r
[0]()}function f(n
){var t
=n
.match(/^\/(.*)\/([a-z]*)$/);return t
?new RegExp(t
[1],t
[2].indexOf("i")==-1?"":"i"):n
}function r(n
,r
){var u
=t(n
);if(u
.query
)return e(n
,r
);i(n
,l
,"Search for:",function(t
){n
.operation(function(){t
&&!u
.query
&&(u
.query
=f(t
),n
.removeOverlay(u
.overlay
),u
.overlay
=s(u
.query
),n
.addOverlay(u
.overlay
),u
.posFrom
=u
.posTo
=n
.getCursor(),e(n
,r
))})})}function e(i
,r
){i
.operation(function(){var f
=t(i
),u
=n(i
,f
.query
,r
?f
.posFrom
:f
.posTo
);(u
.find(r
)||(u
=n(i
,f
.query
,r
?CodeMirror
.Pos(i
.lastLine()):CodeMirror
.Pos(i
.firstLine(),0)),u
.find(r
)))&&(i
.setSelection(u
.from(),u
.to()),i
.scrollIntoView({from:u
.from(),to
:u
.to()}),f
.posFrom
=u
.from(),f
.posTo
=u
.to())})}function u(n
){n
.operation(function(){var i
=t(n
);i
.query
&&(i
.query
=null,n
.removeOverlay(i
.overlay
))})}function o(t
,r
){i(t
,a
,"Replace:",function(e
){e
&&(e
=f(e
),i(t
,v
,"Replace with:",function(i
){if(r
)t
.operation(function(){for(var u
,r
=n(t
,e
);r
.findNext();)typeof e
!="string"?(u
=t
.getRange(r
.from(),r
.to()).match(e
),r
.replace(i
.replace(/\$(\d)/,function(n
,t
){return u
[t
]}))):r
.replace(i
)});else{u(t
);var f
=n(t
,e
,t
.getCursor()),o=function(){var i
=f
.from(),r
;((r
=f
.findNext())||(f
=n(t
,e
),(r
=f
.findNext())&&(!i
||f
.from().line
!=i
.line
||f
.from().ch
!=i
.ch
)))&&(t
.setSelection(f
.from(),f
.to()),t
.scrollIntoView({from:f
.from(),to
:f
.to()}),c(t
,y
,"Replace?",[function(){s(r
)},o
]))},s=function(n
){f
.replace(typeof e
=="string"?i
:i
.replace(/\$(\d)/,function(t
,i
){return n
[i
]})),o()};o()}}))})}var l
='Search: <input type="text" style="width: 10em"/> <span style="color: #888">(Use /re/ syntax for regexp search)<\/span>',a
='Replace: <input type="text" style="width: 10em"/> <span style="color: #888">(Use /re/ syntax for regexp search)<\/span>',v
='With: <input type="text" style="width: 10em"/>',y
="Replace? <button>Yes<\/button> <button>No<\/button> <button>Stop<\/button>";CodeMirror
.commands
.find=function(n
){u(n
),r(n
)},CodeMirror
.commands
.findNext
=r
,CodeMirror
.commands
.findPrev=function(n
){r(n
,!0)},CodeMirror
.commands
.clearSearch
=u
,CodeMirror
.commands
.replace
=o
,CodeMirror
.commands
.replaceAll=function(n
){o(n
,!0)}}(),function(){function t(t
,i
,r
,u
){if(this.atOccurrence
=!1,this.doc
=t
,u
==null&&typeof i
=="string"&&(u
=!1),r
=r
?t
.clipPos(r
):n(0,0),this.pos
={from:r
,to
:r
},typeof i
!="string")i
.global
||(i
=new RegExp(i
.source
,i
.ignoreCase
?"ig":"g")),this.matches=function(r
,u
){var o
,h
,f
,s
,c
,e
;if(r
){for(i
.lastIndex
=0,o
=t
.getLine(u
.line
).slice(0,u
.ch
),h
=0;;){if(i
.lastIndex
=h
,c
=i
.exec(o
),!c
)break;if(f
=c
,s
=f
.index
,h
=f
.index
+(f
[0].length
||1),h
==o
.length
)break}e
=f
&&f
[0].length
||0,e
||(s
==0&&o
.length
==0?f
=undefined:s
!=t
.getLine(u
.line
).length
&&e
++)}else{i
.lastIndex
=u
.ch
;var o
=t
.getLine(u
.line
),f
=i
.exec(o
),e
=f
&&f
[0].length
||0,s
=f
&&f
.index
;s
+e
==o
.length
||e
||(e
=1)}if(f
&&e
)return{from:n(u
.line
,s
),to
:n(u
.line
,s
+e
),match
:f
}};else{u
&&(i
=i
.toLowerCase());var e
=u
?function(n
){return n
.toLowerCase()}:function(n
){return n
},f
=i
.split("\n");this.matches
=f
.length
==1?i
.length
?function(r
,u
){var s
=e(t
.getLine(u
.line
)),o
=i
.length
,f
;if(r
?u
.ch
>=o
&&(f
=s
.lastIndexOf(i
,u
.ch
-o
))!=-1:(f
=s
.indexOf(i
,u
.ch
))!=-1)return{from:n(u
.line
,f
),to
:n(u
.line
,f
+o
)}}:function(){}:function(i
,r
){var s
=r
.line
,h
=i
?f
.length
-1:0,u
=f
[h
],o
=e(t
.getLine(s
)),c
=i
?o
.indexOf(u
)+u
.length
:o
.lastIndexOf(u
),l
,a
,v
;if(!(i
?c
>r
.ch
||c
!=u
.length
:c
<r
.ch
||c
!=o
.length
-u
.length
))for(;;){if(i
?!s
:s
==t
.lineCount()-1)return;if(o
=e(t
.getLine(s
+=i
?-1:1)),u
=f
[i
?--h
:++h
],h
>0&&h
<f
.length
-1){if(o
!=u
)return;continue}return(l
=i
?o
.lastIndexOf(u
):o
.indexOf(u
)+u
.length
,i
?l
!=o
.length
-u
.length
:l
!=u
.length
)?void 0:(a
=n(r
.line
,c
),v
=n(s
,l
),{from:i
?v
:a
,to
:i
?a
:v
})}}}}var n
=CodeMirror
.Pos
;t
.prototype={findNext:function(){return this.find(!1)},findPrevious:function(){return this.find(!0)},find:function(t
){function f(t
){var i
=n(t
,0);return u
.pos
={from:i
,to
:i
},u
.atOccurrence
=!1,!1}for(var u
=this,i
=this.doc
.clipPos(t
?this.pos
.from:this.pos
.to
),r
;;){if(this.pos
=this.matches(t
,i
))return this.pos
.from&&this.pos
.to
||console
.log(this.matches
,this.pos
),this.atOccurrence
=!0,this.pos
.match
||!0;if(t
){if(!i
.line
)return f(0);i
=n(i
.line
-1,this.doc
.getLine(i
.line
-1).length
)}else{if(r
=this.doc
.lineCount(),i
.line
==r
-1)return f(r
);i
=n(i
.line
+1,0)}}},from:function(){if(this.atOccurrence
)return this.pos
.from},to:function(){if(this.atOccurrence
)return this.pos
.to
},replace:function(t
){if(this.atOccurrence
){var i
=CodeMirror
.splitLines(t
);this.doc
.replaceRange(i
,this.pos
.from,this.pos
.to
),this.pos
.to
=n(this.pos
.from.line
+i
.length
-1,i
[i
.length
-1].length
+(i
.length
==1?this.pos
.from.ch
:0))}}},CodeMirror
.defineExtension("getSearchCursor",function(n
,i
,r
){return new t(this.doc
,n
,i
,r
)}),CodeMirror
.defineDocExtension("getSearchCursor",function(n
,i
,r
){return new t(this,n
,i
,r
)})}()