You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

3 lines
72 KiB

3 years ago
var Gitment=function(a){function c(d){if(b[d])return b[d].exports;var e=b[d]={i:d,l:!1,exports:{}};return a[d].call(e.exports,e,e.exports,c),e.l=!0,e.exports}var b={};return c.m=a,c.c=b,c.i=function(a){return a},c.d=function(a,b,d){c.o(a,b)||Object.defineProperty(a,b,{configurable:!1,enumerable:!0,get:d})},c.n=function(a){var b=a&&a.__esModule?function(){return a["default"]}:function(){return a};return c.d(b,"a",b),b},c.o=function(a,b){return Object.prototype.hasOwnProperty.call(a,b)},c.p="",c(c.s=5)}([function(a,b){"use strict";Object.defineProperty(b,"__esModule",{value:!0}),b.LS_ACCESS_TOKEN_KEY="gitment-comments-token",b.LS_USER_KEY="gitment-user-info",b.NOT_INITIALIZED_ERROR=new Error("Comments Not Initialized")},function(a,b,c){"use strict";!function(c){function i(a){return function(b,c,d){return d&&"function"==typeof d.value?(d.value=_(a,d.value),d.enumerable=!1,d.configurable=!0,d):f(a).apply(this,arguments)}}function j(a,b,c){var d="string"==typeof a?a:a.name||"<unnamed action>",e="function"==typeof a?a:b,f="function"==typeof a?b:c;return vd("function"==typeof e,qd("m002")),vd(0===e.length,qd("m003")),vd("string"==typeof d&&d.length>0,"actions should have valid names, got: '"+d+"'"),ab(d,e,f,void 0)}function k(a){return"function"==typeof a&&a.isMobxAction===!0}function l(a,b,c){var d=function(){return ab(b,c,a,arguments)};d.isMobxAction=!0,Jd(a,b,d)}function m(a,b,c){function h(){e(g)}var d,e,f,g;return"string"==typeof a?(d=a,e=b,f=c):(d=a.name||"Autorun@"+td(),e=a,f=b),vd("function"==typeof e,qd("m004")),vd(k(e)===!1,qd("m005")),f&&(e=e.bind(f)),g=new Ub(d,function(){this.track(h)}),g.schedule(),g.getDisposer()}function n(a,b,c,d){var e,f,g,h,i;return"string"==typeof a?(e=a,f=b,g=c,h=d):(e="When@"+td(),f=a,g=b,h=c),i=m(e,function(a){if(f.call(h)){a.dispose();var b=xb();g.call(h),yb(b)}})}function o(a,b,c,d){function l(){f(j)}var e,f,g,h,i,j;return"string"==typeof a?(e=a,f=b,g=c,h=d):(e=a.name||"AutorunAsync@"+td(),f=a,g=b,h=c),vd(k(f)===!1,qd("m006")),void 0===g&&(g=1),h&&(f=f.bind(h)),i=!1,j=new Ub(e,function(){i||(i=!0,setTimeout(function(){i=!1,j.isDisposed||j.track(l)},g))}),j.schedule(),j.getDisposer()}function p(a,b,c){function k(){if(!j.isDisposed){var c=!1;j.track(function(){var b=a(j);c=Fd(e.compareStructural,i,b),i=b}),f&&e.fireImmediately&&b(i,j),f||c!==!0||b(i,j),f&&(f=!1)}}var e,f,g,i,j;return arguments.length>3&&ud(qd("m007")),rc(a)&&ud(qd("m008")),e="object"===("undefined"==typeof c?"undefined":d(c))?c:{},e.name=e.name||a.name||b.name||"Reaction@"+td(),e.fireImmediately=c===!0||e.fireImmediately===!0,e.delay=e.delay||0,e.compareStructural=e.compareStructural||e.struct||!1,b=h(e.name,e.context?b.bind(e.context):b),e.context&&(a=a.bind(e.context)),f=!0,g=!1,j=new Ub(e.name,function(){f||e.delay<1?k():g||(g=!0,setTimeout(function(){g=!1,k()},e.delay))}),j.schedule(),j.getDisposer()}function q(a){return hd(function(b,c,d,e,f){vd("undefined"!=typeof f,qd("m009")),vd("function"==typeof f.get,qd("m010"));var g=Qc(b,"");Tc(g,c,f.get,f.set,a,!1)},function(a){var b=this.$mobx.values[a];return void 0===b?void 0:b.get()},function(a,b){this.$mobx.values[a].set(b)},!1,!1)}function u(a,b){var c,d,f;return vd("function"==typeof a&&a.length<2,"createTransformer expects a function that accepts one argument"),c={},d=Cb.resetId,f=function(d){function f(b,c){var e=d.call(this,function(){return a(c)},void 0,!1,"Transformer-"+a.name+"-"+b,void 0)||this;return e.sourceIdentifier=b,e.sourceObject=c,e}return e(f,d),f.prototype.onBecomeUnobserved=function(){var a=this.value;d.prototype.onBecomeUnobserved.call(this),delete c[this.sourceIdentifier],b&&b(a,this.sourceObject)},f}(lb),function(a){var b,e;return d!==Cb.resetId&&(c={},d=Cb.resetId),b=v(a),(e=c[b])?e.get():(e=c[b]=new f(b,a),e.get())}}function v(a){if(null===a||"object"!==("undefined"==typeof a?"undefined":d(a)))throw new Error("[mobx] transform expected some kind of object, got: "+a);var b=a.$transformId;return void 0===b&&(b=td(),Jd(a,"$transformId",b)),b}function w(a,b){return rb()||console.warn(qd("m013")),t(a,{context:b}).get()}function x(a){var c,b=[];for(c
},a}(),lb.prototype[Td()]=lb.prototype.valueOf,mb=Pd("ComputedValue",lb),function(a){a[a["NOT_TRACKING"]=-1]="NOT_TRACKING",a[a["UP_TO_DATE"]=0]="UP_TO_DATE",a[a["POSSIBLY_STALE"]=1]="POSSIBLY_STALE",a[a["STALE"]=2]="STALE"}(nb||(nb={})),b.IDerivationState=nb,ob=function(){function a(a){this.cause=a}return a}(),b.untracked=wb,Ab=["mobxGuid","resetId","spyListeners","strictMode","runId"],Bb=function(){function a(){this.version=5,this.trackingDerivation=null,this.computationDepth=0,this.runId=0,this.mobxGuid=0,this.inBatch=0,this.pendingUnobservations=[],this.pendingReactions=[],this.isRunningReactions=!1,this.allowStateChanges=!0,this.strictMode=!1,this.resetId=0,this.spyListeners=[],this.globalReactionErrorHandlers=[]}return a}(),Cb=new Bb,Ub=function(){function a(a,b){void 0===a&&(a="Reaction@"+td()),this.name=a,this.onInvalidate=b,this.observing=[],this.newObserving=[],this.dependenciesState=nb.NOT_TRACKING,this.diffValue=0,this.runId=0,this.unboundDepsCount=0,this.__mapid="#"+td(),this.isDisposed=!1,this._isScheduled=!1,this._isTrackPending=!1,this._isRunning=!1}return a.prototype.onBecomeStale=function(){this.schedule()},a.prototype.schedule=function(){this._isScheduled||(this._isScheduled=!0,Cb.pendingReactions.push(this),Zb())},a.prototype.isScheduled=function(){return this._isScheduled},a.prototype.runReaction=function(){this.isDisposed||(Nb(),this._isScheduled=!1,qb(this)&&(this._isTrackPending=!0,this.onInvalidate(),this._isTrackPending&&bc()&&cc({object:this,type:"scheduled-reaction"})),Ob())},a.prototype.track=function(a){var b,c,d;Nb(),b=bc(),b&&(c=Date.now(),dc({object:this,type:"reaction",fn:a})),this._isRunning=!0,d=tb(this,a,void 0),this._isRunning=!1,this._isTrackPending=!1,this.isDisposed&&vb(this),pb(d)&&this.reportExceptionInDerivation(d.cause),b&&fc({time:Date.now()-c}),Ob()},a.prototype.reportExceptionInDerivation=function(a){var c,d,b=this;return this.errorHandler?(this.errorHandler(a,this),void 0):(c="[mobx] Encountered an uncaught exception that was thrown by a reaction or observer component, in: '"+this,d=qd("m037"),console.error(c||d,a),bc()&&cc({type:"error",message:c,error:a,object:this}),Cb.globalReactionErrorHandlers.forEach(function(c){return c(a,b)}),void 0)},a.prototype.dispose=function(){this.isDisposed||(this.isDisposed=!0,this._isRunning||(Nb(),vb(this),Ob()))},a.prototype.getDisposer=function(){var a=this.dispose.bind(this);return a.$mobx=this,a.onError=Vb,a},a.prototype.toString=function(){return"Reaction["+this.name+"]"},a.prototype.whyRun=function(){var a=Ad(this._isRunning?this.newObserving:this.observing).map(function(a){return a.name});return"\nWhyRun? reaction '"+this.name+"':\n * Status: ["+(this.isDisposed?"stopped":this._isRunning?"running":this.isScheduled()?"scheduled":"idle")+"]\n * This reaction will re-run if any of the following observables changes:\n "+Bd(a)+"\n "+(this._isRunning?" (... or any observable accessed during the remainder of the current run)":"")+"\n "+qd("m038")+"\n"},a}(),b.Reaction=Ub,Xb=100,Yb=function(a){return a()},_b=Pd("Reaction",Ub),ec={spyReportEnd:!0},b.spy=gc,b.asReference=nc,b.asStructure=oc,b.asFlat=pc,b.asMap=qc,b.isModifierDescriptor=rc,yc=1e4,zc=function(){var a=!1,b={};return Object.defineProperty(b,"0",{set:function(){a=!0}}),Object.create(b)["0"]=1,a===!1}(),Ac=0,Bc=function(){function a(){}return a}(),Bc.prototype=[],Cc=function(){function a(a,b,c,d){this.array=c,this.owned=d,this.lastKnownLength=0,this.interceptors=null,this.changeListeners=null,this.atom=new ib(a||"ObservableArray@"+td()),this.enhancer=function(c,d){return b(c,d,a+"[..]")}}return a.prototype.intercept=function(a){return ic(this,a)},a.prototype.observe=function(a,b){return void 0===b&&(b=!1),b&&a({object:this.array,type:"splice",index:0,added:this.values.slice(),addedCount:this.values.length,removed:[],removedCount:0}),lc(this,a)},a.prototype.getArrayLength=function(){return this.atom.reportObserved(),this.values.length},a.prototype.setArrayLength=function(a){var b,c,d;if("number"!=typeof a||0>a)throw new Error("[mobx.array] Out of range: "+a);if(b=this.value
},function(a){"use strict";var d="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},e=function(){return this}();try{e=e||Function("return this")()||(1,eval)("this")}catch(f){"object"===("undefined"==typeof window?"undefined":d(window))&&(e=window)}a.exports=e},function(a,b,c){"use strict";function j(a){return a&&a.__esModule?a:{"default":a}}function k(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function m(a,b){a[b]=function(c){var d=g.getTargetContainer(c),f=a.theme[b]||a.defaultTheme[b];return e.autorun(function(){var b=f(a.state,a);d.firstChild?d.replaceChild(b,d.firstChild):d.appendChild(b)}),d}}var d=function(){function a(a,b){var c,d;for(c=0;c<b.length;c++)d=b[c],d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(a,d.key,d)}return function(b,c,d){return c&&a(b.prototype,c),d&&a(b,d),b}}(),e=c(1),f=c(0),g=c(3),h=c(2),i=j(h),l="public_repo",n=function(){function a(){var d,h,l,m,n,o,p,q,r,b=this,c=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};k(this,a),this.defaultTheme=i.default,this.useTheme(i.default),Object.assign(this,{id:window.location.href,title:window.document.title,link:window.location.href,desc:"",labels:[],theme:i.default,oauth:{},perPage:20,maxCommentHeight:250},c),this.useTheme(this.theme),d={};try{h=localStorage.getItem(f.LS_USER_KEY),this.accessToken&&h&&Object.assign(d,JSON.parse(h),{fromCache:!0})}catch(j){localStorage.removeItem(f.LS_USER_KEY)}this.state=e.observable({user:d,error:null,meta:{},comments:void 0,reactions:[],commentReactions:{},currentPage:1}),l=g.Query.parse(),l.code?(m=this.oauth,n=m.client_id,o=m.client_secret,p=l.code,delete l.code,q=g.Query.stringify(l),r=""+window.location.origin+window.location.pathname+q+window.location.hash,history.replaceState({},"",r),Object.assign(this,{id:r,link:r},c),this.state.user.isLoggingIn=!0,g.http.post("https://gh-oauth.imsun.net",{code:p,client_id:n,client_secret:o},"").then(function(a){b.accessToken=a.access_token,b.update()}).catch(function(a){b.state.user.isLoggingIn=!1,alert(a)})):this.update()}return d(a,[{key:"accessToken",get:function(){return localStorage.getItem(f.LS_ACCESS_TOKEN_KEY)},set:function(a){localStorage.setItem(f.LS_ACCESS_TOKEN_KEY,a)}},{key:"loginLink",get:function(){var a="https://github.com/login/oauth/authorize",b=this.oauth.redirect_uri||window.location.href,c=Object.assign({scope:l,redirect_uri:b},this.oauth);return""+a+g.Query.stringify(c)}}]),d(a,[{key:"init",value:function(){var a=this;return this.createIssue().then(function(){return a.loadComments()}).then(function(b){return a.state.error=null,b})}},{key:"useTheme",value:function(){var c,a=this,b=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.theme=b,c=Object.keys(this.theme),c.forEach(function(b){return m(a,b)})}},{key:"update",value:function(){var a=this;return Promise.all([this.loadMeta(),this.loadUserInfo()]).then(function(){return Promise.all([a.loadComments().then(function(){return a.loadCommentReactions()}),a.loadReactions()])}).catch(function(b){return a.state.error=b})}},{key:"markdown",value:function(a){return g.http.post("/markdown",{text:a,mode:"gfm"})}},{key:"createIssue",value:function(){var a=this,b=this.id,c=this.owner,d=this.repo,e=this.title,f=this.link,h=this.desc,i=this.labels;return g.http.post("/repos/"+c+"/"+d+"/issues",{title:e,labels:i.concat(["gitment",b]),body:f+"\n\n"+h}).then(function(b){return a.state.meta=b,b})}},{key:"getIssue",value:function(){return this.state.meta.id?Promise.resolve(this.state.meta):this.loadMeta()}},{key:"post",value:function(a){var b=this;return this.getIssue().then(function(b){return g.http.post(b.comments_url,{body:a},"")}).then(function(a){b.state.meta.comments++;var c=Math.ceil(b.state.meta.comments/b.perPage);return b.state.currentPage===c&&b.state.comments.push(a),a})}},{key:"loadMeta",value:function(){var a=this,b=this.id,c=this.owner,d=this.repo