@sync-in/server
Version:
The secure, open-source platform for file storage, sharing, collaboration, and sync
10 lines (9 loc) • 211 kB
JavaScript
/*! Hammer.JS - v2.0.7 - 2016-04-22
* http://hammerjs.github.io/
*
* Copyright (c) 2016 Jorik Tangelder;
* Licensed under the MIT license */(function(k,j,Q,G){"use strict";function R(f,h,p){return setTimeout(Ue(f,p),h)}function C(f,h,p){return Array.isArray(f)?(M(f,p[h],p),!0):!1}function M(f,h,p){var m;if(f)if(f.forEach)f.forEach(h,p);else if(f.length!==G)for(m=0;m<f.length;)h.call(p,f[m],m,f),m++;else for(m in f)f.hasOwnProperty(m)&&h.call(p,f[m],m,f)}function z(f,h,p){var m="DEPRECATED METHOD: "+h+`
`+p+` AT
`;return function(){var S=new Error("get-stack-trace"),P=S&&S.stack?S.stack.replace(/^[^\(]+?[\n$]/gm,"").replace(/^\s+at\s+/gm,"").replace(/^Object.<anonymous>\s*\(/gm,"{anonymous}()@"):"Unknown Stack Trace",B=k.console&&(k.console.warn||k.console.log);return B&&B.call(k.console,m,P),f.apply(this,arguments)}}function q(f,h,p){var m,S=h.prototype;m=f.prototype=Object.create(S),m.constructor=f,m._super=S,p&&Ve(m,p)}function Ue(f,h){return function(){return f.apply(h,arguments)}}function se(f,h){return typeof f==gr?f.apply(h&&h[0]||G,h):f}function Se(f,h){return f===G?h:f}function ne(f,h,p){M(ht(h),function(m){f.addEventListener(m,p,!1)})}function Tt(f,h,p){M(ht(h),function(m){f.removeEventListener(m,p,!1)})}function Ui(f,h){for(;f;){if(f==h)return!0;f=f.parentNode}return!1}function Lt(f,h){return f.indexOf(h)>-1}function ht(f){return f.trim().split(/\s+/g)}function rt(f,h,p){if(f.indexOf&&!p)return f.indexOf(h);for(var m=0;m<f.length;){if(p&&f[m][p]==h||!p&&f[m]===h)return m;m++}return-1}function ct(f){return Array.prototype.slice.call(f,0)}function Ae(f,h,p){for(var m=[],S=[],P=0;P<f.length;){var B=h?f[P][h]:f[P];rt(S,B)<0&&m.push(f[P]),S[P]=B,P++}return p&&(m=h?m.sort(function(J,je){return J[h]>je[h]}):m.sort()),m}function Ar(f,h){for(var p,m,S=h[0].toUpperCase()+h.slice(1),P=0;P<Jt.length;){if(p=Jt[P],m=p?p+S:h,m in f)return m;P++}return G}function Mn(){return hi++}function dt(f){var h=f.ownerDocument||f;return h.defaultView||h.parentWindow||k}function Oe(f,h){var p=this;this.manager=f,this.callback=h,this.element=f.element,this.target=f.options.inputTarget,this.domHandler=function(m){se(f.options.enable,[f])&&p.handler(m)},this.init()}function ni(f){var h,p=f.options.inputClass;return new(h=p||(le?mt:Xi?Kt:$?ke:gt))(f,Yt)}function Yt(f,h,p){var m=p.pointers.length,S=p.changedPointers.length,P=h&ae&&m-S===0,B=h&(te|Me)&&m-S===0;p.isFirst=!!P,p.isFinal=!!B,P&&(f.session={}),p.eventType=h,kt(f,p),f.emit("hammer.input",p),f.recognize(p),f.session.prevInput=p}function kt(f,h){var p=f.session,m=h.pointers,S=m.length;p.firstInput||(p.firstInput=E(h)),S>1&&!p.firstMultiple?p.firstMultiple=E(h):S===1&&(p.firstMultiple=!1);var P=p.firstInput,B=p.firstMultiple,J=B?B.center:P.center,je=h.center=Mt(m);h.timeStamp=Ye(),h.deltaTime=h.timeStamp-P.timeStamp,h.angle=nt(J,je),h.distance=we(J,je),pt(p,h),h.offsetDirection=it(h.deltaX,h.deltaY);var Ie=vt(h.deltaTime,h.deltaX,h.deltaY);h.overallVelocityX=Ie.x,h.overallVelocityY=Ie.y,h.overallVelocity=At(Ie.x)>At(Ie.y)?Ie.x:Ie.y,h.scale=B?pr(B.pointers,m):1,h.rotation=B?oi(B.pointers,m):0,h.maxPointers=p.prevInput?h.pointers.length>p.prevInput.maxPointers?h.pointers.length:p.prevInput.maxPointers:h.pointers.length,Ee(p,h);var Ze=f.element;Ui(h.srcEvent.target,Ze)&&(Ze=h.srcEvent.target),h.target=Ze}function pt(f,h){var p=h.center,m=f.offsetDelta||{},S=f.prevDelta||{},P=f.prevInput||{};h.eventType!==ae&&P.eventType!==te||(S=f.prevDelta={x:P.deltaX||0,y:P.deltaY||0},m=f.offsetDelta={x:p.x,y:p.y}),h.deltaX=S.x+(p.x-m.x),h.deltaY=S.y+(p.y-m.y)}function Ee(f,h){var p,m,S,P,B=f.lastInterval||h,J=h.timeStamp-B.timeStamp;if(h.eventType!=Me&&(J>ci||B.velocity===G)){var je=h.deltaX-B.deltaX,Ie=h.deltaY-B.deltaY,Ze=vt(J,je,Ie);m=Ze.x,S=Ze.y,p=At(Ze.x)>At(Ze.y)?Ze.x:Ze.y,P=it(je,Ie),f.lastInterval=h}else p=B.velocity,m=B.velocityX,S=B.velocityY,P=B.direction;h.velocity=p,h.velocityX=m,h.velocityY=S,h.direction=P}function E(f){for(var h=[],p=0;p<f.pointers.length;)h[p]={clientX:$e(f.pointers[p].clientX),clientY:$e(f.pointers[p].clientY)},p++;return{timeStamp:Ye(),pointers:h,center:Mt(h),deltaX:f.deltaX,deltaY:f.deltaY}}function Mt(f){var h=f.length;if(h===1)return{x:$e(f[0].clientX),y:$e(f[0].clientY)};for(var p=0,m=0,S=0;h>S;)p+=f[S].clientX,m+=f[S].clientY,S++;return{x:$e(p/h),y:$e(m/h)}}function vt(f,h,p){return{x:h/f||0,y:p/f||0}}function it(f,h){return f===h?$t:At(f)>=At(h)?0>f?mr:Ot:0>h?yr:Et}function we(f,h,p){p||(p=Ki);var m=h[p[0]]-f[p[0]],S=h[p[1]]-f[p[1]];return Math.sqrt(m*m+S*S)}function nt(f,h,p){p||(p=Ki);var m=h[p[0]]-f[p[0]],S=h[p[1]]-f[p[1]];return 180*Math.atan2(S,m)/Math.PI}function oi(f,h){return nt(h[1],h[0],er)+nt(f[1],f[0],er)}function pr(f,h){return we(h[0],h[1],er)/we(f[0],f[1],er)}function gt(){this.evEl=Nn,this.evWin=An,this.pressed=!1,Oe.apply(this,arguments)}function mt(){this.evEl=Wt,this.evWin=ji,Oe.apply(this,arguments),this.store=this.manager.session.pointerEvents=[]}function yt(){this.evTarget=pi,this.evWin=Zi,this.started=!1,Oe.apply(this,arguments)}function Or(f,h){var p=ct(f.touches),m=ct(f.changedTouches);return h&(te|Me)&&(p=Ae(p.concat(m),"identifier",!0)),[p,m]}function Kt(){this.evTarget=A,this.targetIds={},Oe.apply(this,arguments)}function Dt(f,h){var p=ct(f.touches),m=this.targetIds;if(h&(ae|ot)&&p.length===1)return m[p[0].identifier]=!0,[p,p];var S,P,B=ct(f.changedTouches),J=[],je=this.target;if(P=p.filter(function(Ie){return Ui(Ie.target,je)}),h===ae)for(S=0;S<P.length;)m[P[S].identifier]=!0,S++;for(S=0;S<B.length;)m[B[S].identifier]&&J.push(B[S]),h&(te|Me)&&delete m[B[S].identifier],S++;return J.length?[Ae(P.concat(J),"identifier",!0),J]:void 0}function ke(){Oe.apply(this,arguments);var f=Ue(this.handler,this);this.touch=new Kt(this.manager,f),this.mouse=new gt(this.manager,f),this.primaryTouch=null,this.lastTouches=[]}function xt(f,h){f&ae?(this.primaryTouch=h.changedPointers[0].identifier,he.call(this,h)):f&(te|Me)&&he.call(this,h)}function he(f){var h=f.changedPointers[0];if(h.identifier===this.primaryTouch){var p={x:h.clientX,y:h.clientY};this.lastTouches.push(p);var m=this.lastTouches,S=function(){var P=m.indexOf(p);P>-1&&m.splice(P,1)};setTimeout(S,It)}}function _i(f){for(var h=f.srcEvent.clientX,p=f.srcEvent.clientY,m=0;m<this.lastTouches.length;m++){var S=this.lastTouches[m],P=Math.abs(h-S.x),B=Math.abs(p-S.y);if(Rr>=P&&Rr>=B)return!0}return!1}function jt(f,h){this.manager=f,this.set(h)}function Je(f){if(Lt(f,b))return b;var h=Lt(f,F),p=Lt(f,Ft);return h&&p?b:h||p?h?F:Ft:Lt(f,xr)?xr:rr}function si(){if(!X)return!1;var f={},h=k.CSS&&k.CSS.supports;return["auto","manipulation","pan-y","pan-x","pan-x pan-y","none"].forEach(function(p){f[p]=h?k.CSS.supports("touch-action",p):!0}),f}function Pe(f){this.options=Ve({},this.defaults,f||{}),this.id=Mn(),this.manager=null,this.options.enable=Se(this.options.enable,!0),this.state=Rt,this.simultaneous={},this.requireFail=[]}function Er(f){return f&nr?"cancel":f&H?"end":f&zt?"move":f&Ce?"start":""}function vr(f){return f==Et?"down":f==yr?"up":f==mr?"left":f==Ot?"right":""}function Zt(f,h){var p=h.manager;return p?p.get(f):f}function U(){Pe.apply(this,arguments)}function Nt(){U.apply(this,arguments),this.pX=null,this.pY=null}function li(){U.apply(this,arguments)}function Pr(){Pe.apply(this,arguments),this._timer=null,this._input=null}function Wr(){U.apply(this,arguments)}function ai(){U.apply(this,arguments)}function Qt(){Pe.apply(this,arguments),this.pTime=!1,this.pCenter=!1,this._timer=null,this._input=null,this.count=0}function _e(f,h){return h=h||{},h.recognizers=Se(h.recognizers,_e.defaults.preset),new Hr(f,h)}function Hr(f,h){this.options=Ve({},_e.defaults,h||{}),this.options.inputTarget=this.options.inputTarget||f,this.handlers={},this.session={},this.recognizers=[],this.oldCssProps={},this.element=f,this.input=ni(this),this.touchAction=new jt(this,this.options.touchAction),qi(this,!0),M(this.options.recognizers,function(p){var m=this.add(new p[0](p[1]));p[2]&&m.recognizeWith(p[2]),p[3]&&m.requireFailure(p[3])},this)}function qi(f,h){var p=f.element;if(p.style){var m;M(f.options.cssProps,function(S,P){m=Ar(p.style,P),h?(f.oldCssProps[m]=p.style[m],p.style[m]=S):p.style[m]=f.oldCssProps[m]||""}),h||(f.oldCssProps={})}}function ui(f,h){var p=j.createEvent("Event");p.initEvent(f,!0,!0),p.gesture=h,h.target.dispatchEvent(p)}var Ve,Jt=["","webkit","Moz","MS","ms","o"],Dn=j.createElement("div"),gr="function",$e=Math.round,At=Math.abs,Ye=Date.now;Ve=typeof Object.assign!="function"?function(f){if(f===G||f===null)throw new TypeError("Cannot convert undefined or null to object");for(var h=Object(f),p=1;p<arguments.length;p++){var m=arguments[p];if(m!==G&&m!==null)for(var S in m)m.hasOwnProperty(S)&&(h[S]=m[S])}return h}:Object.assign;var fi=z(function(f,h,p){for(var m=Object.keys(h),S=0;S<m.length;)(!p||p&&f[m[S]]===G)&&(f[m[S]]=h[m[S]]),S++;return f},"extend","Use `assign`."),I=z(function(f,h){return fi(f,h,!0)},"merge","Use `assign`."),hi=1,We=/mobile|tablet|ip(ad|hone|od)|android/i,$="ontouchstart"in k,le=Ar(k,"PointerEvent")!==G,Xi=$&&We.test(navigator.userAgent),xe="touch",Vt="pen",de="mouse",Yi="kinect",ci=25,ae=1,ot=2,te=4,Me=8,$t=1,mr=2,Ot=4,yr=8,Et=16,et=mr|Ot,Pt=yr|Et,Ir=et|Pt,Ki=["x","y"],er=["clientX","clientY"];Oe.prototype={handler:function(){},init:function(){this.evEl&&ne(this.element,this.evEl,this.domHandler),this.evTarget&&ne(this.target,this.evTarget,this.domHandler),this.evWin&&ne(dt(this.element),this.evWin,this.domHandler)},destroy:function(){this.evEl&&Tt(this.element,this.evEl,this.domHandler),this.evTarget&&Tt(this.target,this.evTarget,this.domHandler),this.evWin&&Tt(dt(this.element),this.evWin,this.domHandler)}};var tr={mousedown:ae,mousemove:ot,mouseup:te},Nn="mousedown",An="mousemove mouseup";q(gt,Oe,{handler:function(f){var h=tr[f.type];h&ae&&f.button===0&&(this.pressed=!0),h&ot&&f.which!==1&&(h=te),this.pressed&&(h&te&&(this.pressed=!1),this.callback(this.manager,h,{pointers:[f],changedPointers:[f],pointerType:de,srcEvent:f}))}});var Fr={pointerdown:ae,pointermove:ot,pointerup:te,pointercancel:Me,pointerout:Me},di={2:xe,3:Vt,4:de,5:Yi},Wt="pointerdown",ji="pointermove pointerup pointercancel";k.MSPointerEvent&&!k.PointerEvent&&(Wt="MSPointerDown",ji="MSPointerMove MSPointerUp MSPointerCancel"),q(mt,Oe,{handler:function(f){var h=this.store,p=!1,m=f.type.toLowerCase().replace("ms",""),S=Fr[m],P=di[f.pointerType]||f.pointerType,B=P==xe,J=rt(h,f.pointerId,"pointerId");S&ae&&(f.button===0||B)?0>J&&(h.push(f),J=h.length-1):S&(te|Me)&&(p=!0),0>J||(h[J]=f,this.callback(this.manager,S,{pointers:h,changedPointers:[f],pointerType:P,srcEvent:f}),p&&h.splice(J,1))}});var Ht={touchstart:ae,touchmove:ot,touchend:te,touchcancel:Me},pi="touchstart",Zi="touchstart touchmove touchend touchcancel";q(yt,Oe,{handler:function(f){var h=Ht[f.type];if(h===ae&&(this.started=!0),this.started){var p=Or.call(this,f,h);h&(te|Me)&&p[0].length-p[1].length===0&&(this.started=!1),this.callback(this.manager,h,{pointers:p[0],changedPointers:p[1],pointerType:xe,srcEvent:f})}}});var re={touchstart:ae,touchmove:ot,touchend:te,touchcancel:Me},A="touchstart touchmove touchend touchcancel";q(Kt,Oe,{handler:function(f){var h=re[f.type],p=Dt.call(this,f,h);p&&this.callback(this.manager,h,{pointers:p[0],changedPointers:p[1],pointerType:xe,srcEvent:f})}});var It=2500,Rr=25;q(ke,Oe,{handler:function(f,h,p){var m=p.pointerType==xe,S=p.pointerType==de;if(!(S&&p.sourceCapabilities&&p.sourceCapabilities.firesTouchEvents)){if(m)xt.call(this,h,p);else if(S&&_i.call(this,p))return;this.callback(f,h,p)}},destroy:function(){this.touch.destroy(),this.mouse.destroy()}});var Ke=Ar(Dn.style,"touchAction"),X=Ke!==G,bt="compute",rr="auto",xr="manipulation",b="none",F="pan-x",Ft="pan-y",ir=si();jt.prototype={set:function(f){f==bt&&(f=this.compute()),X&&this.manager.element.style&&ir[f]&&(this.manager.element.style[Ke]=f),this.actions=f.toLowerCase().trim()},update:function(){this.set(this.manager.options.touchAction)},compute:function(){var f=[];return M(this.manager.recognizers,function(h){se(h.options.enable,[h])&&(f=f.concat(h.getTouchAction()))}),Je(f.join(" "))},preventDefaults:function(f){var h=f.srcEvent,p=f.offsetDirection;if(this.manager.session.prevented)return void h.preventDefault();var m=this.actions,S=Lt(m,b)&&!ir[b],P=Lt(m,Ft)&&!ir[Ft],B=Lt(m,F)&&!ir[F];if(S){var J=f.pointers.length===1,je=f.distance<2,Ie=f.deltaTime<250;if(J&&je&&Ie)return}return B&&P?void 0:S||P&&p&et||B&&p&Pt?this.preventSrc(h):void 0},preventSrc:function(f){this.manager.session.prevented=!0,f.preventDefault()}};var Rt=1,Ce=2,zt=4,H=8,st=H,nr=16,He=32;Pe.prototype={defaults:{},set:function(f){return Ve(this.options,f),this.manager&&this.manager.touchAction.update(),this},recognizeWith:function(f){if(C(f,"recognizeWith",this))return this;var h=this.simultaneous;return f=Zt(f,this),h[f.id]||(h[f.id]=f,f.recognizeWith(this)),this},dropRecognizeWith:function(f){return C(f,"dropRecognizeWith",this)?this:(f=Zt(f,this),delete this.simultaneous[f.id],this)},requireFailure:function(f){if(C(f,"requireFailure",this))return this;var h=this.requireFail;return f=Zt(f,this),rt(h,f)===-1&&(h.push(f),f.requireFailure(this)),this},dropRequireFailure:function(f){if(C(f,"dropRequireFailure",this))return this;f=Zt(f,this);var h=rt(this.requireFail,f);return h>-1&&this.requireFail.splice(h,1),this},hasRequireFailures:function(){return this.requireFail.length>0},canRecognizeWith:function(f){return!!this.simultaneous[f.id]},emit:function(f){function h(S){p.manager.emit(S,f)}var p=this,m=this.state;H>m&&h(p.options.event+Er(m)),h(p.options.event),f.additionalEvent&&h(f.additionalEvent),m>=H&&h(p.options.event+Er(m))},tryEmit:function(f){return this.canEmit()?this.emit(f):void(this.state=He)},canEmit:function(){for(var f=0;f<this.requireFail.length;){if(!(this.requireFail[f].state&(He|Rt)))return!1;f++}return!0},recognize:function(f){var h=Ve({},f);return se(this.options.enable,[this,h])?(this.state&(st|nr|He)&&(this.state=Rt),this.state=this.process(h),void(this.state&(Ce|zt|H|nr)&&this.tryEmit(h))):(this.reset(),void(this.state=He))},process:function(f){},getTouchAction:function(){},reset:function(){}},q(U,Pe,{defaults:{pointers:1},attrTest:function(f){var h=this.options.pointers;return h===0||f.pointers.length===h},process:function(f){var h=this.state,p=f.eventType,m=h&(Ce|zt),S=this.attrTest(f);return m&&(p&Me||!S)?h|nr:m||S?p&te?h|H:h&Ce?h|zt:Ce:He}}),q(Nt,U,{defaults:{event:"pan",threshold:10,pointers:1,direction:Ir},getTouchAction:function(){var f=this.options.direction,h=[];return f&et&&h.push(Ft),f&Pt&&h.push(F),h},directionTest:function(f){var h=this.options,p=!0,m=f.distance,S=f.direction,P=f.deltaX,B=f.deltaY;return S&h.direction||(h.direction&et?(S=P===0?$t:0>P?mr:Ot,p=P!=this.pX,m=Math.abs(f.deltaX)):(S=B===0?$t:0>B?yr:Et,p=B!=this.pY,m=Math.abs(f.deltaY))),f.direction=S,p&&m>h.threshold&&S&h.direction},attrTest:function(f){return U.prototype.attrTest.call(this,f)&&(this.state&Ce||!(this.state&Ce)&&this.directionTest(f))},emit:function(f){this.pX=f.deltaX,this.pY=f.deltaY;var h=vr(f.direction);h&&(f.additionalEvent=this.options.event+h),this._super.emit.call(this,f)}}),q(li,U,{defaults:{event:"pinch",threshold:0,pointers:2},getTouchAction:function(){return[b]},attrTest:function(f){return this._super.attrTest.call(this,f)&&(Math.abs(f.scale-1)>this.options.threshold||this.state&Ce)},emit:function(f){if(f.scale!==1){var h=f.scale<1?"in":"out";f.additionalEvent=this.options.event+h}this._super.emit.call(this,f)}}),q(Pr,Pe,{defaults:{event:"press",pointers:1,time:251,threshold:9},getTouchAction:function(){return[rr]},process:function(f){var h=this.options,p=f.pointers.length===h.pointers,m=f.distance<h.threshold,S=f.deltaTime>h.time;if(this._input=f,!m||!p||f.eventType&(te|Me)&&!S)this.reset();else if(f.eventType&ae)this.reset(),this._timer=R(function(){this.state=st,this.tryEmit()},h.time,this);else if(f.eventType&te)return st;return He},reset:function(){clearTimeout(this._timer)},emit:function(f){this.state===st&&(f&&f.eventType&te?this.manager.emit(this.options.event+"up",f):(this._input.timeStamp=Ye(),this.manager.emit(this.options.event,this._input)))}}),q(Wr,U,{defaults:{event:"rotate",threshold:0,pointers:2},getTouchAction:function(){return[b]},attrTest:function(f){return this._super.attrTest.call(this,f)&&(Math.abs(f.rotation)>this.options.threshold||this.state&Ce)}}),q(ai,U,{defaults:{event:"swipe",threshold:10,velocity:.3,direction:et|Pt,pointers:1},getTouchAction:function(){return Nt.prototype.getTouchAction.call(this)},attrTest:function(f){var h,p=this.options.direction;return p&(et|Pt)?h=f.overallVelocity:p&et?h=f.overallVelocityX:p&Pt&&(h=f.overallVelocityY),this._super.attrTest.call(this,f)&&p&f.offsetDirection&&f.distance>this.options.threshold&&f.maxPointers==this.options.pointers&&At(h)>this.options.velocity&&f.eventType&te},emit:function(f){var h=vr(f.offsetDirection);h&&this.manager.emit(this.options.event+h,f),this.manager.emit(this.options.event,f)}}),q(Qt,Pe,{defaults:{event:"tap",pointers:1,taps:1,interval:300,time:250,threshold:9,posThreshold:10},getTouchAction:function(){return[xr]},process:function(f){var h=this.options,p=f.pointers.length===h.pointers,m=f.distance<h.threshold,S=f.deltaTime<h.time;if(this.reset(),f.eventType&ae&&this.count===0)return this.failTimeout();if(m&&S&&p){if(f.eventType!=te)return this.failTimeout();var P=this.pTime?f.timeStamp-this.pTime<h.interval:!0,B=!this.pCenter||we(this.pCenter,f.center)<h.posThreshold;this.pTime=f.timeStamp,this.pCenter=f.center,B&&P?this.count+=1:this.count=1,this._input=f;var J=this.count%h.taps;if(J===0)return this.hasRequireFailures()?(this._timer=R(function(){this.state=st,this.tryEmit()},h.interval,this),Ce):st}return He},failTimeout:function(){return this._timer=R(function(){this.state=He},this.options.interval,this),He},reset:function(){clearTimeout(this._timer)},emit:function(){this.state==st&&(this._input.tapCount=this.count,this.manager.emit(this.options.event,this._input))}}),_e.VERSION="2.0.7",_e.defaults={domEvents:!1,touchAction:bt,enable:!0,inputTarget:null,inputClass:null,preset:[[Wr,{enable:!1}],[li,{enable:!1},["rotate"]],[ai,{direction:et}],[Nt,{direction:et},["swipe"]],[Qt],[Qt,{event:"doubletap",taps:2},["tap"]],[Pr]],cssProps:{userSelect:"none",touchSelect:"none",touchCallout:"none",contentZooming:"none",userDrag:"none",tapHighlightColor:"rgba(0,0,0,0)"}};var tt=1,vi=2;Hr.prototype={set:function(f){return Ve(this.options,f),f.touchAction&&this.touchAction.update(),f.inputTarget&&(this.input.destroy(),this.input.target=f.inputTarget,this.input.init()),this},stop:function(f){this.session.stopped=f?vi:tt},recognize:function(f){var h=this.session;if(!h.stopped){this.touchAction.preventDefaults(f);var p,m=this.recognizers,S=h.curRecognizer;(!S||S&&S.state&st)&&(S=h.curRecognizer=null);for(var P=0;P<m.length;)p=m[P],h.stopped===vi||S&&p!=S&&!p.canRecognizeWith(S)?p.reset():p.recognize(f),!S&&p.state&(Ce|zt|H)&&(S=h.curRecognizer=p),P++}},get:function(f){if(f instanceof Pe)return f;for(var h=this.recognizers,p=0;p<h.length;p++)if(h[p].options.event==f)return h[p];return null},add:function(f){if(C(f,"add",this))return this;var h=this.get(f.options.event);return h&&this.remove(h),this.recognizers.push(f),f.manager=this,this.touchAction.update(),f},remove:function(f){if(C(f,"remove",this))return this;if(f=this.get(f)){var h=this.recognizers,p=rt(h,f);p!==-1&&(h.splice(p,1),this.touchAction.update())}return this},on:function(f,h){if(f!==G&&h!==G){var p=this.handlers;return M(ht(f),function(m){p[m]=p[m]||[],p[m].push(h)}),this}},off:function(f,h){if(f!==G){var p=this.handlers;return M(ht(f),function(m){h?p[m]&&p[m].splice(rt(p[m],h),1):delete p[m]}),this}},emit:function(f,h){this.options.domEvents&&ui(f,h);var p=this.handlers[f]&&this.handlers[f].slice();if(p&&p.length){h.type=f,h.preventDefault=function(){h.srcEvent.preventDefault()};for(var m=0;m<p.length;)p[m](h),m++}},destroy:function(){this.element&&qi(this,!1),this.handlers={},this.session={},this.input.destroy(),this.element=null}},Ve(_e,{INPUT_START:ae,INPUT_MOVE:ot,INPUT_END:te,INPUT_CANCEL:Me,STATE_POSSIBLE:Rt,STATE_BEGAN:Ce,STATE_CHANGED:zt,STATE_ENDED:H,STATE_RECOGNIZED:st,STATE_CANCELLED:nr,STATE_FAILED:He,DIRECTION_NONE:$t,DIRECTION_LEFT:mr,DIRECTION_RIGHT:Ot,DIRECTION_UP:yr,DIRECTION_DOWN:Et,DIRECTION_HORIZONTAL:et,DIRECTION_VERTICAL:Pt,DIRECTION_ALL:Ir,Manager:Hr,Input:Oe,TouchAction:jt,TouchInput:Kt,MouseInput:gt,PointerEventInput:mt,TouchMouseInput:ke,SingleTouchInput:yt,Recognizer:Pe,AttrRecognizer:U,Tap:Qt,Pan:Nt,Swipe:ai,Pinch:li,Rotate:Wr,Press:Pr,on:ne,off:Tt,each:M,merge:I,extend:fi,assign:Ve,inherit:q,bindFn:Ue,prefixed:Ar});var Qi=typeof k<"u"?k:typeof self<"u"?self:{};Qi.Hammer=_e,typeof define=="function"&&define.amd?define(function(){return _e}):typeof module<"u"&&module.exports?module.exports=_e:k[Q]=_e})(window,document,"Hammer"),(function(k,j){typeof exports=="object"&&typeof module<"u"?module.exports=j():typeof define=="function"&&define.amd?define(j):(k=k||self,k.CodeMirror=j())})(this,(function(){"use strict";var k=navigator.userAgent,j=navigator.platform,Q=/gecko\/\d/i.test(k),G=/MSIE \d/.test(k),R=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(k),C=/Edge\/(\d+)/.exec(k),M=G||R||C,z=M&&(G?document.documentMode||6:+(C||R)[1]),q=!C&&/WebKit\//.test(k),Ue=q&&/Qt\/\d+\.\d+/.test(k),se=!C&&/Chrome\/(\d+)/.exec(k),Se=se&&+se[1],ne=/Opera\//.test(k),Tt=/Apple Computer/.test(navigator.vendor),Ui=/Mac OS X 1\d\D([8-9]|\d\d)\D/.test(k),Lt=/PhantomJS/.test(k),ht=Tt&&(/Mobile\/\w+/.test(k)||navigator.maxTouchPoints>2),rt=/Android/.test(k),ct=ht||rt||/webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(k),Ae=ht||/Mac/.test(j),Ar=/\bCrOS\b/.test(k),Mn=/win/i.test(j),dt=ne&&k.match(/Version\/(\d*\.\d*)/);dt&&(dt=Number(dt[1])),dt&&dt>=15&&(ne=!1,q=!0);var Oe=Ae&&(Ue||ne&&(dt==null||dt<12.11)),ni=Q||M&&z>=9;function Yt(e){return new RegExp("(^|\\s)"+e+"(?:$|\\s)\\s*")}var kt=function(e,t){var i=e.className,r=Yt(t).exec(i);if(r){var n=i.slice(r.index+r[0].length);e.className=i.slice(0,r.index)+(n?r[1]+n:"")}};function pt(e){for(var t=e.childNodes.length;t>0;--t)e.removeChild(e.firstChild);return e}function Ee(e,t){return pt(e).appendChild(t)}function E(e,t,i,r){var n=document.createElement(e);if(i&&(n.className=i),r&&(n.style.cssText=r),typeof t=="string")n.appendChild(document.createTextNode(t));else if(t)for(var o=0;o<t.length;++o)n.appendChild(t[o]);return n}function Mt(e,t,i,r){var n=E(e,t,i,r);return n.setAttribute("role","presentation"),n}var vt;document.createRange?vt=function(e,t,i,r){var n=document.createRange();return n.setEnd(r||e,i),n.setStart(e,t),n}:vt=function(e,t,i){var r=document.body.createTextRange();try{r.moveToElementText(e.parentNode)}catch{return r}return r.collapse(!0),r.moveEnd("character",i),r.moveStart("character",t),r};function it(e,t){if(t.nodeType==3&&(t=t.parentNode),e.contains)return e.contains(t);do if(t.nodeType==11&&(t=t.host),t==e)return!0;while(t=t.parentNode)}function we(e){var t=e.ownerDocument||e,i;try{i=e.activeElement}catch{i=t.body||null}for(;i&&i.shadowRoot&&i.shadowRoot.activeElement;)i=i.shadowRoot.activeElement;return i}function nt(e,t){var i=e.className;Yt(t).test(i)||(e.className+=(i?" ":"")+t)}function oi(e,t){for(var i=e.split(" "),r=0;r<i.length;r++)i[r]&&!Yt(i[r]).test(t)&&(t+=" "+i[r]);return t}var pr=function(e){e.select()};ht?pr=function(e){e.selectionStart=0,e.selectionEnd=e.value.length}:M&&(pr=function(e){try{e.select()}catch{}});function gt(e){return e.display.wrapper.ownerDocument}function mt(e){return yt(e.display.wrapper)}function yt(e){return e.getRootNode?e.getRootNode():e.ownerDocument}function Or(e){return gt(e).defaultView}function Kt(e){var t=Array.prototype.slice.call(arguments,1);return function(){return e.apply(null,t)}}function Dt(e,t,i){t||(t={});for(var r in e)e.hasOwnProperty(r)&&(i!==!1||!t.hasOwnProperty(r))&&(t[r]=e[r]);return t}function ke(e,t,i,r,n){t==null&&(t=e.search(/[^\s\u00a0]/),t==-1&&(t=e.length));for(var o=r||0,s=n||0;;){var l=e.indexOf(" ",o);if(l<0||l>=t)return s+(t-o);s+=l-o,s+=i-s%i,o=l+1}}var xt=function(){this.id=null,this.f=null,this.time=0,this.handler=Kt(this.onTimeout,this)};xt.prototype.onTimeout=function(e){e.id=0,e.time<=+new Date?e.f():setTimeout(e.handler,e.time-+new Date)},xt.prototype.set=function(e,t){this.f=t;var i=+new Date+e;(!this.id||i<this.time)&&(clearTimeout(this.id),this.id=setTimeout(this.handler,e),this.time=i)};function he(e,t){for(var i=0;i<e.length;++i)if(e[i]==t)return i;return-1}var _i=50,jt={toString:function(){return"CodeMirror.Pass"}},Je={scroll:!1},si={origin:"*mouse"},Pe={origin:"+move"};function Er(e,t,i){for(var r=0,n=0;;){var o=e.indexOf(" ",r);o==-1&&(o=e.length);var s=o-r;if(o==e.length||n+s>=t)return r+Math.min(s,t-n);if(n+=o-r,n+=i-n%i,r=o+1,n>=t)return r}}var vr=[""];function Zt(e){for(;vr.length<=e;)vr.push(U(vr)+" ");return vr[e]}function U(e){return e[e.length-1]}function Nt(e,t){for(var i=[],r=0;r<e.length;r++)i[r]=t(e[r],r);return i}function li(e,t,i){for(var r=0,n=i(t);r<e.length&&i(e[r])<=n;)r++;e.splice(r,0,t)}function Pr(){}function Wr(e,t){var i;return Object.create?i=Object.create(e):(Pr.prototype=e,i=new Pr),t&&Dt(t,i),i}var ai=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;function Qt(e){return/\w/.test(e)||e>"\x80"&&(e.toUpperCase()!=e.toLowerCase()||ai.test(e))}function _e(e,t){return t?t.source.indexOf("\\w")>-1&&Qt(e)?!0:t.test(e):Qt(e)}function Hr(e){for(var t in e)if(e.hasOwnProperty(t)&&e[t])return!1;return!0}var qi=/[\u0300-\u036f\u0483-\u0489\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u065e\u0670\u06d6-\u06dc\u06de-\u06e4\u06e7\u06e8\u06ea-\u06ed\u0711\u0730-\u074a\u07a6-\u07b0\u07eb-\u07f3\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0900-\u0902\u093c\u0941-\u0948\u094d\u0951-\u0955\u0962\u0963\u0981\u09bc\u09be\u09c1-\u09c4\u09cd\u09d7\u09e2\u09e3\u0a01\u0a02\u0a3c\u0a41\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a70\u0a71\u0a75\u0a81\u0a82\u0abc\u0ac1-\u0ac5\u0ac7\u0ac8\u0acd\u0ae2\u0ae3\u0b01\u0b3c\u0b3e\u0b3f\u0b41-\u0b44\u0b4d\u0b56\u0b57\u0b62\u0b63\u0b82\u0bbe\u0bc0\u0bcd\u0bd7\u0c3e-\u0c40\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0cbc\u0cbf\u0cc2\u0cc6\u0ccc\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0d3e\u0d41-\u0d44\u0d4d\u0d57\u0d62\u0d63\u0dca\u0dcf\u0dd2-\u0dd4\u0dd6\u0ddf\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0eb1\u0eb4-\u0eb9\u0ebb\u0ebc\u0ec8-\u0ecd\u0f18\u0f19\u0f35\u0f37\u0f39\u0f71-\u0f7e\u0f80-\u0f84\u0f86\u0f87\u0f90-\u0f97\u0f99-\u0fbc\u0fc6\u102d-\u1030\u1032-\u1037\u1039\u103a\u103d\u103e\u1058\u1059\u105e-\u1060\u1071-\u1074\u1082\u1085\u1086\u108d\u109d\u135f\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b7-\u17bd\u17c6\u17c9-\u17d3\u17dd\u180b-\u180d\u18a9\u1920-\u1922\u1927\u1928\u1932\u1939-\u193b\u1a17\u1a18\u1a56\u1a58-\u1a5e\u1a60\u1a62\u1a65-\u1a6c\u1a73-\u1a7c\u1a7f\u1b00-\u1b03\u1b34\u1b36-\u1b3a\u1b3c\u1b42\u1b6b-\u1b73\u1b80\u1b81\u1ba2-\u1ba5\u1ba8\u1ba9\u1c2c-\u1c33\u1c36\u1c37\u1cd0-\u1cd2\u1cd4-\u1ce0\u1ce2-\u1ce8\u1ced\u1dc0-\u1de6\u1dfd-\u1dff\u200c\u200d\u20d0-\u20f0\u2cef-\u2cf1\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua66f-\ua672\ua67c\ua67d\ua6f0\ua6f1\ua802\ua806\ua80b\ua825\ua826\ua8c4\ua8e0-\ua8f1\ua926-\ua92d\ua947-\ua951\ua980-\ua982\ua9b3\ua9b6-\ua9b9\ua9bc\uaa29-\uaa2e\uaa31\uaa32\uaa35\uaa36\uaa43\uaa4c\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uabe5\uabe8\uabed\udc00-\udfff\ufb1e\ufe00-\ufe0f\ufe20-\ufe26\uff9e\uff9f]/;function ui(e){return e.charCodeAt(0)>=768&&qi.test(e)}function Ve(e,t,i){for(;(i<0?t>0:t<e.length)&&ui(e.charAt(t));)t+=i;return t}function Jt(e,t,i){for(var r=t>i?-1:1;;){if(t==i)return t;var n=(t+i)/2,o=r<0?Math.ceil(n):Math.floor(n);if(o==t)return e(o)?t:i;e(o)?i=o:t=o+r}}function Dn(e,t,i,r){if(!e)return r(t,i,"ltr",0);for(var n=!1,o=0;o<e.length;++o){var s=e[o];(s.from<i&&s.to>t||t==i&&s.to==t)&&(r(Math.max(s.from,t),Math.min(s.to,i),s.level==1?"rtl":"ltr",o),n=!0)}n||r(t,i,"ltr")}var gr=null;function $e(e,t,i){var r;gr=null;for(var n=0;n<e.length;++n){var o=e[n];if(o.from<t&&o.to>t)return n;o.to==t&&(o.from!=o.to&&i=="before"?r=n:gr=n),o.from==t&&(o.from!=o.to&&i!="before"?r=n:gr=n)}return r??gr}var At=(function(){var e="bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN",t="nnnnnnNNr%%r,rNNmmmmmmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmmmnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmnNmmmmmmrrmmNmmmmrr1111111111";function i(u){return u<=247?e.charAt(u):1424<=u&&u<=1524?"R":1536<=u&&u<=1785?t.charAt(u-1536):1774<=u&&u<=2220?"r":8192<=u&&u<=8203?"w":u==8204?"b":"L"}var r=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/,n=/[stwN]/,o=/[LRr]/,s=/[Lb1n]/,l=/[1n]/;function a(u,c,d){this.level=u,this.from=c,this.to=d}return function(u,c){var d=c=="ltr"?"L":"R";if(u.length==0||c=="ltr"&&!r.test(u))return!1;for(var g=u.length,v=[],y=0;y<g;++y)v.push(i(u.charCodeAt(y)));for(var x=0,w=d;x<g;++x){var T=v[x];T=="m"?v[x]=w:w=T}for(var D=0,L=d;D<g;++D){var N=v[D];N=="1"&&L=="r"?v[D]="n":o.test(N)&&(L=N,N=="r"&&(v[D]="R"))}for(var W=1,O=v[0];W<g-1;++W){var _=v[W];_=="+"&&O=="1"&&v[W+1]=="1"?v[W]="1":_==","&&O==v[W+1]&&(O=="1"||O=="n")&&(v[W]=O),O=_}for(var Z=0;Z<g;++Z){var me=v[Z];if(me==",")v[Z]="N";else if(me=="%"){var ee=void 0;for(ee=Z+1;ee<g&&v[ee]=="%";++ee);for(var Xe=Z&&v[Z-1]=="!"||ee<g&&v[ee]=="1"?"1":"N",ze=Z;ze<ee;++ze)v[ze]=Xe;Z=ee-1}}for(var ue=0,Be=d;ue<g;++ue){var be=v[ue];Be=="L"&&be=="1"?v[ue]="L":o.test(be)&&(Be=be)}for(var ce=0;ce<g;++ce)if(n.test(v[ce])){var fe=void 0;for(fe=ce+1;fe<g&&n.test(v[fe]);++fe);for(var ie=(ce?v[ce-1]:d)=="L",Ge=(fe<g?v[fe]:d)=="L",ri=ie==Ge?ie?"L":"R":d,dr=ce;dr<fe;++dr)v[dr]=ri;ce=fe-1}for(var Le=[],Ct,ye=0;ye<g;)if(s.test(v[ye])){var So=ye;for(++ye;ye<g&&s.test(v[ye]);++ye);Le.push(new a(0,So,ye))}else{var Xt=ye,Dr=Le.length,Nr=c=="rtl"?1:0;for(++ye;ye<g&&v[ye]!="L";++ye);for(var Ne=Xt;Ne<ye;)if(l.test(v[Ne])){Xt<Ne&&(Le.splice(Dr,0,new a(1,Xt,Ne)),Dr+=Nr);var ii=Ne;for(++Ne;Ne<ye&&l.test(v[Ne]);++Ne);Le.splice(Dr,0,new a(2,ii,Ne)),Dr+=Nr,Xt=Ne}else++Ne;Xt<ye&&Le.splice(Dr,0,new a(1,Xt,ye))}return c=="ltr"&&(Le[0].level==1&&(Ct=u.match(/^\s+/))&&(Le[0].from=Ct[0].length,Le.unshift(new a(0,0,Ct[0].length))),U(Le).level==1&&(Ct=u.match(/\s+$/))&&(U(Le).to-=Ct[0].length,Le.push(new a(0,g-Ct[0].length,g)))),c=="rtl"?Le.reverse():Le}})();function Ye(e,t){var i=e.order;return i==null&&(i=e.order=At(e.text,t)),i}var fi=[],I=function(e,t,i){if(e.addEventListener)e.addEventListener(t,i,!1);else if(e.attachEvent)e.attachEvent("on"+t,i);else{var r=e._handlers||(e._handlers={});r[t]=(r[t]||fi).concat(i)}};function hi(e,t){return e._handlers&&e._handlers[t]||fi}function We(e,t,i){if(e.removeEventListener)e.removeEventListener(t,i,!1);else if(e.detachEvent)e.detachEvent("on"+t,i);else{var r=e._handlers,n=r&&r[t];if(n){var o=he(n,i);o>-1&&(r[t]=n.slice(0,o).concat(n.slice(o+1)))}}}function $(e,t){var i=hi(e,t);if(i.length)for(var r=Array.prototype.slice.call(arguments,2),n=0;n<i.length;++n)i[n].apply(null,r)}function le(e,t,i){return typeof t=="string"&&(t={type:t,preventDefault:function(){this.defaultPrevented=!0}}),$(e,i||t.type,e,t),ci(t)||t.codemirrorIgnore}function Xi(e){var t=e._handlers&&e._handlers.cursorActivity;if(t)for(var i=e.curOp.cursorActivityHandlers||(e.curOp.cursorActivityHandlers=[]),r=0;r<t.length;++r)he(i,t[r])==-1&&i.push(t[r])}function xe(e,t){return hi(e,t).length>0}function Vt(e){e.prototype.on=function(t,i){I(this,t,i)},e.prototype.off=function(t,i){We(this,t,i)}}function de(e){e.preventDefault?e.preventDefault():e.returnValue=!1}function Yi(e){e.stopPropagation?e.stopPropagation():e.cancelBubble=!0}function ci(e){return e.defaultPrevented!=null?e.defaultPrevented:e.returnValue==!1}function ae(e){de(e),Yi(e)}function ot(e){return e.target||e.srcElement}function te(e){var t=e.which;return t==null&&(e.button&1?t=1:e.button&2?t=3:e.button&4&&(t=2)),Ae&&e.ctrlKey&&t==1&&(t=3),t}var Me=(function(){if(M&&z<9)return!1;var e=E("div");return"draggable"in e||"dragDrop"in e})(),$t;function mr(e){if($t==null){var t=E("span","\u200B");Ee(e,E("span",[t,document.createTextNode("x")])),e.firstChild.offsetHeight!=0&&($t=t.offsetWidth<=1&&t.offsetHeight>2&&!(M&&z<8))}var i=$t?E("span","\u200B"):E("span","\xA0",null,"display: inline-block; width: 1px; margin-right: -1px");return i.setAttribute("cm-text",""),i}var Ot;function yr(e){if(Ot!=null)return Ot;var t=Ee(e,document.createTextNode("A\u062EA")),i=vt(t,0,1).getBoundingClientRect(),r=vt(t,1,2).getBoundingClientRect();return pt(e),!i||i.left==i.right?!1:Ot=r.right-i.right<3}var Et=`
b`.split(/\n/).length!=3?function(e){for(var t=0,i=[],r=e.length;t<=r;){var n=e.indexOf(`
`,t);n==-1&&(n=e.length);var o=e.slice(t,e.charAt(n-1)=="\r"?n-1:n),s=o.indexOf("\r");s!=-1?(i.push(o.slice(0,s)),t+=s+1):(i.push(o),t=n+1)}return i}:function(e){return e.split(/\r\n?|\n/)},et=window.getSelection?function(e){try{return e.selectionStart!=e.selectionEnd}catch{return!1}}:function(e){var t;try{t=e.ownerDocument.selection.createRange()}catch{}return!t||t.parentElement()!=e?!1:t.compareEndPoints("StartToEnd",t)!=0},Pt=(function(){var e=E("div");return"oncopy"in e?!0:(e.setAttribute("oncopy","return;"),typeof e.oncopy=="function")})(),Ir=null;function Ki(e){if(Ir!=null)return Ir;var t=Ee(e,E("span","x")),i=t.getBoundingClientRect(),r=vt(t,0,1).getBoundingClientRect();return Ir=Math.abs(i.left-r.left)>1}var er={},tr={};function Nn(e,t){arguments.length>2&&(t.dependencies=Array.prototype.slice.call(arguments,2)),er[e]=t}function An(e,t){tr[e]=t}function Fr(e){if(typeof e=="string"&&tr.hasOwnProperty(e))e=tr[e];else if(e&&typeof e.name=="string"&&tr.hasOwnProperty(e.name)){var t=tr[e.name];typeof t=="string"&&(t={name:t}),e=Wr(t,e),e.name=t.name}else{if(typeof e=="string"&&/^[\w\-]+\/[\w\-]+\+xml$/.test(e))return Fr("application/xml");if(typeof e=="string"&&/^[\w\-]+\/[\w\-]+\+json$/.test(e))return Fr("application/json")}return typeof e=="string"?{name:e}:e||{name:"null"}}function di(e,t){t=Fr(t);var i=er[t.name];if(!i)return di(e,"text/plain");var r=i(e,t);if(Wt.hasOwnProperty(t.name)){var n=Wt[t.name];for(var o in n)n.hasOwnProperty(o)&&(r.hasOwnProperty(o)&&(r["_"+o]=r[o]),r[o]=n[o])}if(r.name=t.name,t.helperType&&(r.helperType=t.helperType),t.modeProps)for(var s in t.modeProps)r[s]=t.modeProps[s];return r}var Wt={};function ji(e,t){var i=Wt.hasOwnProperty(e)?Wt[e]:Wt[e]={};Dt(t,i)}function Ht(e,t){if(t===!0)return t;if(e.copyState)return e.copyState(t);var i={};for(var r in t){var n=t[r];n instanceof Array&&(n=n.concat([])),i[r]=n}return i}function pi(e,t){for(var i;e.innerMode&&(i=e.innerMode(t),!(!i||i.mode==e));)t=i.state,e=i.mode;return i||{mode:e,state:t}}function Zi(e,t,i){return e.startState?e.startState(t,i):!0}var re=function(e,t,i){this.pos=this.start=0,this.string=e,this.tabSize=t||8,this.lastColumnPos=this.lastColumnValue=0,this.lineStart=0,this.lineOracle=i};re.prototype.eol=function(){return this.pos>=this.string.length},re.prototype.sol=function(){return this.pos==this.lineStart},re.prototype.peek=function(){return this.string.charAt(this.pos)||void 0},re.prototype.next=function(){if(this.pos<this.string.length)return this.string.charAt(this.pos++)},re.prototype.eat=function(e){var t=this.string.charAt(this.pos),i;if(typeof e=="string"?i=t==e:i=t&&(e.test?e.test(t):e(t)),i)return++this.pos,t},re.prototype.eatWhile=function(e){for(var t=this.pos;this.eat(e););return this.pos>t},re.prototype.eatSpace=function(){for(var e=this.pos;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>e},re.prototype.skipToEnd=function(){this.pos=this.string.length},re.prototype.skipTo=function(e){var t=this.string.indexOf(e,this.pos);if(t>-1)return this.pos=t,!0},re.prototype.backUp=function(e){this.pos-=e},re.prototype.column=function(){return this.lastColumnPos<this.start&&(this.lastColumnValue=ke(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue),this.lastColumnPos=this.start),this.lastColumnValue-(this.lineStart?ke(this.string,this.lineStart,this.tabSize):0)},re.prototype.indentation=function(){return ke(this.string,null,this.tabSize)-(this.lineStart?ke(this.string,this.lineStart,this.tabSize):0)},re.prototype.match=function(e,t,i){if(typeof e=="string"){var r=function(s){return i?s.toLowerCase():s},n=this.string.substr(this.pos,e.length);if(r(n)==r(e))return t!==!1&&(this.pos+=e.length),!0}else{var o=this.string.slice(this.pos).match(e);return o&&o.index>0?null:(o&&t!==!1&&(this.pos+=o[0].length),o)}},re.prototype.current=function(){return this.string.slice(this.start,this.pos)},re.prototype.hideFirstChars=function(e,t){this.lineStart+=e;try{return t()}finally{this.lineStart-=e}},re.prototype.lookAhead=function(e){var t=this.lineOracle;return t&&t.lookAhead(e)},re.prototype.baseToken=function(){var e=this.lineOracle;return e&&e.baseToken(this.pos)};function A(e,t){if(t-=e.first,t<0||t>=e.size)throw new Error("There is no line "+(t+e.first)+" in the document.");for(var i=e;!i.lines;)for(var r=0;;++r){var n=i.children[r],o=n.chunkSize();if(t<o){i=n;break}t-=o}return i.lines[t]}function It(e,t,i){var r=[],n=t.line;return e.iter(t.line,i.line+1,function(o){var s=o.text;n==i.line&&(s=s.slice(0,i.ch)),n==t.line&&(s=s.slice(t.ch)),r.push(s),++n}),r}function Rr(e,t,i){var r=[];return e.iter(t,i,function(n){r.push(n.text)}),r}function Ke(e,t){var i=t-e.height;if(i)for(var r=e;r;r=r.parent)r.height+=i}function X(e){if(e.parent==null)return null;for(var t=e.parent,i=he(t.lines,e),r=t.parent;r;t=r,r=r.parent)for(var n=0;r.children[n]!=t;++n)i+=r.children[n].chunkSize();return i+t.first}function bt(e,t){var i=e.first;e:do{for(var r=0;r<e.children.length;++r){var n=e.children[r],o=n.height;if(t<o){e=n;continue e}t-=o,i+=n.chunkSize()}return i}while(!e.lines);for(var s=0;s<e.lines.length;++s){var l=e.lines[s],a=l.height;if(t<a)break;t-=a}return i+s}function rr(e,t){return t>=e.first&&t<e.first+e.size}function xr(e,t){return String(e.lineNumberFormatter(t+e.firstLineNumber))}function b(e,t,i){if(i===void 0&&(i=null),!(this instanceof b))return new b(e,t,i);this.line=e,this.ch=t,this.sticky=i}function F(e,t){return e.line-t.line||e.ch-t.ch}function Ft(e,t){return e.sticky==t.sticky&&F(e,t)==0}function ir(e){return b(e.line,e.ch)}function Rt(e,t){return F(e,t)<0?t:e}function Ce(e,t){return F(e,t)<0?e:t}function zt(e,t){return Math.max(e.first,Math.min(t,e.first+e.size-1))}function H(e,t){if(t.line<e.first)return b(e.first,0);var i=e.first+e.size-1;return t.line>i?b(i,A(e,i).text.length):st(t,A(e,t.line).text.length)}function st(e,t){var i=e.ch;return i==null||i>t?b(e.line,t):i<0?b(e.line,0):e}function nr(e,t){for(var i=[],r=0;r<t.length;r++)i[r]=H(e,t[r]);return i}var He=function(e,t){this.state=e,this.lookAhead=t},tt=function(e,t,i,r){this.state=t,this.doc=e,this.line=i,this.maxLookAhead=r||0,this.baseTokens=null,this.baseTokenPos=1};tt.prototype.lookAhead=function(e){var t=this.doc.getLine(this.line+e);return t!=null&&e>this.maxLookAhead&&(this.maxLookAhead=e),t},tt.prototype.baseToken=function(e){if(!this.baseTokens)return null;for(;this.baseTokens[this.baseTokenPos]<=e;)this.baseTokenPos+=2;var t=this.baseTokens[this.baseTokenPos+1];return{type:t&&t.replace(/( |^)overlay .*/,""),size:this.baseTokens[this.baseTokenPos]-e}},tt.prototype.nextLine=function(){this.line++,this.maxLookAhead>0&&this.maxLookAhead--},tt.fromSaved=function(e,t,i){return t instanceof He?new tt(e,Ht(e.mode,t.state),i,t.lookAhead):new tt(e,Ht(e.mode,t),i)},tt.prototype.save=function(e){var t=e!==!1?Ht(this.doc.mode,this.state):this.state;return this.maxLookAhead>0?new He(t,this.maxLookAhead):t};function vi(e,t,i,r){var n=[e.state.modeGen],o={};J(e,t.text,e.doc.mode,i,function(u,c){return n.push(u,c)},o,r);for(var s=i.state,l=function(u){i.baseTokens=n;var c=e.state.overlays[u],d=1,g=0;i.state=!0,J(e,t.text,c.mode,i,function(v,y){for(var x=d;g<v;){var w=n[d];w>v&&n.splice(d,1,v,n[d+1],w),d+=2,g=Math.min(v,w)}if(y)if(c.opaque)n.splice(x,d-x,v,"overlay "+y),d=x+2;else for(;x<d;x+=2){var T=n[x+1];n[x+1]=(T?T+" ":"")+"overlay "+y}},o),i.state=s,i.baseTokens=null,i.baseTokenPos=1},a=0;a<e.state.overlays.length;++a)l(a);return{styles:n,classes:o.bgClass||o.textClass?o:null}}function Qi(e,t,i){if(!t.styles||t.styles[0]!=e.state.modeGen){var r=f(e,X(t)),n=t.text.length>e.options.maxHighlightLength&&Ht(e.doc.mode,r.state),o=vi(e,t,r);n&&(r.state=n),t.stateAfter=r.save(!n),t.styles=o.styles,o.classes?t.styleClasses=o.classes:t.styleClasses&&(t.styleClasses=null),i===e.doc.highlightFrontier&&(e.doc.modeFrontier=Math.max(e.doc.modeFrontier,++e.doc.highlightFrontier))}return t.styles}function f(e,t,i){var r=e.doc,n=e.display;if(!r.mode.startState)return new tt(r,!0,t);var o=je(e,t,i),s=o>r.first&&A(r,o-1).stateAfter,l=s?tt.fromSaved(r,s,o):new tt(r,Zi(r.mode),o);return r.iter(o,t,function(a){h(e,a.text,l);var u=l.line;a.stateAfter=u==t-1||u%5==0||u>=n.viewFrom&&u<n.viewTo?l.save():null,l.nextLine()}),i&&(r.modeFrontier=l.line),l}function h(e,t,i,r){var n=e.doc.mode,o=new re(t,e.options.tabSize,i);for(o.start=o.pos=r||0,t==""&&p(n,i.state);!o.eol();)m(n,o,i.state),o.start=o.pos}function p(e,t){if(e.blankLine)return e.blankLine(t);if(e.innerMode){var i=pi(e,t);if(i.mode.blankLine)return i.mode.blankLine(i.state)}}function m(e,t,i,r){for(var n=0;n<10;n++){r&&(r[0]=pi(e,i).mode);var o=e.token(t,i);if(t.pos>t.start)return o}throw new Error("Mode "+e.name+" failed to advance stream.")}var S=function(e,t,i){this.start=e.start,this.end=e.pos,this.string=e.current(),this.type=t||null,this.state=i};function P(e,t,i,r){var n=e.doc,o=n.mode,s;t=H(n,t);var l=A(n,t.line),a=f(e,t.line,i),u=new re(l.text,e.options.tabSize,a),c;for(r&&(c=[]);(r||u.pos<t.ch)&&!u.eol();)u.start=u.pos,s=m(o,u,a.state),r&&c.push(new S(u,s,Ht(n.mode,a.state)));return r?c:new S(u,s,a.state)}function B(e,t){if(e)for(;;){var i=e.match(/(?:^|\s+)line-(background-)?(\S+)/);if(!i)break;e=e.slice(0,i.index)+e.slice(i.index+i[0].length);var r=i[1]?"bgClass":"textClass";t[r]==null?t[r]=i[2]:new RegExp("(?:^|\\s)"+i[2]+"(?:$|\\s)").test(t[r])||(t[r]+=" "+i[2])}return e}function J(e,t,i,r,n,o,s){var l=i.flattenSpans;l==null&&(l=e.options.flattenSpans);var a=0,u=null,c=new re(t,e.options.tabSize,r),d,g=e.options.addModeClass&&[null];for(t==""&&B(p(i,r.state),o);!c.eol();){if(c.pos>e.options.maxHighlightLength?(l=!1,s&&h(e,t,r,c.pos),c.pos=t.length,d=null):d=B(m(i,c,r.state,g),o),g){var v=g[0].name;v&&(d="m-"+(d?v+" "+d:v))}if(!l||u!=d){for(;a<c.start;)a=Math.min(c.start,a+5e3),n(a,u);u=d}c.start=c.pos}for(;a<c.pos;){var y=Math.min(c.pos,a+5e3);n(y,u),a=y}}function je(e,t,i){for(var r,n,o=e.doc,s=i?-1:t-(e.doc.mode.innerMode?1e3:100),l=t;l>s;--l){if(l<=o.first)return o.first;var a=A(o,l-1),u=a.stateAfter;if(u&&(!i||l+(u instanceof He?u.lookAhead:0)<=o.modeFrontier))return l;var c=ke(a.text,null,e.options.tabSize);(n==null||r>c)&&(n=l-1,r=c)}return n}function Ie(e,t){if(e.modeFrontier=Math.min(e.modeFrontier,t),!(e.highlightFrontier<t-10)){for(var i=e.first,r=t-1;r>i;r--){var n=A(e,r).stateAfter;if(n&&(!(n instanceof He)||r+n.lookAhead<t)){i=r+1;break}}e.highlightFrontier=Math.min(e.highlightFrontier,i)}}var Ze=!1,Bt=!1;function cl(){Ze=!0}function dl(){Bt=!0}function Ji(e,t,i){this.marker=e,this.from=t,this.to=i}function gi(e,t){if(e)for(var i=0;i<e.length;++i){var r=e[i];if(r.marker==t)return r}}function pl(e,t){for(var i,r=0;r<e.length;++r)e[r]!=t&&(i||(i=[])).push(e[r]);return i}function vl(e,t,i){var r=i&&window.WeakSet&&(i.markedSpans||(i.markedSpans=new WeakSet));r&&e.markedSpans&&r.has(e.markedSpans)?e.markedSpans.push(t):(e.markedSpans=e.markedSpans?e.markedSpans.concat([t]):[t],r&&r.add(e.markedSpans)),t.marker.attachLine(e)}function gl(e,t,i){var r;if(e)for(var n=0;n<e.length;++n){var o=e[n],s=o.marker,l=o.from==null||(s.inclusiveLeft?o.from<=t:o.from<t);if(l||o.from==t&&s.type=="bookmark"&&(!i||!o.marker.insertLeft)){var a=o.to==null||(s.inclusiveRight?o.to>=t:o.to>t);(r||(r=[])).push(new Ji(s,o.from,a?null:o.to))}}return r}function ml(e,t,i){var r;if(e)for(var n=0;n<e.length;++n){var o=e[n],s=o.marker,l=o.to==null||(s.inclusiveRight?o.to>=t:o.to>t);if(l||o.from==t&&s.type=="bookmark"&&(!i||o.marker.insertLeft)){var a=o.from==null||(s.inclusiveLeft?o.from<=t:o.from<t);(r||(r=[])).push(new Ji(s,a?null:o.from-t,o.to==null?null:o.to-t))}}return r}function On(e,t){if(t.full)return null;var i=rr(e,t.from.line)&&A(e,t.from.line).markedSpans,r=rr(e,t.to.line)&&A(e,t.to.line).markedSpans;if(!i&&!r)return null;var n=t.from.ch,o=t.to.ch,s=F(t.from,t.to)==0,l=gl(i,n,s),a=ml(r,o,s),u=t.text.length==1,c=U(t.text).length+(u?n:0);if(l)for(var d=0;d<l.length;++d){var g=l[d];if(g.to==null){var v=gi(a,g.marker);v?u&&(g.to=v.to==null?null:v.to+c):g.to=n}}if(a)for(var y=0;y<a.length;++y){var x=a[y];if(x.to!=null&&(x.to+=c),x.from==null){var w=gi(l,x.marker);w||(x.from=c,u&&(l||(l=[])).push(x))}else x.from+=c,u&&(l||(l=[])).push(x)}l&&(l=Co(l)),a&&a!=l&&(a=Co(a));var T=[l];if(!u){var D=t.text.length-2,L;if(D>0&&l)for(var N=0;N<l.length;++N)l[N].to==null&&(L||(L=[])).push(new Ji(l[N].marker,null,null));for(var W=0;W<D;++W)T.push(L);T.push(a)}return T}function Co(e){for(var t=0;t<e.length;++t){var i=e[t];i.from!=null&&i.from==i.to&&i.marker.clearWhenEmpty!==!1&&e.splice(t--,1)}return e.length?e:null}function yl(e,t,i){var r=null;if(e.iter(t.line,i.line+1,function(v){if(v.markedSpans)for(var y=0;y<v.markedSpans.length;++y){var x=v.markedSpans[y].marker;x.readOnly&&(!r||he(r,x)==-1)&&(r||(r=[])).push(x)}}),!r)return null;for(var n=[{from:t,to:i}],o=0;o<r.length;++o)for(var s=r[o],l=s.find(0),a=0;a<n.length;++a){var u=n[a];if(!(F(u.to,l.from)<0||F(u.from,l.to)>0)){var c=[a,1],d=F(u.from,l.from),g=F(u.to,l.to);(d<0||!s.inclusiveLeft&&!d)&&c.push({from:u.from,to:l.from}),(g>0||!s.inclusiveRight&&!g)&&c.push({from:l.to,to:u.to}),n.splice.apply(n,c),a+=c.length-3}}return n}function To(e){var t=e.markedSpans;if(t){for(var i=0;i<t.length;++i)t[i].marker.detachLine(e);e.markedSpans=null}}function Lo(e,t){if(t){for(var i=0;i<t.length;++i)t[i].marker.attachLine(e);e.markedSpans=t}}function Vi(e){return e.inclusiveLeft?-1:0}function $i(e){return e.inclusiveRight?1:0}function En(e,t){var i=e.lines.length-t.lines.length;if(i!=0)return i;var r=e.find(),n=t.find(),o=F(r.from,n.from)||Vi(e)-Vi(t);if(o)return-o;var s=F(r.to,n.to)||$i(e)-$i(t);return s||t.id-e.id}function ko(e,t){var i=Bt&&e.markedSpans,r;if(i)for(var n=void 0,o=0;o<i.length;++o)n=i[o],n.marker.collapsed&&(t?n.from:n.to)==null&&(!r||En(r,n.marker)<0)&&(r=n.marker);return r}function Mo(e){return ko(e,!0)}function en(e){return ko(e,!1)}function xl(e,t){var i=Bt&&e.markedSpans,r;if(i)for(var n=0;n<i.length;++n){var o=i[n];o.marker.collapsed&&(o.from==null||o.from<t)&&(o.to==null||o.to>t)&&(!r||En(r,o.marker)<0)&&(r=o.marker)}return r}function Do(e,t,i,r,n){var o=A(e,t),s=Bt&&o.markedSpans;if(s)for(var l=0;l<s.length;++l){var a=s[l];if(a.marker.collapsed){var u=a.marker.find(0),c=F(u.from,i)||Vi(a.marker)-Vi(n),d=F(u.to,r)||$i(a.marker)-$i(n);if(!(c>=0&&d<=0||c<=0&&d>=0)&&(c<=0&&(a.marker.inclusiveRight&&n.inclusiveLeft?F(u.to,i)>=0:F(u.to,i)>0)||c>=0&&(a.marker.inclusiveRight&&n.inclusiveLeft?F(u.from,r)<=0:F(u.from,r)<0)))return!0}}}function lt(e){for(var t;t=Mo(e);)e=t.find(-1,!0).line;return e}function bl(e){for(var t;t=en(e);)e=t.find(1,!0).line;return e}function Sl(e){for(var t,i;t=en(e);)e=t.find(1,!0).line,(i||(i=[])).push(e);return i}function Pn(e,t){var i=A(e,t),r=lt(i);return i==r?t:X(r)}function No(e,t){if(t>e.lastLine())return t;var i=A(e,t),r;if(!or(e,i))return t;for(;r=en(i);)i=r.find(1,!0).line;return X(i)+1}function or(e,t){var i=Bt&&t.markedSpans;if(i){for(var r=void 0,n=0;n<i.length;++n)if(r=i[n],!!r.marker.collapsed){if(r.from==null)return!0;if(!r.marker.widgetNode&&r.from==0&&r.marker.inclusiveLeft&&Wn(e,t,r))return!0}}}function Wn(e,t,i){if(i.to==null){var r=i.marker.find(1,!0);return Wn(e,r.line,gi(r.line.markedSpans,i.marker))}if(i.marker.inclusiveRight&&i.to==t.text.length)return!0;for(var n=void 0,o=0;o<t.markedSpans.length;++o)if(n=t.markedSpans[o],n.marker.collapsed&&!n.marker.widgetNode&&n.from==i.to&&(n.to==null||n.to!=i.from)&&(n.marker.inclusiveLeft||i.marker.inclusiveRight)&&Wn(e,t,n))return!0}function Gt(e){e=lt(e);for(var t=0,i=e.parent,r=0;r<i.lines.length;++r){var n=i.lines[r];if(n==e)break;t+=n.height}for(var o=i.parent;o;i=o,o=i.parent)for(var s=0;s<o.children.length;++s){var l=o.children[s];if(l==i)break;t+=l.height}return t}function tn(e){if(e.height==0)return 0;for(var t=e.text.length,i,r=e;i=Mo(r);){var n=i.find(0,!0);r=n.from.line,t+=n.from.ch-n.to.ch}for(r=e;i=en(r);){var o=i.find(0,!0);t-=r.text.length-o.from.ch,r=o.to.line,t+=r.text.length-o.to.ch}return t}function Hn(e){var t=e.display,i=e.doc;t.maxLine=A(i,i.first),t.maxLineLength=tn(t.maxLine),t.maxLineChanged=!0,i.iter(function(r){var n=tn(r);n>t.maxLineLength&&(t.maxLineLength=n,t.maxLine=r)})}var zr=function(e,t,i){this.text=e,Lo(this,t),this.height=i?i(this):1};zr.prototype.lineNo=function(){return X(this)},Vt(zr);function wl(e,t,i,r){e.text=t,e.stateAfter&&(e.stateAfter=null),e.styles&&(e.styles=null),e.order!=null&&(e.order=null),To(e),Lo(e,i);var n=r?r(e):1;n!=e.height&&Ke(e,n)}function Cl(e){e.parent=null,To(e)}var Tl={},Ll={};function Ao(e,t){if(!e||/^\s*$/.test(e))return null;var i=t.addModeClass?Ll:Tl;return i[e]||(i[e]=e.replace(/\S+/g,"cm-$&"))}function Oo(e,t){var i=Mt("span",null,null,q?"padding-right: .1px":null),r={pre:Mt("pre",[i],"CodeMirror-line"),content:i,col:0,pos:0,cm:e,trailingSpace:!1,splitSpaces:e.getOption("lineWrapping")};t.measure={};for(var n=0;n<=(t.rest?t.rest.length:0);n++){var o=n?t.rest[n-1]:t.line,s=void 0;r.pos=0,r.addToken=Ml,yr(e.display.measure)&&(s=Ye(o,e.doc.direction))&&(r.addToken=Nl(r.addToken,s)),r.map=[];var l=t!=e.