{"version":3,"names":["window","require","registerSettings","api_provider","giphy_api_key","giphy_file_format","giphy_content_rating","giphy_locale","limit_infinite_search_results","max_results_limit","tenor_api_key","tenor_client_key","tenor_file_detail","tenor_content_filter","tenor_country","tenor_locale","theme_uploads","define","_exports","_component","_modifier","_object","_service","_dIcon","_i18n","_gif","_component2","_templateFactory","Object","defineProperty","value","default","getObjectForTheme","themePrefix","key1","GifButton","static","dt7948","g","this","prototype","service","modal","i","showGifModal","show","n","action","setComponentTemplate","createTemplateFactory","id","block","moduleName","scope","on","isStrictMode","_helper","_template2","GifResult","style","width","width1","height","height1","args","gif","htmlSafe","keyDown","event1","key","pick","fn","_didInsert","_didUpdate","_runloop","_conditionalLoadingSpinner","_minimasonry","_gifResult","GifResultList","site","observer","masonry","willDestroy","super","arguments","disconnect","setup","IntersectionObserver","scroller1","document","querySelector","scrollTop","content","length","loadMore","target1","observe","container","baseWidth","mobileView","surroundingGutter","schedule","layout","update","_tracking","_debounce","_I18n","settings","__COLOCATED_TEMPLATE__","Gif","appEvents","dialog","tracked","currentGifs","loading","offset","query","providerLogo","markup","title","original","model","customPickHandler","trigger","closeModal","search","refresh","event","target","undefined","Error","toUpperCase","response","fetch","getEndpoint","ok","errorMsg","status","t","headers","get","includes","errorResponse","json","error","details","find","e","reason","code","message","map","join","replaceAll","text","data","images","preview","fixed_width","webp","url","results","hasTinyGif","media_formats","media_format","tinygif","dims","pagination","count","next","addObjects","alert","params","q","country","locale","contentfilter","media_filter","limit","pos","client_key","URLSearchParams","api_key","lang","rating","_pluginApi","name","initialize","withPluginApi","api","lookup","onToolbarCreate","toolbar","context","composerEvents","addButton","group","icon","registerChatComposerButton","translatedLabel","position","modifyClass","p","pluginId","showChatGifModal","sendChatMessage","draft","channel","threadId","thread","caps","isSafari","isIOS","documentElement","classList","add","MiniMasonry","conf","_sizes","_columns","_container","_count","_width","_removeListener","_currentGutterX","_currentGutterY","_resizeTimeout","gutterX","gutterY","gutter","minify","ultimateGutter","direction","wedge","init","nodeName","onResize","resizeThrottler","bind","addEventListener","removeEventListener","clearTimeout","reset","clientWidth","minWidth","getCount","Math","floor","computeWidth","Number","parseFloat","toFixed","colWidth","startX","children","k","clientHeight","occupiedSpace","index","x","nextColumn","getShortest","getNextColumn","childrenGutter","y","transform","round","getLongest","console","shortest","longest","setTimeout","destroy","removeProperty"],"sourceRoot":"theme-9/","sources":["settings.js","discourse/components/gif-button.gjs","discourse/components/gif-result.gjs","discourse/components/gif-result-list.gjs","discourse/components/modal/gif.js","discourse/templates/connectors/composer-mobile-buttons-bottom/mobile-gif-button.js","discourse/initializers/gif-integration.js","discourse/lib/minimasonry.js"],"sourcesContent":["(function() {\n  if ('require' in window) {\n    require(\"discourse/lib/theme-settings-store\").registerSettings(9, {\"api_provider\":\"giphy\",\"giphy_api_key\":\"zRH0gHMsAzhnYt8ValXouvIrYXd1d7ME\",\"giphy_file_format\":\"webp\",\"giphy_content_rating\":\"r\",\"giphy_locale\":\"en\",\"limit_infinite_search_results\":false,\"max_results_limit\":240,\"tenor_api_key\":\"\",\"tenor_client_key\":\"discourse\",\"tenor_file_detail\":\"gif\",\"tenor_content_filter\":\"high\",\"tenor_country\":\"US\",\"tenor_locale\":\"en_US\",\"theme_uploads\":{\"giphy-logo\":\"https://communitycdn.ortussolutions.com/original/2X/d/dbdc564bd4335e3190b0c3beed437b36cfd418cb.gif\",\"tenor-logo\":\"https://communitycdn.ortussolutions.com/original/2X/7/7aab078ffae237ff5522c7a9c32482985f4f1131.png\",\"icons-sprite\":\"https://communitycdn.ortussolutions.com/original/2X/f/f12ce05b66e5cb7eba2bb0dbf1aa2712ef206865.svg\"}});\n  }\n})();\n","if ('define' in window) {\ndefine(\"discourse/theme-9/discourse/components/gif-button\", [\"exports\", \"@glimmer/component\", \"@ember/modifier\", \"@ember/object\", \"@ember/service\", \"discourse-common/helpers/d-icon\", \"discourse-common/helpers/i18n\", \"../components/modal/gif\", \"@ember/component\", \"@ember/template-factory\"], function (_exports, _component, _modifier, _object, _service, _dIcon, _i18n, _gif, _component2, _templateFactory) {\n  \"use strict\";\n\n  Object.defineProperty(_exports, \"__esModule\", {\n    value: true\n  });\n  _exports.default = void 0;\n  const settings = require(\"discourse/lib/theme-settings-store\").getObjectForTheme(9);\n  const themePrefix = key1 => `theme_translations.9.${key1}`;\n  class GifButton extends _component.default {\n    static #_ = (() => dt7948.g(this.prototype, \"modal\", [_service.service]))();\n    #modal = (() => (dt7948.i(this, \"modal\"), void 0))();\n    showGifModal() {\n      this.modal.show(_gif.default);\n    }\n    static #_2 = (() => dt7948.n(this.prototype, \"showGifModal\", [_object.action]))();\n    static #_3 = (() => (0, _component2.setComponentTemplate)((0, _templateFactory.createTemplateFactory)(\n    /*\n      \n        <button\n          type=\"button\"\n          class=\"btn btn-default no-text mobile-gif-insert\"\n          aria-label={{i18n (themePrefix \"gif.composer_title\")}}\n          {{on \"click\" this.showGifModal}}\n        >\n          {{icon \"discourse-gifs-gif\"}}\n        </button>\n      \n    */\n    {\n      \"id\": null,\n      \"block\": \"[[[1,\\\"\\\\n    \\\"],[11,\\\"button\\\"],[24,0,\\\"btn btn-default no-text mobile-gif-insert\\\"],[16,\\\"aria-label\\\",[28,[32,0],[[28,[32,1],[\\\"gif.composer_title\\\"],null]],null]],[24,4,\\\"button\\\"],[4,[32,2],[\\\"click\\\",[30,0,[\\\"showGifModal\\\"]]],null],[12],[1,\\\"\\\\n      \\\"],[1,[28,[32,3],[\\\"discourse-gifs-gif\\\"],null]],[1,\\\"\\\\n    \\\"],[13],[1,\\\"\\\\n  \\\"]],[],false,[]]\",\n      \"moduleName\": \"/discourse/theme-9/discourse/components/gif-button\",\n      \"scope\": () => [_i18n.default, themePrefix, _modifier.on, _dIcon.default],\n      \"isStrictMode\": true\n    }), this))();\n  }\n  _exports.default = GifButton;\n});\n}\n","if ('define' in window) {\ndefine(\"discourse/theme-9/discourse/components/gif-result\", [\"exports\", \"@glimmer/component\", \"@ember/helper\", \"@ember/modifier\", \"@ember/object\", \"@ember/template\", \"@ember/component\", \"@ember/template-factory\"], function (_exports, _component, _helper, _modifier, _object, _template2, _component2, _templateFactory) {\n  \"use strict\";\n\n  Object.defineProperty(_exports, \"__esModule\", {\n    value: true\n  });\n  _exports.default = void 0;\n  const settings = require(\"discourse/lib/theme-settings-store\").getObjectForTheme(9);\n  const themePrefix = key1 => `theme_translations.9.${key1}`;\n  class GifResult extends _component.default {\n    get style() {\n      const {\n        width: width1,\n        height: height1\n      } = this.args.gif;\n      if (width1 && height1) {\n        return (0, _template2.htmlSafe)(`--aspect-ratio: ${width1 / height1};`);\n      }\n    }\n    keyDown(event1) {\n      if (event1.key === \"Enter\") {\n        this.args.pick(this.args.gif);\n      }\n    }\n    static #_ = (() => dt7948.n(this.prototype, \"keyDown\", [_object.action]))();\n    static #_2 = (() => (0, _component2.setComponentTemplate)((0, _templateFactory.createTemplateFactory)(\n    /*\n      \n        <div\n          {{on \"click\" (fn @pick @gif)}}\n          {{on \"keydown\" this.keyDown}}\n          role=\"button\"\n          tabindex=\"0\"\n          class=\"gif-imgwrap\"\n        >\n          <img\n            class=\"gif-img\"\n            alt={{@gif.title}}\n            title={{@gif.title}}\n            src={{@gif.preview}}\n            style={{this.style}}\n            width={{@gif.width}}\n            height={{@gif.height}}\n          />\n        </div>\n      \n    */\n    {\n      \"id\": null,\n      \"block\": \"[[[1,\\\"\\\\n    \\\"],[11,0],[24,\\\"role\\\",\\\"button\\\"],[24,\\\"tabindex\\\",\\\"0\\\"],[24,0,\\\"gif-imgwrap\\\"],[4,[32,0],[\\\"click\\\",[28,[32,1],[[30,1],[30,2]],null]],null],[4,[32,0],[\\\"keydown\\\",[30,0,[\\\"keyDown\\\"]]],null],[12],[1,\\\"\\\\n      \\\"],[10,\\\"img\\\"],[14,0,\\\"gif-img\\\"],[15,\\\"alt\\\",[30,2,[\\\"title\\\"]]],[15,\\\"title\\\",[30,2,[\\\"title\\\"]]],[15,\\\"src\\\",[30,2,[\\\"preview\\\"]]],[15,5,[30,0,[\\\"style\\\"]]],[15,\\\"width\\\",[30,2,[\\\"width\\\"]]],[15,\\\"height\\\",[30,2,[\\\"height\\\"]]],[12],[13],[1,\\\"\\\\n    \\\"],[13],[1,\\\"\\\\n  \\\"]],[\\\"@pick\\\",\\\"@gif\\\"],false,[]]\",\n      \"moduleName\": \"/discourse/theme-9/discourse/components/gif-result\",\n      \"scope\": () => [_modifier.on, _helper.fn],\n      \"isStrictMode\": true\n    }), this))();\n  }\n  _exports.default = GifResult;\n});\n}\n","if ('define' in window) {\ndefine(\"discourse/theme-9/discourse/components/gif-result-list\", [\"exports\", \"@glimmer/component\", \"@ember/object\", \"@ember/render-modifiers/modifiers/did-insert\", \"@ember/render-modifiers/modifiers/did-update\", \"@ember/runloop\", \"@ember/service\", \"discourse/components/conditional-loading-spinner\", \"../lib/minimasonry\", \"./gif-result\", \"@ember/component\", \"@ember/template-factory\"], function (_exports, _component, _object, _didInsert, _didUpdate, _runloop, _service, _conditionalLoadingSpinner, _minimasonry, _gifResult, _component2, _templateFactory) {\n  \"use strict\";\n\n  Object.defineProperty(_exports, \"__esModule\", {\n    value: true\n  });\n  _exports.default = void 0;\n  const settings = require(\"discourse/lib/theme-settings-store\").getObjectForTheme(9);\n  const themePrefix = key1 => `theme_translations.9.${key1}`;\n  class GifResultList extends _component.default {\n    static #_ = (() => dt7948.g(this.prototype, \"site\", [_service.service]))();\n    #site = (() => (dt7948.i(this, \"site\"), void 0))();\n    observer;\n    masonry;\n    willDestroy() {\n      super.willDestroy(...arguments);\n      this.observer.disconnect();\n    }\n    setup() {\n      this.observer = new IntersectionObserver(() => {\n        const scroller1 = document.querySelector(\".gif-content\");\n        // ensure we don't load more if we haven't scrolled at all\n        if (scroller1?.scrollTop > 0 && this.args.content?.length > 0) {\n          this.args.loadMore();\n        }\n      });\n      let target1 = document.querySelector(\"div.gif-box div.loading-container\");\n      this.observer.observe(target1);\n      this.masonry = new _minimasonry.default({\n        container: \".gif-result-list\",\n        baseWidth: this.site.mobileView ? 145 : 200,\n        surroundingGutter: false\n      });\n      (0, _runloop.schedule)(\"afterRender\", () => this.masonry.layout());\n    }\n    static #_2 = (() => dt7948.n(this.prototype, \"setup\", [_object.action]))();\n    update() {\n      (0, _runloop.schedule)(\"afterRender\", () => this.masonry.layout());\n    }\n    static #_3 = (() => dt7948.n(this.prototype, \"update\", [_object.action]))();\n    static #_4 = (() => (0, _component2.setComponentTemplate)((0, _templateFactory.createTemplateFactory)(\n    /*\n      \n        <div\n          {{didInsert this.setup}}\n          {{didUpdate this.update @content}}\n          class=\"gif-result-list\"\n        >\n          {{#each @content as |result|}}\n            <GifResult @gif={{result}} @pick={{@pick}} />\n          {{/each}}\n    \n          <ConditionalLoadingSpinner @condition={{this.loading}} />\n        </div>\n      \n    */\n    {\n      \"id\": null,\n      \"block\": \"[[[1,\\\"\\\\n    \\\"],[11,0],[24,0,\\\"gif-result-list\\\"],[4,[32,0],[[30,0,[\\\"setup\\\"]]],null],[4,[32,1],[[30,0,[\\\"update\\\"]],[30,1]],null],[12],[1,\\\"\\\\n\\\"],[42,[28,[31,1],[[28,[31,1],[[30,1]],null]],null],null,[[[1,\\\"        \\\"],[8,[32,2],null,[[\\\"@gif\\\",\\\"@pick\\\"],[[30,2],[30,3]]],null],[1,\\\"\\\\n\\\"]],[2]],null],[1,\\\"\\\\n      \\\"],[8,[32,3],null,[[\\\"@condition\\\"],[[30,0,[\\\"loading\\\"]]]],null],[1,\\\"\\\\n    \\\"],[13],[1,\\\"\\\\n  \\\"]],[\\\"@content\\\",\\\"result\\\",\\\"@pick\\\"],false,[\\\"each\\\",\\\"-track-array\\\"]]\",\n      \"moduleName\": \"/discourse/theme-9/discourse/components/gif-result-list\",\n      \"scope\": () => [_didInsert.default, _didUpdate.default, _gifResult.default, _conditionalLoadingSpinner.default],\n      \"isStrictMode\": true\n    }), this))();\n  }\n  _exports.default = GifResultList;\n});\n}\n","if ('define' in window) {\ndefine(\"discourse/theme-9/discourse/components/modal/gif\", [\"exports\", \"@ember/component\", \"@glimmer/component\", \"@glimmer/tracking\", \"@ember/object\", \"@ember/service\", \"discourse-common/lib/debounce\", \"I18n\", \"@ember/template-factory\"], function (_exports, _component, _component2, _tracking, _object, _service, _debounce, _I18n, _templateFactory) {\n  \"use strict\";\n\n  Object.defineProperty(_exports, \"__esModule\", {\n    value: true\n  });\n  _exports.default = void 0;\n  const settings = require(\"discourse/lib/theme-settings-store\").getObjectForTheme(9);\n  const themePrefix = key => `theme_translations.9.${key}`;\n  const __COLOCATED_TEMPLATE__ = (0, _templateFactory.createTemplateFactory)(\n  /*\n    <DModal\n    @title={{theme-i18n \"gif.modal_title\"}}\n    @closeModal={{@closeModal}}\n    id=\"gif-modal\"\n    class=\"gif-modal\"\n  >\n    <:body>\n      <div class=\"gif-input\">\n        <Input\n          {{on \"input\" this.refresh}}\n          @type=\"text\"\n          name=\"query\"\n          autofocus={{true}}\n        />\n  \n        {{#if this.loading}}\n          {{loading-spinner size=\"small\"}}\n        {{/if}}\n      </div>\n  \n      {{#if this.currentGifs}}\n        <div class=\"gif-content\">\n          <div class=\"gif-box\">\n            <GifResultList\n              @content={{this.currentGifs}}\n              @pick={{this.pick}}\n              @loadMore={{this.loadMore}}\n            />\n          </div>\n        </div>\n      {{else}}\n        <div class=\"gif-no-results\">{{theme-i18n \"gif.no_results\"}}</div>\n      {{/if}}\n    </:body>\n  \n    <:footer>\n      <img src={{this.providerLogo}} />\n    </:footer>\n  </DModal>\n  */\n  {\n    \"id\": null,\n    \"block\": \"[[[8,[39,0],[[24,1,\\\"gif-modal\\\"],[24,0,\\\"gif-modal\\\"]],[[\\\"@title\\\",\\\"@closeModal\\\"],[[28,[37,1],[9,\\\"gif.modal_title\\\"],null],[30,1]]],[[\\\"body\\\",\\\"footer\\\"],[[[[1,\\\"\\\\n    \\\"],[10,0],[14,0,\\\"gif-input\\\"],[12],[1,\\\"\\\\n      \\\"],[8,[39,2],[[24,3,\\\"query\\\"],[16,\\\"autofocus\\\",true],[4,[38,3],[\\\"input\\\",[30,0,[\\\"refresh\\\"]]],null]],[[\\\"@type\\\"],[\\\"text\\\"]],null],[1,\\\"\\\\n\\\\n\\\"],[41,[30,0,[\\\"loading\\\"]],[[[1,\\\"        \\\"],[1,[28,[35,5],null,[[\\\"size\\\"],[\\\"small\\\"]]]],[1,\\\"\\\\n\\\"]],[]],null],[1,\\\"    \\\"],[13],[1,\\\"\\\\n\\\\n\\\"],[41,[30,0,[\\\"currentGifs\\\"]],[[[1,\\\"      \\\"],[10,0],[14,0,\\\"gif-content\\\"],[12],[1,\\\"\\\\n        \\\"],[10,0],[14,0,\\\"gif-box\\\"],[12],[1,\\\"\\\\n          \\\"],[8,[39,6],null,[[\\\"@content\\\",\\\"@pick\\\",\\\"@loadMore\\\"],[[30,0,[\\\"currentGifs\\\"]],[30,0,[\\\"pick\\\"]],[30,0,[\\\"loadMore\\\"]]]],null],[1,\\\"\\\\n        \\\"],[13],[1,\\\"\\\\n      \\\"],[13],[1,\\\"\\\\n\\\"]],[]],[[[1,\\\"      \\\"],[10,0],[14,0,\\\"gif-no-results\\\"],[12],[1,[28,[35,1],[9,\\\"gif.no_results\\\"],null]],[13],[1,\\\"\\\\n\\\"]],[]]],[1,\\\"  \\\"]],[]],[[[1,\\\"\\\\n    \\\"],[10,\\\"img\\\"],[15,\\\"src\\\",[30,0,[\\\"providerLogo\\\"]]],[12],[13],[1,\\\"\\\\n  \\\"]],[]]]]]],[\\\"@closeModal\\\"],false,[\\\"d-modal\\\",\\\"theme-i18n\\\",\\\"input\\\",\\\"on\\\",\\\"if\\\",\\\"loading-spinner\\\",\\\"gif-result-list\\\"]]\",\n    \"moduleName\": \"discourse/components/modal/gif.hbs\",\n    \"isStrictMode\": false\n  });\n  class Gif extends _component2.default {\n    static #_ = (() => dt7948.g(this.prototype, \"appEvents\", [_service.service]))();\n    #appEvents = (() => (dt7948.i(this, \"appEvents\"), void 0))();\n    static #_2 = (() => dt7948.g(this.prototype, \"dialog\", [_service.service]))();\n    #dialog = (() => (dt7948.i(this, \"dialog\"), void 0))();\n    static #_3 = (() => dt7948.g(this.prototype, \"currentGifs\", [_tracking.tracked], function () {\n      return [];\n    }))();\n    #currentGifs = (() => (dt7948.i(this, \"currentGifs\"), void 0))();\n    static #_4 = (() => dt7948.g(this.prototype, \"loading\", [_tracking.tracked], function () {\n      return false;\n    }))();\n    #loading = (() => (dt7948.i(this, \"loading\"), void 0))();\n    static #_5 = (() => dt7948.g(this.prototype, \"offset\", [_tracking.tracked], function () {\n      return 0;\n    }))();\n    #offset = (() => (dt7948.i(this, \"offset\"), void 0))();\n    static #_6 = (() => dt7948.g(this.prototype, \"query\", [_tracking.tracked], function () {\n      return \"\";\n    }))();\n    #query = (() => (dt7948.i(this, \"query\"), void 0))();\n    get providerLogo() {\n      return settings.theme_uploads[`${settings.api_provider}-logo`];\n    }\n    pick(content) {\n      let markup = `\\n![${content.title}|${content.width}x${content.height}](${content.original})\\n`;\n      if (this.args.model?.customPickHandler) {\n        this.args.model.customPickHandler(markup);\n      } else {\n        this.appEvents.trigger(\"composer:insert-text\", markup);\n      }\n      this.args.closeModal();\n    }\n    static #_7 = (() => dt7948.n(this.prototype, \"pick\", [_object.action]))();\n    loadMore() {\n      if (!this.loading) {\n        this.search(false);\n      }\n    }\n    static #_8 = (() => dt7948.n(this.prototype, \"loadMore\", [_object.action]))();\n    refresh(event) {\n      this.query = event.target.value;\n      (0, _debounce.default)(this, this.search, 700);\n    }\n    static #_9 = (() => dt7948.n(this.prototype, \"refresh\", [_object.action]))();\n    async search() {\n      let clearResults = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;\n      if (clearResults) {\n        this.currentGifs = [];\n        this.offset = 0;\n      }\n\n      // Check for minimum search query and if search result limit was set & reached\n      if (this.query.length > 2 && !settings.limit_infinite_search_results || settings.limit_infinite_search_results && this.currentGifs.length < settings.max_results_limit) {\n        this.loading = true;\n        try {\n          if (settings.api_provider === \"tenor\" && settings.tenor_api_key === \"\" || settings.api_provider === \"giphy\" && settings.giphy_api_key === \"\") {\n            throw new Error(`${settings.api_provider.toUpperCase()} API key is not set. Site Admins, \\\n            please visit the \"Discourse Gifs\" theme-component topic on Discourse Meta \\\n            for setup instructions.`);\n          }\n          const response = await fetch(this.getEndpoint(this.query, this.offset));\n          if (!response.ok) {\n            // Use the same errorMsg variable to handle variable replacement at the end for API Provider Display Name $api_provider.\n            let errorMsg;\n\n            // Only check for certain errors if setting is configured to do so.\n            // This is to allow server admins time & the choice to update the custom messages. Existing Plugin users will have this setting disabled by default.\n            if (response.status === 429) {\n              errorMsg = _I18n.default.t(themePrefix(\"gif.error_rate_limit\"));\n            } else if (response.status === 414) {\n              errorMsg = _I18n.default.t(themePrefix(\"gif.error_search_too_long\"));\n            } else if (response.status === 403 || response.status === 401) {\n              errorMsg = _I18n.default.t(themePrefix(\"gif.bad_api_key\"));\n            }\n\n            // Parse Error Messages from Tenor if one isn't set yet\n            if (!errorMsg && settings.api_provider === \"tenor\" && response.headers.get(\"content-type\")?.includes(\"application/json\")) {\n              const errorResponse = await response.json();\n\n              // Check for API Key Errors first\n              if (errorResponse.error.details.find(e => e.reason === \"API_KEY_INVALID\") !== undefined) {\n                errorMsg = _I18n.default.t(themePrefix(\"gif.bad_api_key\"));\n              } else {\n                // Map Error Message according to default Google API standards\n                throw new Error(`Tenor Error Code ${errorResponse.error.code}: ${errorResponse.error.message} [${errorResponse.error.details.map(e => e.reason).join(\", \")}]`);\n              }\n            }\n\n            // If error message is set, check if the API Provider variable was used.\n            // Replace if needed - throw at the end of it.\n            if (errorMsg) {\n              throw new Error(errorMsg.replaceAll(\"$api_provider\", settings.api_provider.toUpperCase()));\n            } else {\n              // Fallback to returning the entire response along with a status code.\n              throw new Error(`${settings.api_provider.toUpperCase()} Status ${response.status}: ${await response.text()}`);\n            }\n          }\n          const data = await response.json();\n          let images;\n          if (settings.api_provider === \"giphy\") {\n            // Giphy\n            images = data.data.map(gif => ({\n              title: gif.title,\n              preview: settings.giphy_file_format === \"webp\" ? gif.images.fixed_width.webp : gif.images.fixed_width.url,\n              original: settings.giphy_file_format === \"webp\" ? gif.images.original.webp : gif.images.original.url,\n              width: gif.images.original.width,\n              height: gif.images.original.height\n            }));\n          } else {\n            // Tenor\n            images = data.results.map(gif => {\n              // Use tinygif as default for previews and \"preview\" as a backup\n              const hasTinyGif = (\"tinygif\" in gif.media_formats);\n\n              // Use user-defined file format for attached GIFS and \"preview\" as a backup\n              const media_format = settings.tenor_file_detail in gif.media_formats ? gif.media_formats[`${settings.tenor_file_detail}`] : gif.media_formats.preview;\n              return {\n                title: gif.title,\n                preview: hasTinyGif ? gif.media_formats.tinygif.url : gif.media_formats.preview.url,\n                original: media_format.url,\n                width: media_format.dims[0],\n                height: media_format.dims[1]\n              };\n            });\n          }\n\n          // Handle offset differences between Giphy and Tenor\n          this.offset = settings.api_provider === \"giphy\" ? data.pagination.offset + data.pagination.count : data.next === \"\" ? 0 : data.next;\n          this.currentGifs.addObjects(images);\n        } catch (error) {\n          this.dialog.alert({\n            message: error\n          });\n        } finally {\n          this.loading = false;\n        }\n      }\n    }\n    getEndpoint(query, offset) {\n      if (settings.api_provider === \"tenor\") {\n        let params = {\n          key: settings.tenor_api_key,\n          q: query,\n          country: settings.tenor_country,\n          locale: settings.tenor_locale,\n          contentfilter: settings.tenor_content_filter,\n          media_filter: settings.tenor_file_detail,\n          limit: 24,\n          pos: offset\n        };\n\n        // Optional Parameter\n        if (settings.tenor_client_key !== \"\") {\n          params.client_key = settings.tenor_client_key;\n        }\n\n        // Include tinygif for preview and \"preview\" for backup.\n        params.media_filter += settings.tenor_file_detail !== \"tinygif\" ? \",tinygif,preview\" : \",preview\";\n        return \"https://tenor.googleapis.com/v2/search?\" + new URLSearchParams(params);\n      } else {\n        // GIPHY\n        return \"https://api.giphy.com/v1/gifs/search?\" + new URLSearchParams({\n          limit: 24,\n          q: query,\n          offset,\n          api_key: settings.giphy_api_key,\n          lang: settings.giphy_locale,\n          rating: settings.giphy_content_rating\n        });\n      }\n    }\n  }\n  _exports.default = Gif;\n  (0, _component.setComponentTemplate)(__COLOCATED_TEMPLATE__, Gif);\n});\n}\n","if ('define' in window) {\ndefine(\"discourse/theme-9/discourse/templates/connectors/composer-mobile-buttons-bottom/mobile-gif-button\", [\"exports\", \"@ember/template-factory\"], function (_exports, _templateFactory) {\n  \"use strict\";\n\n  Object.defineProperty(_exports, \"__esModule\", {\n    value: true\n  });\n  _exports.default = void 0;\n  var _default = _exports.default = (0, _templateFactory.createTemplateFactory)(\n  /*\n    <GifButton />\n  */\n  {\n    \"id\": null,\n    \"block\": \"[[[8,[39,0],null,null,null]],[],false,[\\\"gif-button\\\"]]\",\n    \"moduleName\": \"discourse/theme-9/discourse/templates/connectors/composer-mobile-buttons-bottom/mobile-gif-button\",\n    \"isStrictMode\": false\n  });\n});\n}\n","if ('define' in window) {\ndefine(\"discourse/theme-9/discourse/initializers/gif-integration\", [\"exports\", \"@ember/object\", \"discourse/lib/plugin-api\", \"../components/modal/gif\"], function (_exports, _object, _pluginApi, _gif) {\n  \"use strict\";\n\n  Object.defineProperty(_exports, \"__esModule\", {\n    value: true\n  });\n  _exports.default = void 0;\n  const settings = require(\"discourse/lib/theme-settings-store\").getObjectForTheme(9);\n  const themePrefix = key => `theme_translations.9.${key}`;\n  var _default = _exports.default = {\n    name: \"discourse-gifs\",\n    initialize(container) {\n      (0, _pluginApi.withPluginApi)(\"0.1\", api => {\n        if (!api.container.lookup(\"service:site\").mobileView) {\n          api.onToolbarCreate(toolbar => {\n            if (toolbar.context.composerEvents) {\n              toolbar.addButton({\n                title: themePrefix(\"gif.composer_title\"),\n                id: \"gif_button\",\n                group: \"extras\",\n                icon: \"discourse-gifs-gif\",\n                action: () => {\n                  const modal = api.container.lookup(\"service:modal\");\n                  modal.show(_gif.default);\n                }\n              });\n            }\n          });\n        }\n        const chat = api.container.lookup(\"service:chat\");\n        if (chat) {\n          api.registerChatComposerButton?.({\n            translatedLabel: themePrefix(\"gif.composer_title\"),\n            id: \"gif_button\",\n            icon: \"discourse-gifs-gif\",\n            action: \"showChatGifModal\",\n            position: \"dropdown\"\n          });\n          api.modifyClass(\"component:chat-composer\", dt7948.p({\n            pluginId: \"discourse-gifs\",\n            showChatGifModal(context) {\n              this.modal.show(_gif.default, {\n                model: {\n                  customPickHandler: message => {\n                    api.sendChatMessage(this.draft.channel.id, {\n                      message,\n                      threadId: context === \"thread\" ? this.draft.thread.id : null\n                    });\n                  }\n                }\n              });\n            }\n          }, [[\"method\", \"showChatGifModal\", [_object.action]]]));\n        }\n      });\n\n      // for old tenor gifs compat\n      const caps = container.lookup(\"service:capabilities\");\n      if (caps.isSafari || caps.isIOS) {\n        document.documentElement.classList.add(\"discourse-gifs-with-img\");\n      }\n    }\n  };\n});\n}\n","if ('define' in window) {\ndefine(\"discourse/theme-9/discourse/lib/minimasonry\", [\"exports\"], function (_exports) {\n  \"use strict\";\n\n  Object.defineProperty(_exports, \"__esModule\", {\n    value: true\n  });\n  _exports.default = void 0;\n  const settings = require(\"discourse/lib/theme-settings-store\").getObjectForTheme(9);\n  const themePrefix = key => `theme_translations.9.${key}`;\n  var MiniMasonry = function (conf) {\n    this._sizes = [];\n    this._columns = [];\n    this._container = null;\n    this._count = null;\n    this._width = 0;\n    this._removeListener = null;\n    this._currentGutterX = null;\n    this._currentGutterY = null;\n    this._resizeTimeout = null, this.conf = {\n      baseWidth: 255,\n      gutterX: null,\n      gutterY: null,\n      gutter: 10,\n      container: null,\n      minify: true,\n      ultimateGutter: 5,\n      surroundingGutter: true,\n      direction: 'ltr',\n      wedge: false\n    };\n    this.init(conf);\n    return this;\n  };\n  MiniMasonry.prototype.init = function (conf) {\n    for (var i in this.conf) {\n      if (conf[i] != undefined) {\n        this.conf[i] = conf[i];\n      }\n    }\n    if (this.conf.gutterX == null || this.conf.gutterY == null) {\n      this.conf.gutterX = this.conf.gutterY = this.conf.gutter;\n    }\n    this._currentGutterX = this.conf.gutterX;\n    this._currentGutterY = this.conf.gutterY;\n    this._container = typeof this.conf.container == 'object' && this.conf.container.nodeName ? this.conf.container : document.querySelector(this.conf.container);\n    if (!this._container) {\n      throw new Error('Container not found or missing');\n    }\n    var onResize = this.resizeThrottler.bind(this);\n    window.addEventListener(\"resize\", onResize);\n    this._removeListener = function () {\n      window.removeEventListener(\"resize\", onResize);\n      if (this._resizeTimeout != null) {\n        window.clearTimeout(this._resizeTimeout);\n        this._resizeTimeout = null;\n      }\n    };\n    this.layout();\n  };\n  MiniMasonry.prototype.reset = function () {\n    this._sizes = [];\n    this._columns = [];\n    this._count = null;\n    this._width = this._container.clientWidth;\n    var minWidth = this.conf.baseWidth;\n    if (this._width < minWidth) {\n      this._width = minWidth;\n      this._container.style.minWidth = minWidth + 'px';\n    }\n    if (this.getCount() == 1) {\n      // Set ultimate gutter when only one column is displayed\n      this._currentGutterX = this.conf.ultimateGutter;\n      // As gutters are reduced, two column may fit, forcing to 1\n      this._count = 1;\n    } else if (this._width < this.conf.baseWidth + 2 * this._currentGutterX) {\n      // Remove gutter when screen is to low\n      this._currentGutterX = 0;\n    } else {\n      this._currentGutterX = this.conf.gutterX;\n    }\n  };\n  MiniMasonry.prototype.getCount = function () {\n    if (this.conf.surroundingGutter) {\n      return Math.floor((this._width - this._currentGutterX) / (this.conf.baseWidth + this._currentGutterX));\n    }\n    return Math.floor((this._width + this._currentGutterX) / (this.conf.baseWidth + this._currentGutterX));\n  };\n  MiniMasonry.prototype.computeWidth = function () {\n    var width;\n    if (this.conf.surroundingGutter) {\n      width = (this._width - this._currentGutterX) / this._count - this._currentGutterX;\n    } else {\n      width = (this._width + this._currentGutterX) / this._count - this._currentGutterX;\n    }\n    width = Number.parseFloat(width.toFixed(2));\n    return width;\n  };\n  MiniMasonry.prototype.layout = function () {\n    if (!this._container) {\n      console.error('Container not found');\n      return;\n    }\n    this.reset();\n\n    //Computing columns count\n    if (this._count == null) {\n      this._count = this.getCount();\n    }\n    //Computing columns width\n    var colWidth = this.computeWidth();\n    for (var i = 0; i < this._count; i++) {\n      this._columns[i] = 0;\n    }\n\n    //Saving children real heights\n    var children = this._container.children;\n    for (var k = 0; k < children.length; k++) {\n      // Set colWidth before retrieving element height if content is proportional\n      children[k].style.width = colWidth + 'px';\n      this._sizes[k] = children[k].clientHeight;\n    }\n    var startX;\n    if (this.conf.direction == 'ltr') {\n      startX = this.conf.surroundingGutter ? this._currentGutterX : 0;\n    } else {\n      startX = this._width - (this.conf.surroundingGutter ? this._currentGutterX : 0);\n    }\n    if (this._count > this._sizes.length) {\n      //If more columns than children\n      var occupiedSpace = this._sizes.length * (colWidth + this._currentGutterX) - this._currentGutterX;\n      if (this.conf.wedge === false) {\n        if (this.conf.direction == 'ltr') {\n          startX = (this._width - occupiedSpace) / 2;\n        } else {\n          startX = this._width - (this._width - occupiedSpace) / 2;\n        }\n      } else {\n        if (this.conf.direction == 'ltr') {\n          //\n        } else {\n          startX = this._width - this._currentGutterX;\n        }\n      }\n    }\n\n    //Computing position of children\n    for (var index = 0; index < children.length; index++) {\n      var nextColumn = this.conf.minify ? this.getShortest() : this.getNextColumn(index);\n      var childrenGutter = 0;\n      if (this.conf.surroundingGutter || nextColumn != this._columns.length) {\n        childrenGutter = this._currentGutterX;\n      }\n      var x;\n      if (this.conf.direction == 'ltr') {\n        x = startX + (colWidth + childrenGutter) * nextColumn;\n      } else {\n        x = startX - (colWidth + childrenGutter) * nextColumn - colWidth;\n      }\n      var y = this._columns[nextColumn];\n      children[index].style.transform = 'translate3d(' + Math.round(x) + 'px,' + Math.round(y) + 'px,0)';\n      this._columns[nextColumn] += this._sizes[index] + (this._count > 1 ? this.conf.gutterY : this.conf.ultimateGutter); //margin-bottom\n    }\n    this._container.style.height = this._columns[this.getLongest()] - this._currentGutterY + 'px';\n  };\n  MiniMasonry.prototype.getNextColumn = function (index) {\n    return index % this._columns.length;\n  };\n  MiniMasonry.prototype.getShortest = function () {\n    var shortest = 0;\n    for (var i = 0; i < this._count; i++) {\n      if (this._columns[i] < this._columns[shortest]) {\n        shortest = i;\n      }\n    }\n    return shortest;\n  };\n  MiniMasonry.prototype.getLongest = function () {\n    var longest = 0;\n    for (var i = 0; i < this._count; i++) {\n      if (this._columns[i] > this._columns[longest]) {\n        longest = i;\n      }\n    }\n    return longest;\n  };\n  MiniMasonry.prototype.resizeThrottler = function () {\n    // ignore resize events as long as an actualResizeHandler execution is in the queue\n    if (!this._resizeTimeout) {\n      this._resizeTimeout = setTimeout(function () {\n        this._resizeTimeout = null;\n        //IOS Safari throw random resize event on scroll, call layout only if size has changed\n        if (this._container.clientWidth != this._width) {\n          this.layout();\n        }\n        // The actualResizeHandler will execute at a rate of 30fps\n      }.bind(this), 33);\n    }\n  };\n  MiniMasonry.prototype.destroy = function () {\n    if (typeof this._removeListener == \"function\") {\n      this._removeListener();\n    }\n    var children = this._container.children;\n    for (var k = 0; k < children.length; k++) {\n      children[k].style.removeProperty('width');\n      children[k].style.removeProperty('transform');\n    }\n    this._container.style.removeProperty('height');\n    this._container.style.removeProperty('min-width');\n  };\n  var _default = _exports.default = MiniMasonry;\n});\n}\n"],"mappings":"AACM,YAAaA,QACfC,QAAQ,sCAAsCC,iBAAiB,EAAG,CAACC,aAAe,QAAQC,cAAgB,mCAAmCC,kBAAoB,OAAOC,qBAAuB,IAAIC,aAAe,KAAKC,+BAAgC,EAAMC,kBAAoB,IAAIC,cAAgB,GAAGC,iBAAmB,YAAYC,kBAAoB,MAAMC,qBAAuB,OAAOC,cAAgB,KAAKC,aAAe,QAAQC,cAAgB,CAAC,aAAa,qGAAqG,aAAa,qGAAqG,eAAe,wGCF/qB,WAAYhB,QAChBiB,OAAO,oDAAqD,CAAC,UAAW,qBAAsB,kBAAmB,gBAAiB,iBAAkB,kCAAmC,gCAAiC,0BAA2B,mBAAoB,4BAA4B,SAAUC,EAAUC,EAAYC,EAAWC,EAASC,EAAUC,EAAQC,EAAOC,EAAMC,EAAaC,GACjY;AAEAC,OAAOC,eAAeX,EAAU,aAAc,CAC5CY,OAAO,IAETZ,EAASa,aAAU;AACF9B,QAAQ,sCAAsC+B,kBA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