diff --git a/js/dist/forum.js b/js/dist/forum.js index cb721ef..a508a99 100644 --- a/js/dist/forum.js +++ b/js/dist/forum.js @@ -1,3 +1,3 @@ /*! For license information please see forum.js.LICENSE.txt */ -(()=>{var t={879:t=>{t.exports=function(t){for(var e=[],n=0,o=0,a=0,s=t.length;a{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{for(var o in e)n.o(e,o)&&!n.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:e[o]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var o={};(()=>{"use strict";n.r(o),n.d(o,{components:()=>ot,extend:()=>mt,models:()=>rt,utils:()=>at});const t=flarum.core.compat["forum/app"];var e=n.n(t);const a=flarum.core.compat["common/extend"],s=flarum.core.compat["forum/utils/DiscussionControls"];var r=n.n(s);const i=flarum.core.compat["common/components/Button"];var u=n.n(i);function c(t,e){return c=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},c(t,e)}function l(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,c(t,e)}const g=flarum.core.compat["common/components/Modal"];var f=n.n(g);const d=flarum.core.compat["forum/components/DiscussionPage"];var p=n.n(d);const h=flarum.core.compat["common/Component"];var v=n.n(h),b=n(879),y=n.n(b);const L=flarum.core.compat["common/helpers/icon"];var w=n.n(L);const D=function(t){if(t){var e=t.emoji?t.emoji():t;return e?m("img",{alt:t.country&&t.country()||"",className:"emoji",draggable:"false",loading:"lazy",src:"//cdn.jsdelivr.net/gh/twitter/twemoji@14/assets/72x72/"+y()(e)+".png"}):w()("fas fa-globe")}};function x(){return x=Object.assign||function(t){for(var e=1;ee.code().toLowerCase()};const j=flarum.core.compat["forum/components/DiscussionHero"];var M=n.n(j);const A=flarum.core.compat["forum/states/DiscussionListState"];var I=n.n(A);const q=flarum.core.compat["forum/components/DiscussionListItem"];var F=n.n(q);const T=flarum.core.compat["forum/states/GlobalSearchState"];var z=n.n(T);const E=flarum.core.compat["common/utils/setRouteWithForcedRefresh"];var R=n.n(E);const U=flarum.core.compat["common/components/Dropdown"];var G=n.n(U);const H=flarum.core.compat["common/utils/classList"];var W=n.n(H);const $=flarum.core.compat["common/utils/Stream"];var J=n.n($),K=function(t){function n(){for(var e,n=arguments.length,o=new Array(n),a=0;a{var t={879:t=>{t.exports=function(t){for(var e=[],n=0,o=0,a=0,s=t.length;a{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{for(var o in e)n.o(e,o)&&!n.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:e[o]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var o={};(()=>{"use strict";n.r(o),n.d(o,{components:()=>ot,extend:()=>mt,models:()=>rt,utils:()=>at});const t=flarum.core.compat["forum/app"];var e=n.n(t);const a=flarum.core.compat["common/extend"],s=flarum.core.compat["forum/utils/DiscussionControls"];var r=n.n(s);const i=flarum.core.compat["common/components/Button"];var u=n.n(i);function c(t,e){return c=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},c(t,e)}function l(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,c(t,e)}const g=flarum.core.compat["common/components/Modal"];var f=n.n(g);const d=flarum.core.compat["forum/components/DiscussionPage"];var p=n.n(d);const h=flarum.core.compat["common/Component"];var v=n.n(h),b=n(879),y=n.n(b);const L=flarum.core.compat["common/helpers/icon"];var w=n.n(L);const D=function(t){if(t){var e=t.emoji?t.emoji():t;return e?m("img",{alt:t.country&&t.country()||"",className:"emoji",draggable:"false",loading:"lazy",src:"//cdn.jsdelivr.net/gh/twitter/twemoji@14/assets/72x72/"+y()(e)+".png"}):w()("fas fa-globe")}};function x(){return x=Object.assign||function(t){for(var e=1;ee.code().toLowerCase()};const j=flarum.core.compat["forum/components/DiscussionHero"];var M=n.n(j);const A=flarum.core.compat["forum/states/DiscussionListState"];var I=n.n(A);const q=flarum.core.compat["forum/components/DiscussionListItem"];var F=n.n(q);const T=flarum.core.compat["forum/states/GlobalSearchState"];var z=n.n(T);const E=flarum.core.compat["common/utils/setRouteWithForcedRefresh"];var R=n.n(E);const U=flarum.core.compat["common/components/Dropdown"];var G=n.n(U);const H=flarum.core.compat["common/utils/classList"];var W=n.n(H);const $=flarum.core.compat["common/utils/Stream"];var J=n.n($),K=function(t){function n(){for(var e,n=arguments.length,o=new Array(n),a=0;a {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['forum/app'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['common/extend'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['forum/utils/DiscussionControls'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['common/components/Button'];","export default function _setPrototypeOf(o, p) {\n _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {\n o.__proto__ = p;\n return o;\n };\n\n return _setPrototypeOf(o, p);\n}","import setPrototypeOf from \"./setPrototypeOf.js\";\nexport default function _inheritsLoose(subClass, superClass) {\n subClass.prototype = Object.create(superClass.prototype);\n subClass.prototype.constructor = subClass;\n setPrototypeOf(subClass, superClass);\n}","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['common/components/Modal'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['forum/components/DiscussionPage'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['common/Component'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['common/helpers/icon'];","import basename from 'twemoji-basename';\nimport icon from 'flarum/common/helpers/icon';\n\nexport default (language) => {\n if (!language) return;\n\n const emoji = language.emoji ? language.emoji() : language;\n\n return emoji ? (\n \n ) : (\n icon('fas fa-globe')\n );\n};\n","export default function _extends() {\n _extends = Object.assign || function (target) {\n for (var i = 1; i < arguments.length; i++) {\n var source = arguments[i];\n\n for (var key in source) {\n if (Object.prototype.hasOwnProperty.call(source, key)) {\n target[key] = source[key];\n }\n }\n }\n\n return target;\n };\n\n return _extends.apply(this, arguments);\n}","import Language from '../../common/models/Language';\nimport LanguageDisplay from '../components/LanguageDisplay';\nimport app from 'flarum/forum/app';\nimport type Mithril from 'mithril';\n\nexport default function generateLanguageOptions(extraOptions?: Record): Record {\n const options: Record = {};\n const languages = app.store.all('discussion-languages');\n\n // Populate the options with the languages\n languages.forEach((lang) => {\n options[lang.code()] = ;\n });\n\n // Merge extra options, if provided\n return { ...options, ...extraOptions };\n}\n","import app from 'flarum/forum/app';\nimport Component from 'flarum/common/Component';\nimport flag from '../../common/utils/flag';\nimport Language from '../../common/models/Language';\nimport type Mithril from 'mithril';\nimport generateLanguageOptions from '../utils/generateLanguageOptions';\n\ninterface LanguageDisplayAttrs {\n language: Language;\n uppercase?: boolean;\n extra?: Record;\n}\n\nexport default class LanguageDisplay extends Component {\n options!: Record;\n\n oninit(vnode: Mithril.Vnode): void {\n super.oninit(vnode);\n\n this.options = generateLanguageOptions(this.attrs.extra);\n }\n\n view(): Mithril.Child {\n const { language, uppercase } = this.attrs;\n const name = language.name() || '';\n\n return (\n \n {flag(language)} {uppercase ? name.toUpperCase() : name}\n \n );\n }\n}\n","import app from 'flarum/forum/app';\nimport Modal from 'flarum/common/components/Modal';\nimport Button from 'flarum/common/components/Button';\nimport DiscussionPage from 'flarum/forum/components/DiscussionPage';\n\nimport LanguageDisplay from './LanguageDisplay';\n\nexport default class LanguageDiscussionModal extends Modal {\n oninit(vnode) {\n super.oninit(vnode);\n\n this.languages = app.store.all('discussion-languages').filter((language) => language.code() !== 'any');\n\n this.current = this.attrs.selected || (this.attrs.discussion && this.attrs.discussion.language());\n this.selected = this.current;\n }\n\n className() {\n return 'FoFLanguageDiscussionModal';\n }\n\n title() {\n return this.attrs.discussion\n ? app.translator.trans('fof-discussion-language.forum.change_language.edit_title', { title: {this.attrs.discussion.title()} })\n : app.translator.trans('fof-discussion-language.forum.change_language.title');\n }\n\n content() {\n return [\n
\n
\n {this.languages.map((language) => (\n \n ))}\n
\n\n {!this.attrs.hideSubmitButton && (\n
\n {Button.component(\n {\n type: 'submit',\n className: 'Button Button--primary',\n disabled: !this.selected || this.selected === this.current,\n loading: this.loading,\n icon: 'fas fa-check',\n },\n app.translator.trans('fof-discussion-language.forum.change_language.submit_button')\n )}\n
\n )}\n
,\n ];\n }\n\n select(language) {\n this.selected = language;\n\n if (this.attrs.hideSubmitButton) return this.onsubmit();\n\n m.redraw();\n }\n\n onsubmit(e) {\n if (e) e.preventDefault();\n\n const { discussion, onsubmit } = this.attrs;\n\n this.loading = true;\n\n if (!discussion) {\n this.hide();\n\n if (onsubmit) onsubmit(this.selected);\n\n return;\n }\n\n const language = this.selected;\n\n discussion\n .save({ relationships: { language } })\n .then(() => {\n if (app.current instanceof DiscussionPage) {\n app.current.stream.update();\n }\n\n return this.hide();\n })\n .catch(this.loaded.bind(this));\n }\n}\n","import app from 'flarum/forum/app';\nimport { extend } from 'flarum/common/extend';\nimport DiscussionControls from 'flarum/forum/utils/DiscussionControls';\nimport Button from 'flarum/common/components/Button';\n\nimport LanguageDiscussionModal from './components/LanguageDiscussionModal';\n\nexport default () => {\n extend(DiscussionControls, 'moderationControls', function (items, discussion) {\n if (discussion.canChangeLanguage()) {\n items.add(\n 'language',\n Button.component(\n {\n icon: 'fas fa-globe',\n onclick: () => app.modal.show(LanguageDiscussionModal, { discussion }),\n },\n app.translator.trans('fof-discussion-language.forum.discussion_controls.change_language_button')\n )\n );\n }\n });\n};\n","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['forum/components/IndexPage'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['forum/components/DiscussionComposer'];","import { extend, override } from 'flarum/common/extend';\nimport app from 'flarum/forum/app';\nimport IndexPage from 'flarum/forum/components/IndexPage';\nimport DiscussionComposer from 'flarum/forum/components/DiscussionComposer';\n\nimport LanguageDiscussionModal from './components/LanguageDiscussionModal';\nimport LanguageDisplay from './components/LanguageDisplay';\n\nconst sort = (a, b) => a.code().toLowerCase() > b.code().toLowerCase();\n\nexport default () => {\n extend(IndexPage.prototype, 'newDiscussionAction', function (promise) {\n const dislang = app.search.params().language;\n\n if (dislang) {\n promise.then((composer) => (composer.fields.language = app.store.getBy('discussion-languages', 'code', dislang)));\n } else {\n const localeComposer = app.forum.attribute('fof-discussion-language.composerLocaleDefault');\n app.composer.fields.language = localeComposer ? app.store.getBy('discussion-languages', 'code', app.translator.getLocale()) : '';\n }\n });\n\n DiscussionComposer.prototype.chooseLanguage = function (hide, callback) {\n app.modal.show(LanguageDiscussionModal, {\n selected: this.composer.fields.language,\n hideSubmitButton: hide,\n onsubmit: (language) => {\n this.composer.fields.language = language;\n this.$('textarea').focus();\n\n if (callback) callback();\n },\n });\n };\n\n extend(DiscussionComposer.prototype, 'headerItems', function (items) {\n // Don't add lang item to byobu composers\n if (this._isByobuComposer) return;\n\n items.add(\n 'language',\n \n \n {this.composer.fields.language\n ? LanguageDisplay.component({ language: this.composer.fields.language, uppercase: true })\n : app.translator.trans('fof-discussion-language.forum.composer_discussion.choose_language_link')}\n \n ,\n 20\n );\n });\n\n override(DiscussionComposer.prototype, 'onsubmit', function (original) {\n // Don't add lang stuff to byobu composers\n if (this._isByobuComposer) return original();\n\n if (!this.composer.fields.language) return this.chooseLanguage(true, original);\n\n original();\n });\n\n extend(DiscussionComposer.prototype, 'data', function (data) {\n // Don't add lang stuff to byobu composers\n if (this._isByobuComposer) return;\n\n data.relationships = data.relationships || {};\n\n data.relationships.language = this.composer.fields.language || app.store.all('discussion-languages').sort(sort)[0];\n });\n};\n","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['forum/components/DiscussionHero'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['forum/states/DiscussionListState'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['forum/components/DiscussionListItem'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['forum/states/GlobalSearchState'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['common/utils/setRouteWithForcedRefresh'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['common/components/Dropdown'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['common/utils/classList'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['common/utils/Stream'];","import app from 'flarum/forum/app';\nimport Button from 'flarum/common/components/Button';\nimport Dropdown, { IDropdownAttrs } from 'flarum/common/components/Dropdown';\nimport type Mithril from 'mithril';\nimport icon from 'flarum/common/helpers/icon';\nimport classList from 'flarum/common/utils/classList';\nimport generateLanguageOptions from '../utils/generateLanguageOptions';\nimport Stream from 'flarum/common/utils/Stream';\n\nexport interface LanguageDropdownAttrs extends IDropdownAttrs {\n className?: string;\n selected?: string;\n onclick?: (langId: string) => void;\n extra?: Record;\n}\n\nexport default class LanguageDropdown extends Dropdown {\n selected!: Stream;\n options!: Record;\n loaded: boolean = false;\n\n static initAttrs(attrs: LanguageDropdownAttrs): void {\n attrs.buttonClassName = 'Button';\n attrs.className = classList(attrs.className, 'Dropdown--select', 'Dropdown--language');\n super.initAttrs(attrs);\n }\n\n oninit(vnode: Mithril.Vnode): void {\n super.oninit(vnode);\n\n this.loadLanguages();\n this.selected = Stream(this.initSelectedLanguage());\n }\n\n getDefaultLanguage(): string {\n return (app.forum.attribute('fof-discussion-language.showAnyLangOpt') ? 'any' : app.translator.getLocale()) || '';\n }\n\n initSelectedLanguage(): string {\n return this.attrs.selected || this.getDefaultLanguage();\n }\n\n loadLanguages(): void {\n if (this.loaded === false) {\n this.options = generateLanguageOptions(this.attrs.extra);\n this.loaded = true;\n }\n }\n\n buildDropdownContent(): Mithril.ChildArray {\n return Object.keys(this.options).map((langId) => {\n const isItemSelected = this.selected() === langId;\n\n return (\n {\n this.selected(langId);\n\n if (this.attrs.onclick) {\n this.attrs.onclick.call(this, langId);\n }\n }}\n aria-label={langId}\n >\n {this.options[langId]}\n \n );\n });\n }\n\n view(vnode: Mithril.Vnode) {\n const children = this.buildDropdownContent();\n\n return super.view({ ...vnode.attrs, children });\n }\n\n getButton(children: Mithril.ChildArray): Mithril.Vnode {\n return (\n \n {this.getButtonContent(children)}\n \n );\n }\n\n getButtonContent(children: Mithril.ChildArray): Mithril.ChildArray {\n return [\n {this.options[this.selected()]},\n this.attrs.caretIcon ? icon(this.attrs.caretIcon, { className: 'Button-caret' }) : null,\n ];\n }\n\n getMenu(items: Mithril.Vnode[]): Mithril.Vnode {\n return (\n
    \n {items}\n
\n );\n }\n}\n","import app from 'flarum/forum/app';\nimport { extend } from 'flarum/common/extend';\nimport IndexPage from 'flarum/forum/components/IndexPage';\nimport DiscussionHero from 'flarum/forum/components/DiscussionHero';\nimport DiscussionListState from 'flarum/forum/states/DiscussionListState';\nimport DiscussionListItem from 'flarum/forum/components/DiscussionListItem';\nimport GlobalSearchState from 'flarum/forum/states/GlobalSearchState';\nimport setRouteWithForcedRefresh from 'flarum/common/utils/setRouteWithForcedRefresh';\n\nimport flag from '../common/utils/flag';\nimport LanguageDropdown from './components/LanguageDropdown';\n\nconst addLanguage = function (items) {\n // Ignore PDs from Byobu\n // Must be conditional call in case byobu not installed\n if (this.attrs.discussion.isPrivateDiscussion?.()) return;\n\n const language = this.attrs.discussion.language();\n\n if (!language) return;\n\n items.add(\n 'discussion-language',\n \n {flag(language) || }\n {language.name()}\n ,\n 5\n );\n};\n\nexport default () => {\n extend(DiscussionListItem.prototype, 'infoItems', addLanguage);\n extend(DiscussionHero.prototype, 'items', addLanguage);\n\n extend(DiscussionListState.prototype, 'requestParams', function (params) {\n const routeName = app.current.data.routeName;\n\n if (routeName === 'byobuPrivate') return;\n if (routeName === 'byobuUserPrivate') return;\n\n params.include.push('language');\n\n // Do not filter user discussions page as there is no dropdown\n if (routeName === 'user.discussions') return;\n\n // Required until https://github.com/flarum/framework/pull/3376 is released.\n if (routeName === 'following' && params.filter.q) {\n params.filter.q += ` is:${params.filter.subscription || 'following'}`;\n delete params.filter.subscription;\n }\n\n const paramLang = app.search.params().language;\n const locale = app.search.params().language ?? app.translator.getLocale();\n const showAnyOpt = app.forum.attribute('fof-discussion-language.showAnyLangOpt');\n\n if (params.filter.q) {\n if (showAnyOpt) {\n if (paramLang) {\n params.filter.q += ' language:' + paramLang;\n }\n } else {\n params.filter.q += ' language:' + locale;\n }\n } else {\n if (!showAnyOpt || paramLang) {\n params.filter.language = locale;\n }\n }\n });\n\n extend(GlobalSearchState.prototype, 'stickyParams', (params) => (params.language = m.route.param('language')));\n\n extend(IndexPage.prototype, 'viewItems', function (items) {\n // Don't add language controls to /private (fof/byobu)\n if (app.current.data.routeName === 'byobuPrivate') return;\n\n const defaultSelected = app.forum.attribute('fof-discussion-language.showAnyLangOpt') ? 'any' : app.translator.getLocale();\n\n items.add(\n 'language',\n {\n // if `key` is not a string, return early\n if (typeof key !== 'string') return;\n\n const params = app.search.params();\n\n if (key === defaultSelected) delete params.language;\n else params.language = key;\n\n setRouteWithForcedRefresh(app.route(app.current.get('routeName'), params));\n }}\n />\n );\n });\n};\n","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['tags/common/models/Tag'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['common/models/Discussion'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['common/Model'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.extensions['fof-follow-tags'];","import LanguageDisplay from './LanguageDisplay';\nimport LanguageDiscussionModal from './LanguageDiscussionModal';\nimport LanguageDropdown from './LanguageDropdown';\n\nexport const components = {\n LanguageDisplay,\n LanguageDiscussionModal,\n LanguageDropdown,\n};\n","import flag from './flag';\n\nexport const utils = {\n flag,\n};\n","import Model from 'flarum/common/Model';\n\nexport default class Language extends Model {\n id() {\n return Model.attribute('id').call(this);\n }\n\n code() {\n return Model.attribute('code').call(this);\n }\n\n country() {\n return Model.attribute('country').call(this);\n }\n\n name() {\n return Model.attribute('name').call(this);\n }\n\n emoji() {\n return Model.attribute('emoji').call(this);\n }\n\n apiEndpoint() {\n return `/fof/discussion-language${this.exists ? `/${this.data.id}` : ''}`;\n }\n}\n","import Language from './Language';\n\nexport const models = {\n Language,\n};\n","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['common/extenders'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['common/models/Forum'];","import Extend from 'flarum/common/extenders';\nimport Language from '../common/models/Language';\nimport Discussion from 'flarum/common/models/Discussion';\nimport Forum from 'flarum/common/models/Forum';\nimport Tag from 'flarum/tags/common/models/Tag';\n\nexport default [\n new Extend.Store() //\n .add('discussion-languages', Language),\n\n new Extend.Model(Discussion) //\n .hasOne('language')\n .attribute('canChangeLanguage'),\n\n new Extend.Model(Forum) //\n .hasMany('discussionLanguages'),\n\n new Extend.Model(Tag) //\n .attribute('subscriptionLanguage')\n .attribute('localisedLastDiscussion'),\n];\n","import commonExtend from '../common/extend';\n\nexport default [...commonExtend];\n","import app from 'flarum/forum/app';\nimport addEditLanguageModal from './addEditLanguageModal';\nimport addLanguageComposer from './addLanguageComposer';\nimport addLanguageToDiscussionList from './addLanguageToDiscussionList';\nimport useLocalisedLastDiscussionOnTagsPage from './useLocalisedLastDiscussionOnTagsPage';\nimport extendSubscriptionModal from './extendSubscriptionModal';\n\nexport * from './components';\nexport * from '../common/utils';\nexport * from '../common/models';\nexport { default as extend } from './extend';\n\napp.initializers.add('fof/discussion-language', () => {\n addEditLanguageModal();\n addLanguageComposer();\n addLanguageToDiscussionList();\n useLocalisedLastDiscussionOnTagsPage();\n extendSubscriptionModal();\n});\n","import app from 'flarum/forum/app';\n\nimport Tag from 'flarum/tags/common/models/Tag';\n\nimport Discussion from 'flarum/common/models/Discussion';\nimport Model from 'flarum/common/Model';\n\nexport default function useLocalisedLastDiscussionOnTagsPage() {\n if (!('flarum-tags' in flarum.extensions)) return;\n\n Tag.prototype.lastPostedDiscussion = function (this: Tag) {\n const original = Model.hasOne('lastPostedDiscussion').bind(this);\n\n if (!app.forum.attribute('fof-discussion-language.useLocaleForTagsPageLastDiscussion')) {\n return original();\n }\n\n const data = this.localisedLastDiscussion();\n\n /**\n * Priorities:\n *\n * 1. User's selected forum locale\n * 2. Detected locale\n * 3. First disucssion language available\n */\n const desiredLanguageCode =\n app.session.user?.preferences?.()?.locale || (app.translator as any).formatter.locale || (app.forum as any).discussionLanguages()[0].code();\n\n const desiredLanguageId = (app.forum as any)\n .discussionLanguages()\n .find((lang: any) => lang.code() === desiredLanguageCode)\n ?.id();\n\n // If forum locale not available as a discussion lang, default to any language\n if (!desiredLanguageId) {\n return original();\n }\n\n const discussion = data[desiredLanguageId];\n\n // fall back to original attribute\n if (!discussion) return original();\n\n return new Discussion({\n attributes: {\n title: discussion.title,\n slug: discussion.id, // navigating using only ID works fine\n lastPostedAt: new Date(discussion.at * 1000).toISOString(),\n },\n });\n };\n}\n","import app from 'flarum/forum/app';\nimport { extend } from 'flarum/common/extend';\nimport { components } from '@fof-follow-tags';\nimport LanguageDropdown from './components/LanguageDropdown';\nimport Stream from 'flarum/common/utils/Stream';\n\nconst SUBSCRIPTION_LANGUAGE_PRIORITY = 80;\n\nexport default function extendSubscriptionModal() {\n if (!('fof-follow-tags' in flarum.extensions)) return;\n\n extend(components.SubscriptionModal.prototype, 'oninit', function () {\n const tag = this.attrs.model;\n const subscriptionLanguage = tag.subscriptionLanguage();\n this.language = Stream(subscriptionLanguage);\n });\n\n extend(components.SubscriptionModal.prototype, 'formOptionItems', function (items) {\n items.add(\n 'subscription_language',\n
\n \n

{app.translator.trans('fof-discussion-language.forum.sub_controls.subscription_language_help')}

\n {\n if (typeof key !== 'string') return;\n\n this.language(key);\n }}\n />\n
,\n SUBSCRIPTION_LANGUAGE_PRIORITY\n );\n });\n\n extend(components.SubscriptionModal.prototype, 'requestData', function (data) {\n data.language = this.language();\n\n return data;\n });\n}\n"],"names":["module","exports","str","r","c","p","i","l","length","charCodeAt","push","toString","join","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","undefined","__webpack_modules__","n","getter","__esModule","d","a","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","Symbol","toStringTag","value","flarum","core","compat","_setPrototypeOf","setPrototypeOf","__proto__","_inheritsLoose","subClass","superClass","create","constructor","language","emoji","m","alt","country","className","draggable","loading","src","basename","icon","_extends","assign","target","arguments","source","apply","this","generateLanguageOptions","extraOptions","options","app","all","forEach","lang","code","LanguageDisplay","_Component","_this","_len","args","Array","_key","concat","_proto","oninit","vnode","attrs","extra","view","_this$attrs","uppercase","name","flag","toUpperCase","Component","LanguageDiscussionModal","_Modal","languages","filter","current","selected","discussion","title","trans","content","map","Button","onclick","select","bind","hideSubmitButton","type","disabled","onsubmit","redraw","e","_this2","preventDefault","hide","save","relationships","then","DiscussionPage","stream","update","loaded","Modal","sort","b","toLowerCase","LanguageDropdown","_Dropdown","initAttrs","buttonClassName","classList","loadLanguages","Stream","initSelectedLanguage","getDefaultLanguage","attribute","getLocale","buildDropdownContent","keys","langId","isItemSelected","active","children","getButton","accessibleToggleLabel","getButtonContent","caretIcon","getMenu","items","menuClassName","Dropdown","addLanguage","_this$attrs$discussio","_this$attrs$discussio2","isPrivateDiscussion","add","extensions","components","utils","Language","_Model","id","Model","apiEndpoint","exists","data","models","Extend","Discussion","hasOne","Forum","hasMany","Tag","commonExtend","extend","DiscussionControls","canChangeLanguage","show","IndexPage","promise","dislang","params","composer","fields","getBy","localeComposer","DiscussionComposer","chooseLanguage","callback","$","focus","_isByobuComposer","component","override","original","DiscussionListItem","DiscussionHero","DiscussionListState","_app$search$params$la","routeName","include","q","subscription","paramLang","locale","showAnyOpt","GlobalSearchState","route","param","defaultSelected","setRouteWithForcedRefresh","lastPostedDiscussion","_app$session$user","_app$session$user$pre","_discussionLanguages$","localisedLastDiscussion","desiredLanguageCode","user","preferences","formatter","discussionLanguages","desiredLanguageId","find","attributes","slug","lastPostedAt","Date","at","toISOString","SubscriptionModal","subscriptionLanguage","model"],"sourceRoot":""} \ No newline at end of file +{"version":3,"file":"forum.js","mappings":";qBAGAA,EAAOC,QAAU,SAAUC,GAOzB,IANA,IAAIC,EAAI,GACJC,EAAI,EACJC,EAAI,EACJC,EAAI,EACJC,EAAIL,EAAIM,OAELF,EAAIC,GACTH,EAAIF,EAAIO,WAAWH,KACfD,GACFF,EAAEO,MAAM,OAAYL,EAAI,OAAW,KAAOD,EAAI,QAASO,SAAS,KAChEN,EAAI,GACK,OAAUD,GAAKA,GAAK,MAC7BC,EAAID,EAEJD,EAAEO,KAAKN,EAAEO,SAAS,KAItB,OAAOR,EAAES,KAAK,IAChB,ICtBIC,EAA2B,CAAC,EAGhC,SAASC,EAAoBC,GAE5B,IAAIC,EAAeH,EAAyBE,GAC5C,QAAqBE,IAAjBD,EACH,OAAOA,EAAaf,QAGrB,IAAID,EAASa,EAAyBE,GAAY,CAGjDd,QAAS,CAAC,GAOX,OAHAiB,EAAoB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AiCrC,KAEA0J,EAAAA,EAAAA,QAAOjB,GAAAA,WAAWwE,kBAAkBzM,UAAW,eAAe,SAAUyI,GAGtE,OAFAA,EAAKxH,SAAWiB,KAAKjB,WAEdwH,CACT,IF3BF","sources":["webpack://@fof/discussion-language/./node_modules/twemoji-basename/index.js","webpack://@fof/discussion-language/webpack/bootstrap","webpack://@fof/discussion-language/webpack/runtime/compat get default export","webpack://@fof/discussion-language/webpack/runtime/define property getters","webpack://@fof/discussion-language/webpack/runtime/hasOwnProperty shorthand","webpack://@fof/discussion-language/webpack/runtime/make namespace object","webpack://@fof/discussion-language/external root \"flarum.core.compat['forum/app']\"","webpack://@fof/discussion-language/external root \"flarum.core.compat['common/extend']\"","webpack://@fof/discussion-language/external root \"flarum.core.compat['forum/utils/DiscussionControls']\"","webpack://@fof/discussion-language/external root \"flarum.core.compat['common/components/Button']\"","webpack://@fof/discussion-language/./node_modules/@babel/runtime/helpers/esm/setPrototypeOf.js","webpack://@fof/discussion-language/./node_modules/@babel/runtime/helpers/esm/inheritsLoose.js","webpack://@fof/discussion-language/external root \"flarum.core.compat['common/components/Modal']\"","webpack://@fof/discussion-language/external root \"flarum.core.compat['forum/components/DiscussionPage']\"","webpack://@fof/discussion-language/external root \"flarum.core.compat['common/Component']\"","webpack://@fof/discussion-language/external root \"flarum.core.compat['common/helpers/icon']\"","webpack://@fof/discussion-language/./src/common/utils/flag.js","webpack://@fof/discussion-language/./node_modules/@babel/runtime/helpers/esm/extends.js","webpack://@fof/discussion-language/./src/forum/utils/generateLanguageOptions.tsx","webpack://@fof/discussion-language/./src/forum/components/LanguageDisplay.tsx","webpack://@fof/discussion-language/./src/forum/components/LanguageDiscussionModal.js","webpack://@fof/discussion-language/./src/forum/addEditLanguageModal.js","webpack://@fof/discussion-language/external root \"flarum.core.compat['forum/components/IndexPage']\"","webpack://@fof/discussion-language/external root \"flarum.core.compat['forum/components/DiscussionComposer']\"","webpack://@fof/discussion-language/./src/forum/addLanguageComposer.js","webpack://@fof/discussion-language/external root \"flarum.core.compat['forum/components/DiscussionHero']\"","webpack://@fof/discussion-language/external root \"flarum.core.compat['forum/states/DiscussionListState']\"","webpack://@fof/discussion-language/external root \"flarum.core.compat['forum/components/DiscussionListItem']\"","webpack://@fof/discussion-language/external root \"flarum.core.compat['forum/states/GlobalSearchState']\"","webpack://@fof/discussion-language/external root \"flarum.core.compat['common/utils/setRouteWithForcedRefresh']\"","webpack://@fof/discussion-language/external root \"flarum.core.compat['common/components/Dropdown']\"","webpack://@fof/discussion-language/external root \"flarum.core.compat['common/utils/classList']\"","webpack://@fof/discussion-language/external root \"flarum.core.compat['common/utils/Stream']\"","webpack://@fof/discussion-language/./src/forum/components/LanguageDropdown.tsx","webpack://@fof/discussion-language/./src/forum/addLanguageToDiscussionList.js","webpack://@fof/discussion-language/external root \"flarum.core.compat['tags/common/models/Tag']\"","webpack://@fof/discussion-language/external root \"flarum.core.compat['common/models/Discussion']\"","webpack://@fof/discussion-language/external root \"flarum.core.compat['common/Model']\"","webpack://@fof/discussion-language/external assign \"flarum.extensions['fof-follow-tags']\"","webpack://@fof/discussion-language/./src/forum/components/index.js","webpack://@fof/discussion-language/./src/common/utils/index.js","webpack://@fof/discussion-language/./src/common/models/Language.ts","webpack://@fof/discussion-language/./src/common/models/index.ts","webpack://@fof/discussion-language/external root \"flarum.core.compat['common/extenders']\"","webpack://@fof/discussion-language/external root \"flarum.core.compat['common/models/Forum']\"","webpack://@fof/discussion-language/./src/common/extend.ts","webpack://@fof/discussion-language/./src/forum/extend.ts","webpack://@fof/discussion-language/./src/forum/index.ts","webpack://@fof/discussion-language/./src/forum/useLocalisedLastDiscussionOnTagsPage.ts","webpack://@fof/discussion-language/./src/forum/extendSubscriptionModal.js"],"sourcesContent":["/*! Copyright Twitter Inc. and other contributors. Licensed under MIT */\n/* https://github.com/twitter/twemoji/blob/gh-pages/LICENSE */\n\nmodule.exports = function (str) {\n var r = []\n var c = 0\n var p = 0\n var i = 0\n var l = str.length\n\n while (i < l) {\n c = str.charCodeAt(i++)\n if (p) {\n r.push((0x10000 + ((p - 0xD800) << 10) + (c - 0xDC00)).toString(16))\n p = 0\n } else if (0xD800 <= c && c <= 0xDBFF) {\n p = c\n } else {\n r.push(c.toString(16))\n }\n }\n\n return r.join('-')\n}\n","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// getDefaultExport function for compatibility with non-harmony modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['forum/app'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['common/extend'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['forum/utils/DiscussionControls'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['common/components/Button'];","export default function _setPrototypeOf(o, p) {\n _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {\n o.__proto__ = p;\n return o;\n };\n\n return _setPrototypeOf(o, p);\n}","import setPrototypeOf from \"./setPrototypeOf.js\";\nexport default function _inheritsLoose(subClass, superClass) {\n subClass.prototype = Object.create(superClass.prototype);\n subClass.prototype.constructor = subClass;\n setPrototypeOf(subClass, superClass);\n}","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['common/components/Modal'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['forum/components/DiscussionPage'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['common/Component'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['common/helpers/icon'];","import basename from 'twemoji-basename';\nimport icon from 'flarum/common/helpers/icon';\n\nexport default (language) => {\n if (!language) return;\n\n const emoji = language.emoji ? language.emoji() : language;\n\n return emoji ? (\n \n ) : (\n icon('fas fa-globe')\n );\n};\n","export default function _extends() {\n _extends = Object.assign || function (target) {\n for (var i = 1; i < arguments.length; i++) {\n var source = arguments[i];\n\n for (var key in source) {\n if (Object.prototype.hasOwnProperty.call(source, key)) {\n target[key] = source[key];\n }\n }\n }\n\n return target;\n };\n\n return _extends.apply(this, arguments);\n}","import Language from '../../common/models/Language';\nimport LanguageDisplay from '../components/LanguageDisplay';\nimport app from 'flarum/forum/app';\nimport type Mithril from 'mithril';\n\nexport default function generateLanguageOptions(extraOptions?: Record): Record {\n const options: Record = {};\n const languages = app.store.all('discussion-languages');\n\n // Populate the options with the languages\n languages.forEach((lang) => {\n options[lang.code()] = ;\n });\n\n // Merge extra options, if provided\n return { ...options, ...extraOptions };\n}\n","import app from 'flarum/forum/app';\nimport Component from 'flarum/common/Component';\nimport flag from '../../common/utils/flag';\nimport Language from '../../common/models/Language';\nimport type Mithril from 'mithril';\nimport generateLanguageOptions from '../utils/generateLanguageOptions';\n\ninterface LanguageDisplayAttrs {\n language: Language;\n uppercase?: boolean;\n extra?: Record;\n}\n\nexport default class LanguageDisplay extends Component {\n options!: Record;\n\n oninit(vnode: Mithril.Vnode): void {\n super.oninit(vnode);\n\n this.options = generateLanguageOptions(this.attrs.extra);\n }\n\n view(): Mithril.Child {\n const { language, uppercase } = this.attrs;\n const name = language.name() || '';\n\n return (\n \n {flag(language)} {uppercase ? name.toUpperCase() : name}\n \n );\n }\n}\n","import app from 'flarum/forum/app';\nimport Modal from 'flarum/common/components/Modal';\nimport Button from 'flarum/common/components/Button';\nimport DiscussionPage from 'flarum/forum/components/DiscussionPage';\n\nimport LanguageDisplay from './LanguageDisplay';\n\nexport default class LanguageDiscussionModal extends Modal {\n oninit(vnode) {\n super.oninit(vnode);\n\n this.languages = app.store.all('discussion-languages').filter((language) => language.code() !== 'any');\n\n this.current = this.attrs.selected || (this.attrs.discussion && this.attrs.discussion.language());\n this.selected = this.current;\n }\n\n className() {\n return 'FoFLanguageDiscussionModal';\n }\n\n title() {\n return this.attrs.discussion\n ? app.translator.trans('fof-discussion-language.forum.change_language.edit_title', { title: {this.attrs.discussion.title()} })\n : app.translator.trans('fof-discussion-language.forum.change_language.title');\n }\n\n content() {\n return [\n
\n
\n {this.languages.map((language) => (\n \n ))}\n
\n\n {!this.attrs.hideSubmitButton && (\n
\n {Button.component(\n {\n type: 'submit',\n className: 'Button Button--primary',\n disabled: !this.selected || this.selected === this.current,\n loading: this.loading,\n icon: 'fas fa-check',\n },\n app.translator.trans('fof-discussion-language.forum.change_language.submit_button')\n )}\n
\n )}\n
,\n ];\n }\n\n select(language) {\n this.selected = language;\n\n if (this.attrs.hideSubmitButton) return this.onsubmit();\n\n m.redraw();\n }\n\n onsubmit(e) {\n if (e) e.preventDefault();\n\n const { discussion, onsubmit } = this.attrs;\n\n this.loading = true;\n\n if (!discussion) {\n this.hide();\n\n if (onsubmit) onsubmit(this.selected);\n\n return;\n }\n\n const language = this.selected;\n\n discussion\n .save({ relationships: { language } })\n .then(() => {\n if (app.current instanceof DiscussionPage) {\n app.current.stream.update();\n }\n\n return this.hide();\n })\n .catch(this.loaded.bind(this));\n }\n}\n","import app from 'flarum/forum/app';\nimport { extend } from 'flarum/common/extend';\nimport DiscussionControls from 'flarum/forum/utils/DiscussionControls';\nimport Button from 'flarum/common/components/Button';\n\nimport LanguageDiscussionModal from './components/LanguageDiscussionModal';\n\nexport default () => {\n extend(DiscussionControls, 'moderationControls', function (items, discussion) {\n if (discussion.canChangeLanguage()) {\n items.add(\n 'language',\n Button.component(\n {\n icon: 'fas fa-globe',\n onclick: () => app.modal.show(LanguageDiscussionModal, { discussion }),\n },\n app.translator.trans('fof-discussion-language.forum.discussion_controls.change_language_button')\n )\n );\n }\n });\n};\n","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['forum/components/IndexPage'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['forum/components/DiscussionComposer'];","import { extend, override } from 'flarum/common/extend';\nimport app from 'flarum/forum/app';\nimport IndexPage from 'flarum/forum/components/IndexPage';\nimport DiscussionComposer from 'flarum/forum/components/DiscussionComposer';\n\nimport LanguageDiscussionModal from './components/LanguageDiscussionModal';\nimport LanguageDisplay from './components/LanguageDisplay';\n\nconst sort = (a, b) => a.code().toLowerCase() > b.code().toLowerCase();\n\nexport default () => {\n extend(IndexPage.prototype, 'newDiscussionAction', function (promise) {\n const dislang = app.search.params().language;\n\n if (dislang) {\n promise.then((composer) => (composer.fields.language = app.store.getBy('discussion-languages', 'code', dislang)));\n } else {\n const localeComposer = app.forum.attribute('fof-discussion-language.composerLocaleDefault');\n app.composer.fields.language = localeComposer ? app.store.getBy('discussion-languages', 'code', app.translator.getLocale()) : '';\n }\n });\n\n DiscussionComposer.prototype.chooseLanguage = function (hide, callback) {\n app.modal.show(LanguageDiscussionModal, {\n selected: this.composer.fields.language,\n hideSubmitButton: hide,\n onsubmit: (language) => {\n this.composer.fields.language = language;\n this.$('textarea').focus();\n\n if (callback) callback();\n },\n });\n };\n\n extend(DiscussionComposer.prototype, 'headerItems', function (items) {\n // Don't add lang item to byobu composers\n if (this._isByobuComposer) return;\n\n items.add(\n 'language',\n \n \n {this.composer.fields.language\n ? LanguageDisplay.component({ language: this.composer.fields.language, uppercase: true })\n : app.translator.trans('fof-discussion-language.forum.composer_discussion.choose_language_link')}\n \n ,\n 20\n );\n });\n\n override(DiscussionComposer.prototype, 'onsubmit', function (original) {\n // Don't add lang stuff to byobu composers\n if (this._isByobuComposer) return original();\n\n if (!this.composer.fields.language) return this.chooseLanguage(true, original);\n\n original();\n });\n\n extend(DiscussionComposer.prototype, 'data', function (data) {\n // Don't add lang stuff to byobu composers\n if (this._isByobuComposer) return;\n\n data.relationships = data.relationships || {};\n\n data.relationships.language = this.composer.fields.language || app.store.all('discussion-languages').sort(sort)[0];\n });\n};\n","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['forum/components/DiscussionHero'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['forum/states/DiscussionListState'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['forum/components/DiscussionListItem'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['forum/states/GlobalSearchState'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['common/utils/setRouteWithForcedRefresh'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['common/components/Dropdown'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['common/utils/classList'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['common/utils/Stream'];","import app from 'flarum/forum/app';\nimport Button from 'flarum/common/components/Button';\nimport Dropdown, { IDropdownAttrs } from 'flarum/common/components/Dropdown';\nimport type Mithril from 'mithril';\nimport icon from 'flarum/common/helpers/icon';\nimport classList from 'flarum/common/utils/classList';\nimport generateLanguageOptions from '../utils/generateLanguageOptions';\nimport Stream from 'flarum/common/utils/Stream';\n\nexport interface LanguageDropdownAttrs extends IDropdownAttrs {\n className?: string;\n selected?: string;\n onclick?: (langId: string) => void;\n extra?: Record;\n}\n\nexport default class LanguageDropdown extends Dropdown {\n selected!: Stream;\n options!: Record;\n loaded: boolean = false;\n\n static initAttrs(attrs: LanguageDropdownAttrs): void {\n attrs.buttonClassName = 'Button';\n attrs.className = classList(attrs.className, 'Dropdown--select', 'Dropdown--language');\n super.initAttrs(attrs);\n }\n\n oninit(vnode: Mithril.Vnode): void {\n super.oninit(vnode);\n\n this.loadLanguages();\n this.selected = Stream(this.initSelectedLanguage());\n }\n\n getDefaultLanguage(): string {\n return (app.forum.attribute('fof-discussion-language.showAnyLangOpt') ? 'any' : app.translator.getLocale()) || '';\n }\n\n initSelectedLanguage(): string {\n return this.attrs.selected || this.getDefaultLanguage();\n }\n\n loadLanguages(): void {\n if (this.loaded === false) {\n this.options = generateLanguageOptions(this.attrs.extra);\n this.loaded = true;\n }\n }\n\n buildDropdownContent(): Mithril.ChildArray {\n return Object.keys(this.options).map((langId) => {\n const isItemSelected = this.selected() === langId;\n\n return (\n {\n this.selected(langId);\n\n if (this.attrs.onclick) {\n this.attrs.onclick.call(this, langId);\n }\n }}\n aria-label={langId}\n >\n {this.options[langId]}\n \n );\n });\n }\n\n view(vnode: Mithril.Vnode) {\n const children = this.buildDropdownContent();\n\n return super.view({ ...vnode.attrs, children });\n }\n\n getButton(children: Mithril.ChildArray): Mithril.Vnode {\n return (\n \n {this.getButtonContent(children)}\n \n );\n }\n\n getButtonContent(children: Mithril.ChildArray): Mithril.ChildArray {\n return [\n {this.options[this.selected()]},\n this.attrs.caretIcon ? icon(this.attrs.caretIcon, { className: 'Button-caret' }) : null,\n ];\n }\n\n getMenu(items: Mithril.Vnode[]): Mithril.Vnode {\n return (\n
    \n {items}\n
\n );\n }\n}\n","import app from 'flarum/forum/app';\nimport { extend } from 'flarum/common/extend';\nimport IndexPage from 'flarum/forum/components/IndexPage';\nimport DiscussionHero from 'flarum/forum/components/DiscussionHero';\nimport DiscussionListState from 'flarum/forum/states/DiscussionListState';\nimport DiscussionListItem from 'flarum/forum/components/DiscussionListItem';\nimport GlobalSearchState from 'flarum/forum/states/GlobalSearchState';\nimport setRouteWithForcedRefresh from 'flarum/common/utils/setRouteWithForcedRefresh';\n\nimport flag from '../common/utils/flag';\nimport LanguageDropdown from './components/LanguageDropdown';\n\nconst addLanguage = function (items) {\n // Ignore PDs from Byobu\n // Must be conditional call in case byobu not installed\n if (this.attrs.discussion.isPrivateDiscussion?.()) return;\n\n const language = this.attrs.discussion.language();\n\n if (!language) return;\n\n items.add(\n 'discussion-language',\n \n {flag(language) || }\n {language.name()}\n ,\n 5\n );\n};\n\nexport default () => {\n extend(DiscussionListItem.prototype, 'infoItems', addLanguage);\n extend(DiscussionHero.prototype, 'items', addLanguage);\n\n extend(DiscussionListState.prototype, 'requestParams', function (params) {\n const routeName = app.current.data.routeName;\n\n if (routeName === 'byobuPrivate') return;\n if (routeName === 'byobuUserPrivate') return;\n\n params.include.push('language');\n\n // Do not filter user discussions page as there is no dropdown\n if (routeName === 'user.discussions') return;\n\n // Required until https://github.com/flarum/framework/pull/3376 is released.\n if (routeName === 'following' && params.filter.q) {\n params.filter.q += ` is:${params.filter.subscription || 'following'}`;\n delete params.filter.subscription;\n }\n\n const paramLang = app.search.params().language;\n const locale = app.search.params().language ?? app.translator.getLocale();\n const showAnyOpt = app.forum.attribute('fof-discussion-language.showAnyLangOpt');\n\n if (params.filter.q) {\n if (showAnyOpt) {\n if (paramLang) {\n params.filter.q += ' language:' + paramLang;\n }\n } else {\n params.filter.q += ' language:' + locale;\n }\n } else {\n if (!showAnyOpt || paramLang) {\n params.filter.language = locale;\n }\n }\n });\n\n extend(GlobalSearchState.prototype, 'stickyParams', (params) => (params.language = m.route.param('language')));\n\n extend(IndexPage.prototype, 'viewItems', function (items) {\n // Don't add language controls to /private (fof/byobu)\n if (app.current.data.routeName === 'byobuPrivate') return;\n\n const defaultSelected = app.forum.attribute('fof-discussion-language.showAnyLangOpt') ? 'any' : app.translator.getLocale();\n\n items.add(\n 'language',\n {\n // if `key` is not a string, return early\n if (typeof key !== 'string') return;\n\n const params = app.search.params();\n\n if (key === defaultSelected) delete params.language;\n else params.language = key;\n\n setRouteWithForcedRefresh(app.route(app.current.get('routeName'), params));\n }}\n />\n );\n });\n};\n","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['tags/common/models/Tag'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['common/models/Discussion'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['common/Model'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.extensions['fof-follow-tags'];","import LanguageDisplay from './LanguageDisplay';\nimport LanguageDiscussionModal from './LanguageDiscussionModal';\nimport LanguageDropdown from './LanguageDropdown';\n\nexport const components = {\n LanguageDisplay,\n LanguageDiscussionModal,\n LanguageDropdown,\n};\n","import flag from './flag';\n\nexport const utils = {\n flag,\n};\n","import Model from 'flarum/common/Model';\n\nexport default class Language extends Model {\n id() {\n return Model.attribute('id').call(this);\n }\n\n code() {\n return Model.attribute('code').call(this);\n }\n\n country() {\n return Model.attribute('country').call(this);\n }\n\n name() {\n return Model.attribute('name').call(this);\n }\n\n emoji() {\n return Model.attribute('emoji').call(this);\n }\n\n apiEndpoint() {\n return `/fof/discussion-language${this.exists ? `/${this.data.id}` : ''}`;\n }\n}\n","import Language from './Language';\n\nexport const models = {\n Language,\n};\n","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['common/extenders'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['common/models/Forum'];","import Extend from 'flarum/common/extenders';\nimport Language from '../common/models/Language';\nimport Discussion from 'flarum/common/models/Discussion';\nimport Forum from 'flarum/common/models/Forum';\nimport Tag from 'flarum/tags/common/models/Tag';\n\nexport default [\n new Extend.Store() //\n .add('discussion-languages', Language),\n\n new Extend.Model(Discussion) //\n .hasOne('language')\n .attribute('canChangeLanguage'),\n\n new Extend.Model(Forum) //\n .hasMany('discussionLanguages'),\n\n new Extend.Model(Tag) //\n .attribute('subscriptionLanguage')\n .attribute('localisedLastDiscussion'),\n];\n","import commonExtend from '../common/extend';\n\nexport default [...commonExtend];\n","import app from 'flarum/forum/app';\nimport addEditLanguageModal from './addEditLanguageModal';\nimport addLanguageComposer from './addLanguageComposer';\nimport addLanguageToDiscussionList from './addLanguageToDiscussionList';\nimport useLocalisedLastDiscussionOnTagsPage from './useLocalisedLastDiscussionOnTagsPage';\nimport extendSubscriptionModal from './extendSubscriptionModal';\n\nexport * from './components';\nexport * from '../common/utils';\nexport * from '../common/models';\nexport { default as extend } from './extend';\n\napp.initializers.add('fof/discussion-language', () => {\n addEditLanguageModal();\n addLanguageComposer();\n addLanguageToDiscussionList();\n useLocalisedLastDiscussionOnTagsPage();\n extendSubscriptionModal();\n});\n","import app from 'flarum/forum/app';\n\nimport Tag from 'flarum/tags/common/models/Tag';\n\nimport Discussion from 'flarum/common/models/Discussion';\nimport Model from 'flarum/common/Model';\n\nexport default function useLocalisedLastDiscussionOnTagsPage() {\n if (!('flarum-tags' in flarum.extensions)) return;\n\n Tag.prototype.lastPostedDiscussion = function (this: Tag) {\n const original = Model.hasOne('lastPostedDiscussion').bind(this);\n\n if (!app.forum.attribute('fof-discussion-language.useLocaleForTagsPageLastDiscussion')) {\n return original();\n }\n\n const data = this.localisedLastDiscussion();\n\n /**\n * Priorities:\n *\n * 1. User's selected forum locale\n * 2. Detected locale\n * 3. First disucssion language available\n */\n const desiredLanguageCode =\n app.session.user?.preferences?.()?.locale || (app.translator as any).formatter.locale || (app.forum as any).discussionLanguages()[0].code();\n\n const desiredLanguageId = (app.forum as any)\n .discussionLanguages()\n .find((lang: any) => lang.code() === desiredLanguageCode)\n ?.id();\n\n // If forum locale not available as a discussion lang, default to any language\n if (!desiredLanguageId) {\n return original();\n }\n\n const discussion = data[desiredLanguageId];\n\n // fall back to original attribute\n if (!discussion) return original();\n\n return new Discussion({\n attributes: {\n title: discussion.title,\n slug: discussion.id, // navigating using only ID works fine\n lastPostedAt: new Date(discussion.at * 1000).toISOString(),\n },\n });\n };\n}\n","import app from 'flarum/forum/app';\nimport { extend } from 'flarum/common/extend';\nimport { components } from '@fof-follow-tags';\nimport LanguageDropdown from './components/LanguageDropdown';\nimport Stream from 'flarum/common/utils/Stream';\n\nconst SUBSCRIPTION_LANGUAGE_PRIORITY = 80;\n\nexport default function extendSubscriptionModal() {\n if (!('fof-follow-tags' in flarum.extensions)) return;\n\n extend(components.SubscriptionModal.prototype, 'oninit', function () {\n const tag = this.attrs.model;\n let subscriptionLanguage = tag.subscriptionLanguage();\n\n if (!app.forum.attribute('fof-discussion-language.showAnyLangOpt') && subscriptionLanguage === null) {\n subscriptionLanguage = app.translator.getLocale();\n }\n\n this.language = Stream(subscriptionLanguage);\n });\n\n extend(components.SubscriptionModal.prototype, 'formOptionItems', function (items) {\n items.add(\n 'subscription_language',\n
\n \n

{app.translator.trans('fof-discussion-language.forum.sub_controls.subscription_language_help')}

\n {\n if (typeof key !== 'string') return;\n\n this.language(key);\n }}\n />\n
,\n SUBSCRIPTION_LANGUAGE_PRIORITY\n );\n });\n\n extend(components.SubscriptionModal.prototype, 'requestData', function (data) {\n data.language = this.language();\n\n return data;\n });\n}\n"],"names":["module","exports","str","r","c","p","i","l","length","charCodeAt","push","toString","join","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","undefined","__webpack_modules__","n","getter","__esModule","d","a","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","Symbol","toStringTag","value","flarum","core","compat","_setPrototypeOf","setPrototypeOf","__proto__","_inheritsLoose","subClass","superClass","create","constructor","language","emoji","m","alt","country","className","draggable","loading","src","basename","icon","_extends","assign","target","arguments","source","apply","this","generateLanguageOptions","extraOptions","options","app","all","forEach","lang","code","LanguageDisplay","_Component","_this","_len","args","Array","_key","concat","_proto","oninit","vnode","attrs","extra","view","_this$attrs","uppercase","name","flag","toUpperCase","Component","LanguageDiscussionModal","_Modal","languages","filter","current","selected","discussion","title","trans","content","map","Button","onclick","select","bind","hideSubmitButton","type","disabled","onsubmit","redraw","e","_this2","preventDefault","hide","save","relationships","then","DiscussionPage","stream","update","loaded","Modal","sort","b","toLowerCase","LanguageDropdown","_Dropdown","initAttrs","buttonClassName","classList","loadLanguages","Stream","initSelectedLanguage","getDefaultLanguage","attribute","getLocale","buildDropdownContent","keys","langId","isItemSelected","active","children","getButton","accessibleToggleLabel","getButtonContent","caretIcon","getMenu","items","menuClassName","Dropdown","addLanguage","_this$attrs$discussio","_this$attrs$discussio2","isPrivateDiscussion","add","extensions","components","utils","Language","_Model","id","Model","apiEndpoint","exists","data","models","Extend","Discussion","hasOne","Forum","hasMany","Tag","commonExtend","extend","DiscussionControls","canChangeLanguage","show","IndexPage","promise","dislang","params","composer","fields","getBy","localeComposer","DiscussionComposer","chooseLanguage","callback","$","focus","_isByobuComposer","component","override","original","DiscussionListItem","DiscussionHero","DiscussionListState","_app$search$params$la","routeName","include","q","subscription","paramLang","locale","showAnyOpt","GlobalSearchState","route","param","defaultSelected","setRouteWithForcedRefresh","lastPostedDiscussion","_app$session$user","_app$session$user$pre","_discussionLanguages$","localisedLastDiscussion","desiredLanguageCode","user","preferences","formatter","discussionLanguages","desiredLanguageId","find","attributes","slug","lastPostedAt","Date","at","toISOString","SubscriptionModal","subscriptionLanguage","model"],"sourceRoot":""} \ No newline at end of file