framework/extensions/suspend/js/dist/forum.js
flarum-bot d63cd16f15 Bundled output for commit 7453bc338a
Includes transpiled JS/TS.

[skip ci]
2021-12-20 16:33:35 +00:00

2 lines
18 KiB
JavaScript

module.exports=function(t){var e={};function n(s){if(e[s])return e[s].exports;var r=e[s]={i:s,l:!1,exports:{}};return t[s].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=t,n.c=e,n.d=function(t,e,s){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:s})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var s=Object.create(null);if(n.r(s),Object.defineProperty(s,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)n.d(s,r,function(e){return t[e]}.bind(null,r));return s},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=19)}([function(t,e){t.exports=flarum.core.compat["forum/app"]},function(t,e){t.exports=flarum.core.compat.app},function(t,e){t.exports=flarum.core.compat.Model},function(t,e){t.exports=flarum.core.compat["models/User"]},function(t,e){t.exports=flarum.core.compat["utils/Stream"]},function(t,e){t.exports=flarum.core.compat["components/Button"]},function(t,e){t.exports=flarum.core.compat["components/Notification"]},function(t,e){t.exports=flarum.core.compat["utils/withAttr"]},function(t,e,n){t.exports=function(){"use strict";var t=6e4,e=36e5,n="millisecond",s="second",r="minute",i="hour",a="day",o="week",u="month",c="quarter",l="year",f="date",d="Invalid Date",m=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,p=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,h={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_")},$=function(t,e,n){var s=String(t);return!s||s.length>=e?t:""+Array(e+1-s.length).join(n)+t},y={s:$,z:function(t){var e=-t.utcOffset(),n=Math.abs(e),s=Math.floor(n/60),r=n%60;return(e<=0?"+":"-")+$(s,2,"0")+":"+$(r,2,"0")},m:function t(e,n){if(e.date()<n.date())return-t(n,e);var s=12*(n.year()-e.year())+(n.month()-e.month()),r=e.clone().add(s,u),i=n-r<0,a=e.clone().add(s+(i?-1:1),u);return+(-(s+(n-r)/(i?r-a:a-r))||0)},a:function(t){return t<0?Math.ceil(t)||0:Math.floor(t)},p:function(t){return{M:u,y:l,w:o,d:a,D:f,h:i,m:r,s:s,ms:n,Q:c}[t]||String(t||"").toLowerCase().replace(/s$/,"")},u:function(t){return void 0===t}},g="en",v={};v[g]=h;var M=function(t){return t instanceof D},b=function(t,e,n){var s;if(!t)return g;if("string"==typeof t)v[t]&&(s=t),e&&(v[t]=e,s=t);else{var r=t.name;v[r]=t,s=r}return!n&&s&&(g=s),s||!n&&g},_=function(t,e){if(M(t))return t.clone();var n="object"==typeof e?e:{};return n.date=t,n.args=arguments,new D(n)},S=y;S.l=b,S.i=M,S.w=function(t,e){return _(t,{locale:e.$L,utc:e.$u,x:e.$x,$offset:e.$offset})};var D=function(){function h(t){this.$L=b(t.locale,null,!0),this.parse(t)}var $=h.prototype;return $.parse=function(t){this.$d=function(t){var e=t.date,n=t.utc;if(null===e)return new Date(NaN);if(S.u(e))return new Date;if(e instanceof Date)return new Date(e);if("string"==typeof e&&!/Z$/i.test(e)){var s=e.match(m);if(s){var r=s[2]-1||0,i=(s[7]||"0").substring(0,3);return n?new Date(Date.UTC(s[1],r,s[3]||1,s[4]||0,s[5]||0,s[6]||0,i)):new Date(s[1],r,s[3]||1,s[4]||0,s[5]||0,s[6]||0,i)}}return new Date(e)}(t),this.$x=t.x||{},this.init()},$.init=function(){var t=this.$d;this.$y=t.getFullYear(),this.$M=t.getMonth(),this.$D=t.getDate(),this.$W=t.getDay(),this.$H=t.getHours(),this.$m=t.getMinutes(),this.$s=t.getSeconds(),this.$ms=t.getMilliseconds()},$.$utils=function(){return S},$.isValid=function(){return!(this.$d.toString()===d)},$.isSame=function(t,e){var n=_(t);return this.startOf(e)<=n&&n<=this.endOf(e)},$.isAfter=function(t,e){return _(t)<this.startOf(e)},$.isBefore=function(t,e){return this.endOf(e)<_(t)},$.$g=function(t,e,n){return S.u(t)?this[e]:this.set(n,t)},$.unix=function(){return Math.floor(this.valueOf()/1e3)},$.valueOf=function(){return this.$d.getTime()},$.startOf=function(t,e){var n=this,c=!!S.u(e)||e,d=S.p(t),m=function(t,e){var s=S.w(n.$u?Date.UTC(n.$y,e,t):new Date(n.$y,e,t),n);return c?s:s.endOf(a)},p=function(t,e){return S.w(n.toDate()[t].apply(n.toDate("s"),(c?[0,0,0,0]:[23,59,59,999]).slice(e)),n)},h=this.$W,$=this.$M,y=this.$D,g="set"+(this.$u?"UTC":"");switch(d){case l:return c?m(1,0):m(31,11);case u:return c?m(1,$):m(0,$+1);case o:var v=this.$locale().weekStart||0,M=(h<v?h+7:h)-v;return m(c?y-M:y+(6-M),$);case a:case f:return p(g+"Hours",0);case i:return p(g+"Minutes",1);case r:return p(g+"Seconds",2);case s:return p(g+"Milliseconds",3);default:return this.clone()}},$.endOf=function(t){return this.startOf(t,!1)},$.$set=function(t,e){var o,c=S.p(t),d="set"+(this.$u?"UTC":""),m=(o={},o[a]=d+"Date",o[f]=d+"Date",o[u]=d+"Month",o[l]=d+"FullYear",o[i]=d+"Hours",o[r]=d+"Minutes",o[s]=d+"Seconds",o[n]=d+"Milliseconds",o)[c],p=c===a?this.$D+(e-this.$W):e;if(c===u||c===l){var h=this.clone().set(f,1);h.$d[m](p),h.init(),this.$d=h.set(f,Math.min(this.$D,h.daysInMonth())).$d}else m&&this.$d[m](p);return this.init(),this},$.set=function(t,e){return this.clone().$set(t,e)},$.get=function(t){return this[S.p(t)]()},$.add=function(n,c){var f,d=this;n=Number(n);var m=S.p(c),p=function(t){var e=_(d);return S.w(e.date(e.date()+Math.round(t*n)),d)};if(m===u)return this.set(u,this.$M+n);if(m===l)return this.set(l,this.$y+n);if(m===a)return p(1);if(m===o)return p(7);var h=(f={},f[r]=t,f[i]=e,f[s]=1e3,f)[m]||1,$=this.$d.getTime()+n*h;return S.w($,this)},$.subtract=function(t,e){return this.add(-1*t,e)},$.format=function(t){var e=this,n=this.$locale();if(!this.isValid())return n.invalidDate||d;var s=t||"YYYY-MM-DDTHH:mm:ssZ",r=S.z(this),i=this.$H,a=this.$m,o=this.$M,u=n.weekdays,c=n.months,l=function(t,n,r,i){return t&&(t[n]||t(e,s))||r[n].substr(0,i)},f=function(t){return S.s(i%12||12,t,"0")},m=n.meridiem||function(t,e,n){var s=t<12?"AM":"PM";return n?s.toLowerCase():s},h={YY:String(this.$y).slice(-2),YYYY:this.$y,M:o+1,MM:S.s(o+1,2,"0"),MMM:l(n.monthsShort,o,c,3),MMMM:l(c,o),D:this.$D,DD:S.s(this.$D,2,"0"),d:String(this.$W),dd:l(n.weekdaysMin,this.$W,u,2),ddd:l(n.weekdaysShort,this.$W,u,3),dddd:u[this.$W],H:String(i),HH:S.s(i,2,"0"),h:f(1),hh:f(2),a:m(i,a,!0),A:m(i,a,!1),m:String(a),mm:S.s(a,2,"0"),s:String(this.$s),ss:S.s(this.$s,2,"0"),SSS:S.s(this.$ms,3,"0"),Z:r};return s.replace(p,(function(t,e){return e||h[t]||r.replace(":","")}))},$.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},$.diff=function(n,f,d){var m,p=S.p(f),h=_(n),$=(h.utcOffset()-this.utcOffset())*t,y=this-h,g=S.m(this,h);return g=(m={},m[l]=g/12,m[u]=g,m[c]=g/3,m[o]=(y-$)/6048e5,m[a]=(y-$)/864e5,m[i]=y/e,m[r]=y/t,m[s]=y/1e3,m)[p]||y,d?g:S.a(g)},$.daysInMonth=function(){return this.endOf(u).$D},$.$locale=function(){return v[this.$L]},$.locale=function(t,e){if(!t)return this.$L;var n=this.clone(),s=b(t,e,!0);return s&&(n.$L=s),n},$.clone=function(){return S.w(this.$d,this)},$.toDate=function(){return new Date(this.valueOf())},$.toJSON=function(){return this.isValid()?this.toISOString():null},$.toISOString=function(){return this.$d.toISOString()},$.toString=function(){return this.$d.toUTCString()},h}(),x=D.prototype;return _.prototype=x,[["$ms",n],["$s",s],["$m",r],["$H",i],["$W",a],["$M",u],["$y",l],["$D",f]].forEach((function(t){x[t[1]]=function(e){return this.$g(e,t[0],t[1])}})),_.extend=function(t,e){return t.$i||(t(e,D,_),t.$i=!0),_},_.locale=b,_.isDayjs=M,_.unix=function(t){return _(1e3*t)},_.en=v[g],_.Ls=v,_.p={},_}()},function(t,e){t.exports=flarum.core.compat.extend},function(t,e){t.exports=flarum.core.compat["common/utils/ItemList"]},function(t,e){t.exports=flarum.core.compat["utils/UserControls"]},function(t,e){t.exports=flarum.core.compat["components/Badge"]},function(t,e){t.exports=flarum.core.compat["components/Modal"]},function(t,e,n){t.exports=function(){"use strict";var t="minute",e=/[+-]\d\d(?::?\d\d)?/g,n=/([+-]|\d\d)/g;return function(s,r,i){var a=r.prototype;i.utc=function(t){var e={date:t,utc:!0,args:arguments};return new r(e)},a.utc=function(e){var n=i(this.toDate(),{locale:this.$L,utc:!0});return e?n.add(this.utcOffset(),t):n},a.local=function(){return i(this.toDate(),{locale:this.$L,utc:!1})};var o=a.parse;a.parse=function(t){t.utc&&(this.$u=!0),this.$utils().u(t.$offset)||(this.$offset=t.$offset),o.call(this,t)};var u=a.init;a.init=function(){if(this.$u){var t=this.$d;this.$y=t.getUTCFullYear(),this.$M=t.getUTCMonth(),this.$D=t.getUTCDate(),this.$W=t.getUTCDay(),this.$H=t.getUTCHours(),this.$m=t.getUTCMinutes(),this.$s=t.getUTCSeconds(),this.$ms=t.getUTCMilliseconds()}else u.call(this)};var c=a.utcOffset;a.utcOffset=function(s,r){var i=this.$utils().u;if(i(s))return this.$u?0:i(this.$offset)?c.call(this):this.$offset;if("string"==typeof s&&null===(s=function(t){void 0===t&&(t="");var s=t.match(e);if(!s)return null;var r=(""+s[0]).match(n)||["-",0,0],i=r[0],a=60*+r[1]+ +r[2];return 0===a?0:"+"===i?a:-a}(s)))return this;var a=Math.abs(s)<=16?60*s:s,o=this;if(r)return o.$offset=a,o.$u=0===s,o;if(0!==s){var u=this.$u?this.toDate().getTimezoneOffset():-1*this.utcOffset();(o=this.local().add(a+u,t)).$offset=a,o.$x.$localOffset=u}else o=this.utc();return o};var l=a.format;a.format=function(t){var e=t||(this.$u?"YYYY-MM-DDTHH:mm:ss[Z]":"");return l.call(this,e)},a.valueOf=function(){var t=this.$utils().u(this.$offset)?0:this.$offset+(this.$x.$localOffset||(new Date).getTimezoneOffset());return this.$d.valueOf()-6e4*t},a.isUTC=function(){return!!this.$u},a.toISOString=function(){return this.toDate().toISOString()},a.toString=function(){return this.toDate().toUTCString()};var f=a.toDate;a.toDate=function(t){return"s"===t&&this.$offset?i(this.format("YYYY-MM-DD HH:mm:ss:SSS")).toDate():f.call(this)};var d=a.diff;a.diff=function(t,e,n){if(t&&this.$u===t.$u)return d.call(this,t,e,n);var s=this.local(),r=i(t).local();return d.call(s,r,e,n)}}}()},function(t,e){t.exports=flarum.core.compat["common/components/Modal"]},function(t,e){t.exports=flarum.core.compat["common/components/Button"]},function(t,e){t.exports=flarum.core.compat["common/helpers/fullTime"]},function(t,e){t.exports=flarum.core},function(t,e,n){"use strict";n.r(e);var s=n(9),r=n(1),i=n.n(r),a=n(11),o=n.n(a),u=n(5),c=n.n(u),l=n(12),f=n.n(l),d=n(2),p=n.n(d),h=n(3),$=n.n(h);function y(t,e){return(y=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function g(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,y(t,e)}var v=n(0),M=n.n(v),b=n(13),_=n.n(b),S=n(4),D=n.n(S),x=n(7),O=n.n(x),w=n(10),T=n.n(w),U=n(8),N=n.n(U),k=n(14),C=n.n(k);function Y(t){return N.a.utc(t).isSame(N.a.utc("2038-01-01"))}N.a.extend(C.a);var j=function(t){function e(){return t.apply(this,arguments)||this}g(e,t);var n=e.prototype;return n.oninit=function(e){t.prototype.oninit.call(this,e);var n=this.attrs.user.suspendedUntil(),s=this.attrs.user.suspendReason(),r=this.attrs.user.suspendMessage(),i=null;new Date>n&&(n=null),n&&(i=9999===n.getFullYear()?"indefinitely":"limited"),this.status=D()(i),this.reason=D()(s),this.message=D()(r),this.daysRemaining=D()("limited"===i&&1-dayjs().diff(n,"days"))},n.className=function(){return"SuspendUserModal Modal--medium"},n.title=function(){return M.a.translator.trans("flarum-suspend.forum.suspend_user.title",{user:this.attrs.user})},n.content=function(){return m("div",{className:"Modal-body"},m("div",{className:"Form"},m("div",{className:"Form-group"},m("label",null,M.a.translator.trans("flarum-suspend.forum.suspend_user.status_heading")),m("div",null,this.formItems().toArray())),m("div",{className:"Form-group"},m(c.a,{className:"Button Button--primary",loading:this.loading,type:"submit"},M.a.translator.trans("flarum-suspend.forum.suspend_user.submit_button")))))},n.radioItems=function(){var t=this,e=new T.a;return e.add("not-suspended",m("label",{className:"checkbox"},m("input",{type:"radio",name:"status",checked:!this.status(),value:"",onclick:O()("value",this.status)}),M.a.translator.trans("flarum-suspend.forum.suspend_user.not_suspended_label")),100),e.add("indefinitely",m("label",{className:"checkbox"},m("input",{type:"radio",name:"status",checked:"indefinitely"===this.status(),value:"indefinitely",onclick:O()("value",this.status)}),M.a.translator.trans("flarum-suspend.forum.suspend_user.indefinitely_label")),90),e.add("time-suspension",m("label",{className:"checkbox SuspendUserModal-days"},m("input",{type:"radio",name:"status",checked:"limited"===this.status(),value:"limited",onclick:function(e){t.status(e.target.value),m.redraw.sync(),t.$(".SuspendUserModal-days-input input").select(),e.redraw=!1}}),M.a.translator.trans("flarum-suspend.forum.suspend_user.limited_time_label"),"limited"===this.status()&&m("div",{className:"SuspendUserModal-days-input"},m("input",{type:"number",min:"0",value:this.daysRemaining(),oninput:O()("value",this.daysRemaining),className:"FormControl"}),M.a.translator.trans("flarum-suspend.forum.suspend_user.limited_time_days_text"))),80),e},n.formItems=function(){var t=new T.a;return t.add("radioItems",m("div",{className:"Form-group"},this.radioItems().toArray()),100),t.add("reason",m("div",{className:"Form-group"},m("label",null,M.a.translator.trans("flarum-suspend.forum.suspend_user.reason"),m("textarea",{className:"FormControl",bidi:this.reason,placeholder:M.a.translator.trans("flarum-suspend.forum.suspend_user.placeholder_optional"),rows:"2"}))),90),t.add("message",m("div",{className:"Form-group"},m("label",null,M.a.translator.trans("flarum-suspend.forum.suspend_user.display_message"),m("textarea",{className:"FormControl",bidi:this.message,placeholder:M.a.translator.trans("flarum-suspend.forum.suspend_user.placeholder_optional"),rows:"2"}))),80),t},n.onsubmit=function(t){var e=this;t.preventDefault(),this.loading=!0;var n=null;switch(this.status()){case"indefinitely":n=new Date("2038-01-01");break;case"limited":n=dayjs().add(this.daysRemaining(),"days").toDate()}this.attrs.user.save({suspendedUntil:n,suspendReason:this.reason(),suspendMessage:this.message()}).then((function(){return e.hide()}),this.loaded.bind(this))},e}(_.a),I=n(6),F=n.n(I),H=function(t){function e(){return t.apply(this,arguments)||this}g(e,t);var n=e.prototype;return n.icon=function(){return"fas fa-ban"},n.href=function(){return M.a.route.user(this.attrs.notification.subject())},n.content=function(){var t=this.attrs.notification,e=t.content(),n=dayjs(e).from(t.createdAt(),!0);return Y(e)?M.a.translator.trans("flarum-suspend.forum.notifications.user_suspended_indefinite_text"):M.a.translator.trans("flarum-suspend.forum.notifications.user_suspended_text",{timeReadable:n})},e}(F.a),A=function(t){function e(){return t.apply(this,arguments)||this}g(e,t);var n=e.prototype;return n.icon=function(){return"fas fa-ban"},n.href=function(){return M.a.route.user(this.attrs.notification.subject())},n.content=function(){this.attrs.notification;return M.a.translator.trans("flarum-suspend.forum.notifications.user_unsuspended_text")},e}(F.a),L=n(15),W=n.n(L),B=n(16),R=n.n(B),P=n(17),z=n.n(P),Z=function(t){function e(){return t.apply(this,arguments)||this}g(e,t);var n=e.prototype;return n.oninit=function(e){t.prototype.oninit.call(this,e),this.message=this.attrs.message,this.until=this.attrs.until},n.className=function(){return"SuspensionInfoModal Modal"},n.title=function(){return M.a.translator.trans("flarum-suspend.forum.suspension_info.title")},n.content=function(){var t=Y(new Date(this.until))?M.a.translator.trans("flarum-suspend.forum.suspension_info.indefinite"):M.a.translator.trans("flarum-suspend.forum.suspension_info.limited",{date:z()(this.until)});return m("div",{className:"Modal-body"},m("div",{className:"Form Form--centered"},m("p",{className:"helpText"},this.message),m("p",{className:"helpText"},t),m("div",{className:"Form-group"},m(R.a,{className:"Button Button--primary Button--block",onclick:this.hide.bind(this)},M.a.translator.trans("flarum-suspend.forum.suspension_info.dismiss_button")))))},n.hide=function(){localStorage.setItem("flarum-suspend.acknowledge-suspension",this.attrs.until.getTime()),this.attrs.state.close()},e}(W.a),J=function(){return setTimeout((function(){if(M.a.session.user){var t=M.a.session.user.suspendMessage(),e=M.a.session.user.suspendedUntil(),n=localStorage.getItem("flarum-suspend.acknowledge-suspension")===(null==e?void 0:e.getTime().toString());t&&!n?M.a.modal.show(Z,{message:t,until:e}):!e&&localStorage.getItem("flarum-suspend.acknowledge-suspension")&&localStorage.removeItem("flarum-suspend.acknowledge-suspension")}}),0)},V={"suspend/components/suspendUserModal":j,"suspend/components/suspensionInfoModal":Z,"suspend/components/UserSuspendedNotification":H,"suspend/components/UserUnsuspendedNotification":A,"suspend/checkForSuspension":J},q=n(18);i.a.initializers.add("flarum-suspend",(function(){i.a.notificationComponents.userSuspended=H,i.a.notificationComponents.userUnsuspended=A,$.a.prototype.canSuspend=p.a.attribute("canSuspend"),$.a.prototype.suspendedUntil=p.a.attribute("suspendedUntil",p.a.transformDate),$.a.prototype.suspendReason=p.a.attribute("suspendReason"),$.a.prototype.suspendMessage=p.a.attribute("suspendMessage"),Object(s.extend)(o.a,"moderationControls",(function(t,e){e.canSuspend()&&t.add("suspend",c.a.component({icon:"fas fa-ban",onclick:function(){return i.a.modal.show(j,{user:e})}},i.a.translator.trans("flarum-suspend.forum.user_controls.suspend_button")))})),Object(s.extend)($.a.prototype,"badges",(function(t){var e=this.suspendedUntil();new Date<e&&t.add("suspended",f.a.component({icon:"fas fa-ban",type:"suspended",label:i.a.translator.trans("flarum-suspend.forum.user_badge.suspended_tooltip")}))})),J()})),Object.assign(q.compat,V)}]);
//# sourceMappingURL=forum.js.map