{"version":3,"file":"swapd-pm-notes.js","names":["define","_exports","_ajaxError","_ajax","_decorators","_formatter","_component","_htmlSafe","Object","defineProperty","value","default","extend","dt7948","p","classNames","editing","saving","note_copy","actions","edit","this","set","notes","get","note","cancel","save","ajax","type","data","then","result","catch","popupAjaxError","finally","date","time","Date","relativeAge","format","_templateFactory","createTemplateFactory","id","block","moduleName","isStrictMode"],"sources":["discourse/plugins/swapd-pm-notes/discourse/components/edit-pm-note.js","discourse/plugins/swapd-pm-notes/discourse/connectors/topic-above-suggested/pm-note.js","discourse/plugins/swapd-pm-notes/discourse/templates/components/edit-pm-note.js","discourse/plugins/swapd-pm-notes/discourse/templates/connectors/topic-above-suggested/pm-note.js"],"sourcesContent":["define(\"discourse/plugins/swapd-pm-notes/discourse/components/edit-pm-note\", [\"exports\", \"discourse/lib/ajax-error\", \"discourse/lib/ajax\", \"discourse-common/utils/decorators\", \"discourse/lib/formatter\", \"@ember/component\", \"discourse-common/helpers/html-safe\"], function (_exports, _ajaxError, _ajax, _decorators, _formatter, _component, _htmlSafe) {\n  \"use strict\";\n\n  Object.defineProperty(_exports, \"__esModule\", {\n    value: true\n  });\n  _exports.default = void 0;\n  var _default = _exports.default = _component.default.extend(dt7948.p({\n    classNames: [\"edit-pm-note\"],\n    editing: false,\n    saving: false,\n    note_copy: \"\",\n    actions: {\n      edit() {\n        this.set(\"editing\", true);\n        const notes = this.get(\"notes\");\n        if (notes) {\n          this.set(\"note_copy\", notes.note);\n        }\n      },\n      cancel() {\n        if (this.get(\"saving\")) return;\n        this.set(\"editing\", false);\n        this.set(\"note_copy\", \"\");\n      },\n      save() {\n        if (this.get(\"saving\")) return;\n        this.set(\"saving\", true);\n        (0, _ajax.ajax)(`/pm-notes/${this.get(\"topic.id\")}`, {\n          type: \"POST\",\n          data: {\n            note: this.get(\"note_copy\")\n          }\n        }).then(result => {\n          this.set(\"notes\", result);\n          this.set(\"editing\", false);\n        }).catch(_ajaxError.popupAjaxError).finally(() => {\n          this.set(\"saving\", false);\n        });\n      }\n    },\n    date(time) {\n      if (!time) return;\n      const date = new Date(time * 1000);\n      return (0, _htmlSafe.default)((0, _formatter.relativeAge)(date, {\n        format: \"medium-with-ago\"\n      }));\n    }\n  }, [[\"method\", \"date\", [(0, _decorators.default)(\"notes.time\")]]]));\n});","define(\"discourse/plugins/swapd-pm-notes/discourse/connectors/topic-above-suggested/pm-note\", [\"exports\"], function (_exports) {\n  \"use strict\";\n\n  Object.defineProperty(_exports, \"__esModule\", {\n    value: true\n  });\n  _exports.default = void 0;\n  var _default = _exports.default = {\n    // setupComponent({model}, component) {\n    //   component.set(\"topic\", model);\n    // }\n  };\n});","define(\"discourse/plugins/swapd-pm-notes/discourse/templates/components/edit-pm-note\", [\"exports\", \"@ember/template-factory\"], function (_exports, _templateFactory) {\n  \"use strict\";\n\n  Object.defineProperty(_exports, \"__esModule\", {\n    value: true\n  });\n  _exports.default = void 0;\n  var _default = _exports.default = (0, _templateFactory.createTemplateFactory)(\n  /*\n    <h3>\n    {{d-icon \"edit\" class=\"pm-notes-edit\"}}\n  \n    {{#if this.notes}}\n      {{bound-avatar-template this.notes.avatar \"small\"}}\n    {{/if}}\n  \n    {{i18n \"pm_notes.notes\"}}\n  \n    {{#if this.notes}}\n      -\n      {{i18n \"pm_notes.last_edited_by\"}}\n      {{this.notes.username}}\n      -\n      {{{this.date}}}\n    {{/if}}\n  \n    {{#unless this.editing}}\n      {{d-button\n        action=(action \"edit\")\n        icon=\"pencil\"\n        class=\"btn-flat fright\"}}\n    {{/unless}}\n  </h3>\n  \n  {{#if this.editing}}\n    <Textarea @value={{this.note_copy}} rows=\"5\" />\n  \n    <div>\n      {{d-button\n        action=(action \"cancel\")\n        label=\"cancel\"\n        class=\"btn-danger\"\n        disabled=this.saving}}\n  \n        {{d-button\n          action=(action \"save\")\n          label=\"save\"\n          class=\"btn-primary\"\n          disabled=this.saving}}\n    </div>\n  {{else}}\n    {{#if this.notes}}\n      <div class=\"pm-notes\">{{this.notes.note}}</div>\n    {{/if}}\n  {{/if}}\n  \n  */\n  {\n    \"id\": \"yg81lk07\",\n    \"block\": \"[[[10,\\\"h3\\\"],[12],[1,\\\"\\\\n  \\\"],[1,[28,[35,1],[\\\"edit\\\"],[[\\\"class\\\"],[\\\"pm-notes-edit\\\"]]]],[1,\\\"\\\\n\\\\n\\\"],[41,[30,0,[\\\"notes\\\"]],[[[1,\\\"    \\\"],[1,[28,[35,3],[[30,0,[\\\"notes\\\",\\\"avatar\\\"]],\\\"small\\\"],null]],[1,\\\"\\\\n\\\"]],[]],null],[1,\\\"\\\\n  \\\"],[1,[28,[35,4],[\\\"pm_notes.notes\\\"],null]],[1,\\\"\\\\n\\\\n\\\"],[41,[30,0,[\\\"notes\\\"]],[[[1,\\\"    -\\\\n    \\\"],[1,[28,[35,4],[\\\"pm_notes.last_edited_by\\\"],null]],[1,\\\"\\\\n    \\\"],[1,[30,0,[\\\"notes\\\",\\\"username\\\"]]],[1,\\\"\\\\n    -\\\\n    \\\"],[2,[30,0,[\\\"date\\\"]]],[1,\\\"\\\\n\\\"]],[]],null],[1,\\\"\\\\n\\\"],[41,[51,[30,0,[\\\"editing\\\"]]],[[[1,\\\"    \\\"],[1,[28,[35,6],null,[[\\\"action\\\",\\\"icon\\\",\\\"class\\\"],[[28,[37,7],[[30,0],\\\"edit\\\"],null],\\\"pencil\\\",\\\"btn-flat fright\\\"]]]],[1,\\\"\\\\n\\\"]],[]],null],[13],[1,\\\"\\\\n\\\\n\\\"],[41,[30,0,[\\\"editing\\\"]],[[[1,\\\"  \\\"],[8,[39,8],[[24,\\\"rows\\\",\\\"5\\\"]],[[\\\"@value\\\"],[[30,0,[\\\"note_copy\\\"]]]],null],[1,\\\"\\\\n  \\\"],[10,0],[12],[1,\\\"\\\\n    \\\"],[1,[28,[35,6],null,[[\\\"action\\\",\\\"label\\\",\\\"class\\\",\\\"disabled\\\"],[[28,[37,7],[[30,0],\\\"cancel\\\"],null],\\\"cancel\\\",\\\"btn-danger\\\",[30,0,[\\\"saving\\\"]]]]]],[1,\\\"\\\\n\\\\n      \\\"],[1,[28,[35,6],null,[[\\\"action\\\",\\\"label\\\",\\\"class\\\",\\\"disabled\\\"],[[28,[37,7],[[30,0],\\\"save\\\"],null],\\\"save\\\",\\\"btn-primary\\\",[30,0,[\\\"saving\\\"]]]]]],[1,\\\"\\\\n  \\\"],[13],[1,\\\"\\\\n\\\"]],[]],[[[41,[30,0,[\\\"notes\\\"]],[[[1,\\\"    \\\"],[10,0],[14,0,\\\"pm-notes\\\"],[12],[1,[30,0,[\\\"notes\\\",\\\"note\\\"]]],[13],[1,\\\"\\\\n\\\"]],[]],null]],[]]]],[],false,[\\\"h3\\\",\\\"d-icon\\\",\\\"if\\\",\\\"bound-avatar-template\\\",\\\"i18n\\\",\\\"unless\\\",\\\"d-button\\\",\\\"action\\\",\\\"textarea\\\",\\\"div\\\"]]\",\n    \"moduleName\": \"discourse/plugins/swapd-pm-notes/discourse/templates/components/edit-pm-note.hbs\",\n    \"isStrictMode\": false\n  });\n});","define(\"discourse/plugins/swapd-pm-notes/discourse/templates/connectors/topic-above-suggested/pm-note\", [\"exports\", \"@ember/template-factory\"], function (_exports, _templateFactory) {\n  \"use strict\";\n\n  Object.defineProperty(_exports, \"__esModule\", {\n    value: true\n  });\n  _exports.default = void 0;\n  var _default = _exports.default = (0, _templateFactory.createTemplateFactory)(\n  /*\n    {{#if this.siteSettings.pm_notes_enabled}}\n    {{#if this.currentUser.staff}}\n      {{#if this.args.model.isPrivateMessage}}\n        {{edit-pm-note topic=this.args.model notes=this.args.model.pm_notes}}\n      {{/if}}\n    {{/if}}\n  {{/if}}\n  \n  */\n  {\n    \"id\": \"qT/4mZgS\",\n    \"block\": \"[[[41,[30,0,[\\\"siteSettings\\\",\\\"pm_notes_enabled\\\"]],[[[41,[30,0,[\\\"currentUser\\\",\\\"staff\\\"]],[[[41,[30,0,[\\\"args\\\",\\\"model\\\",\\\"isPrivateMessage\\\"]],[[[1,\\\"      \\\"],[1,[28,[35,1],null,[[\\\"topic\\\",\\\"notes\\\"],[[30,0,[\\\"args\\\",\\\"model\\\"]],[30,0,[\\\"args\\\",\\\"model\\\",\\\"pm_notes\\\"]]]]]],[1,\\\"\\\\n\\\"]],[]],null]],[]],null]],[]],null]],[],false,[\\\"if\\\",\\\"edit-pm-note\\\"]]\",\n    \"moduleName\": \"discourse/plugins/swapd-pm-notes/discourse/templates/connectors/topic-above-suggested/pm-note.hbs\",\n    \"isStrictMode\": false\n  });\n});"],"mappings":"AAAAA,OAAA,gQAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,GACA;AAEAC,OAAAC,eAAAR,EAAA,cACAS,OAAA,IAEAT,EAAAU,aAAA;AACAV,EAAAU,QAAAL,EAAAK,QAAAC,OAAAC,OAAAC,EAAA,CACAC,WAAA,iBACAC,SAAA,EACAC,QAAA,EACAC,UAAA,GACAC,QAAA,CACA,IAAAC,GACAC,KAAAC,IAAA;AACA,MAAAC,EAAAF,KAAAG,IAAA;AACAD,GACAF,KAAAC,IAAA,YAAAC,EAAAE,KAEA,EACA,MAAAC,GACAL,KAAAG,IAAA,YACAH,KAAAC,IAAA,cACAD,KAAAC,IAAA,gBACA,EACA,IAAAK,GACAN,KAAAG,IAAA,YACAH,KAAAC,IAAA,cACA,EAAAnB,EAAAyB,MAAA,aAAAP,KAAAG,IAAA,eACAK,KAAA,OACAC,KAAA,CACAL,KAAAJ,KAAAG,IAAA,gBAEAO,KAAAC,IACAX,KAAAC,IAAA,QAAAU,GACAX,KAAAC,IAAA,gBACAW,MAAA/B,EAAAgC,gBAAAC,QAAA,KACAd,KAAAC,IAAA,eAEA,GAEA,IAAAc,CAAAC,GACA,IAAAA,EAAA;AACA,MAAAD,EAAA,IAAAE,KAAA,IAAAD;AACA,SAAA9B,EAAAI,UAAA,EAAAN,EAAAkC,aAAAH,EAAA,CACAI,OAAA,oBAEA,GACA,sBAAApC,EAAAO,SAAA,kB,GChDAX,OAAA,2GAAAC,GACA;AAEAO,OAAAC,eAAAR,EAAA,cACAS,OAAA,IAEAT,EAAAU,aAAA;AACAV,EAAAU,QAAA,CAIA,C,GCXAX,OAAA,8HAAAC,EAAAwC,GACA;AAEAjC,OAAAC,eAAAR,EAAA,cACAS,OAAA,IAEAT,EAAAU,aAAA;AACAV,EAAAU,SAAA,EAAA8B,EAAAC,uBAkDA,CACAC,GAAA,WACAC,MAAA,k2CACAC,WAAA,mFACAC,cAAA,G,GC7DA9C,OAAA,+IAAAC,EAAAwC,GACA;AAEAjC,OAAAC,eAAAR,EAAA,cACAS,OAAA,IAEAT,EAAAU,aAAA;AACAV,EAAAU,SAAA,EAAA8B,EAAAC,uBAWA,CACAC,GAAA,WACAC,MAAA,0UACAC,WAAA,oGACAC,cAAA,G","ignoreList":[]}