mirror of
https://github.com/discourse/discourse.git
synced 2024-12-02 10:15:48 +08:00
76f0cf10e6
Short URLs were resolved before diffHTML was loaded and content was swapped by it, which meant that no URLs were found and the URLs remained unsolved. This caused image elements to be blank. * DEV: Updated diffHTML to 1.0.0-beta.20
1 line
27 KiB
JavaScript
1 line
27 KiB
JavaScript
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):(e=e||self,t(e.diff={}))}(this,function(e){"use strict";function t(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function r(e){for(var r=1;r<arguments.length;r++){var n=null!=arguments[r]?arguments[r]:{};r%2?t(Object(n),!0).forEach(function(t){i(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):t(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function o(e,t,r){return t&&a(e.prototype,t),r&&a(e,r),e}function i(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function s(e){return c(e)||d(e)||l(e)||f()}function c(e){if(Array.isArray(e))return u(e)}function d(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function l(e,t){if(e){if("string"==typeof e)return u(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?u(e,t):void 0}}function u(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function f(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function h(e,t){var r=String(e);switch(t){case"boolean":return"false"!==r;case"string":return r;case"number":return ie(r,10);case"array":return r.split(",");case"object":return se(r)}}function p(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:typeof t,n=arguments.length>3?arguments[3]:void 0;if(n&&e in n)return n[e];var a="DIFF_".concat(e.replace(/[^a-zA-Z0-9]/,"")).toLowerCase();if(fe){var o=new de(ce.search);if(o.has(a))return h(decodeURIComponent(String(o.get(a))),r)}return he&&a in ae.env?h(ae.env[a],r):t}function v(e,t,n){var a=null;if(Se.protected.has(e)||Se.allocated.has(e))a=e;else if(!e||we(e)){var o=e?e.length:0;n=[];for(var i=0;i<o;i++)e&&n.push(e[i]);a=v(ke,null,n)}if(a)return a;var c="object"==typeof e,d=e;if(e&&c&&"ownerDocument"in d){if(d.nodeType===G.TEXT){var l=v(Re,d.nodeValue);return K.set(l,d),l}t={},n=[];var u=d.attributes;if(d.nodeType===G.ELEMENT&&u&&u.length)for(var f=0;f<u.length;f++){var h=u[f],p=h.name,m=h.value;m===X.STR&&p in d?t[p]=e[p]:t[p]=m}if(d.nodeType===G.ELEMENT||d.nodeType===G.FRAGMENT){n=[];for(var g=0;g<d.childNodes.length;g++){var N=d.childNodes[g];n.push(v(N))}}return K.forEach(function(t,r){t===e&&(a=r)}),a=a||v(d.nodeName,t,n),a.attributes=r(r({},a.attributes),t),a.childNodes=n,K.set(a,d),a}if(c){var b=e.rawNodeName,y=e.nodeName,T=e.nodeValue,E=e.attributes,w=e.childNodes,S=e.children,k=b||y,R=v(k,E||null,S||w);return T&&(R.nodeValue=T),R}for(var O=arguments.length,M=new Array(O>3?O-3:0),x=3;x<O;x++)M[x-3]=arguments[x];M.length&&(n=[n].concat(M)),a=Ee.get();var A=e===Re;"string"==typeof e?(a.rawNodeName=e,a.nodeName=a.rawNodeName.toLowerCase()):(a.rawNodeName=e,a.nodeName=ke),a.nodeValue=X.STR,a.key=X.STR,a.childNodes.length=0,a.attributes={};var C=we(t)||"object"!=typeof t,_=C?t:n,L=we(_)?_:[_];if(A){var I=L.join(X.STR);return a.nodeType=G.TEXT,a.nodeValue=String(I),a}if(a.nodeName===ke?a.nodeType=G.FRAGMENT:a.nodeType="#comment"===e?G.COMMENT:G.ELEMENT,_&&L.length&&(!t||!t.childNodes))for(var D=0;D<L.length;D++){var j=L[D];if(we(j)){var V;(V=a.childNodes).push.apply(V,s(j))}else{if(!j)continue;if(j.nodeType===G.FRAGMENT&&"string"==typeof j.rawNodeName){var P;(P=a.childNodes).push.apply(P,s(j.childNodes))}else j&&"object"==typeof j?a.childNodes.push(v(j)):a.childNodes.push(v(Re,null,j))}}if(t&&"object"==typeof t&&!we(t)&&(a.attributes=r({},t),t.childNodes)){var H="object"==typeof t.childNodes;a.childNodes.push(H?v(t.childNodes):v("#text",t.childNodes))}return"script"===a.nodeName&&a.attributes.src&&(a.key=String(a.attributes.src)),a.attributes&&"key"in a.attributes&&(a.key=String(a.attributes.key)),W.size&&W.forEach(function(e,t){(t=e(a))&&(a=v(t))}),a}function m(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};r.parser||(r.parser={}),t||(t=Ae);var n=new Set(p("rawElements",Le,"array",r.parser)),a=new Set(p("selfClosingElements",Ie,"array",r.parser)),o=/<!--[^]*?(?=-->)-->|<(\/?)([a-z\-\_][a-z0-9\-\_]*)\s*([^>]*?)(\/?)>/gi,i=v("#document-fragment",null,[]),s=[i],c=i,d=-1;if(!e.includes("<")&&e)return Ve(c,e,t),i;for(var l,u,f=0;l=o.exec(e);f++){d>-1&&d+l[0].length<o.lastIndex&&(u=e.slice(d,o.lastIndex-l[0].length))&&Ve(c,u,t);var h=o.lastIndex-l[0].length;if(-1===d&&h>0){var m=e.slice(0,h);m&&!Me.exec(m)&&Ve(c,m,t)}if(d=o.lastIndex,"!"!==l[0][1]){var g=xe.exec(l[2]),N=g&&t.tags[g[1]],b=N?N.name||N:l[2];if(!l[1]&&(!l[4]&&De[c.rawNodeName]&&De[c.rawNodeName][b]&&(s.pop(),c=s[s.length-1]),c=c.childNodes[c.childNodes.push(Pe(l[2],l[3],t))-1],s.push(c),r.parser.strict||n.has(b))){var y="</".concat(b,">"),T=e.indexOf(y,o.lastIndex);if(n.has(b)){-1===T?d=o.lastIndex=e.length+1:(d=T+y.length,o.lastIndex=d,l[1]=" ");var E=e.slice(l.index+l[0].length,T);Ve(c,E,t)}}if(l[1]||l[4]||a.has(b))for(;c;){if("/"===l[4]&&g){s.pop(),c=s[s.length-1];break}if(N&&c.rawNodeName===b){s.pop(),c=s[s.length-1];break}if(c.rawNodeName===b){s.pop(),c=s[s.length-1];break}var w=je[c.rawNodeName];{if(!w||!w[b])break;s.pop(),c=s[s.length-1]}}}}var S=e.slice(-1===d?0:d);if(S&&Ve(c,S,t),i.childNodes.length&&"html"===i.childNodes[0].nodeName){var k={before:[],after:[]},R={after:[]},O=i.childNodes[0],M=!0,x=!0;if(O.childNodes=O.childNodes.filter(function(e){if("body"===e.nodeName||"head"===e.nodeName)return"head"===e.nodeName&&(M=!1),"body"===e.nodeName&&(x=!1),!0;e.nodeType===G.ELEMENT&&(M&&x?k.before.push(e):!M&&x?k.after.push(e):x||R.after.push(e))}),O.childNodes[0]&&"head"===O.childNodes[0].nodeName){var A=O.childNodes[0].childNodes;A.unshift.apply(A,k.before),A.push.apply(A,k.after)}else{var C=v("head",null,[]);if(C){var _=C.childNodes;_.unshift.apply(_,k.before),_.push.apply(_,k.after),O.childNodes.unshift(C)}}if(O.childNodes[1]&&"body"===O.childNodes[1].nodeName){var L=O.childNodes[1].childNodes;L.push.apply(L,R.after)}else{var I=v("body",null,[]);if(I){var D=I.childNodes;D.push.apply(D,R.after),O.childNodes.push(I)}}}return i}function g(e){if(He(e),e.childNodes.length)for(var t=0;t<e.childNodes.length;t++)g(e.childNodes[t])}function N(e){if(Fe(e),e.childNodes.length)for(var t=0;t<e.childNodes.length;t++)N(e.childNodes[t]);K.delete(e)}function b(){Be.allocated.forEach(function(e){Be.free.add(e),Be.allocated.delete(e),K.delete(e)})}function y(e){var t=e.mount,r=e.input,n=r,a=Xe++;return p("collectMetrics",!1)?function(e){e="[".concat(a,"] ").concat(e);var r=t.host;t&&r?e="".concat(r.constructor.name," ").concat(e):n&&"function"==typeof n.rawNodeName&&(e="".concat(n.rawNodeName.name," ").concat(e));var o="".concat(e,"-end");if(Je.has(e)){var i=Je.get(e)||0,s=(performance.now()-i).toFixed(3);Je.delete(e),performance.mark(o),performance.measure("".concat(Ue," ").concat(e," (").concat(s,"ms)"),e,o)}else Je.set(e,performance.now()),performance.mark(e)}:Ge}function T(e){var t=e.state,r=e.state.isRendering;t.measure("schedule"),q.forEach(function(n){var a=n.activeTransaction&&n.activeTransaction.mount,o=e.mount;a&&o&&n.isRendering&&(a.contains&&a.contains(o)||o.contains&&o.contains(a)?(t=n,r=!0):a===o&&(t=n,r=!0))});var n=t,a=n.activeTransaction,o=n.nextTransaction;if(r){var i=e.tasks;t.nextTransaction=e,e.abort();var s=o&&o.promise||a.promise||Promise.resolve();return e.promise=s.then(function(){return e.aborted=!1,e.state.isRendering=!0,e.state.activeTransaction=e,t.measure("schedule"),st.flow(e,i.slice(1))})}t.isRendering=!0,t.activeTransaction=e,t.measure("schedule")}function E(e){var t=e.mount,r=e.input,n=e.state.measure,a=e.config,o=a.inner?"innerHTML":"outerHTML";n("should update");var i=t;if("string"==typeof r&&i[o]===r)return e.abort(!0);n("should update")}function w(e){if(q.has(e)){var t=q.get(e),r=t.mutationObserver,n=t.oldTree;r&&r.disconnect(),q.delete(e),n&&!K.has(n)&&(re.forEach(function(e){return e(n)}),N(n))}if(e){var a=e;if(a.childNodes&&a.childNodes.length)for(var o=0;o<a.childNodes.length;o++)w(a.childNodes[o]);a.shadowRoot&&w(a.shadowRoot),K.forEach(function(e,t){e===a&&(re.forEach(function(e){return e(t)}),N(t))})}}function S(e){var t=e.state,r=e.mount,n=e.input,a=e.config,o=a.inner,i=r,s=i.outerHTML;t.mutationObserver&&!t.isDirty&&(t.isDirty=Boolean(t.mutationObserver.takeRecords().length)),t.previousMarkup!==s&&(t.isDirty=!0),!t.isDirty&&t.oldTree&&s||(w(r),t.oldTree=v(i),g(t.oldTree),q.set(r,t));var c=t.oldTree,d=c.nodeName,l=c.attributes,u=n;if(!o&&u.nodeType===G.FRAGMENT&&t.oldTree.nodeType!==G.FRAGMENT){var f=[];u.childNodes.forEach(function(e){e.nodeType===G.TEXT&&!e.nodeValue.trim()||f.push(e)}),1===f.length?e.newTree=f[0]:f.length>1&&(e.newTree=v(u.childNodes))}e.newTree||(e.newTree=v(n)),e.oldTree=t.oldTree;var h=e.oldTree,p=e.newTree;if(o&&h&&p){var m="string"!=typeof p.rawNodeName,N=p.nodeType===G.FRAGMENT,b=N&&!m?p.childNodes:p;e.newTree=v(d,l,b)}}function k(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},a=arguments.length>4&&void 0!==arguments[4]&&arguments[4];e||(e=X.OBJ),t||(t=X.OBJ);var o=n.svgElements,i=void 0===o?new Set:o,s=e.nodeName,c=t.nodeName,d=e===X.OBJ||a,l="svg"===c||i.has(t),u=null;if(te.size&&te.forEach(function(n){var a=n(e,t);a&&a===e?u=r:!1===a?u=!1:a&&(t=a)}),null!==u||!t)return u;if(c===Ze){if(s===Ze&&e.nodeValue!==t.nodeValue)return r.push(Y.NODE_VALUE,e,t.nodeValue,e.nodeValue),e.nodeValue=t.nodeValue,r;if(d)return r.push(Y.NODE_VALUE,t,t.nodeValue,null),r}var f=t.childNodes||[];if(t.nodeType===G.ELEMENT){var h=d?X.OBJ:e.attributes,p=t.attributes||{};for(var v in p){var m=p[v];v in h&&h[v]===p[v]||(d||(h[v]=m),(e&&"script"===e.nodeName||"script"!==t.nodeName||"type"!==v)&&r.push(Y.SET_ATTRIBUTE,d?t:e,v,m))}if(!d)for(var g in h)g in p||(r.push(Y.REMOVE_ATTRIBUTE,e,g),delete h[g])}if(a){for(var N=0;N<f.length;N++)l&&i.add(f[N]),k(null,f[N],r,n,!0);return r}for(var b={old:new Map,new:new Map},y=0;y<$e.length;y++){var T=$e[y],E=b[T],w=arguments[y],S=w&&w.childNodes;if(S&&S.length)for(var R=0;R<S.length;R++){var O=S[R];O.key&&E.set(O.key,O)}}for(var M=e.childNodes,x=Ye(f.length,M.length),A=0;A<x;A++){var C=M&&M[A],_=f[A];if((l||_&&"svg"===_.nodeName)&&i.add(_),_)if(C){var L=_.key,I=C.key,D=b.new.has(I),j=b.old.has(L);if(I||L){if(!D&&!j){M.splice(M.indexOf(C),1,_),k(null,_,r,n,!0),r.push(Y.REPLACE_CHILD,_,C),A-=1;continue}if(!D){r.push(Y.REMOVE_CHILD,C),M.splice(M.indexOf(C),1),A-=1;continue}if(L!==I){var V=_;L&&j?(V=b.old.get(L),M.splice(M.indexOf(V),1)):V=_,k(null,V,r,n,!0),r.push(Y.INSERT_BEFORE,e,V,C),M.splice(A,0,V);continue}}var P=C.nodeName===_.nodeName,H=k(C,_,r,n,!P);if(!1!==H){if(!P){M[A]=_;var F=M.lastIndexOf(_);F>A&&M.splice(F,1),r.push(Y.REPLACE_CHILD,_,C)}}else f.splice(A,0,C),x+=1}else M.push(_),k(null,_,r,n,!0),r.push(Y.INSERT_BEFORE,e,_,null);else!1===k(C,null,r,n,!0)&&f.splice(A,0,C)}if(M.length!==f.length){for(var B=f.length;B<M.length;B++)r.push(Y.REMOVE_CHILD,M[B]);M.length=f.length}return r}function R(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:oe.document,r=arguments.length>2?arguments[2]:void 0,n=v(e),a=K.get(n);if(a)return a;var o=n.nodeName,i=n.rawNodeName,s=void 0===i?o:i,c=n.childNodes,d=void 0===c?[]:c;r=r||"svg"===o;var l=null,u=null;if(ee.forEach(function(e){(u=e(n))&&(l=u)}),!t)return l;null===l&&(l="#text"===o?t.createTextNode(n.nodeValue||X.STR):"#document-fragment"===o?t.createDocumentFragment():r?t.createElementNS(qe,s):t.createElement(s),"script"===o&&(l.type="no-execute"));var f=l;K.set(n,f);for(var h=0;h<d.length;h++){var p=R(d[h],t,r);f.appendChild(p)}return f}function O(e){var t=e.state,r=e.state.measure,n=e.oldTree,a=e.newTree,o=e.mount;if(r("sync trees"),n&&a&&n.nodeName!==a.nodeName&&a.nodeType!==G.FRAGMENT){e.patches=[Y.REPLACE_CHILD,a,n],e.oldTree=t.oldTree=a;var i=R(a);q.delete(o),q.set(i,t),e.mount=i,"script"===a.nodeName&&t.scriptsToExecute.set(a,a.attributes.type||X.STR)}else e.patches=k(n||null,a||null,[],t);r("sync trees")}function M(e,t){var r;null===(r=Z.get(e))||void 0===r||r.add(t)}function x(e,t){if(!t&&e){var r;null===(r=Z.get(e))||void 0===r||r.clear()}else if(e&&t){var n;null===(n=Z.get(e))||void 0===n||n.delete(t)}else for(var a=0;a<$.length;a++){var o;null===(o=Z.get($[a]))||void 0===o||o.clear()}}function A(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];var a=Z.get(e),o=[];if(!a)return o;var i=r[0],c=i.nodeType===G.ELEMENT;return!a.size||"textChanged"!==e&&!c?o:(a.forEach(function(e){var t=r.map(function(e){return K.get(e)||e}),n=e.apply(void 0,s(t));"object"==typeof n&&n.then&&o.push(n)}),"attached"!==e&&"detached"!==e||i.childNodes.forEach(function(t){o.push.apply(o,s(A.apply(void 0,[e,t].concat(s(r.slice(1))))))}),o)}function C(e){return Ke&&e&&e.indexOf&&e.includes("&")?(Ke.innerHTML=e,Ke.textContent||X.STR):e}function _(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:X.OBJ,r=[],n=t.ownerDocument,a=t.svgElements,o=void 0===a?new Set:a,i=e.length,c=0;;){var d=e[c];if(c===i)break;switch(d){case Y.SET_ATTRIBUTE:if("break"===function(){var t=e[c+1],a=e[c+2],i=C(e[c+3]);c+=4;var d=o.has(t),l=R(t,n,d);if(!l)return"break";var u=l.getAttribute(a),f=A("attributeChanged",t,a,u,i);return g(t),f.length?(Promise.all(f).then(function(){return rt(t,l,a,i)}),r.push.apply(r,s(f))):rt(t,l,a,i),"break"}())break;case Y.REMOVE_ATTRIBUTE:if("break"===function(){var t=e[c+1],a=e[c+2];c+=3;var i=o.has(t),d=R(t,n,i);if(!d)return"break";var l=d.getAttribute(a),u=A("attributeChanged",t,a,l,null);return g(t),u.length?(Promise.all(u).then(function(){return nt(d,a)}),r.push.apply(r,s(u))):nt(d,a),"break"}())break;case Y.NODE_VALUE:if("break"===function(){var t=e[c+1],a=e[c+2],i=e[c+3],d=o.has(t);c+=4;var l=R(t,n,d);if(!l)return"break";g(t);var u=A("textChanged",t,i,a);return u.length?(Promise.all(u).then(function(){return at(l,a)}),r.push.apply(r,s(u))):at(l,a),"break"}())break;case Y.INSERT_BEFORE:var l=e[c+1],u=e[c+2],f=e[c+3];c+=4;var h=K.get(l);if(!h)break;var p=o.has(u);g(u);var v=f&&R(f,n,p),m=R(u,n,p);h.insertBefore(m,v||null),r.push.apply(r,s(A("attached",u)));break;case Y.REPLACE_CHILD:if("break"===function(){var t,a,i,d=e[c+1],l=e[c+2];c+=3;var u=o.has(d),f=K.get(l),h=R(d,n,u);if(!f||!f.parentNode)return"break";g(d);var p=null===(t=Z.get("attached"))||void 0===t?void 0:t.size,v=null===(a=Z.get("detached"))||void 0===a?void 0:a.size,m=null===(i=Z.get("replaced"))||void 0===i?void 0:i.size;if(!p&&!v&&!m)return f.parentNode&&(f.parentNode.replaceChild(h,f),N(l)),"break";f.parentNode&&f.parentNode.insertBefore(h,f);var b=[].concat(s(p&&A("attached",d)||X.ARR),s(v&&A("detached",l)||X.ARR),s(m&&A("replaced",l,d)||X.ARR));return b.length?(Promise.all(b).then(function(){f.parentNode&&f.parentNode.removeChild(f),N(l)}),r.push.apply(r,s(b))):(f.parentNode&&f.parentNode.removeChild(f),N(l)),"break"}())break;case Y.REMOVE_CHILD:if("break"===function(){var t=e[c+1];c+=2;var n=K.get(t);if(!n||!n.parentNode)return"break";var a=A("detached",t);return a.length?(Promise.all(a).then(function(){n.parentNode&&n.parentNode.removeChild(n),N(t)}),r.push.apply(r,s(a))):(n.parentNode&&n.parentNode.removeChild(n),N(t)),"break"}())break}}return r}function L(e){var t=e.mount,r=e.state,n=e.patches,a=r.mutationObserver,o=r.measure,i=r.scriptsToExecute;o("patch node");var c=t.ownerDocument,d=e.promises||[];r.ownerDocument=c||oe.document,a&&a.disconnect();var l=function(e){"script"===e.nodeName&&i.set(e,e.attributes.type)};ee.add(l),r.ownerDocument&&d.push.apply(d,s(_(n,r))),ee.delete(l),e.promises=d,o("patch node")}function I(e){var t=e.promises;return t&&t.length?e.promise=Promise.all(t).then(function(){return e.end()}):e.promise=Promise.resolve(e.end())}function D(e){var t=e.state,r=e.input,n=e.config,a=t.measure,o=n.inner;if("string"==typeof r){a("parsing input for new tree");var i,s=m(r,void 0,n),c=s.childNodes;i=v(o?c:c[0]||c),i&&(e.newTree=i),a("parsing input for new tree")}}function j(e){return e.replace(/[&<>]/g,function(e){return"&#".concat(e.charCodeAt(0),";")})}function V(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:X.STR,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return r.inner=!0,r.executeScripts=!("executeScripts"in r)||r.executeScripts,r.tasks=r.tasks||ot,st.create(e,t,r).start()}function P(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:X.STR,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return r.inner=!1,r.executeScripts=!("executeScripts"in r)||r.executeScripts,r.tasks=r.tasks||ot,st.create(e,t,r).start()}function H(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=v(),n=new Set(t.tasks||ot);n.delete(it.endAsPromise),n.add(function(e){return B(e.oldTree)}),t.tasks=s(n),t.inner=!0;var a="";try{a=st.create(r,e,t).start()}catch(e){throw w(r),e}return w(r),a}function F(e){var t=ft(e);return t.length?" "+t.map(function(t){var r=e[t],n=!r,a="object"==typeof r||"function"==typeof r;return"".concat(t).concat(n||a?"":'="'.concat(String(r),'"'))}).join(" "):""}function B(e){var t="";if(!e)return t;var r=e.childNodes,n=e.nodeType,a=e.nodeName,o=e.nodeValue,i=e.attributes;if(11===n)for(var s=0;s<r.length;s++)t+=B(r[s]);else if(r.length||1!==n){if(3===n)t+=o;else if(r.length){var c=r.map(function(e){return"".concat(B(e))}).join("");t+="<".concat(a).concat(F(i),">").concat(c,"</").concat(a,">")}}else t+="<".concat(a).concat(F(i),"></").concat(a,">");return t}function z(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];var a=v("#text",X.STR);if(!e)return a;if("string"==typeof e&&(e=[e]),1===e.length&&!r.length){if(!e[0])return a;var o=p("strict",!1,"boolean",{strict:z[ut]});delete z[ut];var i=m(e[0],void 0,{parser:{strict:o}}),s=i.childNodes;return v(1===s.length?s[0]:s)}var c=X.STR,d={attributes:{},children:{},tags:{}};e.forEach(function(e,t){if(c+=e,r.length){var n=vt(r),a=c.trim().slice(-1),o=c.lastIndexOf(">")<c.lastIndexOf("<"),i=Boolean(a.match(pt)),s="object"==typeof n,l="".concat(Oe).concat(t,"__");i?(d.tags[t]=n,c+=l):o?(d.attributes[t]=n,c+=l):ht(n)||s?(d.children[t]=v(n),c+=l):n&&(c+=n)}});var l=p("strict",!1,"boolean",{strict:z[ut]}),u=m(c,d,{parser:{strict:l}}),f=u.childNodes;return v(1===f.length?f[0]:f)}function U(e){z[ut]=!0;for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];return z.apply(void 0,[e].concat(r))}function J(e){var t="function"==typeof e,r=e.subscribe,n=e.unsubscribe,a=e.createTreeHook,o=e.createNodeHook,i=e.syncTreeHook,s=e.releaseHook,c=e.parseHook;return t&&Q.add(e),r&&r(dt),a&&W.add(a),o&&ee.add(o),i&&te.add(i),s&&re.add(s),c&&ne.add(c),function(){t&&Q.delete(e),n&&n(dt),a&&W.delete(a),o&&ee.delete(o),i&&te.delete(i),s&&re.delete(s),c&&ne.delete(c)}}var G={ELEMENT:1,ATTR:2,TEXT:3,COMMENT:8,FRAGMENT:11},X={STR:"",NUM:1,OBJ:{},ARR:[],MAP:new Map,SET:new Set,DOM:{}},Y={SET_ATTRIBUTE:0,REMOVE_ATTRIBUTE:1,NODE_VALUE:2,INSERT_BEFORE:3,REPLACE_CHILD:4,REMOVE_CHILD:5},$=["attached","detached","replaced","attributeChanged","textChanged"],Z=new Map([["attached",new Set],["detached",new Set],["replaced",new Set],["attributeChanged",new Set],["textChanged",new Set]]),q=new Map,K=new Map,Q=new Set,W=new Set,ee=new Set,te=new Set,re=new Set,ne=new Set,ae="undefined"!=typeof process?process:{env:{NODE_ENV:"development"},argv:[]},oe="object"==typeof global?global:window||{},ie=Number.parseInt,se=JSON.parse,ce=oe.location,de=oe.URLSearchParams,le=void 0!==de,ue=void 0!==ce,fe=le&&ue,he=ae.env,pe={collectMetrics:!0,executeScripts:!0},ve=p("initialPoolSize",5e3),me=new Set,ge=new Set,Ne=new Set,be=function(){return{rawNodeName:X.STR,nodeName:X.STR,nodeValue:X.STR,nodeType:G.ELEMENT,key:X.STR,childNodes:[],attributes:{}}},ye={free:me,allocated:ge,protected:Ne},Te=me.values(),Ee={size:ve,memory:ye,fill:function(){for(var e=this,t=me.size;t<this.size;t++)me.add(be());this.size<me.size&&me.forEach(function(t){me.size!==e.size&&me.delete(t)})},get:function(){var e=Te.next(),t=e.value,r=void 0===t?be():t;return e.done&&(Te=me.values()),me.delete(r),ge.add(r),r},protect:function(e){ge.delete(e),Ne.add(e)},unprotect:function(e){Ne.has(e)?(Ne.delete(e),me.add(e)):ge.has(e)&&(ge.delete(e),me.add(e))}};Ee.fill();var we=Array.isArray,Se=Ee.memory,ke="#document-fragment",Re="#text",Oe="__DIFFHTML__",Me=/<!DOCTYPE.*>/i,xe=new RegExp("".concat(Oe,"([^_]*)__")),Ae={tags:[],attributes:{},children:{}},Ce=Object.assign,_e=Array.isArray,Le=["script","noscript","style","template"],Ie=["meta","img","link","input","area","br","hr","area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],De={li:{li:!0},p:{p:!0,div:!0},td:{td:!0,th:!0},th:{td:!0,th:!0}},je={li:{ul:!0,ol:!0},a:{div:!0},b:{div:!0},i:{div:!0},p:{div:!0},td:{tr:!0,table:!0},th:{tr:!0,table:!0}},Ve=function(e,t,r){var n;if(!("childNodes"in e.attributes)){if(t&&!Me.test(t)&&!xe.test(t))return e.childNodes.push(v("#text",t));for(var a=[],o=t.split(xe),i=0;i<o.length;i++){var c=o[i];if(c)if(i%2==1){var d=r.children[c],l=c in r.children?d:v("#text","".concat(Oe).concat(c,"__"));if(!l)continue;var u=l.nodeType===G.FRAGMENT;"string"==typeof l.rawNodeName&&u?a.push.apply(a,s(l.childNodes)):a.push(l)}else Me.test(c)||a.push(v("#text",c))}(n=e.childNodes).push.apply(n,a)}},Pe=function(e,t,r,n){var a=null,o=/([_@$#a-z][^\s\x00-\x1F"'>\/=\uFDD0-\uFDEF\uFFFE\uFFFF]*)\s*(=\s*("([^"]+)"|'([^']+)'|(\S+)))?/gi;if(a=xe.exec(e))return Pe(r.tags[a[1]],t,r);for(var i,s={};i=o.exec(t||X.STR);){var c="string"==typeof e,d=i[1],l=void 0;if(""===d){var u=t.match(xe);l=u?u[0]:""}var f=i[6]||i[5]||i[4],h=l||f||(c?i[1]:f||!0),p=String(h).match(xe);if(p&&p.length)for(var m=String(h).split(xe),g=xe.exec(d),N=g?r.attributes[g[1]]:d,b=0;b<m.length;b++){var y=m[b];if(y)if(b%2==1){var T="object"==typeof N,E=r.attributes[y],w="".concat(Oe).concat(y,"__");s[N]?s[N]+=y in r.attributes?E:w:T?N&&!_e(N)&&Ce(s,N):N&&(s[N]=y in r.attributes?E:w)}else s[N]?s[N]+=y:s[N]=y}else if(p=xe.exec(d)){var S=r.attributes[p[1]];"object"!=typeof S||_e(S)?s[S]=X.STR:Ce(s,S)}else s[d]="''"===h||'""'===h?X.STR:h}return v(e,s,s.childNodes||[])},He=Ee.protect,Fe=Ee.unprotect,Be=Ee.memory,ze=Object.freeze({__proto__:null,protectVTree:g,unprotectVTree:N,gc:b}),Ue="diffHTML",Je=new Map,Ge=function(){},Xe=0,Ye=Math.max,$e=["old","new"],Ze="#text",qe="http://www.w3.org/2000/svg",Ke=oe.document?document.createElement("div"):null,Qe=Object.keys,We=new Set,et=new Set,tt=["class","checked","disabled","selected"],rt=function(e,t,r,n){var a="object"==typeof n&&n,o="function"==typeof n,i="symbol"==typeof n,s=0===r.indexOf("on"),c=s?r.toLowerCase():r,d=e.nodeName+"-"+c,l=t;if(et.has(d))t[c]=n;else if(!We.has(d))try{t[c]=n,et.add(d)}catch(e){We.add(d)}if(a||o||i){if(a&&"style"===c)for(var u=Qe(n),f=0;f<u.length;f++)l.style[u[f]]=n[u[f]]}else{var h=null===n||void 0===n;c&&l.setAttribute(c,h?X.STR:n)}},nt=function(e,t){var r=0===t.indexOf("on");e.removeAttribute(t);var n=e.nodeName+"-"+t;if(et.has(n)){var a=e;r?a[t]=void 0:delete a[t],tt.includes(t)&&(e[t]=!1)}else if(!We.has(n))try{var o=e;r?o[t]=void 0:delete o[t],tt.includes(t)&&(e[t]=!1),et.add(n)}catch(e){We.add(n)}},at=function(e,t){var r=e;t.includes("&")?r.nodeValue=C(t):r.nodeValue=t},ot=[T,E,S,O,L,I],it={schedule:T,shouldUpdate:E,reconcileTrees:S,syncTrees:O,patchNode:L,endAsPromise:I},st=function(){function e(t,r,a){var o=this;n(this,e),i(this,"state",X.OBJ),i(this,"mount",X.OBJ),i(this,"input",X.OBJ),i(this,"oldTree",void 0),i(this,"newTree",void 0),i(this,"promise",void 0),i(this,"promises",void 0),i(this,"tasks",[]),i(this,"patches",[]),this.mount=t,this.input=r,this.config=a;var s=function(){return o.state.isDirty=!0},c="MutationObserver"in(oe.window||X.OBJ);this.state=q.get(t)||{measure:y(this),svgElements:new Set,scriptsToExecute:new Map,activeTransaction:this,mutationObserver:c&&new oe.window.MutationObserver(s)},this.tasks=p("tasks",ot,void 0,a).slice(),this.endedCallbacks=new Set,q.set(t,this.state)}return o(e,[{key:"start",value:function(){var t=this.state.measure,r=this.tasks,n=r.pop();return t("render"),this.aborted=!1,e.invokeMiddleware(this),n&&r.push(n),e.flow(this,r)}},{key:"abort",value:function(e){if(this.aborted=!0,e)return this.tasks[this.tasks.length-1](this)}},{key:"end",value:function(){var e=this,t=this.state,r=this.config,n=this.mount,a=t.mutationObserver,o=t.measure,i=t.svgElements,s=t.scriptsToExecute,c=n;return o("finalize"),this.completed=!0,i.clear(),t.isRendering=!1,t.isDirty=!1,c.ownerDocument&&a?a.observe(c,{subtree:!0,childList:!0,attributes:!0,characterData:!0}):t.isDirty=!0,s.forEach(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:X.STR,t=arguments.length>1?arguments[1]:void 0,r=K.get(t);e?r.setAttribute("type",e):r.removeAttribute("type")}),t.previousMarkup="outerHTML"in c?c.outerHTML:X.STR,r.executeScripts&&s.forEach(function(e,r){var n=K.get(r),a=n.cloneNode(!0);n&&(q.has(n)&&(w(n),q.set(a,t)),K.set(r,a),n.parentNode&&n.parentNode.replaceChild(a,n))}),s.clear(),Ee.memory.free.size<2*Ee.memory.allocated.size&&b(),this.endedCallbacks.forEach(function(t){return t(e)}),this.endedCallbacks.clear(),o("finalize"),o("render"),this}},{key:"onceEnded",value:function(e){this.endedCallbacks.add(e)}}],[{key:"create",value:function(t,r,n){return new e(t,r,n)}},{key:"flow",value:function(e,t){for(var r=e,n=0;n<t.length;n++){if(e.aborted)return r;if(void 0!==(r=t[n](e))&&r!==e)return r}return r}},{key:"assert",value:function(e){}},{key:"invokeMiddleware",value:function(e){var t=e.state.measure,r=e.tasks;Q.forEach(function(n){var a="invoke ".concat(n.name||"anon");t(a);var o=n(e);o&&r.push(o),t(a)})}}]),e}(),ct={StateCache:q,NodeCache:K,TransitionCache:Z,MiddlewareCache:Q,CreateTreeHookCache:W,CreateNodeHookCache:ee,SyncTreeHookCache:te,ReleaseHookCache:re,ParseHookCache:ne},dt=r({decodeEntities:C,escape:j,makeMeasure:y,memory:ze,Pool:Ee,process:ae,PATCH_TYPE:Y,globalConfig:pe,createNode:R,syncTree:k,Transaction:st,defaultTasks:ot,tasks:it},ct),lt=Symbol.for("diffHTML"),ut=Symbol.for("diff.strict"),ft=Object.keys,ht=Array.isArray,pt=/(<|\/)/,vt=function(e){var t=e.shift();return"string"==typeof t?j(C(t)):t};delete z[ut],z.strict=U;ot.splice(ot.indexOf(S),0,D),dt.parse=m,dt.VERSION="1.0.0-beta.20";var mt={};mt.VERSION="1.0.0-beta.20",mt.addTransitionState=M,mt.removeTransitionState=x,mt.release=w,mt.createTree=v,mt.use=J,mt.outerHTML=P,mt.innerHTML=V,mt.toString=H,mt.html=z,mt.Internals=dt;var gt=oe;if(lt in oe){var Nt=gt[lt];"1.0.0-beta.20"!==Nt.VERSION&&console.log("Loaded ".concat("1.0.0-beta.20"," after ").concat(Nt.VERSION))}gt[lt]=mt,gt.devTools&&(gt.unsubscribeDevTools=J(gt.devTools(dt))),e.Internals=dt,e.VERSION="1.0.0-beta.20",e.addTransitionState=M,e.createTree=v,e.default=mt,e.html=z,e.innerHTML=V,e.outerHTML=P,e.release=w,e.removeTransitionState=x,e.toString=H,e.use=J,Object.defineProperty(e,"__esModule",{value:!0})}); |