AIRA/src/frontend/libs/linkify-element.min.js

1 line
1.8 KiB
JavaScript

"use strict";!function(e,t){var n=function(t){function n(e,t,n){var r=n[n.length-1];e.replaceChild(r,t);for(var i=n.length-2;i>=0;i--)e.insertBefore(n[i],r),r=n[i]}function r(e,t,n){for(var r=[],i=e,a=Array.isArray(i),o=0,i=a?i:i[Symbol.iterator]();;){var l;if(a){if(o>=i.length)break;l=i[o++]}else{if(o=i.next(),o.done)break;l=o.value}var s=l;if("nl"===s.type&&t.nl2br)r.push(n.createElement("br"));else if(s.isLink&&t.check(s)){var f=t.resolve(s),c=f.formatted,d=f.formattedHref,u=f.tagName,v=f.className,h=f.target,m=f.events,g=f.attributes,p=n.createElement(u);if(p.setAttribute("href",d),v&&p.setAttribute("class",v),h&&p.setAttribute("target",h),g)for(var b in g)p.setAttribute(b,g[b]);if(m)for(var y in m)p.addEventListener?p.addEventListener(y,m[y]):p.attachEvent&&p.attachEvent("on"+y,m[y]);p.appendChild(n.createTextNode(c)),r.push(p)}else r.push(n.createTextNode(s.toString()))}return r}function i(e,t,a){if(!e||e.nodeType!==c)throw new Error("Cannot linkify "+e+" - Invalid DOM Node type");var s=t.ignoreTags;if("A"===e.tagName||l.contains(s,e.tagName))return e;for(var u=e.firstChild;u;){var v=void 0,h=void 0,m=void 0;switch(u.nodeType){case c:i(u,t,a);break;case d:if(v=u.nodeValue,h=o(v),0===h.length||1===h.length&&h[0]instanceof f)break;m=r(h,t,a),n(e,u,m),u=m[m.length-1]}u=u.nextSibling}return e}function a(t,n){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];try{r=r||document||e&&e.document||global&&global.document}catch(a){}if(!r)throw new Error("Cannot find document implementation. If you are in a non-browser environment like Node.js, pass the document implementation as the third argument to linkifyElement.");return n=new s(n),i(t,n,r)}var o=t.tokenize,l=t.options,s=l.Options,f=t.parser.TOKENS.TEXT,c=1,d=3;return a.helper=i,a.normalize=function(e){return new s(e)},a}(t);e.linkifyElement=n}(window,linkify);