{\r\n this.$emit(key, props);\r\n };\r\n }\r\n\r\n this.containerElement = this.$refs.container || this.$el;\r\n this.container = smoothDnD(this.containerElement, options);\r\n },\r\n unmounted () {\r\n if (this.container) {\r\n this.container.dispose();\r\n }\r\n },\r\n emits: ['drop', 'drag-start', 'drag-end', 'drag-enter', 'drag-leave', 'drop-ready' ],\r\n props: {\r\n removeOnDropOut: { type: Boolean, default: false },\r\n autoScrollEnabled: { type: Boolean, default: true },\r\n behaviour: String,\r\n groupName: String,\r\n orientation: String,\r\n dragHandleSelector: String,\r\n nonDragAreaSelector: String,\r\n lockAxis: String,\r\n dragClass: String,\r\n dropClass: String,\r\n dragBeginDelay: Number,\r\n animationDuration: Number,\r\n getChildPayload: Function,\r\n shouldAnimateDrop: Function,\r\n shouldAcceptDrop: Function,\r\n getGhostParent: Function,\r\n dropPlaceholder: [Object, Boolean],\r\n tag: {\r\n validator: validateTagProp,\r\n default: 'div',\r\n }\r\n },\r\n render(){\r\n const tagProps = getTagProps(this);\r\n return h(\r\n tagProps.value,\r\n Object.assign({}, { ref: 'container' }, tagProps.props),\r\n this.$slots.default(),\r\n );\r\n }\r\n});\n\nvar Draggable = defineComponent({\r\n name: 'Draggable',\r\n props: {\r\n tag: {\r\n validator: validateTagProp,\r\n default: 'div'\r\n },\r\n },\r\n render: function () {\r\n //wrap child\r\n const tagProps = getTagProps(this, constants.wrapperClass);\r\n return h(\r\n tagProps.value,\r\n Object.assign({}, tagProps.props),\r\n this.$slots.default()\r\n );\r\n }\r\n});\n\nexport { Container, Draggable };\n//# sourceMappingURL=vue3-smooth-dnd.esm.js.map\n","export const applyDrag = (arr, dragResult) => {\n const { removedIndex, addedIndex, payload } = dragResult\n if (removedIndex === null && addedIndex === null) return arr\n\n const result = [...arr]\n let itemToAdd = payload\n\n if (removedIndex !== null) {\n itemToAdd = result.splice(removedIndex, 1)[0]\n }\n\n if (addedIndex !== null) {\n result.splice(addedIndex, 0, itemToAdd)\n }\n\n return result\n}","\n \n \n \n
\n\n\n\n\n\n","\n \n\n\n\n","\n\n \n
\n\n
\n\n
\n
\n\n\n\n","\nexport default class FormValidator {\n\n constructor(table, document) {\n this.table = table\n this.document = document\n }\n\n isValid() {\n let fields = this.table.fields\n\n // NOTE: the field \"index\" is actually its ID\n for (let i = 0; i < fields.length; i++) {\n let field = fields[i]\n\n if(!this.isFieldValid(field)) {\n return false\n }\n }\n\n return true\n }\n\n isFieldValid(field) {\n if(field.required) {\n let fieldValue = this.document[field.index]\n\n if(fieldValue === undefined || fieldValue === null || fieldValue === '' ) {\n return false\n }\n\n if(field.field_type === 'Number' && !this.isValidNumber(fieldValue)) {\n return false\n }\n\n if(field.name.toLowerCase().indexOf('email') > -1) {\n return /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/.test(fieldValue)\n }\n }\n\n return true\n }\n\n isValidNumber(fieldValue) {\n return !isNaN(fieldValue)\n }\n}","\n \n
\n\n
\n {{field.name}} is required\n
\n
\n\n\n\n","\n\n \n\n
\n\n
\n\n
\n {{field.name}} is required\n
\n
\n\n\n\n\n\n\n","import RestService from './RestService'\n\nexport default class AttachmentService extends RestService {\n constructor () {\n super( 'attachments' )\n }\n\n saveAttachment(appId, fieldId, recordId, file) {\n let url = this.baseUrl + '/api/v1/attachments.json?t=' + Date.now()\n\n let formData = new FormData()\n formData.append('attachment[name]', file.name)\n formData.append('attachment[file]', file)\n formData.append(\"attachment[file_type]\", file.type)\n formData.append('attachment[app_id]', appId)\n formData.append('attachment[field_id]', fieldId)\n formData.append('attachment[record_id]', recordId)\n\n\n return new Promise((resolve, reject) => {\n this.http.post(url)\n .send(formData)\n .set('x-api-token', this.authToken)\n .set('Accept', 'application/json')\n .end((error, response) => {\n\n if (response.status === 200 || response.status === 201) {\n let updatedRecord = JSON.parse(response.text)\n console.log('Attachment saved')\n console.log(updatedRecord)\n resolve(updatedRecord)\n } else {\n // this.messageUtil.error(response.statusText)\n reject(response.statusText)\n }\n\n })\n })\n }\n}","\n \n\n
0\" class=\"my-2 d-flex flex-wrap\">\n
\n\n
\n\n
\n \n
\n\n
\n\n\n","\n \n\n
\n
\n \n
\n
\n\n
\n
\n \n \n {{fieldName(documentId)}}\n \n
\n
\n\n
\n\n
\n\n\n\n\n\n","export default class FieldValidator {\n\n constructor(field, document) {\n this.field = field\n this.document = document\n }\n\n isValid() {\n\n let fieldValue = this.document[this.field.index]\n\n if (fieldValue === undefined || fieldValue === null || fieldValue === '') {\n return false\n }\n\n if (this.field.field_type === 'Number' && !this.isValidNumber(fieldValue)) {\n return false\n }\n\n if (this.field.name.toLowerCase().indexOf('email') > -1) {\n return /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/.test(fieldValue)\n }\n\n\n return true\n }\n\n isValidNumber(fieldValue) {\n return !isNaN(fieldValue)\n }\n}","import RestService from './RestService'\n\nexport default class ImageService extends RestService {\n constructor() {\n super('images')\n }\n\n siteImages(websiteId) {\n let url = this.baseUrl + `/api/v1/images.json?site_id=${websiteId}&t=${Date.now()}`\n return this.executeGet(url)\n }\n\n uploadImage(imageableType, imageableId, file) {\n let url = this.baseUrl + '/api/v1/images.json?t=' + Date.now()\n\n let formData = new FormData()\n formData.append('image[name]', file.name)\n formData.append('image[source]', 'Upload')\n formData.append('image[paperclip_image]', file)\n formData.append('image[imageable_type]', imageableType)\n formData.append('image[imageable_id]', imageableId)\n\n return new Promise((resolve, reject) => {\n this.http.post(url)\n .send(formData)\n .set('x-api-token', this.authToken)\n .set('Accept', 'application/json')\n .end((error, response) => {\n\n if (response.status === 200 || response.status === 201) {\n let updatedRecord = JSON.parse(response.text)\n console.log('Image saved')\n console.log(updatedRecord)\n resolve(updatedRecord)\n } else {\n // this.messageUtil.error(response.statusText)\n reject(response.statusText)\n }\n\n })\n })\n }\n}","\n \n
\n\n
\n \n\n \n\n \n
\n\n
0\" class=\"w-100 mt-2 d-flex justify-content-center flex-wrap\">\n
\n
![]()
\n
\n
\n
\n
\n\n\n\n\n\n","/*\nTrix 2.0.4\nCopyright © 2022 37signals, LLC\n */\nconst t={preview:{presentation:\"gallery\",caption:{name:!0,size:!0}},file:{caption:{size:!0}}},e={default:{tagName:\"div\",parse:!1},quote:{tagName:\"blockquote\",nestable:!0},heading1:{tagName:\"h1\",terminal:!0,breakOnReturn:!0,group:!1},code:{tagName:\"pre\",terminal:!0,text:{plaintext:!0}},bulletList:{tagName:\"ul\",parse:!1},bullet:{tagName:\"li\",listAttribute:\"bulletList\",group:!1,nestable:!0,test(t){return i(t.parentNode)===e[this.listAttribute].tagName}},numberList:{tagName:\"ol\",parse:!1},number:{tagName:\"li\",listAttribute:\"numberList\",group:!1,nestable:!0,test(t){return i(t.parentNode)===e[this.listAttribute].tagName}},attachmentGallery:{tagName:\"div\",exclusive:!0,terminal:!0,parse:!1,group:!1}},i=t=>{var e;return null==t||null===(e=t.tagName)||void 0===e?void 0:e.toLowerCase()},n=navigator.userAgent.match(/android\\s([0-9]+.*Chrome)/i),r=n&&parseInt(n[1]);var o={composesExistingText:/Android.*Chrome/.test(navigator.userAgent),recentAndroid:r&&r>12,samsungAndroid:r&&navigator.userAgent.match(/Android.*SM-/),forcesObjectResizing:/Trident.*rv:11/.test(navigator.userAgent),supportsInputEvents:\"undefined\"!=typeof InputEvent&&[\"data\",\"getTargetRanges\",\"inputType\"].every((t=>t in InputEvent.prototype))},s={attachFiles:\"Attach Files\",bold:\"Bold\",bullets:\"Bullets\",byte:\"Byte\",bytes:\"Bytes\",captionPlaceholder:\"Add a caption…\",code:\"Code\",heading1:\"Heading\",indent:\"Increase Level\",italic:\"Italic\",link:\"Link\",numbers:\"Numbers\",outdent:\"Decrease Level\",quote:\"Quote\",redo:\"Redo\",remove:\"Remove\",strike:\"Strikethrough\",undo:\"Undo\",unlink:\"Unlink\",url:\"URL\",urlPlaceholder:\"Enter a URL…\",GB:\"GB\",KB:\"KB\",MB:\"MB\",PB:\"PB\",TB:\"TB\"};const a=[s.bytes,s.KB,s.MB,s.GB,s.TB,s.PB];var l={prefix:\"IEC\",precision:2,formatter(t){switch(t){case 0:return\"0 \".concat(s.bytes);case 1:return\"1 \".concat(s.byte);default:let e;\"SI\"===this.prefix?e=1e3:\"IEC\"===this.prefix&&(e=1024);const i=Math.floor(Math.log(t)/Math.log(e)),n=(t/Math.pow(e,i)).toFixed(this.precision).replace(/0*$/,\"\").replace(/\\.$/,\"\");return\"\".concat(n,\" \").concat(a[i])}}};const c=function(t){for(const e in t){const i=t[e];this[e]=i}return this},h=document.documentElement,u=h.matches,d=function(t){let{onElement:e,matchingSelector:i,withCallback:n,inPhase:r,preventDefault:o,times:s}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const a=e||h,l=i,c=\"capturing\"===r,u=function(t){null!=s&&0==--s&&u.destroy();const e=p(t.target,{matchingSelector:l});null!=e&&(null==n||n.call(e,t,e),o&&t.preventDefault())};return u.destroy=()=>a.removeEventListener(t,u,c),a.addEventListener(t,u,c),u},g=function(t){let{onElement:e,bubbles:i,cancelable:n,attributes:r}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const o=null!=e?e:h;i=!1!==i,n=!1!==n;const s=document.createEvent(\"Events\");return s.initEvent(t,i,n),null!=r&&c.call(s,r),o.dispatchEvent(s)},m=function(t,e){if(1===(null==t?void 0:t.nodeType))return u.call(t,e)},p=function(t){let{matchingSelector:e,untilNode:i}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};for(;t&&t.nodeType!==Node.ELEMENT_NODE;)t=t.parentNode;if(null!=t){if(null==e)return t;if(t.closest&&null==i)return t.closest(e);for(;t&&t!==i;){if(m(t,e))return t;t=t.parentNode}}},f=t=>document.activeElement!==t&&b(t,document.activeElement),b=function(t,e){if(t&&e)for(;e;){if(e===t)return!0;e=e.parentNode}},v=function(t){var e;if(null===(e=t)||void 0===e||!e.parentNode)return;let i=0;for(t=t.previousSibling;t;)i++,t=t.previousSibling;return i},A=t=>{var e;return null==t||null===(e=t.parentNode)||void 0===e?void 0:e.removeChild(t)},x=function(t){let{onlyNodesOfType:e,usingFilter:i,expandEntityReferences:n}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const r=(()=>{switch(e){case\"element\":return NodeFilter.SHOW_ELEMENT;case\"text\":return NodeFilter.SHOW_TEXT;case\"comment\":return NodeFilter.SHOW_COMMENT;default:return NodeFilter.SHOW_ALL}})();return document.createTreeWalker(t,r,null!=i?i:null,!0===n)},y=t=>{var e;return null==t||null===(e=t.tagName)||void 0===e?void 0:e.toLowerCase()},C=function(t){let e,i,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};\"object\"==typeof t?(n=t,t=n.tagName):n={attributes:n};const r=document.createElement(t);if(null!=n.editable&&(null==n.attributes&&(n.attributes={}),n.attributes.contenteditable=n.editable),n.attributes)for(e in n.attributes)i=n.attributes[e],r.setAttribute(e,i);if(n.style)for(e in n.style)i=n.style[e],r.style[e]=i;if(n.data)for(e in n.data)i=n.data[e],r.dataset[e]=i;return n.className&&n.className.split(\" \").forEach((t=>{r.classList.add(t)})),n.textContent&&(r.textContent=n.textContent),n.childNodes&&[].concat(n.childNodes).forEach((t=>{r.appendChild(t)})),r};let R;const E=function(){if(null!=R)return R;R=[];for(const t in e){const i=e[t];i.tagName&&R.push(i.tagName)}return R},S=t=>D(null==t?void 0:t.firstChild),k=function(t){return E().includes(y(t))&&!E().includes(y(t.firstChild))},L=function(t){let{strict:e}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{strict:!0};return e?D(t):D(t)||!D(t.firstChild)&&k(t)},D=t=>w(t)&&\"block\"===(null==t?void 0:t.data),w=t=>(null==t?void 0:t.nodeType)===Node.COMMENT_NODE,T=function(t){let{name:e}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(t)return I(t)?\"\\ufeff\"===t.data?!e||t.parentNode.dataset.trixCursorTarget===e:void 0:T(t.firstChild)},F=t=>m(t,\"[data-trix-attachment]\"),B=t=>I(t)&&\"\"===(null==t?void 0:t.data),I=t=>(null==t?void 0:t.nodeType)===Node.TEXT_NODE,P={level2Enabled:!0,getLevel(){return this.level2Enabled&&o.supportsInputEvents?2:0},pickFiles(t){const e=C(\"input\",{type:\"file\",multiple:!0,hidden:!0,id:this.fileInputId});e.addEventListener(\"change\",(()=>{t(e.files),A(e)})),A(document.getElementById(this.fileInputId)),document.body.appendChild(e),e.click()}};var N={removeBlankTableCells:!1,tableCellSeparator:\" | \",tableRowSeparator:\"\\n\"},O={bold:{tagName:\"strong\",inheritable:!0,parser(t){const e=window.getComputedStyle(t);return\"bold\"===e.fontWeight||e.fontWeight>=600}},italic:{tagName:\"em\",inheritable:!0,parser:t=>\"italic\"===window.getComputedStyle(t).fontStyle},href:{groupTagName:\"a\",parser(t){const e=\"a:not(\".concat(\"[data-trix-attachment]\",\")\"),i=t.closest(e);if(i)return i.getAttribute(\"href\")}},strike:{tagName:\"del\",inheritable:!0},frozen:{style:{backgroundColor:\"highlight\"}}},M={getDefaultHTML:()=>'\\n \\n \\n \\n \\n \\n \\n\\n \\n \\n \\n \\n \\n \\n \\n \\n \\n\\n \\n \\n \\n\\n \\n\\n \\n \\n \\n \\n
\\n\\n ')};const j={interval:5e3};var W=Object.freeze({__proto__:null,attachments:t,blockAttributes:e,browser:o,css:{attachment:\"attachment\",attachmentCaption:\"attachment__caption\",attachmentCaptionEditor:\"attachment__caption-editor\",attachmentMetadata:\"attachment__metadata\",attachmentMetadataContainer:\"attachment__metadata-container\",attachmentName:\"attachment__name\",attachmentProgress:\"attachment__progress\",attachmentSize:\"attachment__size\",attachmentToolbar:\"attachment__toolbar\",attachmentGallery:\"attachment-gallery\"},fileSize:l,input:P,keyNames:{8:\"backspace\",9:\"tab\",13:\"return\",27:\"escape\",37:\"left\",39:\"right\",46:\"delete\",68:\"d\",72:\"h\",79:\"o\"},lang:s,parser:N,textAttributes:O,toolbar:M,undo:j});class U{static proxyMethod(t){const{name:e,toMethod:i,toProperty:n,optional:r}=q(t);this.prototype[e]=function(){let t,o;var s,a;i?o=r?null===(s=this[i])||void 0===s?void 0:s.call(this):this[i]():n&&(o=this[n]);return r?(t=null===(a=o)||void 0===a?void 0:a[e],t?V.call(t,o,arguments):void 0):(t=o[e],V.call(t,o,arguments))}}}const q=function(t){const e=t.match(z);if(!e)throw new Error(\"can't parse @proxyMethod expression: \".concat(t));const i={name:e[4]};return null!=e[2]?i.toMethod=e[1]:i.toProperty=e[1],null!=e[3]&&(i.optional=!0),i},{apply:V}=Function.prototype,z=new RegExp(\"^(.+?)(\\\\(\\\\))?(\\\\?)?\\\\.(.+?)$\");var _,H,J;class K extends U{static box(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:\"\";return t instanceof this?t:this.fromUCS2String(null==t?void 0:t.toString())}static fromUCS2String(t){return new this(t,Y(t))}static fromCodepoints(t){return new this(Q(t),t)}constructor(t,e){super(...arguments),this.ucs2String=t,this.codepoints=e,this.length=this.codepoints.length,this.ucs2Length=this.ucs2String.length}offsetToUCS2Offset(t){return Q(this.codepoints.slice(0,Math.max(0,t))).length}offsetFromUCS2Offset(t){return Y(this.ucs2String.slice(0,Math.max(0,t))).length}slice(){return this.constructor.fromCodepoints(this.codepoints.slice(...arguments))}charAt(t){return this.slice(t,t+1)}isEqualTo(t){return this.constructor.box(t).ucs2String===this.ucs2String}toJSON(){return this.ucs2String}getCacheKey(){return this.ucs2String}toString(){return this.ucs2String}}const G=1===(null===(_=Array.from)||void 0===_?void 0:_.call(Array,\"👼\").length),$=null!=(null===(H=\" \".codePointAt)||void 0===H?void 0:H.call(\" \",0)),X=\" 👼\"===(null===(J=String.fromCodePoint)||void 0===J?void 0:J.call(String,32,128124));let Y,Q;Y=G&&$?t=>Array.from(t).map((t=>t.codePointAt(0))):function(t){const e=[];let i=0;const{length:n}=t;for(;iString.fromCodePoint(...Array.from(t||[])):function(t){return(()=>{const e=[];return Array.from(t).forEach((t=>{let i=\"\";t>65535&&(t-=65536,i+=String.fromCharCode(t>>>10&1023|55296),t=56320|1023&t),e.push(i+String.fromCharCode(t))})),e})().join(\"\")};let Z=0;class tt extends U{static fromJSONString(t){return this.fromJSON(JSON.parse(t))}constructor(){super(...arguments),this.id=++Z}hasSameConstructorAs(t){return this.constructor===(null==t?void 0:t.constructor)}isEqualTo(t){return this===t}inspect(){const t=[],e=this.contentsForInspection()||{};for(const i in e){const n=e[i];t.push(\"\".concat(i,\"=\").concat(n))}return\"#<\".concat(this.constructor.name,\":\").concat(this.id).concat(t.length?\" \".concat(t.join(\", \")):\"\",\">\")}contentsForInspection(){}toJSONString(){return JSON.stringify(this)}toUTF16String(){return K.box(this)}getCacheKey(){return this.id.toString()}}const et=function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];if(t.length!==e.length)return!1;for(let i=0;i1?i-1:0),r=1;r(ot||(ot=gt().concat(ut())),ot),ht=t=>e[t],ut=()=>(st||(st=Object.keys(e)),st),dt=t=>O[t],gt=()=>(at||(at=Object.keys(O)),at),mt=function(t,e){pt(t).textContent=e.replace(/%t/g,t)},pt=function(t){const e=document.createElement(\"style\");e.setAttribute(\"type\",\"text/css\"),e.setAttribute(\"data-tag-name\",t.toLowerCase());const i=ft();return i&&e.setAttribute(\"nonce\",i),document.head.insertBefore(e,document.head.firstChild),e},ft=function(){const t=bt(\"trix-csp-nonce\")||bt(\"csp-nonce\");if(t)return t.getAttribute(\"content\")},bt=t=>document.head.querySelector(\"meta[name=\".concat(t,\"]\")),vt={\"application/x-trix-feature-detection\":\"test\"},At=function(t){const e=t.getData(\"text/plain\"),i=t.getData(\"text/html\");if(!e||!i)return null==e?void 0:e.length;{const{body:t}=(new DOMParser).parseFromString(i,\"text/html\");if(t.textContent===e)return!t.querySelector(\"*\")}},xt=/Mac|^iP/.test(navigator.platform)?t=>t.metaKey:t=>t.ctrlKey,yt=t=>setTimeout(t,1),Ct=function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const e={};for(const i in t){const n=t[i];e[i]=n}return e},Rt=function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(Object.keys(t).length!==Object.keys(e).length)return!1;for(const i in t){if(t[i]!==e[i])return!1}return!0},Et=function(t){if(null!=t)return Array.isArray(t)||(t=[t,t]),[Lt(t[0]),Lt(null!=t[1]?t[1]:t[0])]},St=function(t){if(null==t)return;const[e,i]=Et(t);return Dt(e,i)},kt=function(t,e){if(null==t||null==e)return;const[i,n]=Et(t),[r,o]=Et(e);return Dt(i,r)&&Dt(n,o)},Lt=function(t){return\"number\"==typeof t?t:Ct(t)},Dt=function(t,e){return\"number\"==typeof t?t===e:Rt(t,e)};class wt extends U{constructor(){super(...arguments),this.update=this.update.bind(this),this.run=this.run.bind(this),this.selectionManagers=[]}start(){if(!this.started)return this.started=!0,\"onselectionchange\"in document?document.addEventListener(\"selectionchange\",this.update,!0):this.run()}stop(){if(this.started)return this.started=!1,document.removeEventListener(\"selectionchange\",this.update,!0)}registerSelectionManager(t){if(!this.selectionManagers.includes(t))return this.selectionManagers.push(t),this.start()}unregisterSelectionManager(t){if(this.selectionManagers=this.selectionManagers.filter((e=>e!==t)),0===this.selectionManagers.length)return this.stop()}notifySelectionManagersOfSelectionChange(){return this.selectionManagers.map((t=>t.selectionDidChange()))}update(){const t=It();if(!Tt(t,this.domRange))return this.domRange=t,this.notifySelectionManagersOfSelectionChange()}reset(){return this.domRange=null,this.update()}run(){if(this.started)return this.update(),requestAnimationFrame(this.run)}}const Tt=(t,e)=>(null==t?void 0:t.startContainer)===(null==e?void 0:e.startContainer)&&(null==t?void 0:t.startOffset)===(null==e?void 0:e.startOffset)&&(null==t?void 0:t.endContainer)===(null==e?void 0:e.endContainer)&&(null==t?void 0:t.endOffset)===(null==e?void 0:e.endOffset),Ft=new wt,Bt=function(){const t=window.getSelection();if(t.rangeCount>0)return t},It=function(){var t;const e=null===(t=Bt())||void 0===t?void 0:t.getRangeAt(0);if(e&&!Nt(e))return e},Pt=function(t){const e=window.getSelection();return e.removeAllRanges(),e.addRange(t),Ft.update()},Nt=t=>Ot(t.startContainer)||Ot(t.endContainer),Ot=t=>!Object.getPrototypeOf(t),Mt=t=>t.replace(new RegExp(\"\".concat(\"\\ufeff\"),\"g\"),\"\").replace(new RegExp(\"\".concat(\" \"),\"g\"),\" \"),jt=new RegExp(\"[^\\\\S\".concat(\" \",\"]\")),Wt=t=>t.replace(new RegExp(\"\".concat(jt.source),\"g\"),\" \").replace(/\\ {2,}/g,\" \"),Ut=function(t,e){if(t.isEqualTo(e))return[\"\",\"\"];const i=qt(t,e),{length:n}=i.utf16String;let r;if(n){const{offset:o}=i,s=t.codepoints.slice(0,o).concat(t.codepoints.slice(o+n));r=qt(e,K.fromCodepoints(s))}else r=qt(e,t);return[i.utf16String.toString(),r.utf16String.toString()]},qt=function(t,e){let i=0,n=t.length,r=e.length;for(;ii+1&&t.charAt(n-1).isEqualTo(e.charAt(r-1));)n--,r--;return{utf16String:t.slice(i,n),offset:i}};class Vt extends tt{static fromCommonAttributesOfObjects(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];if(!t.length)return new this;let e=Jt(t[0]),i=e.getKeys();return t.slice(1).forEach((t=>{i=e.getKeysCommonToHash(Jt(t)),e=e.slice(i)})),e}static box(t){return Jt(t)}constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super(...arguments),this.values=Ht(t)}add(t,e){return this.merge(zt(t,e))}remove(t){return new Vt(Ht(this.values,t))}get(t){return this.values[t]}has(t){return t in this.values}merge(t){return new Vt(_t(this.values,Kt(t)))}slice(t){const e={};return Array.from(t).forEach((t=>{this.has(t)&&(e[t]=this.values[t])})),new Vt(e)}getKeys(){return Object.keys(this.values)}getKeysCommonToHash(t){return t=Jt(t),this.getKeys().filter((e=>this.values[e]===t.values[e]))}isEqualTo(t){return et(this.toArray(),Jt(t).toArray())}isEmpty(){return 0===this.getKeys().length}toArray(){if(!this.array){const t=[];for(const e in this.values){const i=this.values[e];t.push(t.push(e,i))}this.array=t.slice(0)}return this.array}toObject(){return Ht(this.values)}toJSON(){return this.toObject()}contentsForInspection(){return{values:JSON.stringify(this.values)}}}const zt=function(t,e){const i={};return i[t]=e,i},_t=function(t,e){const i=Ht(t);for(const t in e){const n=e[t];i[t]=n}return i},Ht=function(t,e){const i={};return Object.keys(t).sort().forEach((n=>{n!==e&&(i[n]=t[n])})),i},Jt=function(t){return t instanceof Vt?t:new Vt(t)},Kt=function(t){return t instanceof Vt?t.values:t};class Gt{static groupObjects(){let t,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],{depth:i,asTree:n}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};n&&null==i&&(i=0);const r=[];return Array.from(e).forEach((e=>{var o;if(t){var s,a,l;if(null!==(s=e.canBeGrouped)&&void 0!==s&&s.call(e,i)&&null!==(a=(l=t[t.length-1]).canBeGroupedWith)&&void 0!==a&&a.call(l,e,i))return void t.push(e);r.push(new this(t,{depth:i,asTree:n})),t=null}null!==(o=e.canBeGrouped)&&void 0!==o&&o.call(e,i)?t=[e]:r.push(e)})),t&&r.push(new this(t,{depth:i,asTree:n})),r}constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],{depth:e,asTree:i}=arguments.length>1?arguments[1]:void 0;this.objects=t,i&&(this.depth=e,this.objects=this.constructor.groupObjects(this.objects,{asTree:i,depth:this.depth+1}))}getObjects(){return this.objects}getDepth(){return this.depth}getCacheKey(){const t=[\"objectGroup\"];return Array.from(this.getObjects()).forEach((e=>{t.push(e.getCacheKey())})),t.join(\"/\")}}class $t extends U{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];super(...arguments),this.objects={},Array.from(t).forEach((t=>{const e=JSON.stringify(t);null==this.objects[e]&&(this.objects[e]=t)}))}find(t){const e=JSON.stringify(t);return this.objects[e]}}class Xt{constructor(t){this.reset(t)}add(t){const e=Yt(t);this.elements[e]=t}remove(t){const e=Yt(t),i=this.elements[e];if(i)return delete this.elements[e],i}reset(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return this.elements={},Array.from(t).forEach((t=>{this.add(t)})),t}}const Yt=t=>t.dataset.trixStoreKey;class Qt extends U{isPerforming(){return!0===this.performing}hasPerformed(){return!0===this.performed}hasSucceeded(){return this.performed&&this.succeeded}hasFailed(){return this.performed&&!this.succeeded}getPromise(){return this.promise||(this.promise=new Promise(((t,e)=>(this.performing=!0,this.perform(((i,n)=>{this.succeeded=i,this.performing=!1,this.performed=!0,this.succeeded?t(n):e(n)})))))),this.promise}perform(t){return t(!1)}release(){var t,e;null===(t=this.promise)||void 0===t||null===(e=t.cancel)||void 0===e||e.call(t),this.promise=null,this.performing=null,this.performed=null,this.succeeded=null}}Qt.proxyMethod(\"getPromise().then\"),Qt.proxyMethod(\"getPromise().catch\");class Zt extends U{constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(...arguments),this.object=t,this.options=e,this.childViews=[],this.rootView=this}getNodes(){return this.nodes||(this.nodes=this.createNodes()),this.nodes.map((t=>t.cloneNode(!0)))}invalidate(){var t;return this.nodes=null,this.childViews=[],null===(t=this.parentView)||void 0===t?void 0:t.invalidate()}invalidateViewForObject(t){var e;return null===(e=this.findViewForObject(t))||void 0===e?void 0:e.invalidate()}findOrCreateCachedChildView(t,e,i){let n=this.getCachedViewForObject(e);return n?this.recordChildView(n):(n=this.createChildView(...arguments),this.cacheViewForObject(n,e)),n}createChildView(t,e){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};e instanceof Gt&&(i.viewClass=t,t=te);const n=new t(e,i);return this.recordChildView(n)}recordChildView(t){return t.parentView=this,t.rootView=this.rootView,this.childViews.push(t),t}getAllChildViews(){let t=[];return this.childViews.forEach((e=>{t.push(e),t=t.concat(e.getAllChildViews())})),t}findElement(){return this.findElementForObject(this.object)}findElementForObject(t){const e=null==t?void 0:t.id;if(e)return this.rootView.element.querySelector(\"[data-trix-id='\".concat(e,\"']\"))}findViewForObject(t){for(const e of this.getAllChildViews())if(e.object===t)return e}getViewCache(){return this.rootView!==this?this.rootView.getViewCache():this.isViewCachingEnabled()?(this.viewCache||(this.viewCache={}),this.viewCache):void 0}isViewCachingEnabled(){return!1!==this.shouldCacheViews}enableViewCaching(){this.shouldCacheViews=!0}disableViewCaching(){this.shouldCacheViews=!1}getCachedViewForObject(t){var e;return null===(e=this.getViewCache())||void 0===e?void 0:e[t.getCacheKey()]}cacheViewForObject(t,e){const i=this.getViewCache();i&&(i[e.getCacheKey()]=t)}garbageCollectCachedViews(){const t=this.getViewCache();if(t){const e=this.getAllChildViews().concat(this).map((t=>t.object.getCacheKey()));for(const i in t)e.includes(i)||delete t[i]}}}class te extends Zt{constructor(){super(...arguments),this.objectGroup=this.object,this.viewClass=this.options.viewClass,delete this.options.viewClass}getChildViews(){return this.childViews.length||Array.from(this.objectGroup.getObjects()).forEach((t=>{this.findOrCreateCachedChildView(this.viewClass,t,this.options)})),this.childViews}createNodes(){const t=this.createContainerElement();return this.getChildViews().forEach((e=>{Array.from(e.getNodes()).forEach((e=>{t.appendChild(e)}))})),[t]}createContainerElement(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.objectGroup.getDepth();return this.getChildViews()[0].createContainerElement(t)}}const{css:ee}=W;class ie extends Zt{constructor(){super(...arguments),this.attachment=this.object,this.attachment.uploadProgressDelegate=this,this.attachmentPiece=this.options.piece}createContentNodes(){return[]}createNodes(){let t;const e=t=C({tagName:\"figure\",className:this.getClassName(),data:this.getData(),editable:!1}),i=this.getHref();return i&&(t=C({tagName:\"a\",editable:!1,attributes:{href:i,tabindex:-1}}),e.appendChild(t)),this.attachment.hasContent()?t.innerHTML=this.attachment.getContent():this.createContentNodes().forEach((e=>{t.appendChild(e)})),t.appendChild(this.createCaptionElement()),this.attachment.isPending()&&(this.progressElement=C({tagName:\"progress\",attributes:{class:ee.attachmentProgress,value:this.attachment.getUploadProgress(),max:100},data:{trixMutable:!0,trixStoreKey:[\"progressElement\",this.attachment.id].join(\"/\")}}),e.appendChild(this.progressElement)),[ne(\"left\"),e,ne(\"right\")]}createCaptionElement(){const t=C({tagName:\"figcaption\",className:ee.attachmentCaption}),e=this.attachmentPiece.getCaption();if(e)t.classList.add(\"\".concat(ee.attachmentCaption,\"--edited\")),t.textContent=e;else{let e,i;const n=this.getCaptionConfig();if(n.name&&(e=this.attachment.getFilename()),n.size&&(i=this.attachment.getFormattedFilesize()),e){const i=C({tagName:\"span\",className:ee.attachmentName,textContent:e});t.appendChild(i)}if(i){e&&t.appendChild(document.createTextNode(\" \"));const n=C({tagName:\"span\",className:ee.attachmentSize,textContent:i});t.appendChild(n)}}return t}getClassName(){const t=[ee.attachment,\"\".concat(ee.attachment,\"--\").concat(this.attachment.getType())],e=this.attachment.getExtension();return e&&t.push(\"\".concat(ee.attachment,\"--\").concat(e)),t.join(\" \")}getData(){const t={trixAttachment:JSON.stringify(this.attachment),trixContentType:this.attachment.getContentType(),trixId:this.attachment.id},{attributes:e}=this.attachmentPiece;return e.isEmpty()||(t.trixAttributes=JSON.stringify(e)),this.attachment.isPending()&&(t.trixSerialize=!1),t}getHref(){if(!re(this.attachment.getContent(),\"a\"))return this.attachment.getHref()}getCaptionConfig(){var e;const i=this.attachment.getType(),n=Ct(null===(e=t[i])||void 0===e?void 0:e.caption);return\"file\"===i&&(n.name=!0),n}findProgressElement(){var t;return null===(t=this.findElement())||void 0===t?void 0:t.querySelector(\"progress\")}attachmentDidChangeUploadProgress(){const t=this.attachment.getUploadProgress(),e=this.findProgressElement();e&&(e.value=t)}}const ne=t=>C({tagName:\"span\",textContent:\"\\ufeff\",data:{trixCursorTarget:t,trixSerialize:!1}}),re=function(t,e){const i=C(\"div\");return i.innerHTML=t||\"\",i.querySelector(e)};class oe extends ie{constructor(){super(...arguments),this.attachment.previewDelegate=this}createContentNodes(){return this.image=C({tagName:\"img\",attributes:{src:\"\"},data:{trixMutable:!0}}),this.refresh(this.image),[this.image]}createCaptionElement(){const t=super.createCaptionElement(...arguments);return t.textContent||t.setAttribute(\"data-trix-placeholder\",s.captionPlaceholder),t}refresh(t){var e;t||(t=null===(e=this.findElement())||void 0===e?void 0:e.querySelector(\"img\"));if(t)return this.updateAttributesForImage(t)}updateAttributesForImage(t){const e=this.attachment.getURL(),i=this.attachment.getPreviewURL();if(t.src=i||e,i===e)t.removeAttribute(\"data-trix-serialized-attributes\");else{const i=JSON.stringify({src:e});t.setAttribute(\"data-trix-serialized-attributes\",i)}const n=this.attachment.getWidth(),r=this.attachment.getHeight();null!=n&&(t.width=n),null!=r&&(t.height=r);const o=[\"imageElement\",this.attachment.id,t.src,t.width,t.height].join(\"/\");t.dataset.trixStoreKey=o}attachmentDidChangeAttributes(){return this.refresh(this.image),this.refresh()}}class se extends Zt{constructor(){super(...arguments),this.piece=this.object,this.attributes=this.piece.getAttributes(),this.textConfig=this.options.textConfig,this.context=this.options.context,this.piece.attachment?this.attachment=this.piece.attachment:this.string=this.piece.toString()}createNodes(){let t=this.attachment?this.createAttachmentNodes():this.createStringNodes();const e=this.createElement();if(e){const i=function(t){for(;null!==(e=t)&&void 0!==e&&e.firstElementChild;){var e;t=t.firstElementChild}return t}(e);Array.from(t).forEach((t=>{i.appendChild(t)})),t=[e]}return t}createAttachmentNodes(){const t=this.attachment.isPreviewable()?oe:ie;return this.createChildView(t,this.piece.attachment,{piece:this.piece}).getNodes()}createStringNodes(){var t;if(null!==(t=this.textConfig)&&void 0!==t&&t.plaintext)return[document.createTextNode(this.string)];{const t=[],e=this.string.split(\"\\n\");for(let i=0;i0){const e=C(\"br\");t.push(e)}if(n.length){const e=document.createTextNode(this.preserveSpaces(n));t.push(e)}}return t}}createElement(){let t,e,i;const n={};for(e in this.attributes){i=this.attributes[e];const o=dt(e);if(o){if(o.tagName){var r;const e=C(o.tagName);r?(r.appendChild(e),r=e):t=r=e}if(o.styleProperty&&(n[o.styleProperty]=i),o.style)for(e in o.style)i=o.style[e],n[e]=i}}if(Object.keys(n).length)for(e in t||(t=C(\"span\")),n)i=n[e],t.style[e]=i;return t}createContainerElement(){for(const t in this.attributes){const e=this.attributes[t],i=dt(t);if(i&&i.groupTagName){const n={};return n[t]=e,C(i.groupTagName,n)}}}preserveSpaces(t){return this.context.isLast&&(t=t.replace(/\\ $/,\" \")),t=t.replace(/(\\S)\\ {3}(\\S)/g,\"$1 \".concat(\" \",\" $2\")).replace(/\\ {2}/g,\"\".concat(\" \",\" \")).replace(/\\ {2}/g,\" \".concat(\" \")),(this.context.isFirst||this.context.followsWhitespace)&&(t=t.replace(/^\\ /,\" \")),t}}class ae extends Zt{constructor(){super(...arguments),this.text=this.object,this.textConfig=this.options.textConfig}createNodes(){const t=[],e=Gt.groupObjects(this.getPieces()),i=e.length-1;for(let r=0;r!t.hasAttribute(\"blockBreak\")))}}const le=t=>/\\s$/.test(null==t?void 0:t.toString()),{css:ce}=W;class he extends Zt{constructor(){super(...arguments),this.block=this.object,this.attributes=this.block.getAttributes()}createNodes(){const t=[document.createComment(\"block\")];if(this.block.isEmpty())t.push(C(\"br\"));else{var i;const e=null===(i=ht(this.block.getLastAttribute()))||void 0===i?void 0:i.text,n=this.findOrCreateCachedChildView(ae,this.block.text,{textConfig:e});t.push(...Array.from(n.getNodes()||[])),this.shouldAddExtraNewlineElement()&&t.push(C(\"br\"))}if(this.attributes.length)return t;{let i;const{tagName:n}=e.default;this.block.isRTL()&&(i={dir:\"rtl\"});const r=C({tagName:n,attributes:i});return t.forEach((t=>r.appendChild(t))),[r]}}createContainerElement(t){let e,i;const n=this.attributes[t],{tagName:r}=ht(n);if(0===t&&this.block.isRTL()&&(e={dir:\"rtl\"}),\"attachmentGallery\"===n){const t=this.block.getBlockBreakPosition();i=\"\".concat(ce.attachmentGallery,\" \").concat(ce.attachmentGallery,\"--\").concat(t)}return C({tagName:r,className:i,attributes:e})}shouldAddExtraNewlineElement(){return/\\n\\n$/.test(this.block.toString())}}class ue extends Zt{static render(t){const e=C(\"div\"),i=new this(t,{element:e});return i.render(),i.sync(),e}constructor(){super(...arguments),this.element=this.options.element,this.elementStore=new Xt,this.setDocument(this.object)}setDocument(t){t.isEqualTo(this.document)||(this.document=this.object=t)}render(){if(this.childViews=[],this.shadowElement=C(\"div\"),!this.document.isEmpty()){const t=Gt.groupObjects(this.document.getBlocks(),{asTree:!0});Array.from(t).forEach((t=>{const e=this.findOrCreateCachedChildView(he,t);Array.from(e.getNodes()).map((t=>this.shadowElement.appendChild(t)))}))}}isSynced(){return ge(this.shadowElement,this.element)}sync(){const t=this.createDocumentFragmentForSync();for(;this.element.lastChild;)this.element.removeChild(this.element.lastChild);return this.element.appendChild(t),this.didSync()}didSync(){return this.elementStore.reset(de(this.element)),yt((()=>this.garbageCollectCachedViews()))}createDocumentFragmentForSync(){const t=document.createDocumentFragment();return Array.from(this.shadowElement.childNodes).forEach((e=>{t.appendChild(e.cloneNode(!0))})),Array.from(de(t)).forEach((t=>{const e=this.elementStore.remove(t);e&&t.parentNode.replaceChild(e,t)})),t}}const de=t=>t.querySelectorAll(\"[data-trix-store-key]\"),ge=(t,e)=>me(t.innerHTML)===me(e.innerHTML),me=t=>t.replace(/ /g,\" \");function pe(t){this.wrapped=t}function fe(t){var e,i;function n(e,i){try{var o=t[e](i),s=o.value,a=s instanceof pe;Promise.resolve(a?s.wrapped:s).then((function(t){a?n(\"return\"===e?\"return\":\"next\",t):r(o.done?\"return\":\"normal\",t)}),(function(t){n(\"throw\",t)}))}catch(t){r(\"throw\",t)}}function r(t,r){switch(t){case\"return\":e.resolve({value:r,done:!0});break;case\"throw\":e.reject(r);break;default:e.resolve({value:r,done:!1})}(e=e.next)?n(e.key,e.arg):i=null}this._invoke=function(t,r){return new Promise((function(o,s){var a={key:t,arg:r,resolve:o,reject:s,next:null};i?i=i.next=a:(e=i=a,n(t,r))}))},\"function\"!=typeof t.return&&(this.return=void 0)}function be(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}fe.prototype[\"function\"==typeof Symbol&&Symbol.asyncIterator||\"@@asyncIterator\"]=function(){return this},fe.prototype.next=function(t){return this._invoke(\"next\",t)},fe.prototype.throw=function(t){return this._invoke(\"throw\",t)},fe.prototype.return=function(t){return this._invoke(\"return\",t)};class ve extends tt{static registerType(t,e){e.type=t,this.types[t]=e}static fromJSON(t){const e=this.types[t.type];if(e)return e.fromJSON(t)}constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(...arguments),this.attributes=Vt.box(e)}copyWithAttributes(t){return new this.constructor(this.getValue(),t)}copyWithAdditionalAttributes(t){return this.copyWithAttributes(this.attributes.merge(t))}copyWithoutAttribute(t){return this.copyWithAttributes(this.attributes.remove(t))}copy(){return this.copyWithAttributes(this.attributes)}getAttribute(t){return this.attributes.get(t)}getAttributesHash(){return this.attributes}getAttributes(){return this.attributes.toObject()}hasAttribute(t){return this.attributes.has(t)}hasSameStringValueAsPiece(t){return t&&this.toString()===t.toString()}hasSameAttributesAsPiece(t){return t&&(this.attributes===t.attributes||this.attributes.isEqualTo(t.attributes))}isBlockBreak(){return!1}isEqualTo(t){return super.isEqualTo(...arguments)||this.hasSameConstructorAs(t)&&this.hasSameStringValueAsPiece(t)&&this.hasSameAttributesAsPiece(t)}isEmpty(){return 0===this.length}isSerializable(){return!0}toJSON(){return{type:this.constructor.type,attributes:this.getAttributes()}}contentsForInspection(){return{type:this.constructor.type,attributes:this.attributes.inspect()}}canBeGrouped(){return this.hasAttribute(\"href\")}canBeGroupedWith(t){return this.getAttribute(\"href\")===t.getAttribute(\"href\")}getLength(){return this.length}canBeConsolidatedWith(t){return!1}}be(ve,\"types\",{});class Ae extends Qt{constructor(t){super(...arguments),this.url=t}perform(t){const e=new Image;e.onload=()=>(e.width=this.width=e.naturalWidth,e.height=this.height=e.naturalHeight,t(!0,e)),e.onerror=()=>t(!1),e.src=this.url}}class xe extends tt{static attachmentForFile(t){const e=new this(this.attributesForFile(t));return e.setFile(t),e}static attributesForFile(t){return new Vt({filename:t.name,filesize:t.size,contentType:t.type})}static fromJSON(t){return new this(t)}constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super(t),this.releaseFile=this.releaseFile.bind(this),this.attributes=Vt.box(t),this.didChangeAttributes()}getAttribute(t){return this.attributes.get(t)}hasAttribute(t){return this.attributes.has(t)}getAttributes(){return this.attributes.toObject()}setAttributes(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const e=this.attributes.merge(t);var i,n,r,o;if(!this.attributes.isEqualTo(e))return this.attributes=e,this.didChangeAttributes(),null===(i=this.previewDelegate)||void 0===i||null===(n=i.attachmentDidChangeAttributes)||void 0===n||n.call(i,this),null===(r=this.delegate)||void 0===r||null===(o=r.attachmentDidChangeAttributes)||void 0===o?void 0:o.call(r,this)}didChangeAttributes(){if(this.isPreviewable())return this.preloadURL()}isPending(){return null!=this.file&&!(this.getURL()||this.getHref())}isPreviewable(){return this.attributes.has(\"previewable\")?this.attributes.get(\"previewable\"):xe.previewablePattern.test(this.getContentType())}getType(){return this.hasContent()?\"content\":this.isPreviewable()?\"preview\":\"file\"}getURL(){return this.attributes.get(\"url\")}getHref(){return this.attributes.get(\"href\")}getFilename(){return this.attributes.get(\"filename\")||\"\"}getFilesize(){return this.attributes.get(\"filesize\")}getFormattedFilesize(){const t=this.attributes.get(\"filesize\");return\"number\"==typeof t?l.formatter(t):\"\"}getExtension(){var t;return null===(t=this.getFilename().match(/\\.(\\w+)$/))||void 0===t?void 0:t[1].toLowerCase()}getContentType(){return this.attributes.get(\"contentType\")}hasContent(){return this.attributes.has(\"content\")}getContent(){return this.attributes.get(\"content\")}getWidth(){return this.attributes.get(\"width\")}getHeight(){return this.attributes.get(\"height\")}getFile(){return this.file}setFile(t){if(this.file=t,this.isPreviewable())return this.preloadFile()}releaseFile(){this.releasePreloadedFile(),this.file=null}getUploadProgress(){return null!=this.uploadProgress?this.uploadProgress:0}setUploadProgress(t){var e,i;if(this.uploadProgress!==t)return this.uploadProgress=t,null===(e=this.uploadProgressDelegate)||void 0===e||null===(i=e.attachmentDidChangeUploadProgress)||void 0===i?void 0:i.call(e,this)}toJSON(){return this.getAttributes()}getCacheKey(){return[super.getCacheKey(...arguments),this.attributes.getCacheKey(),this.getPreviewURL()].join(\"/\")}getPreviewURL(){return this.previewURL||this.preloadingURL}setPreviewURL(t){var e,i,n,r;if(t!==this.getPreviewURL())return this.previewURL=t,null===(e=this.previewDelegate)||void 0===e||null===(i=e.attachmentDidChangeAttributes)||void 0===i||i.call(e,this),null===(n=this.delegate)||void 0===n||null===(r=n.attachmentDidChangePreviewURL)||void 0===r?void 0:r.call(n,this)}preloadURL(){return this.preload(this.getURL(),this.releaseFile)}preloadFile(){if(this.file)return this.fileObjectURL=URL.createObjectURL(this.file),this.preload(this.fileObjectURL)}releasePreloadedFile(){this.fileObjectURL&&(URL.revokeObjectURL(this.fileObjectURL),this.fileObjectURL=null)}preload(t,e){if(t&&t!==this.getPreviewURL()){this.preloadingURL=t;return new Ae(t).then((i=>{let{width:n,height:r}=i;return this.getWidth()&&this.getHeight()||this.setAttributes({width:n,height:r}),this.preloadingURL=null,this.setPreviewURL(t),null==e?void 0:e()})).catch((()=>(this.preloadingURL=null,null==e?void 0:e())))}}}be(xe,\"previewablePattern\",/^image(\\/(gif|png|jpe?g)|$)/);class ye extends ve{static fromJSON(t){return new this(xe.fromJSON(t.attachment),t.attributes)}constructor(t){super(...arguments),this.attachment=t,this.length=1,this.ensureAttachmentExclusivelyHasAttribute(\"href\"),this.attachment.hasContent()||this.removeProhibitedAttributes()}ensureAttachmentExclusivelyHasAttribute(t){this.hasAttribute(t)&&(this.attachment.hasAttribute(t)||this.attachment.setAttributes(this.attributes.slice([t])),this.attributes=this.attributes.remove(t))}removeProhibitedAttributes(){const t=this.attributes.slice(ye.permittedAttributes);t.isEqualTo(this.attributes)||(this.attributes=t)}getValue(){return this.attachment}isSerializable(){return!this.attachment.isPending()}getCaption(){return this.attributes.get(\"caption\")||\"\"}isEqualTo(t){var e;return super.isEqualTo(t)&&this.attachment.id===(null==t||null===(e=t.attachment)||void 0===e?void 0:e.id)}toString(){return\"\"}toJSON(){const t=super.toJSON(...arguments);return t.attachment=this.attachment,t}getCacheKey(){return[super.getCacheKey(...arguments),this.attachment.getCacheKey()].join(\"/\")}toConsole(){return JSON.stringify(this.toString())}}be(ye,\"permittedAttributes\",[\"caption\",\"presentation\"]),ve.registerType(\"attachment\",ye);class Ce extends ve{static fromJSON(t){return new this(t.string,t.attributes)}constructor(t){super(...arguments),this.string=(t=>t.replace(/\\r\\n/g,\"\\n\"))(t),this.length=this.string.length}getValue(){return this.string}toString(){return this.string.toString()}isBlockBreak(){return\"\\n\"===this.toString()&&!0===this.getAttribute(\"blockBreak\")}toJSON(){const t=super.toJSON(...arguments);return t.string=this.string,t}canBeConsolidatedWith(t){return t&&this.hasSameConstructorAs(t)&&this.hasSameAttributesAsPiece(t)}consolidateWith(t){return new this.constructor(this.toString()+t.toString(),this.attributes)}splitAtOffset(t){let e,i;return 0===t?(e=null,i=this):t===this.length?(e=this,i=null):(e=new this.constructor(this.string.slice(0,t),this.attributes),i=new this.constructor(this.string.slice(t),this.attributes)),[e,i]}toConsole(){let{string:t}=this;return t.length>15&&(t=t.slice(0,14)+\"…\"),JSON.stringify(t.toString())}}ve.registerType(\"string\",Ce);class Re extends tt{static box(t){return t instanceof this?t:new this(t)}constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];super(...arguments),this.objects=t.slice(0),this.length=this.objects.length}indexOf(t){return this.objects.indexOf(t)}splice(){for(var t=arguments.length,e=new Array(t),i=0;it(e,i)))}insertObjectAtIndex(t,e){return this.splice(e,0,t)}insertSplittableListAtIndex(t,e){return this.splice(e,0,...t.objects)}insertSplittableListAtPosition(t,e){const[i,n]=this.splitObjectAtPosition(e);return new this.constructor(i).insertSplittableListAtIndex(t,n)}editObjectAtIndex(t,e){return this.replaceObjectAtIndex(e(this.objects[t]),t)}replaceObjectAtIndex(t,e){return this.splice(e,1,t)}removeObjectAtIndex(t){return this.splice(t,1)}getObjectAtIndex(t){return this.objects[t]}getSplittableListInRange(t){const[e,i,n]=this.splitObjectsAtRange(t);return new this.constructor(e.slice(i,n+1))}selectSplittableList(t){const e=this.objects.filter((e=>t(e)));return new this.constructor(e)}removeObjectsInRange(t){const[e,i,n]=this.splitObjectsAtRange(t);return new this.constructor(e).splice(i,n-i+1)}transformObjectsInRange(t,e){const[i,n,r]=this.splitObjectsAtRange(t),o=i.map(((t,i)=>n<=i&&i<=r?e(t):t));return new this.constructor(o)}splitObjectsAtRange(t){let e,[i,n,r]=this.splitObjectAtPosition(Se(t));return[i,e]=new this.constructor(i).splitObjectAtPosition(ke(t)+r),[i,n,e-1]}getObjectAtPosition(t){const{index:e}=this.findIndexAndOffsetAtPosition(t);return this.objects[e]}splitObjectAtPosition(t){let e,i;const{index:n,offset:r}=this.findIndexAndOffsetAtPosition(t),o=this.objects.slice(0);if(null!=n)if(0===r)e=n,i=0;else{const t=this.getObjectAtIndex(n),[s,a]=t.splitAtOffset(r);o.splice(n,1,s,a),e=n+1,i=s.getLength()-r}else e=o.length,i=0;return[o,e,i]}consolidate(){const t=[];let e=this.objects[0];return this.objects.slice(1).forEach((i=>{var n,r;null!==(n=(r=e).canBeConsolidatedWith)&&void 0!==n&&n.call(r,i)?e=e.consolidateWith(i):(t.push(e),e=i)})),e&&t.push(e),new this.constructor(t)}consolidateFromIndexToIndex(t,e){const i=this.objects.slice(0).slice(t,e+1),n=new this.constructor(i).consolidate().toArray();return this.splice(t,i.length,...n)}findIndexAndOffsetAtPosition(t){let e,i=0;for(e=0;ethis.endPosition+=t.getLength()))),this.endPosition}toString(){return this.objects.join(\"\")}toArray(){return this.objects.slice(0)}toJSON(){return this.toArray()}isEqualTo(t){return super.isEqualTo(...arguments)||Ee(this.objects,null==t?void 0:t.objects)}contentsForInspection(){return{objects:\"[\".concat(this.objects.map((t=>t.inspect())).join(\", \"),\"]\")}}}const Ee=function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];if(t.length!==e.length)return!1;let i=!0;for(let n=0;nt[0],ke=t=>t[1];class Le extends tt{static textForAttachmentWithAttributes(t,e){return new this([new ye(t,e)])}static textForStringWithAttributes(t,e){return new this([new Ce(t,e)])}static fromJSON(t){return new this(Array.from(t).map((t=>ve.fromJSON(t))))}constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];super(...arguments);const e=t.filter((t=>!t.isEmpty()));this.pieceList=new Re(e)}copy(){return this.copyWithPieceList(this.pieceList)}copyWithPieceList(t){return new this.constructor(t.consolidate().toArray())}copyUsingObjectMap(t){const e=this.getPieces().map((e=>t.find(e)||e));return new this.constructor(e)}appendText(t){return this.insertTextAtPosition(t,this.getLength())}insertTextAtPosition(t,e){return this.copyWithPieceList(this.pieceList.insertSplittableListAtPosition(t.pieceList,e))}removeTextAtRange(t){return this.copyWithPieceList(this.pieceList.removeObjectsInRange(t))}replaceTextAtRange(t,e){return this.removeTextAtRange(e).insertTextAtPosition(t,e[0])}moveTextFromRangeToPosition(t,e){if(t[0]<=e&&e<=t[1])return;const i=this.getTextAtRange(t),n=i.getLength();return t[0]e.copyWithAdditionalAttributes(t))))}removeAttributeAtRange(t,e){return this.copyWithPieceList(this.pieceList.transformObjectsInRange(e,(e=>e.copyWithoutAttribute(t))))}setAttributesAtRange(t,e){return this.copyWithPieceList(this.pieceList.transformObjectsInRange(e,(e=>e.copyWithAttributes(t))))}getAttributesAtPosition(t){var e;return(null===(e=this.pieceList.getObjectAtPosition(t))||void 0===e?void 0:e.getAttributes())||{}}getCommonAttributes(){const t=Array.from(this.pieceList.toArray()).map((t=>t.getAttributes()));return Vt.fromCommonAttributesOfObjects(t).toObject()}getCommonAttributesAtRange(t){return this.getTextAtRange(t).getCommonAttributes()||{}}getExpandedRangeForAttributeAtOffset(t,e){let i,n=i=e;const r=this.getLength();for(;n>0&&this.getCommonAttributesAtRange([n-1,i])[t];)n--;for(;i!!t.attachment))}getAttachments(){return this.getAttachmentPieces().map((t=>t.attachment))}getAttachmentAndPositionById(t){let e=0;for(const n of this.pieceList.toArray()){var i;if((null===(i=n.attachment)||void 0===i?void 0:i.id)===t)return{attachment:n.attachment,position:e};e+=n.length}return{attachment:null,position:null}}getAttachmentById(t){const{attachment:e}=this.getAttachmentAndPositionById(t);return e}getRangeOfAttachment(t){const e=this.getAttachmentAndPositionById(t.id),i=e.position;if(t=e.attachment)return[i,i+1]}updateAttributesForAttachment(t,e){const i=this.getRangeOfAttachment(e);return i?this.addAttributesAtRange(t,i):this}getLength(){return this.pieceList.getEndPosition()}isEmpty(){return 0===this.getLength()}isEqualTo(t){var e;return super.isEqualTo(t)||(null==t||null===(e=t.pieceList)||void 0===e?void 0:e.isEqualTo(this.pieceList))}isBlockBreak(){return 1===this.getLength()&&this.pieceList.getObjectAtIndex(0).isBlockBreak()}eachPiece(t){return this.pieceList.eachObject(t)}getPieces(){return this.pieceList.toArray()}getPieceAtPosition(t){return this.pieceList.getObjectAtPosition(t)}contentsForInspection(){return{pieceList:this.pieceList.inspect()}}toSerializableText(){const t=this.pieceList.selectSplittableList((t=>t.isSerializable()));return this.copyWithPieceList(t)}toString(){return this.pieceList.toString()}toJSON(){return this.pieceList.toJSON()}toConsole(){return JSON.stringify(this.pieceList.toArray().map((t=>JSON.parse(t.toConsole()))))}getDirection(){return rt(this.toString())}isRTL(){return\"rtl\"===this.getDirection()}}class De extends tt{static fromJSON(t){return new this(Le.fromJSON(t.text),t.attributes)}constructor(t,e){super(...arguments),this.text=we(t||new Le),this.attributes=e||[]}isEmpty(){return this.text.isBlockBreak()}isEqualTo(t){return!!super.isEqualTo(t)||this.text.isEqualTo(null==t?void 0:t.text)&&et(this.attributes,null==t?void 0:t.attributes)}copyWithText(t){return new De(t,this.attributes)}copyWithoutText(){return this.copyWithText(null)}copyWithAttributes(t){return new De(this.text,t)}copyWithoutAttributes(){return this.copyWithAttributes(null)}copyUsingObjectMap(t){const e=t.find(this.text);return e?this.copyWithText(e):this.copyWithText(this.text.copyUsingObjectMap(t))}addAttribute(t){const e=this.attributes.concat(Ne(t));return this.copyWithAttributes(e)}removeAttribute(t){const{listAttribute:e}=ht(t),i=Me(Me(this.attributes,t),e);return this.copyWithAttributes(i)}removeLastAttribute(){return this.removeAttribute(this.getLastAttribute())}getLastAttribute(){return Oe(this.attributes)}getAttributes(){return this.attributes.slice(0)}getAttributeLevel(){return this.attributes.length}getAttributeAtLevel(t){return this.attributes[t-1]}hasAttribute(t){return this.attributes.includes(t)}hasAttributes(){return this.getAttributeLevel()>0}getLastNestableAttribute(){return Oe(this.getNestableAttributes())}getNestableAttributes(){return this.attributes.filter((t=>ht(t).nestable))}getNestingLevel(){return this.getNestableAttributes().length}decreaseNestingLevel(){const t=this.getLastNestableAttribute();return t?this.removeAttribute(t):this}increaseNestingLevel(){const t=this.getLastNestableAttribute();if(t){const e=this.attributes.lastIndexOf(t),i=it(this.attributes,e+1,0,...Ne(t));return this.copyWithAttributes(i)}return this}getListItemAttributes(){return this.attributes.filter((t=>ht(t).listAttribute))}isListItem(){var t;return null===(t=ht(this.getLastAttribute()))||void 0===t?void 0:t.listAttribute}isTerminalBlock(){var t;return null===(t=ht(this.getLastAttribute()))||void 0===t?void 0:t.terminal}breaksOnReturn(){var t;return null===(t=ht(this.getLastAttribute()))||void 0===t?void 0:t.breakOnReturn}findLineBreakInDirectionFromPosition(t,e){const i=this.toString();let n;switch(t){case\"forward\":n=i.indexOf(\"\\n\",e);break;case\"backward\":n=i.slice(0,e).lastIndexOf(\"\\n\")}if(-1!==n)return n}contentsForInspection(){return{text:this.text.inspect(),attributes:this.attributes}}toString(){return this.text.toString()}toJSON(){return{text:this.text,attributes:this.attributes}}getDirection(){return this.text.getDirection()}isRTL(){return this.text.isRTL()}getLength(){return this.text.getLength()}canBeConsolidatedWith(t){return!this.hasAttributes()&&!t.hasAttributes()&&this.getDirection()===t.getDirection()}consolidateWith(t){const e=Le.textForStringWithAttributes(\"\\n\"),i=this.getTextWithoutBlockBreak().appendText(e);return this.copyWithText(i.appendText(t.text))}splitAtOffset(t){let e,i;return 0===t?(e=null,i=this):t===this.getLength()?(e=this,i=null):(e=this.copyWithText(this.text.getTextAtRange([0,t])),i=this.copyWithText(this.text.getTextAtRange([t,this.getLength()]))),[e,i]}getBlockBreakPosition(){return this.text.getLength()-1}getTextWithoutBlockBreak(){return Ie(this.text)?this.text.getTextAtRange([0,this.getBlockBreakPosition()]):this.text.copy()}canBeGrouped(t){return this.attributes[t]}canBeGroupedWith(t,i){const n=t.getAttributes(),r=n[i],o=this.attributes[i];return o===r&&!(!1===ht(o).group&&!(()=>{if(!lt){lt=[];for(const t in e){const{listAttribute:i}=e[t];null!=i&<.push(i)}}return lt})().includes(n[i+1]))&&(this.getDirection()===t.getDirection()||t.isEmpty())}}const we=function(t){return t=Te(t),t=Be(t)},Te=function(t){let e=!1;const i=t.getPieces();let n=i.slice(0,i.length-1);const r=i[i.length-1];return r?(n=n.map((t=>t.isBlockBreak()?(e=!0,Pe(t)):t)),e?new Le([...n,r]):t):t},Fe=Le.textForStringWithAttributes(\"\\n\",{blockBreak:!0}),Be=function(t){return Ie(t)?t:t.appendText(Fe)},Ie=function(t){const e=t.getLength();if(0===e)return!1;return t.getTextAtRange([e-1,e]).isBlockBreak()},Pe=t=>t.copyWithoutAttribute(\"blockBreak\"),Ne=function(t){const{listAttribute:e}=ht(t);return e?[e,t]:[t]},Oe=t=>t.slice(-1)[0],Me=function(t,e){const i=t.lastIndexOf(e);return-1===i?t:it(t,i,1)};class je extends tt{static fromJSON(t){return new this(Array.from(t).map((t=>De.fromJSON(t))))}static fromString(t,e){const i=Le.textForStringWithAttributes(t,e);return new this([new De(i)])}constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];super(...arguments),0===t.length&&(t=[new De]),this.blockList=Re.box(t)}isEmpty(){const t=this.getBlockAtIndex(0);return 1===this.blockList.length&&t.isEmpty()&&!t.hasAttributes()}copy(){const t=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).consolidateBlocks?this.blockList.consolidate().toArray():this.blockList.toArray();return new this.constructor(t)}copyUsingObjectsFromDocument(t){const e=new $t(t.getObjects());return this.copyUsingObjectMap(e)}copyUsingObjectMap(t){const e=this.getBlocks().map((e=>t.find(e)||e.copyUsingObjectMap(t)));return new this.constructor(e)}copyWithBaseBlockAttributes(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];const e=this.getBlocks().map((e=>{const i=t.concat(e.getAttributes());return e.copyWithAttributes(i)}));return new this.constructor(e)}replaceBlock(t,e){const i=this.blockList.indexOf(t);return-1===i?this:new this.constructor(this.blockList.replaceObjectAtIndex(e,i))}insertDocumentAtRange(t,e){const{blockList:i}=t;e=Et(e);let[n]=e;const{index:r,offset:o}=this.locationFromPosition(n);let s=this;const a=this.getBlockAtPosition(n);return St(e)&&a.isEmpty()&&!a.hasAttributes()?s=new this.constructor(s.blockList.removeObjectAtIndex(r)):a.getBlockBreakPosition()===o&&n++,s=s.removeTextAtRange(e),new this.constructor(s.blockList.insertSplittableListAtPosition(i,n))}mergeDocumentAtRange(t,e){let i,n;e=Et(e);const[r]=e,o=this.locationFromPosition(r),s=this.getBlockAtIndex(o.index).getAttributes(),a=t.getBaseBlockAttributes(),l=s.slice(-a.length);if(et(a,l)){const e=s.slice(0,-a.length);i=t.copyWithBaseBlockAttributes(e)}else i=t.copy({consolidateBlocks:!0}).copyWithBaseBlockAttributes(s);const c=i.getBlockCount(),h=i.getBlockAtIndex(0);if(et(s,h.getAttributes())){const t=h.getTextWithoutBlockBreak();if(n=this.insertTextAtRange(t,e),c>1){i=new this.constructor(i.getBlocks().slice(1));const e=r+t.getLength();n=n.insertDocumentAtRange(i,e)}}else n=this.insertDocumentAtRange(i,e);return n}insertTextAtRange(t,e){e=Et(e);const[i]=e,{index:n,offset:r}=this.locationFromPosition(i),o=this.removeTextAtRange(e);return new this.constructor(o.blockList.editObjectAtIndex(n,(e=>e.copyWithText(e.text.insertTextAtPosition(t,r)))))}removeTextAtRange(t){let e;t=Et(t);const[i,n]=t;if(St(t))return this;const[r,o]=Array.from(this.locationRangeFromRange(t)),s=r.index,a=r.offset,l=this.getBlockAtIndex(s),c=o.index,h=o.offset,u=this.getBlockAtIndex(c);if(n-i==1&&l.getBlockBreakPosition()===a&&u.getBlockBreakPosition()!==h&&\"\\n\"===u.text.getStringAtPosition(h))e=this.blockList.editObjectAtIndex(c,(t=>t.copyWithText(t.text.removeTextAtRange([h,h+1]))));else{let t;const i=l.text.getTextAtRange([0,a]),n=u.text.getTextAtRange([h,u.getLength()]),r=i.appendText(n);t=s!==c&&0===a&&l.getAttributeLevel()>=u.getAttributeLevel()?u.copyWithText(r):l.copyWithText(r);const o=c+1-s;e=this.blockList.splice(s,o,t)}return new this.constructor(e)}moveTextFromRangeToPosition(t,e){let i;t=Et(t);const[n,r]=t;if(n<=e&&e<=r)return this;let o=this.getDocumentAtRange(t),s=this.removeTextAtRange(t);const a=nn=n.editObjectAtIndex(o,(function(){return ht(t)?i.addAttribute(t,e):r[0]===r[1]?i:i.copyWithText(i.text.addAttributeAtRange(t,e,r))})))),new this.constructor(n)}addAttribute(t,e){let{blockList:i}=this;return this.eachBlock(((n,r)=>i=i.editObjectAtIndex(r,(()=>n.addAttribute(t,e))))),new this.constructor(i)}removeAttributeAtRange(t,e){let{blockList:i}=this;return this.eachBlockAtRange(e,(function(e,n,r){ht(t)?i=i.editObjectAtIndex(r,(()=>e.removeAttribute(t))):n[0]!==n[1]&&(i=i.editObjectAtIndex(r,(()=>e.copyWithText(e.text.removeAttributeAtRange(t,n)))))})),new this.constructor(i)}updateAttributesForAttachment(t,e){const i=this.getRangeOfAttachment(e),[n]=Array.from(i),{index:r}=this.locationFromPosition(n),o=this.getTextAtIndex(r);return new this.constructor(this.blockList.editObjectAtIndex(r,(i=>i.copyWithText(o.updateAttributesForAttachment(t,e)))))}removeAttributeForAttachment(t,e){const i=this.getRangeOfAttachment(e);return this.removeAttributeAtRange(t,i)}insertBlockBreakAtRange(t){let e;t=Et(t);const[i]=t,{offset:n}=this.locationFromPosition(i),r=this.removeTextAtRange(t);return 0===n&&(e=[new De]),new this.constructor(r.blockList.insertSplittableListAtPosition(new Re(e),i))}applyBlockAttributeAtRange(t,e,i){const n=this.expandRangeToLineBreaksAndSplitBlocks(i);let r=n.document;i=n.range;const o=ht(t);if(o.listAttribute){r=r.removeLastListAttributeAtRange(i,{exceptAttributeName:t});const e=r.convertLineBreaksToBlockBreaksInRange(i);r=e.document,i=e.range}else r=o.exclusive?r.removeBlockAttributesAtRange(i):o.terminal?r.removeLastTerminalAttributeAtRange(i):r.consolidateBlocksAtRange(i);return r.addAttributeAtRange(t,e,i)}removeLastListAttributeAtRange(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},{blockList:i}=this;return this.eachBlockAtRange(t,(function(t,n,r){const o=t.getLastAttribute();o&&ht(o).listAttribute&&o!==e.exceptAttributeName&&(i=i.editObjectAtIndex(r,(()=>t.removeAttribute(o))))})),new this.constructor(i)}removeLastTerminalAttributeAtRange(t){let{blockList:e}=this;return this.eachBlockAtRange(t,(function(t,i,n){const r=t.getLastAttribute();r&&ht(r).terminal&&(e=e.editObjectAtIndex(n,(()=>t.removeAttribute(r))))})),new this.constructor(e)}removeBlockAttributesAtRange(t){let{blockList:e}=this;return this.eachBlockAtRange(t,(function(t,i,n){t.hasAttributes()&&(e=e.editObjectAtIndex(n,(()=>t.copyWithoutAttributes())))})),new this.constructor(e)}expandRangeToLineBreaksAndSplitBlocks(t){let e;t=Et(t);let[i,n]=t;const r=this.locationFromPosition(i),o=this.locationFromPosition(n);let s=this;const a=s.getBlockAtIndex(r.index);if(r.offset=a.findLineBreakInDirectionFromPosition(\"backward\",r.offset),null!=r.offset&&(e=s.positionFromLocation(r),s=s.insertBlockBreakAtRange([e,e+1]),o.index+=1,o.offset-=s.getBlockAtIndex(r.index).getLength(),r.index+=1),r.offset=0,0===o.offset&&o.index>r.index)o.index-=1,o.offset=s.getBlockAtIndex(o.index).getBlockBreakPosition();else{const t=s.getBlockAtIndex(o.index);\"\\n\"===t.text.getStringAtRange([o.offset-1,o.offset])?o.offset-=1:o.offset=t.findLineBreakInDirectionFromPosition(\"forward\",o.offset),o.offset!==t.getBlockBreakPosition()&&(e=s.positionFromLocation(o),s=s.insertBlockBreakAtRange([e,e+1]))}return i=s.positionFromLocation(r),n=s.positionFromLocation(o),{document:s,range:t=Et([i,n])}}convertLineBreaksToBlockBreaksInRange(t){t=Et(t);let[e]=t;const i=this.getStringAtRange(t).slice(0,-1);let n=this;return i.replace(/.*?\\n/g,(function(t){e+=t.length,n=n.insertBlockBreakAtRange([e-1,e])})),{document:n,range:t}}consolidateBlocksAtRange(t){t=Et(t);const[e,i]=t,n=this.locationFromPosition(e).index,r=this.locationFromPosition(i).index;return new this.constructor(this.blockList.consolidateFromIndexToIndex(n,r))}getDocumentAtRange(t){t=Et(t);const e=this.blockList.getSplittableListInRange(t).toArray();return new this.constructor(e)}getStringAtRange(t){let e;const i=t=Et(t);return i[i.length-1]!==this.getLength()&&(e=-1),this.getDocumentAtRange(t).toString().slice(0,e)}getBlockAtIndex(t){return this.blockList.getObjectAtIndex(t)}getBlockAtPosition(t){const{index:e}=this.locationFromPosition(t);return this.getBlockAtIndex(e)}getTextAtIndex(t){var e;return null===(e=this.getBlockAtIndex(t))||void 0===e?void 0:e.text}getTextAtPosition(t){const{index:e}=this.locationFromPosition(t);return this.getTextAtIndex(e)}getPieceAtPosition(t){const{index:e,offset:i}=this.locationFromPosition(t);return this.getTextAtIndex(e).getPieceAtPosition(i)}getCharacterAtPosition(t){const{index:e,offset:i}=this.locationFromPosition(t);return this.getTextAtIndex(e).getStringAtRange([i,i+1])}getLength(){return this.blockList.getEndPosition()}getBlocks(){return this.blockList.toArray()}getBlockCount(){return this.blockList.length}getEditCount(){return this.editCount}eachBlock(t){return this.blockList.eachObject(t)}eachBlockAtRange(t,e){let i,n;t=Et(t);const[r,o]=t,s=this.locationFromPosition(r),a=this.locationFromPosition(o);if(s.index===a.index)return i=this.getBlockAtIndex(s.index),n=[s.offset,a.offset],e(i,n,s.index);for(let t=s.index;t<=a.index;t++)if(i=this.getBlockAtIndex(t),i){switch(t){case s.index:n=[s.offset,i.text.getLength()];break;case a.index:n=[0,a.offset];break;default:n=[0,i.text.getLength()]}e(i,n,t)}}getCommonAttributesAtRange(t){t=Et(t);const[e]=t;if(St(t))return this.getCommonAttributesAtPosition(e);{const e=[],i=[];return this.eachBlockAtRange(t,(function(t,n){if(n[0]!==n[1])return e.push(t.text.getCommonAttributesAtRange(n)),i.push(We(t))})),Vt.fromCommonAttributesOfObjects(e).merge(Vt.fromCommonAttributesOfObjects(i)).toObject()}}getCommonAttributesAtPosition(t){let e,i;const{index:n,offset:r}=this.locationFromPosition(t),o=this.getBlockAtIndex(n);if(!o)return{};const s=We(o),a=o.text.getAttributesAtPosition(r),l=o.text.getAttributesAtPosition(r-1),c=Object.keys(O).filter((t=>O[t].inheritable));for(e in l)i=l[e],(i===a[e]||c.includes(e))&&(s[e]=i);return s}getRangeOfCommonAttributeAtPosition(t,e){const{index:i,offset:n}=this.locationFromPosition(e),r=this.getTextAtIndex(i),[o,s]=Array.from(r.getExpandedRangeForAttributeAtOffset(t,n)),a=this.positionFromLocation({index:i,offset:o}),l=this.positionFromLocation({index:i,offset:s});return Et([a,l])}getBaseBlockAttributes(){let t=this.getBlockAtIndex(0).getAttributes();for(let e=1;e{const e=[];for(let r=0;r{let{text:i}=e;return t=t.concat(i.getAttachmentPieces())})),t}getAttachments(){return this.getAttachmentPieces().map((t=>t.attachment))}getRangeOfAttachment(t){let e=0;const i=this.blockList.toArray();for(let n=0;n{const r=n.getLength();n.hasAttribute(t)&&i.push([e,e+r]),e+=r})),i}findRangesForTextAttribute(t){let{withValue:e}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=0,n=[];const r=[];return this.getPieces().forEach((o=>{const s=o.getLength();(function(i){return e?i.getAttribute(t)===e:i.hasAttribute(t)})(o)&&(n[1]===i?n[1]=i+s:r.push(n=[i,i+s])),i+=s})),r}locationFromPosition(t){const e=this.blockList.findIndexAndOffsetAtPosition(Math.max(0,t));if(null!=e.index)return e;{const t=this.getBlocks();return{index:t.length-1,offset:t[t.length-1].getLength()}}}positionFromLocation(t){return this.blockList.findPositionAtIndexAndOffset(t.index,t.offset)}locationRangeFromPosition(t){return Et(this.locationFromPosition(t))}locationRangeFromRange(t){if(!(t=Et(t)))return;const[e,i]=Array.from(t),n=this.locationFromPosition(e),r=this.locationFromPosition(i);return Et([n,r])}rangeFromLocationRange(t){let e;t=Et(t);const i=this.positionFromLocation(t[0]);return St(t)||(e=this.positionFromLocation(t[1])),Et([i,e])}isEqualTo(t){return this.blockList.isEqualTo(null==t?void 0:t.blockList)}getTexts(){return this.getBlocks().map((t=>t.text))}getPieces(){const t=[];return Array.from(this.getTexts()).forEach((e=>{t.push(...Array.from(e.getPieces()||[]))})),t}getObjects(){return this.getBlocks().concat(this.getTexts()).concat(this.getPieces())}toSerializableDocument(){const t=[];return this.blockList.eachObject((e=>t.push(e.copyWithText(e.text.toSerializableText())))),new this.constructor(t)}toString(){return this.blockList.toString()}toJSON(){return this.blockList.toJSON()}toConsole(){return JSON.stringify(this.blockList.toArray()).map((t=>JSON.parse(t.text.toConsole())))}}const We=function(t){const e={},i=t.getLastAttribute();return i&&(e[i]=!0),e},Ue=\"style href src width height class\".split(\" \"),qe=\"javascript:\".split(\" \"),Ve=\"script iframe\".split(\" \");class ze extends U{static sanitize(t,e){const i=new this(t,e);return i.sanitize(),i}constructor(t){let{allowedAttributes:e,forbiddenProtocols:i,forbiddenElements:n}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(...arguments),this.allowedAttributes=e||Ue,this.forbiddenProtocols=i||qe,this.forbiddenElements=n||Ve,this.body=_e(t)}sanitize(){return this.sanitizeElements(),this.normalizeListElementNesting()}getHTML(){return this.body.innerHTML}getBody(){return this.body}sanitizeElements(){const t=x(this.body),e=[];for(;t.nextNode();){const i=t.currentNode;switch(i.nodeType){case Node.ELEMENT_NODE:this.elementIsRemovable(i)?e.push(i):this.sanitizeElement(i);break;case Node.COMMENT_NODE:e.push(i)}}return e.forEach((t=>A(t))),this.body}sanitizeElement(t){return t.hasAttribute(\"href\")&&this.forbiddenProtocols.includes(t.protocol)&&t.removeAttribute(\"href\"),Array.from(t.attributes).forEach((e=>{let{name:i}=e;this.allowedAttributes.includes(i)||0===i.indexOf(\"data-trix\")||t.removeAttribute(i)})),t}normalizeListElementNesting(){return Array.from(this.body.querySelectorAll(\"ul,ol\")).forEach((t=>{const e=t.previousElementSibling;e&&\"li\"===y(e)&&e.appendChild(t)})),this.body}elementIsRemovable(t){if((null==t?void 0:t.nodeType)===Node.ELEMENT_NODE)return this.elementIsForbidden(t)||this.elementIsntSerializable(t)}elementIsForbidden(t){return this.forbiddenElements.includes(y(t))}elementIsntSerializable(t){return\"false\"===t.getAttribute(\"data-trix-serialize\")&&!F(t)}}const _e=function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:\"\";t=t.replace(/<\\/html[^>]*>[^]*$/i,\"