@limetech/lime-crm-building-blocks 1.117.0 → 1.117.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## [1.117.1](https://github.com/Lundalogik/lime-crm-building-blocks/compare/v1.117.0...v1.117.1) (2026-04-29)
2
+
3
+ ### Bug Fixes
4
+
5
+
6
+ * **text-editor:** use download URL for image uploads ([147c12e](https://github.com/Lundalogik/lime-crm-building-blocks/commit/147c12ee6d1169104cc74d277134461b5c296bd2))
7
+
1
8
  ## [1.117.0](https://github.com/Lundalogik/lime-crm-building-blocks/compare/v1.116.6...v1.117.0) (2026-04-28)
2
9
 
3
10
  ### Features
@@ -1074,20 +1074,21 @@ class UploadHandler {
1074
1074
  return uploadedFile;
1075
1075
  }
1076
1076
  /**
1077
- * Extracts a file ID from a image source string.
1077
+ * Extracts a file ID from an image source string.
1078
1078
  *
1079
- * This function parses a URL to find a file ID that appears before
1080
- * '/contents/' at the end of the URL.
1079
+ * Matches a file ID that appears before '/download/' (current URL
1080
+ * format) or '/contents/' (legacy URL format, kept for historical
1081
+ * HTML stored before the switch to '/download/').
1081
1082
  *
1082
1083
  * @param src - The URL string to parse
1083
1084
  * @returns The extracted file ID or undefined if no match is found
1084
1085
  *
1085
1086
  * @example
1086
1087
  * // Returns 123
1087
- * parseFileIdFromSrc('/api/file/123/contents/');
1088
+ * parseFileIdFromSrc('/api/file/123/download/');
1088
1089
  *
1089
1090
  * @example
1090
- * // Returns 456
1091
+ * // Returns 456 (legacy URL)
1091
1092
  * parseFileIdFromSrc('https://example.com/limepkg-email/api/v1/file/456/contents/');
1092
1093
  *
1093
1094
  * @example
@@ -1096,7 +1097,7 @@ class UploadHandler {
1096
1097
  */
1097
1098
  parseFileIdFromSrc(src) {
1098
1099
  if (src) {
1099
- const regex = /\/(\d+)\/contents\/?$/;
1100
+ const regex = /\/(\d+)\/(?:download|contents)\/?$/;
1100
1101
  const matches = regex.exec(src);
1101
1102
  if (matches && matches[1]) {
1102
1103
  return Number(matches[1]);
@@ -1145,7 +1146,7 @@ class UploadHandler {
1145
1146
  imageUpload.contentType = response.contentType;
1146
1147
  imageUpload.size = response.size;
1147
1148
  imageUpload.state = 'done';
1148
- imageUpload.href = (_a = response._links) === null || _a === void 0 ? void 0 : _a.contents.href;
1149
+ imageUpload.href = (_a = response._links) === null || _a === void 0 ? void 0 : _a.download.href;
1149
1150
  return imageUpload;
1150
1151
  }
1151
1152
  get http() {
@@ -32,20 +32,21 @@ export class UploadHandler {
32
32
  return uploadedFile;
33
33
  }
34
34
  /**
35
- * Extracts a file ID from a image source string.
35
+ * Extracts a file ID from an image source string.
36
36
  *
37
- * This function parses a URL to find a file ID that appears before
38
- * '/contents/' at the end of the URL.
37
+ * Matches a file ID that appears before '/download/' (current URL
38
+ * format) or '/contents/' (legacy URL format, kept for historical
39
+ * HTML stored before the switch to '/download/').
39
40
  *
40
41
  * @param src - The URL string to parse
41
42
  * @returns The extracted file ID or undefined if no match is found
42
43
  *
43
44
  * @example
44
45
  * // Returns 123
45
- * parseFileIdFromSrc('/api/file/123/contents/');
46
+ * parseFileIdFromSrc('/api/file/123/download/');
46
47
  *
47
48
  * @example
48
- * // Returns 456
49
+ * // Returns 456 (legacy URL)
49
50
  * parseFileIdFromSrc('https://example.com/limepkg-email/api/v1/file/456/contents/');
50
51
  *
51
52
  * @example
@@ -54,7 +55,7 @@ export class UploadHandler {
54
55
  */
55
56
  parseFileIdFromSrc(src) {
56
57
  if (src) {
57
- const regex = /\/(\d+)\/contents\/?$/;
58
+ const regex = /\/(\d+)\/(?:download|contents)\/?$/;
58
59
  const matches = regex.exec(src);
59
60
  if (matches && matches[1]) {
60
61
  return Number(matches[1]);
@@ -103,7 +104,7 @@ export class UploadHandler {
103
104
  imageUpload.contentType = response.contentType;
104
105
  imageUpload.size = response.size;
105
106
  imageUpload.state = 'done';
106
- imageUpload.href = (_a = response._links) === null || _a === void 0 ? void 0 : _a.contents.href;
107
+ imageUpload.href = (_a = response._links) === null || _a === void 0 ? void 0 : _a.download.href;
107
108
  return imageUpload;
108
109
  }
109
110
  get http() {
@@ -1 +1 @@
1
- import{proxyCustomElement as t,HTMLElement as e,createEvent as i,h as s,transformTag as r}from"@stencil/core/internal/client";import{n,Z as o,Q as a,j as h}from"./index.esm.js";import{A as c,E as u,b as l,a as d,T as f}from"./keycodes.js";import{U as m,S as b,g as v}from"./_Uint8Array.js";import{d as p}from"./_defineProperty.js";import{e as g}from"./_MapCache.js";import{o as y,d as j,g as w,f as x,n as O,a as k}from"./_getTag.js";import{d as S,S as I,i as E,a as T,r as C}from"./_Map.js";import{c as A}from"./random-string.js";import{h as M,a as P,b as F}from"./limetype.js";import{i as _}from"./non-null.js";import{d as N}from"./empty-state.js";import{d as z}from"./text-editor-picker.js";import{i as D}from"./isSymbol.js";var L=/\s/,Q=/^\s+/;var R=/^[-+]0x[0-9a-f]+$/i,U=/^0b[01]+$/i,$=/^0o[0-7]+$/i,G=parseInt;function q(t){if("number"==typeof t)return t;if(D(t))return NaN;if(S(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=S(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=function(t){return t?t.slice(0,function(t){for(var e=t.length;e--&&L.test(t.charAt(e)););return e}(t)+1).replace(Q,""):t}(t);var i=U.test(t);return i||$.test(t)?G(t.slice(2),i?2:8):R.test(t)?NaN:+t}var W=Object.create,B=function(){function t(){}return function(e){if(!S(e))return{};if(W)return W(e);t.prototype=e;var i=new t;return t.prototype=void 0,i}}(),H=Object.prototype.hasOwnProperty;var K=y(Object.getPrototypeOf,Object);"object"==typeof exports&&exports&&!exports.nodeType&&exports&&"object"==typeof module&&module&&!module.nodeType&&module;var V=Object.prototype.hasOwnProperty;function Z(t){var e=new t.constructor(t.byteLength);return new m(e).set(new m(t)),e}var J=/\w*$/,X=I?I.prototype:void 0,Y=X?X.valueOf:void 0;var tt=O&&O.isMap,et=tt?x(tt):function(t){return E(t)&&"[object Map]"==w(t)},it=O&&O.isSet,st=it?x(it):function(t){return E(t)&&"[object Set]"==w(t)},rt="[object Arguments]",nt="[object Function]",ot="[object Object]",at={};function ht(t,e,i,s,r,n){var o;if(void 0!==o)return o;if(!S(t))return t;var a=T(t);if(a)o=function(t){var e=t.length,i=new t.constructor(e);return e&&"string"==typeof t[0]&&V.call(t,"index")&&(i.index=t.index,i.input=t.input),i}(t);else{var h=w(t),c=h==nt||"[object GeneratorFunction]"==h;if(k(t))return function(t){return t.slice()}(t);if(h==ot||h==rt||c&&!r)o=c?{}:function(t){return"function"!=typeof t.constructor||j(t)?{}:B(K(t))}(t);else{if(!at[h])return r?t:{};o=function(t,e){var i=t.constructor;switch(e){case"[object ArrayBuffer]":return Z(t);case"[object Boolean]":case"[object Date]":return new i(+t);case"[object DataView]":return function(t){var e=Z(t.buffer);return new t.constructor(e,t.byteOffset,t.byteLength)}(t);case"[object Float32Array]":case"[object Float64Array]":case"[object Int8Array]":case"[object Int16Array]":case"[object Int32Array]":case"[object Uint8Array]":case"[object Uint8ClampedArray]":case"[object Uint16Array]":case"[object Uint32Array]":return function(t){var e=Z(t.buffer);return new t.constructor(e,t.byteOffset,t.length)}(t);case"[object Map]":case"[object Set]":return new i;case"[object Number]":case"[object String]":return new i(t);case"[object RegExp]":return function(t){var e=new t.constructor(t.source,J.exec(t));return e.lastIndex=t.lastIndex,e}(t);case"[object Symbol]":return function(t){return Y?Object(Y.call(t)):{}}(t)}}(t,h)}}n||(n=new b);var u=n.get(t);if(u)return u;n.set(t,o),st(t)?t.forEach((function(s){o.add(ht(s,e,i,0,t,n))})):et(t)&&t.forEach((function(s,r){o.set(r,ht(s,e,i,0,t,n))}));var l=a?void 0:v(t);return function(t,e){for(var i=-1,s=null==t?0:t.length;++i<s&&!1!==e(t[i],i););}(l||t,(function(s,r){l&&(s=t[r=s]),function(t,e,i){var s=t[e];H.call(t,e)&&g(s,i)&&(void 0!==i||e in t)||function(t,e,i){"__proto__"==e&&p?p(t,e,{configurable:!0,enumerable:!0,value:i,writable:!0}):t[e]=i}(t,e,i)}(o,r,ht(s,e,i,0,t,n))})),o}at[rt]=at["[object Array]"]=at["[object ArrayBuffer]"]=at["[object DataView]"]=at["[object Boolean]"]=at["[object Date]"]=at["[object Float32Array]"]=at["[object Float64Array]"]=at["[object Int8Array]"]=at["[object Int16Array]"]=at["[object Int32Array]"]=at["[object Map]"]=at["[object Number]"]=at[ot]=at["[object RegExp]"]=at["[object Set]"]=at["[object String]"]=at["[object Symbol]"]=at["[object Uint8Array]"]=at["[object Uint8ClampedArray]"]=at["[object Uint16Array]"]=at["[object Uint32Array]"]=!0,at["[object Error]"]=at[nt]=at["[object WeakMap]"]=!1;var ct=function(){return C.Date.now()},ut=Math.max,lt=Math.min;function dt(t,e){return t.map(((t,i)=>{const s=function(t){return ht(t,5)}(t);return Object.assign(Object.assign({},s),{selected:i===e})}))}class ft{get limeObjectService(){return this.platform.get(n.LimeObjectRepository)}get queryService(){return this.platform.get(n.Query)}get viewFactoryRegistry(){return this.platform.get(n.ViewFactoryRegistry)}get translator(){var t;return null===(t=this.platform)||void 0===t?void 0:t.get(n.Translate)}get triggerCharacter(){return this._triggerCharacter}get triggerHandler(){return this._triggerHandler}constructor(t,e,i){this.platform=t,this.context=e,this.searchableLimetypes=i,this.groupCounts={},this._triggerCharacter="@",this._triggerHandler={searcher:t=>this.searcher(t),inserter:(t,e)=>this.inserter(t,e),emptySearchMessage:"Start typing a name...",noItemsFoundMessage:"No results for your search...",nodeDefinition:{customElement:{tagName:"limebb-mention",attributes:["limetype","objectid","href"]},mapAttributes:t=>({limetype:t.value.getLimetype().name,objectid:t.value.id,href:`object/${this.context.limetype}/${this.context.id}`})}},this.searcher=async t=>{if(!t)return[];const{objects:e}=await this.limeObjectService.search(t,this.searchableLimetypes,10);return this.createSearchListItems(e)},this.inserter=async(t,e)=>{var i;const s=this.triggerHandler.nodeDefinition;s&&t.insert({node:{tagName:s.customElement.tagName,attributes:s.mapAttributes(e)},children:[null===(i=e.value)||void 0===i?void 0:i.descriptive]})}}async initialize(){await this.loadGroupCounts()}async loadGroupCounts(){const t=this.searchableLimetypes.filter((t=>!P(t,"user")&&M(t,"user"))).map((t=>this.getGroupCounts(t)));for(const e of await Promise.all(t))Object.assign(this.groupCounts,e)}async getGroupCounts(t){var e;const i=F(t,"user"),s=t.name;try{const t=await this.queryService.execute({limetype:s,responseFormat:{object:{_id:null,[i.name]:{count:{aggregate:{op:o.Count}}}}}});if(!(null===(e=t.objects)||void 0===e?void 0:e.length))return{[s]:{}};const r=this.createGroupCount(t.objects,i.name);return{[s]:r}}catch(e){return console.error("Error fetching group count for limetype: "+t.name,e),{[s]:{}}}}createGroupCount(t,e){const i={};for(const s of t){const{_id:t,[e]:r}=s;i[t]=r.count}return i}createSearchListItems(t=[]){return t.map((t=>this.createSearchListItem(t))).filter(_)}createSearchListItem(t){const e=this.viewFactoryRegistry.getFactory("search"),i=this.limeObjectService.getObject(t._limetype,t._id);if(!i)return null;const s=e(i,this.context),r=this.getGroupCountComponent(i);return Object.assign(Object.assign({},s),r?{primaryComponent:r}:{})}getGroupCountComponent(t){var e;const i=t.getLimetype(),s=null===(e=this.groupCounts[i.name])||void 0===e?void 0:e[t.id],r=F(i,"user");if(void 0!==s&&r)return{name:"limebb-mention-group-counter",props:{count:s,limetype:r.relation.getLimetype(),helperLabel:this.translator.get("webclient.notification-center.members-will-be-notified")}}}}class mt{constructor(t,e){this.file=t,this.http=e,this.uploadCancelled=!1,this.getUrl=t=>"api/v1/file/"+(null!=t?t:"")}async initialize(){this.uploadService=await this.http.createFileUpload(a.Post,this.getUrl(),this.file),this.progressCallback&&(this.uploadService.onProgress=this.progressCallback)}async upload(){return this.uploadService.upload()}getFileName(){return this.file.name}cancel(){this.uploadService.cancel(),this.uploadCancelled=!0}set onProgress(t){this.progressCallback=t,this.uploadService&&(this.uploadService.onProgress=t)}}class bt{constructor(t){this.platform=t}async handleImagePasted(t){const e=null==t?void 0:t.fileInfo;if(!e)return;if(!this.validateImageSize(e))return;t.insertThumbnail();const i=await this.createFileUpload(e),s=null==i?void 0:i.href;return s&&void 0!==(null==i?void 0:i.fileId)?t.insertImage(s):t.insertFailedThumbnail(),i}parseFileIdFromSrc(t){if(t){const e=/\/(\d+)\/contents\/?$/.exec(t);if(e&&e[1])return Number(e[1])}}validateImageSize(t){return!!t.fileContent&&t.fileContent.size<=52428800}async createFileUpload(t){var e;if(!t.fileContent)return;const i=new mt(t.fileContent,this.http);await i.initialize();const s=Object.assign(Object.assign({},t),{progress:0,file:i,state:"added",fileId:void 0,href:void 0,id:t.id});i.onProgress=t=>{0===s.progress&&(s.state="uploading"),s.progress=t,100===t&&(s.state="finalizing")};const r=await i.upload();return s.fileId=r.id,s.filename=r.filename,s.extension=r.extension,s.contentType=r.contentType,s.size=r.size,s.state="done",s.href=null===(e=r._links)||void 0===e?void 0:e.contents.href,s}get http(){return this.platform.get(n.Http)}}const vt=t(class extends e{watchOpen(){this.setupHandlers(),this.setPickerMessage()}watchQuery(){this.setPickerMessage()}constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.change=i(this,"change",7),this.metadataChange=i(this,"metadataChange",7),this.allowMentioning=!1,this.contentType="markdown",this.language="en",this.disabled=!1,this.readonly=!1,this.invalid=!1,this.required=!1,this.ui="standard",this.allowResize=!0,this.value="",this.triggerMap={},this.customElements=[],this.allowInlineImages=!1,this.items=[],this.highlightedItemIndex=0,this.isPickerOpen=!1,this.isSearching=!1,this.registeredTriggers=[],this.registeredTriggerMap=this.triggerMap,this.registeredCustomElements=this.customElements,this.activeTrigger=void 0,this.handleMouseClick=t=>{this.textEditorPickerElement&&(t.target===this.textEditorPickerElement||this.resetTriggerAndPicker())},this.handleKeyPress=t=>{if(!this.isPickerOpen||!this.activeTrigger)return;if(![u,l,c,d,f].includes(t.key))return;if(t.stopPropagation(),t.preventDefault(),"keyup"===t.type)return;const e={[u]:this.handleEscapeKey,[d]:this.handleEnterOrTabKey,[f]:this.handleEnterOrTabKey,[c]:this.handleArrowKeyPress,[l]:this.handleArrowKeyPress}[t.key];e&&e(t)},this.handleArrowKeyPress=t=>{this.highlightedItemIndex=this.findNonSeparatorIndex(t.key,this.highlightedItemIndex)},this.findNonSeparatorIndex=(t,e,i=0)=>{if(0===this.items.length||i>this.items.length)return e;const s=((t,e,i)=>(e+(t===c?1:-1)+i)%i)(t,e,this.items.length);return this.isListSeparator(this.items[s])?this.findNonSeparatorIndex(t,s,i+1):s},this.handleEscapeKey=()=>{var t;null===(t=this.triggerFunction)||void 0===t||t.stopTrigger(),this.resetTriggerAndPicker()},this.handleEnterOrTabKey=t=>{this.handleItemSelection(t)},this.handleMetadataChange=t=>{t.stopPropagation();const e=t.detail,i=this.getEnhancedImages(e.images||[]),s=Object.assign(Object.assign({},e),{images:i});this.metadataChange.emit(s)},this.handleImagePasted=t=>{t.stopPropagation(),this.allowInlineImages&&this.uploadHandler.handleImagePasted(t.detail)},this.handleTriggerStart=t=>{t.stopPropagation(),this.activeTrigger=t.detail.trigger,this.triggerFunction=t.detail.textEditor,this.isPickerOpen=!0},this.handleTriggerStop=t=>{t.stopPropagation(),this.resetTriggerAndPicker()},this.handleTriggerChange=t=>{var e;t.stopImmediatePropagation(),this.editorPickerQuery=t.detail.value;const i=null===(e=this.registeredTriggerMap[t.detail.trigger])||void 0===e?void 0:e.searcher;i&&(this.isSearching=!0,this.debouncedSearchFn(i,this.editorPickerQuery))},this.resetTriggerAndPicker=()=>{this.isPickerOpen=!1,this.activeTrigger=void 0,this.triggerFunction=void 0,this.isSearching=!1,this.highlightedItemIndex=0,this.items=[]},this.handleItemSelection=t=>{var e;let i;if(t instanceof CustomEvent)i=t.detail;else{if(!(t instanceof KeyboardEvent))return;{const t=this.items[this.highlightedItemIndex];if(this.isListSeparator(t))return;i=t}}if(!this.activeTrigger||(null==i?void 0:i.disabled))return;const s=this.registeredTriggerMap[this.activeTrigger];try{s.inserter(this.triggerFunction,i)}catch(t){console.error("Error inserting",t)}this.resetTriggerAndPicker(),null===(e=this.textEditor)||void 0===e||e.focus()},this.handleVisibilityChange=()=>{"hidden"===document.visibilityState&&this.saveDraft()},this.handleBeforeUnload=()=>{this.saveDraft()},this.portalId=A(),this.debouncedSearchFn=function(t,e,i){var s,r,n,o,a,h,c=0,u=!1,l=!1,d=!0;if("function"!=typeof t)throw new TypeError("Expected a function");function f(e){var i=s,n=r;return s=r=void 0,c=e,o=t.apply(n,i)}function m(t){var i=t-h;return void 0===h||i>=e||i<0||l&&t-c>=n}function b(){var t=ct();if(m(t))return v(t);a=setTimeout(b,function(t){var i=e-(t-h);return l?lt(i,n-(t-c)):i}(t))}function v(t){return a=void 0,d&&s?f(t):(s=r=void 0,o)}function p(){var t=ct(),i=m(t);if(s=arguments,r=this,h=t,i){if(void 0===a)return function(t){return c=t,a=setTimeout(b,e),u?f(t):o}(h);if(l)return clearTimeout(a),a=setTimeout(b,e),f(h)}return void 0===a&&(a=setTimeout(b,e)),o}return e=q(e)||0,S(i)&&(u=!!i.leading,n=(l="maxWait"in i)?ut(q(i.maxWait)||0,e):n,d="trailing"in i?!!i.trailing:d),p.cancel=function(){void 0!==a&&clearTimeout(a),c=0,s=h=r=a=void 0},p.flush=function(){return void 0===a?o:v(ct())},p}((async(t,e)=>{try{const i=await t(e);if(e!==this.editorPickerQuery||!this.activeTrigger)return;this.items=i}catch(t){console.error("Error searching",t)}finally{this.isSearching=!1}}),300)}connectedCallback(){var t,e,i,s;if(this.draftIdentifier){const r=null!==(e=null===(t=this.context)||void 0===t?void 0:t.id)&&void 0!==e?e:"no-limeobject",n=null!==(s=null===(i=this.context)||void 0===i?void 0:i.limetype)&&void 0!==s?s:"no-limetype";this.textEditorInnerId=["text-editor-draft",n,r,this.draftIdentifier].join("-")}this.textEditorInnerId&&(document.addEventListener("visibilitychange",this.handleVisibilityChange),window.addEventListener("beforeunload",this.handleBeforeUnload)),this.uploadHandler=new bt(this.platform)}componentWillLoad(){this.allowMentioning&&this.registerMentions(),this.registerTriggers(),this.loadDraft()}disconnectedCallback(){document.removeEventListener("visibilitychange",this.handleVisibilityChange),window.removeEventListener("beforeunload",this.handleBeforeUnload),document.removeEventListener("mousedown",this.handleMouseClick),this.saveDraft(),this.host&&(this.host.removeEventListener("keyup",this.handleKeyPress,{capture:!0}),this.host.removeEventListener("keydown",this.handleKeyPress,{capture:!0})),this.debouncedSearchFn&&this.debouncedSearchFn.cancel&&this.debouncedSearchFn.cancel()}registerMentions(){const t=new ft(this.platform,this.context,this.searchableLimetypes),e=t.triggerHandler.nodeDefinition;e&&(this.registeredCustomElements.push(e.customElement),this.registeredTriggerMap[t.triggerCharacter]=t.triggerHandler,t.initialize())}registerTriggers(){this.registeredTriggers=Object.keys(this.registeredTriggerMap)}setPickerMessage(){var t;if(!this.activeTrigger)return;const e=this.registeredTriggerMap[this.activeTrigger];this.pickerMessage=(null===(t=this.editorPickerQuery)||void 0===t?void 0:t.length)>0?e.noItemsFoundMessage:e.emptySearchMessage}setupHandlers(){this.isPickerOpen?(this.host.addEventListener("keyup",this.handleKeyPress,{capture:!0}),this.host.addEventListener("keydown",this.handleKeyPress,{capture:!0}),document.addEventListener("mousedown",this.handleMouseClick)):(this.host.removeEventListener("keyup",this.handleKeyPress,{capture:!0}),this.host.removeEventListener("keydown",this.handleKeyPress,{capture:!0}),document.removeEventListener("mousedown",this.handleMouseClick))}isListSeparator(t){return"separator"in t&&!0===t.separator}render(){return[s("limel-text-editor",{key:"9cd16fcb065db254b472f33f31d5b28abf2ca760",ref:t=>this.textEditor=t,tabindex:this.disabled?-1:0,value:this.value,contentType:this.contentType,customElements:this.registeredCustomElements,"aria-disabled":this.disabled,language:this.language,triggers:this.registeredTriggers,onTriggerStart:this.handleTriggerStart,onTriggerStop:this.handleTriggerStop,onTriggerChange:this.handleTriggerChange,onImagePasted:this.handleImagePasted,onMetadataChange:this.handleMetadataChange,ui:this.ui,allowResize:this.allowResize,required:this.required,disabled:this.disabled,readonly:this.readonly,helperText:this.helperText,placeholder:this.placeholder,label:this.label,invalid:this.invalid}),this.renderPicker()]}renderPicker(){if(this.isPickerOpen)return s("limel-portal",{containerId:this.portalId,visible:this.isPickerOpen,openDirection:"top",inheritParentWidth:!0,anchor:this.textEditor},s("limebb-text-editor-picker",{ref:t=>this.textEditorPickerElement=t,items:dt(this.items,this.highlightedItemIndex),onItemSelected:this.handleItemSelection,emptyMessage:this.pickerMessage,isSearching:this.isSearching}))}getEnhancedImages(t){return t.map((t=>{let e;return"success"===t.state&&(e=this.uploadHandler.parseFileIdFromSrc(t.src)),e?Object.assign(Object.assign({},t),{fileId:e}):t}))}loadDraft(){if(!this.userDataService||!this.textEditorInnerId)return;if(this.value)return;const t=this.userDataService.get(this.textEditorInnerId);t&&this.change.emit(t)}saveDraft(){var t,e,i,s;if(!this.textEditorInnerId)return;const r=null===(t=this.value)||void 0===t?void 0:t.trim(),n=null===(e=this.userDataService)||void 0===e?void 0:e.get(this.textEditorInnerId);r&&r!==n?null===(i=this.userDataService)||void 0===i||i.set(this.textEditorInnerId,r):!r&&n&&(null===(s=this.userDataService)||void 0===s||s.set(this.textEditorInnerId,void 0))}get userDataService(){return this.platform.get(n.UserDataRepository)}static get delegatesFocus(){return!0}get host(){return this}static get watchers(){return{isPickerOpen:[{watchOpen:0}],editorPickerQuery:[{watchQuery:0}]}}static get style(){return":host(limebb-text-editor){display:block;width:100%;min-width:5rem;min-height:5rem;height:100%;max-height:var(--text-editor-max-height, calc(100vh - (env(safe-area-inset-top) + env(safe-area-inset-bottom)) - 4rem))}"}},[17,"limebb-text-editor",{platform:[16],context:[16],allowMentioning:[4,"allow-mentioning"],contentType:[1,"content-type"],language:[513],disabled:[516],readonly:[516],helperText:[513,"helper-text"],placeholder:[513],label:[513],invalid:[516],required:[516],selectedContext:[16],ui:[513],allowResize:[4,"allow-resize"],value:[1],draftIdentifier:[1,"draft-identifier"],triggerMap:[16],customElements:[16],allowInlineImages:[4,"allow-inline-images"],items:[32],highlightedItemIndex:[32],editorPickerQuery:[32],searchableLimetypes:[32],isPickerOpen:[32],isSearching:[32]},void 0,{isPickerOpen:[{watchOpen:0}],editorPickerQuery:[{watchQuery:0}]}]);!function(t,e,i,s){var r,n=arguments.length,o=n<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(t,e,i,s);else for(var a=t.length-1;a>=0;a--)(r=t[a])&&(o=(n<3?r(o):n>3?r(e,i,o):r(e,i))||o);n>3&&o&&Object.defineProperty(e,i,o)}([h({map:[function(t){return Object.values(t).filter((t=>P(t,"user")||M(t,"user")))}]})],vt.prototype,"searchableLimetypes",void 0);const pt=vt,gt=function(){"undefined"!=typeof customElements&&["limebb-text-editor","limebb-empty-state","limebb-text-editor-picker"].forEach((t=>{switch(t){case"limebb-text-editor":customElements.get(r(t))||customElements.define(r(t),vt);break;case"limebb-empty-state":customElements.get(r(t))||N();break;case"limebb-text-editor-picker":customElements.get(r(t))||z()}}))};export{pt as LimebbTextEditor,gt as defineCustomElement}
1
+ import{proxyCustomElement as t,HTMLElement as e,createEvent as i,h as s,transformTag as r}from"@stencil/core/internal/client";import{n,Z as o,Q as a,j as h}from"./index.esm.js";import{A as c,E as u,b as l,a as d,T as f}from"./keycodes.js";import{U as m,S as b,g as v}from"./_Uint8Array.js";import{d as p}from"./_defineProperty.js";import{e as g}from"./_MapCache.js";import{o as y,d as j,g as w,f as x,n as O,a as k}from"./_getTag.js";import{d as S,S as I,i as E,a as T,r as C}from"./_Map.js";import{c as A}from"./random-string.js";import{h as M,a as P,b as F}from"./limetype.js";import{i as _}from"./non-null.js";import{d as N}from"./empty-state.js";import{d as z}from"./text-editor-picker.js";import{i as D}from"./isSymbol.js";var L=/\s/,Q=/^\s+/;var R=/^[-+]0x[0-9a-f]+$/i,U=/^0b[01]+$/i,$=/^0o[0-7]+$/i,G=parseInt;function q(t){if("number"==typeof t)return t;if(D(t))return NaN;if(S(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=S(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=function(t){return t?t.slice(0,function(t){for(var e=t.length;e--&&L.test(t.charAt(e)););return e}(t)+1).replace(Q,""):t}(t);var i=U.test(t);return i||$.test(t)?G(t.slice(2),i?2:8):R.test(t)?NaN:+t}var W=Object.create,B=function(){function t(){}return function(e){if(!S(e))return{};if(W)return W(e);t.prototype=e;var i=new t;return t.prototype=void 0,i}}(),H=Object.prototype.hasOwnProperty;var K=y(Object.getPrototypeOf,Object);"object"==typeof exports&&exports&&!exports.nodeType&&exports&&"object"==typeof module&&module&&!module.nodeType&&module;var V=Object.prototype.hasOwnProperty;function Z(t){var e=new t.constructor(t.byteLength);return new m(e).set(new m(t)),e}var J=/\w*$/,X=I?I.prototype:void 0,Y=X?X.valueOf:void 0;var tt=O&&O.isMap,et=tt?x(tt):function(t){return E(t)&&"[object Map]"==w(t)},it=O&&O.isSet,st=it?x(it):function(t){return E(t)&&"[object Set]"==w(t)},rt="[object Arguments]",nt="[object Function]",ot="[object Object]",at={};function ht(t,e,i,s,r,n){var o;if(void 0!==o)return o;if(!S(t))return t;var a=T(t);if(a)o=function(t){var e=t.length,i=new t.constructor(e);return e&&"string"==typeof t[0]&&V.call(t,"index")&&(i.index=t.index,i.input=t.input),i}(t);else{var h=w(t),c=h==nt||"[object GeneratorFunction]"==h;if(k(t))return function(t){return t.slice()}(t);if(h==ot||h==rt||c&&!r)o=c?{}:function(t){return"function"!=typeof t.constructor||j(t)?{}:B(K(t))}(t);else{if(!at[h])return r?t:{};o=function(t,e){var i=t.constructor;switch(e){case"[object ArrayBuffer]":return Z(t);case"[object Boolean]":case"[object Date]":return new i(+t);case"[object DataView]":return function(t){var e=Z(t.buffer);return new t.constructor(e,t.byteOffset,t.byteLength)}(t);case"[object Float32Array]":case"[object Float64Array]":case"[object Int8Array]":case"[object Int16Array]":case"[object Int32Array]":case"[object Uint8Array]":case"[object Uint8ClampedArray]":case"[object Uint16Array]":case"[object Uint32Array]":return function(t){var e=Z(t.buffer);return new t.constructor(e,t.byteOffset,t.length)}(t);case"[object Map]":case"[object Set]":return new i;case"[object Number]":case"[object String]":return new i(t);case"[object RegExp]":return function(t){var e=new t.constructor(t.source,J.exec(t));return e.lastIndex=t.lastIndex,e}(t);case"[object Symbol]":return function(t){return Y?Object(Y.call(t)):{}}(t)}}(t,h)}}n||(n=new b);var u=n.get(t);if(u)return u;n.set(t,o),st(t)?t.forEach((function(s){o.add(ht(s,e,i,0,t,n))})):et(t)&&t.forEach((function(s,r){o.set(r,ht(s,e,i,0,t,n))}));var l=a?void 0:v(t);return function(t,e){for(var i=-1,s=null==t?0:t.length;++i<s&&!1!==e(t[i],i););}(l||t,(function(s,r){l&&(s=t[r=s]),function(t,e,i){var s=t[e];H.call(t,e)&&g(s,i)&&(void 0!==i||e in t)||function(t,e,i){"__proto__"==e&&p?p(t,e,{configurable:!0,enumerable:!0,value:i,writable:!0}):t[e]=i}(t,e,i)}(o,r,ht(s,e,i,0,t,n))})),o}at[rt]=at["[object Array]"]=at["[object ArrayBuffer]"]=at["[object DataView]"]=at["[object Boolean]"]=at["[object Date]"]=at["[object Float32Array]"]=at["[object Float64Array]"]=at["[object Int8Array]"]=at["[object Int16Array]"]=at["[object Int32Array]"]=at["[object Map]"]=at["[object Number]"]=at[ot]=at["[object RegExp]"]=at["[object Set]"]=at["[object String]"]=at["[object Symbol]"]=at["[object Uint8Array]"]=at["[object Uint8ClampedArray]"]=at["[object Uint16Array]"]=at["[object Uint32Array]"]=!0,at["[object Error]"]=at[nt]=at["[object WeakMap]"]=!1;var ct=function(){return C.Date.now()},ut=Math.max,lt=Math.min;function dt(t,e){return t.map(((t,i)=>{const s=function(t){return ht(t,5)}(t);return Object.assign(Object.assign({},s),{selected:i===e})}))}class ft{get limeObjectService(){return this.platform.get(n.LimeObjectRepository)}get queryService(){return this.platform.get(n.Query)}get viewFactoryRegistry(){return this.platform.get(n.ViewFactoryRegistry)}get translator(){var t;return null===(t=this.platform)||void 0===t?void 0:t.get(n.Translate)}get triggerCharacter(){return this._triggerCharacter}get triggerHandler(){return this._triggerHandler}constructor(t,e,i){this.platform=t,this.context=e,this.searchableLimetypes=i,this.groupCounts={},this._triggerCharacter="@",this._triggerHandler={searcher:t=>this.searcher(t),inserter:(t,e)=>this.inserter(t,e),emptySearchMessage:"Start typing a name...",noItemsFoundMessage:"No results for your search...",nodeDefinition:{customElement:{tagName:"limebb-mention",attributes:["limetype","objectid","href"]},mapAttributes:t=>({limetype:t.value.getLimetype().name,objectid:t.value.id,href:`object/${this.context.limetype}/${this.context.id}`})}},this.searcher=async t=>{if(!t)return[];const{objects:e}=await this.limeObjectService.search(t,this.searchableLimetypes,10);return this.createSearchListItems(e)},this.inserter=async(t,e)=>{var i;const s=this.triggerHandler.nodeDefinition;s&&t.insert({node:{tagName:s.customElement.tagName,attributes:s.mapAttributes(e)},children:[null===(i=e.value)||void 0===i?void 0:i.descriptive]})}}async initialize(){await this.loadGroupCounts()}async loadGroupCounts(){const t=this.searchableLimetypes.filter((t=>!P(t,"user")&&M(t,"user"))).map((t=>this.getGroupCounts(t)));for(const e of await Promise.all(t))Object.assign(this.groupCounts,e)}async getGroupCounts(t){var e;const i=F(t,"user"),s=t.name;try{const t=await this.queryService.execute({limetype:s,responseFormat:{object:{_id:null,[i.name]:{count:{aggregate:{op:o.Count}}}}}});if(!(null===(e=t.objects)||void 0===e?void 0:e.length))return{[s]:{}};const r=this.createGroupCount(t.objects,i.name);return{[s]:r}}catch(e){return console.error("Error fetching group count for limetype: "+t.name,e),{[s]:{}}}}createGroupCount(t,e){const i={};for(const s of t){const{_id:t,[e]:r}=s;i[t]=r.count}return i}createSearchListItems(t=[]){return t.map((t=>this.createSearchListItem(t))).filter(_)}createSearchListItem(t){const e=this.viewFactoryRegistry.getFactory("search"),i=this.limeObjectService.getObject(t._limetype,t._id);if(!i)return null;const s=e(i,this.context),r=this.getGroupCountComponent(i);return Object.assign(Object.assign({},s),r?{primaryComponent:r}:{})}getGroupCountComponent(t){var e;const i=t.getLimetype(),s=null===(e=this.groupCounts[i.name])||void 0===e?void 0:e[t.id],r=F(i,"user");if(void 0!==s&&r)return{name:"limebb-mention-group-counter",props:{count:s,limetype:r.relation.getLimetype(),helperLabel:this.translator.get("webclient.notification-center.members-will-be-notified")}}}}class mt{constructor(t,e){this.file=t,this.http=e,this.uploadCancelled=!1,this.getUrl=t=>"api/v1/file/"+(null!=t?t:"")}async initialize(){this.uploadService=await this.http.createFileUpload(a.Post,this.getUrl(),this.file),this.progressCallback&&(this.uploadService.onProgress=this.progressCallback)}async upload(){return this.uploadService.upload()}getFileName(){return this.file.name}cancel(){this.uploadService.cancel(),this.uploadCancelled=!0}set onProgress(t){this.progressCallback=t,this.uploadService&&(this.uploadService.onProgress=t)}}class bt{constructor(t){this.platform=t}async handleImagePasted(t){const e=null==t?void 0:t.fileInfo;if(!e)return;if(!this.validateImageSize(e))return;t.insertThumbnail();const i=await this.createFileUpload(e),s=null==i?void 0:i.href;return s&&void 0!==(null==i?void 0:i.fileId)?t.insertImage(s):t.insertFailedThumbnail(),i}parseFileIdFromSrc(t){if(t){const e=/\/(\d+)\/(?:download|contents)\/?$/.exec(t);if(e&&e[1])return Number(e[1])}}validateImageSize(t){return!!t.fileContent&&t.fileContent.size<=52428800}async createFileUpload(t){var e;if(!t.fileContent)return;const i=new mt(t.fileContent,this.http);await i.initialize();const s=Object.assign(Object.assign({},t),{progress:0,file:i,state:"added",fileId:void 0,href:void 0,id:t.id});i.onProgress=t=>{0===s.progress&&(s.state="uploading"),s.progress=t,100===t&&(s.state="finalizing")};const r=await i.upload();return s.fileId=r.id,s.filename=r.filename,s.extension=r.extension,s.contentType=r.contentType,s.size=r.size,s.state="done",s.href=null===(e=r._links)||void 0===e?void 0:e.download.href,s}get http(){return this.platform.get(n.Http)}}const vt=t(class extends e{watchOpen(){this.setupHandlers(),this.setPickerMessage()}watchQuery(){this.setPickerMessage()}constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.change=i(this,"change",7),this.metadataChange=i(this,"metadataChange",7),this.allowMentioning=!1,this.contentType="markdown",this.language="en",this.disabled=!1,this.readonly=!1,this.invalid=!1,this.required=!1,this.ui="standard",this.allowResize=!0,this.value="",this.triggerMap={},this.customElements=[],this.allowInlineImages=!1,this.items=[],this.highlightedItemIndex=0,this.isPickerOpen=!1,this.isSearching=!1,this.registeredTriggers=[],this.registeredTriggerMap=this.triggerMap,this.registeredCustomElements=this.customElements,this.activeTrigger=void 0,this.handleMouseClick=t=>{this.textEditorPickerElement&&(t.target===this.textEditorPickerElement||this.resetTriggerAndPicker())},this.handleKeyPress=t=>{if(!this.isPickerOpen||!this.activeTrigger)return;if(![u,l,c,d,f].includes(t.key))return;if(t.stopPropagation(),t.preventDefault(),"keyup"===t.type)return;const e={[u]:this.handleEscapeKey,[d]:this.handleEnterOrTabKey,[f]:this.handleEnterOrTabKey,[c]:this.handleArrowKeyPress,[l]:this.handleArrowKeyPress}[t.key];e&&e(t)},this.handleArrowKeyPress=t=>{this.highlightedItemIndex=this.findNonSeparatorIndex(t.key,this.highlightedItemIndex)},this.findNonSeparatorIndex=(t,e,i=0)=>{if(0===this.items.length||i>this.items.length)return e;const s=((t,e,i)=>(e+(t===c?1:-1)+i)%i)(t,e,this.items.length);return this.isListSeparator(this.items[s])?this.findNonSeparatorIndex(t,s,i+1):s},this.handleEscapeKey=()=>{var t;null===(t=this.triggerFunction)||void 0===t||t.stopTrigger(),this.resetTriggerAndPicker()},this.handleEnterOrTabKey=t=>{this.handleItemSelection(t)},this.handleMetadataChange=t=>{t.stopPropagation();const e=t.detail,i=this.getEnhancedImages(e.images||[]),s=Object.assign(Object.assign({},e),{images:i});this.metadataChange.emit(s)},this.handleImagePasted=t=>{t.stopPropagation(),this.allowInlineImages&&this.uploadHandler.handleImagePasted(t.detail)},this.handleTriggerStart=t=>{t.stopPropagation(),this.activeTrigger=t.detail.trigger,this.triggerFunction=t.detail.textEditor,this.isPickerOpen=!0},this.handleTriggerStop=t=>{t.stopPropagation(),this.resetTriggerAndPicker()},this.handleTriggerChange=t=>{var e;t.stopImmediatePropagation(),this.editorPickerQuery=t.detail.value;const i=null===(e=this.registeredTriggerMap[t.detail.trigger])||void 0===e?void 0:e.searcher;i&&(this.isSearching=!0,this.debouncedSearchFn(i,this.editorPickerQuery))},this.resetTriggerAndPicker=()=>{this.isPickerOpen=!1,this.activeTrigger=void 0,this.triggerFunction=void 0,this.isSearching=!1,this.highlightedItemIndex=0,this.items=[]},this.handleItemSelection=t=>{var e;let i;if(t instanceof CustomEvent)i=t.detail;else{if(!(t instanceof KeyboardEvent))return;{const t=this.items[this.highlightedItemIndex];if(this.isListSeparator(t))return;i=t}}if(!this.activeTrigger||(null==i?void 0:i.disabled))return;const s=this.registeredTriggerMap[this.activeTrigger];try{s.inserter(this.triggerFunction,i)}catch(t){console.error("Error inserting",t)}this.resetTriggerAndPicker(),null===(e=this.textEditor)||void 0===e||e.focus()},this.handleVisibilityChange=()=>{"hidden"===document.visibilityState&&this.saveDraft()},this.handleBeforeUnload=()=>{this.saveDraft()},this.portalId=A(),this.debouncedSearchFn=function(t,e,i){var s,r,n,o,a,h,c=0,u=!1,l=!1,d=!0;if("function"!=typeof t)throw new TypeError("Expected a function");function f(e){var i=s,n=r;return s=r=void 0,c=e,o=t.apply(n,i)}function m(t){var i=t-h;return void 0===h||i>=e||i<0||l&&t-c>=n}function b(){var t=ct();if(m(t))return v(t);a=setTimeout(b,function(t){var i=e-(t-h);return l?lt(i,n-(t-c)):i}(t))}function v(t){return a=void 0,d&&s?f(t):(s=r=void 0,o)}function p(){var t=ct(),i=m(t);if(s=arguments,r=this,h=t,i){if(void 0===a)return function(t){return c=t,a=setTimeout(b,e),u?f(t):o}(h);if(l)return clearTimeout(a),a=setTimeout(b,e),f(h)}return void 0===a&&(a=setTimeout(b,e)),o}return e=q(e)||0,S(i)&&(u=!!i.leading,n=(l="maxWait"in i)?ut(q(i.maxWait)||0,e):n,d="trailing"in i?!!i.trailing:d),p.cancel=function(){void 0!==a&&clearTimeout(a),c=0,s=h=r=a=void 0},p.flush=function(){return void 0===a?o:v(ct())},p}((async(t,e)=>{try{const i=await t(e);if(e!==this.editorPickerQuery||!this.activeTrigger)return;this.items=i}catch(t){console.error("Error searching",t)}finally{this.isSearching=!1}}),300)}connectedCallback(){var t,e,i,s;if(this.draftIdentifier){const r=null!==(e=null===(t=this.context)||void 0===t?void 0:t.id)&&void 0!==e?e:"no-limeobject",n=null!==(s=null===(i=this.context)||void 0===i?void 0:i.limetype)&&void 0!==s?s:"no-limetype";this.textEditorInnerId=["text-editor-draft",n,r,this.draftIdentifier].join("-")}this.textEditorInnerId&&(document.addEventListener("visibilitychange",this.handleVisibilityChange),window.addEventListener("beforeunload",this.handleBeforeUnload)),this.uploadHandler=new bt(this.platform)}componentWillLoad(){this.allowMentioning&&this.registerMentions(),this.registerTriggers(),this.loadDraft()}disconnectedCallback(){document.removeEventListener("visibilitychange",this.handleVisibilityChange),window.removeEventListener("beforeunload",this.handleBeforeUnload),document.removeEventListener("mousedown",this.handleMouseClick),this.saveDraft(),this.host&&(this.host.removeEventListener("keyup",this.handleKeyPress,{capture:!0}),this.host.removeEventListener("keydown",this.handleKeyPress,{capture:!0})),this.debouncedSearchFn&&this.debouncedSearchFn.cancel&&this.debouncedSearchFn.cancel()}registerMentions(){const t=new ft(this.platform,this.context,this.searchableLimetypes),e=t.triggerHandler.nodeDefinition;e&&(this.registeredCustomElements.push(e.customElement),this.registeredTriggerMap[t.triggerCharacter]=t.triggerHandler,t.initialize())}registerTriggers(){this.registeredTriggers=Object.keys(this.registeredTriggerMap)}setPickerMessage(){var t;if(!this.activeTrigger)return;const e=this.registeredTriggerMap[this.activeTrigger];this.pickerMessage=(null===(t=this.editorPickerQuery)||void 0===t?void 0:t.length)>0?e.noItemsFoundMessage:e.emptySearchMessage}setupHandlers(){this.isPickerOpen?(this.host.addEventListener("keyup",this.handleKeyPress,{capture:!0}),this.host.addEventListener("keydown",this.handleKeyPress,{capture:!0}),document.addEventListener("mousedown",this.handleMouseClick)):(this.host.removeEventListener("keyup",this.handleKeyPress,{capture:!0}),this.host.removeEventListener("keydown",this.handleKeyPress,{capture:!0}),document.removeEventListener("mousedown",this.handleMouseClick))}isListSeparator(t){return"separator"in t&&!0===t.separator}render(){return[s("limel-text-editor",{key:"9cd16fcb065db254b472f33f31d5b28abf2ca760",ref:t=>this.textEditor=t,tabindex:this.disabled?-1:0,value:this.value,contentType:this.contentType,customElements:this.registeredCustomElements,"aria-disabled":this.disabled,language:this.language,triggers:this.registeredTriggers,onTriggerStart:this.handleTriggerStart,onTriggerStop:this.handleTriggerStop,onTriggerChange:this.handleTriggerChange,onImagePasted:this.handleImagePasted,onMetadataChange:this.handleMetadataChange,ui:this.ui,allowResize:this.allowResize,required:this.required,disabled:this.disabled,readonly:this.readonly,helperText:this.helperText,placeholder:this.placeholder,label:this.label,invalid:this.invalid}),this.renderPicker()]}renderPicker(){if(this.isPickerOpen)return s("limel-portal",{containerId:this.portalId,visible:this.isPickerOpen,openDirection:"top",inheritParentWidth:!0,anchor:this.textEditor},s("limebb-text-editor-picker",{ref:t=>this.textEditorPickerElement=t,items:dt(this.items,this.highlightedItemIndex),onItemSelected:this.handleItemSelection,emptyMessage:this.pickerMessage,isSearching:this.isSearching}))}getEnhancedImages(t){return t.map((t=>{let e;return"success"===t.state&&(e=this.uploadHandler.parseFileIdFromSrc(t.src)),e?Object.assign(Object.assign({},t),{fileId:e}):t}))}loadDraft(){if(!this.userDataService||!this.textEditorInnerId)return;if(this.value)return;const t=this.userDataService.get(this.textEditorInnerId);t&&this.change.emit(t)}saveDraft(){var t,e,i,s;if(!this.textEditorInnerId)return;const r=null===(t=this.value)||void 0===t?void 0:t.trim(),n=null===(e=this.userDataService)||void 0===e?void 0:e.get(this.textEditorInnerId);r&&r!==n?null===(i=this.userDataService)||void 0===i||i.set(this.textEditorInnerId,r):!r&&n&&(null===(s=this.userDataService)||void 0===s||s.set(this.textEditorInnerId,void 0))}get userDataService(){return this.platform.get(n.UserDataRepository)}static get delegatesFocus(){return!0}get host(){return this}static get watchers(){return{isPickerOpen:[{watchOpen:0}],editorPickerQuery:[{watchQuery:0}]}}static get style(){return":host(limebb-text-editor){display:block;width:100%;min-width:5rem;min-height:5rem;height:100%;max-height:var(--text-editor-max-height, calc(100vh - (env(safe-area-inset-top) + env(safe-area-inset-bottom)) - 4rem))}"}},[17,"limebb-text-editor",{platform:[16],context:[16],allowMentioning:[4,"allow-mentioning"],contentType:[1,"content-type"],language:[513],disabled:[516],readonly:[516],helperText:[513,"helper-text"],placeholder:[513],label:[513],invalid:[516],required:[516],selectedContext:[16],ui:[513],allowResize:[4,"allow-resize"],value:[1],draftIdentifier:[1,"draft-identifier"],triggerMap:[16],customElements:[16],allowInlineImages:[4,"allow-inline-images"],items:[32],highlightedItemIndex:[32],editorPickerQuery:[32],searchableLimetypes:[32],isPickerOpen:[32],isSearching:[32]},void 0,{isPickerOpen:[{watchOpen:0}],editorPickerQuery:[{watchQuery:0}]}]);!function(t,e,i,s){var r,n=arguments.length,o=n<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(t,e,i,s);else for(var a=t.length-1;a>=0;a--)(r=t[a])&&(o=(n<3?r(o):n>3?r(e,i,o):r(e,i))||o);n>3&&o&&Object.defineProperty(e,i,o)}([h({map:[function(t){return Object.values(t).filter((t=>P(t,"user")||M(t,"user")))}]})],vt.prototype,"searchableLimetypes",void 0);const pt=vt,gt=function(){"undefined"!=typeof customElements&&["limebb-text-editor","limebb-empty-state","limebb-text-editor-picker"].forEach((t=>{switch(t){case"limebb-text-editor":customElements.get(r(t))||customElements.define(r(t),vt);break;case"limebb-empty-state":customElements.get(r(t))||N();break;case"limebb-text-editor-picker":customElements.get(r(t))||z()}}))};export{pt as LimebbTextEditor,gt as defineCustomElement}
@@ -1072,20 +1072,21 @@ class UploadHandler {
1072
1072
  return uploadedFile;
1073
1073
  }
1074
1074
  /**
1075
- * Extracts a file ID from a image source string.
1075
+ * Extracts a file ID from an image source string.
1076
1076
  *
1077
- * This function parses a URL to find a file ID that appears before
1078
- * '/contents/' at the end of the URL.
1077
+ * Matches a file ID that appears before '/download/' (current URL
1078
+ * format) or '/contents/' (legacy URL format, kept for historical
1079
+ * HTML stored before the switch to '/download/').
1079
1080
  *
1080
1081
  * @param src - The URL string to parse
1081
1082
  * @returns The extracted file ID or undefined if no match is found
1082
1083
  *
1083
1084
  * @example
1084
1085
  * // Returns 123
1085
- * parseFileIdFromSrc('/api/file/123/contents/');
1086
+ * parseFileIdFromSrc('/api/file/123/download/');
1086
1087
  *
1087
1088
  * @example
1088
- * // Returns 456
1089
+ * // Returns 456 (legacy URL)
1089
1090
  * parseFileIdFromSrc('https://example.com/limepkg-email/api/v1/file/456/contents/');
1090
1091
  *
1091
1092
  * @example
@@ -1094,7 +1095,7 @@ class UploadHandler {
1094
1095
  */
1095
1096
  parseFileIdFromSrc(src) {
1096
1097
  if (src) {
1097
- const regex = /\/(\d+)\/contents\/?$/;
1098
+ const regex = /\/(\d+)\/(?:download|contents)\/?$/;
1098
1099
  const matches = regex.exec(src);
1099
1100
  if (matches && matches[1]) {
1100
1101
  return Number(matches[1]);
@@ -1143,7 +1144,7 @@ class UploadHandler {
1143
1144
  imageUpload.contentType = response.contentType;
1144
1145
  imageUpload.size = response.size;
1145
1146
  imageUpload.state = 'done';
1146
- imageUpload.href = (_a = response._links) === null || _a === void 0 ? void 0 : _a.contents.href;
1147
+ imageUpload.href = (_a = response._links) === null || _a === void 0 ? void 0 : _a.download.href;
1147
1148
  return imageUpload;
1148
1149
  }
1149
1150
  get http() {
@@ -1 +1 @@
1
- import{p as e,b as t}from"./p-BIwHMk6j.js";export{s as setNonce}from"./p-BIwHMk6j.js";import{g as i}from"./p-DQuL1Twl.js";(()=>{const t=import.meta.url,i={};return""!==t&&(i.resourcesUrl=new URL(".",t).href),e(i)})().then((async e=>(await i(),t(JSON.parse('[["p-fdf269f7",[[1,"limebb-lime-query-builder",{"platform":[16],"context":[16],"value":[16],"label":[1],"activeLimetype":[1,"active-limetype"],"limetypes":[32],"mode":[32],"codeValue":[32],"limetype":[32],"filter":[32],"internalResponseFormat":[32],"limit":[32],"orderBy":[32],"description":[32]}]]],["p-21ec697f",[[1,"limebb-feed",{"platform":[16],"context":[16],"items":[16],"emptyStateMessage":[1,"empty-state-message"],"heading":[1],"loading":[4],"minutesOfProximity":[2,"minutes-of-proximity"],"totalCount":[2,"total-count"],"direction":[513],"lastVisitedTimestamp":[1,"last-visited-timestamp"],"highlightedItemId":[8,"highlighted-item-id"]},null,{"highlightedItemId":[{"highlightedItemIdChanged":0}]}]]],["p-3252e153",[[1,"limebb-kanban",{"platform":[16],"context":[16],"groups":[16]}]]],["p-b10faec5",[[1,"limebb-chat-list",{"platform":[16],"context":[16],"items":[16],"loading":[516],"isTypingIndicatorVisible":[516,"is-typing-indicator-visible"],"lastVisitedTimestamp":[513,"last-visited-timestamp"],"order":[513]},null,{"items":[{"handleItemsChange":0}]}]]],["p-9ae55a96",[[1,"limebb-lime-query-response-format-builder",{"platform":[16],"context":[16],"limetype":[1],"value":[16],"label":[1],"helperText":[1,"helper-text"],"limetypes":[32],"mode":[32],"codeValue":[32],"internalValue":[32]}]]],["p-ebe6040f",[[1,"limebb-document-chips",{"accessibleLabel":[513,"accessible-label"],"files":[16]},null,{"files":[{"onFilesChanged":0}]}]]],["p-8e2cc2e8",[[1,"limebb-limeobject-file-viewer",{"platform":[16],"context":[16],"property":[1],"fileTypes":[16],"limeobject":[32],"limetype":[32]}]]],["p-b36ad4e8",[[17,"limebb-text-editor",{"platform":[16],"context":[16],"allowMentioning":[4,"allow-mentioning"],"contentType":[1,"content-type"],"language":[513],"disabled":[516],"readonly":[516],"helperText":[513,"helper-text"],"placeholder":[513],"label":[513],"invalid":[516],"required":[516],"selectedContext":[16],"ui":[513],"allowResize":[4,"allow-resize"],"value":[1],"draftIdentifier":[1,"draft-identifier"],"triggerMap":[16],"customElements":[16],"allowInlineImages":[4,"allow-inline-images"],"items":[32],"highlightedItemIndex":[32],"editorPickerQuery":[32],"searchableLimetypes":[32],"isPickerOpen":[32],"isSearching":[32]},null,{"isPickerOpen":[{"watchOpen":0}],"editorPickerQuery":[{"watchQuery":0}]}]]],["p-49afe71b",[[1,"limebb-data-cells",{"platform":[16],"context":[16],"limeobject":[8],"items":[16]}]]],["p-35a51259",[[1,"limebb-date-range",{"platform":[16],"context":[16],"startTime":[16],"endTime":[16],"startTimeLabel":[1,"start-time-label"],"endTimeLabel":[1,"end-time-label"],"language":[1],"timeFormat":[1,"time-format"],"type":[1]}]]],["p-685dd8a1",[[1,"limebb-document-picker",{"platform":[16],"context":[16],"items":[16],"label":[513],"helperText":[513,"helper-text"],"invalid":[516],"required":[516],"type":[513]}]]],["p-b2383e7f",[[1,"limebb-info-tile-currency-format",{"platform":[16],"context":[16],"value":[16]}]]],["p-e2e9adff",[[1,"limebb-notification-list",{"platform":[16],"context":[16],"items":[16],"loading":[4],"lastVisitedTimestamp":[1,"last-visited-timestamp"]},null,{"items":[{"handleItemsChange":0}]}]]],["p-fcedbc77",[[257,"limebb-alert-dialog",{"type":[513],"open":[516],"icon":[513],"heading":[513],"subheading":[1]}]]],["p-aaeecca6",[[17,"limebb-browser",{"platform":[16],"context":[16],"items":[16],"layout":[1],"filter":[32]}]]],["p-ba42e434",[[1,"limebb-component-config",{"platform":[16],"context":[16],"value":[16],"required":[4],"readonly":[4],"disabled":[4],"label":[1],"helperText":[1,"helper-text"],"formInfo":[16],"type":[1],"nameField":[1,"name-field"],"configComponent":[32],"configViewType":[32]},null,{"formInfo":[{"watchFormInfo":0}],"configComponent":[{"watchconfigComponent":0}]}]]],["p-38201f65",[[1,"limebb-component-picker",{"platform":[16],"context":[16],"type":[1],"tags":[16],"value":[1],"copyLabel":[1,"copy-label"],"hideCopyButton":[4,"hide-copy-button"],"required":[4],"readonly":[4],"disabled":[4],"label":[1],"helperText":[1,"helper-text"]}]]],["p-528f3635",[[257,"limebb-composer-toolbar",{"platform":[16],"mentions":[516],"textSnippets":[516,"text-snippets"],"internalLinks":[516,"internal-links"],"richText":[516,"rich-text"],"fileInput":[16]}]]],["p-18fc1a06",[[257,"limebb-dashboard-widget",{"heading":[513],"subheading":[513],"supportingText":[513,"supporting-text"],"icon":[513]}]]],["p-4ddd75bc",[[1,"limebb-icon-picker",{"value":[1],"required":[4],"readonly":[4],"invalid":[4],"disabled":[4],"label":[1],"helperText":[1,"helper-text"]}]]],["p-943c8589",[[1,"limebb-info-tile",{"platform":[16],"context":[16],"filterId":[513,"filter-id"],"disabled":[4],"icon":[513],"label":[1],"prefix":[1],"suffix":[1],"propertyName":[1,"property-name"],"aggregateOperator":[1,"aggregate-operator"],"format":[16],"config":[32],"filters":[32],"value":[32],"loading":[32],"error":[32],"limetypes":[32]},null,{"filterId":[{"watchFilterId":0}],"propertyName":[{"watchPropertyName":0}],"aggregateOperator":[{"watchAggregateOperator":0}]}]]],["p-1428aa13",[[1,"limebb-info-tile-date-format",{"value":[16]}]]],["p-dabb227b",[[1,"limebb-info-tile-decimal-format",{"value":[16]}]]],["p-152edb10",[[1,"limebb-info-tile-format",{"platform":[16],"context":[16],"type":[1],"value":[16]}]]],["p-32f8477f",[[1,"limebb-info-tile-relative-date-format",{"value":[16]}]]],["p-3263f8d5",[[1,"limebb-info-tile-unit-format",{"value":[16]}]]],["p-60e22f51",[[1,"limebb-loader",{"platform":[16],"context":[16]}]]],["p-71191041",[[1,"limebb-locale-picker",{"platform":[16],"context":[16],"value":[1],"required":[4],"disabled":[4],"label":[1],"helperText":[1,"helper-text"],"readonly":[4],"multipleChoice":[4,"multiple-choice"],"allLanguages":[32]}]]],["p-0afc0db2",[[257,"limebb-mention",{"limetype":[1],"objectid":[2],"limeobject":[32]}]]],["p-6cb2d9dd",[[1,"limebb-mention-group-counter",{"count":[2],"limetype":[16],"helperLabel":[1,"helper-label"]}]]],["p-740ae712",[[1,"limebb-object-chip",{"limetype":[1],"objectid":[2],"size":[1],"platform":[16],"data":[32]},null,{"limetype":[{"handlePropChange":0}],"objectid":[{"handlePropChange":0}]}]]],["p-5a1f0a2b",[[1,"limebb-trend-indicator",{"platform":[16],"context":[16],"value":[520],"formerValue":[514,"former-value"],"suffix":[513],"label":[513],"invalid":[516],"required":[516],"helperText":[513,"helper-text"],"reducePresence":[516,"reduce-presence"]},null,{"value":[{"valueChanged":0}]}]]],["p-b3ee6683",[[1,"limebb-feed-timeline-item",{"platform":[16],"context":[16],"item":[16],"ui":[513],"helperText":[1,"helper-text"],"hasError":[516,"has-error"],"isBundled":[516,"is-bundled"],"headingCanExpand":[32],"isHeadingExpanded":[32],"showMore":[32],"isTall":[32]}]]],["p-62437a1d",[[1,"limebb-currency-picker",{"platform":[16],"context":[16],"label":[513],"currencies":[16],"helperText":[513,"helper-text"],"required":[516],"readonly":[516],"invalid":[516],"disabled":[516],"value":[1]}]]],["p-8477cb5d",[[257,"limebb-kanban-item",{"platform":[16],"context":[16],"item":[16]}]]],["p-be8dc8ae",[[1,"limebb-kanban-group",{"platform":[16],"context":[16],"identifier":[1],"heading":[513],"help":[1],"items":[16],"summary":[1],"loading":[516],"totalCount":[514,"total-count"]}]]],["p-4446f170",[[1,"limebb-empty-state",{"heading":[513],"value":[513],"icon":[16]}]]],["p-d2a01f51",[[1,"limebb-text-editor-picker",{"items":[16],"open":[516],"isSearching":[4,"is-searching"],"emptyMessage":[1,"empty-message"]},null,{"open":[{"watchOpen":0}]}]]],["p-6fdee70a",[[1,"limebb-date-picker",{"platform":[16],"context":[16],"disabled":[516],"readonly":[516],"invalid":[516],"label":[513],"placeholder":[513],"helperText":[513,"helper-text"],"required":[516],"value":[1],"type":[513]}]]],["p-f23ea0e7",[[17,"limebb-document-item",{"platform":[16],"context":[16],"item":[16],"type":[513],"fileTypes":[16]}]]],["p-c3b13800",[[1,"limebb-live-docs-info"]]],["p-cff9bccd",[[1,"limebb-notification-item",{"platform":[16],"context":[16],"item":[16]}]]],["p-f375d69a",[[1,"limebb-percentage-visualizer",{"platform":[16],"context":[16],"value":[520],"rangeMax":[514,"range-max"],"rangeMin":[514,"range-min"],"multiplier":[514],"label":[513],"invalid":[516],"required":[516],"helperText":[513,"helper-text"],"reducePresence":[516,"reduce-presence"],"displayPercentageColors":[516,"display-percentage-colors"]},null,{"value":[{"valueChanged":0}]}]]],["p-eec0a0c8",[[1,"limebb-lime-query-order-by-item",{"platform":[16],"context":[16],"limetype":[1],"item":[16]}]]],["p-fa41a9e6",[[1,"limebb-feed-item-thumbnail-file-info",{"description":[1]}]]],["p-52fb2a66",[[1,"limebb-lime-query-filter-builder",{"platform":[16],"context":[16],"limetype":[1],"activeLimetype":[1,"active-limetype"],"expression":[16]}],[1,"limebb-lime-query-order-by-editor",{"platform":[16],"context":[16],"limetype":[1],"value":[16],"label":[1],"items":[32]},null,{"value":[{"handleValueChange":0}]}],[0,"limebb-limetype-field",{"platform":[16],"context":[16],"label":[513],"required":[516],"readonly":[516],"disabled":[516],"value":[513],"helperText":[513,"helper-text"],"invalid":[4],"limetypes":[16],"propertyFields":[16],"fieldName":[1,"field-name"],"formInfo":[16]}]]],["p-8a05a0e5",[[1,"limebb-chat-icon-list",{"item":[16]}],[1,"limebb-chat-item",{"platform":[16],"context":[16],"item":[16],"helperText":[1,"helper-text"],"hasError":[516,"has-error"]}],[1,"limebb-typing-indicator"]]],["p-1f02a411",[[1,"limebb-property-selector",{"platform":[16],"context":[16],"limetype":[1],"value":[1],"label":[1],"required":[4],"helperText":[1,"helper-text"],"limetypes":[32],"isOpen":[32],"navigationPath":[32]}]]],["p-1a61674f",[[1,"limebb-lime-query-response-format-editor",{"platform":[16],"context":[16],"limetype":[1],"value":[16],"label":[1],"items":[32]}],[1,"limebb-lime-query-response-format-item",{"platform":[16],"context":[16],"limetype":[1],"item":[16],"showAliasInput":[32],"showDescriptionInput":[32]}]]],["p-a48a6ff8",[[1,"limebb-lime-query-filter-expression",{"platform":[16],"context":[16],"label":[1],"limetype":[1],"activeLimetype":[1,"active-limetype"],"expression":[16]}],[1,"limebb-lime-query-filter-comparison",{"platform":[16],"context":[16],"label":[513],"limetype":[1],"activeLimetype":[1,"active-limetype"],"expression":[16]}]]],["p-ffb847d0",[[257,"limebb-summary-popover",{"triggerDelay":[514,"trigger-delay"],"heading":[513],"subheading":[513],"image":[16],"file":[16],"icon":[513],"value":[1],"openDirection":[513,"open-direction"],"popoverMaxWidth":[513,"popover-max-width"],"popoverMaxHeight":[513,"popover-max-height"],"actions":[16],"isPopoverOpen":[32]}],[17,"limebb-navigation-button",{"href":[513],"tooltipLabel":[513,"tooltip-label"],"tooltipHelperLabel":[513,"tooltip-helper-label"],"type":[513]}]]],["p-bac3d599",[[1,"limebb-lime-query-value-input",{"platform":[16],"context":[16],"limetype":[1],"activeLimetype":[1,"active-limetype"],"propertyPath":[1,"property-path"],"operator":[1],"value":[8],"label":[1],"limetypes":[32],"inputMode":[32]}],[1,"limebb-lime-query-filter-group",{"platform":[16],"context":[16],"limetype":[1],"activeLimetype":[1,"active-limetype"],"expression":[16],"value":[32]}],[1,"limebb-lime-query-filter-not",{"platform":[16],"context":[16],"label":[1],"limetype":[1],"activeLimetype":[1,"active-limetype"],"expression":[16]}]]]]'),e))));
1
+ import{p as e,b as t}from"./p-BIwHMk6j.js";export{s as setNonce}from"./p-BIwHMk6j.js";import{g as i}from"./p-DQuL1Twl.js";(()=>{const t=import.meta.url,i={};return""!==t&&(i.resourcesUrl=new URL(".",t).href),e(i)})().then((async e=>(await i(),t(JSON.parse('[["p-fdf269f7",[[1,"limebb-lime-query-builder",{"platform":[16],"context":[16],"value":[16],"label":[1],"activeLimetype":[1,"active-limetype"],"limetypes":[32],"mode":[32],"codeValue":[32],"limetype":[32],"filter":[32],"internalResponseFormat":[32],"limit":[32],"orderBy":[32],"description":[32]}]]],["p-21ec697f",[[1,"limebb-feed",{"platform":[16],"context":[16],"items":[16],"emptyStateMessage":[1,"empty-state-message"],"heading":[1],"loading":[4],"minutesOfProximity":[2,"minutes-of-proximity"],"totalCount":[2,"total-count"],"direction":[513],"lastVisitedTimestamp":[1,"last-visited-timestamp"],"highlightedItemId":[8,"highlighted-item-id"]},null,{"highlightedItemId":[{"highlightedItemIdChanged":0}]}]]],["p-3252e153",[[1,"limebb-kanban",{"platform":[16],"context":[16],"groups":[16]}]]],["p-b10faec5",[[1,"limebb-chat-list",{"platform":[16],"context":[16],"items":[16],"loading":[516],"isTypingIndicatorVisible":[516,"is-typing-indicator-visible"],"lastVisitedTimestamp":[513,"last-visited-timestamp"],"order":[513]},null,{"items":[{"handleItemsChange":0}]}]]],["p-9ae55a96",[[1,"limebb-lime-query-response-format-builder",{"platform":[16],"context":[16],"limetype":[1],"value":[16],"label":[1],"helperText":[1,"helper-text"],"limetypes":[32],"mode":[32],"codeValue":[32],"internalValue":[32]}]]],["p-ebe6040f",[[1,"limebb-document-chips",{"accessibleLabel":[513,"accessible-label"],"files":[16]},null,{"files":[{"onFilesChanged":0}]}]]],["p-8e2cc2e8",[[1,"limebb-limeobject-file-viewer",{"platform":[16],"context":[16],"property":[1],"fileTypes":[16],"limeobject":[32],"limetype":[32]}]]],["p-d13b6d30",[[17,"limebb-text-editor",{"platform":[16],"context":[16],"allowMentioning":[4,"allow-mentioning"],"contentType":[1,"content-type"],"language":[513],"disabled":[516],"readonly":[516],"helperText":[513,"helper-text"],"placeholder":[513],"label":[513],"invalid":[516],"required":[516],"selectedContext":[16],"ui":[513],"allowResize":[4,"allow-resize"],"value":[1],"draftIdentifier":[1,"draft-identifier"],"triggerMap":[16],"customElements":[16],"allowInlineImages":[4,"allow-inline-images"],"items":[32],"highlightedItemIndex":[32],"editorPickerQuery":[32],"searchableLimetypes":[32],"isPickerOpen":[32],"isSearching":[32]},null,{"isPickerOpen":[{"watchOpen":0}],"editorPickerQuery":[{"watchQuery":0}]}]]],["p-49afe71b",[[1,"limebb-data-cells",{"platform":[16],"context":[16],"limeobject":[8],"items":[16]}]]],["p-35a51259",[[1,"limebb-date-range",{"platform":[16],"context":[16],"startTime":[16],"endTime":[16],"startTimeLabel":[1,"start-time-label"],"endTimeLabel":[1,"end-time-label"],"language":[1],"timeFormat":[1,"time-format"],"type":[1]}]]],["p-685dd8a1",[[1,"limebb-document-picker",{"platform":[16],"context":[16],"items":[16],"label":[513],"helperText":[513,"helper-text"],"invalid":[516],"required":[516],"type":[513]}]]],["p-b2383e7f",[[1,"limebb-info-tile-currency-format",{"platform":[16],"context":[16],"value":[16]}]]],["p-e2e9adff",[[1,"limebb-notification-list",{"platform":[16],"context":[16],"items":[16],"loading":[4],"lastVisitedTimestamp":[1,"last-visited-timestamp"]},null,{"items":[{"handleItemsChange":0}]}]]],["p-fcedbc77",[[257,"limebb-alert-dialog",{"type":[513],"open":[516],"icon":[513],"heading":[513],"subheading":[1]}]]],["p-aaeecca6",[[17,"limebb-browser",{"platform":[16],"context":[16],"items":[16],"layout":[1],"filter":[32]}]]],["p-ba42e434",[[1,"limebb-component-config",{"platform":[16],"context":[16],"value":[16],"required":[4],"readonly":[4],"disabled":[4],"label":[1],"helperText":[1,"helper-text"],"formInfo":[16],"type":[1],"nameField":[1,"name-field"],"configComponent":[32],"configViewType":[32]},null,{"formInfo":[{"watchFormInfo":0}],"configComponent":[{"watchconfigComponent":0}]}]]],["p-38201f65",[[1,"limebb-component-picker",{"platform":[16],"context":[16],"type":[1],"tags":[16],"value":[1],"copyLabel":[1,"copy-label"],"hideCopyButton":[4,"hide-copy-button"],"required":[4],"readonly":[4],"disabled":[4],"label":[1],"helperText":[1,"helper-text"]}]]],["p-528f3635",[[257,"limebb-composer-toolbar",{"platform":[16],"mentions":[516],"textSnippets":[516,"text-snippets"],"internalLinks":[516,"internal-links"],"richText":[516,"rich-text"],"fileInput":[16]}]]],["p-18fc1a06",[[257,"limebb-dashboard-widget",{"heading":[513],"subheading":[513],"supportingText":[513,"supporting-text"],"icon":[513]}]]],["p-4ddd75bc",[[1,"limebb-icon-picker",{"value":[1],"required":[4],"readonly":[4],"invalid":[4],"disabled":[4],"label":[1],"helperText":[1,"helper-text"]}]]],["p-943c8589",[[1,"limebb-info-tile",{"platform":[16],"context":[16],"filterId":[513,"filter-id"],"disabled":[4],"icon":[513],"label":[1],"prefix":[1],"suffix":[1],"propertyName":[1,"property-name"],"aggregateOperator":[1,"aggregate-operator"],"format":[16],"config":[32],"filters":[32],"value":[32],"loading":[32],"error":[32],"limetypes":[32]},null,{"filterId":[{"watchFilterId":0}],"propertyName":[{"watchPropertyName":0}],"aggregateOperator":[{"watchAggregateOperator":0}]}]]],["p-1428aa13",[[1,"limebb-info-tile-date-format",{"value":[16]}]]],["p-dabb227b",[[1,"limebb-info-tile-decimal-format",{"value":[16]}]]],["p-152edb10",[[1,"limebb-info-tile-format",{"platform":[16],"context":[16],"type":[1],"value":[16]}]]],["p-32f8477f",[[1,"limebb-info-tile-relative-date-format",{"value":[16]}]]],["p-3263f8d5",[[1,"limebb-info-tile-unit-format",{"value":[16]}]]],["p-60e22f51",[[1,"limebb-loader",{"platform":[16],"context":[16]}]]],["p-71191041",[[1,"limebb-locale-picker",{"platform":[16],"context":[16],"value":[1],"required":[4],"disabled":[4],"label":[1],"helperText":[1,"helper-text"],"readonly":[4],"multipleChoice":[4,"multiple-choice"],"allLanguages":[32]}]]],["p-0afc0db2",[[257,"limebb-mention",{"limetype":[1],"objectid":[2],"limeobject":[32]}]]],["p-6cb2d9dd",[[1,"limebb-mention-group-counter",{"count":[2],"limetype":[16],"helperLabel":[1,"helper-label"]}]]],["p-740ae712",[[1,"limebb-object-chip",{"limetype":[1],"objectid":[2],"size":[1],"platform":[16],"data":[32]},null,{"limetype":[{"handlePropChange":0}],"objectid":[{"handlePropChange":0}]}]]],["p-5a1f0a2b",[[1,"limebb-trend-indicator",{"platform":[16],"context":[16],"value":[520],"formerValue":[514,"former-value"],"suffix":[513],"label":[513],"invalid":[516],"required":[516],"helperText":[513,"helper-text"],"reducePresence":[516,"reduce-presence"]},null,{"value":[{"valueChanged":0}]}]]],["p-b3ee6683",[[1,"limebb-feed-timeline-item",{"platform":[16],"context":[16],"item":[16],"ui":[513],"helperText":[1,"helper-text"],"hasError":[516,"has-error"],"isBundled":[516,"is-bundled"],"headingCanExpand":[32],"isHeadingExpanded":[32],"showMore":[32],"isTall":[32]}]]],["p-62437a1d",[[1,"limebb-currency-picker",{"platform":[16],"context":[16],"label":[513],"currencies":[16],"helperText":[513,"helper-text"],"required":[516],"readonly":[516],"invalid":[516],"disabled":[516],"value":[1]}]]],["p-8477cb5d",[[257,"limebb-kanban-item",{"platform":[16],"context":[16],"item":[16]}]]],["p-be8dc8ae",[[1,"limebb-kanban-group",{"platform":[16],"context":[16],"identifier":[1],"heading":[513],"help":[1],"items":[16],"summary":[1],"loading":[516],"totalCount":[514,"total-count"]}]]],["p-4446f170",[[1,"limebb-empty-state",{"heading":[513],"value":[513],"icon":[16]}]]],["p-d2a01f51",[[1,"limebb-text-editor-picker",{"items":[16],"open":[516],"isSearching":[4,"is-searching"],"emptyMessage":[1,"empty-message"]},null,{"open":[{"watchOpen":0}]}]]],["p-6fdee70a",[[1,"limebb-date-picker",{"platform":[16],"context":[16],"disabled":[516],"readonly":[516],"invalid":[516],"label":[513],"placeholder":[513],"helperText":[513,"helper-text"],"required":[516],"value":[1],"type":[513]}]]],["p-f23ea0e7",[[17,"limebb-document-item",{"platform":[16],"context":[16],"item":[16],"type":[513],"fileTypes":[16]}]]],["p-c3b13800",[[1,"limebb-live-docs-info"]]],["p-cff9bccd",[[1,"limebb-notification-item",{"platform":[16],"context":[16],"item":[16]}]]],["p-f375d69a",[[1,"limebb-percentage-visualizer",{"platform":[16],"context":[16],"value":[520],"rangeMax":[514,"range-max"],"rangeMin":[514,"range-min"],"multiplier":[514],"label":[513],"invalid":[516],"required":[516],"helperText":[513,"helper-text"],"reducePresence":[516,"reduce-presence"],"displayPercentageColors":[516,"display-percentage-colors"]},null,{"value":[{"valueChanged":0}]}]]],["p-eec0a0c8",[[1,"limebb-lime-query-order-by-item",{"platform":[16],"context":[16],"limetype":[1],"item":[16]}]]],["p-fa41a9e6",[[1,"limebb-feed-item-thumbnail-file-info",{"description":[1]}]]],["p-52fb2a66",[[1,"limebb-lime-query-filter-builder",{"platform":[16],"context":[16],"limetype":[1],"activeLimetype":[1,"active-limetype"],"expression":[16]}],[1,"limebb-lime-query-order-by-editor",{"platform":[16],"context":[16],"limetype":[1],"value":[16],"label":[1],"items":[32]},null,{"value":[{"handleValueChange":0}]}],[0,"limebb-limetype-field",{"platform":[16],"context":[16],"label":[513],"required":[516],"readonly":[516],"disabled":[516],"value":[513],"helperText":[513,"helper-text"],"invalid":[4],"limetypes":[16],"propertyFields":[16],"fieldName":[1,"field-name"],"formInfo":[16]}]]],["p-8a05a0e5",[[1,"limebb-chat-icon-list",{"item":[16]}],[1,"limebb-chat-item",{"platform":[16],"context":[16],"item":[16],"helperText":[1,"helper-text"],"hasError":[516,"has-error"]}],[1,"limebb-typing-indicator"]]],["p-1f02a411",[[1,"limebb-property-selector",{"platform":[16],"context":[16],"limetype":[1],"value":[1],"label":[1],"required":[4],"helperText":[1,"helper-text"],"limetypes":[32],"isOpen":[32],"navigationPath":[32]}]]],["p-1a61674f",[[1,"limebb-lime-query-response-format-editor",{"platform":[16],"context":[16],"limetype":[1],"value":[16],"label":[1],"items":[32]}],[1,"limebb-lime-query-response-format-item",{"platform":[16],"context":[16],"limetype":[1],"item":[16],"showAliasInput":[32],"showDescriptionInput":[32]}]]],["p-a48a6ff8",[[1,"limebb-lime-query-filter-expression",{"platform":[16],"context":[16],"label":[1],"limetype":[1],"activeLimetype":[1,"active-limetype"],"expression":[16]}],[1,"limebb-lime-query-filter-comparison",{"platform":[16],"context":[16],"label":[513],"limetype":[1],"activeLimetype":[1,"active-limetype"],"expression":[16]}]]],["p-ffb847d0",[[257,"limebb-summary-popover",{"triggerDelay":[514,"trigger-delay"],"heading":[513],"subheading":[513],"image":[16],"file":[16],"icon":[513],"value":[1],"openDirection":[513,"open-direction"],"popoverMaxWidth":[513,"popover-max-width"],"popoverMaxHeight":[513,"popover-max-height"],"actions":[16],"isPopoverOpen":[32]}],[17,"limebb-navigation-button",{"href":[513],"tooltipLabel":[513,"tooltip-label"],"tooltipHelperLabel":[513,"tooltip-helper-label"],"type":[513]}]]],["p-bac3d599",[[1,"limebb-lime-query-value-input",{"platform":[16],"context":[16],"limetype":[1],"activeLimetype":[1,"active-limetype"],"propertyPath":[1,"property-path"],"operator":[1],"value":[8],"label":[1],"limetypes":[32],"inputMode":[32]}],[1,"limebb-lime-query-filter-group",{"platform":[16],"context":[16],"limetype":[1],"activeLimetype":[1,"active-limetype"],"expression":[16],"value":[32]}],[1,"limebb-lime-query-filter-not",{"platform":[16],"context":[16],"label":[1],"limetype":[1],"activeLimetype":[1,"active-limetype"],"expression":[16]}]]]]'),e))));
@@ -0,0 +1 @@
1
+ import{r as t,c as i,h as e,g as s}from"./p-BIwHMk6j.js";import{n as r,Z as n,Q as o,j as a}from"./p-CcGMZOP-.js";import{A as h,a as c,b as u,E as l,T as d}from"./p-CwMJvF_Z.js";import{U as f,S as v,g as m}from"./p-B8RiYkLS.js";import{d as p}from"./p-V3xfp9dg.js";import{e as b}from"./p-yc--7_7T.js";import{o as g,d as j,g as y,f as w,n as O,a as k}from"./p-wbuFLk-j.js";import{d as x,S,i as C,a as I,r as T}from"./p-ByjZfyP_.js";import{c as A}from"./p-C2JP2nLw.js";import{h as F,a as M,b as P}from"./p-CMfAKLlA.js";import{i as E}from"./p-CkTg5UPD.js";import{i as _}from"./p-CQ-z_HTt.js";var L=/\s/,N=/^\s+/;var $=/^[-+]0x[0-9a-f]+$/i,D=/^0b[01]+$/i,R=/^0o[0-7]+$/i,U=parseInt;function z(t){if("number"==typeof t)return t;if(_(t))return NaN;if(x(t)){var i="function"==typeof t.valueOf?t.valueOf():t;t=x(i)?i+"":i}if("string"!=typeof t)return 0===t?t:+t;var e;t=(e=t)?e.slice(0,function(t){for(var i=t.length;i--&&L.test(t.charAt(i)););return i}(e)+1).replace(N,""):e;var s=D.test(t);return s||R.test(t)?U(t.slice(2),s?2:8):$.test(t)?NaN:+t}var G=Object.create,B=function(){function t(){}return function(i){if(!x(i))return{};if(G)return G(i);t.prototype=i;var e=new t;return t.prototype=void 0,e}}(),Q=Object.prototype.hasOwnProperty;var H=g(Object.getPrototypeOf,Object);"object"==typeof exports&&exports&&!exports.nodeType&&exports&&"object"==typeof module&&module&&!module.nodeType&&module;var Z=Object.prototype.hasOwnProperty;function W(t){var i=new t.constructor(t.byteLength);return new f(i).set(new f(t)),i}var q=/\w*$/,J=S?S.prototype:void 0,K=J?J.valueOf:void 0;var V=O&&O.isMap,Y=V?w(V):function(t){return C(t)&&"[object Map]"==y(t)},X=O&&O.isSet,tt=X?w(X):function(t){return C(t)&&"[object Set]"==y(t)},it="[object Arguments]",et="[object Function]",st="[object Object]",rt={};function nt(t,i,e,s,r,n){var o;if(void 0!==o)return o;if(!x(t))return t;var a=I(t);if(a)o=function(t){var i=t.length,e=new t.constructor(i);return i&&"string"==typeof t[0]&&Z.call(t,"index")&&(e.index=t.index,e.input=t.input),e}(t);else{var h=y(t),c=h==et||"[object GeneratorFunction]"==h;if(k(t))return t.slice();if(h==st||h==it||c&&!r)o=c?{}:function(t){return"function"!=typeof t.constructor||j(t)?{}:B(H(t))}(t);else{if(!rt[h])return r?t:{};o=function(t,i){var e,s,r,n,o=t.constructor;switch(i){case"[object ArrayBuffer]":return W(t);case"[object Boolean]":case"[object Date]":return new o(+t);case"[object DataView]":return n=W((r=t).buffer),new r.constructor(n,r.byteOffset,r.byteLength);case"[object Float32Array]":case"[object Float64Array]":case"[object Int8Array]":case"[object Int16Array]":case"[object Int32Array]":case"[object Uint8Array]":case"[object Uint8ClampedArray]":case"[object Uint16Array]":case"[object Uint32Array]":return function(t){var i=W(t.buffer);return new t.constructor(i,t.byteOffset,t.length)}(t);case"[object Map]":case"[object Set]":return new o;case"[object Number]":case"[object String]":return new o(t);case"[object RegExp]":return(s=new(e=t).constructor(e.source,q.exec(e))).lastIndex=e.lastIndex,s;case"[object Symbol]":return K?Object(K.call(t)):{}}}(t,h)}}n||(n=new v);var u=n.get(t);if(u)return u;n.set(t,o),tt(t)?t.forEach((function(s){o.add(nt(s,i,e,0,t,n))})):Y(t)&&t.forEach((function(s,r){o.set(r,nt(s,i,e,0,t,n))}));var l=a?void 0:m(t);return function(t,i){for(var e=-1,s=null==t?0:t.length;++e<s&&!1!==i(t[e],e););}(l||t,(function(s,r){l&&(s=t[r=s]),function(t,i,e){var s=t[i];Q.call(t,i)&&b(s,e)&&(void 0!==e||i in t)||function(t,i,e){"__proto__"==i&&p?p(t,i,{configurable:!0,enumerable:!0,value:e,writable:!0}):t[i]=e}(t,i,e)}(o,r,nt(s,i,e,0,t,n))})),o}rt[it]=rt["[object Array]"]=rt["[object ArrayBuffer]"]=rt["[object DataView]"]=rt["[object Boolean]"]=rt["[object Date]"]=rt["[object Float32Array]"]=rt["[object Float64Array]"]=rt["[object Int8Array]"]=rt["[object Int16Array]"]=rt["[object Int32Array]"]=rt["[object Map]"]=rt["[object Number]"]=rt[st]=rt["[object RegExp]"]=rt["[object Set]"]=rt["[object String]"]=rt["[object Symbol]"]=rt["[object Uint8Array]"]=rt["[object Uint8ClampedArray]"]=rt["[object Uint16Array]"]=rt["[object Uint32Array]"]=!0,rt["[object Error]"]=rt[et]=rt["[object WeakMap]"]=!1;var ot=function(){return T.Date.now()},at=Math.max,ht=Math.min;class ct{get limeObjectService(){return this.platform.get(r.LimeObjectRepository)}get queryService(){return this.platform.get(r.Query)}get viewFactoryRegistry(){return this.platform.get(r.ViewFactoryRegistry)}get translator(){var t;return null===(t=this.platform)||void 0===t?void 0:t.get(r.Translate)}get triggerCharacter(){return this._triggerCharacter}get triggerHandler(){return this._triggerHandler}constructor(t,i,e){this.platform=t,this.context=i,this.searchableLimetypes=e,this.groupCounts={},this._triggerCharacter="@",this._triggerHandler={searcher:t=>this.searcher(t),inserter:(t,i)=>this.inserter(t,i),emptySearchMessage:"Start typing a name...",noItemsFoundMessage:"No results for your search...",nodeDefinition:{customElement:{tagName:"limebb-mention",attributes:["limetype","objectid","href"]},mapAttributes:t=>({limetype:t.value.getLimetype().name,objectid:t.value.id,href:`object/${this.context.limetype}/${this.context.id}`})}},this.searcher=async t=>{if(!t)return[];const{objects:i}=await this.limeObjectService.search(t,this.searchableLimetypes,10);return this.createSearchListItems(i)},this.inserter=async(t,i)=>{var e;const s=this.triggerHandler.nodeDefinition;s&&t.insert({node:{tagName:s.customElement.tagName,attributes:s.mapAttributes(i)},children:[null===(e=i.value)||void 0===e?void 0:e.descriptive]})}}async initialize(){await this.loadGroupCounts()}async loadGroupCounts(){const t=this.searchableLimetypes.filter((t=>!M(t,"user")&&F(t,"user"))).map((t=>this.getGroupCounts(t)));for(const i of await Promise.all(t))Object.assign(this.groupCounts,i)}async getGroupCounts(t){var i;const e=P(t,"user"),s=t.name;try{const t=await this.queryService.execute({limetype:s,responseFormat:{object:{_id:null,[e.name]:{count:{aggregate:{op:n.Count}}}}}});if(!(null===(i=t.objects)||void 0===i?void 0:i.length))return{[s]:{}};const r=this.createGroupCount(t.objects,e.name);return{[s]:r}}catch(i){return console.error(`Error fetching group count for limetype: ${t.name}`,i),{[s]:{}}}}createGroupCount(t,i){const e={};for(const s of t){const{_id:t,[i]:r}=s;e[t]=r.count}return e}createSearchListItems(t=[]){return t.map((t=>this.createSearchListItem(t))).filter(E)}createSearchListItem(t){const i=this.viewFactoryRegistry.getFactory("search"),e=this.limeObjectService.getObject(t._limetype,t._id);if(!e)return null;const s=i(e,this.context),r=this.getGroupCountComponent(e);return Object.assign(Object.assign({},s),r?{primaryComponent:r}:{})}getGroupCountComponent(t){var i;const e=t.getLimetype(),s=null===(i=this.groupCounts[e.name])||void 0===i?void 0:i[t.id],r=P(e,"user");if(void 0!==s&&r)return{name:"limebb-mention-group-counter",props:{count:s,limetype:r.relation.getLimetype(),helperLabel:this.translator.get("webclient.notification-center.members-will-be-notified")}}}}class ut{constructor(t,i){this.file=t,this.http=i,this.uploadCancelled=!1,this.getUrl=t=>`api/v1/file/${null!=t?t:""}`}async initialize(){this.uploadService=await this.http.createFileUpload(o.Post,this.getUrl(),this.file),this.progressCallback&&(this.uploadService.onProgress=this.progressCallback)}async upload(){return this.uploadService.upload()}getFileName(){return this.file.name}cancel(){this.uploadService.cancel(),this.uploadCancelled=!0}set onProgress(t){this.progressCallback=t,this.uploadService&&(this.uploadService.onProgress=t)}}class lt{constructor(t){this.platform=t}async handleImagePasted(t){const i=null==t?void 0:t.fileInfo;if(!i)return;if(!this.validateImageSize(i))return;t.insertThumbnail();const e=await this.createFileUpload(i),s=null==e?void 0:e.href;return s&&void 0!==(null==e?void 0:e.fileId)?t.insertImage(s):t.insertFailedThumbnail(),e}parseFileIdFromSrc(t){if(t){const i=/\/(\d+)\/(?:download|contents)\/?$/.exec(t);if(i&&i[1])return Number(i[1])}}validateImageSize(t){return!!t.fileContent&&t.fileContent.size<=52428800}async createFileUpload(t){var i;if(!t.fileContent)return;const e=new ut(t.fileContent,this.http);await e.initialize();const s=Object.assign(Object.assign({},t),{progress:0,file:e,state:"added",fileId:void 0,href:void 0,id:t.id});e.onProgress=t=>{0===s.progress&&(s.state="uploading"),s.progress=t,100===t&&(s.state="finalizing")};const r=await e.upload();return s.fileId=r.id,s.filename=r.filename,s.extension=r.extension,s.contentType=r.contentType,s.size=r.size,s.state="done",s.href=null===(i=r._links)||void 0===i?void 0:i.download.href,s}get http(){return this.platform.get(r.Http)}}const dt=class{watchOpen(){this.setupHandlers(),this.setPickerMessage()}watchQuery(){this.setPickerMessage()}constructor(e){t(this,e),this.change=i(this,"change"),this.metadataChange=i(this,"metadataChange"),this.allowMentioning=!1,this.contentType="markdown",this.language="en",this.disabled=!1,this.readonly=!1,this.invalid=!1,this.required=!1,this.ui="standard",this.allowResize=!0,this.value="",this.triggerMap={},this.customElements=[],this.allowInlineImages=!1,this.items=[],this.highlightedItemIndex=0,this.isPickerOpen=!1,this.isSearching=!1,this.registeredTriggers=[],this.registeredTriggerMap=this.triggerMap,this.registeredCustomElements=this.customElements,this.activeTrigger=void 0,this.handleMouseClick=t=>{this.textEditorPickerElement&&(t.target===this.textEditorPickerElement||this.resetTriggerAndPicker())},this.handleKeyPress=t=>{if(!this.isPickerOpen||!this.activeTrigger)return;if(![c,u,h,l,d].includes(t.key))return;if(t.stopPropagation(),t.preventDefault(),"keyup"===t.type)return;const i={[c]:this.handleEscapeKey,[l]:this.handleEnterOrTabKey,[d]:this.handleEnterOrTabKey,[h]:this.handleArrowKeyPress,[u]:this.handleArrowKeyPress}[t.key];i&&i(t)},this.handleArrowKeyPress=t=>{this.highlightedItemIndex=this.findNonSeparatorIndex(t.key,this.highlightedItemIndex)},this.findNonSeparatorIndex=(t,i,e=0)=>{if(0===this.items.length||e>this.items.length)return i;const s=((t,i,e)=>(i+(t===h?1:-1)+e)%e)(t,i,this.items.length);return this.isListSeparator(this.items[s])?this.findNonSeparatorIndex(t,s,e+1):s},this.handleEscapeKey=()=>{var t;null===(t=this.triggerFunction)||void 0===t||t.stopTrigger(),this.resetTriggerAndPicker()},this.handleEnterOrTabKey=t=>{this.handleItemSelection(t)},this.handleMetadataChange=t=>{t.stopPropagation();const i=t.detail,e=this.getEnhancedImages(i.images||[]),s=Object.assign(Object.assign({},i),{images:e});this.metadataChange.emit(s)},this.handleImagePasted=t=>{t.stopPropagation(),this.allowInlineImages&&this.uploadHandler.handleImagePasted(t.detail)},this.handleTriggerStart=t=>{t.stopPropagation(),this.activeTrigger=t.detail.trigger,this.triggerFunction=t.detail.textEditor,this.isPickerOpen=!0},this.handleTriggerStop=t=>{t.stopPropagation(),this.resetTriggerAndPicker()},this.handleTriggerChange=t=>{var i;t.stopImmediatePropagation(),this.editorPickerQuery=t.detail.value;const e=null===(i=this.registeredTriggerMap[t.detail.trigger])||void 0===i?void 0:i.searcher;e&&(this.isSearching=!0,this.debouncedSearchFn(e,this.editorPickerQuery))},this.resetTriggerAndPicker=()=>{this.isPickerOpen=!1,this.activeTrigger=void 0,this.triggerFunction=void 0,this.isSearching=!1,this.highlightedItemIndex=0,this.items=[]},this.handleItemSelection=t=>{var i;let e;if(t instanceof CustomEvent)e=t.detail;else{if(!(t instanceof KeyboardEvent))return;{const t=this.items[this.highlightedItemIndex];if(this.isListSeparator(t))return;e=t}}if(!this.activeTrigger||(null==e?void 0:e.disabled))return;const s=this.registeredTriggerMap[this.activeTrigger];try{s.inserter(this.triggerFunction,e)}catch(t){console.error("Error inserting",t)}this.resetTriggerAndPicker(),null===(i=this.textEditor)||void 0===i||i.focus()},this.handleVisibilityChange=()=>{"hidden"===document.visibilityState&&this.saveDraft()},this.handleBeforeUnload=()=>{this.saveDraft()},this.portalId=A(),this.debouncedSearchFn=function(t,i,e){var s,r,n,o,a,h,c=0,u=!1,l=!1,d=!0;if("function"!=typeof t)throw new TypeError("Expected a function");function f(i){var e=s,n=r;return s=r=void 0,c=i,o=t.apply(n,e)}function v(t){var e=t-h;return void 0===h||e>=i||e<0||l&&t-c>=n}function m(){var t=ot();if(v(t))return p(t);a=setTimeout(m,function(t){var e=i-(t-h);return l?ht(e,n-(t-c)):e}(t))}function p(t){return a=void 0,d&&s?f(t):(s=r=void 0,o)}function b(){var t=ot(),e=v(t);if(s=arguments,r=this,h=t,e){if(void 0===a)return function(t){return c=t,a=setTimeout(m,i),u?f(t):o}(h);if(l)return clearTimeout(a),a=setTimeout(m,i),f(h)}return void 0===a&&(a=setTimeout(m,i)),o}return i=z(i)||0,x(e)&&(u=!!e.leading,n=(l="maxWait"in e)?at(z(e.maxWait)||0,i):n,d="trailing"in e?!!e.trailing:d),b.cancel=function(){void 0!==a&&clearTimeout(a),c=0,s=h=r=a=void 0},b.flush=function(){return void 0===a?o:p(ot())},b}((async(t,i)=>{try{const e=await t(i);if(i!==this.editorPickerQuery||!this.activeTrigger)return;this.items=e}catch(t){console.error("Error searching",t)}finally{this.isSearching=!1}}),300)}connectedCallback(){var t,i,e,s;if(this.draftIdentifier){const r=null!==(i=null===(t=this.context)||void 0===t?void 0:t.id)&&void 0!==i?i:"no-limeobject",n=null!==(s=null===(e=this.context)||void 0===e?void 0:e.limetype)&&void 0!==s?s:"no-limetype";this.textEditorInnerId=["text-editor-draft",n,r,this.draftIdentifier].join("-")}this.textEditorInnerId&&(document.addEventListener("visibilitychange",this.handleVisibilityChange),window.addEventListener("beforeunload",this.handleBeforeUnload)),this.uploadHandler=new lt(this.platform)}componentWillLoad(){this.allowMentioning&&this.registerMentions(),this.registerTriggers(),this.loadDraft()}disconnectedCallback(){document.removeEventListener("visibilitychange",this.handleVisibilityChange),window.removeEventListener("beforeunload",this.handleBeforeUnload),document.removeEventListener("mousedown",this.handleMouseClick),this.saveDraft(),this.host&&(this.host.removeEventListener("keyup",this.handleKeyPress,{capture:!0}),this.host.removeEventListener("keydown",this.handleKeyPress,{capture:!0})),this.debouncedSearchFn&&this.debouncedSearchFn.cancel&&this.debouncedSearchFn.cancel()}registerMentions(){const t=new ct(this.platform,this.context,this.searchableLimetypes),i=t.triggerHandler.nodeDefinition;i&&(this.registeredCustomElements.push(i.customElement),this.registeredTriggerMap[t.triggerCharacter]=t.triggerHandler,t.initialize())}registerTriggers(){this.registeredTriggers=Object.keys(this.registeredTriggerMap)}setPickerMessage(){var t;if(!this.activeTrigger)return;const i=this.registeredTriggerMap[this.activeTrigger];this.pickerMessage=(null===(t=this.editorPickerQuery)||void 0===t?void 0:t.length)>0?i.noItemsFoundMessage:i.emptySearchMessage}setupHandlers(){this.isPickerOpen?(this.host.addEventListener("keyup",this.handleKeyPress,{capture:!0}),this.host.addEventListener("keydown",this.handleKeyPress,{capture:!0}),document.addEventListener("mousedown",this.handleMouseClick)):(this.host.removeEventListener("keyup",this.handleKeyPress,{capture:!0}),this.host.removeEventListener("keydown",this.handleKeyPress,{capture:!0}),document.removeEventListener("mousedown",this.handleMouseClick))}isListSeparator(t){return"separator"in t&&!0===t.separator}render(){return[e("limel-text-editor",{key:"9cd16fcb065db254b472f33f31d5b28abf2ca760",ref:t=>this.textEditor=t,tabindex:this.disabled?-1:0,value:this.value,contentType:this.contentType,customElements:this.registeredCustomElements,"aria-disabled":this.disabled,language:this.language,triggers:this.registeredTriggers,onTriggerStart:this.handleTriggerStart,onTriggerStop:this.handleTriggerStop,onTriggerChange:this.handleTriggerChange,onImagePasted:this.handleImagePasted,onMetadataChange:this.handleMetadataChange,ui:this.ui,allowResize:this.allowResize,required:this.required,disabled:this.disabled,readonly:this.readonly,helperText:this.helperText,placeholder:this.placeholder,label:this.label,invalid:this.invalid}),this.renderPicker()]}renderPicker(){if(this.isPickerOpen)return e("limel-portal",{containerId:this.portalId,visible:this.isPickerOpen,openDirection:"top",inheritParentWidth:!0,anchor:this.textEditor},e("limebb-text-editor-picker",{ref:t=>this.textEditorPickerElement=t,items:(t=this.items,i=this.highlightedItemIndex,t.map(((t,e)=>{const s=nt(t,5);return Object.assign(Object.assign({},s),{selected:e===i})}))),onItemSelected:this.handleItemSelection,emptyMessage:this.pickerMessage,isSearching:this.isSearching}));var t,i}getEnhancedImages(t){return t.map((t=>{let i;return"success"===t.state&&(i=this.uploadHandler.parseFileIdFromSrc(t.src)),i?Object.assign(Object.assign({},t),{fileId:i}):t}))}loadDraft(){if(!this.userDataService||!this.textEditorInnerId)return;if(this.value)return;const t=this.userDataService.get(this.textEditorInnerId);t&&this.change.emit(t)}saveDraft(){var t,i,e,s;if(!this.textEditorInnerId)return;const r=null===(t=this.value)||void 0===t?void 0:t.trim(),n=null===(i=this.userDataService)||void 0===i?void 0:i.get(this.textEditorInnerId);r&&r!==n?null===(e=this.userDataService)||void 0===e||e.set(this.textEditorInnerId,r):!r&&n&&(null===(s=this.userDataService)||void 0===s||s.set(this.textEditorInnerId,void 0))}get userDataService(){return this.platform.get(r.UserDataRepository)}static get delegatesFocus(){return!0}get host(){return s(this)}static get watchers(){return{isPickerOpen:[{watchOpen:0}],editorPickerQuery:[{watchQuery:0}]}}};(function(t,i,e,s){var r,n=arguments.length,o=n<3?i:null===s?s=Object.getOwnPropertyDescriptor(i,e):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(t,i,e,s);else for(var a=t.length-1;a>=0;a--)(r=t[a])&&(o=(n<3?r(o):n>3?r(i,e,o):r(i,e))||o);n>3&&o&&Object.defineProperty(i,e,o)})([a({map:[function(t){return Object.values(t).filter((t=>M(t,"user")||F(t,"user")))}]})],dt.prototype,"searchableLimetypes",void 0),dt.style=":host(limebb-text-editor){display:block;width:100%;min-width:5rem;min-height:5rem;height:100%;max-height:var(--text-editor-max-height, calc(100vh - (env(safe-area-inset-top) + env(safe-area-inset-bottom)) - 4rem))}";export{dt as limebb_text_editor}
@@ -12,20 +12,21 @@ export declare class UploadHandler {
12
12
  */
13
13
  handleImagePasted(imageInserter: ImageInserter): Promise<FileWrapper | undefined>;
14
14
  /**
15
- * Extracts a file ID from a image source string.
15
+ * Extracts a file ID from an image source string.
16
16
  *
17
- * This function parses a URL to find a file ID that appears before
18
- * '/contents/' at the end of the URL.
17
+ * Matches a file ID that appears before '/download/' (current URL
18
+ * format) or '/contents/' (legacy URL format, kept for historical
19
+ * HTML stored before the switch to '/download/').
19
20
  *
20
21
  * @param src - The URL string to parse
21
22
  * @returns The extracted file ID or undefined if no match is found
22
23
  *
23
24
  * @example
24
25
  * // Returns 123
25
- * parseFileIdFromSrc('/api/file/123/contents/');
26
+ * parseFileIdFromSrc('/api/file/123/download/');
26
27
  *
27
28
  * @example
28
- * // Returns 456
29
+ * // Returns 456 (legacy URL)
29
30
  * parseFileIdFromSrc('https://example.com/limepkg-email/api/v1/file/456/contents/');
30
31
  *
31
32
  * @example
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@limetech/lime-crm-building-blocks",
3
- "version": "1.117.0",
3
+ "version": "1.117.1",
4
4
  "description": "A home for shared components meant for use with Lime CRM",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.js",
@@ -1 +0,0 @@
1
- import{r as t,c as i,h as e,g as s}from"./p-BIwHMk6j.js";import{n as r,Z as n,Q as o,j as a}from"./p-CcGMZOP-.js";import{A as h,a as c,b as u,E as l,T as d}from"./p-CwMJvF_Z.js";import{U as f,S as v,g as m}from"./p-B8RiYkLS.js";import{d as p}from"./p-V3xfp9dg.js";import{e as b}from"./p-yc--7_7T.js";import{o as g,d as j,g as y,f as w,n as O,a as k}from"./p-wbuFLk-j.js";import{d as x,S,i as C,a as I,r as T}from"./p-ByjZfyP_.js";import{c as A}from"./p-C2JP2nLw.js";import{h as F,a as M,b as P}from"./p-CMfAKLlA.js";import{i as E}from"./p-CkTg5UPD.js";import{i as _}from"./p-CQ-z_HTt.js";var L=/\s/,N=/^\s+/;var $=/^[-+]0x[0-9a-f]+$/i,D=/^0b[01]+$/i,R=/^0o[0-7]+$/i,U=parseInt;function z(t){if("number"==typeof t)return t;if(_(t))return NaN;if(x(t)){var i="function"==typeof t.valueOf?t.valueOf():t;t=x(i)?i+"":i}if("string"!=typeof t)return 0===t?t:+t;var e;t=(e=t)?e.slice(0,function(t){for(var i=t.length;i--&&L.test(t.charAt(i)););return i}(e)+1).replace(N,""):e;var s=D.test(t);return s||R.test(t)?U(t.slice(2),s?2:8):$.test(t)?NaN:+t}var G=Object.create,B=function(){function t(){}return function(i){if(!x(i))return{};if(G)return G(i);t.prototype=i;var e=new t;return t.prototype=void 0,e}}(),Q=Object.prototype.hasOwnProperty;var H=g(Object.getPrototypeOf,Object);"object"==typeof exports&&exports&&!exports.nodeType&&exports&&"object"==typeof module&&module&&!module.nodeType&&module;var Z=Object.prototype.hasOwnProperty;function W(t){var i=new t.constructor(t.byteLength);return new f(i).set(new f(t)),i}var q=/\w*$/,J=S?S.prototype:void 0,K=J?J.valueOf:void 0;var V=O&&O.isMap,Y=V?w(V):function(t){return C(t)&&"[object Map]"==y(t)},X=O&&O.isSet,tt=X?w(X):function(t){return C(t)&&"[object Set]"==y(t)},it="[object Arguments]",et="[object Function]",st="[object Object]",rt={};function nt(t,i,e,s,r,n){var o;if(void 0!==o)return o;if(!x(t))return t;var a=I(t);if(a)o=function(t){var i=t.length,e=new t.constructor(i);return i&&"string"==typeof t[0]&&Z.call(t,"index")&&(e.index=t.index,e.input=t.input),e}(t);else{var h=y(t),c=h==et||"[object GeneratorFunction]"==h;if(k(t))return t.slice();if(h==st||h==it||c&&!r)o=c?{}:function(t){return"function"!=typeof t.constructor||j(t)?{}:B(H(t))}(t);else{if(!rt[h])return r?t:{};o=function(t,i){var e,s,r,n,o=t.constructor;switch(i){case"[object ArrayBuffer]":return W(t);case"[object Boolean]":case"[object Date]":return new o(+t);case"[object DataView]":return n=W((r=t).buffer),new r.constructor(n,r.byteOffset,r.byteLength);case"[object Float32Array]":case"[object Float64Array]":case"[object Int8Array]":case"[object Int16Array]":case"[object Int32Array]":case"[object Uint8Array]":case"[object Uint8ClampedArray]":case"[object Uint16Array]":case"[object Uint32Array]":return function(t){var i=W(t.buffer);return new t.constructor(i,t.byteOffset,t.length)}(t);case"[object Map]":case"[object Set]":return new o;case"[object Number]":case"[object String]":return new o(t);case"[object RegExp]":return(s=new(e=t).constructor(e.source,q.exec(e))).lastIndex=e.lastIndex,s;case"[object Symbol]":return K?Object(K.call(t)):{}}}(t,h)}}n||(n=new v);var u=n.get(t);if(u)return u;n.set(t,o),tt(t)?t.forEach((function(s){o.add(nt(s,i,e,0,t,n))})):Y(t)&&t.forEach((function(s,r){o.set(r,nt(s,i,e,0,t,n))}));var l=a?void 0:m(t);return function(t,i){for(var e=-1,s=null==t?0:t.length;++e<s&&!1!==i(t[e],e););}(l||t,(function(s,r){l&&(s=t[r=s]),function(t,i,e){var s=t[i];Q.call(t,i)&&b(s,e)&&(void 0!==e||i in t)||function(t,i,e){"__proto__"==i&&p?p(t,i,{configurable:!0,enumerable:!0,value:e,writable:!0}):t[i]=e}(t,i,e)}(o,r,nt(s,i,e,0,t,n))})),o}rt[it]=rt["[object Array]"]=rt["[object ArrayBuffer]"]=rt["[object DataView]"]=rt["[object Boolean]"]=rt["[object Date]"]=rt["[object Float32Array]"]=rt["[object Float64Array]"]=rt["[object Int8Array]"]=rt["[object Int16Array]"]=rt["[object Int32Array]"]=rt["[object Map]"]=rt["[object Number]"]=rt[st]=rt["[object RegExp]"]=rt["[object Set]"]=rt["[object String]"]=rt["[object Symbol]"]=rt["[object Uint8Array]"]=rt["[object Uint8ClampedArray]"]=rt["[object Uint16Array]"]=rt["[object Uint32Array]"]=!0,rt["[object Error]"]=rt[et]=rt["[object WeakMap]"]=!1;var ot=function(){return T.Date.now()},at=Math.max,ht=Math.min;class ct{get limeObjectService(){return this.platform.get(r.LimeObjectRepository)}get queryService(){return this.platform.get(r.Query)}get viewFactoryRegistry(){return this.platform.get(r.ViewFactoryRegistry)}get translator(){var t;return null===(t=this.platform)||void 0===t?void 0:t.get(r.Translate)}get triggerCharacter(){return this._triggerCharacter}get triggerHandler(){return this._triggerHandler}constructor(t,i,e){this.platform=t,this.context=i,this.searchableLimetypes=e,this.groupCounts={},this._triggerCharacter="@",this._triggerHandler={searcher:t=>this.searcher(t),inserter:(t,i)=>this.inserter(t,i),emptySearchMessage:"Start typing a name...",noItemsFoundMessage:"No results for your search...",nodeDefinition:{customElement:{tagName:"limebb-mention",attributes:["limetype","objectid","href"]},mapAttributes:t=>({limetype:t.value.getLimetype().name,objectid:t.value.id,href:`object/${this.context.limetype}/${this.context.id}`})}},this.searcher=async t=>{if(!t)return[];const{objects:i}=await this.limeObjectService.search(t,this.searchableLimetypes,10);return this.createSearchListItems(i)},this.inserter=async(t,i)=>{var e;const s=this.triggerHandler.nodeDefinition;s&&t.insert({node:{tagName:s.customElement.tagName,attributes:s.mapAttributes(i)},children:[null===(e=i.value)||void 0===e?void 0:e.descriptive]})}}async initialize(){await this.loadGroupCounts()}async loadGroupCounts(){const t=this.searchableLimetypes.filter((t=>!M(t,"user")&&F(t,"user"))).map((t=>this.getGroupCounts(t)));for(const i of await Promise.all(t))Object.assign(this.groupCounts,i)}async getGroupCounts(t){var i;const e=P(t,"user"),s=t.name;try{const t=await this.queryService.execute({limetype:s,responseFormat:{object:{_id:null,[e.name]:{count:{aggregate:{op:n.Count}}}}}});if(!(null===(i=t.objects)||void 0===i?void 0:i.length))return{[s]:{}};const r=this.createGroupCount(t.objects,e.name);return{[s]:r}}catch(i){return console.error(`Error fetching group count for limetype: ${t.name}`,i),{[s]:{}}}}createGroupCount(t,i){const e={};for(const s of t){const{_id:t,[i]:r}=s;e[t]=r.count}return e}createSearchListItems(t=[]){return t.map((t=>this.createSearchListItem(t))).filter(E)}createSearchListItem(t){const i=this.viewFactoryRegistry.getFactory("search"),e=this.limeObjectService.getObject(t._limetype,t._id);if(!e)return null;const s=i(e,this.context),r=this.getGroupCountComponent(e);return Object.assign(Object.assign({},s),r?{primaryComponent:r}:{})}getGroupCountComponent(t){var i;const e=t.getLimetype(),s=null===(i=this.groupCounts[e.name])||void 0===i?void 0:i[t.id],r=P(e,"user");if(void 0!==s&&r)return{name:"limebb-mention-group-counter",props:{count:s,limetype:r.relation.getLimetype(),helperLabel:this.translator.get("webclient.notification-center.members-will-be-notified")}}}}class ut{constructor(t,i){this.file=t,this.http=i,this.uploadCancelled=!1,this.getUrl=t=>`api/v1/file/${null!=t?t:""}`}async initialize(){this.uploadService=await this.http.createFileUpload(o.Post,this.getUrl(),this.file),this.progressCallback&&(this.uploadService.onProgress=this.progressCallback)}async upload(){return this.uploadService.upload()}getFileName(){return this.file.name}cancel(){this.uploadService.cancel(),this.uploadCancelled=!0}set onProgress(t){this.progressCallback=t,this.uploadService&&(this.uploadService.onProgress=t)}}class lt{constructor(t){this.platform=t}async handleImagePasted(t){const i=null==t?void 0:t.fileInfo;if(!i)return;if(!this.validateImageSize(i))return;t.insertThumbnail();const e=await this.createFileUpload(i),s=null==e?void 0:e.href;return s&&void 0!==(null==e?void 0:e.fileId)?t.insertImage(s):t.insertFailedThumbnail(),e}parseFileIdFromSrc(t){if(t){const i=/\/(\d+)\/contents\/?$/.exec(t);if(i&&i[1])return Number(i[1])}}validateImageSize(t){return!!t.fileContent&&t.fileContent.size<=52428800}async createFileUpload(t){var i;if(!t.fileContent)return;const e=new ut(t.fileContent,this.http);await e.initialize();const s=Object.assign(Object.assign({},t),{progress:0,file:e,state:"added",fileId:void 0,href:void 0,id:t.id});e.onProgress=t=>{0===s.progress&&(s.state="uploading"),s.progress=t,100===t&&(s.state="finalizing")};const r=await e.upload();return s.fileId=r.id,s.filename=r.filename,s.extension=r.extension,s.contentType=r.contentType,s.size=r.size,s.state="done",s.href=null===(i=r._links)||void 0===i?void 0:i.contents.href,s}get http(){return this.platform.get(r.Http)}}const dt=class{watchOpen(){this.setupHandlers(),this.setPickerMessage()}watchQuery(){this.setPickerMessage()}constructor(e){t(this,e),this.change=i(this,"change"),this.metadataChange=i(this,"metadataChange"),this.allowMentioning=!1,this.contentType="markdown",this.language="en",this.disabled=!1,this.readonly=!1,this.invalid=!1,this.required=!1,this.ui="standard",this.allowResize=!0,this.value="",this.triggerMap={},this.customElements=[],this.allowInlineImages=!1,this.items=[],this.highlightedItemIndex=0,this.isPickerOpen=!1,this.isSearching=!1,this.registeredTriggers=[],this.registeredTriggerMap=this.triggerMap,this.registeredCustomElements=this.customElements,this.activeTrigger=void 0,this.handleMouseClick=t=>{this.textEditorPickerElement&&(t.target===this.textEditorPickerElement||this.resetTriggerAndPicker())},this.handleKeyPress=t=>{if(!this.isPickerOpen||!this.activeTrigger)return;if(![c,u,h,l,d].includes(t.key))return;if(t.stopPropagation(),t.preventDefault(),"keyup"===t.type)return;const i={[c]:this.handleEscapeKey,[l]:this.handleEnterOrTabKey,[d]:this.handleEnterOrTabKey,[h]:this.handleArrowKeyPress,[u]:this.handleArrowKeyPress}[t.key];i&&i(t)},this.handleArrowKeyPress=t=>{this.highlightedItemIndex=this.findNonSeparatorIndex(t.key,this.highlightedItemIndex)},this.findNonSeparatorIndex=(t,i,e=0)=>{if(0===this.items.length||e>this.items.length)return i;const s=((t,i,e)=>(i+(t===h?1:-1)+e)%e)(t,i,this.items.length);return this.isListSeparator(this.items[s])?this.findNonSeparatorIndex(t,s,e+1):s},this.handleEscapeKey=()=>{var t;null===(t=this.triggerFunction)||void 0===t||t.stopTrigger(),this.resetTriggerAndPicker()},this.handleEnterOrTabKey=t=>{this.handleItemSelection(t)},this.handleMetadataChange=t=>{t.stopPropagation();const i=t.detail,e=this.getEnhancedImages(i.images||[]),s=Object.assign(Object.assign({},i),{images:e});this.metadataChange.emit(s)},this.handleImagePasted=t=>{t.stopPropagation(),this.allowInlineImages&&this.uploadHandler.handleImagePasted(t.detail)},this.handleTriggerStart=t=>{t.stopPropagation(),this.activeTrigger=t.detail.trigger,this.triggerFunction=t.detail.textEditor,this.isPickerOpen=!0},this.handleTriggerStop=t=>{t.stopPropagation(),this.resetTriggerAndPicker()},this.handleTriggerChange=t=>{var i;t.stopImmediatePropagation(),this.editorPickerQuery=t.detail.value;const e=null===(i=this.registeredTriggerMap[t.detail.trigger])||void 0===i?void 0:i.searcher;e&&(this.isSearching=!0,this.debouncedSearchFn(e,this.editorPickerQuery))},this.resetTriggerAndPicker=()=>{this.isPickerOpen=!1,this.activeTrigger=void 0,this.triggerFunction=void 0,this.isSearching=!1,this.highlightedItemIndex=0,this.items=[]},this.handleItemSelection=t=>{var i;let e;if(t instanceof CustomEvent)e=t.detail;else{if(!(t instanceof KeyboardEvent))return;{const t=this.items[this.highlightedItemIndex];if(this.isListSeparator(t))return;e=t}}if(!this.activeTrigger||(null==e?void 0:e.disabled))return;const s=this.registeredTriggerMap[this.activeTrigger];try{s.inserter(this.triggerFunction,e)}catch(t){console.error("Error inserting",t)}this.resetTriggerAndPicker(),null===(i=this.textEditor)||void 0===i||i.focus()},this.handleVisibilityChange=()=>{"hidden"===document.visibilityState&&this.saveDraft()},this.handleBeforeUnload=()=>{this.saveDraft()},this.portalId=A(),this.debouncedSearchFn=function(t,i,e){var s,r,n,o,a,h,c=0,u=!1,l=!1,d=!0;if("function"!=typeof t)throw new TypeError("Expected a function");function f(i){var e=s,n=r;return s=r=void 0,c=i,o=t.apply(n,e)}function v(t){var e=t-h;return void 0===h||e>=i||e<0||l&&t-c>=n}function m(){var t=ot();if(v(t))return p(t);a=setTimeout(m,function(t){var e=i-(t-h);return l?ht(e,n-(t-c)):e}(t))}function p(t){return a=void 0,d&&s?f(t):(s=r=void 0,o)}function b(){var t=ot(),e=v(t);if(s=arguments,r=this,h=t,e){if(void 0===a)return function(t){return c=t,a=setTimeout(m,i),u?f(t):o}(h);if(l)return clearTimeout(a),a=setTimeout(m,i),f(h)}return void 0===a&&(a=setTimeout(m,i)),o}return i=z(i)||0,x(e)&&(u=!!e.leading,n=(l="maxWait"in e)?at(z(e.maxWait)||0,i):n,d="trailing"in e?!!e.trailing:d),b.cancel=function(){void 0!==a&&clearTimeout(a),c=0,s=h=r=a=void 0},b.flush=function(){return void 0===a?o:p(ot())},b}((async(t,i)=>{try{const e=await t(i);if(i!==this.editorPickerQuery||!this.activeTrigger)return;this.items=e}catch(t){console.error("Error searching",t)}finally{this.isSearching=!1}}),300)}connectedCallback(){var t,i,e,s;if(this.draftIdentifier){const r=null!==(i=null===(t=this.context)||void 0===t?void 0:t.id)&&void 0!==i?i:"no-limeobject",n=null!==(s=null===(e=this.context)||void 0===e?void 0:e.limetype)&&void 0!==s?s:"no-limetype";this.textEditorInnerId=["text-editor-draft",n,r,this.draftIdentifier].join("-")}this.textEditorInnerId&&(document.addEventListener("visibilitychange",this.handleVisibilityChange),window.addEventListener("beforeunload",this.handleBeforeUnload)),this.uploadHandler=new lt(this.platform)}componentWillLoad(){this.allowMentioning&&this.registerMentions(),this.registerTriggers(),this.loadDraft()}disconnectedCallback(){document.removeEventListener("visibilitychange",this.handleVisibilityChange),window.removeEventListener("beforeunload",this.handleBeforeUnload),document.removeEventListener("mousedown",this.handleMouseClick),this.saveDraft(),this.host&&(this.host.removeEventListener("keyup",this.handleKeyPress,{capture:!0}),this.host.removeEventListener("keydown",this.handleKeyPress,{capture:!0})),this.debouncedSearchFn&&this.debouncedSearchFn.cancel&&this.debouncedSearchFn.cancel()}registerMentions(){const t=new ct(this.platform,this.context,this.searchableLimetypes),i=t.triggerHandler.nodeDefinition;i&&(this.registeredCustomElements.push(i.customElement),this.registeredTriggerMap[t.triggerCharacter]=t.triggerHandler,t.initialize())}registerTriggers(){this.registeredTriggers=Object.keys(this.registeredTriggerMap)}setPickerMessage(){var t;if(!this.activeTrigger)return;const i=this.registeredTriggerMap[this.activeTrigger];this.pickerMessage=(null===(t=this.editorPickerQuery)||void 0===t?void 0:t.length)>0?i.noItemsFoundMessage:i.emptySearchMessage}setupHandlers(){this.isPickerOpen?(this.host.addEventListener("keyup",this.handleKeyPress,{capture:!0}),this.host.addEventListener("keydown",this.handleKeyPress,{capture:!0}),document.addEventListener("mousedown",this.handleMouseClick)):(this.host.removeEventListener("keyup",this.handleKeyPress,{capture:!0}),this.host.removeEventListener("keydown",this.handleKeyPress,{capture:!0}),document.removeEventListener("mousedown",this.handleMouseClick))}isListSeparator(t){return"separator"in t&&!0===t.separator}render(){return[e("limel-text-editor",{key:"9cd16fcb065db254b472f33f31d5b28abf2ca760",ref:t=>this.textEditor=t,tabindex:this.disabled?-1:0,value:this.value,contentType:this.contentType,customElements:this.registeredCustomElements,"aria-disabled":this.disabled,language:this.language,triggers:this.registeredTriggers,onTriggerStart:this.handleTriggerStart,onTriggerStop:this.handleTriggerStop,onTriggerChange:this.handleTriggerChange,onImagePasted:this.handleImagePasted,onMetadataChange:this.handleMetadataChange,ui:this.ui,allowResize:this.allowResize,required:this.required,disabled:this.disabled,readonly:this.readonly,helperText:this.helperText,placeholder:this.placeholder,label:this.label,invalid:this.invalid}),this.renderPicker()]}renderPicker(){if(this.isPickerOpen)return e("limel-portal",{containerId:this.portalId,visible:this.isPickerOpen,openDirection:"top",inheritParentWidth:!0,anchor:this.textEditor},e("limebb-text-editor-picker",{ref:t=>this.textEditorPickerElement=t,items:(t=this.items,i=this.highlightedItemIndex,t.map(((t,e)=>{const s=nt(t,5);return Object.assign(Object.assign({},s),{selected:e===i})}))),onItemSelected:this.handleItemSelection,emptyMessage:this.pickerMessage,isSearching:this.isSearching}));var t,i}getEnhancedImages(t){return t.map((t=>{let i;return"success"===t.state&&(i=this.uploadHandler.parseFileIdFromSrc(t.src)),i?Object.assign(Object.assign({},t),{fileId:i}):t}))}loadDraft(){if(!this.userDataService||!this.textEditorInnerId)return;if(this.value)return;const t=this.userDataService.get(this.textEditorInnerId);t&&this.change.emit(t)}saveDraft(){var t,i,e,s;if(!this.textEditorInnerId)return;const r=null===(t=this.value)||void 0===t?void 0:t.trim(),n=null===(i=this.userDataService)||void 0===i?void 0:i.get(this.textEditorInnerId);r&&r!==n?null===(e=this.userDataService)||void 0===e||e.set(this.textEditorInnerId,r):!r&&n&&(null===(s=this.userDataService)||void 0===s||s.set(this.textEditorInnerId,void 0))}get userDataService(){return this.platform.get(r.UserDataRepository)}static get delegatesFocus(){return!0}get host(){return s(this)}static get watchers(){return{isPickerOpen:[{watchOpen:0}],editorPickerQuery:[{watchQuery:0}]}}};(function(t,i,e,s){var r,n=arguments.length,o=n<3?i:null===s?s=Object.getOwnPropertyDescriptor(i,e):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(t,i,e,s);else for(var a=t.length-1;a>=0;a--)(r=t[a])&&(o=(n<3?r(o):n>3?r(i,e,o):r(i,e))||o);n>3&&o&&Object.defineProperty(i,e,o)})([a({map:[function(t){return Object.values(t).filter((t=>M(t,"user")||F(t,"user")))}]})],dt.prototype,"searchableLimetypes",void 0),dt.style=":host(limebb-text-editor){display:block;width:100%;min-width:5rem;min-height:5rem;height:100%;max-height:var(--text-editor-max-height, calc(100vh - (env(safe-area-inset-top) + env(safe-area-inset-bottom)) - 4rem))}";export{dt as limebb_text_editor}