{"version":3,"sources":["webpack:///../WCC.UI/App/components/openAiCompletion/openAiCompletion.html?f429","webpack:///../WCC.UI/App/components/openAiCompletion/openAiCompletion.scss?0f90","webpack:///../WCC.UI/App/components/openAiCompletion/openAiCompletion.ts","webpack:///../WCC.UI/App/webpack/runtime/htmlExposer.js","webpack:///../WCC.UI/App/components/openAiCompletion/openAiCompletion.scss","webpack:///../WCC.UI/App/components/openAiCompletion/openAiCompletion.html"],"names":["content","expose","__esModule","default","api","module","i","options","exports","locals","GenerateCommentViewType","text","value","OpenAiCompletionView","constructor","data","isSelected","oIsSelected","ko","observable","this","type","title","icon","isSeparator","require","OpenAiCompletionSentence","oTranslationNeeded","_data$SuggestionText","_data$SuggestionTrans","cDisplayString","pureComputed","suggestionText","system","stripHtml","suggestionTranslatedText","SuggestionText","trim","SuggestionTranslatedText","OpenAiCompletion","config","info","_config$tasksSite","busy","oIsInSelectionState","notNativeSpeaker","WCC","Settings","NotNativeSpeaker","oThankYouCompletions","observableArray","oTellMeMoreCompletions","oGenerateCommentCompletions","cGenerationViewSelected","oSelectedView","cCompletionsToDisplay","enums","OpenAiReplySuggestionType","ThankYou","cHasCompletions","length","oCommentGenerationPrompt","commentGenerationPromptPlaceholder","labels","RequestACommentPrompt","generateBtnText","Generate","oCommentGenerationPromptFocused","onCompletionSelected","openAiCompletionCallback","onSuggestionsLoaded","suggestionsLoadedCallback","threadId","unwrap","tasksSite","translationNeeded","collapsedHeaderText","ReplySuggestionLabels","SuggestedResponses","OpenAiCompletionViews","ReplySuggestionThankYou","ReplySuggestionTellMeMore","TellMeMore","ReplySuggestionGenerateAComment","completionViews","map","t","fillSuggestions","replySuggestions","collapseIfCommented","cHasModReply","preLoadExisting","loadExistingCompletions","ref","switchToSelectionState","getNewCompletions","findViewByType","typeVal","_$find","_","find","v","exitSelectionState","selectCompletionView","switchState","getCompletions","hasModReplies","API","apiRequest","url","method","loadExisting","suggestions","e","showFailedRequestMessage","console","warn","forEach","s","SuggestionType","push","view","doNotLoadData","isNullOrWhitespace","showErrorMessage","Prompt","onCommentGenerationPromptKeyDown","obj","keyCode","getCommentGenerationCompletions","selectCompletion","sentence","__decorate","autobind","injectable","__param","inject","wccModules","componentConfig","componentInfo","SystemHelpers","html","getTemplatesAndResources","node","document","head","appendChild","___CSS_LOADER_API_IMPORT___"],"mappings":"qJAAA,UAAO,CACC,qHACA,wDAIC,KAJyC,EAAF,SAAYA,EAASC,GAGzD,OADAA,EADAD,EAAUA,EAAQE,WAAaF,EAAQG,QAAUH,GAE1CA,GACV,4B,kFCNT,IAAII,EAAM,EAAQ,gFACFJ,EAAU,EAAQ,gKAIC,iBAFvBA,EAAUA,EAAQE,WAAaF,EAAQG,QAAUH,KAG/CA,EAAU,CAAC,CAACK,EAAOC,EAAIN,EAAS,MAG9C,IAAIO,EAAU,CAEd,OAAiB,OACjB,WAAoB,GAEPH,EAAIJ,EAASO,GAI1BF,EAAOG,QAAUR,EAAQS,QAAU,I,u1BCkBnC,MAAMC,EAA0B,CAAEC,KAAM,WAAYC,OAAQ,GAE5D,MAAMC,EAQFC,YAAYC,EAAiCC,GAF7C,KAAAC,YAAcC,EAAGC,YAAW,GAGxBC,KAAKC,KAAON,EAAKH,MACjBQ,KAAKE,MAAQP,EAAKJ,KAClBS,KAAKG,KAAOR,EAAKQ,KACjBH,KAAKI,YAAkC,GAApBT,EAAKS,YAExBJ,KAAKH,YAAYD,IAINS,EAAQ,4CAE3B,MAAMC,EAYFZ,YAAYC,EAAmCY,GAAuC,IAAAC,EAAAC,EAAvC,KAAAF,qBAR/C,KAAAG,eAAiBZ,EAAGa,aAAa,KAC7B,IAAIC,EAAiBC,EAAOC,UAAUd,KAAKY,gBAI3C,OAHIZ,KAAKe,2BACLH,EAAiB,QAAQA,oEAAiFC,EAAOC,UAAUd,KAAKe,mCAE7HH,IAIPZ,KAAKY,eAAoC,OAAtBJ,EAAGb,EAAKqB,qBAAc,EAAnBR,EAAqBS,OAC3CjB,KAAKe,yBAAwD,OAAhCN,EA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I,MAAMN,EAAS,EAAQ,mCAAkB2G,cAEzC,OAAO,SAAUC,GACb5G,EAAO6G,yBAAyBD,GAC3BxB,SAAQ,SAAU0B,GAAQC,SAASC,KAAKC,YAAYH,QAEhE,+B,gLCLDvI,EADkC,EAAQ,wDAChC2I,EAA4B,IAE9B3B,KAAK,CAACnH,EAAOC,EAAI,8kEAA+kE,KAExmED,EAAOG,QAAUA,G,gICHjBH,EAAOG,QAFI","file":"308.494f4b354c92ec7b8aaf.js","sourcesContent":["define([\n \"!!../../../node_modules/html-loader/dist/cjs.js??ref--26-1!./openAiCompletion.html\", \n \"!../../webpack/runtime/htmlExposer.js\"], function (content, expose) {\n content = content.__esModule ? content.default : content;\n expose(content);\n return content;\n });","var api = require(\"!../../../node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js\");\n var content = require(\"!!../../../node_modules/css-loader/dist/cjs.js!../../../node_modules/sass-loader/dist/cjs.js!./openAiCompletion.scss\");\n\n content = content.__esModule ? content.default : content;\n\n if (typeof content === 'string') {\n content = [[module.id, content, '']];\n }\n\nvar options = {};\n\noptions.insert = \"head\";\noptions.singleton = false;\n\nvar update = api(content, options);\n\n\n\nmodule.exports = content.locals || {};","import './openAiCompletion.html';\r\nimport './openAiCompletion.scss';\r\n\r\nimport {inject, injectable} from \"inversify\";\r\nimport {wccModules} from \"enums/wccModules\";\r\nimport autobind from \"decorators/autobind\";\r\nimport {Observable, Subscribable} from \"knockout\";\r\nimport {EnumValue} from \"interfaces/enumValue\";\r\nimport {IOpenAiResponse, IReplySuggestionJson} from \"models/openAI\";\r\n\r\ninterface IOpenAiCompletionConfig {\r\n threadId: string\r\n replySuggestions: IReplySuggestionJson[]\r\n openAiCompletionCallback?: ((completion: string) => void) | undefined\r\n suggestionsLoadedCallback?: ((suggestion: IReplySuggestionJson[]) => void) | undefined\r\n ref: Observable\r\n cHasModReply: Subscribable\r\n collapseIfCommented: boolean\r\n preLoadExisting?: boolean\r\n tasksSite?: boolean\r\n translationNeeded: Observable\r\n}\r\n\r\nclass OpenAiResponse {\r\n constructor(public Response: IOpenAiResponse, public Type: EnumValue) {\r\n \r\n }\r\n}\r\n\r\ninterface IOpenAiCompletionViewType {\r\n text: string\r\n value: EnumValue\r\n icon: string\r\n isSeparator?: boolean\r\n}\r\n\r\nconst GenerateCommentViewType = { text: 'Generate', value: -1 };\r\n\r\nclass OpenAiCompletionView {\r\n type: EnumValue;\r\n title: string;\r\n icon: string;\r\n isSeparator: boolean;\r\n\r\n oIsSelected = ko.observable(false);\r\n \r\n constructor(data: IOpenAiCompletionViewType, isSelected: boolean) {\r\n this.type = data.value;\r\n this.title = data.text;\r\n this.icon = data.icon;\r\n this.isSeparator = data.isSeparator == true;\r\n \r\n this.oIsSelected(isSelected);\r\n }\r\n}\r\n\r\nconst _clipboard = require('Scripts/clipboard.2.0.0.min');\r\n\r\nclass OpenAiCompletionSentence {\r\n suggestionText: string;\r\n suggestionTranslatedText: string;\r\n \r\n cDisplayString = ko.pureComputed(() => {\r\n let suggestionText = system.stripHtml(this.suggestionText);\r\n if (this.suggestionTranslatedText) {\r\n suggestionText = `
${suggestionText}
${system.stripHtml(this.suggestionTranslatedText)}
`;\r\n }\r\n return suggestionText;\r\n });\r\n \r\n constructor(data: IReplySuggestionJson, public oTranslationNeeded: Observable) {\r\n this.suggestionText = data.SuggestionText?.trim();\r\n this.suggestionTranslatedText = data.SuggestionTranslatedText?.trim();\r\n }\r\n}\r\n\r\n@injectable()\r\nexport default class OpenAiCompletion {\r\n \r\n busy = ko.observable(false);\r\n oIsInSelectionState = ko.observable(false);\r\n\r\n notNativeSpeaker = WCC.Settings.NotNativeSpeaker === true;\r\n collapsedHeaderText: string;\r\n\r\n completionViews: OpenAiCompletionView[];\r\n oSelectedView: Observable;\r\n\r\n oThankYouCompletions = ko.observableArray();\r\n oTellMeMoreCompletions = ko.observableArray();\r\n oGenerateCommentCompletions = ko.observableArray();\r\n\r\n cGenerationViewSelected = ko.pureComputed(() => this.oSelectedView().type.value == GenerateCommentViewType.value);\r\n \r\n cCompletionsToDisplay = ko.pureComputed(() => {\r\n switch(this.oSelectedView().type.value) {\r\n case GenerateCommentViewType.value:\r\n return this.oGenerateCommentCompletions();\r\n \r\n case enums.OpenAiReplySuggestionType.ThankYou.value:\r\n return this.oThankYouCompletions();\r\n \r\n default:\r\n return this.oTellMeMoreCompletions();\r\n }\r\n });\r\n cHasCompletions = ko.pureComputed(() => this.cCompletionsToDisplay().length > 0);\r\n \r\n oTranslationNeeded: Observable\r\n\r\n oCommentGenerationPrompt = ko.observable('');\r\n commentGenerationPromptPlaceholder = labels.RequestACommentPrompt;\r\n generateBtnText = labels.Generate;\r\n oCommentGenerationPromptFocused = ko.observable(false);\r\n \r\n private onCompletionSelected: ((completion: string, translatedCompletion: string | undefined) => void) | undefined;\r\n private onSuggestionsLoaded: ((suggestions: IReplySuggestionJson[]) => void) | undefined;\r\n private threadId: string;\r\n private tasksSite: boolean;\r\n\r\n constructor(\r\n @inject(wccModules.componentConfig) private config: IOpenAiCompletionConfig,\r\n @inject(wccModules.componentInfo) info: ko.components.ComponentInfo,\r\n ) {\r\n this.onCompletionSelected = config.openAiCompletionCallback;\r\n this.onSuggestionsLoaded = config.suggestionsLoadedCallback;\r\n this.threadId = ko.unwrap(config.threadId);\r\n this.tasksSite = config.tasksSite ?? false;\r\n this.oTranslationNeeded = config.translationNeeded;\r\n\r\n this.collapsedHeaderText = this.notNativeSpeaker && WCC.Settings.ReplySuggestionLabels.SuggestedResponses\r\n ? WCC.Settings.ReplySuggestionLabels.SuggestedResponses : labels.SuggestedResponses;\r\n const OpenAiCompletionViews: IOpenAiCompletionViewType[] = [\r\n { \r\n text: this.notNativeSpeaker && WCC.Settings.ReplySuggestionLabels.ReplySuggestionThankYou \r\n ? WCC.Settings.ReplySuggestionLabels.ReplySuggestionThankYou : labels.ReplySuggestionThankYou, \r\n value: enums.OpenAiReplySuggestionType.ThankYou, \r\n icon: 'fal fa-hands-clapping' \r\n },\r\n { \r\n text: this.notNativeSpeaker && WCC.Settings.ReplySuggestionLabels.ReplySuggestionTellMeMore\r\n ? WCC.Settings.ReplySuggestionLabels.ReplySuggestionTellMeMore : labels.ReplySuggestionTellMeMore, \r\n value: enums.OpenAiReplySuggestionType.TellMeMore, \r\n icon: 'fal fa-comment-dots' },\r\n { text: '', value: { text: '', value: -2 }, icon: '', isSeparator: true },\r\n { \r\n text: this.notNativeSpeaker && WCC.Settings.ReplySuggestionLabels.ReplySuggestionGenerateAComment\r\n ? WCC.Settings.ReplySuggestionLabels.ReplySuggestionGenerateAComment : labels.ReplySuggestionGenerateAComment, \r\n value: GenerateCommentViewType, \r\n icon: 'fal fa-message-plus' },\r\n ];\r\n this.completionViews = OpenAiCompletionViews.map(t => \r\n new OpenAiCompletionView(t, t.value == enums.OpenAiReplySuggestionType.ThankYou));\r\n this.oSelectedView = ko.observable(this.completionViews[0]);\r\n \r\n this.fillSuggestions(ko.unwrap(config.replySuggestions));\r\n \r\n // config.cHasModReply() - this is not really working on tasks site\r\n if(ko.unwrap(config.replySuggestions).length && (!config.collapseIfCommented || !config.cHasModReply())) {\r\n this.oIsInSelectionState(true);\r\n }\r\n \r\n if(config.preLoadExisting) {\r\n this.loadExistingCompletions(!config.collapseIfCommented || !config.cHasModReply());\r\n }\r\n\r\n config.ref(this);\r\n }\r\n \r\n @autobind\r\n switchToSelectionState() {\r\n this.oIsInSelectionState(true);\r\n if(!this.cGenerationViewSelected())\r\n this.getNewCompletions();\r\n }\r\n \r\n findViewByType(typeVal: number) {\r\n return _.find(this.completionViews, v => v.type.value == typeVal) ?? this.completionViews[0];\r\n };\r\n \r\n @autobind\r\n exitSelectionState() {\r\n this.oIsInSelectionState(false);\r\n this.selectCompletionView(this.completionViews[0], true);\r\n }\r\n \r\n @autobind\r\n async loadExistingCompletions(switchState: boolean) {\r\n await this.getCompletions(true);\r\n \r\n if(this.cHasCompletions()) {\r\n let hasModReplies = false;\r\n if(this.tasksSite) {\r\n hasModReplies = await WCC.API.apiRequest({\r\n url: `threads/${this.threadId}/modReplies/count`,\r\n method: 'GET',\r\n }) != 0;\r\n }\r\n \r\n if(switchState && !hasModReplies) {\r\n this.oIsInSelectionState(true);\r\n }\r\n }\r\n }\r\n \r\n @autobind\r\n async getNewCompletions() {\r\n await this.getCompletions(false);\r\n }\r\n\r\n @autobind\r\n private async getCompletions(loadExisting: boolean) {\r\n if(this.busy())\r\n return;\r\n\r\n if(this.oSelectedView().type == enums.OpenAiReplySuggestionType.ThankYou) {\r\n if(this.oThankYouCompletions().length > 0) return;\r\n }\r\n else {\r\n if(this.oTellMeMoreCompletions().length > 0) return;\r\n }\r\n\r\n this.busy(true);\r\n try {\r\n const suggestions: IReplySuggestionJson[] = await WCC.API.apiRequest({\r\n url: `openai/threads/${this.threadId}/replySuggestions`,\r\n method: loadExisting ? 'GET' : 'POST',\r\n });\r\n \r\n this.fillSuggestions(suggestions);\r\n if(this.onSuggestionsLoaded)\r\n this.onSuggestionsLoaded(suggestions);\r\n }\r\n catch (e) {\r\n system.showFailedRequestMessage(e);\r\n console.warn(e);\r\n }\r\n this.busy(false);\r\n }\r\n \r\n fillSuggestions(suggestions: IReplySuggestionJson[]) {\r\n //console.log(suggestions)\r\n suggestions.forEach(s => {\r\n if(s.SuggestionType == enums.OpenAiReplySuggestionType.ThankYou.value)\r\n this.oThankYouCompletions.push(new OpenAiCompletionSentence(s, this.oTranslationNeeded));\r\n else\r\n this.oTellMeMoreCompletions.push(new OpenAiCompletionSentence(s, this.oTranslationNeeded));\r\n });\r\n }\r\n \r\n @autobind\r\n async selectCompletionView(view: OpenAiCompletionView, doNotLoadData: boolean = false) {\r\n if(view.oIsSelected()) return;\r\n this.oSelectedView().oIsSelected(false);\r\n view.oIsSelected(true);\r\n this.oSelectedView(view);\r\n \r\n if(view.type.value == GenerateCommentViewType.value) {\r\n this.oCommentGenerationPrompt('');\r\n this.oGenerateCommentCompletions([]);\r\n this.oCommentGenerationPromptFocused(true);\r\n }\r\n else {\r\n if(doNotLoadData === true) return;\r\n await this.getNewCompletions();\r\n }\r\n }\r\n \r\n @autobind\r\n async selectCompletionViewWithSwitch(view: OpenAiCompletionView) {\r\n await this.selectCompletionView(view);\r\n this.switchToSelectionState();\r\n }\r\n\r\n @autobind\r\n async getCommentGenerationCompletions() {\r\n if(system.isNullOrWhitespace(this.oCommentGenerationPrompt())) {\r\n system.showErrorMessage('Prompt is mandatory');\r\n return;\r\n }\r\n \r\n this.busy(true);\r\n try {\r\n const suggestions: IReplySuggestionJson[] = await WCC.API.apiRequest({\r\n url: `openai/threads/${this.threadId}/generateComments`,\r\n method: 'POST',\r\n data: {\r\n Prompt: this.oCommentGenerationPrompt()\r\n }\r\n });\r\n\r\n this.oGenerateCommentCompletions(suggestions.map(s => new OpenAiCompletionSentence(s, this.oTranslationNeeded)));\r\n }\r\n catch (e) {\r\n system.showFailedRequestMessage(e);\r\n console.warn(e);\r\n }\r\n this.busy(false);\r\n }\r\n \r\n @autobind\r\n onCommentGenerationPromptKeyDown(obj:any, e: JQuery.Event) { // JQueryEventObject\r\n switch (e.keyCode) {\r\n case 13:\r\n this.getCommentGenerationCompletions();\r\n return false;\r\n default:\r\n return true;\r\n }\r\n }\r\n \r\n @autobind\r\n selectCompletion(sentence: OpenAiCompletionSentence) {\r\n if(this.onCompletionSelected) {\r\n this.onCompletionSelected(sentence.suggestionText, sentence.suggestionTranslatedText);\r\n }\r\n this.exitSelectionState();\r\n }\r\n}","define(function () {\r\n const system = require('helpers/system').SystemHelpers;\r\n\r\n return function (html) {\r\n system.getTemplatesAndResources(html)\r\n .forEach(function (node) { document.head.appendChild(node) });\r\n }\r\n});","// Imports\nvar ___CSS_LOADER_API_IMPORT___ = require(\"../../../node_modules/css-loader/dist/runtime/api.js\");\nexports = ___CSS_LOADER_API_IMPORT___(false);\n// Module\nexports.push([module.id, \".open-ai-completion__container{display:flex;flex-direction:column;position:relative}.open-ai-completion__header{background-color:#48bcf5;color:#f5f9e8;padding:6px 10px}.open-ai-completion__header:hover{color:#f5f9e8}.open-ai-completion__header a{color:#364800;white-space:nowrap;max-width:130px;overflow:hidden;text-overflow:ellipsis}.open-ai-completion__header a:hover{color:#f5f9e8;border:none}.open-ai-completion__header-initial{cursor:pointer;display:flex;flex-direction:row;column-gap:8px;align-items:center}.open-ai-completion__header-filled{display:grid;grid-template-columns:1fr min-content;border-bottom:1px solid #0083c3;align-items:baseline}.open-ai-completion__header__links{grid-column:1;display:flex;flex-direction:row;column-gap:15px}.open-ai-completion__header__links a,.open-ai-completion__header__links a:hover{border-bottom:none !important}.open-ai-completion__header__links i{font-size:20px}.open-ai-completion__header__link_active{color:#f5f9e8}.open-ai-completion__header__buttons{grid-column:2;display:flex;flex-direction:row;column-gap:10px;align-content:flex-end}.open-ai-completion__header__buttons-btn{cursor:pointer;color:#f5f9e8}.open-ai-completion__header__buttons-btn:hover{color:#000}.open-ai-completion__header__buttons-cog{color:#f5f9e8}.open-ai-completion__completions-header{font-weight:bold;padding:4px 10px;color:#458bad;border-bottom:1px solid #b0cedb;background-color:#d9edff}.open-ai-completion__completion{background-color:#eef9ff;color:#676363;padding:10px;cursor:pointer;border-bottom:1px solid #d9e5ea}.open-ai-completion__completion:hover{background-color:#48bcf5;color:#f5f9e8}.open-ai-completion__completion__translation{font-style:italic;padding-top:5px;color:#1c1c1c}.open-ai-completion__no-completions-msg{background-color:#ffd09e;color:#676363;padding:10px;display:flex;flex-direction:column;row-gap:10px}.open-ai-completion__toolbar{border-top:1px solid #c6c6c6;border-radius:0 0 4px 4px;background-color:#f8f8f7;display:flex;justify-content:flex-end}.open-ai-completion__toolbar-btn{padding:6px 10px;cursor:pointer;border-color:#c6c6c6;background-color:#000;color:#fff}\", \"\"]);\n// Exports\nmodule.exports = exports;\n","// Module\nvar code = \"\";\n// Exports\nmodule.exports = code;"],"sourceRoot":""}