define("discourse/plugins/discourse-ai/discourse/admin-discourse-ai-personas-route-map",["exports"],(function(e){"use strict"
Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
e.default={resource:"admin.adminPlugins",path:"/plugins",map(){this.route("discourse-ai",(function(){this.route("ai-personas",{path:"ai_personas"},(function(){this.route("new"),this.route("show",{path:"/:id"})}))}))}}})),define("discourse/plugins/discourse-ai/discourse/admin-discourse-ai-route-map",["exports"],(function(e){"use strict"
Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
e.default={resource:"admin.dashboard",path:"/dashboard",map(){this.route("admin.dashboardSentiment",{path:"/dashboard/sentiment",resetNamespace:!0})}}})),define("discourse/plugins/discourse-ai/discourse/admin/adapters/ai-persona",["exports","discourse/adapters/rest"],(function(e,t){"use strict"
function i(e,t,i){var s
return(t="symbol"==typeof(s=function(e,t){if("object"!=typeof e||!e)return e
var i=e[Symbol.toPrimitive]
if(void 0!==i){var s=i.call(e,t||"default")
if("object"!=typeof s)return s
throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(t,"string"))?s:String(s))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
class s extends t.default{constructor(){super(...arguments),i(this,"jsonMode",!0)}basePath(){return"/admin/plugins/discourse-ai/"}pathFor(){return super.pathFor(...arguments)+".json"}apiNameFor(){return"ai-persona"}}e.default=s})),define("discourse/plugins/discourse-ai/discourse/admin/models/ai-persona",["exports","@glimmer/tracking","discourse/models/rest"],(function(e,t,i){"use strict"
var s,o
Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
const r=["name","description","commands","system_prompt","allowed_group_ids","enabled","system","priority"]
let n=(s=class{constructor(){var e,t,i,s
e=this,t="value",s=this,(i=o)&&Object.defineProperty(e,t,{enumerable:i.enumerable,configurable:i.configurable,writable:i.writable,value:i.initializer?i.initializer.call(s):void 0})}},a=s.prototype,l="value",u=[t.tracked],c={configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}},p={},Object.keys(c).forEach((function(e){p[e]=c[e]})),p.enumerable=!!p.enumerable,p.configurable=!!p.configurable,("value"in p||p.initializer)&&(p.writable=!0),p=u.slice().reverse().reduce((function(e,t){return t(a,l,e)||e}),p),d&&void 0!==p.initializer&&(p.value=p.initializer?p.initializer.call(d):void 0,p.initializer=void 0),void 0===p.initializer&&(Object.defineProperty(a,l,p),p=null),o=p,s)
var a,l,u,c,d,p
class m extends i.default{init(e){e.commands&&(e.commands=e.commands.map((e=>{if("string"==typeof e)return e
{let[t,i]=e
for(let e in i)i.hasOwnProperty(e)&&(this.getCommandOption(t,e).value=i[e])
return t}}))),super.init(e),this.commands=e.commands}getCommandOption(e,t){return this.commandOptions||={},this.commandOptions[e]||={},this.commandOptions[e][t]||=new n}populateCommandOptions(e){if(!e.commands)return
let t=[]
e.commands.forEach((e=>{if("string"!=typeof e&&(e=e[0]),this.commandOptions&&this.commandOptions[e]){let i=this.commandOptions[e],s={}
for(let e in i){if(!i.hasOwnProperty(e))continue
let t=i[e]
s[e]=t.value}t.push([e,s])}else t.push(e)})),e.commands=t}updateProperties(){let e=this.getProperties(r)
return e.id=this.id,this.populateCommandOptions(e),e}createProperties(){let e=this.getProperties(r)
return this.populateCommandOptions(e),e}workingCopy(){return m.create(this.createProperties())}}e.default=m})),define("discourse/plugins/discourse-ai/discourse/components/ai-bot-header-panel",["exports","@ember/component","@glimmer/component","@ember/object","@ember/service","I18n","discourse/plugins/discourse-ai/discourse/lib/ai-bot-helper","@ember/template-factory"],(function(e,t,i,s,o,r,n,a){"use strict"
var l,u,c,d
function p(e,t,i,s){i&&Object.defineProperty(e,t,{enumerable:i.enumerable,configurable:i.configurable,writable:i.writable,value:i.initializer?i.initializer.call(s):void 0})}function m(e,t){(function(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.add(e)}function g(e,t,i,s,o){var r={}
return Object.keys(s).forEach((function(e){r[e]=s[e]})),r.enumerable=!!r.enumerable,r.configurable=!!r.configurable,("value"in r||r.initializer)&&(r.writable=!0),r=i.slice().reverse().reduce((function(i,s){return s(e,t,i)||i}),r),o&&void 0!==r.initializer&&(r.value=r.initializer?r.initializer.call(o):void 0,r.initializer=void 0),void 0===r.initializer&&(Object.defineProperty(e,t,r),r=null),r}Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
const h=(0,a.createTemplateFactory)({id:"90vXLYKC",block:'[[[10,0],[14,0,"bot-panel ai-bot-available-bot-options"],[12],[1,"\\n  "],[10,0],[14,0,"menu-panel drop-down"],[12],[1,"\\n    "],[10,0],[14,0,"panel-body"],[12],[1,"\\n      "],[10,0],[14,0,"panel-body-contents"],[12],[1,"\\n        "],[10,0],[14,0,"sidebar-hamburger-dropdown"],[12],[1,"\\n"],[42,[28,[37,1],[[28,[37,1],[[30,0,["botNames"]]],null]],null],null,[[[1,"            "],[8,[39,2],[[24,0,"btn-flat ai-bot-available-bot-content"]],[["@translatedTitle","@translatedLabel","@action"],[[30,1,["humanized"]],[30,1,["humanized"]],[28,[37,3],[[30,0],"composeMessageWithTargetBot",[30,1,["modelName"]]],null]]],null],[1,"\\n"]],[1]],null],[1,"        "],[13],[1,"\\n      "],[13],[1,"\\n    "],[13],[1,"\\n  "],[13],[1,"\\n"],[13]],["bot"],false,["each","-track-array","d-button","action"]]',moduleName:"discourse/plugins/discourse-ai/discourse/components/ai-bot-header-panel.hbs",isStrictMode:!1})
let b=e.default=(d=new WeakSet,l=class extends i.default{constructor(){super(...arguments),m(this,d),p(this,"siteSettings",u,this),p(this,"composer",c,this)}composeMessageWithTargetBot(e){(function(e,t,i){if(!t.has(e))throw new TypeError("attempted to get private field on non-instance")
return i})(this,d,f).call(this,e)}get botNames(){return this.enabledBotOptions.map((e=>({humanized:r.default.t(`discourse_ai.ai_bot.bot_names.${e}`),modelName:e})))}get enabledBotOptions(){return this.siteSettings.ai_bot_enabled_chat_bots.split("|")}},u=g(l.prototype,"siteSettings",[o.inject],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),c=g(l.prototype,"composer",[o.inject],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),g(l.prototype,"composeMessageWithTargetBot",[s.action],Object.getOwnPropertyDescriptor(l.prototype,"composeMessageWithTargetBot"),l.prototype),l)
function f(e){this.args.closePanel(),(0,n.composeAiBotMessage)(e,this.composer)}(0,t.setComponentTemplate)(h,b)})),define("discourse/plugins/discourse-ai/discourse/components/ai-command-selector",["exports","@ember/object","select-kit/components/multi-select"],(function(e,t,i){"use strict"
Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
e.default=i.default.extend({_modelDisabledChanged:(0,t.observer)("attrs.disabled",(function(){this.selectKit.options.set("disabled",this.get("attrs.disabled.value"))})),content:(0,t.computed)((function(){return this.commands})),value:"",selectKitOptions:{filterable:!0}})})),define("discourse/plugins/discourse-ai/discourse/components/ai-helper-custom-prompt",["exports","@glimmer/component","@glimmer/tracking","@ember/component","@ember/helper","@ember/object","@ember/render-modifiers/modifiers/did-insert","discourse/components/d-button","discourse-common/helpers/i18n","truth-helpers/helpers/not","@ember/template-factory"],(function(e,t,i,s,o,r,n,a,l,u,c){"use strict"
var d,p,m
function g(e,t,i,s,o){var r={}
return Object.keys(s).forEach((function(e){r[e]=s[e]})),r.enumerable=!!r.enumerable,r.configurable=!!r.configurable,("value"in r||r.initializer)&&(r.writable=!0),r=i.slice().reverse().reduce((function(i,s){return s(e,t,i)||i}),r),o&&void 0!==r.initializer&&(r.value=r.initializer?r.initializer.call(o):void 0,r.initializer=void 0),void 0===r.initializer&&(Object.defineProperty(e,t,r),r=null),r}Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
e.default=(m=class extends t.default{constructor(){var e,t,i,s
super(...arguments),e=this,t="_customPromptInput",s=this,(i=p)&&Object.defineProperty(e,t,{enumerable:i.enumerable,configurable:i.configurable,writable:i.writable,value:i.initializer?i.initializer.call(s):void 0})}setupCustomPrompt(){this._customPromptInput=document.querySelector(".ai-custom-prompt__input"),this._customPromptInput.focus()}sendInput(){return this.args.submit(this.args.promptArgs)}},(0,s.setComponentTemplate)((0,c.createTemplateFactory)({id:"R9H8RJGc",block:'[[[1,"\\n    "],[11,0],[24,0,"ai-custom-prompt"],[4,[32,0],[[30,0,["setupCustomPrompt"]]],null],[12],[1,"\\n      "],[8,[32,1],[[16,"placeholder",[28,[32,2],["discourse_ai.ai_helper.context_menu.custom_prompt.placeholder"],null]],[24,0,"ai-custom-prompt__input"]],[["@value","@enter"],[[30,1],[30,0,["sendInput"]]]],null],[1,"\\n\\n      "],[8,[32,3],[[24,0,"ai-custom-prompt__submit btn-primary"]],[["@icon","@action","@disabled"],["discourse-sparkles",[28,[32,4],[[30,2],[30,3]],null],[28,[32,5],[[30,1,["length"]]],null]]],null],[1,"\\n    "],[13],[1,"\\n  "]],["@value","@submit","@promptArgs"],false,[]]',moduleName:"/var/www/discourse/app/assets/javascripts/discourse/discourse/plugins/discourse-ai/discourse/components/ai-helper-custom-prompt.js",scope:()=>[n.default,s.Input,l.default,a.default,o.fn,u.default],isStrictMode:!0}),m),p=g((d=m).prototype,"_customPromptInput",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),g(d.prototype,"setupCustomPrompt",[r.action],Object.getOwnPropertyDescriptor(d.prototype,"setupCustomPrompt"),d.prototype),g(d.prototype,"sendInput",[r.action],Object.getOwnPropertyDescriptor(d.prototype,"sendInput"),d.prototype),d)})),define("discourse/plugins/discourse-ai/discourse/components/ai-helper-loading",["exports","discourse/components/d-button","discourse-common/helpers/i18n","@ember/template-factory","@ember/component","@ember/component/template-only"],(function(e,t,i,s,o,r){"use strict"
Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
const n=(0,o.setComponentTemplate)((0,s.createTemplateFactory)({id:"Av2n/cr8",block:'[[[1,"\\n  "],[10,0],[14,0,"ai-helper-context-menu__loading"],[12],[1,"\\n    "],[10,0],[14,0,"dot-falling"],[12],[13],[1,"\\n    "],[10,1],[12],[1,"\\n      "],[1,[28,[32,0],["discourse_ai.ai_helper.context_menu.loading"],null]],[1,"\\n    "],[13],[1,"\\n    "],[8,[32,1],[[24,0,"btn-flat cancel-request"]],[["@icon","@title","@action"],["times","discourse_ai.ai_helper.context_menu.cancel",[30,1]]],null],[1,"\\n  "],[13],[1,"\\n"]],["@cancel"],false,[]]',moduleName:"/var/www/discourse/app/assets/javascripts/discourse/discourse/plugins/discourse-ai/discourse/components/ai-helper-loading.js",scope:()=>[i.default,t.default],isStrictMode:!0}),(0,r.default)())
e.default=n})),define("discourse/plugins/discourse-ai/discourse/components/ai-persona-command-option-editor",["exports","@ember/component","@ember/template-factory","@ember/component/template-only"],(function(e,t,i,s){"use strict"
Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
const o=(0,t.setComponentTemplate)((0,i.createTemplateFactory)({id:"WHtmf9wt",block:'[[[1,"\\n  "],[10,0],[14,0,"control-group ai-persona-command-option-editor"],[12],[1,"\\n    "],[10,"label"],[12],[1,"\\n      "],[1,[30,1,["name"]]],[1,"\\n    "],[13],[1,"\\n    "],[10,0],[14,0,""],[12],[1,"\\n      "],[8,[32,0],null,[["@value"],[[30,1,["value","value"]]]],null],[1,"\\n    "],[13],[1,"\\n    "],[10,0],[14,0,"ai-persona-command-option-editor__instructions"],[12],[1,"\\n      "],[1,[30,1,["description"]]],[1,"\\n    "],[13],[1,"\\n  "],[13],[1,"\\n"]],["@option"],false,[]]',moduleName:"/var/www/discourse/app/assets/javascripts/discourse/discourse/plugins/discourse-ai/discourse/components/ai-persona-command-option-editor.js",scope:()=>[t.Input],isStrictMode:!0}),(0,s.default)())
e.default=o})),define("discourse/plugins/discourse-ai/discourse/components/ai-persona-command-options",["exports","@glimmer/component","discourse-i18n","discourse/plugins/discourse-ai/discourse/components/ai-persona-command-option-editor","@ember/template-factory","@ember/component"],(function(e,t,i,s,o,r){"use strict"
var n
Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
class a extends t.default{get showCommandOptions(){const e=this.args.allCommands
return!!e&&this.commandNames.any((t=>e.find((e=>e.id===t))?.options))}get commandNames(){return this.args.commands?this.args.commands.map((e=>"string"==typeof e?e:e[0])):[]}get commandOptions(){if(!this.args.commands)return[]
const e=this.args.allCommands
if(!e)return[]
const t=[]
return this.commandNames.forEach((i=>{const s=e.find((e=>e.id===i)),o=s?.name,r=s?.options
if(r){const e=Object.keys(r).map((e=>{const t=this.args.persona.getCommandOption(i,e)
return Object.assign({},r[e],{id:e,value:t})}))
t.push({commandName:o,options:e})}})),t}}e.default=a,n=a,(0,r.setComponentTemplate)((0,o.createTemplateFactory)({id:"4ZSHKwgK",block:'[[[1,"\\n"],[41,[30,0,["showCommandOptions"]],[[[1,"      "],[10,0],[14,0,"control-group"],[12],[1,"\\n        "],[10,"label"],[12],[1,[28,[32,0,["t"]],["discourse_ai.ai_persona.command_options"],null]],[13],[1,"\\n        "],[10,0],[12],[1,"\\n"],[42,[28,[31,2],[[28,[31,2],[[30,0,["commandOptions"]]],null]],null],null,[[[1,"            "],[10,0],[14,0,"ai-persona-editor__command-options"],[12],[1,"\\n              "],[10,0],[14,0,"ai-persona-editor__command-options-name"],[12],[1,"\\n                "],[1,[30,1,["commandName"]]],[1,"\\n              "],[13],[1,"\\n              "],[10,0],[14,0,"ai-persona-editor__command-option-options"],[12],[1,"\\n"],[42,[28,[31,2],[[28,[31,2],[[30,1,["options"]]],null]],null],null,[[[1,"                  "],[8,[32,1],null,[["@option"],[[30,2]]],null],[1,"\\n"]],[2]],null],[1,"              "],[13],[1,"\\n            "],[13],[1,"\\n"]],[1]],null],[1,"        "],[13],[1,"\\n      "],[13],[1,"\\n"]],[]],null],[1,"  "]],["commandOption","option"],false,["if","each","-track-array"]]',moduleName:"/var/www/discourse/app/assets/javascripts/discourse/discourse/plugins/discourse-ai/discourse/components/ai-persona-command-options.js",scope:()=>[i.default,s.default],isStrictMode:!0}),n)})),define("discourse/plugins/discourse-ai/discourse/components/ai-persona-editor",["exports","@glimmer/component","@glimmer/tracking","@ember/component","@ember/modifier","@ember/object","@ember/render-modifiers/modifiers/did-insert","@ember/render-modifiers/modifiers/did-update","@ember/runloop","@ember/service","discourse/components/d-button","discourse/components/d-textarea","discourse/components/d-toggle-switch","discourse/lib/ajax-error","discourse/models/group","discourse-i18n","select-kit/components/group-chooser","float-kit/components/d-tooltip","discourse/plugins/discourse-ai/discourse/components/ai-command-selector","discourse/plugins/discourse-ai/discourse/components/ai-persona-command-options","@ember/template-factory"],(function(e,t,i,s,o,r,n,a,l,u,c,d,p,m,g,h,b,f,y,_,v){"use strict"
var w,S,j,P,O,z,T,x,A,k,M
function E(e,t,i,s){i&&Object.defineProperty(e,t,{enumerable:i.enumerable,configurable:i.configurable,writable:i.writable,value:i.initializer?i.initializer.call(s):void 0})}function C(e,t){(function(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.add(e)}function I(e,t,i){if(!t.has(e))throw new TypeError("attempted to get private field on non-instance")
return i}function N(e,t,i,s,o){var r={}
return Object.keys(s).forEach((function(e){r[e]=s[e]})),r.enumerable=!!r.enumerable,r.configurable=!!r.configurable,("value"in r||r.initializer)&&(r.writable=!0),r=i.slice().reverse().reduce((function(i,s){return s(e,t,i)||i}),r),o&&void 0!==r.initializer&&(r.value=r.initializer?r.initializer.call(o):void 0,r.initializer=void 0),void 0===r.initializer&&(Object.defineProperty(e,t,r),r=null),r}Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
e.default=(M=new WeakSet,k=class extends t.default{constructor(){super(...arguments),C(this,M),E(this,"router",S,this),E(this,"store",j,this),E(this,"dialog",P,this),E(this,"toasts",O,this),E(this,"allGroups",z,this),E(this,"isSaving",T,this),E(this,"editingModel",x,this),E(this,"showDelete",A,this)}updateModel(){this.editingModel=this.args.model.workingCopy(),this.showDelete=!this.args.model.isNew&&!this.args.model.system}async updateAllGroups(){this.allGroups=await g.default.findAll()}async save(){const e=this.args.model.isNew
this.isSaving=!0
const t=this.args.model.workingCopy()
this.args.model.setProperties(this.editingModel)
try{await this.args.model.save(),I(this,M,R).call(this),e?(this.args.personas.addObject(this.args.model),this.router.transitionTo("adminPlugins.discourse-ai.ai-personas.show",this.args.model)):this.toasts.success({data:{message:h.default.t("discourse_ai.ai_persona.saved")},duration:2e3})}catch(i){this.args.model.setProperties(t),(0,m.popupAjaxError)(i)}finally{(0,l.later)((()=>{this.isSaving=!1}),1e3)}}delete(){return this.dialog.confirm({message:h.default.t("discourse_ai.ai_persona.confirm_delete"),didConfirm:()=>this.args.model.destroyRecord().then((()=>{this.args.personas.removeObject(this.args.model),this.router.transitionTo("adminPlugins.discourse-ai.ai-personas.index")}))})}updateAllowedGroups(e){this.editingModel.set("allowed_group_ids",e)}async toggleEnabled(){if(this.args.model.set("enabled",!this.args.model.enabled),this.editingModel.set("enabled",this.args.model.enabled),!this.args.model.isNew)try{await this.args.model.update({enabled:this.args.model.enabled})}catch(e){(0,m.popupAjaxError)(e)}}async togglePriority(){if(this.args.model.set("priority",!this.args.model.priority),this.editingModel.set("priority",this.args.model.priority),!this.args.model.isNew)try{await this.args.model.update({priority:this.args.model.priority}),I(this,M,R).call(this)}catch(e){(0,m.popupAjaxError)(e)}}},(0,s.setComponentTemplate)((0,v.createTemplateFactory)({id:"2JXvYGjy",block:'[[[1,"\\n    "],[11,"form"],[24,0,"form-horizontal ai-persona-editor"],[4,[32,0],[[30,0,["updateModel"]],[30,1,["id"]]],null],[4,[32,1],[[30,0,["updateModel"]],[30,1,["id"]]],null],[4,[32,1],[[30,0,["updateAllGroups"]],[30,1,["id"]]],null],[12],[1,"\\n      "],[10,0],[14,0,"control-group"],[12],[1,"\\n        "],[8,[32,2],[[24,0,"ai-persona-editor__enabled"],[4,[32,3],["click",[30,0,["toggleEnabled"]]],null]],[["@state","@label"],[[30,1,["enabled"]],"discourse_ai.ai_persona.enabled"]],null],[1,"\\n      "],[13],[1,"\\n      "],[10,0],[14,0,"control-group ai-persona-editor__priority"],[12],[1,"\\n        "],[8,[32,2],[[24,0,"ai-persona-editor__priority"],[4,[32,3],["click",[30,0,["togglePriority"]]],null]],[["@state","@label"],[[30,1,["priority"]],"discourse_ai.ai_persona.priority"]],null],[1,"\\n        "],[8,[32,4],null,[["@icon","@content"],["question-circle",[28,[32,5,["t"]],["discourse_ai.ai_persona.priority_help"],null]]],null],[1,"\\n      "],[13],[1,"\\n      "],[10,0],[14,0,"control-group"],[12],[1,"\\n        "],[10,"label"],[12],[1,[28,[32,5,["t"]],["discourse_ai.ai_persona.name"],null]],[13],[1,"\\n        "],[8,[32,6],[[24,0,"ai-persona-editor__name"],[16,"disabled",[30,0,["editingModel","system"]]]],[["@type","@value"],["text",[30,0,["editingModel","name"]]]],null],[1,"\\n      "],[13],[1,"\\n      "],[10,0],[14,0,"control-group"],[12],[1,"\\n        "],[10,"label"],[12],[1,[28,[32,5,["t"]],["discourse_ai.ai_persona.description"],null]],[13],[1,"\\n        "],[8,[32,7],[[24,0,"ai-persona-editor__description"],[16,"disabled",[30,0,["editingModel","system"]]]],[["@value"],[[30,0,["editingModel","description"]]]],null],[1,"      "],[13],[1,"\\n      "],[10,0],[14,0,"control-group"],[12],[1,"\\n        "],[10,"label"],[12],[1,[28,[32,5,["t"]],["discourse_ai.ai_persona.commands"],null]],[13],[1,"\\n        "],[8,[32,8],[[24,0,"ai-persona-editor__commands"]],[["@value","@disabled","@commands"],[[30,0,["editingModel","commands"]],[30,0,["editingModel","system"]],[30,2,["resultSetMeta","commands"]]]],null],[1,"\\n      "],[13],[1,"\\n"],[41,[51,[30,0,["editingModel","system"]]],[[[1,"        "],[8,[32,9],null,[["@persona","@commands","@allCommands"],[[30,0,["editingModel"]],[30,0,["editingModel","commands"]],[30,2,["resultSetMeta","commands"]]]],null],[1,"\\n"]],[]],null],[1,"      "],[10,0],[14,0,"control-group"],[12],[1,"\\n        "],[10,"label"],[12],[1,[28,[32,5,["t"]],["discourse_ai.ai_persona.allowed_groups"],null]],[13],[1,"\\n        "],[8,[32,10],null,[["@value","@content","@onChange"],[[30,0,["editingModel","allowed_group_ids"]],[30,0,["allGroups"]],[30,0,["updateAllowedGroups"]]]],null],[1,"\\n      "],[13],[1,"\\n      "],[10,0],[14,0,"control-group"],[12],[1,"\\n        "],[10,"label"],[14,"for","ai-persona-editor__system_prompt"],[12],[1,[28,[32,5,["t"]],["discourse_ai.ai_persona.system_prompt"],null]],[13],[1,"\\n        "],[8,[32,7],[[24,0,"ai-persona-editor__system_prompt"],[16,"disabled",[30,0,["editingModel","system"]]]],[["@value"],[[30,0,["editingModel","system_prompt"]]]],null],[1,"      "],[13],[1,"\\n      "],[10,0],[14,0,"control-group ai-persona-editor__action_panel"],[12],[1,"\\n        "],[8,[32,11],[[24,0,"btn-primary ai-persona-editor__save"]],[["@action","@disabled"],[[30,0,["save"]],[30,0,["isSaving"]]]],[["default"],[[[[1,[28,[32,5,["t"]],["discourse_ai.ai_persona.save"],null]]],[]]]]],[1,"\\n"],[41,[30,0,["showDelete"]],[[[1,"          "],[8,[32,11],[[24,0,"btn-danger ai-persona-editor__delete"]],[["@action"],[[30,0,["delete"]]]],[["default"],[[[[1,"\\n            "],[1,[28,[32,5,["t"]],["discourse_ai.ai_persona.delete"],null]],[1,"\\n          "]],[]]]]],[1,"\\n"]],[]],null],[1,"      "],[13],[1,"\\n    "],[13],[1,"\\n  "]],["@model","@personas"],false,["unless","if"]]',moduleName:"/var/www/discourse/app/assets/javascripts/discourse/discourse/plugins/discourse-ai/discourse/components/ai-persona-editor.js",scope:()=>[a.default,n.default,p.default,o.on,f.default,h.default,s.Input,d.default,y.default,_.default,b.default,c.default],isStrictMode:!0}),k),S=N((w=k).prototype,"router",[u.inject],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),j=N(w.prototype,"store",[u.inject],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),P=N(w.prototype,"dialog",[u.inject],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),O=N(w.prototype,"toasts",[u.inject],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),z=N(w.prototype,"allGroups",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),T=N(w.prototype,"isSaving",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),x=N(w.prototype,"editingModel",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),A=N(w.prototype,"showDelete",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),N(w.prototype,"updateModel",[r.action],Object.getOwnPropertyDescriptor(w.prototype,"updateModel"),w.prototype),N(w.prototype,"updateAllGroups",[r.action],Object.getOwnPropertyDescriptor(w.prototype,"updateAllGroups"),w.prototype),N(w.prototype,"save",[r.action],Object.getOwnPropertyDescriptor(w.prototype,"save"),w.prototype),N(w.prototype,"delete",[r.action],Object.getOwnPropertyDescriptor(w.prototype,"delete"),w.prototype),N(w.prototype,"updateAllowedGroups",[r.action],Object.getOwnPropertyDescriptor(w.prototype,"updateAllowedGroups"),w.prototype),N(w.prototype,"toggleEnabled",[r.action],Object.getOwnPropertyDescriptor(w.prototype,"toggleEnabled"),w.prototype),N(w.prototype,"togglePriority",[r.action],Object.getOwnPropertyDescriptor(w.prototype,"togglePriority"),w.prototype),w)
function R(){const e=this.args.personas.toArray().sort(((e,t)=>e.priority&&!t.priority?-1:!e.priority&&t.priority?1:e.name.localeCompare(t.name)))
this.args.personas.clear(),this.args.personas.setObjects(e)}})),define("discourse/plugins/discourse-ai/discourse/components/ai-persona-list-editor",["exports","@glimmer/component","@glimmer/tracking","@ember/routing","discourse/helpers/concat-class","discourse/lib/text","discourse-common/helpers/d-icon","discourse-i18n","discourse/plugins/discourse-ai/discourse/components/ai-persona-editor","@ember/template-factory","@ember/component"],(function(e,t,i,s,o,r,n,a,l,u,c){"use strict"
var d,p,m
Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
e.default=(m=class extends t.default{constructor(){var e,t,i,s
super(...arguments),e=this,t="_noPersonaText",s=this,(i=p)&&Object.defineProperty(e,t,{enumerable:i.enumerable,configurable:i.configurable,writable:i.writable,value:i.initializer?i.initializer.call(s):void 0})}get noPersonaText(){if(null===this._noPersonaText){const e=a.default.t("discourse_ai.ai_persona.no_persona_selected");(0,r.cook)(e).then((e=>{this._noPersonaText=e}))}return this._noPersonaText}},(0,c.setComponentTemplate)((0,u.createTemplateFactory)({id:"ZGQwJcK9",block:'[[[1,"\\n    "],[10,0],[14,0,"ai-persona-list-editor__header"],[12],[1,"\\n      "],[10,"h3"],[12],[1,[28,[32,0,["t"]],["discourse_ai.ai_persona.title"],null]],[13],[1,"\\n"],[41,[51,[30,1,["isNew"]]],[[[1,"        "],[8,[32,1],[[24,0,"btn btn-primary"]],[["@route"],["adminPlugins.discourse-ai.ai-personas.new"]],[["default"],[[[[1,"\\n          "],[1,[28,[32,2],["plus"],null]],[1,"\\n          "],[10,1],[12],[1,[28,[32,0,["t"]],["discourse_ai.ai_persona.new"],null]],[13],[1,"\\n        "]],[]]]]],[1,"\\n"]],[]],null],[1,"    "],[13],[1,"\\n    "],[10,0],[14,0,"content-list ai-persona-list-editor"],[12],[1,"\\n      "],[10,"ul"],[12],[1,"\\n"],[42,[28,[31,2],[[28,[31,2],[[30,2]],null]],null],null,[[[1,"          "],[10,"li"],[15,0,[28,[32,3],[[52,[30,3,["enabled"]],"","diabled"],[52,[30,3,["priority"]],"priority"]],null]],[12],[1,"\\n            "],[8,[32,1],[[24,"current-when","true"]],[["@route","@model"],["adminPlugins.discourse-ai.ai-personas.show",[30,3]]],[["default"],[[[[1,[30,3,["name"]]],[1,"\\n            "]],[]]]]],[1,"\\n          "],[13],[1,"\\n"]],[3]],null],[1,"      "],[13],[1,"\\n    "],[13],[1,"\\n    "],[10,"section"],[14,0,"ai-persona-list-editor__current content-body"],[12],[1,"\\n"],[41,[30,1],[[[1,"        "],[8,[32,4],null,[["@model","@personas"],[[30,1],[30,2]]],null],[1,"\\n"]],[]],[[[1,"        "],[10,0],[14,0,"ai-persona-list-editor__empty"],[12],[1,"\\n          "],[1,[30,0,["noPersonaText"]]],[1,"\\n        "],[13],[1,"\\n"]],[]]],[1,"    "],[13],[1,"\\n  "]],["@currentPersona","@personas","persona"],false,["unless","each","-track-array","if"]]',moduleName:"/var/www/discourse/app/assets/javascripts/discourse/discourse/plugins/discourse-ai/discourse/components/ai-persona-list-editor.js",scope:()=>[a.default,s.LinkTo,n.default,o.default,l.default],isStrictMode:!0}),m),g=(d=m).prototype,h="_noPersonaText",b=[i.tracked],f={configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}},_={},Object.keys(f).forEach((function(e){_[e]=f[e]})),_.enumerable=!!_.enumerable,_.configurable=!!_.configurable,("value"in _||_.initializer)&&(_.writable=!0),_=b.slice().reverse().reduce((function(e,t){return t(g,h,e)||e}),_),y&&void 0!==_.initializer&&(_.value=_.initializer?_.initializer.call(y):void 0,_.initializer=void 0),void 0===_.initializer&&(Object.defineProperty(g,h,_),_=null),p=_,d)
var g,h,b,f,y,_})),define("discourse/plugins/discourse-ai/discourse/components/ai-split-topic-suggester",["exports","@glimmer/component","@glimmer/tracking","@ember/helper","@ember/modifier","@ember/object","@ember/service","discourse/components/d-button","discourse/helpers/category-badge","discourse/lib/ajax","discourse/lib/ajax-error","float-kit/components/d-menu","truth-helpers/helpers/eq","@ember/template-factory","@ember/component"],(function(e,t,i,s,o,r,n,a,l,u,c,d,p,m,g){"use strict"
var h,b,f,y,_,v,w
function S(e,t,i,s){i&&Object.defineProperty(e,t,{enumerable:i.enumerable,configurable:i.configurable,writable:i.writable,value:i.initializer?i.initializer.call(s):void 0})}function j(e,t,i){var s
return(t="symbol"==typeof(s=function(e,t){if("object"!=typeof e||!e)return e
var i=e[Symbol.toPrimitive]
if(void 0!==i){var s=i.call(e,t||"default")
if("object"!=typeof s)return s
throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(t,"string"))?s:String(s))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function P(e,t,i,s,o){var r={}
return Object.keys(s).forEach((function(e){r[e]=s[e]})),r.enumerable=!!r.enumerable,r.configurable=!!r.configurable,("value"in r||r.initializer)&&(r.writable=!0),r=i.slice().reverse().reduce((function(i,s){return s(e,t,i)||i}),r),o&&void 0!==r.initializer&&(r.value=r.initializer?r.initializer.call(o):void 0,r.initializer=void 0),void 0===r.initializer&&(Object.defineProperty(e,t,r),r=null),r}Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
e.default=(w=class extends t.default{constructor(){super(...arguments),S(this,"site",b,this),S(this,"menu",f,this),S(this,"suggestions",y,this),S(this,"loading",_,this),S(this,"icon",v,this),j(this,"SUGGESTION_TYPES",{title:"suggest_title",category:"suggest_category",tag:"suggest_tags"})}get input(){return this.args.selectedPosts.map((e=>e.cooked)).join("\n")}get disabled(){return this.loading||this.suggestions.length>0}loadSuggestions(){this.loading||this.suggestions.length>0||(this.loading=!0,(0,u.ajax)(`/discourse-ai/ai-helper/${this.args.mode}`,{method:"POST",data:{text:this.input}}).then((e=>{if(this.args.mode===this.SUGGESTION_TYPES.title)this.suggestions=e.suggestions
else if(this.args.mode===this.SUGGESTION_TYPES.category){const t=e.assistant.map((e=>e.name)),i=this.site.categories.filter((e=>t.includes(e.name.toLowerCase())))
this.suggestions=i}else this.suggestions=e.assistant.map((e=>e.name))})).catch(c.popupAjaxError).finally((()=>{this.loading=!1})))}applySuggestion(e,t){if(this.args.mode){if(this.args.mode===this.SUGGESTION_TYPES.title)return this.args.updateAction(e),t.close()
if(this.args.mode===this.SUGGESTION_TYPES.category)return this.args.updateAction(e.id),t.close()
if(this.args.mode===this.SUGGESTION_TYPES.tag){if(this.args.currentValue)if(Array.isArray(this.args.currentValue)){const t=[...this.args.currentValue,e]
this.args.updateAction([...new Set(t)])}else{const t=[this.args.currentValue,e]
this.args.updateAction([...new Set(t)])}else this.args.updateAction(e)
return t.close()}}}},(0,g.setComponentTemplate)((0,m.createTemplateFactory)({id:"OK/TJTRS",block:'[[[1,"\\n"],[41,[30,0,["loading"]],[[[1,"      "],[8,[32,0],[[24,0,"ai-split-topic-loading-placeholder"]],[["@disabled","@icon"],[true,"spinner"]],null],[1,"\\n"]],[]],null],[1,"    "],[8,[32,1],[[24,0,"ai-split-topic-suggestion-button"],[16,"data-suggestion-mode",[30,1]],[4,[32,2],["click",[30,0,["loadSuggestions"]]],null]],[["@icon","@interactive","@identifier"],["discourse-sparkles",true,"ai-split-topic-suggestion-menu"]],[["default"],[[[[1,"\\n      "],[10,"ul"],[14,0,"ai-split-topic-suggestion__results"],[12],[1,"\\n"],[41,[51,[30,0,["loading"]]],[[[42,[28,[31,3],[[28,[31,3],[[30,0,["suggestions"]]],null]],null],null,[[[41,[28,[32,3],[[30,1],"suggest_category"],null],[[[1,"              "],[11,"li"],[16,"data-name",[30,3,["name"]]],[16,"data-value",[30,3,["id"]]],[24,0,"ai-split-topic-suggestion__category-result"],[24,"role","button"],[4,[32,2],["click",[28,[32,4],[[30,0,["applySuggestion"]],[30,3],[30,2]],null]],null],[12],[1,"\\n                "],[1,[28,[32,5],[[30,3]],null]],[1,"\\n              "],[13],[1,"\\n"]],[]],[[[1,"              "],[10,"li"],[15,"data-name",[30,3]],[15,"data-value",[30,4]],[12],[1,"\\n                "],[8,[32,0],null,[["@translatedLabel","@action"],[[30,3],[28,[32,4],[[30,0,["applySuggestion"]],[30,3],[30,2]],null]]],null],[1,"\\n              "],[13],[1,"\\n"]],[]]]],[3,4]],null]],[]],null],[1,"      "],[13],[1,"\\n    "]],[2]]]]],[1,"\\n  "]],["@mode","menu","suggestion","index"],false,["if","unless","each","-track-array"]]',moduleName:"/var/www/discourse/app/assets/javascripts/discourse/discourse/plugins/discourse-ai/discourse/components/ai-split-topic-suggester.js",scope:()=>[a.default,d.default,o.on,p.default,s.fn,l.default],isStrictMode:!0}),w),b=P((h=w).prototype,"site",[n.inject],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),f=P(h.prototype,"menu",[n.inject],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),y=P(h.prototype,"suggestions",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),_=P(h.prototype,"loading",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),v=P(h.prototype,"icon",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return"discourse-sparkles"}}),P(h.prototype,"loadSuggestions",[r.action],Object.getOwnPropertyDescriptor(h.prototype,"loadSuggestions"),h.prototype),P(h.prototype,"applySuggestion",[r.action],Object.getOwnPropertyDescriptor(h.prototype,"applySuggestion"),h.prototype),h)})),define("discourse/plugins/discourse-ai/discourse/components/ai-suggestion-dropdown",["exports","@glimmer/component","@glimmer/tracking","@ember/helper","@ember/object","@ember/render-modifiers/modifiers/did-insert","@ember/service","discourse/components/d-button","discourse/lib/ajax","discourse/lib/ajax-error","discourse-common/utils/decorators","I18n","@ember/template-factory","@ember/component"],(function(e,t,i,s,o,r,n,a,l,u,c,d,p,m){"use strict"
var g,h,b,f,y,_,v,w,S,j,P,O,z,T,x
function A(e,t,i,s){i&&Object.defineProperty(e,t,{enumerable:i.enumerable,configurable:i.configurable,writable:i.writable,value:i.initializer?i.initializer.call(s):void 0})}function k(e,t){(function(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.add(e)}function M(e,t,i){var s
return(t="symbol"==typeof(s=function(e,t){if("object"!=typeof e||!e)return e
var i=e[Symbol.toPrimitive]
if(void 0!==i){var s=i.call(e,t||"default")
if("object"!=typeof s)return s
throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(t,"string"))?s:String(s))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function E(e,t,i){if(!t.has(e))throw new TypeError("attempted to get private field on non-instance")
return i}function C(e,t,i,s,o){var r={}
return Object.keys(s).forEach((function(e){r[e]=s[e]})),r.enumerable=!!r.enumerable,r.configurable=!!r.configurable,("value"in r||r.initializer)&&(r.writable=!0),r=i.slice().reverse().reduce((function(i,s){return s(e,t,i)||i}),r),o&&void 0!==r.initializer&&(r.value=r.initializer?r.initializer.call(o):void 0,r.initializer=void 0),void 0===r.initializer&&(Object.defineProperty(e,t,r),r=null),r}Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
e.default=(O=new WeakSet,z=new WeakSet,T=new WeakSet,x=new WeakSet,P=class extends t.default{constructor(){super(...arguments),k(this,x),k(this,T),k(this,z),k(this,O),A(this,"dialog",h,this),A(this,"siteSettings",b,this),A(this,"composer",f,this),A(this,"loading",y,this),A(this,"showMenu",_,this),A(this,"generatedSuggestions",v,this),A(this,"suggestIcon",w,this),A(this,"showErrors",S,this),A(this,"error",j,this),M(this,"SUGGESTION_TYPES",{title:"suggest_title",category:"suggest_category",tag:"suggest_tags"})}willDestroy(){super.willDestroy(...arguments),document.removeEventListener("click",this.onClickOutside)}get showAIButton(){const e=this.composer.model.replyLength>40,t=document.querySelector(".composer-fields")
return t&&(e?t.classList.add("showing-ai-suggestions"):t.classList.remove("showing-ai-suggestions")),e}get disableSuggestionButton(){return this.loading}applyClasses(){this.showAIButton?document.querySelector(".composer-fields")?.classList.add("showing-ai-suggestions"):document.querySelector(".composer-fields")?.classList.remove("showing-ai-suggestions")}onClickOutside(e){const t=document.querySelector(".ai-title-suggestions-menu")
if(e.target!==t)return E(this,O,I).call(this)}handleClickOutside(){document.addEventListener("click",this.onClickOutside)}applySuggestion(e){if(!this.args.mode)return
const t=this.args?.composer
if(t){if(this.args.mode===this.SUGGESTION_TYPES.title)return t.set("title",e),E(this,O,I).call(this)
if(this.args.mode===this.SUGGESTION_TYPES.category){const i=this.composer.categories.find((t=>t.slug===e)).id
return t.set("categoryId",i),E(this,O,I).call(this)}this.args.mode===this.SUGGESTION_TYPES.tag&&E(this,z,N).call(this,e,t)}}async performSuggestion(){if(this.args.mode)return 0===this.composer.model.replyLength?this.dialog.alert(d.default.t("discourse_ai.ai_helper.missing_content")):(this.loading=!0,this.suggestIcon="spinner",(0,l.ajax)(`/discourse-ai/ai-helper/${this.args.mode}`,{method:"POST",data:{text:this.composer.model.reply}}).then((e=>{E(this,x,D).call(this,e,this.args.mode)})).catch(u.popupAjaxError).finally((()=>{this.loading=!1,this.suggestIcon="sync-alt",this.showMenu=!0,"suggest_category"===this.args.mode&&document.querySelector(".category-input")?.classList.add("showing-ai-suggestion-menu")})))}},(0,m.setComponentTemplate)((0,p.createTemplateFactory)({id:"Cn6HectJ",block:'[[[1,"\\n"],[41,[30,0,["showAIButton"]],[[[1,"      "],[8,[32,0],[[16,0,[29,["suggestion-button ",[52,[30,0,["loading"]],"is-loading"]]]],[17,1]],[["@icon","@title","@action","@disabled"],[[30,0,["suggestIcon"]],"discourse_ai.ai_helper.suggest",[30,0,["performSuggestion"]],[30,0,["disableSuggestionButton"]]]],null],[1,"\\n"]],[]],null],[1,"\\n"],[41,[30,0,["showMenu"]],[[[1,"      "],[11,"ul"],[24,0,"popup-menu ai-suggestions-menu"],[4,[32,1],[[30,0,["handleClickOutside"]]],null],[12],[1,"\\n"],[41,[30,0,["showErrors"]],[[[1,"          "],[10,"li"],[14,0,"ai-suggestions-menu__errors"],[12],[1,[30,0,["error"]]],[13],[1,"\\n"]],[]],null],[42,[28,[31,2],[[28,[31,2],[[30,0,["generatedSuggestions"]]],null]],null],null,[[[1,"          "],[10,"li"],[15,"data-name",[30,2]],[15,"data-value",[30,3]],[12],[1,"\\n            "],[8,[32,0],[[24,0,"popup-menu-btn"]],[["@translatedLabel","@action"],[[30,2],[28,[32,2],[[30,0,["applySuggestion"]],[30,2]],null]]],null],[1,"\\n          "],[13],[1,"\\n"]],[2,3]],null],[1,"      "],[13],[1,"\\n"]],[]],null],[1,"  "]],["&attrs","suggestion","index"],false,["if","each","-track-array"]]',moduleName:"/var/www/discourse/app/assets/javascripts/discourse/discourse/plugins/discourse-ai/discourse/components/ai-suggestion-dropdown.js",scope:()=>[a.default,r.default,s.fn],isStrictMode:!0}),P),h=C((g=P).prototype,"dialog",[n.inject],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),b=C(g.prototype,"siteSettings",[n.inject],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),f=C(g.prototype,"composer",[n.inject],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),y=C(g.prototype,"loading",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),_=C(g.prototype,"showMenu",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),v=C(g.prototype,"generatedSuggestions",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),w=C(g.prototype,"suggestIcon",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return"discourse-sparkles"}}),S=C(g.prototype,"showErrors",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),j=C(g.prototype,"error",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return""}}),C(g.prototype,"applyClasses",[o.action],Object.getOwnPropertyDescriptor(g.prototype,"applyClasses"),g.prototype),C(g.prototype,"onClickOutside",[c.bind],Object.getOwnPropertyDescriptor(g.prototype,"onClickOutside"),g.prototype),C(g.prototype,"handleClickOutside",[o.action],Object.getOwnPropertyDescriptor(g.prototype,"handleClickOutside"),g.prototype),C(g.prototype,"applySuggestion",[o.action],Object.getOwnPropertyDescriptor(g.prototype,"applySuggestion"),g.prototype),C(g.prototype,"performSuggestion",[o.action],Object.getOwnPropertyDescriptor(g.prototype,"performSuggestion"),g.prototype),g)
function I(){this.showMenu&&"suggest_category"===this.args.mode&&document.querySelector(".category-input")?.classList.remove("showing-ai-suggestion-menu"),this.suggestIcon="discourse-sparkles",this.showMenu=!1,this.showErrors=!1,this.errors=""}function N(e,t){const i=this.siteSettings.max_tags_per_topic
if(!t.tags)return t.set("tags",[e]),void(this.generatedSuggestions=this.generatedSuggestions.filter((t=>t!==e)))
const s=t.tags
return s?.length>=i?(this.showErrors=!0,void(this.error=d.default.t("select_kit.max_content_reached",{count:i}))):(s.push(e),t.set("tags",[...s]),this.generatedSuggestions=this.generatedSuggestions.filter((t=>t!==e)))}function R(){return this.args.composer?.tags&&this.args.composer?.tags.length>0}function D(e,t){if(t===this.SUGGESTION_TYPES.title)return this.generatedSuggestions=e.suggestions
const i=e.assistant.map((e=>e.name))
return t===this.SUGGESTION_TYPES.tag&&E(this,T,R).call(this)?this.generatedSuggestions=i.filter((e=>!this.args.composer.tags.includes(e))):this.generatedSuggestions=i}})),define("discourse/plugins/discourse-ai/discourse/components/modal/diff-modal",["exports","@glimmer/component","@ember/object","@ember/template","discourse/components/d-button","discourse/components/d-modal","discourse-common/helpers/i18n","@ember/template-factory","@ember/component"],(function(e,t,i,s,o,r,n,a,l){"use strict"
var u,c
function d(e,t,i,s,o){var r={}
return Object.keys(s).forEach((function(e){r[e]=s[e]})),r.enumerable=!!r.enumerable,r.configurable=!!r.configurable,("value"in r||r.initializer)&&(r.writable=!0),r=i.slice().reverse().reduce((function(i,s){return s(e,t,i)||i}),r),o&&void 0!==r.initializer&&(r.value=r.initializer?r.initializer.call(o):void 0,r.initializer=void 0),void 0===r.initializer&&(Object.defineProperty(e,t,r),r=null),r}Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
e.default=(c=class extends t.default{triggerConfirmChanges(){this.args.closeModal(),this.args.confirm()}triggerRevertChanges(){this.args.closeModal(),this.args.revert()}},(0,l.setComponentTemplate)((0,a.createTemplateFactory)({id:"tqHStVL1",block:'[[[1,"\\n    "],[8,[32,0],[[24,0,"composer-ai-helper-modal"]],[["@title","@closeModal"],[[28,[32,1],["discourse_ai.ai_helper.context_menu.changes"],null],[30,1]]],[["body","footer"],[[[[1,"\\n"],[41,[30,2],[[[1,"          "],[1,[28,[32,2],[[30,2]],null]],[1,"\\n"]],[]],[[[1,"          "],[10,0],[14,0,"composer-ai-helper-modal__old-value"],[12],[1,"\\n            "],[1,[30,3]],[1,"\\n          "],[13],[1,"\\n\\n          "],[10,0],[14,0,"composer-ai-helper-modal__new-value"],[12],[1,"\\n            "],[1,[30,4]],[1,"\\n          "],[13],[1,"\\n"]],[]]],[1,"      "]],[]],[[[1,"\\n        "],[8,[32,3],[[24,0,"btn-primary confirm"]],[["@action","@label"],[[30,0,["triggerConfirmChanges"]],"discourse_ai.ai_helper.context_menu.confirm"]],null],[1,"\\n        "],[8,[32,3],[[24,0,"btn-flat"]],[["@action","@label"],[[30,0,["triggerRevertChanges"]],"discourse_ai.ai_helper.context_menu.revert"]],null],[1,"\\n      "]],[]]]]],[1,"\\n  "]],["@closeModal","@diff","@oldValue","@newValue"],false,["if"]]',moduleName:"/var/www/discourse/app/assets/javascripts/discourse/discourse/plugins/discourse-ai/discourse/components/modal/diff-modal.js",scope:()=>[r.default,n.default,s.htmlSafe,o.default],isStrictMode:!0}),c),d((u=c).prototype,"triggerConfirmChanges",[i.action],Object.getOwnPropertyDescriptor(u.prototype,"triggerConfirmChanges"),u.prototype),d(u.prototype,"triggerRevertChanges",[i.action],Object.getOwnPropertyDescriptor(u.prototype,"triggerRevertChanges"),u.prototype),u)})),define("discourse/plugins/discourse-ai/discourse/components/modal/share-modal",["exports","@glimmer/component","@glimmer/tracking","@ember/component","@ember/modifier","@ember/object","@ember/template","discourse/components/d-button","discourse/components/d-modal","discourse-common/helpers/i18n","discourse-common/lib/later","discourse-i18n","discourse/plugins/discourse-ai/discourse/lib/copy-conversation","@ember/template-factory"],(function(e,t,i,s,o,r,n,a,l,u,c,d,p,m){"use strict"
var g,h,b,f,y,_,v
function w(e,t,i,s){i&&Object.defineProperty(e,t,{enumerable:i.enumerable,configurable:i.configurable,writable:i.writable,value:i.initializer?i.initializer.call(s):void 0})}function S(e,t,i,s,o){var r={}
return Object.keys(s).forEach((function(e){r[e]=s[e]})),r.enumerable=!!r.enumerable,r.configurable=!!r.configurable,("value"in r||r.initializer)&&(r.writable=!0),r=i.slice().reverse().reduce((function(i,s){return s(e,t,i)||i}),r),o&&void 0!==r.initializer&&(r.value=r.initializer?r.initializer.call(o):void 0,r.initializer=void 0),void 0===r.initializer&&(Object.defineProperty(e,t,r),r=null),r}Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
e.default=(v=class extends t.default{constructor(){super(...arguments),w(this,"contextValue",h,this),w(this,"htmlContext",b,this),w(this,"maxContext",f,this),w(this,"allPosts",y,this),w(this,"justCopiedText",_,this)
const e=this.args.model.topic.get("postStream")
let t=[]
for(let i=1;i<=this.args.model.post_number;i++)t.push(i)
this.allPosts=t.map((t=>{let i=e.findPostIdForPostNumber(t)
if(i)return e.findLoadedPost(i)})).filter((e=>e)),this.maxContext=this.allPosts.length/2,this.contextValue=1,this.updateHtmlContext()}updateHtmlContext(){let e=[]
for(let t=this.allPosts.length-2*this.contextValue;t<this.allPosts.length;t++){const i=this.allPosts[t]
e.push(`<p><b>${i.username}:</b></p>`),e.push(i.cooked)}this.htmlContext=(0,n.htmlSafe)(e.join("\n"))}async copyContext(){const e=this.allPosts[this.allPosts.length-2*this.contextValue].post_number,t=this.args.model.post_number
await(0,p.default)(this.args.model.topic,e,t),this.justCopiedText=d.default.t("discourse_ai.ai_bot.conversation_shared"),(0,c.default)((()=>{this.justCopiedText=""}),2e3)}},(0,s.setComponentTemplate)((0,m.createTemplateFactory)({id:"pMctz3Jd",block:'[[[1,"\\n    "],[8,[32,0],[[24,0,"ai-share-modal"]],[["@title","@closeModal"],[[28,[32,1],["discourse_ai.ai_bot.share_modal.title"],null],[30,1]]],[["body","footer"],[[[[1,"\\n        "],[10,0],[14,0,"ai-share-modal__preview"],[12],[1,"\\n          "],[1,[30,0,["htmlContext"]]],[1,"\\n        "],[13],[1,"\\n      "]],[]],[[[1,"\\n        "],[10,0],[14,0,"ai-share-modal__slider"],[12],[1,"\\n          "],[8,[32,2],[[24,"min","1"],[16,"max",[30,0,["maxContext"]]],[4,[32,3],["change",[30,0,["updateHtmlContext"]]],null]],[["@type","@value"],["range",[30,0,["contextValue"]]]],null],[1,"\\n          "],[10,0],[14,0,"ai-share-modal__context"],[12],[1,"\\n            "],[1,[28,[32,1],["discourse_ai.ai_bot.share_modal.context"],null]],[1,"\\n            "],[1,[30,0,["contextValue"]]],[1,"\\n          "],[13],[1,"\\n        "],[13],[1,"\\n        "],[8,[32,4],[[24,0,"btn-primary confirm"]],[["@icon","@action","@label"],["copy",[30,0,["copyContext"]],"discourse_ai.ai_bot.share_modal.copy"]],null],[1,"\\n        "],[10,1],[14,0,"ai-share-modal__just-copied"],[12],[1,[30,0,["justCopiedText"]]],[13],[1,"\\n      "]],[]]]]],[1,"\\n  "]],["@closeModal"],false,[]]',moduleName:"/var/www/discourse/app/assets/javascripts/discourse/discourse/plugins/discourse-ai/discourse/components/modal/share-modal.js",scope:()=>[l.default,u.default,s.Input,o.on,a.default],isStrictMode:!0}),v),h=S((g=v).prototype,"contextValue",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1}}),b=S(g.prototype,"htmlContext",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return""}}),f=S(g.prototype,"maxContext",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),y=S(g.prototype,"allPosts",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),_=S(g.prototype,"justCopiedText",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return""}}),S(g.prototype,"updateHtmlContext",[r.action],Object.getOwnPropertyDescriptor(g.prototype,"updateHtmlContext"),g.prototype),S(g.prototype,"copyContext",[r.action],Object.getOwnPropertyDescriptor(g.prototype,"copyContext"),g.prototype),g)})),define("discourse/plugins/discourse-ai/discourse/components/modal/thumbnail-suggestions",["exports","@glimmer/component","@glimmer/tracking","@ember/object","discourse/components/d-button","discourse/components/d-modal","discourse/components/d-modal-cancel","discourse-common/helpers/i18n","discourse/plugins/discourse-ai/discourse/components/thumbnail-suggestion-item","@ember/template-factory","@ember/component"],(function(e,t,i,s,o,r,n,a,l,u,c){"use strict"
var d,p,m
function g(e,t,i,s,o){var r={}
return Object.keys(s).forEach((function(e){r[e]=s[e]})),r.enumerable=!!r.enumerable,r.configurable=!!r.configurable,("value"in r||r.initializer)&&(r.writable=!0),r=i.slice().reverse().reduce((function(i,s){return s(e,t,i)||i}),r),o&&void 0!==r.initializer&&(r.value=r.initializer?r.initializer.call(o):void 0,r.initializer=void 0),void 0===r.initializer&&(Object.defineProperty(e,t,r),r=null),r}Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
e.default=(m=class extends t.default{constructor(){var e,t,i,s
super(...arguments),e=this,t="selectedImages",s=this,(i=p)&&Object.defineProperty(e,t,{enumerable:i.enumerable,configurable:i.configurable,writable:i.writable,value:i.initializer?i.initializer.call(s):void 0})}get isDisabled(){return 0===this.selectedImages.length}addSelection(e){const t=`![${e.original_filename}|${e.width}x${e.height}](${e.short_url})`
this.selectedImages=[...this.selectedImages,t]}removeSelection(e){const t=`![${e.original_filename}|${e.width}x${e.height}](${e.short_url})`
this.selectedImages=this.selectedImages.filter((e=>{if(e!==t)return e}))}appendSelectedImages(){const e="\n\n"+this.selectedImages.join("\n"),t=document.querySelector(".d-editor-input")
t.setSelectionRange(t.value.length,t.value.length),t.focus(),document.execCommand("insertText",!1,e),this.args.closeModal()}},(0,c.setComponentTemplate)((0,u.createTemplateFactory)({id:"rVPkxzzs",block:'[[[1,"\\n    "],[8,[32,0],[[24,0,"thumbnail-suggestions-modal"]],[["@title","@closeModal"],[[28,[32,1],["discourse_ai.ai_helper.thumbnail_suggestions.title"],null],[30,1]]],[["body","footer"],[[[[1,"\\n        "],[10,0],[14,0,"ai-thumbnail-suggestions"],[12],[1,"\\n"],[42,[28,[31,1],[[28,[31,1],[[30,2]],null]],null],null,[[[1,"            "],[8,[32,2],null,[["@thumbnail","@addSelection","@removeSelection"],[[30,3],[30,0,["addSelection"]],[30,0,["removeSelection"]]]],null],[1,"\\n"]],[3]],null],[1,"        "],[13],[1,"\\n      "]],[]],[[[1,"\\n        "],[8,[32,3],[[24,0,"btn-primary create"]],[["@action","@label","@disabled"],[[30,0,["appendSelectedImages"]],"save",[30,0,["isDisabled"]]]],null],[1,"\\n        "],[8,[32,4],null,[["@close"],[[30,1]]],null],[1,"\\n      "]],[]]]]],[1,"\\n  "]],["@closeModal","@thumbnails","thumbnail"],false,["each","-track-array"]]',moduleName:"/var/www/discourse/app/assets/javascripts/discourse/discourse/plugins/discourse-ai/discourse/components/modal/thumbnail-suggestions.js",scope:()=>[r.default,a.default,l.default,o.default,n.default],isStrictMode:!0}),m),p=g((d=m).prototype,"selectedImages",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),g(d.prototype,"addSelection",[s.action],Object.getOwnPropertyDescriptor(d.prototype,"addSelection"),d.prototype),g(d.prototype,"removeSelection",[s.action],Object.getOwnPropertyDescriptor(d.prototype,"removeSelection"),d.prototype),g(d.prototype,"appendSelectedImages",[s.action],Object.getOwnPropertyDescriptor(d.prototype,"appendSelectedImages"),d.prototype),d)})),define("discourse/plugins/discourse-ai/discourse/components/model-accuracies",["exports","@ember/component","@ember/component/template-only","@ember/template-factory"],(function(e,t,i,s){"use strict"
Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
const o=(0,s.createTemplateFactory)({id:"r8usWg+W",block:'[[[41,[30,1],[[[1,"  "],[10,"table"],[14,0,"reviewable-scores"],[12],[1,"\\n    "],[10,"tbody"],[12],[1,"\\n"],[42,[28,[37,2],[[30,1]],null],null,[[[1,"        "],[10,"tr"],[12],[1,"\\n          "],[10,"td"],[14,"colspan","4"],[12],[1,[28,[35,3],["discourse_ai.reviewables.model_used"],null]],[13],[1,"\\n          "],[10,"td"],[14,"colspan","3"],[12],[1,[30,3]],[13],[1,"\\n          "],[10,"td"],[14,"colspan","4"],[12],[1,[28,[35,3],["discourse_ai.reviewables.accuracy"],null]],[13],[1,"\\n          "],[10,"td"],[14,"colspan","3"],[12],[1,[30,2]],[1,"%"],[13],[1,"\\n        "],[13],[1,"\\n"]],[2,3]],null],[1,"    "],[13],[1,"\\n  "],[13],[1,"\\n"]],[]],null]],["@accuracies","acc","model"],false,["if","each","-each-in","i18n"]]',moduleName:"discourse/plugins/discourse-ai/discourse/components/model-accuracies.hbs",isStrictMode:!1})
e.default=(0,t.setComponentTemplate)(o,(0,i.default)())})),define("discourse/plugins/discourse-ai/discourse/components/reviewable-ai-chat-message",["exports","@ember/component","@glimmer/component","discourse/plugins/chat/discourse/models/chat-channel","@ember/template-factory"],(function(e,t,i,s,o){"use strict"
Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
const r=(0,o.createTemplateFactory)({id:"yKOx21Wk",block:'[[[41,[30,0,["chatChannel"]],[[[1,"  "],[10,0],[14,0,"flagged-post-header"],[12],[1,"\\n    "],[8,[39,1],null,[["@route","@models"],["chat.channel.near-message",[28,[37,2],[[30,0,["chatChannel","slugifiedTitle"]],[30,0,["chatChannel","id"]],[30,1,["target_id"]]],null]]],[["default"],[[[[1,"\\n      "],[8,[39,3],null,[["@channel"],[[30,0,["chatChannel"]]]],null],[1,"\\n    "]],[]]]]],[1,"\\n  "],[13],[1,"\\n"]],[]],null],[1,"\\n"],[10,0],[14,0,"post-contents-wrapper"],[12],[1,"\\n  "],[8,[39,4],null,[["@user","@tagName"],[[30,1,["target_created_by"]],""]],null],[1,"\\n  "],[10,0],[14,0,"post-contents"],[12],[1,"\\n    "],[8,[39,5],null,[["@reviewable","@createdBy","@tagName"],[[30,1],[30,1,["target_created_by"]],""]],null],[1,"\\n\\n    "],[10,0],[14,0,"post-body"],[12],[1,"\\n      "],[1,[28,[35,6],[[28,[37,7],[[30,1,["payload","message_cooked"]],[30,1,["cooked"]]],null]],null]],[1,"\\n    "],[13],[1,"\\n\\n    "],[18,2,null],[1,"\\n\\n    "],[8,[39,9],null,[["@accuracies"],[[30,1,["payload","accuracies"]]]],null],[1,"\\n  "],[13],[1,"\\n"],[13]],["@reviewable","&default"],false,["if","link-to","array","chat-channel-title","reviewable-created-by","reviewable-post-header","html-safe","or","yield","model-accuracies"]]',moduleName:"discourse/plugins/discourse-ai/discourse/components/reviewable-ai-chat-message.hbs",isStrictMode:!1})
class n extends i.default{get chatChannel(){if(this.args.reviewable.chat_channel)return s.default.create(this.args.reviewable.chat_channel)}}e.default=n,(0,t.setComponentTemplate)(r,n)})),define("discourse/plugins/discourse-ai/discourse/components/reviewable-ai-post",["exports","@ember/component","@ember/component/template-only","@ember/template-factory"],(function(e,t,i,s){"use strict"
Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
const o=(0,s.createTemplateFactory)({id:"XJ3JIp4P",block:'[[[10,0],[14,0,"flagged-post-header"],[12],[1,"\\n  "],[8,[39,0],null,[["@reviewable","@tagName"],[[30,1],""]],null],[1,"\\n  "],[8,[39,1],null,[["@reviewable","@tagName"],[[30,1],""]],null],[1,"\\n"],[13],[1,"\\n\\n"],[10,0],[14,0,"post-contents-wrapper"],[12],[1,"\\n  "],[8,[39,2],null,[["@user","@tagName"],[[30,1,["target_created_by"]],""]],null],[1,"\\n  "],[10,0],[14,0,"post-contents"],[12],[1,"\\n    "],[8,[39,3],null,[["@reviewable","@createdBy","@tagName"],[[30,1],[30,1,["target_created_by"]],""]],null],[1,"\\n    "],[10,0],[14,0,"post-body"],[12],[1,"\\n"],[41,[30,1,["blank_post"]],[[[1,"        "],[10,2],[12],[1,[28,[35,5],["review.deleted_post"],null]],[13],[1,"\\n"]],[]],[[[1,"        "],[1,[28,[35,6],[[30,1,["cooked"]]],null]],[1,"\\n"]],[]]],[1,"    "],[13],[1,"\\n\\n    "],[18,2,null],[1,"\\n\\n    "],[8,[39,8],null,[["@accuracies"],[[30,1,["payload","accuracies"]]]],null],[1,"\\n  "],[13],[1,"\\n"],[13]],["@reviewable","&default"],false,["reviewable-topic-link","reviewable-post-edits","reviewable-created-by","reviewable-post-header","if","i18n","html-safe","yield","model-accuracies"]]',moduleName:"discourse/plugins/discourse-ai/discourse/components/reviewable-ai-post.hbs",isStrictMode:!1})
e.default=(0,t.setComponentTemplate)(o,(0,i.default)())})),define("discourse/plugins/discourse-ai/discourse/components/thumbnail-suggestion-item",["exports","@glimmer/component","@glimmer/tracking","@ember/helper","@ember/object","discourse/components/d-button","@ember/template-factory","@ember/component"],(function(e,t,i,s,o,r,n,a){"use strict"
var l,u,c,d,p
function m(e,t,i,s){i&&Object.defineProperty(e,t,{enumerable:i.enumerable,configurable:i.configurable,writable:i.writable,value:i.initializer?i.initializer.call(s):void 0})}function g(e,t,i,s,o){var r={}
return Object.keys(s).forEach((function(e){r[e]=s[e]})),r.enumerable=!!r.enumerable,r.configurable=!!r.configurable,("value"in r||r.initializer)&&(r.writable=!0),r=i.slice().reverse().reduce((function(i,s){return s(e,t,i)||i}),r),o&&void 0!==r.initializer&&(r.value=r.initializer?r.initializer.call(o):void 0,r.initializer=void 0),void 0===r.initializer&&(Object.defineProperty(e,t,r),r=null),r}Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
e.default=(p=class extends t.default{constructor(){super(...arguments),m(this,"selected",u,this),m(this,"selectIcon",c,this),m(this,"selectLabel",d,this)}toggleSelection(e){return this.selected?(this.selectIcon="far-circle",this.selectLabel="discourse_ai.ai_helper.thumbnail_suggestions.select",this.selected=!1,this.args.removeSelection(e)):(this.selectIcon="check-circle",this.selectLabel="discourse_ai.ai_helper.thumbnail_suggestions.selected",this.selected=!0,this.args.addSelection(e))}},(0,a.setComponentTemplate)((0,n.createTemplateFactory)({id:"BsBgpDKw",block:'[[[1,"\\n    "],[10,0],[14,0,"ai-thumbnail-suggestions__item"],[12],[1,"\\n      "],[8,[32,0],[[16,0,[52,[30,0,["selected"]],"btn-primary"]]],[["@icon","@label","@action"],[[30,0,["selectIcon"]],[30,0,["selectLabel"]],[28,[32,1],[[30,0,["toggleSelection"]],[30,1]],null]]],null],[1,"\\n      "],[10,"img"],[15,"src",[30,1,["url"]]],[14,"loading","lazy"],[15,"width",[30,1,["thumbnail_width"]]],[15,"height",[30,1,["thumbnail_height"]]],[12],[13],[1,"\\n    "],[13],[1,"\\n  "]],["@thumbnail"],false,["if"]]',moduleName:"/var/www/discourse/app/assets/javascripts/discourse/discourse/plugins/discourse-ai/discourse/components/thumbnail-suggestion-item.js",scope:()=>[r.default,s.fn],isStrictMode:!0}),p),u=g((l=p).prototype,"selected",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),c=g(l.prototype,"selectIcon",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return"far-circle"}}),d=g(l.prototype,"selectLabel",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return"discourse_ai.ai_helper.thumbnail_suggestions.select"}}),g(l.prototype,"toggleSelection",[o.action],Object.getOwnPropertyDescriptor(l.prototype,"toggleSelection"),l.prototype),l)})),define("discourse/plugins/discourse-ai/discourse/connectors/admin-dashboard-tabs-after/admin-sentiment-dashbboard",["exports","@glimmer/component","@ember/routing","discourse-common/helpers/i18n","@ember/template-factory","@ember/component"],(function(e,t,i,s,o,r){"use strict"
var n
Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
class a extends t.default{static shouldRender(e,t){return t.siteSettings.ai_sentiment_enabled}}e.default=a,n=a,(0,r.setComponentTemplate)((0,o.createTemplateFactory)({id:"aCrw9598",block:'[[[1,"\\n    "],[10,"li"],[14,0,"navigation-item sentiment"],[12],[1,"\\n      "],[8,[32,0],[[24,0,"navigation-link"]],[["@route"],["admin.dashboardSentiment"]],[["default"],[[[[1,"\\n        "],[1,[28,[32,1],["discourse_ai.sentiments.dashboard.title"],null]],[1,"\\n      "]],[]]]]],[1,"\\n    "],[13],[1,"\\n  "]],[],false,[]]',moduleName:"/var/www/discourse/app/assets/javascripts/discourse/discourse/plugins/discourse-ai/discourse/connectors/admin-dashboard-tabs-after/admin-sentiment-dashbboard.js",scope:()=>[i.LinkTo,s.default],isStrictMode:!0}),n)})),define("discourse/plugins/discourse-ai/discourse/connectors/after-composer-category-input/ai-category-suggestion",["exports","@glimmer/component","@ember/service","discourse/plugins/discourse-ai/discourse/components/ai-suggestion-dropdown","discourse/plugins/discourse-ai/discourse/lib/show-ai-helper","@ember/template-factory","@ember/component"],(function(e,t,i,s,o,r,n){"use strict"
var a,l,u
Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
e.default=(u=class extends t.default{constructor(){var e,t,i,s
super(...arguments),e=this,t="siteSettings",s=this,(i=l)&&Object.defineProperty(e,t,{enumerable:i.enumerable,configurable:i.configurable,writable:i.writable,value:i.initializer?i.initializer.call(s):void 0})}static shouldRender(e,t){return(0,o.showComposerAIHelper)(e,t)}},(0,n.setComponentTemplate)((0,r.createTemplateFactory)({id:"tgy79Whv",block:'[[[1,"\\n"],[41,[30,0,["siteSettings","ai_embeddings_enabled"]],[[[1,"      "],[8,[32,0],[[24,0,"suggest-category-button"]],[["@mode","@composer"],["suggest_category",[30,1,["composer"]]]],null],[1,"\\n"]],[]],null],[1,"  "]],["@outletArgs"],false,["if"]]',moduleName:"/var/www/discourse/app/assets/javascripts/discourse/discourse/plugins/discourse-ai/discourse/connectors/after-composer-category-input/ai-category-suggestion.js",scope:()=>[s.default],isStrictMode:!0}),u),c=(a=u).prototype,d="siteSettings",p=[i.inject],m={configurable:!0,enumerable:!0,writable:!0,initializer:null},h={},Object.keys(m).forEach((function(e){h[e]=m[e]})),h.enumerable=!!h.enumerable,h.configurable=!!h.configurable,("value"in h||h.initializer)&&(h.writable=!0),h=p.slice().reverse().reduce((function(e,t){return t(c,d,e)||e}),h),g&&void 0!==h.initializer&&(h.value=h.initializer?h.initializer.call(g):void 0,h.initializer=void 0),void 0===h.initializer&&(Object.defineProperty(c,d,h),h=null),l=h,a)
var c,d,p,m,g,h})),define("discourse/plugins/discourse-ai/discourse/connectors/after-composer-tag-input/ai-tag-suggestion",["exports","@glimmer/component","@ember/service","discourse/plugins/discourse-ai/discourse/components/ai-suggestion-dropdown","discourse/plugins/discourse-ai/discourse/lib/show-ai-helper","@ember/template-factory","@ember/component"],(function(e,t,i,s,o,r,n){"use strict"
var a,l,u
Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
e.default=(u=class extends t.default{constructor(){var e,t,i,s
super(...arguments),e=this,t="siteSettings",s=this,(i=l)&&Object.defineProperty(e,t,{enumerable:i.enumerable,configurable:i.configurable,writable:i.writable,value:i.initializer?i.initializer.call(s):void 0})}static shouldRender(e,t){return(0,o.showComposerAIHelper)(e,t)}},(0,n.setComponentTemplate)((0,r.createTemplateFactory)({id:"qB6wq01S",block:'[[[1,"\\n"],[41,[30,0,["siteSettings","ai_embeddings_enabled"]],[[[1,"      "],[8,[32,0],[[24,0,"suggest-tags-button"]],[["@mode","@composer"],["suggest_tags",[30,1,["composer"]]]],null],[1,"\\n"]],[]],null],[1,"  "]],["@outletArgs"],false,["if"]]',moduleName:"/var/www/discourse/app/assets/javascripts/discourse/discourse/plugins/discourse-ai/discourse/connectors/after-composer-tag-input/ai-tag-suggestion.js",scope:()=>[s.default],isStrictMode:!0}),u),c=(a=u).prototype,d="siteSettings",p=[i.inject],m={configurable:!0,enumerable:!0,writable:!0,initializer:null},h={},Object.keys(m).forEach((function(e){h[e]=m[e]})),h.enumerable=!!h.enumerable,h.configurable=!!h.configurable,("value"in h||h.initializer)&&(h.writable=!0),h=p.slice().reverse().reduce((function(e,t){return t(c,d,e)||e}),h),g&&void 0!==h.initializer&&(h.value=h.initializer?h.initializer.call(g):void 0,h.initializer=void 0),void 0===h.initializer&&(Object.defineProperty(c,d,h),h=null),l=h,a)
var c,d,p,m,g,h})),define("discourse/plugins/discourse-ai/discourse/connectors/after-composer-title-input/ai-title-suggestion",["exports","@glimmer/component","discourse/plugins/discourse-ai/discourse/components/ai-suggestion-dropdown","discourse/plugins/discourse-ai/discourse/lib/show-ai-helper","@ember/template-factory","@ember/component"],(function(e,t,i,s,o,r){"use strict"
var n
Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
class a extends t.default{static shouldRender(e,t){return(0,s.showComposerAIHelper)(e,t)}}e.default=a,n=a,(0,r.setComponentTemplate)((0,o.createTemplateFactory)({id:"4En7i5/x",block:'[[[1,"\\n    "],[8,[32,0],[[24,0,"suggest-titles-button"]],[["@mode","@composer"],["suggest_title",[30,1,["composer"]]]],null],[1,"\\n  "]],["@outletArgs"],false,[]]',moduleName:"/var/www/discourse/app/assets/javascripts/discourse/discourse/plugins/discourse-ai/discourse/connectors/after-composer-title-input/ai-title-suggestion.js",scope:()=>[i.default],isStrictMode:!0}),n)})),define("discourse/plugins/discourse-ai/discourse/connectors/after-d-editor/ai-helper-context-menu",["exports","@glimmer/component","@glimmer/tracking","@ember/object","@ember/service","@popperjs/core","discourse/lib/ajax","discourse/lib/ajax-error","discourse/lib/utilities","discourse-common/config/environment","discourse-common/utils/decorators","discourse/plugins/discourse-ai/discourse/lib/show-ai-helper"],(function(e,t,i,s,o,r,n,a,l,u,c,d){"use strict"
var p,m,g,h,b,f,y,_,v,w,S,j,P,O,z,T,x,A,k,M,E,C,I,N,R,D,B,L,U,F
function q(e,t,i,s){i&&Object.defineProperty(e,t,{enumerable:i.enumerable,configurable:i.configurable,writable:i.writable,value:i.initializer?i.initializer.call(s):void 0})}function G(e,t,i){var s
return(t="symbol"==typeof(s=function(e,t){if("object"!=typeof e||!e)return e
var i=e[Symbol.toPrimitive]
if(void 0!==i){var s=i.call(e,t||"default")
if("object"!=typeof s)return s
throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(t,"string"))?s:String(s))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function V(e,t,i,s,o){var r={}
return Object.keys(s).forEach((function(e){r[e]=s[e]})),r.enumerable=!!r.enumerable,r.configurable=!!r.configurable,("value"in r||r.initializer)&&(r.writable=!0),r=i.slice().reverse().reduce((function(i,s){return s(e,t,i)||i}),r),o&&void 0!==r.initializer&&(r.value=r.initializer?r.initializer.call(o):void 0,r.initializer=void 0),void 0===r.initializer&&(Object.defineProperty(e,t,r),r=null),r}Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
e.default=(p=(0,c.debounce)(u.INPUT_DELAY),m=class extends t.default{static shouldRender(e,t){return(0,d.showComposerAIHelper)(e,t)}constructor(){super(...arguments),q(this,"currentUser",g,this),q(this,"siteSettings",h,this),q(this,"modal",b,this),q(this,"capabilities",f,this),q(this,"helperOptions",y,this),q(this,"showContextMenu",_,this),q(this,"caretCoords",v,this),q(this,"virtualElement",w,this),q(this,"selectedText",S,this),q(this,"newSelectedText",j,this),q(this,"loading",P,this),q(this,"lastUsedOption",O,this),q(this,"showDiffModal",z,this),q(this,"showThumbnailModal",T,this),q(this,"diff",x,this),q(this,"popperPlacement",A,this),q(this,"previousMenuState",k,this),q(this,"customPromptValue",M,this),q(this,"initialValue",E,this),q(this,"thumbnailSuggestions",C,this),q(this,"selectionRange",I,this),q(this,"lastSelectionRange",N,this),G(this,"CONTEXT_MENU_STATES",{triggers:"TRIGGERS",options:"OPTIONS",resets:"RESETS",loading:"LOADING",review:"REVIEW"}),G(this,"prompts",[]),G(this,"promptTypes",{}),G(this,"minSelectionChars",3),q(this,"_menuState",R,this),q(this,"_popper",D,this),q(this,"_dEditorInput",B,this)
q(this,"_customPromptInput",L,this),q(this,"_contextMenu",U,this),q(this,"_activeAIRequest",F,this),0===this.helperOptions.length&&this.loadPrompts()}willDestroy(){super.willDestroy(...arguments),document.removeEventListener("selectionchange",this.selectionChanged),document.removeEventListener("keydown",this.onKeyDown),this._popper?.destroy()}get menuState(){return this._menuState}set menuState(e){this.previousMenuState=this._menuState,this._menuState=e}async loadPrompts(){let e=await(0,n.ajax)("/discourse-ai/ai-helper/prompts")
e=e.filter((e=>e.location.includes("composer"))).filter((e=>"generate_titles"!==e.name))
const t=e.findIndex((e=>"custom_prompt"===e.name))
if(-1!==t){const i=e.splice(t,1)[0]
e.unshift(i)}this._showUserCustomPrompts()||(e=e.filter((e=>"custom_prompt"!==e.name))),e.forEach((e=>{this.prompts[e.id]=e})),this.promptTypes=e.reduce(((e,t)=>(e[t.name]=t.prompt_type,e)),{}),this.helperOptions=e}selectionChanged(){if(document.activeElement!==this._dEditorInput)return
const e=Boolean(window.getSelection()&&document.activeElement&&document.activeElement.value)
this.selectedText=e?document.activeElement.value.substring(document.activeElement.selectionStart,document.activeElement.selectionEnd):"",this.selectionRange=e?{x:document.activeElement.selectionStart,y:document.activeElement.selectionEnd}:{x:0,y:0},0!==this.selectedText?.length?this.selectedText?.length<this.minSelectionChars||this._onSelectionChanged():this.closeContextMenu()}updatePosition(){this.showContextMenu&&this.positionContextMenu()}onKeyDown(e){return"Escape"===e.key||"Backspace"===e.key&&this.selectedText?this.closeContextMenu():void 0}_onSelectionChanged(){this.positionContextMenu(),this.showContextMenu=!0}generateGetBoundingClientRect(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0
return()=>({width:e,height:t,top:s,right:i,bottom:s,left:i})}get canCloseContextMenu(){return document.activeElement!==this._customPromptInput&&((!this.loading||null===this._activeAIRequest)&&this.menuState!==this.CONTEXT_MENU_STATES.review)}closeContextMenu(){this.canCloseContextMenu&&(this.showContextMenu=!1,this.menuState=this.CONTEXT_MENU_STATES.triggers,this.customPromptValue="")}_updateSuggestedByAI(e){this.newSelectedText=e.suggestions[0],e.diff&&(this.diff=e.diff),this._insertAt(this.selectionRange.x,this.selectionRange.y,this.newSelectedText),this.menuState=this.CONTEXT_MENU_STATES.review}_insertAt(e,t,i){this._dEditorInput.setSelectionRange(e,t),this._dEditorInput.focus(),document.execCommand("insertText",!1,i)}_toggleLoadingState(e){return e?(this._dEditorInput.classList.add("loading"),this.loading=!0):(this._dEditorInput.classList.remove("loading"),this.loading=!1)}_showUserCustomPrompts(){const e=this.siteSettings?.ai_helper_custom_prompts_allowed_groups.split("|").map((e=>parseInt(e,10)))
return this.currentUser?.groups.some((t=>e.includes(t.id)))}handleBoundaries(){const e=document.querySelector(".d-editor-textarea-wrapper").getBoundingClientRect(),t=document.querySelector(".d-editor-button-bar").getBoundingClientRect().bottom,i=e.bottom,s=this._contextMenu.getBoundingClientRect()
s.top<t||s.bottom>i?this._contextMenu.classList.add("out-of-bounds"):this._contextMenu.classList.remove("out-of-bounds"),this.caretCoords.y-s.height<t?this.popperPlacement="bottom-start":this.popperPlacement="top-start"}positionContextMenu(){this._contextMenu=document.querySelector(".ai-helper-context-menu"),this.caretCoords=(0,l.getCaretPosition)(this._dEditorInput,{pos:(0,l.caretPosition)(this._dEditorInput)}),this.handleBoundaries(),this.virtualElement={getBoundingClientRect:this.generateGetBoundingClientRect(this._contextMenu.clientWidth,this._contextMenu.clientHeight,this.caretCoords.x,this.caretCoords.y)},this._popper=(0,r.createPopper)(this.virtualElement,this._contextMenu,{placement:this.popperPlacement,modifiers:[{name:"offset",options:{offset:[10,0]}}]})}setupContextMenu(){document.addEventListener("selectionchange",this.selectionChanged),document.addEventListener("keydown",this.onKeyDown),this._dEditorInput=document.querySelector(".d-editor-input"),this._dEditorInput&&this._dEditorInput.addEventListener("scroll",this.updatePosition)}setupCustomPrompt(){this._customPromptInput=document.querySelector(".ai-custom-prompt__input"),this._customPromptInput.focus()}toggleAiHelperOptions(){0===this.helperOptions.length&&this.loadPrompts(),this.menuState=this.CONTEXT_MENU_STATES.options}undoAIAction(){this.capabilities.isFirefox?this._insertAt(this.lastSelectionRange.x,this.lastSelectionRange.y,this.initialValue):document.execCommand("undo",!1,null),this.menuState=this.CONTEXT_MENU_STATES.resets,this.closeContextMenu()}async updateSelected(e){return this._toggleLoadingState(!0),this.lastUsedOption=e,this.menuState=this.CONTEXT_MENU_STATES.loading,this.initialValue=this.selectedText,this.lastSelectionRange=this.selectionRange,this._activeAIRequest=(0,n.ajax)("/discourse-ai/ai-helper/suggest",{method:"POST",data:{mode:e.id,text:this.selectedText,custom_prompt:this.customPromptValue}}),this._activeAIRequest.then((t=>{this.diff=null,this.newSelectedText=null,this.thumbnailSuggestions=null,"illustrate_post"===e.name?(this._toggleLoadingState(!1),this.closeContextMenu(),this.showThumbnailModal=!0,this.thumbnailSuggestions=t.thumbnails):this._updateSuggestedByAI(t)})).catch(a.popupAjaxError).finally((()=>{this._toggleLoadingState(!1)})),this._activeAIRequest}viewChanges(){this.showDiffModal=!0}confirmChanges(){this.menuState=this.CONTEXT_MENU_STATES.resets}cancelAIAction(){this._activeAIRequest&&(this._activeAIRequest.abort(),this._activeAIRequest=null,this._toggleLoadingState(!1),this.closeContextMenu())}togglePreviousMenu(){this.menuState=this.previousMenuState}},g=V(m.prototype,"currentUser",[o.inject],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),h=V(m.prototype,"siteSettings",[o.inject],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),b=V(m.prototype,"modal",[o.inject],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),f=V(m.prototype,"capabilities",[o.inject],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),y=V(m.prototype,"helperOptions",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),_=V(m.prototype,"showContextMenu",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),v=V(m.prototype,"caretCoords",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),w=V(m.prototype,"virtualElement",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),S=V(m.prototype,"selectedText",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return""}}),j=V(m.prototype,"newSelectedText",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),P=V(m.prototype,"loading",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),O=V(m.prototype,"lastUsedOption",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),z=V(m.prototype,"showDiffModal",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),T=V(m.prototype,"showThumbnailModal",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),x=V(m.prototype,"diff",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),A=V(m.prototype,"popperPlacement",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return"top-start"}}),k=V(m.prototype,"previousMenuState",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),M=V(m.prototype,"customPromptValue",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return""}}),E=V(m.prototype,"initialValue",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return""}}),C=V(m.prototype,"thumbnailSuggestions",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),I=V(m.prototype,"selectionRange",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return{x:0,y:0}}}),N=V(m.prototype,"lastSelectionRange",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),R=V(m.prototype,"_menuState",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return this.CONTEXT_MENU_STATES.triggers}}),D=V(m.prototype,"_popper",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),B=V(m.prototype,"_dEditorInput",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),L=V(m.prototype,"_customPromptInput",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),U=V(m.prototype,"_contextMenu",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),F=V(m.prototype,"_activeAIRequest",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),V(m.prototype,"selectionChanged",[c.bind],Object.getOwnPropertyDescriptor(m.prototype,"selectionChanged"),m.prototype),V(m.prototype,"updatePosition",[c.bind],Object.getOwnPropertyDescriptor(m.prototype,"updatePosition"),m.prototype),V(m.prototype,"onKeyDown",[c.bind],Object.getOwnPropertyDescriptor(m.prototype,"onKeyDown"),m.prototype),V(m.prototype,"_onSelectionChanged",[p],Object.getOwnPropertyDescriptor(m.prototype,"_onSelectionChanged"),m.prototype),V(m.prototype,"positionContextMenu",[c.afterRender],Object.getOwnPropertyDescriptor(m.prototype,"positionContextMenu"),m.prototype),V(m.prototype,"setupContextMenu",[s.action],Object.getOwnPropertyDescriptor(m.prototype,"setupContextMenu"),m.prototype),V(m.prototype,"setupCustomPrompt",[s.action],Object.getOwnPropertyDescriptor(m.prototype,"setupCustomPrompt"),m.prototype),V(m.prototype,"toggleAiHelperOptions",[s.action],Object.getOwnPropertyDescriptor(m.prototype,"toggleAiHelperOptions"),m.prototype),V(m.prototype,"undoAIAction",[s.action],Object.getOwnPropertyDescriptor(m.prototype,"undoAIAction"),m.prototype),V(m.prototype,"updateSelected",[s.action],Object.getOwnPropertyDescriptor(m.prototype,"updateSelected"),m.prototype),V(m.prototype,"viewChanges",[s.action],Object.getOwnPropertyDescriptor(m.prototype,"viewChanges"),m.prototype),V(m.prototype,"confirmChanges",[s.action],Object.getOwnPropertyDescriptor(m.prototype,"confirmChanges"),m.prototype),V(m.prototype,"cancelAIAction",[s.action],Object.getOwnPropertyDescriptor(m.prototype,"cancelAIAction"),m.prototype),V(m.prototype,"togglePreviousMenu",[s.action],Object.getOwnPropertyDescriptor(m.prototype,"togglePreviousMenu"),m.prototype),m)})),define("discourse/plugins/discourse-ai/discourse/connectors/after-d-editor/composer-open",["exports","@glimmer/component","@ember/object","@ember/service","discourse-i18n"],(function(e,t,i,s,o){"use strict"
var r,n,a,l,u
function c(e,t,i,s){i&&Object.defineProperty(e,t,{enumerable:i.enumerable,configurable:i.configurable,writable:i.writable,value:i.initializer?i.initializer.call(s):void 0})}function d(e,t,i,s,o){var r={}
return Object.keys(s).forEach((function(e){r[e]=s[e]})),r.enumerable=!!r.enumerable,r.configurable=!!r.configurable,("value"in r||r.initializer)&&(r.writable=!0),r=i.slice().reverse().reduce((function(i,s){return s(e,t,i)||i}),r),o&&void 0!==r.initializer&&(r.value=r.initializer?r.initializer.call(o):void 0,r.initializer=void 0),void 0===r.initializer&&(Object.defineProperty(e,t,r),r=null),r}Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
e.default=(r=(0,i.computed)("composerModel.targetRecipients","composerModel.title"),n=(0,i.computed)("composerModel.targetRecipients"),a=class extends t.default{constructor(){super(...arguments),c(this,"currentUser",l,this),c(this,"siteSettings",u,this)}get composerModel(){return this.args?.outletArgs?.composer}get renderChatWarning(){return this.siteSettings.ai_bot_enable_chat_warning}get aiBotClasses(){return this.composerModel?.title===o.default.t("discourse_ai.ai_bot.default_pm_prefix")?"ai-bot-chat":"ai-bot-pm"}get isAiBotChat(){if(this.composerModel&&this.composerModel.targetRecipients&&this.currentUser.ai_enabled_chat_bots){let e=this.composerModel.targetRecipients.split(",")
return this.currentUser.ai_enabled_chat_bots.any((t=>e.any((e=>e===t.username))))}return!1}},l=d(a.prototype,"currentUser",[s.inject],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),u=d(a.prototype,"siteSettings",[s.inject],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),d(a.prototype,"aiBotClasses",[r],Object.getOwnPropertyDescriptor(a.prototype,"aiBotClasses"),a.prototype),d(a.prototype,"isAiBotChat",[n],Object.getOwnPropertyDescriptor(a.prototype,"isAiBotChat"),a.prototype),a)})),define("discourse/plugins/discourse-ai/discourse/connectors/after-search-result-entry/search-result-decoration",["exports","discourse-common/helpers/d-icon","discourse-common/helpers/i18n","@ember/template-factory","@ember/component","@ember/component/template-only"],(function(e,t,i,s,o,r){"use strict"
Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
const n=(0,o.setComponentTemplate)((0,s.createTemplateFactory)({id:"+zzrKPCx",block:'[[[1,"\\n  "],[10,0],[14,0,"ai-result__icon"],[15,"title",[28,[32,0],["discourse_ai.embeddings.ai_generated_result"],null]],[12],[1,"\\n    "],[1,[28,[32,1],["discourse-sparkles"],null]],[1,"\\n  "],[13],[1,"\\n"]],[],false,[]]',moduleName:"/var/www/discourse/app/assets/javascripts/discourse/discourse/plugins/discourse-ai/discourse/connectors/after-search-result-entry/search-result-decoration.js",scope:()=>[i.default,t.default],isStrictMode:!0}),(0,r.default)())
e.default=n})),define("discourse/plugins/discourse-ai/discourse/connectors/composer-fields/persona-selector",["exports","@glimmer/component","@ember/helper","@ember/service","discourse/lib/key-value-store","select-kit/components/dropdown-select-box","@ember/template-factory","@ember/component"],(function(e,t,i,s,o,r,n,a){"use strict"
var l,u,c
function d(e,t,i){var s
return(t="symbol"==typeof(s=function(e,t){if("object"!=typeof e||!e)return e
var i=e[Symbol.toPrimitive]
if(void 0!==i){var s=i.call(e,t||"default")
if("object"!=typeof s)return s
throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(t,"string"))?s:String(s))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
e.default=(c=class extends t.default{static shouldRender(e,t){return t?.currentUser?.ai_enabled_personas&&function(e,t){if(e&&e.targetRecipients&&t.ai_enabled_chat_bots){const i=e.targetRecipients.split(",")
return t.ai_enabled_chat_bots.any((e=>i.any((t=>t===e.username))))}return!1}(e.model,t.currentUser)}constructor(){var e,t,i,s
if(super(...arguments),e=this,t="currentUser",s=this,(i=u)&&Object.defineProperty(e,t,{enumerable:i.enumerable,configurable:i.configurable,writable:i.writable,value:i.initializer?i.initializer.call(s):void 0}),d(this,"STORE_NAMESPACE","discourse_ai_persona_selector_"),d(this,"preferredPersonaStore",new o.default(this.STORE_NAMESPACE)),this.botOptions&&this.composer){let e=this.preferredPersonaStore.getObject("id")
this._value=this.botOptions[0].id,e&&(e=parseInt(e,10),this.botOptions.any((t=>t.id===e))&&(this._value=e)),this.composer.metaData={ai_persona_id:this._value}}}get composer(){return this.args?.outletArgs?.model}get botOptions(){if(this.currentUser.ai_enabled_personas)return this.currentUser.ai_enabled_personas.map((e=>({id:e.id,name:e.name,description:e.description})))}get filterable(){return this.botOptions.length>4}get value(){return this._value}set value(e){this._value=e,this.preferredPersonaStore.setObject({key:"id",value:e}),this.composer.metaData={ai_persona_id:e}}},(0,a.setComponentTemplate)((0,n.createTemplateFactory)({id:"TcbpLBxH",block:'[[[1,"\\n    "],[10,0],[14,0,"gpt-persona"],[12],[1,"\\n      "],[8,[32,0],[[24,0,"persona-selector__dropdown"]],[["@value","@content","@options"],[[30,0,["value"]],[30,0,["botOptions"]],[28,[32,1],null,[["icon","filterable"],["robot",[30,0,["filterable"]]]]]]],null],[1,"\\n    "],[13],[1,"\\n  "]],[],false,[]]',moduleName:"/var/www/discourse/app/assets/javascripts/discourse/discourse/plugins/discourse-ai/discourse/connectors/composer-fields/persona-selector.js",scope:()=>[r.default,i.hash],isStrictMode:!0}),c),p=(l=c).prototype,m="currentUser",g=[s.inject],h={configurable:!0,enumerable:!0,writable:!0,initializer:null},f={},Object.keys(h).forEach((function(e){f[e]=h[e]})),f.enumerable=!!f.enumerable,f.configurable=!!f.configurable,("value"in f||f.initializer)&&(f.writable=!0),f=g.slice().reverse().reduce((function(e,t){return t(p,m,e)||e}),f),b&&void 0!==f.initializer&&(f.value=f.initializer?f.initializer.call(b):void 0,f.initializer=void 0),void 0===f.initializer&&(Object.defineProperty(p,m,f),f=null),u=f,l)
var p,m,g,h,b,f})),define("discourse/plugins/discourse-ai/discourse/connectors/fast-edit-footer-after/ai-edit-suggestion-button",["exports","@glimmer/component","@glimmer/tracking","@ember/object","discourse/components/d-button","discourse/lib/ajax","discourse/lib/ajax-error","discourse/plugins/discourse-ai/discourse/lib/show-ai-helper","@ember/template-factory","@ember/component"],(function(e,t,i,s,o,r,n,a,l,u){"use strict"
var c,d,p,m,g
function h(e,t,i,s){i&&Object.defineProperty(e,t,{enumerable:i.enumerable,configurable:i.configurable,writable:i.writable,value:i.initializer?i.initializer.call(s):void 0})}function b(e,t,i,s,o){var r={}
return Object.keys(s).forEach((function(e){r[e]=s[e]})),r.enumerable=!!r.enumerable,r.configurable=!!r.configurable,("value"in r||r.initializer)&&(r.writable=!0),r=i.slice().reverse().reduce((function(i,s){return s(e,t,i)||i}),r),o&&void 0!==r.initializer&&(r.value=r.initializer?r.initializer.call(o):void 0,r.initializer=void 0),void 0===r.initializer&&(Object.defineProperty(e,t,r),r=null),r}Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
e.default=(g=class extends t.default{static shouldRender(e,t){return(0,a.showPostAIHelper)(e,t)}constructor(){super(...arguments),h(this,"loading",d,this),h(this,"suggestion",p,this),h(this,"_activeAIRequest",m,this),this.mode||this.loadMode()}get disabled(){return this.loading||this.suggestion?.length>0}async loadMode(){let e=await(0,r.ajax)("/discourse-ai/ai-helper/prompts",{method:"GET",data:{name_filter:"proofread"}})
this.mode=e[0]}suggest(){return this.loading=!0,this._activeAIRequest=(0,r.ajax)("/discourse-ai/ai-helper/suggest",{method:"POST",data:{mode:this.mode.id,text:this.args.outletArgs.initialValue,custom_prompt:""}}),this._activeAIRequest.then((e=>{let{suggestions:t}=e
this.suggestion=t[0].trim(),this.args.outletArgs.updateValue(this.suggestion)})).catch(n.popupAjaxError).finally((()=>{this.loading=!1})),this._activeAIRequest}},(0,u.setComponentTemplate)((0,l.createTemplateFactory)({id:"9jHc25oQ",block:'[[[1,"\\n"],[41,[51,[30,1,["newValue"]]],[[[1,"      "],[8,[32,0],[[24,0,"btn-small btn-ai-suggest-edit"]],[["@action","@icon","@label","@isLoading","@disabled"],[[30,0,["suggest"]],"discourse-sparkles","discourse_ai.ai_helper.fast_edit.suggest_button",[30,0,["loading"]],[30,0,["disabled"]]]],null],[1,"\\n"]],[]],null],[1,"  "]],["@outletArgs"],false,["unless"]]',moduleName:"/var/www/discourse/app/assets/javascripts/discourse/discourse/plugins/discourse-ai/discourse/connectors/fast-edit-footer-after/ai-edit-suggestion-button.js",scope:()=>[o.default],isStrictMode:!0}),g),d=b((c=g).prototype,"loading",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),p=b(c.prototype,"suggestion",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return""}}),m=b(c.prototype,"_activeAIRequest",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),b(c.prototype,"suggest",[s.action],Object.getOwnPropertyDescriptor(c.prototype,"suggest"),c.prototype),c)}))
define("discourse/plugins/discourse-ai/discourse/connectors/full-page-search-below-search-header/semantic-search",["exports","@glimmer/component","@glimmer/tracking","@ember/modifier","@ember/object","@ember/render-modifiers/modifiers/did-insert","@ember/service","discourse/components/d-toggle-switch","discourse/controllers/full-page-search","discourse/lib/ajax","discourse/lib/ajax-error","discourse/lib/plugin-api","discourse/lib/search","discourse-common/helpers/d-icon","I18n","@ember/template-factory","@ember/component"],(function(e,t,i,s,o,r,n,a,l,u,c,d,p,m,g,h,b){"use strict"
var f,y,_,v,w,S,j,P,O
function z(e,t,i,s){i&&Object.defineProperty(e,t,{enumerable:i.enumerable,configurable:i.configurable,writable:i.writable,value:i.initializer?i.initializer.call(s):void 0})}function T(e,t,i){var s
return(t="symbol"==typeof(s=function(e,t){if("object"!=typeof e||!e)return e
var i=e[Symbol.toPrimitive]
if(void 0!==i){var s=i.call(e,t||"default")
if("object"!=typeof s)return s
throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(t,"string"))?s:String(s))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function x(e,t,i,s,o){var r={}
return Object.keys(s).forEach((function(e){r[e]=s[e]})),r.enumerable=!!r.enumerable,r.configurable=!!r.configurable,("value"in r||r.initializer)&&(r.writable=!0),r=i.slice().reverse().reduce((function(i,s){return s(e,t,i)||i}),r),o&&void 0!==r.initializer&&(r.value=r.initializer?r.initializer.call(o):void 0,r.initializer=void 0),void 0===r.initializer&&(Object.defineProperty(e,t,r),r=null),r}Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
e.default=(O=class extends t.default{constructor(){super(...arguments),z(this,"appEvents",y,this),z(this,"siteSettings",_,this),z(this,"searchPreferencesManager",v,this),z(this,"searching",w,this),z(this,"AIResults",S,this),z(this,"showingAIResults",j,this),z(this,"preventAISearch",P,this),T(this,"initialSearchTerm",this.args.outletArgs.search)}static shouldRender(e,t){let{siteSettings:i}=t
return i.ai_embeddings_semantic_search_enabled}get disableToggleSwitch(){if(this.searching||0===this.AIResults.length||this.preventAISearch)return!0}get searchStateText(){return this.AIResults.length>0?this.showingAIResults?g.default.t("discourse_ai.embeddings.semantic_search_results.toggle",{count:this.AIResults.length}):g.default.t("discourse_ai.embeddings.semantic_search_results.toggle_hidden",{count:this.AIResults.length}):this.preventAISearch?g.default.t("discourse_ai.embeddings.semantic_search_disabled_sort"):this.searching?g.default.t("discourse_ai.embeddings.semantic_search_loading"):0===this.AIResults.length&&this.searchTerm!==this.initialSearchTerm?g.default.t("discourse_ai.embeddings.semantic_search_results.new"):0===this.AIResults.length?g.default.t("discourse_ai.embeddings.semantic_search_results.none"):void 0}get searchTerm(){return this.initialSearchTerm!==this.args.outletArgs.search&&(this.initialSearchTerm=void 0),this.args.outletArgs.search}get searchEnabled(){return this.args.outletArgs.type===l.SEARCH_TYPE_DEFAULT&&(0,p.isValidSearchTerm)(this.searchTerm,this.siteSettings)}toggleAIResults(){this.showingAIResults?this.args.outletArgs.addSearchResults([],"topic_id"):this.args.outletArgs.addSearchResults(this.AIResults,"topic_id"),this.showingAIResults=!this.showingAIResults}resetAIResults(){this.AIResults=[],this.showingAIResults=!1}handleSearch(){if(this.searchEnabled)if(void 0===this.searchPreferencesManager?.sortOrder||0===this.searchPreferencesManager?.sortOrder){if(this.preventAISearch=!1,this.initialSearchTerm&&!this.searching)return this.performHyDESearch()
this.resetAIResults(),(0,d.withPluginApi)("1.15.0",(e=>{e.onAppEvent("full-page-search:trigger-search",(()=>{if(!this.searching)return this.performHyDESearch()}))}))}else this.preventAISearch=!0}performHyDESearch(){this.searching=!0,this.resetAIResults(),(0,u.ajax)("/discourse-ai/embeddings/semantic-search",{data:{q:this.searchTerm}}).then((async e=>{const t=await(0,p.translateResults)(e)||{}
0!==t.posts?.length?(t.posts.forEach((e=>{e.generatedByAI=!0})),this.AIResults=t.posts):this.searching=!1})).catch(c.popupAjaxError).finally((()=>this.searching=!1))}},(0,b.setComponentTemplate)((0,h.createTemplateFactory)({id:"3cSLRgPA",block:'[[[1,"\\n"],[41,[30,0,["searchEnabled"]],[[[1,"      "],[10,0],[14,0,"semantic-search__container search-results"],[14,"role","region"],[12],[1,"\\n        "],[11,0],[24,0,"semantic-search__results"],[4,[32,0],[[30,0,["handleSearch"]]],null],[12],[1,"\\n          "],[10,0],[15,0,[29,["semantic-search__searching\\n              ",[52,[30,0,["searching"]],"in-progress"]]]],[12],[1,"\\n            "],[8,[32,1],[[16,"disabled",[30,0,["disableToggleSwitch"]]],[24,"title","AI search results hidden"],[24,0,"semantic-search__results-toggle"],[4,[32,2],["click",[30,0,["toggleAIResults"]]],null]],[["@state"],[[30,0,["showingAIResults"]]]],null],[1,"\\n\\n            "],[10,0],[14,0,"semantic-search__searching-text"],[12],[1,"\\n              "],[1,[28,[32,3],["discourse-sparkles"],null]],[1,"\\n              "],[1,[30,0,["searchStateText"]]],[1,"\\n            "],[13],[1,"\\n\\n"],[41,[30,0,["searching"]],[[[1,"              "],[10,1],[14,0,"semantic-search__indicator-wave"],[12],[1,"\\n                "],[10,1],[14,0,"semantic-search__indicator-dot"],[12],[1,"."],[13],[1,"\\n                "],[10,1],[14,0,"semantic-search__indicator-dot"],[12],[1,"."],[13],[1,"\\n                "],[10,1],[14,0,"semantic-search__indicator-dot"],[12],[1,"."],[13],[1,"\\n              "],[13],[1,"\\n"]],[]],null],[1,"          "],[13],[1,"\\n        "],[13],[1,"\\n      "],[13],[1,"\\n"]],[]],null],[1,"  "]],[],false,["if"]]',moduleName:"/var/www/discourse/app/assets/javascripts/discourse/discourse/plugins/discourse-ai/discourse/connectors/full-page-search-below-search-header/semantic-search.js",scope:()=>[r.default,a.default,s.on,m.default],isStrictMode:!0}),O),y=x((f=O).prototype,"appEvents",[n.inject],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),_=x(f.prototype,"siteSettings",[n.inject],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),v=x(f.prototype,"searchPreferencesManager",[n.inject],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),w=x(f.prototype,"searching",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),S=x(f.prototype,"AIResults",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),j=x(f.prototype,"showingAIResults",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),P=x(f.prototype,"preventAISearch",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),x(f.prototype,"toggleAIResults",[o.action],Object.getOwnPropertyDescriptor(f.prototype,"toggleAIResults"),f.prototype),x(f.prototype,"resetAIResults",[o.action],Object.getOwnPropertyDescriptor(f.prototype,"resetAIResults"),f.prototype),x(f.prototype,"handleSearch",[o.action],Object.getOwnPropertyDescriptor(f.prototype,"handleSearch"),f.prototype),f)})),define("discourse/plugins/discourse-ai/discourse/connectors/post-text-buttons/ai-helper-options-menu",["exports","@glimmer/component","@glimmer/tracking","@ember/helper","@ember/object","@ember/render-modifiers/modifiers/did-insert","@ember/render-modifiers/modifiers/will-destroy","@ember/service","discourse/components/cook-text","discourse/components/d-button","discourse/components/fast-edit","discourse/components/modal/fast-edit","discourse/lib/ajax","discourse/lib/ajax-error","discourse/lib/utilities","discourse-common/utils/decorators","truth-helpers/helpers/eq","truth-helpers/helpers/not","discourse/plugins/discourse-ai/discourse/components/ai-helper-custom-prompt","discourse/plugins/discourse-ai/discourse/components/ai-helper-loading","discourse/plugins/discourse-ai/discourse/lib/show-ai-helper","@ember/template-factory","@ember/component"],(function(e,t,i,s,o,r,n,a,l,u,c,d,p,m,g,h,b,f,y,_,v,w,S){"use strict"
var j,P,O,z,T,x,A,k,M,E,C,I,N,R,D,B,L,U,F
function q(e,t,i,s){i&&Object.defineProperty(e,t,{enumerable:i.enumerable,configurable:i.configurable,writable:i.writable,value:i.initializer?i.initializer.call(s):void 0})}function G(e,t,i){var s
return(t="symbol"==typeof(s=function(e,t){if("object"!=typeof e||!e)return e
var i=e[Symbol.toPrimitive]
if(void 0!==i){var s=i.call(e,t||"default")
if("object"!=typeof s)return s
throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(t,"string"))?s:String(s))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function V(e,t,i,s,o){var r={}
return Object.keys(s).forEach((function(e){r[e]=s[e]})),r.enumerable=!!r.enumerable,r.configurable=!!r.configurable,("value"in r||r.initializer)&&(r.writable=!0),r=i.slice().reverse().reduce((function(i,s){return s(e,t,i)||i}),r),o&&void 0!==r.initializer&&(r.value=r.initializer?r.initializer.call(o):void 0,r.initializer=void 0),void 0===r.initializer&&(Object.defineProperty(e,t,r),r=null),r}Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
e.default=(F=class extends t.default{static shouldRender(e,t){return(0,v.showPostAIHelper)(e,t)}constructor(){super(...arguments),q(this,"messageBus",P,this),q(this,"site",O,this),q(this,"modal",z,this),q(this,"siteSettings",T,this),q(this,"currentUser",x,this),q(this,"menu",A,this),q(this,"helperOptions",k,this),q(this,"menuState",M,this),q(this,"loading",E,this),q(this,"suggestion",C,this),q(this,"showMainButtons",I,this),q(this,"customPromptValue",N,this),q(this,"copyButtonIcon",R,this),q(this,"copyButtonLabel",D,this),q(this,"showFastEdit",B,this),q(this,"showAiButtons",L,this),G(this,"MENU_STATES",{triggers:"TRIGGERS",options:"OPTIONS",loading:"LOADING",result:"RESULT"}),q(this,"_activeAIRequest",U,this),0===this.helperOptions.length&&this.loadPrompts()}async showAIHelperOptions(){this.showMainButtons=!1,this.menuState=this.MENU_STATES.options,this.menu.activeMenu.options.placement="bottom"}subscribe(){const e=`/discourse-ai/ai-helper/explain/${this.args.outletArgs.data.quoteState.postId}`
this.messageBus.subscribe(e,this._updateResult)}unsubscribe(){this.messageBus.unsubscribe("/discourse-ai/ai-helper/explain/*",this._updateResult)}_updateResult(e){this.suggestion=e.result}async performAISuggestion(e){if(this.menuState=this.MENU_STATES.loading,"explain"===e.name){this.menuState=this.MENU_STATES.result
const t="/discourse-ai/ai-helper/explain"
this._activeAIRequest=(0,p.ajax)(t,{method:"POST",data:{mode:e.value,text:this.args.outletArgs.data.quoteState.buffer,post_id:this.args.outletArgs.data.quoteState.postId}})}else this._activeAIRequest=(0,p.ajax)("/discourse-ai/ai-helper/suggest",{method:"POST",data:{mode:e.id,text:this.args.outletArgs.data.quoteState.buffer,custom_prompt:this.customPromptValue}})
return"explain"!==e.name&&this._activeAIRequest.then((t=>{let{suggestions:i}=t
if(this.suggestion=i[0].trim(),"proofread"===e.name)return this.showAiButtons=!1,this.site.desktopView?void(this.showFastEdit=!0):this.modal.show(d.default,{model:{initialValue:this.args.outletArgs.data.quoteState.buffer,newValue:this.suggestion,post:this.args.outletArgs.post,close:this.closeFastEdit}})})).catch(m.popupAjaxError).finally((()=>{this.loading=!1,this.menuState=this.MENU_STATES.result})),this._activeAIRequest}cancelAIAction(){this._activeAIRequest&&(this._activeAIRequest.abort(),this._activeAIRequest=null,this.loading=!1,this.menuState=this.MENU_STATES.options)}copySuggestion(){this.suggestion?.length>0&&((0,g.clipboardCopy)(this.suggestion),this.copyButtonIcon="check",this.copyButtonLabel="discourse_ai.ai_helper.post_options_menu.copied",setTimeout((()=>{this.copyButtonIcon="copy",this.copyButtonLabel="discourse_ai.ai_helper.post_options_menu.copy"}),3500))}async loadPrompts(){let e=await(0,p.ajax)("/discourse-ai/ai-helper/prompts")
e=e.filter((e=>e.location.includes("post")))
const t=e.findIndex((e=>"custom_prompt"===e.name))
if(-1!==t){const i=e.splice(t,1)[0]
e.unshift(i)}this._showUserCustomPrompts()||(e=e.filter((e=>"custom_prompt"!==e.name))),this.args.outletArgs.data.canEditPost||(e=e.filter((e=>"proofread"!==e.name))),this.helperOptions=e}_showUserCustomPrompts(){const e=this.siteSettings?.ai_helper_custom_prompts_allowed_groups.split("|").map((e=>parseInt(e,10)))
return this.currentUser?.groups.some((t=>e.includes(t.id)))}async closeFastEdit(){this.showFastEdit=!1,await this.args.outletArgs.data.hideToolbar()}},(0,S.setComponentTemplate)((0,w.createTemplateFactory)({id:"j9occbDk",block:'[[[1,"\\n"],[41,[30,0,["showMainButtons"]],[[[1,"      "],[18,3,null],[1,"\\n"]],[]],null],[1,"\\n"],[41,[30,0,["showAiButtons"]],[[[1,"      "],[10,0],[14,0,"ai-post-helper"],[12],[1,"\\n"],[41,[28,[32,0],[[30,0,["menuState"]],[30,0,["MENU_STATES","triggers"]]],null],[[[1,"          "],[8,[32,1],[[24,0,"btn-flat ai-post-helper__trigger"]],[["@icon","@title","@label","@action"],["discourse-sparkles","discourse_ai.ai_helper.post_options_menu.title","discourse_ai.ai_helper.post_options_menu.trigger",[30,0,["showAIHelperOptions"]]]],null],[1,"\\n\\n"]],[]],[[[41,[28,[32,0],[[30,0,["menuState"]],[30,0,["MENU_STATES","options"]]],null],[[[1,"          "],[10,0],[14,0,"ai-post-helper__options"],[12],[1,"\\n"],[42,[28,[31,3],[[28,[31,3],[[30,0,["helperOptions"]]],null]],null],null,[[[41,[28,[32,0],[[30,1,["name"]],"custom_prompt"],null],[[[1,"                "],[8,[32,2],null,[["@value","@promptArgs","@submit"],[[30,0,["customPromptValue"]],[30,1],[30,0,["performAISuggestion"]]]],null],[1,"\\n"]],[]],[[[1,"                "],[8,[32,1],[[16,"data-name",[30,1,["name"]]],[16,"data-value",[30,1,["id"]]],[24,0,"btn-flat ai-post-helper__options-button"]],[["@icon","@translatedLabel","@action"],[[30,1,["icon"]],[30,1,["translated_name"]],[28,[32,3],[[30,0,["performAISuggestion"]],[30,1]],null]]],null],[1,"\\n"]],[]]]],[1]],null],[1,"          "],[13],[1,"\\n\\n"]],[]],[[[41,[28,[32,0],[[30,0,["menuState"]],[30,0,["MENU_STATES","loading"]]],null],[[[1,"          "],[8,[32,4],null,[["@cancel"],[[30,0,["cancelAIAction"]]]],null],[1,"\\n"]],[]],[[[41,[28,[32,0],[[30,0,["menuState"]],[30,0,["MENU_STATES","result"]]],null],[[[1,"          "],[11,0],[24,0,"ai-post-helper__suggestion"],[4,[32,5],[[30,0,["subscribe"]]],null],[4,[32,6],[[30,0,["unsubscribe"]]],null],[12],[1,"\\n"],[41,[30,0,["suggestion"]],[[[1,"              "],[10,0],[14,0,"ai-post-helper__suggestion__text"],[14,"dir","auto"],[12],[1,"\\n                "],[8,[32,7],null,[["@rawText"],[[30,0,["suggestion"]]]],null],[1,"\\n              "],[13],[1,"\\n              "],[10,"di"],[14,0,"ai-post-helper__suggestion__buttons"],[12],[1,"\\n                "],[8,[32,1],[[24,0,"btn-flat ai-post-helper__suggestion__cancel"]],[["@icon","@label","@action"],["times","discourse_ai.ai_helper.post_options_menu.cancel",[30,0,["cancelAIAction"]]]],null],[1,"\\n                "],[8,[32,1],[[24,0,"btn-flat ai-post-helper__suggestion__copy"]],[["@icon","@label","@action","@disabled"],[[30,0,["copyButtonIcon"]],[30,0,["copyButtonLabel"]],[30,0,["copySuggestion"]],[28,[32,8],[[30,0,["suggestion"]]],null]]],null],[1,"\\n              "],[13],[1,"\\n"]],[]],[[[1,"              "],[8,[32,4],null,[["@cancel"],[[30,0,["cancelAIAction"]]]],null],[1,"\\n"]],[]]],[1,"          "],[13],[1,"\\n        "]],[]],null]],[]]]],[]]]],[]]],[1,"      "],[13],[1,"\\n"]],[]],null],[1,"\\n"],[41,[30,0,["showFastEdit"]],[[[1,"      "],[10,0],[14,0,"ai-post-helper__fast-edit"],[12],[1,"\\n        "],[8,[32,9],null,[["@initialValue","@newValue","@post","@close"],[[30,2,["data","quoteState","buffer"]],[30,0,["suggestion"]],[30,2,["post"]],[30,0,["closeFastEdit"]]]],null],[1,"\\n      "],[13],[1,"\\n"]],[]],null],[1,"  "]],["option","@outletArgs","&default"],false,["if","yield","each","-track-array"]]',moduleName:"/var/www/discourse/app/assets/javascripts/discourse/discourse/plugins/discourse-ai/discourse/connectors/post-text-buttons/ai-helper-options-menu.js",scope:()=>[b.default,u.default,y.default,s.fn,_.default,r.default,n.default,l.default,f.default,c.default],isStrictMode:!0}),F),P=V((j=F).prototype,"messageBus",[a.inject],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),O=V(j.prototype,"site",[a.inject],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),z=V(j.prototype,"modal",[a.inject],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),T=V(j.prototype,"siteSettings",[a.inject],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),x=V(j.prototype,"currentUser",[a.inject],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),A=V(j.prototype,"menu",[a.inject],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),k=V(j.prototype,"helperOptions",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),M=V(j.prototype,"menuState",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return this.MENU_STATES.triggers}}),E=V(j.prototype,"loading",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),C=V(j.prototype,"suggestion",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return""}}),I=V(j.prototype,"showMainButtons",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),N=V(j.prototype,"customPromptValue",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return""}}),R=V(j.prototype,"copyButtonIcon",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return"copy"}}),D=V(j.prototype,"copyButtonLabel",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return"discourse_ai.ai_helper.post_options_menu.copy"}}),B=V(j.prototype,"showFastEdit",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),L=V(j.prototype,"showAiButtons",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),U=V(j.prototype,"_activeAIRequest",[i.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),V(j.prototype,"showAIHelperOptions",[o.action],Object.getOwnPropertyDescriptor(j.prototype,"showAIHelperOptions"),j.prototype),V(j.prototype,"subscribe",[h.bind],Object.getOwnPropertyDescriptor(j.prototype,"subscribe"),j.prototype),V(j.prototype,"unsubscribe",[h.bind],Object.getOwnPropertyDescriptor(j.prototype,"unsubscribe"),j.prototype),V(j.prototype,"_updateResult",[h.bind],Object.getOwnPropertyDescriptor(j.prototype,"_updateResult"),j.prototype),V(j.prototype,"performAISuggestion",[o.action],Object.getOwnPropertyDescriptor(j.prototype,"performAISuggestion"),j.prototype),V(j.prototype,"cancelAIAction",[o.action],Object.getOwnPropertyDescriptor(j.prototype,"cancelAIAction"),j.prototype),V(j.prototype,"copySuggestion",[o.action],Object.getOwnPropertyDescriptor(j.prototype,"copySuggestion"),j.prototype),V(j.prototype,"closeFastEdit",[o.action],Object.getOwnPropertyDescriptor(j.prototype,"closeFastEdit"),j.prototype),j)})),define("discourse/plugins/discourse-ai/discourse/connectors/split-new-topic-category-after/ai-category-suggestion",["exports","@glimmer/component","@ember/service","discourse/plugins/discourse-ai/discourse/components/ai-split-topic-suggester","discourse/plugins/discourse-ai/discourse/lib/show-ai-helper","@ember/template-factory","@ember/component"],(function(e,t,i,s,o,r,n){"use strict"
var a,l,u
Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
e.default=(u=class extends t.default{constructor(){var e,t,i,s
super(...arguments),e=this,t="siteSettings",s=this,(i=l)&&Object.defineProperty(e,t,{enumerable:i.enumerable,configurable:i.configurable,writable:i.writable,value:i.initializer?i.initializer.call(s):void 0})}static shouldRender(e,t){return(0,o.showPostAIHelper)(e,t)}},(0,n.setComponentTemplate)((0,r.createTemplateFactory)({id:"4O7HJkah",block:'[[[1,"\\n"],[41,[30,0,["siteSettings","ai_embeddings_enabled"]],[[[1,"      "],[8,[32,0],null,[["@selectedPosts","@mode","@updateAction"],[[30,1,["selectedPosts"]],"suggest_category",[30,1,["updateCategoryId"]]]],null],[1,"\\n"]],[]],null],[1,"  "]],["@outletArgs"],false,["if"]]',moduleName:"/var/www/discourse/app/assets/javascripts/discourse/discourse/plugins/discourse-ai/discourse/connectors/split-new-topic-category-after/ai-category-suggestion.js",scope:()=>[s.default],isStrictMode:!0}),u),c=(a=u).prototype,d="siteSettings",p=[i.inject],m={configurable:!0,enumerable:!0,writable:!0,initializer:null},h={},Object.keys(m).forEach((function(e){h[e]=m[e]})),h.enumerable=!!h.enumerable,h.configurable=!!h.configurable,("value"in h||h.initializer)&&(h.writable=!0),h=p.slice().reverse().reduce((function(e,t){return t(c,d,e)||e}),h),g&&void 0!==h.initializer&&(h.value=h.initializer?h.initializer.call(g):void 0,h.initializer=void 0),void 0===h.initializer&&(Object.defineProperty(c,d,h),h=null),l=h,a)
var c,d,p,m,g,h})),define("discourse/plugins/discourse-ai/discourse/connectors/split-new-topic-tag-after/ai-tag-suggestion",["exports","@glimmer/component","@ember/service","discourse/plugins/discourse-ai/discourse/components/ai-split-topic-suggester","discourse/plugins/discourse-ai/discourse/lib/show-ai-helper","@ember/template-factory","@ember/component"],(function(e,t,i,s,o,r,n){"use strict"
var a,l,u
Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
e.default=(u=class extends t.default{constructor(){var e,t,i,s
super(...arguments),e=this,t="siteSettings",s=this,(i=l)&&Object.defineProperty(e,t,{enumerable:i.enumerable,configurable:i.configurable,writable:i.writable,value:i.initializer?i.initializer.call(s):void 0})}static shouldRender(e,t){return(0,o.showPostAIHelper)(e,t)}},(0,n.setComponentTemplate)((0,r.createTemplateFactory)({id:"jo6+zYZR",block:'[[[1,"\\n"],[41,[30,0,["siteSettings","ai_embeddings_enabled"]],[[[1,"      "],[8,[32,0],null,[["@selectedPosts","@mode","@updateAction","@currentValue"],[[30,1,["selectedPosts"]],"suggest_tags",[30,1,["updateTags"]],[30,1,["tags"]]]],null],[1,"\\n"]],[]],null],[1,"  "]],["@outletArgs"],false,["if"]]',moduleName:"/var/www/discourse/app/assets/javascripts/discourse/discourse/plugins/discourse-ai/discourse/connectors/split-new-topic-tag-after/ai-tag-suggestion.js",scope:()=>[s.default],isStrictMode:!0}),u),c=(a=u).prototype,d="siteSettings",p=[i.inject],m={configurable:!0,enumerable:!0,writable:!0,initializer:null},h={},Object.keys(m).forEach((function(e){h[e]=m[e]})),h.enumerable=!!h.enumerable,h.configurable=!!h.configurable,("value"in h||h.initializer)&&(h.writable=!0),h=p.slice().reverse().reduce((function(e,t){return t(c,d,e)||e}),h),g&&void 0!==h.initializer&&(h.value=h.initializer?h.initializer.call(g):void 0,h.initializer=void 0),void 0===h.initializer&&(Object.defineProperty(c,d,h),h=null),l=h,a)
var c,d,p,m,g,h})),define("discourse/plugins/discourse-ai/discourse/connectors/split-new-topic-title-after/ai-title-suggestion",["exports","@glimmer/component","discourse/plugins/discourse-ai/discourse/components/ai-split-topic-suggester","discourse/plugins/discourse-ai/discourse/lib/show-ai-helper","@ember/template-factory","@ember/component"],(function(e,t,i,s,o,r){"use strict"
var n
Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
class a extends t.default{static shouldRender(e,t){return(0,s.showPostAIHelper)(e,t)}}e.default=a,n=a,(0,r.setComponentTemplate)((0,o.createTemplateFactory)({id:"obhR2Q8M",block:'[[[1,"\\n    "],[8,[32,0],null,[["@selectedPosts","@mode","@updateAction"],[[30,1,["selectedPosts"]],"suggest_title",[30,1,["updateTopicName"]]]],null],[1,"\\n  "]],["@outletArgs"],false,[]]',moduleName:"/var/www/discourse/app/assets/javascripts/discourse/discourse/plugins/discourse-ai/discourse/connectors/split-new-topic-title-after/ai-title-suggestion.js",scope:()=>[i.default],isStrictMode:!0}),n)})),define("discourse/plugins/discourse-ai/discourse/connectors/topic-more-content/related-topics",["exports","@glimmer/component","@ember/object","@ember/service","I18n"],(function(e,t,i,s,o){"use strict"
var r,n,a,l,u
function c(e,t,i,s){i&&Object.defineProperty(e,t,{enumerable:i.enumerable,configurable:i.configurable,writable:i.writable,value:i.initializer?i.initializer.call(s):void 0})}function d(e,t,i){var s
return(t="symbol"==typeof(s=function(e,t){if("object"!=typeof e||!e)return e
var i=e[Symbol.toPrimitive]
if(void 0!==i){var s=i.call(e,t||"default")
if("object"!=typeof s)return s
throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(t,"string"))?s:String(s))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function p(e,t,i,s,o){var r={}
return Object.keys(s).forEach((function(e){r[e]=s[e]})),r.enumerable=!!r.enumerable,r.configurable=!!r.configurable,("value"in r||r.initializer)&&(r.writable=!0),r=i.slice().reverse().reduce((function(i,s){return s(e,t,i)||i}),r),o&&void 0!==r.initializer&&(r.value=r.initializer?r.initializer.call(o):void 0,r.initializer=void 0),void 0===r.initializer&&(Object.defineProperty(e,t,r),r=null),r}Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
e.default=(r=(0,i.computed)("moreTopicsPreferenceTracking.selectedTab"),n=class extends t.default{constructor(){super(...arguments),c(this,"store",a,this),c(this,"site",l,this),c(this,"moreTopicsPreferenceTracking",u,this),d(this,"listId","related-topics")}static shouldRender(e){return(e.model.related_topics?.length||0)>0}get hidden(){return this.moreTopicsPreferenceTracking.selectedTab!==this.listId}get relatedTopics(){return this.args.outletArgs.model.related_topics.map((e=>this.store.createRecord("topic",e)))}registerList(){this.moreTopicsPreferenceTracking.registerTopicList({name:o.default.t("discourse_ai.related_topics.pill"),id:this.listId,icon:"discourse-sparkles"})}removeList(){this.moreTopicsPreferenceTracking.removeTopicList(this.listId)}},a=p(n.prototype,"store",[s.inject],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),l=p(n.prototype,"site",[s.inject],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),u=p(n.prototype,"moreTopicsPreferenceTracking",[s.inject],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),p(n.prototype,"hidden",[r],Object.getOwnPropertyDescriptor(n.prototype,"hidden"),n.prototype),p(n.prototype,"registerList",[i.action],Object.getOwnPropertyDescriptor(n.prototype,"registerList"),n.prototype),p(n.prototype,"removeList",[i.action],Object.getOwnPropertyDescriptor(n.prototype,"removeList"),n.prototype),n)})),define("discourse/plugins/discourse-ai/discourse/controllers/admin-dashboard-sentiment",["exports","@ember/object","admin/controllers/admin-dashboard-tab"],(function(e,t,i){"use strict"
var s,o
Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
e.default=(s=(0,t.computed)("startDate","endDate"),o=class extends i.default{get filters(){return{startDate:this.startDate,endDate:this.endDate}}},r=o.prototype,n="filters",a=[s],l=Object.getOwnPropertyDescriptor(o.prototype,"filters"),u=o.prototype,c={},Object.keys(l).forEach((function(e){c[e]=l[e]})),c.enumerable=!!c.enumerable,c.configurable=!!c.configurable,("value"in c||c.initializer)&&(c.writable=!0),c=a.slice().reverse().reduce((function(e,t){return t(r,n,e)||e}),c),u&&void 0!==c.initializer&&(c.value=c.initializer?c.initializer.call(u):void 0,c.initializer=void 0),void 0===c.initializer&&(Object.defineProperty(r,n,c),c=null),o)
var r,n,a,l,u,c})),define("discourse/plugins/discourse-ai/discourse/lib/ai-bot-helper",["exports","discourse/models/composer","I18n"],(function(e,t,i){"use strict"
Object.defineProperty(e,"__esModule",{value:!0}),e.composeAiBotMessage=function(e,s){let o=s.currentUser.ai_enabled_chat_bots.find((t=>t.model_name===e)).username
s.focusComposer({fallbackToNewTopic:!0,openOpts:{action:t.default.PRIVATE_MESSAGE,recipients:o,topicTitle:i.default.t("discourse_ai.ai_bot.default_pm_prefix"),archetypeId:"private_message",draftKey:t.default.NEW_PRIVATE_MESSAGE_KEY,hasGroups:!1,warningsDisabled:!0}})}})),define("discourse/plugins/discourse-ai/discourse/lib/ai-streamer",["exports","@ember/runloop","discourse/lib/load-script","discourse/lib/text"],(function(e,t,i,s){"use strict"
Object.defineProperty(e,"__esModule",{value:!0}),e.MIN_LETTERS_PER_INTERVAL=void 0,e.addProgressDot=c,e.applyProgress=m,e.default=function(e,t){if(t.noop)return;(e.aiStreamingStatus=e.aiStreamingStatus||{})[t.post_id]=t,g(e)}
const o=40,r=6e4,n=e.MIN_LETTERS_PER_INTERVAL=6,a=800
let l=null
function u(e){let t=e.lastChild
for(;t&&t.nodeType===Node.TEXT_NODE&&!/\S/.test(t.textContent);)t=t.previousSibling
return t}function c(e){let t=e
for(;;){let e=u(t)
if(!e)break
if(e.nodeType!==Node.ELEMENT_NODE)break
t=e}const i=document.createElement("span")
i.classList.add("progress-dot"),t.appendChild(i)}class d{set streaming(e){throw"not implemented"}async setCooked(){throw"not implemented"}async setRaw(){throw"not implemented"}get element(){throw"not implemented"}get raw(){throw"not implemented"}}class p extends d{constructor(e,t){super(),this.postStream=e,this.postId=t,this.post=e.findLoadedPost(t),this.post&&(this.postElement=document.querySelector(`#post_${this.post.post_number}`))}get element(){return this.postElement}set streaming(e){this.postElement&&(e?this.postElement.classList.add("streaming"):this.postElement.classList.remove("streaming"))}async setRaw(e,t){this.post.set("raw",e)
const i=await(0,s.cook)(e)
this.element.classList.remove("streaming"),this.element.offsetWidth,this.element.classList.add("streaming")
const o=document.createElement("div")
o.innerHTML=i,t||c(o),await this.setCooked(o.innerHTML)}async setCooked(e){this.post.set("cooked",e)
const t=this.postElement.querySelector(".cooked")
await(0,i.default)("/javascripts/diffhtml.min.js"),window.diff.innerHTML(t,e)}get raw(){return this.post.get("raw")||""}}async function m(e,t){if(e.startTime=e.startTime||Date.now(),Date.now()-e.startTime>r)return t.streaming=!1,!0
if(!t.element)return!1
const i=t.raw
if(e.raw===i&&!e.done){if(t.element.querySelector(".progress-dot"))return!1}if(void 0!==e.raw){let s=e.raw
if(!e.done)if(0===i.length&&-1!==s.indexOf("</details>"))s=e.raw
else{const t=s.length-i.length
let r=Math.floor(t/(a/o))
r<n&&(r=n),s=e.raw.substring(0,i.length+r)}await t.setRaw(s,e.done)}return e.done&&(e.cooked&&await t.setCooked(e.cooked),t.streaming=!1),e.done}function g(e){l||(l=(0,t.later)((async()=>{const t=await async function(e){const t=e.aiStreamingStatus
let i=!1
const s=Object.keys(t).map((async s=>{let o=t[s]
const r=new p(e,o.post_id)
await m(o,r)?delete t[s]:i=!0}))
return await Promise.all(s),i}(e)
l=null,t&&g(e)}),o))}})),define("discourse/plugins/discourse-ai/discourse/lib/copy-conversation",["exports","discourse/lib/ajax","discourse/lib/utilities","discourse-i18n"],(function(e,t,i,s){"use strict"
Object.defineProperty(e,"__esModule",{value:!0}),e.default=async function(e,o,r){await(0,i.clipboardCopyAsync)((async()=>{const i=await async function(e,i,o){const r=e.get("postStream")
let n=[]
for(let t=i;t<=o;t++)n.push(t)
const a=n.map((e=>r.findPostIdForPostNumber(e))),l=`/t/${e.id}/posts.json`,u={post_ids:a,include_raw:!0},c=await(0,t.ajax)(l,{data:u})
let d=[]
d.push("<details class='ai-quote'>"),d.push("<summary>"),d.push(`<span>${e.title}</span>`),d.push(`<span title='${s.default.t("discourse_ai.ai_bot.ai_title")}'>${s.default.t("discourse_ai.ai_bot.ai_label")}</span>`),d.push("</summary>"),c.post_stream.posts.forEach((e=>{d.push(""),d.push(`**${e.username}:**`),d.push(""),d.push(e.raw)})),d.push("</details>")
const p=d.join("\n")
window.discourseAiTestClipboard&&(window.discourseAiClipboard=p)
return p}(e,o,r)
return new Blob([i],{type:"text/plain"})}))}})),define("discourse/plugins/discourse-ai/discourse/lib/show-ai-helper",["exports"],(function(e){"use strict"
function t(e){return e.discourse_ai_enabled&&e.composer_ai_helper_enabled}function i(e){return e.split("|").map((e=>parseInt(e,10)))}function s(e,t){return e?.groups.some((e=>t.includes(e.id)))}Object.defineProperty(e,"__esModule",{value:!0}),e.showComposerAIHelper=function(e,o){const r=t(o.siteSettings),n=s(o.currentUser,i(o.siteSettings.ai_helper_allowed_groups)),a=o.siteSettings.ai_helper_allowed_in_pm
if(e?.composer?.privateMessage)return r&&n&&a
return r&&n},e.showPostAIHelper=function(e,o){return t(o.siteSettings)&&s(o.currentUser,i(o.siteSettings.post_ai_helper_allowed_groups))}})),define("discourse/plugins/discourse-ai/discourse/routes/admin-plugins-discourse-ai-ai-personas-index",["exports","discourse/routes/discourse"],(function(e,t){"use strict"
Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
e.default=t.default.extend({model(){return this.modelFor("adminPlugins.discourse-ai.ai-personas")}})})),define("discourse/plugins/discourse-ai/discourse/routes/admin-plugins-discourse-ai-ai-personas-new",["exports","discourse/routes/discourse"],(function(e,t){"use strict"
Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
e.default=t.default.extend({async model(){const e=this.store.createRecord("ai-persona")
return e.set("allowed_group_ids",[10]),e},setupController(e,t){this._super(e,t),e.set("allPersonas",this.modelFor("adminPlugins.discourse-ai.ai-personas"))}})})),define("discourse/plugins/discourse-ai/discourse/routes/admin-plugins-discourse-ai-ai-personas-show",["exports","discourse/routes/discourse"],(function(e,t){"use strict"
Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
e.default=t.default.extend({async model(e){const t=this.modelFor("adminPlugins.discourse-ai.ai-personas"),i=parseInt(e.id,10)
return t.findBy("id",i)},setupController(e,t){this._super(e,t),e.set("allPersonas",this.modelFor("adminPlugins.discourse-ai.ai-personas"))}})})),define("discourse/plugins/discourse-ai/discourse/routes/admin-plugins-discourse-ai-ai-personas",["exports","discourse/routes/discourse"],(function(e,t){"use strict"
Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
e.default=t.default.extend({async model(){return this.store.findAll("ai-persona")}})})),define("discourse/plugins/discourse-ai/discourse/routes/admin-plugins-discourse-ai-index",["exports","@ember/service","discourse/routes/discourse"],(function(e,t,i){"use strict"
Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
e.default=i.default.extend({router:(0,t.inject)(),beforeModel(){this.router.transitionTo("adminPlugins.discourse-ai.ai-personas")}})})),define("discourse/plugins/discourse-ai/discourse/templates/admin-dashboard-sentiment",["exports","@ember/template-factory"],(function(e,t){"use strict"
Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
e.default=(0,t.createTemplateFactory)({id:"nGq01/Xy",block:'[[[10,0],[14,0,"sentiment section"],[12],[1,"\\n  "],[10,0],[14,0,"period-section"],[12],[1,"\\n    "],[10,0],[14,0,"section-title"],[12],[1,"\\n      "],[10,"h2"],[12],[1,"\\n        "],[1,[28,[35,0],["discourse_ai.sentiments.dashboard.title"],null]],[1,"\\n      "],[13],[1,"\\n\\n      "],[8,[39,1],null,[["@period","@setPeriod","@startDate","@endDate","@setCustomDateRange"],[[30,0,["period"]],[30,0,["setPeriod"]],[30,0,["startDate"]],[30,0,["endDate"]],[30,0,["setCustomDateRange"]]]],null],[1,"\\n    "],[13],[1,"\\n  "],[13],[1,"\\n\\n  "],[10,0],[14,0,"section-body"],[12],[1,"\\n    "],[10,0],[14,0,"charts"],[12],[1,"\\n      "],[8,[39,2],null,[["@dataSourceName","@filters","@showHeader"],["overall_sentiment",[30,0,["filters"]],true]],null],[1,"\\n\\n      "],[8,[39,2],null,[["@dataSourceName","@filters","@showHeader"],["post_emotion",[30,0,["filters"]],true]],null],[1,"\\n    "],[13],[1,"\\n  "],[13],[1,"\\n"],[13]],[],false,["i18n","dashboard-period-selector","admin-report"]]',moduleName:"discourse/plugins/discourse-ai/discourse/templates/admin-dashboard-sentiment.hbs",isStrictMode:!1})})),define("discourse/plugins/discourse-ai/discourse/templates/admin-plugins/discourse-ai/ai-personas/index",["exports","@ember/template-factory"],(function(e,t){"use strict"
Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
e.default=(0,t.createTemplateFactory)({id:"+08OpQF9",block:'[[[8,[39,0],null,[["@personas"],[[30,0,["model"]]]],null]],[],false,["ai-persona-list-editor"]]',moduleName:"discourse/plugins/discourse-ai/discourse/templates/admin-plugins/discourse-ai/ai-personas/index.hbs",isStrictMode:!1})})),define("discourse/plugins/discourse-ai/discourse/templates/admin-plugins/discourse-ai/ai-personas/new",["exports","@ember/template-factory"],(function(e,t){"use strict"
Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
e.default=(0,t.createTemplateFactory)({id:"4OQ50K5K",block:'[[[8,[39,0],null,[["@personas","@currentPersona"],[[30,0,["allPersonas"]],[30,0,["model"]]]],null]],[],false,["ai-persona-list-editor"]]',moduleName:"discourse/plugins/discourse-ai/discourse/templates/admin-plugins/discourse-ai/ai-personas/new.hbs",isStrictMode:!1})})),define("discourse/plugins/discourse-ai/discourse/templates/admin-plugins/discourse-ai/ai-personas/show",["exports","@ember/template-factory"],(function(e,t){"use strict"
Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
e.default=(0,t.createTemplateFactory)({id:"4Vqg1JJH",block:'[[[8,[39,0],null,[["@personas","@currentPersona"],[[30,0,["allPersonas"]],[30,0,["model"]]]],null]],[],false,["ai-persona-list-editor"]]',moduleName:"discourse/plugins/discourse-ai/discourse/templates/admin-plugins/discourse-ai/ai-personas/show.hbs",isStrictMode:!1})})),define("discourse/plugins/discourse-ai/discourse/templates/connectors/after-d-editor/ai-helper-context-menu",["exports","@ember/template-factory"],(function(e,t){"use strict"
Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
e.default=(0,t.createTemplateFactory)({id:"9lPQdG4P",block:'[[[11,0],[4,[38,0],[[30,0,["setupContextMenu"]]],null],[12],[1,"\\n"],[41,[30,0,["showContextMenu"]],[[[1,"    "],[10,0],[14,0,"ai-helper-context-menu"],[12],[1,"\\n"],[41,[28,[37,2],[[30,0,["menuState"]],[30,0,["CONTEXT_MENU_STATES","triggers"]]],null],[[[1,"        "],[10,"ul"],[14,0,"ai-helper-context-menu__trigger"],[12],[1,"\\n          "],[10,"li"],[12],[1,"\\n            "],[8,[39,3],[[24,0,"btn-flat"]],[["@icon","@action","@label"],["discourse-sparkles",[30,0,["toggleAiHelperOptions"]],"discourse_ai.ai_helper.context_menu.trigger"]],null],[1,"\\n          "],[13],[1,"\\n        "],[13],[1,"\\n\\n"]],[]],[[[41,[28,[37,2],[[30,0,["menuState"]],[30,0,["CONTEXT_MENU_STATES","options"]]],null],[[[1,"        "],[10,"ul"],[14,0,"ai-helper-context-menu__options"],[12],[1,"\\n"],[42,[28,[37,5],[[28,[37,5],[[30,0,["helperOptions"]]],null]],null],null,[[[41,[28,[37,2],[[30,1,["name"]],"custom_prompt"],null],[[[1,"              "],[8,[39,6],null,[["@value","@promptArgs","@submit"],[[30,0,["customPromptValue"]],[30,1],[30,0,["updateSelected"]]]],null],[1,"\\n"]],[]],[[[1,"              "],[10,"li"],[15,"data-name",[30,1,["translated_name"]]],[15,"data-value",[30,1,["id"]]],[12],[1,"\\n                "],[8,[39,3],[[24,0,"btn-flat"]],[["@icon","@translatedLabel","@action"],[[30,1,["icon"]],[30,1,["translated_name"]],[28,[37,7],[[30,0,["updateSelected"]],[30,1]],null]]],null],[1,"\\n              "],[13],[1,"\\n"]],[]]]],[1]],null],[1,"        "],[13],[1,"\\n\\n"]],[]],[[[41,[28,[37,2],[[30,0,["menuState"]],[30,0,["CONTEXT_MENU_STATES","loading"]]],null],[[[1,"        "],[8,[39,8],null,[["@cancel"],[[30,0,["cancelAIAction"]]]],null],[1,"\\n\\n"]],[]],[[[41,[28,[37,2],[[30,0,["menuState"]],[30,0,["CONTEXT_MENU_STATES","review"]]],null],[[[1,"        "],[10,"ul"],[14,0,"ai-helper-context-menu__review"],[12],[1,"\\n          "],[10,"li"],[12],[1,"\\n            "],[8,[39,3],[[24,0,"btn-flat view-changes"]],[["@icon","@label","@action"],["exchange-alt","discourse_ai.ai_helper.context_menu.view_changes",[30,0,["viewChanges"]]]],null],[1,"\\n          "],[13],[1,"\\n          "],[10,"li"],[12],[1,"\\n            "],[8,[39,3],[[24,0,"btn-flat revert"]],[["@icon","@label","@action"],["undo","discourse_ai.ai_helper.context_menu.revert",[30,0,["undoAIAction"]]]],null],[1,"\\n          "],[13],[1,"\\n          "],[10,"li"],[12],[1,"\\n            "],[8,[39,3],[[24,0,"btn-flat confirm"]],[["@icon","@label","@action"],["check","discourse_ai.ai_helper.context_menu.confirm",[30,0,["confirmChanges"]]]],null],[1,"\\n          "],[13],[1,"\\n        "],[13],[1,"\\n\\n"]],[]],[[[41,[28,[37,2],[[30,0,["menuState"]],[30,0,["CONTEXT_MENU_STATES","resets"]]],null],[[[1,"        "],[10,"ul"],[14,0,"ai-helper-context-menu__resets"],[12],[1,"\\n          "],[10,"li"],[12],[1,"\\n            "],[8,[39,3],[[24,0,"btn-flat undo"]],[["@icon","@label","@action"],["undo","discourse_ai.ai_helper.context_menu.undo",[30,0,["undoAIAction"]]]],null],[1,"\\n          "],[13],[1,"\\n          "],[10,"li"],[12],[1,"\\n            "],[8,[39,3],[[24,0,"btn-flat"]],[["@icon","@label","@action"],["discourse-sparkles","discourse_ai.ai_helper.context_menu.regen",[28,[37,7],[[30,0,["updateSelected"]],[30,0,["lastUsedOption"]]],null]]],null],[1,"\\n          "],[13],[1,"\\n        "],[13],[1,"\\n      "]],[]],null]],[]]]],[]]]],[]]]],[]]],[1,"    "],[13],[1,"\\n"]],[]],null],[13],[1,"\\n\\n"],[41,[30,0,["showDiffModal"]],[[[1,"  "],[8,[39,9],null,[["@confirm","@diff","@oldValue","@newValue","@revert","@closeModal"],[[30,0,["confirmChanges"]],[30,0,["diff"]],[30,0,["initialValue"]],[30,0,["newSelectedText"]],[30,0,["undoAIAction"]],[28,[37,7],[[28,[37,10],[[30,0,["showDiffModal"]]],null],false],null]]],null],[1,"\\n"]],[]],null],[1,"\\n"],[41,[30,0,["showThumbnailModal"]],[[[1,"  "],[8,[39,11],null,[["@thumbnails","@closeModal"],[[30,0,["thumbnailSuggestions"]],[28,[37,7],[[28,[37,10],[[30,0,["showThumbnailModal"]]],null],false],null]]],null],[1,"\\n"]],[]],null]],["option"],false,["did-insert","if","eq","d-button","each","-track-array","ai-helper-custom-prompt","fn","ai-helper-loading","modal/diff-modal","mut","modal/thumbnail-suggestions"]]',moduleName:"discourse/plugins/discourse-ai/discourse/templates/connectors/after-d-editor/ai-helper-context-menu.hbs",isStrictMode:!1})})),define("discourse/plugins/discourse-ai/discourse/templates/connectors/after-d-editor/composer-open",["exports","@ember/template-factory"],(function(e,t){"use strict"
Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
e.default=(0,t.createTemplateFactory)({id:"+kLlck0i",block:'[[[41,[30,0,["isAiBotChat"]],[[[1,"  "],[8,[39,1],null,[["@bodyClass"],[[30,0,["aiBotClasses"]]]],null],[1,"\\n"],[41,[30,0,["renderChatWarning"]],[[[1,"    "],[10,0],[14,0,"ai-bot-chat-warning"],[12],[1,[28,[35,2],["discourse_ai.ai_bot.pm_warning"],null]],[13],[1,"\\n"]],[]],null]],[]],null]],[],false,["if","d-section","i18n"]]',moduleName:"discourse/plugins/discourse-ai/discourse/templates/connectors/after-d-editor/composer-open.hbs",isStrictMode:!1})})),define("discourse/plugins/discourse-ai/discourse/templates/connectors/topic-more-content/related-topics",["exports","@ember/template-factory"],(function(e,t){"use strict"
Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
e.default=(0,t.createTemplateFactory)({id:"6Oz8VQA3",block:'[[[11,0],[24,1,"related-topics"],[16,0,[29,["more-topics__list ",[52,[30,0,["hidden"]],"hidden"]]]],[24,"role","complementary"],[24,"aria-labelledby","related-topics-title"],[4,[38,1],[[30,0,["registerList"]]],null],[4,[38,2],[[30,0,["removeList"]]],null],[12],[1,"\\n  "],[10,"h3"],[14,1,"related-topics-title"],[14,0,"more-topics__list-title"],[12],[1,"\\n    "],[1,[28,[35,3],["discourse_ai.related_topics.title"],null]],[1,"\\n  "],[13],[1,"\\n  "],[10,0],[14,0,"topics"],[12],[1,"\\n    "],[8,[39,4],null,[["@topics"],[[30,0,["relatedTopics"]]]],null],[1,"\\n  "],[13],[1,"\\n"],[13]],[],false,["if","did-insert","will-destroy","i18n","basic-topic-list"]]',moduleName:"discourse/plugins/discourse-ai/discourse/templates/connectors/topic-more-content/related-topics.hbs",isStrictMode:!1})})),define("discourse/plugins/discourse-ai/discourse/widgets/ai-bot-header-panel-wrapper",["exports","@ember/object","discourse/widgets/render-glimmer","discourse/widgets/widget","@ember/template-factory"],(function(e,t,i,s,o){"use strict"
var r
function n(e,t,i,s,o){var r={}
return Object.keys(s).forEach((function(e){r[e]=s[e]})),r.enumerable=!!r.enumerable,r.configurable=!!r.configurable,("value"in r||r.initializer)&&(r.writable=!0),r=i.slice().reverse().reduce((function(i,s){return s(e,t,i)||i}),r),o&&void 0!==r.initializer&&(r.value=r.initializer?r.initializer.call(o):void 0,r.initializer=void 0),void 0===r.initializer&&(Object.defineProperty(e,t,r),r=null),r}Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
e.default=(n((r=class extends s.default{buildAttributes(){return{"data-click-outside":!0}}html(){return[new i.default(this,"div.widget-component-connector",(0,o.createTemplateFactory)({id:"w7fEG46j",block:'[[[8,[39,0],null,[["@closePanel"],[[30,1,["closePanel"]]]],null]],["@data"],false,["ai-bot-header-panel"]]',moduleName:"/var/www/discourse/app/assets/javascripts/discourse/discourse/plugins/discourse-ai/discourse/widgets/ai-bot-header-panel-wrapper.js",isStrictMode:!1}),{closePanel:this.closePanel})]}closePanel(){this.sendWidgetAction("hideAiBotPanel")}clickOutside(){this.closePanel()}}).prototype,"closePanel",[t.action],Object.getOwnPropertyDescriptor(r.prototype,"closePanel"),r.prototype),n(r.prototype,"clickOutside",[t.action],Object.getOwnPropertyDescriptor(r.prototype,"clickOutside"),r.prototype),r)})),define("discourse/plugins/discourse-ai/initializers/ai-bot-replies",["exports","discourse/lib/ajax","discourse/lib/ajax-error","discourse/lib/plugin-api","discourse/widgets/render-glimmer","discourse/plugins/discourse-ai/discourse/lib/ai-bot-helper","discourse/plugins/discourse-ai/discourse/components/modal/share-modal","discourse/plugins/discourse-ai/discourse/lib/ai-streamer","discourse/plugins/discourse-ai/discourse/lib/copy-conversation","@ember/template-factory"],(function(e,t,i,s,o,r,n,a,l,u){"use strict"
Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
function c(e){return e&&[-110,-111,-112,-113,-114,-115,-116].includes(e.id)}function d(e){const t=e.container.lookup("service:site-settings"),i=t.ai_bot_add_to_header?t.ai_bot_enabled_chat_bots.split("|").filter(Boolean):[]
i.length>0&&(e.attachWidgetAction("header","showAiBotPanel",(function(){this.state.botSelectorVisible=!0})),e.attachWidgetAction("header","hideAiBotPanel",(function(){this.state.botSelectorVisible=!1})),e.decorateWidget("header-icons:before",(e=>e.attach("header-dropdown",{title:"discourse_ai.ai_bot.shortcut_title",icon:"robot",action:"clickStartAiBotChat",active:!1,classNames:["ai-bot-button"]}))),1===i.length?e.attachWidgetAction("header","clickStartAiBotChat",(function(){(0,r.composeAiBotMessage)(i[0],e.container.lookup("service:composer"))})):e.attachWidgetAction("header","clickStartAiBotChat",(function(){this.sendWidgetAction("showAiBotPanel")})),e.addHeaderPanel("ai-bot-header-panel-wrapper","botSelectorVisible",(function(){return{}})))}function p(e){e.addPostMenuButton("cancel-gpt",(e=>{if(c(e.user))return{icon:"pause",action:"cancelStreaming",title:"discourse_ai.ai_bot.cancel_streaming",className:"btn btn-default cancel-streaming",position:"first"}})),e.attachWidgetAction("post","cancelStreaming",(function(){(0,t.ajax)(`/discourse-ai/ai-bot/post/${this.model.id}/stop-streaming`,{type:"POST"}).then((()=>{document.querySelector(`#post_${this.model.post_number}`).classList.remove("streaming")})).catch(i.popupAjaxError)})),e.modifyClass("controller:topic",{pluginId:"discourse-ai",onAIBotStreamedReply:function(e){(0,a.default)(this.model.postStream,e)},subscribe:function(){this._super(),this.model.isPrivateMessage&&this.model.details.allowed_users&&this.model.details.allowed_users.filter(c).length>=1&&this.messageBus.subscribe(`discourse-ai/ai-bot/topic/${this.model.id}`,this.onAIBotStreamedReply.bind(this),-2)},unsubscribe:function(){this.messageBus.unsubscribe("discourse-ai/ai-bot/topic/*"),this._super()}})}function m(e){let t=null
e.decorateWidget("poster-name:after",(i=>{if(c(i.attrs.user))return t=t||e.container.lookup("controller:topic"),i.widget.attach("persona-flair",{topicController:t})})),(0,o.registerWidgetShim)("persona-flair","span.persona-flair",(0,u.createTemplateFactory)({id:"9jYzNJdM",block:'[[[1,[30,1,["topicController","model","ai_persona_name"]]]],["@data"],false,[]]',moduleName:"/var/www/discourse/app/assets/javascripts/discourse/discourse/plugins/discourse-ai/initializers/ai-bot-replies.js",isStrictMode:!1}))}e.default={name:"discourse-ai-bot-replies",initialize(e){const t=e.lookup("service:site-settings"),i=e.lookup("service:current-user")
i?.ai_enabled_chat_bots&&(t.ai_bot_add_to_header&&(0,s.withPluginApi)("1.6.0",d),(0,s.withPluginApi)("1.6.0",p),(0,s.withPluginApi)("1.6.0",m),(0,s.withPluginApi)("1.22.0",(e=>function(e){const t=e.getCurrentUser()
if(!t||!t.ai_enabled_chat_bots)return
let i=async function(e){let{post:t,showFeedback:i}=e
t.post_number<=4?(await(0,l.default)(t.topic,1,t.post_number),i("discourse_ai.ai_bot.conversation_shared")):s.show(n.default,{model:t})}
e.addPostMenuButton("share",(e=>{if(t.ai_enabled_chat_bots.any((t=>e.username===t.username)))return{action:i,icon:"share",className:"post-action-menu__share",title:"discourse_ai.ai_bot.share",position:"first"}}))
const s=e.container.lookup("service:modal")}(e))))}}})),define("discourse/plugins/discourse-ai/initializers/ai-semantic-search",["exports","discourse/lib/api"],(function(e,t){"use strict"
Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
e.default=(0,t.apiInitializer)("1.15.0",(e=>{e.modifyClass("component:search-result-entry",{pluginId:"discourse-ai",classNameBindings:["bulkSelectEnabled","post.generatedByAI:ai-result"]})}))})),define("discourse/plugins/discourse-ai/initializers/related-topics",["exports","discourse/lib/plugin-api"],(function(e,t){"use strict"
Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
e.default={name:"discourse-ai-related-topics",initialize(e){e.lookup("service:site-settings").ai_embeddings_semantic_related_topics_enabled&&(0,t.withPluginApi)("1.1.0",(e=>{e.modifyClass("model:post-stream",{pluginId:"discourse-ai",_setSuggestedTopics(e){this._super(...arguments),e.related_topics&&this.topic.setProperties({related_topics:e.related_topics})}})}))}}})),define("discourse/plugins/discourse-ai/lib/discourse-markdown/ai-tags",["exports"],(function(e){"use strict"
Object.defineProperty(e,"__esModule",{value:!0}),e.setup=function(e){e.allowList(["details[class=ai-quote]"])}}))

//# sourceMappingURL=discourse-ai-67ea89297393fff1f3d83b1f070ad86c6cefcbec12956107e62a2eeb0f83885a.map
//!

;
