1!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},t=(new e.Error).stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="474cd548-ee37-483b-93dc-aa4accdfb118",e._sentryDebugIdIdentifier="sentry-dbid-474cd548-ee37-483b-93dc-aa4accdfb118")}catch(e){}}();"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6303],{27114:function(e,t,i){i.d(t,{M:function(){return A}});var r=i(62377),o=i(79804),n=i(95525),s=i(8527),a=i(86074),l=i(15693),d=i(68886),h=i(97827),c=i(25679),p=i(44298),g=i(16223),m=i(55029),u=i(30610),f=i(4925),y=i(39967),v=i(79401),H=i(21274),C=i(1883),F=i(71814),w=i(75143),I=i(31822),x=i(63e3),b=i(22665),W=i(94517),P=i(57021),k=i(48590),R=i(31353),T=i(89981),S=i(92599),B=i(46124),L=i(9366),E=function(e,t,i,r){return new(i||(i=Promise))(function(o,n){function s(e){try{l(r.next(e))}catch(e){n(e)}}function a(e){try{l(r.throw(e))}catch(e){n(e)}}function l(e){e.done?o(e.value):new i(function(t){t(e.value)}).then(s,a)}l((r=r.apply(e,t||[])).next())})},O=function(e,t){var i,r,o,n,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return n={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(n[Symbol.iterator]=function(){return this}),n;function a(n){return function(a){return function(n){if(i)throw TypeError("Generator is already executing.");for(;s;)try{if(i=1,r&&(o=2&n[0]?r.return:n[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,n[1])).done)return o;switch(r=0,o&&(n=[2&n[0],o.value]),n[0]){case 0:case 1:o=n;break;case 4:return s.label++,{value:n[1],done:!1};case 5:s.label++,r=n[1],n=[0];continue;case 7:n=s.ops.pop(),s.trys.pop();continue;default:if(!(o=(o=s.trys).length>0&&o[o.length-1])&&(6===n[0]||2===n[0])){s=0;continue}if(3===n[0]&&(!o||n[1]>o[0]&&n[1]<o[3])){s.label=n[1];break}if(6===n[0]&&s.label<o[1]){s.label=o[1],o=n;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(n);break}o[2]&&s.ops.pop(),s.trys.pop();continue}n=t.call(e,s)}catch(e){n=[6,e],r=0}finally{i=o=0}if(5&n[0])throw n[1];return{value:n[0]?n[1]:void 0,done:!0}}([n,a])}}},A=function(){function e(e){var t=this;this.nodes=[],this.editHyperlinkInternal=!1,this.startParagraph=void 0,this.positionForPasteIcon=void 0,this.endParagraph=void 0,this.lastElementForPasteIcon=void 0,this.formFieldCounter=1,this.skipFieldDeleteTracking=!1,this.skipFootNoteDeleteTracking=!1,this.isForHyperlinkFormat=!1,this.isTrackingFormField=!1,this.isInsertText=!1,this.casingIndex=-1,this.checkLastLetterSpace="",this.checkLastLetterSpaceDot="",this.pasteFootNoteType="",this.hasShownRestrictPane=!1,this.isInsertingText=!1,this.isRTFContentPasting=!1,this.isInternalPaste=!1,this.type=null,this.keywordIndex=0,this.dictionaryObjcetIDIncreament=1,this.dictionaryObjectIndexIncrement=0,this.XMLFilesCount=1,this.XMLFilesNameSpaceCount=1,this.xmlData=[],this.dictionaryObject=[],this.isFootnoteElementRemoved=!1,this.isEndnoteElementRemoved=!1,this.handledEnter=!1,this.handledTextInput=!1,this.isDeleteOrBackSpace=!1,this.isRemoveRevision=!1,this.isFootNoteInsert=!1,this.isTableInsert=!1,this.isFootNote=!1,this.isHandledComplex=!1,this.isUserInsert=!1,this.tableResize=void 0,this.tocStyles={},this.triggerPageSpellCheck=!0,this.chartType=!1,this.isSkipGrouping=!1,this.removedBookmarkElements=[],this.removedEditRangeStartElements=[],this.removedEditRangeEndElements=[],this.removedContentControlElements=[],this.tocBookmarkId=0,this.copiedData=void 0,this.collabTrackAction=!1,this.isPasteContentCheck=!1,this.isDeleteTrackedContent=!1,this.isSelectionBasedonEndRevision=!1,this.pageRefFields={},this.delBlockContinue=!1,this.delBlock=void 0,this.delSection=void 0,this.isInsertingTOC=!1,this.isUpdateToc=!1,this.isMeasureParaWidth=!1,this.editStartRangeCollection=[],this.skipReplace=!1,this.skipTableElements=!1,this.isPasteOverWriteCells=!1,this.editRangeID=[],this.isImageInsert=!1,this.isSkipOperationsBuild=!1,this.isCellFormatApplied=!1,this.revisionData=void 0,this.splittedRevisions=[],this.isSkipComments=!1,this.isRemoteAction=!1,this.isIncrementalSave=!1,this.listFormatInfo=void 0,this.listLevelNumber=0,this.isXmlMapped=!1,this.restrictLayout=!1,this.isAutoList=!1,this.isLastParaMarkCopied=!1,this.combineLastBlock=!1,this.remotePasteRevision=[],this.isFieldOperation=!1,this.decreasedIndent=!1,this.increasedIndent=!1,this.copiedContent="",this.copiedTextContent="",this.previousParaFormat=void 0,this.previousCharFormat=void 0,this.previousSectionFormat=void 0,this.pasteTextPosition=void 0,this.capturedOriginalHeaderFooters=null,this.isCurrentWholeDocumentPaste=!1,this.isPaste=!1,this.isPasteListUpdated=!1,this.isHtmlPaste=!1,this.isInsertField=!1,this.isBordersAndShadingDialog=!1,this.pasteImageIndex=void 0,this.onTextInputInternal=function(){if(a.AR.isDevice){var e=t.documentHelper,i=RegExp(String.fromCharCode(160),"g"),r=RegExp("\n","g");e.prefix=e.prefix.replace(i," ").replace(r," ");var o=e.editableDiv.textContent.replace(i," ").replace(r," "),n=o.substring(2);if(e.isCompositionStart&&e.isCompositionUpdated){e.isCompositionUpdated=!1,!e.owner.isReadOnlyMode&&e.owner.isDocumentLoaded&&t.canEditContentControl&&e.prefix.substring(2)!==n&&(t.selection.isEmpty?(t.selection.start.setPositionForLineWidget(e.selection.start.currentWidget,t.selection.start.offset-(e.prefix.length-2)),t.handleTextInput(n),e.prefix="@"+String.fromCharCode(160)+n):(t.handleTextInput(n),e.prefix="@"+String.fromCharCode(160)+n));return}if(e.isCompositionStart&&e.isCompositionEnd&&""===e.suffix){e.prefix.substring(2)!==n?t.selection.isEmpty&&e.isCompositionStart?(e.isCompositionStart=!1,t.selection.start.setPositionForLineWidget(e.selection.start.currentWidget,t.selection.start.offset-e.prefix.substring(2).length),t.selection.retrieveCurrentFormatProperties(),(""===e.suffix||""===n)&&t.handleTextInput(n)):t.selection.isEmpty||(e.isCompositionStart=!1,t.handleTextInput(n)):""===n?(e.isCompositionStart=!1,t.handleBackKey()):e.prefix.substring(2)===n&&""===e.suffix&&(e.isCompositionStart=!1,t.handleTextInput(" ")),e.isCompositionEnd=!1;return}if(e.isCompositionEnd||e.isCompositionStart&&!e.isCompositionUpdated){if(n.length<e.prefix.length&&n===e.prefix.substring(2,e.prefix.length-1)||e.editableDiv.innerText.length<2){t.handleBackKey();return}if(""!==e.suffix&&e.editableDiv.innerText[e.editableDiv.innerText.length-1]!==String.fromCharCode(160)){e.isCompositionStart=!1,t.selection.start.setPositionForLineWidget(e.selection.start.currentWidget,t.selection.start.offset-(e.prefix.length-2)),t.selection.end.setPositionForLineWidget(e.selection.end.currentWidget,t.selection.end.offset+e.suffix.length),t.selection.retrieveCurrentFormatProperties(),t.handleTextInput(n);return}}"\r"!==o&&"\b"!==o&&"\x1b"!==o&&!e.owner.isReadOnlyMode&&!1===e.isControlPressed&&t.canEditContentControl&&("@"===o||"@"!==o[0]||""===o||o.length<e.prefix.length&&n===e.prefix.substring(2,e.prefix.length-1)?(t.handleBackKey(),e.editableDiv.innerText.length<2&&t.predictText()):0===o.indexOf(e.prefix)&&o.length>e.prefix.length?t.handleTextInput(o.substring(e.prefix.length)):-1===o.indexOf(e.prefix)&&o[o.length-1]!==String.fromCharCode(160)&&" "!==o[o.length-1]?(n.charAt(0).toLowerCase()+n.slice(1)===e.prefix.substring(2)&&t.selection.start.setPositionParagraph(e.selection.start.currentWidget,t.selection.start.offset-(e.prefix.length-2)),t.handleTextInput(n)):2!==o.length&&t.handleTextInput(" "))}else{var o=t.documentHelper.editableDiv.innerText;o!==String.fromCharCode(160)?"\r"!==o&&"\b"!==o&&"\x1b"!==o&&!t.owner.isReadOnlyMode&&!1===t.documentHelper.isControlPressed&&t.canEditContentControl&&t.handleTextInput(o):t.handleTextInput(" "),t.documentHelper.editableDiv.innerText=""}},this.onPaste=function(e){!t.owner.isReadOnlyMode&&t.canEditContentControl&&t.pasteInternal(e),e.preventDefault()},this.documentHelper=e,(0,a.le)(this.documentHelper)||(this.tableResize=new P.d(this.documentHelper.owner)),this.base64=new s.DS}return Object.defineProperty(e.prototype,"restrictFormatting",{get:function(){return this.documentHelper.isDocumentProtected&&(this.documentHelper.restrictFormatting||!this.documentHelper.restrictFormatting&&!this.selection.isSelectionInEditRegion())&&"RevisionsOnly"!==this.documentHelper.protectionType},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"restrictEditing",{get:function(){return this.documentHelper.isDocumentProtected&&(("ReadOnly"===this.documentHelper.protectionType||this.documentHelper.isCommentOnlyMode)&&!this.selection.isSelectionInEditRegion()||"FormFieldsOnly"===this.documentHelper.protectionType)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"canEditContentControl",{get:function(){var e=this.selection.currentContentControl;
1if((0,a.le)(e)){if(this.selection.checkContentControlLocked())return!1}else if(e.contentControlProperties.lockContents||"DropDownList"===e.contentControlProperties.type)return!1;return!this.owner.isReadOnly},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"viewer",{get:function(){if(!(0,a.le)(this.owner))return this.owner.viewer},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"editorHistory",{get:function(){return this.documentHelper.owner.editorHistoryModule},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"selection",{get:function(){if(this.documentHelper)return this.documentHelper.selection},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"owner",{get:function(){if(this.documentHelper)return this.documentHelper.owner},enumerable:!0,configurable:!0}),e.prototype.getModuleName=function(){return"Editor"},e.prototype.beginBatchEdit=function(){this.restrictLayout=!0},e.prototype.endBatchEdit=function(){this.restrictLayout=!1,this.documentHelper.layout.layoutWholeDocument()},e.prototype.setFieldInfo=function(e){var t=this.selection.getHyperlinkField(!0);(0,a.le)(t)||(this.selection.selectField(),this.insertField(e.code,e.result))},e.prototype.insertField=function(e,t){this.isInsertField=!0;var i=e;if("NUMPAGES"===(i=s.o_.trimStart(i)).substring(0,8))this.insertPageCount(t);else if("PAGE"===i.substring(0,4))this.insertPageNumber(t);else{if((0,a.le)(t)){if("DOCVARIABLE"===i.substring(0,11)){var r=(i=i.substring(11).trim()).indexOf("\\*");t="\xab"+i.substring(0,r).trim()+"\xbb"}else if("MERGEFIELD"===i.substring(0,10)){var r=(i=i.substring(10).trim()).indexOf("\\*");t="\xab"+i.substring(0,r).trim()+"\xbb"}}var d=new o.ZH,h=new n.a(void 0,this.owner),c=this.selection.start.paragraph;this.selection.isForward||(c=this.selection.end.paragraph);var p=this.selection.start.currentWidget.getInline(this.selection.start.offset,0);h=c.isEmpty()?c.characterFormat:(0,a.le)(p.element)?this.copyInsertFormat(h,!1):p.element.characterFormat;var g=new o.z7(d),m=new o.V8(0);m.characterFormat.assignFormat(h),g.children.push(m);var u=new o.a3;u.characterFormat.assignFormat(h),u.text=e,g.children.push(u);var f=new o.V8(2);f.characterFormat.assignFormat(h),f.fieldBegin=m,m.fieldSeparator=f,g.children.push(f);var y=new o.a3;y.text=t,y.characterFormat.assignFormat(h),!this.documentHelper.textHelper.isRTLText(t)&&y.characterFormat.bidi&&(y.characterFormat.bidi=!1),g.children.push(y);var v=new o.V8(1);v.characterFormat.assignFormat(h),v.fieldSeparator=f,v.fieldBegin=m,m.fieldEnd=v,f.fieldEnd=v,g.children.push(v),m.line=g,d.childWidgets.push(g),this.documentHelper.fields.push(m);var H=new o.VB;H.sectionFormat=new l.Z(H),H.childWidgets.push(d),this.pasteContentsInternal([H],!1,c.paragraphFormat)}this.isInsertField=!1},e.prototype.isLinkedStyle=function(e){var t=this.documentHelper.styles.findByName(e);return!(0,a.le)(t.link)},e.prototype.applyStyle=function(e,t){t=!(0,a.le)(t)&&t;var i=void 0,r=void 0,o=this.documentHelper.styles.findByName(e);if(t){this.initComplexHistory("ApplyStyle"),this.setOffsetValue(this.selection),i=this.startOffset,r=this.endOffset;var n=this.selection.isEmpty;this.isSkipOperationsBuild=this.owner.enableCollaborativeEditing,!(0,a.le)(o)&&o instanceof b.l2&&"Character"===o.type?this.clearFormattingInternal(!1,!0):this.clearFormattingInternal(!0,!0),this.isSkipOperationsBuild=!1,n&&!this.selection.isEmpty&&this.selection.end.setPositionInternal(this.selection.start)}if(void 0!==o){if(o instanceof b.l2&&"Character"===o.type){if(this.selection.isEmpty){var s=this.selection.start.offset,l=this.selection.start.clone(),d=this.selection.end.clone();this.selection.selectCurrentWord(),s===this.selection.start.offset||s===this.selection.end.offset-1?(this.selection.start=l,this.selection.end=d,this.selection.characterFormat.copyFormat(o.characterFormat)):this.onApplyCharacterFormat("styleName",o,!1,!0)}else this.onApplyCharacterFormat("styleName",o,!1,!0)}else this.onApplyParagraphFormat("styleName",o,!1,!0)}else this.documentHelper.owner.parser.parseStyle(JSON.parse(this.getCompleteStyles()),JSON.parse(this.documentHelper.preDefinedStyles.get(e)),this.documentHelper.styles),this.applyStyle(e);this.editorHistory&&this.editorHistory.currentHistoryInfo&&"ApplyStyle"===this.editorHistory.currentHistoryInfo.action&&(this.startOffset=i,this.endOffset=r,this.editorHistory.updateComplexHistory()),this.startParagraph=void 0,this.endParagraph=void 0},e.prototype.cut=function(){if(!this.owner.isReadOnlyMode&&!this.selection.isEmpty&&this.canEditContentControl){if(!this.selection.isEmpty){var e=this.selection.bookmarks;e.length>0&&this.extendSelectionToBookmarkStart(e)}var t=this.selection.start,i=this.selection.end,r=0===t.offset?this.selection.getElementInfo(t.currentWidget,t.offset-1):this.selection.getElementInfo(t.currentWidget,this.selection.isForward?t.offset:t.offset+1),n=0===i.offset?this.selection.getElementInfo(i.currentWidget,i.offset-1):this.selection.getElementInfo(i.currentWidget,this.selection.isForward?i.offset+1:i.offset);!(0,a.le)(r)&&!(0,a.le)(n)&&r.element&&n.element&&-1!==r.index&&-1!==n.index&&r.element instanceof o.aQ&&n.element instanceof o.aQ&&r.element.name===n.element.name&&!(!(0,a.le)(r.element.nextElement)&&!(0,a.le)(n.element.previousElement)&&r.element.nextElement instanceof o.V8&&n.element.previousElement instanceof o.V8)&&(this.selection.isForward?(this.selection.start.setPositionParagraph(r.element.line,r.element.line.getOffset(r.element,0)),this.selection.end.setPositionParagraph(n.element.line,n.element.line.getOffset(n.element,1)
1)):(this.selection.start.setPositionParagraph(r.element.line,r.element.line.getOffset(r.element,1)),this.selection.end.setPositionParagraph(n.element.line,n.element.line.getOffset(n.element,0)))),this.selection.copySelectedContent(!0),this.documentHelper.owner.parser.isCutPerformed=!0}},e.prototype.insertEditingRegion=function(e){this.insertEditRangeElement(e&&""!==e?e:"Everyone")},e.prototype.enforceProtection=function(e,t,i){var r,o;"boolean"==typeof t?(r=i?"ReadOnly":this.documentHelper.protectionType,o=t):r=t,(0,a.le)(o)||(this.documentHelper.restrictFormatting=o),this.documentHelper.protectionType=r,this.selection.isHighlightEditRegion=!0,this.addProtection(e,this.documentHelper.protectionType,!1)},e.prototype.enforceProtectionAsync=function(e,t,i){return E(this,void 0,void 0,function(){var r,o;return O(this,function(n){switch(n.label){case 0:return"boolean"==typeof t?(r=i?"ReadOnly":this.documentHelper.protectionType,o=t):(o=!0,r=t),this.documentHelper.restrictFormatting=o,this.documentHelper.protectionType=r,this.selection.isHighlightEditRegion=!0,[4,this.addProtection(e,this.documentHelper.protectionType,!0)];case 1:return n.sent(),[2]}})})},e.prototype.getCommentHierarchicalIndex=function(e){for(var t="";e.ownerComment;)(0,a.le)(e.ownerComment)?t=e.replyComments.indexOf(e)+";"+t:(t=e.ownerComment.replyComments.indexOf(e)+";"+t,e=e.ownerComment);return"C;"+this.documentHelper.comments.indexOf(e)+";"+t},e.prototype.alertBox=function(){var e=new a.E7("documenteditor",this.owner.defaultLocale);e.setLocale(this.owner.locale),S.hZ.alert({title:e.getConstant("Information"),content:e.getConstant("Multiple Comment")})},e.prototype.insertReplyComment=function(e,t,i){var r,o={},n=this.getCommentInfo(t);if(o={author:i.author?i.author:"Guest user",initial:this.constructCommentInitial(i.author?i.author:"Guest user"),text:(0,a.le)(n.innerText)?a.pJ.sanitize(t):a.pJ.sanitize(n.innerText),commentId:Math.random().toString(36).substring(2,15)+Math.random().toString(36).substring(2,15),done:!1,date:i.dateTime?s.o_.getUtcDate(i.dateTime):s.o_.getUtcDate()},this.documentHelper.comments.length>0){for(var l=0;l<this.documentHelper.comments.length;l++)if(this.documentHelper.comments[l].commentId===e){r=this.documentHelper.comments[l];break}}this.replyComment(r,(0,a.le)(n.innerText)?t:n.innerText,n.itemData,o);var d={author:o.author,isResolved:o.done,dateTime:this.parseDateTime(o.date)};return new C.s(o.commentId,d,t)},e.prototype.getCommentInfo=function(e){for(var t,i=[],r=[],o=/<a href="mailto:([^"]+)">([^<]+)<\/a>/g,n=0;null!==(t=o.exec(e));)t.index>n&&r.push({text:e.substring(n,t.index)}),r.push({mailto:t[1],text:t[2]}),n=o.lastIndex;n<e.length&&r.push({text:e.substring(n)});var s="";if(r.length>0)for(var a=0;a<r.length;a++)r[a].mailto?(i.push({text:r[a].text.replace("@",""),value:r[a].mailto}),s+='<span contenteditable="false" class="e-mention-chip">'+r[a].text.replace("@","")+"</span>"):r[a].text&&(s+=r[a].text.replace(/(\r\n|\n\r|\n|\r)/g,"<br>"));else""!==e&&(s=e.replace(/(\r\n|\n\r|\n|\r)/g,"<br>"));return{itemData:i,innerText:s}},e.prototype.insertComment=function(e,t){if(!((0,a.le)(this.selection.start)||this.owner.isReadOnlyMode&&!this.documentHelper.isCommentOnlyMode||this.viewer.owner.enableHeaderAndFooter||!this.viewer.owner.enableComment||this.selection.isPlainContentControl())&&!this.selection.isInShape){if(this.viewer.owner.commentReviewPane.commentPane.isEditMode)return this.alertBox();(0,a.le)(e)&&(e="");var i={},r=this.getCommentInfo(e);if((0,a.le)(t))i={author:this.owner.currentUser?a.pJ.sanitize(this.owner.currentUser):"Guest user",initial:this.constructCommentInitial(this.owner.currentUser?a.pJ.sanitize(this.owner.currentUser):"Guest user"),text:a.pJ.sanitize(e),commentId:Math.random().toString(36).substring(2,15)+Math.random().toString(36).substring(2,15),done:!1,date:s.o_.getUtcDate()};else{var o=(0,a.le)(t.author)?this.owner.currentUser:t.author;i={author:o,initial:this.constructCommentInitial(o),text:a.pJ.sanitize(""===r.innerText?e:r.innerText),commentId:Math.random().toString(36).substring(2,15)+Math.random().toString(36).substring(2,15),done:!!t.isResolved&&t.isResolved,date:t.dateTime?s.o_.getUtcDate(t.dateTime):s.o_.getUtcDate()}}this.insertCommentInternal((0,a.le)(r.innerText)?"":r.innerText,i,r.itemData);var n={author:i.author,isResolved:i.done,dateTime:this.parseDateTime(i.date)};return new C.s(i.commentId,n,e)}},e.prototype.parseDateTime=function(e){var t=new Date(e);return new Date(t.getTime()+6e4*t.getTimezoneOffset())},e.prototype.insertCommentInternal=function(e,t,i){if(this.documentHelper.layout.allowLayout=!1,this.selection.isEmpty){if(this.selection.start.isAtSamePosition(this.selection.end)&&this.selection.start.isAtParagraphEnd){var n=this.selection.start.offset;this.selection.start.offset=n-1!=-1?n-1:n}this.selection.selectCurrentWord()}this.selection.isParagraphLastLine(this.selection.end.currentWidget)&&this.selection.end.offset===this.selection.getLineLength(this.selection.end.currentWidget)+1&&(this.selection.end.offset-=1);var s=this.selection.getParagraphInfo(this.selection.start),l=this.selection.getHierarchicalIndex(s.paragraph,s.offset.toString()),d=this.selection.start,h=this.selection.end,c=new r.JK(this.owner);this.selection.isForward||(d=this.selection.end,h=this.selection.start),c.setPositionInternal(d),this.initComplexHistory("InsertComment");var p=new o.Xw(0),g=new o.Xw(1);if(d.setPositionInternal(h),this.initInsertInline(g),(0,a.le)(c.paragraph)||-1===c.currentWidget.indexInOwner){var m=this.selection.getTextPosBasedOnLogicalIndex(l);c.setPositionInternal(m)}d.setPositionInternal(c),h.setPositionInternal(c),this.initInsertInline(p);var u=new o._A(t.date);if(i&&i.length>0&&(u.mentions=i),this.owner.editorHistoryModule&&(this.initHistory("InsertCommentWidget"),this.owner.editorHistoryModule.currentBaseHistoryInfo.insertedText=R.j5.Marker_Start+R.j5.Marker_End,this.owner.editorHistoryModule.currentBaseHistoryInfo.removedNodes.push(u)),this.updateCommentElement(u,p,g,t),this.addCommentWidget(u,!0,!0,!0),this.owner.isSpellCheck&&p.previousElement&&p.previousElement instanceof o.a3&&(p.previousElement.isChangeDetected=!0),this.owner.isSpellCheck&&g.previousElement&&g.previousElement instanceof o.a3&&p.line!==g.line&&(g.previousElement.isChangeDetected=!0),this.editorHistory&&(this.editorHistory.currentBaseHistoryInfo.insertPosition=this.getCommentHierarchicalIndex(u),this.editorHistory.updateHistory()),this.editorHistory&&this.editorHistory.updateComplexHistory(),this.reLayout(this.selection,!1),this.documentHelper.layout.allowLayout=!0,!this.isUserInsert){var f=this.owner.commentReviewPane.commentPane.comments.get(u);i&&i.length>0&&(f.itemData=i),f.postComment()}},e.prototype.updateCommentElement=function(e,t,i,r){return e.author=r.author,e.initial=r.initial,e.text=r.text,e.commentId=r.commentId,(0,a.le)(r.done)||(e.isResolved=r.done),(0,a.le)(r.isReply)||(e.isReply=r.isReply),(0,a.le)(t)||(0,a.le)(i)||(t.comment=e,t.commentId=e.commentId,i.comment=e,i.commentId=e.commentId,e.commentStart=t,e.commentEnd=i),e},e.prototype.deleteAllComments=function(){if(0!==this.documentHelper.comments.length){for(this.initComplexHistory("DeleteAllComments"),this.owner.isLayoutEnabled=!1,this.editorHistory&&this.editorHistory.currentHistoryInfo&&(e=this.editorHistory.currentHistoryInfo);this.documentHelper.comments.length>0;){var e,t=this.documentHelper.comments[0];this.initComplexHistory("DeleteComment"),this.deleteCommentInternal(t),this.editorHistory&&this.editorHistory.currentHistoryInfo&&e.addModifiedAction(this.editorHistory.currentHistoryInfo)}this.selection.selectContent(this.owner.documentStart,!0),this.editorHistory&&(this.editorHistory.currentHistoryInfo=e,this.editorHistory.updateComplexHistory())}},e.prototype.deleteComment=function(e){if(!(this.owner.isReadOnlyMode&&!this.documentHelper.isCommentOnlyMode||(0,a.le)(this.owner)||(0,a.le)(this.owner.viewer)||(0,a.le)(this.owner.documentHelper.currentSelectedComment)&&(0,a.le)(e))&&!this.owner.enableHeaderAndFooter&&this.viewer.owner.enableComment){if((0,a.le)(e))this.deleteCommentInternal(this.owner.documentHelper.currentSelectedComment);else{var t,i=void 0;if(this.documentHelper.comments.length>0)for(var r=0;r<this.documentHelper.comments.length;r++){if((i=this.documentHelper.comments[r]).commentId===e){t=this.documentHelper.comments[r];break}if(i.replyComments&&i.replyComments.length>0){for(var o=0;o<i.replyComments.length;o++)if(i.replyComments[o].commentId===e){t=i.replyComments[o];break}}}if((0,a.le)(t))throw Error("Enter a valid comment id.");this.deleteCommentInternal(t)}}},e.prototype.deleteCommentInternal=function(e){if(this.initComplexHistory("DeleteComment"),e){if(e.replyComments.length>0)for(var t=e.replyComments.length-1;t>=0;t--)this.deleteCommentInternal(e.replyComments[t]);this.deleteCommentWidgetInternal(e);var i=e.commentStart,r=e.commentEnd;-1!==r.indexInOwner&&this.removeInline(r),-1!==i.indexInOwner&&this.removeInline(i),i.removeCommentMark()}this.editorHistory&&this.editorHistory.updateComplexHistory()},e.prototype.deleteCommentWidgetInternal=function(e){this.owner.editorHistoryModule&&(this.initHistory("DeleteCommentWidget"),this.owner.editorHistoryModule.currentBaseHistoryInfo.insertPosition=this.getCommentHierarchicalIndex(e),this.owner.editorHistoryModule.currentBaseHistoryInfo.removedNodes.push(e)),this.deleteCommentWidget(e),this.editorHistory&&this.editorHistory.updateHistory()},e.prototype.deleteCommentWidget=function(e){var t=this.documentHelper.comments.indexOf(e);-1!==t?this.documentHelper.comments.splice(t,1):e.isReply&&e.ownerComment&&(t=e.ownerComment.replyComments.indexOf(e),e.ownerComment.replyComments.splice(t,1)
1),this.owner.commentReviewPane&&(this.owner.commentReviewPane.deleteComment(e),this.documentHelper.currentSelectedComment===e&&(this.documentHelper.currentSelectedComment=void 0))},e.prototype.resolveComment=function(e){if(!this.owner.isReadOnlyMode||this.documentHelper.isCommentOnlyMode){var t={author:e.author,cancel:!1,type:"Resolve"};this.owner.trigger(F.x$,t),t.cancel&&"Resolve"===t.type||(this.initHistory("ResolveComment"),this.editorHistory&&this.editorHistory.currentBaseHistoryInfo&&this.editorHistory.currentBaseHistoryInfo.removedNodes.push(e),this.resolveOrReopenComment(e,!0))}},e.prototype.reopenComment=function(e){if(!this.owner.isReadOnlyMode||this.documentHelper.isCommentOnlyMode){var t={author:e.author,cancel:!1,type:"Reopen"};this.owner.trigger(F.x$,t),t.cancel&&"Reopen"===t.type||(this.initHistory("ResolveComment"),this.editorHistory&&this.editorHistory.currentBaseHistoryInfo&&this.editorHistory.currentBaseHistoryInfo.removedNodes.push(e),this.resolveOrReopenComment(e,!1))}},e.prototype.resolveOrReopenComment=function(e,t){e.isResolved=t;for(var i=0;i<e.replyComments.length;i++)e.replyComments[i].isResolved=t;this.owner.commentReviewPane&&(t?this.owner.commentReviewPane.resolveComment(e):this.owner.commentReviewPane.reopenComment(e)),this.reLayout(this.selection,!1,!1)},e.prototype.replyComment=function(e,t,i,n,l){if(!this.owner.isReadOnlyMode||this.documentHelper.isCommentOnlyMode){var d=l?a.pJ.sanitize(l):a.pJ.sanitize(t);if(e){var h=void 0;n?((h=new o._A(n.date)).author=n.author,h.text=d,h.mentions=i||[],h.commentId=n.commentId,h.isReply=!0):((h=new o._A(s.o_.getUtcDate())).author=this.owner.currentUser?a.pJ.sanitize(this.owner.currentUser):"Guest user",h.text=d||"",h.mentions=i||[],h.commentId=Math.random().toString(36).substring(2,15)+Math.random().toString(36).substring(2,15),h.isReply=!0);var c={author:h.author,cancel:!1,type:"Post",text:t||"",mentions:h.mentions};if(this.owner.trigger(F.x$,c),c.cancel&&"Post"===c.type)return;this.initComplexHistory("InsertComment");var p=e.commentStart,g=e.commentEnd,m=e.replyComments.length,u=p.line.getOffset(p,m+1),f=new r.JK(this.documentHelper.owner);f.setPositionParagraph(p.line,u);var y=g.line.getOffset(g,m+1),v=new r.JK(this.documentHelper.owner);v.setPositionParagraph(g.line,y),this.selection.start.setPositionInternal(f),this.selection.end.setPositionInternal(v),f=this.selection.start,v=this.selection.end;var H=new r.JK(this.owner);H.setPositionInternal(v);var C=new o.Xw(0),w=new o.Xw(1),I=f.currentWidget===v.currentWidget;v.setPositionInternal(f);var x=H.currentWidget.indexInOwner;this.initInsertInline(C),-1===H.currentWidget.indexInOwner&&(H.currentWidget=H.currentWidget.paragraph.childWidgets[x]),I&&H.setPositionParagraph(H.currentWidget,H.offset+C.length),f.setPositionInternal(H),v.setPositionInternal(H),this.initInsertInline(w),e.replyComments.push(h),h.ownerComment=e,this.owner.editorHistoryModule&&(this.initHistory("InsertCommentWidget"),this.owner.editorHistoryModule.currentBaseHistoryInfo.removedNodes.push(h),this.owner.editorHistoryModule.currentBaseHistoryInfo.insertedText=R.j5.Marker_Start+R.j5.Marker_End),C.comment=h,C.commentId=h.commentId,w.comment=h,w.commentId=h.commentId,h.commentStart=C,h.commentEnd=w,this.owner.commentReviewPane&&this.owner.commentReviewPane.addReply(h,!1,!0),this.editorHistory&&(this.editorHistory.currentBaseHistoryInfo.insertPosition=this.getCommentHierarchicalIndex(h),this.editorHistory.updateHistory()),this.editorHistory&&this.editorHistory.updateComplexHistory(),this.isSkipOperationsBuild=this.owner.enableCollaborativeEditing,this.reLayout(this.selection),this.isSkipOperationsBuild=!1}}},e.prototype.removeInline=function(e){this.selection.start.setPositionParagraph(e.line,e.line.getOffset(e,0)),this.selection.end.setPositionParagraph(this.selection.start.currentWidget,this.selection.start.offset+e.length),this.initHistory("RemoveInline"),this.editorHistory&&this.editorHistory.currentBaseHistoryInfo&&this.updateHistoryPosition(this.selection.start,!0),this.removeSelectedContents(this.documentHelper.selection),this.editorHistory&&this.editorHistory.updateHistory(),this.fireContentChange()},e.prototype.addCommentWidget=function(e,t,i,r){if(-1===this.documentHelper.comments.indexOf(e)){var o=!1;if(this.documentHelper.comments.length>0)for(var n=this.selection.getElementPosition(e.commentStart).startPosition,s=0;s<this.documentHelper.comments.length;s++){var a=this.selection.getElementPosition(this.documentHelper.comments[s].commentStart).startPosition;if(n.isExistBefore(a)){o=!0,this.documentHelper.comments.splice(s,0,e);break}}o||this.documentHelper.comments.push(e),this.owner.commentReviewPane&&(this.owner.showComments=i,this.owner.commentReviewPane.selectedTab=0,this.owner.commentReviewPane.addComment(e,t,r),this.owner.commentReviewPane.reviewTab.selectedItem=0,r&&this.owner.selectionModule.selectComment(e))}},e.prototype.addReplyComment=function(e,t){var i=t.split(";"),r=this.documentHelper.comments[parseInt(i[1],10)];""!==i[2]&&(r.replyComments.splice(parseInt(i[2],10),0,e),e.ownerComment=r),this.owner.commentReviewPane&&(this.owner.showComments=!0,this.owner.commentReviewPane.addReply(e,!1,!0),this.owner.selectionModule.selectComment(e))},e.prototype.addProtection=function(e,t,i){return E(this,void 0,void 0,function(){var r=this;return O(this,function(o){return[2,new Promise(function(o,n){if(i=!!(0,a.le)(i)||i,""===e)r.protectDocument(t),o();else{r.currentProtectionType=t;var s=new L.q,l=r.base64.encodeString(e);r.documentHelper.cryptAlgorithmSid="14";var d={passwordBase64:l,saltBase64:"",spinCount:1e5,algorithmSid:r.documentHelper.cryptAlgorithmSid},h=r.owner.serviceUrl+r.owner.serverActionSettings.restrictEditing;s.url=h,s.contentType="application/json;charset=UTF-8",s.onSuccess=function(e){r.enforceProtectionInternal(e),o()}
1,s.onFailure=function(e){r.protectionFailureHandler(e),n()},s.onError=function(e){r.protectionFailureHandler(e),n()},s.customHeaders=r.owner.headers;var c={serverActionType:"RestrictEditing",headers:r.owner.headers,timeout:0,cancel:!1,withCredentials:!1};r.owner.trigger(F.z1,c),c.cancel?r.documentHelper.dialog.visible&&r.documentHelper.dialog.hide():s.send(d,c,i)}})]})})},e.prototype.protectionFailureHandler=function(e){if(this.owner){var t=new a.E7("documenteditor",this.owner.defaultLocale);t.setLocale(this.documentHelper.owner.locale),"onError"===e.name?S.hZ.alert(t.getConstant("Error in establishing connection with web server")):(this.owner.fireServiceFailure(e),console.error(e.statusText))}},e.prototype.enforceProtectionInternal=function(e){var t=JSON.parse(e.data);this.enforceProtectionAssign(t[0],t[1],this.currentProtectionType),this.owner.showHideRulers()},e.prototype.enforceProtectionAssign=function(e,t,i){this.documentHelper&&(this.documentHelper.saltValue=e,this.documentHelper.hashValue=t,this.protectDocument(i))},e.prototype.toggleTrackChangesProtection=function(e){this.viewer.owner.enableTrackChanges=e,this.owner.trigger(F.rC,{isTrackChangesEnabled:e})},e.prototype.protectDocument=function(e){this.documentHelper.owner.getSettingData("protection",null,this.documentHelper.hashValue,this.documentHelper.saltValue,e),this.protect(e);var t=this.documentHelper.restrictEditingPane.restrictPane;t&&"block"===t.style.display&&(this.documentHelper.restrictEditingPane.showStopProtectionPane(!0),this.documentHelper.restrictEditingPane.loadPaneValue(),this.documentHelper.dialog.visible&&this.documentHelper.dialog.hide()),this.owner.notify(F.Bx,{}),"RevisionsOnly"===e&&this.toggleTrackChangesProtection(!0),this.owner.commentReviewPane.enableDisableItems(),this.owner.trackChangesPane.enableDisableButton(!1,!0),this.documentHelper.owner.enableCollaborativeEditing||this.fireContentChange()},e.prototype.stopProtection=function(e){if(this.documentHelper.isDocumentProtected){if(!(0,a.le)(this.documentHelper.saltValue)&&""===this.documentHelper.saltValue&&!(0,a.le)(this.documentHelper.hashValue)&&""===this.documentHelper.hashValue&&!(0,a.le)(e)&&""===e){this.unProtectDocument();return}var t=new L.q,i={passwordBase64:this.base64.encodeString(e),saltBase64:this.documentHelper.saltValue,spinCount:1e5,algorithmSid:this.documentHelper.cryptAlgorithmSid};t.url=this.owner.serviceUrl+this.owner.serverActionSettings.restrictEditing,t.contentType="application/json;charset=UTF-8",t.customHeaders=this.owner.headers,t.onSuccess=this.onUnProtectionSuccess.bind(this),t.onFailure=this.protectionFailureHandler.bind(this),t.onError=this.protectionFailureHandler.bind(this);var r={serverActionType:"RestrictEditing",headers:this.owner.headers,timeout:0,cancel:!1,withCredentials:!1};this.owner.trigger(F.z1,r),r.cancel?this.documentHelper.dialog.visible&&this.documentHelper.dialog.hide():t.send(i,r,!1),this.owner.enableTrackChanges||this.toggleTrackChangesProtection(!1)}},e.prototype.stopProtectionAsync=function(e){return E(this,void 0,void 0,function(){var t=this;return O(this,function(i){return[2,new Promise(function(i,r){if(t.documentHelper.isDocumentProtected){if(!(0,a.le)(t.documentHelper.saltValue)&&""===t.documentHelper.saltValue&&!(0,a.le)(t.documentHelper.hashValue)&&""===t.documentHelper.hashValue&&!(0,a.le)(e)&&""===e){t.unProtectDocument(),i();return}var o=new L.q,n={passwordBase64:t.base64.encodeString(e),saltBase64:t.documentHelper.saltValue,spinCount:1e5,algorithmSid:t.documentHelper.cryptAlgorithmSid};o.url=t.owner.serviceUrl+t.owner.serverActionSettings.restrictEditing,o.contentType="application/json;charset=UTF-8",o.customHeaders=t.owner.headers,o.onSuccess=function(e){t.onUnProtectionSuccess(e)?i():r()},o.onFailure=function(e){t.protectionFailureHandler(e),r()},o.onError=function(e){t.protectionFailureHandler(e),r()};var s={serverActionType:"RestrictEditing",headers:t.owner.headers,timeout:0,cancel:!1,withCredentials:!1};t.owner.trigger(F.z1,s),s.cancel?t.documentHelper.dialog.visible&&t.documentHelper.dialog.hide():o.send(n,s),t.owner.enableTrackChanges||t.toggleTrackChangesProtection(!1)}})]})})},e.prototype.onUnProtectionSuccess=function(e){var t=JSON.parse(e.data),i=this.validateHashValue(t[1]);
1return this.owner.showHideRulers(),i},e.prototype.validateHashValue=function(e){this.currentHashValue=e;var t=new a.E7("documenteditor",this.owner.defaultLocale);t.setLocale(this.documentHelper.owner.locale);var i=this.base64.decodeString(e),r=this.documentHelper.hashValue,o=this.base64.decodeString(r),n=!0;if(i.length===o.length){for(var s=0;s<i.length;s++)if(i[s]!==o[s]){n=!1;break}}else n=!1;return n?(this.unProtectDocument(),!0):(S.hZ.alert({title:t.getConstant("Information"),content:t.getConstant("The password is incorrect")}),!1)},e.prototype.unProtectDocument=function(){this.hasShownRestrictPane=!1,this.documentHelper.owner.getSettingData("protection",!1,this.currentHashValue),this.currentHashValue=null;var e=this.documentHelper.protectionType;this.documentHelper.isDocumentProtected=!1,this.documentHelper.restrictFormatting=!1,this.documentHelper.protectionType="NoProtection",this.documentHelper.saltValue="",this.documentHelper.hashValue="",this.documentHelper.selection.highlightEditRegion();var t=this.documentHelper.restrictEditingPane.restrictPane;t&&"block"===t.style.display&&this.documentHelper.restrictEditingPane.showStopProtectionPane(!1),"RevisionsOnly"!==e||this.owner.enableTrackChanges||this.toggleTrackChangesProtection(!1),this.owner.trackChangesPane.enableDisableButton(!0,!0),(0,a.le)(this.editorHistory)||this.owner.editorHistoryModule.clearHistory(),this.owner.notify(F.Bx,{}),this.documentHelper.dialog.visible&&this.documentHelper.dialog.hide(),this.owner.commentReviewPane.enableDisableItems(),this.owner.showHideRulers(),this.documentHelper.owner.enableCollaborativeEditing||this.fireContentChange()},e.prototype.fireContentChange=function(){this.owner.documentHelper.render.commentMarkDictionary.clear(),this.selection.isHighlightEditRegion&&(this.owner.enableLockAndEdit?this.owner.collaborativeEditingModule.updateLockRegion():this.selection.onHighlight()),this.selection.highlightFormFields(),this.isPaste||(this.copiedContent=void 0,this.copiedTextContent="",this.previousSectionFormat=void 0,this.previousParaFormat=void 0,this.previousCharFormat=void 0,this.selection.isViewPasteOptions=!1,this.isPasteListUpdated&&(this.isPasteListUpdated=!1),this.selection.showHidePasteOptions(void 0,void 0)),!this.documentHelper.owner.isLayoutEnabled||this.documentHelper.owner.editorModule.isUserInsert||this.documentHelper.owner.isShiftingEnabled||this.isSkipOperationsBuild||this.isRemoteAction||!(0,a.le)(this.owner.optionsPaneModule)&&this.owner.optionsPaneModule.isUpdateHeading||this.documentHelper.owner.fireContentChange(),!(0,a.le)(this.owner.optionsPaneModule)&&this.owner.optionsPaneModule.isOptionsPaneShow&&!this.owner.optionsPaneModule.isUpdateHeading&&"BodyText"!==this.selection.paragraphFormat.outlineLevel&&this.owner.optionsPaneModule.isHeadingTab&&this.owner.optionsPaneModule.updateHeadingTab(),this.owner.isSpellCheck&&!(0,a.le)(this.selection.editPosition)&&(this.triggerPageSpellCheck=!1)},e.prototype.updateSelectionTextPosition=function(e){this.getOffsetValue(this.selection),this.selection.start.updatePhysicalPosition(!0),this.selection.isEmpty?this.selection.end.setPositionInternal(this.selection.start):this.selection.end.updatePhysicalPosition(!0),this.selection.upDownSelectionLength=this.selection.end.location.x,this.selection.fireSelectionChanged(e)},e.prototype.predictText=function(){this.documentHelper.suffix="",this.selection.start.paragraph.isEmpty()||0===this.selection.start.offset&&this.selection.start.currentWidget.isFirstLine()||0===this.selection.end.offset&&this.selection.end.currentWidget.isFirstLine()?this.documentHelper.prefix="":this.getPrefixAndSuffix(),this.documentHelper.prefix="@"+String.fromCharCode(160)+this.documentHelper.prefix,this.documentHelper.editableDiv.innerText=this.documentHelper.prefix,(this.owner.enableAutoFocus||!this.documentHelper.layout.isInitialLoad)&&this.documentHelper.selection.setEditableDivCaretPosition(this.documentHelper.prefix.length)},e.prototype.getPrefixAndSuffix=function(){var e=this.owner.documentHelper;if(""!==this.selection.text){e.prefix="";return}var t=0,i=this.selection.start.currentWidget.getInline(this.selection.start.offset,t),r=i.element;if(t=i.index,void 0!==r){var n=this.selection.getElementBoxInternal(r,t),s=n.element;t=n.index;var l=0;if(!(0,a.le)(s)){var d=!1;for(s instanceof o.a3&&t>0&&(e.prefix=""),r instanceof o.a3||(r=this.selection.getPreviousTextElement(r));(l=e.prefix.lastIndexOf(" "))<0&&r instanceof o.a3;)if(r.previousNode instanceof o.a3&&-1===e.prefix.indexOf(" ")){if(d?e.prefix=r.text+e.prefix:(e.prefix=r.text.substring(0,t),d=!0),(r=r.previousNode)instanceof o.no)break;r instanceof o.a3||(r=this.selection.getPreviousTextElement(r))}else if(!(r.previousNode instanceof o.a3)){d?e.prefix=r.text+e.prefix:(e.prefix=r.text.substring(0,t),d=!0);break}e.prefix.length>1&&" "===e.prefix[e.prefix.length-1]&&"."===e.prefix[e.prefix.length-2]?(l=-1,e.prefix=""):l=e.prefix.lastIndexOf(" "),e.prefix=l<0?e.prefix:e.prefix.substring(l),0===e.prefix.indexOf(" ")&&e.prefix.length>=1&&(e.prefix=e.prefix.substring(1));var h=0,c=this.selection.end.currentWidget.getInline(this.selection.end.offset,h),p=c.element;if(h=c.index,s=(n=this.selection.getElementBoxInternal(p,h)).element,h=n.index,s){var g=!1;for(s instanceof o.a3&&h<s.length&&(e.suffix="");(l=e.suffix.indexOf(" "))<0&&p instanceof o.a3;)if(p.nextNode instanceof o.a3&&-1===e.suffix.indexOf(" "))g?e.suffix=e.suffix+p.text:(e.suffix=s.text.substring(h),g=!0),p=p.nextNode;else if(!(p.nextNode instanceof o.a3)){g?e.suffix=e.suffix+p.text:(e.suffix=s.text.substring(h),g=!0);break}l=e.suffix.indexOf(" "),e.suffix=l<0?e.suffix:e.suffix.substring(0,l)}}}},e.prototype.onKeyDownInternal=function(e,t,i,r){var o=this,n=s.o_.getLegacyKeyCode(e);if(this.owner.focusIn(),!t||i||r){if(!i||t||r){if(i&&t&&!r)switch(n){case 13:this.owner.isReadOnlyMode||(e.preventDefault(),this.insertColumnBreak());break;case 68:this.owner.isReadOnlyMode||this.owner.selectionModule.toggleUnderline("Double");break;case 77:this.owner.isReadOnlyMode||this.owner.selectionModule.decreaseIndent(),e.preventDefault();break;case 188:e.preventDefault(),this.owner.isReadOnlyMode||this.onApplyCharacterFormat("fontSize","decrement",!0);break;case 190:e.preventDefault(),this.owner.isReadOnlyMode||this.onApplyCharacterFormat("fontSize","increment",!0);break;case 187:e.preventDefault(),this.owner.isReadOnlyMode||this.toggleBaselineAlignment("Superscript");break;case 69:if(e.preventDefault(),!this.owner.isReadOnlyMode){var a={isTrackChangesEnabled:!this.owner.enableTrackChanges};this.owner.trigger(F.rC,a)}}else if(!i&&t&&r)switch(n){case 72:e.preventDefault(),!this.owner.isReadOnlyMode&&this.owner.isDocumentLoaded&&this.toggleHighlightColor();break;case 70:e.preventDefault(),!this.owner.isReadOnlyMode&&this.owner.isDocumentLoaded&&this.insertFootnote();break;case 68:e.preventDefault(),!this.owner.isReadOnlyMode&&this.owner.isDocumentLoaded&&this.insertEndnote()}else switch(n){case 8:e.preventDefault(),this.handleBackKey();break;case 9:this.checkAndShowRestrictPane(),this.owner.acceptTab?(e.preventDefault(),this.selection.handleTabKey(!0,!1)):this.documentHelper.editableDiv.blur();break;case 13:e.preventDefault(),this.owner.isSpellCheck&&(this.documentHelper.triggerSpellCheck=!0),this.handleEnterKey(),this.owner.isSpellCheck&&(this.documentHelper.triggerSpellCheck=!1);break;case 27:e.preventDefault(),this.isPaste||(this.copiedContent=void 0,this.copiedTextContent="",this.previousParaFormat=void 0,this.previousCharFormat=void 0,this.previousSectionFormat=void 0,this.selection.isViewPasteOptions=!1,this.isPasteListUpdated&&(this.isPasteListUpdated=!1),this.selection.showHidePasteOptions(void 0,void 0));break;case 46:this.handleDelete(),e.preventDefault();break;case 32:this.selection.handleSpaceBarKey();break;case 120:var l=this.selection.getDocumentEnd();l.offset=this.selection.getDocumentEnd().offset+1,this.selection.start.isAtSamePosition(this.selection.getDocumentStart())&&this.selection.end.isAtSamePosition(l)?this.owner.updateFields():this.selection.updateRefField()}}else switch(n){case 9:this.owner.acceptTab?(e.preventDefault(),this.selection.handleTabKey(!1,!0)):this.documentHelper.editableDiv.blur();break;case 13:this.handleShiftEnter(),e.preventDefault();break;case 114:e.preventDefault(),this.changeCase(this.toggleChangeCase())}}else switch(this.documentHelper.isControlPressed=!0,n){case 8:e.preventDefault(),this.handleCtrlBackKey();break;case 46:e.preventDefault(),this.handleCtrlDelete();break;case 9:e.preventDefault(),this.owner.acceptTab&&this.selection.handleTabKey(!1,!1);break;case 13:e.preventDefault(),this.insertPageBreak();break;case 48:e.preventDefault();var d=0,h=this.documentHelper.selection.start.paragraph.paragraphFormat.beforeSpacing;h>12?d=12:h>
10&&h<=12?d=0:0===h&&(d=12),this.onApplyParagraphFormat("beforeSpacing",d,!0,!1);break;case 49:e.preventDefault(),(!this.owner.isReadOnlyMode||this.selection.isInlineFormFillMode())&&this.onApplyParagraphFormat("lineSpacing",1,!1,!1);break;case 50:e.preventDefault(),(!this.owner.isReadOnlyMode||this.selection.isInlineFormFillMode())&&this.onApplyParagraphFormat("lineSpacing",2,!1,!1);break;case 53:e.preventDefault(),(!this.owner.isReadOnlyMode||this.selection.isInlineFormFillMode())&&this.onApplyParagraphFormat("lineSpacing",1.5,!1,!1);break;case 66:e.preventDefault(),(!this.owner.isReadOnlyMode||this.selection.isInlineFormFillMode())&&this.toggleBold();break;case 68:e.preventDefault(),!this.owner.isReadOnlyMode&&this.owner.fontDialogModule&&this.owner.fontDialogModule.showFontDialog();break;case 69:(!this.owner.isReadOnlyMode||this.selection.isInlineFormFillMode())&&this.toggleTextAlignment("Center"),e.preventDefault();break;case 72:e.preventDefault(),!this.owner.isReadOnly&&this.owner.optionsPaneModule&&(this.owner.optionsPaneModule.isReplace=!0,this.owner.optionsPaneModule.isFind=!1,this.owner.documentEditorSettings.showNavigationPane=!0,this.owner.optionsPaneModule.showHideOptionsPane(!0),setTimeout(function(){o.owner.optionsPaneModule.isReplace&&(o.owner.optionsPaneModule.isReplace=!1)},10));break;case 73:e.preventDefault(),(!this.owner.isReadOnlyMode||this.selection.isInlineFormFillMode())&&this.toggleItalic();break;case 74:(!this.owner.isReadOnlyMode||this.selection.isInlineFormFillMode())&&this.toggleTextAlignment("Justify"),e.preventDefault();break;case 75:e.preventDefault(),this.owner.hyperlinkDialogModule&&!this.owner.isReadOnlyMode&&this.owner.hyperlinkDialogModule.show();break;case 76:(!this.owner.isReadOnlyMode||this.selection.isInlineFormFillMode())&&this.toggleTextAlignment("Left"),e.preventDefault();break;case 77:(!this.owner.isReadOnlyMode||this.selection.isInlineFormFillMode())&&this.owner.selectionModule.increaseIndent(),e.preventDefault();break;case 78:e.preventDefault(),this.owner.isReadOnlyMode||this.owner.openBlank();break;case 82:(!this.owner.isReadOnlyMode||this.selection.isInlineFormFillMode())&&this.toggleTextAlignment("Right"),e.preventDefault();break;case 85:e.preventDefault(),(!this.owner.isReadOnlyMode||this.selection.isInlineFormFillMode())&&this.owner.selectionModule.toggleUnderline("Single");break;case 88:e.preventDefault(),this.owner.isReadOnlyMode||this.owner.editorModule.cut();break;case 89:this.owner.enableEditorHistory&&(this.editorHistory.redo(),e.preventDefault());break;case 90:this.owner.enableEditorHistory&&(this.editorHistory.undo(),e.preventDefault());break;case 219:e.preventDefault(),(!this.owner.isReadOnlyMode||this.selection.isInlineFormFillMode())&&this.onApplyCharacterFormat("fontSize","decrement",!0);break;case 221:e.preventDefault(),(!this.owner.isReadOnlyMode||this.selection.isInlineFormFillMode())&&this.onApplyCharacterFormat("fontSize","increment",!0);break;case 187:e.preventDefault(),(!this.owner.isReadOnlyMode||this.selection.isInlineFormFillMode())&&this.toggleBaselineAlignment("Subscript")}},e.prototype.handleShiftEnter=function(){this.owner.isReadOnlyMode||this.handleTextInput("\v"),this.selection.checkForCursorVisibility()},e.prototype.handleBackKey=function(){this.checkAndShowRestrictPane()||((!this.owner.isReadOnlyMode&&this.canEditContentControl||"FormFieldsOnly"===this.documentHelper.protectionType&&this.canEditContentControl&&!(0,a.le)(this.documentHelper.selection)&&this.documentHelper.selection.checkContentControlLocked()||this.selection.isInlineFormFillMode())&&this.owner.editorModule.onBackSpace(),this.selection.checkForCursorVisibility())},e.prototype.handleDelete=function(){this.checkAndShowRestrictPane()||((!this.owner.isReadOnlyMode&&this.canEditContentControl||"FormFieldsOnly"===this.documentHelper.protectionType&&this.canEditContentControl&&!(0,a.le)(this.documentHelper.selection)&&this.documentHelper.selection.checkContentControlLocked()||this.selection.isInlineFormFillMode())&&this.owner.editorModule.delete(),this.selection.checkForCursorVisibility())},e.prototype.handleEnterKey=function(){if(!this.checkAndShowRestrictPane()){var e=this.documentHelper.owner.selection.currentContentControl;(!this.owner.isReadOnlyMode&&!this.documentHelper.selection.checkContentControl
1Locked()||this.selection.isInlineFormFillMode()||("FormFieldsOnly"===this.documentHelper.protectionType||"NoProtection"==this.documentHelper.protectionType)&&e.contentControlProperties.multiline&&!(0,a.le)(this.documentHelper.selection)&&this.documentHelper.selection.checkContentControlLocked()||!(0,a.le)(e)&&"RichText"===e.contentControlProperties.type&&this.canEditContentControl&&("Block"===e.contentControlWidgetType||"Cell"===e.contentControlWidgetType))&&(a.AR.isDevice&&(this.documentHelper.isCompositionStart=!1),this.owner.editorModule.onEnter()),this.selection.checkForCursorVisibility()}},e.prototype.handleCtrlBackKey=function(){var e=this.selection.start,t=this.selection.end;if(!this.owner.isReadOnlyMode||this.selection.isInlineFormFillMode()){if(this.selection.isForward||(e=t),this.selection.isEmpty)this.selection.handleControlShiftLeftKey(),this.owner.editorModule.onBackSpace();else{if(((0,a.le)(e.paragraph.previousRenderedWidget)||e.paragraph.previousRenderedWidget instanceof o.dm)&&0===e.offset)return;this.selection.handleLeftKey(),this.selection.handleControlShiftLeftKey(),this.owner.editorModule.onBackSpace()}}},e.prototype.handleCtrlDelete=function(){if(!this.owner.isReadOnlyMode&&this.canEditContentControl||this.selection.isInlineFormFillMode()){if(this.selection.isEmpty)this.selection.handleControlShiftRightKey(),this.owner.editorModule.delete();else{this.selection.handleLeftKey(),this.selection.handleControlShiftRightKey();var e=this.selection.text;s.o_.endsWith(e)&&this.selection.handleShiftLeftKey(),this.owner.editorModule.delete()}}},e.prototype.handleTextInput=function(e){var t=this;this.checkAndShowRestrictPane()||((!this.owner.isReadOnlyMode&&this.canEditContentControl||"FormFieldsOnly"===this.documentHelper.protectionType&&this.canEditContentControl&&!(0,a.le)(this.documentHelper.selection)&&this.documentHelper.selection.checkContentControlLocked()||this.selection.isInlineFormFillMode())&&(this.animationTimer&&clearTimeout(this.animationTimer),(0,a.s1)(this.selection.caret,[],["e-de-cursor-animation"]),this.handledTextInput=!0,this.owner.editorModule.insertText(e),this.handledTextInput=!1,this.animationTimer=Number(setTimeout(function(){t.animationTimer&&clearTimeout(t.animationTimer),t.selection&&t.selection.caret&&(0,a.s1)(t.selection.caret,["e-de-cursor-animation"],[])},600))),this.selection.checkForCursorVisibility())},e.prototype.copyInsertFormat=function(e,t,i){var r=i?new n.a(i,this.owner):new n.a(void 0,this.owner),o=this.selection.characterFormat;return t&&r.copyFormat(e),(0,a.le)(o.bidi)||e.bidi===o.bidi||(r.bidi=o.bidi),(0,a.le)(o.bold)||e.bold===o.bold||(r.bold=o.bold),(0,a.le)(o.italic)||e.italic===o.italic||(r.italic=o.italic),o.fontSize>0&&e.fontSize!==o.fontSize&&(r.fontSize=o.fontSize),(0,a.le)(o.fontFamily)||e.fontFamily===o.fontFamily||(r.fontFamily=o.fontFamily),(0,a.le)(o.highlightColor)||e.highlightColor===o.highlightColor||(r.highlightColor=o.highlightColor),(0,a.le)(o.baselineAlignment)||e.baselineAlignment===o.baselineAlignment||(r.baselineAlignment=o.baselineAlignment),(0,a.le)(o.fontColor)||e.fontColor===o.fontColor||(r.fontColor=o.fontColor),(0,a.le)(o.underline)||e.underline===o.underline||(r.underline=o.underline),(0,a.le)(o.strikethrough)||e.strikethrough===o.strikethrough||(r.strikethrough=o.strikethrough),(0,a.le)(o.boldBidi)||e.boldBidi===o.boldBidi||(r.boldBidi=o.boldBidi),(0,a.le)(o.italicBidi)||e.italicBidi===o.italicBidi||(r.italicBidi=o.italicBidi),o.fontSizeBidi>0&&e.fontSizeBidi!==o.fontSizeBidi&&(r.fontSizeBidi=o.fontSizeBidi),r},e.prototype.getResultContentControlText=function(e){for(var t=e.nextNode,i="";!(t instanceof o.h)&&(t instanceof o.a3&&(i+=t.text),!(0,a.le)(t));)if((0,a.le)(t.nextNode)){if(t.paragraph.nextRenderedWidget)t=t.paragraph.nextRenderedWidget.firstChild.children[0];else break}else t=t.nextNode;return i},e.prototype.insertContentControlPlaceholder=function(){var e=this.owner.selection.currentContentControl;if(!(0,a.le)(e)&&e.nextElement instanceof o.h&&e.nextElement===e.reference){var t=new o.a3,i=new a.E7("documenteditor",this.owner.defaultLocale);i.setLocale(this.owner.locale),t.text=i.getConstant("Default Content Control Text"),("ComboBox"===e.contentControlProperties.type||"DropDownList"===e.contentControlProperties.type)&&(t.text=i.getConstant("Choose an item")),"Date"===e.contentControlProperties.type&&(t.text=i.getConstant("Default Date Picker")),t.characterFormat=this.owner.editor.copyInsertFormat(this.selection.start.paragraph.characterFormat,!0),this.owner.editor.insertElementsInternal(this.owner.selectionModule.end,[t]),e.contentControlProperties.hasPlaceHolderText=!0}},e.prototype.insertContentControl=function(e,t,i){if(!this.selection.isPlainContentControl()&&!this.owner.isReadOnlyMode){switch("string"!=typeof e?(r=e.type,t=e.value,i=e.items,o=e):r=e,(0,a.le)(o)&&(o={title:void 0,tag:void 0,value:String(t),canDelete:!1,canEdit:!1,type:r,xmlString:void 0,xmlPath:void 0}
1),(0,a.le)(o)||(0,a.le)(o.xmlString)||(0,a.le)(o.xmlString)||(t=(o=this.mapXmlStringPath(o)).value,this.owner.isXmlMapCC=!0),this.isInsertNewLineAfterContentControl()&&this.onEnter(),r){case"RichText":if((0,a.le)(t))this.applyRichText();else try{var r,o,n=t;"object"!=typeof n&&(n=JSON.parse(t)),(n&&"object"==typeof n||"sections"in n)&&this.applyRichText(t,o.title,o.tag,o.canDelete,o.canEdit)}catch(e){var s={sections:[{blocks:[{inlines:[{text:t}]}]}]};this.applyRichText(JSON.stringify(s),o.title,o.tag,o.canDelete,o.canEdit)}break;case"Text":(0,a.le)(t)?this.applyPlainText():this.applyPlainText(t,o.title,o.tag,o.canDelete,o.canEdit);break;case"Picture":this.applyPictureContentControl(r,t,o.title,o.tag,o.canDelete,o.canEdit);break;case"ComboBox":this.applyComboBox("ComboBox",i,t,o.title,o.tag,o.canDelete,o.canEdit);break;case"DropDownList":this.applyComboBox("DropDownList",i,t,o.title,o.tag,o.canDelete,o.canEdit);break;case"Date":this.applyDatePickerContentControl(r,t,o.title,o.tag,o.canDelete,o.canEdit);break;case"CheckBox":this.applyCheckBoxContentControl(r,String.fromCharCode(9744),t,o.title,o.tag,o.canDelete,o.canEdit)}var l=this.selection.currentContentControl;if(!(0,a.le)(l))return{title:l.contentControlProperties.title,tag:l.contentControlProperties.tag,value:String(t),canDelete:l.contentControlProperties.lockContentControl,canEdit:l.contentControlProperties.lockContents,type:l.contentControlProperties.type,xmlString:o.xmlString,xmlPath:o.xmlPath}}},e.prototype.openContentDialog=function(e){var t=new a.E7("documenteditor",this.owner.defaultLocale);t.setLocale(this.owner.locale),S.hZ.alert({title:t.getConstant("Information"),content:e?t.getConstant("Rich text Controls"):t.getConstant("Plain text Controls"),showCloseIcon:!0,closeOnEscape:!0,animationSettings:{effect:"Zoom"},position:{X:"center",Y:"center"}})},e.prototype.updatePropertiesToBlock=function(e,t){var i=e.contentControlProperties;if("Inline"!==i.contentControlWidgetType){var r=e.line.paragraph,o=e.reference.line.paragraph;if("Cell"===i.contentControlWidgetType&&r.associatedCell)r.associatedCell.contentControlProperties=t?e.contentControlProperties:void 0;else if("Block"===i.contentControlWidgetType)for(var n=r.isInsideTable?this.documentHelper.layout.getParentTable(r):r,s=o.isInsideTable?this.documentHelper.layout.getParentTable(o):o;n;)n.contentControlProperties||(n.contentControlProperties=t?e.contentControlProperties:void 0),n=n!==s?n.nextRenderedWidget:void 0}},e.prototype.updateContentControlPosition=function(e,t){if(!this.selection.isEmpty){var i=e.currentWidget.getInline(e.offset,0),r=t.currentWidget.getInline(t.offset,0);i&&i.element instanceof o.h&&"Block"===i.element.contentControlWidgetType&&e.offset++,r&&r.element instanceof o.h&&"Block"===r.element.contentControlWidgetType&&t.offset--}},e.prototype.applyRichText=function(e,t,i,r,n){var s,l,d="Inline";if(!(0,a.le)(this.selection.currentContentControl)&&this.selection.currentContentControl.contentControlProperties.hasPlaceHolderText)this.editorHistory&&this.initComplexHistory("InsertContentControl"),this.delete(),this.selection.selectContentControlInternal(this.selection.currentContentControl),s=this.selection.start.clone(),l=this.selection.end.clone(),d=this.selection.currentContentControl.contentControlWidgetType;else{if(s=this.selection.isForward?this.selection.start.clone():this.selection.end.clone(),l=this.selection.isForward?this.selection.end.clone():this.selection.start.clone(),this.selection.isParagraphMarkSelected()&&(s.isAtSamePosition(l)&&(s.offset-=1),l.offset-=1),s.paragraph!==l.paragraph){if(s.isAtParagraphStart){if(s.isAtParagraphStart&&!l.isAtParagraphEnd){var h=void 0;h=l.paragraph.previousRenderedWidget instanceof o.dm?this.selection.getLastBlockInLastCell(l.paragraph.previousRenderedWidget):l.paragraph.previousRenderedWidget,l.setPositionParagraph(h.lastChild,h.lastChild.getEndOffset())}}else l.setPositionParagraph(s.paragraph.lastChild,s.paragraph.lastChild.getEndOffset())}if(this.updateContentControlPosition(s,l),s.isAtParagraphStart&&l.isAtParagraphEnd&&(d="Block"),s.paragraph.isInsideTable&&l.paragraph.isInsideTable&&s.paragraph.associatedCell===l.paragraph.associatedCell){var c=s.paragraph.associatedCell;(c.isEmpty()||!s.isAtSamePosition(l)&&this.selection.isCellSelected(c,s,l,!0))&&(d="Cell")}this.editorHistory&&this.initComplexHistory("InsertContentControl")}var p=new o.h(d),g=new o.h(d),m=new o.Me(d);if(m.color="#00000000",m.hasPlaceHolderText=!!s.isAtSamePosition(l),m.isTemporary=!1,m.lockContentControl=!(0,a.le)(r)&&!r,m.lockContents=!(0,a.le)(n)&&!n,m.tag=(0,a.le)(i)?void 0:i,m.t
1itle=(0,a.le)(t)?void 0:t,m.multiline=!1,m.type="RichText",this.owner.isXmlMapCC&&this.addXmlProperties(m,this.owner.xPathString),p.contentControlProperties=m,g.contentControlProperties=p.contentControlProperties,p.type=0,g.type=1,p.reference=g,g.reference=p,m.hasPlaceHolderText){var u=new o.a3,f=new a.E7("documenteditor",this.owner.defaultLocale);f.setLocale(this.owner.locale),u.text=f.getConstant("Default Content Control Text"),u.characterFormat=this.copyInsertFormat(this.selection.start.paragraph.characterFormat,!0);var y=this.selection.getParagraphInfo(s);this.insertElementsInternal(s,[g]);var v=this.selection.getLineInfoBasedOnParagraph(y.paragraph,y.offset);s.setPositionFromLine(v.line,v.offset),this.insertElementsInternal(s,[u]),v=this.selection.getLineInfoBasedOnParagraph(y.paragraph,y.offset),s.setPositionFromLine(v.line,v.offset),this.insertElementsInternal(s,[p])}else this.insertElementsInternal(l,[g]),this.insertElementsInternal(s,[p]);(0,a.le)(e)||(this.documentHelper.selection.selectContentControlInternal(p),this.paste(e),m.hasPlaceHolderText=!1),this.updatePropertiesToBlock(p,!0),m.hasPlaceHolderText?this.selection.selectPlaceHolderText(p):this.selection.selectContentControlInternal(p),this.selection.contentControleditRegionHighlighters.clear(),this.selection.onHighlightContentControl(),this.editorHistory&&this.editorHistory.updateComplexHistory(),this.documentHelper.owner.enableHeaderAndFooter&&this.updateHeaderFooterWidget(),this.documentHelper.viewer.updateScrollBars()},e.prototype.isInsertNewLineAfterContentControl=function(){if((0,a.le)(this.selection.currentContentControl)&&this.selection.isEmpty){var e=this.selection.start.currentWidget.getInline(this.selection.start.offset,0).element;if(e instanceof o.h&&1==e.type&&"Block"===e.contentControlWidgetType&&e.reference&&e.paragraph!==e.reference.paragraph)return!0}return!1},e.prototype.isInvalidElementPresent=function(e,t){for(var i=this.selection.getElementInfo(e.currentWidget,e.offset+1),r=this.selection.getElementInfo(t.currentWidget,t.offset),n=e.currentWidget.indexInOwner;n<t.currentWidget.indexInOwner+1;n++)for(var s=e.currentWidget.paragraph.childWidgets[n],a=i.element.indexInOwner;a<s.children.length;a++){var l=s.children[a];if(!(l instanceof o.a3))return!0;if(r.element==l)return!1}return!1},e.prototype.applyPlainText=function(e,t,i,r,n){var s=this.selection.currentContentControl;if((0,a.le)(s)||"RichText"===s.contentControlProperties.type){var l=this.selection.isForward?this.selection.start.clone():this.selection.end.clone(),d=this.selection.isForward?this.selection.end.clone():this.selection.start.clone();this.selection.isParagraphMarkSelected()&&(l.isAtSamePosition(d)&&(l.offset-=1),d.offset-=1),l.paragraph!==d.paragraph&&d.setPositionParagraph(l.paragraph.lastChild,l.paragraph.lastChild.getEndOffset());var h="Inline";l.isAtParagraphStart&&d.isAtParagraphEnd&&(h="Block");var c=l.isAtSamePosition(d);if(!c&&this.isInvalidElementPresent(l,d)){this.openContentDialog(!1);return}if(l.paragraph.isInsideTable&&d.paragraph.isInsideTable&&l.paragraph.associatedCell===d.paragraph.associatedCell){var p=l.paragraph.associatedCell;(p.isEmpty()||!c&&this.selection.isCellSelected(p,l,d,!0))&&(h="Cell")}var g=new o.h(h),m=new o.h(h),u=new o.Me(h);if(u.color="#00000000",c?u.hasPlaceHolderText=!0:u.hasPlaceHolderText=!1,u.isTemporary=!1,u.lockContentControl=!(0,a.le)(r)&&!r,u.lockContents=!(0,a.le)(n)&&!n,u.tag=(0,a.le)(i)?void 0:i,u.title=(0,a.le)(t)?void 0:t,u.multiline=!1,u.type="Text",this.owner.isXmlMapCC&&this.addXmlProperties(u,this.owner.xPathString),g.contentControlProperties=u,m.contentControlProperties=g.contentControlProperties,g.type=0,m.type=1,g.reference=m,m.reference=g,this.editorHistory&&this.initComplexHistory("InsertContentControl"),u.hasPlaceHolderText){var f=new o.a3;if((0,a.le)(e)){var y=new a.E7("documenteditor",this.owner.defaultLocale);
1y.setLocale(this.owner.locale),f.text=y.getConstant("Default Content Control Text")}else f.text=e,u.hasPlaceHolderText=!1;f.characterFormat=this.copyInsertFormat(this.selection.start.paragraph.characterFormat,!0);var v=this.selection.getParagraphInfo(l);this.insertElementsInternal(l,[m]);var H=this.selection.getLineInfoBasedOnParagraph(v.paragraph,v.offset);l.setPositionFromLine(H.line,H.offset),this.insertElementsInternal(l,[f]),H=this.selection.getLineInfoBasedOnParagraph(v.paragraph,v.offset),l.setPositionFromLine(H.line,H.offset),this.insertElementsInternal(l,[g])}else this.insertElementsInternal(d,[m]),this.insertElementsInternal(l,[g]),this.documentHelper.selection.selectContentControlInternal(g),(0,a.le)(e)||this.insertText(e);this.updatePropertiesToBlock(g,!0),u.hasPlaceHolderText?this.selection.selectPlaceHolderText(g):this.selection.selectContentControlInternal(g),this.editorHistory&&this.editorHistory.updateComplexHistory(),this.documentHelper.owner.enableHeaderAndFooter&&this.updateHeaderFooterWidget(),this.documentHelper.viewer.updateScrollBars()}},e.prototype.applyComboBox=function(e,t,i,n,s,l,d){var h=this.selection.currentContentControl;if((0,a.le)(h)||"RichText"===h.contentControlProperties.type){var c=new o.h("Inline"),p=new o.h("Inline"),g=new o.Me("Inline");g.color="#00000000",g.type=e,g.tag=(0,a.le)(s)?void 0:s,g.title=(0,a.le)(n)?void 0:n,this.selection.isEmpty?g.hasPlaceHolderText=!0:g.hasPlaceHolderText=!1,g.isTemporary=!1,g.lockContentControl=!(0,a.le)(l)&&l,g.lockContents=!(0,a.le)(d)&&d,g.multiline=!1;var m=[];if((0,a.le)(t)){var u=new o.zN,f=new a.E7("documenteditor",this.owner.defaultLocale);u.displayText=f.getConstant("Choose an item"),u.value=f.getConstant("Choose an item"),m.push(u)}else for(var y=0;y<t.length;y++){var u=new o.zN;u.displayText=t[y],u.value=t[y],m.push(u)}g.contentControlListItems=m,g.contentControlWidgetType="Inline",this.owner.isXmlMapCC&&this.addXmlProperties(g,this.owner.xPathString),c.contentControlProperties=g,p.contentControlProperties=c.contentControlProperties,c.type=0,p.type=1,c.reference=p,p.reference=c,this.editorHistory&&this.initComplexHistory("InsertContentControl");var v=this.selection.isForward?this.selection.start.clone():this.selection.end.clone(),H=this.selection.isForward?this.selection.end.clone():this.selection.start.clone();if(H.paragraph!==v.paragraph&&(H=new r.JK(this.owner)).setPositionParagraph(v.paragraph.lastChild,v.paragraph.lastChild.getEndOffset()),g.hasPlaceHolderText){var u=new o.a3,f=new a.E7("documenteditor",this.owner.defaultLocale);u.text=f.getConstant("Choose an item"),u.characterFormat=this.copyInsertFormat(this.selection.start.paragraph.characterFormat,!0);var C=this.selection.getParagraphInfo(v);this.insertElementsInternal(v,[p]);var F=this.selection.getLineInfoBasedOnParagraph(C.paragraph,C.offset);v.setPositionFromLine(F.line,F.offset),this.insertElementsInternal(v,[u]),F=this.selection.getLineInfoBasedOnParagraph(C.paragraph,C.offset),v.setPositionFromLine(F.line,F.offset),this.insertElementsInternal(v,[c])}else this.insertElementsInternal(H,[p]),this.insertElementsInternal(v,[c]);this.selection.start.currentWidget.getInline(this.selection.start.offset-1,0).element.contentControlProperties=g,(0,a.le)(t)?this.selection.selectContentControlInternal(c):this.dropDownChange(c,i),this.editorHistory&&this.editorHistory.updateComplexHistory(),this.documentHelper.owner.enableHeaderAndFooter&&this.updateHeaderFooterWidget(),this.documentHelper.viewer.updateScrollBars()}},e.prototype.applyDatePickerContentControl=function(e,t,i,n,s,l){this.dateValue=t;var d=this.selection.currentContentControl;if((0,a.le)(d)||"RichText"===d.contentControlProperties.type){var h=new o.h("Inline"),c=new o.h("Inline"),p=new o.Me("Inline");p.color="#00000000",this.selection.isEmpty?p.hasPlaceHolderText=!0:p.hasPlaceHolderText=!1,p.isTemporary=!1,p.lockContentControl=!(0,a.le)(s)&&!s,p.lockContents=!(0,a.le)(l)&&!l,p.tag=(0,a.le)(n)?void 0:n,p.title=(0,a.le)(i)?void 0:i,p.multiline=!1,p.type=e,p.contentControlWidgetType="Inline",this.owner.isXmlMapCC&&this.addXmlProperties(p,this.owner.xPathString),h.contentControlProperties=p,c.contentControlProperties=h.contentControlProperties,h.type=0,c.type=1,h.reference=c,c.reference=h,this.editorHistory&&this.initComplexHistory("InsertContentControl");var g=this.selection.isForward?this.selection.start.clone():this.selection.end.clone(),m=this.selection.isForward?this.selection.end.clone():this.selection.start.clone();if(m.paragraph!==g.paragraph&&(m=new r.JK(this.owner)).setPositionParagraph(g.paragraph.lastChild,g.paragraph.lastChild.getEndOffset()),p.hasPlaceHolderText){var u=new o.a3;if(t)u.text=t;else{var f=new a.E7("documenteditor",this.owner.defaultLocale);f.setLocale(this.owner.locale),u.text=f.getConstant("Default Date Picker")}u.characterFormat=this.copyInsertFormat(this.selection.start.paragraph.characterFormat,!0);var y=this.selection.getParagraphInfo(g);this.insertElementsInternal(g,[c]);var v=this.selection.getLineInfoBasedOnParagraph(y.paragraph,y.offset);g.setPositionFromLine(v.line,v.offset),this.insertElementsInternal(g,[u]),v=this.selection.getLineInfoBasedOnParagraph(y.paragraph,y.offset),g.setPositionFromLine(v.line,v.offset),this.insertElementsInternal(g,[h])}else this.insertElementsInternal(m,[c]),this.insertElementsInternal(g,[h]);this.selection.start.currentWidget.getInline(this.selection.start.offset-1,0).element.contentControlProperties=p,this.selection.selectContentControlInternal(h),this.editorHistory&&this.editorHistory.updateComplexHistory(),this.documentHelper.owner.enableHeaderAndFooter&&this.updateHeaderFooterWidget(),this.documentHelper.viewer.updateScrollBars()}},e.prototype.applyCheckBoxContentControl=function(e,t,i,n,s,l,d){var h=this.selection.currentContentControl;if((0,a.le)(h)||"RichText"===h.contentControlProperties.type){var c=new o.h("Inline"),p=new o.h("Inline"),g=new o.Me("Inline");g.color="#00000000",g.hasPlaceHolderText=!1,g.isTemporary=!1,g.lockContentControl=!(0,a.le)(l)&&l,g.lockContents=!(0,a.le)(d)&&d,g.multiline=!1,g.type=e,g.tag=(0,a.le)(s)?void 0:s,g.title=(0,a.le)(n)?void 0:n,(0,a.le)(i)?g.isChecked=!1:g.isChecked=i,g.uncheckedState=new o._p,g.uncheckedState.font=this.selection.characterFormat.fontFamily,g.uncheckedState.value=String.fromCharCode(9744),g.checkedState=new o._p,g.checkedState.font=this.selection.characterFormat.fontFamily,g.checkedState.value=String.fromCharCode(9746),g.contentControlWidgetType="Inline",this.owner.isXmlMapCC&&this.addXmlProperties(g,this.owner.xPathString),c.contentControlProperties=g,p.contentControlProperties=c.contentControlProperties,c.type=0,p.type=1,c.reference=p,p.reference=c,this.editorHistory&&this.initComplexHistory("InsertContentControl");var m=this.selection.isForward?this.selection.start.clone():this.selection.end.clone(),u=this.selection.isForward?this.selection.end.clone():this.selection.start.clone();if(u.paragraph!==m.paragraph&&(u=new r.JK(this.owner)).setPositionParagraph(m.paragraph.lastChild,m.paragraph.lastChild.getEndOffset()),this.selection){var f=new o.a3;f.text=t,f.characterFormat=this.copyInsertFormat(this.selection.start.paragraph.characterFormat,!0);var y=this.selection.getParagraphInfo(m);this.insertElementsInternal(m,[p]);var v=this.selection.getLineInfoBasedOnParagraph(y.paragraph,y.offset);m.setPositionFromLine(v.line,v.offset),this.insertElementsInternal(m,[f]),v=this.selection.getLineInfoBasedOnParagraph(y.paragraph,y.offset),m.setPositionFromLine(v.line,v.offset),this.insertElementsInternal(m,[c])}this.selection.selectContentControlInternal(c),this.editorHistory&&this.editorHistory.updateComplexHistory(),this.documentHelper.owner.enableHeaderAndFooter&&this.updateHeaderFooterWidget(),this.documentHelper.viewer.updateScrollBars()}},e.prototype.applyPictureContentControl=function(e,t,i,r,n,s){var l=this.selection.currentContentControl;if((0,a.le)(l)||"RichText"===l.contentControlProperties.type){var d=new o.h("Inline"),h=new o.h("Inline"),c=new o.Me("Inline");c.color="#00000000",c.hasPlaceHolderText=!1,c.isTemporary=!1,c.lockContentControl=!(0,a.le)(n)&&n,c.lockContents=!(0,a.le)(s)&&s,c.multiline=!1,c.type=e,c.tag=(0,a.le)(r)?void 0:r,c.title=(0,a.le)(i)?void 0:i,c.contentControlWidgetType="Inline",this.owner.isXmlMapCC&&this.addXmlProperties(c,this.owner.xPathString),d.contentControlProperties=c,h.contentControlProperties=d.contentControlProperties,d.type=0,h.type=1,this.editorHistory&&this.initComplexHistory("InsertContentControl");var p=this.selection.start.clone(),g=this.selection.end.clone();this.selection.isForward||(d.type=1,h.type=0),this.selection.start.paragraph==this.selection.end.paragraph&&(this.insertElementsInternal(p,[d]),(0,a.le)(t)||this.insertImageAsync(t),this.insertElementsInternal(g,[h])),this.editorHistory&&this.editorHistory.updateComplexHistory(),this.documentHelper.owner.enableHeaderAndFooter&&this.updateHeaderFooterWidget(),this.documentHelper.viewer.updateScrollBars()}},e.prototype.getPrefixMapping=function(e){var t=new DOMParser().parseFromString(e,"application/xml");this.documentHelper.owner.prefixMappings=t.documentElement.namespaceURI},e.prototype.addXmlProperties=function(e,t){e.xmlMapping=new o.jl,e.xmlMapping.isMapped=!0,(0,a.le)(this.documentHelper.owner.prefixMappings)?e.xmlMapping.prefixMapping=" ":e.xmlMapping.prefixMapping=this.documentHelper.owner.prefixMappings,e.xmlMapping.xPath=t,(0,a.le)(this.guid)&&(this.guid=this.createGuid()),e.xmlMapping.storeItemId="{"+this.guid+"}",this.documentHelper.customXmlData.add(e.xmlMapping.storeItemId,this.xmlStringValue)},e.prototype.createGuid=function(){var e=new Date().getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){var i=(e+16*Math.random())%16|0;return e=Math.floor(e/16),("x"===t?i:3&i|8).toString(16)})},e.prototype.mapXmlStringPath=function(e){this.getPrefixMapping(e.xmlString);var t=this.parseXml(e.xmlString),i=this.objectToArray(t);this.setXmlData(t,i),this.xmlData;var r=e.xmlPath.split("/").pop(),o=e.xmlPath.split("/"),n=o[o.length-2],s=this.getXmlValue(n,r);return this.owner.isXmlMapCC=!0,e.xmlPath=this.transformString(e.xmlPath),this.owner.xPathString="/"+e.xmlPath,e.value=s,e},e.prototype.setContentControlInfo=function(e){var t=this.documentHelper.selection.getContentControlInfo();if(!(0,a.le)(t)){t.xmlString=e.xmlString,t.xmlPath=e.xmlPath,t.title=e.title,t.tag=e.tag,t.value=e.value,t.canDelete=e.canDelete,t.canEdit=e.canEdit;var i=this.selection.currentContentControl,r=this.documentHelper.owner.getImageContentControl();
1if((!(0,a.le)(i)||!(0,a.le)(r))&&!(0,a.le)(t)){if(!(0,a.le)(t.xmlString)&&!(0,a.le)(t.xmlString)){t=this.mapXmlStringPath(t),this.documentHelper.owner.selection.selectContentControlInternal(i),this.insertText(t.value);var o=this.getContentControl();this.addXmlProperties(o.contentControlProperties,this.owner.xPathString),this.owner.isXmlMapCC=!1}(0,a.le)(t.tag)||t.tag===i.contentControlProperties.tag||(i.contentControlProperties.tag=t.tag),(0,a.le)(t.title)||t.title===i.contentControlProperties.title||(i.contentControlProperties.title=t.title),(0,a.le)(t.value)||i.nextElement.text===t.value||t.canEdit||this.insertText(t.value),(0,a.le)(t.canDelete)||t.canDelete===i.contentControlProperties.lockContentControl||(i.contentControlProperties.lockContentControl=t.canDelete),(0,a.le)(t.canEdit)||t.canEdit===i.contentControlProperties.lockContents||(i.contentControlProperties.lockContents=t.canEdit)}return t}},e.prototype.transformString=function(e){return e.split("/").map(function(e){return e+"[1]"}).join("/")},e.prototype.getXmlValue=function(e,t){for(var i,r,o=0;o<this.xmlData.length;o++)if(this.xmlData[o].displayText==e&&(i=this.xmlData[o].id),!isNaN(i=Number(i))&&this.xmlData[o].displayText==t&&this.xmlData[i-1].displayText==e){this.xmlData[o].id,r=(r=this.xmlData[o].displayValue).toString();break}return r},e.prototype.objectToArray=function(e){return Object.keys(e).map(function(t,i){return{index:String(i+1),data:e[t]}})},e.prototype.parseXml=function(e){this.xmlStringValue=e;try{var t=new DOMParser().parseFromString(e,"text/xml"),i=this.xmlToJson(t.documentElement);return this.xmlTitle=t.documentElement.nodeName,i}catch(e){return console.error("Error parsing XML string:",e),null}},e.prototype.xmlToJson=function(e){var t={};if(e.hasChildNodes())for(var i=0;i<e.childNodes.length;i++){var r=e.childNodes[i];if(1===r.nodeType)r.nextSibling&&r.nextSibling.nodeName===r.nodeName?(t[r.nodeName]||(t[r.nodeName]=[]),t[r.nodeName].push(this.xmlToJson(r))):t[r.nodeName]=this.xmlToJson(r);else if(3===r.nodeType){var o=r.textContent.trim();o&&(t=o)}}return t},e.prototype.setXmlData=function(e,t){var i=2;this.xmlData=[],this.xmlData.push({id:1,displayText:this.xmlTitle,hasChild:!0,expanded:!0});var r=0;for(var o in e){for(var n=!0;r<t.length;r++){var s=t[r].data;n=s instanceof Object&&Object.keys(s).length>0,r+=1;break}this.xmlData.push({id:i++,displayText:o,displayValue:e[o],pid:"1",hasChild:n,expanded:n});for(var a=e[o],l=0;l<t.length;l++){var d=t[l].data,h=(i-1).toString();if(d instanceof Object&&d==a)for(var c in d)this.xmlData.push({id:i++,displayText:c,displayValue:a[c],pid:h})}}this.dictionaryObject[this.dictionaryObjectIndexIncrement++]={ID:"(no namespace)_"+this.dictionaryObjcetIDIncreament,Data:this.xmlData},this.dictionaryObjcetIDIncreament++},e.prototype.dropDownChange=function(e,t){(0,a.le)(e)||this.documentHelper.owner.isReadOnlyMode||(this.documentHelper.selection.selectContentControlInternal(e),this.insertTextInternal(t,!0),e.contentControlProperties.isTemporary&&this.removeContentControl())},e.prototype.updateXmlMappedContentControl=function(){if(this.isXmlMapped){var e=this.selection.currentContentControl;e&&e.contentControlProperties&&e.contentControlProperties.xmlMapping&&this.updateCustomXml(e.contentControlProperties.xmlMapping.storeItemId,e.contentControlProperties.xmlMapping.xPath,this.getResultContentControlText(e))}},e.prototype.updateCustomXml=function(e,t,i){if(this.documentHelper.customXmlData.containsKey(e)&&!(0,a.le)(t)){var r=this.documentHelper.customXmlData.get(e),o=new DOMParser().parseFromString(r,"text/xml"),n=t.substring(t.lastIndexOf("/")+1);n=(n=(n=n.split("[")[0]).substring(n.lastIndexOf(":")+1)).substring(n.lastIndexOf("@")+1);var s=o.getElementsByTagName(n);if(s.length>0)s[0].childNodes[0].nodeValue=i;else{if(!(o.documentElement.attributes.length>0)||null===o.documentElement.attributes.getNamedItem(n))return;o.documentElement.attributes.getNamedItem(n).value=i}var l=new XMLSerializer().serializeToString(o);this.documentHelper.customXmlData.set(e,l)}},e.prototype.updateInsertPositionForRtl=function(e){var t=this.documentHelper.selection,i=t.start.currentWidget;if(!((0,a.le)(t)||!t.isEmpty||this.documentHelper.textHelper.getRtlLanguage(e).isRtl||(0,a.le)(i))){var r=0,n=i.getInline(t.start.offset,r,!1,!0),s=n.element,l=i.getOffset(s,0);if(r=n.index,s instanceof o.a3&&this.documentHelper.textHelper.isRTLText(s.text)){var d=l+s.length;if(t.start.offset===d){if(s.previousElement instanceof o.a3){var h=s.previousElement.text;if(this.documentHelper.textHelper.isRTLText(h))return}var c=s.indexInOwner,p=!1,g=i.getInline(t.start.offset+1,0,!1,!0);if(s.previousElement instanceof o.a3){var h=s.previousElement.text;this.documentHelper.textHelper.isRTLText(h)&&this.documentHelper.textHelper.isWordSplitChar(h.charAt(h.length-1))||(p=!0)}if(!p&&(g.element==s||g.element instanceof o.a3&&this.documentHelper.textHelper.isRTLText(g.element.text)&&s!==g.element||g.element instanceof o.a3&&0==g.element.text.trim().length&&(0,a.le)(g.element.nextElement)))return;for(;c+1<i.children.length;){var m=i.children[c+1];if(!(m instanceof o.a3))break;var u=m.text,f=0===u.length||"\xa0"===u.charAt(0)||this.documentHelper.textHelper.isWordSplitChar(u.charAt(0));if(this.documentHelper.textHelper.isRTLText(u)||f){c++;continue}break}if(c!==s.indexInOwner){var y=i.children[c],v=i.getOffset(y,y.length);this.setPositionParagraph(i.paragraph,v,!0),t.editPosition=t.getHierarchicalIndex(i.paragraph,v.toString())}}}}},e.prototype.checkAndShowRestrictPane=function(){var e=this.owner.isReadOnly||"ReadOnly"===this.documentHelper.protectionType&&!this.selection.isSelectionInEditRegion()||"CommentsOnly"===this.documentHelper.protectionType&&!this.selection.isSelectionInEditRegion();if(e){var t=this.documentHelper.restrictEditingPane;this.hasShownRestrictPane||!t||t.isShowRestrictPane||(this.hasShownRestrictPane=!0,t.showHideRestrictPane(!0))}return e},e.prototype.insertText=function(e){!(0,a.le)(e)&&""!==e&&!this.owner.isReadOnly&&("ReadOnly"!==this.documentHelper.protectionType||this.selection.isSelectionInEditRegion())&&("CommentsOnly"!==this.documentHelper.protectionType||!this.owner.isReadOnly)&&
1(this.isInsertingText=!0,this.insertTextInternal(e,!1),this.isInsertingText=!1)},e.prototype.insertTextInternal=function(e,t,i,r){if(e.indexOf("\r")>=0||e.indexOf("\n")>=0){"\r"===e||"\n"===e||"\r\n"===e?this.onEnter():(this.isInsertText=!0,this.pasteContents(e),this.isInsertText=!1);return}if("FormFieldsOnly"===this.documentHelper.protectionType&&this.selection.isInlineFormFillMode()){var l,d=this.selection.currentFormField;if(!d.formFieldData.enabled)return;var h=this.getFieldResultText(d),c=RegExp(this.owner.documentHelper.textHelper.getEnSpaceCharacter(),"gi");h.length>0&&""===h.replace(c,"")&&(h="",this.selection.selectFieldInternal(d));var p=d.formFieldData.maxLength;if(0!==p&&h.length>=p)return}t&&(this.documentHelper.layout.isReplaceAll=!(0,a.le)(r)&&!r);var g=this.documentHelper.owner.selection.currentContentControl,m=!1;!(0,a.le)(g)&&g.contentControlProperties.hasPlaceHolderText&&(m=g.contentControlProperties.hasPlaceHolderText,this.documentHelper.selection.selectContentControlInternal(g),g.contentControlProperties.hasPlaceHolderText=!1);var u=this.documentHelper.selection,f=!0,y=!1;i=this.owner.enableTrackChanges&&(0,a.le)(i)?"Insertion":i;var v=this.checkAndRemoveComments(t);if(this.isListTextSelected(),this.documentHelper.isBookmarkInserted&&!u.isEmpty&&!this.documentHelper.layout.isReplacingAll){var H=u.bookmarks;H.length>0&&this.extendSelectionToBookmarkStart(H)}var C=!1;if(u.isEmpty){var F=u.start.currentWidget.getInline(u.start.offset,0),w=F.element;w instanceof o.aQ&&1===w.bookmarkType&&!(0,a.le)(w.properties)&&w.properties.hasOwnProperty("isAfterParagraphMark")&&w.properties.isAfterParagraphMark&&(u.start.setPositionParagraph(w.line,w.line.getOffset(w,0)),u.end.setPositionInternal(u.start));var I=u.start.isAtParagraphStart,x=u.end.isAtParagraphEnd;if((I||x)&&w&&w instanceof o.h&&(0,a.le)(u.currentContentControl)&&"Block"===w.contentControlWidgetType&&w.reference&&w.paragraph!==w.reference.paragraph&&(this.initComplexHistory("Insert"),C=!0,this.onEnter(),I)){var b=w.paragraph.previousWidget;b instanceof o.ZH&&b.isEmpty()&&u.moveToPreviousParagraph()}if(w instanceof o.aQ&&0===w.bookmarkType){for(;!(0,a.le)(w.nextNode)&&w.nextNode instanceof o.aQ&&0===w.nextNode.bookmarkType;)w=w.nextNode;u.start.setPositionParagraph(w.line,w.line.getOffset(w,w.length)),u.end.setPositionInternal(u.start)}}if(this.documentHelper.isDoubleTap&&s.o_.endsWith(u.text)){var W=u.text.length-s.o_.trimEnd(u.text).length;this.documentHelper.isDoubleTap=!1,u.end.offset-=W}if(this.updateInsertPositionForRtl(e),((0,a.le)(i)||"Insertion"===i)&&(this.initHistory("Insert"),!(0,a.le)(this.editorHistory)&&!(0,a.le)(this.editorHistory.currentBaseHistoryInfo)&&(this.editorHistory.currentBaseHistoryInfo.insertedText=e,"FormFieldsOnly"===this.documentHelper.protectionType))){var P=this.documentHelper.selection.getCurrentFormField();P&&P instanceof o.V8&&P.formFieldData&&P.formFieldData instanceof o.CN&&(this.editorHistory.currentBaseHistoryInfo.fieldBegin=P,this.editorHistory.currentBaseHistoryInfo.dropDownIndex=P.formFieldData.selectedIndex)}var k=this.selection.getParagraphInfo(u.start),R=k.paragraph.paragraphFormat;u.editPosition=u.getHierarchicalIndex(k.paragraph,k.offset.toString());var T=u.start.paragraph.paragraphFormat.bidi;if((u.isEmpty||u.isImageSelected)&&(!this.documentHelper.isListTextSelected||"List"!==u.contextType))!u.isEmpty||this.documentHelper.isListTextSelected||t||(this.documentHelper.isTextInput=!0);else{u.isSkipLayouting=!0,u.skipFormatRetrieval=!0;var S=void 0,B=void 0,L=0,E=0;if(this.owner.enableTrackChanges&&(this.selection.start.isExistBefore(this.selection.end)?(B=this.selection.getParagraphInfo(u.end),S=this.selection.end.clone()):(B=this.selection.getParagraphInfo(u.start),S=this.selection.start.clone()),E=B.paragraph.getLength(),L=B.offset-1===E?B.offset-1:B.offset,this.skipReplace=!0),(f=this.removeSelectedContents(u))&&(this.updateInsertPosition(),y=!0),this.skipReplace=!1,this.removedBookmarkElements.length>0){var O=u.start.clone();u.isForward||(O=u.end.clone()),O.offset+=e.length,this.updateHistoryPosition(O,!1),this.insertRemoveBookMarkElements(!1)}if(!(0,a.le)(S)&&this.owner.searchModule&&this.owner.searchModule.isRepalceTracking)this.owner.searchModule.isRepalceTracking=!1,this.selection.start.setPositionInternal(this.selection.start),this.selection.end.setPositionInternal(S);else if(L>0&&L<=E){var A=B.paragraph.getLength();E!==A&&(L-=E-A),this.setPositionParagraph(B.paragraph,L,!0)}u.skipFormatRetrieval=!1,u.isSkipLayouting=!1}(k=this.selection.getParagraphInfo(u.start)).paragraph.paragraphFormat.copyFormat(R);var N=this.documentHelper.textHelper.containsSpecialCharAlone(e);if(f){if(u.owner.isShiftingEnabled=!0,!y&&((0,a.le)(i)||"Insertion"===i)&&this.updateInsertPosition(),(l=u.start).paragraph.isEmpty()){var M=new o.a3,D=this.copyInsertFormat(l.paragraph.characterFormat,!0);M.characterFormat.copyFormat(D),M.text=e;var V=this.documentHelper.textHelper.getRtlLanguage(e).isRtl||this.selection.characterFormat.bidi;M.characterFormat.bidi=V,D.bidi=V,M.isRightToLeft=V,M.line=l.paragraph.childWidgets[0],M.margin=new o.Zt(0,0,0,0),M.line.children.push(M),this.setCharFormatForCollaborativeEditing(M.characterFormat),this.owner.enableTrackChanges&&this.insertRevision(M,i),("Center"===l.paragraph.paragraphFormat.textAlignment||"Right"===l.paragraph.paragraphFormat.textAlignment||"Justify"===l.paragraph.paragraphFormat.textAlignment&&l.paragraph.paragraphFormat.bidi)&&-1===l.paragraph.paragraphFormat.listFormat.listId&&(l.paragraph.x=l.paragraph.clientX?l.paragraph.clientX:this.owner.viewer.clientActiveArea.x,l.paragraph.clientX=void 0,l.paragraph.hasOwnProperty("absoluteXPosition")&&delete l.paragraph.absoluteXPosition),M instanceof o.a3&&M.text.length>90&&s.o_.splitWordByMaxLength(M,M.line),this.documentHelper.layout.reLayoutParagraph(l.paragraph,0,0)}else{var U=0,F=l.currentWidget.getInline(l.offset,U,T,!t&&!this.isInsertingText),d=F.element;U=F.index,d.isChangeDetected=!0,d instanceof o.a3&&" "!==e&&this.documentHelper.owner.isSpellCheck&&(this.owner.spellCheckerModule.removeErrorsFromCollection({element:d,text:d.text}),t||(d.ignoreOnceItems=[])),d.canTrigger&&d.text.length<=1&&(d.canTrigger=!1);var D=this.copyInsertFormat(d.characterFormat,!0);D.hidden&&(D.hidden=!1);var V=this.documentHelper.textHelper.getRtlLanguage(e).isRtl||this.selection.characterFormat.bidi,z=0,Z=!1,j=!1;if(d instanceof o.a3&&(z=this.documentHelper.textHelper.getRtlLanguage(d.text).id,Z=this.documentHelper.textHelper.getRtlLanguage(d.text).isRtl,j=this.documentHelper.textHelper.containsSpecialCharAlone(e)),(!V&&d.characterFormat.bidi&&this.selection.characterFormat.bidi&&(0!==z||j&&Z)||" "===e&&this.selection.characterFormat.bidi)&&(V=!0),(V||!this.documentHelper.owner.isSpellCheck)&&(D.bidi=V),this.setCharFormatForCollaborativeEditing(D),(!this.documentHelper.owner.isSpellCheck||" "!==e&&" "!==d.text&&!s.o_.endsWith(d.text))&&"\x0e"!==e&&!(d instanceof o.h)&&!(d instanceof o.Xw)&&D.isSameFormat(d.characterFormat)&&d.revisionLength<=1&&this.canInsertRevision(d,i)||""===e.trim()&&!V&&d.characterFormat.bidi||Z&&D.isSameFormat(d.characterFormat)&&N)this.insertTextInline(d,u,e,U,void 0,i,V),this.setCharFormatForCollaborativeEditing(d.characterFormat);else{var _=new o.a3;_.text=e,_.line=d.line,_.isRightToLeft=Z,!(0,a.le)(d)&&d.contentControlProperties?(_.contentControlProperties=d.contentControlProperties,m?_.characterFormat.copyFormat(d.characterFormat):_.characterFormat=this.copyInsertFormat(new n.a(void 0,this.owner),!1)):_.characterFormat.copyFormat(D),this.setCharFormatForCollaborativeEditing(_.characterFormat);var K=!1,X=d.indexInOwner;if(U===d.length){var J=-1;J=X+1,!this.owner.enableTrackChanges||d instanceof o.aQ||(K=this.checkToMapRevisionWithInlineText(d,U,_,V,i))||(K=this.checkToMapRevisionWithNextNode(d.nextNode,_,V,i)),d.line.children.splice(J,0,_),!K&&(this.checkToSplitRevisionInPrevNxt(_),this.owner.enableTrackChanges&&this.insertRevision(_,i))}else if(0===U)!this.owner.enableTrackChanges||(K=this.checkToMapRevisionWithInlineText(d,U,_,V,i))||this.checkToMapRevisionWithPreviousNode(d.previousNode,_,V,i),d.line.children.splice(X,0,_),!K&&(this.checkToSplitRevisionInPrevNxt(_),this.owner.enableTrackChanges&&this.insertRevision(_,i));else if(d instanceof o.a3){var Q=new o.a3;Q.line=d.line,Q.characterFormat.copyFormat(d.characterFormat),!(0,a.le)(d)&&d.contentControlProperties&&(Q.contentControlProperties=d.contentControlProperties),Q.text=d.text.substring(U);for(var q=0;q<d.revisionLength;q++)Q.addRevision(d.getRevision(q));""!==Q.text&&d.line.children.splice(X+1,0,Q),d.text=d.text.slice(0,U),d.isWidthUpdated=!1,d.line.children.splice(X+1,0,_),this.owner.enableTrackChanges||this.selection.isInField||this.updateRevisionForSpittedTextElement(d,Q,_),this.owner.enableTrackChanges?(K=this.checkToMapRevisionWithInlineText(d,U,_,V,i))?this.copyElementRevision(d,Q):(this.updateRevisionForSpittedTextElement(d,Q,_),this.insertRevision(_,i)):this.selection.isInField&&this.copyElementRevision(d,Q),this.owner.isSpellCheck&&this.owner.spellCheckerModule.updateSplittedElementError(d,Q)}_ instanceof o.a3&&_.text.length>90&&s.o_.splitWordByMaxLength(_,_.line),((0,a.le)(i)||"Deletion"!==i||l.paragraph.isLayouted)&&this.documentHelper.layout.reLayoutParagraph(l.paragraph,d.line.indexInOwner,0),d instanceof o.a3&&-1!==d.line.children.indexOf(d)&&""===d.text&&d.line.children.splice(d.line.children.indexOf(d),1)}}!(0,a.le)(g)&&g.contentControlProperties.isTemporary&&this.removeContentControl(),this.documentHelper.layout.allowLayout=!0,this.setPositionParagraph(k.paragraph,k.offset+e.length,!0),((0,a.le)(i)||"Insertion"===i)&&this.updateEndPosition(),(0,a.le)(this.editorHistory)||(0,a.le)(this.editorHistory.currentHistoryInfo)||"ListSelect"!==this.editorHistory.currentHistoryInfo.action||!this.documentHelper.isListTextSelected||(this.editorHistory.updateHistory(),this.editorHistory.updateComplexHistory()),((0,a.le)(i)||"Insertion"===i)&&!this.isFieldOperation&&this.reLayout(u),C&&this.editorHistory&&this.editorHistory.updateComplexHistory(),this.documentHelper.isTextInput=!1}if(this.updateXmlMappedContentControl(),!t&&f&&(" "===e||" "===e||"\v"===e)){var G=!1;if("\v"===e||this.isRemoteAction||(G=this.checkAndConvertList(u," "===e)),!G){if(!(0,a.le)(u.getHyperlinkField()))return;this.checkAndConvertToHyperlink(u,!1)}}this.updateHistoryForComments(v)},e.prototype.extendSelectionToBookmarkStart=function(e){if(this.documentHelper.bookmarks.length>0){var t=this.selection.start;this.selection.end,this.selection.isForward||(t=this.selection.end,this.selection.start);for(var i=void 0,r=0;r<e.length;r++)if(i=this.documentHelper.bookmarks.get(e[r]),this.selection.isElementInSelection(i.reference,!1)&&!this.selection.isElementInSelection(i,!0)){var o=i.line.paragraph,n=this.selection.getParagraphInfo(t);if(o.equals(n.paragraph)){var s=i.line.getOffset(i,i.bookmarkType);i.line===t.currentWidget&&n.offset===s+1&&t.offset--}}}},e.prototype.retrieveFieldResultantText=function(e){var t="";if(1===e.fieldType){var i=e.previousElement;for((0,a.le)(i)&&0===e.indexInOwner&&!(0,a.le)(e.line)&&!(0,a.le)(e.line.previousLine)&&e.line.previousLine.children[e.line.previousLine.children.length-1]instanceof o.a3&&(i=e.line.previousLine.children[e.line.previousLine.children.length-1]);!(0,a.le)(i)&&i instanceof o.a3;)t=i.text+t,i=(0,a.le)(i.previousNode)?void 0:i.previousNode.previousValidNodeForTracking}return t},e.prototype.checkToMapRevisionWithNextNode=function(e,t,i,r){if((0,a.le)(e))return!1;var o=e.nextValidNodeForTracking;return!(0,a.le)(o)&&this.checkToMapRevisionWithInlineText(o,0,t,i,r)},e.prototype.checkToMapRevisionWithPreviousNode=function(e,t,i,r){if((0,a.le)(e))return!1;var o=e.previousValidNodeForTracking;return!(0,a.le)(o)&&this.checkToMapRevisionWithInlineText(o,o.length,t,i,r)},e.prototype.checkToMapRevisionWithInlineText=function(e,t,i,r,o){if(!(0,a.le)(e)){
1if("Deletion"===o&&this.updateLastDeletedRevision(i),e.length===t&&void 0!=e.previousValidNodeForTracking){if(t=(e=e.previousValidNodeForTracking).length,e.revisionLength>0)return this.applyMatchedRevisionInorder(e,i,t,!1,r,o)}else if(0===t&&(e=e.nextValidNodeForTracking,!(0,a.le)(e)&&e.revisionLength>0))return this.applyMatchedRevisionInorder(e,i,t,!0,r,o)}return!1},e.prototype.combineElementRevisions=function(e,t){if(0!==e.revisionLength&&0!==t.revisionLength)for(var i=0;i<e.revisionLength;i++)for(var r=e.getRevision(i),o=0;o<t.revisionLength;o++){var n=t.getRevision(o);if(-1===r.getRange().indexOf(t)&&this.compareTwoRevisions(r,n)){for(var s=n.getRange(!0),a=0;a<s.length;a++){var l=s[a];l.removeRevision(o),l.insertRevisionAt(o,r)}this.owner.revisions.remove(n),this.owner.trackChangesPane.updateCurrentTrackChanges(r)}}},e.prototype.applyMatchedRevisionInorder=function(e,t,i,r,o,n,s){var l;return!(0,a.le)(s)&&(0,a.le)(e)?(l=this.getMatchedRevisionsToCombine(s.getAllRevision(),n)).length>0&&this.mapMatchedRevisions(l,s,t,r):(l=this.getMatchedRevisionsToCombine(e.getAllRevision(),n)).length>0&&this.mapMatchedRevisions(l,e,t,r)},e.prototype.copyElementRevision=function(e,t){if(!this.isTrackingFormField)for(var i=0;i<e.revisionLength;i++){var r=e.getRevision(i);t.insertRevisionAt(0,r),this.owner.trackChangesPane.updateCurrentTrackChanges(r)}},e.prototype.mapMatchedRevisions=function(e,t,i,r){for(var n=0;n<e.length;n++){var s=e[n];if(!this.isRevisionAlreadyIn(i,s))return i.insertRevisionAt(0,s),this.editorHistory&&!(0,a.le)(this.editorHistory.currentBaseHistoryInfo)&&0===this.editorHistory.currentBaseHistoryInfo.markerData.length&&this.editorHistory.currentBaseHistoryInfo.markerData.push(this.getMarkerData(void 0,void 0,s)),i instanceof o.R5&&this.insertRevisionForFootnoteWidget(i,s),this.owner.trackChangesPane.updateCurrentTrackChanges(s),!0}return!1},e.prototype.isRevisionAlreadyIn=function(e,t){if(e.revisionLength>0){for(var i=0;i<e.revisionLength;i++)if(e.revisions[i].revisionID===t.revisionID)return!0}return!1},e.prototype.getMatchedRevisionsToCombine=function(e,t){for(var i=[],r=0;r<e.length;r++)this.isRevisionMatched(e[r],t)&&i.push(e[r]);return i},e.prototype.insertIMEText=function(e,t){if(this.documentHelper.lastComposedText!==e||!t){var i=this.selection.isForward?this.selection.getParagraphInfo(this.selection.start):this.selection.getParagraphInfo(this.selection.end),o=this.selection.getHierarchicalIndex(i.paragraph,i.offset.toString());this.insertText(e),this.documentHelper.lastComposedText=e;var n=this.selection.start;this.setPositionForCurrentIndex(n,o);var s=new r.JK(this.owner);s.setPositionForLineWidget(n.currentWidget,n.offset+e.length),this.owner.enableTrackChanges?(t||this.selection.start.setPositionInternal(this.selection.end),this.selection.end.updatePhysicalPosition(!0)):this.selection.selectPosition(t?n:s,s)}},e.prototype.insertSectionBreak=function(e,t){(0,a.le)(e)&&(e=R.nj.NewPage);var i=this.documentHelper.selection;(0,a.le)(i)||this.owner.isReadOnlyMode||i.start.paragraph.isInHeaderFooter||i.isInShape||(e===R.nj.Continuous?this.initHistory("SectionBreakContinuous"):this.initHistory("SectionBreak"),i.isEmpty||i.selectContent(i.isForward?i.start:i.end,!0),this.documentHelper.owner.isShiftingEnabled=!0,this.updateInsertPosition(),e===R.nj.Continuous?(this.documentHelper.layout.isSectionBreakCont=!0,this.insertSection(i,!0,void 0,!0,void 0,t)):this.insertSection(i,!0,void 0,void 0,!0,t),this.updateEndPosition(),this.reLayout(i,!0),this.documentHelper.layout.layoutWholeDocument(!0),this.documentHelper.layout.isSectionBreakCont=!1)},e.prototype.removeRevision=function(e){var t=this.selection.start.currentWidget.getInline(this.selection.start.offset+1,0),i=t.element;if(t.element.revisionLength>0){for(var r=0;r<i.revisionLength;r++)if(i.getRevision(r).revisionType===e.revisionType)for(var o=i.getRevision(r),n=o.getRange(!0),s=n.indexOf(i),a=s;s<n.length;s++)n[a].removeRevision(r),this.owner.trackChangesPane.updateCurrentTrackChanges(o)}},e.prototype.clearElementRevision=function(e){if(!(0,a.le)(e)){for(var t=0;t<e.getRange().length;t++)if(e.getRange()[t]instanceof o.nR){var i=e.getRange()[t];i.removeRevision(i.revisionLength-1),this.owner.trackChangesPane.updateCurrentTrackChanges(e)}}}
1,e.prototype.insertRevision=function(e,t,i,r,n,l,d){if(!(this.isRemoteAction&&(0,a.le)(this.revisionData))||this.documentHelper.owner.parser.isPaste){if((0,a.le)(n)&&!(0,a.le)(this.revisionData)&&this.revisionData.length>0){var h,c=this.revisionData[0];i=c.author,r=c.date}(0,a.le)(d)||(h=d),i=(0,a.le)(i)?this.owner.currentUser?this.owner.currentUser:"Guest user":i;var p=(0,a.le)(r)?s.o_.getUtcDate():r,g=new B.k(this.owner,i,p,this.getOwnerNodeForRevision(e));return g.revisionType=t,this.owner.documentEditorSettings.revisionSettings&&this.owner.documentEditorSettings.revisionSettings.customData&&(g.customData=this.owner.documentEditorSettings.revisionSettings.customData),this.owner.enableCollaborativeEditing&&this.isRemoteAction&&!(0,a.le)(h)&&""!=h?g.revisionID=h:g.revisionID=Math.random().toString(36).substring(2,15)+Math.random().toString(36).substring(2,15),!(0,a.le)(n)&&n.length>0&&this.clearAndUpdateRevisions(n,g,n.indexOf(e)),(0,a.le)(e)||-1!==e.getAllRevision().indexOf(g)||e.addRevision(g),this.isRemoteAction&&this.documentHelper.owner.parser.isPaste?this.remotePasteRevision.push(g):g.getRange().length>0&&!this.documentHelper.owner.parser.isPaste&&this.updateRevisionCollection(g),(0,a.le)(e)||(e instanceof o.R5&&this.insertRevisionForFootnoteWidget(e,g),this.owner.enableCollaborativeEditing&&!(0,a.le)(this.editorHistory)&&this.editorHistory.currentBaseHistoryInfo&&!l&&this.editorHistory.currentBaseHistoryInfo.markerData.splice(0,0,this.getMarkerData(e,void 0,g))),g}},e.prototype.getOwnerNodeForRevision=function(e){return e instanceof o.nR?e.paragraph.getSplitWidgets()[0]:e},e.prototype.insertRevisionForFootnoteWidget=function(e,t){var i=e.bodyWidget.childWidgets;this.skipFootNoteDeleteTracking=!0,this.footnoteRevision=t;for(var r=0;r<i.length;r++)this.insertRevisionForBlock(i[r],t.revisionType,!1,t,void 0,void 0,void 0,!0);this.footnoteRevision=void 0,this.skipFootNoteDeleteTracking=!1},e.prototype.clearAndUpdateRevisions=function(e,t,i){for(var r=i;r<e.length;r++)if(e[r]instanceof o.nR||e[r]instanceof n.a){var s=e[r];if(s instanceof o.a3&&""===s.text){s.removeRevision(s.revisionLength-1);continue}for(var a=0;a<s.revisionLength;a++){var l=s.getRevision(a);this.compareTwoRevisions(l,t)&&(s.removeRevision(a),s.insertRevisionAt(a,t))}}this.owner.trackChangesPane.updateCurrentTrackChanges(t)},e.prototype.splitRevisionByElement=function(e,t){if(e.revisionLength>0){var i=t.getRange(!0);return this.owner.trackChangesPane.updateCurrentTrackChanges(t),i}},e.prototype.updateRevisionForSpittedTextElement=function(e,t,i){for(var r=0;r<e.revisionLength;r++){var n=e.getRevision(r);if(-1!==t.getAllRevision().indexOf(n)){var s=t.paragraph.getRevisionRange(n);if(t&&t instanceof o.a3&&""===t.text)continue;this.insertRevision(t,n.revisionType,n.author,n.date,s,!0)}}this.splitRevisionsAndViewBasedOnUntrackedContent(i)},e.prototype.getRevision=function(e){for(var t=0;t<this.owner.documentHelper.revisionsInternal.length;t++){var i=this.owner.documentHelper.revisionsInternal.keys[t];if(i===e)return this.owner.documentHelper.revisionsInternal.get(i)}},e.prototype.isRevisionMatched=function(e,t){var i=this.owner.currentUser?this.owner.currentUser:"Guest user";if(e instanceof B.k){if(((0,a.le)(t)||t===e.revisionType)&&e.author===i)return!0}else if(e.revisionLength>0)for(var r=0;r<e.revisionLength;r++){var o=e.revisions[r];if(((0,a.le)(t)||t===o.revisionType)&&o.author===i)return!0}return!1},e.prototype.compareElementRevision=function(e,t){if(0===e.revisionLength||0===t.revisionLength)return!1;for(var i=0;i<e.revisionLength;i++)for(var r=e.revisions[i],o=0;o<t.revisionLength;o++)if(this.compareTwoRevisions(r,t.getRevision(o)))return!0;return!1},e.prototype.compareTwoRevisions=function(e,t){return e.revisionType===t.revisionType&&e.author===t.author},e.prototype.canInsertRevision=function(e,t){var i=(0,a.le)(t)?"Insertion":t;
1return"Deletion"!==i&&(this.owner.enableTrackChanges?this.isRevisionMatched(e,i):!(e.revisionLength>0))},e.prototype.insertRevisionAtEnd=function(e,t,i){return!(t instanceof o.aQ)&&!(t instanceof o.Xw)&&!(t instanceof o.Cw)&&!(t instanceof o.jn)&&!(t instanceof o.h)&&(e=e.previousValidNodeForTracking,!(0,a.le)(e)&&this.insertRevisionAtPosition(e,t,!0,i))},e.prototype.insertRevisionAtPosition=function(e,t,i,r){var o=t.revisionLength,n=this.checkToMapRevisionWithInlineText(e,i?e.length:0,t,!1,r);return i?n||t.revisionLength!==o||(n=this.checkToMapRevisionWithNextNode(e.nextNode,t,!1,r)):n||t.revisionLength!==o||(n=this.checkToMapRevisionWithPreviousNode(e.previousNode,t,!1,r)),n},e.prototype.insertRevisionAtBegining=function(e,t,i){return!(t instanceof o.aQ)&&!(t instanceof o.Xw)&&!(t instanceof o.Cw)&&!(t instanceof o.jn)&&!(t instanceof o.h)&&(e=e.nextValidNodeForTracking,!(0,a.le)(e)&&this.insertRevisionAtPosition(e,t,!1,i))},e.prototype.splitRevisionForSpittedElement=function(e,t){for(var i=e.revisionLength-1;i>=0;i--){var r=e.getRevision(i),o=this.splitRevisionByElement(e,r);this.insertRevision(t,r.revisionType,r.author,r.date,o)}},e.prototype.combineElementRevisionToPrevNxt=function(e){e.revisionLength>0&&e.nextNode instanceof o.nR&&e.nextNode.revisionLength>0&&this.combineElementRevision(e.getAllRevision(),e.nextNode.getAllRevision())},e.prototype.combineElementRevision=function(e,t,i){for(var r=0;r<e.length;r++)for(var o=0;o<t.length;o++){var n=e[r],s=t[o];if(n===s)break;if(this.compareTwoRevisions(n,s)){for(var l=s.getRange(!0).length,d=0;d<l;d++){var h=s.getRange(!0)[0];h.removeRevision(h.getAllRevision().indexOf(s)),this.owner.trackChangesPane.updateCurrentTrackChanges(s);var c=void 0;(0,a.le)(n)||(c=this.owner.trackChangesPane.changes.get(n)),(0,a.le)(c)&&n.getRange().length>0&&this.updateRevisionCollection(n),h.addRevision(n),this.owner.trackChangesPane.updateCurrentTrackChanges(n)}0===s.getRange(!0).length&&this.owner.revisions.remove(s)}}},e.prototype.insertRevisionForBlock=function(e,t,i,r,o,n,s,l){if(0!==e.childWidgets.length&&(this.owner.enableTrackChanges||i)){if("Deletion"!==t||this.editorHistory.isUndoing||i){for(var d=0;d<e.childWidgets.length;d++)for(var h=e.childWidgets[d].children,c=0;c<h.length;c++)if(this.owner.enableTrackChanges){if(this.updateRevisions(h[c]),0===c){var p=h[c].revisionLength;r=this.insertRevision(h[c],t),h[d].revisionLength>p?r=h[d].getRevision(h[c].revisionLength-1):h[c].addRevision(r)}else h[c].addRevision(r)}else i&&h[c].revisionLength>0&&this.updateRevisions(h[c]);!l&&(this.owner.enableTrackChanges?this.insertRevision(e.characterFormat,t):i&&e.characterFormat.revisionLength>0&&this.updateRevisions(e.characterFormat))}else{var g=this.selection.editPosition,m=this.selection.start.clone(),u=this.selection.end.clone();this.documentHelper.layout.clearListElementBox(e);var f=e==this.getLastParaForBodywidgetCollection(e),y=this.selection.getNextParagraphBlock(e),v=this.selection.getParagraphInfo(this.selection.start),H=this.selection.getParagraphInfo(this.selection.end),C=this.selection.getHierarchicalIndex(v.paragraph,v.offset.toString()),F=this.selection.getHierarchicalIndex(H.paragraph,H.offset.toString()),w=!1,I=!1;f&&(!this.editorHistory||!this.editorHistory.currentBaseHistoryInfo||"RemoveRowTrack"!==this.editorHistory.currentBaseHistoryInfo.action)||(0,a.le)(y)&&e.isEmpty()||n||(I=!0),I&&((0,a.le)(y)||y.isInsideTable||e.bodyWidget.sectionIndex===y.bodyWidget.sectionIndex||this.addRemovedNodes(e.bodyWidget),s||(l||this.isPasteOverWriteCells||this.addRemovedNodes(e.clone()),w=this.handleDeleteParaMark(e)));for(var d=e.childWidgets.length-1;d>-1;d--){var x=e.childWidgets[d];this.removeContent(x,0,this.documentHelper.selection.getLineLength(x),void 0,!!s||!n&&!f)}if(I&&(s&&(w=this.handleDeleteParaMark(e)),w&&(e.isEmpty()?this.removeBlock(e):(this.editorHistory&&!(0,a.le)(this.editorHistory.currentBaseHistoryInfo)&&"Delete"===this.editorHistory.currentBaseHistoryInfo.action&&(g=this.selection.getHierarchicalIndex(e,this.documentHelper.selection.getLineLength(e.lastChild).toString())),this.deleteParagraphMark(e,this.selection,0,!1,!0,!0)))),this.selection.editPosition=g,this.selection.start.setPositionInternal(m),this.selection.end.setPositionInternal(u),this.removeEmptyLine(e),!o&&!(0,a.le)(e.containerWidget)){if(this.documentHelper.layout.reLayoutParagraph(e,0,0),-1===this.selection.start.currentWidget.indexInOwner&&-1!==v.paragraph.indexInOwner){var b=this.selection.getTextPosBasedOnLogicalIndex(C);this.selection.start.setPositionInternal(b)}if(-1===this.selection.end.currentWidget.indexInOwner&&-1!==H.paragraph.indexInOwner){var W=this.selection.getTextPosBasedOnLogicalIndex(F);this.selection.end.setPositionInternal(W)}}}}},e.prototype.checkToSplitRevisionInPrevNxt=function(e){var t=e.previousNode,i=e.nextNode,r=!1;t&&i&&(t=t.previousValidNodeForTracking,i=i.nextValidNodeForTracking,t&&e&&!this.compareElementRevision(t,e)&&i&&this.compareElementRevision(t,i)&&!(e instanceof o.aQ||e instanceof o.Cw||e instanceof o.jn)&&(this.updateRevisionForSpittedTextElement(t,i,e),r=!0)),r||this.splitRevisionsAndViewBasedOnUntrackedContent(e)},e.prototype.getLastParaForBodywidgetCollection=function(e){var t=e.containerWidget;if(t.containerWidget instanceof o.tf||t instanceof o.nb){for(var i=t.getSplitWidgets(),r=i.length;r>0&&0===i[r-1].childWidgets.length;)r--;return i[r-1].lastChild}if(t instanceof o.yw||t instanceof o.NB)return t.childWidgets[t.childWidgets.length-1];var n=this.documentHelper.pages[this.documentHelper.pages.length-1],s=n.bodyWidgets[n.bodyWidgets.length-1],l=s.childWidgets[s.childWidgets.length-1];return(0,a.le)(l)?(this.documentHelper.removeEmptyPages(),this.getLastParaForBodywidgetCollection(e)):l},e.prototype.updatePasteRevision=function(){for(var e=0;e<this.remotePasteRevision.length;e++)0>this.owner.revisions.changes.indexOf(this.remotePasteRevision[e])?this.updateRevisionCollection(this.remotePasteRevision[e]):this.owner.trackChangesPane.updateCurrentTrackChanges(this.remotePasteRevision[e]);this.remotePasteRevision=[]},e.prototype.updateRevisionCollection=function(e){if(!(this.owner.revisions.changes.indexOf(e)>=0)){this.documentHelper.revisionsInternal.containsKey(e.revisionID)||this.documentHelper.revisionsInternal.add(e.revisionID,e);var t=e.getRange(!0)[0],i=this.getPositionFromRange(t),r=!1,n=this.owner.revisions.changes,s=n.length;if(n.length>0&&i){for(var l=0,d=n.length-1;l<=d;){var h=Math.floor((l+d)/2),c=n[h].getRange(!1)[0];c instanceof o.nR&&!(0,a.le)(c.line)&&c.line.paragraph.bodyWidget&&c instanceof o.T_&&c.paragraph.containerWidget.footNoteReference.revisionLength>0&&(c=c.paragraph.containerWidget.footNoteReference);var p=this.getPositionFromRange(c);if(this.footnoteRevision===n[h]){var g=n.indexOf(this.footnoteRevision);this.owner.revisions.insertRevisionAt(g+1,e),r=!0;break}if((0,a.le)(p)){l=h+1;continue}i.isExistBefore(p)?(d=h-1,s=h):l=h+1}r||(this.owner.revisions.insertRevisionAt(s,e),r=!0)}r||this.owner.revisions.addRevision(e),this.documentHelper.updateAuthorIdentity()}},e.prototype.getPositionFromRange=function(e){if(e instanceof o.nR)return this.selection.getElementPosition(e,!1,!1).startPosition;if(e instanceof n.a){var t=e.ownerBase;if(t.lastChild){var i=t.getLength()+1,s=new r.JK(this.owner);return s.setPositionParagraph(t.lastChild,i,!1),s}}else if(e instanceof d.J){var a=this.getFirstCellFromRow(e.ownerBase),l=this.selection.getFirstParagraph(a),s=new r.JK(this.owner);return s.setPositionParagraph(l.firstChild,0,!1),s}return null},e.prototype.getFirstCellFromRow=function(e){var t=e.childWidgets[0];if(0===t.childWidgets.length){for(var i=1;i<e.childWidgets.length;i++)if(e.childWidgets[i].childWidgets.length>0){t=e.childWidgets[i];break}}return t},e.prototype.insertSection=function(e,t,i,r,n,s){var l,d,h,c=this.selection.start.paragraph;if(r&&!i&&!c.isInsideTable&&0===e.start.offset&&e.start.currentWidget===c.firstChild&&!(0,a.le)(c.previousRenderedWidget)&&c.previousRenderedWidget instanceof o.ZH&&c.previousRenderedWidget.isEndsWithPageBreak){this.selection.start.paragraph.bodyWidget.sectionFormat.breakCode="NoBreak",this.selection.start.paragraph.index=0,this.updateNextBlocksIndex(this.selection.start.paragraph,!0),this.updateSectionIndex(this.selection.start.paragraph.bodyWidget.sectionFormat,this.selection.start.paragraph.bodyWidget,!0),this.selection.moveToNextParagraph(),this.editorHistory.currentBaseHistoryInfo.insertPosition=void 0,this.updateInsertPosition();return}if(l=(0,a.le)(s)?this.selection.start.paragraph.bodyWidget.sectionFormat.cloneFormat():s,e.start.paragraph.isInsideTable)d=this.splitTableBasedonBreak(e,!0);else{var p=this.selection.getParagraphInfo(e.start),g=this.selection.getHierarchicalIndex(p.paragraph,p.offset.toString());i||this.splitParagraphInternal(e,e.start.paragraph,e.start.currentWidget,e.start.offset,e.start.paragraph.characterFormat),this.setPositionForCurrentIndex(e.start,g),d=e.start.paragraph.getSplitWidgets().pop(),i&&void 0!==d.previousRenderedWidget&&(d=d.previousRenderedWidget)}h=this.splitBodyWidget(d.bodyWidget,l,d,r,n).firstChild;var m=d.previousWidget;return d instanceof o.ZH&&d.isEmpty()&&m instanceof o.ZH&&(d.isSectionBreak=!0,this.documentHelper.layout.reLayoutParagraph(d,0,0)),h instanceof o.dm&&h.updateRowIndex(0),this.documentHelper.layout.layoutBodyWidgetCollection(h.index,h.containerWidget,h,!1),h instanceof o.dm&&(h=this.documentHelper.getFirstParagraphInFirstCell(h)),t&&e.selectParagraphInternal(h,!0),h},e.prototype.splitBodyWidget=function(e,t,i,r,o){var n=!0,s=this.documentHelper.layout.moveBlocksToNextPage(i,!0,void 0,r);if((this.editorHistory.isUndoing||this.editorHistory.isRedoing&&!(0,a.le)(t.ownerBase))&&(i.bodyWidget.sectionFormat=t),void 0===s.page)s.page=e.page,e.page.bodyWidgets.splice(e.page.bodyWidgets.indexOf(e)+1,0,s);else if(e.page.bodyWidgets.length>1&&void 0!==s.page&&!this.editorHistory.isUndoing){for(var d=s;!(0,a.le)(e.nextRenderedWidget)&&s!==e.nextRenderedWidget;){var h=e.nextRenderedWidget.page.bodyWidgets.indexOf(e.nextRenderedWidget);s.page.bodyWidgets.push(e.nextRenderedWidget),e.nextRenderedWidget.page.bodyWidgets.splice(h,1)}for(;!(0,a.le)(s.nextRenderedWidget)&&s!==e.nextRenderedWidget;)s.nextRenderedWidget.page=s.page,s=s.nextRenderedWidget;(s=d).sectionFormat=new l.Z(s),t.numberOfColumns>1&&(this.viewer.owner.parser.parseSectionFormat(0,e.sectionFormat,s.sectionFormat,!0),n=!1),s.sectionFormat.breakCode="NewPage"}r&&(t.numberOfColumns>1&&n?(s.sectionFormat=t,this.viewer.owner.parser.parseSectionFormat(0,e.sectionFormat,s.sectionFormat,!0)):this.isPaste&&n?s.sectionFormat=t:(s.sectionFormat=new l.Z(s),!(t.numberOfColumns>1)&&((0,a.le)(e.page)||(0,a.le)(e.page.nextPage)||this.documentHelper.getPageWidth(e.page)===this.documentHelper.getPageWidth(e.page.nextPage))||this.viewer.owner.parser.parseSectionFormat(0,e.sectionFormat,s.sectionFormat,!0)),s.sectionFormat.breakCode="NoBreak"),o&&(t.numberOfColumns>1&&n?(s.sectionFormat=t,this.viewer.owner.parser.parseSectionFormat(0,e.sectionFormat,s.sectionFormat,!0)):this.isPaste&&n?s.sectionFormat=t:(s.sectionFormat=new l.Z(s),this.viewer.owner.parser.parseSectionFormat(0,e.sectionFormat,s.sectionFormat,!0)),s.sectionFormat.breakCode="NewPage"),this.updateSectionIndex(s.sectionFormat,s,!0),s.sectionFormat.numberOfColumns>1&&this.updateColumnIndex(s,!1),this.editorHistory&&!this.editorHistory.isUndoing&&this.insertRemoveHeaderFooter(s.sectionIndex,!0);var c=0;return s.firstChild&&s.firstChild===i.nextSplitWidget&&(c=i.index),this.updateBlockIndex(c,s.firstChild),this.owner.viewer.updateClientArea(s,s.page),s},e.prototype.insertRemoveHeaderFooter=function(e,t){this.documentHelper.headersFooters[e]?this.documentHelper.headersFooters.splice(e,0,{}):this.documentHelper.headersFooters[e]={}},e.prototype.updateBlockIndex=function(e,t){var i,r=t.bodyWidget.sectionIndex;do{i=t.getSplitWidgets();for(var o=0;o<i.length;o++)i[o].index=e;e++,t=i.pop().nextRenderedWidget}while(!(0,a.le)(t)&&t.bodyWidget.sectionIndex===r)},e.prototype.updateSectionIndex=function(e,t,i){var r=t.sectionIndex,o=t;do o.index===r&&e&&(o.sectionFormat=e),i?o.index++:o.index--,o=o.nextRenderedWidget;while(o)},e.prototype.updateColumnIndex=function(e,t){var i=e;do{if(!t&&0===i.columnIndex||(t?i.columnIndex++:i.columnIndex--,!(0,a.le)(i.nextRenderedWidget)&&i.sectionIndex!==i.nextRenderedWidget.sectionIndex))break;i=i.nextRenderedWidget}while(i)},e.prototype.checkAndConvertList=function(e,t){var i=e.paragraphFormat.getList();if(!(0,a.le)(i)||e.start.paragraph.containerWidget instanceof o.tf)return!1;var r=!1,n=!1,l=0,d=e.start.currentWidget.getInline(e.start.offset-1,l),h=d.element;if(l=d.index,!(h instanceof o.a3))return!1;for(var c=h,p=c.text.substring(0,l),g=0,m=0;!(0,a.le)(c.previousNode);){if(c.previousNode instanceof o.a3&&(" "===c.previousNode.text||0===c.previousNode.text.trim().length)){" "===c.previousNode.text?g+=36:m=2.5*c.previousNode.text.length,c=c.previousNode;continue}return!1}c=h;var u=0,f=p.lastIndexOf(" ");for(u=f>=0?f+1:p.lastIndexOf(" ")+1;c.previousNode instanceof o.a3&&0===u;){var y=(c=c.previousNode).text;u=(f=y.lastIndexOf(" "))>=0?f+1:y.lastIndexOf(" ")+1,p=(p=c.text+p).substring(u)}var H=(p=s.o_.trimStart(p)).substring(1,2),C=void 0,F=this.getListLevelPattern(p.substring(0,1));if("None"!==F&&this.checkNumberFormat(H,"Bullet"===F,p)?(C=this.checkNextLevelAutoList(p),r
1=!0):this.checkLeadingZero(p)?(n=!0,r=!0):(C=this.checkNextLevelAutoList(p),(0,a.le)(C)||(r=!0)),!r||"Bullet"!==F||"- "!==h.text||(0,a.le)(h.paragraph.previousWidget)||h.paragraph.previousWidget.firstChild.children[0]instanceof o.no||(r=!1),r){this.initComplexHistory("AutoList");var w=h.paragraph;e.start.setPositionParagraph(w.childWidgets[0],w.childWidgets[0].getOffset(h,l+1)),e.end.setPositionParagraph(w.childWidgets[0],0),this.initHistory("Delete"),this.deleteSelectedContents(e,!1),this.reLayout(e,!1),H=n?"%1"+p.substring(p.length-1,p.length):"%1"+H;var I=p.substring(p.length-3,p.length-1);F=n?this.getListLevelPattern(I):F;var x=new v.q(void 0);x.listLevelPattern=F,"Bullet"===F?"*"===p?(x.numberFormat=String.fromCharCode(61623),x.characterFormat.fontFamily="Symbol"):"-"===p&&(x.numberFormat="-"):x.numberFormat=H,x.followCharacter=t?"Tab":"Space";var b=e.paragraphFormat.leftIndent;0!==g||0!==m?x.paragraphFormat.leftIndent=b+18+g+m:l>2?x.paragraphFormat.leftIndent=b+(l-2)*2.5+18:b>0?x.paragraphFormat.leftIndent=b+18:x.paragraphFormat.leftIndent=36,x.paragraphFormat.firstLineIndent=-18,(n||"0"!==p.substring(0,1))&&"00"!==I?x.startAt=1:x.startAt=0,(0,a.le)(C)?this.autoConvertList(e,x):e.paragraphFormat.setList(C),this.editorHistory&&!(0,a.le)(this.editorHistory.currentHistoryInfo)?this.editorHistory.updateComplexHistory():this.reLayout(e)}return r},e.prototype.checkNextLevelAutoList=function(e){for(var t=this.documentHelper.selection,i=void 0,r=!1,n=t.start.paragraph,s=t.getPreviousParagraphBlock(n);!(0,a.le)(s)&&s instanceof o.ZH;){if(s.paragraphFormat.listFormat&&-1!==s.paragraphFormat.listFormat.listId){var l=s.paragraphFormat.listFormat.listLevelNumber;if(r=this.isConvertList(e,s)){this.listLevelNumber=l,this.isAutoList=!0;break}if("*"===e||"-"===e){this.isAutoList=!0,r=!0;break}}s=t.getPreviousParagraphBlock(s,!0)}return r&&(i=this.documentHelper.getListById(s.paragraphFormat.listFormat.listId)),i},e.prototype.isConvertList=function(e,t){var i,r=!1,o=this.documentHelper.layout.getListNumber(t,!0),n=o.substring(0,o.length-1),s=e.substring(0,e.length-1);if(o.substring(o.length-1)!==e.substring(e.length-1))r=!1;else if(s.match(/^[0-9]+$/)&&n.match(/^[0-9]+$/))i=parseInt(s,10),(parseInt(n,10)===i||parseInt(n,10)+1===i||parseInt(n,10)+2===i)&&(r=!0);else if(s.match(/^[a-zA-Z]+$/)&&n.match(/^[a-zA-Z]+$/)){if(n.charCodeAt(0)===e.charCodeAt(0)||n.charCodeAt(0)+1===e.charCodeAt(0)||n.charCodeAt(0)+2===e.charCodeAt(0))r=!0;else if(s.match(/^[MDCLXVImdclxvi]+$/)&&n.match(/^[MDCLXVImdclxvi]+$/)){var a=this.getNumber(n.toUpperCase()),l=this.getNumber(s.toUpperCase());(a===l||a+1===l||a+2===l)&&(r=!0)}}return r},e.prototype.getNumber=function(e){for(var t={M:1e3,D:500,C:100,L:50,X:10,V:5,I:1},i=e.split(""),r=0,o=0;o<i.length;o++){var n=t[i[o]];n<t[i[o+1]]?r-=n:r+=n}return r},e.prototype.getListLevelPattern=function(e){switch(e){case"0":case"1":return"Arabic";case"I":return"UpRoman";case"i":return"LowRoman";case"A":return"UpLetter";case"a":return"LowLetter";case"*":case"-":return"Bullet";case"00":case"01":return"LeadingZero";default:return"None"}},e.prototype.autoConvertList=function(e,t){e.start,e.isForward||e.end;var i=new f.f;this.documentHelper.lists.length>0?i.listId=this.documentHelper.lists[this.documentHelper.lists.length-1].listId+1:i.listId=0;var r=new y.S,o=this.documentHelper;o.abstractLists.length>0?r.abstractListId=o.abstractLists[o.abstractLists.length-1].abstractListId+1:r.abstractListId=0,i.abstractListId=r.abstractListId,i.abstractList=r,i.nsid=r.nsid=s.o_.generateUniqueId(o.lists),o.abstractLists.push(r),r.levels.push(t),t.ownerBase=r,e.paragraphFormat.setList(i),e.paragraphFormat.listLevelNumber=0},e.prototype.checkNumberFormat=function(e,t,i){if(t)return""===e;var r=i.indexOf(e);return("."===e||")"===e||">"===e||"-"===e)&&""===i.substring(r,i.length-1)},e.prototype.checkLeadingZero=function(e){for(var t,i=!1,r=0;r<=e.length-1;r++){if("0"===e.charAt(r)){i=!0;continue}t=r;break}var o=void 0;return o="1"===e.charAt(t)?e.charAt(t+1):e.charAt(t),i&&this.checkNumberFormat(o,!1,e)},e.prototype.getPageFromBlockWidget=function(e){var t=void 0;return e.containerWidget instanceof o.VB?t=e.containerWidget.page:e.containerWidget instanceof o.NB?t=e.containerWidget.page:e.containerWidget instanceof o.nb&&(t=e.containerWidget.bodyWidget.page),t}
1,e.prototype.insertTextInline=function(e,t,i,r,n,l,d){if(e instanceof o.a3){if(e.text=s.o_.insert(e.text,r,i),e.isWidthUpdated=!1,this.owner.enableTrackChanges){var h=e.getRevision(0);(0,a.le)(this.editorHistory)||(0,a.le)(this.editorHistory.currentBaseHistoryInfo)||this.editorHistory.currentBaseHistoryInfo.markerData.push(this.getMarkerData(void 0,void 0,h)),this.owner.trackChangesPane.updateCurrentTrackChanges(h)}var c=e.line.paragraph,p=c.childWidgets.indexOf(e.line),g=e.line.children.indexOf(e);e instanceof o.a3&&e.text.length>90&&s.o_.splitWordByMaxLength(e,e.line),((0,a.le)(n)||!n)&&this.documentHelper.layout.reLayoutParagraph(c,p,g,e.line.paragraph.bidi)}else e instanceof o.XY?this.insertImageText(e,t,i,r):e instanceof o.V8?0===e.fieldType?(this.insertFieldBeginText(e,t,i,r),!(0,a.le)(l)&&this.canInsertRevision(e,l)&&this.checkToMapRevisionWithInlineText(e,r,e.nextElement,d,l)):2===e.fieldType?this.insertFieldSeparatorText(e,t,i,r):this.insertFieldEndText(e,t,i,r):(e instanceof o.aQ||e instanceof o.Cw||e instanceof o.jn)&&this.insertBookMarkText(e,i)},e.prototype.insertFieldBeginText=function(e,t,i,r){var n=new o.a3;n.text=i;var s=e.line.paragraph.childWidgets.indexOf(e.line),a=e.line.children.indexOf(e);this.owner.enableCollaborativeEditing&&this.isRemoteAction&&a++,n.characterFormat.copyFormat(e.characterFormat),e.line.children.splice(a,0,n),n.line=e.line,this.documentHelper.layout.reLayoutParagraph(e.line.paragraph,s,a)},e.prototype.insertBookMarkText=function(e,t){var i=new o.a3;i.text=t;var r=e.line.paragraph.childWidgets.indexOf(e.line),n=e.line.children.indexOf(e);i.characterFormat.copyFormat(e.characterFormat),e instanceof o.jn?e.line.children.splice(n,0,i):e.line.children.splice(n+1,0,i),i.line=e.line,this.documentHelper.layout.reLayoutParagraph(e.line.paragraph,r,n)},e.prototype.insertFieldSeparatorText=function(e,t,i,r){var n=t.getPreviousTextInline(e),s=t.getNextTextInline(e),l=new o.a3;l.text=i;var d=e.line.children.indexOf(e);if(r===e.length&&d++,(0,a.le)(n)&&(0,a.le)(s))l.characterFormat.copyFormat(e.line.paragraph.characterFormat);else if((0,a.le)(n))l.characterFormat.copyFormat(s.characterFormat);else if(this.owner.enableCollaborativeEditing&&this.isRemoteAction){var h=this.getCharacterFormat(this.selection);l.characterFormat.copyFormat(h)}else l.characterFormat.copyFormat(n.characterFormat);e.line.children.splice(d,0,l),l.line=e.line;var c=e.line.paragraph.childWidgets.indexOf(e.line);this.documentHelper.layout.reLayoutParagraph(e.line.paragraph,c,d)},e.prototype.insertFieldEndText=function(e,t,i,r){var n=new o.a3;n.text=i;var s=e.line.children.indexOf(e);n.characterFormat.copyFormat(e.characterFormat),t.isInlineFormFillMode()&&0==r?e.line.children.splice(s,0,n):e.line.children.splice(s+1,0,n),n.line=e.line;var a=e.line.paragraph.childWidgets.indexOf(e.line);if(this.owner.enableTrackChanges){var l=this.documentHelper.textHelper.getRtlLanguage(i).isRtl,d="Insertion",h=this.checkToMapRevisionWithInlineText(e,r,n,l,d);h||0!==n.revisionLength||(h=this.checkToMapRevisionWithNextNode(e.nextNode,n,l,d))}this.documentHelper.layout.reLayoutParagraph(e.line.paragraph,a,s)},e.prototype.insertImageText=function(e,t,i,r){var n=t.getPreviousTextInline(e),s=t.getNextTextInline(e),l=e.line,d=new o.a3,h=l.paragraph,c=h.childWidgets.indexOf(l);d.text=i;var p=l.children.indexOf(e);r===e.length&&p++,(0,a.le)(n)&&(0,a.le)(s)?d.characterFormat.copyFormat(h.characterFormat):(0,a.le)(n)?d.characterFormat.copyFormat(s.characterFormat):d.characterFormat.copyFormat(n.characterFormat),l.children.splice(p,0,d),d.line=l,this.documentHelper.layout.reLayoutParagraph(h,c,p)},e.prototype.isListTextSelected=function(){this.documentHelper.isListTextSelected&&(this.initComplexHistory("ListSelect"),this.documentHelper.selection.start.paragraph.paragraphFormat.listFormat&&-1!==this.documentHelper.selection.start.paragraph.paragraphFormat.listFormat.listId&&this.onApplyList(void 0))},e.prototype.checkAndConvertToHyperlink=function(e,t,i){if(t)n=(s=i.lastChild.children[i.lastChild.children.length-1]).text;else{var n,s,l=0,d=e.start.currentWidget.getInline(e.start.offset-1,l),h=d.element;if(l=d.index,!(h instanceof o.a3))return;n=(s=h).text.substring(0,l)}var c=s,p=0,g=n.lastIndexOf(" ");for(p=g>=0?g+1:n.lastIndexOf(" ")+1;0===p;){var m=s.previousElement;if((0,a.le)(m)){var u=s.line.previousLine;u&&u.children.length>0&&(m=u.children[u.children.length-1])}if(!(m instanceof o.a3))break;var f=(s=m).text;p=(g=f.lastIndexOf(" "))>=0?g+1:f.lastIndexOf(" ")+1,n=s.text+n}var y=(n=n.substring(p)).toLowerCase(),v=!1;if("file:///"===y.substring(0,8)||"http://"===y.substring(0,7)&&y.length>7||"https://"===y.substring(0,8)&&y.length>8||"www."===y.substring(0,4)&&y.length>4||"\\"===y.substring(0,3)&&y.length>3||"mailto:"===y.substring(0,7)&&y.length>7)v=!0,"www."===y.substring(0,4)&&y.length>4&&(n="http://"+n);else{var H=n.indexOf("@"),C=n.lastIndexOf(".");H>0&&H<C&&C<n.length-1&&(v=!0,n="mailto:"+n)}if(v){var F=new r.JK(this.documentHelper.owner);F.setPositionParagraph(s.line,s.line.getOffset(s,p));var w=new r.JK(this.documentHelper.owner);if(t)w.setPositionParagraph(c.line,c.line.getEndOffset());else if(0===e.end.currentWidget.children.length&&0===e.end.offset){var I=e.end.currentWidget.previousLine;w.setPositionParagraph(I,I.getEndOffset())}else w.setPositionParagraph(e.end.currentWidget,e.end.offset-1);this.autoFormatHyperlink(e,n,F,w)}},e.prototype.autoFormatHyperlink=function(e,t,i,r){if(!this.owner.enableCollaborativeEditing||!this.isRemoteAction){this.initComplexHistory("AutoFormatHyperlink");var o=this.selection.getParagraphInfo(i),s=this.selection.getHierarchicalIndex(o.paragraph,o.offset.toString());this.editorHistory&&this.editorHistory.currentHistoryInfo&&(this.editorHistory.currentHistoryInfo.insertPosition=s),e.start.setPositionInternal(i),e.end.setPositionInternal(r);var a=this.getCharacterFormat(e),l=new n.a(void 0,this.owner);l.copyFormat(a);var d=this.createHyperlinkElement(t,i,r,l);e.start.setPositionParagraph(d.line,d.line.getOffset(d,1)),e.start.moveNextPosition(),e.end.setPositionInternal(e.start),o=this.selection.getParagraphInfo(e.end);var h=this.selection.getHierarchicalIndex(o.paragraph,o.offset.toString());this.editorHistory&&this.editorHistory.currentHistoryInfo?(this.editorHistory.currentHistoryInfo.endPosition=h,this.isSkipOperationsBuild=this.owner.enableCollaborativeEditing,this.editorHistory.updateComplexHistory(),this.isSkipOperationsBuild=!1,this.reLayout(e)):this.updateComplexWithoutHistory(0,s,h)}},e.prototype.appylingHyperlinkFormat=function(e){this.initHistory("Underline"),this.updateCharacterFormatWithUp
1date(e,"underline","Single",!1),this.editorHistory&&this.editorHistory.updateHistory(),this.reLayout(e,!1),this.initHistory("FontColor"),this.isForHyperlinkFormat=!0,this.updateCharacterFormatWithUpdate(e,"fontColor","#0563c1",!1),this.isForHyperlinkFormat=!1,this.editorHistory&&this.editorHistory.updateHistory(),this.reLayout(e,!1)},e.prototype.createHyperlinkElement=function(e,t,i,r){var n=this.selection;this.documentHelper.layout.allowLayout=!1,this.documentHelper.layout.isReplaceAll=!0,this.appylingHyperlinkFormat(n);var s=new o.V8(1);s.characterFormat.copyFormat(r),s.line=n.end.currentWidget,n.start.setPositionInternal(n.end),this.initInsertInline(s),n.start.setPositionInternal(t),n.end.setPositionInternal(n.start);var a=this.insertHyperlinkfield(n,r,e),l=n.start.paragraph.childWidgets.indexOf(a.line),d=a.line.children.indexOf(a);return s.linkFieldCharacter(this.documentHelper),this.documentHelper.layout.isReplaceAll=!1,this.documentHelper.layout.allowLayout=!0,this.documentHelper.layout.reLayoutParagraph(n.start.paragraph,l,d),s},e.prototype.insertHyperlinkfield=function(e,t,i,r){var n=new o.V8(0);n.characterFormat.copyFormat(t),n.line=e.start.currentWidget,this.initInsertInline(n);var s=new o.a3;s.characterFormat.copyFormat(t),r?s.text=' HYPERLINK \\l "'+i+'" ':s.text=' HYPERLINK "'+i+'" ',s.line=e.start.currentWidget,this.initInsertInline(s);var a=new o.V8(2);return a.characterFormat.copyFormat(t),a.line=e.start.currentWidget,this.initInsertInline(a),n},e.prototype.unlinkRevisionFromItem=function(e){for(var t=e.revisionLength-1;t>=0;t--){var i=e.revisions[t];e.removeRevision(e.getAllRevision().indexOf(i)),this.owner.trackChangesPane.updateCurrentTrackChanges(i),0===i.getRange(!0).length&&(this.owner.revisions.remove(i),this.isRemoveRevision&&this.documentHelper.revisionsInternal.containsKey(i.revisionID)&&(this.documentHelper.revisionsInternal.remove(i.revisionID),this.owner.trackChangesPane.updateTrackChanges()))}this.constructRevisionsForLink(e,!0)},e.prototype.constructRevisionsForLink=function(e,t){if(e instanceof o.V8&&2===e.fieldType&&!(0,a.le)(this.editorHistory)&&!(0,a.le)(this.editorHistory.historyInfoStack)&&this.editorHistory.historyInfoStack.length>0&&"InsertHyperlink"===this.editorHistory.historyInfoStack[0].action){var i=e.nextElement,r=!1;for((0,a.le)(e.fieldEnd)||-1===e.fieldEnd.indexInOwner||(r=!0);!(0,a.le)(i)&&(!(i instanceof o.V8)||1!==i.fieldType);)t?(this.addRemovedRevisionInfo(i),this.unlinkRevisionFromItem(i)):r&&i.removedIds.length>0&&this.constructRevisionFromID(i,!1),(0,a.le)(i.nextElement)?!(0,a.le)(i.paragraph)&&!(0,a.le)(i.paragraph.nextRenderedWidget)&&i.paragraph.nextRenderedWidget instanceof o.ZH&&!i.paragraph.nextRenderedWidget.isEmpty()?(t?(this.addRemovedRevisionInfo(i.paragraph.characterFormat,void 0),this.unlinkRevisionFromItem(i.paragraph.characterFormat)):r&&i.paragraph.characterFormat.removedIds.length>0&&this.constructRevisionFromID(i.paragraph.characterFormat),i=i.paragraph.nextRenderedWidget.firstChild.children[0]):i=void 0:i=i.nextElement}},e.prototype.unLinkFieldCharacter=function(e){if(e instanceof o.V8&&0===e.fieldType&&e.fieldEnd&&(this.documentHelper&&(this.documentHelper.fieldToLayout=e,this.documentHelper.fieldEndParagraph=e.line.paragraph),e.fieldEnd&&(e.fieldEnd.fieldBegin=void 0),e.fieldEnd=void 0),e instanceof o.V8&&2===e.fieldType)(0,a.le)(e.fieldEnd)||(this.documentHelper&&(this.documentHelper.fieldToLayout=e.fieldBegin,this.documentHelper.fieldEndParagraph=e.line.paragraph),e.fieldBegin.fieldSeparator=void 0,e.fieldEnd.fieldSeparator=void 0);else if(e instanceof o.V8&&1===e.fieldType&&e.fieldBegin){(0,a.le)(this.documentHelper)||(this.documentHelper.fieldToLayout=e.fieldBegin,this.documentHelper.fieldEndParagraph=e.line.paragraph);var t=this.documentHelper.fields.indexOf(e.fieldBegin);-1!==t&&this.documentHelper.fields.splice(t,1);var i=this.documentHelper.formFields.indexOf(e.fieldBegin);-1!==i&&this.documentHelper.formFields.splice(i,1),e.fieldBegin.fieldEnd=void 0,e.fieldBegin=void 0}},e.prototype.getCharacterFormat=function(e){return e.start.paragraph.isEmpty()?e.start.paragraph.characterFormat:e.start.currentWidget.getInline(e.start.offset+1,0).element.characterFormat},e.prototype.insertHyperlink=function(e,t,i){(s.o_.startsWith(e,"http://")||s.o_.startsWith(e,"https://"))&&(e=e.replace(/\s/g,"")),(0,a.le)(t)&&(t=e),(0,a.le)(i)||(e=e+'" \\o "'+i),this.insertHyperlinkInternal(e,t,this.owner.selectionModule.text!==t,!1)},e.prototype.insertHyperlinkInternal=function(e,t,i,s){var l=this.documentHelper.selection;if(!(l.start.paragraph.associatedCell!==l.end.paragraph.associatedCell||this.selection.isPlainContentControl())){var d=l.start,h=l.end;if(l.isForward||(d=l.end,h=l.start),h.offset==h.paragraph.getLength()+1){var c=this.selection.getElementInfo(h.currentWidget,h.offset-1);c.element instanceof o.aQ&&1===c.element.bookmarkType&&!(0,a.le)(c.element.properties)&&c.element.properties.hasOwnProperty("isAfterParagraphMark")&&c.element.properties.isAfterParagraphMark?h.setPositionParagraph(c.element.line,c.element.line.getOffset(c.element,0)):h.movePreviousPosition()}if(i)this.insertHyperlinkInternalInternal(l,e,t,s);else{this.documentHelper.layout.allowLayout=!1;var p=new r.JK(this.documentHelper.owner);p.setPositionInternal(d);var g=this.getCharacterFormat(l),m=new n.a(void 0,this.owner);m.copyFormat(g),this.initComplexHistory("InsertHyperlink");var u=this.selection.getParagraphInfo(d),f=this.selection.getHierarchicalIndex(u.paragraph,u.offset.toString());this.editorHistory&&this.editorHistory.currentHistoryInfo&&(this.editorHistory.currentHistoryInfo.insertPosition=this.selection.getHierarchicalIndex(u.paragraph,u.offset.toString())),this.appylingHyperlinkFormat(l),d.setPositionInternal(h);var y=new o.V8(1);y.characterFormat.copyFormat(m),y.line=l.end.currentWidget,d.setPositionInternal(h),this.initInsertInline(y),d.setPositionInternal(p),h.setPositionInternal(d);var v=this.insertHyperlinkfield(l,m,e,s);y.linkFieldCharacter(this.documentHelper);var H=l.start.paragraph.childWidgets.indexOf(v.line),C=v.line.children.indexOf(v);this.documentHelper.layout.allowLayout=!0,this.documentHelper.layout.reLayoutParagraph(l.start.paragraph,H,C);var F=y.line;l.selects(F,F.getOffset(y,y.length),!0),u=this.selection.getParagraphInfo(h);var w=this.selection.getHierarchicalIndex(u.paragraph,u.offset.toString());this.editorHistory&&this.editorHistory.currentHistoryInfo?(this.editorHistory.currentHistoryInfo.endPosition=this.selection.getHierarchicalIndex(u.paragraph,u.offset.toString()),this.editorHistory.updateComplexHistory()):this.updateComplexWithoutHistory(1,f,w)}}},e.prototype.insertHyperlinkInternalInternal=function(e,t,i,r){if(!((0,a.le)(e.start)||this.editHyperlink(e,t,i))){var o=this.checkAndRemoveComments(),s=this.getCharacterFormat(e);this.initHistory("InsertHyperlink");var l=!0;if(!e.isEmpty){var d=this.owner.enableTrackChanges;this.owner.enableTrackChanges=!1,l=this.removeSelectedContents(e),this.owner.enableTrackChanges=d}if(l){var h=new n.a(void 0,this.owner);h.copyFormat(s),this.insertHyperlinkByFormat(e,t,i,h,r)}this.updateHistoryForComments(o)}},e.prototype.insertHyperlinkByFormat=function(e,t,i,r,n){this.updateInsertPosition(),e.owner.isShiftingEnabled=!0;var s=[],l=new o.V8(0);!(0,a.le)(this.editorHistory)&&this.editorHistory.currentBaseHistoryInfo&&(this.editorHistory.currentBaseHistoryInfo.fieldBegin=l),l.characterFormat.copyFormat(r),s.push(l);var d=new o.a3;n?d.text=' HYPERLINK \\l "'+t+'" ':d.text=' HYPERLINK "'+t+'" ',d.characterFormat.copyFormat(r),s.push(d);var h=new o.V8(2);h.characterFormat.copyFormat(r),s.push(h),(0,a.le)(i)||""===i||((d=new o.a3).characterFormat.copyFormat(r),d.characterFormat.underline="Single",d.characterFormat.fontColor="#0563c1",d.text=i,s.push(d));var c=new o.V8(1);c.characterFormat.copyFormat(r),s.push(c),l.fieldSeparator=c.fieldSeparator=h,l.fieldEnd=h.fieldEnd=c,h.fieldBegin=c.fieldBegin=l,this.insertElement(s),c.linkFieldCharacter(this.documentHelper),-1===this.documentHelper.fields.indexOf(l)&&this.documentHelper.fields.push(l),e.selects(c.line,c.line.getOffset(c,c.length),!0),this.updateEndPosition(),this.reLayout(e,!0)},e.prototype.initInsertInline=function(e,t,i){var r=this.selection;this.initHistory("InsertInline"),this.insertInlineInSelection(r,e),this.editorHistory&&this.editorHistory.updateHistory()},e.prototype.insertElementInCurrentLine=function(e,t){this.checkIsNotRedoing()&&(e.owner.isShiftingEnabled=!0),e.isEmpty||this.removeSelectedContents(e),this.updateInsertPosition(),this.insertElement([t]),this.checkEndPosition(e)&&this.updateHistoryPosition(e.start,!1),this.fireContentChange()},e.prototype.editHyperlink=function(e,t,i,r){var s=e.getHyperlinkField();if((0,a.le)(s))return!1;this.initHistory("InsertHyperlink"),this.editHyperlinkInternal=(0,a.le)(this.editorHistory)||this.editorHistory&&(0,a.le)(this.editorHistory.currentBaseHistoryInfo);var l="",d=!1,h=this.getCharacterFormat(e),c=new n.a(void 0,this.owner);c.copyFormat(h);var p=void 0;if(!(0,a.le)(s.fieldSeparator)){p=s.fieldSeparator;var g=e.getHyperlinkDisplayText(s.fieldSeparator.line.paragraph,s.fieldSeparator,s.fieldEnd,d,c);l=g.displayText,d=g.isNestedField,c=g.format}var m=s.line.getOffset(s,0);if(e.start.setPositionParagraph(s.line,m),m=s.fieldEnd.line.getOffset(s.fieldEnd,1),e.end.setPositionParagraph(s.fieldEnd.line,m),this.skipFieldDeleteTracking=!0,this.deleteSelectedContents(e,!0),!d&&l!==i||(0,a.le)(p))this.insertHyperlinkByFormat(e,t,i,c,r),this.skipFieldDeleteTracking=!1;else{this.updateInsertPosition();var u=new o.V8(0);this.editorHistory&&!(0,a.le)(this.editorHistory.currentBaseHistoryInfo)&&(this.editorHistory.currentBaseHistoryInfo.fieldBegin=u,this.editorHistory.currentBaseHistoryInfo.isEditHyperlink=!0),u.characterFormat.copyFormat(s.characterFormat),u.line=e.start.currentWidget,this.insertInlineInternal(u);var f=new o.a3;f.characterFormat.copyFormat(s.characterFormat),r?f.text=' HYPERLINK \\l "'+t+'" ':f.text=' HYPERLINK "'+t+'" ',f.line=e.start.currentWidget,this.insertInlineInternal(f);var y=this.editorHistory&&this.editorHistory.currentBaseHistoryInfo?this.editorHistory.currentBaseHistoryInfo.removedNodes:this.nodes;this.insertClonedFieldResult(e,y,p),e.end.currentWidget.getInline(e.end.offset,0).element.linkFieldCharacter(this.documentHelper),this.skipFieldDeleteTracking=!1;var v=u.line.paragraph,H=u.line.paragraph.childWidgets.indexOf(u.line),C=u.line.children.indexOf(u);this.documentHelper.layout.reLayoutParagraph(v,H,C),m=u.fieldEnd.line.getOffset(u.fieldEnd,1),e.selects(u.fieldEnd.line,m,!0),this.updateEndPosition(),this.reLayout(e,!0)}return this.editHyperlinkInternal=!1,this.nodes=[],!0},e.prototype.insertClonedFieldResult=function(e,t,i){for(var r=!1,n=t.length-1;n>-1;n--){var s=t[n];if(!r){if(i===s)r=!0;else{if(s instanceof o.ZH&&s===i.line.paragraph){r=!0;var a=void 0;if(n===t.length-1){a=e.start.paragraph;var l=i.line.paragraph;this.getClonedFieldResultWithSel(l,e,i)}else a=this.getClonedFieldResult(i.line.paragraph,i),this.insertParagraph(a,!0);e.selectParagraphInternal(e.getNextParagraphBlock(a),!0)}continue}}s instanceof o.nR?this.insertInlineInternal(s.clone()):s instanceof o.qc&&this.insertBlock(s.clone())}},e.prototype.getClonedFieldResultWithSel=function(e,t,i){for(var r=e.childWidgets.indexOf(i.line),o=e.childWidgets[r].children.indexOf(i),n=r;n<e.childWidgets.length;n++){var s=e.childWidgets[n];n!==r&&(o=0);for(var a=o;a<s.children.length;a++)this.insertInlineInternal(s.children[a].clone())}},e.prototype.getClonedFieldResult=function(e,t){var i=new o.ZH;i.characterFormat.copyFormat(e.characterFormat),i.paragraphFormat.copyFormat(e.paragraphFormat);for(var r=e.childWidgets.indexOf(t.line),n=e.childWidgets[r].children.indexOf(t),s=r;s<e.childWidgets.length;s++){var a=e.childWidgets[s];s!==r&&(n=0);for(var l=n;l<a.children.length;l++)i.childWidgets[0].children.push(a.children[l])}return i},e.prototype.removeContentControl=function(){var e=this.documentHelper.owner.selection.currentContentControl;if(e instanceof o.h){var t=e.reference,i=this.selection.start.clone(),r=this.selection.end.clone(),n=this.selection.getElementInfo(r.currentWidget,r.offset);this.selection.start.setPositionParagraph(e.line,e.line.getOffset(e,e.length)),this.selection.end.setPositionParagraph(t.line,t.line.getOffset(t,t.length)-1),this.initHistory("RemoveContentControl"),this.selection.selectPosition(i,r),this.editorHistory&&(this.editorHistory.currentBaseHistoryInfo.insertedText=R.j5.Marker_Start,this.editorHistory.currentBaseHistoryInfo.markerData.push({text:"RemoveContentControl",type:e.contentControlWidgetType}),this.editorHistory.currentBaseHistoryInfo.setContentControlInfo(e)),this.removeContentControlInternal(e),this.editorHistory&&this.editorHistory.updateHistory(),n.element!==e&&n.element!==t&&this.selection.end.setPositionParagraph(n.element.line,n.element.line.getOffset(n.element,n.index))}this.fireContentChange(),this.viewer.updateScrollBars()},e.prototype.removeContentControlInternal=function(e){(0,a.le)(e)&&(e=this.documentHelper.owner.selection.currentContentControl),"Picture"==e.contentControlProperties.type&&this.owner.renderPictureContentControlElement(this.owner,!1,!1);var t=this.documentHelper.contentControlCollection.indexOf(e);t>=0&&(this.updatePropertiesToBlock(e),this.documentHelper.contentControlCollection.splice(t,1),e.line.children.splice(e.indexInOwner,1),(0,a.le)(e.reference)||(e.reference.line.children.splice(e.reference.indexInOwner,1),this.updatePropertiesToBlock(e))),this.selection.updateContentControlHighlightSelection();var i=this.documentHelper.owner,r=i.element.querySelector("#contenticon"),o=i.element.querySelector("#"+this.owner.element.i
1d+"PICTURE_CONTENT_CONTROL");r&&(r.style.display="none"),o&&(o.style.display="none"),this.viewer.updateScrollBars()},e.prototype.removeHyperlink=function(){if(!this.owner.isReadOnlyMode){var e=this.selection,t=e.getHyperlinkField();if(!(0,a.le)(t)){var i=t.fieldEnd,o=t.fieldSeparator,n=new r.JK(e.owner);n.setPositionParagraph(t.line,t.line.getOffset(t,0));var s=this.selection.getParagraphInfo(n),l=this.selection.getHierarchicalIndex(s.paragraph,s.offset.toString()),d=new r.JK(e.owner);d.setPositionParagraph(o.line,o.line.getOffset(o,o.length)),s=this.selection.getParagraphInfo(d);var h=this.selection.getHierarchicalIndex(s.paragraph,s.offset.toString());this.initComplexHistory("RemoveHyperlink"),e.start.setPositionParagraph(i.line,i.line.getOffset(i,0)),s=this.selection.getParagraphInfo(e.start);var c=this.selection.getHierarchicalIndex(s.paragraph,s.offset.toString());e.end.setPositionParagraph(i.line,i.line.getOffset(i,1)),this.delete(),e.start.setPositionInternal(this.selection.getTextPosBasedOnLogicalIndex(h)),this.initHistory("Underline"),this.updateCharacterFormatWithUpdate(e,"underline","None",!1),this.editorHistory&&this.editorHistory.updateHistory(),e.end.setPositionInternal(this.selection.getTextPosBasedOnLogicalIndex(c)),this.initHistory("FontColor"),this.updateCharacterFormatWithUpdate(e,"fontColor",void 0,!1),this.editorHistory&&this.editorHistory.updateHistory(),this.reLayout(e,!1),e.end.setPositionInternal(e.start),e.start.setPositionInternal(this.selection.getTextPosBasedOnLogicalIndex(l)),this.initHistory("Delete"),this.deleteSelectedContents(e,!1),this.reLayout(e,!0),this.combineElementRevision(o.getAllRevision(),i.getAllRevision()),this.editorHistory&&!(0,a.le)(this.editorHistory.currentHistoryInfo)&&this.editorHistory.updateComplexHistory()}}},e.prototype.updateHyperlinkFormat=function(e){var t=e.getHyperlinkField();if(!(0,a.le)(t)){var i=t.fieldEnd,r=t.fieldSeparator;e.start.setPositionParagraph(r.line,r.line.getOffset(r,r.length)),e.end.setPositionParagraph(i.line,i.line.getOffset(i,0)),this.initHistory("Underline"),this.updateCharacterFormatWithUpdate(e,"underline","Single",!1),this.editorHistory&&this.editorHistory.updateHistory(),this.reLayout(e,!1),this.initHistory("FontColor"),this.isForHyperlinkFormat=!0,this.updateCharacterFormatWithUpdate(e,"fontColor","#0563c1",!1),this.isForHyperlinkFormat=!1,this.editorHistory&&this.editorHistory.updateHistory(),this.reLayout(e,!1)}},e.prototype.triggerBeforePasteEvent=function(e,t){if(!(0,a.le)(this.owner)&&!(0,a.le)(this.owner.beforePaste)){var i={cancel:!1,pasteContent:e,pasteType:t};return this.owner.trigger(F.xO,i),i}},e.prototype.pasteInternal=function(e,t){if(this.currentPasteOptions=this.owner.defaultPasteOption,this.isHtmlPaste=!1,this.documentHelper.owner.enableLocalPaste)this.paste();else{(0,T.yh)(this.owner.element),this.selection.isViewPasteOptions=!0,this.selection.pasteElement&&(this.selection.pasteElement.style.display="none"),(0,a.le)(t)&&(t=window);var i="",r="",o="",l="",d=t.clipboardData?t.clipboardData:e.clipboardData;if("msie"!==a.AR.info.name&&(o=d.getData("Text/Rtf"),r=d.getData("Text/Html"),l=d.getData("application/json")),this.copiedTextContent=i=s.o_.sanitizeString(d.getData("Text")),this.previousCharFormat=new n.a(void 0,this.owner),this.previousCharFormat.copyFormat(this.selection.start.paragraph.characterFormat),this.previousParaFormat=new h.h,this.previousParaFormat.copyFormat(this.selection.start.paragraph.paragraphFormat),"FormFieldsOnly"===this.documentHelper.protectionType&&this.documentHelper.selection.isInlineFormFillMode()&&(r="",o=""),""!==l)this.isInternalPaste=!0,this.type=".sfdt",this.pasteFormattedContent({data:JSON.parse(l)}),this.isInternalPaste=!1;else if(""!==o)this.isRTFContentPasting=!0,this.pasteAjax(o,".rtf");else if(""!==r)this.isHtmlPaste=!0,this.pasteAjax(r,".html");else if(null!==i&&""!==i){this.selection.currentPasteAction="TextOnly",this.type=".text";var c=i;this.beforePasteEvent(c,this.type),this.applyPasteOptions(this.currentPasteOptions,!0),this.copiedContent=void 0,this.documentHelper.editableDiv.innerHTML="",(0,T.v3)(this.owner.element)}else if("msie"!==a.AR.info.name&&void 0!==d.items&&0!==d.items.length){for(var p=0;p<d.items.length;p++){var g=d.items[p];("image/png"===g.type||"image/svg+xml"===g.type&&"string"!==g.kind||"image/jpeg"===g.type&&"string"!==g.kind)&&this.pasteImage(g.getAsFile())}(0,T.v3)(this.owner.element)}else"msie"===a.AR.info.name&&void 0!==d.files&&0!==d.files.length&&"image/png"===d.files[0].type&&(this.pasteImage(d.files[0]),(0,T.v3)(this.owner.element))}},e.prototype.pasteImage=function(e){var t=this,i=new FileReader;i.onload=function(){t.onPasteImage(i.result)},i.readAsDataURL(e)},e.prototype.onPasteImage=function(e){var t=document.createElement("img"),i=this;t.addEventListener("load",function(){i.insertImageInternal(e,!0,this.width,this.height,this.alt)}),t.src=e},e.prototype.pasteAjax=function(e,t){var i={content:e,type:t};this.type=t,this.pasteRequestHandler=new L.q,this.owner.documentHelper.viewerContainer.focus(),this.pasteRequestHandler.url=this.owner.serviceUrl+this.owner.serverActionSettings.systemClipboard,this.pasteRequestHandler.responseType="json",this.pasteRequestHandler.contentType="application/json;charset=UTF-8",this.pasteRequestHandler.customHeaders=this.owner.headers,this.pasteRequestHandler.onSuccess=this.pasteFormattedContent.bind(this),this.pasteRequestHandler.onFailure=this.onPasteFailure.bind(this),this.pasteRequestHandler.onError=this.onPasteFailure.bind(this);var r={serverActionType:"SystemClipboard",headers:this.owner.headers,timeout:0,cancel:!1,withCredentials:!1,clipboardData:i};this.owner.trigger(F.z1,r),r.cancel?(0,T.v3)(this.owner.element):this.pasteRequestHandler.send(i,r)},e.prototype.getPasteTypeFromFileExtension=function(e){switch(e){case".html":return"Html";case".rtf":return"Rtf";case".sfdt":return"Sfdt";default:return"Text"}},e.prototype.pasteFormattedContent=function(e){var t=this;this.isPasteListUpdated&&(this.isPasteListUpdated=!1);var i=null==e.data?this.copiedTextContent:e.data instanceof Object?JSON.stringify(e.data):e.data;this.beforePasteEvent(i,this.type),"KeepSourceFormatting"!==this.currentPasteOptions&&this.applyPasteOptions(this.currentPasteOptions),this.isRTFContentPasting=!1,(0,T.v3)(this.owner.element),setTimeout(function(){(0,a.le)(t.viewer)||(t.documentHelper.isScrollHandler=!0,t.isPasteContentCheck=!0,t.viewer.updateScrollBars(),t.documentHelper.isScrollHandler=!1,t.isPasteContentCheck=!1)},0)},e.prototype.beforePasteEvent=function(e,t){var i=this.triggerBeforePasteEvent((0,a.le)(e)?this.copiedTextContent:e,this.getPasteTypeFromFileExtension(t));if(i&&i.cancel){(0,T.v3)(this.owner.element);return}i&&((0,a.le)(i.pasteContent)?alert("Provide valid paste content"):e=i.pasteContent);try{var r=JSON.parse(e);this.pasteContents(s.o_.getSfdtDocument(r))}catch(t){this.pasteContents((0,a.le)(e)?this.copiedTextContent:e)}},e.prototype.onPasteFailure=function(e){this.owner.fireServiceFailure(e),console.error(e.status,e.statusText),(0,T.v3)(this.owner.element),this.documentHelper.updateFocus()},e.prototype.paste=function(e,t){var i=this;(0,a.le)(e)&&(e=this.owner.enableLocalPaste?this.copiedData:void 0),(0,a.le)(t)||(this.currentPasteOptions=t);var r=!!this.canEditContentControl;if(!this.canEditContentControl&&this.owner.editorHistoryModule&&this.owner.editorHistoryModule.currentHistoryInfo&&"InsertContentControl"
1===this.owner.editorHistoryModule.currentHistoryInfo.action&&(r=!0),e&&r){var o=s.o_.getSfdtDocument(e);this.pasteContents(o,null,t),this.applyPasteOptions(this.currentPasteOptions),this.currentPasteOptions=void 0,this.chartType&&(setTimeout(function(){(0,a.le)(i.viewer)||i.viewer.updateScrollBars()},30),this.chartType=!1)}},e.prototype.getUniqueListOrAbstractListId=function(e){if(e&&this.documentHelper.lists.length){var t=this.documentHelper.lists.slice().sort(function(e,t){return e.listId-t.listId});return t[t.length-1].listId+1}if(this.documentHelper.abstractLists.length){var i=this.documentHelper.abstractLists.slice().sort(function(e,t){return e.abstractListId-t.abstractListId});return i[i.length-1].abstractListId+1}return 0},e.prototype.getBlocksToUpdate=function(e){for(var t=[],i=0;i<e.length;i++){var r=e[i];if(r[w.GXW[this.keywordIndex]]&&r[w.GXW[this.keywordIndex]][w.lK9[this.keywordIndex]]&&Object.keys(r[w.GXW[this.keywordIndex]][w.lK9[this.keywordIndex]]).length>0)t.push(r);else if(r[w.Gjb[this.keywordIndex]])for(var o=0;o<r[w.Gjb[this.keywordIndex]].length;o++)for(var n=r[w.Gjb[this.keywordIndex]][o],s=0;s<n[w.K5N[this.keywordIndex]].length;s++){var a=n[w.K5N[this.keywordIndex]][s];t=t.concat(this.getBlocksToUpdate(a[w.si1[this.keywordIndex]]))}}return t},e.prototype.updateListIdForBlocks=function(e,t,i,r,o,n,s){for(var l=!1,d=0;d<e.length;d++){var h=e[d];if(h[w.GXW[this.keywordIndex]]&&h[w.GXW[this.keywordIndex]][w.lK9[this.keywordIndex]]&&Object.keys(h[w.GXW[this.keywordIndex]][w.lK9[this.keywordIndex]]).length>0){var c=h[w.GXW[this.keywordIndex]][w.lK9[this.keywordIndex]],p=this.isNsIdMatchWithExistingAbstractList(t[w.ca4]);c[w.OQZ[this.keywordIndex]]===r&&((0,a.le)(p)?(l=!0,c[w.OQZ[this.keywordIndex]]=o):n?(l=!0,c[w.OQZ[this.keywordIndex]]=o,c[w.ca4]=s):(c.isUpdated||(c[w.OQZ[this.keywordIndex]]=p.listId,c.isUpdated=!0),l=!1))}else if(h[w.Gjb[this.keywordIndex]])for(var g=0;g<h[w.Gjb[this.keywordIndex]].length;g++)for(var m=h[w.Gjb[this.keywordIndex]][g],u=0;u<m[w.K5N[this.keywordIndex]].length;u++){var f=m[w.K5N[this.keywordIndex]][u],y=this.updateListIdForBlocks(f[w.si1[this.keywordIndex]],t,i,r,o);l||(l=y)}}return l},e.prototype.isNsIdMatchWithExistingAbstractList=function(e){for(var t=0;t<this.documentHelper.lists.length;t++){var i=this.documentHelper.lists[t];if(i.abstractList.nsid===e)return i}},e.prototype.updatePasteContent=function(e,t){var i=this,r=this.getUniqueListOrAbstractListId(!0);if(e[w.R6L[this.keywordIndex]].filter(function(e){return e[w.OQZ[i.keywordIndex]]===r}).length>0){var o=e[w.R6L[this.keywordIndex]].slice().sort(function(e,t){return e[w.OQZ[i.keywordIndex]]-t[w.OQZ[i.keywordIndex]]});r=o[o.length-1][w.OQZ[this.keywordIndex]]+1}var n=this.getUniqueListOrAbstractListId(!1);if(e[w.eNA[this.keywordIndex]].filter(function(e){return e[w.BY3[i.keywordIndex]]===n}).length>0){var l=e[w.eNA[this.keywordIndex]].slice().sort(function(e,t){return e[w.BY3[i.keywordIndex]]-t[w.BY3[i.keywordIndex]]});n=l[l.length-1][w.BY3[this.keywordIndex]]+1}for(var d,h=e[w.R6L[this.keywordIndex]].length,c=this,p=0;p<e[w.R6L[this.keywordIndex]].length;p++)(function(o){var l=e[w.R6L[c.keywordIndex]][o],p=e[w.eNA[c.keywordIndex]].filter(function(e){return e[w.BY3[i.keywordIndex]]===l[w.BY3[i.keywordIndex]]})[0],g=c.documentHelper.lists.filter(function(e){return e.listId===l[w.OQZ[i.keywordIndex]]});if(!(0,a.le)(p)){var m=!1,u=0;if(!(0,a.le)(c.selection)&&!(0,a.le)(c.selection.start.paragraph)&&(-1!==c.selection.start.paragraph.paragraphFormat.listFormat.listId?m=!1:(m=c.getPreviousParagraphListFormat(c.selection.start.paragraph,h))&&(u=s.o_.generateUniqueId(c.documentHelper.lists))),c.updateListIdForBlocks(e[w.d52[c.keywordIndex]][t][w.si1[c.keywordIndex]],p,g[0],l[w.OQZ[c.keywordIndex]],r,m,u)){for(var f=p[w.BY3[c.keywordIndex]],y=0;y<e[w.R6L[c.keywordIndex]].length;y++){var v=e[w.R6L[c.keywordIndex]][y];v[w.BY3[c.keywordIndex]]===f&&(v[w.BY3[c.keywordIndex]]=n)}p[w.BY3[c.keywordIndex]]=n,l[w.OQZ[c.keywordIndex]]=r,m&&0!==u&&(p[w.ca4]=l[w.ca4]=u),r++,n++}else e[w.R6L[c.keywordIndex]].splice(o,1),e[w.eNA[c.keywordIndex]].splice(e[w.eNA[c.keywordIndex]].indexOf(p),1),o--}d=o})(p),p=d;for(var g=this.getBlocksToUpdate(e[w.d52[this.keywordIndex]][t][w.si1[this.keywordIndex]]),m=0;m<g.length;m++){var u=g[m];delete u[w.GXW[this.keywordIndex]][w.lK9[this.keywordIndex]].isUpdated}},e.prototype.getPreviousParagraphListFormat=function(e,t){if(!(0,a.le)(this.documentHelper.layout)){for(var i=this.selection.getPreviousParagraphBlock(e);!(0,a.le)(i)&&(i.isEmpty()||!this.documentHelper.layout.hasValidElement(i));)i=this.selection.getPreviousParagraphBlock(i);if(!(0,a.le)(i)&&-1===i.paragraphFormat.listFormat.listId&&1===t)return!0}return!1},e.prototype.getBlocks=function(e,t,i,r,n,s){var d=[];if(this.documentHelper.copiedHeaderFooterData=[],"string"==typeof e){var c=this.selection.start.paragraph;this.selection.isForward||(c=this.selection.end.paragraph);var p=[],g=e;p=(g=g.replace(/\r?\n/g,"\r")).split("\r");var m=[],u=new o.VB;u.sectionFormat=new l.Z(u),u.childWidgets=m;for(var f=0;f<p.length;f++)if(f!==p.length-1||0!==p[f].length||this.isInsertText){var y=this.selection.start.currentWidget.getInline(this.selection.start.offset,0),v=this.selection.getPreviousValidElement(y.element);v!==y.element&&(v=this.documentHelper.getNextValidElement(y.element));var H=void 0;c.isEmpty()||this.selection.isEmpty&&this.isInsertText?H=c.characterFormat:(0,a.le)(v)||this.isInsertText?this.copyInsertFormat(c.characterFormat,!1):H=v.characterFormat;var C=void 0;this.isInsertText?(C=new h.h).copyFormat(this.selection.end.paragraph.paragraphFormat):C=this.documentHelper.selection.copySelectionParagraphFormat(),(0,a.le)(this.previousParaFormat)||(C=this.previousParaFormat);var F=new o.ZH;F.paragraphFormat.copyFormat(C);var I=new o.z7(F);if(p[f].length>0)for(var x=p[f].split(/(\s+)/),b=0;b<x.length;b++){var W=new o.a3;W.characterFormat.copyFormat(H),W.text=x[b],I.children.push(W),W.line=I}
1F.childWidgets.push(I),F.containerWidget=u,m.push(F)}d.push(u)}else{var P=this.documentHelper.owner.parser;P.keywordIndex=this.keywordIndex,P.isPaste=t,P.isContextBasedPaste=!(0,a.le)(s)&&s,P.isHtmlPaste=this.isHtmlPaste,!s&&(P.addCustomStyles(e),e[w.YWb[this.keywordIndex]]&&e[w.YWb[this.keywordIndex]].length>0&&(P.commentsCollection=new k.X,P.commentStarts=new k.X,P.commentEnds=new k.X,P.parseComments(e,r||this.documentHelper.comments)),e[w.ajW[this.keywordIndex]]&&e[w.ajW[this.keywordIndex]].length>0&&P.parseCustomXml(e));var u=void 0;this.selection.currentPasteAction="DefaultPaste";for(var f=0;f<e[w.d52[this.keywordIndex]].length;f++){if(!s&&(this.isPasteListUpdated||(0,a.le)(e[w.R6L[this.keywordIndex]])||(this.documentHelper.lists.length>0&&this.updatePasteContent(e,f),this.isPasteListUpdated=!0,(0,a.le)(e[w.eNA[this.keywordIndex]])||P.parseAbstractList(e,this.documentHelper.abstractLists),(0,a.le)(e[w.R6L[this.keywordIndex]])||P.parseList(e,this.documentHelper.lists)),!(0,a.le)(e[w.$Bm[this.keywordIndex]]))){if(t){this.viewer.owner.revisionsInternal.changes,(0,a.le)(P.revisionCollection)||(P.revisionCollection=void 0),this.isRemoteAction?P.revisionCollection=this.documentHelper.revisionsInternal:P.revisionCollection=new k.X;var R=P.revisionCollection;if(!(this.documentHelper.owner.sfdtExportModule.copyWithTrackChange&&P.isCutPerformed)&&e[w.$Bm[this.keywordIndex]].length>=1)for(var T=0;T<e[w.$Bm[this.keywordIndex]].length;T++)R.containsKey(e[w.$Bm[this.keywordIndex]][T][w.UVm[this.keywordIndex]])||P.parseRevisions(e,[]);this.documentHelper.owner.sfdtExportModule.copyWithTrackChange=!1}else P.revisionCollection=this.documentHelper.revisionsInternal,P.parseRevisions(e,n)}if((u=new o.VB).sectionFormat=new l.Z(u),!t||s?i.unshift(u):d.push(u),t&&!s&&!(0,a.le)(e[w.Vp8[this.keywordIndex]]))for(var b=0;b<e[w.Vp8[this.keywordIndex]].length;b++){var S=e[w.Vp8[this.keywordIndex]][b][w.wz_[this.keywordIndex]],B=this.documentHelper.styles.findByName(S);(0,a.le)(B)&&"Normal (Web)"!==S&&P.parseStyle(e,e[w.Vp8[this.keywordIndex]][b],this.documentHelper.styles)}if(P.parseBody(e[w.d52[this.keywordIndex]][f][w.si1[this.keywordIndex]],u.childWidgets,void 0,void 0,void 0,e[w.Vp8[this.keywordIndex]]),((e[w.E8U[this.keywordIndex]]||this.owner.enableLocalPaste)&&this.selection.start.paragraph.isEmpty()&&1==this.documentHelper.pages.length&&1==this.documentHelper.pages[0].bodyWidgets[0].childWidgets.length||e[w.d52[this.keywordIndex]][f][w.qTT[this.keywordIndex]]&&e[w.d52[this.keywordIndex]][f][w.qTT[this.keywordIndex]][w.oHw[this.keywordIndex]]>1||e[w.d52[this.keywordIndex]][f][w.qTT[this.keywordIndex]]&&"NoBreak"===e[w.d52[this.keywordIndex]][f][w.qTT[this.keywordIndex]][w.EIi[this.keywordIndex]])&&P.parseSectionFormat(this.keywordIndex,e[w.d52[this.keywordIndex]][f][w.qTT[this.keywordIndex]],u.sectionFormat),t&&!s&&!(0,a.le)(e[w.d52[this.keywordIndex]][f][w.gcX[this.keywordIndex]])){var L=e[w.d52[this.keywordIndex]][f][w.gcX[this.keywordIndex]];if(L&&Object.keys(L).length>0){var E=P.parseHeaderFooter(L,this.documentHelper.headersFooters);this.documentHelper.copiedHeaderFooterData.push(E)}}if(t&&!this.isRemoteAction&&!(0,a.le)(r)){for(var O=[],A=0;A<this.documentHelper.comments.length;A++)O.push(this.documentHelper.comments[A].commentId);for(var N=0;N<r.length;N++){var M=r[N];if(-1!==O.indexOf(M.commentId)&&!(0,a.le)(M.commentStart)&&!(0,a.le)(M.commentEnd)){var D=Math.random().toString(36).substring(2,15)+Math.random().toString(36).substring(2,15);M.commentId=M.commentStart.commentId=M.commentEnd.commentId=D}this.documentHelper.comments.push(M)}}P.isPaste=!1,P.isHtmlPaste=!1,P.isContextBasedPaste=!1}if(e[w.E8U[this.keywordIndex]]&&!s||this.owner.documentEditorSettings.pasteAsNewParagraph){this.isLastParaMarkCopied=!0;var V=new o.ZH;u.childWidgets.push(V)}}return"MergeWithExistingFormatting"!==this.currentPasteOptions||s||this.applyMergeFormat(d),d},e.prototype.applyMergeFormat=function(e){var t=this.selection.start.paragraph,i=this.selection.start.currentWidget.getInline(this.selection.start.offset,0),r=this.selection.getPreviousValidElement(i.element),s=new n.a(void 0,this.owner);s=!(0,a.le)(r)&&r.contentControlProperties?this.copyInsertFormat(new n.a(void 0,this.owner),!1):r?r.characterFormat:this.copyInsertFormat(t.characterFormat,!0,t);for(var l=this.documentHelper.selection.paragraphFormat,d=0;d<e.length;d++)for(var h=e[d].childWidgets,c=0;c<h.length;c++){var p=h[c];if(p instanceof o.ZH)this.applyParaFormatInternal(p.paragraphFormat,l),this.applyFormatInternal(p,s);else for(var g=0;g<p.childWidgets.length;g++)for(var m=p.childWidgets[g],u=0;u<m.childWidgets.length;u++)for(var f=m.childWidgets[u],y=0;y<f.childWidgets.length;y++)this.applyFormatInternal(f.childWidgets[y],s)}},e.prototype.applyParaFormatInternal=function(e,t){(0,a.le)(t.leftIndent)||(e.leftIndent=t.leftIndent),(0,a.le)(t.rightIndent)||(e.rightIndent=t.rightIndent),(0,a.le)(t.firstLineIndent)||(e.firstLineIndent=t.firstLineIndent),(0,a.le)(t.textAlignment)?e.textAlignment="Left":e.textAlignment=t.textAlignment,(0,a.le)(t.outlineLevel)?e.outlineLevel="BodyText":e.outlineLevel=t.outlineLevel,-1===t.beforeSpacing?e.beforeSpacing=0:e.beforeSpacing=t.beforeSpacing,-1===t.afterSpacing?e.afterSpacing=0:e.afterSpacing=t.afterSpacing,0===t.lineSpacing?e.lineSpacing=1:e.lineSpacing=t.lineSpacing,(0,a.le)(t.lineSpacingType)||(e.lineSpacingType=t.lineSpacingType),
1(0,a.le)(t.bidi)||(e.bidi=t.bidi),(0,a.le)(t.spaceAfterAuto)||(e.spaceAfterAuto=t.spaceAfterAuto),(0,a.le)(t.spaceBeforeAuto)||(e.spaceBeforeAuto=t.spaceBeforeAuto),(0,a.le)(t.keepWithNext)||(e.keepWithNext=t.keepWithNext),(0,a.le)(t.keepLinesTogether)||(e.keepLinesTogether=t.keepLinesTogether),(0,a.le)(t.widowControl)||(e.widowControl=t.widowControl),(0,a.le)(t.contextualSpacing)||(e.contextualSpacing=t.contextualSpacing),e.tabs&&(e.tabs=[])},e.prototype.applyFormatInternal=function(e,t){if(e instanceof o.ZH)for(var i=0;i<e.childWidgets.length;i++)for(var r=e.childWidgets[i],n=0;n<r.children.length;n++){var s=r.children[n].characterFormat.cloneFormat();s.bold&&(r.children[n].characterFormat.bold=s.bold),s.italic&&(r.children[n].characterFormat.italic=s.italic),"None"!==s.underline&&(r.children[n].characterFormat.underline=s.underline),"MergeWithExistingFormatting"!==this.currentPasteOptions||(0,a.le)(t)||(t.bold&&(r.children[n].characterFormat.bold=t.bold),t.italic&&(r.children[n].characterFormat.italic=t.italic),"None"!==t.underline&&(r.children[n].characterFormat.underline=t.underline),r.children[n].characterFormat.fontColor!==t.fontColor&&(r.children[n].characterFormat.fontColor=t.fontColor),r.children[n].characterFormat.highlightColor!==t.highlightColor&&(r.children[n].characterFormat.highlightColor=t.highlightColor),r.children[n].characterFormat.fontSize!==t.fontSize&&(r.children[n].characterFormat.fontSize=t.fontSize,r.children[n].characterFormat.fontSizeBidi=t.fontSizeBidi),r.children[n].characterFormat.fontFamily!==t.fontFamily&&(r.children[n].characterFormat.fontFamily=t.fontFamily,r.children[n].characterFormat.fontFamilyBidi=t.fontFamilyBidi),r.children[n].characterFormat.fontFamilyAscii!==t.fontFamilyAscii&&(r.children[n].characterFormat.fontFamilyAscii=t.fontFamilyAscii),r.children[n].characterFormat.fontFamilyFarEast!==t.fontFamilyFarEast&&(r.children[n].characterFormat.fontFamilyFarEast=t.fontFamilyFarEast),r.children[n].characterFormat.fontFamilyAscii===t.fontFamilyAscii||(r.children[n].characterFormat.fontFamilyAscii=t.fontFamilyAscii))}else for(var i=0;i<e.childWidgets.length;i++)for(var l=e.childWidgets[i],n=0;n<l.childWidgets.length;n++)for(var d=l.childWidgets[n],h=0;h<d.childWidgets.length;h++)this.applyFormatInternal(d.childWidgets[h],t)},e.prototype.applyPasteOptions=function(e,t){if(!(0,a.le)(this.copiedContent)&&""!==this.copiedTextContent&&!t){this.currentPasteOptions=e;var i=(this.selection.isForward?this.selection.start:this.selection.end).paragraph.paragraphFormat,r=this.copiedContent,o=this.copiedTextContent;switch(this.editorHistory&&this.editorHistory.canUndo()&&this.editorHistory.isUndoGroupingEnded?(this.editorHistory.undo(),this.editorHistory.redoStack.pop()):(0,a.le)(this.editorHistory)||this.editorHistory.isUndoGroupingEnded||!(this.editorHistory.historyInfoStack.length>0)||(this.editorHistory.undoStackIn=(0,a.le)(this.editorHistory.undoStackIn)?[]:this.editorHistory.undoStackIn,this.editorHistory.undoStackIn.push(this.editorHistory.historyInfoStack[this.editorHistory.historyInfoStack.length-1].modifiedActions.pop()),this.editorHistory.undo()),this.copiedContent=r,this.copiedTextContent=o,this.selection.isViewPasteOptions=!0,e){case"KeepSourceFormatting":this.pasteContents(""!==this.copiedContent?this.copiedContent:this.copiedTextContent);break;case"MergeWithExistingFormatting":this.pasteContents(""!==this.copiedContent?this.copiedContent:this.copiedTextContent,i);break;case"KeepTextOnly":this.pasteContents(this.copiedTextContent)}}},e.prototype.applyTablePasteOptions=function(e){if(!(0,a.le)(this.copiedContent)&&""!==this.copiedTextContent){this.isPaste=!0;var t=""!==this.copiedContent?this.copiedContent:this.copiedTextContent;this.editorHistory&&this.editorHistory.canUndo()&&(this.editorHistory.undo(),this.editorHistory.redoStack.pop());var i=this.getBlocks(t,!0),r=this.selection.start.paragraph.paragraphFormat;switch(e){case"NestTable":this.pasteAsNestedTable(i,r);break;case"InsertAsRows":this.pasteAsNewRow(i[0].childWidgets[0]);break;case"InsertAsColumns":this.pasteAsNewColumn(i[0].childWidgets[0]);break;case"OverwriteCells":this.pasteOverwriteCell(i[0].childWidgets[0])}this.isPaste=!1}},e.prototype.pasteContents=function(e,t,i){var r,o;
1if(!(0,a.le)(e.optimizeSfdt)&&e.optimizeSfdt?this.keywordIndex=1:this.keywordIndex=0,"string"!=typeof e&&(this.copiedContent=e),!(0,a.le)(this.documentHelper)){if("FormFieldsOnly"===this.documentHelper.protectionType&&this.documentHelper.selection.isInlineFormFillMode()){var n=this.selection.getCurrentFormField(),s=this.getFieldResultText(),l=n.formFieldData.maxLength,d=this.documentHelper.selection.text.length;if(l>0){if(0===d){var h=l-s.length;e=e.substring(0,h)}else d>0&&(e=e.substring(0,d))}}if(!(0,a.le)(e[w.xPb[this.keywordIndex]])){var c=e[w.xPb[this.keywordIndex]];if(this.documentHelper.images.length>0){this.pasteImageIndex=new k.X;var p={};for(var g in c){var m=Math.max.apply(Math,this.documentHelper.images.keys)+1+parseInt(g);p[m]=c[g],this.pasteImageIndex.add(g,m.toString())}c=p}this.documentHelper.owner.parser.parseImages(c)}var u=[],f=this.getBlocks(e,!0,void 0,u);this.capturedOriginalHeaderFooters=[],this.isCurrentWholeDocumentPaste=!1;var y=this.documentHelper.headersFooters.slice();this.documentHelper.copiedHeaderFooterData.length>0&&!this.selection.start.paragraph.isInHeaderFooter&&(0,a.le)(this.selection.start.paragraph.bodyWidget.nextRenderedWidget)&&this.selection.start.paragraph.bodyWidget.page.headerWidget.isEmpty&&this.selection.start.paragraph.bodyWidget.page.footerWidget.isEmpty&&this.selection.start.paragraph.bodyWidget.childWidgets[0]&&this.isSectionEmpty(this.selection)&&(1==this.documentHelper.headersFooters.length?(this.documentHelper.headersFooters=this.documentHelper.copiedHeaderFooterData,this.isCurrentWholeDocumentPaste=!0):this.documentHelper.headersFooters.length>1&&this.documentHelper.headersFooters.length==this.selection.start.paragraph.bodyWidget.sectionIndex+1?(this.documentHelper.headersFooters.pop(),(r=this.documentHelper.headersFooters).push.apply(r,this.documentHelper.copiedHeaderFooterData),this.documentHelper.copiedHeaderFooterData=this.documentHelper.headersFooters.slice(),this.isCurrentWholeDocumentPaste=!0):this.documentHelper.headersFooters.length>1&&this.documentHelper.headersFooters.length<this.selection.start.paragraph.bodyWidget.sectionIndex+1&&((o=this.documentHelper.headersFooters).push.apply(o,this.documentHelper.copiedHeaderFooterData),this.documentHelper.copiedHeaderFooterData=this.documentHelper.headersFooters.slice(),this.isCurrentWholeDocumentPaste=!0)),this.isCurrentWholeDocumentPaste&&(this.documentHelper.layout.layoutWholeDocument(!0),this.capturedOriginalHeaderFooters=y),this.pasteContentsInternal(f,!0,t,i,u),!(0,a.le)(u)&&u.length>0&&this.documentHelper.layout.layoutComments(u),(0,a.le)(this.pasteImageIndex)||this.pasteImageIndex.destroy(),this.pasteImageIndex=void 0,this.isInsertField=!1,this.isPasteListUpdated=!1,this.isLastParaMarkCopied=!1}},e.prototype.pasteContentsInternal=function(e,t,i,r,n){this.isPaste=t;var s,l=this.documentHelper.selection;if(l.start.paragraph.isInsideTable&&l.end.paragraph.isInsideTable){var d=!1;if(1===e.length){var h=e[0].childWidgets;h.length<3&&(1===h.length&&h[0]instanceof o.dm||2===h.length&&h[0]instanceof o.dm&&h[1].isEmpty())&&(d=!0)}if(d){var c=l.start.paragraph.associatedCell,p=l.end.paragraph.associatedCell,g=e[0].childWidgets[0];if((0,a.le)(r)||"MergeWithExistingFormatting"===r||"KeepSourceFormatting"===r||"KeepTextOnly"===r)c.ownerTable.equals(p.ownerTable)&&((0===l.start.paragraph.associatedCell.rowIndex&&0===l.end.paragraph.associatedCell.rowIndex||this.documentHelper.isDragging&&this.documentHelper.dragStartParaInfo&&this.documentHelper.dragStartParaInfo.paragraph.associatedCell&&this.documentHelper.dragStartParaInfo.paragraph.associatedCell.ownerTable.equals(c.ownerTable))&&c.equals(p)&&!this.selection.isCellSelected(c,l.start,l.end)&&(!this.isInternalPaste||this.isLastParaMarkCopied)&&(!this.documentHelper.isDragging||this.isLastParaMarkCopied)?(this.selection.currentPasteAction="InsertAsColumns",this.pasteAsNewColumn(g)):(this.selection.currentPasteAction="OverwriteCells",this.pasteOverwriteCell(g)));else switch(r){case"InsertAsColumns":this.selection.currentPasteAction="InsertAsColumns",this.pasteAsNewColumn(g);break;case"OverwriteCells":this.selection.currentPasteAction="OverwriteCells",this.pasteOverwriteCell(g);break;case"NestTable":this.selection.currentPasteAction="NestTable",this.pasteAsNestedTable(e);break;case"InsertAsRows":this.selection.currentPasteAction="InsertAsRows",this.pasteAsNewRow(g)}this.isPaste=!1;return}}s=this.checkAndRemoveComments(),this.defaultPaste(e,i,n,r),this.updateHistoryForComments(s)},e.prototype.defaultPaste=function(e,t,i,r){var o,n=this.documentHelper.selection,s=!0,l=!1;if(this.initComplexHistory("Paste"),this.documentHelper.isListTextSelected){var d=n.start.paragraph;d.paragraphFormat.listFormat&&-1!==d.paragraphFormat.listFormat.listId&&this.onApplyList(void 0)}if(this.initHistory("Paste"),(n.isEmpty||this.owner.documentHelper.isDragging&&this.owner.selection.isImageSelected)&&!this.documentHelper.isListTextSelected||(s=this.removeSelectedContentInternal(n,n.start,n.end)),(0,a.le)(t)&&!(0,a.le)(r)&&"MergeWithExistingFormatting"===r){var h=this.selection.isForward?this.selection.start:this.selection.end;t=h.paragraph.paragraphFormat}if(s?(l=this.pasteContent(e,t),this.owner.enableTrackChanges&&this.isInsertingTOC&&(0,a.le)(this.owner.documentHelper.blockToShift)&&(this.owner.documentHelper.blockToShift=this.selection.start.paragraph),this.isRemoteAction&&(this.updatePasteRevision(),this.owner.showRevisions&&this.owner.trackChangesPane.updateTrackChanges())):this.editorHistory&&(this.editorHistory.currentBaseHistoryInfo=void 0),this.editorHistory&&this.editorHistory.currentHistoryInfo){if(this.editorHistory.currentBaseHistoryInfo&&"Paste"===this.editorHistory.currentBaseHistoryInfo.action){this.editorHistory.currentBaseHistoryInfo.endRevisionLogicalIndex&&(this.editorHistory.currentBaseHistoryInfo.endRevisionLogicalIndex=void 0),this.isCurrentWholeDocumentPaste&&this.capturedOriginalHeaderFooters.length>0&&(this.editorHistory.currentBaseHistoryInfo.isWholeDocumentPaste=!0,this.editorHistory.currentBaseHistoryInfo.originalHeaderFooters=this.capturedOriginalHeaderFooters);var h=this.selection.getTextPosBasedOnLogicalIndex(this.editorHistory.currentBaseHistoryInfo.insertPosition),c=this.selection.getTextPosBasedOnLogicalIndex(this.editorHistory.currentBaseHistoryInfo.endPosition);if(!this.isRemoteAction){var p=(0,a.le)(this.owner.sfdtExportModule)?{}:this.owner.sfdtExportModule.write(this.owner.documentEditorSettings.optimizeSfdt?1:0,h.currentWidget,h.offset,c.currentWidget,c.offset,!1,!0);this.editorHistory.currentBaseHistoryInfo.pasteContent=p}!(0,a.le)(i)&&i.length>0&&(o=this.editorHistory.currentBaseHistoryInfo.pastedComments).push.apply(o,i)}this.editorHistory.updateHistory(),this.editorHistory.updateComplexHistory(),n.isHighlightContentControlEditRegion=!0}else this.reLayout(n,n.isEmpty);l&&(this.selection.pasteElement&&(this.selection.pasteElement.style.display="none"),!this.restrictLayout&&this.viewer.owner.enableLayout&&this.documentHelper.layout.layoutWholeDocument(!0)),this.isPaste=!1,this.positionForPasteIcon=void 0},e.prototype.pasteAsNewColumn=function(e){var t,i=!0;if(this.documentHelper.dragStartParaInfo&&(t=this.documentHelper.dragStartParaInfo.paragraph.associatedCell),!this.owner.isReadOnlyMode&&this.canEditContentControl&&this.selection.start.paragraph.isInsideTable){this.checkIsNotRedoing()&&this.initHistory("PasteColumn");var r=this.getOwnerCell(this.selection.isForward),o=r.ownerRow.ownerTable.combineWidget(this.owner.viewer);this.editorHistory&&this.cloneTableToHistoryInfo(o),t&&r.ownerTable&&r.ownerTable.equals(t.ownerTable)&&(i=!1);var n=this.owner.documentHelper.isDragging&&!i&&t&&r&&t.columnIndex===r.columnIndex;this.selection.owner.isLayoutEnabled=!1;var s=e.clone(),l=s.childWidgets[0],d=s.childWidgets.length,h=l.childWidgets.length,c=r.columnIndex,p=void 0,g=void 0,m=[];d>o.childWidgets.length?(this.addRows(d-o.childWidgets.length,o),this.tableUpdate(o)):o.childWidgets.length>d&&(this.addRows(o.childWidgets.length-d,s,o),this.tableUpdate(o));for(var u=0;u<h;u++)for(var f=0;f<o.childWidgets.length;f++){var y=o.childWidgets[f],v=s.childWidgets[f].childWidgets[u];
1if(!(0,a.le)(v)){var H=y.childWidgets[r.columnIndex];(g=this.createColumn(this.selection.getLastParagraph(r))).index=f,g.rowIndex=y.index,g.containerWidget=y;var C=y.previousWidget,F=this.rowspannedCollection(y,m);if(null!=H)g.cellFormat.copyFormat(H.cellFormat),g.cellFormat.rowSpan=1;else if(F.length>0)for(var w=0;w<F.length;w++)C.rowIndex+(F[w].cellFormat.rowSpan-1)>=y.rowIndex&&(g.cellFormat.copyFormat(F[w].cellFormat),g.cellFormat.rowSpan=1);v.containerWidget=g.containerWidget,g.childWidgets=v.childWidgets,(0,a.le)(p)&&(p=this.selection.getFirstParagraph(g));var I=(0===c?u:c)+(n?1:0);0===c?y.childWidgets.splice(I,0,g):this.insertSpannedCells(y,m,g,I)}}this.tableReLayout(o,p,g,!0)}},e.prototype.pasteAsNestedTable=function(e,t){var i=e[0].childWidgets[0];if(this.selection.start.paragraph.isInsideTable){this.checkIsNotRedoing()&&this.initHistory("PasteNested");var r=this.getOwnerCell(this.selection.isForward),n=r.ownerRow.ownerTable.combineWidget(this.owner.viewer);this.editorHistory&&this.cloneTableToHistoryInfo(n);var s=void 0,l=i.clone(),d=this.selection.end.paragraph.containerWidget,h=void 0;if(r!=d){for(var c=r.ownerRow;c!=d.ownerRow.nextRow;){for(var p=r.columnIndex;p<=d.columnIndex;p++){h=c.childWidgets[p];var g=l.clone(),m=new o.ZH;h.childWidgets=[],h.childWidgets[0]=g,h.childWidgets[1]=m,m.containerWidget=h,g.containerWidget=h,g.index=0,m.index=1,c.childWidgets[p]=h,(0,a.le)(s)&&(s=this.selection.getFirstParagraph(h))}c=c.nextRow}this.tableReLayout(n,s,h)}else this.defaultPaste(e,t)}},e.prototype.pasteOverwriteCell=function(e){if(this.selection.start.paragraph.isInsideTable){this.checkIsNotRedoing()&&this.initHistory("PasteOverwrite");var t=this.getOwnerCell(this.selection.isForward),i=t.ownerRow.ownerTable.combineWidget(this.owner.viewer);this.editorHistory&&this.cloneTableToHistoryInfo(i);var r=e.clone(),o=r.childWidgets.length,n=this.getOwnerCell(!this.selection.isForward);t.columnIndex;var s=t.rowIndex,l=void 0,d=this.selection.start.paragraph.associatedCell.ownerRow,h=r.childWidgets[0],c=void 0;h.childWidgets.length;var p=t.ownerRow;if(t!=n){for(var g=0,m=void 0,u=void 0,f=void 0,y=void 0,v=void 0;p!=n.ownerRow.nextRow;){for(var H=(h=r.childWidgets[g]||r.childWidgets[g=0]).childWidgets.length,C=0,F=t.columnIndex;F<=n.columnIndex;F++)if(h=r.childWidgets[g],v=p.getCell(p.index,F),!(0,a.le)(v)){m>1&&u===F&&(F++,m--,u=null),f>1&&C>=H-(f-1)&&(F+=(f=1)-1,C=0),y=(c=h.childWidgets[C]||h.childWidgets[C=0]).clone();for(var w=0;w<y.childWidgets.length;w++){var I=y.childWidgets[w];I.containerWidget=v,y.childWidgets[w]=I}this.owner.enableTrackChanges?this.replaceCellContents(v,y):v.childWidgets=y.childWidgets,c.cellFormat.rowSpan>1&&(m=c.cellFormat.rowSpan,u=F),c.cellFormat.columnSpan>1&&(f=c.cellFormat.columnSpan),(0,a.le)(l)&&(l=this.selection.getFirstParagraph(y)),C++}p=p.nextRow,g++}this.tableReLayout(i,l,v,!0)}else{for(var x=void 0,m=void 0,u=void 0,v=void 0,b=0;b<o;b++){for(var F=t.columnIndex,W=(h=r.childWidgets[b]).childWidgets.length,P=0;P<W;P++){var y=(c=h.childWidgets[P]).clone();if(m>1&&u===F&&(F++,m--,u=null),v=d.childWidgets[F]){for(var k=0;k<y.childWidgets.length;k++){var I=y.childWidgets[k];I.containerWidget=v,y.childWidgets[k]=I}this.owner.enableTrackChanges?(this.replaceCellContents(v,y),F++):(v.childWidgets=y.childWidgets,c.cellFormat.rowSpan>1&&(m=c.cellFormat.rowSpan,u=F),d.childWidgets.splice(F++,1,v))}else{(v=this.createColumn(void 0)).containerWidget=d,v.index=F,v.cellFormat.preferredWidth=y.cellFormat.cellWidth;for(var k=0;k<y.childWidgets.length;k++){var I=y.childWidgets[k];I.containerWidget=v,y.childWidgets[k]=I,this.owner.enableTrackChanges&&this.insertRevisionForBlock(I,"Insertion")}v.childWidgets=y.childWidgets,d.childWidgets.splice(F,1,v),F++}(0,a.le)(l)&&(l=this.selection.getFirstParagraph(v))}(0,a.le)(d.nextRow)&&o>i.childWidgets.length-s&&(x=o-i.childWidgets.length+s,this.addRows(x,i)),d=d.nextRow}this.tableReLayout(i,l,v,!0)}}},e.prototype.replaceCellContents=function(e,t){for(var i=0;i<e.childWidgets.length;i++){var r=e.childWidgets[i];if(r.childWidgets.length>0){if(r instanceof o.ZH)this.selection.start.setPosition(r.firstChild,!0),this.selection.end.setPositionParagraph(r.lastChild,r.lastChild.getEndOffset()+1);else{var n=this.documentHelper.getFirstParagraphBlock(r),s=this.documentHelper.getLastParagraphBlock(r),l=s.lastChild.getEndOffset();this.selection.start.setPosition(n.childWidgets[0],!0),this.selection.end.setPositionParagraph(s.lastChild,l+1),this.selection.selectPosition(this.selection.start,this.selection.end)}this.isPasteOverWriteCells=!0,this.deleteSelectedContents(this.selection,!0),this.isPasteOverWriteCells=!1}}var d=e.firstChild;if(!(0,a.le)(d)&&d instanceof o.ZH){if(d.isEmptyInternal(!0)){var h=new o.z7(d);d.childWidgets.push(h)}this.selection.selectParagraphInternal(d,!0)}for(var i=0;i<t.childWidgets.length;i++){var c=t.childWidgets[i];c instanceof o.ZH&&i===t.childWidgets.length-1?c.childWidgets.length>0&&c.childWidgets[0].children.length>0&&this.insertElement(c.childWidgets[0].children,c.paragraphFormat):(c instanceof o.dm&&this.generateTableRevision(c),this.insertBlockInternal(c))}},e.prototype.pasteAsNewRow=function(e){if(!this.owner.isReadOnlyMode&&this.canEditContentControl){this.checkIsNotRedoing()&&this.initHistory("PasteRow"),this.documentHelper.owner.isShiftingEnabled=!0;var t=this.getOwnerCell(this.selection.isForward).getSplitWidgets()[0],i=this.getOwnerCell(!this.selection.isForward).getSplitWidgets()[0],r=t.ownerTable.combineWidget(this.owner.viewer),n=i.ownerRow;this.editorHistory&&this.cloneTableToHistoryInfo(r),this.getRowCountToInsert(),this.getColumnCountToInsert();var s=[],a=n.rowIndex;a++;for(var l=e.childWidgets.length,d=0;d<l;d++){var h=e.childWidgets[d].clone();this.owner.enableTrackChanges&&this.insertRevision(h.rowFormat,"Insertion"),s.push(h)}r.insertTableRowsInternal(s,a,!1);var c=void 0,p=void 0;if(r.childWidgets[a]instanceof o.BC)c=r.childWidgets[a].firstChild,p=this.selection.getFirstParagraph(c);else{for(var g=void 0;!(g instanceof o.dm);)g=r.nextRenderedWidget;p=this.documentHelper.getFirstParagraphInFirstCell(g)}this.copyContent(r),this.documentHelper.layout.reLayoutTable(r),this.selection.selectParagraphInternal(p,!0),this.reLayout(this.selection,!0)}},e.prototype.tableUpdate=function(e){e.isGridUpdated=!1,e.calculateGrid(),e.buildTableColumns(),e.isGridUpdated=!0}
1,e.prototype.rowspannedCollection=function(e,t){for(var i=0;i<e.childWidgets.length;i++){var r=e.childWidgets[i];r.cellFormat.rowSpan>1&&t.push(r)}return t},e.prototype.insertSpannedCells=function(e,t,i,r){for(var o=!1,n=0;n<e.childWidgets.length;n++){var s=e.childWidgets[n];if(s.cellFormat.rowSpan>1&&t.push(s),s.columnIndex+s.cellFormat.columnSpan===r?(e.childWidgets.splice(s.cellIndex+1,0,i),o=!0):r>s.columnIndex&&s.columnIndex+s.cellFormat.columnSpan>r&&r<s.columnIndex+s.cellFormat.columnSpan&&(e.childWidgets.splice(s.cellIndex+1,0,i),o=!0),o)break}if(!o&&t.length>0)for(var a=0;a<t.length;a++){var l=t[a];if(l.ownerRow!==e&&e.rowIndex<=l.ownerRow.rowIndex+l.cellFormat.rowSpan-1&&(l.columnIndex+l.cellFormat.columnSpan===r?(l.cellIndex>e.childWidgets.length?e.childWidgets.push(i):e.childWidgets.splice(l.cellIndex+1,0,i),o=!0):r>l.columnIndex&&l.columnIndex+l.cellFormat.columnSpan>r&&r<l.columnIndex+l.cellFormat.columnSpan&&(e.childWidgets.splice(l.columnIndex,0,i),o=!0)),o)break}},e.prototype.addRows=function(e,t,i){if(!this.owner.isReadOnlyMode&&this.canEditContentControl){var r=this.selection.isForward?this.selection.start:this.selection.end;this.selection.isForward?this.selection.end:this.selection.start;var o=t.childWidgets.length,n=t.childWidgets[o-1],s=n.childWidgets.length;if(r.paragraph.isInsideTable){var a=this.getOwnerCell(this.selection.isForward).getSplitWidgets()[0],l=n.childWidgets[s-1],d=l.ownerRow;this.rowInsertion(e,"Below",a,l,d,t,!1)}}},e.prototype.pasteContent=function(e,t){this.documentHelper.owner.isShiftingEnabled=!0;var i="";if(this.editorHistory&&this.editorHistory.currentBaseHistoryInfo)this.editorHistory.currentBaseHistoryInfo.insertPosition=void 0,this.updateInsertPosition(),i=this.editorHistory.currentBaseHistoryInfo.insertPosition;else{var o=this.selection.start;this.selection.isForward||(o=this.selection.end);var n=this.selection.getParagraphInfo(o);i=this.selection.getHierarchicalIndex(n.paragraph,n.offset.toString())}this.documentHelper.owner.isLayoutEnabled=!0,this.documentHelper.owner.isPastingContent=!0;var s=this.pasteCopiedData(e,t),a="";if(this.updateEndPosition(),this.editorHistory&&this.editorHistory.currentBaseHistoryInfo)a=this.editorHistory.currentBaseHistoryInfo.endPosition;else{var n=this.selection.getParagraphInfo(this.selection.start);a=this.selection.getHierarchicalIndex(n.paragraph,n.offset.toString())}this.selection.start.paragraph.isEmpty()&&this.selection.start.paragraph.paragraphFormat.bidi&&this.documentHelper.layout.reLayoutParagraph(this.selection.start.paragraph,0,0);var l=new r.JK(this.documentHelper.owner);this.setPositionForCurrentIndex(l,i);var d=new r.JK(this.documentHelper.owner);return this.setPositionForCurrentIndex(d,a),this.pasteTextPosition={startPosition:l,endPosition:d},this.documentHelper.owner.isPastingContent=!1,this.documentHelper.selection.fireSelectionChanged(!0),s},e.prototype.pasteCopiedData=function(e,t){var i=this.selection.start.paragraph.isInsideTable,n=!1,s=!1;if(this.documentHelper.layout.isBidiReLayout&&(this.documentHelper.layout.isBidiReLayout=!1),this.isPaste&&this.isSectionEmpty(this.selection)&&!this.selection.start.paragraph.isInHeaderFooter){if(this.previousSectionFormat=new l.Z,this.previousSectionFormat.copyFormat(this.selection.start.paragraph.bodyWidget.sectionFormat),this.selection.start.paragraph.bodyWidget.sectionFormat.copyFormat(e[0].sectionFormat),this.selection.start.paragraph.bodyWidget.sectionFormat.footerDistance=this.previousSectionFormat.footerDistance,this.selection.start.paragraph.bodyWidget.sectionFormat.headerDistance=this.previousSectionFormat.headerDistance,this.owner.viewer instanceof x._){var d=this.selection.start.paragraph.bodyWidget.page;this.owner.viewer.updatePageBoundingRectangle(this.selection.start.paragraph.bodyWidget,d,d.boundingRectangle.y),this.owner.viewer.updateClientArea(this.selection.start.paragraph.bodyWidget,d)}n=!0}var h=this.selection.start.paragraph.isInsideTable;this.documentHelper.layout.isPastingContent=!0;for(var c=0;c<e.length;c++){0!==c&&this.insertSectionBreak(e[c].sectionFormat.breakCode,e[c].sectionFormat);for(var p=e[c].childWidgets,g=this.isPaste&&!this.isInsertingTOC&&this.isCurrentContentControlInline(),m=c===e.length-1,u=0;u<p.length;u++){var f=u===p.length-1;f&&(i=!f),f&&m&&(this.documentHelper.layout.isPastingContent=!1);var y=p[u];
1if(y instanceof o.dm&&this.isRTFContentPasting&&y.tableFormat&&(y.tableFormat.isRTFTable=!0),y instanceof o.ZH&&0===y.childWidgets.length&&(y.childWidgets[0]=new o.z7(y)),y instanceof o.ZH&&!(0,a.le)(t)){y.paragraphFormat.copyFormat(t);var v=this.copyInsertFormat(this.selection.start.paragraph.characterFormat,!1);y.characterFormat.mergeFormat(v)}if(u!==p.length-1&&this.isPaste&&(0,a.le)(t)&&this.previousParaFormat&&y instanceof o.ZH&&!(0,a.le)(y.paragraphFormat.listFormat)&&(0,a.le)(y.paragraphFormat.listFormat.list)&&-1===y.paragraphFormat.listFormat.listId){if(this.previousParaFormat.listFormat&&this.previousParaFormat.listFormat.list&&-1!==this.previousParaFormat.listFormat.listId)y.paragraphFormat.listFormat.copyFormat(this.previousParaFormat.listFormat),y.paragraphFormat.leftIndent=this.previousParaFormat.leftIndent,y.paragraphFormat.firstLineIndent=this.previousParaFormat.firstLineIndent,this.previousParaFormat.baseStyle instanceof b.wk&&(y.paragraphFormat.baseStyle.name=this.previousParaFormat.baseStyle.name);else if(this.previousParaFormat.baseStyle&&this.previousParaFormat.baseStyle instanceof b.wk&&this.previousParaFormat.baseStyle.paragraphFormat.listFormat&&this.previousParaFormat.baseStyle.paragraphFormat.listFormat.list&&-1!==this.previousParaFormat.baseStyle.paragraphFormat.listFormat.listId){var H=this.previousParaFormat.baseStyle.paragraphFormat;y.paragraphFormat.listFormat.copyFormat(H.listFormat),y.paragraphFormat.leftIndent=H.leftIndent,y.paragraphFormat.firstLineIndent=H.firstLineIndent}}if(y instanceof o.dm&&g){u++;continue}if(u===p.length-1&&y instanceof o.ZH&&(!(0,a.le)(y.paragraphFormat.listFormat)&&(0,a.le)(y.paragraphFormat.listFormat.list)&&-1===y.paragraphFormat.listFormat.listId||this.isInsertField)||g){if(y.childWidgets.length>0&&y.childWidgets[0].children.length>0){var C=this.selection.start;("Center"===C.paragraph.paragraphFormat.textAlignment||"Right"===C.paragraph.paragraphFormat.textAlignment)&&-1===C.paragraph.paragraphFormat.listFormat.listId&&(C.paragraph.x=this.owner.viewer.clientActiveArea.x),!(0,a.le)(this.editorHistory)&&this.editorHistory.currentBaseHistoryInfo&&this.editorHistory.currentBaseHistoryInfo.insertedNodes.push(y.clone()),s=this.insertElement(y.childWidgets[0].children,y.paragraphFormat,!0)}else if(f&&m){var F=this.selection.start.paragraph;this.documentHelper.layout.reLayoutParagraph(F,0,0,F.paragraphFormat.bidi)}}else if(y instanceof o.qc){var w=this.selection.start.paragraph;if(y instanceof o.dm){if(this.generateTableRevision(y),w.isInsideTable){var I=w.getContainerWidth();y.fitCellsToClientArea(I)}if(w.isEmpty()&&w.previousWidget instanceof o.dm&&!this.isPaste)return this.insertTableRows(y,w.previousWidget),n}this.insertBlockInternal(y,void 0,i,this.isRemoteAction,!0),y instanceof o.dm&&(this.lastElementForPasteIcon=void 0)}}}if(this.lastElementForPasteIcon&&this.lastElementForPasteIcon instanceof o.a3&&!h){var W=this.lastElementForPasteIcon.line.getOffset(this.lastElementForPasteIcon,this.lastElementForPasteIcon.length);this.positionForPasteIcon=new r.JK(this.owner),this.positionForPasteIcon.setPositionParagraph(this.lastElementForPasteIcon.line,W,!0),this.lastElementForPasteIcon=void 0}if(this.documentHelper.layout.isPastingContent=!1,!(0,a.le)(this.documentHelper.currentPage)){var P=this.documentHelper.currentPage;if(!(0,a.le)(P.endnoteWidget)&&!(0,a.le)(P.bodyWidgets)&&P.bodyWidgets.length>0){var k=P.bodyWidgets[P.bodyWidgets.length-1];if(k){var R=!(0,a.le)(k.childWidgets)&&k.childWidgets.length>0?k.childWidgets[k.childWidgets.length-1]:null;R&&P.endnoteWidget.y<=R.y+R.height&&(s=!0)}}}return s&&(n=!0,"Footnote"===this.pasteFootNoteType?this.arrangeFootnoteCollection():"Endnote"===this.pasteFootNoteType&&this.arrangeEndnoteCollection()),!n&&(0,a.le)(this.documentHelper.blockToShift)&&this.shiftFootnoteContent(),n},e.prototype.isCurrentContentControlInline=function(){var e=this.selection.start.currentWidget.getInline(this.selection.start.offset,0);return!!e.element&&("Inline"===e.element.contentControlWidgetType||!!e.element.contentControlProperties&&"Inline"===e.element.contentControlProperties.contentControlWidgetType)},e.prototype.arrangeEndnoteCollection=function(){for(var e=0;e<this.documentHelper.endnoteCollection.length;e++)for(var t=0;t<this.documentHelper.endnoteCollection.length-1-e;t++){var i=this.selection.getElementPosition(this.documentHelper.endnoteCollection[t]).startPosition,r=this.selection.getElementPosition(this.documentHelper.endnoteCollection[t+1]).startPosition;if(!i.isExistBefore(r)){var o=this.documentHelper.endnoteCollection[t];this.documentHelper.endnoteCollection[t]=this.documentHelper.endnoteCollection[t+1],this.documentHelper.endnoteCollection[t+1]=o}}},e.prototype.arrangeFootnoteCollection=function(){for(var e=0;e<this.documentHelper.footnoteCollection.length;e++)for(var t=0;t<this.documentHelper.footnoteCollection.length-1-e;t++){var i=this.selection.getElementPosition(this.documentHelper.footnoteCollection[t]).startPosition,r=this.selection.getElementPosition(this.documentHelper.footnoteCollection[t+1]).startPosition;if(!i.isExistBefore(r)){var o=this.documentHelper.footnoteCollection[t];this.documentHelper.footnoteCollection[t]=this.documentHelper.footnoteCollection[t+1],this.documentHelper.footnoteCollection[t+1]=o}}},e.prototype.generateTableRevision=function(e){if(this.owner.enableTrackChanges&&!(0,a.le)(e))for(var t=0;t<e.childWidgets.length;t++){var i=e.childWidgets[t];this.insertRevision(i.rowFormat,"Insertion");for(var r=0;r<i.childWidgets.length;r++)for(var n=i.childWidgets[r],s=0;s<n.childWidgets.length;s++){var l=n.childWidgets[s];(0,a.le)(l)||(l instanceof o.ZH?this.insertRevisionForBlock(l,"Insertion"):this.generateTableRevision(l))}}},e.prototype.isSectionEmpty=function(e){var t=e.start.paragraph;if(t){if(t.isInsideTable||t.isInHeaderFooter||t!==e.end.paragraph)return!1;var i=t.bodyWidget;if(i){var r=i.page;if(r&&((0,a.le)(r.previousPage)||r.previousPage.sectionIndex!==r.sectionIndex)&&(0,a.le)(r.nextPage)&&t.isEmpty()&&1===i.childWidgets.length){var n=!0,s=e.start.paragraph.bodyWidget.sectionIndex,l=this.documentHelper.headersFooters[s];if(l){for(var d in l){var h=l[d];if((0,a.le)(h))n=!1;else{var c=h.childWidgets[0];c instanceof o.dm?n=!1:c instanceof o.ZH&&!c.isEmpty()&&(n=!1)}if(!n)break}return n}}}}return!1},e.prototype.insertTableInternal=function(e,t,i,r){var n,s=e.index;r||!e.isInsideTable||t.isInsideTable||(e=this.documentHelper.layout.getParentTable(e));var l=this.selection.start.paragraph;if(!e.isInsideTable&&t.isInsideTable&&(s=t.index,r=!0,n=l.containerWidget),i)for(var d=0,h=0;d<e.childWidgets.length;d++,h++){var c=e.childWidgets[d];t.childWidgets.splice(h,0,c),c.containerWidget=t,e.childWidgets.splice(d,1),d--}if(!l.isInsideTable&&(0,a.le)(n)?(e.containerWidget=l.containerWidget,n=l.containerWidget):(0,a.le)(n)&&(n=e.containerWidget),e.isInsideTable&&(n=n.combineWidget(this.owner.viewer)),r||this.removeBlock(e,!0,!1,!1,!0),this.removeRevisionFromTable(t),n instanceof o.nb)n=n.combineWidget(this.owner.viewer);else{var p=this.documentHelper.layout.checkAndGetBlock(n,s);-1!==n.childWidgets.indexOf(p)&&(s=n.childWidgets.indexOf(p))}n.childWidgets.splice(s,0,t),r||(e.containerWidget=void 0,t.index=e.index),t.containerWidget=n,this.updateNextBlocksIndex(t,!0),this.documentHelper.layout.clearTableWidget(t,!0,!0,!0),t.buildTableColumns(),this.constructRevisionsForTable(t,!0),t.isGridUpdated=!0,this.documentHelper.layout.linkFieldInTable(t),this.documentHelper.layout.layoutBodyWidgetCollection(t.index,n,t,!1)},e.prototype.removeRevisionFromTable=function(e){for(var t=0;t<e.childWidgets.length;t++){var i=e.childWidgets[t];
1if(i.rowFormat.revisionLength>0){for(var r=0;r<i.rowFormat.revisionLength;r++)if(0===i.rowFormat.getAllRevision()[r].getRange().length){var n=i.rowFormat.getAllRevision().indexOf(i.rowFormat.getAllRevision()[r]);i.rowFormat.removeRevision(n),r--}}for(var r=0;r<i.childWidgets.length;r++)for(var s=i.childWidgets[r],a=0;a<s.childWidgets.length;a++){var l=s.childWidgets[a];l instanceof o.dm&&this.removeRevisionFromTable(l)}}},e.prototype.canConstructRevision=function(e){return!!(e.revisionLength>0&&((0,a.le)(e.getRevision(0).ownerNode)||0===e.getRevision(0).getRange().length))||e.removedIds.length>0},e.prototype.constructRevisionsForTable=function(e,t){for(var i=0;i<e.childWidgets.length;i++){var r=e.childWidgets[i];if(t){this.canConstructRevision(r.rowFormat)&&this.constructRevisionFromID(r.rowFormat);for(var n=0;n<r.childWidgets.length;n++)for(var s=r.childWidgets[n],a=0;a<s.childWidgets.length;a++)s.childWidgets[a]instanceof o.ZH?this.constructRevisionsForBlock(s.childWidgets[a],t):s.childWidgets[a]instanceof o.dm&&this.constructRevisionsForTable(s.childWidgets[a],!0)}else this.addRemovedRevisionInfo(r.rowFormat),this.removeRevisionsInRow(r,!0,!0)}},e.prototype.constructRevisionForFootnote=function(e,t){for(var i=0;i<e.bodyWidget.childWidgets.length;i++)e.bodyWidget.childWidgets[i]instanceof o.ZH&&this.constructRevisionsForBlock(e.bodyWidget.childWidgets[i],t)},e.prototype.constructRevisionsForBlock=function(e,t){for(var i=0;i<e.childWidgets.length;i++)for(var r=e.childWidgets[i],n=0;n<r.children.length;n++)if(t&&(r.children[n]instanceof o.nR&&this.canConstructRevision(r.children[n])&&this.constructRevisionFromID(r.children[n]),r.children[n]instanceof o.R5)){var s=r.children[n];this.constructRevisionForFootnote(s,t)}this.canConstructRevision(e.characterFormat)&&this.constructRevisionFromID(e.characterFormat)},e.prototype.applyRevisionForCurrentPara=function(e,t,i,r,n){var s=e.getInline(t+1,0),l=s.element;s.element instanceof o.a3&&""===s.element.text&&!(0,a.le)(s.element.previousElement)&&(l=s.element.previousElement);var d=!1;t===e.getLength()&&(d=!0),t===i&&e.nextSplitWidget&&(i+=l.length);var h=e.getInline(i,0).element;(0,a.le)(e.nextSplitWidget)||(n=!1);var c=0,p=e;if(p.nextSplitWidget)for(;p;)(0,a.le)(p)||(c+=p.getLength()),p=p.nextSplitWidget;else for(;p;)(0,a.le)(p)||(c+=p.getLength()),p=p.previousSplitWidget;if((0,a.le)(e.previousSplitWidget)||0===c||t===c||(d=!1),i>c&&(n=!0),n)e.characterFormat.removedIds=[],e.characterFormat.removedIds.push(r),this.constructRevisionFromID(e.characterFormat,!0);else if((0,a.le)(l)||(0,a.le)(h))(0,a.le)(l)||d?(0,a.le)(h)||(h.removedIds.push(r),this.constructRevisionFromID(h,!0)):(l.removedIds.push(r),this.constructRevisionFromID(l,!0));else if(d||l!==h){for(;!(0,a.le)(l)&&l!==h;)d||(l.removedIds.push(r),this.constructRevisionFromID(l,!0)),(0,a.le)(l.nextNode)||(l=l.nextNode instanceof o.aQ?l.nextNode:l.nextNode.nextValidNodeForTracking),d=!1;(0,a.le)(l)||d||(l.removedIds.push(r),this.constructRevisionFromID(l,!0))}else l.removedIds.push(r),this.constructRevisionFromID(l,!0)},e.prototype.insertBlockTable=function(e,t,i){var r=e.start.offset;e.start.paragraph.childWidgets.indexOf(e.start.currentWidget),t instanceof o.ZH&&r>0&&(this.moveInlines(e.start.paragraph,t,0,0,e.start.paragraph.firstChild,r,e.start.currentWidget),e.selectParagraphInternal(e.start.paragraph,!0),this.checkInsertPosition(e)&&this.updateHistoryPosition(this.selection.getHierarchicalIndex(t,r.toString()),!0)),r>0&&this.checkInsertPosition(e)&&this.updateHistoryPosition(e.start,!0);var n=i.indexInOwner;if(i.containerWidget.childWidgets.splice(n,0,t),t.containerWidget=i.containerWidget,t.index=i.index,this.updateNextBlocksIndex(t,!0),t instanceof o.ZH&&this.constructRevisionsForBlock(t,!0),this.documentHelper.layout.layoutBodyWidgetCollection(t.index,t.containerWidget,t,!1),this.checkInsertPosition(e)){var s=void 0;t instanceof o.ZH&&(s=t),t instanceof o.dm&&(s=this.documentHelper.getFirstParagraphInFirstCell(t)),this.updateHistoryPosition(this.selection.getHierarchicalIndex(s,"0"),!0)}},e.prototype.handleCut=function(e){var t=e.start,i=e.end,o=this.checkAndRemoveComments();e.isForward||(t=e.end,i=e.start),t.paragraph===i.paragraph&&t.offset+1===i.offset&&t.paragraph.getInline(i.offset,0).element;var n=this.selection.getParagraphInfo(t);e.editPosition=this.selection.getHierarchicalIndex(n.paragraph,n.offset.toString()),this.initHistory("Cut"),e.owner.isShiftingEnabled=!0,this.editorHistory&&this.editorHistory.currentBaseHistoryInfo&&this.checkInsertPosition(e)&&this.updateHistoryPosition(e.editPosition,!0),this.deleteSelectedContent(i.paragraph,e,t,i,3);var s=new r.JK(e.owner);this.setPositionForCurrentIndex(s,e.editPosition),e.selectContent(s,!0),this.editorHistory&&this.editorHistory.currentBaseHistoryInfo&&this.checkEndPosition(e)&&this.updateHistoryPosition(e.end,!1),this.reLayout(e),this.updateHistoryForComments(o)},e.prototype.insertInlineInternal=function(e,t){var i=this.selection,r=e.length,n=this.selection.getParagraphInfo(i.start);
1if(t=(0,a.le)(t)?"Insertion":t,i.start.paragraph.isEmpty()){var s=i.start.paragraph;("Center"===s.paragraphFormat.textAlignment||"Right"===s.paragraphFormat.textAlignment)&&-1===s.paragraphFormat.listFormat.listId&&(s.x=this.owner.viewer.clientActiveArea.x);var l=!(0,a.le)(this.editorHistory)&&(this.editorHistory.isUndoing||this.editorHistory.isRedoing);s.childWidgets[0].children.push(e),e.line=s.childWidgets[0],this.owner.enableTrackChanges&&e.isValidNodeForTracking&&!l&&!(!(0,a.le)(this.editorHistory)&&!(0,a.le)(this.editorHistory.currentBaseHistoryInfo)&&"InsertHyperlink"===this.editorHistory.currentBaseHistoryInfo.action)&&this.insertRevision(e,t),(e.removedIds.length>0||l)&&this.constructRevisionFromID(e),e.linkFieldCharacter(this.documentHelper),e instanceof o.R5&&(this.constructRevisionForFootnote(e,!0),l&&(e.isLayout=!1),"Footnote"===e.footnoteType&&this.updateFootnoteCollection(e),"Endnote"===e.footnoteType&&this.updateEndnoteCollection(e)),this.documentHelper.layout.reLayoutParagraph(s,0,0,void 0,void 0)}else{var d=0,h=i.start.currentWidget.getInline(i.start.offset,d),c=h.element;d=h.index,this.insertElementInternal(c,e,d,t,!0)}this.setPositionParagraph(n.paragraph,n.offset+r,!0),this.checkToSplitRevisionInPrevNxt(e)},e.prototype.insertElement=function(e,t,i){var r=!1,s=this.selection,l=0,d=void 0,h=-1,c=void 0,p=0,g=void 0,m=void 0,u=this.selection.getParagraphInfo(s.start),f=this.owner.enableTrackChanges,y=void 0,v=void 0,H=0;if(s.start.paragraph.isEmpty())c=(d=s.start.paragraph).childWidgets[0],h=0;else{var C=s.start.currentWidget.getInline(s.start.offset,H);y=C.element,H=C.index,h=(d=y.line.paragraph).childWidgets.indexOf(y.line),p=y.indexInOwner,c=y.line;var F=y.nextNode;if(this.isPaste&&y instanceof o.h&&0==y.type&&!(0,a.le)(F)&&F instanceof o.h&&1==F.type&&(m=!0),this.isPaste&&d.isInsideTable&&y instanceof o.h&&1===y.type&&H===y.length&&!(0,a.le)(d.associatedCell)&&!(0,a.le)(d.associatedCell.ownerRow)){var w=d.associatedCell.ownerRow.ownerTable;(0,a.le)(w)||(0,a.le)(w.contentControlProperties)||(H=0)}if(H===y.length)p++,g=!1;else if(0===H)(0,a.le)(y.previousNode)&&(p=0),g=!0;else{p++,(v=new o.a3).characterFormat.copyFormat(y.characterFormat),v.text=y.text.substring(H),y.text=y.text.slice(0,H);for(var I=0;I<y.revisionLength;I++)v.addRevision(y.getRevision(I));y.isWidthUpdated=!1,c.children.splice(p,0,v),v.line=y.line,y.revisionLength>0&&!this.owner.enableTrackChanges&&this.splitRevisionForSpittedElement(y,v)}}for(var x=0;x<e.length;x++){l+=e[x].length,e[x]instanceof o.a3&&e[x].text.indexOf(" ")>=0&&(this.documentHelper.triggerSpellCheck=!0);var b=e[x].revisionLength;if(e[x].isChangeDetected=!0,c.children.splice(p,0,e[x]),e[x].line=c,e[x].linkFieldCharacter(this.documentHelper),i&&!f)this.updateRevisions(e[x]);else{var W=this.updateRevisionForElement(y,e[x],H,0===x,v,g);!f||W||e[x].revisionLength!==b||(this.checkToSplitRevisionInPrevNxt(e[x]),e[x]instanceof o.aQ||e[x]instanceof o.Xw||e[x]instanceof o.Cw||e[x]instanceof o.jn||this.insertRevision(e[x],"Insertion"))}y=e[x],p++,e[x]instanceof o.R5&&(this.pasteFootNoteType=e[x].footnoteType,r=!0)}if((!this.isPaste||m)&&t&&((0,a.le)(d.paragraphFormat.listFormat.list)||!(0,a.le)(d.paragraphFormat.listFormat)&&-1===d.paragraphFormat.listFormat.listId)&&d.paragraphFormat.copyFormat(t),this.isPaste){if(this.isRemoteAction)for(var P=t.ownerBase.characterFormat.getAllRevision(),k=!1,x=0;x<P.length;x++){d.characterFormat.addRevision(P[x]);for(var R=P[x].getRange(),T=0;T<R.length;T++)if(R[T]instanceof n.a&&R[T]==t.ownerBase.characterFormat){k=!0;break}if(k)break}d.textWrapWidth=!1,this.viewer.updateClientAreaForBlock(d,!0),d.x=this.viewer.clientActiveArea.x}return this.documentHelper.layout.reLayoutParagraph(d,h,0,this.isInsertField?void 0:d.paragraphFormat.bidi),this.setPositionParagraph(u.paragraph,u.offset+l,!0),r},e.prototype.updateRevisionForElement=function(e,t,i,r,o,n){if(!this.owner.enableTrackChanges||(0,a.le)(e)&&(0,a.le)(o))return!1;var s=!!(0,a.le)(n),l=t.revisionLength;if(!r)return this.insertRevisionAtEnd(e,t,"Insertion");if(s)this.checkToMapRevisionWithInlineText(e,i,t,!1,"Insertion")||t.revisionLength>l?this.copyElementRevision(e,o):0===t.revisionLength&&(this.splitRevisionForSpittedElement(e,o),this.insertRevision(t,"Insertion"));else if(n)return this.insertRevisionAtBegining(e,t,"Insertion");else return this.insertRevisionAtEnd(e,t,"Insertion");return!1},e.prototype.insertElementInternal=function(e,t,i,r,n,s){var l=e.line,d=l.paragraph,h=l.indexInOwner,c=e.indexInOwner,p=d.paragraphFormat.bidi&&e.isRightToLeft,g=!1;r=(0,a.le)(r)?"Insertion":r;var m=this.skipTracking(),u=this.owner.enableTrackChanges,f=!1;if(this.owner.editorHistoryModule&&(this.owner.editorHistoryModule.isUndoing||this.owner.editorHistoryModule.isRedoing)&&t instanceof o.a3&&(g=e.characterFormat.isEqualFormat(t.characterFormat)&&this.documentHelper.textHelper.isRTLText(t.text)),this.editorHistory&&this.editorHistory.currentHistoryInfo&&(this.editorHistory.isUndoing||this.editorHistory.isRedoing||(this.editorHistory.currentHistoryInfo.isTrackingEnabled=u),(this.editorHistory.isUndoing||this.editorHistory.isRedoing)&&!(0,a.le)(this.editorHistory.currentHistoryInfo.isTrackingEnabled)&&(u=this.editorHistory.currentHistoryInfo.isTrackingEnabled)),t.line=l,g)e.text=e.text.substring(0,i)+t.text+e.text.substring(i),e.isWidthUpdated=!1;else if(i===e.length)c=this.incrementCommentIndex(p,e,c),l.children.splice(c,0,t),t.removedIds.length>0||m?this.constructRevisionFromID(t,!1):!u||m||this.skipFieldDeleteTracking||(f=this.insertRevisionAtEnd(e,t,r)),t instanceof o.R5&&(t.revisionLength>0&&(this.footnoteRevision=t.getRevision(0)),this.constructRevisionForFootnote(t,!0),this.footnoteRevision=void 0),t instanceof o.V8&&2===t.fieldType&&this.constructRevisionsForLink(t,!1),!f&&(e.revisionLength>0&&!u&&0===t.removedIds.length?t instanceof o.Xw&&(1===t.commentType?this.checkToSplitRevisionInPrevNxt(t):this.copyElementRevision(e,t)):u&&t instanceof o.Xw&&(1!==t.commentType||(0,a.le)(this.retrieveRevisionByType(e,"Deletion"))?this.copyElementRevision(e,t):this.checkToSplitRevisionInPrevNxt(t)));else if(0===i)(0,a.le)(e.previousNode)?(e.line.children.splice(0,0,t),c=0):e.line.children.splice(c,0,t),t.removedIds.length>0||m?this.constructRevisionFromID(t,!1):!u||m||this.skipFieldDeleteTracking||(f=this.insertRevisionAtBegining(e,t,r));else if(this.editorHistory&&this.editorHistory.currentBaseHistoryInfo&&this.editorHistory.currentBaseHistoryInfo.isHyperlinkField&&t instanceof o.V8&&1===t.fieldType&&t.removedIds.length>0)l.children.splice(c,0,t),this.constructRevisionFromID(t,!1);else{c=this.incrementCommentIndex(p,e,c);var y=new o.a3;y.characterFormat.copyFormat(e.characterFormat),y.text=e.text.substring(i),e.text=e.text.substr(0,i),e.isWidthUpdated=!1,y.isChangeDetected=!0,l.children.splice(c,0,y),y.line=e.line,f=!0,l.children.splice(c,0,t),!(e.revisionLength>0)||u||m||0!==t.removedIds.length||(t instanceof o.Xw?(this.copyElementRevision(e,y),1===t.commentType?this.splitRevisionForSpittedElement(e,y):this.copyElementRevision(e,t)):this.copyElementRevision(e,y)),this.isTrackingFormField=e.previousElement instanceof o.V8,t.removedIds.length>0&&!this.isTrackingFormField?(this.constructRevisionFromID(t,!1),this.copyElementRevision(e,y)):u&&(t instanceof o.aQ||t instanceof o.Xw||t instanceof o.Cw||t instanceof o.jn?t instanceof o.Xw?(this.copyElementRevision(e,y),1!==t.commentType||(0,a.le)(this.retrieveRevisionByType(e,"Deletion"))?this.copyElementRevision(e,t):this.splitRevisionForSpittedElement(e,y)):this.copyElementRevision(e,y):this.checkToMapRevisionWithInlineText(e,i,t,p,r)?this.copyElementRevision(e,y):(this.copyElementRevision(e,y),this.splitRevisionForSpittedElement(e,y),this.insertRevision(t,r))),c-=1}if(t instanceof o.a3&&(t.isChangeDetected=!0),t instanceof o.aQ){var v=this.documentHelper.bookmarks;t.reference&&(t.reference.reference=t),v.containsKey(t.name)||v.add(t.name,t)}!(0,a.le)(t.line.paragraph.containerWidget)&&!(0,a.le)(t.line.paragraph.containerWidget.containerWidget)&&t.line.paragraph.containerWidget.containerWidget instanceof o.tf&&(t.line.paragraph.containerWidget.containerWidget.height+=t.height),t.linkFieldCharacter(this.documentHelper),t instanceof o.h&&0===t.type&&(this.insertContentControlInCollection(t),this.owner.editorHistoryModule&&(this.owner.editorHistoryModule.isUndoing||this.owner.editorHistoryModule.isRedoing)&&this.updatePropertiesToBlock(t,!0)),(t instanceof o.XY&&"Inline"!==t.textWrappingStyle||t instanceof o.f7)&&(-1===d.floatingElements.indexOf(t)&&d.floatingElements.push(t),-1===d.bodyWidget.floatingElements.indexOf(t)&&"Inline"!==t.textWrappingStyle&&d.bodyWidget.floatingElements.push(t)),!u||f||m||this.skipFieldDeleteTracking||this.isInsertingTOC||t instanceof o.aQ||t instanceof o.Xw||t instanceof o.Cw||t instanceof o.jn||this.insertRevision(t,r),t instanceof o.R5&&(m&&(t.isLayout=!1),"Footnote"===t.footnoteType&&(this.updateFootnoteCollection(t),this.updateFootNoteIndex()),"Endnote"===t.footnoteType&&(this.updateEndnoteCollection(t),this.updateEndNoteIndex())),t instanceof o.Xw||this.combineElementRevisionToPrevNxt(t),n&&!s?this.documentHelper.layout.reLayoutParagraph(d,h,c,void 0,void 0):s&&t instanceof o.aQ&&this.documentHelper.layout.updateMargin(l)},e.prototype.incrementCommentIndex=function(e,t,i){return(!this.owner.editorHistoryModule||!(this.owner.editorHistoryModule&&this.owner.editorHistoryModule.currentHistoryInfo)||this.owner.editorHistoryModule&&this.owner.editorHistoryModule.currentHistoryInfo&&("SkipCommentInline"!==this.owner.editorHistoryModule.currentHistoryInfo.action||"SkipCommentInline"===this.owner.editorHistoryModule.currentHistoryInfo.action&&(this.owner.editorHistoryModule.currentHistoryInfo.modifiedActions[0]===this.editorHistory.currentBaseHistoryInfo||this.owner.editorHistoryModule.currentHistoryInfo.modifiedActions[0]!==this.editorHistory.currentBaseHistoryInfo&&!(t instanceof o.Xw))))&&i++,i},e.prototype.constructRevisionFromID=function(e,t){if(e.removedIds.length>0){for(var i=0;i<e.removedIds.length;i++){var r=void 0;this.documentHelper.revisionsInternal.containsKey(e.removedIds[i])&&((r=this.documentHelper.revisionsInternal.get(e.removedIds[i])).ownerNode=this.getOwnerNodeForRevision(e),e.addRevision(r),(0,a.le)(this.editorHistory)||(0,a.le)(this.editorHistory.currentBaseHistoryInfo)||this.editorHistory.currentBaseHistoryInfo.markerData.push(this.getMarkerData(e,void 0,r)),t||this.owner.trackChangesPane.updateCurrentTrackChanges(r),this.updateRevisionCollection(r))}e.removedIds=[]}else for(var i=0;i<e.revisionLength;i++){var o=e.getRevision(i);this.documentHelper.revisionsInternal.containsKey(o.revisionID)&&((o=this.documentHelper.revisionsInternal.get(o.revisionID)).ownerNode=this.getOwnerNodeForRevision(e),e.removeRevision(i),e.insertRevisionAt(i,o),this.updateRevisionCollection(o))}},e.prototype.insertBlock=function(e,t){var i=!0,r=!1,n=this.selection;if(n.isEmpty||(i=this.removeSelectedContents(n),r=!0),i||n.selectContent(n.start,!1),this.insertBlockInternal(e,r,t),this.checkInsertPosition(n)){var s=void 0;s=e instanceof o.ZH?e:this.documentHelper.getFirstParagraphInFirstCell(e),this.updateHistoryPosition(this.selection.getHierarchicalIndex(s,"0"),!0)}this.fireContentChange()},e.prototype.updateRevisions=function(e){for(var t=0;t<e.revisionLength;t++)this.updateRevisionCollection(e.getRevision(t))},e.prototype.insertBlockInternal=function(e,t,i,r,n){var s=this.selection,l=this.selection.start.paragraph,d=this.selection.start.isAtParagraphStart,h=this.skipTracking();if(this.selection.getLineLength(this.selection.start.currentWidget)+1===this.selection.start.offset&&(this.selection.start.offset-=1),!s.start.isAtParagraphStart){if(e instanceof o.ZH){var c=this.selection.startOffset;if((0,a.le)(this.editorHistory)||!this.editorHistory.currentBaseHistoryInfo||this.editorHistory.isUndoing||this.editorHistory.isRedoing||this.editorHistory.currentBaseHistoryInfo.insertedNodes.push(e.clone()),this.insertNewParagraphWidget(e,!1),!this.skipTracking()&&!r){for(var p=this.documentHelper.selection.getTextPosBasedOnLogicalIndex(c),g=this.selection.getElementInfo(p.currentWidget,p.offset).element.nextNode,m=void 0;!(0,a.le)(g);)this.owner.enableTrackChanges?(this.updateRevisions(g),(0,a.le)(m)?this.insertRevision(g,"Insertion"):g.addRevision(m)):n&&g.revisionLength>0&&this.updateRevisions(g),g=g.nextNode;this.owner.enableTrackChanges?(this.updateRevisions(e.characterFormat),this.insertRevision(e.characterFormat,"Insertion")):n&&e.characterFormat.revisionLength>0&&this.updateRevisions(e.characterFormat)}return}this.updateInsertPosition(),l=l.combineWidget(this.owner.viewer),
1(0,a.le)(this.editorHistory)||!this.editorHistory.currentBaseHistoryInfo||this.editorHistory.isUndoing||this.editorHistory.isRedoing||this.editorHistory.currentBaseHistoryInfo.insertedNodes.push(l.clone()),this.splitParagraph(l,l.firstChild,0,s.start.currentWidget,s.start.offset,!1),s.selectParagraphInternal(this.selection.start.paragraph,!0)}var u=s.start.paragraph.containerWidget,f=s.start.paragraph.index;if(!(0,a.le)(u)){if(!(0,a.le)(this.editorHistory)&&((0,a.le)(this.editorHistory.currentBaseHistoryInfo)||this.editorHistory.isUndoing||this.editorHistory.isRedoing||this.editorHistory.currentBaseHistoryInfo.insertedNodes.push(e.clone()),this.editorHistory.isRedoing&&t&&u.firstChild instanceof o.ZH&&u.firstChild.isEmpty()&&u.firstChild===u.lastChild&&e instanceof o.ZH&&e.isEmpty()))return;var y=u.childWidgets.indexOf(s.start.paragraph);if(u.childWidgets[u.childWidgets.length-1]===s.start.paragraph&&e instanceof o.ZH&&e.isSectionBreak&&(y++,f++),s.start.paragraph.isEmpty()&&s.start.paragraph.index===e.index&&1===u.childWidgets.length&&s.start.paragraph.containerWidget.containerWidget instanceof o.tf&&this.owner.editorHistory.isUndoing&&u.childWidgets.splice(0,1),u.childWidgets.splice(y,0,e),e.containerWidget=u,e.index=f,e.height=0,e instanceof o.dm&&(e.isGridUpdated=!1,e.buildTableColumns(),e.isGridUpdated=!0),this.updateNextBlocksIndex(e,!0),e instanceof o.ZH&&this.documentHelper.layout.linkFieldInParagraph(e),!this.skipTracking()&&e instanceof o.ZH&&!r&&!(!(0,a.le)(this.editorHistory)&&!(0,a.le)(this.editorHistory.currentBaseHistoryInfo)&&"InsertHyperlink"===this.editorHistory.currentBaseHistoryInfo.action)?this.insertRevisionForBlock(e,"Insertion",n):e instanceof o.ZH?(this.constructRevisionsForBlock(e,!0),this.splitRevisionsAndViewBasedOnUntrackedContent(e.characterFormat)):e instanceof o.dm&&this.constructRevisionsForTable(e,!0),this.documentHelper.owner.editorModule.isRemoteAction&&!d&&e instanceof o.dm&&(this.updateNextBlocksIndex(e.nextWidget,!1),u.childWidgets.splice(e.indexInOwner+1,1)),this.isPaste&&!(0,a.le)(e.previousWidget)&&e.previousWidget instanceof o.ZH&&e instanceof o.ZH&&e.paragraphFormat.contextualSpacing&&!i&&this.documentHelper.layout.reLayoutParagraph(e.previousWidget,0,0),h&&e instanceof o.ZH)for(var v=this.documentHelper.layout.getFootnoteElementsOfParagraph(e),H=0;H<v.length;H++){var g=v[H];g instanceof o.R5&&(g.isLayout=!1,"Footnote"===g.footnoteType&&(this.updateFootnoteCollection(g),this.updateFootNoteIndex()),"Endnote"===g.footnoteType&&(this.updateEndnoteCollection(g),this.updateEndNoteIndex()))}this.documentHelper.layout.layoutBodyWidgetCollection(f,u,e,!1,void 0,i)}},e.prototype.insertImage=function(e,t,i,r){this.insertImageInternal(e,!1,t,i,r)},e.prototype.insertImageAsync=function(e,t,i,r){return E(this,void 0,void 0,function(){return O(this,function(o){switch(o.label){case 0:return[4,this.insertImageInternal(e,!1,t,i,r)];case 1:return o.sent(),[2]}})})},e.prototype.insertImageInternal=function(e,t,i,r,n){return E(this,void 0,void 0,function(){var s=this;return O(this,function(l){return[2,new Promise(function(l,d){var h=s.selection.getCurrentFormField(),c="FormFieldsOnly"===s.documentHelper.protectionType&&!(0,a.le)(h)&&h.formFieldData instanceof o.$o;if((s.owner.isReadOnlyMode||!s.canEditContentControl)&&!c){l();return}if((0,a.le)(i)||(0,a.le)(r)){var p=document.createElement("img");p.addEventListener("load",function(){this.width=(0,a.le)(i)?this.width:i,this.height=(0,a.le)(r)?this.height:r,this.alt=(0,a.le)(n)?this.alt:n,s.insertPicture(e,this.width,this.height,this.alt,!0),l()}),p.src=e}else s.insertPicture(e,i,r,n,t),l();setTimeout(function(){(0,a.le)(s.documentHelper)||s.viewer.updateScrollBars()},30)})]})})},e.prototype.insertTable=function(e,t){var i,r=this.selection.start;if(!(this.owner.isReadOnlyMode||!this.canEditContentControl||this.selection.isPlainContentControl())){e=e||1,t=t||1;var n=new a.E7("documenteditor",this.owner.defaultLocale);if(n.setLocale(this.documentHelper.owner.locale),t<1||t>this.documentHelper.owner.documentEditorSettings.maximumColumns){var s=n.getConstant("Number of columns must be between")+" 1 "+n.getConstant("and")+" "+this.documentHelper.owner.documentEditorSettings.maximumColumns.toString();S.hZ.alert(s).enableRtl=this.documentHelper.owner.enableRtl;return}if(e<1||e>this.documentHelper.owner.documentEditorSettings.maximumRows){var l=n.getConstant("Number of rows must be between")+" 1 "+n.getConstant("and")+" "+this.documentHelper.owner.documentEditorSettings.maximumColumns.toString();n.getConstant("Number of rows must be between 1 and 32767.").replace("32767",this.documentHelper.owner.documentEditorSettings.maximumRows.toString()),S.hZ.alert(l).enableRtl=this.documentHelper.owner.enableRtl;return}var d=!1,h=r.paragraph.previousWidget;r.currentWidget.isFirstLine()&&0===r.offset&&h instanceof o.dm&&(d=!0);var c=this.createTable(e,t),p=r.paragraph.getContainerWidth()-c.tableFormat.leftIndent;if(c.splitWidthToTableCells(p),d&&h instanceof o.dm){this.insertTableRows(c,h,!0),c.destroy();return}i=this.checkAndRemoveComments(),this.initHistory("InsertTable"),this.documentHelper.owner.isShiftingEnabled=!0,c.tableFormat.bidi=r.paragraph.paragraphFormat.bidi,this.insertBlock(c),!(0,a.le)(c.containerWidget)&&!(0,a.le)(c.containerWidget.containerWidget)&&c.containerWidget.containerWidget instanceof o.tf&&(c.containerWidget.containerWidget.height+=c.height,this.isTableInsert=!0);var g=c.getSplitWidgets();if(this.owner.enableTrackChanges)for(var m=0;m<g.length;m++)for(var u=0;u<g[m].childWidgets.length;u++){var f=g[m].childWidgets[u];this.insertRevision(f.rowFormat,"Insertion")}var y=this.documentHelper.getFirstParagraphInFirstCell(c).childWidgets[0];r.setPosition(y,!0),this.selection.end.setPositionInternal(r);var v=this.documentHelper.getLastParagraphInLastCell(c.getSplitWidgets().pop()),H=v.getLength()+1;this.editorHistory&&this.editorHistory.currentBaseHistoryInfo&&(this.editorHistory.currentBaseHistoryInfo.endPosition=this.selection.getHierarchicalIndex(v,H.toString())),this.reLayout(this.selection),this.isTableInsert=!1,this.updateHistoryForComments(i)}},e.prototype.insertRow=function(e,t){var i=e?"Above":"Below";if(!this.owner.isReadOnlyMode&&this.canEditContentControl){var r=this.selection.isForward?this.selection.start:this.selection.end;if(this.selection.isForward?this.selection.end:this.selection.start,r.paragraph.isInsideTable){this.checkIsNotRedoing()&&this.initHistory("Above"===i?"InsertRowAbove":"InsertRowBelow"),this.documentHelper.owner.isShiftingEnabled=!0;var o=this.getOwnerCell(this.selection.isForward).getSplitWidgets()[0],n=this.getOwnerCell(!this.selection.isForward).getSplitWidgets()[0],s=o.ownerTable.combineWidget(this.owner.viewer),a="Below"===i?n.ownerRow:o.ownerRow;this.editorHistory&&this.cloneTableToHistoryInfo(s),this.rowInsertion(t,i,o,n,a,s,!0)}this.reLayout(this.selection,!0)}},e.prototype.rowInsertion=function(e,t,i,r,n,s,l){var d=e||this.getRowCountToInsert(),h=[],c=n.rowIndex;if("Below"===t){c++;var p=(0,a.le)(r.previousWidget)||r.columnIndex===r.previousWidget.columnIndex+1;!(r.cellIndex!==r.columnIndex&&p&&n.rowIndex+i.cellFormat.rowSpan-1===r.ownerRow.rowIndex)&&r.cellFormat.rowSpan>1&&!(0,a.le)(n.nextWidget)&&n.nextWidget instanceof o.BC&&(r.cellFormat.rowSpan+=d,n=n.nextWidget),n.bottomBorderWidth=0}for(var g=0;g<d;g++){var m=this.updateRowspan(n,"Below"===t?r:i,t),u=this.createRowAndColumn(m.count,g,c,s);u.rowFormat=n.rowFormat.cloneFormat(),u.rowFormat.removedIds=[],u.containerWidget=n.containerWidget,u.rowFormat.ownerBase=u,this.updateCellFormatForInsertedRow(u,m.cellFormats),!(0,a.le)(this.editorHistory)&&this.editorHistory.currentBaseHistoryInfo&&this.owner.enableCollaborativeEditing&&this.editorHistory.currentBaseHistoryInfo.insertedNodes.push(u),h.push(u)}var f=h.slice();if(s.insertTableRowsInternal(h,c,l,void 0,l),this.owner.enableTrackChanges)for(var g=0;g<f.length;g++)this.insertRevision(f[g].rowFormat,"Insertion");if(l){this.splitRevisionsAndViewBasedOnUntrackedContent(s.childWidgets[c].rowFormat);var y=void 0,v=void 0;if(s.childWidgets[c]instanceof o.BC)y=s.childWidgets[c].firstChild,v=this.selection.getFirstParagraph(y);else{for(var H=void 0;!(H instanceof o.dm);)H=s.nextRenderedWidget;v=this.documentHelper.getFirstParagraphInFirstCell(H)}this.documentHelper.layout.reLayoutTable(s),this.selection.selectParagraphInternal(v,!0)}},e.prototype.getPreviousNodeRevision=function(e){for(;(e instanceof o.no||e instanceof o.aQ||e instanceof o.Cw||e instanceof o.jn)&&0===e.revisionLength;)e=e.previousNode;return e},e.prototype.getNextNodeRevision=function(e){for(;(e instanceof o.no||e instanceof o.aQ||e instanceof o.Cw||e instanceof o.jn)&&0===e.revisionLength;)e=e.nextNode;return e},e.prototype.splitRevisionsAndViewBasedOnUntrackedContent=function(e){var t,i,r=!0;if(e instanceof o.nR?r=!(e.paragraph.containerWidget instanceof o.nb&&e.paragraph.containerWidget.ownerRow.rowFormat.revisionLength>0):e instanceof n.a?e.ownerBase instanceof o.ZH&&(r=!(e.ownerBase.containerWidget instanceof o.nb&&e.ownerBase.containerWidget.ownerRow.rowFormat.revisionLength>0)):e instanceof d.J&&e.ownerBase instanceof o.BC&&e.ownerBase.ownerTable.containerWidget instanceof o.nb&&e.ownerBase.ownerTable.containerWidget.ownerRow.rowFormat.revisionLength>0&&(r=!1),r&&0===e.revisionLength&&!(e instanceof o.no||e instanceof o.aQ||e instanceof o.Cw||e instanceof o.jn)){if(e instanceof o.nR){var s=this.getPreviousNodeRevision(e.previousNode),l=e.paragraph.getSplitWidgets()[0],h=l.previousRenderedWidget;s instanceof o.nR&&s.revisionLength>0?t=s.getAllRevision():(0,a.le)(s)&&h instanceof o.ZH&&h.characterFormat.revisionLength>0&&(t=h.characterFormat.getAllRevision())}else if(e instanceof n.a){var c=e.ownerBase,p=c.getSplitWidgets(),h=
1p[0].previousRenderedWidget,s=void 0;if(c.isEmpty()&&h instanceof o.ZH)s=h.characterFormat;else{var g=p[p.length-1].lastChild;s=this.getPreviousNodeRevision(g.children[g.children.length-1]),(0,a.le)(s)&&h instanceof o.ZH&&(s=h.characterFormat)}!(0,a.le)(s)&&s.revisionLength>0&&(t=s.getAllRevision())}else if(e instanceof d.J){var m=e.ownerBase,u=m.previousRenderedWidget;!(0,a.le)(u)&&u.rowFormat.revisionLength>0&&(t=u.rowFormat.getAllRevision())}if((0,a.le)(t)){var c=void 0;e instanceof o.nR?c=e.paragraph:e instanceof n.a?c=e.ownerBase:e instanceof d.J&&(c=e.ownerBase.ownerTable);var f=c.containerWidget;if(f instanceof o.nb){var y=f.ownerRow.rowFormat;y.revisionLength>0&&(t=y.getAllRevision())}}if(e instanceof o.nR){var v=e.nextNode,l=e.paragraph.getSplitWidgets()[0];v instanceof o.nR&&v.revisionLength>0?i=v.getAllRevision():(0,a.le)(v)&&l.characterFormat.revisionLength>0&&(i=l.characterFormat.getAllRevision())}else if(e instanceof n.a){var c=e.ownerBase,p=c.getSplitWidgets(),H=p[p.length-1].nextRenderedWidget,C=void 0;H instanceof o.ZH&&(H.isEmpty()?C=H.characterFormat:(C=this.getNextNodeRevision(H.firstChild.children[0]),(0,a.le)(C)&&H instanceof o.ZH&&(C=H.characterFormat))),!(0,a.le)(C)&&C.revisionLength>0&&(i=C.getAllRevision())}else if(e instanceof d.J){var m=e.ownerBase,F=m.nextRenderedWidget;!(0,a.le)(F)&&F.rowFormat.revisionLength>0&&(i=F.rowFormat.getAllRevision())}}if(t&&i)for(var w=0,I=t;w<I.length;w++){var x=I[w],b=this.owner.trackChangesPane.changes.get(x);if(b)for(var W=0,P=i;W<P.length;W++){var k=P[W],R=this.owner.trackChangesPane.changes.get(k);if(R&&b===R){var T=b.outerSingleDiv?this.owner.revisions.getChildIndexQuery(b.outerSingleDiv):0;this.owner.revisions.splitView(x,b,R,T);break}}}},e.prototype.combineRevisionsAndViewBasedOnUntrackedContent=function(e){if(0===e.revisionLength){if(e instanceof o.nR){var t,i,r=this.getPreviousNodeRevision(e.previousNode),s=e.paragraph.getSplitWidgets()[0],l=s.previousRenderedWidget;r instanceof o.nR&&r.revisionLength>0?t=r.getAllRevision():(0,a.le)(r)&&l instanceof o.ZH&&l.characterFormat.revisionLength>0&&(t=l.characterFormat.getAllRevision())}else if(e instanceof n.a){var h=e.ownerBase,c=h.getSplitWidgets(),l=c[0].previousRenderedWidget,r=void 0;if(h.isEmpty()&&l instanceof o.ZH)r=l.characterFormat;else{var p=c[c.length-1].lastChild;r=this.getPreviousNodeRevision(p.children[p.children.length-1]),(0,a.le)(r)&&l instanceof o.ZH&&(r=l.characterFormat)}!(0,a.le)(r)&&r.revisionLength>0&&(t=r.getAllRevision())}else if(e instanceof d.J){var g=e.ownerBase,m=g.previousRenderedWidget;!(0,a.le)(m)&&m.rowFormat.revisionLength>0&&(t=m.rowFormat.getAllRevision())}if((0,a.le)(t)){var h=void 0;e instanceof o.nR?h=e.paragraph:e instanceof n.a?h=e.ownerBase:e instanceof d.J&&(h=e.ownerBase.ownerTable);var u=h.containerWidget;if(u instanceof o.nb){var f=u.ownerRow.rowFormat;f.revisionLength>0&&(t=f.getAllRevision())}}if(e instanceof o.nR){var y=e.nextNode,s=e.paragraph.getSplitWidgets()[0];y instanceof o.nR&&y.revisionLength>0?i=y.getAllRevision():(0,a.le)(y)&&s.characterFormat.revisionLength>0&&(i=s.characterFormat.getAllRevision())}else if(e instanceof n.a){var h=e.ownerBase,c=h.getSplitWidgets(),v=c[c.length-1].nextRenderedWidget,H=void 0;v instanceof o.ZH&&(v.isEmpty()?H=v.characterFormat:(H=this.getNextNodeRevision(v.firstChild.children[0]),(0,a.le)(H)&&v instanceof o.ZH&&(H=v.characterFormat))),!(0,a.le)(H)&&H.revisionLength>0&&(i=H.getAllRevision())}else if(e instanceof d.J){var g=e.ownerBase,C=g.nextRenderedWidget;!(0,a.le)(C)&&C.rowFormat.revisionLength>0&&(i=C.rowFormat.getAllRevision())}}if(t&&i)for(var F=0;F<t.length;F++)for(var w=this.owner.trackChangesPane.changes.get(t[F]),I=0;I<i.length;I++){var x=this.owner.trackChangesPane.changes.get(i[I]);w&&x&&w!==x&&this.compareTwoRevisions(t[F],i[I])&&this.owner.revisions.combineWithNextRevision(t[F],i[I])}},e.prototype.autoFitTable=function(e){!this.documentHelper.owner.isReadOnlyMode&&this.canEditContentControl&&this.insertAutoFitTable(e)},e.prototype.insertAutoFitTable=function(e,t){if((0,a.le)(t)){var i=this.selection.start,r=this.selection.end;this.selection.isForward||(i=this.selection.end,r=this.selection.start),t=(t=this.selection.getTable(i,r)).getSplitWidgets()[0]}var o=this.documentHelper.layout.getParentTable(t);
1(0,a.le)(o)||(this.setOffsetValue(this.selection),o=o.combineWidget(this.owner.viewer),this.initHistory("FitToContents"===e?"TableAutoFitToContents":"FitToWindow"===e?"TableAutoFitToWindow":"TableFixedColumnWidth"),this.documentHelper.owner.editorHistoryModule&&this.cloneTableToHistoryInfo(o),o.updateProperties(!0,t,e),this.documentHelper.owner.isShiftingEnabled=!0,this.documentHelper.layout.reLayoutTable(t),this.reLayout(this.selection,!0))},e.prototype.rowInsertionForCE=function(e,t,i,r,n,s,a,l){for(var d=[],h=0;h<i;h++){var c=this.createRowAndColumn(t,h,e,r);this.documentHelper.owner.parser.parseRowFormat(n,c.rowFormat,0);for(var p=0;p<t;p++){var g=c.childWidgets[p];this.documentHelper.owner.parser.parseCellFormat(s[p],g.cellFormat,0),this.documentHelper.owner.parser.parseParagraphFormat(0,a[p],g.childWidgets[0].paragraphFormat),this.documentHelper.owner.parser.parseCharacterFormat(0,l[p],g.childWidgets[0].characterFormat)}d.push(c)}var m=d.slice();if(r.insertTableRowsInternal(d,e,!0),this.owner.enableTrackChanges)for(var h=0;h<m.length;h++)this.insertRevision(m[h].rowFormat,"Insertion");this.splitRevisionsAndViewBasedOnUntrackedContent(r.childWidgets[e].rowFormat);var u=void 0,f=void 0;if(r.childWidgets[e]instanceof o.BC)u=r.childWidgets[e].firstChild,f=this.selection.getFirstParagraph(u);else{for(var y=void 0;!(y instanceof o.dm);)y=r.nextRenderedWidget;f=this.documentHelper.getFirstParagraphInFirstCell(y)}this.documentHelper.layout.reLayoutTable(r),this.selection.selectParagraphInternal(f,!0),this.reLayout(this.selection,!0)},e.prototype.updateCellFormatForInsertedRow=function(e,t){for(var i=0;i<e.childWidgets.length;i++)e.childWidgets[i].cellFormat.copyFormat(t[i]),e.childWidgets[i].cellFormat.rowSpan=1},e.prototype.updateRowspan=function(e,t,i){for(var r=e.getPreviousRowSpannedCells(!0),o=0,n=[],s=0;s<e.childWidgets.length;s++){for(var l=e.childWidgets[s],d=!1,h=(0,a.le)(l.previousWidget)||l.columnIndex!==l.previousWidget.columnIndex+1,c=0;c<r.length;c++)if(h){var p=r[c],g=p.ownerRow.rowIndex+p.cellFormat.rowSpan-1;if(l.columnIndex<p.columnIndex&&l.cellIndex!==l.columnIndex&&!d&&(d=!0,o++,n.push(l.cellFormat)),1===t.cellFormat.rowSpan){if(g>l.ownerRow.rowIndex){if("Above"===i&&p.ownerRow===t.ownerRow)continue;p.cellFormat.rowSpan+=1,r.splice(c,1),c--}else l.cellIndex!==l.columnIndex&&h&&g===l.ownerRow.rowIndex&&("Above"===i?(p.cellFormat.rowSpan+=1,r.splice(c,1),c--):(o++,n.push(p.cellFormat),r.splice(c,1),c--))}else if(p!==t){if("Above"===i&&(p.ownerRow===t.ownerRow||p.columnIndex===t.columnIndex))continue;p.columnIndex!==t.columnIndex&&p.ownerRow.rowIndex!==l.ownerRow.rowIndex&&(g>t.ownerRow.rowIndex||"Above"===i&&g===t.ownerRow.rowIndex)&&(p.cellFormat.rowSpan+=1,r.splice(c,1),c--)}}-1===r.indexOf(l)&&l.cellFormat.rowSpan>1&&(d=!0),d||(o++,n.push(l.cellFormat))}return n.sort(function(e,t){return e.ownerBase.columnIndex-t.ownerBase.columnIndex}),{count:o,cellFormats:n}},e.prototype.getInsertedTable=function(e,t){e.childWidgets&&e.childWidgets.length>0&&(e.childWidgets.splice(0,t),this.owner.enableCollaborativeEditing&&this.editorHistory.currentBaseHistoryInfo.insertedNodes.push(e))},e.prototype.insertTableRows=function(e,t,i){this.initHistory("InsertTableBelow"),e.containerWidget=t.containerWidget;var r=(t=t.combineWidget(this.owner.viewer)).childWidgets[t.childWidgets.length-1],o=t.childWidgets.length,n=!1,s=e.tableFormat.borders,a=t.tableFormat.borders;(s.left.lineStyle!==a.left.lineStyle||s.top.lineStyle!==a.top.lineStyle||s.right.lineStyle!==a.right.lineStyle||s.bottom.lineStyle!==a.bottom.lineStyle)&&(n=!0),t.insertTableRowsInternal(e.childWidgets,o,!0,n);var l=t.clone();if(this.getInsertedTable(l,o),i&&this.owner.enableTrackChanges)for(var d=o;d<t.childWidgets.length;d++){var h=t.childWidgets[d];this.insertRevision(h.rowFormat,"Insertion")}var c=this.selection.getFirstParagraph(r.nextWidget.childWidgets[0]);t.isDefaultFormatUpdated=!1,this.documentHelper.layout.reLayoutTable(t),this.checkInsertPosition(this.selection)&&this.updateHistoryPosition(this.selection.getHierarchicalIndex(c,"0"),!0),this.selection.start.setPosition(c.firstChild,!0),this.editorHistory&&this.editorHistory.currentBaseHistoryInfo&&this.updateHistoryPosition(this.selection.end,!1),this.selection.end.setPosition(c.firstChild,!0),this.reLayout(this.selection)},e.prototype.insertColumn=function(e,t){if(!this.owner.isReadOnlyMode&&this.canEditContentControl){var i=e?"Left":"Right";if(this.selection.start.paragraph.isInsideTable){this.checkIsNotRedoing()&&this.initHistory("Left"===i?"InsertColumnLeft":"InsertColumnRight"),this.selection.owner.isShiftingEnabled=!0;var r=this.getOwnerCell(this.selection.isForward),o=this.getOwnerCell(!this.selection.isForward),n=r.ownerRow.ownerTable.combineWidget(this.owner.viewer);this.editorHistory&&this.cloneTableToHistoryInfo(n),this.selection.owner.isLayoutEnabled=!1;var s=r.columnIndex;n.bidi?s="Right"===i?s:o.columnIndex+o.cellFormat.columnSpan:"Right"===i&&(s=o.columnIndex+o.cellFormat.columnSpan);for(var l=void 0,d=void 0,h=t||this.getColumnCountToInsert(),c=[],p=n.tableFormat.shading,g=0;g<h;g++)for(var m=0;m<n.childWidgets.length;m++){var u=n.childWidgets[m];(d=this.createColumn(this.selection.getLastParagraph(r))).index=m,d.rowIndex=u.rowIndex,d.containerWidget=u,d.cellFormat.copyFormat(r.cellFormat),d.cellFormat.shading=p,d.cellFormat.borders.clearFormat(),d.cellFormat.rowSpan=1,(0,a.le)(l)&&(l=this.selection.getFirstParagraph(d)),0===s?u.childWidgets.splice(s,0,d):this.insertSpannedCells(u,c,d,s),this.copyCellFormats(u,s);for(var f=0;f<u.rowFormat.revisionLength;f++)u.rowFormat.getRevision(f).hasChanges=!0;this.owner.enableCollaborativeEditing&&this.editorHistory.currentBaseHistoryInfo.insertedNodes.push(d)}this.tableReLayout(n,l,d)}}},e.prototype.cellInsertionForCE=function(e,t,i,r,n){var s=void 0;s=this.createColumn(void 0);var a=new o.z7(s.childWidgets[0]);s.childWidgets[0].childWidgets.push(a),s.index=t.index,s.rowIndex=t.rowIndex,s.containerWidget=t,this.documentHelper.owner.parser.parseCellFormat(i,s.cellFormat,0),this.documentHelper.owner.parser.parseParagraphFormat(0,r,s.childWidgets[0].paragraphFormat),this.documentHelper.owner.parser.parseCharacterFormat(0,n,s.childWidgets[0].characterFormat),s.cellFormat.rowSpan=1,t.childWidgets.splice(e,0,s)},e.prototype.copyCellFormats=function(e,t){var i=e.childWidgets[t];
1if(!(0,a.le)(i)){var r=i.firstChild;t==e.childWidgets.length-1?--t:++t;for(var n=e.childWidgets[t].firstChild;n instanceof o.dm;)n=n.firstChild.firstChild.firstChild;var s=n,l=void 0,d=void 0;s.childWidgets.length>0&&(l=s.firstChild).children.length>0&&(d=l.children[0]),r.paragraphFormat.copyFormat(s.paragraphFormat),(0,a.le)(d)?r.characterFormat.copyFormat(s.characterFormat):r.characterFormat.copyFormat(d.characterFormat)}},e.prototype.copyContent=function(e){if(this.editorHistory&&this.editorHistory.currentBaseHistoryInfo&&this.owner.enableCollaborativeEditing){var t=this.documentHelper.getLastParagraphBlock(e),i=this.documentHelper.getFirstParagraphBlock(e);0===i.childWidgets.length&&(i.childWidgets[0]=new o.z7(i)),0===t.childWidgets.length&&(t.childWidgets[0]=new o.z7(t));var r=i.firstChild,n=t.lastChild,s=t.lastChild.getEndOffset(),l=(0,a.le)(this.owner.sfdtExportModule)?{}:this.owner.sfdtExportModule.write(this.owner.documentEditorSettings.optimizeSfdt?1:0,r,0,n,s,!1,!0);this.editorHistory.currentBaseHistoryInfo.pasteContent=l}},e.prototype.tableReLayout=function(e,t,i,r){e.updateRowIndex(0);var o=this.documentHelper.layout.getParentTable(e);o?o.fitChildToClientArea():e.fitChildToClientArea(),this.selection.owner.isLayoutEnabled=!0,this.selection.owner.isShiftingEnabled=!0,e.isGridUpdated=!1,e.buildTableColumns(),e.isGridUpdated=!0,this.documentHelper.skipScrollToPosition=!0,r&&this.copyContent(e),this.documentHelper.layout.reLayoutTable(e),this.selection.start.setPosition(t.firstChild,!0),this.selection.end.setPosition(this.selection.getLastParagraph(i).firstChild,!1),(this.checkIsNotRedoing()||(0,a.le)(this.editorHistory))&&this.reLayout(this.selection)},e.prototype.createTable=function(e,t){this.selection.start.paragraph;var i=new o.dm;i.tableFormat.preferredWidthType="Auto",i.tableFormat.leftIndent=this.selection.start.paragraph.leftIndent,i.tableFormat.initializeTableBorders();for(var r=0;r<e;){var n=this.createRowAndColumn(t,r);n.rowFormat.heightType="Auto",n.containerWidget=i,i.childWidgets.push(n),r++}return i},e.prototype.createRowAndColumn=function(e,t,i,r){var n=this.selection.start.paragraph,s=new o.BC;s.rowFormat=new d.J(s),s.index=t;for(var l=0;l<e;l++){if(!(0,a.le)(i)&&!(0,a.le)(r)){if(i&&i>0&&r.childWidgets[i-1]&&r.childWidgets[i-1].childWidgets[l]){for(var h=r.childWidgets[i-1].childWidgets[l].childWidgets[0];h instanceof o.dm;)h=h.childWidgets[0].childWidgets[0].childWidgets[0];n=h}else if(0==i){for(var h=r.childWidgets[i].childWidgets[l].childWidgets[0];h instanceof o.dm;)h=h.childWidgets[0].childWidgets[0].childWidgets[0];n=h}}var c=this.createColumn(n,!0);c.index=l,c.rowIndex=t,c.containerWidget=s,s.childWidgets.push(c)}return s},e.prototype.createColumn=function(e,t){var i=new o.nb,r=new o.ZH,n=new o.z7(r);if(r.childWidgets.push(n),t){r.paragraphFormat.copyFormat(e.paragraphFormat),r.paragraphFormat.leftIndent=0,r.paragraphFormat.firstLineIndent=0;var s=void 0;(0,a.le)(e.childWidgets[0])||(s=e.childWidgets[0].children[0]),(0,a.le)(s)?r.characterFormat.copyFormat(e.characterFormat):r.characterFormat.copyFormat(s.characterFormat),r.characterFormat.removedIds=[]}return e&&e.associatedCell&&(i.columnIndex=e.associatedCell.columnIndex),r.containerWidget=i,i.childWidgets.push(r),i.cellFormat=new c.D(i),i},e.prototype.getColumnCountToInsert=function(){var e=1,t=this.selection.start,i=this.selection.end;if(this.selection.isForward||(t=this.selection.end,i=this.selection.start),t&&i&&this.selection.getTable(t,i)){if(t.paragraph.associatedCell===i.paragraph.associatedCell)return 1;if(t.paragraph.associatedCell.ownerRow===i.paragraph.associatedCell.ownerRow)return e+i.paragraph.associatedCell.cellIndex-t.paragraph.associatedCell.cellIndex;e=0;for(var r=t.paragraph.associatedCell.ownerTable.getColumnCellsForSelection(t.paragraph.associatedCell,i.paragraph.associatedCell),o=0;o<r.length;o++)t.paragraph.associatedCell.ownerRow===r[o].ownerRow&&e++}return 0===e?1:e},e.prototype.getRowCountToInsert=function(){var e=this.selection.start,t=this.selection.end;return(this.selection.isForward||(e=this.selection.end,t=this.selection.start),(0,a.le)(e)||(0,a.le)(t)||(0,a.le)(this.selection.getTable(e,t)))?1:e.paragraph.associatedCell===t.paragraph.associatedCell||e.paragraph.associatedCell.ownerRow===t.paragraph.associatedCell.ownerRow?1:1+this.getOwnerRow(!this.selection.isForward).rowIndex-this.getOwnerRow(this.selection.isForward).rowIndex},e.prototype.getOwnerCell=function(e){var t=void 0,i=e?this.selection.start.paragraph.associatedCell:this.selection.end.paragraph.associatedCell,r=e?this.selection.end.paragraph.associatedCell:this.selection.start.paragraph.associatedCell,n=(t=i).ownerTable,s=!1;for((0,a.le)(n)||((0,a.le)(n.nextSplitWidget)||n.nextSplitWidget!==r.ownerTable)&&((0,a.le)(n.previousSplitWidget)||n.previousSplitWidget!==r.ownerTable)||(s=!0);!(0,a.le)(n)&&n.containerWidget instanceof o.nb&&n!==r.ownerTable&&!s;)n=(t=n.containerWidget).ownerTable;return t},e.prototype.getOwnerRow=function(e){for(var t,i=e?this.selection.start.paragraph.associatedCell.ownerRow:this.selection.end.paragraph.associatedCell.ownerRow,r=e?this.selection.end.paragraph.associatedCell.ownerRow:this.selection.start.paragraph.associatedCell.ownerRow,n=(t=i).ownerTable;!(0,a.le)(n)&&n.containerWidget instanceof o.nb&&n!==r.ownerTable;)n=(t=n.containerWidget.ownerRow).ownerTable;return t},e.prototype.getOwnerTable=function(e){var t=void 0,i=this.selection.start.paragraph.isInsideTable?this.selection.start.paragraph.associatedCell.ownerTable:void 0,r=this.selection.end.paragraph.isInsideTable?this.selection.end.paragraph.associatedCell.ownerTable:void 0;for(t=e?i:r;!(0,a.le)(t)&&t.containerWidget instanceof o.nb&&t!==(e?r:i);)t=t.containerWidget.ownerTable;return t},e.prototype.mergeSelectedCellsInTable=function(){if(this.canMergeCells()){if(this.owner.enableTrackChanges){var e=new a.E7("documenteditor",this.owner.defaultLocale);e.setLocale(this.owner.locale),this.alertDialog=S.hZ.alert({title:e.getConstant("UnTrack"),
1content:e.getConstant("Merge Track"),showCloseIcon:!0,okButton:{text:"Ok",click:this.confirmCellMerge.bind(this)},closeOnEscape:!0,position:{X:"center",Y:"center"},animationSettings:{effect:"Zoom"}}),this.alertDialog.enableRtl=this.owner.enableRtl}else this.confirmCellMerge()}},e.prototype.confirmCellMerge=function(){this.checkIsNotRedoing()&&this.initHistory("MergeCells"),this.selection.owner.isShiftingEnabled=!0;var e=this.selection.start,t=this.selection.end;this.selection.isForward||(e=this.selection.end,t=this.selection.start);var i=this.getOwnerCell(this.selection.isForward),r=this.getOwnerCell(!this.selection.isForward),o=this.selection.getContainerCellOf(i,r);if(o.ownerTable.contains(r)&&!this.selection.containsCell(o,r)){var n=i.ownerTable.combineWidget(this.owner.viewer);i=this.selection.getSelectedCell(i,o),r=this.selection.getSelectedCell(r,o);var s=this.mergeSelectedCells(n,i,r),l=this.selection.getFirstParagraph(s);e.setPosition(l.firstChild,!0);var d=this.selection.getLastParagraph(s);t.setPosition(d.lastChild,!1),this.selection.fireSelectionChanged(!1)}(this.checkIsNotRedoing()||(0,a.le)(this.editorHistory))&&this.reLayout(this.selection,!1),(0,a.le)(this.alertDialog)||(this.alertDialog.close(),this.alertDialog=void 0)},e.prototype.mergeSelectedCells=function(e,t,i){this.cloneTableToHistoryInfo(e),this.selection.owner.isLayoutEnabled=!1;var r,n=this.selection.getCellLeft(t.ownerRow,t),l=n+t.cellFormat.cellWidth,d=this.selection.getCellLeft(i.ownerRow,i),h=d+i.cellFormat.cellWidth,c=this.updateSelectedCellsInTable(n,l,d,h);n=c.start,l=c.end;var p=i.cellFormat.rowSpan,g=e.childWidgets.indexOf(i.ownerRow),m=e.childWidgets.indexOf(t.ownerRow),u=void 0;e.updateCellFormatPreferredWidth();for(var f=m;f<=g;f++){for(var y=e.childWidgets[f],v=0;v<y.childWidgets.length;
1v++){var H=y.childWidgets[v],C=this.selection.getCellLeft(y,H);if(s.o_.round(n,2)<=s.o_.round(C,2)&&s.o_.round(C,2)<s.o_.round(l,2)){var F=H.lastChild;if(F instanceof o.ZH&&F.isEmpty()&&H.childWidgets.pop(),(0,a.le)(u))u=H,r=F;else{f===m&&(u.cellFormat.preferredWidth+=H.cellFormat.preferredWidth,u.cellFormat.columnSpan+=H.cellFormat.columnSpan,this.mergeBorders(u,H));for(var w=0;w<H.childWidgets.length;w++){var I=H.childWidgets[w],x=I.clone();x.containerWidget=u,u.childWidgets.push(x),this.removeFieldInBlock(I),this.removeFieldInBlock(I,!0)}y.childWidgets.splice(v,1),H.destroy(),v--;for(var b=this.documentHelper.contentControlCollection.length-1;b>-1;b--){var W=this.documentHelper.contentControlCollection[b];(0,a.le)(W.contentControlProperties)&&this.documentHelper.contentControlCollection.splice(b)}}}}if((0===u.childWidgets.length||1===u.childWidgets.length&&u.childWidgets[0]instanceof o.dm)&&r){var x=r.clone();u.childWidgets.push(x),x.containerWidget=u}if(0===y.childWidgets.length){var P=e.childWidgets.indexOf(y);y.updateRowBySpannedCells(),e.childWidgets.splice(P,1),g--,f--}}return!(0,a.le)(u)&&m<g&&(u.cellFormat.rowSpan=g-m+p),this.updateBlockIndexAfterMerge(u),e.updateRowIndex(0),e.calculateGrid(),e.isGridUpdated=!1,e.buildTableColumns(),e.isGridUpdated=!0,this.documentHelper.layout.linkFieldInTable(e),this.documentHelper.layout.reLayoutTable(e),this.selection.owner.isLayoutEnabled=!0,u},e.prototype.mergeBorders=function(e,t){var i=void 0,r=null;if((0,a.le)(e.cellFormat.borders)||(i=e.cellFormat.borders),(0,a.le)(t.cellFormat.borders)||(r=t.cellFormat.borders),!((0,a.le)(i)&&(0,a.le)(r))){if((0,a.le)(i))(i=new p.A(e.cellFormat)).copyFormat(r);else{if((0,a.le)(r))return;e.ownerRow.rowIndex!==t.ownerRow.rowIndex||(i.top=e.getBorderBasedOnPriority(i.top,r.bottom),i.bottom=e.getBorderBasedOnPriority(i.bottom,r.bottom),(0,a.le)(i.top)||(i.top.ownerBase=i),(0,a.le)(i.bottom)||(i.bottom.ownerBase=i))}}},e.prototype.updateBlockIndexAfterMerge=function(e){for(var t=0;t<e.childWidgets.length;t++)e.childWidgets[t].index=t},e.prototype.canMergeCells=function(){if(this.selection.isEmpty||!this.selection.start.paragraph.isInsideTable||!this.selection.end.paragraph.isInsideTable)return!1;this.selection.start,this.selection.end,this.selection.isForward||(this.selection.end,this.selection.start);var e=this.getOwnerCell(this.selection.isForward),t=this.getOwnerCell(!this.selection.isForward),i=this.selection.getContainerCellOf(e,t);if(i.ownerTable.contains(t)&&!this.selection.containsCell(i,t)){e=this.selection.getSelectedCell(e,i),t=this.selection.getSelectedCell(t,i);var r=1;if(e.ownerRow===t.ownerRow){for(var o=e.ownerRow.childWidgets.indexOf(e),n=o;n<=e.ownerRow.childWidgets.indexOf(t);n++){var s=e.ownerRow.childWidgets[n],l=s.previousWidget;if(n!==o&&(s.cellFormat.rowSpan!==r||!(0,a.le)(l)&&s.columnIndex!==l.cellFormat.columnSpan+l.columnIndex))return!1;r=s.cellFormat.rowSpan}return!0}return this.canMergeSelectedCellsInTable(e.ownerTable,e,t)}return!1},e.prototype.canMergeSelectedCellsInTable=function(e,t,i){var r=e.childWidgets.indexOf(i.ownerRow),o=e.childWidgets.indexOf(t.ownerRow),n=this.selection.getCellLeft(t.ownerRow,t),l=n+t.cellFormat.cellWidth,d=this.selection.getCellLeft(i.ownerRow,i),h=d+i.cellFormat.cellWidth,c=this.updateSelectedCellsInTable(n,l,d,h);n=c.start,l=c.end;for(var p=0,g=0,m=!1,u=!1,f=[],y=o;y<=r;y++){for(var v=e.childWidgets[y],H=0,C=0,F=!1,w=0;w<v.childWidgets.length;w++){var I=v.childWidgets[w],x=this.selection.getCellLeft(v,I);if(this.checkCellWithInSelection(n,l,x)){m=!1,u=!1,I.cellFormat.rowSpan>1&&f.push(I),F||(H=x,C=x,F=!0);var b=I.previousWidget;0!==C&&s.o_.round(C,0)!==s.o_.round(x,0)&&(C=x),C+=s.o_.convertPointToPixel(I.cellFormat.cellWidth);var W=this.checkPrevOrNextCellIsWithinSel(n,l,I,!0),P=this.checkPrevOrNextCellIsWithinSel(n,l,I,!1),k=0===f.length||1===f.length&&f[0]===I,R=this.checkCurrentCell(f,I,W,P);if(y===r&&!(0,a.le)(b)&&I.cellFormat.rowSpan>b.cellFormat.rowSpan&&!R)return!1;if(y!==o)for(var T=0;T<f.length;T++){var S=f[T].ownerRow.rowIndex+f[T].cellFormat.rowSpan-1;if(S>=v.rowIndex){if(f[T].columnIndex>I.columnIndex?u=!0:m=!0,y===r&&f[T]!==I&&S>I.ownerRow.rowIndex+I.cellFormat.rowSpan-1)return!1;
1S!==v.rowIndex||this.checkPrevOrNextCellIsWithinSel(n,l,I,!1)||f.splice(f.indexOf(f[T]),1)}}if(W&&!(0,a.le)(b)&&k&&I.columnIndex!==b.columnIndex+1&&this.checkCellWidth(I))return!1}}if(y===o)p=H,g=C;else{if(C>0&&H>0&&!((m||Math.round(p)===Math.round(H))&&(u||Math.round(g)===Math.round(C))))return!1;if(y===r)return!0}}return!1},e.prototype.checkCellWidth=function(e){var t=e.previousWidget,i=this.documentHelper.selection.getCellLeft(e.ownerRow,e),r=this.documentHelper.selection.getCellLeft(e.ownerRow,t)+s.o_.convertPointToPixel(t.cellFormat.cellWidth);return s.o_.round(r,2)!==s.o_.round(i,2)},e.prototype.checkCellWithInSelection=function(e,t,i){return!!(s.o_.round(e,2)<=s.o_.round(i,2)&&s.o_.round(i,2)<s.o_.round(t,2))},e.prototype.checkPrevOrNextCellIsWithinSel=function(e,t,i,r){var o=r?i.previousWidget:i.nextWidget,n=0;return!(0,a.le)(o)&&(n=this.documentHelper.selection.getCellLeft(o.ownerRow,o),this.checkCellWithInSelection(e,t,n))},e.prototype.checkCurrentCell=function(e,t,i,r){var o=t.ownerRow;if(e.length>0)for(var n=0;n<e.length;n++){var s=e[n].ownerRow,a=s.rowIndex+e[n].cellFormat.rowSpan-1;if(e[n]===t&&(1===e.length||this.checkRowSpannedCells(e,t))&&!(r||i)||e[n]!==t&&s.rowIndex<o.rowIndex&&a===o.rowIndex+t.cellFormat.rowSpan-1)return!0}return!1},e.prototype.checkRowSpannedCells=function(e,t){for(var i=0;i<e.length;i++)if(e[i]!==t&&e[i].columnIndex===t.columnIndex)return!0;return!1},e.prototype.insertNewParagraphWidget=function(e,t){if(this.updateInsertPosition(),this.insertParagraph(e,t),!t){var i=void 0,r=e;do r=i=this.selection.getNextParagraphBlock(r);while(i&&i.equals(e));(0,a.le)(i)?this.selection.selectParagraphInternal(e,!0):this.selection.selectParagraphInternal(i,!0)}this.fireContentChange()},e.prototype.updateBookmarkEndPositions=function(e){if(!(0,a.le)(e)&&e.isUpdateBookmarkEnd){var t=e.lastChild;if(!(0,a.le)(t)){for(var i=0;i<t.children.length;i++){var r=t.children[i];r instanceof o.aQ&&1===r.bookmarkType&&((0,a.le)(r.properties)&&this.owner.documentHelper.render.isBookmarkEndAtStart(r)&&(r.properties={}),r.properties.isAfterParagraphMark=!0)}e.isUpdateBookmarkEnd=!1}}},e.prototype.insertParagraph=function(e,t){var i=this.selection.start.currentWidget,r=this.selection.start.offset;this.editorHistory&&this.editorHistory.isUndoing&&this.editorHistory.currentBaseHistoryInfo&&"InsertTextParaReplace"===this.editorHistory.currentBaseHistoryInfo.action&&(r=0);var n=this.selection.start.paragraph;if((this.editorHistory.isUndoing||this.editorHistory.isRedoing)&&this.updateBookmarkEndPositions(n),n=n.combineWidget(this.owner.viewer),t){var s=this.selection.getLineLength(n.lastChild),a=e.firstChild?e.firstChild.children.length:0;this.moveInlines(n,e,a,r,i,s,n.lastChild)}else r>0&&this.moveInlines(n,e,0,0,n.firstChild,r,i);var l=n.getSplitWidgets(),d=(n=t?l[l.length-1]:l[0]).containerWidget.childWidgets.indexOf(n);t&&d++;var h=n.containerWidget;e.index=n.index,e.containerWidget=h,h.childWidgets.splice(d,0,e),this.constructRevisionsForBlock(e,!0),this.updateNextBlocksIndex(t?n:e,!0),t?this.updateRevisionForSplittedPara(n,e):this.splitRevisionsAndViewBasedOnUntrackedContent(e.characterFormat),e.height=0,e instanceof o.ZH&&this.documentHelper.layout.linkFieldInParagraph(e),this.documentHelper.layout.layoutBodyWidgetCollection(e.index,h,e,!1)},e.prototype.moveInlines=function(e,t,i,r,n,s,a,l){if(0===t.childWidgets.length){var d=new o.z7(t);t.childWidgets.push(d)}var h=!1;this.documentHelper.layout.clearListElementBox(e),this.documentHelper.layout.clearListElementBox(t);for(var c=0;c<e.childWidgets.length;c++){var p=e.childWidgets[c];if(n===p&&a===p){i=this.moveContent(p,r,s,i,t);break}if(a===p){i=this.moveContent(p,0,s,i,t);break}n===p?(h=!0,i=this.moveContent(p,r,this.documentHelper.selection.getLineLength(p),i,t)):h&&(i=this.moveContent(p,0,this.documentHelper.selection.getLineLength(p),i,t))}this.removeEmptyLine(e),t.getAllRevisions(!0),e.isInsideTable||l||(this.viewer.updateClientArea(e.bodyWidget,e.bodyWidget.page),this.documentHelper.layout.reLayoutParagraph(e,0,0))},e.prototype.moveContent=function(e,t,i,r,n){for(var s=0,l=0;l<e.children.length;l++){var d=e.children[l];if(t>=s+d.length||d instanceof o.no){d instanceof o.no||(s+=d.length);continue}var h=0;t>s&&(h=t-s);var c=i-s;if(c>d.length&&(c=d.length),h>0&&(s+=h),0===h&&c===d.length){if(d instanceof o.pK){var p=e.paragraph.floatingElements.indexOf(d);-1!==p&&e.paragraph.floatingElements.splice(p,1)}n.paragraphFormat.isSameFormat(d.paragraph.paragraphFormat)||(d.isWidthUpdated=!1),n.firstChild.children.splice(r,0,d),d.line=n.firstChild,r++,e.children.splice(l,1),!(0,a.le)(e.layoutedElements)&&e.layoutedElements.length>0&&e.layoutedElements.splice(l,1),l--}else if(d instanceof o.a3){var g=new o.a3;if(g.characterFormat.copyFormat(d.characterFormat),g.text=d.text.substr(h,c-h),d.isChangeDetected=!0,g.isChangeDetected=!0,""!==g.text&&(n.firstChild.children.splice(r,0,g),g.line=n.firstChild,d.revisionLength>0))for(var m=0;m<d.revisionLength;m++){var u=d.getRevision(m);g.addRevision(u)}r++,d.text=d.text.slice(0,h)+d.text.slice(c),d.isWidthUpdated=!1,d.isChangeDetected=!0}if(i<=s+c-h)break;s+=c-h}return r},e.prototype.updateRevisionForSplittedPara=function(e,t){var i=e.childWidgets.length-1,r=e.childWidgets[i].children.length-1,o=e.childWidgets[i].children[r],n=t.firstChild.children[0];!(0,a.le)(n)&&!(0,a.le)(o)&&this.compareElementRevision(o,n)&&this.updateRevisionForSpittedTextElement(o,n,e.characterFormat)},e.prototype.updateComplexWithoutHistory=function(e,t,i){var o=this.documentHelper.selection;if(0===e){var n=new r.JK(o.owner);this.setPositionForCurrentIndex(n,t),this.documentHelper.layout.reLayoutParagraph(n.paragraph,0,0),this.setPositionForCurrentIndex(o.start,i),this.setPositionForCurrentIndex(o.end,i)}if(1===e){var n=new r.JK(o.owner);this.setPositionForCurrentIndex(n,t);var s=new r.JK(o.owner);this.setPositionForCurrentIndex(s,i),this.documentHelper.layout.reLayoutParagraph(n.paragraph,0,0),s.paragraph!==n.paragraph&&this.documentHelper.layout.reLayoutParagraph(s.paragraph,0,0)}o.owner.isShiftingEnabled&&(this.documentHelper.layout.shiftLayoutedItems(!1),this.documentHelper.owner.enableHeaderAndFooter&&this.updateHeaderFooterWidget()),o.owner.isShiftingEnabled=!1,o.start.updatePhysicalPosition(!0),o.isEmpty?o.end.setPositionInternal(o.start):o.end.updatePhysicalPosition(!0),o.upDownSelectionLength=o.end.location.x,o.fireSelectionChanged(!0),this.documentHelper.updateFocus(),this.owner.viewer.updateScrollBars(),this.fireContentChange(),this.isHandledComplex=!0},e.prototype.groupInsertAction=function(){if(this.editorHistory&&this.editorHistory.undoStack){if(this.editorHistory.undoStack.length>1){var e=this.editorHistory.undoStack[this.editorHistory.undoStack.length-1],t=this.editorHistory.undoStack[this.editorHistory.undoStack.length-2];("Insert"===t.action||"InsertTextParaReplace"===t.action)&&"Insert"===e.action&&t.endPosition===e.insertPosition&&!this.owner.editorModule.isSkipGrouping&&!this.skipTracking()&&this.handledTextInput&&t.insertedText.length<=127?(t.insertedText+=e.insertedText,t.endPosition=e.endPosition,this.editorHistory.undoStack.splice(this.editorHistory.undoStack.length-1,1)):this.skipTracking()||(this.owner.editorModule.isSkipGrouping=!1)}else 1!==this.editorHistory.undoStack.length||this.skipTracking()||(this.owner.editorModule.isSkipGrouping=!1)}},e.prototype.reLayout=function(e,t,i,r){if(this.owner.isSpellCheck&&e.start&&e.start.currentWidget){var n=e.start.currentWidget;n.paragraph&&n.paragraph.isInHeaderFooter&&(this.documentHelper.triggerSpellCheckForHF=!0)}if(!(0,a.le)(this.previousBlockToLayout)){var s=this.previousBlockToLayout;this.documentHelper.layout.layoutBodyWidgetCollection(s.index,s.bodyWidget,s,!1,!1),this.previousBlockToLayout=void 0}if((0,a.le)(e.editRegionHighlighters)||e.editRegionHighlighters.clear(),!this.documentHelper.isComposingIME&&this.editorHistory&&this.editorHistory.isH
1andledComplexHistory()&&!r){if(this.editorHistory.currentHistoryInfo&&"ClearFormat"!==this.editorHistory.currentHistoryInfo.action&&"ApplyStyle"!==this.editorHistory.currentHistoryInfo.action&&("DragAndDropContent"===this.editorHistory.currentHistoryInfo.action&&this.documentHelper.layout.shiftLayoutedItems(!0),this.startParagraph=void 0,this.endParagraph=void 0),this.isHandledComplex=!1,this.editorHistory.currentHistoryInfo&&("ColumnBreak"===this.editorHistory.currentHistoryInfo.action||"PageBreak"===this.editorHistory.currentHistoryInfo.action));else{this.shiftFootnoteContent(),this.selection.updateContentControlHighlightSelection();return}}if(((0,a.le)(this.documentHelper.blockToShift)||(0,a.le)(this.documentHelper.blockToShift.containerWidget))&&(this.documentHelper.removeEmptyPages(),this.documentHelper.layout.updateFieldElements(),this.documentHelper.layout.checkAndShiftEndnote(!0),this.selection.updateContentControlHighlightSelection(),this.documentHelper.owner.enableHeaderAndFooter||e.isHighlightEditRegion||this.owner.viewer.updateScrollBars(),(!e.owner.isShiftingEnabled||this.documentHelper.isRowOrCellResizing)&&(e.fireSelectionChanged(!0),this.startParagraph=void 0,this.endParagraph=void 0)),(0,a.le)(t)&&(t=e.isEmpty),this.owner.showRevisions&&this.owner.trackChangesPane.isUpdateTrackChanges(this.owner.revisions.length)&&(this.owner.trackChangesPane.updatePendingChangesToView(),this.owner.trackChangesPane.updateTrackChanges()),e.owner.isShiftingEnabled){e.owner.isShiftingEnabled=!1,e.owner.isLayoutEnabled=!0;var l=e.start.paragraph.bodyWidget,d=l.getSplitWidgets();l=d[d.length-1];var h=!!this.editorHistory&&!!this.editorHistory.currentHistoryInfo&&"ColumnBreak"===this.editorHistory.currentHistoryInfo.action&&!!this.documentHelper.layout.isMultiColumnDoc;if("Word2010"!==this.documentHelper.compatibilityMode||!l.isWord2010NextColumn&&((0,a.le)(l.nextRenderedWidget)||!l.nextRenderedWidget.isWord2010NextColumn&&(!(l.nextRenderedWidget.sectionFormat.numberOfColumns>1)||"NoBreak"!==l.nextRenderedWidget.sectionFormat.breakCode))||l instanceof o.NB||!(0,a.le)(l.containerWidget)&&l.containerWidget instanceof o.tf){if(((0,a.le)(l.nextRenderedWidget)||"NoBreak"!==l.nextRenderedWidget.sectionFormat.breakCode||!this.documentHelper.layout.isMultiColumnDoc)&&("NoBreak"!==l.sectionFormat.breakCode||l.sectionIndex!==l.page.bodyWidgets[0].sectionIndex||!(l.sectionFormat.numberOfColumns>1))&&!h||l instanceof o.NB||!(0,a.le)(l.containerWidget)&&l.containerWidget instanceof o.tf)this.documentHelper.layout.shiftLayoutedItems(!0);else{var c=this.documentHelper.selection.start,p=this.documentHelper.selection.end,g=this.selection.getParagraphInfo(c),m=this.selection.getParagraphInfo(p),u=this.selection.getHierarchicalIndex(g.paragraph,g.offset.toString()),f=this.selection.getHierarchicalIndex(m.paragraph,m.offset.toString());this.documentHelper.layout.shiftLayoutedItems(!0),this.setPositionForCurrentIndex(c,u),this.setPositionForCurrentIndex(p,f),this.documentHelper.selection.selectPosition(c,p),this.documentHelper.owner.enableHeaderAndFooter||this.owner.viewer.updateScrollBars()}}else this.documentHelper.layout.layoutWholeDocument(!0,!0);this.documentHelper.owner.enableHeaderAndFooter&&(this.updateHeaderFooterWidget(),this.owner.viewer.updateScrollBars()),this.documentHelper.isRowOrCellResizing||(this.shiftFootnoteContent(),this.getOffsetValue(e),e.upDownSelectionLength=e.end.location.x,e.fireSelectionChanged(!0),this.owner.enableAutoFocus&&this.documentHelper.updateFocus(),this.startParagraph=void 0,this.endParagraph=void 0)}else this.documentHelper.owner.enableHeaderAndFooter&&(this.updateHeaderFooterWidget(),this.owner.viewer.updateScrollBars());if(this.editorHistory&&this.editorHistory.currentBaseHistoryInfo&&("RowResizing"!==this.editorHistory.currentBaseHistoryInfo.action&&"CellResizing"!==this.editorHistory.currentBaseHistoryInfo.action||this.editorHistory.isUndoing||this.editorHistory.isRedoing)&&(this.editorHistory.currentBaseHistoryInfo.modifiedProperties.length>0&&"AddRevision"!==this.editorHistory.currentBaseHistoryInfo.action&&this.editorHistory.currentBaseHistoryInfo.updateSelection(),this.editorHistory.undoStack&&this.editorHistory.undoStack.length>0&&this.editorHistory.undoStack[this.editorHistory.undoStack.length-1]instanceof W.d&&this.editorHistory.undoStack[this.editorHistory.undoStack.length-1].modifiedActions&&this.editorHistory.undoStack[this.editorHistory.undoStack.length-1].modifiedActions[this.editorHistory.undoStack[this.editorHistory.undoStack.length-1].modifiedActions.length-1]===this.editorHistory.currentBaseHistoryInfo?this.editorHistory.currentBaseHistoryInfo=void 0:this.editorHistory.updateHistory()),i){!(0,a.le)(e)&&this.documentHelper.formFields.length>0&&e.highlightFormFields();return}this.fireContentChange(),this.groupInsertAction(),this.owner.enableLockAndEdit&&this.owner.viewer.updateScrollBars(),this.owner.documentHelper.layout.isRelayout=!1,this.documentHelper.triggerSpellCheckForHF=!1,this.isFootnoteElementRemoved=!1,this.isEndnoteElementRemoved=!1},e.prototype.shiftFootnoteContent=function(){!(0,a.le)(this.selection.start.paragraph)&&!(0,a.le)(this.selection.start.paragraph.bodyWidget)&&!(0,a.le)(this.selection.start.paragraph.bodyWidget.containerWidget)&&this.selection.start.paragraph.bodyWidget.containerWidget instanceof o.tf&&("Footnote"===this.selection.start.paragraph.bodyWidget.containerWidget.footNoteType?(this.documentHelper.layout.isRelayoutFootnote=!0,this.shiftFootnotePageContent(this.selection.start.paragraph.bodyWidget.containerWidget)):(this.documentHelper.layout.isRelayoutFootnote=!1,this.shiftFootnotePageContent()))},e.prototype.updateHeaderFooterWidget=function(e){(0,a.le)(e)&&(e=this.selection.start.paragraph.bodyWidget),this.updateHeaderFooterWidgetToPage(e),this.shiftPageContent(e.headerFooterType,e.sectionFormat)},e.prototype.updateHeaderFooterWidgetToPage=function(e){e.page;for(var t="EvenHeader"===e.headerFooterType||"EvenFooter"===e.headerFooterType,i="FirstPageHeader"===e.headerFooterType||"FirstPageFooter"===e.headerFooterType,r=0;r<this.documentHelper.pages.length;r++){var o=this.documentHelper.pages[r];if(o.bodyWidgets[0].sectionFormat.differentFirstPage&&i&&(o.headerWidgetIn.headerFooterType==e.headerFooterType||o.footerWi
1dgetIn.headerFooterType==e.headerFooterType)){this.updateHeaderFooterWidgetToPageInternal(o,e,-1!==e.headerFooterType.indexOf("Header"));continue}(!o.bodyWidgets[0].sectionFormat.differentFirstPage||!i&&(i||0!=o.index)&&o.sectionIndex==o.previousPage.sectionIndex)&&(o.bodyWidgets[0].sectionFormat.differentOddAndEvenPages?t&&(r+1)%2==0?this.updateHeaderFooterWidgetToPageInternal(o,e,-1!==e.headerFooterType.indexOf("Header")):t||(r+1)%2==0||!(r>0)&&o.bodyWidgets[0].sectionFormat.differentFirstPage||this.updateHeaderFooterWidgetToPageInternal(o,e,-1!==e.headerFooterType.indexOf("Header")):this.updateHeaderFooterWidgetToPageInternal(o,e,-1!==e.headerFooterType.indexOf("Header")))}},e.prototype.updateHeaderFooterWidgetToPageInternal=function(e,t,i){if(i?t!=e.headerWidgetIn&&t.page.headerWidget==e.headerWidget:t!=e.footerWidgetIn&&t.page.footerWidget==e.footerWidget){var r=t.clone();this.documentHelper.layout.clearBlockWidget(r.childWidgets,!0,!0,!0),r.page=e,r.parentHeaderFooter=t,this.documentHelper.layout.updateRevisionsToHeaderFooter(r,e),this.owner.viewer.updateHFClientArea(r.sectionFormat,i),r=this.documentHelper.layout.layoutHeaderFooterItems(this.owner.viewer,r);var o=void 0;i?(o=e.headerWidgetIn,e.headerWidget=r,e.headerWidget.height=r.height):(o=e.footerWidgetIn,e.footerWidget=r),this.removeFieldInWidget(o),this.removeFieldInWidget(o,void 0,!0),o.destroy()}},e.prototype.removeFieldInWidget=function(e,t,i,r){(0,a.le)(t)&&(t=!1);for(var o=0;o<e.childWidgets.length;o++)this.removeFieldInBlock(e.childWidgets[o],t,i,r)},e.prototype.removeFieldInBlock=function(e,t,i,r){if(e instanceof o.dm){if(e.wrapTextAround&&!(0,a.le)(e.bodyWidget)){var n=e.bodyWidget.floatingElements.indexOf(e);-1!==n&&e.bodyWidget.floatingElements.splice(n,1)}this.removeFieldTable(e,t,i,r)}else if(e instanceof o.BC)for(var s=0;s<e.childWidgets.length;s++)this.removeFieldInWidget(e.childWidgets[s],t,i,r);else this.removeField(e,t,i,r)},e.prototype.removeFieldTable=function(e,t,i,r){for(var o=0;o<e.childWidgets.length;o++)for(var n=e.childWidgets[o],s=0;s<n.childWidgets.length;s++)this.removeFieldInWidget(n.childWidgets[s],t,i,r)},e.prototype.shiftFootnotePageContent=function(e){var t=this.documentHelper.pages[0].bodyWidgets[0];if(!(0,a.le)(e)){var i=this.documentHelper.pages.indexOf(e.page);t=this.documentHelper.pages[i].bodyWidgets[0]}(0,a.le)(t.page.footnoteWidget)||this.checkAndShiftFromBottom(t.page,t.page.footnoteWidget,!(0,a.le)(e)),(0,a.le)(t.page.endnoteWidget),this.documentHelper.blockToShift&&(this.documentHelper.renderedLists.clear(),this.documentHelper.renderedLevelOverrides=[],this.documentHelper.layout.shiftLayoutedItems(!1),this.documentHelper.layout.checkAndShiftEndnote(!1))},e.prototype.shiftPageContent=function(e,t){if(-1!==e.indexOf("First"))i=0;else if(t.differentOddAndEvenPages){var i,r=-1!==e.indexOf("Even");i=t.differentFirstPage?r?1:2:r?1:0}else 1==(i=t.differentFirstPage?1:0)&&1===this.documentHelper.pages.length&&(i=0);var n=this.documentHelper.pages[i].bodyWidgets[0];do{if(-1!==e.indexOf("Header")){var l=n.page.headerWidget,d=!l.isEmpty||l.isEmpty&&this.owner.enableHeaderAndFooter,h=n.firstChild,c=s.o_.convertPointToPixel(t.topMargin),p=s.o_.convertPointToPixel(t.headerDistance);if(d&&(c=Math.max(p+n.page.headerWidget.height,c)),h.y!==c){this.owner.viewer.updateClientArea(n,n.page);var g=(h=h.combineWidget(this.owner.viewer)).previousRenderedWidget,m="NoBreak"===n.sectionFormat.breakCode;!m&&g&&h.containerWidget.equals(g.containerWidget)&&!(g.containerWidget.lastChild instanceof o.ZH&&(g.containerWidget.lastChild.isEndsWithPageBreak||g.containerWidget.lastChild.isEndsWithColumnBreak))&&(this.owner.viewer.cutFromTop(g.y+g.height),this.documentHelper.layout.updateContainerWidget(h,g.containerWidget,g.indexInOwner+1,!1)),m&&g||(this.documentHelper.blockToShift=h)}}else this.checkAndShiftFromBottom(n.page,n.page.footerWidget);for(this.documentHelper.blockToShift&&(this.documentHelper.renderedLists.clear(),this.documentHelper.renderedLevelOverrides=[],this.documentHelper.layout.shiftLayoutedItems(!1));n;){var u=n;do{var f=n.getSplitWidgets();n=f[f.length-1].nextRenderedWidget}while(n&&u.page===n.page);if(n){if(0===i||n.page.index+1===0&&1===i||n.page.index+1!==0&&2===i)break;var y=n.page.nextPage;if(!(0,a.le)(y)&&y.bodyWidgets[0].equals(n)){n=y.bodyWidgets[0];break}}}}while(n)},e.prototype.checkAndShiftFromBottom=function(e,t,i){var r,n=e.bodyWidgets[0];if(n.childWidgets.length>1){for(var s=0;s<n.childWidgets.length;s++){var l=n.childWidgets[s];if(l.y+l.height>t.y||!(t instanceof o.tf)&&n.childWidgets.length-1===s&&l.y+l.height<t.y){r=l;break}}(0,a.le)(r)&&i&&(r=n.lastChild),(0,a.le)(r)||(this.owner.viewer.updateClientArea(n,e,!0),this.owner.viewer.cutFromTop(r.y),this.documentHelper.blockToShift=r)}},e.prototype.allowFormattingInFormFields=function(e){if("FormFieldsOnly"===this.documentHelper.protectionType&&this.selection.isInlineFormFillMode()&&!(0,a.le)(this.owner.documentEditorSettings.formFieldSettings.formattingExceptions)){for(var t=0;t<this.owner.documentEditorSettings.formFieldSettings.formattingExceptions.length;t++)if(e.toLowerCase()===this.owner.documentEditorSettings.formFieldSettings.formattingExceptions[t].toLowerCase())return!0}return!1},e.prototype.insertContentControlInCollection=function(e){var t=this.documentHelper.contentControlCollection,i=this.selection.getElementPosition(e).startPosition;(0,a.le)(i)&&(i=this.selection.isForward?this.selection.start:this.selection.end);var r=void 0,o=!1;if(-1===t.indexOf(e))for(var n=0;n<t.length;n++){var s=t[n];if(r=this.selection.getElementPosition(s).startPosition,!(0,a.le)(i)&&!(0,a.le)(r)&&i.isExistBefore(r)){t.splice(n,0,e),o=!0;break}}else o=!0;o||t.push(e)},e.prototype.getContentControl=function(){var e=this.getContentControls();if(e.length>0)return e[e.length-1]},e.prototype.getContentControls=function(){for(var e=[],t=0;t<this.documentHelper.contentControlCollection.length;t++)if((0,a.le)(this.documentHelper.contentControlCollection[t].paragraph)||!this.documentHelper.contentControlCollection[t].paragraph.isInHeaderFooter||"Continuous"!==this.documentHelper.owner.layoutType){var i=this.documentHelper.contentControlCollection[t];if(this.owner.enableHeaderAndFooter){if(i.paragraph.isInHeaderFooter&&this.pushContentControlByOrder(i,e))break}else if(!(0,a.le)(this.documentHelper.contentControlCollection[t].paragraph)&&!i.paragraph.isInHeaderFooter&&this.pushContentControlByOrder(i,e))break}return e},e.prototype.pushContentControlByOrder=function(e,t){var i=e.line;if(!(0,a.le)(i.children)&&!(0,a.le)(i.children.length)){var r=this.selection.getPosition(e,!0);if(r.startPosition&&r.endPosition){var o=r.startPosition,n=r.endPosition,s=this.selection.start,l=this.selection.end;this.selection.isForward||(s=this.selection.end,l=this.selection.start);var d=s.isExistAfter(o)||s.isAtSamePosition(o),h=l.isExistBefore(n)||l.isAtSamePosition(n);if(d&&h)t.push(e);else if(!e.paragraph.isInHeaderFooter&&!d)return!0}}return!1},e.prototype.checkPlainTextContentControl=function(){var e,t,i=this.selection.start,o=this.selection.end;this.selection.isForward||(o=this.selection.start,i=this.selection.end);var n=0,s=0,l=i.currentWidget.getInline(i.offset,n),d=o.currentWidget.getInline(o.offset,s);n=l.index,s=d.index;var h=l.element,c=d.element;if(h&&h.contentControlProperties&&"Text"===h.contentControlProperties.type||c&&c.contentControlProperties&&"Text"===c.contentControlProperties.type){if(h=this.getContentControl(),!(0,a.le)(h)&&h.contentControlProperties){var p=h.line.getOffset(h,1);(e=new r.JK(this.owner)).setPositionParagraph(h.line,p)}else e=i;if(c.contentControlProperties&&!(0,a.le)(h)&&h.reference){var g=(c=h.reference).line.getOffset(c,c.length);
1(t=new r.JK(this.owner)).setPositionParagraph(c.line,g)}else t=o;this.selection.selectRange(e,t)}else i.paragraph.contentControlProperties&&"Text"===i.paragraph.contentControlProperties.type&&this.selection.selectParagraph()},e.prototype.onApplyCharacterFormat=function(e,t,i,r){var o=this.documentHelper.isFormFillProtectedMode&&this.documentHelper.selection.isInlineFormFillMode()&&this.allowFormattingInFormFields(e);if(!(this.restrictFormatting&&!o||!(0,a.le)(this.selection)&&this.selection.checkContentControlLocked(!0))){this.documentHelper.layout.isBidiReLayout=!0;var n=this.documentHelper.selection;if((!n.owner.isReadOnlyMode||o)&&n.owner.isDocumentLoaded){i=!(0,a.le)(i)&&i,r=!(0,a.le)(r)&&r;var s=e[0].toUpperCase()+e.slice(1),l=n.start.paragraph;if(l.childWidgets[l.childWidgets.length-1],this.checkPlainTextContentControl(),n.isEmpty&&"List"!==n.contextType&&!r){n.skipFormatRetrieval=!0,n.end.isAtParagraphEnd?(this.initHistory(s),this.documentHelper.owner.isShiftingEnabled=!0,this.applyCharFormatValue(l.characterFormat,e,t,i),"fontSize"===e&&(0,a.le)(this.documentHelper.blockToShift)&&l.isEmpty()&&this.documentHelper.layout.reLayoutParagraph(l,0,0),this.reLayout(this.documentHelper.selection),this.documentHelper.updateFocus()):n.fireSelectionChanged(!0),n.skipFormatRetrieval=!1;return}if("highlightColor"===e&&n.start.isInSameParagraph(n.end)){var d=n.start,h=n.end;if(this.selection.isForward||(h=n.start,d=n.end),h.offset===n.getLineLength(h.currentWidget)+1&&h.offset-1===d.offset)return}this.setOffsetValue(n),this.initHistory(s),"List"===n.contextType?this.applyCharacterFormatForListText(n,e,t,i):this.updateSelectionCharacterFormatting(e,t,i),this.documentHelper.layout.isBidiReLayout=!1}}},e.prototype.applyCharacterFormatForListText=function(e,t,i,r){var o=e.getListLevel(e.start.paragraph);if(!(0,a.le)(o)){var n=o.characterFormat;switch(t){case"bold":this.applyListCharacterFormatByValue(e,n,"bold",!n.bold);break;case"italic":this.applyListCharacterFormatByValue(e,n,"italic",!n.italic);break;case"fontColor":this.applyListCharacterFormatByValue(e,n,"fontColor",i);break;case"fontFamily":this.applyListCharacterFormatByValue(e,n,"fontFamily",i);break;case"fontSize":this.applyListCharacterFormatByValue(e,n,"fontSize",i);break;case"highlightColor":this.applyListCharacterFormatByValue(e,n,"highlightColor",i);break;case"baselineAlignment":n.baselineAlignment===i&&(i="Normal"),this.applyListCharacterFormatByValue(e,n,"baselineAlignment",i);break;case"strikethrough":n.strikethrough===i&&(i="None"),this.applyListCharacterFormatByValue(e,n,"strikethrough",i);break;case"underline":n.underline===i&&(i="None"),this.applyListCharacterFormatByValue(e,n,"underline",i);break;case"characterFormat":this.applyListCharacterFormatByValue(e,n,void 0,i)}}},e.prototype.applyListCharacterFormatByValue=function(e,t,i,r){this.initHistory("ListCharacterFormat"),this.applyCharFormatValue(t,i,r,!1),this.editorHistory.updateHistory(),this.reLayout(e),this.fireContentChange()},e.prototype.updateListCharacterFormat=function(e,t,i){this.updateListTextSelRange(e,t,i,!1)},e.prototype.updateListTextSelRange=function(e,t,i,r){this.documentHelper.owner.isShiftingEnabled=!0;var o=e.start,n=e.end;e.isForward||(o=e.end,n=e.start),this.initHistoryPosition(e,o);var s=e.getListLevel(e.start.paragraph);this.applyCharFormatValue(s.characterFormat,t,i,r),this.startSelectionReLayouting(o.paragraph,e,o,n)},e.prototype.updateInsertPosition=function(){var e=this.documentHelper.selection,t=e.start;e.isForward||(t=e.end),this.editorHistory&&!(0,a.le)(this.editorHistory.currentBaseHistoryInfo)&&!(0,a.le)(t)&&(0,a.le)(this.editorHistory.currentBaseHistoryInfo.insertPosition)&&this.updateHistoryPosition(t,!0)},e.prototype.setOffsetValue=function(e){var t=this.selection.getParagraphInfo(e.start);this.startParagraph=t.paragraph,this.startOffset=t.offset,t=this.selection.getParagraphInfo(e.end),this.endParagraph=t.paragraph,this.endOffset=t.offset},e.prototype.toggleHighlightColor=function(e){var t=this.documentHelper.selection;((0,a.le)(e)||"NoColor"===e)&&(e="Yellow"),t.characterFormat.highlightColor===e&&(e="NoColor"),this.selection.characterFormat.highlightColor=e},e.prototype.toggleSubscript=function(){if(!this.owner.isReadOnlyMode&&!this.restrictFormatting){var e="Subscript"===this.selection.characterFormat.baselineAlignment?"Normal":"Subscript";this.selection.characterFormat.baselineAlignment=e}},e.prototype.toggleSuperscript=function(){if(!this.owner.isReadOnlyMode&&!this.restrictFormatting){var e="Superscript"===this.selection.characterFormat.baselineAlignment?"Normal":"Superscript";this.selection.characterFormat.baselineAlignment=e}},e.prototype.increaseIndent=function(){(!this.owner.isReadOnlyMode||this.selection.isInlineFormFillMode())&&(this.increasedIndent=!0,this.onApplyParagraphFormat("leftIndent",this.documentHelper.defaultTabWidth,!0,!1),this.increasedIndent=!1)},e.prototype.decreaseIndent=function(){(!this.owner.isReadOnlyMode||this.selection.isInlineFormFillMode())&&(this.decreasedIndent=!0,this.onApplyParagraphFormat("leftIndent",-this.documentHelper.defaultTabWidth,!0,!1),this.decreasedIndent=!1)},e.prototype.clearList=function(){this.selection.owner.editorModule.onApplyList(void 0)},e.prototype.applyBullet=function(e,t){(!this.owner.isReadOnlyMode||this.selection.isInlineFormFillMode())&&this.applyBulletOrNumbering(e,"Bullet",t)},e.prototype.applyNumbering=function(e,t){(!this.owner.isReadOnlyMode||this.selection.isInlineFormFillMode())&&this.applyBulletOrNumbering(e,t,"Verdana")},e.prototype.toggleBaselineAlignment=function(e){this.updateProperty(2,e)},e.prototype.clearFormattingInternal=function(e,t){var i=this.documentHelper.selection;this.setPreviousBlockToLayout(),this.initComplexHistory("ClearFormat"),(i.isEmpty||!(0,a.le)(e)&&e)&&(i.start.moveToParagraphStartInternal(i,!1),i.end.moveToParagraphEndInternal(i,!1)),this.setOffsetValue(i),this.editorHistory&&this.editorHistory.initializeHistory("ClearCharacterFormat"),this.updateSelectionCharacterFormatting("ClearCharacterFormat",void 0,!1),this.getOffsetValue(i),this.editorHistory&&this.editorHistory.updateHistory(),this.setOffsetValue(i),((0,a.le)(e)||e)&&(this.editorHistory&&this.editorHistory.initializeHistory("ClearParagraphFormat"),this.updateParagraphFormatInternal("ClearParagraphFormat",void 0,!1)),this.editorHistory&&this.editorHistory.updateHistory(),this.getOffsetValue(i),this.editorHistory&&!(0,a.le)(this.editorHistory.currentHistoryInfo)&&(t?this.editorHistory.updateComplexHistoryInternal():this.editorHistory.updateComplexHistory()),this.startParagraph=void 0,this.endParagraph=void 0},e.prototype.clearFormatting=function(){this.owner.isReadOnlyMode||this.clearFormattingInternal()},e.prototype.updateProperty=function(e,t){var i=this.selection;if((!this.owner.isReadOnlyMode&&!this.restrictFormatting||this.selection.isInlineFormFillMode())&&i.owner.isDocumentLoaded){var r=i.start;i.end,i.isForward||(r=i.end,i.start);var o=0,n=r.currentWidget.getInline(r.offset,o),s=n.element;o=n.index;var l=r.paragraph;if((0,a.le)(s)||s.length!==o||this.selection.isEmpty||(s=s.nextNode),1===e){var d="None";(0,a.le)(s)?(0,a.le)(l)||(d=l.characterFormat.underline):d=s.characterFormat.underline,this.selection.characterFormat.underline=t===d?"None":t}else{var h="Normal";(0,a.le)(s)?(0,a.le)(l)||(h=l.characterFormat.baselineAlignment):h=s.characterFormat.baselineAlignment,h===t&&(t="Normal"),this.selection.characterFormat.baselineAlignment=t}}},e.prototype.getCompleteStyles=function(){for(var e='{"styles":[',t=0,i=this.documentHelper.preDefinedStyles.keys;t<i.length;t++){var r=i[t];e+=this.documentHelper.preDefinedStyles.get(r)+","}return e.slice(0,-1)+"]}"},e.prototype.intializeDefaultStyles=function(){this.owner.skipStyleUpdate=!0;for(var e=this.owner.getStyleNames("Paragraph"),t=["Normal","Heading 1","Heading 2","Heading 3","Heading 4","Heading 5","Heading 6","Heading 7","Heading 8","Heading 9","Header","Footer"].filter(function(t){return -1===e.indexOf(t)}),i=0;i<t.length;i++){var r=t[i];this.createStyle(this.documentHelper.preDefinedStyles.get(r))}},e.prototype.createStyle=function(e,t){return this.createStyleIn(e,t).name},e.prototype.createStyleIn=function(e,t){var i=JSON.parse(e),r=this.documentHelper.styles.findByName(i.name),o=i.type;return(0,a.le)(r)||(0,a.le)(t)||!t?(void 0!==r&&(i.name=this.getUniqueStyleName(i.name)),this.documentHelper.owner.parser.parseStyle(JSON.parse(this.getCompleteStyles()),i,this.documentHelper.styles,!0)):o===r.type?this.setStyle(r,i):(i.name=this.getUniqueStyleName(i.name),this.documentHelper.owner.parser.parseStyle(JSON.parse(this.getCompleteStyles()),i,this.documentHelper.styles,!0)),this.owner.notify(F.PC,{}),this.documentHelper.styles.findByName(i.name)},e.prototype.setStyle=function(e,t){if(!(0,a.le)(t.basedOn)){var i=this.documentHelper.styles.findByName(t.basedOn);if((0,a.le)(i)){var r=this.getStyle(t.basedOn,JSON.parse(this.getCompleteStyles())),o=void 0;o=(0,a.le)(r)||r.type!==t.type?"Paragraph"===t.type?JSON.parse('{"type":"Paragraph","name":"Normal","next":"Normal"}'):JSON.parse('{"type": "Character","name": "Default Paragraph Font"}'):r,e.basedOn=this.documentHelper.styles.findByName(o.name)}else i.type===t.type&&(e.basedOn=i)}if(!(0,a.le)(t.next)&&"Paragraph"===t.type){if(t.next===t.name)e.next=e;else{var n=this.documentHelper.styles.findByName(t.next);(0,a.le)(n)||n.type!==e.type?e.next=e:e.next=n}}if(!(0,a.le)(t.link)){var s=this.documentHelper.styles.findByName(t.link),l=void 0;if((0,a.le)(s)||"Character"!==s.type){var d={};d.characterFormat=t.characterFormat,void 0!==this.documentHelper.styles.findByName(t.name+" Char").name?d.name=this.getUniqueStyleName(t.name)+" Char":d.name=t.name+" Char",d.type="Character",d.basedOn="Default Paragraph Font",l=d,this.documentHelper.owner.parser.parseStyle(JSON.parse(this.getCompleteStyles()),l,this.documentHelper.styles),e.link=this.documentHelper.styles.findByName(l.name)}
1else this.documentHelper.owner.parser.parseCharacterFormat(0,t.characterFormat,s.characterFormat),e.link=s;if("Character"==t.type)for(var h=0;h<this.documentHelper.styles.length;h++){var c=this.documentHelper.styles.getItem(h),p=c.link,g=void 0===p?"":p.name;"Paragraph"!==c.type||g!==t.link||(0,a.le)(c.characterFormat)||this.documentHelper.owner.parser.parseCharacterFormat(0,t.characterFormat,c.characterFormat)}}(0,a.le)(t.paragraphFormat)||this.documentHelper.owner.parser.parseParagraphFormat(0,t.paragraphFormat,e.paragraphFormat),(0,a.le)(t.characterFormat)||this.documentHelper.owner.parser.parseCharacterFormat(0,t.characterFormat,e.characterFormat)},e.prototype.getStyle=function(e,t){for(var i=0;i<t.styles.length;i++)if(t.styles[i].name===e)return t.styles[i]},e.prototype.getUniqueStyleName=function(e){for(var t=this.getUniqueName(e),i=this.documentHelper.styles.findByName(t);!(0,a.le)(i);)t=this.getUniqueStyleName(i.name),i=this.documentHelper.styles.findByName(t);return t},e.prototype.getUniqueName=function(e){var t=e.match(/\d+$/);return!(0,a.le)(t)&&t.length>0?e.replace(t[0],(parseInt(t[0],10)+1).toString()):e+"_1"},e.prototype.updateSelectionCharacterFormatting=function(e,t,i){switch((0,a.le)(e)&&(e="CharacterFormat"),!(0,a.le)(this.editorHistory)&&this.editorHistory.currentBaseHistoryInfo&&(this.editorHistory.currentBaseHistoryInfo.insertedFormat=t),e){case"bold":this.updateCharacterFormat("bold",t);break;case"italic":this.updateCharacterFormat("italic",t);break;case"fontColor":this.updateCharacterFormat("fontColor",t);break;case"fontFamily":this.updateCharacterFormat("fontFamily",t);break;case"fontSize":this.documentHelper.layout.isBidiReLayout=!1,this.updateCharacterFormatWithUpdate(this.documentHelper.selection,"fontSize",t,i);break;case"highlightColor":this.updateCharacterFormat("highlightColor",t);break;case"baselineAlignment":this.updateCharacterFormat("baselineAlignment",t);break;case"strikethrough":this.updateCharacterFormat("strikethrough",t);break;case"underline":this.updateCharacterFormat("underline",t);break;case"styleName":this.updateCharacterFormatWithUpdate(this.documentHelper.selection,"styleName",t,!0,!0);break;case"CharacterFormat":this.updateCharacterFormat(void 0,t);break;case"ClearCharacterFormat":this.updateCharacterFormat("ClearCharacterFormat",t);break;case"allCaps":this.updateCharacterFormat("allCaps",t)}this.reLayout(this.documentHelper.selection)},e.prototype.updateCharacterFormat=function(e,t){this.updateCharacterFormatWithUpdate(this.documentHelper.selection,e,t,!1)},e.prototype.updateCharacterFormatWithUpdate=function(e,t,i,r,o){o=!(0,a.le)(o)&&o,this.documentHelper.owner.isShiftingEnabled=!0;var n=e.start,s=e.end;if(e.isEmpty||e.isForward||(n=e.end,s=e.start),e.isEmpty&&o){var l=n.offset,d=n.clone(),h=s.clone();this.selection.selectCurrentWord(),(l===this.selection.start.offset||l===this.selection.end.offset-1)&&(this.selection.start=d,this.selection.end=h)}this.applyCharFormatSelectedContent(n.paragraph,e,n,s,t,i,r)},e.prototype.applyCharFormatSelectedContent=function(e,t,i,r,n,s,a){if(i.paragraph.isInsideTable&&(!r.paragraph.isInsideTable||i.paragraph.associatedCell!==r.paragraph.associatedCell||t.isCellSelected(i.paragraph.associatedCell,i,r))){var l=void 0;i.paragraph.associatedCell.ownerTable.combineWidget(this.owner.viewer),this.checkInsertPosition(t)&&this.updateHistoryPosition(i,!0),l=i.paragraph.associatedCell;for(var d=this.applyCharFormatCell(l,t,i,r,n,s,a);d;)d=d instanceof o.ZH?this.applyCharFormat(d,t,i,r,n,s,a):this.applyCharFormatForTable(0,d,t,i,r,n,s,a);var h=l.ownerTable;this.documentHelper.layout.layoutBodyWidgetCollection(h.index,h.containerWidget,h,!1)}else{var d=e;do d=d instanceof o.ZH?this.applyCharFormat(d,t,i,r,n,s,a):this.applyCharFormatForTable(0,d,t,i,r,n,s,a);while(d)}},e.prototype.applyCharFormatForSelectedPara=function(e,t,i,r,o){for(var n=0;n<e.childWidgets.length;n++)for(var s=e.childWidgets[n],a=0;a<s.children.length;a++){var l=s.children[a];l.isWidthUpdated=!1,this.applyCharFormatValue(l.characterFormat,i,r,o)}this.applyCharFormatValue(e.characterFormat,i,r,o)},e.prototype.splittedLastParagraph=function(e){var t=e.getSplitWidgets();return t[t.length-1]},e.prototype.getNextParagraphForCharacterFormatting=function(e,t,i,r,o,n){var s=e.getSplitWidgets();return e=s[s.length-1],this.documentHelper.selection.getNextRenderedBlock(e)},e.prototype.applyCharFormat=function(e,t,i,r,n,s,l){var d=e.previousSplitWidget,h=!1;!(0,a.le)(d)&&d instanceof o.ZH&&(h=!0),e=e.combineWidget(this.owner.viewer);var c=0,p=t.getParagraphLength(e),g=-1!==e.childWidgets.indexOf(i.currentWidget)?e.childWidgets.indexOf(i.currentWidget):0,m=r.offset,u=-1!==e.childWidgets.indexOf(r.currentWidget)?e.childWidgets.indexOf(r.currentWidget):e.childWidgets.length-1;if((0,a.le)(t)||e!==i.paragraph||(c=i.offset),e.equals(r.paragraph)){var f=e.childWidgets[e.childWidgets.length-1];t.isParagraphLastLine(f)&&r.currentWidget===f&&(m===t.getLineLength(f)+1||t.isEmpty&&t.end.isAtParagraphEnd)&&(this.applyCharFormatValue(e.characterFormat,n,s,l),f.children&&f.children[0]instanceof o.no||(e.characterFormat.highlightColor="NoColor"))}else{var f=e.childWidgets[e.childWidgets.length-1];"highlightColor"===n&&t.isParagraphLastLine(f)&&i.currentWidget===f&&i.offset===t.getLineLength(f)||this.applyCharFormatValue(e.characterFormat,n,s,l),m=p}for(var y=g;y<=u;y++){var v=e.childWidgets[y];y!==g&&(c=t.getStartLineOffset(v)),m=v===r.currentWidget?r.offset:t.getLineLength(v);for(var H=0,C=void 0,F=-1,w=!0,I=0;I<v.children.length;w?I++:I--){var x=v.children[I];if(x.isWidthUpdated=!1,!(x instanceof o.no)){if(C===x&&(C=void 0,I=F,F=-1,w=!0),c>=H+x.length){H+=x.length;continue}var b=0;c>H&&(b=c-H);var W=m-H,P=x.length;W>P&&(W=P);var k=this.applyCharFormatInline(x,t,b,W,n,s,l);if(("fontColor"!==n||0===e.characterFormat.revisionLength)&&!e.equals(r.paragraph)&&this.isForHyperlinkFormat&&this.owner.enableTrackChanges&&v.children[I].indexInOwner===v.children.length-1&&v===v.paragraph.lastChild&&!(0,a.le)(x)&&x.revisionLength>0){var R=x.getRevision(x.revisionLength-1);this.insertRevision(e.characterFormat,R.revisionType)}if(I+=k,m<=H+P)break;H+=P}}}var T=r.paragraph;if(this.documentHelper.layout.reLayoutParagraph(e,h?0:g,0),!e.equals(T))return this.getNextParagraphForCharacterFormatting(e,i,r,n,s,l)},e.prototype.toggleBold=function(){if(!this.owner.isReadOnlyMode&&!this.restrictFormatting||this.selection.isInlineFormFillMode()){var e=this.getCurrentSelectionValue("bold");this.selection.characterFormat.bold=e}},e.prototype.toggleItalic=function(){if(!this.owner.isReadOnlyMode&&!this.restrictFormatting||this.selection.isInlineFormFillMode()){var e=this.getCurrentSelectionValue("italic");this.selection.characterFormat.italic=e}},e.prototype.changeCase=function(e){if(!this.selection.isEmpty&&(!this.owner.isReadOnlyMode&&!this.restrictFormatting||this.selection.isInlineFormFillMode())){this.initHistory(e),this.documentHelper.owner.isShiftingEnabled=!0;var t=this.selection,i=t.start,r=t.end;
1t.isForward||(i=t.end,r=t.start),this.changeSelectedTextCase(t,i,r,e),this.reLayout(t)}},e.prototype.changeSelectedTextCase=function(e,t,i,r,o){var n=this.selection.getParagraphInfo(t);e.editPosition=this.selection.getHierarchicalIndex(n.paragraph,n.offset.toString()),this.editorHistory&&this.editorHistory.currentBaseHistoryInfo&&this.checkInsertPosition(e)&&this.updateHistoryPosition(t,!0);var s=this.editorHistory.isUndoing;s&&!(0,a.le)(o)&&o.length>0&&(this.removedTextNodes=o);var l=e.isForward?i.selection.endOffset:i.selection.startOffset;this.changeTextCase(t.paragraph,e,t,i,r,s),this.editorHistory&&this.editorHistory.currentBaseHistoryInfo&&(i=e.getTextPosBasedOnLogicalIndex(l),this.checkEndPosition(e)&&this.updateHistoryPosition(i,!1),e.selectPosition(t,i))},e.prototype.changeTextCase=function(e,t,i,r,o,n){if(i.paragraph.isInsideTable&&(!r.paragraph.isInsideTable||i.paragraph.associatedCell!==r.paragraph.associatedCell||t.isCellSelected(i.paragraph.associatedCell,i,r))){var s=void 0;i.paragraph.associatedCell.ownerTable.combineWidget(this.owner.viewer),this.checkInsertPosition(t)&&this.updateHistoryPosition(i,!0),s=i.paragraph.associatedCell,this.changeCaseParaFormatInCell(s,i,r,o,n);var a=s.ownerTable;this.documentHelper.layout.layoutBodyWidgetCollection(a.index,a.containerWidget,a,!1)}else this.changeCaseParagraph(e,t,i,r,o,n)},e.prototype.changeCaseParagraph=function(e,t,i,r,n,s){e=e.combineWidget(this.owner.viewer);var l=0,d=t.getParagraphLength(e),h=-1!==e.childWidgets.indexOf(i.currentWidget)?e.childWidgets.indexOf(i.currentWidget):0,c=r.offset,p=-1!==e.childWidgets.indexOf(r.currentWidget)?e.childWidgets.indexOf(r.currentWidget):e.childWidgets.length-1;(0,a.le)(t)||e!==i.paragraph||(l=i.offset),e.equals(r.paragraph)||(c=d);for(var g=h;g<=p;g++){this.checkLastLetterSpaceDot="",this.checkLastLetterSpace="";var m=e.childWidgets[g];g!==h&&(l=t.getStartLineOffset(m)),c=m===r.currentWidget?r.offset:t.getLineLength(m);for(var u=0,f=void 0,y=-1,v=!0,H=0;H<m.children.length;v?H++:H--){var C=m.children[H],F=!1;if((0===H||H>0&&m.children[H-1]instanceof o.a3)&&(F=!0,H>0)){var w=m.children[H-1];this.checkLastLetterSpace=w.text.substr(-1),this.checkLastLetterSpaceDot=w.text.substr(-2)}if(!(C instanceof o.no)){if(f===C&&(f=void 0,H=y,y=-1,v=!0),l>=u+C.length){u+=C.length;continue}var I=0;l>u&&(I=l-u);var x=c-u,b=C.length;if(x>b&&(x=b),H+=this.changeCaseInline(C,t,I,x,n,s,F),c<=u+b)break;u+=b}}}var W=r.paragraph;this.documentHelper.layout.reLayoutParagraph(e,h,0),e.equals(W)||this.changeCaseNextBlock(e,i,r,n,s)},e.prototype.changeCaseInline=function(e,t,i,r,n,s,a){if(e instanceof o.a3){if(0!==i||r!==e.length)return this.changeCaseInlineInternal(e,t,i,r,n,s,a);this.changeCaseInlineInternal(e,t,i,r,n,s,a)}return 0},e.prototype.addRemovedTextNodes=function(e,t){if(e instanceof o.a3&&!(0,a.le)(this.editorHistory.currentBaseHistoryInfo)){var i=this.editorHistory.currentBaseHistoryInfo.removedNodes[0];(0,a.le)(i)&&((i=new o.a3).text="",this.editorHistory.currentBaseHistoryInfo.removedNodes.push(i)),i.text+=t,i.isWidthUpdated=!1}},e.prototype.changeCaseInlineInternal=function(e,t,i,r,n,l,d){var h,c=0,p=!1,g=e.line.children.indexOf(e),m=e.paragraph,u=m.childWidgets.indexOf(e.line);if(e.isWidthUpdated=!1,i>0){var f=e.text.substr(i,r-i);if(this.addRemovedTextNodes(e,f),(h=new o.a3).characterFormat.copyFormat(e.characterFormat),h.line=e.line,"CapitalizeEachWord"===n){var y=e.text.substr(i-1,1);p=" "===y}if("SentenceCase"===n){var y=e.text.substr(i-2,2);p=". "===y}h.characterFormat.allCaps="Uppercase"===n&&!l,h.text=this.getChangeCaseText(f,n,l,p),h.isRightToLeft=e.isRightToLeft,g++,e.line.children.splice(g,0,h),c++}r<e.length&&((h=new o.a3).characterFormat.copyFormat(e.characterFormat),h.text=e.text.substring(r),h.line=e.line,h.isRightToLeft=e.isRightToLeft,g++,e.line.children.splice(g,0,h),c++);var v=e;if(0===i){var H=v.text.substr(0,r);if(this.addRemovedTextNodes(e,H),"SentenceCase"===n)". "===this.checkLastLetterSpaceDot?p=!0:0===u&&""===this.checkLastLetterSpaceDot&&(p=!d||m.childWidgets[0].children[0]===v),this.checkLastLetterSpaceDot=v.text.substr(-2);else if("CapitalizeEachWord"==n){if(d)p=0===t.getIndexInInline(e)||" "===this.checkLastLetterSpace||v.previousElement instanceof o.u3;else if(v.previousElement instanceof o.Xw||v.previousElement instanceof o.aQ||v.previousElement instanceof o.V8){var C=(0,a.le)(v.previousElement.previousElement)?void 0:v.previousElement.previousElement.text;p=!!((0,a.le)(C)||s.o_.endsWith(C))}else p=!0;this.checkLastLetterSpace=v.text.charAt(v.length-1)}v.characterFormat.allCaps="Uppercase"===n&&!l,v.text=this.getChangeCaseText(H,n,l,p)}else{var F=v.text.substr(0,i);v.text=F}return c},e.prototype.changeCaseNextBlock=function(e,t,i,r,n){e=this.getNextBlockForChangeCase(e,t,i,r,n),(0,a.le)(e)||(e instanceof o.ZH?this.changeCaseParagraph(e,this.documentHelper.selection,t,i,r,n):this.changeCaseForTable(0,e,this.documentHelper.selection,t,i,r,n))},e.prototype.getNextBlockForChangeCase=function(e,t,i,r,o){var n=e.getSplitWidgets();return e=n[n.length-1],e=this.documentHelper.selection.getNextRenderedBlock(e)},e.prototype.getChangeCaseText=function(e,t,i,r){if(i){if(!(0,a.le)(this.removedTextNodes)&&this.removedTextNodes.length>0){var o=this.removedTextNodes[0],n=o.text.substr(0,e.length);o.text=o.text.substr(n.length,o.length-n.length),e=n,""===o.text&&this.removedTextNodes.splice(0,1)}}else switch(t){case"SentenceCase":e=this.sentencecase(e,r);break;case"Uppercase":e=e.toUpperCase();break;case"Lowercase":e=e.toLowerCase();break;case"CapitalizeEachWord":e=this.capitalizeFirst(e,r);break;case"ToggleCase":e=this.togglecase(e)}return e},e.prototype.capitalizeFirst=function(e,t){if(/\b\w+'\w+\b/g.test(e))return e.split(/[^a-zA-Z0-9'\-]+/).toString(),e.split(" ").map(function(e){return e.charAt(0).toUpperCase()+e.slice(1)}).join(" ");for(var i=e.split(/[^\w\u00C0-\u024F]+/g).map(function(e,i){return 0===i?t?e.charAt(0).toUpperCase()+e.slice(1).toLowerCase():e.toLowerCase():e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()}
1),r=e.split(/[\w\u00C0-\u024F]+/g).filter(Boolean),o=[],n=0;n<Math.max(i.length,r.length);n++)i[n]&&o.push(i[n]),r[n]&&o.push(r[n]);return o.join("")},e.prototype.sentencecase=function(e,t){return e.split(". ").map(function(e,i){return 0===i?t?e.charAt(0).toUpperCase()+e.slice(1).toLowerCase():e.toLowerCase():e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()}).join(". ")},e.prototype.togglecase=function(e){return e.split("").map(function(e){return e===e.toLowerCase()?e.toUpperCase():e.toLowerCase()}).join("")},e.prototype.changeCaseForTable=function(e,t,i,r,o,n,s){t=t.combineWidget(this.owner.viewer);for(var a=e;a<t.childWidgets.length;a++){for(var l=t.childWidgets[a],d=0;d<l.childWidgets.length;d++)this.changeCaseForSelectedCell(l.childWidgets[d],i,n,s);if(o.paragraph.isInsideTable&&i.containsRow(l,o.paragraph.associatedCell)){this.documentHelper.layout.layoutBodyWidgetCollection(t.index,t.containerWidget,t,!1);return}}this.documentHelper.layout.layoutBodyWidgetCollection(t.index,t.containerWidget,t,!1),this.changeCaseNextBlock(t,r,o,n,s)},e.prototype.changeCaseForSelectedCell=function(e,t,i,r){for(var n=0;n<e.childWidgets.length;n++){var s=e.childWidgets[n];s instanceof o.ZH?this.changeCaseForSelectedPara(s,t,i,r):this.changeCaseForSelTable(s,t,i,r)}},e.prototype.changeCaseForSelectedPara=function(e,t,i,r){for(var n=0;n<e.childWidgets.length;n++)for(var s=e.childWidgets[n],l="",d=0;d<s.children.length;d++){var h=s.children[d];h.characterFormat.allCaps="Uppercase"===i&&!r;var c=!1;!(0,a.le)(h)&&h instanceof o.a3&&(this.addRemovedTextNodes(h,h.text),"CapitalizeEachWord"===i?(c=0===d||" "===l,l=h.text.substr(h.length-1,1)):"SentenceCase"===i&&(c=". "===h.text.substr(h.length-2,2)||0===d),h.text=this.getChangeCaseText(h.text,i,r,c),h.isWidthUpdated=!1)}},e.prototype.changeCaseForSelTable=function(e,t,i,r){for(var o=0;o<e.childWidgets.length;o++)for(var n=e.childWidgets[o],s=0;s<n.childWidgets.length;s++)this.changeCaseForSelectedCell(n.childWidgets[s],t,i,r)},e.prototype.changeCaseParaFormatInCell=function(e,t,i,r,o){var n=this.documentHelper.selection;if(i.paragraph.isInsideTable){var s=n.getContainerCellOf(e,i.paragraph.associatedCell);if(s.ownerTable.contains(i.paragraph.associatedCell)){var a=n.getSelectedCell(e,s),l=n.getSelectedCell(i.paragraph.associatedCell,s);n.containsCell(s,i.paragraph.associatedCell)?n.isCellSelected(s,t,i)?this.changeCaseParaForCellInternal(s,n,r,o):a===s?this.changeCaseParagraph(t.paragraph,n,t,i,r,o):this.changeCaseParaForRow(a.ownerRow,n,t,i,r,o):this.changeCaseParaForTableCell(s.ownerTable,s,l,r,o)}else this.changeCaseParaForRow(s.ownerRow,n,t,i,r,o)}else{var d=n.getContainerCell(e);this.changeCaseParaForRow(d.ownerRow,n,t,i,r,o)}},e.prototype.changeCaseParaForTableCell=function(e,t,i,r,o){var n=this.documentHelper.selection,s=n.getCellLeft(t.ownerRow,t),a=s+t.cellFormat.cellWidth,l=n.getCellLeft(i.ownerRow,i),d=l+i.cellFormat.cellWidth,h=this.updateSelectedCellsInTable(s,a,l,d);s=h.start,a=h.end;for(var c=e.childWidgets.indexOf(i.ownerRow),p=e.childWidgets.indexOf(t.ownerRow);p<=c;p++)for(var g=e.childWidgets[p],m=0;m<g.childWidgets.length;m++){var u=n.getCellLeft(g,g.childWidgets[m]);Math.round(s)<=Math.round(u)&&Math.round(u)<Math.round(a)&&this.changeCaseParaForCellInternal(g.childWidgets[m],n,r,o)}},e.prototype.changeCaseParaForCellInternal=function(e,t,i,r){for(var n=0;n<e.childWidgets.length;n++){var s=e.childWidgets[n];s instanceof o.ZH?this.changeCaseForSelectedPara(s,t,i,r):this.changeCaseParaFormatTableInternal(s,t,i,r)}},e.prototype.changeCaseParaFormatTableInternal=function(e,t,i,r){for(var o=0;o<e.childWidgets.length;o++)for(var n=e.childWidgets[o],s=0;s<n.childWidgets.length;s++)this.changeCaseParaForCellInternal(n.childWidgets[s],t,i,r)},e.prototype.changeCaseParaForRow=function(e,t,i,r,o,n){for(var s=e.rowIndex;s<e.ownerTable.childWidgets.length;s++){for(var a=e.ownerTable.childWidgets[s],l=0;l<a.childWidgets.length;l++)this.changeCaseParaForCellInternal(a.childWidgets[l],t,o,n);if(r.paragraph.isInsideTable&&this.documentHelper.selection.containsRow(a,r.paragraph.associatedCell))return}this.changeCaseNextBlock(e.ownerTable,i,r,o,n)},e.prototype.toggleAllCaps=function(){if(!this.documentHelper.owner.isReadOnlyMode||this.selection.isInlineFormFillMode()){var e=this.getCurrentSelectionValue("allCaps");this.selection.characterFormat.allCaps=e}},e.prototype.toggleChangeCase=function(){var e=["Uppercase","Lowercase","CapitalizeEachWord"];return this.casingIndex++,this.casingIndex>=e.length&&(this.casingIndex=0),e[this.casingIndex]},e.prototype.getCurrentSelectionValue=function(e){var t=!1;if("bold"===e||"italic"===e){var i=this.getSelectedCharacterFormat();"bold"===e&&(t=!i.bold),"italic"===e&&(t=!i.italic)}return t},e.prototype.getSelectedCharacterFormat=function(){var e=0,t=this.selection.start;this.selection.isForward||(t=this.selection.end);var i=t.currentWidget,r=i.getInline(t.offset,e),o=r.element;e=r.index;var n=i.paragraph.characterFormat;if(!(0,a.le)(o)){if(this.selection.isEmpty&&"List"===this.selection.contextType){var s=this.selection.getListLevel(this.selection.start.paragraph);s.characterFormat.uniqueCharacterFormat&&(n=s.characterFormat)}else n=this.selection.isEmpty||e!==o.length?o.characterFormat:(0,a.le)(o.nextNode)?i.paragraph.characterFormat:o.nextNode.characterFormat}return n},e.prototype.toggleUnderline=function(e){(!this.owner.isReadOnlyMode&&!this.restrictFormatting||this.selection.isInlineFormFillMode())&&this.updateProperty(1,e)},e.prototype.toggleStrikethrough=function(e){if(!this.owner.isReadOnlyMode||this.selection.isInlineFormFillMode()){var t=void 0;t=(0,a.le)(e)?"SingleStrike"===this.selection.characterFormat.strikethrough?"None":"SingleStrike":e,this.selection.characterFormat.strikethrough=t}},e.prototype.updateFontSize=function(e,t){if("number"==typeof t&&!(t<0&&1===e.fontSize))return e.fontSize+t;var i=[8,9,10,11,12,14,16,18,20,24,26,28,36,48,72];if("string"==typeof t&&"increment"===t){if(e.fontSize<8)return e.fontSize+1;if(e.fontSize>=72&&e.fontSize<80)return 80;if(e.fontSize>=80)return e.fontSize+10;for(var r=0;r<i.length;r++)if(e.fontSize<i[r])return i[r]}else if("string"==typeof t&&"decrement"===t&&e.fontSize>1){if(e.fontSize<=8)return e.fontSize-1;if(e.fontSize>72&&e.fontSize<=80)return 72;if(e.fontSize>80)return e.fontSize-10;for(var r=0;r<i.length;r++)if(e.fontSize<=i[r])return i[r-1]}return e.fontSize},e.prototype.applyCharFormatInline=function(e,t,i,r,n,s,a){if(0===i&&r===e.length)this.applyCharFormatValue(e.characterFormat,n,s,a);else if(e instanceof o.a3)return this.formatInline(e,t,i,r,n,s,a);return 0},e.prototype.formatInline=function(e,t,i,r,n,s,l){var d,h=0,c=e.line.children.indexOf(e);e.paragraph;var p=0;return i>0&&(p+=1,(d=new o.a3).characterFormat.copyFormat(e.characterFormat),(0,a.le)(e.contentControlProperties)||(d.contentControlProperties=e.contentControlProperties),d.line=e.line,d.text=e.text.substr(i,r-i),d.isRightToLeft=e.isRightToLeft,this.applyCharFormatValue(d.characterFormat,n,s,l),c++,e.line.children.splice(c,0,d),h++,this.updateRevisionForFormattedContent(e,d,p)),r<e.length&&(p+=1,(d=new o.a3).characterFormat.copyFormat(e.characterFormat),(0,a.le)(e.contentControlProperties)||(d.contentControlProperties=e.contentControlProperties),d.text=e.text.substring(r),d.line=e.line,d.isRightToLeft=e.isRightToLeft,c++,e.line.children.splice(c,0,d),h++,this.updateRevisionForFormattedContent(e,d,p)),0===i?(e.text=e.text.substr(0,r),this.applyCharFormatValue(e.characterFormat,n,s,l)):e.text=e.text.substr(0,i),h},e.prototype.updateRevisionForFormattedContent=function(e,t,i){for(var r=0;r<e.revisionLength;r++){var o=e.getRevision(r);t.insertRevisionAt(0,o),this.owner.trackChangesPane.updateCurrentTrackChanges(o)}},e.prototype.applyCharFormatCell=function(e,t,i,r,o,n,s){if(r.paragraph.isInsideTable){var a=t.getContainerCellOf(e,r.paragraph.associatedCell);if(!a.ownerTable.contains(r.paragraph.associatedCell))return this.applyCharFormatRow(a.ownerRow,t,i,r,o,n,s);var l=t.getSelectedCell(e,a),d=t.getSelectedCell(r.paragraph.associatedCell,a);if(t.containsCell(a,r.paragraph.associatedCell)){if(t.isCellSelected(a,i,r)){n=this.getCharacterFormatValueOfCell(e,t,n,o),this.applyCharFormatForSelectedCell(a,t,o,n,s);return}return l===a?this.applyCharFormat(i.paragraph,t,i,r,o,n,s):this.applyCharFormatRow(l.ownerRow,t,i,r,o,n,s)}return void this.applyCharFormatForTableCell(a.ownerTable,t,a,d,o,n,s)}var h=t.getContainerCell(e);return this.applyCharFormatRow(h.ownerRow,t,i,r,o,n,s)},e.prototype.applyCharFormatForSelectedCell=function(e,t,i,r,n){for(var s=0;s<e.childWidgets.length;s++){var a=e.childWidgets[s];a instanceof o.ZH?this.applyCharFormatForSelectedPara(a,t,i,r,n):this.applyCharFormatForSelTable(a,t,i,r,n)}},e.prototype.applyCharFormatRow=function(e,t,i,r,o,n,s){return n=this.getCharacterFormatValueOfCell(e.childWidgets[0],t,n,o),this.applyCharFormatForTable(e.rowIndex,e.ownerTable,t,i,r,o,n,s)},e.prototype.applyCharFormatForTable=function(e,t,i,r,o,n,s,a){t=t.combineWidget(this.owner.viewer);for(var l=e;l<t.childWidgets.length;l++){for(var d=t.childWidgets[l],h=0;h<d.childWidgets.length;h++)this.applyCharFormatForSelectedCell(d.childWidgets[h],i,n,s,a);if(o.paragraph.isInsideTable&&i.containsRow(d,o.paragraph.associatedCell)){this.documentHelper.layout.layoutBodyWidgetCollection(t.index,t.containerWidget,t,!1);return}}return this.documentHelper.layout.layoutBodyWidgetCollection(t.index,t.containerWidget,t,!1),this.getNextParagraphForCharacterFormatting(t,r,o,n,s,a)},e.prototype.applyCharFormatForSelTable=function(e,t,i,r,o){for(var n=0;n<e.childWidgets.length;n++)for(var s=e.childWidgets[n],a=0;a<s.childWidgets.length;a++)this.applyCharFormatForSelectedCell(s.childWidgets[a],t,i,r,o)},e.prototype.applyCharFormatForTableCell=function(e,t,i,r,o,n,a){var l=t.getCellLeft(i.ownerRow,i),d=l+i.cellFormat.cellWidth,h=t.getCellLeft(r.ownerRow,r),c=h+r.cellFormat.cellWidth,p=this.updateSelectedCellsInTable(l,d,h,c);l=p.start,d=p.end;for(var g=e.childWidgets.indexOf(r.ownerRow),m=!1,u=e.childWidgets.indexOf(i.ownerRow);u<=g;u++)for(var f=e.childWidgets[u],y=0;y<f.childWidgets.length;y++){var v=t.getCellLeft(f,f.childWidgets[y]);s.o_.round(l,2)<=s.o_.round(v,2)&&s.o_.round(v,2)<s.o_.round(d,2)&&(m||(n=this.getCharacterFormatValueOfCell(f.childWidgets[y],t,n,o),m=!0),this.applyCharFormatForSelectedCell(f.childWidgets[y],t,o,n,a))}},e.prototype.updateSelectedCellsInTable=function(e,t,i,r){var o=this.documentHelper.selection;return e>i&&(e=i),t<r&&(t=r),e>o.upDownSelectionLength&&(e=o.upDownSelectionLength),t<o.upDownSelectionLength&&(t=o.upDownSelectionLength),{start:e,end:t}},e.prototype.getCharacterFormatValueOfCell=function(e,t,i,r){if("boolean"==typeof i||void 0===i&&("bold"===r||"italic"===r)){var o=t.getFirstParagraph(e),n=o.characterFormat;o.childWidgets.length>0&&o.childWidgets[0].children.length>0&&(n=o.childWidgets[0].children[0].characterFormat),i=!n.getPropertyValue(r)}return i},e.prototype.applyCharFormatValueInternal=function(e,t,i,r){this.applyCharFormatValue(t,i,r,!1)},e.prototype.copyInlineCharacterFormat=function(e,t){t.uniqueCharacterFormat=e.uniqueCharacterFormat,t.baseCharStyle=e.baseCharStyle},e.prototype.applyCharFormatValue=function(e,t,i,r){if(r&&"fontSize"===t&&(i=this.updateFontSize(e,i)),this.editorHistory&&!(0,a.le)(this.editorHistory.currentBaseHistoryInfo)&&(i=this.editorHistory.currentBaseHistoryInfo.addModifiedProperties(e,t,i),this.editorHistory.currentBaseHistoryInfo.insertedFormat=i),i instanceof n.a){this.editorHistory&&(this.editorHistory.isUndoing||this.editorHistory.isRedoing)?(this.copyInlineCharacterFormat(i,e),this.owner.enableCollaborativeEditing&&e.ownerBase instanceof o.nR&&this.editorHistory.currentBaseHistoryInfo.buildCharacterFormatOperation(e.ownerBase,e)):e.copyFormat(i);return}if(this.isForHyperlinkFormat&&this.owner.enableTrackChanges&&e.ownerBase instanceof o.nR){for(var s=e.ownerBase,l=s.previousNode;!(0,a.le)(l)&&!(l instanceof o.a3);
1)l=l.previousNode;if(!(0,a.le)(l)&&l.revisionLength>0){var d=l.getRevision(l.revisionLength-1);"fontColor"===t&&0!==s.revisionLength||this.isRevisionAlreadyIn(s,d)||(s.addRevision(d),this.owner.trackChangesPane.updateCurrentTrackChanges(d))}else{var d=s.getRevision(s.revisionLength-1);("fontColor"!==t||0===s.revisionLength)&&!(0,a.le)(d)&&d.getRange().length>0&&(s.removeRevision(s.revisionLength-1),this.owner.trackChangesPane.updateCurrentTrackChanges(d)),("fontColor"!==t||0===s.revisionLength)&&this.insertRevision(s,"Insertion")}}if((0,a.le)(i)&&(0,a.le)(t)){e.clearFormat(),(0,a.le)(this.editorHistory)||(0,a.le)(this.editorHistory.currentBaseHistoryInfo)||(this.editorHistory.currentBaseHistoryInfo.insertedFormat=e[t]);return}if("bold"===t)this.isRTLFormat(e)&&(e.boldBidi=e.bold==e.boldBidi?i:!i),this.selection.isEmpty&&this.selection.start.paragraph.lastChild===this.selection.start.currentWidget&&this.selection.start.offset===this.selection.getLineLength(this.selection.start.currentWidget)&&this.selection.start.paragraph.firstChild.children[0]instanceof o.no||(e.bold=i);else if("bidi"===t)e.bidi=i;else if("italic"===t)this.isRTLFormat(e)&&(e.italicBidi=e.italic==e.italicBidi?i:!i),this.selection.isEmpty&&this.selection.start.paragraph.lastChild===this.selection.start.currentWidget&&this.selection.start.offset===this.selection.getLineLength(this.selection.start.currentWidget)&&this.selection.start.paragraph.firstChild.children[0]instanceof o.no||(e.italic=i);else if("fontColor"===t)e.fontColor=i;else if("fontFamily"===t)e.fontFamily=i,e.fontFamilyAscii=i,e.fontFamilyFarEast=i,e.fontFamilyNonFarEast=i,e.fontFamilyBidi=i;else if("fontSize"===t)e.fontSize=i,this.isRTLFormat(e)&&(e.fontSizeBidi=i);else if("highlightColor"===t)e.highlightColor=i;else if("baselineAlignment"===t)e.baselineAlignment=i;else if("strikethrough"===t)e.strikethrough=i;else if("underline"===t)e.underline=i;else if("styleName"===t)e.baseCharStyle=i;else if("allCaps"===t)e.allCaps=i;else if("ClearCharacterFormat"===t){var h=e.bidi,c=e.highlightColor;e.clearFormat(),e.bidi=h,e.highlightColor=c}"fontColor"===t&&this.editorHistory&&!(0,a.le)(this.editorHistory.currentBaseHistoryInfo)&&(this.editorHistory.currentBaseHistoryInfo.insertedFormat=e.fontColor)},e.prototype.isRTLFormat=function(e){return e.bidi||e.complexScript||!(0,a.le)(e.ownerBase)&&e.ownerBase instanceof o.a3&&this.documentHelper.textHelper.getRtlLanguage(e.ownerBase.text).isRtl},e.prototype.updateStyleObject=function(e){var t=new b.eZ,i=this.owner.parser.keywordIndex;this.owner.parser.keywordIndex=1;var r=this.owner.editor.isRemoteAction;this.owner.editor.isRemoteAction=!0,this.owner.parser.parseStyles(e,t);for(var o=0;o<t.length;o++){var n=t.getItem(o),s=this.owner.documentHelper.styles.findByName(n.name);if((0,a.le)(e[w.eNA[1]])||(this.owner.parser.parseAbstractList(e,this.owner.documentHelper.abstractLists),(0,a.le)(e[w.R6L[1]])||this.owner.parser.parseList(e,this.owner.documentHelper.lists)),(0,a.le)(s)){if(this.owner.editorHistory.isRedoing){var l=n instanceof b.wk?n.paragraphFormat.listFormat.listId:-1,d=this.documentHelper.owner.getStyleObject(n,l);d.isNew=!0,this.documentHelper.owner.editorHistoryModule.currentBaseHistoryInfo.modifiedProperties.push(d)}this.owner.documentHelper.styles.push(n)}else{if(this.owner.editorHistoryModule&&(this.owner.editorHistoryModule.isUndoing||this.owner.editorHistoryModule.isRedoing)&&0===o&&this.owner.editorHistoryModule.currentBaseHistoryInfo&&"ModifyStyle"===this.owner.editorHistoryModule.currentBaseHistoryInfo.action){var l=s instanceof b.wk?s.paragraphFormat.listFormat.listId:-1,d=this.owner.getStyleObject(s,l);(0,a.le)(e.isNew)||(d.isNew=e.isNew),this.owner.editorHistoryModule.currentBaseHistoryInfo.modifiedProperties.push(d)}e.isNew&&this.owner.editorHistoryModule.isUndoing?this.owner.documentHelper.styles.remove(s):this.owner.updateStyle(s,n)}}this.owner.editor.isRemoteAction=r,t.length>0&&(this.owner.isShiftingEnabled=!0,this.documentHelper.layout.layoutWholeDocument(),this.owner.isShiftingEnabled=!1),this.owner.parser.keywordIndex=i},e.prototype.onImageFormat=function(e,t,i,o){var n=new r.$Y(e);this.editorHistory&&(this.editorHistory.initializeHistory("ImageResizing"),this.editorHistory.currentBaseHistoryInfo.modifiedProperties.push(n),this.editorHistory.currentBaseHistoryInfo.insertedText=R.j5.Image,this.editorHistory.currentBaseHistoryInfo.insertedData={width:s.o_.convertPixelToPoint(t),height:s.o_.convertPixelToPoint(i),alternativeText:o}),this.setOffsetValue(this.selection),e.width=t,e.height=i,e.alternateText=o,this.documentHelper.layout.reLayoutParagraph(e.line.paragraph,e.line.indexInOwner,0),this.reLayout(this.selection,!1),this.documentHelper.owner.imageResizerModule&&!this.isRemoteAction&&this.documentHelper.owner.imageResizerModule.positionImageResizer(e)},e.prototype.toggleTextAlignment=function(e){(!this.documentHelper.owner.isReadOnlyMode||this.selection.isInlineFormFillMode())&&this.documentHelper.owner.isDocumentLoaded&&((0,a.le)(this.documentHelper.selection.paragraphFormat.textAlignment)||this.documentHelper.selection.paragraphFormat.textAlignment!==e?this.onApplyParagraphFormat("textAlignment",e,!1,!0):"Left"===e?this.onApplyParagraphFormat("textAlignment","Justify",!1,!0):this.onApplyParagraphFormat("textAlignment","Left",!1,!0))},e.prototype.setPreviousBlockToLayout=function(){var e=this.documentHelper.selection.start;this.documentHelper.selection.isForward||(e=this.documentHelper.selection.end);var t=e.paragraph;if(t.paragraphFormat.keepWithNext){var i=t.bodyWidget;if(!(0,a.le)(i)&&i instanceof o.VB&&i.page){var r=i.page.previousPage;r&&(this.previousBlockToLayout=r.bodyWidgets[0].lastChild)}}},e.prototype.applyParagraphBorders=function(e,t,i){var r=new g.V;switch(e){case"color":r.color=i;break;case"lineWidth":r.lineWidth=i;break;case"lineStyle":r.lineStyle=i;break;case"shadow":r.shadow=i;break;case"space":r.space=i}this.onApplyParagraphFormat(t,r,!1,!1)},e.prototype.applyRulerMarkerValues=function(e,t,i){var r=s.o_.convertPixelToPoint(i-t)/this.owner.zoomFactor;if("firstLineIndent"===e){var o=this.owner.selectionModule.start.paragraph.paragraphFormat.firstLineIndent;this.onApplyParagraphFormat(e,o+r,!1,!1)}else if("hangingIndent"===e){var o=this.owner.selectionModule.start.paragraph.paragraphFormat.firstLineIndent;this.onApplyParagraphFormat("firstLineIndent",o-r,!1,!1);var n=this.owner.selectionModule.start.paragraph.paragraphFormat.leftIndent+
1o;o-=r,this.onApplyParagraphFormat("leftIndent",n-o,!1,!1,!0)}else if("leftIndent"===e){var o=this.owner.selectionModule.start.paragraph.paragraphFormat.leftIndent;this.onApplyParagraphFormat(e,o+r,!1,!1)}else if("rightIndent"===e){var o=this.owner.selectionModule.start.paragraph.paragraphFormat.rightIndent;this.onApplyParagraphFormat(e,o+r,!1,!1)}},e.prototype.onApplyParagraphFormat=function(e,t,i,r,o){var n=this.documentHelper.isFormFillProtectedMode&&this.documentHelper.selection.isInlineFormFillMode()&&this.allowFormattingInFormFields(e);if(!(this.restrictFormatting&&!n||!(0,a.le)(this.selection)&&this.selection.checkContentControlLocked(!0))){this.setPreviousBlockToLayout();var l="bidi"===e?"ParagraphBidi":e[0].toUpperCase()+e.slice(1);this.documentHelper.owner.isShiftingEnabled=!0;var d=this.documentHelper.selection,h=d.start.paragraph,c=!1;if(d.isForward||(h=d.end.paragraph),"leftIndent"==e&&(c=this.isFirstParaForList(d,h)),t<=0&&"leftIndent"==e&&!o){var p=s.o_.convertPointToPixel(t);if(h.x+p<this.viewer.clientArea.x&&!h.paragraphFormat.bidi){this.documentHelper.owner.isShiftingEnabled=!1;return}}if(this.initHistory(l),(!this.owner.isReadOnlyMode||n)&&this.owner.isDocumentLoaded){if("leftIndent"===e&&!(0,a.le)(d.paragraphFormat.listId)&&-1!==d.paragraphFormat.listId&&i){c?this.updateListLevelIndent(t,h):this.updateListLevel(t>0);return}if(!(t instanceof b.l2&&"styleName"==e&&d.isEmpty)&&d.isEmpty){this.setOffsetValue(d),d.paragraphFormat.bidi&&("listFormat"===e||-1!==d.paragraphFormat.listId)||(this.documentHelper.layout.isBidiReLayout=!0),i&&"leftIndent"===e&&(t=this.getIndentIncrementValue(d.start.paragraph,t));var g=d.start.paragraph;this.documentHelper.layout,g=g.combineWidget(this.owner.viewer),this.applyParaFormatProperty(g,e,t,i),this.isMeasureParaWidth=!0,this.layoutItemBlock(g,!1),this.isMeasureParaWidth=!1}else"ParagraphBidi"!==l&&this.setOffsetValue(d),this.updateSelectionParagraphFormatting(e,t,i);this.reLayout(d)}}},e.prototype.updateListLevelIndent=function(e,t){var i,r,o=this.documentHelper.getListById(t.paragraphFormat.listFormat.listId),n=this.documentHelper.getAbstractListById(o.abstractListId),s=void 0;if((0,a.le)(this.editorHistory)||(0,a.le)(this.editorHistory.currentBaseHistoryInfo)||(s=this.editorHistory.currentBaseHistoryInfo.action),this.initHistory("List"),e<0&&n.levels[0].paragraphFormat.leftIndent+e<=0&&(e=18-n.levels[0].paragraphFormat.leftIndent),0!=e){for(var l=0;l<n.levels.length;l++)this.editorHistory&&!(0,a.le)(this.editorHistory.currentBaseHistoryInfo)&&this.editorHistory.currentBaseHistoryInfo.addModifiedPropertiesForList(n.levels[l]),r=n.levels[l],r.paragraphFormat.leftIndent+=e;(0,a.le)(this.editorHistory)||(0,a.le)(this.editorHistory.currentBaseHistoryInfo)||(0,a.le)(s)||(this.editorHistory.currentBaseHistoryInfo.insertedFormat=((i={})[s.toString().charAt(0).toLowerCase()+s.toString().slice(1)]=e,i.isFirstParaForList=!0,i)),this.documentHelper.owner.isShiftingEnabled=!0,this.documentHelper.layout.layoutWholeDocument(),this.documentHelper.owner.isShiftingEnabled=!1}},e.prototype.isFirstParaForList=function(e,t){var i=!1;if(!(0,a.le)(e.paragraphFormat.listId)&&-1!==e.paragraphFormat.listId&&0===t.paragraphFormat.listFormat.listLevelNumber){var r=this.updateWholeListItems(t,!0,e.paragraphFormat.listId);(0,a.le)(r)&&(i=!0)}return i},e.prototype.updateListLevel=function(e){var t,i=this.documentHelper;this.documentHelper.selection.start.paragraph.paragraphFormat.listFormat;var r=void 0;r=this.documentHelper.selection.isForward?i.selection.start.paragraph.paragraphFormat:i.selection.end.paragraph.paragraphFormat;var o=i.getListById(r.listFormat.listId);i.layout.getListLevel(o,r.listFormat.listLevelNumber);var n=r.listFormat.listLevelNumber;t=e?8===n?n:n+1:0===n?n:n-1;var s=i.layout.getListLevel(o,t);(0,a.le)(s)||(this.onApplyListInternal(o,t),i.selection.start.updatePhysicalPosition(!0),i.selection.end.updatePhysicalPosition(!0),i.selection.updateCaretPosition())},e.prototype.onApplyListInternal=function(e,t){var i=new m.s;!(0,a.le)(e)&&t>=0&&t<9&&(i.listId=e.listId,i.listLevelNumber=t),this.onApplyParagraphFormat("listFormat",i,!1,!1)},e.prototype.updateSelectionParagraphFormatting=function(e,t,i){var r=this.documentHelper.selection;"leftIndent"===e&&i&&(t=!(0,a.le)(r.start)&&r.start.isExistBefore(r.end)?this.getIndentIncrementValue(r.start.paragraph,t):this.getIndentIncrementValue(r.end.paragraph,t)),this.updateParagraphFormatInternal(e,t,i)},e.prototype.getIndentIncrementValue=function(e,t){var i=e.paragraphFormat.leftIndent;if(!(i<0))return this.getIndentIncrementValueInternal(i,t);if(t<0||i+t>=0)return-i;var r=-this.getIndentIncrementValueInternal(-i,-t);return r%t==0?r:r+t},e.prototype.getIndentIncrementValueInternal=function(e,t){var i=Math.abs(t);if(0===e||0===i)return t>0?i:0;var r=(Math.round(e)-100*Math.round(e)%(100*Math.round(i))/100)/Math.round(i)*i;return t>0&&(r+=i),r-e==0?t:r-e},e.prototype.updateParagraphFormatInternal=function(e,t,i){switch((0,a.le)(e)&&(e="ParagraphFormat"),e){case"afterSpacing":this.updateParagraphFormat("afterSpacing",t,!1);break;case"beforeSpacing":this.updateParagraphFormat("beforeSpacing",t,!1);break;case"spaceAfterAuto":this.updateParagraphFormat("spaceAfterAuto",t,!1);break;case"spaceBeforeAuto":this.updateParagraphFormat("spaceBeforeAuto",t,!1);break;case"rightIndent":this.updateParagraphFormat("rightIndent",t,!1);break;case"leftIndent":this.updateParagraphFormat("leftIndent",t,i);break;case"firstLineIndent":this.updateParagraphFormat("firstLineIndent",t,!1);break;case"lineSpacing":this.updateParagraphFormat("lineSpacing",t,!1);break;case"lineSpacingType":this.updateParagraphFormat("lineSpacingType",t,!1);break;case"textAlignment":this.updateParagraphFormat("textAlignment",t,!1);break;case"borders":case"topBorder":case"bottomBorder":case"leftBorder":case"rightBorder":case"horizontalBorder":case"verticalBorder":this.updateParagraphFormat(e,t,!1);break;case"listFormat":this.updateParagraphFormat("listFormat",t,!1);break;case"ParagraphFormat":case"ClearParagraphFormat":this.updateParagraphFormat(void 0,t,!1);break;case"styleName":this.updateParagraphFormat("styleName",t,!1);break;case"bidi":var r=-1!==this.selection.paragraphFormat.listId;r||(this.documentHelper.layout.isBidiReLayout=!0),this.updateParagraphFormat("bidi",t,!1),r||(this.documentHelper.layout.isBidiReLayout=!1);break;case"contextualSpacing":this.updateParagraphFormat("contextualSpacing",t,!1);break;case"tabStop":this.updateParagraphFormat("tabStop",t,!1)}},e.prototype.updateParagraphFormat=function(e,t,i){var r=this.documentHelper.selection,o=r.start,n=r.end;r.isForward||(o=r.end,n=r.start),this.applyParaFormatSelectedContent(o,n,e,t,i)},e.prototype.applyParaFormatSelectedContent=function(e,t,i,r,o){var n=this.documentHelper.selection;if(e.paragraph.isInsideTable&&(!t.paragraph.isInsideTable||e.paragraph.associatedCell!==t.paragraph.associatedCell||n.isCellSelected(e.paragraph.associatedCell,e,t))){var s=void 0;e.paragraph.associatedCell.ownerTable.combineWidget(this.owner.viewer),this.checkInsertPosition(n)&&this.updateHistoryPosition(e,!0),s=e.paragraph.associatedCell,this.applyParaFormatInCell(s,e,t,i,r,o);var l=s.ownerTable;this.documentHelper.layout.layoutBodyWidgetCollection(l.index,l.containerWidget,l,!1)}else{if(!(0,a.le)(r)&&!this.selection.isEmpty&&"styleName"===i&&this.applyCharacterStyle(e.paragraph,e,t,i,r,o))return;this.applyParaFormat(e.paragraph,e,t,i,r,o)}},e.prototype.applyParaFormatProperty=function(e,t,i,r,n){var s=e.paragraphFormat;if(r&&"leftIndent"===t&&(i=s.leftIndent+i),"listFormat"===t&&i instanceof m.s){var l=i;l.hasValue("listLevelNumber")||(this.isAutoList?(l.listLevelNumber=this.listLevelNumber,this.listLevelNumber=0,this.isAutoList=!1):l.listLevelNumber=s.listFormat.listLevelNumber)}if(this.editorHistory&&!(0,a.le)(this.editorHistory.currentBaseHistoryInfo)&&(i=this.editorHistory.currentBaseHistoryInfo.addModifiedPropertiesForParagraphFormat(s,t,i),this.editorHistory.currentBaseHistoryInfo.insertedFormat=i),i instanceof h.h&&((0,a.le)(t)?this.editorHistory&&(this.editorHistory.isUndoing||this.editorHistory.isRedoing)?this.copyParagraphFormat(i,s):this.isRemoteAction?this.copyParagraphFormat(i,s):s.copyFormat(i):"listFormat"===t&&(s.listFormat=i.listFormat,s.listFormat.ownerBase=s,s.copyFormat(i)),this.editorHistory&&!(0,a.le)(this.editorHistory.currentBaseHistoryInfo)&&this.owner.enableCollaborativeEditing&&this.editorHistory.isUndoing&&this.editorHistory.currentBaseHistoryInfo.getParagraohFormatOperation(e,s)),(0,a.le)(i)){s.clearFormat(),this.documentHelper.layout.reLayoutParagraph(s.ownerBase,0,0);return}if("afterSpacing"===t)s.afterSpacing=i;else if("beforeSpacing"===t)s.beforeSpacing=i;else if("leftIndent"===t)s.leftIndent=i;else if("lineSpacingType"===t)s.lineSpacingType=i;else if("lineSpacing"===t)s.lineSpacing=i;else if("rightIndent"===t)s.rightIndent=i;else if("firstLineIndent"===t)s.firstLineIndent=i;else if("textAlignment"===t){var d=i;s.bidi&&!(this.editorHistory.isUndoing||this.editorHistory.isRedoing)&&("Left"===d?d="Right":"Right"===d&&(d="Left")),s.textAlignment=d}else if("outlineLevel"===t)s.outlineLevel=i;else if("topBorder"===t)this.applyBorder(s.borders.top,i);else if("bottomBorder"===t)this.applyBorder(s.borders.bottom,i);else if("leftBorder"===t)this.applyBorder(s.borders.left,i);else if("rightBorder"===t)this.applyBorder(s.borders.right,i);else if("horizontalBorder"===t)this.applyBorder(s.borders.horizontal,i);else if("verticalBorder"===t)this.applyBorder(s.borders.vertical,i);else if("borders"===t)s.borders.copyFormat(i);else if("styleName"===t)"string"==typeof i&&(i=this.documentHelper.styles.findByName(i)),s.applyStyle(i);else if("listFormat"===t){if(s.ownerBase instanceof o.ZH&&!s.ownerBase.isInsideTable&&!this.documentHelper.layout.hasValidElement(s.ownerBase)){for(var c=s.ownerBase,p=!1,g=0;
1g<c.childWidgets.length;g++)for(var u=c.childWidgets[g],f=0;f<u.children.length;f++){var y=u.children[f];(y instanceof o.no||y instanceof o.pK&&"Inline"===y.textWrappingStyle)&&(p=!0)}if(!(c===this.selection.start.paragraph&&c===this.selection.end.paragraph)&&!p)return}i instanceof h.h&&(i=i.listFormat),s.listFormat.copyFormat(i),this.documentHelper.layout.clearListElementBox(s.ownerBase),s.listFormat.listId>=0&&s.clearIndent(),n||this.layoutItemBlock(s.ownerBase,!1);return}else if("bidi"===t)s.bidi=i;else if("keepWithNext"===t)s.keepWithNext=i;else if("keepLinesTogether"===t)s.keepLinesTogether=i;else if("widowControl"===t)s.widowControl=i;else if("contextualSpacing"===t)s.contextualSpacing=i;else if("spaceAfterAuto"===t)s.spaceAfterAuto=i;else if("spaceBeforeAuto"===t)s.spaceBeforeAuto=i;else if("tabStop"===t){var v=this.editorHistory.isUndoing||this.editorHistory.isRedoing;this.updateTabStopCollection(e,i,v)}},e.prototype.copyParagraphFormat=function(e,t){t.uniqueParagraphFormat=e.uniqueParagraphFormat,t.listFormat=e.listFormat,t.listFormat.ownerBase=t,t.baseStyle=e.baseStyle},e.prototype.copyFromListLevelParagraphFormat=function(e,t){(0,a.le)(t.leftIndent)||(e.leftIndent=t.leftIndent),(0,a.le)(t.firstLineIndent)||(e.firstLineIndent=t.firstLineIndent)},e.prototype.applyContinueNumbering=function(){var e=this.selection;this.editorHistory&&this.editorHistory.initializeHistory("ContinueNumbering"),this.applyContinueNumberingInternal(e)},e.prototype.continueNumbering=function(){var e=this.selection;this.editorHistory&&this.editorHistory.initializeHistory("ContinueNumbering"),(0,a.le)(e)||this.applyContinueNumberingInternal(e)},e.prototype.applyContinueNumberingInternal=function(e,t){var i=e.start.paragraph,r=this.getContinueNumberingInfo(i);(0,a.le)(t)&&(t=this.getParagraphFormat(i,r.listLevelNumber,r.listPattern)),t=(0,a.le)(t)?i.paragraphFormat:t,!(0,a.le)(r.currentList)&&(this.changeListId(r.currentList,i,t,r.listLevelNumber,r.listPattern),this.reLayout(e,!1),this.owner.enableAutoFocus&&this.documentHelper.updateFocus())},e.prototype.getContinueNumberingInfo=function(e){var t=void 0,i=0,r="None";(0,a.le)(e.paragraphFormat)||(0,a.le)(e.paragraphFormat.listFormat)||(t=this.documentHelper.getListById(e.paragraphFormat.listFormat.listId),i=e.paragraphFormat.listFormat.listLevelNumber);var o=this.documentHelper;if(0!==i&&!(0,a.le)(t)&&!(0,a.le)(o.getAbstractListById(t.abstractListId))&&!(0,a.le)(o.getAbstractListById(t.abstractListId).levels[i])){var n=this.documentHelper.layout.getListLevel(t,i);(0,a.le)(n)||(r=n.listLevelPattern)}return{currentList:t,listLevelNumber:i,listPattern:r}},e.prototype.revertContinueNumbering=function(e,t){var i=e.start.paragraph,r=this.getContinueNumberingInfo(i);this.changeListId(r.currentList,i,t,r.listLevelNumber,r.listPattern),this.reLayout(e,!1),this.editorHistory&&!(0,a.le)(this.editorHistory.currentBaseHistoryInfo)&&this.editorHistory.updateHistory()},e.prototype.changeListId=function(e,t,i,r,n){if(!(0,a.le)(t)){if(t instanceof o.ZH&&e.listId===t.paragraphFormat.listFormat.listId){if(this.editorHistory){var s=this.editorHistory.currentBaseHistoryInfo;(0,a.le)(s)||(i=s.addModifiedPropertiesForContinueNumbering(t.paragraphFormat,i),s.insertedFormat=i)}r===t.paragraphFormat.listFormat.listLevelNumber?t.paragraphFormat.copyFormat(i):t.paragraphFormat.listFormat.listId=i.listFormat.listId,this.documentHelper.layout.reLayoutParagraph(t,0,0)}return this.changeListId(e,t.nextRenderedWidget,i,r,n)}},e.prototype.getParagraphFormat=function(e,t,i){if(!(0,a.le)(e.previousRenderedWidget)){if(e.previousRenderedWidget instanceof o.ZH)return(0,a.le)(e.previousRenderedWidget.paragraphFormat.listFormat)||-1===e.previousRenderedWidget.paragraphFormat.listFormat.listId?this.getParagraphFormat(e.previousRenderedWidget,t,i):t===e.previousRenderedWidget.paragraphFormat.listFormat.listLevelNumber?e.previousRenderedWidget.paragraphFormat:this.getParagraphFormat(e.previousRenderedWidget,t,i);var r=this.getTableFormat(e.previousRenderedWidget,t,i);return(0,a.le)(r)?this.getParagraphFormat(e.previousRenderedWidget,t,i):r}},e.prototype.getTableFormat=function(e,t,i){if(!(0,a.le)(e))for(var r=e.childWidgets.length-1;r>=0;r--)for(var n=e.childWidgets[r],s=n.childWidgets.length-1;s>=0;s--)for(var l=n.childWidgets[s],d=l.childWidgets.length-1;d>=0;d--){var h=l.childWidgets[d];if(h instanceof o.ZH&&!(0,a.le)(h.paragraphFormat.listFormat)&&-1!==h.paragraphFormat.listFormat.listId){if(t===h.paragraphFormat.listFormat.listLevelNumber)return h.paragraphFormat}else if(h instanceof o.dm)return this.getTableFormat(h,t,i)}},e.prototype.checkNumberArabic=function(e,t){return"Number"===e&&"Arabic"===t||"Number"===t&&"Arabic"===e},e.prototype.restartNumbering=function(){this.editorHistory&&this.editorHistory.initializeHistory("RestartNumbering");var e=this.documentHelper.selection;(0,a.le)(e)||this.restartListAt(e)},e.prototype.applyRestartNumbering=function(e){this.editorHistory&&this.editorHistory.initializeHistory("RestartNumbering"),this.restartListAt(e)},e.prototype.restartListAt=function(e){if(e.paragraphFormat.getList()){var t=e.paragraphFormat.getList(),i=t.clone();i.listId=this.documentHelper.lists[this.documentHelper.lists.length-1].listId+1,this.documentHelper.lists.push(i);var r=t.abstractList.clone();r.abstractListId=this.documentHelper.abstractLists[this.documentHelper.abstractLists.length-1].abstractListId+1,i.abstractListId=r.abstractListId,i.nsid=r.nsid,i.abstractList=r,this.documentHelper.abstractLists.push(r),this.restartListAtInternal(e,i.listId,i.nsid)}},e.prototype.restartListAtInternal=function(e,t,i){var r=this.getContinueNumberingInfo(e.start.paragraph);this.changeRestartNumbering(r.currentList,e.start.paragraph,t,i),this.reLayout(e,!1),this.documentHelper.updateFocus()},e.prototype.changeRestartNumbering=function(e,t,i,r){if(!(0,a.le)(t)){if(t instanceof o.ZH&&e.listId===t.paragraphFormat.listFormat.listId){if(this.editorHistory){var n=this.editorHistory.currentBaseHistoryInfo;(0,a.le)(n)||(i=n.addModifiedPropertiesForRestartNumbering(t.paragraphFormat.listFormat,i),n.insertedFormat={listId:i,nsid:r})}t.paragraphFormat.listFormat.listId=i,this.documentHelper.layout.reLayoutParagraph(t,0,0)}return this.changeRestartNumbering(e,t.nextRenderedWidget,i,r)}},e.prototype.applyParaFormat=function(e,t,i,r,n,s){this.setOffsetValue(this.selection),e=e.combineWidget(this.owner.viewer);var l=0;!(0,a.le)(e.nextWidget)&&e.nextWidget instanceof o.ZH&&"listFormat"===r&&!(0,a.le)(n)&&n instanceof m.s&&e.leftIndent<e.nextWidget.leftIndent&&-1===e.paragraphFormat.listFormat.listId&&-1===e.nextWidget.paragraphFormat.listFormat.listId&&(l=n.listLevelNumber+Math.floor(e.nextWidget.leftIndent/36)-Math.floor(e.leftIndent/36)),this.applyParaFormatProperty(e,r,n,s),this.isMeasureParaWidth=!0,this.layoutItemBlock(e,!1),this.isMeasureParaWidth=!1,this.getOffsetValue(this.selection),e.equals(i.paragraph)||(l>0&&n instanceof m.s&&(l>8&&(l=8),n.listLevelNumber=l),this.getNextParagraphForFormatting(e,t,i,r,n,s))},e.prototype.applyCharacterStyle=function(e,t,i,r,o,n){var s=e.getSplitWidgets(),l=i.owner.selectionModule,d=i.currentWidget;if(!(0===t.offset&&(l.isParagraphLastLine(d)&&i.currentWidget===d&&i.offset===l.getLineLength(d)+1||i.isAtParagraphEnd))&&(i.paragraph===e||-1!==s.indexOf(i.paragraph))&&("Paragraph"===o.type&&o.link instanceof b.l2||"Character"===o.type)&&((0,a.le)(e.paragraphFormat.baseStyle)||o.name!==e.paragraphFormat.baseStyle.name)){var h="Character"===o.type?o:o.link;return this.updateSelectionCharacterFormatting(r,h,n),!0}return!1},e.prototype.applyParaFormatInCell=function(e,t,i,r,o,n){var s=this.documentHelper.selection;if(i.paragraph.isInsideTable){var a=s.getContainerCellOf(e,i.paragraph.associatedCell);if(a.ownerTable.contains(i.paragraph.associatedCell)){var l=s.getSelectedCell(e,a),d=s.get
1SelectedCell(i.paragraph.associatedCell,a);s.containsCell(a,i.paragraph.associatedCell)?s.isCellSelected(a,t,i)?(o=this.getParaFormatValueInCell(a,r,o),this.applyParaFormatCellInternal(a,r,o,n)):l===a?this.applyParaFormat(t.paragraph,t,i,r,o,n):this.applyParagraphFormatRow(l.ownerRow,t,i,r,o,n):this.applyParaFormatTableCell(a.ownerTable,a,d,r,o,n)}else this.applyParagraphFormatRow(a.ownerRow,t,i,r,o,n)}else{var h=s.getContainerCell(e);this.applyParagraphFormatRow(h.ownerRow,t,i,r,o,n)}},e.prototype.applyParaFormatCellInternal=function(e,t,i,r,n,s){for(var a=0;a<e.childWidgets.length;a++){var l=e.childWidgets[a];l instanceof o.ZH?("listFormat"===t&&i instanceof m.s&&n&&l.paragraphFormat.listFormat.hasValue("listLevelNumber")&&i.listLevelNumber<l.paragraphFormat.listFormat.listLevelNumber&&(i.listLevelNumber=l.paragraphFormat.listFormat.listLevelNumber),this.isMeasureParaWidth=!0,this.applyParaFormatProperty(l,t,i,r,s),this.isMeasureParaWidth=!1):this.applyParagraphFormatTableInternal(l,t,i,r,n,s)}},e.prototype.getParaFormatValueInCell=function(e,t,i){return"boolean"==typeof i&&(i=!this.documentHelper.selection.getFirstParagraph(e).paragraphFormat.getPropertyValue(t)),i},e.prototype.applyParagraphFormatRow=function(e,t,i,r,o,n){o=this.getParaFormatValueInCell(e.childWidgets[0],r,o);for(var s=e.rowIndex;s<e.ownerTable.childWidgets.length;s++){for(var a=e.ownerTable.childWidgets[s],l=0;l<a.childWidgets.length;l++)this.applyParaFormatCellInternal(a.childWidgets[l],r,o,n);if(i.paragraph.isInsideTable&&this.documentHelper.selection.containsRow(a,i.paragraph.associatedCell))return}this.getNextParagraphForFormatting(e.ownerTable,t,i,r,o,n)},e.prototype.applyParaFormatTableCell=function(e,t,i,r,o,n){var s=this.documentHelper.selection,a=s.getCellLeft(t.ownerRow,t),l=a+t.cellFormat.cellWidth,d=s.getCellLeft(i.ownerRow,i),h=d+i.cellFormat.cellWidth,c=this.updateSelectedCellsInTable(a,l,d,h);a=c.start,l=c.end;for(var p=e.childWidgets.indexOf(i.ownerRow),g=!1,m=e.childWidgets.indexOf(t.ownerRow);m<=p;m++)for(var u=e.childWidgets[m],f=0;f<u.childWidgets.length;f++){var y=s.getCellLeft(u,u.childWidgets[f]);Math.round(a)<=Math.round(y)&&Math.round(y)<Math.round(l)&&(g||(o=this.getParaFormatValueInCell(u.childWidgets[f],r,o),g=!0),this.applyParaFormatCellInternal(u.childWidgets[f],r,o,n,!1,!0))}this.isMeasureParaWidth=!0,this.documentHelper.layout.reLayoutTable(e),this.isMeasureParaWidth=!1},e.prototype.applyParaFormatTable=function(e,t,i,r,o,n,s){e=e.combineWidget(this.owner.viewer);for(var a=this.documentHelper.selection,l=0;l<e.childWidgets.length;l++){for(var d=e.childWidgets[l],h=0;h<d.childWidgets.length;h++)this.applyParaFormatCellInternal(d.childWidgets[h],r,o,n,s);if(i.paragraph.isInsideTable&&a.containsRow(d,i.paragraph.associatedCell)){this.documentHelper.layout.layoutBodyWidgetCollection(e.index,e.containerWidget,e,!1);return}}this.documentHelper.layout.layoutBodyWidgetCollection(e.index,e.containerWidget,e,!1),this.getNextParagraphForFormatting(e,t,i,r,o,n)},e.prototype.getNextParagraphForFormatting=function(e,t,i,r,n,s){var l=e.getSplitWidgets();if(e=l[l.length-1],e=this.documentHelper.selection.getNextRenderedBlock(e),!(0,a.le)(e)){if(e instanceof o.ZH){if(n instanceof m.s&&e.paragraphFormat.listFormat.hasValue("listLevelNumber")){var d=e.paragraphFormat.listFormat.listLevelNumber;"listFormat"!==r||!(n.listLevelNumber<d)||this.increasedIndent||this.decreasedIndent||(n.listLevelNumber=d),this.increasedIndent&&n.listLevelNumber-1!==d&&(n.listLevelNumber=8===d?d:d+1),this.decreasedIndent&&n.listLevelNumber+1!==d&&(n.listLevelNumber=0===d?d:d-1)}this.applyParaFormat(e,t,i,r,n,s)}else this.applyParaFormatTable(e,t,i,r,n,s,!0)}},e.prototype.applyParagraphFormatTableInternal=function(e,t,i,r,o,n){for(var s=0;s<e.childWidgets.length;s++)for(var a=e.childWidgets[s],l=0;l<a.childWidgets.length;l++)this.applyParaFormatCellInternal(a.childWidgets[l],t,i,r,o,n)},e.prototype.onApplyColumnFormat=function(e,t){if(!this.restrictFormatting){this.initHistory("SectionFormat");var i,r,o=this.documentHelper.selection;o.owner.isShiftingEnabled=!0;var n=o.start,s=o.end;o.isForward||(n=o.end,s=o.start),this.documentHelper.clearContent();for(var a=n.paragraph.bodyWidget.sectionIndex,l=s.paragraph.bodyWidget.sectionIndex,d=!1,h=0;h<this.documentHelper.pages.length;h++)this.documentHelper.pages[h].bodyWidgets[0].index===a?i=h:d=!0;for(var h=i;h<this.documentHelper.pages.length;h++){var c=this.documentHelper.pages[h].bodyWidgets[0];if(r=h,c.index!==a){if(c.index>=a&&c.index<=l)continue;r=h-1;break}}d&&"differentOddAndEvenPages"==e&&n.paragraph.isInHeaderFooter&&(i=0,r=this.documentHelper.pages.length-1);for(var p=!0,g=0,h=i;h<=r;h++)g===this.documentHelper.pages[h].bodyWidgets[0].index||p||(p=!0),this.applyPropertyValueForSection(this.documentHelper.pages[h].bodyWidgets[0].sectionFormat,e,t,p),g=this.documentHelper.pages[h].bodyWidgets[0].index,p=!1;this.documentHelper.layout.layoutWholeDocument(),this.fireContentChange()}},e.prototype.onApplySectionFormat=function(e,t){if(!this.restrictFormatting){if((0,a.le)(e))this.initHistory("SectionFormat");else{var i=e[0].toUpperCase()+e.slice(1);this.initHistory(i)}this.updateSectionFormat(e,t)}},e.prototype.removeInlineHeaderFooterWidget=function(e,t,i,r){if(0!=e){var n=this.documentHelper.headersFooters[e],s=this.viewer.getHeaderFooter(t),l=(this.selection.start.paragraph.containerWidget instanceof o.nb?this.owner.selectionModule.getContainerWidget(this.selection.start.paragraph.containerWidget):this.selection.start.paragraph.containerWidget).sectionFormat.cloneFormat();if(!(0,a.le)(r)){if(!(0,a.le)(i)){var d=i[0].toUpperCase()+i.slice(1);this.initHistory(d),this.editorHistory&&!(0,a.le)(this.editorHistory.currentBaseHistoryInfo)&&(this.editorHistory.currentBaseHistoryInfo.insertedFormat=r);var h=this.selection.getParagraphInfo(this.selection.start);this.selection.editPosition=this.selection.getHierarchicalIndex(h.paragraph,h.offset.toString()),this.checkInsertPosition(this.selection)&&this.setPositionForHistory(this.selection.editPosition)}if(r)n&&!(0,a.le)(n[s])&&(l.removedHeaderFooters.push(n[s]),this.editorHistory.currentBaseHistoryInfo.addModifiedPropertiesForSection(l,i,r),delete n[s]);else{var c=this.viewer.getCurrentHeaderFooter(t,e);if(!(0,a.le)(c)&&(0,a.le)(n[s])){var p=c.clone();n[s]=p,l.removedHeaderFooters.push(p),this.editorHistory.currentBaseHistoryInfo.addModifiedPropertiesForSection(l,i,r)}}this.selection.updateTextPositionForBlockContainer(this.selection.start.paragraph.containerWidget),this.isSkipOperationsBuild=this.owner.enableCollaborativeEditing,this.documentHelper.layout.layoutWholeDocument(),this.isSkipOperationsBuild=!1,this.fireContentChange()}}},e.prototype.updateHeaderFooters=function(e,t,i,r){var o=this.documentHelper.headersFooters[i],n=this.viewer.getHeaderFooter(r.headerFooterType),s=o[n];(this.editorHistory.isUndoing||this.editorHistory.isRedoing)&&((0,a.le)(s)?this.documentHelper.headersFooters[i][n]=r:(0,a.le)(s)||delete o[n]),this.selection.updateTextPositionForBlockContainer(this.selection.start.paragraph.containerWidget),this.documentHelper.layout.layoutWholeDocument()},e.prototype.updateSectionFormat=function(e,t){if(1===this.documentHelper.selection.startPage&&"differentFirstPage"===e){var i,r,n=void 0;n=this.documentHelper.selection.start.paragraph.containerWidget instanceof o.nb?this.getFirstChildOfTable(this.documentHelper.selection.start.paragraph.containerWidget):this.documentHelper.selection.start.paragraph.containerWidget.childWidgets[0];var s=this.selection.getHierarchicalIndex(n,"0");this.documentHelper.selection.select(s,s)}var l=this.documentHelper.selection;l.owner.isShiftingEnabled=!0;var d=l.start,h=l.end;l.isForward||(d=l.end,h=l.start),this.documentHelper.clearContent();for(var c=d.paragraph.bodyWidget.sectionIndex,p=h.paragraph.bodyWidget.sectionIndex,g=!1,m=!1,u=0;u<this.documentHelper.pages.length;u++){for(var f=0;f<this.documentHelper.pages[u].bodyWidgets.length;f++)if(this.documentHelper.pages[u].bodyWidgets[f].index===c){if(i=u,l.isForward){m=!0;break}}else g=!0;if(m)break}for(var u=i;u<this.documentHelper.pages.length;u++)for(var f=0;f<this.documentHelper.pages[u].bodyWidgets.length;f++){var y=this.documentHelper.pages[u].bodyWidgets[f];if(y.index===c||y.index>=c&&y.index<=p){r=u;continue}}g&&"differentOddAndEvenPages"==e&&d.paragraph.isInHeaderFooter&&(i=0,r=this.documentHelper.pages.length-1);for(var v=!0,H=0,u=i;u<=r;u++)for(var f=0;f<this.documentHelper.pages[u].bodyWidgets.length;f++)if(this.documentHelper.pages[u].bodyWidgets[f].index>=c&&this.documentHelper.pages[u].bodyWidgets[f].index<=p||!l.isForward&&this.documentHelper.pages[u].bodyWidgets[f].index<=c&&this.documentHelper.pages[u].bodyWidgets[f].index>=p){H===this.documentHelper.pages[u].bodyWidgets[f].index||v||(v=!0),this.applyPropertyValueForSection(this.documentHelper.pages[u].bodyWidgets[f].sectionFormat,e,t,v),H=this.documentHelper.pages[u].bodyWidgets[f].index,v=!1;var C=this.documentHelper.pages[u].bodyWidgets[f];(0,a.le)(C.nextWidget)||C.sectionFormat.pageHeight===C.nextWidget.sectionFormat.pageHeight&&C.sectionFormat.pageWidth===C.nextWidget.sectionFormat.pageWidth||"NoBreak"!==C.nextWidget.sectionFormat.breakCode||(C.nextWidget.sectionFormat.breakCode="NewPage",C=this.documentHelper.layout.getBodyWidget(C.nextWidget,!1),(0,a.le)(C.nextWidget)||(C.nextWidget.sectionFormat.breakCode="NewPage"))}this.isSkipOperationsBuild=this.owner.enableCollaborativeEditing,this.documentHelper.layout.layoutWholeDocument(),this.isSkipOperationsBuild=!1,this.fireContentChange()},e.prototype.getFirstChildOfTable=function(e){return e.ownerTable.childWidgets[0].childWidgets[0].childWidgets[0]},e.prototype.onApplyTableFormat=function(e,t,i){if(!this.restrictFormatting){var r=this.getTableFormatAction(e);this.viewer.owner.isShiftingEnabled=!0;var o=this.documentHelper.selection;(0,a.le)(i)&&(i=o.start.paragraph.associatedCell.ownerTable),i=i.combineWidget(this.owner.viewer),o.isEmpty?(this.initHistory(r),this.applyTablePropertyValue(e,t,i)):this.updateSelectionTableFormat(this.selection,r,t),i.calculateGrid(),this.selection.owner.isLayoutEnabled=!0,this.documentHelper.layout.reLayoutTable(i),this.reLayout(o,!1)}},e.prototype.getTableFormatAction=function(e){switch(e){case"tableAlignment":return"TableAlignment";case"leftIndent":return"TableLeftIndent";case"leftMargin":return"DefaultCellLeftMargin";case"rightMargin":return"DefaultCellRightMargin";case"bottomMargin":return"DefaultCellBottomMargin";case"topMargin":return"DefaultCellTopMargin";case"preferredWidth":return"TablePreferredWidth";case"preferredWidthType":return"TablePreferredWidthType";case"shading":return"Shading";case"bidi":return"TableBidi";case"title":return"TableTitle";case"description":return"TableDescription";default:return"DefaultCellSpacing"}},e.prototype.onApplyTableRowFormat=function(e,t){if(!this.restrictFormatting){var i=this.getRowAction(e);this.documentHelper.owner.isShiftingEnabled=!0;var r=this.documentHelper.selection;r.isEmpty?(this.initHistory(i),r.start.paragraph.associatedCell.ownerRow.ownerTable,this.applyRowPropertyValue(r,e,t,r.start.paragraph.associatedCell.ownerRow)):this.updateSelectionTableFormat(this.selection,i,t),this.reLayout(r,!1)}},e.prototype.getRowAction=function(e){switch(e){case"height":return"RowHeight";case"heightType":return"RowHeightType";case"isHeader":return"RowHeader";default:return"AllowBreakAcrossPages"}},e.prototype.onApplyTableCellFormat=function(e,t){if(!this.restrictFormatting){var i=this.getTableCellAction(e);this.documentHelper.owner.isShiftingEnabled=!0;var r=this.documentHelper.selection,o=r.start.paragraph.associatedCell.ownerTable;o=o.combineWidget(this.owner.viewer),r.isEmpty&&"preferredWidthType"!==e&&"preferredWidth"!==e?(this.initHistory(i),this.applyCellPropertyValue(r,e,t,r.start.paragraph.associatedCell.cellFormat),"shading"!==e&&o.calculateGrid(),this.selection.owner.isLayoutEnabled=!0,this.documentHelper.layout.reLayoutTable(
1o)):this.updateSelectionTableFormat(this.selection,i,t),this.reLayout(r,!1)}},e.prototype.getTableCellAction=function(e){switch(e){case"verticalAlignment":return"CellContentVerticalAlignment";case"leftMargin":return"CellLeftMargin";case"rightMargin":return"CellRightMargin";case"bottomMargin":return"CellBottomMargin";case"topMargin":return"CellTopMargin";case"preferredWidth":return"CellPreferredWidth";case"shading":return"Shading";default:return"CellPreferredWidthType"}},e.prototype.applyPropertyValueForSection=function(e,t,i,r){if(r&&this.editorHistory&&!(0,a.le)(this.editorHistory.currentBaseHistoryInfo)&&("columns"===t&&(e.numberOfColumns=i.length),i=this.editorHistory.currentBaseHistoryInfo.addModifiedPropertiesForSection(e,t,i),this.editorHistory.currentBaseHistoryInfo.insertedFormat=i),!(0,a.le)(i)){if(i instanceof l.Z){(0,a.le)(t)&&e.copyFormat(i,this.editorHistory);return}"pageHeight"===t?e.pageHeight=i:"pageWidth"===t?e.pageWidth=i:"leftMargin"===t?e.leftMargin=i:"rightMargin"===t?e.rightMargin=i:"topMargin"===t?e.topMargin=i:"bottomMargin"===t?e.bottomMargin=i:"differentFirstPage"===t?e.differentFirstPage=i:"differentOddAndEvenPages"===t?e.differentOddAndEvenPages=i:"headerDistance"===t?e.headerDistance=i:"footerDistance"===t?e.footerDistance=i:"pageStartingNumber"===t?e.pageStartingNumber=i:"restartPageNumbering"===t?e.restartPageNumbering=i:"endnoteNumberFormat"===t?e.endnoteNumberFormat=i:"footNoteNumberFormat"===t?e.footNoteNumberFormat=i:"restartIndexForEndnotes"===t?e.restartIndexForEndnotes=i:"restartIndexForFootnotes"===t?e.restartIndexForFootnotes=i:"initialFootNoteNumber"===t?e.initialFootNoteNumber=i:"initialEndNoteNumber"===t?e.initialEndNoteNumber=i:"numberOfColumns"==t?e.numberOfColumns=i:"equalWidth"==t?e.equalWidth=i:"lineBetweenColumns"==t?e.lineBetweenColumns=i:"columns"==t&&(e.columns=i)}},e.prototype.combineFollowingSection=function(){var e=[],t=this.documentHelper.selection.start.paragraph.bodyWidget.getSplitWidgets()[0];if(t.childWidgets[0]instanceof o.ZH)this.updateWholeListItems(t.childWidgets[0]);else{var i=this.documentHelper.getFirstParagraphInFirstCell(t.childWidgets[0]);this.viewer.owner.editorModule.updateWholeListItems(i)}var r=this.documentHelper.pages.indexOf(t.page),n=0===t.indexInOwner?r:r+1;do t=this.documentHelper.combineSectionChild(t,e,!1);while(t);for(var s=n;s<this.documentHelper.pages.length;s++)this.documentHelper.pages[s].destroy(),s--;for(var a=r;a<this.documentHelper.pages.length;a++)for(var l=0;l<this.documentHelper.pages[a].bodyWidgets.length;l++)0===this.documentHelper.pages[a].bodyWidgets[l].childWidgets.length&&(this.documentHelper.pages[a].bodyWidgets.splice(l,1),l--);return e},e.prototype.updateSelectionTableFormat=function(e,t,i){switch(t){case"TableAlignment":this.editorHistory.initializeHistory("TableAlignment"),this.updateTableFormat(e,"tableAlignment",i);break;case"TableLeftIndent":this.editorHistory.initializeHistory("TableLeftIndent"),this.updateTableFormat(e,"leftIndent",i);break;case"DefaultCellSpacing":this.editorHistory.initializeHistory("DefaultCellSpacing"),this.updateTableFormat(e,"cellSpacing",i);break;case"DefaultCellLeftMargin":this.editorHistory.initializeHistory("DefaultCellLeftMargin"),this.updateTableFormat(e,"leftMargin",i);break;case"DefaultCellRightMargin":this.editorHistory.initializeHistory("DefaultCellRightMargin"),this.updateTableFormat(e,"rightMargin",i);break;case"DefaultCellTopMargin":this.editorHistory.initializeHistory("DefaultCellTopMargin"),this.updateTableFormat(e,"topMargin",i);break;case"TablePreferredWidth":this.editorHistory.initializeHistory("TablePreferredWidth"),this.updateTableFormat(e,"preferredWidth",i);break;case"TablePreferredWidthType":this.editorHistory.initializeHistory("TablePreferredWidthType"),this.updateTableFormat(e,"preferredWidthType",i);break;case"DefaultCellBottomMargin":this.editorHistory.initializeHistory("DefaultCellBottomMargin"),this.updateTableFormat(e,"bottomMargin",i);break;case"CellContentVerticalAlignment":this.editorHistory.initializeHistory("CellContentVerticalAlignment"),this.updateCellFormat(e,"verticalAlignment",i);break;case"CellLeftMargin":this.editorHistory.initializeHistory("CellLeftMargin"),this.updateCellFormat(e,"leftMargin",i);break;case"CellRightMargin":this.editorHistory.initializeHistory("CellRightMargin"),this.updateCellFormat(e,"rightMargin",i);break;case"CellTopMargin":this.editorHistory.initializeHistory("CellTopMargin"),this.updateCellFormat(e,"topMargin",i);break;case"CellBottomMargin":this.editorHistory.initializeHistory("CellBottomMargin"),this.updateCellFormat(e,"bottomMargin",i);break;case"CellPreferredWidth":this.editorHistory.initializeHistory("CellPreferredWidth"),this.updateCellFormat(e,"preferredWidth",i);break;case"CellPreferredWidthType":this.editorHistory.initializeHistory("CellPreferredWidthType"),this.updateCellFormat(e,"preferredWidthType",i);break;case"Shading":this.editorHistory.initializeHistory("Shading"),this.updateCellFormat(e,"shading",i
1);break;case"RowHeight":this.editorHistory.initializeHistory("RowHeight"),this.updateRowFormat(e,"height",i);break;case"RowHeightType":this.editorHistory.initializeHistory("RowHeightType"),this.updateRowFormat(e,"heightType",i);break;case"RowHeader":this.editorHistory.initializeHistory("RowHeader"),this.updateRowFormat(e,"isHeader",i);break;case"AllowBreakAcrossPages":this.editorHistory.initializeHistory("AllowBreakAcrossPages"),this.updateRowFormat(e,"allowBreakAcrossPages",i);break;case"TableBidi":this.editorHistory.initializeHistory(t),this.updateTableFormat(e,"bidi",i);break;case"TableTitle":this.editorHistory.initializeHistory(t),this.updateTableFormat(e,"title",i);break;case"TableDescription":this.editorHistory.initializeHistory(t),this.updateTableFormat(e,"description",i)}},e.prototype.updateTableFormat=function(e,t,i){var r=e.start;e.end,e.isForward||(r=e.end,e.start),this.initHistoryPosition(e,r),this.applyTablePropertyValue(t,i,r.paragraph.associatedCell.ownerTable),this.editorHistory&&(this.editorHistory.isUndoing||this.editorHistory.isRedoing)&&this.documentHelper.layout.reLayoutTable(r.paragraph.associatedCell.ownerTable)},e.prototype.updateCellFormat=function(e,t,i){e.owner.isShiftingEnabled=!0;var r=e.start;e.end,e.isForward||(r=e.end,e.start),this.initHistoryPosition(e,r),this.updateFormatForCell(e,t,i)},e.prototype.updateRowFormat=function(e,t,i){var r=e.start,o=e.end;e.isForward||(r=e.end,o=e.start),this.initHistoryPosition(e,r),this.applyRowFormat(r.paragraph.associatedCell.ownerRow,r,o,t,i)},e.prototype.initHistoryPosition=function(e,t){this.documentHelper.owner.editorHistoryModule&&!(0,a.le)(this.editorHistory.currentBaseHistoryInfo)&&((0,a.le)(t)?(0,a.le)(this.editorHistory.currentBaseHistoryInfo.insertPosition)&&(this.editorHistory.currentBaseHistoryInfo.insertPosition=e.start.getHierarchicalIndexInternal()):(0,a.le)(this.editorHistory.currentBaseHistoryInfo.insertPosition)&&(this.editorHistory.currentBaseHistoryInfo.insertPosition=t.getHierarchicalIndexInternal()))},e.prototype.startSelectionReLayouting=function(e,t,i,r){if(t.owner.isLayoutEnabled=!0,i.paragraph.isInsideTable){for(var o=i.paragraph.associatedCell.ownerTable;o.isInsideTable;)o=o.associatedCell.ownerTable;this.reLayoutSelectionOfTable(o,t,i,r)}else this.reLayoutSelection(e,t,i,r)},e.prototype.reLayoutSelectionOfTable=function(e,t,i,r){var o=!1;if(this.documentHelper.layout.layoutBodyWidgetCollection(e.index,e.containerWidget,e,!1),!(0,a.le)(r.paragraph.associatedCell)&&e.contains(r.paragraph.associatedCell))return!0;var n=t.getNextRenderedBlock(e);return(0,a.le)(n)||(o=this.reLayoutSelectionOfBlock(n,t,i,r)),o},e.prototype.reLayoutSelection=function(e,t,i,r){if(i.paragraph===e){i.offset,t.getParagraphLength(e);var n=0,s=0,l=e.getInline(i.offset,n),d=l.element;n=l.index,(0,a.le)(d)||(n!==d.length||(0,a.le)(d.nextNode)||(d=d.nextNode),s=d.line.children.indexOf(d));var h=0;i.currentWidget.paragraph===e&&(h=e.childWidgets.indexOf(i.currentWidget),s=i.currentWidget.children.indexOf(d)),d instanceof o.a3&&!d.line&&s>0?this.documentHelper.layout.reLayoutParagraph(e,h,s-1):this.documentHelper.layout.reLayoutParagraph(e,h,s)}else this.documentHelper.layout.reLayoutParagraph(e,0,0);if(r.paragraph===e)return!0;var c=t.getNextRenderedBlock(e);return!(0,a.le)(c)&&this.reLayoutSelectionOfBlock(c,t,i,r)},e.prototype.reLayoutSelectionOfBlock=function(e,t,i,r){return e instanceof o.ZH?this.reLayoutSelection(e,t,i,r):void 0},e.prototype.layoutItemBlock=function(e,t){var i=void 0;if(e.containerWidget instanceof o.VW||e.containerWidget instanceof o.yw)!(0,a.le)(this.documentHelper.owner)&&this.documentHelper.owner.isLayoutEnabled&&(i=(e=e.combineWidget(this.viewer)).containerWidget,this.documentHelper.layout.layoutBodyWidgetCollection(e.index,i,e,!1));else if(e.containerWidget instanceof o.nb){var r=e.containerWidget;r=this.documentHelper.selection.getContainerCell(r),!(0,a.le)(this.documentHelper.owner)&&this.documentHelper.owner.isLayoutEnabled&&this.documentHelper.layout.reLayoutTable(e)}},e.prototype.removeSelectedContents=function(e){return this.removeSelectedContentInternal(e,e.start,e.end)},e.prototype.removeSelectedContentInternal=function(e,t,i){var n=t,s=i;if(t.isExistBefore(i)||(n=i,s=t),n.paragraph===s.paragraph&&n.paragraph.childWidgets.indexOf(n.currentWidget)===n.paragraph.childWidgets.length-1&&n.offset===e.getParagraphLength(n.paragraph)&&n.offset+1===s.offset)return e.owner.isShiftingEnabled=!0,e.selectContent(n,!0),!0;var a=this.selection.getParagraphInfo(n);e.editPosition=this.selection.getHierarchicalIndex(a.paragraph,a.offset.toString());var l=n.clone(),d=l.paragraph.containerWidget,h=l.currentWidget.isFirstLine(),c=this.checkMultipleSectionSelected(l,s),p=this.removeSelectedContent(s.paragraph,e,n,s),g=new r.JK(e.owner);if(c&&"DefaultPaste"==this.selection.currentPasteAction&&h&&l.offset<1){var m=l.paragraph,u=new o.ZH,f=new o.z7(u);f.paragraph=u,u.containerWidget=d,u.childWidgets.push(f),d.childWidgets.push(u),u.
1index=m.index,u.x=l.location.x,u.y=l.location.y}return this.setPositionForCurrentIndex(g,e.editPosition),e.selectContent(g,!0),p},e.prototype.checkMultipleSectionSelected=function(e,t){return this.getBodyWidgetIndex(e)!=this.getBodyWidgetIndex(t)},e.prototype.getBodyWidgetIndex=function(e){var t=e.hierarchicalPosition,i=t.indexOf(";");return t.substring(0,i),i=(t=t.substring(i).replace(";","")).indexOf(";"),parseInt(t.substring(0,i),10)},e.prototype.removeSelectedContent=function(e,t,i,r){return(!r.paragraph.isInsideTable||r.paragraph===this.documentHelper.getLastParagraphInLastCell(r.paragraph.associatedCell.ownerTable)||!!i.paragraph.isInsideTable&&i.paragraph.associatedCell.ownerTable.index===r.paragraph.associatedCell.ownerTable.index)&&(t.owner.isShiftingEnabled=!0,this.deleteSelectedContent(e,t,i,r,2),!0)},e.prototype.deleteSelectedContent=function(e,t,i,r,n){var s=r.offset===this.selection.getLineLength(r.currentWidget)+1;if(i.isAtParagraphStart&&(s||r.isAtParagraphEnd)){var l=i.currentWidget.getInline(i.offset,0).element,d=r.currentWidget.getInline(r.offset,0).element,h=l instanceof o.h&&!l.contentControlProperties.lockContents,c=d instanceof o.h&&!d.contentControlProperties.lockContents,p=!1;if(h&&c&&l.reference===d&&l.nextNode!==d?(i.offset+=1,r.offset-=s?2:1,p=!0):!h&&c&&(r.offset-=s?2:1,p=!0),p){var g=this.selection.getParagraphInfo(i);t.editPosition=this.selection.getHierarchicalIndex(g.paragraph,g.offset.toString()),this.editorHistory&&this.editorHistory.currentBaseHistoryInfo&&this.editorHistory.currentBaseHistoryInfo.updateSelection()}}var m=0,u=i.currentWidget.getInline(i.offset,m);if(u.element,m=u.index,m=0,(u=r.currentWidget.getInline(r.offset,m)).element,m=u.index,r.paragraph!==e){this.deleteSelectedContent(r.paragraph,t,i,r,n);return}var f=!1;if((0,a.le)(this.editorHistory)||(0,a.le)(this.editorHistory.currentBaseHistoryInfo)||"BackSpace"!==this.editorHistory.currentBaseHistoryInfo.action&&"DeleteCells"!==this.editorHistory.currentBaseHistoryInfo.action&&"Accept Change"!==this.editorHistory.currentBaseHistoryInfo.action&&"Reject Change"!==this.editorHistory.currentBaseHistoryInfo.action&&("RemoveRowTrack"!==this.editorHistory.currentBaseHistoryInfo.action||this.editorHistory.currentBaseHistoryInfo.isClearCell)&&(!i.paragraph.isInsideTable||!this.editorHistory.isUndoing||"InsertTable"!==this.editorHistory.currentBaseHistoryInfo.action)||(f=!0),r.paragraph.isInsideTable&&(!i.paragraph.isInsideTable||i.paragraph.associatedCell&&!i.paragraph.associatedCell.equals(r.paragraph.associatedCell)||t.isCellSelected(r.paragraph.associatedCell,i,r)))r.paragraph.associatedCell.ownerTable.combineWidget(this.owner.viewer),this.deleteTableCell(r.paragraph.associatedCell,t,i,r,n,f);else{var y=void 0;if(this.owner.viewer instanceof x._&&e.bodyWidget.sectionFormat.numberOfColumns>1&&e===e.bodyWidget.lastChild&&!(0,a.le)(e.bodyWidget.nextRenderedWidget)&&e.bodyWidget.index!==e.bodyWidget.nextRenderedWidget.index&&e.bodyWidget.page===e.bodyWidget.nextRenderedWidget.page&&(y=e.nextRenderedWidget),this.deletePara(e,i,r,n),this.delBlockContinue&&this.delBlock){if(this.delSection){var v=e.bodyWidget instanceof o.VB?e.bodyWidget:void 0;this.deleteSection(t,this.delSection,v,n),this.delSection=void 0}this.deleteBlock(this.delBlock,t,i,r,n),this.delBlockContinue=!1,this.delBlock=void 0}this.owner.viewer instanceof x._&&void 0!==y&&(this.documentHelper.blockToShift=y)}},e.prototype.mergeCells=function(){!this.owner.isReadOnlyMode&&this.canEditContentControl&&this.owner.isDocumentLoaded&&((0,a.le)(this.documentHelper)||this.selection.isEmpty||this.mergeSelectedCellsInTable())},e.prototype.deleteTable=function(){if(!this.owner.isReadOnlyMode&&this.canEditContentControl){var e=this.selection.isForward?this.selection.start:this.selection.end;if(e.paragraph.isInsideTable){var t=this.getOwnerTable(this.selection.isForward).combineWidget(this.owner.viewer);this.selection.selectTable();var i=[];this.selection.owner.isShiftingEnabled=!0,this.checkIsNotRedoing()&&(i=this.checkAndRemoveComments(),this.initHistory("DeleteTable"),this.updateHistoryPosition(e,!0));var r=!0;if(!this.skipTracking()){for(var o=0,n=0;n<t.childWidgets.length;n++){var s=t.childWidgets[n];1===s.rowFormat.revisionLength&&"Insertion"===s.rowFormat.getRevision(0).revisionType&&s.rowFormat.getRevision(0).author===(""===this.owner.currentUser?"Guest user":this.owner.currentUser)&&(this.addRemovedRevisionInfo(s.rowFormat),this.unlinkRevisionFromItem(s.rowFormat),o++)}o===t.childWidgets.length&&(r=!1)}var l=this.getParagraphForSelection(t);
1if(this.editorHistory&&this.editorHistory.currentBaseHistoryInfo&&(this.editorHistory.currentBaseHistoryInfo.insertedText=R.j5.Table,this.editorHistory.currentBaseHistoryInfo.removedNodes.push(t.clone())),this.owner.enableTrackChanges&&r)for(var n=t.childWidgets.length-1;n>=0;n--){if(n===t.childWidgets.length-1){var d=t.childWidgets[0];l=this.selection.getFirstParagraph(d)}this.trackRowDeletion(t.childWidgets[n])}else this.removeBlock(t,void 0,!1,!1,!0);this.selection.selectParagraphInternal(l,!0),(this.checkIsNotRedoing()||(0,a.le)(this.editorHistory))&&(this.reLayout(this.selection),this.updateHistoryForComments(i))}}},e.prototype.deleteColumn=function(){if(!this.owner.isReadOnlyMode&&this.canEditContentControl){if(this.owner.enableTrackChanges){var e=new a.E7("documenteditor",this.owner.defaultLocale);e.setLocale(this.owner.locale),this.alertDialog=S.hZ.alert({title:e.getConstant("UnTrack"),content:e.getConstant("Merge Track"),showCloseIcon:!0,okButton:{text:"Ok",click:this.onDeleteColumnConfirmed.bind(this)},closeOnEscape:!0,position:{X:"center",Y:"center"},animationSettings:{effect:"Zoom"}}),this.alertDialog.enableRtl=this.owner.enableRtl}else this.onDeleteColumnConfirmed()}},e.prototype.onDeleteColumnConfirmed=function(){var e=this.selection.isForward?this.selection.start:this.selection.end;if(this.selection.isForward?this.selection.end:this.selection.start,e.paragraph.isInsideTable){var t=this.selection.start.clone(),i=this.selection.end.clone();this.selection.selectColumn();var r=[];this.selection.owner.isShiftingEnabled=!0,this.checkIsNotRedoing()&&(r=this.checkAndRemoveComments(),this.selection.start.setPositionInternal(t),this.selection.end.setPositionInternal(i),this.initHistory("DeleteColumn")),this.selection.start.setPositionInternal(t),this.selection.end.setPositionInternal(i);var o=this.getOwnerCell(this.selection.isForward),n=this.getOwnerCell(!this.selection.isForward),s=o.ownerTable.combineWidget(this.owner.viewer);this.editorHistory&&this.editorHistory.currentBaseHistoryInfo&&this.cloneTableToHistoryInfo(s);var l=void 0;if(n.nextWidget){var d=n.nextWidget;l=this.selection.getFirstParagraph(d)}else if(o.previousWidget){var h=o.previousWidget;l=this.selection.getFirstParagraph(h)}(0,a.le)(l)&&(l=this.getParagraphForSelection(s));var c=s.getColumnCellsForSelection(o,n);this.onDeleteColumn(s,c),0===s.childWidgets.length?(l=this.getParagraphForSelection(s),this.removeBlock(s),this.editorHistory&&this.editorHistory.currentBaseHistoryInfo&&(this.editorHistory.currentBaseHistoryInfo.action="DeleteTable"),s.destroy()):this.updateTable(s),this.selection.selectParagraphInternal(l,!0),((0,a.le)(this.editorHistory)||this.checkIsNotRedoing())&&(this.reLayout(this.selection,!0),this.updateHistoryForComments(r)),(0,a.le)(this.alertDialog)||(this.alertDialog.close(),this.alertDialog=void 0)}},e.prototype.onDeleteColumn=function(e,t){for(var i=0,r=[],o=0;o<e.childWidgets.length;o++){var n=e.childWidgets[o];if(1===n.childWidgets.length)t.indexOf(n.childWidgets[0])>=0&&(this.removeFieldInWidget(n.childWidgets[0]),this.removeFieldInWidget(n.childWidgets[0],!0),this.removeFieldInWidget(n.childWidgets[0],void 0,!0),e.childWidgets.splice(e.childWidgets.indexOf(n),1),n.destroy(),i+=1,o--);else{for(var s=0;s<n.childWidgets.length;s++){var l=n.childWidgets[s];t.indexOf(l)>=0&&(this.removeFieldInWidget(l),this.removeFieldInWidget(l,!0),this.removeFieldInWidget(l,void 0,!0),this.removeDeletedCellRevision(n,!1,l.columnIndex,l.columnIndex+l.cellFormat.columnSpan-1),n.childWidgets.splice(s,1),l.destroy(),s--),this.splitSpannedRows(e,o,l,r)}0===n.childWidgets.length&&(e.childWidgets.splice(e.childWidgets.indexOf(n),1),n.destroy(),i+=1,o--)}}for(var d=this.documentHelper.contentControlCollection.length-1;d>=0;d--){var h=this.documentHelper.contentControlCollection[d];(0,a.le)(h.contentControlProperties)&&this.documentHelper.contentControlCollection.splice(d)}return r.length>0&&(this.updateTableCellIndex(e),this.mergeSpannedCells(e,r)),i},e.prototype.splitSpannedRows=function(e,t,i,r){if(!(0,a.le)(i)&&!(0,a.le)(i.cellFormat)&&i.cellFormat.rowSpan>1)for(var o=i.cellFormat.rowSpan,n=1;n<o;n++){var s=t+n;if(s<e.childWidgets.length){var l=e.childWidgets[s];if(!(0,a.le)(l)){var d=this.selection.getLastParagraph(i),h=this.createColumn(d);h.childWidgets[0].paragraphFormat=d.paragraphFormat,h.cellFormat.copyFormat(i.cellFormat),h.cellFormat.rowSpan=1,i.cellFormat.rowSpan-=1,h.containerWidget=l,h.rowIndex=s,-1===r.indexOf(i)&&r.push(i),r.push(h),l.childWidgets.splice(i.columnIndex,0,h)}}}return r},e.prototype.updateTableCellIndex=function(e){for(var t=0;t<e.childWidgets.length;t++){var i=e.childWidgets[t];
1i.index=t;for(var r=0,o=0;o<i.childWidgets.length;o++){var n=i.childWidgets[o];n.index=o,n.columnIndex=r;var s=n.cellFormat&&n.cellFormat.columnSpan?n.cellFormat.columnSpan:1;r+=s}}},e.prototype.mergeSpannedCells=function(e,t){for(var i=0;i<e.childWidgets.length;i++)for(var r=e.childWidgets[i],o=0;o<r.childWidgets.length;o++){var n=r.childWidgets[o];if(-1!==t.indexOf(n))for(var s=n.columnIndex,a=e.childWidgets[i+1];a;){for(var l=!1,d=0;d<a.childWidgets.length;d++){var h=a.childWidgets[d];if(-1!==t.indexOf(h)&&h.columnIndex===s){h.destroy(),l=!0,n.cellFormat.rowSpan++;break}}if(l)a=a.nextRenderedWidget;else break}}},e.prototype.deleteRow=function(){if(!this.owner.isReadOnlyMode&&this.canEditContentControl){var e=this.selection.isForward?this.selection.start:this.selection.end;this.selection.isForward?this.selection.end:this.selection.start;var t=this.selection.getParagraphInfo(e),i=this.selection.getHierarchicalIndex(t.paragraph,t.offset.toString());if(e.paragraph.isInsideTable){var r=this.getOwnerCell(this.selection.isForward),o=this.getOwnerCell(!this.selection.isForward);this.selection.selectRow();var n=[];this.checkIsNotRedoing()&&(n=this.checkAndRemoveComments(),this.initHistory("DeleteRow")),this.selection.owner.isShiftingEnabled=!0;var s=r.ownerTable.combineWidget(this.owner.viewer),l=this.getOwnerRow(!0);this.editorHistory&&this.editorHistory.currentBaseHistoryInfo&&this.cloneTableToHistoryInfo(s);var d=void 0;if(l.nextWidget){var h=l.nextWidget.childWidgets[0];d=this.selection.getFirstParagraph(h)}if((0,a.le)(d)&&(d=this.getParagraphForSelection(s)),e=e.clone(),this.selection.isEmpty)this.owner.enableTrackChanges?this.trackRowDeletion(l,!0,!1):this.removeRow(l);else{var c=this.selection.getContainerCellOf(r,o);if(c.ownerTable.contains(o)){if(r=this.selection.getSelectedCell(r,c),o=this.selection.getSelectedCell(o,c),this.selection.containsCell(c,o))l=r.ownerRow,this.owner.enableTrackChanges?((0,a.le)(this.editorHistory.currentBaseHistoryInfo)||(this.editorHistory.currentBaseHistoryInfo.action="RemoveRowTrack",this.editorHistory.currentBaseHistoryInfo.insertedText=R.j5.Row),this.trackRowDeletion(l,!0,!1)):this.removeRow(l);else{var p=r.ownerRow,g=o.ownerRow,m=p.rowIndex,u=g.rowIndex;if(d=void 0,g.nextWidget){var h=g.nextWidget.childWidgets[0];d=this.selection.getFirstParagraph(h)}(0,a.le)(d)&&(d=this.getParagraphForSelection(s));for(var f=s.childWidgets.length-1;f>=0;f--){var y=s.childWidgets[f];if(y.rowIndex>=m&&y.rowIndex<=u){if(this.owner.enableTrackChanges&&this.checkIsNotRedoing())this.trackRowDeletion(y,!0,!1);else{this.removeFieldInBlock(y),this.removeFieldInBlock(y,!0),this.removeFieldInBlock(y,void 0,!0);for(var v=y.previousRenderedWidget;!(0,a.le)(v);){for(var H=0;H<v.childWidgets.length;H++){var C=v.childWidgets[H];y.rowIndex<C.ownerRow.rowIndex+C.cellFormat.rowSpan&&C.cellFormat.rowSpan--}v=v.previousRenderedWidget}for(var F=0;F<y.childWidgets.length;F++){var C=y.childWidgets[F],w=y.nextRenderedWidget;if(!(0,a.le)(w)&&w.rowIndex<C.ownerRow.rowIndex+C.cellFormat.rowSpan){C.cellFormat.rowSpan--;var I=this.createColumn(this.selection.getLastParagraph(C));I.cellFormat.copyFormat(C.cellFormat),I.index=C.index,I.rowIndex=C.rowIndex,I.columnIndex=C.columnIndex,I.containerWidget=w,I.margin=C.margin.clone(),I.leftBorderWidth=C.leftBorderWidth,I.rightBorderWidth=C.rightBorderWidth,w.childWidgets.splice(I.columnIndex,0,I)}y.childWidgets.splice(F,1),C.destroy(),F--}y.destroy()}}}}}}if(0===s.childWidgets.length?(this.removeBlock(s),this.editorHistory&&this.editorHistory.currentBaseHistoryInfo&&(this.editorHistory.currentBaseHistoryInfo.action="DeleteTable"),s.destroy()):this.updateTable(s),!this.owner.enableTrackChanges||(0,a.le)(s.childWidgets))this.selection.selectParagraphInternal(d,!0);else{var x=this.selection.getTextPosBasedOnLogicalIndex(i);this.selection.selectContent(x,!0)}((0,a.le)(this.editorHistory)||this.checkIsNotRedoing())&&(this.reLayout(this.selection,!0),this.updateHistoryForComments(n))}}},e.prototype.trackRowDeletion=function(e,t,i){var r=e.rowFormat;if(!(0,a.le)(r)){var n=!0;if(r.revisionLength>0){var s=this.retrieveRevisionInOder(r);if("Insertion"===s.revisionType){if(this.isRevisionMatched(r,void 0))return(0,a.le)(t)||t?this.removeRow(e):this.removeRevisionsInRow(e),!0}else"Deletion"===s.revisionType&&(this.unlinkRevisionFromItem(e.rowFormat),this.owner.enableTrackChanges&&!this.skipTracking()?n=!0:(this.removeDeletedCellRevision(e),n=!1))}n&&!this.skipTracking()&&(((0,a.le)(i)||i)&&this.editorHistory&&this.editorHistory.currentBaseHistoryInfo&&!this.isPasteOverWriteCells&&(this.editorHistory.currentBaseHistoryInfo.action="RemoveRowTrack",this.owner.enableCollaborativeEditing&&this.editorHistory.currentBaseHistoryInfo.createAcceptRejectRowOperation("RemoveRowTrack",r.ownerBase)),this.insertRevision(r,"Deletion"),this.updateLastDeletedRevision(e));for(var l=e.childWidgets.length-1;l>=0;l--)for(var d=e.childWidgets[l],h=d.childWidgets.length-1;h>=0;h--)if(d.childWidgets[h]instanceof o.dm)this.trackInnerTable(d.childWidgets[h],!0,i);else{var c=d.childWidgets[h];
1this.skipTableElements=!0,n&&!this.skipTracking()&&this.insertRevisionForBlock(c,"Deletion",void 0,void 0,!0,void 0,!0),this.skipTableElements=!1}}return!1},e.prototype.trackInnerTable=function(e,t,i){for(var r=e.childWidgets.length-1;r>=0;r--)this.trackRowDeletion(e.childWidgets[r],t,i);0===e.childWidgets.length&&this.removeBlock(e)},e.prototype.removeRow=function(e){var t=e.ownerTable;this.removeRevisionsInRow(e),1===t.childWidgets.length?(t.childWidgets.splice(t.childWidgets.indexOf(e),1),this.editorHistory&&this.editorHistory.currentBaseHistoryInfo&&"InsertTable"!==this.editorHistory.currentBaseHistoryInfo.action&&"ClearCells"!==this.editorHistory.currentBaseHistoryInfo.action&&"RemoveRowTrack"!==this.editorHistory.currentBaseHistoryInfo.action&&"DeleteCells"!==this.editorHistory.currentBaseHistoryInfo.action&&(this.editorHistory.currentBaseHistoryInfo.action="Delete")):(this.removeFieldInBlock(e,!0),t.childWidgets.splice(t.childWidgets.indexOf(e),1),this.updateTable(t))},e.prototype.updateTable=function(e,t){t||(e=e.combineWidget(this.viewer)),e.updateRowIndex(0),e.isGridUpdated=!1,e.buildTableColumns(),e.isGridUpdated=!0,this.documentHelper.layout.reLayoutTable(e)},e.prototype.getParagraphForSelection=function(e){var t=void 0,i=e.nextWidget?e.nextWidget:e.nextRenderedWidget,r=e.previousWidget?e.previousWidget:e.previousRenderedWidget;return i?t=i instanceof o.ZH?i:this.documentHelper.getFirstParagraphInFirstCell(i):r&&(t=r instanceof o.ZH?r:this.documentHelper.getLastParagraphInLastCell(r)),t},e.prototype.deletePara=function(e,t,i,r){e=e.combineWidget(this.owner.viewer);var n,s=this.documentHelper.selection,l=s.getStartOffset(e),d=s.getStartOffset(i.paragraph),h=l,c=0,p=!1,g=this.selection.getLineLength(e.lastChild),m=e,u=e.bodyWidget instanceof o.VB?e.bodyWidget:void 0,f=void 0,y=void 0,v=this.combineLastBlock,H=!1,C=t.currentWidget.getInline(t.offset,0).element;e.isInsideTable&&t.paragraph.isInsideTable&&(H=t.paragraph!==e),e===t.paragraph?(h=t.offset,f=t.currentWidget,n=h,h+1===this.documentHelper.selection.getLineLength(e.lastChild)&&(0,a.le)(e.nextWidget)&&h++,i.paragraph.isInsideTable&&(!this.owner.enableTrackChanges||this.skipTracking())&&(p=this.isEndInAdjacentTable(e,i.paragraph)),p||(p=this.combineLastBlock),this.combineLastBlock=!1):f=e.firstChild,e!==t.paragraph&&s.isSkipLayouting&&(s.isSkipLayouting=!1),e===i.paragraph?(y=i.currentWidget,c=i.offset):(y=e.lastChild,c=this.documentHelper.selection.getLineLength(e.lastChild));var F=(0,a.le)(e.previousRenderedWidget)||t.paragraph===e?void 0:e.previousRenderedWidget.combineWidget(this.documentHelper.viewer);if(this.owner.enableTrackChanges&&!(0,a.le)(F)&&F instanceof o.dm&&e.isEmpty()&&(0,a.le)(e.nextRenderedWidget)){this.delBlockContinue=!0,this.delBlock=F;return}(h>l&&t.currentWidget===e.lastChild&&h===g&&(e===i.paragraph&&i.offset===h+1||e.nextRenderedWidget===i.paragraph&&i.offset===d)||this.editorHistory&&this.editorHistory.isUndoing&&this.editorHistory.currentHistoryInfo&&"PageBreak"===this.editorHistory.currentHistoryInfo.action&&F&&F.isPageBreak()&&(0===h&&!t.currentWidget.isFirstLine||h>0)||t.paragraph!==i.paragraph&&2===r&&t.paragraph===e&&t.paragraph.nextWidget===i.paragraph&&!this.owner.enableTrackChanges||!(e.nextRenderedWidget instanceof o.dm)&&!(0,a.le)(this.editorHistory)&&!(0,a.le)(this.editorHistory.currentBaseHistoryInfo)&&("Reject"===this.editorHistory.currentBaseHistoryInfo.isAcceptOrReject||"Reject Change"===this.editorHistory.currentBaseHistoryInfo.action||"Accept"===this.editorHistory.currentBaseHistoryInfo.isAcceptOrReject||"Accept Change"===this.editorHistory.currentBaseHistoryInfo.action||this.collabTrackAction)&&(t.paragraph===i.paragraph&&i.currentWidget.isLastLine()&&c===s.getLineLength(e.lastChild)+1||t.paragraph===e&&i.paragraph!=e)&&(!t.currentWidget.isFirstLine()||h>l))&&(p=!0),n+1===this.documentHelper.selection.getLineLength(e.lastChild)&&(0,a.le)(e.nextWidget)&&h--;var w=i.clone();w.offset=w.offset-1;var I=!1;this.editorHistory&&!(0,a.le)(this.editorHistory.currentBaseHistoryInfo)&&("Insert"===this.editorHistory.currentBaseHistoryInfo.action||"InsertTextParaReplace"===this.editorHistory.currentBaseHistoryInfo.action)&&i.paragraph===e&&c===s.getLineLength(e.lastChild)+1&&(I=!0);var x=t.paragraph===e&&t.isAtParagraphStart&&w.isAtParagraphEnd&&this.editorHistory&&!(0,a.le)(this.editorHistory.currentBaseHistoryInfo)&&"Insert"===this.editorHistory.currentBaseHistoryInfo.action;x&&(this.editorHistory.currentBaseHistoryInfo.action="InsertTextParaReplace",i.paragraph!==e&&this.owner.enableTrackChanges&&2===r&&(x=!1));var b=t.paragraph===e,W=this.editorHistory&&this.editorHistory.currentBaseHistoryInfo&&("Accept Change"===this.editorHistory.currentBaseHistoryInfo.action||"Accept"===this.editorHistory.currentBaseHistoryInfo.isAcceptOrReject||"Reject"===this.editorHistory.currentBaseHistoryInfo.isAcceptOrReject||"Reject Change"===this.editorHistory.currentBaseHistoryInfo.action)||this.collabTrackAction;
1if(i.paragraph===e&&i.currentWidget!==e.lastChild||i.currentWidget===e.lastChild&&i.offset<=s.getLineLength(e.lastChild)||x){if((i.currentWidget.isFirstLine()&&i.offset>l||!i.currentWidget.isFirstLine()||x)&&this.removeInlines(e,f,h,y,c,r),(0,a.le)(F)||b||x)this.delBlockContinue=!1,this.delBlock=void 0;else{this.delBlockContinue=!0,this.delBlock=F;var P=F.bodyWidget instanceof o.VB?F.bodyWidget:void 0;P&&!u.equals(P)&&u.index!==P.index?this.delSection=P:this.delSection=void 0}}else if(t.paragraph===e&&(t.currentWidget!==e.firstChild||t.currentWidget===e.firstChild&&h>l)){if(this.delBlockContinue=!1,this.delBlock=void 0,4===r)return;if(this.owner.enableTrackChanges&&!this.skipTracking()&&"TOC"!==this.editorHistory.currentBaseHistoryInfo.action&&"Reject Change"!==this.editorHistory.currentBaseHistoryInfo.action&&"InsertHyperlink"!==this.editorHistory.currentBaseHistoryInfo.action){if(!this.isSelectionBasedonEndRevision&&i.paragraph===e&&e.nextRenderedWidget instanceof o.dm&&i.currentWidget===e.lastChild&&h===g&&c===g+1){this.editorHistory.currentBaseHistoryInfo=void 0;return}var k=new o.ZH;k.paragraphFormat.copyFormat(e.paragraphFormat),k.characterFormat.copyFormat(e.characterFormat);var R=new o.z7(k);if(k.childWidgets.push(R),k.index=e.index,k.containerWidget=e.containerWidget,e.lastChild!==i.currentWidget||p){if(p){var T=this.handleDeleteParaMark(e);this.removeInlines(e,f,h,y,c,r,k),T&&this.deleteParagraphMark(e,s,r,!1),this.addRemovedNodes(k)}else this.handleDeleteParaMark(e,!0),this.removeInlines(e,f,h,y,c,r,k),this.addRemovedNodes(k)}else this.removeInlines(e,f,h,y,c,r)}else if(e.lastChild!==i.currentWidget||p||W){if(W&&i.paragraph!==e&&p&&(v=!0),m=this.splitParagraph(e,e.firstChild,0,f,h,!0,!0,H),!(0,a.le)(this.editorHistory)&&!(0,a.le)(this.editorHistory.currentBaseHistoryInfo)&&this.editorHistory.currentBaseHistoryInfo.isSameUserDeleteParaMark)for(var S=0;S<e.characterFormat.revisionLength;S++){var B=e.characterFormat.getRevision(S);-1===m.characterFormat.getAllRevision().indexOf(B)&&m.characterFormat.addRevision(B)}this.insertParagraphPaste(e,m,t,i,!this.isDeleteTrackedContent&&p,r,v),this.removeRevisionForBlock(e,!1,!0),(0,a.le)(this.owner.editorHistory)||(0,a.le)(this.owner.editorHistory.currentBaseHistoryInfo)||"Paste"!==this.owner.editorHistory.currentBaseHistoryInfo.action||!(this.owner.editorHistory.historyInfoStack.length>0)||"DragAndDropContent"!==this.owner.editorHistory.historyInfoStack[0].action?this.addRemovedNodes(e):(this.addRemovedNodes(e.clone()),this.removeFieldInBlock(e),this.removeFieldInBlock(e,!0),this.removeFieldInBlock(e,void 0,!0),this.removeCommentsInBlock(e)),v=!1}else this.removeInlines(e,f,h,y,c,r);return}else{if(this.isSelectionBasedonEndRevision||i.paragraph!==e||e.isEmpty()||!(e.nextRenderedWidget instanceof o.dm)||W||this.isRemoteAction||(0,a.le)(this.editorHistory)||(0,a.le)(this.editorHistory.currentBaseHistoryInfo)||"Enter"===this.editorHistory.currentBaseHistoryInfo.action){C instanceof o.h&&0==C.type&&C.contentControlProperties.lockContents&&C.paragraph==e&&C.reference instanceof o.h&&C.paragraph!=C.reference.paragraph&&this.removedContentControlElements.push(C),!(this.owner.enableTrackChanges&&!this.skipTracking())&&!(!(0,a.le)(this.editorHistory)&&!(0,a.le)(this.editorHistory.currentBaseHistoryInfo)&&this.editorHistory.currentBaseHistoryInfo.endRevisionLogicalIndex)&&i.paragraph===e&&i.paragraph.isInsideTable&&(t.currentWidget.isFirstLine()&&t.offset>s.getStartOffset(t.paragraph)||!t.currentWidget.isFirstLine())&&i.offset>=s.getLineLength(i.paragraph.lastChild)&&i.paragraph.nextRenderedWidget&&!this.owner.documentHelper.isDragging&&(this.combineLastBlock=!0);var k=void 0,L=e.previousWidget,E=L instanceof o.ZH?L:void 0;if(r<4){var O=!1,A=e==this.getLastParaForBodywidgetCollection(e);if(A&&e===t.paragraph&&!e.isInsideTable&&!(0,a.le)(e.containerWidget)&&(0,a.le)(e.containerWidget.containerWidget)&&this.editorHistory&&this.editorHistory.currentBaseHistoryInfo&&"Delete"!==this.editorHistory.currentBaseHistoryInfo.action&&"Enter"!==this.editorHistory.currentBaseHistoryInfo.action&&(O=!0),this.owner.enableTrackChanges&&!this.skipTracking()&&this.editorHistory.currentBaseHistoryInfo&&"TOC"!==this.editorHistory.currentBaseHistoryInfo.action&&"InsertHyperlink"!==this.editorHistory.currentBaseHistoryInfo.action){var T=this.handleDeleteParaMark(e,!1,!0);if(T&&!A&&!e.isInsideTable&&e.nextRenderedWidget instanceof o.ZH&&e.bodyWidget.sectionIndex!==e.nextRenderedWidget.bodyWidget.sectionIndex&&this.deleteSection(s,e.bodyWidget,e.nextRenderedWidget.bodyWidget,r),this.insertRevisionForBlock(e,"Deletion",void 0,void 0,void 0,I),t.paragraph!==e&&!(0,a.le)(F)){this.delBlockContinue=!0,this.delBlock=F;return}}else{k=this.checkAndInsertBlock(e,t,i,r,E),this.removeRevisionForBlock(e,!1,!0);var N=e==this.getLastParaForBodywidgetCollection(e);(0,a.le)(k)&&N||(O=!1);var M=!1;if((this.owner.enableTrackChanges||O)&&(N||I)){for(var S=e.childWidgets.length-1;S>-1;S--){var D=e.childWidgets[S];this.removeContent(D,0,this.documentHelper.selection.getLineLength(D),void 0,!1)}this.removeEmptyLine(e),M=!0}else{var V=this.selection.getNextParagraphBlock(e);N||e.isInsideTable||(0,a.le)(V)||e.bodyWidget.sectionIndex===V.bodyWidget.sectionIndex||(this.deleteSection(s,e.bodyWidget,V.bodyWidget,r),b=!0),this.addRemovedNodes(e.clone())}if(!(0,a.le)(F)&&!b&&!x){this.delBlock=F;var P=F.bodyWidget instanceof o.VB?F.bodyWidget:void 0;if(P&&u.index!==P.index){var U=e.bodyWidget instanceof o.VB?e.bodyWidget:void 0;this.deleteSection(s,P,U,r)}}M||this.removeBlock(e,void 0,void 0,H)}if(this.documentHelper.blockToShift===e&&(this.documentHelper.blockToShift=void 0),(0,a.le)(k)){if(e===t.paragraph&&!this.isInsertingTOC){var z=void 0;e.indexInOwner>-1?this.editorHistory&&!(0,a.le)(this.editorHistory.currentBaseHistoryInfo)&&"Delete"===this.editorHistory.currentBaseHistoryInfo.action&&(A||!(0,a.le)(e.nextRenderedWidget)&&e.nextRenderedWidget instanceof o.dm?(0,a.le)(e.containerWidget)||(z=this.selection.getParagraphLength(e),s.editPosition=this.selection.getHierarchicalIndex(e,z.toString())):!(0,a.le)(e.nextRenderedWidget)&&e.nextRenderedWidget instanceof o.ZH&&(z=this.selection.getStartOffset(e.nextRenderedWidget),s.editPosition=this.selection.getHierarchicalIndex(e.nextRenderedWidget,z.toString()))):-1===e.indexInOwner&&A&&(z=this.selection.getParagraphLength(E),s.editPosition=this.selection.getHierarchicalIndex(E,z.toString()),this.editorHistory&&!(0,a.le)(this.editorHistory.currentBaseHistoryInfo)&&(this.editorHistory.currentBaseHistoryInfo.insertPosition=s.editPosition)),this.editorHistory&&!(0,a.le)(this.editorHistory.currentBaseHistoryInfo)&&this.updateHistoryPosition(this.editorHistory.currentBaseHistoryInfo.insertPosition,!1)}}else{s.editPosition=this.selection.getHierarchicalIndex(k,"0");var z=s.getParagraphLength(k)+1;this.editorHistory&&!(0,a.le)(this.editorHistory.currentBaseHistoryInfo)&&(this.editorHistory.currentBaseHistoryInfo.endPosition=this.selection.getHierarchicalIndex(k,z.toString()))}}}else this.owner.enableCollaborativeEditing&&this.selection.getLineLength(y)+1==c&&this.editorHistory&&this.editorHistory.currentBaseHistoryInfo&&(this.editorHistory.currentBaseHistoryInfo.endIndex-=1),this.removeInlines(e,f,h,y,c,r);t.paragraph===e||(0,a.le)(F)?(this.delBlockContinue=!1,this.delBlock=void 0):(this.delBlockContinue=!0,this.delBlock=F)}this.insertParagraphPaste(e,m,t,i,p,r,v)},e.prototype.deleteSection=function(e,t,i,r){if(r<4){if(this.owner.enableCollaborativeEditing){var o=void 0,n=void 0,s=this.owner.documentHelper.headersFooters[t.sectionIndex]["0"];(0,a.le)(s)||(o={paragraph:s.firstChild,offset:0},n=this.owner.selectionModule.getPositionInfoForHeaderFooter(o,{position:0,done:!1}),this.editorHistory.currentBaseHistoryInfo.headerFooterStart=n.position);var l=Object.keys(this.owner.documentHelper.headersFooters[t.sectionIndex]).length;if(l>0&&(s=this.owner.documentHelper.headersFooters[t.sectionIndex][(l-1).toString()],!(0,a.le)(s))){var d=this.owner.selectionModule.getParagraphLength(s.lastChild);o={paragraph:s.lastChild,offset:d+1},n=this.owner.selectionModule.getPositionInfoForHeaderFooter(o,{position:0,done:!1}),this.editorHistory.currentBaseHistoryInfo.headerFooterEnd=n.position}}this.combineSectionInternal(e,t,i)}r>2&&t.sectionFormat.copyFormat(i.sectionFormat)},e.prototype.combineSectionInternal=function(e,t,i){var r="NewPage"===t.sectionFormat.breakCode,n=t.getSplitWidgets()[0],s=[],l=n.y;this.documentHelper.combineSectionChild(n,s,!0);var d=(n=s[0]).lastChild.index;this.updateBlockIndex(d+1,i.firstChild);var h=0;this.viewer instanceof x._&&(i.page.headerWidget=this.viewer.getCurrentPageHeaderFooter(i,!0),i.page.footerWi
1dget=this.viewer.getCurrentPageHeaderFooter(i,!1),0===i.page.headerWidget.height&&this.documentHelper.layout.layoutHeaderFooter(i.page.bodyWidgets[0],this.viewer,i.page));var c=i;c.y=l;for(var p=0;p<n.childWidgets.length;p++){var g=n.childWidgets.splice(p,1)[0];c.childWidgets.splice(h,0,g),g.containerWidget=c,this.documentHelper.layout.layoutBodyWidgetCollection(g.index,g.bodyWidget,g,!1),c=(g=g.getSplitWidgets().pop()).containerWidget,h=g.indexInOwner+1,p--}if(n.sectionIndex>=0&&this.documentHelper.headersFooters[n.sectionIndex]){var m=n.sectionIndex,u=this.documentHelper.headersFooters[m],f=this.documentHelper.headersFooters[m+1],y=!(0,a.le)(u)&&Object.keys(u).length>0,v=!(0,a.le)(f)&&Object.keys(f).length>0;if(!y||(0,a.le)(f)||v||(this.documentHelper.headersFooters[m+1]=u),!y||v||!(0,a.le)(f)&&!v){n.removedHeaderFooters=[];for(var H=this.documentHelper.headersFooters.splice(m,1)[0],C=Object.keys(H),p=0;p<C.length;p++){var F=H[C[p]];this.removeFieldInWidget(F),this.removeFieldInWidget(F,!1,!0),F.page=void 0}n.removedHeaderFooters.push(H)}}if(this.updateSectionIndex(void 0,i,!1),this.addRemovedNodes(n),r&&"NoBreak"===i.sectionFormat.breakCode&&this.viewer instanceof x._&&i.page){var w=i.page;if(w.previousPage)for(var I=w.previousPage,p=0;p<w.bodyWidgets.length;p++){var b=w.bodyWidgets[p];w.bodyWidgets.splice(w.bodyWidgets.indexOf(b),1),I.bodyWidgets.splice(I.bodyWidgets.length,0,b),b.page=I,p--}}this.documentHelper.removeEmptyPages(),this.editorHistory&&this.editorHistory.isUndoing&&!(this.editorHistory.currentBaseHistoryInfo&&(this.editorHistory.currentBaseHistoryInfo.endRevisionLogicalIndex||this.editorHistory.currentBaseHistoryInfo.lastDeletedNodeRevision))&&(i.sectionFormat.numberOfColumns>1?i.sectionFormat.copyFormat(t.sectionFormat,this.editorHistory):i.sectionFormat=t.sectionFormat);var W=i.page;do this.documentHelper.layout.layoutHeaderFooter(W.bodyWidgets[0],this.viewer,W),W=W.nextPage;while(W);this.documentHelper.blockToShift&&this.documentHelper.blockToShift.containerWidget instanceof o.VB&&0===this.documentHelper.blockToShift.containerWidget.sectionFormat.columns.length&&this.documentHelper.layout.shiftLayoutedItems(!1,void 0,!0)},e.prototype.checkAndInsertBlock=function(e,t,i,r,n){if(e instanceof o.ZH&&e===t.paragraph||e instanceof o.dm){var s=void 0;if((0,a.le)(e.nextRenderedWidget)&&((0,a.le)(n)||n.nextRenderedWidget instanceof o.dm)){if(s=new o.ZH,1===r&&e instanceof o.ZH&&!(0,a.le)(e.paragraphFormat.baseStyle)&&"Normal"===e.paragraphFormat.baseStyle.name){if(s.characterFormat.copyFormat(e.characterFormat),(0,a.le)(e.previousRenderedWidget)&&0!==s.characterFormat.removedIds.length)for(;s.characterFormat.removedIds.length>0;)s.characterFormat.removedIds.splice(0,1);s.paragraphFormat.copyFormat(e.paragraphFormat)}if(s.index=e.index+1,s.containerWidget=e.containerWidget,e instanceof o.ZH){s.paragraphFormat.lineSpacing=e.paragraphFormat.lineSpacing,s.paragraphFormat.lineSpacingType=e.paragraphFormat.lineSpacingType;var l=this.documentHelper.styles.findByName("Normal");(0,a.le)(l)||(s.paragraphFormat.baseStyle=new b.wk,s.paragraphFormat.baseStyle.copyStyle(l))}this.owner.enableLayout||this.documentHelper.layout.addLineWidget(s),this.documentHelper.layout.layoutBodyWidgetCollection(s.index,s.bodyWidget,s,!1),e.containerWidget instanceof o.$L&&e.containerWidget.childWidgets.push(s)}return s}},e.prototype.splitParagraph=function(e,t,i,r,s,l,d,c){var p=new o.ZH;p.paragraphFormat=new h.h(p),p.characterFormat=new n.a(p,this.owner),p.paragraphFormat.copyFormat(e.paragraphFormat),p.characterFormat.copyFormat(e.characterFormat),p.characterFormat.removedIds=[];var g=new o.z7(p);p.childWidgets.push(g);var m=e.index,u=e.indexInOwner;if(this.moveInlines(e,p,0,i,t,s,r,l),e.containerWidget.childWidgets[u]){for(var f=[],y=e.containerWidget.childWidgets[u],v=0;v<y.childWidgets.length;v++)for(var H=y.childWidgets[v],C=0;C<H.children.length;C++){var F=H.children[C];F instanceof o.R5?this.removeFootnote(F):F instanceof o.aQ&&l&&(!this.owner.enableTrackChanges||this.owner.enableTrackChanges&&this.skipTracking())&&(!(this.editorHistory&&(this.editorHistory.isUndoing||this.editorHistory.isRedoing))&&F instanceof o.aQ&&f.push(F),F instanceof o.aQ&&this.documentHelper.bookmarks.containsKey(F.name)&&(this.owner.enableCollaborativeEditing&&!(0,a.le)(this.editorHistory.currentBaseHistoryInfo)&&this.editorHistory.currentBaseHistoryInfo.markerData.push({bookmarkName:F.name}),this.documentHelper.bookmarks.remove(F.name)))}for(var v=f.length-1;v>=0;v--)-1===this.removedBookmarkElements.indexOf(f[v])&&this.removedBookmarkElements.push(f[v])}return e.containerWidget.childWidgets.splice(u,0,p),p.index=m,p.containerWidget=e.containerWidget,e.contentControlProperties&&(p.contentControlProperties=e.contentControlProperties),this.updateNextBlocksIndex(p,!0),this.updateRevisionForSplittedPara(p,e),l&&this.removeBlock(e,void 0,d,c),this.documentHelper.layout.layoutBodyWidgetCollection(m,p.containerWidget,p,!1),p},e.prototype.removeCommentsInBlock=function(e){if(e instanceof o.dm)for(var t=0;t<e.childWidgets.length;t++)for(var i=e.childWidgets[t],r=0;r<i.childWidgets.length;r++)for(var n=i.childWidgets[r],s=0;s<n.childWidgets.length;s++){var a=n.childWidgets[s];this.removeCommentsInBlock(a)}else this.removeCommentInPara(e)},e.prototype.removeCommentInPara=function(e){for(var t=0;t<e.childWidgets.length;t++)for(var i=e.childWidgets[t],r=0;r<i.children.length;r++)this.removeCommentsInline(i.children[r])},e.prototype.removeCommentsInline=function(e){e instanceof o.Xw&&(1===e.commentType||e.removeCommentMark())},e.prototype.removeBlock=function(e,t,i,r,n){var s,l;i||(this.removeFieldInBlock(e),this.removeFieldInBlock(e,!0),this.removeFieldInBlock(e,void 0,!0),this.removeFieldInBlock(e,void 0,void 0,!0),this.removeCommentsInBlock(e)),e.isInsideTable?(l=e.associatedCell,this.checkToCombineRevisionsInPane(e),n&&this.checkAndRemoveRevisionFromBlock(e),s=e.associatedCell.childWidgets.indexOf(e),e.associatedCell.childWidgets,this.updateNextBlocksIndex(e,!1),e.associatedCell.childWidgets.splice(s,1),e.containerWidget=void 0,this.documentHelper.layout.layoutBodyWidgetCollection(e.index,l,e,!1,void 0,r)):(l=e.containerWidget,this.checkToCombineRevisionsInPane(e),n&&this.checkAndRemoveRevisionFromBlock(e),s=l.childWidgets.indexOf(e),l.childWidgets,this.updateNextBlocksIndex(e,!1),l.childWidgets.splice(s,1),e.containerWidget=void 0,l.height-=e.he
1ight,!(0,a.le)(l.containerWidget)&&l.containerWidget instanceof o.tf&&(l.containerWidget.height-=e.height),this.documentHelper.layout.layoutBodyWidgetCollection(e.index,l,e,!1,t,r))},e.prototype.checkToCombineRevisionsInPane=function(e){var t=e.previousRenderedWidget,i=e.nextRenderedWidget;if(t instanceof o.ZH&&i instanceof o.ZH){var r=t.characterFormat,n=(0,a.le)(i.firstChild)?void 0:(0,a.le)(i.firstChild.children[0])?i.characterFormat:i.firstChild.children[0];if(!(0,a.le)(r)&&!(0,a.le)(n))for(var s=r.getAllRevision(),l=n.getAllRevision(),d=0;d<s.length;d++)for(var h=0;h<l.length;h++)this.compareTwoRevisions(s[d],l[h])&&this.owner.revisions.combineWithNextRevision(s[d],l[h])}},e.prototype.checkAndRemoveRevisionFromBlock=function(e){if(e instanceof o.dm)for(var t=0;t<e.childWidgets.length;t++){var i=e.childWidgets[t];this.addRemovedRevisionInfo(i.rowFormat),this.removeRevisionsInRow(i,!0,!0)}else e instanceof o.ZH&&this.removeRevisionForBlock(e,!1,!0)},e.prototype.removePrevParaMarkRevision=function(e,t,i){if(t=!(0,a.le)(t)&&t,this.owner.enableTrackChanges||0!=e.characterFormat.revisionLength){var r=-1,o=void 0,s=e;t||(0,a.le)(s.previousRenderedWidget)||(s=s.previousRenderedWidget),s.characterFormat.revisionLength>0&&(o=s.characterFormat.getRevision(s.characterFormat.revisionLength-1),r=0),r>=0&&!(0,a.le)(o)&&o.getRange()[r]instanceof n.a&&(this.owner.trackChangesPane.updateCurrentTrackChanges(o),s.characterFormat&&s.characterFormat.getAllRevision().indexOf(o)>-1&&(i&&e.characterFormat.removedIds.push(o.revisionID),s.characterFormat.removeRevision(s.characterFormat.getAllRevision().indexOf(o))),0==o.getRange().length&&this.owner.revisionsInternal.remove(o))}},e.prototype.isPasteRevertAction=function(){return!(0,a.le)(this.editorHistory)&&!!this.editorHistory.currentBaseHistoryInfo&&"Paste"===this.editorHistory.currentBaseHistoryInfo.action},e.prototype.toCheckForTrack=function(e,t){if(this.owner.enableTrackChanges&&e instanceof o.dm&&e.childWidgets.length>0)for(var i=!1,r=e.childWidgets.length-1;r>=0;r--){var n=e.childWidgets[r];if(t.paragraph.isInsideTable&&this.owner.selectionModule.containsRow(n,t.paragraph.associatedCell)||i){if(!(n.rowFormat.revisionLength>0&&"Insertion"===n.rowFormat.getRevision(0).revisionType&&n.rowFormat.getRevision(0).author===(""===this.owner.currentUser?"Guest user":this.owner.currentUser)))return!0;i=!0}}return!1},e.prototype.removeFootnote=function(e,t){if(e.paragraph.bodyWidget.page.footnoteWidget){for(var i=e.paragraph.bodyWidget.page.footnoteWidget,r=0;r<i.bodyWidgets.length;r++)if(e===i.bodyWidgets[r].footNoteReference){if(i.height-=i.bodyWidgets[r].childWidgets[0].height,this.owner.enableTrackChanges)for(var o=0;o<i.bodyWidgets[r].childWidgets.length;o++)this.removeRevisionForBlock(i.bodyWidgets[r].childWidgets[o],!1,!0);i.bodyWidgets.splice(r,1),r--,this.isFootnoteElementRemoved=!0}0===i.bodyWidgets.length&&(e.paragraph.bodyWidget.page.footnoteWidget=void 0)}this.documentHelper.footnoteCollection.splice(this.documentHelper.footnoteCollection.indexOf(e),1),this.updateFootNoteIndex()},e.prototype.removeEndnote=function(e,t){var i=this.documentHelper.pages.length,r=this.documentHelper.pages[i-1].bodyWidgets[0];if(r.page.endnoteWidget){for(var o=r.page.endnoteWidget,n=0;n<o.bodyWidgets.length;n++)if(e===o.bodyWidgets[n].footNoteReference){if(o.height-=o.bodyWidgets[n].childWidgets[0].height,this.owner.enableTrackChanges)for(var s=0;s<o.bodyWidgets[n].childWidgets.length;s++)this.removeRevisionForBlock(o.bodyWidgets[n].childWidgets[s],!1,!0);o.bodyWidgets.splice(n,1),this.isEndnoteElementRemoved=!0,n--}0===o.bodyWidgets.length&&(r.page.endnoteWidget=void 0)}this.documentHelper.endnoteCollection.splice(this.documentHelper.endnoteCollection.indexOf(e),1),this.updateEndNoteIndex()},e.prototype.removeAutoShape=function(e){var t=e.line.paragraph.floatingElements.indexOf(e),i=e.line.paragraph.bodyWidget.floatingElements.indexOf(e);i>-1&&e.line.paragraph.bodyWidget.floatingElements.splice(i,1),e.line.paragraph.floatingElements.splice(t,1)},e.prototype.removeField=function(e,t,i,r){if(r)for(var n=this.documentHelper.editRanges.keys,s=0;s<n.length;s++){for(var l=this.documentHelper.editRanges.get(n[s]),d=0;d<l.length;d++){var h=l[d];h.line.paragraph===e&&(l.splice(d,1),d--)}0===l.length&&(this.documentHelper.editRanges.remove(n[s]),s--)}else{var c=this.documentHelper.fields;if(t?c=this.documentHelper.bookmarks.keys:i&&(c=this.documentHelper.contentControlCollection),e.floatingElements.length>0)for(var p=0;p<e.floatingElements.length;p++){var g=e.floatingElements[p];if(g instanceof o.f7&&g.textFrame&&g.textFrame.childWidgets.length>0)for(var s=0;s<g.textFrame.childWidgets.length;s++){var m=g.textFrame.childWidgets[s];this.removeFieldInBlock(m,t,i)}this.removeAutoShape(g),p--}for(var s=0;s<c.length;s++){var h=t?this.documentHelper.bookmarks.get(c[s]):c[s];if(h.line.paragraph===e||h instanceof o.aQ&&!(0,a.le)(h.reference)&&h.reference.line.paragraph===e){if(t){if(this.documentHelper.bookmarks.remove(c[s]),h.line.children.splice(h.indexInOwner,1),!(0,a.le)(h.line.paragraph.associatedCell)){var u=h.line.paragraph.associatedCell;u.isRenderBookmarkStart?u.isRenderBookmarkStart=!1:u.isRenderBookmarkEnd=!1}var f=h.reference;if(f&&f.line.children.splice(f.indexInOwner,1),f&&!(0,a.le)(f.line.paragraph.associatedCell)){var u=f.line.paragraph.associatedCell;u.isRenderBookmarkStart?u.isRenderBookmarkStart=!1:u.isRenderBookmarkEnd=!1}}else i?this.documentHelper.contentControlCollection.splice(s,1):(this.documentHelper.fields.splice(s,1),-1!==this.documentHelper.formFields.indexOf(h)&&this.documentHelper.formFields.splice(this.documentHelper.formFields.indexOf(h),1));s--}}}if(this.documentHelper.footnoteCollection.length>0)for(var s=0;s<this.documentHelper.footnoteCollection.length;s++){var h=this.documentHelper.footnoteCollection[s];if(h.line.paragraph===e){if(h.paragraph.bodyWidget.page.footnoteWidget){for(var y=h.paragraph.bodyWidget.page.footnoteWidget,d=0;d<y.bodyWidgets.length;d++)h===y.bodyWidgets[d].footNoteReference&&(y.height-=y.bodyWidgets[d].height,y.bodyWidgets.splice(d,1),d--);0===y.bodyWidgets.length&&(h.paragraph.bodyWidget.page.footnoteWidget=void 0)}this.documentHelper.footnoteCollection.splice(s,1),s--}}if(this.documentHelper.endnoteCollection.length>0)for(var s=0;s<this.documentHelper.endnoteCollection.length;s++){var h=this.documentHelper.endnoteCollection[s];if(h.line.paragraph===e){if(h.paragraph.bodyWidget.page.endnoteWidget){for(var v=h.paragraph.bodyWidget.page.endnoteWidget,d=0;d<v.bodyWidgets.length;d++)h===v.bodyWidgets[d].footNoteReference&&(v.height-=v.bodyWidgets[d].height,v.bodyWidgets.splice(d,1),d--);0===v.bodyWidgets.length&&(h.paragraph.bodyWidget.page.endnoteWidget=void 0)}this.documentHelper.endnoteCollection.splice(s,1),s--}}},e.prototype.getTabsInSelection=function(){var e=[],t=this.owner.selectionModule,i=t.selectedWidgets.keys,r=[];if(0===i.length||t.start.paragraph===t.end.paragraph)return t.start.paragraph.paragraphFormat.getUpdatedTabs();t.start.paragraph!==t.end.paragraph&&(r=this.owner.selectionModule.getParagraphsInSelection());for(var o=r.length>0?r[0]:void 0,n=(0,a.le)(o)?[]:o.paragraphFormat.getUpdatedTabs(),s=!0,l=0;l<n.length;l++)e.push(n[l]);for(var d=1;d<r.length;d++){var h=r[d].paragraphFormat.getUpdatedTabs(),c=[];s=!0;for(var p=0;p<e.length;p++){for(var l=0;l<h.length;l++)if(h[l].equals(e[p])){s=!1;break}s&&c.push(e[p])}for(var p=0;p<c.length;p++)e.splice(e.indexOf(c[p]),1)}return e},e.prototype.updateTabStopCollection=function(e,t,i){var r=e.paragraphFormat.tabs;if(i){e.paragraphFormat.tabs=[];for(var o=0;o<t.length;o++)e.paragraphFormat.tabs.push(t[o]);return}for(var o=0;o<t.length;o++){for(var n=t[o],s=-1,a=0;a<r.length;a++){var l=r[a];if(n.position===l.position){s=a;break}if(n.position<l.position)break}s>=0?this.modifyTabStop(r[s],n):this.addTabStopToCollection(r,n)}},e.prototype.modifyTabStop=function(e,t){e.deletePosition=t.deletePosition,e.tabJustification=t.tabJustification,e.tabLeader=t.tabLeader},e.prototype.removeTabStops=function(e,t){for(var i=0;i<e.length;i++)for(var r=e[i].paragraphFormat.tabs,o=0;o<t.length;o++)for(var n=t[o],s=0;s<r.length;s++)if(r[s].equals(n)){r.splice(s,1);break}},e.prototype.addTabStopToCollection=function(e,t,i){for(var r=-1,o=0;o<e.length;o++)if(e[o].position>t.position){r=o;break}return r=-1===r?e.length:r,i||e.splice(r,0,t.clone()),r},e.prototype.addRemovedNodes=function(e,t){e instanceof o.Xw&&0===e.commentType&&e.commentMark&&e.removeCommentMark(),e instanceof o.h&&(0===e.type?this.documentHelper.contentControlCollection.splice(this.documentHelper.contentControlCollection.indexOf(e),1):this.updatePropertiesToBlock(e.reference)),e instanceof o.V8&&0===e.fieldType&&(-1!==this.documentHelper.fields.indexOf(e)&&this.documentHelper.fields.splice(this.documentHelper.fields.indexOf(e),1),-1!==this.documentHelper.formFields.indexOf(e)&&this.documentHelper.formFields.splice(this.documentHelper.formFields.indexOf(e),1)),this.editorHistory&&!(0,a.le)(this.editorHistory.currentBaseHistoryInfo)?t?this.editorHistory.currentBaseHistoryInfo.removedNodes.splice(0,0,e):this.editorHistory.currentBaseHistoryInfo.removedNodes.push(e):this.editHyperlinkInternal&&this.nodes.push(e)},e.prototype.deleteBlock=function(e,t,i,r,n){if(e instanceof o.ZH){if(this.deletePara(e,i,r,n),this.delBlockContinue&&this.delBlock){if(this.delSection){var s=e.bodyWidget instanceof o.VB?e.bodyWidget:void 0;this.deleteSection(t,this.delSection,s,n),this.delSection=void 0}-1!==this.delBlock.indexInOwner&&this.deleteBlock(this.delBlock,t,i,r,n),this.delBlockContinue=!1,this.delBlock=void 0}}else this.deleteTableBlock(e,t,i,r,n),(0,a.le)(e.bodyWidget)||!this.owner.enableTrackChanges||this.skipTracking()||this.documentHelper.layout.reLayoutTable(e)},e.prototype.deleteTableCell=function(e,t,i,r,n,s){var l=!(i.paragraph.isInsideTable&&e.ownerTable.contains(i.paragraph.associatedCell)),d=e.ownerTable.previousRenderedWidget;if(i.paragraph.isInsideTable){var h=t.getContainerCellOf(e,i.paragraph.associatedCell);if(h.ownerTable.contains(i.paragraph.associatedCell)){var c=t.getSelectedCell(e,h);if(t.getSelectedCell(i.paragraph.associatedCell,h),t.containsCell(h,i.paragraph.associatedCell)){if(t.isCellSelected(h,i,r)){if(s)this.updateEditPosition(h,t),this.deleteCellsInTable(e.ownerRow.ownerTable,t,i,r,n);else{var p=this.clearCell(h,t,n,i,r);!p&&2!==n&&this.editorHistory?this.editorHistory.currentBaseHistoryInfo=void 0:p&&(this.editorHistory&&this.editorHistory.currentBaseHistoryInfo&&!this.editorHistory.currentBaseHistoryInfo.isClearCell&&(this.editorHistory.currentBaseHistoryInfo.isClearCell=!0),this.documentHelper.layout.reLayoutTable(h.ownerRow.ownerTable))}}else if(c===h){if(this.deletePara(r.paragraph,i,r,n),this.delBlockContinue&&this.delBlock){if(this.delSection){var g=r.paragraph,m=g.bodyWidget instanceof o.VB?g.bodyWidget:void 0;this.deleteSection(t,this.delSection,m,n),this.delSection=void 0}this.deleteBlock(this.delBlock,t,i,r,n),this.delBlockContinue=!1,this.delBlock=void 0}}else this.deleteContainer(c,t,i,r,n)}else{var u=this.editorHistory&&!(0,a.le)(this.editorHistory.currentBaseHistoryInfo)&&"Accept Change"===this.editorHistory.currentBaseHistoryInfo.action||"Reject Change"===this.editorHistory.currentBaseHistoryInfo.action;2!==n||u?(l=!1,this.deleteCellsInTable(h.ownerTable,t,i,r,n,void 0,!0)):this.deleteCell(e,t,2)}}else this.deleteContainer(h,t,i,r,n)}else{var f=t.getContainerCell(e);(0,a.le)(this.editorHistory)||(0,a.le)(this.editorHistory.currentBaseHistoryInfo)||"RemoveRowTrack"!==this.editorHistory.currentBaseHistoryInfo.action?this.deleteContainer(f,t,i,r,n):(this.deleteTableBlock(f.ownerTable,t,i,r,n),l=!1)}l&&!(0,a.le)(d)&&this.deleteBlock(d,t,i,r,n)},e.prototype.deleteCellsInTable=function(e,t,i,r,o,n,s){var l,d=this,h="Delete",c=!1,p=i.paragraph.associatedCell,g=r.paragraph.associatedCell;(0,a.le)(n)||(g=n);var m=this.documentHelper.layout.getParentTable(p),u=this.documentHelper.layout.getParentCell(p),f=this.documentHelper.layout.getParentCell(g);(0,a.le)(n)&&i.paragraph.isInsideTable&&r.paragraph.isInsideTable&&this.selection.isCellSelected(u,i,r)&&(p=u,g=f);var y=p.columnIndex,v=g.columnIndex+g.cellFormat.columnSpan-1;m.bidi&&p.ownerRow!==g.ownerRow&&(y=(l=[v,y])[0],v=l[1]);
1var H=p.rowIndex,C=g.rowIndex,F=this.isWholeRowSelected(p,g),w=this.editorHistory&&!(0,a.le)(this.editorHistory.currentBaseHistoryInfo)&&("Accept Change"===this.editorHistory.currentBaseHistoryInfo.action||"Reject Change"===this.editorHistory.currentBaseHistoryInfo.action||this.collabTrackAction);if(this.editorHistory&&!(0,a.le)(this.editorHistory.currentBaseHistoryInfo)&&!this.isPasteOverWriteCells){if(h=this.editorHistory.currentBaseHistoryInfo.action,c="BackSpace"===this.editorHistory.currentBaseHistoryInfo.action||"DeleteCells"===this.editorHistory.currentBaseHistoryInfo.action||w||"InsertTable"===this.editorHistory.currentBaseHistoryInfo.action||"RemoveRowTrack"===this.editorHistory.currentBaseHistoryInfo.action||(0,a.le)(p.ownerRow.previousWidget)&&(0,a.le)(g.ownerRow.nextWidget)&&"Cut"===this.editorHistory.currentBaseHistoryInfo.action,this.cloneTableToHistoryInfo(e,e===m),this.editorHistory.isRedoing&&"RemoveRowTrack"===this.editorHistory.currentBaseHistoryInfo.action)for(var I=e.childWidgets.length-1;I>=0;I--){var x=e.childWidgets[I];x.index>=H&&x.index<=C&&F&&this.trackRowDeletion(x,!1)}if("RemoveRowTrack"===this.editorHistory.currentBaseHistoryInfo.action)return;this.editorHistory.currentBaseHistoryInfo.action=c?"DeleteCells":"ClearCells",t.owner.isLayoutEnabled=!1}if(!this.owner.enableTrackChanges||this.skipTracking()||w)this.onConfirmedTableCellsDeletion(e,t,i,r,H,C,y,v,c,o,F,h,w);else{var b=!1;if(F)1!==o&&s?this.trackDeletedContentInTableCell(e,t,i,r,o,H,C,y,v):this.onConfirmedTableCellsDeletion(e,t,i,r,H,C,y,v,c,o,F,h);else if(1===o){var W=new a.E7("documenteditor",this.owner.defaultLocale),P=W.getConstant("UnTrack"),k=W.getConstant("Merge Track");W.setLocale(this.owner.locale),this.alertDialog=S.hZ.alert({title:P,content:k,showCloseIcon:!0,okButton:{text:"Ok",click:function(){b=!0,d.onConfirmedTableCellsDeletion(e,t,i,r,H,C,y,v,c,o,F,h)}},closeOnEscape:!0,position:{X:"center",Y:"center"},animationSettings:{effect:"Zoom"},close:function(){b||(d.documentHelper.layout.reLayoutTable(e),d.viewer.updateScrollBars())}}),this.alertDialog.enableRtl=this.owner.enableRtl}else this.trackDeletedContentInTableCell(e,t,i,r,o,H,C,y,v)}},e.prototype.removeDeletedCellRevision=function(e,t,i,r){for(var n=0;n<e.childWidgets.length;n++){var s=e.childWidgets[n];if((0,a.le)(i)&&(0,a.le)(r)||!(0,a.le)(i)&&!(0,a.le)(r)&&s.columnIndex>=i&&s.columnIndex<=r)for(var l=0;l<s.childWidgets.length;l++){var d=s.childWidgets[l];if(!(0,a.le)(d)&&d instanceof o.ZH){for(var h=0;h<d.childWidgets.length;h++){var c=d.childWidgets[h];if(!(0,a.le)(c.children))for(var p=0;p<c.children.length;p++){var g=c.children[p];g.revisionLength>0&&(t&&this.addRemovedRevisionInfo(g),this.unlinkRevisionFromItem(g))}}t&&this.addRemovedRevisionInfo(d.characterFormat),this.unlinkRevisionFromItem(d.characterFormat)}else if(!(0,a.le)(d)&&d instanceof o.dm)for(var m=0;m<d.childWidgets.length;m++){var u=d.childWidgets[m];this.removeRevisionsInRow(u)}}}},e.prototype.removeDeletedShapeRevision=function(e){var t=e.textFrame;if(!(0,a.le)(t))for(var i=0;i<t.childWidgets.length;i++){var r=t.childWidgets[i];if(!(0,a.le)(r)&&r instanceof o.ZH){for(var n=0;n<r.childWidgets.length;n++){var s=r.childWidgets[n];if(!(0,a.le)(s.children))for(var l=0;l<s.children.length;l++){var d=s.children[l];d.revisionLength>0&&this.unlinkRevisionFromItem(d)}}this.unlinkRevisionFromItem(r.characterFormat)}}},e.prototype.insertShape=function(e,t){var i=this.getShape(e,t);this.owner.documentHelper.selection.start.currentWidget.children.push(i),this.reLayout(this.owner.documentHelper.selection),this.documentHelper.currentPage.bodyWidgets[0].floatingElements.push(i)},e.prototype.getShape=function(e,t){var i=new o.f7().clone();i.shapeId=parseInt(Date.now().toString().slice(0,10),10),i.name=e+" "+(this.documentHelper.currentPage.bodyWidgets[0].floatingElements.length+1),t=(0,a.le)(t)?{}:t,i.x=(0,a.le)(t.x)?50:t.x,i.y=(0,a.le)(t.x)?50:t.y,i.autoShapeType=e,"UpDownArrow"===e?(i.height=(0,a.le)(t.height)?140:t.height,i.width=(0,a.le)(t.width)?96:t.width):"LeftRightArrow"===e||"LeftRightArrowCallout"===e?(i.height=(0,a.le)(t.height)?80:t.height,i.width=(0,a.le)(t.width)?140:t.width):(i.height=(0,a.le)(t.height)?96:t.height,i.width=(0,a.le)(t.width)?96:t.width),i.visible=!!(0,a.le)(t.visible)||t.visible,i.widthScale=(0,a.le)(t.widthScale)?100:t.widthScale,i.heightScale=(0,a.le)(t.heightScale)?100:t.heightScale,i.verticalPosition=(0,a.le)(t.verticalPosition)?i.y:t.verticalPosition,i.verticalOrigin=(0,a.le)(t.verticalOrigin)?"Paragraph":t.verticalOrigin,i.verticalAlignment=(0,a.le)(t.verticalAlignment)?"None":t.verticalAlignment,i.verticalRelativePercent=-34028235e31,i.horizontalPosition=(0,a.le)(t.horizontalPosition)?i.x:t.horizontalPosition,i.horizontalRelativePercent=-34028235e31,i.heightRelativePercent=-34028235e31,i.widthRelativePercent=0,i.horizontalOrigin=(0,a.le)(t.horizontalOrigin)?"Column":t.horizontalOrigin,i.horizontalAlignment=(0,a.le)(t.horizontalAlignment)?"None":t.horizontalAlignment,i.zOrderPosition=251659264,i.allowOverlap=!!(0,a.le)(t.allowOverLap)||t.allowOverLap,i.textWrappingStyle=(0,a.le)(t.textWrappingStyle)?"InFrontOfText":t.textWrappingStyle,i.textWrappingType=(0,a.le)(t.textWrappingType)?"Both":t.textWrappingType,i.isBelowText=!(0,a.le)(t.isBelowText)&&t.isBelowText,i.distanceBottom=(0,a.le)(t.distanceBottom)?0:t.distanceBottom,i.distanceTop=(0,a.le)(t.distanceTop)?0:t.distanceTop,i.distanceLeft=(0,a.le)(t.distanceLeft)?12:t.distanceLeft,i.distanceRight=(0,a.le)(t.distanceRight)?12:t.distanceRight,i.isHorizontalRule=!(0,a.le)(t.isH
1orizontalRule)&&t.isHorizontalRule,i.layoutInCell=!!(0,a.le)(t.layoutInCell)||t.layoutInCell,i.lockAnchor=!(0,a.le)(t.lockAnchor)&&t.lockAnchor;var r=new o.yw;"Arc"===e||"CurvedConnector"===e||"ElbowConnector"===e?r.textVerticalAlignment="Top":r.textVerticalAlignment="Middle",r.marginLeft=10,r.marginRight=10,r.marginTop=5,r.marginBottom=5,i.textFrame=r,r.containerShape=i;var n=new o._E;"Arc"===e||"CurvedConnector"===e||"ElbowConnector"===e||"DoubleBracket"===e||"DoubleBrace"===e||"RightBrace"===e||"LeftBrace"===e||"RightBracket"===e||"LeftBracket"===e?(n.color=(0,a.le)(t.fillColor)?"#FFFFFFFF":t.fillColor,n.fill=!!(0,a.le)(t.fill)||t.fill):(n.fill=!!(0,a.le)(t.fill)||t.fill,n.color=(0,a.le)(t.fillColor)?"#156082FF":t.fillColor),i.fillFormat=n;var s=new o.hu;return s.lineFormatType=(0,a.le)(t.lineFormatType)?"Solid":t.lineFormatType,s.dashStyle=(0,a.le)(t.dashStyle)?"Solid":t.dashStyle,s.line=!!(0,a.le)(t.line)||t.line,"Arc"===e||"CurvedConnector"===e||"ElbowConnector"===e||"DoubleBracket"===e||"DoubleBrace"===e||"RightBrace"===e||"LeftBrace"===e||"RightBracket"===e||"LeftBracket"===e?(s.color=(0,a.le)(t.lineColor)?"#156082FF":t.lineColor,s.weight=(0,a.le)(t.lineWeight)?.5:t.lineWeight):(s.color=(0,a.le)(t.lineColor)?"#042433FF":t.lineColor,s.weight=(0,a.le)(t.lineWeight)?1:t.lineWeight),i.lineFormat=s,i.line=this.owner.documentHelper.selection.start.currentWidget,i},e.prototype.trackDeletedContentInTableCell=function(e,t,i,r,n,s,a,l,d){this.selection.hasMergedCells()?(c=this.selection.getCellFromSelectionInTable(0),p=this.selection.getCellFromSelectionInTable(1)):(c=this.selection.getCellFromSelection(0),p=this.selection.getCellFromSelection(1));var h,c,p,g=this.selection.getActualOffset(c,0),m=this.selection.getActualOffset(p,1),u=[],f=!1;this.editorHistory&&this.editorHistory.currentBaseHistoryInfo&&u.push.apply(u,this.editorHistory.currentBaseHistoryInfo.removedNodes);for(var y=e.childWidgets.length-1;y>=0;y--){var v=e.childWidgets[y];if(v.index>=s&&v.index<=a)for(var H=v.childWidgets.length-1;H>=0;H--){var C=v.childWidgets[H];if(C.columnIndex>=l&&C.columnIndex<=d)for(var F=v.childWidgets[H],w=F.childWidgets.length,I=F.childWidgets.length-1;I>=0;I--){var x=F.childWidgets[I];if(x instanceof o.ZH)this.insertRevisionForBlock(x,"Deletion",void 0,void 0,!0),w!==F.childWidgets.length&&(w=F.childWidgets.length,f=!0);else{for(var b=x.childWidgets.length-1;b>=0;b--)this.trackRowDeletion(x.childWidgets[b],void 0,!1);0===x.childWidgets.length&&this.removeBlock(x)}}}}this.editorHistory&&this.editorHistory.currentBaseHistoryInfo&&(this.editorHistory.currentBaseHistoryInfo.removedNodes.length=0,(h=this.editorHistory.currentBaseHistoryInfo.removedNodes).push.apply(h,u),this.editorHistory.currentBaseHistoryInfo.isRevisionEndInAnotherCell=!0,this.editorHistory.currentBaseHistoryInfo.selectionStart=g,this.editorHistory.currentBaseHistoryInfo.insertPosition=g,this.editorHistory.currentBaseHistoryInfo.selectionEnd=m,this.editorHistory.currentBaseHistoryInfo.endPosition=m,f&&(m=this.selection.getActualOffset(p,1),this.editorHistory.currentBaseHistoryInfo.selectionEnd=m,this.editorHistory.currentBaseHistoryInfo.endPosition=m,this.selection.editPosition=g)),this.documentHelper.layout.reLayoutTable(e)},e.prototype.onConfirmedTableCellsDeletion=function(e,t,i,r,o,n,s,l,d,h,c,p,g){for(var m=[],u=0;u<e.childWidgets.length;u++)for(var f=e.childWidgets[u],y=0;y<f.childWidgets.length;y++){var v=f.childWidgets[y];this.splitSpannedRows(e,u,v,m)}for(var u=e.childWidgets.length-1;u>=0;u--){var f=e.childWidgets[u],H=!1;if(f.index>=o&&f.index<=n&&(!this.owner.enableTrackChanges||this.skipTracking()||g?this.onConfirmedCellDeletion(f,t,i,r,o,n,s,l,d,h,c):c?(H=this.trackRowDeletion(f,!1))&&this.onConfirmedCellDeletion(f,t,i,r,o,n,s,l,d,h,c):this.onConfirmedCellDeletion(f,t,i,r,o,n,s,l,d,h,c)),H||0===f.childWidgets.length){for(var C=e.childWidgets[u],F=C.previousRenderedWidget;!(0,a.le)(F)&&F.ownerTable===C.ownerTable;){for(var w=0;w<F.childWidgets.length;w++){var I=F.childWidgets[w];C.rowIndex<I.ownerRow.rowIndex+I.cellFormat.rowSpan&&I.cellFormat.rowSpan--}F=F.previousRenderedWidget}this.updateNextBlocksIndex(C,!1),e.childWidgets.splice(u,1)}}if(m.length>0&&(this.updateTableCellIndex(e),this.mergeSpannedCells(e,m)),t.owner.isLayoutEnabled=!0,0===e.childWidgets.length?(t.editPosition=this.selection.getHierarchicalIndex(e,"0"),this.setActionInternal(t,p),this.removeBlock(e)):(e.isGridUpdated=!1,e.buildTableColumns(),e.isGridUpdated=!0,this.documentHelper.layout.reLayoutTable(e)),!(0,a.le)(this.alertDialog)){var x=t.getTextPosBasedOnLogicalIndex(t.editPosition);t.selectContent(x,!0),this.reLayout(t),this.alertDialog.close(),this.alertDialog=void 0}},e.prototype.onConfirmedCellDeletion=function(e,t,i,r,n,s,l,d,h,c,p){var g=!1;this.editorHistory&&this.editorHistory.currentBaseHistoryInfo&&"ClearCells"===this.editorHistory.currentBaseHistoryInfo.action&&(p=!1),this.removeRevisionsInRow(e,p,void 0,l,d);for(var m=Math.min(l,d),u=Math.max(l,d),f=0;f<e.childWidgets.length;f++){var y=e.childWidgets[f];if(y.columnIndex>=m&&y.columnIndex<=u){if(g||(this.updateEditPosition(y,t),g=!0),h){var v=e.childWidgets[f];this.updateNextBlocksIndex(v,!1);for(var H=0;H<v.childWidgets.length;H++)for(var C=v.childWidgets[H],F=0;F<C.childWidgets.length;F++){var w=C.childWidgets[F];if(w instanceof o.z7)for(var I=0;I<w.children.length;I++){var x=w.children[I];x instanceof o.R5&&this.removeFootnote(x)}}var b=e.nextRenderedWidget;if(!(0,a.le)(b)&&b.rowIndex<v.ownerRow.rowIndex+v.cellFormat.rowSpan){v.cellFormat.rowSpan--;var W=this.createColumn(this.selection.getLastParagraph(v));W.cellFormat.copyFormat(v.cellFormat),W.index=v.index,W.rowIndex=v.rowIndex,W.columnIndex=v.columnIndex,W.containerWidget=b,W.margin=v.margin.clone(),W.leftBorderWidth=v.leftBorderWidth,W.rightBorderWidth=v.rightBorderWidth,b.childWidgets.splice(W.columnIndex,0,W)}var P=e.childWidgets[f];this.removeFieldInWidget(P,!0),this.removeFieldInWidget(P,void 0,!0),e.childWidgets.splice(f,1),f--}else c<4&&this.deleteCell(y,t,c)}}},e.prototype.removeRevisionsInRow=function(e,t,i,r,o){e.rowFormat.revisionLength>0&&((0,a.le)(t)||t)&&this.unlinkRevisionFromItem(e.rowFormat),this.removeDeletedCellRevision(e,i,r,o)},e.prototype.removeRevisionForBlock=function(e,t,i){if(e.characterFormat.revisionLength>0&&!t&&(i&&this.addRemovedRevisionInfo(e.characterFormat),this.unlinkRevisionFromItem(e.characterFormat),e.characterFormat.clearRevision()),!(0,a.le)(e))for(var r=0;r<e.childWidgets.length;r++)for(var n=e.childWidgets[r],s=0;s<n.children.length;s++){var l=n.children[s];if(l instanceof o.R5){var d=l.nextValidNodeForTracking;"Footnote"===d.footnoteType?this.removeFootnote(d):this.removeEndnote(d)}!(0,a.le)(l)&&l.revisionLength>0&&(i&&this.addRemovedRevisionInfo(l),this.unlinkRevisionFromItem(l),l.clearRevision())}},e.prototype.isWholeRowSelected=function(e,t){return 0===e.cellIndex&&t.cellIndex===t.ownerRow.childWidgets.length-1},e.prototype.deleteCell=function(e,t,i){var r=e.childWidgets[0];if(!(1===e.childWidgets.length&&r instanceof o.ZH&&r.isEmpty())){for(var n=e.childWidgets.length-1,s=e.childWidgets.length-1;s>-1;s--)if(r=e.childWidgets[s],i<4){if(r instanceof o.ZH&&s===n){var l=r;if(this.checkClearCells(t))l.isEmpty()||(this.removeInlines(l,l.firstChild,0,l.lastChild,l.lastChild.getEndOffset(),i),1===(e=e.combineWidget(this.owner.viewer)).childWidgets.length&&(t.editPosition=this.selection.getHierarchicalIndex(e.childWidgets[0],"0"),this.updateHistoryPosition(t.editPosition,!0)));else for(var d=l.childWidgets.length-1;d>=0;d--){for(var h=l.childWidgets[d],c=h.children.length-1;c>=0;c--){var p=h.children[c];p instanceof o.R5?this.removeFootnote(p):p instanceof o.aQ&&0===p.bookmarkType&&this.documentHelper.bookmarks.containsKey(p.name)&&this.documentHelper.bookmarks.remove(p.name),this.unLinkFieldCharacter(p),h.children.splice(c,1),(0,a.le)(h.layoutedElements)||h.layoutedElements.splice(c,1)}l.childWidgets.length>1&&l.childWidgets.splice(d,1)}continue}this.removeBlock(r),this.checkClearCells(t)&&(this.addRemovedNodes(r),1===e.childWidgets.length&&(t.editPosition=this.selection.getHierarchicalIndex(e.childWidgets[0],"0"),this.updateHistoryPosition(t.editPosition,!0)))}}},e.prototype.clearCell=function(e,t,i,r,n){var s=e.childWidgets[0];if(1===e.childWidgets.length&&s instanceof o.ZH&&s.isEmpty())return!1;for(var a=e.childWidgets.length-1,l=e.childWidgets.length-1;l>-1;l--)if(s=e.childWidgets[l],i<4){if(s instanceof o.ZH&&l===a){s.isEmpty()||(this.removeInlines(s,s.firstChild,0,s.lastChild,s.lastChild.getEndOffset(),i),e=e.combineWidget(this.owner.viewer));continue}this.deleteBlock(s,t,r,n,i);break}return!0},e.prototype.deleteContainer=function(e,t,i,r,o){var n=e.ownerTable;if(n.childWidgets.length>0){var s=n.childWidgets[n.childWidgets.length-1];if(t.containsRow(s,r.paragraph.associatedCell)){if(this.owner.enableTrackChanges){this.cloneTableToHistoryInfo(n);for(var l=n.childWidgets.length-1;l>=0;l--)this.trackRowDeletion(n.childWidgets[l]);(0===n.childWidgets.length||!(0,a.le)(this.editorHistory)&&(this.editorHistory.isUndoing||this.editorHistory.isRedoing))&&this.removeBlock(n)}else this.deleteContent(n,t,o)}else{if(this.toCheckForTrack(n,r)){this.cloneTableToHistoryInfo(n);for(var d=!1,l=n.childWidgets.length-1;l>=0;l--){var h=n.childWidgets[l];(r.paragraph.isInsideTable&&t.containsRow(h,r.paragraph.associatedCell)||d)&&(this.trackRowDeletion(h),d=!0)}!(0,a.le)(this.editorHistory)&&(this.editorHistory.isUndoing||this.editorHistory.isRedoing)?this.removeBlock(n):this.documentHelper.layout.reLayoutTable(n);return}for(var l=0;l<n.childWidgets.length;l++){var c=n.childWidgets[l];if(o<4&&(this.updateNextBlocksIndex(c,!1),this.addRemovedRevisionInfo(c.rowFormat),this.removeRevisionsInRow(c,!0,
1!0),n.childWidgets.splice(l,1),this.addRemovedNodes(c),l--),r.paragraph.isInsideTable&&t.containsRow(c,r.paragraph.associatedCell)){this.documentHelper.layout.reLayoutTable(n);return}}}}},e.prototype.deleteTableBlock=function(e,t,i,r,n){if(e=e.combineWidget(this.owner.viewer),i.paragraph.isInsideTable&&e.contains(i.paragraph.associatedCell)){var s=e.previousRenderedWidget,l=this.checkAndInsertBlock(e,i,r,n,s instanceof o.ZH?s:void 0);if(t.containsRow(e.firstChild,i.paragraph.associatedCell)){if(this.owner.enableTrackChanges){this.cloneTableToHistoryInfo(e);for(var d=e.childWidgets.length-1;d>=0;d--)this.trackRowDeletion(e.childWidgets[d]);(0===e.childWidgets.length||!(0,a.le)(this.editorHistory)&&(this.editorHistory.isUndoing||this.editorHistory.isRedoing))&&this.removeBlock(e)}else this.deleteContent(e,t,n)}else if(this.owner.enableTrackChanges){if((0,a.le)(r.paragraph.associatedCell)&&!r.paragraph.isInsideTable){var h=e.lastChild.lastChild;this.deleteCellsInTable(e,t,i,r,n,h)}else if(!(0,a.le)(r.paragraph.associatedCell)&&!(0,a.le)(i.paragraph.associatedCell)&&i.paragraph.associatedCell.ownerTable!==r.paragraph.associatedCell.ownerTable){this.cloneTableToHistoryInfo(e);for(var d=e.childWidgets.length-1;d>=0;d--){var c=e.childWidgets[d];if(this.trackRowDeletion(c),i.paragraph.isInsideTable&&t.containsRow(c,i.paragraph.associatedCell)){this.documentHelper.layout.reLayoutTable(c.ownerTable);return}}}}else{var p=this.splitTable(e,i.paragraph.associatedCell.ownerRow);this.deleteContent(e,t,n),this.documentHelper.layout.layoutBodyWidgetCollection(p.index,p.containerWidget,p,!1)}(0,a.le)(l)||(t.editPosition=this.selection.getHierarchicalIndex(l,"0"),!this.editorHistory||(0,a.le)(this.editorHistory.currentBaseHistoryInfo)||(this.editorHistory.currentBaseHistoryInfo.endPosition=t.editPosition))}else{var g=e.previousRenderedWidget;if(this.owner.enableTrackChanges){this.cloneTableToHistoryInfo(e);for(var d=e.childWidgets.length-1;d>=0;d--)this.trackRowDeletion(e.childWidgets[d]);(0===e.childWidgets.length||!(0,a.le)(this.editorHistory)&&(this.editorHistory.isUndoing||this.editorHistory.isRedoing))&&this.removeBlock(e)}else this.deleteContent(e,t,n);(0,a.le)(g)||this.deleteBlock(g,t,i,r,n)}},e.prototype.splitTable=function(e,t){var i=new o.dm;i.tableFormat.copyFormat(e.tableFormat),i.index=e.index;for(var r=0;r<e.childWidgets.length;r++){var n=e.childWidgets[r];if(n===t)break;i.childWidgets.push(n),n.containerWidget=i,e.childWidgets.splice(r,1),r--}var s=e.getIndex();return e.containerWidget.childWidgets.splice(s,0,i),i.containerWidget=e.containerWidget,this.updateNextBlocksIndex(i,!0),i},e.prototype.updateEditPosition=function(e,t){var i=this.documentHelper.getFirstParagraphInCell(e);t.editPosition=this.selection.getHierarchicalIndex(i,"0")},e.prototype.deleteContent=function(e,t,i){i<4&&(this.removeBlock(e,!1,!1,!1,!0),this.addRemovedNodes(e))},e.prototype.setActionInternal=function(e,t){this.documentHelper.owner.enableHistoryMode&&!(0,a.le)(this.editorHistory.currentBaseHistoryInfo)&&(this.editorHistory.currentBaseHistoryInfo.action=t)},e.prototype.checkClearCells=function(e){return this.editorHistory&&this.editorHistory.currentBaseHistoryInfo&&"ClearCells"!==this.editorHistory.currentBaseHistoryInfo.action},e.prototype.isEndInAdjacentTable=function(e,t){var i=this.getOwnerTable(!1);if(!(0,a.le)(i)&&(0,a.le)(i.containerWidget))return!0;var r=this.selection.getHierarchicalIndex(e,""),o=this.selection.getHierarchicalIndex(t,""),n=r.split(";"),s=o.split(";");return n.length<s.length},e.prototype.cloneTableToHistoryInfo=function(e,t){if(this.editorHistory&&!(0,a.le)(this.editorHistory.currentBaseHistoryInfo)){var i=e.clone();i.index=e.index,this.editorHistory.currentBaseHistoryInfo.removedNodes.push(i);var r=this.documentHelper.selection.start,o=this.documentHelper.selection.end;return this.documentHelper.selection.isForward||(o=r=o),(r.paragraph.isInsideTable&&r.paragraph.associatedCell.ownerTable===e||t)&&this.updateHistoryPosition(this.selection.getHierarchicalIndex(e,"0"),!0),i}},e.prototype.insertParagraphPaste=function(e,t,i,r,o,n,s){if(this.editorHistory&&(this.editorHistory.isUndoing||this.editorHistory.isRedoing)&&!(0,a.le)(this.editorHistory.currentBaseHistoryInfo)&&"Paste"===this.editorHistory.currentBaseHistoryInfo.action){var l=this.selection.getNextParagraphBlock(t);if(l&&i.offset>0&&l===r.paragraph&&e===i.paragraph&&"Paste"===this.editorHistory.currentBaseHistoryInfo.action){var d=0;this.documentHelper.layout.clearListElementBox(l),this.documentHelper.layout.clearListElementBox(t),l.paragraphFormat.isSameFormat(t.paragraphFormat)||(this.isMeasureParaWidth=!0);for(var h=0;h<t.childWidgets.length;h++){var c=t.childWidgets[h];l.childWidgets.splice(d,0,c),t.childWidgets.splice(h,1),h--,d++,c.paragraph=l}this.removeBlock(t),this.documentHelper.layout.reLayoutParagraph(l,0,0),this.isMeasureParaWidth=!1,o=!1;var p=this.selection.editPosition.substring(this.selection.editPosition.lastIndexOf(";")+1);this.selection.editPosition=this.selection.getHierarchicalIndex(l,p)}}o&&this.deleteParagraphMark(t,this.selection,n,!1,s)},e.prototype.removeInlines=function(e,t,i,n,s,l,d){var h=!1;this.documentHelper.layout.clearListElementBox(e),e.childWidgets.indexOf(t);var c=this.selection.start.clone(),p=this.selection.end.clone(),g=this.selection.getElementInfo(c.currentWidget,0!==c.offset&&this.selection.isForward?c.offset+1:c.offset),m=this.selection.getElementInfo(p.currentWidget,0===p.offset||this.selection.isForward?p.offset:p.offset+1);if(g.element instanceof o.V8&&2!==g.element.fieldType&&!(m.element instanceof o.V8)||m.element instanceof o.V8&&2!==m.element.fieldType&&!(g.element instanceof o.V8)){if(this.selection.isForward){if(g.element instanceof o.V8&&0===g.element.fieldType&&!(0,a.le)(g.element.fieldEnd)){var u=g.element.fieldEnd.line.getOffset(g.element.fieldEnd,1),f=new r.JK(this.owner);f.setPositionParagraph(g.element.fieldEnd.line,u),p.isExistBefore(f)&&g.element.fieldSeparator&&(this.selection.start.setPositionParagraph(g.element.fieldSeparator.line,g.element.fieldSeparator.line.getOffset(g.element.fieldSeparator,1)),i=this.selection.start.offset,(0,a.le)(this.editorHistory)||(0,a.le)(this.editorHistory.currentBaseHistoryInfo)||(this.editorHistory.currentBaseHistoryInfo.selectionStart=this.owner.selection.startOffset,this.editorHistory.currentBaseHistoryInfo.insertPosition=this.owner.selection.startOffset,this.selection.editPosition=this.owner.selection.startOffset))}else if(m.element instanceof o.V8&&1===m.element.fieldType&&!(0,a.le)(m.element.fieldBegin)){var y=m.element.fieldBegin.line.getOffset(m.element.fieldBegin,0),v=new r.JK(this.owner);v.setPositionParagraph(m.element.fieldBegin.line,y),!c.isExistAfter(v)||(this.selection.end.setPositionParagraph(m.element.line,m.element.line.getOffset(m.element,0)),s=this.selection.end.offset,(0,a.le)(this.editorHistory)||(0,a.le)(this.editorHistory.currentBaseHistoryInfo)||(this.editorHistory.currentBaseHistoryInfo.selectionEnd=this.owner.selection.endOffset))}}else if(g.element instanceof o.V8&&1===g.element.fieldType&&!(0,a.le)(g.element.fieldBegin)){var y=g.element.fieldBegin.line.getOffset(g.element.fieldBegin,0),v=new r.JK(this.owner);v.setPositionParagraph(g.element.fieldBegin.line,y),!p.isExistAfter(v)||(this.selection.start.setPositionParagraph(g.element.line,g.element.line.getOffset(g.element,0)),s=this.selection.start.offset,(0,a.le)(this.editorHistory)||(0,a.le)(this.editorHistory.currentBaseHistoryInfo)||(this.editorHistory.currentBaseHistoryInfo.selectionStart=this.owner.selection.startOffset,this.editorHistory.currentBaseHistoryInfo.insertPosition=this.owner.selection.endOffset,this.selection.editPosition=this.owner.selection.endOffset))}else if(m.element instanceof o.V8&&0===m.element.fieldType&&m.element.fieldSeparator&&!(0,a.le)(m.element.fieldEnd)){var u=m.element.fieldEnd.line.getOffset(m.element.fieldEnd,1),f=new r.JK(this.owner);f.setPositionParagraph(m.element.fieldEnd.line,u),!c.isExistBefore(f)||(this.selection.end.setPositionParagraph(m.element.fieldSeparator.line,m.element.fieldSeparator.line.getOffset(m.element.fieldSeparator,1)),i=this.selection.end.offset,(0,a.le)(this.editorHistory)||(0,a.le)(this.editorHistory.currentBaseHistoryInfo)||(this.editorHistory.currentBaseHistoryInfo.selectionEnd=this.owner.selection.endOffset,this.editorHistory.currentBaseHistoryInfo.insertPosition=this.owner.selection.endOffset,this.selection.editPosition=this.owner.selection.endOffset))}}var H=this.selection.getElementInfo(c.currentWidget,this.selection.isForward?c.offset:c.offset+1),C=this.selection.getElementInfo(p.currentWidget,this.selection.isForward?p.offset+1:p.offset),F=!(0,a.le)(this.editorHistory)&&(this.editorHistory.isUndoing||this.editorHistory.isRedoing);this.selection.isExcludeBookmarkStartEnd||F||this.isInsertingText||this.editorHistory&&this.editorHistory.currentBaseHistoryInfo&&"Insert"===this.editorHistory.currentBaseHistoryInfo.action||(0,a.le)(H)||(0,a.le)(C)||!H.element||!C.element||!(H.element instanceof o.aQ)||!(C.element instanceof o.aQ)||H.element.name!==C.element.name||!(0,a.le)(H.element.nextElement)&&!(0,a.le)(C.element.previousElement)&&H.element.nextElement instanceof o.aQ&&C.element.previousElement instanceof o.aQ&&H.element.nextElement.name===C.element.previousElement.name||!(0,a.le)(H.element.nextElement)&&!(0,a.le)(C.element.previousElement)&&H.element.nextElement instanceof o.V8&&C.element.previousElement instanceof o.V8||(this.selection.isForward?(this.selection.start.setPositionParagraph(H.element.line,H.element.line.getOffset(H.element,0)),this.selection.end.setPositionParagraph(C.element.line,C.element.line.getOffset(C.element,1)
1),i=this.selection.start.offset,s=this.selection.end.offset,(0,a.le)(this.editorHistory)||(0,a.le)(this.editorHistory.currentBaseHistoryInfo)||(this.editorHistory.currentBaseHistoryInfo.selectionStart=this.owner.selection.startOffset,this.editorHistory.currentBaseHistoryInfo.selectionEnd=this.owner.selection.endOffset,this.editorHistory.currentBaseHistoryInfo.insertPosition=this.owner.selection.startOffset,this.selection.editPosition=this.owner.selection.startOffset)):(this.selection.start.setPositionParagraph(H.element.line,H.element.line.getOffset(H.element,1)),this.selection.end.setPositionParagraph(C.element.line,C.element.line.getOffset(C.element,0)),i=this.selection.end.offset,s=this.selection.start.offset,(0,a.le)(this.editorHistory)||(0,a.le)(this.editorHistory.currentBaseHistoryInfo)||(this.editorHistory.currentBaseHistoryInfo.selectionStart=this.owner.selection.startOffset,this.editorHistory.currentBaseHistoryInfo.selectionEnd=this.owner.selection.endOffset,this.editorHistory.currentBaseHistoryInfo.insertPosition=this.owner.selection.endOffset,this.selection.editPosition=this.owner.selection.endOffset)));for(var w=this.selection.editPosition,I=this.selection.getParagraphInfo(this.selection.start),x=this.selection.getParagraphInfo(this.selection.end),b=this.selection.getHierarchicalIndex(I.paragraph,I.offset.toString()),W=this.selection.getHierarchicalIndex(x.paragraph,x.offset.toString()),P=e.childWidgets.length-1;P>=0;P--){var k=e.childWidgets[P];if(t===k&&n===k){this.removeContent(k,i,s,l,void 0,d),h=!0;break}if(n===k)e.isLayouted=!1,h=!0,this.removeContent(k,0,s,l,void 0,d);else if(t===k){this.removeContent(k,i,this.documentHelper.selection.getLineLength(k),l,void 0,d);break}else h&&this.removeContent(k,0,this.documentHelper.selection.getLineLength(k),l,void 0,d)}if(this.owner.enableTrackChanges&&!this.skipTracking()&&(this.selection.start.setPositionInternal(c),this.selection.end.setPositionInternal(p),this.skipReplace&&(this.editorHistory.currentBaseHistoryInfo.insertPosition=void 0,this.updateInsertPosition()),this.selection.editPosition=w),h){if(e.isLayouted=!0,this.removeEmptyLine(e),this.documentHelper.layout.isReplacingAll||this.documentHelper.layout.reLayoutParagraph(e,0,0),this.selection.start.currentWidget.paragraph.isInsideTable&&this.owner.enableTrackChanges&&-1===this.selection.start.currentWidget.indexInOwner){var R=this.selection.getTextPosBasedOnLogicalIndex(b);this.selection.start.setPositionInternal(R)}if(this.selection.end.currentWidget.paragraph.isInsideTable&&this.owner.enableTrackChanges&&-1===this.selection.end.currentWidget.indexInOwner){var T=this.selection.getTextPosBasedOnLogicalIndex(W);this.selection.end.setPositionInternal(T)}}},e.prototype.skipTracking=function(){return!(0,a.le)(this.editorHistory)&&(!!this.editorHistory.isUndoing||!!this.editorHistory.isRedoing)||!(0,a.le)(this.editorHistory)&&!!this.editorHistory.currentBaseHistoryInfo&&("Reject Change"===this.editorHistory.currentBaseHistoryInfo.action||"Accept Change"===this.editorHistory.currentBaseHistoryInfo.action)||!!this.collabTrackAction},e.prototype.canHandleDeletion=function(){return!(0,a.le)(this.editorHistory)&&!!this.editorHistory.currentBaseHistoryInfo&&"DeleteRow"===this.editorHistory.currentBaseHistoryInfo.action},e.prototype.deleteCommentInSelection=function(e){var t=this.editorHistory.currentBaseHistoryInfo;this.editorHistory&&this.editorHistory.currentBaseHistoryInfo&&!this.editorHistory.currentHistoryInfo&&!(this.editorHistory.isUndoing||this.editorHistory.isRedoing)&&this.initComplexHistory("DeleteCommentInline"),this.deleteCommentInternal(e),this.editorHistory&&this.editorHistory.currentHistoryInfo&&(this.editorHistory.isUndoing||this.editorHistory.isRedoing||this.editorHistory.currentHistoryInfo.addModifiedAction(t),this.selection.editPosition=t.insertPosition,this.editorHistory.currentHistoryInfo.insertPosition=this.selection.editPosition,this.editorHistory.currentBaseHistoryInfo=t)},e.prototype.removeContent=function(e,t,i,n,l,d){for(var h=this.selection.getLineLength(e),c=void 0,p=0,g=void 0,m=e.children.length-1;m>=0;m--){var u=e.children[m];if(this.owner.enableTrackChanges&&u instanceof o.a3&&""===u.text){e.children.splice(m,1);continue}if(u.isWidthUpdated=!1,(0,a.le)(n)||2!==n&&1!==n)for(var f=0;f<e.children.length;f++){var y=e.children[f];if(y instanceof o.a3){var v=y.text;if(v.length+p>t&&!(p>t)&&(c=v[t-p-1],(0,a.le)(c)&&t-p==0&&(c=g)),v.length+p>i){var H=i-p;if(" "===v[H]){var C=1;" "===v[H+1]&&C++,1===C&&y.nextNode instanceof o.a3&&s.o_.startsWith(y.nextNode.text," ")&&C++,1===C&&(0===t||" "===c)&&i++}}g=v[v.length-1]}p+=y.length}if(i<=h-u.length){h-=u.length;continue}var F=u.length;h>i&&h-F<i&&(F=i-(h-u.length));var w=0;if(h-u.length<t&&(w=t-(h-u.length)),h>i&&(h-=u.length-F),0===w&&F===u.length){if(!this.owner.enableTrackChanges||this.owner.enableTrackChanges&&this.skipTracking()){if(!(this.editorHistory&&(this.editorHistory.isUndoing||this.editorHistory.isRedoing))&&u instanceof o.aQ&&(-1===this.removedBookmarkElements.indexOf(u)&&this.removedBookmarkElements.push(u),u.reference.paragraph!==u.paragraph&&this.selection.start.paragraph!==this.selection.end.paragraph&&!this.selection.start.paragraph.isInsideTable&&!this.selection.end.paragraph.isInsideTable)){var I=this.selection.start,x=this.selection.end;if(this.selection.isForward||(I=this.selection.end,x=this.selection.start),0===u.reference.bookmarkType){var b=u.reference.line.getOffset(u.reference,0),W=new r.JK(this.owner);W.setPositionParagraph(u.reference.line,b),(I.isExistBefore(W)||I.isAtSamePosition(W))&&-1===this.removedBookmarkElements.indexOf(u.reference)&&this.removedBookmarkElements.push(u.reference)}else if(1===u.reference.bookmarkType){var b=u.reference.line.getOffset(u.reference,1),P=new r.JK(this.owner);P.setPositionParagraph(u.reference.line,b),(x.isExistAfter(P)||x.isAtSamePosition(P))&&-1===this.removedBookmarkElements.indexOf(u.reference)&&this.removedBookmarkElements.push(u.reference)}}u instanceof o.aQ&&this.documentHelper.bookmarks.containsKey(u.name)&&(this.owner.enableCollaborativeEditing&&!(0,a.le)(this.editorHistory.currentBaseHistoryInfo)&&this.editorHistory.currentBaseHistoryInfo.markerData.push({bookmarkName:u.name}),this.documentHelper.bookmarks.remove(u.name))}if((u instanceof o.XY&&"Inline"!==u.textWrappingStyle||u instanceof o.f7||u instanceof o.qu)&&this.removeAutoShape(u),this.skipFieldDeleteTracking&&u.revisionLength>0){var k=u;k instanceof o.V8&&((1===k.fieldType||2===k.fieldType)&&(k=k.fieldBegin),this.clearFieldElementRevisions(k,u.getAllRevision()))}
1if(this.canHandleDeletion()||this.owner.enableTrackChanges&&!this.skipTracking()&&!this.skipFieldDeleteTracking)this.skipTableElements||this.isPasteOverWriteCells||this.skipFootNoteDeleteTracking||l||this.isElementAddedToNewPara(d,u)||this.addRemovedNodes(u.clone()),this.handleDeleteTracking(u,t,i,m,l,d);else{u instanceof o.R5&&(u.isLayout=!1),this.unLinkFieldCharacter(u),l||this.isElementAddedToNewPara(d,u)||(u instanceof o._A?this.addRemovedNodes(u.clone()):this.addRemovedNodes(u)),u instanceof o.Cw?(this.editorHistory&&(this.editorHistory.isUndoing||this.editorHistory.isRedoing)||this.removedEditRangeStartElements.push(u),-1!=u.columnFirst&&-1!=u.columnLast&&this.removeEditRangeFromCollection(u)):u instanceof o.jn?this.editorHistory&&(this.editorHistory.isUndoing||this.editorHistory.isRedoing)||this.removedEditRangeEndElements.push(u):u instanceof o.h&&!this.isInsertingTOC&&this.removedContentControlElements.push(u);var R=u.previousNode;this.addRemovedRevisionInfo(u),u instanceof o.V8&&2===u.fieldType?(this.unlinkRevisionFromItem(u),e.children.splice(m,1)):(this.combineRevisionsAndViewBasedOnUntrackedContent(u),e.children.splice(m,1),this.unlinkRevisionFromItem(u)),(0,a.le)(R)||this.combineElementRevisionToPrevNxt(R),!(0,a.le)(e.layoutedElements)&&e.layoutedElements.length>0&&e.layoutedElements.splice(m,1)}}else if(u instanceof o.a3){var T=this.handleDeleteTracking(u,w,F,void 0,void 0,d);(0,a.le)(T)||""===T.text||this.skipTableElements||(u.revisionLength>0&&this.addRemovedRevisionInfo(u,T),this.isElementAddedToNewPara(d,T)||this.addRemovedNodes(T))}if((!this.owner.enableTrackChanges||this.skipTracking())&&u instanceof o.R5&&("Footnote"===u.footnoteType?this.removeFootnote(u):this.removeEndnote(u)),t>=h-(F-w))break;h-=F-w,this.documentHelper.layout.clearListElementBox(e.paragraph)}},e.prototype.deleteCommentWidgetInline=function(e){},e.prototype.clearFieldElementRevisions=function(e,t){for(var i=0;i<t.length;i++)for(var r=t[i],n=0;n<r.getRange().length;n++)if(r.getRange()[n]===e)for(var s=n;s<r.getRange().length;s){if(r.getRange()[n]instanceof o.V8&&1===r.getRange()[n].fieldType&&r.getRange()[n].fieldBegin===e){r.removeCurrentRevisionFromItem(r.getRange()[n]),0===r.getRange().length&&this.owner.revisions.remove(r);break}r.removeCurrentRevisionFromItem(r.getRange()[n])}},e.prototype.addRemovedRevisionInfo=function(e,t){for(var i=0;i<e.revisionLength;i++){var r=e.getRevision(i).revisionID;(0,a.le)(t)?e.removedIds.push(r):t.removedIds.push(r)}},e.prototype.removeEmptyLine=function(e){if(e.childWidgets.length>1)for(var t=0;t<e.childWidgets.length;t++)0===e.childWidgets[t].children.length&&e.childWidgets.length>1&&(e.childWidgets.splice(t,1),t--)},e.prototype.cloneListLevel=function(e){var t=new v.q(void 0);return this.copyListLevel(t,e),t},e.prototype.copyListLevel=function(e,t){(0,a.le)(t.paragraphFormat)||(e.paragraphFormat=new h.h(e),e.paragraphFormat.copyFormat(t.paragraphFormat)),(0,a.le)(t.characterFormat)||(e.characterFormat=new n.a(e,this.owner),e.characterFormat.copyFormat(t.characterFormat)),(0,a.le)(t.followCharacter)||(e.followCharacter=t.followCharacter),(0,a.le)(t.listLevelPattern)||(e.listLevelPattern=t.listLevelPattern),(0,a.le)(t.numberFormat)||(e.numberFormat=t.numberFormat),(0,a.le)(t.restartLevel)||(e.restartLevel=t.restartLevel),(0,a.le)(t.startAt)||(e.startAt=t.startAt)},e.prototype.cloneLevelOverride=function(e){var t=new H.J;return(0,a.le)(e.startAt)||(t.startAt=e.startAt),(0,a.le)(e.overrideListLevel)||(t.overrideListLevel=e.overrideListLevel),(0,a.le)(e.levelNumber)||(t.levelNumber=e.levelNumber),t},e.prototype.updateListParagraphs=function(){this.documentHelper.listParagraphs=[];for(var e=0;e<this.documentHelper.pages.length;e++)for(var t=this.documentHelper.pages[e].bodyWidgets[0],i=0;i<t.childWidgets.length;i++)this.updateListParagraphsInBlock(t.childWidgets[i])},e.prototype.updateListParagraphsInBlock=function(e){if(e instanceof o.ZH)(0,a.le)(e.paragraphFormat)||(0,a.le)(e.paragraphFormat.listFormat)||(0,a.le)(e.paragraphFormat.listFormat.listId)||(e.paragraphFormat.listFormat.listId>=0&&e.paragraphFormat.clearIndent(),(0,a.le)(this.documentHelper.listParagraphs)&&(this.documentHelper.listParagraphs=[]),this.documentHelper.listParagraphs.push(e));else if(e instanceof o.dm)for(var t=0;t<e.childWidgets.length;t++)for(var i=0;i<e.childWidgets[t].childWidgets.length;i++)for(var r=e.childWidgets[t].childWidgets[i],n=0;n<r.childWidgets.length;n++)this.updateListParagraphsInBlock(r.childWidgets[n])},e.prototype.onApplyList=function(e){var t=this.documentHelper.selection;this.setOffsetValue(this.documentHelper.selection),this.initHistory("ListFormat");var i=new m.s;(0,a.le)(e)||(i.listId=e.listId,i.nsid=e.nsid),this.documentHelper.owner.isShiftingEnabled=!0,t.isEmpty?(this.applyParaFormatProperty(t.start.paragraph,"listFormat",i,!1),this.isMeasureParaWidth=!0,this.layoutItemBlock(t.start.paragraph,!1),this.isMeasureParaWidth=!1):this.updateSelectionParagraphFormatting("listFormat",i,!1),this.documentHelper.owner.isShiftingEnabled=!0,this.documentHelper.layout.layoutWholeDocument(),this.documentHelper.owner.isShiftingEnabled=!1,this.startParagraph=void 0,this.endParagraph=void 0},e.prototype.applyBulletOrNumbering=function(e,t,i){var r=this.documentHelper.selection,n=r.paragraphFormat.getList(),s=!1,l=r.start;r.isForward||(l=r.end);var d=l.paragraph;if((0,a.le)(n)||-1!==n.listId||-1!==l.paragraph.paragraphFormat.listFormat.listId||(n=void 0),(0,a.le)(n)){for(var h=!1,c=r.getPreviousParagraphBlock(d);!(0,a.le)(c)&&c instanceof o.ZH;){if(c.paragraphFormat.listFormat&&-1!==c.paragraphFormat.listFormat.listId){d=c,h=!0;break}c=r.getPreviousParagraphBlock(c,!0)}if(h){for(;!(0,a.le)(d.previousWidget)&&d.previousWidget instanceof o.ZH&&-1!==d.previousWidget.paragraphFormat.listFormat.listId&&l.paragraph.paragraphFormat.firstLineIndent<Math.abs(d.previousWidget.paragraphFormat.firstLineIndent);)d=d.previousWidget;n=this.documentHelper.getListById(d.paragraphFormat.listFormat.listId),s=!0,n.levelOverrides.length>0&&(n=void 0)}if(!s){for(;!(0,a.le)(d.nextWidget)&&d.nextWidget instanceof o.ZH&&d.nextWidget.isEmpty()&&-1===d.nextWidget.paragraphFormat.listFormat.listId;)d=d.nextWidget;d.nextWidget&&d.nextWidget instanceof o.ZH&&-1!==d.nextWidget.paragraphFormat.listFormat.listId&&(d=d.nextWidget,n=this.documentHelper.getListById(d.paragraphFormat.listFormat.listId),s=!0)}}var p=void 0,g=-1,m=void 0,u=!1,H=!1;if(!(0,a.le)(n)&&-1===l.paragraph.paragraphFormat.listFormat.listId&&-1!==d.paragraphFormat.listFormat.listId&&d.paragraphFormat.listFormat.listLevelNumber>0&&d.paragraphFormat.listFormat.listLevel.listLevelPattern!==t&&(H=!0,n=void 0),!H&&-1!==d.paragraphFormat.listFormat.listId&&!(0,a.le)(d.paragraphFormat.listFormat.listLevel)){var C=d.paragraphFormat.listFormat;this.listFormatInfo={listNumberFormat:C.listLevel.numberFormat,listLevelPattern:C.listLevel.listLevelPattern,listCharacterFormat:C.listLevel.characterFormat.hasValue("fontFamily")?C.listLevel.characterFormat.fontFamily:d.characterFormat.fontFamily,listId:C.listId},(0,a.le)(d.previousWidget)&&C.listLevelNumber>0?this.listFormatInfo.listLevelNumber=this.listLevelNumber=l.paragraph.paragraphFormat.listFormat.listLevelNumber:this.listFormatInfo.listLevelNumber=this.listLevelNumber=C.listLevelNumber}if(!(0,a.le)(n)){g=(0,a.le)(d.previousWidget)&&d.paragraphFormat.listFormat.listLevelNumber>0?l.paragraph.paragraphFormat.listFormat.listLevelNumber:d.paragraphFormat.listFormat.listLevelNumber;var F=this.documentHelper.getListById(d.paragraphFormat.listFormat.listId);p=this.documentHelper.layout.getListLevel(F,g),g>0&&(m=this.documentHelper.layout.getListLevel(F,0),u=!(0,a.le)(m)&&g>
10&&r.start.isInSameListParagraph(r.end));var w=F.abstractList;if(w||(w=this.documentHelper.getAbstractListById(n.abstractListId)),0===w.levels.length&&(p=this.documentHelper.layout.getListLevel(F,d.paragraphFormat.listFormat.listLevelNumber)),s){if("Bullet"!==t&&p.listLevelPattern===t&&(p.numberFormat===e||-1!==p.numberFormat.indexOf(e))){r.paragraphFormat.listId=n.listId,r.paragraphFormat.listLevelNumber=g,r.paragraphFormat.setList(n);return}p=w.levels[0]}}if((0,a.le)(n)||!(0,a.le)(n)&&0===g&&(p.listLevelPattern!==t||p.numberFormat!==e||p.characterFormat.fontFamily!==i&&"Bullet"===p.listLevelPattern)){s=!1,n=new f.f,this.documentHelper.lists.length>0?n.listId=this.documentHelper.lists[this.documentHelper.lists.length-1].listId+1:n.listId=0;var w=new y.S;if(this.documentHelper.abstractLists.length>0?w.abstractListId=this.documentHelper.abstractLists[this.documentHelper.abstractLists.length-1].abstractListId+1:w.abstractListId=0,n.nsid=w.nsid,n.abstractListId=w.abstractListId,n.abstractList=w,this.documentHelper.abstractLists.push(w),"bullet"===e||"multiLevel"===e||"numbering"===e)this.addListLevels(w,e,r);else{var I=new v.q(w);I.listLevelPattern=t,I.numberFormat=e,"Bullet"!==t?I.startAt=1:I.characterFormat.fontFamily=i,I.paragraphFormat.leftIndent=36,I.paragraphFormat.firstLineIndent=-18,w.levels.push(I),r.paragraphFormat.listLevelNumber=0}r.paragraphFormat.setList(n)}else if(!u||(0,a.le)(n)||s)!(0,a.le)(n)&&s?r.paragraphFormat.setList(n):r.paragraphFormat.setList(void 0);else{var F=this.documentHelper.getListById(d.paragraphFormat.listFormat.listId),I=this.documentHelper.layout.getListLevel(F,g);if("Bullet"===t)I.numberFormat=e,I.characterFormat.fontFamily=i,I.listLevelPattern=t;else{I.listLevelPattern=t,I.characterFormat.fontFamily=i,I.characterFormat.fontFamilyAscii=i,I.characterFormat.fontFamilyBidi=i,I.characterFormat.fontFamilyFarEast=i,I.characterFormat.fontFamilyNonFarEast=i,I.startAt=1;var x=I.numberFormat.substring(I.numberFormat.length-1);I.numberFormat.length!==e.length&&g>0?I.numberFormat=e:e.substring(e.length-1)!==I.numberFormat.substring(I.numberFormat.length-1)&&(I.numberFormat=I.numberFormat.replace(x,e.substring(e.length-1)))}r.paragraphFormat.setList(F)}},e.prototype.addListLevels=function(e,t,i){for(var r=[String.fromCharCode(61558),String.fromCharCode(61656),String.fromCharCode(61607),String.fromCharCode(61623),String.fromCharCode(61608)],o=e.levels.length;o<9;o++){var n=new v.q(e);if(t.match("bullet"))n.listLevelPattern="Bullet",n.numberFormat=r[o<5?o%5:o%5+1],n.characterFormat.fontFamily=o<3||5===o?"Wingdings":"Symbol";else{if(t.match("multiLevel")){for(var s=0;s<o+1;s++)n.numberFormat+="%"+(s+1).toString()+".";n.listLevelPattern="Number"}else n.numberFormat="%"+(o+1).toString()+")",n.listLevelPattern=o%3==0?"Number":o%3==1?"LowLetter":"LowRoman";n.startAt=1,n.restartLevel=o}0===o?n.paragraphFormat.leftIndent=36:n.paragraphFormat.leftIndent=36*o,n.paragraphFormat.firstLineIndent=-18,e.levels.push(n),i.paragraphFormat.listLevelNumber=o}},e.prototype.insertPageBreak=function(){this.owner.isReadOnlyMode||this.documentHelper.selection.start.paragraph.isInHeaderFooter||this.documentHelper.selection.isInShape||(this.initComplexHistory("PageBreak"),this.isSkipOperationsBuild=this.owner.enableCollaborativeEditing,this.onEnter("PageBreak"),this.isSkipOperationsBuild=!1,this.editorHistory&&!(0,a.le)(this.editorHistory.currentHistoryInfo)&&this.editorHistory.updateComplexHistory(),this.owner.enableAutoFocus&&this.selection.checkForCursorVisibility())},e.prototype.insertColumnBreak=function(){if(!this.owner.isReadOnlyMode&&!this.documentHelper.selection.start.paragraph.isInsideTable&&!this.documentHelper.selection.start.paragraph.isInHeaderFooter&&!this.documentHelper.selection.isInShape){this.initComplexHistory("ColumnBreak");var e=this.documentHelper.selection.start.paragraph;if(this.viewer instanceof x._&&e.bodyWidget.sectionFormat.columns.length>1){var t=this.documentHelper.layout.getBodyWidget(e.bodyWidget,!1);(0,a.le)(t.nextRenderedWidget)||t.page!==t.nextRenderedWidget.page||this.documentHelper.layout.combineMultiColumn(t)}this.insertTextInternal("\x0e",!1),this.editorHistory&&!(0,a.le)(this.editorHistory.currentHistoryInfo)&&this.editorHistory.updateComplexHistory(),this.owner.enableAutoFocus&&this.selection.checkForCursorVisibility()}},e.prototype.splitTableBasedonBreak=function(e,t){var i,r=new o.a3,n=this.documentHelper.layout.getParentTable(e.start.paragraph);n=n.combineWidget(this.owner.viewer);var s=!1;0===e.start.paragraph.associatedCell.rowIndex&&(s=!0);var l=new o.ZH;if(!t){r.text="\f";var d=new o.z7(l);d.children.push(r),r.line=d,l.childWidgets.push(d)}var h=n.previousRenderedWidget;s?i=n:(i=this.splitTable(n,e.start.paragraph.associatedCell.ownerRow),this.documentHelper.layout.layoutBodyWidgetCollection(i.index,i.containerWidget,i,!1),i=i.getSplitWidgets().pop());var c=0;if(((0,a.le)(h)||!h.bodyWidget.equals(i.bodyWidget))&&s?(c=0,l.index=0):(c=i.indexInOwner+1,l.index=i.index+1),i.containerWidget.childWidgets.splice(c,0,l),l.containerWidget=i.containerWidget,this.updateNextBlocksIndex(l,!0),this.documentHelper.layout.layoutBodyWidgetCollection(l.index,l.containerWidget,l,!1),i=l,t||e.selectParagraphInternal(i,!0),t)return i},e.prototype.onEnter=function(e){this.handledEnter=!0;var t,i=this.documentHelper.selection,r=!1,n=!1;if(((0,a.le)(i.start.paragraph.paragraphFormat.baseStyle)||"Normal"===i.start.paragraph.paragraphFormat.baseStyle.name||"Normal (Web)"===i.start.paragraph.paragraphFormat.baseStyle.name)&&((t=new I.jP(void 0)).cloneFormat(this.selection.characterFormat),i.start.paragraph.lastChild.children[i.start.paragraph.lastChild.children.length-1]instanceof o.R5&&(t.baselineAlignment="Normal")),i.isEmpty&&i.start.paragraph.isInsideTable&&(i.start.paragraph.associatedCell.ownerTable.isInsideTable||1===i.startPage)&&0===i.start.paragraph.associatedCell.ownerTable.index&&0===i.start.paragraph.associatedCell.columnIndex&&0===i.start.paragraph.associatedCell.rowIndex&&0===i.start.paragraph.index&&0===i.start.offset&&(r=!0),!this.isXmlMapped){if(i.isEmpty){var s=i.getHyperlinkField();if(!(0,a.le)(s)){i.fireRequestNavigate(s);return}var l=i.start.paragraph;if(l.isEmpty()&&-1!==l.paragraphFormat.listFormat.listId&&!r){this.onApplyListInternal(this.documentHelper.getListById(l.paragraphFormat.listFormat.listId),l.paragraphFormat.listFormat.listLevelNumber-1);return}var d=i.start.currentWidget.getInline(i.start.offset,0).element;d instanceof o.aQ&&1===d.bookmarkType&&!(0,a.le)(d.properties)&&d.properties.hasOwnProperty("isAfterParagraphMark")&&d.properties.isAfterParagraphMark&&(i.start.setPositionParagraph(d.line,d.line.getOffset(d,0)),i.end.setPositionInternal(i.start))}var h=this.checkAndRemoveComments();this.updateInsertPositionForRtl("\n"),this.initHistory("Enter");var c=!0;i.isEmpty||i.isImageSelected||(c=this.removeSelectedContents(i));var p=!1;if(c){if(i.isImageSelected&&!i.isForward){var g=i.start;i.start=i.end,i.end=g}if(i.owner.isShiftingEnabled=!0,this.updateInsertPosition(),i.start.paragraph.isInsideTable&&!(0,a.le)(e)&&"PageBreak"===e)p=!0,this.splitTableBasedonBreak(i,!1);else{var m=this.selection.getParagraphInfo(i.start),u=this.selection.getHierarchicalIndex(m.paragraph,m.offset.toString()),f=this.copyInsertFormat(this.selection.start.paragraph.characterFormat,!0),y=i.start.paragraph,v=i.start.currentWidget;this.owner.enableTrackChanges&&v===y.lastChild&&i.start.offset===i.getLineLength(v)&&!y.isContainsShapeAlone()&&this.retrieveRevisionByType(y.characterFormat,"Deletion")&&(n=!0);var H=this.splitParagraphInternal(i,y,v,i.start.offset,f,r,n);if(this.setPositionForCurrentIndex(i.start,u),!(0,a.le)(e)&&("PageBreak"===e||"ColumnBreak"===e)){var C=i.start.paragraph,F=new o.a3;switch(e){case"PageBreak":F.text="\f";break;case"ColumnBreak":F.text="\x0e"}var w=i.start.currentWidget;F.line=w,w.children.push(F),this.owner.enableTrackChanges&&C.characterFormat.revisionLength>0&&this.insertRevision(F,"Insertion"),this.documentHelper.layout.layoutBodyWidgetCollection(C.index,C.containerWidget,C,!1),H&&i.selectParagraphInternal(H,!0)}}var x=i.start.paragraph.nextWidget;(0,a.le)(x)&&(x=i.getNextRenderedBlock(i.start.paragraph)),p||i.selectParagraphInternal(r||x instanceof o.dm?i.start.paragraph:x,!0),r||n||this.updateEndPosition(),!(0,a.le)(e)&&this.editorHistory&&this.owner.editorHistoryModule.updateHistory(),this.reLayout(i),!(0,a.le)(i.start.paragraph.previousRenderedWidget)&&i.start.paragraph.previousRenderedWidget.containerWidget instanceof o.VB&&i.start.paragraph.containerWidget instanceof o.VB&&i.start.paragraph.previousRenderedWidget.containerWidget.page.index!==i.start.paragraph.containerWidget.page.index&&this.documentHelper.layout.reLayoutParagraph(i.start.paragraph,0,0);var b=this.selection.start.paragraph.containerWidget.firstChild;if(!(0,a.le)(b)){b.isChangeDetected=!1;for(var W=b.nextRenderedWidget;this.owner.isSpellCheck&&!(0,a.le)(W);)(b=W).isChangeDetected=!1,W=b.nextRenderedWidget}if(!p){var l=i.start.paragraph.previousWidget;!(0,a.le)(l)&&!l.isEmpty()&&l.lastChild.children[l.lastChild.children.length-1]instanceof o.a3&&this.checkAndConvertToHyperlink(i,!0,l)}}!(0,a.le)(t)&&!(0,a.le)(i.start.paragraph)&&i.start.paragraph.isEmpty()&&!r&&(this.selection.isRetrieveFormatting=!0,this.selection.characterFormat.cloneFormat(t),this.selection.isRetrieveFormatting=!1),this.documentHelper.layout.islayoutFootnote=!1,this.updateHistoryForComments(h),this.handledEnter=!1}},e.prototype.removeHeadingFormat=function(e,t){e.paragraphFormat.baseStyle&&"Normal"!=e.paragraphFormat.baseStyle.name&&"Header"!=e.paragraphFormat.baseStyle.name&&"Footer"!=e.paragraphFormat.baseStyle.name&&(t.paragraphFormat.copyFormat(e.paragraphFormat),t.characterFormat.copyFormat(e.characterFormat),t.characterFormat.removedIds=[],this.documentHelper.layout.reLayoutParagraph(e,0,0))},e.prototype.splitParagraphInternal=function(e,t,i,r,n,s,l){var d,h=0,c=t.index,p=t;for(p.isChangeDetected=0===r;this.owner.isSpellCheck&&!(0,a.le)(p.nextRenderedWidget);)(p=p.nextRenderedWidget).isChangeDetected=!0;var g=new o.ZH,m=new o.z7(g),u=!1,f=!1;if(g.childWidgets.push(m),g.paragraphFormat.ownerBase=g,t.contentControlProperties&&((r!==e.getLineLength(i)||t.nextRenderedWidget&&t.nextRenderedWidget instanceof o.ZH&&t.nextRenderedWidget.ischildContentControl)&&(g.ischildContentControl=!0),!(0,a.le)(g)&&g.ischildContentControl&&(g.contentControlProperties=t.contentControlProperties)),i!==t.lastChild||r!==e.getLineLength(i)||t.isContainsShapeAlone()){if(g.paragraphFormat.copyFormat(t.paragraphFormat),g.characterFormat.copyFormat(n),g.characterFormat.removedIds=[],!(r>0)&&i.isFirstLine()||t.isContainsShapeAlone()){if(this.owner.enableTrackChanges){var y=t.firstChild.children[0];(0,a.le)(y)?(0,a.le)(y)&&(h++,c++):(g.characterFormat.clearRevision(),f=!0)}}else t=t.combineWidget(this.owner.viewer),this.moveInlines(t,g,0,0,t.firstChild,r,i),u=!0,this.owner.enableTrackChanges&&(f=!0);t=t.getSplitWidgets()[0]}else s||(t.paragraphFormat.baseStyle&&"Normal"!==t.paragraphFormat.baseStyle.name&&t.paragraphFormat.baseStyle.next instanceof b.wk?(t.paragraphFormat.baseStyle.name===t.paragraphFormat.baseStyle.next.name?(g.paragraphFormat.copyFormat(t.paragraphFormat),g.characterFormat.copyFormat(t.characterFormat)):g.paragraphFormat.baseStyle=t.paragraphFormat.baseStyle.next,this.selection.skipFormatRetrieval=!1):(g.paragraphFormat.copyFormat(t.paragraphFormat),g.characterFormat.copyFormat(t.characterFormat)),!(t.lastChild.children.length>0)||t.firstChild.children[0]instanceof o.no||t.characterFormat.copyFormat(t.lastChild.children[t.lastChild.children.length-1].characterFormat)),g.characterFormat.removedIds=[],this.owner.enableTrackChanges?(f=!0,s?(g.characterFormat.clearRevision(),h++,c++):this.retrieveRevisionByType(t.characterFormat,"Deletion")?(h++,c++):(t=t.combineWidget(this.owner.viewer),this.moveInlines(t,g,0,0,t.firstChild,r,t.last
1Child),this.removeHeadingFormat(t,g))):t.characterFormat.revisionLength>0?(t=t.combineWidget(this.owner.viewer),this.moveInlines(t,g,0,0,t.firstChild,r,t.lastChild),this.removeHeadingFormat(t,g)):(h++,c++);if(s?(h=0,c=0,(d=t.associatedCell.ownerTable.containerWidget).childWidgets.splice(0,0,g),g.containerWidget=d,g.index=0,this.updateNextBlocksIndex(g,!0)):(h+=t.getIndex(),(d=t.containerWidget).childWidgets.splice(h,0,g),g.containerWidget=d,g.index=c,this.updateNextBlocksIndex(g,!0)),(l||s)&&(this.owner.selectionModule.start.setPositionParagraph(g.firstChild,0),this.owner.selectionModule.end.setPositionParagraph(g.firstChild,1),(0,a.le)(this.editorHistory)||(0,a.le)(this.editorHistory.currentBaseHistoryInfo)||(this.editorHistory.currentBaseHistoryInfo.selectionStart=this.owner.selectionModule.startOffset,this.editorHistory.currentBaseHistoryInfo.selectionEnd=this.owner.selectionModule.startOffset,this.editorHistory.currentBaseHistoryInfo.insertPosition=this.owner.selectionModule.startOffset,this.editorHistory.currentBaseHistoryInfo.endPosition=this.owner.selectionModule.endOffset)),f&&this.insertRevision(g.characterFormat,"Insertion"),u?this.updateRevisionForSplittedPara(g,t):this.splitRevisionsAndViewBasedOnUntrackedContent(g.characterFormat),!(0,a.le)(d.containerWidget)&&d.containerWidget instanceof o.tf||d instanceof o.nb&&!(0,a.le)(d.bodyWidget)&&d.bodyWidget.containerWidget instanceof o.tf){var v=this.documentHelper.textHelper.getParagraphMarkSize(g.characterFormat).Height;d instanceof o.nb?(d.bodyWidget.height+=v,d.bodyWidget.containerWidget.height+=v):(d.containerWidget.height+=v,d.height+=v)}return g.previousWidget instanceof o.ZH&&g.previousWidget.paragraphFormat.contextualSpacing&&!(0,a.le)(g.paragraphFormat)&&!(0,a.le)(g.previousWidget.paragraphFormat.baseStyle)&&!(0,a.le)(g.paragraphFormat.baseStyle)&&g.previousWidget.paragraphFormat.baseStyle.name===g.paragraphFormat.baseStyle.name&&this.documentHelper.layout.reLayoutParagraph(g.previousWidget,g.previousWidget.lastChild.indexInOwner,0),this.documentHelper.layout.layoutBodyWidgetCollection(c,d,g,!1),g},e.prototype.updateNextBlocksIndex=function(e,t){var i=e.containerWidget.childWidgets.indexOf(e)+1;if(e.containerWidget instanceof o.VB&&!(e.containerWidget.containerWidget instanceof o.tf)){if(e.containerWidget.page.bodyWidgets.length>1&&e.containerWidget.sectionFormat.numberOfColumns>1)for(var r=e.containerWidget.indexInOwner,n=this.documentHelper.pages.indexOf(e.containerWidget.page);n<this.documentHelper.pages.length;n++){for(var s=this.documentHelper.pages[n],l=0;l<s.bodyWidgets.length;l++)if(s.bodyWidgets[l].indexInOwner===r){for(var d=i;d<s.bodyWidgets[l].childWidgets.length;d++){var h=s.bodyWidgets[l].childWidgets[d];this.updateIndex(h,t)}i=0,!(0,a.le)(s.bodyWidgets[l].nextRenderedWidget)&&s.bodyWidgets[l].nextRenderedWidget.sectionIndex===s.bodyWidgets[l].sectionIndex&&r++}r!==e.containerWidget.indexInOwner&&!(0,a.le)(s.bodyWidgets[s.bodyWidgets.length-1].nextRenderedWidget)&&s.bodyWidgets[s.bodyWidgets.length-1].nextRenderedWidget.sectionFormat.columns.length>1&&(r=0)}else if(e.containerWidget.page.bodyWidgets.length>1){for(var c=e.containerWidget.index,n=this.documentHelper.pages.indexOf(e.containerWidget.page);n<this.documentHelper.pages.length;n++)for(var s=this.documentHelper.pages[n],l=0;l<s.bodyWidgets.length;l++)if(s.bodyWidgets[l].index===c){for(var d=i;d<s.bodyWidgets[l].childWidgets.length;d++){var h=s.bodyWidgets[l].childWidgets[d];this.updateIndex(h,t)}i=0}}else for(var c=e.containerWidget.index,l=this.documentHelper.pages.indexOf(e.containerWidget.page);l<this.documentHelper.pages.length;l++){var s=this.documentHelper.pages[l];if(s.bodyWidgets[0].index!==c)return;for(var d=i;d<s.bodyWidgets[0].childWidgets.length;d++){var h=s.bodyWidgets[0].childWidgets[d];this.updateIndex(h,t)}i=0}}else if(e.containerWidget instanceof o.nb)for(var p=e.containerWidget.getSplitWidgets(),g=p.indexOf(e.containerWidget),m=g;m<p.length;m++){for(var u=p[m].childWidgets,f=i;f<u.length;f++)this.updateIndex(u[f],t);g=0,i=0}else if(e.containerWidget instanceof o.BC)for(var n=i;n<e.containerWidget.childWidgets.length;n++){var y=e.containerWidget.childWidgets[n];y.rowIndex===e.containerWidget.index&&this.updateIndex(y,t)}else if(e.containerWidget instanceof o.dm)for(var n=i;n<e.containerWidget.childWidgets.length;n++){var v=e.containerWidget.childWidgets[n];this.updateIndex(v,t);for(var l=0;l<v.childWidgets.length;l++)v.childWidgets[l].rowIndex=v.index}else if(e.containerWidget instanceof o.NB||e.containerWidget instanceof o.yw||!(0,a.le)(e.containerWidget)&&e.containerWidget.containerWidget instanceof o.tf){if(e.containerWidget.containerWidget instanceof o.tf&&"Endnote"===e.containerWidget.containerWidget.footNoteType&&e===e.containerWidget.lastChild)for(var H=e.containerWidget.index,C=this.documentHelper.pages.indexOf(e.containerWidget.containerWidget.page),n=C+1;n<this.documentHelper.pages.length;n++){var s=this.documentHelper.pages[n];if(!s.endnoteWidget||!(s.endnoteWidget.bodyWidgets.length>0)||s.endnoteWidget.bodyWidgets[0].index!==H)return;for(var l=0;l<s.endnoteWidget.bodyWidgets[0].childWidgets.length;l++){var h=s.endnoteWidget.bodyWidgets[0].childWidgets[l];this.updateIndex(h,t)}}else for(var n=i;n<e.containerWidget.childWidgets.length;n++){var F=e.containerWidget.childWidgets[n];this.updateIndex(F,t)}}},e.prototype.updateIndex=function(e,t){t?e.index++:e.index--},e.prototype.updateEndPosition=function(){var e=this.documentHelper.selection;this.editorHistory&&!(0,a.le)(this.editorHistory.currentBaseHistoryInfo)&&this.updateHistoryPosition(e.start,!1)},e.prototype.checkAndRemoveComments=function(e,t){var i=this.selection;if(i.isEmpty||this.owner.enableTrackChanges&&!t||e)return[];var r=!1,o=this.getSelectedComments();if(o.commentEndInfo.length>0||o.commentStartInfo.length>0){r||(r=!0,this.initComplexHistory("RemoveComment"));var n=this.selection.start,s=this.selection.end;this.selection.isForward||(n=this.selection.end,s=this.selection.start);for(var l=this.selection.getParagraphInfo(n),d=this.selection.getParagraphInfo(s),h=0;h<o.commentEndInfo.length;h++){var c=o.commentEndInfo[h].comment,p=c.commentStart,g=c.commentEnd,m=this.selection.getParagraphInfoInternal(p.line,p.line.getOffset(p,0)),u=this.selection.getParagraphInfoInternal(g.line,g.line.getOffset(g,0));if(d.paragraph===u.paragraph){if(c.replyComments.length>0)for(var f=0;f<c.replyComments.length;f++){var y=c.replyComments[f];!(0,a.le)(y.commentEnd)&&d.offset--}d.offset--}if(l.paragraph===m.paragraph||d.paragraph===m.paragraph){var v=l.paragraph===m.paragraph&&m.offset<l.offset;if(c.replyComments.length>0)for(var f=0;f<c.replyComments.length;f++){var y=c.replyComments[f];if(!(0,a.le)(y.commentStart)){var H=this.selection.getParagraphInfoInternal(y.commentStart.line,y.commentStart.line.getOffset(y.commentStart,0));l.paragraph===m.paragraph&&H.offset<l.offset&&l.offset--,d.paragraph===m.paragraph&&d.offset--}}v&&l.offset--,d.paragraph===m.paragraph&&d.offset--}this.deleteCommentInternal(c)}if(o.commentStartInfo.length>0)for(var C=0;C<o.commentStartInfo.length;C++)o.commentStartInfo[C].line.paragraph.equals(d.paragraph)&&d.offset--,this.removeInline(o.commentStartInfo[C]);var F=i.getLineInfoBasedOnParagraph(l.paragraph,l.offset);i.start.setPositionFromLine(F.line,F.offset);var w=i.getLineInfoBasedOnParagraph(d.paragraph,d.offset);i.end.setPositionFromLine(w.line,w.offset)}return o.commentStartInfo},e.prototype.updateHistoryForComments=function(e){if(this.editorHistory&&!(0,a.le)(this.editorHistory.currentHistoryInfo)&&"RemoveComment"===this.editorHistory.currentHistoryInfo.action){if(!(0,a.le)(e))for(var t=0;t<e.length;t++)this.initInsertInline(e[t],!1);this.editorHistory.currentHistoryInfo.endPosition=this.selection.startOffset,this.editorHistory.updateComplexHistory()}},e.prototype.removeEmptyParagraph=function(){var e=this.documentHelper.selection.start.paragraph;if(e.isEmpty()&&this.selection.isEmpty){var t=e.containerWidget,i=t.previousRenderedWidget,r=t.nextRenderedWidget;if(t instanceof o.VB&&1==t.childWidgets.length){if(t.equals(i))this.onBackSpace();else{if(!t.equals(r))return;this.delete()}}else e.isInsideTable&&void 0==e.nextWidget?this.onBackSpace():this.delete()}},e.prototype.onBackSpace=function(){this.isDeleteOrBackSpace=!0;var e=this.documentHelper.selection;if("List"!=e.contextType&&(e.skipFormatRetrieval=!0),!e.isEmpty){var t=e.bookmarks;t.length>0&&this.extendSelectionToBookmarkStart(t)}if(e.isEmpty)this.singleBackspace(e,!1);else{if(this.owner.enableTrackChanges&&this.canSkipDeleteTrack(e))return;if(!e.isForward){var i=e.start.getHierarchicalIndexInternal(),r=e.end.getHierarchicalIndexInternal();e.start.validateBackwardFieldSelection(i,r)}var o=this.checkAndRemoveComments();this.initHistory("BackSpace");var n=this.deleteSelectedContents(e,!0);if(e.skipFormatRetrieval=!1,this.editorHistory&&this.editorHistory.currentBaseHistoryInfo&&(n?this.editorHistory.currentBaseHistoryInfo=void 0:(this.checkEndPosition(e)&&this.updateHistoryPosition(e.end,!1),this.isSkipOperationsBuild=!(0,a.le)(this.alertDialog),this.reLayout(e),this.isSkipOperationsBuild=!1,this.insertSpaceInFormField())),this.editorHistory&&!(0,a.le)(this.editorHistory.currentHistoryInfo)){for(var s=0;s<o.length;s++)this.initInsertInline(o[s],!1);this.editorHistory.currentHistoryInfo.endPosition=this.selection.startOffset,this.editorHistory.updateComplexHistory()}this.owner.isSpellCheck&&(this.documentHelper.triggerSpellCheck=!1)}this.isDeleteOrBackSpace=!1,this.documentHelper.layout.islayoutFootnote=!1,this.updateXmlMappedContentControl()},e.prototype.canSkipDeleteTrack=function(e){var t=e.start,i=e.end;if(e.start.isExistBefore(e.end)||(t=e.end,i=e.start),!t.paragraph.isInsideTable&&i.paragraph.isInsideTable||t.paragraph.isInsideTable&&i.paragraph.isInsideTable&&this.documentHelper.layout.getParentCell(t.paragraph.associatedCell)===this.documentHelper.layout.getParentCell(i.paragraph.associatedCell)&&t.paragraph.associatedCell!==i.paragraph.associatedCell&&t.paragraph.associatedCell.ownerTable!==i.paragraph.associatedCell.ownerTable){var r=t.offset===e.getStartOffset(t.paragraph)&&e.start.currentWidget.isFirstLine(),o=e.getContainerCell(i.paragraph.associatedCell).ownerTable,n=o.childWidgets[o.childWidgets.length-1];if(!r&&!e.containsRow(n,i.paragraph.associatedCell))return!0}return!1},e.prototype.insertRemoveBookMarkElements=function(e){var t=!1,i=!1;if(!this.isRemoteAction)for(var r=0;r<this.removedBookmarkElements.length;r++){var o=this.removedBookmarkElements[r];if(0===o.bookmarkType){if(o&&o.reference&&-1!==this.removedBookmarkElements.indexOf(o.reference)){var n=this.removedBookmarkElements.indexOf(o.reference),s=this.removedBookmarkElements.indexOf(o);this.removedBookmarkElements.splice(n,1),this.removedBookmarkElements.splice(s,1),r--}else this.editorHistory.currentBaseHistoryInfo&&!e&&(this.initComplexHistory(this.editorHistory.currentBaseHistoryInfo.action),this.editorHistory.updateHistory()),this.initInsertInline(o.clone(),void 0,!0),i=!0}else if(o&&o.reference&&-1!==this.removedBookmarkElements.indexOf(o.reference)){var n=this.removedBookmarkElements.indexOf(o.reference),s=this.removedBookmarkElements.indexOf(o);this.removedBookmarkElements.splice(n,1),this.removedBookmarkElements.splice(s,1),r--}else this.editorHistory.currentBaseHistoryInfo&&!e&&(this.initComplexHistory(this.editorHistory.currentBaseHistoryInfo.action),this.editorHistory.updateHistory()),this.initInsertInline(o.clone(),void 0,!0),i=!0}return i&&this.editorHistory.currentHistoryInfo&&0===this.removedContentControlElements.length&&0===this.removedEditRangeStartElements.length&&0===this.removedEditRangeEndElements.length&&(this.editorHistory.updateComplexHistory(),t=!0),this.removedBookmarkElements=[],t},e.prototype.insertRemoveContentControlElements=function(e){var t=!1;if(!this.isRemoteAction)for(var i=0;i<this.removedContentControlElements.length;i++){var r=this.removedContentControlElements[i];if(0===r.type){if(r&&r.reference&&-1!==this.removedContentControlElements.indexOf(r.reference)){var o=this.removedContentControlElements.indexOf(r.reference),n=this.removedContentControlElements.indexOf(r);this.removedContentControlElements.splice(o,1),this.removedContentControlElements.splice(n,1),i--}else this.editorHistory.currentBaseHistoryInfo&&!e&&(this.initComplexHistory(this.editorHistory.currentBaseHistoryInfo.action),this.editorHistory.updateHistory()),this.initInsertInline(r.clone(),void 0,!0),this.editorHistory.currentHistoryInfo&&i===this.removedContentControlElements.length-1&&0===this.removedBookmarkElements.length&&0===this.removedEditRangeStartElements.length&&0===this.removedEditRangeEndElements.length&&(this.editorHistory.updateComplexHistory(),t=!0)}else if(r&&r.reference&&-1!==this.removedContentControlElements.indexOf(r.reference)){var o=this.removedContentControlElements.indexOf(r.reference),n=this.removedContentControlElements.indexOf(r);this.removedContentControlElements.splice(o,1),this.removedContentControlElements.splice(n,1),i--}else this.editorHistory.currentBaseHistoryInfo&&!e&&(this.initComplexHistory(this.editorHistory.currentBaseHistoryInfo.action),this.editorHistory.updateHistory()),this.initInsertInline(r.clone(),void 0,!0),this.editorHistory.currentHistoryInfo&&i===this.removedContentControlElements.length-1&&0===this.removedBookmarkElements.length&&0===this.removedEditRangeStartElements.length&&0===this.removedEditRangeEndElements.length&&(this.editorHistory.updateComplexHistory(),t=!0)}return this.removedContentControlElements=[],t},e.prototype.insertRemovedEditRangeEndElements=function(e){var t=!1;if(!this.isRemoteAction)for(var i=this.removedEditRangeEndElements.length-1;i>=0;i--){var r=this.removedEditRangeEndElements[i];if(r&&-1!==this.removedEditRangeStartElements.indexOf(r.editRangeStart)){var o=this.removedEditRangeEndElements.indexOf(r),n=this.removedEditRangeStartElements.indexOf(r.editRangeStart);this.removedEditRangeEndElements.splice(o,1),this.removedEditRangeStartElements.splice(n,1),i--}else{this.editorHistory.currentBaseHistoryInfo&&!e&&(this.initComplexHistory(this.editorHistory.currentBaseHistoryInfo.action),this.editorHistory.updateHistory()),this.initInsertInline(r.clone(),void 0,!0);var s=this.selection.start.paragraph.getInline(this.selection.start.offset,0);s.element.editRangeStart.editRangeEnd=s.element,this.editorHistory.currentHistoryInfo&&0===i&&0===this.removedContentControlElements.length&&0===this.removedEditRangeStartElements.length&&0===this.removedBookmarkElements.length&&(this.editorHistory.updateComplexHistory(),t=!0)}}return this.removedEditRangeEndElements=[],t},e.prototype.insertRemovedEditRangeStartElements=function(e){var t=!1;if(!this.isRemoteAction)for(var i=0;i<this.removedEditRangeStartElements.length;i++){var r=this.removedEditRangeStartElements[i];if(r&&-1!==this.removedEditRangeEndElements.indexOf(r.editRangeEnd)){var o=this.removedEditRangeEndElements.indexOf(r.editRangeEnd),n=this.removedEditRangeStartElements.indexOf(r);this.removedEditRangeEndElements.splice(o,1),this.removedEditRangeStartElements.splice(n,1),i--}else{this.editorHistory.currentBaseHistoryInfo&&!e&&(this.initComplexHistory(this.editorHistory.currentBaseHistoryInfo.action),this.editorHistory.updateHistory()),this.initInsertInline(r.clone(),void 0,!0);var s=this.selection.start.paragraph.getInline(this.selection.start.offset,0);s.element.editRangeEnd.editRangeStart=s.element,this.editorHistory.currentHistoryInfo&&i===this.removedEditRangeStartElements.length-1&&0===this.removedContentControlElements.length&&0===this.removedBookmarkElements.length&&0===this.removedEditRangeEndElements.length&&(this.editorHistory.updateComplexHistory(),t=!0)}}return this.removedEditRangeStartElements=[],t},e.prototype.deleteSelectedContents=function(e,t){var i=this.deleteSelectedContentInternal(e,t,e.start,e.end),r=e.getTextPosBasedOnLogicalIndex(e.editPosition);return e.selectContent(r,!0),i},e.prototype.removeWholeElement=function(e){this.initHistory("BackSpace"),this.deleteSelectedContents(e,!0),this.checkEndPosition(e)&&this.updateHistoryPosition(e.end,!1),this.reLayout(e)},e.prototype.getSelectedComments=function(){for(var e=this.documentHelper.comments,t=[],i=[],r=0;r<e.length;r++){var o=e[r],n=o.commentEnd,s=o.commentStart;if(!(0,a.le)(n)&&this.selection.isElemen
1tInSelection(n,!0))t.push(n);else if(!(0,a.le)(s)&&this.selection.isElementInSelection(s,!1)){i.push(s);for(var l=0;l<o.replyComments.length;l++)o.replyComments[l].commentStart&&i.push(o.replyComments[l].commentStart)}}return{commentStartInfo:i,commentEndInfo:t}},e.prototype.isEditRangeAtListBoundary=function(e){if(e instanceof o.Cw){var t=e.line.paragraph;if(!(t.paragraphFormat.listFormat&&-1!==t.paragraphFormat.listFormat.listId))return!1;for(var i=e.previousNode;i&&(i instanceof o.aQ||i instanceof o.h||i instanceof o.Xw||i instanceof o.V8||i instanceof o.Cw||i instanceof o.jn);)i=i.previousNode;return i instanceof o.no||(o.a3,!1)}return e instanceof o.jn&&e.previousNode instanceof o.no},e.prototype.singleBackspace=function(e,t){var i,r=this.editorHistory;if(r&&!t&&!r.canRedo()&&r.canUndo()){var n=r.undoStack[r.undoStack.length-1],l=this.selection.getParagraphInfo(e.start),d=this.selection.getParagraphInfo(e.end);if("AutoFormatHyperlink"===n.action&&n.insertPosition===this.selection.getHierarchicalIndex(l.paragraph,l.offset.toString())&&n.endPosition===this.selection.getHierarchicalIndex(d.paragraph,d.offset.toString())){r.undo();return}}for(var h=!1,c=e.start.paragraph,p=e.start.currentWidget,g=e.start.offset,m=0,u=p.getInline(g,m),f=u.element,y=!1,v=g,H=!1;f instanceof o.Xw;){var C=f;if(f=f.previousNode,(0,a.le)(f)&&(f=i),(0,a.le)(f)||0!=f.commentType?f instanceof o.no&&(f=void 0):i=f.previousNode,f&&(v=f.length),0===C.commentType&&((0,a.le)(f)||!(f instanceof o.Xw))){(0,a.le)(f)?(f=C,v=0):v=f.length,H=!0;break}1===C.commentType&&(y||(this.initComplexHistory("RemoveComment"),y=!0),this.isSkipOperationsBuild=this.owner.enableCollaborativeEditing,this.deleteCommentInternal(C.comment),this.isSkipOperationsBuild=!1,H=!0)}if((0,a.le)(f)||!f.characterFormat.hidden){if(H){if((0,a.le)(f)){var F=c.childWidgets[0];e.start.setPositionParagraph(F,0),e.end.setPositionParagraph(F,0)}else c=f.line.paragraph,g=f.line.getOffset(f,v),e.start.setPositionParagraph(f.line,g),e.end.setPositionParagraph(f.line,g)}if(f instanceof o.h){if(1===f.type){f.contentControlProperties.lockContents?this.selection.selectContentControl(f.reference):this.selection.selectContentControlInternal(f.reference);return}if(0===f.type&&f.contentControlProperties.lockContentControl)return}var w=this.selection.currentContentControl;if(!w||!w.contentControlProperties||!w.contentControlProperties.lockContents){if(this.selection.isInlineFormFillMode()){if(f instanceof o.V8&&2===f.fieldType)return;if(1===this.getFieldResultText().length){this.selection.selectFieldInternal(this.selection.getCurrentFormField()),this.insertTextInternal(this.documentHelper.textHelper.repeatChar(this.documentHelper.textHelper.getEnSpaceCharacter(),5),!0),this.selection.selectTextElementStartOfField(this.selection.getCurrentFormField());return}}if(m=u.index,f instanceof o.a3&&(f.ignoreOnceItems=[]),f instanceof o.V8&&2===f.fieldType&&s.o_.isLinkedFieldCharacter(f)){var I=f.fieldBegin,x=f.fieldEnd;I.nextNode instanceof o.aQ&&I.nextNode.reference&&(x=I.nextNode.reference),e.start.setPositionParagraph(I.line,I.line.getOffset(I,0)),e.end.setPositionParagraph(x.line,x.line.getOffset(x,0)+1),e.fireSelectionChanged(!0);return}if(!this.owner.enableTrackChanges&&f instanceof o.R5&&("Footnote"===f.footnoteType?this.removeFootnote(f):this.removeEndnote(f)),f&&(f instanceof o.h||f.previousNode instanceof o.h)){if(f instanceof o.h&&f.previousNode&&!(f.previousElement instanceof o.no)&&(c=(f=f.previousNode).line.paragraph,g=f.line.getOffset(f,f.length)),f&&1===f.length&&f.nextNode instanceof o.h&&f.previousNode instanceof o.h&&!this.documentHelper.isFormFillProtectedMode){var b=f.previousNode,W=f.nextNode;if(!b.contentControlProperties.lockContentControl){e.start.setPositionParagraph(b.line,b.line.getOffset(b,0)),e.end.setPositionParagraph(W.line,W.line.getOffset(W,0)+1),this.removeWholeElement(e);return}}if(f instanceof o.h&&0==f.type&&f.nextNode instanceof o.h&&1==f.nextNode.type){var P=f,k=f.nextNode;e.start.setPositionParagraph(P.line,P.line.getOffset(P,0)),e.end.setPositionParagraph(k.line,k.line.getOffset(k,0)+1),this.removeWholeElement(e);return}if(f instanceof o.h&&0==f.type&&"Block"===f.contentControlWidgetType&&f.reference&&f.paragraph!==f.reference.paragraph)return}if(f instanceof o.V8&&1===f.fieldType&&!this.selection.isInlineFormFillMode()){var R=e.getPreviousValidElement(f);if(R instanceof o.V8&&0!==R.fieldType){if(c=(f=R.fieldBegin).line.paragraph,g=f.line.getOffset(f,0),f.nextNode instanceof o.aQ&&f.nextNode.reference){var T=f.nextNode.reference;e.start.setPositionParagraph(T.line,T.line.getOffset(T,1))}e.end.setPositionParagraph(f.line,g),e.fireSelectionChanged(!0);return}R!==f&&(c=(f=R).line.paragraph,g=f.line.getOffset(f,f.length))}if((f instanceof o.Cw||f instanceof o.jn)&&this.isEditRangeAtListBoundary(f)){if(f instanceof o.Cw&&c.childWidgets&&c.childWidgets.length>0){var S=c.childWidgets[0];S.children&&S.children.length>0&&(f=S.children[0],g=0,c=f.line.paragraph)}}else if(f instanceof o.Cw||f instanceof o.jn){if(f.nextNode instanceof o.jn&&f.editRangeEnd===f.nextNode||f.previousNode instanceof o.Cw&&f.editRangeStart===f.previousNode)return;if(f instanceof o.Cw&&!(f.previousNode instanceof o.jn)){e.skipFormatRetrieval=!1;return}if(f instanceof o.jn)do{if((0,a.le)(f.previousNode))break;c=(f=f.previousNode).line.paragraph,g=f.line.getOffset(f,f.length)}while(f instanceof o.jn);if(1===f.length&&f.nextNode instanceof o.jn&&f.previousNode instanceof o.Cw){var B=f.previousNode,L=f.nextNode;e.start.setPositionParagraph(B.line,B.line.getOffset(B,0)),e.end.setPositionParagraph(L.line,L.line.getOffset(L,0)+1),this.removeWholeElement(e);return}}if(f&&(f instanceof o.aQ||f.previousNode instanceof o.aQ)){if(this.documentHelper.isDocumentProtected&&"ReadOnly"===this.documentHelper.protectionType&&(f.previousNode&&f.previousNode instanceof o.Cw||f.previousNode instanceof o.jn))return;if(f instanceof o.aQ){if(!f.previousNode||f.previousNode instanceof o.no){if(1===f.bookmarkType){if(c.previousRenderedWidget instanceof o.ZH){var E=c.previousRenderedWidget,O=E.lastChild;e.start.setPositionParagraph(f.line,f.line.getOffset(f,0)),e.end.setPositionParagraph(O,O.getEndOffset()),this.removeWholeElement(e);return}}else{if(!(f.paragraph.previousWidget instanceof o.ZH))return;e.start.setPositionFromLine(f.line,0),e.end.setPositionInternal(e.start),g=0}}else{if((f=f.previousNode)instanceof o.V8&&!this.selection.isInlineFormFillMode()){if(c=(f=f.fieldBegin).line.paragraph,g=f.line.getOffset(f,0),f.nextNode instanceof o.aQ&&f.nextNode.reference){var A=f.nextNode.reference;e.start.setPositionParagraph(A.line,A.line.getOffset(A,1))}e.end.setPositionParagraph(f.line,g),e.fireSelectionChanged(!0);return}c=f.line.paragraph,g=f.line.getOffset(f,f.length),e.start.setPositionFromLine(f.line,g),e.end.setPositionInternal(e.start)}}else if(f.nextNode instanceof o.aQ&&f instanceof o.aQ&&0===f.bookmarkType&&f.reference===f.nextNode){this.deleteBookmark(f.name);return}if(1===f.length&&f.nextNode instanceof o.aQ&&f.previousNode instanceof o.aQ){var N=f.previousNode,M=f.nextNode;e.start.setPositionParagraph(N.line,N.line.getOffset(N,0)),e.end.setPositionParagraph(M.line,M.line.getOffset(M,0)+1),this.removeWholeElement(e);return}}var D=g===e.getStartOffset(c)&&e.start.currentWidget.isFirstLine();if(!(this.owner.enableTrackChanges&&!D&&this.canSkipDeleteTracking(f,!0))){if(this.owner.enableTrackChanges&&D){var V=c.previousRenderedWidget;if(V instanceof o.ZH&&V.characterFormat.revisionLength>0&&this.isDeleteRevisionByCurrentUser(V.characterFormat)){var U=this.documentHelper.selection.getLineLength(V.lastChild),z=V.childWidgets.length-1;e.selects(V.childWidgets[z],U,!1);return}}if(t||this.initHistory("BackSpace"),D){if(c.paragraphFormat.listFormat&&-1!==c.paragraphFormat.listFormat.listId){e.skipFormatRetrieval=!1,(0,a.le)(this.editorHistory)||(0,a.le)(this.editorHistory.undoStack)||!(this.editorHistory.undoStack.length>0)||"ListFormat"!==this.editorHistory.undoStack[this.editorHistory.undoStack.length-1].action?(this.onApplyList(void 0),this.reLayout(e,!0)):this.onApplyListInternal(this.documentHelper.getListById(c.paragraphFormat.listFormat.listId),c.paragraphFormat.listFormat.listLevelNumber-1);return}if(0!==c.paragraphFormat.firstLineIndent){this.onApplyParagraphFormat("firstLineIndent",0,!1,!1),0!==c.paragraphFormat.leftIndent&&this.onApplyParagraphFormat("leftIndent",0,!1,!1),e.skipFormatRetrieval=!1;return}if(0!==c.paragraphFormat.leftIndent){this.onApplyParagraphFormat("leftIndent",0,!1,!1);return}if(!c.paragraphFormat.bidi&&"Left"!==c.paragraphFormat.textAlignment&&"Justify"!==c.paragraphFormat.textAlignment){e.skipFormatRetrieval=!1,this.onApplyParagraphFormat("textAlignment","Left",!1,!0);return}if(c.previousRenderedWidget instanceof o.ZH){var Z=c.previousRenderedWidget;if(Z.characterFormat.hidden)return;if(e.owner.isShiftingEnabled=!0,this.owner.enableTrackChanges&&void 0!=Z&&(0===Z.characterFormat.revisionLength||!this.isInsertRevisionByCurrentUser(Z.characterFormat))){var U=this.documentHelper.selection.getLineLength(Z.lastChild),z=Z.childWidgets.length-1,j=!this.isDeleteRevisionByCurrentUser(Z.characterFormat);if(j){var _=this.retrieveRevisionByType(Z.characterFormat,"Deletion");if(Z.characterFormat.revisionLength>
10&&!(0,a.le)(_)){if(this.owner.editorModule.initComplexHistory("RemoveAndAddRevision"),this.editorHistory&&this.owner.editorHistory.currentHistoryInfo){this.owner.editorModule.initHistory("RemoveRevision");var K=Z.characterFormat.getRevision(0);this.owner.editorHistory.currentBaseHistoryInfo.modifiedProperties.push(K.revisionID),e.selects(Z.childWidgets[z],U,!0),this.editorHistory&&this.editorHistory.currentBaseHistoryInfo&&this.owner.editorHistory.currentBaseHistoryInfo.updateSelection(),this.editorHistory.updateHistory(),this.unlinkRevisionFromItem(Z.characterFormat);var X=this.insertRevision(Z.characterFormat,"Deletion");this.owner.editorModule.initHistory("AddRevision"),this.owner.editorHistory.currentBaseHistoryInfo.modifiedProperties.push(X.revisionID),this.editorHistory.updateHistory()}this.owner.editorHistoryModule&&this.owner.editorHistoryModule.updateComplexHistory()}else{var J=this.insertRevision(Z.characterFormat,"Deletion");this.owner.editorHistory&&this.owner.editorHistory.currentBaseHistoryInfo&&(this.owner.editorHistory.currentBaseHistoryInfo.action="AddRevision",this.owner.editorHistory.currentBaseHistoryInfo.modifiedProperties.push(J.revisionID))}}this.documentHelper.layout.reLayoutParagraph(Z,z,0),e.selects(Z.childWidgets[z],U,!0),j&&this.editorHistory&&this.editorHistory.currentBaseHistoryInfo&&this.owner.editorHistory.currentBaseHistoryInfo.updateSelection()}else if(Z.isEmpty()&&!this.owner.enableTrackChanges){if(this.removePrevParaMarkRevision(c),c===c.bodyWidget.lastChild&&Z.bodyWidget.index!==c.bodyWidget.index){var U=this.documentHelper.selection.getLineLength(Z.lastChild),z=Z.childWidgets.length-1;e.selects(Z.childWidgets[z],U,!0)}else{this.removeBlock(Z),this.addRemovedNodes(Z);var E=c.previousRenderedWidget;(!(0,a.le)(E)&&E instanceof o.ZH&&E.isEmpty()&&E.bodyWidget.index!==c.bodyWidget.index||Z.isSectionBreak)&&e.moveToPreviousCharacter()}}else if(this.owner.enableTrackChanges&&void 0!=Z.characterFormat.getAllRevision()&&e.start.isAtParagraphStart&&Z.isEmpty())this.addRemovedRevisionInfo(Z.characterFormat),this.addRemovedNodes(Z),this.removePrevParaMarkRevision(c),this.removeBlock(Z,!1,!0);else{var Q=!1;if(c===c.bodyWidget.lastChild&&Z.bodyWidget.index!==c.bodyWidget.index||"NoBreak"===c.bodyWidget.sectionFormat.breakCode&&c===c.bodyWidget.firstChild||(Q=!0),Q){Z=Z.combineWidget(this.owner.viewer);var q=this.documentHelper.selection.getParagraphLength(Z),G=this.selection.getHierarchicalIndex(Z,q.toString()),Y=this.splitParagraph(Z,Z.firstChild,0,e.start.currentWidget,e.start.offset,!0);this.removePrevParaMarkRevision(Z,!0,!0),this.deleteParagraphMark(Y,e,0),this.addRemovedNodes(Z),e.selectByHierarchicalIndex(G,G)}else{var U=this.documentHelper.selection.getLineLength(Z.lastChild),$=Z.childWidgets.length-1;e.selects(Z.childWidgets[$],U,!0)}}if(this.setPositionForHistory(),this.documentHelper.layout.getFootNoteWidgetsOf(c).length>0){var ee=this.documentHelper.layout,et=c.bodyWidget;ee.layoutfootNote(et.page.footnoteWidget)}e.skipFormatRetrieval=!1,this.reLayout(e)}else this.editorHistory&&(e.skipFormatRetrieval=!1,this.editorHistory.currentBaseHistoryInfo=void 0)}else{t||(e.owner.isShiftingEnabled=!0);var ei=this.selection.getParagraphInfo(e.start),F=e.start.currentWidget,er=g-1;er<0&&(F=F.previousLine,er=this.documentHelper.selection.getLineLength(F)+er),this.removeAtOffset(F,e,er);var eo=this.selection.currentContentControl;!(0,a.le)(eo)&&eo.contentControlProperties.isTemporary&&this.removeContentControl(),this.setPositionParagraph(ei.paragraph,ei.offset-1,!1),this.setPositionForHistory(),e.skipFormatRetrieval=!1,t?this.fireContentChange():(this.reLayout(e),h&&(this.owner.editorHistoryModule.undoStack[this.owner.editorHistoryModule.undoStack.length-2].modifiedActions.push(this.owner.editorHistoryModule.undoStack[this.owner.editorHistoryModule.undoStack.length-1]),this.owner.editorHistoryModule.undoStack.splice(this.owner.editorHistoryModule.undoStack.length-1,1),h=!1))}y&&this.editorHistory&&this.editorHistory.currentHistoryInfo&&(this.editorHistory.currentHistoryInfo.endPosition=this.selection.startOffset,this.editorHistory.updateComplexHistory())}}}},e.prototype.isSameUserTrackedRecord=function(e,t,i){for(var r=0;r<e.length;r++)if(e[r].author===t&&e[r].revisionType===i)return!0;return!1},e.prototype.canSkipDeleteTracking=function(e,t){return!!(!(0,a.le)(e)&&!(0,a.le)(e.getAllRevision())&&e.revisionLength>0&&this.isSameUserTrackedRecord(e.getAllRevision(),this.owner.currentUser?this.owner.currentUser:"Guest user","Deletion"))&&(t?this.selection.movePreviousPosition():this.selection.moveNextPosition(),!0)},e.prototype.setPositionForHistory=function(e){var t=this.documentHelper.selection;this.editorHistory&&!(0,a.le)(this.editorHistory.currentBaseHistoryInfo)&&((0,a.le)(e)?(this.updateHistoryPosition(t.start,!0),this.editorHistory.currentBaseHistoryInfo.endPosition=this.editorHistory.currentBaseHistoryInfo.insertPosition):(this.editorHistory.currentBaseHistoryInfo.insertPosition=e,this.editorHistory.currentBaseHistoryInfo.endPosition=e))},e.prototype.removeAtOffset=function(e,t,i){var r=0,n=e.paragraph.childWidgets.indexOf(e),s=e.children.length,a=this.selection.getParagraphInfo(t.start);t.editPosition=this.selection.getHierarchicalIndex(a.paragraph,a.offset.toString());for(var l=0;l<s;l++){var d=e.children[l];if(!(d instanceof o.no)){if(this.removeCharacter(d,i,r,e,n,l))break;r+=d.length}}},e.prototype.triggerChangeDetected=function(e){if(e.isChangeDetected=!0,this.owner.isSpellCheck){var t=e.nextElement,i=e.previousElement;this.owner.spellCheckerModule.removeErrorsFromCollection({element:e,text:e.text}),!(0,a.le)(t)&&t instanceof o.a3&&(t.isChangeDetected=!0,this.owner.spellCheckerModule.removeErrorsFromCollection({element:t,text:t.text})),!(0,a.le)(i)&&i instanceof o.a3&&(i.isChangeDetected=!0,this.owner.spellCheckerModule.removeErrorsFromCollection({element:i,text:i.text})),e.canTrigger||(this.documentHelper.triggerSpellCheck=!1)}},e.prototype.removeCharacter=function(e,t,i,r,n,s,l){var d=!1;if(e instanceof o.aQ&&e.reference&&e.line!==e.reference.line&&!(r.children[s]instanceof o.aQ))return(0,a.le)(e.line.previousLine)?(0,a.le)(e.line.paragraph.previousRenderedWidget)?(0,a.le)(e.line.paragraph.nextRenderedWidget)||(e.line.paragraph.nextRenderedWidget.firstChild.children.splice(e.line.paragraph.nextRenderedWidget.firstChild.children.length,0,e),e.line=e.line.paragraph.nextRenderedWidget.firstChild):(e.line.paragraph.previousRenderedWidget.lastChild.children.splice(e.line.paragraph.previousRenderedWidget.lastChild.children.length,0,e),e.line=e.line.paragraph.previousRenderedWidget.lastChild):(e.line.previousLine.children.splice(e.line.previousLine.children.length,0,e),e.line=e.line.previousLine),r.children.splice(s,1),!(0,a.le)(r.layoutedElements)&&r.layoutedElements.length>0&&r.layoutedElements.splice(s,1),!0;if(t<i+e.length){var h=t-i;if(this.triggerChangeDetected(e),t===i&&1===e.length){if(this.owner.enableTrackChanges&&!this.skipTracking())this.addRemovedNodes(e.clone()),this.handleDeleteTracking(e,h,1,s);else{this.unLinkFieldCharacter(e),this.addRemovedRevisionInfo(e),this.addRemovedNodes(e),this.owner.enableTrackChanges&&this.editorHistory.isRedoing&&e instanceof o.R5&&("Footnote"===e.footnoteType?this.removeFootnote(e):this.removeEndnote(e)),this.combineRevisionsAndViewBasedOnUntrackedContent(e);var c=e.previousNode;r.children.splice(s,1),this.unlinkRevisionFromItem(e),(0,a.le)(c)||this.combineElementRevisionToPrevNxt(c),!(0,a.le)(r.layoutedElements)&&r.layoutedElements.length>0&&(r.layoutedElements.splice(s,1),0===r.layoutedElements.length&&(r.layoutedElements=void 0))}var p=r.paragraph;!(0,a.le)(p)&&!p.isEmpty()&&0===r.children.length&&r.isLastLine()&&!r.previousLine.isEndsWithLineBreak&&-1!==p.childWidgets.indexOf(r)&&(this.removeEmptyLine(p),n-=1),this.documentHelper.layout.reLayoutParagraph(r.paragraph,n,s,void 0,l)}else{var g=this.handleDeleteTracking(e,h,1);this.documentHelper.layout.reLayoutParagraph(r.paragraph,n,s,void 0,l),(0,a.le)(g)||(e.revisionLength>0&&this.addRemovedRevisionInfo(e,g),this.addRemovedNodes(g))}e instanceof o.Cw&&(this.selection.skipEditRangeRetrieval=!0,this.removeUserRestrictionsInternal(e,void 0,!0),this.selection.updateEditRangeCollection(),this.fireContentChange(),this.selection.skipEditRangeRetrieval=!1),e instanceof o.aQ&&0===e.bookmarkType&&this.documentHelper.bookmarks.containsKey(e.name)&&this.documentHelper.bookmarks.remove(e.name),d=!0}return d},e.prototype.removeCharacterInLine=function(e,t,i){var r=new o.a3;if(e instanceof o.a3){e.isWidthUpdated=!1,r.characterFormat.copyFormat(e.characterFormat);var n=1===i?1:i-t;r.text=e.text.substr(t,n);var s=e.text;e.text=s.substring(0,t)+s.substring(t+n,s.length),e.contentControlProperties&&(r.contentControlProperties=e.contentControlProperties.clone())}if(e.revisionLength>0)for(var a=0;a<e.revisionLength;a++)e.getRevision(a).hasChanges=!0;return r},e.prototype.removeRevisionsInformation=function(e,t){var i=e.previousElement;"Insertion"===this.retrieveRevisionInOder(i).revisionType&&this.isRevisionMatched(i,void 0)&&e.line.children.splice(t,1)},e.prototype.handleDeleteTracking=function(e,t,i,r,n,s){var l=this.owner.enableTrackChanges,d=void 0;
1if(this.canHandleDeletion()||l&&(!this.skipTracking()||e.paragraph.isInsideTable&&!(0,a.le)(this.editorHistory)&&this.editorHistory.isRedoing&&this.editorHistory.currentBaseHistoryInfo&&"RemoveRowTrack"===this.editorHistory.currentBaseHistoryInfo.action)){if(e instanceof o.aQ||e instanceof o.Xw||e instanceof o.Cw||e instanceof o.jn||e instanceof o.h){if(e instanceof o.aQ&&e.previousElement instanceof o.V8&&e.previousElement.formFieldData)e.previousElement.revisionLength>0&&this.removeRevisionsInformation(e,r);else if(l&&e instanceof o.aQ)this.checkToCombineRevisionsInSides(e,"Deletion")||this.insertRevision(e,"Deletion"),this.updateLastDeletedRevision(e);else if(e instanceof o.Xw){var h=!1,c=e.comment;if(c&&c.ownerComment&&(c=c.ownerComment),c){for(var p=0;p<this.owner.documentHelper.comments.length;p++)if(c.commentId===this.owner.documentHelper.comments[p].commentId){h=!0;break}}!h||this.isRevisionMatched(e,void 0)||this.editorHistory&&this.editorHistory.currentHistoryInfo&&"DeleteComment"===this.editorHistory.currentHistoryInfo.action?e.line.children.splice(e.indexInOwner,1):l&&!(0===e.commentType&&e.nextElement===e.comment.commentEnd||1===e.commentType&&e.previousElement===e.comment.commentStart)&&(this.checkToCombineRevisionsInSides(e,"Deletion")||this.insertRevision(e,"Deletion"),this.updateLastDeletedRevision(e))}else e.line.children.splice(e.indexInOwner,1);return}var g=!1;if(this.owner.editorHistoryModule&&(g=!(0,a.le)(this.owner.editorHistoryModule.currentBaseHistoryInfo)&&"Delete"===this.owner.editorHistoryModule.currentBaseHistoryInfo.action),e.revisionLength>0){var m=this.retrieveRevisionInOder(e),u=this.owner.revisions.changes.indexOf(m);if("Insertion"===m.revisionType){if(this.isRevisionMatched(e,void 0)){if(!(0,a.le)(this.owner.editorHistoryModule)&&!(0,a.le)(this.owner.editorHistoryModule.currentBaseHistoryInfo)){var f=(0,a.le)(r)?t:0,y=(0,a.le)(r)?1===i?1:i-t:e.length;this.owner.editorHistoryModule.currentBaseHistoryInfo.recordInsertRevisionDeletetion(e,f,y)}(0,a.le)(r)?d=this.removeCharacterInLine(e,t,i):(this.unLinkFieldCharacter(e),e.line.children.splice(r,1),this.owner.trackChangesPane.updateCurrentTrackChanges(m),!(0,a.le)(e.line.layoutedElements)&&e.line.layoutedElements.length>0&&-1!==e.line.layoutedElements.indexOf(e)&&e.line.layoutedElements.splice(r,1),0===e.line.children.length&&(e.line.layoutedElements=void 0)),e instanceof o.R5&&("Footnote"===e.footnoteType?this.removeFootnote(e):this.removeEndnote(e))}else if((0,a.le)(r)){var v=this.removeCharacterInLine(e,t,i),H=e.getRevision(0);if((0,a.le)(H)||this.owner.trackChangesPane.updateCurrentTrackChanges(H),0===t){var C=e.previousElement;this.handleDeletionForInsertRevision(C,e,v,i,t,!0,s)}else if(e.length!==t)for(var p=e.revisionLength-1;p>=0;p--){var F=e.getRevision(p),w=new o.a3;w.characterFormat.copyFormat(e.characterFormat),w.line=e.line,w.text=e.text.substr(t),w.insertRevisionAt(0,F),v.insertRevisionAt(0,F),v.line=e.line,v.isWidthUpdated=!1,this.owner.trackChangesPane.updateCurrentTrackChanges(F),e.text=e.text.substr(0,t),e.isWidthUpdated=!1;var I=e.indexInOwner;e.line.children.splice(I+1,0,w),e.line.children.splice(I+1,0,v),this.isElementAddedToNewPara(s,v)||this.addRemovedNodes(v.clone()),this.insertRevision(v,"Deletion"),this.updateLastDeletedRevision(v)}else if(e.length===t){var x=e.nextElement;this.handleDeletionForInsertRevision(x,e,v,i,t,!1,s)}else 1===i&&this.selection.isEmpty?g||(this.selection.start.movePreviousPosition(),this.selection.end.setPositionInternal(this.selection.start)):this.updateCursorForInsertRevision(e,t,i),this.isElementAddedToNewPara(s,v)||this.addRemovedNodes(v.clone()),this.insertInlineInternal(v,"Deletion")}else this.checkToCombineRevisionsInSides(e,"Deletion")||this.insertRevision(e,"Deletion"),this.updateLastDeletedRevision(e)}else if("Deletion"===m.revisionType){if(-1!==u&&m.getRange().length>0){var b=void 0;(0,a.le)(r)?this.handleDeleteBySplitting(e,t,i,s):(e.removeRevision(e.getAllRevision().indexOf(m)),!(0,a.le)(e.nextNode)&&e.nextNode.revisionLength>0&&(b=this.getMatchedRevisionsToCombine(e.nextNode.getAllRevision(),"Deletion")),b&&0===b.length&&this.checkToSplitRevisionInPrevNxt(e),this.checkToCombineRevisionsInSides(e,"Deletion")?this.updateLastDeletedRevision(e):(this.updateLastDeletedRevision(e),this.insertRevision(e,"Deletion")))}else this.updateLastDeletedRevision(e)}0===m.getRange().length&&this.owner.revisions.remove(m)}else(0,a.le)(r)?this.handleDeleteBySplitting(e,t,i,s):(this.skipFootNoteDeleteTracking||this.updateLastDeletedRevision(e),this.checkToCombineRevisionsInSides(e,"Deletion")||this.insertRevision(e,"Deletion"))}else{d=this.removeCharacterInLine(e,t,i);var m=e.getRevision(0);(0,a.le)(m)||this.owner.trackChangesPane.updateCurrentTrackChanges(m)}return d},e.prototype.updateLastDeletedRevision=function(e){!this.skipTableElements&&!this.isPasteOverWriteCells&&this.editorHistory&&this.editorHistory.currentBaseHistoryInfo&&!this.skipReplace&&((0,a.le)(this.owner.searchModule)||!this.owner.searchModule.isRepalceTracking)&&(0,a.le)(this.editorHistory.currentBaseHistoryInfo.lastDeletedNodeRevision)&&(this.editorHistory.currentBaseHistoryInfo.lastDeletedNodeRevision=e)},e.prototype.retrieveRevisionInOder=function(e){if(1===e.revisionLength)return e.getRevision(0);for(var t=0;t<e.revisionLength;
1t++)if("Deletion"===e.revisions[t].revisionType)return e.revisions[t];return e.revisions[e.revisionLength-1]},e.prototype.handleDeletionForInsertRevision=function(e,t,i,r,o,n,s){if(!(0,a.le)(e)&&0===t.revisionLength&&this.isRevisionMatched(e,"Deletion"))this.isElementAddedToNewPara(s,i)||this.addRemovedNodes(i.clone()),this.insertTextInline(e,this.selection,i.text,0);else{var l=t.getRevision(t.revisionLength-1);i.insertRevisionAt(0,l),this.owner.trackChangesPane.updateCurrentTrackChanges(l);var d=!1;this.owner.editorHistoryModule&&(d=!(0,a.le)(this.owner.editorHistoryModule.currentBaseHistoryInfo)&&"Delete"===this.owner.editorHistoryModule.currentBaseHistoryInfo.action),1===r&&this.selection.isEmpty?d||(this.selection.start.movePreviousPosition(),this.selection.end.setPositionInternal(this.selection.start)):this.updateCursorForInsertRevision(t,o,r),""!==i.text&&(this.isElementAddedToNewPara(s,i)||this.addRemovedNodes(i.clone()),this.insertInlineInternal(i,"Deletion"))}},e.prototype.handleDeleteBySplitting=function(e,t,i,o){var n=!1;if(this.owner.editorHistoryModule&&(n=!(0,a.le)(this.owner.editorHistoryModule.currentBaseHistoryInfo)&&"Delete"===this.owner.editorHistoryModule.currentBaseHistoryInfo.action),1===i&&this.selection.isEmpty){var s=e.line.getOffset(e,0);if(s>0){var l=new r.JK(this.owner);l.setPositionForLineWidget(e.line,s+t),this.selection.start.setPositionInternal(l),this.selection.end.setPositionInternal(this.selection.start)}else n||(this.selection.start.movePreviousPosition(),this.selection.end.setPositionInternal(this.selection.start))}else this.updateCursorForInsertRevision(e,t,i);var d=this.removeCharacterInLine(e,t,i),h=e.getRevision(0);(0,a.le)(h)||this.owner.trackChangesPane.updateCurrentTrackChanges(h),e.revisionLength>0&&(d.removedIds=B.k.cloneRevisions(e.getAllRevision())),""!==d.text&&(this.isElementAddedToNewPara(o,d)||this.addRemovedNodes(d.clone()),this.insertTextInternal(d.text,!1,"Deletion",!1))},e.prototype.isElementAddedToNewPara=function(e,t){if(e){var i=e.childWidgets[e.childWidgets.length-1],r=t.clone();return i.children.splice(0,0,r),r.line=i,!0}return!1},e.prototype.updateCursorForInsertRevision=function(e,t,i){var o=e.line.getOffset(e,0);o>0&&(t=o+t,i=o+i);var n=new r.JK(this.owner);n.setPositionFromLine(e.line,t);var s=new r.JK(this.owner);s.setPositionFromLine(e.line,i),n.isExistBefore(s)?(this.selection.end.setPositionInternal(n),this.selection.start.setPositionInternal(n)):(this.selection.start.setPositionInternal(s),this.selection.end.setPositionInternal(s))},e.prototype.checkToCombineRevisionsInSides=function(e,t){var i=e.previousNode,r=e.nextNode,n=!1;if(!(0,a.le)(i)&&(i instanceof o.aQ||(i=i.previousValidNodeForTracking),!(0,a.le)(i))){var s=this.getMatchedRevisionsToCombine(i.getAllRevision(),t);s.length>0&&(this.mapMatchedRevisions(s,i,e,!1),n=!0)}if(!(0,a.le)(r)&&(r instanceof o.aQ||(r=r.nextValidNodeForTracking),!(0,a.le)(r))){var s=this.getMatchedRevisionsToCombine(r.getAllRevision(),t);s.length>0&&(n?this.combineElementRevision(e.getAllRevision(),r.getAllRevision()):this.mapMatchedRevisions(s,r,e,!0),n=!0)}return n},e.prototype.delete=function(){this.isDeleteOrBackSpace=!0;var e=this.documentHelper.selection;if(!e.isEmpty){var t=e.bookmarks;t.length>0&&this.extendSelectionToBookmarkStart(t)}if(e.isEmpty)this.singleDelete(e,!1);else{if(this.owner.enableTrackChanges&&this.canSkipDeleteTrack(e))return;var i=this.checkAndRemoveComments();this.initHistory("Delete"),e.isForward?e.end:e.start,this.deleteSelectedContentInternal(e,!1,e.start,e.end);var o=new r.JK(e.owner);if(this.setPositionForCurrentIndex(o,e.editPosition),e.selectContent(o,!0),this.reLayout(e),this.insertSpaceInFormField(),this.editorHistory&&!(0,a.le)(this.editorHistory.currentHistoryInfo)&&"RemoveComment"===this.editorHistory.currentHistoryInfo.action){for(var n=0;n<i.length;n++)this.initInsertInline(i[n],!1);this.editorHistory.currentHistoryInfo.endPosition=this.selection.startOffset,this.editorHistory.updateComplexHistory()}}this.isDeleteOrBackSpace=!1,this.documentHelper.layout.islayoutFootnote=!1,this.updateXmlMappedContentControl()},e.prototype.deleteEditElement=function(e){this.initHistory("Delete"),this.deleteSelectedContentInternal(e,!1,e.start,e.end);var t=new r.JK(e.owner);this.setPositionForCurrentIndex(t,e.editPosition),e.selectContent(t,!0),this.reLayout(e)},e.prototype.removeContentControlMark=function(e,t){return!e.contentControlProperties.lockContentControl&&(this.selection.start.setPositionParagraph(e.line,e.line.getOffset(e,0)),this.selection.end.setPositionParagraph(t.line,t.line.getOffset(t,0)+1),this.deleteEditElement(this.selection),!0)},e.prototype.singleDelete=function(e,t){var i=e.start.currentWidget,r=e.start.paragraph,n=e.start.offset,s=0,l=i.getInline(e.start.offset,s),d=l.element;if(!r.characterFormat.hidden){if(this.selection.isInlineFormFillMode()){if(d instanceof o.V8&&1===d.fieldType)return;var h=this.getFieldResultText();if(d instanceof o.a3||(d=d.nextElement),1===h.length&&d instanceof o.a3){this.selection.selectFieldInternal(this.selection.getCurrentFormField()),this.insertTextInternal(this.documentHelper.textHelper.repeatChar(this.documentHelper.textHelper.getEnSpaceCharacter(),5),!0),this.selection.selectTextElementStartOfField(this.selection.getCurrentFormField());return}if(d instanceof o.V8&&1===d.fieldType)return}if(d instanceof o.h){0===d.type&&(d.contentControlProperties.lockContents?this.selection.selectContentControl(d):this.selection.selectContentControlInternal(d));return}var c=this.selection.currentContentControl;if(!c||!c.contentControlProperties||!c.contentControlProperties.lockContents){if(s=l.index,r.paragraphFormat.listFormat&&-1!==r.paragraphFormat.listFormat.listId&&this.documentHelper.isListTextSelected&&"List"===e.contextType){this.onApplyList(void 0);return}if(!(0,a.le)(d)&&s===d.length&&!(0,a.le)(d.nextNode)){if((d=d.nextNode)instanceof o.V8&&1===d.fieldType&&!(0,a.le)(d.fieldBegin.formFieldData)||d instanceof o.R5)return;s=0}for(var p=d instanceof o.Xw;d instanceof o.Xw;)if(d.nextNode)d=d.nextNode,s=0;else{s=1;break}if(p&&(r=d.line.paragraph,n=d.line.getOffset(d,s),e.start.setPositionParagraph(d.line,n),e.end.setPositionParagraph(d.line,n)),!this.owner.enableTrackChanges&&d instanceof o.R5&&("Footnote"===d.footnoteType?this.removeFootnote(d):this.removeEndnote(d)),!(0,a.le)(d)){var g=void 0,m=this.documentHelper.getNextValidElement(d);if(d.characterFormat.hidden)return;if(m instanceof o.nR&&(g=m),!(0,a.le)(g)&&g instanceof o.V8&&0===g.fieldType){if(r=(d=g.fieldEnd).line.paragraph,n=d.line.getOffset(d,1),e.end.setPositionParagraph(d.line,n),d.nextNode instanceof o.aQ){var u=d.nextNode;e.end.setPositionParagraph(u.line,u.line.getOffset(u,1))}e.fireSelectionChanged(!0);return}d!==g&&(r=(d=g).line.paragraph,n=d.line.getOffset(d,0),d instanceof o.V8&&1===d.fieldType&&n++)}if(d instanceof o.Cw||d instanceof o.jn){if(d.nextNode instanceof o.jn&&d.editRangeEnd===d.nextNode||d.previousNode instanceof o.Cw&&d.editRangeStart===d.previousNode)return;if(this.documentHelper.isDocumentProtected&&"ReadOnly"===this.documentHelper.protectionType){if(d instanceof o.Cw||d instanceof o.jn)return}else d instanceof o.Cw?(n=(d=d.nextNode).line.getOffset(d,0),r=d.line.paragraph):d instanceof o.jn&&n++;if(1===d.length&&d.nextNode instanceof o.jn&&d.previousNode instanceof o.Cw){var f=d.previousNode,y=d.nextNode;e.start.setPositionParagraph(f.line,f.line.getOffset(f,0)),e.end.setPositionParagraph(y.line,y.line.getOffset(y,0)+1),this.deleteEditElement(e);return}}
1if(d&&(d instanceof o.h||d.nextNode instanceof o.h)){if(d instanceof o.h&&d.nextNode){r=(d=d.nextNode).line.paragraph,n=d.line.getOffset(d,0),e.start.setPositionParagraph(d.line,n),e.end.setPositionParagraph(d.line,n);return}if(d&&1===d.length&&d.nextNode instanceof o.h&&d.previousNode instanceof o.h&&this.removeContentControlMark(d.previousNode,d.nextNode)||d instanceof o.h&&d.previousNode instanceof o.h&&d.previousNode.reference===d&&!this.documentHelper.isFormFillProtectedMode&&this.removeContentControlMark(d.previousNode,d))return}if(d&&(d instanceof o.aQ&&0===d.bookmarkType||d.nextNode instanceof o.aQ)){if(d.nextNode&&d instanceof o.aQ&&(r=(d=d.nextNode).line.paragraph,n=d.line.getOffset(d,0),e.start.setPositionParagraph(d.line,n),e.end.setPositionParagraph(d.line,n)),1===d.length&&d.nextNode instanceof o.aQ&&d.previousNode instanceof o.aQ){var v=d.previousNode,H=d.nextNode;e.start.setPositionParagraph(v.line,v.line.getOffset(v,0)),e.end.setPositionParagraph(H.line,H.line.getOffset(H,0)+1),this.deleteEditElement(e);return}d instanceof o.aQ&&(n=d.line.getOffset(d,1))}var C=e.start.currentWidget.isLastLine()&&n>=this.documentHelper.selection.getLineLength(e.start.currentWidget);if(this.owner.enableTrackChanges&&(!C&&this.canSkipDeleteTracking(d,!1)||C&&!r.isEmpty()&&r.nextRenderedWidget instanceof o.dm))return;if(C){if(r.isInsideTable&&(0,a.le)(r.nextWidget))return;var F=void 0,w=void 0,I=e.getNextParagraphBlock(r);if(!(0,a.le)(I)){if(I.isEmpty()&&I.characterFormat.hidden)return;var x=I.firstChild;if(!(0,a.le)(x)){var b=x.children[0];if(!(0,a.le)(b)&&b.characterFormat.hidden)return}}if((0,a.le)(I)){if(n>0||(r.previousWidget instanceof o.ZH&&(F=r.previousWidget),r.previousWidget instanceof o.tf||r.previousWidget instanceof o.dm||(0,a.le)(F)||r.isEmpty()&&F.characterFormat.revisionLength>0))return}else if(this.owner.enableTrackChanges&&r.characterFormat.revisionLength>0&&this.isDeleteRevisionByCurrentUser(r.characterFormat)){e.selectParagraphInternal(I,!0);return}if(t||this.initHistory("Delete"),r.isEndsWithPageBreak||r.isEndsWithColumnBreak){var W=r.lastChild,P=W.children[W.children.length-1];this.selection.start.setPositionForSelection(W,P,0,this.selection.start.location)}var k=this.selection.getParagraphInfo(e.start);if(e.editPosition=this.selection.getHierarchicalIndex(k.paragraph,k.offset.toString()),this.checkInsertPosition(e)&&this.setPositionForHistory(e.editPosition),e.owner.isShiftingEnabled=!0,r.isEmpty()){if(this.owner.enableTrackChanges&&(0===r.characterFormat.revisionLength||!this.isInsertRevisionByCurrentUser(r.characterFormat))){if(!this.isDeleteRevisionByCurrentUser(r.characterFormat)){var R=this.retrieveRevisionByType(r.characterFormat,"Deletion");if(r.characterFormat.revisionLength>0&&!(0,a.le)(R)){if(this.owner.editorModule.initComplexHistory("RemoveAndAddRevision"),this.editorHistory&&this.owner.editorHistory.currentHistoryInfo){this.owner.editorModule.initHistory("RemoveRevision");var T=r.characterFormat.getRevision(0);this.owner.editorHistory.currentBaseHistoryInfo.modifiedProperties.push(T.revisionID),this.editorHistory.updateHistory(),this.unlinkRevisionFromItem(r.characterFormat);var S=this.insertRevision(r.characterFormat,"Deletion");this.owner.editorModule.initHistory("AddRevision"),this.owner.editorHistory.currentBaseHistoryInfo.modifiedProperties.push(S.revisionID),this.editorHistory.updateHistory()}this.owner.editorHistoryModule&&this.owner.editorHistoryModule.updateComplexHistory()}else{var B=this.insertRevision(r.characterFormat,"Deletion");this.owner.editorHistory&&this.owner.editorHistory.currentBaseHistoryInfo&&(this.owner.editorHistory.currentBaseHistoryInfo.action="AddRevision",this.owner.editorHistory.currentBaseHistoryInfo.modifiedProperties.push(B.revisionID))}}e.selectParagraphInternal(I,!0)}else{this.removePrevParaMarkRevision(r,!0,!0);var L=e.getNextParagraphBlock(r);if(!(0,a.le)(L)&&L instanceof o.ZH&&L.bodyWidget.index!==r.bodyWidget.index&&(this.deleteSection(e,r.bodyWidget,L.bodyWidget,0),this.editorHistory.currentBaseHistoryInfo.type="SectionBreak"),this.removeBlock(r,!1,!0),this.addRemovedNodes(r),(0,a.le)(I)){if((0,a.le)(F)){var E=e.getParagraphLength(w)+1;this.editorHistory&&!(0,a.le)(this.editorHistory.currentBaseHistoryInfo)&&(this.updateHistoryPosition(e.start,!0),this.editorHistory.currentBaseHistoryInfo.endPosition=this.selection.getHierarchicalIndex(w,E.toString()))}else e.selectParagraphInternal(F,!1),this.setPositionForHistory()}else e.selectParagraphInternal(I,!0)}}else if(this.owner.enableTrackChanges&&r.nextRenderedWidget instanceof o.ZH&&(0===r.characterFormat.revisionLength||!this.isInsertRevisionByCurrentUser(r.characterFormat))){if(!this.isDeleteRevisionByCurrentUser(r.characterFormat)){var R=this.retrieveRevisionByType(r.characterFormat,"Deletion");if(r.characterFormat.revisionLength>0&&!(0,a.le)(R)){if(this.owner.editorModule.initComplexHistory("RemoveAndAddRevision"),this.editorHistory&&this.owner.editorHistory.currentHistoryInfo){this.owner.editorModule.initHistory("RemoveRevision");var T=r.characterFormat.getRevision(0);this.owner.editorHistory.currentBaseHistoryInfo.modifiedProperties.push(T.revisionID),this.editorHistory.updateHistory(),this.unlinkRevisionFromItem(r.characterFormat);var S=this.insertRevision(r.characterFormat,"Deletion");this.owner.editorModule.initHistory("AddRevision"),this.owner.editorHistory.currentBaseHistoryInfo.modifiedProperties.push(S.revisionID),this.editorHistory.updateHistory()}this.owner.editorHistoryModule&&this.owner.editorHistoryModule.updateComplexHistory()}else{var B=this.insertRevision(r.characterFormat,"Deletion");this.owner.editorHistory&&this.owner.editorHistory.currentBaseHistoryInfo&&(this.owner.editorHistory.currentBaseHistoryInfo.action="AddRevision",this.owner.editorHistory.currentBaseHistoryInfo.modifiedProperties.push(B.revisionID))}}e.selectParagraphInternal(I,!0)}else{r=r.combineWidget(this.owner.viewer);var O=this.documentHelper.selection.getParagraphLength(r),A=this.selection.getHierarchicalIndex(r,O.toString()),N=this.splitParagraph(r,r.firstChild,0,e.start.currentWidget,e.start.offset,!0);this.removePrevParaMarkRevision(r,!0,!0),this.deleteParagraphMark(N,e,0),this.addRemovedNodes(r),e.selectByHierarchicalIndex(A,A)}this.reLayout(e)}else{var M=l.element;if(M instanceof o.h){var D=this.selection.currentContentControl;if(this.selection.selectContentControlInternal(D),!(0,a.le)(D)&&1===M.type&&D.contentControlProperties.lockContentControl&&(0,a.le)(M.nextElement)){if(!this.selection.isEmpty)return;this.delete()}if(!(0,a.le)(D)&&0===M.type&&M.nextElement!==D.reference||!(0,a.le)(D)&&0===M.type&&D.contentControlProperties.lockContentControl&&M.nextElement===D.reference)return}else this.singleDeleteInternal(e,t,r)}e.start.currentWidget.getInline(e.start.offset+1,0).element instanceof o.aQ&&(e.start.offset++,e.end.offset++)}}},e.prototype.isInsertRevisionByCurrentUser=function(e){if(e.revisionLength>0)for(var t=this.owner.currentUser?this.owner.currentUser:"Guest user",i=0;i<e.revisionLength;i++){var r=e.getRevision(i);if(r.author===t&&"Insertion"===r.revisionType)return!0}return!1},e.prototype.isDeleteRevisionByCurrentUser=function(e){if(e.revisionLength>0)for(var t=this.owner.currentUser?this.owner.currentUser:"Guest user",i=0;i<e.revisionLength;i++){var r=e.getRevision(i);if(r.author===t&&"Deletion"===r.revisionType)return!0}return!1},e.prototype.singleDeleteInternal=function(e,t,i){t||(e.owner.isShiftingEnabled=!0,this.initHistory("Delete")),this.checkInsertPosition(e)&&(this.updateHistoryPosition(e.start,!0),this.editorHistory.currentBaseHistoryInfo.endPosition=this.editorHistory.currentBaseHistoryInfo.insertPosition);var r=this.selection.getParagraphInfo(e.start),o=e.start.currentWidget,n=e.start.offset,s=e.getLineLength(e.start.currentWidget);if(n>=s&&(o=o.nextLine,n-=s),this.removeAtOffset(o,e,n),this.owner.enableTrackChanges&&!(0,a.le)(this.editorHistory)&&this.editorHistory.currentBaseHistoryInfo&&"Delete"===this.editorHistory.currentBaseHistoryInfo.action&&!this.editorHistory.currentBaseHistoryInfo.lastDeletedNodeRevision)this.setPositionParagraph(r.paragraph,r.offset,!1);else if(this.owner.enableTrackChanges&&!this.skipTracking())this.setPositionParagraph(r.paragraph,r.offset+1,!1);else{this.setPositionParagraph(r.paragraph,r.offset,!1);var l=e.start.currentWidget;(0,a.le)(l)||!l.isEndsWithLineBreak||(0,a.le)(l.nextLine)||e.start.offset!==this.selection.getLineLength(l)||(e.start.setPositionFromLine(l.nextLine,0),e.end.setPositionInternal(e.start))}t?this.fireContentChange():this.reLayout(e)},e.prototype.deleteParagraphMark=function(e,t,i,r,n,s){if(!(0,a.le)(e.containerWidget)){e=e.combineWidget(this.owner.viewer);var l=t.getNextParagraphBlock(e);if(!(e.isInsideTable&&(0,a.le)(e.nextWidget)||(0,a.le)(l))){var d=void 0;d=t.getNextRenderedBlock(e) instanceof o.dm?t.getNextRenderedBlock(e):void 0;var h=!!(0,a.le)(r)||!r||this.handleDeleteParaMark(e);if(l.isInsideTable&&!(0,a.le)(d)&&d.contains(l.associatedCell)){if(i<4&&h){var c=0;this.removeBlock(e),this.documentHelper.layout.clearListElementBox(l),this.documentHelper.layout.clearListElementBox(e);for(var p=e.childWidgets.length-1;p>=0;p--)for(var g=e.childWidgets[p],m=g.children.length-1;m>=0;m--){var u=g.children[m];c+=u.length,l.firstChild.children.unshift(u),u.line=l.firstChild}this.documentHelper.layout.reLayoutParagraph(l,0,0),c>0&&(t.editPosition=this.selection.getHierarchicalIndex(l,c.toString()))}}else if(i<4&&(l=l.combineWidget(this.owner.viewer),this.documentHelper.layout.clearListElementBox(l),this.documentHelper.layout.clearListElementBox(e),this.updateEditPositionOnMerge(e,l),h)){this.combineRevisionsAndViewBasedOnUntrackedContent(e.characterFormat);var f=this.selection.getParagraphEndPosition(e),y=this.selection.getHierarchicalIndexByPosition(f);l.bodyWidget.index!==e.bodyWidget.index&&(this.deleteSection(t,e.bodyWidget,l.bodyWidget,i),this.editorHistory.currentBaseHistoryInfo.type="SectionBreak"),e=e.combineWidget(this.owner.viewer);for(var p=0;p<l.childWidgets.length;p++){var v=l.childWidgets[p];l.childWidgets.splice(p,1),e.childWidgets.push(v),v.paragraph=e,p--}if(l.characterFormat.revisionLength>0)for(var p=0;p<l.characterFormat.revisionLength;p++){var H=l.characterFormat.getRevision(p);H.ownerNode=this.getOwnerNodeForRevision(e.characterFormat),e.characterFormat.addRevision(H)}this.addRemovedRevisionInfo(l);for(var p=0;p<l.floatingElements.length;p++){var C=l.floatingElements[p];l.floatingElements.splice(p,1),e.floatingElements.push(C),p--}e.getAllRevisions(!0),this.updateRevisionForCombinedPara(y),0===l.childWidgets.length&&l.childWidgets.push(new o.z7(l)),this.documentHelper.layout.reLayoutParagraph(e,0,0),this.updateBookmarkEnd(e),this.removeBlock(l),this.documentHelper.layout.reLayoutParagraph(e,0,0),this.editorHistory&&this.editorHistory.currentBaseHistoryInfo&&"Insert"!==this.editorHistory.currentBaseHistoryInfo.action&&!s&&this.addRemovedNodes(l,n)}}}},e.prototype.updateBookmarkEnd=function(e){var t=e.lastChild;if(!(0,a.le)(t))for(var i=0;i<t.children.length;i++){var r=t.children[i];r instanceof o.aQ&&1===r.bookmarkType&&!(0,a.le)(r.properties)&&r.properties.hasOwnProperty("isAfterParagraphMark")&&r.properties.isAfterParagraphMark&&(r.properties.isAfterParagraphMark=!1,this.owner.documentHelper.render.isBookmarkEndAtStart(r)&&(r.properties=void 0),r.line.paragraph.isUpdateBookmarkEnd=!0)}},e.prototype.handleDeleteParaMark=function(e,t,i){if(!this.owner.enableTrackChanges&&e.characterFormat.revisionLength>0)for(var r=0;r<e.characterFormat.revisionLength;r++){var o=e.characterFormat.getRevision(r);return e.characterFormat.removeRevision(r),this.owner.trackChangesPane.updateCurrentTrackChanges(o),0===o.getRange().length&&this.owner.revisions.remove(o),!0}if(this.owner.enableTrackChanges){var n=!1;if(!(e.characterFormat.revisionLength>
10))return i||(this.insertRevision(e.characterFormat,"Deletion"),this.updateLastDeletedRevision(e)),!1;var s=this.retrieveRevisionByType(e.characterFormat,"Deletion");if(!(0,a.le)(s)){if(!i){var l=e.characterFormat.getAllRevision().indexOf(s);e.characterFormat.removeRevision(l),this.owner.trackChangesPane.updateCurrentTrackChanges(s),0===s.getRange().length&&this.owner.revisions.remove(s)}n=!1}var d=this.retrieveRevisionByType(e.characterFormat,"Insertion");if(!(0,a.le)(d)&&this.isRevisionMatched(e.characterFormat,"Insertion")){if((0,a.le)(this.owner.editorHistoryModule)||(0,a.le)(this.owner.editorHistoryModule.currentBaseHistoryInfo)||this.owner.editorHistoryModule.currentBaseHistoryInfo.recordInsertRevisionDeletetion(e),t||i)i||(0,a.le)(this.editorHistory)||(0,a.le)(this.editorHistory.currentBaseHistoryInfo)||this.editorHistory.currentBaseHistoryInfo.isSameUserDeleteParaMark||(this.editorHistory.currentBaseHistoryInfo.isSameUserDeleteParaMark=!0);else{var l=e.characterFormat.getAllRevision().indexOf(d);e.characterFormat.removeRevision(l),this.owner.trackChangesPane.updateCurrentTrackChanges(d),0===d.getRange().length&&this.owner.revisions.remove(d)}n=!0}if(!n)return i||(this.insertRevision(e.characterFormat,"Deletion"),this.updateLastDeletedRevision(e)),!1}return!0},e.prototype.retrieveRevisionByType=function(e,t){for(var i=0;i<e.revisionLength;i++)if(e.revisions[i].revisionType===t)return e.revisions[i]},e.prototype.updateRevisionForCombinedPara=function(e){var t=this.documentHelper.selection.getTextPosBasedOnLogicalIndex(e),i=this.selection.getElementInfo(t.currentWidget,t.offset);if(i&&i.element){var r=i.element,o=r?r.nextNode:void 0;(0,a.le)(o)||(0,a.le)(r)||(o=o.nextValidNodeForTracking,r=r.nextValidNodeForTracking,!(0,a.le)(o)&&!(0,a.le)(r)&&o.revisionLength>0&&r.revisionLength>0&&this.combineElementRevisions(r,o))}},e.prototype.updateEditPositionOnMerge=function(e,t){this.documentHelper.selection.editPosition===this.selection.getHierarchicalIndex(t,"0")&&void 0===t.nextRenderedWidget&&(this.documentHelper.selection.editPosition=this.selection.getHierarchicalIndex(e,this.documentHelper.selection.getLineLength(e.lastChild).toString()))},e.prototype.checkEndPosition=function(e){return this.editorHistory&&!(0,a.le)(this.editorHistory.currentBaseHistoryInfo)&&(0,a.le)(this.editorHistory.currentBaseHistoryInfo.endPosition)},e.prototype.checkInsertPosition=function(e){return this.editorHistory&&!(0,a.le)(this.editorHistory.currentBaseHistoryInfo)&&(0,a.le)(this.editorHistory.currentBaseHistoryInfo.insertPosition)},e.prototype.checkIsNotRedoing=function(){return this.documentHelper.owner.enableHistoryMode&&!this.editorHistory.isRedoing},e.prototype.deleteSelectedContentInternal=function(e,t,i,r){var n=i,s=r;i.isExistBefore(r)||(n=r,s=i);var l=this.selection.getParagraphInfo(n);e.editPosition=this.selection.getHierarchicalIndex(l.paragraph,l.offset.toString());var d=!1;if(t&&n.isInSameParagraph(s)&&(n.offset<s.offset&&n.offset===e.getParagraphLength(s.paragraph)&&(d=e.getNextRenderedBlock(n.paragraph) instanceof o.dm,!(0,a.le)(this.editorHistory)&&!(0,a.le)(this.editorHistory.currentBaseHistoryInfo)&&("Accept All"===this.editorHistory.currentBaseHistoryInfo.action||"Accept Change"===this.editorHistory.currentBaseHistoryInfo.action||"Reject All"===this.editorHistory.currentBaseHistoryInfo.action||"Reject Change"===this.editorHistory.currentBaseHistoryInfo.action||this.editorHistory.isUndoing||this.editorHistory.isRedoing)&&(d=!1)),1===s.offset&&s.offset>e.getParagraphLength(s.paragraph)&&!(s.paragraph.isInsideTable&&(0,a.le)(s.paragraph.nextWidget))&&(t=!1)),!d){e.owner.isShiftingEnabled=!0,this.checkInsertPosition(e)&&(this.editorHistory.currentBaseHistoryInfo.insertPosition=e.editPosition);var h=t?1:0;this.deleteSelectedContent(s.paragraph,e,n,s,h)}return d},e.prototype.initHistory=function(e){this.documentHelper.owner.enableHistoryMode&&this.editorHistory.initializeHistory(e)},e.prototype.initComplexHistory=function(e){this.documentHelper.owner.enableHistoryMode&&this.editorHistory.initComplexHistory(this.documentHelper.selection,e)},e.prototype.insertPicture=function(e,t,i,r,n){var l=this,d=new o.XY(!0);if(d.width=t,d.height=i,(0,a.le)(r)&&""==r||(d.alternateText=r),d.textWrappingStyle="Inline",".svg"===s.o_.formatClippedString(e).extension)d.metaFileImageString=e,d.isMetaFile=!0,this.generateFallBackImage(e,t,i,d,n),this.owner.enableCollaborativeEditing||(this.documentHelper.addBase64StringInCollection(d),d.element.src=this.documentHelper.getImageString(d),this.insertPictureInternal(d,n));else if(!(0,a.le)(this.documentHelper)){d.imageString=e,d.element.crossOrigin="Anonymous",this.documentHelper.addBase64StringInCollection(d);var h=this.documentHelper.getImageString(d);!(0,a.le)(h)&&(s.o_.startsWith(h,"http://")||s.o_.startsWith(h,"https://"))&&(new
1URL(h),this.viewer.documentHelper.getBase64(e,t,i).then(function(e){(0,a.le)(l.viewer)||(0,a.le)(l.viewer.documentHelper)||(l.viewer.documentHelper.images.get(parseInt(d.imageString))[1]=e,d.element.src=e)})),d.element.src=h,this.insertPictureInternal(d,n)}},e.prototype.generateFallBackImage=function(e,t,i,r,o){var n=this,s=new Image;s.onload=function(){n.isImageInsert&&n.owner.enableCollaborativeEditing&&(n.isRemoteAction=!0);var e=Math.max(1,window.devicePixelRatio||1),a=document.createElement("canvas");a.width=t*e,a.height=i*e;var l=a.getContext("2d");l.scale(e,e),l.drawImage(s,0,0,t,i),n.owner.enableCollaborativeEditing&&(n.documentHelper.addBase64StringInCollection(r),r.element.src=n.documentHelper.getImageString(r),n.insertPictureInternal(r,o,n.isRemoteAction),n.isImageInsert=!1,n.isRemoteAction=!1),n.viewer.documentHelper.images.get(parseInt(r.imageString))[1]=a.toDataURL("image/png",1)},s.src=e,this.isRemoteAction&&this.insertInlineInSelection(this.selection,r)},e.prototype.insertPictureInternal=function(e,t,i){var r=this.documentHelper.selection,o=this.checkAndRemoveComments();if(this.initHistory("InsertInline"),t&&this.fitImageToPage(r,e),this.owner.enableCollaborativeEditing){var n=void 0,a=void 0;e.isMetaFile?(n=this.documentHelper.images.get(parseInt(e.imageString))[1].toString(),a=this.documentHelper.images.get(parseInt(e.metaFileImageString))[0].toString()):n=this.documentHelper.images.get(parseInt(e.imageString)).toString();var l={imageString:n,height:s.o_.convertPixelToPoint(e.height),width:s.o_.convertPixelToPoint(e.width),metaString:a,alternativeText:e.alternateText};this.editorHistory.currentBaseHistoryInfo.insertedData=l,this.editorHistory.currentBaseHistoryInfo.insertedText=R.j5.Image}i||this.insertInlineInSelection(r,e),this.reLayout(r),this.updateHistoryForComments(o)},e.prototype.fitImageToPage=function(e,t){var i=e.start.paragraph.bodyWidget,r=i.sectionFormat.pageHeight-i.sectionFormat.topMargin-i.sectionFormat.topMargin,n=0;if(i instanceof o.VB&&i.sectionFormat.columns.length>1){var a=i.columnIndex;n=i.sectionFormat.columns[a].width}else n=s.o_.convertPointToPixel(i.sectionFormat.pageWidth-i.sectionFormat.leftMargin-i.sectionFormat.rightMargin);t.width>n&&(t.height=t.height*n/t.width,t.width=n),t.height>r&&(t.width=t.width*r/t.height,t.height=r)},e.prototype.insertInlineInSelection=function(e,t){this.checkIsNotRedoing()&&(e.owner.isShiftingEnabled=!0),e.isEmpty||this.removeSelectedContents(e),!(0,a.le)(this.editorHistory)&&this.editorHistory.currentBaseHistoryInfo&&this.owner.enableCollaborativeEditing&&(this.editorHistory.currentBaseHistoryInfo.insertedElement=t,t instanceof o.Xw?this.editorHistory.currentBaseHistoryInfo.insertedText=0==t.commentType?R.j5.Marker_Start:R.j5.Marker_End:t instanceof o.R5?(this.editorHistory.currentBaseHistoryInfo.insertedText=R.j5.Marker_Start,this.editorHistory.currentBaseHistoryInfo.markerData.push(this.getMarkerData(t))):(t instanceof o.aQ||t instanceof o.Cw||t instanceof o.jn||t instanceof o.V8||t instanceof o.a3&&0==t.removedIds.length)&&(this.editorHistory.currentBaseHistoryInfo.markerData.push(this.getMarkerData(t,this.editorHistory.isUndoing)),t instanceof o.V8&&0===t.fieldType&&(this.editorHistory.currentBaseHistoryInfo.fieldBegin=t))),this.updateInsertPosition(),this.insertInlineInternal(t),this.checkEndPosition(e)&&this.updateHistoryPosition(e.start,!1),this.fireContentChange()},e.prototype.onPortrait=function(){var e=new l.Z,t=this.documentHelper.selection.sectionFormat.pageWidth,i=this.documentHelper.selection.sectionFormat.pageHeight;t>i&&(e.pageWidth=i,e.pageHeight=t),this.onApplySectionFormat(void 0,e)},e.prototype.onLandscape=function(){var e=new l.Z,t=this.documentHelper.selection.sectionFormat.pageWidth,i=this.documentHelper.selection.sectionFormat.pageHeight;t<i&&(e.pageWidth=i,e.pageHeight=t),this.onApplySectionFormat(void 0,e)},e.prototype.copyValues=function(){var e=new l.Z;return e.bottomMargin=this.documentHelper.selection.sectionFormat.bottomMargin,e.topMargin=this.documentHelper.selection.sectionFormat.topMargin,e.leftMargin=this.documentHelper.selection.sectionFormat.leftMargin,e.rightMargin=this.documentHelper.selection.sectionFormat.rightMargin,e.pageHeight=this.documentHelper.selection.sectionFormat.pageHeight,e.pageWidth=this.documentHelper.selection.sectionFormat.pageWidth,e.footerDistance=this.documentHelper.selection.sectionFormat.footerDistance,e.headerDistance=this.documentHelper.selection.sectionFormat.headerDistance,e.differentOddAndEvenPages=this.documentHelper.selection.sectionFormat.differentOddAndEvenPages,e.differentFirstPage=this.documentHelper.selection.sectionFormat.differentFirstPage,e},e.prototype.changeMarginValue=function(e){var t=this.copyValues();"lastCustomSetting"===e||"normal"===e?(t.topMargin=72,t.bottomMargin=72,t.leftMargin=72,t.rightMargin=72):"narrow"===e?(t.topMargin=36,t.bottomMargin=36,t.leftMargin=36,t.rightMargin=36):"moderate"===e?(t.topMargin=72,t.bottomMargin=72,t.leftMargin=54,t.rightMargin=54):"wide"===e?(t.topMargin=72,t.bottomMargin=72,t.leftMargin=144,t.rightMargin=144):"mirrored"===e?(t.topMargin=72,t.bottomMargin=72,t.leftMargin=90,t.rightMargin=72):"office2003Default"===e&&(t.topMargin=72,t.bottomMargin=72,t.leftMargin=90,t.rightMargin=90),this.onApplySectionFormat(void 0,t)},e.prototype.onPaperSize=function(e){var t=this.copyValues(),i=this.documentHelper.selection.sectionFormat.pageWidth,r=this.documentHelper.selection.sectionFormat.pageHeight;"letter"===e?i<r?(t.pageWidth=612,t.pageHeight=792):(t.pageWidth=792,t.pageHeight=612):"tabloid"===e?i<r?(t.pageWidth=792,t.pageHeight=1224):(t.pageWidth=1224,t.pageHeight=792):"legal"===e?i<r?(t.pageWidth=612,t.pageHeight=1008):(t.pageWidth=1008,t.pageHeight=612):"statement"===e?i<r?(t.pageWidth=396,t.pageHeight=612):(t.pageWidth=612,t.pageHeight=396):"executive"===e?i<r?(t.pageWidth=522,t.pageHeight=756):(t.pageWidth=756,t.pageHeight=522):"a3"===e?i<r?(t.pageWidth=841.9,t.pageHeight=1190.55):(t.pageWidth=1190.55,t.pageHeight=841.9):"a4"===e?i<r?(t.pageWidth=595.3,t.pageHeight=841.9):(t.pageWidth=841.9,t.pageHeight=595.3):"a5"===e?i<r?(t.pageWidth=419.55,t.pageHeight=595.3):(t.pageWidth=595.3,t.pageHeight=419.55):"b4"===e?i<r?(t.pageWidth=728.5,t.pageHeight=1031.8):(t.pageWidth=1031.8,t.pageHeight=728.5):"b5"===e&&(i<r?(t.pageWidth=515.9,t.pageHeight=728.5):(t.pageWidth=728.5,t.pageHeight=515.9)),this.onApplySectionFormat(void 0,t)},e.prototype.updateListItemsTillEnd=function(e,t){var i=e.getSplitWidgets(),r=i[i.length-1].nextRenderedWidget;if(!(0,a.le)(r))for(var o=t?this.documentHelper.selection.getNextRenderedBlock(e):e;!(0,a.le)(o)&&!this.documentHelper.isTextInput;)this.updateRenderedListItems(o),o=o.getSplitWidgets().pop().nextRenderedWidget},e.prototype.updateWholeListItems=function(e,t,i){this.documentHelper.renderedLists.clear(),this.documentHelper.renderedLevelOverrides=[],e.bodyWidget.index;for(var r,o=0;o<this.documentHelper.pages.length;o++){for(var n=this.documentHelper.pages[o],s=0;s<n.bodyWidgets.length&&(r=this.getNextBlockForList(n.bodyWidgets[s].firstChild),(0,a.le)(r));s++);if(!(0,a.le)(r))break}
1do{if(!r)break;var l=null;if(t&&(l={paragraph:null,listId:i}),this.updateListItems(r,e,l)){if(!(0,a.le)(l)){if(l.paragraph==e)return null;return l.paragraph}break}r=r.getSplitWidgets().pop().nextRenderedWidget,(0,a.le)(r)||(r=this.getNextBlockForList(r))}while(r);return null},e.prototype.getNextBlockForList=function(e){if(e instanceof o.ZH&&this.documentHelper.layout.isFirstElementWithPageBreak(e)){var t=e.nextRenderedWidget;if(!(0,a.le)(t)&&t.equals(e))return t}return e},e.prototype.updateListItems=function(e,t,i){return e instanceof o.ZH?this.updateListItemsForPara(e,t,i):this.updateListItemsForTable(e,t,i)},e.prototype.updateListItemsForTable=function(e,t,i){if((0,a.le)(i)&&t instanceof o.dm&&e.equals(t))return!0;var r=e.firstChild;do{if(this.updateListItemsForRow(r,t,i))return!0;r=r.getSplitWidgets().pop().nextRenderedWidget}while(r);return!1},e.prototype.updateListItemsForRow=function(e,t,i){var r=e.firstChild;do{var o=this.updateListItemsForCell(r,t,i);if(!(0,a.le)(i)&&!(0,a.le)(i.paragraph)||o)return!0;r=r.nextRenderedWidget}while(r);return!1},e.prototype.updateListItemsForCell=function(e,t,i){if(0===e.childWidgets.length)return!1;var r=e.firstChild;do{var o=this.updateListItems(r,t,i);if(!(0,a.le)(i)&&!(0,a.le)(i.paragraph)||o)return!0;r=r.getSplitWidgets().pop().nextRenderedWidget}while(r);return!1},e.prototype.updateRenderedListItems=function(e){e instanceof o.ZH?(e.isEndsWithColumnBreak&&(e=e.nextRenderedWidget),this.updateRenderedListItemsForPara(e)):this.updateRenderedListItemsForTable(e)},e.prototype.updateRenderedListItemsForTable=function(e){var t=e.firstChild;do this.updateRenderedListItemsForRow(t),t=t.getSplitWidgets().pop().nextRenderedWidget;while(t)},e.prototype.updateRenderedListItemsForRow=function(e){var t=e.firstChild;do this.updateRenderedListItemsForCell(t),t=t.nextRenderedWidget;while(t)},e.prototype.updateRenderedListItemsForCell=function(e){if(0!==e.childWidgets.length){var t=e.firstChild;do this.updateRenderedListItems(t),t=t.getSplitWidgets().pop().nextRenderedWidget;while(t)}},e.prototype.updateListItemsForPara=function(e,t,i){if(e.equals(t))return(0,a.le)(i)||(i.paragraph=e),!0;var r=void 0,o=0;if(!(0,a.le)(e.paragraphFormat)&&!(0,a.le)(e.paragraphFormat.listFormat)){if(!(0,a.le)(i)&&e.paragraphFormat.listFormat.listId===i.listId)return i.paragraph=e,!0;r=this.documentHelper.getListById(e.paragraphFormat.listFormat.listId),o=e.paragraphFormat.listFormat.listLevelNumber}if(!(0,a.le)(r)&&!(0,a.le)(this.documentHelper.getAbstractListById(r.abstractListId))&&!(0,a.le)(this.documentHelper.getAbstractListById(r.abstractListId).levels[o])){var n=this.documentHelper.layout.getListLevel(r,o);this.updateListNumber(n,e,!1)}return!1},e.prototype.updateRenderedListItemsForPara=function(e){if(!(0,a.le)(this.documentHelper.getListById(e.paragraphFormat.listFormat.listId))){var t=this.documentHelper.getListById(e.paragraphFormat.listFormat.listId),i=e.paragraphFormat.listFormat.listLevelNumber;if(!(0,a.le)(t)&&!(0,a.le)(this.documentHelper.getAbstractListById(t.abstractListId))&&!(0,a.le)(this.documentHelper.getAbstractListById(t.abstractListId).levels[e.paragraphFormat.listFormat.listLevelNumber])){var r=this.documentHelper.layout.getListLevel(t,i);this.updateListNumber(r,e,!0)}}},e.prototype.updateListNumber=function(e,t,i){var r,n=void 0;if(t.childWidgets.length>0){var s=t.childWidgets[0];s.children.length>0&&(n=s.children[0])}var l=t.paragraphFormat.listFormat;if(!(0,a.le)(n)&&n.nextElement instanceof o.no&&(r=n.width+n.nextElement.width),!(0,a.le)(n)&&n instanceof o.no){var d=this.documentHelper.layout.getListNumber(t);if(i){var h=n.width;if(n.text=d,this.documentHelper.isIosDevice||this.documentHelper.isLinuxOS){var c=n.text;(c=c===String.fromCharCode(61623)?String.fromCharCode(9679):c===String.fromCharCode(61551)+" "?String.fromCharCode(9675):c)!==n.text&&(n.text=c)}var p=this.documentHelper.textHelper.getTextSize(n,n.characterFormat);p>h&&(n.width=p),this.documentHelper.textHelper.updateTextSize(n,t),!(0,a.le)(r)&&n.width<r&&(n.nextElement.width=r-n.width)}}else(0,a.le)(l)||-1===l.listId||(0,a.le)(n)||!n.isVisible||this.documentHelper.layout.getListNumber(t)},e.prototype.getOffsetValue=function(e){if(this.startParagraph){var t=e.getLineInfoBasedOnParagraph(this.startParagraph,this.startOffset);e.start.setPositionFromLine(t.line,t.offset)}if(e.start.updatePhysicalPosition(!0),e.isEmpty)e.end.setPositionInternal(e.start);else{if(this.endParagraph){var t=e.getLineInfoBasedOnParagraph(this.endParagraph,this.endOffset);e.end.setPositionFromLine(t.line,t.offset)}e.end.updatePhysicalPosition(!0)}},e.prototype.setPositionParagraph=function(e,t,i){var r=this.documentHelper.selection,o=r.getLineInfoBasedOnParagraph(e,t);r.start.setPositionFromLine(o.line,o.offset),r.end.setPositionInternal(r.start),i||r.fireSelectionChanged(!0)},e.prototype.setPositionForCurrentIndex=function(e,t){var i=this.selection.getParagraph({index:t});if(!(0,a.le)(i)){var r=this.selection.getLineInfoBasedOnParagraph(i.paragraph,i.offset);e.setPositionForLineWidget(r.line,r.offset)}},e.prototype.insertPageNumber=function(e){if(!this.owner.isReadOnlyMode){var t="PAGE "+(e=(0,a.le)(e)?"":" \\*"+e)+" \\* MERGEFORMAT";this.createFields(t)}},e.prototype.insertPageCount=function(e){var t="NUMPAGES "+(e=(0,a.le)(e)?"":" *"+e)+" * MERGEFORMAT";this.createFields(t)},e.prototype.createFields=function(e){var t=new o.ZH,i=new o.z7(t),r=new o.V8(0);i.children.push(r);var n=new o.Un;n.fieldBegin=r,n.text="1";var s=new o.a3;s.text=e,i.children.push(s);var a=new o.V8(2);a.fieldBegin=r,r.fieldSeparator=a,i.children.push(a),i.children.push(n);var d=new o.V8(1);d.fieldBegin=r,d.fieldSeparator=a,a.fieldEnd=d,r.fieldEnd=d,i.children.push(d),r.line=i,t.childWidgets.push(i),this.documentHelper.fields.push(r);var h=new o.VB;h.sectionFormat=new l.Z(h),h.childWidgets.push(t),this.pasteContentsInternal([h],!1)},e.prototype.insertBookmark=function(e,t){if(!(!(!(0,a.le)(this.owner.optionsPaneModule)&&this.owner.optionsPaneModule.isBuildHeading)&&this.selection.isPlainContentControl())){var i=!1;if(this.documentHelper.bookmarks.containsKey(e)){var r=this.documentHelper.bookmarks.get(e);if(i=!0,this.initComplexHistory("InsertBookmark"),this.documentHelper.owner.editorModule.isRemoteAction=!0,this.deleteBookmark(e),this.documentHelper.owner.editorModule.isRemoteAction=!1,(0,a.le)(r.reference)||(0,a.le)(r.reference.paragraph.associatedCell)){if(!(0,a.le)(r.properties)){var o=parseInt(r.properties.columnFirst),n=r.paragraph.associatedCell.ownerRow,s=n.getCellUsingColumnIndex(n.rowIndex,o);!(0,a.le)(s)&&s.isRenderBookmarkStart&&(s.isRenderBookmarkStart=!1)}}else{var n=r.reference.paragraph.associatedCell.ownerRow;if(n.isRenderBookmarkEnd&&(n.isRenderBookmarkEnd=!1),!(0,a.le)(r.properties)){var o=parseInt(r.properties.columnFirst),l=r.paragraph.associatedCell.ownerRow,s=l.getCellUsingColumnIndex(l.rowIndex,o);(0,a.le)(s)||(s.isRenderBookmarkStart=!1);for(var d=parseInt(r.properties.columnLast),h=r.reference.paragraph.associatedCell.ownerRow,c=void 0,p=d;(0,a.le)(c)&&p>-1;)c=h.getCell(h.rowIndex,p),(0,a.le)(c)&&p--;c.isRenderBookmarkEnd&&(c.isRenderBookmarkEnd=!1)}}}var g=this.createBookmarkElements(e),m=g[0],u=g[1];if(m.properties=this.selection.getBookmarkProperties(m),u.properties=this.selection.getBookmarkProperties(u),this.owner.isShiftingEnabled=!0,i||this.initComplexHistory("InsertBookmark"),this.insertElements([u],[m],!0,t),this.editorHistory&&this.editorHistory.updateComplexHistoryInternal(),this.documentHelper.owner.enableHeaderAndFooter&&this.updateHeaderFooterWidget(),this.updateBookmarkCollection(e,m),(0,a.le)(m.properties)){this.selection.start.setPositionForSelection(m.line,m,1,this.selection.start.location);var f=0;!(0,a.le)(u.properties)&&u.properties.isAfterParagraphMark&&(f=2),this.selection.end.setPositionForSelection(u.line,u,f,this.selection.end.location);var y=this.documentHelper.blockToShift;if(!(0,a.le)(y)&&this.viewer instanceof x._&&y.bodyWidget.sectionFormat.columns.length>1){var v=this.documentHelper.layout.getBodyWidget(y.bodyWidget,!1);(0,a.le)(v.nextRenderedWidget)||"NoBreak"!==v.nextRenderedWidget.sectionFormat.breakCode||v.page!==v.nextRenderedWidget.page||this.reLayout(this.selection)}this.owner.isShiftingEnabled=!1,this.selection.fireSelectionChanged(!0)}else this.selection.selectBookmarkInTable(m),this.documentHelper.owner.isShiftingEnabled=!1;this.fireContentChange(),!0==this.owner.documentEditorSettings.showBookmarks&&this.viewer.updateScrollBars()}},e.prototype.updateBookmarkCollection=function(e,t){var i=this.documentHelper.bookmarks;if(i.containsKey(e)){var r=i.keys.indexOf(e);r>-1&&(i.keys.splice(r,1),i.values.splice(r,1))}var o=this.selection.getElementPosition(t,!1,!1).startPosition;if((0,a.le)(o)){i.add(e,t);return}for(var n=i.keys,s=i.values,l=s.length,d=0,h=s.length-1;d<=h;){var c=Math.floor((d+h)/2),p=s[parseInt(c.toString(),10)],g=this.selection.getElementPosition(p,!1,!1).startPosition;if((0,a.le)(g)){h=c-1,l=c;continue}o.isExistBefore(g)?(h=c-1,l=c):d=c+1}n.splice(l,0,e),s.splice(l,0,t)},e.prototype.createBookmarkElements=function(e){var t=new o.aQ(0);t.name=e;var i=new o.aQ(1);return i.name=e,t.reference=i,i.reference=t,[t,i]},e.prototype.deleteBookmark=function(e){var t=this.documentHelper.bookmarks.get(e);if(t instanceof o.aQ){var i=t.reference,r=this.selection.start.clone(),n=this.selection.end.clone();this.selection.isForward||(r=this.selection.end.clone(),n=this.selection.start.clone());var s=this.selection.getElementInfo(r.currentWidget,r.offset),l=!1,d=void 0,h=void 0;(0,a.le)(s.element)||s.element===t||s.element.nextElement!==t||(h=this.selection.getElementInfo(r.currentWidget,r.offset),s=this.selection.getElementInfo(r.currentWidget,r.offset+1),r.offset+=1),s.element===t&&(l=!0,d=this.selection.getElementInfo(r.currentWidget,0===r.offset?r.offset+2:r.offset+1));var c=this.selection.getElementInfo(n.currentWidget,n.offset);c.element===i&&(c=this.selection.getElementInfo(n.currentWidget,n.offset-1)),this.selection.start.setPositionParagraph(t.line,t.line.getOffset(t,t.length)),this.selection.end.setPositionParagraph(i.line,i.line.getOffset(i,i.length)-1),this.initHistory("DeleteBookmark"),this.selection.selectPosition(r,n),this.editorHistory&&this.editorHistory.currentBaseHistoryInfo&&(this.editorHistory.currentBaseHistoryInfo.insertedText=R.j5.Marker_Start,this.editorHistory.currentBaseHistoryInfo.markerData.push({bookmarkName:e}),this.editorHistory.currentBaseHistoryInfo.setBookmarkInfo(t)),this.deleteBookmarkInternal(t),this.editorHistory&&this.editorHistory.updateHistory(),l&&!(0,a.le)(d)&&d.element!==t&&d.element!==i?(this.selection.start.setPositionParagraph(d.element.line,d.element.line.getOffset(d.element,d.index)-1),l=!0):l=!1,(0,a.le)(c.element)||c.element===t||c.element===i||this.selection.end.setPositionParagraph(c.element.line,c.element.line.getOffset(c.element,c.index)),c.element===t&&!(0,a.le)(d)&&d.element===i&&(l||(0,a.le)(h)?(0,a.le)(h)&&d.element===i&&(r.offset=0===r.offset?r.offset:r.offset-1,this.selection.selectPosition(r,r)):(this.selection.start.setPositionParagraph(h.element.line,h.element.line.getOffset(h.element,h.index)),this.selection.selectPosition(this.selection.start,this.selection.start)))}this.fireContentChange(),!0==this.owner.documentEditorSettings.showBookmarks&&this.viewer.updateScrollBars()},e.prototype.deleteBookmarkInternal=function(e){var t=e.previousNode;if(t instanceof o.V8&&0===t.fieldType&&!(0,a.le)(t.formFieldData)&&(t.formFieldData.name=""),(0,a.le)(e.properties)){if(this.documentHelper.selection.isRenderBookmarkAtEnd(e)&&!(0,a.le)(e.reference)&&!(0,a.le)(e.reference.paragraph.associatedCell)){var i=e.reference.paragraph.associatedCell.ownerRow;i.isRenderBookmarkEnd&&(i.isRenderBookmarkEnd=!1)}}else{var r=parseInt(e.properties.columnFirst),i=e.paragraph.associatedCell.ownerRow,n=i.getCellUsingColumnIndex(i.rowIndex,r);(0,a.le)(n)||(n.isRenderBookmarkStart=!1);var s=parseInt(e.properties.columnLast);if(!(0,a.le)(e.reference)&&!(0,a.le)(e.reference.paragraph.associatedCell)){for(var l=e.reference.paragraph.associatedCell.ownerRow,d=void 0,h=s;(0,a.le)(d)&&h>-1;)d=l.getCell(l.rowIndex,h),(0,a.le)(d)&&h--;d.isRenderBookmarkEnd&&(d.isRenderBookmarkEnd=!1)}}this.documentHelper.bookmarks.remove(e.name),e.line.children.splice(e.indexInOwner,1),(0,a.le)(e.reference)||e.reference.line.children.splice(e.reference.indexInOwner,1);var c=e.line.paragraph;if(e.line.paragraph.isInHeaderFooter){var p=void 0;c.containerWidget instanceof o.nb?p=c.containerWidget.getContainerTable().containerWidget:c.containerWidget instanceof o.NB&&(p=c.containerWidget),this.updateHeaderFooterWidget(p)}},e.prototype.getSelectionInfo=function(e){var t=this.selection.start,i=this.selection.end;this.selection.isForward||(t=this.selection.end,i=this.selection.start),i.offset===this.selection.getLineLength(i.currentWidget)+1&&this.selection.isParagraphLastLine(i.currentWidget)||this.owner.documentHelper.isDragging||t.paragraph!==i.paragraph||(i.offset+=1);var r=this.selection.getParagraphInfo(t),n=this.selection.getHierarchicalIndex(r.paragraph,r.offset.toString());r=this.selection.getParagraphInfo(i);var s=this.selection.getHierarchicalIndex(r.paragraph,r.offset.toString()),l=this.selection.selectedWidgets.keys;if(this.selection.isEmpty)return{start:n,end:s};if((0,a.le)(e)||!0!=e||this.selection.hasMergedCells()){if(l[0]instanceof o.nb&&t.paragraph.isInsideTable){var d=this.selection.getCellFromSelectionInTable(0);!(0,a.le)(d)&&d instanceof o.nb&&(n=this.selection.getActualOffset(d,0))}if(l[l.length-1]instanceof o.nb&&i.paragraph.isInsideTable){var h=this.selection.getCellFromSelectionInTable(1);!(0,a.le)(h)&&h instanceof o.nb&&(s=this.selection.getActualOffset(h,1))}}else{if(t.paragraph.isInsideTable){var c=this.selection.getCellFromSelection(0);!(0,a.le)(c)&&c instanceof o.nb&&(n=this.selection.getActualOffset(c,0))}if(i.paragraph.isInsideTable){var p=this.selection.getCellFromSelection(1);!(0,a.le)(p)&&p instanceof o.nb&&(s=this.selection.getActualOffset(p,1))}}return{start:n,end:s}},e.prototype.getParagraphEndOffset=function(e){for(var t=0,i=0;i<e.childWidgets.length;i++)t+=this.selection.getLineLength(e.childWidgets[i]);return t+1},e.prototype.moveBookmarkEnd=function(e,t){var i=this.selection.getTextPosBasedOnLogicalIndex(e.end),r=this.owner.documentHelper.selectionEndPage,o=this.documentHelper.pages[this.documentHelper.pages.length-1],n=!(0,a.le)(r)&&r.bodyWidgets&&r.bodyWidgets.length>0&&r.bodyWidgets[r.bodyWidgets.length-1]?r.bodyWidgets[r.bodyWidgets.length-1]:void 0,s=(0,a.le)(n)||(0,a.le)(n.lastChild)?void 0:n.lastChild;if(r===o&&i&&s&&i.paragraph===s){if(s.childWidgets&&0===s.childWidgets.length||0===s.getLength()){var l=s.previousWidget;if(!(0,a.le)(l)&&l.childWidgets){var d=this.getParagraphEndOffset(l);e.end=this.selection.getHierarchicalIndex(l,d.toString())}}else!(0,a.le)(t[0].properties)&&t[0].properties.hasOwnProperty("isAfterParagraphMark")&&t[0].properties.isAfterParagraphMark&&delete t[0].properties.isAfterParagraphMark}},e.prototype.insertElements=function(e,t,i,r){var n=this.getSelectionInfo(i);i&&!(0,a.le)(t[0].properties)&&0==t[0].bookmarkType&&(n=this.owner.selection.updateSelectionInfo(n)),!(0,a.le)(t)&&(this.insertElementsInternal(this.selection.getTextPosBasedOnLogicalIndex(n.start),t,void 0,r),this.owner.isSpellCheck&&i&&t[0].previousElement&&t[0].previousElement instanceof o.a3&&(t[0].previousElement.isChangeDetected=!0)),!(0,a.le)(e)&&(i&&this.moveBookmarkEnd(n,e),this.insertElementsInternal(this.selection.getTextPosBasedOnLogicalIndex(n.end),e,void 0,r),this.owner.isSpellCheck&&i&&e[0].reference.line!==e[0].line&&e[0].previousElement&&e[0].previousElement instanceof o.a3&&(e[0].previousElement.isChangeDetected=!0))},e.prototype.insertElementsInternal=function(e,t,i,r){this.selection.selectPosition(e,e),this.initHistory("InsertElements"),!(0,a.le)(this.editorHistory)&&this.editorHistory.currentBaseHistoryInfo&&((t[0]instanceof o.aQ&&this.editorHistory||t[0]instanceof o.Cw||t[0]instanceof o.jn||t[0]instanceof o.h)&&this.editorHistory.currentBaseHistoryInfo.markerData.push(this.getMarkerData(t[0])),t[0]instanceof o.a3&&(this.editorHistory.currentBaseHistoryInfo.insertedText=t[0].text,this.setCharFormatForCollaborativeEditing(t[0].characterFormat))),this.updateInsertPosition();var n=0,s=this.selection.getParagraphInfo
1(this.selection.start);if(this.selection.start.paragraph.isEmpty()){var l=this.selection.start.paragraph;l.childWidgets[0].children.push(t[0]),t[0].line=l.childWidgets[0],t[0].linkFieldCharacter(this.documentHelper),!this.owner.enableTrackChanges||this.skipTracking()||this.skipFieldDeleteTracking||this.isInsertingTOC||t[0]instanceof o.aQ||t[0]instanceof o.Xw||t[0]instanceof o.Cw||t[0]instanceof o.jn||this.insertRevision(t[0],"Insertion"),this.documentHelper.layout.reLayoutParagraph(l,0,0),this.setPositionParagraph(s.paragraph,s.offset+length,!0),e.setPositionForSelection(t[0].line,t[0],t[0].length,this.selection.start.location),this.selection.selectPosition(e,e)}else{var d=this.selection.start.currentWidget.getInline(this.documentHelper.selection.start.offset,n),h=d.element;n=d.index;var c=t[0];this.insertElementInternal(h,c,n,void 0,!0,r);for(var p=c.indexInOwner,g=c,m=1;m<t.length;m++)g=t[m],c.line.children.splice(p+m,0,g);e.setPositionForSelection(g.line,g,g.length,this.selection.start.location),this.selection.selectPosition(e,e)}this.editorHistory&&(this.checkEndPosition()&&this.updateHistoryPosition(this.selection.start,!1),this.editorHistory.updateHistory())},e.prototype.getMarkerData=function(e,t,i,r){var n={};if(this.editorHistory.currentBaseHistoryInfo||this.editorHistory.isUndoing||this.editorHistory.isRedoing){if(e instanceof o.aQ){var s="",l="",d=void 0,h=void 0,c=void 0,p=void 0;0==e.bookmarkType?(this.editorHistory.isUndoing||this.editorHistory.isRedoing||(this.editorHistory.currentBaseHistoryInfo.insertedText=R.j5.Marker_Start),(0,a.le)(e.properties)||(s=e.properties.columnFirst,l=e.properties.columnLast)):(this.editorHistory.isUndoing||this.editorHistory.isRedoing||(this.editorHistory.currentBaseHistoryInfo.insertedText=R.j5.Marker_End),(0,a.le)(e.properties)||(d=e.properties.isAfterParagraphMark,h=e.properties.isAfterTableMark,c=e.properties.isAfterRowMark,p=e.properties.isAfterCellMark)),n={bookmarkName:e.name,type:"Bookmark",skipOperation:t,columnFirst:s,columnLast:l,isAfterParagraphMark:d,isAfterTableMark:h,isAfterRowMark:c,isAfterCellMark:p}}else if(e instanceof o.Cw||e instanceof o.jn){var g=void 0;e instanceof o.Cw?(g=e,this.editorHistory.isUndoing||this.editorHistory.isRedoing||(this.editorHistory.currentBaseHistoryInfo.insertedText=R.j5.Marker_Start)):(g=e.editRangeStart,this.editorHistory.isUndoing||this.editorHistory.isRedoing||(this.editorHistory.currentBaseHistoryInfo.insertedText=R.j5.Marker_End)),n={user:""===g.user?g.group:g.user,type:"EditRange",editRangeId:g.editRangeId,skipOperation:t,columnFirst:(0,a.le)(g.columnFirst)?void 0:g.columnFirst.toString(),columnLast:(0,a.le)(g.columnLast)?void 0:g.columnLast.toString()}}else e instanceof o.V8?(0==e.fieldType?this.editorHistory.currentBaseHistoryInfo.insertedText=R.j5.Marker_Start:2==e.fieldType?this.editorHistory.currentBaseHistoryInfo.insertedText=R.j5.Field_Separator:this.editorHistory.currentBaseHistoryInfo.insertedText=R.j5.Marker_End,n={type:"Field"}):e instanceof o.R5?n={type:e.footnoteType}:e instanceof o.a3?this.editorHistory.currentBaseHistoryInfo.insertedText=e.text:e instanceof o.h&&(n={type:"ContentControl",text:e.contentControlWidgetType},0==e.type?((0,a.le)(this.editorHistory.currentBaseHistoryInfo)||(this.editorHistory.currentBaseHistoryInfo.insertedText=R.j5.Marker_Start),n.contentControlProperties=JSON.stringify(this.getContentControlPropObject(e.contentControlProperties))):((0,a.le)(this.editorHistory.currentBaseHistoryInfo)||(this.editorHistory.currentBaseHistoryInfo.insertedText=R.j5.Marker_End),n.contentControlProperties=JSON.stringify(this.getContentControlPropObject(e.contentControlProperties))))}return(0,a.le)(i)||(n=this.getRevisionMarkerData(n,i,t,r)),n},e.prototype.getRevisionMarkerData=function(e,t,i,r){return(0,a.le)(e)&&(e={}),e.revisionType=t.revisionType,e.author=t.author,e.date=t.date,e.skipOperation=i,e.isAcceptOrReject=r,e},e.prototype.getCommentElementBox=function(e){var t=e.split(";"),i=this.documentHelper.comments[parseInt(t[1],10)];return t.length>2&&""!==t[2]?i.replyComments[parseInt(t[2],10)]:i},e.prototype.getBlock=function(e){var t=this.selection.getBodyWidget(e);return this.getBlockInternal(t,e)},e.prototype.getBlockInternal=function(e,t){if(!(""===t.index||(0,a.le)(t))){var i=t.index.indexOf(";"),r=t.index.substring(0,i);t.index=t.index.substring(i).replace(";",""),i=parseInt(r,10);var n=this.selection.getBlockByIndex(e,i);if(n){if(!(t.index.indexOf(";")>=0))return{node:n,position:t};if(n instanceof o.ZH)return t.index.indexOf(";")>=0&&(t.index="0"),{node:n,position:t};if(n instanceof o.$L){var s=this.getBlockInternal(n,t);return{node:(0,a.le)(s)?void 0:s.node,position:(0,a.le)(s)?void 0:s.position}}}return{node:e,position:t}}},e.prototype.updateHistoryPosition=function(e,t){if(this.editorHistory&&!(0,a.le)(this.editorHistory.currentBaseHistoryInfo)){var i=void 0;if(e instanceof r.JK){var o=this.selection.getParagraphInfo(e);i=this.selection.getHierarchicalIndex(o.paragraph,o.offset.toString())}else i=e;t?this.editorHistory.currentBaseHistoryInfo.insertPosition=i:this.editorHistory.currentBaseHistoryInfo.endPosition=i}},e.prototype.getLineStyle=function(e,t){return e.lineStyle===t.lineStyle&&e.lineWidth===t.lineWidth&&e.color===t.color?"Cleared":e.lineStyle},e.prototype.getBorders=function(e,t){var i=[];if(this.selection.isEmpty){if("InsideBorders"===e||"InsideVerticalBorder"===e||"InsideHorizontalBorder"===e)return 0;var r=this.selection.isForward?this.selection.end:this.selection.start;t[0]=r.paragraph.associatedCell}for(var o=0;o<t.length;o++){var n=t[o],s=n.ownerRow===t[0].ownerRow,a=n.columnIndex===t[0].columnIndex,l=n.ownerRow===t[t.length-1].ownerRow,d=n.columnIndex+n.cellFormat.columnSpan-1===t[t.length-1].columnIndex;("TopBorder"===e||"OutsideBorders"===e||"AllBorders"===e)&&s&&i.push({border:n.cellFormat.borders.top,type:"top"}),("BottomBorder"===e||"OutsideBorders"===e||"AllBorders"===e)&&l&&i.push({border:n.cellFormat.borders.bottom,type:"bottom"}),("LeftBorder"===e||"OutsideBorders"===e||"AllBorders"===e)&&a&&i.push({border:n.cellFormat.borders.left,type:"left"}),("RightBorder"===e||"OutsideBorders"===e||"AllBorders"===e)&&d&&i.push({border:n.cellFormat.borders.right,type:"right"}),"InsideBorders"!==e&&"InsideVerticalBorder"!==e&&"InsideHorizontalBorder"!==e&&"AllBorders"!==e||(d||"InsideHorizontalBorder"===e||i.push({border:n.cellFormat.borders.right,type:"vertical"}),l||"InsideVerticalBorder"===e||i.push({border:n.cellFormat.borders.bottom,type:"horizontal"}))}return i},e.prototype.applyLineStyles=function(e,t,i){var r=this;if("NoBorder"===t.type||"Cleared"===e.lineStyle)return e.lineStyle;var o=t.type,n=e.lineStyle,s=this.selection.getSelectedCells(),a=[];if((a=this.getBorders(o,s)).length>0){var l=s[0].ownerTable.tableFormat.borders,d=a[0].border,h=a[0].type,c=!0;"None"===d.lineStyle&&(c=!1,d="top"===h?l.top:"bottom"===h?l.bottom:"left"===h?l.left:"r
1ight"===h?l.right:"vertical"===h?l.vertical:"horizontal"===h?l.horizontal:d);for(var p=1;p<a.length;p++){var g=a[p].border;if("None"===g.lineStyle&&(c=!1,g="top"===(h=a[p].type)?l.top:"bottom"===h?l.bottom:"left"===h?l.left:"right"===h?l.right:"vertical"===h?l.vertical:"horizontal"===h?l.horizontal:g),g.lineStyle!==d.lineStyle||g.lineWidth!==d.lineWidth||g.color!==d.color)return n}if(c)n=this.getLineStyle(e,d);else if(this.documentHelper.selection.isTableSelected()||(i=l),n="TopBorder"===o?this.getLineStyle(e,i.top):"BottomBorder"===o?this.getLineStyle(e,i.bottom):"LeftBorder"===o?this.getLineStyle(e,i.left):"RightBorder"===o?this.getLineStyle(e,i.right):"InsideHorizontalBorder"===o?n=this.getLineStyle(e,i.horizontal):"InsideVerticalBorder"===o?this.getLineStyle(e,i.vertical):n,"InsideBorders"===o)n=n="Cleared"===this.getLineStyle(e,i.horizontal)&&"Cleared"===this.getLineStyle(e,i.vertical)?"Cleared":n;else if("OutsideBorders"===o||"AllBorders"===o&&this.selection.isEmpty){var m=[this.getLineStyle(e,i.bottom),this.getLineStyle(e,i.right),this.getLineStyle(e,i.left)].every(function(t){return t===r.getLineStyle(e,i.top)});n=m?this.getLineStyle(e,i.top):n}else if("AllBorders"===o){var m=[this.getLineStyle(e,i.bottom),this.getLineStyle(e,i.right),this.getLineStyle(e,i.left),this.getLineStyle(e,i.horizontal),this.getLineStyle(e,i.vertical)].every(function(t){return t===r.getLineStyle(e,i.top)});n=m?this.getLineStyle(e,i.top):n}}return n},e.prototype.applyBorders=function(e){this.initHistory("Borders");var t,i=this.selection.isForward?this.selection.start:this.selection.end,r=this.selection.isForward?this.selection.end:this.selection.start,o=i.paragraph.associatedCell.ownerTable;o=o.combineWidget(this.owner.viewer),this.editorHistory&&this.cloneTableToHistoryInfo(o),i.paragraph.associatedCell;var n=r.paragraph.associatedCell,s=this.getBorder(e.borderColor,e.lineWidth,e.borderStyle);if((0,a.le)(this.editorHistory.currentBaseHistoryInfo)||(this.editorHistory.currentBaseHistoryInfo.insertedFormat=i.paragraph.associatedCell.cellFormat.borders),this.documentHelper.selection.isTableSelected()){if(s.lineStyle=this.applyLineStyles(s,e,o.tableFormat.borders),"TopBorder"===e.type||"OutsideBorders"===e.type||"AllBorders"===e.type){o.tableFormat.borders.top.copyFormat(s);for(var l=0;l<o.childWidgets.length;l++){var d=o.childWidgets[l];if(d.rowFormat.borders.top.clearFormat(),d.childWidgets&&0===l)for(var h=0;h<d.childWidgets.length;h++)d.childWidgets[h].cellFormat.borders.top.clearFormat()}var c=this.getTopBorderCellsOnSelection();if(!(0,a.le)(c)&&c.length>0)for(var l=0;l<c.length;l++)c[l].cellFormat.borders.top&&c[l].cellFormat.borders.top.clearFormat()}if("BottomBorder"===e.type||"OutsideBorders"===e.type||"AllBorders"===e.type){o.tableFormat.borders.bottom.copyFormat(s);for(var l=0;l<o.childWidgets.length;l++){var d=o.childWidgets[l];if(d.rowFormat.borders.bottom.clearFormat(),d.childWidgets&&l===o.childWidgets.length-1)for(var h=0;h<d.childWidgets.length;h++)d.childWidgets[h].cellFormat.borders.bottom.clearFormat()}var c=this.getBottomBorderCellsOnSelection();if(!(0,a.le)(c)&&c.length>0)for(var l=0;l<c.length;l++)c[l].cellFormat.borders.bottom&&c[l].cellFormat.borders.bottom.clearFormat()}if("LeftBorder"===e.type||"OutsideBorders"===e.type||"AllBorders"===e.type){o.tableFormat.borders.left.copyFormat(s);for(var l=0;l<o.childWidgets.length;l++){var d=o.childWidgets[l];if(d.rowFormat.borders.left.clearFormat(),d.childWidgets)for(var h=0;h<d.childWidgets.length;h++){var p=d.childWidgets[h].columnIndex===d.childWidgets[0].columnIndex;p&&d.childWidgets[h].cellFormat.borders.left.clearFormat()}}var c=this.getLeftBorderCellsOnSelection();if(!(0,a.le)(c)&&c.length>0)for(var l=0;l<c.length;l++)c[l].cellFormat.borders.left&&c[l].cellFormat.borders.left.clearFormat()}if("RightBorder"===e.type||"OutsideBorders"===e.type||"AllBorders"===e.type){o.tableFormat.borders.right.copyFormat(s);for(var l=0;l<o.childWidgets.length;l++){var d=o.childWidgets[l];if(d.rowFormat.borders.right.clearFormat(),d.childWidgets)for(var h=0;h<d.childWidgets.length;h++){var g=d.childWidgets[h].columnIndex===d.childWidgets[d.childWidgets.length-1].columnIndex;g&&d.childWidgets[h].cellFormat.borders.right.clearFormat()}}var c=this.getRightBorderCellsOnSelection();if(!(0,a.le)(c)&&c.length>0)for(var l=0;l<c.length;l++)c[l].cellFormat.borders.right&&c[l].cellFormat.borders.right.clearFormat()}if("InsideHorizontalBorder"===e.type||"AllBorders"===e.type||"InsideBorders"===e.type){o.tableFormat.borders.horizontal.copyFormat(s);for(var l=0;l<o.childWidgets.length;l++){var d=o.childWidgets[l];if(d.rowFormat.borders.horizontal.clearFormat(),d.childWidgets)for(var h=0;h<d.childWidgets.length;h++)l!==o.childWidgets.length-1&&d.childWidgets[h].cellFormat.borders.bottom.clearFormat(),0!==l&&d.childWidgets[h].cellFormat.borders.top.clearFormat()}this.applyInsideBorders(s,e.type,o)}if("InsideVerticalBorder"===e.type||"AllBorders"===e.type||"InsideBorders"===e.type){o.tableFormat.borders.vertical.copyFormat(s);for(var l=0;l<o.childWidgets.length;l++){var d=o.childWidgets[l];if(d.rowFormat.borders.vertical.clearFormat(),d.childWidgets)for(var h=0;h<d.childWidgets.length;h++){var g=d.childWidgets[h].columnIndex+d.childWidgets[h].cellFormat.columnSpan-1===d.childWidgets[d.childWidgets.length-1].columnIndex,p=d.childWidgets[h].columnIndex===d.childWidgets[0].c
1olumnIndex;p||d.childWidgets[h].cellFormat.borders.left.clearFormat(),g||d.childWidgets[h].cellFormat.borders.right.clearFormat()}}this.applyInsideBorders(s,e.type,o)}if("NoBorder"===e.type){this.clearAllBorderValues(o.tableFormat.borders);for(var l=0;l<o.childWidgets.length;l++)o.childWidgets[l].rowFormat.borders.clearFormat();this.applyAllBorders(s,e.type)}}else{if(this.selection.isEmpty)s.lineStyle=this.applyLineStyles(s,e,n.cellFormat.borders),("OutsideBorders"===e.type||"AllBorders"===e.type||"LeftBorder"===e.type)&&n.cellFormat.borders.left.copyFormat(s),("OutsideBorders"===e.type||"AllBorders"===e.type||"TopBorder"===e.type)&&n.cellFormat.borders.top.copyFormat(s),("OutsideBorders"===e.type||"AllBorders"===e.type||"RightBorder"===e.type)&&n.cellFormat.borders.right.copyFormat(s),("OutsideBorders"===e.type||"AllBorders"===e.type||"BottomBorder"===e.type)&&n.cellFormat.borders.bottom.copyFormat(s),("AllBorders"===e.type||"InsideBorders"===e.type||"InsideVerticalBorder"===e.type)&&n.cellFormat.borders.vertical.copyFormat(s),("AllBorders"===e.type||"InsideBorders"===e.type||"InsideHorizontalBorder"===e.type)&&n.cellFormat.borders.horizontal.copyFormat(s),"NoBorder"===e.type&&this.clearAllBorderValues(n.cellFormat.borders);else{if(s.lineStyle=this.applyLineStyles(s,e),"OutsideBorders"===e.type||"TopBorder"===e.type)for(var c=this.getTopBorderCellsOnSelection(),l=0;l<c.length;l++)c[l].cellFormat.borders.top.copyFormat(s);if("OutsideBorders"===e.type||"LeftBorder"===e.type)for(var c=this.getLeftBorderCellsOnSelection(),l=0;l<c.length;l++)c[l].cellFormat.borders.left.copyFormat(s);if("OutsideBorders"===e.type||"RightBorder"===e.type)for(var c=this.getRightBorderCellsOnSelection(),l=0;l<c.length;l++)c[l].cellFormat.borders.right.copyFormat(s);if("OutsideBorders"===e.type||"BottomBorder"===e.type)for(var c=this.getBottomBorderCellsOnSelection(),l=0;l<c.length;l++)c[l].cellFormat.borders.bottom.copyFormat(s)}if("BottomBorder"===e.type||"AllBorders"===e.type||"OutsideBorders"===e.type||"NoBorder"===e.type){t=this.getAdjacentCellToApplyBottomBorder();for(var l=0;l<t.length;l++){var m=t[l];"NoBorder"===e.type?m.cellFormat.borders.top.copyFormat(this.clearBorder()):m.cellFormat.borders.top.copyFormat(s)}}if("TopBorder"===e.type||"AllBorders"===e.type||"OutsideBorders"===e.type||"NoBorder"===e.type){t=this.getAdjacentCellToApplyTopBorder();for(var l=0;l<t.length;l++){var m=t[l];"NoBorder"===e.type?m.cellFormat.borders.bottom.copyFormat(this.clearBorder()):m.cellFormat.borders.bottom.copyFormat(s)}}if("AllBorders"===e.type||"OutsideBorders"===e.type||"RightBorder"===e.type||"NoBorder"===e.type){t=this.getAdjacentCellToApplyRightBorder();for(var l=0;l<t.length;l++){var m=t[l];"NoBorder"===e.type?m.cellFormat.borders.left.copyFormat(this.clearBorder()):m.cellFormat.borders.left.copyFormat(s)}}if("AllBorders"===e.type||"OutsideBorders"===e.type||"LeftBorder"===e.type||"NoBorder"===e.type){t=this.getAdjacentCellToApplyLeftBorder();for(var l=0;l<t.length;l++){var m=t[l];"NoBorder"===e.type?m.cellFormat.borders.right.copyFormat(this.clearBorder()):m.cellFormat.borders.right.copyFormat(s)}}("AllBorders"===e.type||"NoBorder"===e.type)&&this.applyAllBorders(s,e.type),("InsideBorders"===e.type||"InsideVerticalBorder"===e.type||"InsideHorizontalBorder"===e.type||"NoBorder"===e.type)&&this.applyInsideBorders(s,e.type,o)}this.updateGridForTableDialog(o,!1),this.reLayout(this.selection,!1),this.editorHistory.updateHistory()},e.prototype.applyAllBorders=function(e,t){for(var i=this.selection.getSelectedCells(),r=0;r<i.length;r++)"NoBorder"===t?(i[r].cellFormat.borders.left.copyFormat(this.clearBorder()),i[r].cellFormat.borders.right.copyFormat(this.clearBorder()),i[r].cellFormat.borders.top.copyFormat(this.clearBorder()),i[r].cellFormat.borders.bottom.copyFormat(this.clearBorder())):(i[r].cellFormat.borders.left.copyFormat(e),i[r].cellFormat.borders.right.copyFormat(e),i[r].cellFormat.borders.top.copyFormat(e),i[r].cellFormat.borders.bottom.copyFormat(e))},e.prototype.applyInsideBorders=function(e,t,i){for(var r=this.selection.getSelectedCells(),o=0;o<r.length;o++){var n=r[o],s=n.ownerRow===r[r.length-1].ownerRow,a=n.columnIndex+n.cellFormat.columnSpan-1===r[r.length-1].columnIndex,l=this.documentHelper.selection.isTableSelected();if("NoBorder"===t?(n.cellFormat.borders.right.copyFormat(this.clearBorder()),n.cellFormat.borders.bottom.copyFormat(this.clearBorder())):(a||"InsideHorizontalBorder"===t||(l?n.cellFormat.borders.right.clearFormat():n.cellFormat.borders.right.copyFormat(e)),s||"InsideVerticalBorder"===t||(l?n.cellFormat.borders.bottom.clearFormat():n.cellFormat.borders.bottom.copyFormat(e))),!s&&"InsideVerticalBorder"!==t){var d=n.ownerRow.rowIndex+n.cellFormat.rowSpan,h=i.childWidgets[d];if(h)for(var c=this.getAdjacentBottomBorderOnEmptyCells(h,n,!0),p=0;p<c.length;p++)"NoBorder"===t?c[p].cellFormat.borders.top.copyFormat(this.clearBorder()):l?c[p].cellFormat.borders.top.clearFormat():c[p].cellFormat.borders.top.copyFormat(e)}if(!a&&"InsideHorizontalBorder"!==t)for(var g=this.getSelectedCellsNextWidgets(n,i),m=0;m<g.length;m++)"NoBorder"===t?g[m].cellFormat.borders.left.copyFormat(this.clearBorder()):l?g[m].cellFormat.borders.left.clearFormat():g[m].cellFormat.borders.left.copyFormat(e)}},e.prototype.getTopBorderCellsOnSelection=function(){for(var e=(this.selection.isForward?this.selection.start:this.selection.end).paragraph.associatedCell,t=[],i=this.selection.getSelectedCells(),r=0;r<i.length;r++)i[r].ownerRow===e.ownerRow&&t.push(i[r]);return t},e.prototype.getLeftBorderCellsOnSelection=function(){for(var e=(this.selection.isForward?this.selection.start:this.selection.end).paragraph.associatedCell,t=this.selection.getSelectedCells(),i=[],r=0;r<t.length;r++)t[r].columnIndex===e.columnIndex&&i.push(t[r]);return i},e.prototype.getRightBorderCellsOnSelection=function(){for(var e=this.selection.getSelectedCells(),t=[],i=0;i<e.length;i++)i<e.length-1&&e[i].containerWidget===e[i+1].containerWidget||t.push(e[i]);return t},e.prototype.getBottomBorderCellsOnSelection=function(){for(var e=(this.selection.isForward?this.selection.end:this.selection.start).paragraph.associatedCell,t=this.selection.getSelectedCells(),i=[],r=0;r<t.length;r++)t[r].ownerRow===e.ownerRow&&i.push(t[r]);return i},e.prototype.clearAllBorderValues=function(e){var t=this.clearBorder();e.bottom.copyFormat(t),e.left.copyFormat(t),e.right.copyFormat(t),e.top.copyFormat(t),e.vertical.copyFormat(t),e.horizontal.copyFormat(t)},e.prototype.clearBorder=function(){var e=new g.V;return e.lineStyle="Cleared",e},e.prototype.getAdjacentCellToApplyTopBorder=function(){var e=[],t=this.selection.start,i=this.selection.end;this.selection.isForward||(t=this.selection.end,i=this.selection.start);var r=t.paragraph.associatedCell.ownerTable;r=r.combineWidget(this.owner.viewer);var o=t.paragraph.associatedCell;if(i.paragraph.associatedCell,this.selection.isEmpty)e=this.getSelectedCellsAboveWidgets(o,r);else for(var n=this.getTopBorderCellsOnSelection(),s=0;s<n.length;s++){var a=n[s];e=e.concat(this.getSelectedCellsAboveWidgets(a,r))}return e},e.prototype.getSelectedCellsAboveWidgets=function(e,t){var i=[],r=e.ownerRow.rowIndex-1,o=t.childWidgets[r];if(!o)return i;var n=1;e.cellFormat&&"number"==typeof e.cellFormat.columnSpan&&e.cellFormat.columnSpan>0&&(n=e.cellFormat.columnSpan);for(var s=0;s<n;s++)for(var a=e.columnIndex+s,l=0;l<o.childWidgets.length;l++){var d=o.childWidgets[l];if(d.columnIndex===a){i.push(d);break}}return i},e.prototype.getAdjacentCellToApplyLeftBorder=function(){var e=[],t=this.selection.start,i=this.selection.end;this.selection.isForward||(t=this.selection.end,i=this.selection.start);var r=t.paragraph.associatedCell.ownerTable;r=r.combineWidget(this.owner.viewer);var o=t.paragraph.associatedCell;if(i.paragraph.associatedCell,this.selection.isEmpty)e=this.getSelectedCellsPrevWidgets(o,r);else for(var n=this.getLeftBorderCellsOnSelection(),s=0;s<n.length;s++){var a=n[s];e=e.concat(this.getSelectedCellsPrevWidgets(a,r))}return e},e.prototype.getSelectedCellsPrevWidgets=function(e,t){var i=[];if(!(0,a.le)(e.previousWidget)){var r=e.previousWidget;if(i.push(r),e.cellFormat.rowSpan>1)for(var o=e.ownerRow.rowIndex+e.cellFormat.rowSpan,n=e.ownerRow.rowIndex+1;n<o;n++){var s=t.childWidgets[n];if(s)for(var l=0;l<s.childWidgets.length;l++){var d=s.childWidgets[l];d.columnIndex===r.columnIndex&&i.push(d)}}}return i},e.prototype.getAdjacentCellToApplyBottomBorder=function(){var e=[],t=this.selection.start,i=this.selection.end;this.selection.isForward||(t=this.selection.end,i=this.selection.start);var r=t.paragraph.associatedCell.ownerTable;r=r.combineWidget(this.owner.viewer);var o=t.paragraph.associatedCell,n=i.paragraph.associatedCell,s=n.ownerRow.rowIndex+n.cellFormat.rowSpan,a=r.childWidgets[s];if(a){if(n.cellFormat.columnSpan>1)for(var l=n.columnIndex;l<n.columnIndex+n.cellFormat.columnSpan;l++)a.childWidgets[l]&&e.push(a.childWidgets[l]);else if(e=this.getAdjacentBottomBorderOnEmptyCells(a,n),!this.selection.isEmpty)for(var l=0;l<a.childWidgets.length;l++){var d=a.childWidgets[l].columnIndex;d>
1=o.columnIndex&&d<=n.columnIndex&&a.childWidgets[l]&&e.push(a.childWidgets[l])}}return e},e.prototype.getAdjacentBottomBorderOnEmptyCells=function(e,t,i){var r=[];if(t.cellFormat.columnSpan>1)for(var o=t.columnIndex;o<t.columnIndex;o++)r.push(e.childWidgets[o]);else if(this.selection.isEmpty||i)for(var o=0;o<e.childWidgets.length;o++)e.childWidgets[o].columnIndex===t.columnIndex&&r.push(e.childWidgets[o]);return r},e.prototype.getAdjacentCellToApplyRightBorder=function(){var e=[],t=this.selection.start,i=this.selection.end;this.selection.isForward||(t=this.selection.end,i=this.selection.start);var r=t.paragraph.associatedCell.ownerTable;if(r=r.combineWidget(this.owner.viewer),t.paragraph.associatedCell,i.paragraph.associatedCell,this.selection.isEmpty){var o=t.paragraph.associatedCell;e=this.getSelectedCellsNextWidgets(o,r)}else for(var n=this.getRightBorderCellsOnSelection(),s=0;s<n.length;s++){var a=n[s];e=e.concat(this.getSelectedCellsNextWidgets(a,r))}return e},e.prototype.getSelectedCellsNextWidgets=function(e,t){var i=[];if(!(0,a.le)(e.nextWidget)&&(i.push(e.nextWidget),e.cellFormat.rowSpan>1))for(var r=e.ownerRow.rowIndex+e.cellFormat.rowSpan,o=e.ownerRow.rowIndex+1;o<r;o++){var n=t.childWidgets[o];if(n)for(var s=0;s<n.childWidgets.length;s++)n.childWidgets[s].columnIndex===e.nextWidget.columnIndex&&i.push(n.childWidgets[s])}return i},e.prototype.getBorder=function(e,t,i){var r=new g.V;return r.color=e||"#000000",r.lineWidth=t||1,r.lineStyle=i||"Single",r},e.prototype.applyBordersInternal=function(e,t){(0,a.le)(e)||(0,a.le)(e)||((0,a.le)(e.top)||this.applyBorder(e.top,t.top),(0,a.le)(e.bottom)||this.applyBorder(e.bottom,t.bottom),(0,a.le)(e.left)||this.applyBorder(e.left,t.left),(0,a.le)(e.right)||this.applyBorder(e.right,t.right),(0,a.le)(e.horizontal)||this.applyBorder(e.horizontal,t.horizontal),(0,a.le)(e.vertical)||this.applyBorder(e.vertical,t.vertical),(0,a.le)(e.diagonalUp)||this.applyBorder(e.diagonalUp,t.diagonalUp),(0,a.le)(e.diagonalDown)||this.applyBorder(e.diagonalDown,t.diagonalDown))},e.prototype.applyShading=function(e,t){(0,a.le)(t)||(0,a.le)(e)||((0,a.le)(t.backgroundColor)||e.backgroundColor===t.backgroundColor||(e.backgroundColor=t.backgroundColor),(0,a.le)(t.foregroundColor)||e.foregroundColor===t.foregroundColor||(e.foregroundColor=t.foregroundColor),(0,a.le)(t.textureStyle)||e.textureStyle===t.textureStyle||(e.textureStyle=t.textureStyle))},e.prototype.applyBorder=function(e,t){(0,a.le)(e)||(0,a.le)(t)||((0,a.le)(t.color)||e.color===t.color||(e.color=t.color),(0,a.le)(t.lineStyle)||e.lineStyle===t.lineStyle||(e.lineStyle=t.lineStyle),(0,a.le)(t.lineWidth)||e.lineWidth===t.lineWidth||(e.lineWidth=t.lineWidth),(0,a.le)(t.shadow)||e.shadow===t.shadow||(e.shadow=t.shadow),(0,a.le)(t.space)||e.space===t.space||(e.space=t.space))},e.prototype.onTableFormat=function(e,t,i){if(!(0,a.le)(this.selection.tableFormat)){if((0,a.le)(t)&&(t=!1),this.documentHelper.owner.isShiftingEnabled=!0,this.editorHistory.initializeHistory("TableFormat"),(0,a.le)(i)&&(i=this.selection.start.paragraph.associatedCell.ownerTable.combineWidget(this.owner.viewer)),t)for(var r=0;r<i.childWidgets.length;r++)for(var o=i.childWidgets[r],n=0;n<o.childWidgets.length;n++)o.childWidgets[n].cellFormat.shading.copyFormat(e.shading);this.applyTableFormat(i,void 0,e),this.reLayout(this.selection,!1)}},e.prototype.applyTableFormat=function(e,t,i){this.applyTablePropertyValue(void 0,i,e)},e.prototype.applyTablePropertyValue=function(e,t,i){var r=i.tableFormat;if(!(0,a.le)(this.editorHistory)&&this.editorHistory.currentBaseHistoryInfo&&(t=this.editorHistory.currentBaseHistoryInfo.addModifiedTableProperties(r,e,t),this.editorHistory.currentBaseHistoryInfo.insertedFormat=t),t instanceof u.M){(0,a.le)(e)&&this.handleTableFormat(r,t);return}"preferredWidth"===e?r.preferredWidth=t:"leftIndent"===e?r.leftIndent=t:"tableAlignment"===e?r.tableAlignment=t:"cellSpacing"===e?r.cellSpacing=t:"leftMargin"===e?r.leftMargin=t:"rightMargin"===e?r.rightMargin=t:"topMargin"===e?r.topMargin=t:"bottomMargin"===e?r.bottomMargin=t:"preferredWidthType"===e?r.preferredWidthType=t:"bidi"===e?r.bidi=t:"title"===e?r.title=t:"description"===e&&(r.description=t),"shading"===e?r.shading=t:"borders"===e&&(r.borders=t)},e.prototype.handleTableFormat=function(e,t){if((this.isBordersAndShadingDialog||this.editorHistory.isUndoing||this.editorHistory.isRedoing)&&((0,a.le)(e.borders)||this.applyBordersInternal(e.borders,t.borders),!(0,a.le)(e.shading)&&(this.applyShading(e.shading,t.shading),this.editorHistory&&(this.editorHistory.isUndoing||this.editorHistory.isRedoing))))for(var i=e.ownerBase,r=0;r<i.childWidgets.length;r++)for(var o=i.childWidgets[r],n=0;n<o.childWidgets.length;n++){var s=o.childWidgets[n];this.applyShading(s.cellFormat.shading,t.shading)}!this.isBordersAndShadingDialog&&(t.hasValue("bidi")&&t.bidi!==e.bidi&&(e.bidi=t.bidi),t.hasValue("preferredWidth")&&t.preferredWidth!==e.preferredWidth&&(e.preferredWidth=t.preferredWidth),t.hasValue("preferredWidthType")&&t.preferredWidthType!==e.preferredWidthType&&(e.preferredWidthType=t.preferredWidthType),t.hasValue("tableAlignment")&&t.tableAlignment!==e.tableAlignment&&(e.tableAlignment=t.tableAlignment),t.hasValue("leftIndent")&&t.leftIndent!==e.leftIndent&&(e.leftIndent=t.leftIndent)),this.updateGridForTableDialog(e.ownerBase,!1),t.title!==e.title&&(e.title=t.title),t.description!==e.description&&(e.description=t.description)},e.prototype.updateGridForTableDialog=function(e,t){e.tableHolder&&(e.updateRowIndex(0),e.isGridUpdated=!1),this.documentHelper.layout.reLayoutTable(e)},e.prototype.onRowFormat=function(e){if(!((0,a.le)(this.selection)||(0,a.le)(e))){this.editorHistory.initializeHistory("RowFormat"),this.documentHelper.owner.isShiftingEnabled=!0;var t=this.selection.isForward?this.selection.start:this.selection.end,i=this.selection.isForward?this.selection.end:this.selection.start;t.paragraph.associatedCell.ownerTable.combineWidget(this.owner.viewer),this.applyRowFormat(t.paragraph.associatedCell.ownerRow,t,i,void 0,e),this.reLayout(this.selection,!1)}},e.prototype.applyRowFormat=function(e,t,i,r,o){if(this.applyRowPropertyValue(this.documentHelper.selection,r,o,e),i.paragraph.associatedCell.ownerRow!==e){var n=e.nextWidget;(0,a.le)(n)||this.applyRowFormat(n,t,i,r,o)}},e.prototype.applyRowPropertyValue=function(e,t,i,r){var o=r.rowFormat;if((0,a.le)(this.editorHistory.currentBaseHistoryInfo)||(i=this.editorHistory.currentBaseHistoryInfo.addModifiedRowProperties(o,t,i),this.editorHistory.currentBaseHistoryInfo.insertedFormat=i),i instanceof d.J){(0,a.le)(t)&&this.handleRowFormat(i,o);return}"heightType"===t?o.heightType=i:"height"===t?o.height=i:"isHeader"===t?o.isHeader=i:"allowBreakAcrossPages"===t&&(o.allowBreakAcrossPages=i),(0,a.le)(r.ownerTable)||this.layoutItemBlock(r.ownerTable,!0)},e.prototype.handleRowFormat=function(e,t){e.hasValue("allowBreakAcrossPages")&&e.allowBreakAcrossPages!==t.allowBreakAcrossPages&&(t.allowBreakAcrossPages=e.allowBreakAcrossPages),e.hasValue("isHeader")&&e.isHeader!==t.isHeader&&(t.isHeader=e.isHeader),e.hasValue("heightType")&&e.heightType!==t.heightType&&this.documentHelper.owner.tablePropertiesDialogModule.rowHeightCheckBox.checked&&(t.heightType=e.heightType),e.hasValue("height")&&e.height!==t.height&&this.documentHelper.owner.tablePropertiesDialogModule.rowHeightCheckBox.checked&&(t.height=e.height),this.updateGridForTableDialog(t.ownerBase.ownerTable,!0)},e.prototype.onCellFormat=function(e){(0,a.le)(this.selection)||(0,a.le)(e)||(this.documentHelper.owner.isShiftingEnabled=!0,this.editorHistory.initializeHistory("CellFormat"),this.updateFormatForCell(this.selection,void 0,e),this.reLayout(this.selection,!1))},e.prototype.onParaFormat=function(e){(0,a.le)(this.selection)||(0,a.le)(e)||(this.editorHistory.initializeHistory("ParagraphFormat"),this.updateParagraphFormat(void 0,e,!1),this.reLayout(this.selection,!1))},e.prototype.updateCellMargins=function(e,t){var i=e.start,r=e.end;e.isForward||(i=e.end,r=e.start),this.initHistoryPosition(e,i),this.documentHelper.owner.cellOptionsDialogModule.applyCellMarginValue(i.paragraph.associatedCell.ownerRow,i,r,t)},e.prototype.updateFormatForCell=function(e,t,i){var r,o,n,s=e.start,a=e.end;e.isForward||(s=e.end,a=e.start);var l=s.paragraph.associatedCell,d=a.paragraph.associatedCell,h=l.ownerTable.combineWidget(this.owner.viewer);l.columnIndex<d.columnIndex?(o=l.columnIndex,n=d.columnIndex):(o=d.columnIndex,n=l.columnIndex),d.cellFormat.columnSpan>1&&(n=n+d.cellFormat.columnSpan-1);for(var c=o;c<=n;c++){r=this.getSelectedCellInColumn(l.ownerTable,l.ownerRow.rowIndex,c,d.ownerRow.rowIndex);for(var p=0;p<r.length;p++)this.applyCellPropertyValue(this.documentHelper.selection,t,i,r[p].cellFormat)}this.updateGridForTableDialog(h,!1)},e.prototype.getSelectedCellInColumn=function(e,t,i,r){for(var o=[],n=t;n<=r;n++)for(var s=e.childWidgets[n],a=0;a<s.childWidgets.length;a++)s.childWidgets[a].columnIndex===i&&o.push(s.childWidgets[a]);return o},e.prototype.getColumnCells=function(e,t,i){for(var r=[],o=0;o<e.childWidgets.length;o++)for(var n=e.childWidgets[o],s=0;s<n.childWidgets.length;s++){var a=n.childWidgets[s];
1i?a.columnIndex+a.cellFormat.columnSpan===t&&r.push(a):a.columnIndex===t&&r.push(a)}return r},e.prototype.getTableWidth=function(e){return 0!==e.tableFormat.preferredWidth||"Percent"===e.tableFormat.preferredWidthType?"Auto"===e.tableFormat.preferredWidthType||"Point"===e.tableFormat.preferredWidthType?e.tableFormat.preferredWidth:0===e.tableFormat.preferredWidth?0:s.o_.convertPixelToPoint(this.owner.viewer.clientArea.width)/100*e.tableFormat.preferredWidth:s.o_.convertPixelToPoint(this.documentHelper.layout.getTableWidth(e))},e.prototype.applyCellPropertyValue=function(e,t,i,r){if((0,a.le)(this.editorHistory.currentBaseHistoryInfo)||(i=this.editorHistory.currentBaseHistoryInfo.addModifiedCellProperties(r,t,i),this.editorHistory.currentBaseHistoryInfo.insertedFormat=i),i instanceof c.D)return(0,a.le)(t)&&this.handleCellFormat(i,r),i;"leftMargin"===t?r.leftMargin=i:"topMargin"===t?r.topMargin=i:"rightMargin"===t?r.rightMargin=i:"bottomMargin"===t?r.bottomMargin=i:"preferredWidth"===t?(r.preferredWidth=i,r.cellWidth=i):"cellWidth"===t?r.cellWidth=i:"columnSpan"===t?r.columnSpan=i:"rowSpan"===t?r.rowSpan=i:"preferredWidthType"===t?r.preferredWidthType=i:"verticalAlignment"===t&&(r.verticalAlignment=i),"shading"===t?r.shading=i:"borders"===t&&(r.borders=i)},e.prototype.handleCellFormat=function(e,t){(0,a.le)(e)||(0,a.le)(t)||(this.isBordersAndShadingDialog?((0,a.le)(e.borders)||this.applyBordersInternal(t.borders,e.borders),(0,a.le)(e.shading)||this.applyShading(t.shading,e.shading)):(e.hasValue("preferredWidth")&&t.preferredWidth!==e.preferredWidth&&(t.preferredWidth=e.preferredWidth),e.hasValue("preferredWidthType")&&t.preferredWidthType!==e.preferredWidthType&&(t.preferredWidthType=e.preferredWidthType),e.hasValue("verticalAlignment")&&t.verticalAlignment!==e.verticalAlignment&&(t.verticalAlignment=e.verticalAlignment)))},e.prototype.applyColumnFormat=function(e,t){this.applySectionFormatWithColumns(e,t)},e.prototype.applyLeftColumnFormat=function(){this.applySectionFormatWithColumns(2,!1,[1,2])},e.prototype.applyRightColumnFormat=function(){this.applySectionFormatWithColumns(2,!1,[2,1])},e.prototype.applySectionFormatWithColumns=function(e,t,i){var r=new l.Z,o=this.owner.selection.sectionFormat;this.copyCurrentSectionFormat(r,o),r.numberOfColumns=e,r.equalWidth=t;var n=o.pageWidth-o.leftMargin-o.rightMargin,s=[];if(1===e)s.push(this.createColumnFormat(n,0));else if(t||!i)for(var a=n-36*(e-1),d=a/e,h=0;h<e;h++)s.push(this.createColumnFormat(d,h<e-1?36:0));else for(var c=i.reduce(function(e,t){return e+t},0),a=n-36*(e-1),p=a/c,h=0;h<e;h++)s.push(this.createColumnFormat(p*i[h],h<e-1?36:0));r.columns=s,this.onApplySectionFormat(void 0,r)},e.prototype.createColumnFormat=function(e,t){var i=new l.A;return i.width=s.o_.convertPointToPixel(e),i.space=s.o_.convertPointToPixel(t),i},e.prototype.copyCurrentSectionFormat=function(e,t){e.bottomMargin=t.bottomMargin,e.topMargin=t.topMargin,e.leftMargin=t.leftMargin,e.rightMargin=t.rightMargin,e.pageWidth=t.pageWidth,e.pageHeight=t.pageHeight,e.differentOddAndEvenPages=t.differentOddAndEvenPages,e.differentFirstPage=t.differentFirstPage,e.headerDistance=t.headerDistance,e.footerDistance=t.footerDistance,e.breakCode=t.breakCode},e.prototype.destroy=function(){this.tableResize&&(this.tableResize.destroy(),this.tableResize=void 0),this.previousCharFormat&&(this.previousCharFormat.destroy(),this.previousCharFormat=void 0),this.previousParaFormat&&(this.previousParaFormat.destroy(),this.previousParaFormat=void 0),this.alertDialog&&this.alertDialog.destroy(),this.alertDialog=void 0,this.base64&&this.base64.destroy(),this.base64=void 0,this.endParagraph=void 0,this.copiedData=void 0,this.copiedTextContent=void 0,this.listFormatInfo=void 0,this.nodes=[],this.removedTextNodes=[],this.removedBookmarkElements=[],this.editStartRangeCollection=[],this.documentHelper=void 0,this.editRangeID=void 0,this.isCellFormatApplied=void 0,this.removedContentControlElements=[]},e.prototype.updateToc=function(e){var t=this;if((0,a.le)(e)&&(e=this.selection.getTocFieldInternal()),this.documentHelper.layout.isTocField(e)){var i=this.selection.getFieldCode(e);-1!==i.toLocaleLowerCase().indexOf("toc")&&((0,T.yh)(this.owner.element),setTimeout(function(){t.isUpdateToc=!0,t.insertTableOfContents(t.validateTocSettings(t.getTocSettings(i,e))),(0,T.v3)(t.owner.element),t.isUpdateToc=!1}))}},e.prototype.getTocSettings=function(e,t){var i={};if(i.includePageNumber=!0,i.rightAlign=!0,"toc \\mergeformat"===e.toLowerCase())i.startLevel=1,i.endLevel=3;else for(var r=e.split("\\"),o=0;o<r.length;o++){var n=r[o];if(0!==n.length)switch(n[0]){case"o":if((0,a.le)(n.match(/\d+/g)))i.startLevel=1,i.endLevel=9;else{var s=n.match(/\d+/g).map(Number);i.startLevel=s[0],i.endLevel=s[1]}break;case"h":i.includeHyperlink=!0;break;case"n":i.includePageNumber=!1;break;case"p":i.rightAlign=!1;break;case"u":i.includeOutlineLevels=!0;break;case"t":this.decodeTSwitch(i,n)}}var l=t.paragraph.paragraphFormat.getUpdatedTabs();return l.length>0&&(i.tabLeader=l[l.length-1].tabLeader),i.rightAlign&&(0,a.le)(i.tabLeader)&&(i.tabLeader="Dot"),i},e.prototype.decodeTSwitch=function(e,t){e.levelSettings={};for(var i=(t=(t=(t=(t=t.replace("t","")).replace('"',"")).replace('"',"")).trim()).split(","),r=0;r<i.length;r++)e.levelSettings[i[r]]=parseInt(i[r+1],10),r++},e.prototype.insertTableOfContents=function(e){if(!this.selection.isPlainContentControl()&&!this.owner.isReadOnlyMode){this.isInsertingTOC=!0;var t=this.checkAndRemoveComments();this.initComplexHistory("TOC"),(0,a.le)(e)&&((e={}).startLevel=1,e.endLevel=3,e.includeHyperlink=!0,e.includeOutlineLevels=!0,e.includePageNumber=!0,e.rightAlign=!0,e.tabLeader="Dot");var i=void 0,r=void 0;if(this.isUpdateToc)"TableOfContents"===this.selection.contextType&&(i=this.selection.getTocFieldInternal());else for(var n=0;n<this.documentHelper.fields.length;n++){var s=this.documentHelper.fields[n];if(this.documentHelper.layout.isTocField(s)&&(!this.selection.start.paragraph.isInHeaderFooter&&!s.paragraph.isInHeaderFooter||this.selection.start.paragraph.isInHeaderFooter&&s.paragraph.isInHeaderFooter&&(-1!==this.selection.start.paragraph.bodyWidget.headerFooterType.indexOf("Header")&&-1!==s.paragraph.bodyWidget.headerFooterType.indexOf("Header")||-1!==this.selection.start.paragraph.bodyWidget.headerFooterType.indexOf("Footer")&&-1!==s.paragraph.bodyWidget.headerFooterType.indexOf("Footer")))){i=s;break}}if(i instanceof o.V8){this.selection.start.setPositionForSelection(i.line,i,0,this.selection.start.location);var d=2,h=i.fieldEnd.paragraph,c=h.nextWidget;(h===h.bodyWidget.lastChild||c instanceof o.ZH&&c.isSectionBreak)&&d--,this.selection.end.setPositionForSelection(i.fieldEnd.line,i.fieldEnd,d,this.selection.end.location),this.delete()}r=this.constructTocFieldCode(e);var p=this.selection.start.isAtParagraphStart,g=this.selection.getParagraphInfo(this.selection.start),m=this.selection.getHierarchicalIndex(g.paragraph,g.offset.toString()),u=this.buildToc(this.validateTocSettings(e),r,!0,p);if(u.length>0){var f=new o.ZH,y=new o.z7(f);f.childWidgets.push(y);var v=0;p||(v=1);var H=u[v].childWidgets[0].children[0];this.appendEndField(H,y),u.push(f),this.appendEmptyPara(u)}else{var C=new a.E7("documenteditor",this.owner.defaultLocale);C.setLocale(this.owner.locale),S.hZ.alert({title:C.getConstant("No Headings"),content:C.getConstant("Add Headings"),showCloseIcon:!0,closeOnEscape:!0,position:{X:"center",Y:"center"},animationSettings:{effect:"Zoom"}}).enableRtl=this.owner.enableRtl}this.setPositionForCurrentIndex(this.selection.start,m),this.selection.end.setPositionInternal(this.selection.start);var F=new o.VB;F.sectionFormat=new l.Z(F),F.childWidgets=u,this.pasteContentsInternal([F],!1),this.updatePageRef(),this.isInsertingTOC=!1,this.editorHistory&&(this.editorHistory.updateComplexHistory(),this.updateHistoryForComments(t)),0===u.length&&(this.owner.editorHistoryModule.undo(),this.owner.editorHistoryModule.redoStack.pop()),this.owner.enableTrackChanges&&(this.setPositionForCurrentIndex(this.selection.start,m),this.setPositionForCurrentIndex(this.selection.end,m))}},e.prototype.appendEmptyPara=function(e){var t=new o.ZH,i=new o.z7(t);t.childWidgets.push(i),e.push(t)},e.prototype.constructTocFieldCode=function(e){var t="TOC";(0,a.le)(e.startLevel)||0===e.startLevel||(0,a.le)(e.endLevel)||0===e.endLevel||(t=t+' \\o "'+e.startLevel+"-"+e.endLevel+'"'),e.includePageNumber&&!e.rightAlign&&(t+=' \\p " "'),e.includePageNumber||(t+=" \\n"),e.includeHyperlink&&(t+=" \\h \\z"),e.includeOutlineLevels&&(t+=" \\u");var i=this.constructTSwitch(e);return i.length>6&&(t+=i),t},e.prototype.constructTSwitch=function(e){var t="";if(!(0,a.le)(e.levelSettings))for(var i=0,r=Object.keys(e.levelSettings);i<r.length;i++){var o=r[i];t=t+o+","+e.levelSettings[o].toString()+","}return' \\t "'+(t=t.slice(0,-1))+'"'},e.prototype.appendEndField=function(e,t){var i=new o.V8(1);if(i.fieldSeparator=e.fieldSeparator,e.fieldSeparator.fieldEnd=i,i.fieldBegin=e,i.fieldBegin.fieldEnd=i,i.line=t,e.revisionLength>0){var r=e.getRevision(e.revisionLength-1);this.owner.trackChangesPane.updateCurrentTrackChanges(r),i.addRevision(r)}t.children.push(i)},e.prototype.validateTocSettings=function(e){return((0,a.le)(e.startLevel)||e.startLevel<1)&&(e.startLevel=1),((0,a.le)(e.endLevel)||e.endLevel<e.endLevel)&&(e.endLevel=e.startLevel>3?e.startLevel:3),(0,a.le)(e.includeHyperlink)&&(e.includeHyperlink=!1),(0,a.le)(e.includePageNumber)&&(e.includePageNumber=!1),(0,a.le)(e.rightAlign)&&(e.rightAlign=!1),(0,a.le)(e.levelSettings)&&(e.levelSettings={}),e},e.prototype.buildToc=function(e,t,i,r,n){var s=this.documentHelper.pages[0].bodyWidgets[0],l=[];this.createHeadingLevels(e),e.includeOutlineLevels&&this.createOutlineLevels(e);var d=this.selection.start.paragraph.bodyWidget.sectionFormat,h=s.childWidgets[0];for(!(0,a.le)(this.owner.optionsPaneModule)&&this.owner.optionsPaneModule.isHeadingTab&&(this.owner.optionsPaneModule.isBuildHeading=!0);void 0!==h;){if(h instanceof o.ZH&&!(n&&h.isInsideTable)&&(this.isHeadingStyle(h)||e.includeOutlineLevels&&this.isOutlineLevelStyle(h))){var c=this.insertTocBookmark(h,n);(0,a.le)(c)||(this.createTOCWidgets(h,l,t,c,e,i,r,d,n),i=!1)}h=this.selection.getNextParagraphBlock(h.getSplitWidgets().pop())}return this.tocStyles={},!(0,a.le)(this.owner.optionsPaneModule)&&this.owner.optionsPaneModule.isHeadingTab&&(this.owner.optionsPaneModule.isBuildHeading=!1),l},e.prototype.createOutlineLevels=function(e){for(var t=e.startLevel;t<=e.endLevel;t++){var i="Level"+t.toString();(0,a.le)(this.tocStyles[i])&&(this.tocStyles[i]=t)}},e.prototype.createHeadingLevels=function(e){for(var t=e.startLevel;t<=e.endLevel;t++){var i="Heading "+t.toString();(0,a.le)(this.tocStyles[i])&&(this.tocStyles[i]=t)}if(!(0,a.le)(e.levelSettings))for(var r=0,o=Object.keys(e.levelSettings);r<o.length;r++){var n=o[r];this.tocStyles[n]=e.levelSettings[n]}},e.prototype.isHeadingStyle=function(e){var t=e.paragraphFormat.baseStyle;return void 0!==t&&!(0,a.le)(this.tocStyles[t.name])},e.prototype.isOutlineLevelStyle=function(e){var t=e.paragraphFormat.outlineLevel;return!(0,a.le)(this.tocStyles[t])},e.prototype.createTocFieldElement=function(e,t,i){var r=new o.V8(0);r.hasFieldEnd=!0,r.line=e,e.children.push(r);var n=new o.a3;n.text=t,n.line=e,e.children.push(n);var s=new o.V8(2);return s.fieldBegin=r,s.fieldBegin.fieldSeparator=s,s.line=e,e.children.push(s),r},e.prototype.createTOCWidgets=function(e,t,i,r,n,s,l,d,c){var p=void 0,g=void 0,m=void 0;if(1!==t.length||3!==t[0].childWidgets[0].children.length||(0,a.le)(s)||s){g=new o.ZH;var u=void 0,f=e.paragraphFormat.baseStyle.name;u=n.includeOutlineLevels&&(0,a.le)(this.tocStyles[f])?e.paragraphFormat.outlineLevel:f;var y="TOC "+this.tocStyles[u],v="Heading "+this.tocStyles[u],H=void 0;if(c?(H=this.documentHelper.styles.findByName(v,"Paragraph"),(0,a.le)(H)&&(this.documentHelper.owner.parser.parseStyle(JSON.parse(this.getCompleteStyles()),JSON.parse(this.documentHelper.preDefinedStyles.get(v)),this.documentHelper.styles,!0),H=this.documentHelper.styles.findByName(v,"Paragraph"))):(H=this.documentHelper.styles.findByName(y,"Paragraph"),(0,a.le)(H)&&(this.documentHelper.owner.parser.parseStyle(JSON.parse(this.getCompleteStyles()),JSON.parse(this.documentHelper.preDefinedStyles.get(y)),this.documentHelper.styles,!0),H=this.documentHelper.styles.findByName(y,"Paragraph"))),g.paragraphFormat.applyStyle(H),n.rightAlign&&n.includePageNumber){var
1C=new h.t;C.position=d.pageWidth-(d.leftMargin+d.rightMargin),C.tabLeader=n.tabLeader,C.deletePosition=0,C.tabJustification="Right",g.paragraphFormat.tabs.push(C)}m=new o.z7(g),g.childWidgets.push(m)}else m=t[0].childWidgets[0];void 0!==s&&s&&((0,a.le)(l)||l||this.appendEmptyPara(t),this.createTocFieldElement(m,i));for(var F="",w=!1,I=e;I instanceof o.ZH;){for(var x=0;x<I.childWidgets.length;x++)for(var b=I.childWidgets[x],W=0;W<b.children.length;W++){var P=b.children[W];if(!P.isPageBreak&&!P.isColumnBreak){if(P instanceof o.V8||P instanceof o.aQ||w)P instanceof o.V8&&(0===P.fieldType?w=!0:2===P.fieldType&&(w=!1));else if(P instanceof o.a3||P instanceof o.no){var k=P.text;-1!==k.indexOf(" ")&&(k=k.replace(RegExp(" ","g")," ")),F+=k}}}I=I.nextSplitWidget}if(""!==F){if(n.includeHyperlink&&void 0!==r)p=this.insertTocHyperlink(m,r,F,e);else{var R=new o.a3;R.text=F,R.line=m,m.children.push(R)}if(n.includePageNumber&&void 0!==r){if(n.rightAlign){var T=new o.u3;T.text=" ",T.line=m,m.children.push(T)}var S=this.insertTocPageNumber(r,m,n.rightAlign,e);this.appendEndField(S,m)}n.includeHyperlink&&void 0!==p&&this.appendEndField(p,m)}!(0,a.le)(g)&&(""!==F||s)&&t.push(g)},e.prototype.insertTocHyperlink=function(e,t,i,r){var n=this.createTocFieldElement(e,' HYPERLINK \\l "'+t+'" ',!0),s=new o.a3;s.text=i;var a=r.paragraphFormat.baseStyle.name;if(this.documentHelper.styles.findByName(a,"Paragraph").characterFormat.isEqualTocFormat(r.characterFormat)){var l=this.documentHelper.styles.findByName("Normal","Paragraph");s.characterFormat.copyTocFormat(l.characterFormat)}else s.characterFormat.copyTocFormat(r.characterFormat);return s.line=e,e.children.push(s),n},e.prototype.getPageNumber=function(e){return e.bodyWidget.sectionFormat.restartPageNumbering?e.bodyWidget.page.currentPageNum:this.documentHelper.pages.indexOf(e.bodyWidget.page)+1},e.prototype.insertTocPageNumber=function(e,t,i,r){var n=this.createTocFieldElement(t," PAGEREF"+e+" \\h ",!0),s=this.getPageNumber(r).toString(),a=new o.Un;return a.fieldBegin=n,i||(s=" "+s),a.text=s,a.line=t,t.children.push(a),this.pageRefFields[e]=a,n},e.prototype.updatePageRef=function(){for(var e=0,t=Object.keys(this.pageRefFields);e<t.length;e++){var i=t[e];if(this.documentHelper.bookmarks.containsKey(i)){var r=this.documentHelper.bookmarks.get(i),o=this.getPageNumber(r.paragraph).toString(),n=this.pageRefFields[i];if(o!==n.text){n.isWidthUpdated=!1,n.text=o;var s=n.paragraph,l=s.childWidgets.indexOf(n.line),d=n.line.children.indexOf(n);(0,a.le)(s.containerWidget)||this.documentHelper.layout.reLayoutParagraph(s,l,d)}}}},e.prototype.insertTocBookmark=function(e,t){var i=void 0;if(e.childWidgets.length>0){var r=e.getSplitWidgets(),n=r[0],s=r.pop(),l=n.childWidgets[0],d=s.childWidgets[s.childWidgets.length-1];if(void 0!==l&&void 0!==d){var h=l.children[0];if(h instanceof o.no||h instanceof o.Xw)do h=h.nextNode;while(h instanceof o.no||h instanceof o.Xw);if(!(0,a.le)(h)&&h instanceof o.aQ&&0===h.bookmarkType&&h.name.toLowerCase().match("^_toc"))return h.name;var c=d.children[d.children.length-1];if(c&&c.isPageBreak){var p=c.previousNode;if((0,a.le)(p))return i;c=p}void 0===h||void 0===c||this.isRemoteAction||(this.selection.start.setPositionForSelection(l,h,0,this.selection.start.location),this.selection.end.setPositionForSelection(d,c,c.length,this.selection.end.location),i=this.generateBookmarkName(),this.insertBookmark(i,t))}}return i},e.prototype.generateBookmarkName=function(){var e="";do{this.tocBookmarkId++;for(var t=10-this.tocBookmarkId.toString().length,i="";t-1>0;)i="0"+i,t--;e="_Toc"+i+this.tocBookmarkId}while(this.documentHelper.bookmarks.containsKey(e));return e},e.prototype.onCellContentAlignment=function(e,t){this.owner.isShiftingEnabled=!0;var i=this.owner.selectionModule;if(i.isEmpty&&i.start.paragraph.isInsideTable){this.owner.editorHistoryModule&&this.owner.editorHistoryModule.initComplexHistory(i,"MultiSelection"),i.selectTableCell(),this.initHistory("CellContentVerticalAlignment");var r=i.start.paragraph.associatedCell.cellFormat;this.applyCellPropertyValue(i,"verticalAlignment",e,r),this.reLayout(i,!1),this.initHistory("TextAlignment"),this.updateParagraphFormat("textAlignment",t,!1),this.reLayout(this.owner.selectionModule,!1),this.owner.editorHistoryModule&&this.owner.editorHistoryModule.updateComplexHistory()}else this.owner.editorHistoryModule&&this.owner.editorHistoryModule.initComplexHistory(i,"MultiSelection"),(0,a.le)(i.getTable(i.start,i.end))||(this.updateSelectionTableFormat(i,"CellContentVerticalAlignment",e),this.reLayout(this.owner.selectionModule,!1),this.initHistory("TextAlignment"),this.updateSelectionParagraphFormatting("textAlignment",t,!1),this.reLayout(i,!1)),this.owner.editorHistoryModule&&this.owner.editorHistoryModule.updateComplexHistory()},e.prototype.insertEditRangeElement=function(e){if(!this.documentHelper.isDocumentProtected&&!this.documentHelper.selection.isEmpty){this.initComplexHistory("RestrictEditing"),this.selection.skipEditRangeRetrieval=!0;var t=this.documentHelper.selection;if(this.selection.start,this.selection.end,this.selection.isForward||(this.selection.end,this.selection.start),t.start.paragraph.isInsideTable&&t.end.paragraph.isInsideTable&&t.start.paragraph.associatedCell.ownerTable.contains(t.end.paragraph.associatedCell)){var i=this.getOwnerCell(this.selection.isForward),r=this.getOwnerCell(!this.selection.isForward);if(i.rowIndex===r.rowIndex){for(var o=i.ownerRow.childWidgets.indexOf(i),n=i.ownerRow.childWidgets.indexOf(r),s=[],a=[],l=o;l<=n;l++){var d=this.addEditElement(e);l==o&&this.editorHistory&&this.editorHistory.currentHistoryInfo&&(this.editorHistory.currentHistoryInfo.editRangeStart=d),d.columnFirst=l,d.columnLast=l,d.line=t.start.currentWidget;var h=d.editRangeEnd;h.line=t.end.currentWidget,s.push(d),a.push(h),this.insertElements(void 0,[d])}for(var c=this.selection.getLastParagraph(r).lastChild,p=0;p<a.length;p++)a[p].line=c,0==p&&(this.selection.start.setPositionParagraph(c,this.selection.getLineLength(c)),this.selection.end.setPositionParagraph(c,this.selection.getLineLength(c))),this.insertElements(void 0,[a[p]]);this.editorHistory&&this.editorHistory.updateComplexHistoryInternal();var g=s[0].line.getOffset(s[0],1);this.selection.start.setPositionParagraph(s[0].line,g),g=a[0].line.getOffset(a[0],1),this.selection.end.setPositionParagraph(a[0].line,g),this.selection.fireSelectionChanged(!0),this.fireContentChange()}else{this.insertEditRangeInsideTable(i,r,e),this.editorHistory&&this.editorHistory.updateComplexHistoryInternal();var m=this.documentHelper.getFirstParagraphInCell(i).childWidgets[0],u=this.selection.getLastParagraph(r).childWidgets[0],g=m.getOffset(m.children[0],1);this.selection.start.setPositionParagraph(m,g),g=u.getOffset(u.children[0],1),this.selection.end.setPositionParagraph(u,g),this.selection.fireSelectionChanged(!0),this.fireContentChange()}}else this.addRestrictEditingForSelectedArea(e);this.selection.skipEditRangeRetrieval=!1}},e.prototype.insertEditRangeInsideTable=function(e,t,i){var r=e.ownerTable.combineWidget(this.owner.viewer),o=r.childWidgets.indexOf(t.ownerRow),n=r.childWidgets.indexOf(e.ownerRow),s=this.selection.getCellLeft(e.ownerRow,e),a=s+e.cellFormat.cellWidth,l=this.selection.getCellLeft(t.ownerRow,t),d=l+t.cellFormat.cellWidth,h=this.updateSelectedCellsInTable(s,a,l,d);s=h.start,a=h.end;for(var c=[],p=n;p<=o;p++){for(var g=(r=e.ownerTable.combineWidget(this.owner.viewer)).childWidgets[p],m=-1,u=-1,f=0;f<g.childWidgets.length;f++){var y=g.childWidgets[f],v=this.selection.getCellLeft(g,y);this.checkCellWithInSelection(s,a,v)&&(-1===m&&(m=f),u=f)}for(var H=[],C=m;C<=u;C++){var F=void 0,w=void 0,I=void 0;C>=m&&C<=u&&(F=g.childWidgets[m],I=(w=this.documentHelper.getFirstParagraphInCell(F)).childWidgets[0]);var x=this.addEditElement(i);C===m&&(this.editorHistory&&this.editorHistory.currentHistoryInfo&&(this.editorHistory.currentHistoryInfo.editRangeStart=x),this.selection.start.setPositionParagraph(I,this.selection.getStartOffset(w)),this.selection.end.setPositionParagraph(I,this.selection.getStartOffset(w))),x.columnFirst=C,x.columnLast=C,x.line=I,this.insertElements(void 0,[x]);var b=x.editRangeEnd;if(H.push(b),c.length>0&&C===u){for(var W=0;W<c.length;W++)c[W].line=x.line,this.insertElements(void 0,[c[W]]);c=[]}}if(c=H,p===o&&c.length>0)for(var P=g.childWidgets[u],k=this.selection.getLastParagraph(P).lastChild,W=0;W<c.length;W++)c[W].line=k,0==W&&(this.selection.start.setPositionParagraph(k,this.selection.getLineLength(k)),this.selection.end.setPositionParagraph(k,this.selection.getLineLength(k))),this.insertElements(void 0,[c[W]])}},e.prototype.addRestrictEditingForSelectedArea=function(e){var t=this.addEditElement(e),i=t.editRangeEnd;this.editorHistory&&this.editorHistory.currentHistoryInfo&&(this.editorHistory.currentHistoryInfo.editRangeStart=t),this.owner.isShiftingEnabled=!0,this.insertElements([i],[t]),t.editRangeEnd.line=i.line,this.editorHistory&&this.editorHistory.updateComplexHistoryInternal();var r=t.line.getOffset(t,1);this.selection.start.setPositionParagraph(t.line,r),r=i.line.getOffset(i,1),this.selection.end.setPositionParagraph(i.line,r);var o=this.documentHelper.blockToShift;if(!(0,a.le)(o)&&this.viewer instanceof x._&&o.bodyWidget.sectionFormat.columns.length>1){var n=this.documentHelper.layout.getBodyWidget(o.bodyWidget,!1);(0,a.le)(n.nextRenderedWidget)||"NoBreak"!==n.nextRenderedWidget.sectionFormat.breakCode||n.page!==n.nextRenderedWidget.page||this.reLayout(this.selection)}this.owner.isShiftingEnabled=!1,this.selection.fireSelectionChanged(!0),this.fireContentChange()},e.prototype.addEditElement=function(e,t){var i=new o.Cw;"everyone"===e.toLocaleLowerCase()?i.group=e:i.user=e;var r=new o.jn;if(r.editRangeStart=i,i.editRangeEnd=r,t)i.editRangeId=t,r.editRangeId=t;else{var n=this.getEditRangeID(9);i.editRangeId=n,r.editRangeId=n}return this.editStartRangeCollection.push(i),this.addEditCollectionToDocument(),this.editStartRangeCollection=[],i},e.prototype.getEditRangeID=function(e){var t=Math.pow(10,e-1),i=Math.floor(Math.random()*(Math.pow(10,e)-1-t+1))+t;return this.editRangeID.includes(i)?this.getEditRangeID(e):(this.editRangeID.push(i),i)},e.prototype.protect=function(e){this.documentHelper.isDocumentProtected=!0,this.documentHelper.protectionType=e,this.selection.highlightEditRegion(),this.editorHistory&&this.editorHistory.destroy()},e.prototype.addEditCollectionToDocument=function(){for(var e=0;e<this.editStartRangeCollection.length;e++){var t=this.editStartRangeCollection[e],i=""===t.user?t.group:t.user;if(this.documentHelper.editRanges.length>0&&this.documentHelper.editRanges.containsKey(i))this.documentHelper.editRanges.get(i).push(t);else{var r=[];r.push(t),this.documentHelper.editRanges.add(i,r)}}this.selection.updateEditRangeCollection()},e.prototype.updateRangeCollection=function(e,t){if(this.documentHelper.editRanges.length>0&&this.documentHelper.editRanges.containsKey(t))-1===this.documentHelper.editRanges.get(t).indexOf(e)&&this.documentHelper.editRanges.get(t).push(e);else{var i=[];i.push(e),this.documentHelper.editRanges.add(t,i)}},e.prototype.removeUserRestrictions=function(e,t){if(this.selection.checkSelectionIsAtEditRegion()||this.selection.isEditRangeCellSelected()||t&&t.previousElement&&t.previousElement instanceof o.aQ){this.selection.skipEditRangeRetrieval=!0;var i=this.selection.getEditRangeStartElement();i=t||i,this.selection.skipEditRangeRetrieval=!0;var r=this.selection.start,n=this.selection.end;if(this.selection.isForward||(r=this.selection.end,n=this.selection.start),!this.selection.isEmpty&&r.paragraph.isInsideTable&&n.paragraph.isInsideTable&&this.selection.isCellSelected(r.paragraph.associatedCell,r,n)){var s=r.paragraph.associatedCell.ownerTable.combineWidget(this.owner.viewer),a=n.paragraph.associatedCell;s.contains(a)&&this.removeEditRangeElementsOnTable(e)}else this.removeEditRangeElements(i,e);this.fireContentChange(),this.selection.skipEditRangeRetrieval=!1}},e.prototype.removeEditingRegion=function(e){if(!this.documentHelper.isDocumentProtected){e=e&&""!==e?e:"Everyone";for(var t=this.selection.getEditRangeStartElement(!1,!0),i=0;i<t.length;i++){var r=""===t[i].user?t[i].group:t[i].user;e===r&&this.removeUserRestrictions(r,t[i])}}},e.prototype.removeEditRangeElements=function(e,t){this.initHistory("RemoveEditRange"),this.editorHistory&&(this.editorHistory.currentBaseHistoryInfo.markerData.push(this.getMarkerData(e)),this.editorHistory.currentBaseHistoryInfo.setEditRangeInfo(e),this.editorHistory.updateHistory()),(e.user===t||e.group===t)&&this.removeUserRestrictionsInternal(e,t),this.selection.updateEditRangeCollection()},e.prototype.removeEditRangeElementsOnTable=function(e){var t=this.selection.selectedWidgets.keys;if(t){this.initComplexHistory("RemoveEditRange");for(var i=0;i<t.length;i++)if(t[i]instanceof o.nb){var r=t[i],n=r.containerWidget.editRangeID.values;if(n.length>0){for(var s=void 0,a=0;a<n.length;a++){var l=n[a];l.columnFirst==r.index&&l.columnLast==r.index&&(s=l)}if(s){var d=s.editRangeEnd;this.selection.start.setPositionParagraph(s.line,s.line.getOffset(s,s.length)),this.selection.end.setPositionParagraph(d.line,d.line.getOffset(d,d.length)-1),(s.user===e||s.group===e)&&this.removeEditRangeElements(s,e)}}}this.editorHistory&&this.editorHistory.updateComplexHistoryInternal()}},e.prototype.removeUserRestrictionsInternal=function(e,t,i){var r=t;(0,a.le)(t)&&(r=""===e.user?e.group:e.user);var o=this.documentHelper.editRanges.get(r).indexOf(e);this.documentHelper.editRanges.get(r).splice(o,1),0===this.documentHelper.editRanges.get(r).length&&this.documentHelper.editRanges.remove(r),-1!=e.columnFirst&&-1!=e.columnLast&&this.removeEditRangeFromCollection(e),e.removeEditRangeMark(),i||(e.editRangeEnd.line.children.splice(e.editRangeEnd.indexInOwner,1),e.line.children.splice(e.indexInOwner,1))},e.prototype.removeEditRangeFromCollection=function(e){var t=e.paragraph.associatedCell.ownerRow;if(t.editRangeID.containsKey(e.editRangeId)){var i=t.getCellUsingColumnIndex(t.rowIndex,e.columnFirst);!(0,a.le)(i)&&i.isRenderEditRangeStart&&i.isRenderEditRangeEnd&&(i.isRenderEditRangeEnd=!1,i.isRenderEditRangeStart=!1,t.editRangeID.remove(e.editRangeId))}else for(var r=e.paragraph.associatedCell.ownerTable,o=t.rowIndex-1;o>=0;o--){var n=r.childWidgets[o];if(n.editRangeID.containsKey(e.editRangeId)){var s=n.getCellUsingColumnIndex(n.rowIndex,e.columnFirst);if(!(0,a.le)(s)&&s.isRenderEditRangeStart&&s.isRenderEditRangeEnd){s.isRenderEditRangeEnd=!1,s.isRenderEditRangeStart=!1,n.editRangeID.remove(e.editRangeId);break}}}},e.prototype.removeAllEditRestrictions=function(){this.selection.skipEditRangeRetrieval=!0;for(var e=this.selection.start,t=this.selection.end,i=[],r=this.documentHelper.editRanges.keys,o=0;o<r.length;o++){i=this.documentHelper.editRanges.get(r[o]);for(var n=0;n<i.length;n++)i[n].editRangeEnd.line.children.splice(i[n].editRangeEnd.indexInOwner,1),i[n].line.children.splice(i[n].indexInOwner,1)}this.documentHelper.editRanges.clear(),this.selection.updateEditRangeCollection(),this.selection.start.setPositionInternal(e),this.selection.end.setPositionInternal(t),this.selection.editRegionHighlighters.clear(),this.owner.viewer.updateScrollBars(),this.selection.fireSelectionChanged(!1),this.selection.skipEditRangeRetrieval=!1},e.prototype.insertFormField=function(e){if(!((0,a.le)(this.selection.start)||this.owner.enableHeaderAndFooter||this.selection.isPlainContentControl())&&!this.owner.isReadOnlyMode){this.initHistory("InsertHyperlink");var t=!0;this.selection.isEmpty||(t=this.removeSelectedContents(this.selection)),t&&this.insertFormFieldInternal(e)}},e.prototype.insertFormFieldInternal=function(e){this.updateInsertPosition();var t=[],i=this.getCharacterFormat(this.selection),r=new n.a(void 0,this.owner);r.copyFormat(i);var s=new o.V8(0);s.formFieldData=this.getFormFieldData(e),this.editorHistory&&this.editorHistory.currentBaseHistoryInfo&&(this.editorHistory.currentBaseHistoryInfo.formFieldType=e,this.editorHistory.currentBaseHistoryInfo.fieldBegin=s),s.characterFormat.copyFormat(r),t.push(s);var a=new o.aQ(0);
1a.characterFormat.copyFormat(r),s.formFieldData.name=this.getBookmarkName(e,"Insert",this.formFieldCounter),a.name=s.formFieldData.name,t.push(a);var l=new o.a3;l.text=this.getFormFieldCode(e),t.push(l);var d=new o.V8(2);t.push(d);var h=new o.a3;h.characterFormat.copyFormat(r),"CheckBox"===e?(h.text=String.fromCharCode(9744),this.documentHelper.layout.setCheckBoxFontSize(s.formFieldData,h.characterFormat)):h.text=this.documentHelper.textHelper.repeatChar(this.documentHelper.textHelper.getEnSpaceCharacter(),5),t.push(h);var c=new o.V8(1);c.characterFormat.copyFormat(r),t.push(c),s.fieldSeparator=c.fieldSeparator=d,s.fieldEnd=d.fieldEnd=c,d.fieldBegin=c.fieldBegin=s;var p=new o.aQ(1);p.characterFormat.copyFormat(r),p.name=s.formFieldData.name,p.reference=a,a.reference=p,t.push(p),this.documentHelper.layout.isInsertFormField=!0,this.insertElement(t),this.documentHelper.layout.isInsertFormField=!1,this.selection.start.paragraph,c.linkFieldCharacter(this.documentHelper),-1===this.documentHelper.fields.indexOf(s)&&this.documentHelper.fields.push(s),this.addFormFieldWidget(s);var g=p.line.getOffset(p,1);this.selection.selects(p.line,g,!0),this.updateEndPosition(),this.reLayout(this.selection,!0)},e.prototype.addFormFieldWidget=function(e){if(-1===this.documentHelper.formFields.indexOf(e)){var t=!1;if(this.documentHelper.formFields.length>0)for(var i=this.selection.getElementPosition(e).startPosition,r=0;r<this.documentHelper.formFields.length;r++){var o=this.selection.getElementPosition(this.documentHelper.formFields[r]).startPosition;if(i.isExistBefore(o)){t=!0,this.documentHelper.formFields.splice(r,0,e);break}}t||this.documentHelper.formFields.push(e)}},e.prototype.getFormFieldData=function(e){switch(e){case"Text":return new o.$o;case"CheckBox":return new o.rF;case"DropDown":return new o.CN}},e.prototype.setFormField=function(e,t){var i,r;(0,a.le)(t.format)?(0,a.le)(t.sizeType)?(0,a.le)(t.dropdownItems)||(i="DropDown",r=new o.CN):(i="CheckBox",r=new o.rF):(i="Text",r=new o.$o),(0,a.le)(i)||(0,a.le)(r)||(r.name=(0,a.le)(t.name)?e.formFieldData.name:t.name,r.copyFieldInfo(t),this.editFormField(i,r))},e.prototype.editFormField=function(e,t){var i,r,l=this.selection.getCurrentFormField();if((0,a.le)(l)||(0,a.le)(l.formFieldData))return!1;this.initComplexHistory("FormField"),""!==t.name&&(l.formFieldData.name!==t.name&&this.documentHelper.bookmarks.containsKey(t.name)&&this.deleteBookmark(t.name),(i=new o.aQ(0)).name=t.name,(r=new o.aQ(1)).name=t.name,i.reference=r,r.reference=i),this.initHistory("InsertHyperlink"),this.editHyperlinkInternal=(0,a.le)(this.editorHistory)||this.editorHistory&&(0,a.le)(this.editorHistory.currentBaseHistoryInfo);var d=l.characterFormat.cloneFormat(),h=new n.a(void 0,this.owner);h.copyFormat(d);var c=l.fieldSeparator.nextElement.characterFormat.cloneFormat(),p=l.line.getOffset(l,0);this.selection.start.setPositionParagraph(l.line,p);var g=l.fieldEnd;l.nextNode&&l.nextNode instanceof o.aQ&&(g=l.nextNode.reference),p=g.line.getOffset(g,1),this.selection.end.setPositionParagraph(g.line,p),this.skipFieldDeleteTracking=!0,this.deleteSelectedContents(this.selection,!0),this.skipFieldDeleteTracking=!1,this.updateInsertPosition();var m=[],u=new o.V8(0);u.formFieldData=t,this.editorHistory&&this.editorHistory.currentBaseHistoryInfo&&(this.editorHistory.currentBaseHistoryInfo.formFieldType=e,this.editorHistory.currentBaseHistoryInfo.fieldBegin=u),m.push(u),u.characterFormat.copyFormat(h),(0,a.le)(i)||m.push(i);var f=new o.a3;f.text=this.getFormFieldCode(e),m.push(f);var y=new o.V8(2);y.characterFormat.copyFormat(h),m.push(y),(f=new o.a3).characterFormat.copyFormat(c),f.text=this.getDefaultText(t),"CheckBox"===e?(f.characterFormat.copyFormat(u.characterFormat),"Exactly"===t.sizeType&&(f.characterFormat.fontSize=1.35*t.size)):t instanceof o.$o&&""!==t.defaultValue&&("Text"===t.type?f.text=s.o_.formatText(t.format,t.defaultValue):"Number"===t.type?"0%"===t.format&&"%"===t.defaultValue.charAt(t.defaultValue.length-1)?f.text=t.defaultValue:f.text=s.o_.formatNumber(t.format,t.defaultValue):f.text=s.o_.formatDate(t.format,t.defaultValue)),m.push(f);var v=new o.V8(1);v.characterFormat.copyFormat(h),m.push(v);var H=v;(0,a.le)(r)||(H=r,m.push(r)),u.fieldSeparator=v.fieldSeparator=y,u.fieldEnd=y.fieldEnd=v,y.fieldBegin=v.fieldBegin=u,this.documentHelper.layout.isInsertFormField=!0,this.insertElement(m),this.documentHelper.layout.isInsertFormField=!1,this.selection.start.paragraph,v.linkFieldCharacter(this.documentHelper),-1===this.documentHelper.fields.indexOf(u)&&this.documentHelper.fields.push(u),this.addFormFieldWidget(u);var C=H.line.getOffset(H,1);return this.selection.selects(H.line,C,!0),this.updateEndPosition(),this.editorHistory&&this.editorHistory.currentBaseHistoryInfo&&this.editorHistory.updateHistory(),this.editorHistory&&this.editorHistory.currentHistoryInfo&&(this.isSkipOperationsBuild=this.owner.enableCollaborativeEditing,this.editorHistory.updateComplexHistory(),this.isSkipOperationsBuild=!1),this.reLayout(this.selection,!0),this.editHyperlinkInternal=!1,this.nodes=[],!0},e.prototype.getCheckBoxText=function(){return"Cross"===this.owner.documentEditorSettings.defaultCheckBoxOption?String.fromCharCode(9746):String.fromCharCode(9745)},e.prototype.getDefaultText=function(e){var t="";return e instanceof o.rF?t=e.defaultValue?this.getCheckBoxText():String.fromCharCode(9744):e instanceof o.CN?t=e.dropdownItems.length>0?e.dropdownItems[0]:this.documentHelper.textHelper.repeatChar(this.documentHelper.textHelper.getEnSpaceCharacter(),5):e instanceof o.$o&&(t=""!==e.defaultValue?e.defaultValue:this.documentHelper.textHelper.repeatChar(this.documentHelper.textHelper.getEnSpaceCharacter(),5)),t},e.prototype.getFormFieldCode=function(e){switch(e){case"Text":return"FORMTEXT";case"CheckBox":return"FORMCHECKBOX";case"DropDown":return"FORMDROPDOWN"}},e.prototype.toggleCheckBoxFormField=function(e,t,i){var r=e.formFieldData;if(r instanceof o.rF&&r.enabled){if(this.initHistory("UpdateFormField"),this.editorHistory){var n=void 0;r instanceof o.rF&&(n=r.checked),this.editorHistory.currentBaseHistoryInfo.fieldBegin=e,this.editorHistory.currentBaseHistoryInfo.setFormFieldInfo(e,n),this.editorHistory.updateHistory()}t?r.checked=i:r.checked=!r.checked;var s=e.fieldSeparator.nextNode;r.checked?s.text=this.getCheckBoxText():s.text=String.fromCharCode(9744),this.selection.selectFieldInternal(e,!1,!0),s.isWidthUpdated=!1,this.owner.documentHelper.layout.reLayoutParagraph(e.line.paragraph,0,0),this.reLayout(this.selection,!1)}},e.prototype.toggleContentControlCheckBox=function(e,t){(0,a.le)(this.editorHistory)||this.editorHistory.isUndoing||this.editorHistory.isRedoing||(this.selection.selectContentControlInternal(e),this.initHistory("UpdateContentControl")),this.editorHistory&&this.editorHistory.currentBaseHistoryInfo&&this.editorHistory.currentBaseHistoryInfo.setContentControlCheckBox(e,t);var i=e.nextNode;(i instanceof o.Cw||i instanceof o.jn)&&(i=i.nextNode),i instanceof o.a3||(0,a.le)(this.selection)||(i=this.selection.getNextTextElement(i)),i.isWidthUpdated=!1;var r=t?e.contentControlProperties.checkedState:e.contentControlProperties.uncheckedState;(0,a.le)(r.font)||(0,a.le)(r.value)?i.text=String.fromCharCode(t?9746:9744):(i.
1characterFormat.fontFamily=r.font,i.characterFormat.fontFamilyAscii=r.font,i.characterFormat.fontFamilyFarEast=r.font,i.characterFormat.fontFamilyNonFarEast=r.font,i.text=r.value),e.contentControlProperties.isChecked=t,this.reLayout(this.selection,!0)},e.prototype.updateFormField=function(e,t,i){var r=e.formFieldData;r&&this.updateFormFieldInternal(e,r,t,i)},e.prototype.updateContentControl=function(e,t,i){if("RichText"===e.contentControlProperties.type||"Text"===e.contentControlProperties.type||"Date"===e.contentControlProperties.type||"Picture"===e.contentControlProperties.type)this.updateContentControlResult(e,t,i);else if("CheckBox"===e.contentControlProperties.type)this.toggleContentControlCheckBox(e,"true"===t&&!i);else if("ComboBox"===e.contentControlProperties.type||"DropDownList"===e.contentControlProperties.type){var r=new o.zN;if(i){var n=new a.E7("documenteditor",this.owner.defaultLocale);r.displayText=n.getConstant("Choose an item"),r.value=n.getConstant("Choose an item")}else r.displayText=t,r.value=t;e.contentControlProperties.contentControlListItems.push(r),this.dropDownChange(e,r.displayText)}},e.prototype.updateContentControlResult=function(e,t,i){if(this.selection.selectContentControlInternal(e),"Picture"===e.contentControlProperties.type)i&&(t=""),this.insertImageAsync(t);else{if(i||(0,a.le)(t)||""===t){var r=new a.E7("documenteditor",this.owner.defaultLocale);r.setLocale(this.owner.locale),t="Date"===e.contentControlProperties.type?r.getConstant("Default Date Picker"):r.getConstant("Default Content Control Text")}if("RichText"===e.contentControlProperties.type){try{if(/^\d+$/.test(t)){var o={sections:[{blocks:[{inlines:[{text:t}]}]}]};t=JSON.stringify(o)}else"object"!=typeof t&&(t=JSON.parse(t))}catch(e){t=JSON.stringify({sections:[{blocks:[{inlines:[{text:t}]}]}]})}this.paste(t,"MergeWithExistingFormatting"),this.updatePropertiesToBlock(e,!0)}else this.insertText(t)}},e.prototype.getContentControlPropObject=function(e){return(0,a.le)(this.owner.sfdtExportModule)?{}:this.documentHelper.owner.sfdtExportModule.contentControlProperty(e,1)},e.prototype.assignContentControl=function(e,t){this.owner.parser&&this.owner.parser.parseContentControlProperties(t,e,1)},e.prototype.updateFormFieldInternal=function(e,t,i,n){var a=this.getFieldResultText(e);if(t instanceof o.$o){""===i&&(i=n?this.getDefaultText(t):this.documentHelper.textHelper.repeatChar(this.documentHelper.textHelper.getEnSpaceCharacter(),5));var l=i;"Text"===t.type&&""!==t.format&&(l=s.o_.formatText(t.format,i)),l!==a&&this.updateFormFieldResult(e,l)}else if(t instanceof o.CN){var d=t.dropdownItems[i];t.selectedIndex=i,d!==a&&this.updateFormFieldResult(e,d)}var h=e.fieldEnd.line.getOffset(e.fieldEnd,1),c=new r.JK(this.owner);c.setPositionParagraph(e.fieldEnd.line,h),this.documentHelper.selection.selectRange(c,c),this.reLayout(this.selection,!1)},e.prototype.updateFormFieldResult=function(e,t){this.selection.selectFieldInternal(e,!1,!0),this.isSkipOperationsBuild=this.owner.enableCollaborativeEditing,this.insertText(t),this.isSkipOperationsBuild=!1},e.prototype.checkBookmarkAvailability=function(e,t){for(var i=this.documentHelper.bookmarks,r=0;r<i.length;r++)if(i.containsKey(e))return!1;return!0},e.prototype.getBookmarkName=function(e,t,i){for(var r,o=!1;!1===o;)r=e+i,o=this.checkBookmarkAvailability(r,t),i+=1;return r},e.prototype.applyFormTextFormat=function(e){if(!(0,a.le)(e)){var t=this.getFieldResultText(e),i=t;(t=s.o_.formatText(e.formFieldData.format,t))!==i&&(void 0!=e.fieldSeparator&&this.applyTextFormatInternal(e,t),this.initHistory("FormTextFormat"),this.editorHistory&&(this.editorHistory.currentBaseHistoryInfo.setFormFieldInfo(e,i),this.editorHistory.updateHistory()))}},e.prototype.insertSpaceInFormField=function(){if(this.documentHelper.isInlineFormFillProtectedMode&&this.selection.isInlineFormFillMode()){var e=this.getFieldResultText();(0===e.length||"\r"===e)&&(this.insertTextInternal(this.documentHelper.textHelper.repeatChar(this.documentHelper.textHelper.getEnSpaceCharacter(),5),!0),this.selection.selectTextElementStartOfField(this.selection.getCurrentFormField()))}},e.prototype.getFieldResultText=function(e){(0,a.le)(e)&&(e=this.selection.getCurrentFormField());var t=this.selection.startOffset,i=this.selection.endOffset;this.selection.isModifyingSelectionInternally=!0,this.selection.selectFieldInternal(e,!1,!0);var r=this.selection.getText(!1);return this.selection.select(t,i),this.selection.isModifyingSelectionInternally=!1,r},e.prototype.contentControlDropDownChange=function(){var e=this.documentHelper.selection.currentContentControl;(0,a.le)(e)||("ComboBox"==e.contentControlProperties.type||"DropDownList"==e.contentControlProperties.type?this.documentHelper.contentDropDown.showPopUp(e):"Date"==e.contentControlProperties.type&&this.documentHelper.owner.dateContentDialogModule.show())},e.prototype.applyTextFormatInternal=function(e,t){var i=e.fieldSeparator.nextElement,r=0;t=t.replace(/\r/g,"");do if(!(0,a.le)(i)&&i instanceof o.a3&&(i.text=t.slice(r,r+i.text.length),r+=i.length),(0,a.le)(i.nextElement)){if((0,a.le)(i.line.nextLine)){this.documentHelper.layout.layoutBodyWidgetCollection(i.paragraph.index,i.paragraph.bodyWidget,i.paragraph,!0);var n=i.paragraph.nextRenderedWidget;if((0,a.le)(n))break;for(n instanceof o.dm&&(n=this.documentHelper.getFirstParagraphBlock(n));n.isEmpty();)n=n.nextRenderedWidget;i=n.childWidgets[0].children[0]}else i=i.line.nextLine.children[0]}else i=i.nextElement;while(!(i instanceof o.V8&&1===i.fieldType&&i.fieldBegin.formFieldData instanceof o.$o));this.documentHelper.layout.layoutBodyWidgetCollection(i.paragraph.index,i.paragraph.bodyWidget,i.paragraph,!0),this.selection.isFormatUpdated=!0,this.reLayout(this.selection,!1),this.selection.isFormatUpdated=!1},e.prototype.constructCommentInitial=function(e){for(var t=e.split(" "),i="",r=0;r<t.length;r++)t[r].length>0&&""!==t[r]&&(i+=t[r][0]);return i},e.prototype.insertFootnote=function(){if(!(this.selection.isinFootnote||this.selection.isinEndnote||this.selection.isPlainContentControl())&&!this.owner.isReadOnlyMode){this.isFootNoteInsert=!0,this.isFootNote=!0;var e,t=new o.R5;t.characterFormat.baselineAlignment="Superscript",t.footnoteType="Footnote",t.text="s";var i=new o.ZH,r=new o.z7(i),n=new o.T_;i.paragraphFormat.afterSpacing=0,n.characterFormat.baselineAlignment="Superscript",n.line=r,n.text="?",r.children.push(n);var s=new o.a3;if(s.text=" ",s.line=r,r.children.push(s),i.childWidgets.push(r),t.bodyWidget.childWidgets.push(i),this.selection.isEmpty||this.selection.handleRightKey(),this.initInsertInline(t),t.paragraph.bodyWidget.page.footnoteWidget)for(var a=0;a<t.paragraph.bodyWidget.page.footnoteWidget.bodyWidgets.length;a++)t.paragraph.bodyWidget.page.footnoteWidget.bodyWidgets[a].footNoteReference===t&&(e=t.paragraph.bodyWidget.page.footnoteWidget.bodyWidgets[a].childWidgets[0]);this.selection.start.setPositionForLineWidget(e.childWidgets[0],s.line.getOffset(s,t.text.length)),this.selection.end.setPositionInternal(this.selection.start),this.updateFootNoteIndex(),this.reLayout(this.selection,!1),this.documentHelper.layout.isLayoutWhole=!0,this.isSkipOperationsBuild=!0,this.documentHelper.layout.layoutWholeDocument(),this.isSkipOperationsBuild=!1,this.documentHelper.layout.isLayoutWhole=!1,this.separator("footnote"),this.continuationSeparator("footnote"),this.isFootNote=!1,this.isFootNoteInsert=!1}},e.prototype.updateFootnoteCollection=function(e){if(-1===this.documentHelper.footnoteCollection.indexOf(e)){var t=!1;if(this.documentHelper.footnoteCollection.length>0)for(var i=this.selection.getElementPosition(e).startPosition,r=0;r<this.documentHelper.footnoteCollection.length;r++){var o=this.selection.getElementPosition(this.documentHelper.footnoteCollection[r]).startPosition;if(i.isExistBefore(o)){t=!0,this.documentHelper.footnoteCollection.splice(r,0,e);break}}t||this.documentHelper.footnoteCollection.push(e)}},e.prototype.insertEndnote=function(){if(!(this.selection.isinFootnote||this.selection.isinEndnote||this.selection.isPlainContentControl())&&!this.owner.isReadOnlyMode){this.documentHelper.layout.isEndnoteContentChanged=!0;var e,t=new o.R5;t.characterFormat.baselineAlignment="Superscript",t.footnoteType="Endnote",t.text="s";var i=new o.ZH,r=new o.z7(i),n=new o.T_;i.paragraphFormat.afterSpacing=0,n.characterFormat.baselineAlignment="Superscript",n.line=r,n.text="?",r.children.push(n);var s=new o.a3;s.text=" ",s.line=r,r.children.push(s),i.childWidgets.push(r),t.bodyWidget.childWidgets.push(i),this.selection.isEmpty||this.selection.handleRightKey(),this.initInsertInline(t);var a=this.documentHelper.pages.length,l=this.documentHelper.pages[a-1].bodyWidgets[0];if(l.page.endnoteWidget)for(var d=0;d<l.page.endnoteWidget.bodyWidgets.length;d++)l.page.endnoteWidget.bodyWidgets[d].footNoteReference===t&&(e=l.page.endnoteWidget.bodyWidgets[d].childWidgets[0]);this.selection.start.setPositionForLineWidget(e.childWidgets[0],n.line.getOffset(s,t.text.length)),this.selection.end.setPositionInternal(this.selection.start),this.updateEndNoteIndex(),this.reLayout(this.selection,!1),this.documentHelper.layout.isLayoutWhole=!0,this.isSkipOperationsBuild=this.owner.enableCollaborativeEditing,this.documentHelper.layout.layoutWholeDocument(),this.isSkipOperationsBuild=!1,this.documentHelper.layout.isLayoutWhole=!1,this.owner.documentHelper.blockToShift=void 0,this.separator("endnote"),this.continuationSeparator("endnote"),this.documentHelper.layout.isEndnoteContentChanged=!1}},e.prototype.updateEndnoteCollection=function(e){if(-1===this.documentHelper.endnoteCollection.indexOf(e)){var t=!1;if(this.documentHelper.endnoteCollection.length>0)for(var i=this.selection.getElementPosition(e).startPosition,r=0;r<this.documentHelper.endnoteCollection.length;r++){var s=this.selection.getElementPosition(this.documentHelper.endnoteCollection[r]).startPosition;if(i.isExistBefore(s)){t=!0,this.documentHelper.endnoteCollection.splice(r,0,e);break}}t||this.documentHelper.endnoteCollection.push(e);var a=this.documentHelper.pages.length;if(this.documentHelper.endnoteCollection.length>0){var l=!1,d=void 0,c=void 0,p=this.documentHelper.endnoteCollection.indexOf(e),g=1,m=void 0,u=this.documentHelper.pages[a-1].bodyWidgets[0];if(u.page.endnoteWidget)for(var f=0;f<u.page.endnoteWidget.bodyWidgets.length;f++){var y=this.documentHelper.endnoteCollection.indexOf(u.page.endnoteWidget.bodyWidgets[f].footNoteReference);if(y>p&&y-p==1){g=f,l=!0;break}}if(d=e,u.page.endnoteWidget instanceof o.tf&&"Endnote"===u.page.endnoteWidget.footNoteType)c=u.page.endnoteWidget;else{m=!0,(c=new o.tf).footNoteType="Endnote",c.page=u.page;var v=new o.ZH;v.characterFormat=new n.a(void 0,this.owner),v.paragraphFormat=new h.h,v.index=0;var H=new o.z7(v);v.childWidgets.push(H),this.viewer.cutFromTop(this.viewer.clientActiveArea.y+18)}for(var C=d.bodyWidget,f=0;f<d.bodyWidget.childWidgets.length;f++){var F=d.bodyWidget.childWidgets[f];this.documentHelper.layout.isLayoutWhole?F.containerWidget=void 0:(F.containerWidget=C,C.page=u.page,C.sectionFormat=c.sectionFormat,F.containerWidget.containerWidget=c),l?c.bodyWidgets.splice(g,0,C):c.bodyWidgets.push(C)}g++,m&&(u.page.endnoteWidget=c),c.height+=0}}},e.prototype.updateEndNoteIndex=function(){for(var e=this.documentHelper.endnoteCollection,t=0;t<e.length;t++){var i=this.documentHelper.layout.getFootEndNote(e[t].paragraph.bodyWidget.sectionFormat.endnoteNumberFormat,t+1);if(""!=i){if(e[t].text=i,void 0!==e[t].getAllRevision())for(var r=0;r<e[t].revisionLength;)this.owner.trackChangesPane.updateCurrentTrackChanges(e[t].getRevision(r)),r++;var n=e[t].bodyWidget.childWidgets[0].childWidgets[0].children[0];if(!(0,a.le)(n)&&((n instanceof o.T_||s.o_.checkTextFormat(n.text))&&(n.text=i,n.width=e[t].bodyWidget.footNoteReference.width),void 0!=n.getAllRevision()))for(var r=0;r<n.revisionLength;)this.owner.trackChangesPane.updateCurrentTrackChanges(n.getRevision(r)),r++}}},e.prototype.separator=function(e){var t=new o.ZH,i=new o.z7(t),r=new o.a3;r.characterFormat.fontColor="#00000000",r.line=i,r.text="\x03",i.children.push(r),t.childWidgets.push(i),"footnote"===e&&this.documentHelper.footnotes.separator.length<1?this.documentHelper.footnotes.separator.push(t):"endnote"===e&&this.documentHelper.endnotes.separator.length<1&&this.documentHelper.endnotes.separator.push(t)},e.prototype.continuationSeparator=function(e){var t=new o.ZH,i=new o.z7(t),r=new o.a3;r.characterFormat.fontColor="#00000000",r.line=i,r.text="\x04",i.children.push(r),t.childWidgets.push(i),"footnote"===e&&this.documentHelper.footnotes.continuationSeparator.length<1?this.documentHelper.footnotes.continuationSeparator.push(t):"endnote"===e&&this.documentHelper.endnotes.continuationSeparator.length<1&&this.documentHelper.endnotes.continuationSeparator.push(t)},e.prototype.updateFootNoteIndex=function(){for(var e=this.documentHelper.footnoteCollection,t=0;t<e.length;t++){var i=this.documentHelper.layout.getFootEndNote(e[t].paragraph.bodyWidget.sectionFormat.footNoteNumberFormat,t+1);if(""!=i){if(e[t].text=i,void 0!==e[t].getAllRevision())for(var r=0;r<e[t].revisionLength;)this.owner.trackChangesPane.updateCurrentTrackChanges(e[t].getRevision(r)),r++;var n=e[t].bodyWidget.childWidgets[0].childWidgets[0].children[0];if(!(0,a.le)(n)&&n instanceof o.T_&&(n.text=i,n.width=e[t].bodyWidget.footNoteReference.width,void 0!=n.getAllRevision()))for(var r=0;r<n.revisionLength;)this.owner.trackChangesPane.updateCurrentTrackChanges(n.getRevision(r)),r++}}},e.prototype.setCharFormatForCollaborativeEditing=function(e){if(!(0,a.le)(this.editorHistory)&&!(0,a.le)(this.editorHistory.currentBaseHistoryInfo)&&this.owner.enableCollaborativeEditing){var t={};s.o_.writeCharacterFormat(t,!0,e,void 0,!0),this.editorHistory.currentBaseHistoryInfo.type="CharacterFormat",this.editorHistory.currentBaseHistoryInfo.format=JSON.stringify(t)}},e.prototype.clear=function(){this.pageRefFields&&(this.pageRefFields={})},e}()}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.