var root,factory;root=this,factory=function(){var t=["table","thead","tbody","tfoot","tr","col","colgroup","object","embed","param","ol","ul","li","dl","blockquote","select","optgroup","option","textarea","script","style","a","br","b","p","strong"];function e(t){return t.replace(/\s*$/,"")}function i(t,e){if(t.innerText)t.innerText=e;else if(t.nodeValue)t.nodeValue=e;else{if(!t.textContent)return!1;t.textContent=e}}function n(t,e,n,o){var l,h=t.parentElement;t.remove();var r=n?n.length:0;if(h.childNodes.length>r){let a=h.childNodes;return s(l=a[a.length-1-r],e,n,o)}{let d=h.previousElementSibling?h.previousElementSibling.childNodes:null;if((l=d?d[d.length-1]:null)&&l.length)return i(l,l.textContent+o.ellipsis),h.remove(),n&&n.text.length&&(l.append?l.append(n):l.after(n)),!0}return!1}function s(t,s,o,l){return"end"===l.position?function t(s,o,l,h){for(var r,a,d=s.textContent,p="",c=0,g=d.length;c<=g;)r=c+(g-c>>1),i(s,a=e(d.substr(0,r+1))+h.ellipsis),o.clientHeight>h.maxHeight?g=r-1:(c=r+1,p=p.length>a.length?p:a);return p.length>0?(i(s,p),!0):n(s,o,l,h)}(t,s,o,l):"start"===l.position?function t(s,o,l,h){for(var r,a,d=s.textContent,p="",c=0,g=d.length;c<=g;)r=c+(g-c>>1),i(s,a=h.ellipsis+e(d.substr(r-1,d.length))),o.clientHeight>h.maxHeight?c=r+1:(g=r-1,p=p.length>a.length?p:a);return p.length>0?(i(s,p),!0):n(s,o,l,h)}(t,s,o,l):function t(s,o,l,h){for(var r,a,d=s.textContent,p="",c=0,g=d.length,u=g>>1;c<=u;)r=c+(u-c>>1),i(s,a=e(d.substr(0,r))+h.ellipsis+d.substr(g-r,g-r)),o.clientHeight>h.maxHeight?u=r-1:(c=r+1,p=p.length>a.length?p:a);return p.length>0?(i(s,p),!0):n(s,o,l,h)}(t,s,o,l)}function o(e,i,n,o){for(var h,r=e.cloneNode(!0),a=r.childNodes,d=a.length,p=!1;e.firstChild;)e.removeChild(e.firstChild);for(let c=0;c<d&&!p;c++){if(8===(h=a[0]).nodeType){r.removeChild(h);continue}if(e.appendChild(h),n&&n.text.length&&(t.indexOf(e.tagName.toLowerCase())>=0?e.after(n):e.append(n)),i.clientHeight>o.maxHeight){if(h.tagName&&t.indexOf(h.tagName.toLowerCase())>=0){p=!0,e.removeChild(h),c<d&&e.append(n);break}p=3===h.nodeType?s(h,i,n,o):l(h,i,n,o)}!p&&n&&n.text.length&&n.remove()}return p}function l(e,i,n,h){return"end"===h.position?o(e,i,n,h):"start"===h.position?function e(i,n,o,h){for(var r,a=i.cloneNode(!0),d=a.childNodes,p=d.length,c=!1;i.firstChild;)i.removeChild(i.firstChild);for(let g=p-1;g>=0&&!c;g--){if(8===(r=d[d.length-1]).nodeType){a.removeChild(r);continue}i.insertBefore(r,i.firstChild),o&&o.text.length&&(t.indexOf(i.tagName.toLowerCase())>=0?i.after(o):i.append(o)),n.clientHeight>h.maxHeight&&(c=3===r.nodeType?s(r,n,o,h):l(r,n,o,h)),!c&&o&&o.text.length&&o.remove()}return c}(e,i,n,h):o(e,i,n,h)}function h(t,e){this.element=t,this._name="truncate",this._defaults={lines:1,ellipsis:"…",showMore:"",showLess:"",position:"end",lineHeight:"auto"},this.config(e),this.original=this.cached=t.innerHTML,this.isTruncated=!1,this.isCollapsed=!0,this.update()}return h.prototype={config:function(t){if(this.options=Object.assign({},this._defaults,t),"auto"===this.options.lineHeight){var e=getComputedStyle(this.element).lineHeight,i=18;"normal"!==e&&(i=parseInt(e,10)),this.options.lineHeight=i}void 0===this.options.maxHeight&&(this.options.maxHeight=parseInt(this.options.lines,10)*parseInt(this.options.lineHeight,10)),"start"!==this.options.position&&"middle"!==this.options.position&&"end"!==this.options.position&&(this.options.position="end");let n=document.createRange().createContextualFragment(this.options.showMore);this.clipNode=n?n.childNodes[0]:null,this.original&&this.update()},update:function(t){var e=!this.isCollapsed;void 0!==t?this.original=this.element.innerHTML=t:this.isCollapsed&&this.element.innerHTML===this.cached&&(this.element.innerHTML=this.original);var i=document.createElement("div"),n=this.element.childNodes,s=n.length;for(let o=0;o<s;o++){let h=n[0];i.appendChild(h)}i.style.border="none",i.style.margin=0,i.style.padding=0,i.style.width="auto",i.style.height="auto",i.style.wordWrap="break-word",this.element.appendChild(i),this.isTruncated=!1,this.element.clientHeight>this.options.maxHeight?(this.isTruncated=l(i,i,this.clipNode,this.options),this.isExplicitlyCollapsed&&(this.isCollapsed=!0,e=!1)):this.isCollapsed=!1,i.replaceWith(...i.childNodes),this.cached=this.element.innerHTML,e&&(this.element.innerHTML=this.original)},expand:function(){this.isExplicitlyCollapsed&&(this.isExplicitlyCollapsed=!1),this.isCollapsed&&(this.isCollapsed=!1,this.element.innerHTML=this.isTruncated?this.original+this.options.showLess:this.original)},collapse:function(t){this.isExplicitlyCollapsed=!0,!this.isCollapsed&&(this.isCollapsed=!0,(t=t||!1)?this.update():this.element.innerHTML=this.cached)}},h},root.Truncate=factory();
