disqusjs
Version:
Alternative DISQUS - Render comments components from Disqus API
2 lines (1 loc) • 32.8 kB
JavaScript
function e(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}var n,t,r,o,l,_,i,s,u,c,a,d,f,p={},h=[],m=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,v=Array.isArray;function y(e,n){for(var t in n)e[t]=n[t];return e}function g(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function b(e,n,r){var o,l,_,i={};for(_ in n)"key"==_?o=n[_]:"ref"==_?l=n[_]:i[_]=n[_];if(arguments.length>2&&(i.children=arguments.length>3?t.call(arguments,2):r),"function"==typeof e&&null!=e.defaultProps)for(_ in e.defaultProps)void 0===i[_]&&(i[_]=e.defaultProps[_]);return q(e,i,o,l,null)}function q(e,n,t,l,_){var i={type:e,props:n,key:t,ref:l,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:null==_?++o:_,__i:-1,__u:0};return null==_&&null!=r.vnode&&r.vnode(i),i}function k(e){return e.children}function w(e,n){this.props=e,this.context=n}function j(e,n){if(null==n)return e.__?j(e.__,e.__i+1):null;for(var t;n<e.__k.length;n++)if(null!=(t=e.__k[n])&&null!=t.__e)return t.__e;return"function"==typeof e.type?j(e):null}function N(e){(!e.__d&&(e.__d=!0)&&l.push(e)&&!C.__r++||_!==r.debounceRendering)&&((_=r.debounceRendering)||i)(C)}function C(){for(var e,n,t,o,_,i,u=1;l.length;)l.length>u&&l.sort(s),e=l.shift(),u=l.length,e.__d&&(n=void 0,o=(t=e.__v).__e,_=[],i=[],e.__P&&((n=y({},t)).__v=t.__v+1,r.vnode&&r.vnode(n),D(e.__P,n,t,e.__n,e.__P.namespaceURI,32&t.__u?[o]:null,_,null==o?j(t):o,!!(32&t.__u),i),n.__v=t.__v,n.__.__k[n.__i]=n,H(_,n,i),n.__e!=o&&function e(n){var t,r;if(null!=(n=n.__)&&null!=n.__c){for(n.__e=n.__c.base=null,t=0;t<n.__k.length;t++)if(null!=(r=n.__k[t])&&null!=r.__e){n.__e=n.__c.base=r.__e;break}return e(n)}}(n)));C.__r=0}function S(e,n,t,o,l,_,i,s,u,c,a){var d,f,m,y,b,w,N=o&&o.__k||h,C=n.length;for(u=function(e,n,t,o,l){var _,i,s,u,c,a=t.length,d=a,f=0;for(e.__k=Array(l),_=0;_<l;_++)null!=(i=n[_])&&"boolean"!=typeof i&&"function"!=typeof i?(u=_+f,(i=e.__k[_]="string"==typeof i||"number"==typeof i||"bigint"==typeof i||i.constructor==String?q(null,i,null,null,null):v(i)?q(k,{children:i},null,null,null):void 0===i.constructor&&i.__b>0?q(i.type,i.props,i.key,i.ref?i.ref:null,i.__v):i).__=e,i.__b=e.__b+1,s=null,-1!==(c=i.__i=function(e,n,t,r){var o,l,_=e.key,i=e.type,s=n[t];if(null===s&&null==e.key||s&&_==s.key&&i===s.type&&0==(2&s.__u))return t;if(r>+(null!=s&&0==(2&s.__u)))for(o=t-1,l=t+1;o>=0||l<n.length;){if(o>=0){if((s=n[o])&&0==(2&s.__u)&&_==s.key&&i===s.type)return o;o--}if(l<n.length){if((s=n[l])&&0==(2&s.__u)&&_==s.key&&i===s.type)return l;l++}}return -1}(i,t,u,d))&&(d--,(s=t[c])&&(s.__u|=2)),null==s||null===s.__v?(-1==c&&(l>a?f--:l<a&&f++),"function"!=typeof i.type&&(i.__u|=4)):c!=u&&(c==u-1?f--:c==u+1?f++:(c>u?f--:f++,i.__u|=4))):e.__k[_]=null;if(d)for(_=0;_<a;_++)null!=(s=t[_])&&0==(2&s.__u)&&(s.__e==o&&(o=j(s)),function e(n,t,o){var l,_;if(r.unmount&&r.unmount(n),(l=n.ref)&&(l.current&&l.current!==n.__e||T(l,null,t)),null!=(l=n.__c)){if(l.componentWillUnmount)try{l.componentWillUnmount()}catch(e){r.__e(e,t)}l.base=l.__P=null}if(l=n.__k)for(_=0;_<l.length;_++)l[_]&&e(l[_],t,o||"function"!=typeof n.type);o||g(n.__e),n.__c=n.__=n.__e=void 0}(s,s));return o}(t,n,N,u,C),d=0;d<C;d++)null!=(m=t.__k[d])&&(f=-1===m.__i?p:N[m.__i]||p,m.__i=d,w=D(e,m,f,l,_,i,s,u,c,a),y=m.__e,m.ref&&f.ref!=m.ref&&(f.ref&&T(f.ref,null,m),a.push(m.ref,m.__c||y,m)),null==b&&null!=y&&(b=y),4&m.__u||f.__k===m.__k?u=function e(n,t,r){var o,l;if("function"==typeof n.type){for(o=n.__k,l=0;o&&l<o.length;l++)o[l]&&(o[l].__=n,t=e(o[l],t,r));return t}n.__e!=t&&(t&&n.type&&!r.contains(t)&&(t=j(n)),r.insertBefore(n.__e,t||null),t=n.__e);do t=t&&t.nextSibling;while(null!=t&&8==t.nodeType);return t}(m,u,e):"function"==typeof m.type&&void 0!==w?u=w:y&&(u=y.nextSibling),m.__u&=-7);return t.__e=b,u}function x(e,n){return n=n||[],null==e||"boolean"==typeof e||(v(e)?e.some(function(e){x(e,n)}):n.push(e)),n}function P(e,n,t){"-"==n[0]?e.setProperty(n,null==t?"":t):e[n]=null==t?"":"number"!=typeof t||m.test(n)?t:t+"px"}function E(e,n,t,r,o){var l;e:if("style"==n)if("string"==typeof t)e.style.cssText=t;else{if("string"==typeof r&&(e.style.cssText=r=""),r)for(n in r)t&&n in t||P(e.style,n,"");if(t)for(n in t)r&&t[n]===r[n]||P(e.style,n,t[n])}else if("o"==n[0]&&"n"==n[1])l=n!=(n=n.replace(u,"$1")),n=n.toLowerCase()in e||"onFocusOut"==n||"onFocusIn"==n?n.toLowerCase().slice(2):n.slice(2),e.l||(e.l={}),e.l[n+l]=t,t?r?t.t=r.t:(t.t=c,e.addEventListener(n,l?d:a,l)):e.removeEventListener(n,l?d:a,l);else{if("http://www.w3.org/2000/svg"==o)n=n.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if("width"!=n&&"height"!=n&&"href"!=n&&"list"!=n&&"form"!=n&&"tabIndex"!=n&&"download"!=n&&"rowSpan"!=n&&"colSpan"!=n&&"role"!=n&&"popover"!=n&&n in e)try{e[n]=null==t?"":t;break e}catch(e){}"function"==typeof t||(null==t||!1===t&&"-"!=n[4]?e.removeAttribute(n):e.setAttribute(n,"popover"==n&&1==t?"":t))}}function U(e){return function(n){if(this.l){var t=this.l[n.type+e];if(null==n.u)n.u=c++;else if(n.u<t.t)return;return t(r.event?r.event(n):n)}}}function D(e,n,o,l,_,i,s,u,c,a){var d,f,h,m,b,q,N,C,x,P,U,D,H,T,A,I,M,R=n.type;if(void 0!==n.constructor)return null;128&o.__u&&(c=!!(32&o.__u),i=[u=n.__e=o.__e]),(d=r.__b)&&d(n);e:if("function"==typeof R)try{if(C=n.props,x="prototype"in R&&R.prototype.render,P=(d=R.contextType)&&l[d.__c],U=d?P?P.props.value:d.__:l,o.__c?N=(f=n.__c=o.__c).__=f.__E:(x?n.__c=f=new R(C,U):(n.__c=f=new w(C,U),f.constructor=R,f.render=$),P&&P.sub(f),f.props=C,f.state||(f.state={}),f.context=U,f.__n=l,h=f.__d=!0,f.__h=[],f._sb=[]),x&&null==f.__s&&(f.__s=f.state),x&&null!=R.getDerivedStateFromProps&&(f.__s==f.state&&(f.__s=y({},f.__s)),y(f.__s,R.getDerivedStateFromProps(C,f.__s))),m=f.props,b=f.state,f.__v=n,h)x&&null==R.getDerivedStateFromProps&&null!=f.componentWillMount&&f.componentWillMount(),x&&null!=f.componentDidMount&&f.__h.push(f.componentDidMount);else{if(x&&null==R.getDerivedStateFromProps&&C!==m&&null!=f.componentWillReceiveProps&&f.componentWillReceiveProps(C,U),!f.__e&&(null!=f.shouldComponentUpdate&&!1===f.shouldComponentUpdate(C,f.__s,U)||n.__v==o.__v)){for(n.__v!=o.__v&&(f.props=C,f.state=f.__s,f.__d=!1),n.__e=o.__e,n.__k=o.__k,n.__k.some(function(e){e&&(e.__=n)}),D=0;D<f._sb.length;D++)f.__h.push(f._sb[D]);f._sb=[],f.__h.length&&s.push(f);break e}null!=f.componentWillUpdate&&f.componentWillUpdate(C,f.__s,U),x&&null!=f.componentDidUpdate&&f.__h.push(function(){f.componentDidUpdate(m,b,q)})}if(f.context=U,f.props=C,f.__P=e,f.__e=!1,H=r.__r,T=0,x){for(f.state=f.__s,f.__d=!1,H&&H(n),d=f.render(f.props,f.state,f.context),A=0;A<f._sb.length;A++)f.__h.push(f._sb[A]);f._sb=[]}else do f.__d=!1,H&&H(n),d=f.render(f.props,f.state,f.context),f.state=f.__s;while(f.__d&&++T<25);f.state=f.__s,null!=f.getChildContext&&(l=y(y({},l),f.getChildContext())),x&&!h&&null!=f.getSnapshotBeforeUpdate&&(q=f.getSnapshotBeforeUpdate(m,b)),I=d,null!=d&&d.type===k&&null==d.key&&(I=function e(n){return"object"!=typeof n||null==n?n:v(n)?n.map(e):y({},n)}(d.props.children)),u=S(e,v(I)?I:[I],n,o,l,_,i,s,u,c,a),f.base=n.__e,n.__u&=-161,f.__h.length&&s.push(f),N&&(f.__E=f.__=null)}catch(e){if(n.__v=null,c||null!=i)if(e.then){for(n.__u|=c?160:128;u&&8==u.nodeType&&u.nextSibling;)u=u.nextSibling;i[i.indexOf(u)]=null,n.__e=u}else for(M=i.length;M--;)g(i[M]);else n.__e=o.__e,n.__k=o.__k;r.__e(e,n,o)}else null==i&&n.__v==o.__v?(n.__k=o.__k,n.__e=o.__e):u=n.__e=function(e,n,o,l,_,i,s,u,c){var a,d,f,h,m,y,b,q=o.props,k=n.props,w=n.type;if("svg"==w?_="http://www.w3.org/2000/svg":"math"==w?_="http://www.w3.org/1998/Math/MathML":_||(_="http://www.w3.org/1999/xhtml"),null!=i){for(a=0;a<i.length;a++)if((m=i[a])&&"setAttribute"in m==!!w&&(w?m.localName==w:3==m.nodeType)){e=m,i[a]=null;break}}if(null==e){if(null==w)return document.createTextNode(k);e=document.createElementNS(_,w,k.is&&k),u&&(r.__m&&r.__m(n,i),u=!1),i=null}if(null===w)q===k||u&&e.data===k||(e.data=k);else{if(i=i&&t.call(e.childNodes),q=o.props||p,!u&&null!=i)for(q={},a=0;a<e.attributes.length;a++)q[(m=e.attributes[a]).name]=m.value;for(a in q)if(m=q[a],"children"==a);else if("dangerouslySetInnerHTML"==a)f=m;else if(!(a in k)){if("value"==a&&"defaultValue"in k||"checked"==a&&"defaultChecked"in k)continue;E(e,a,null,m,_)}for(a in k)m=k[a],"children"==a?h=m:"dangerouslySetInnerHTML"==a?d=m:"value"==a?y=m:"checked"==a?b=m:u&&"function"!=typeof m||q[a]===m||E(e,a,m,q[a],_);if(d)u||f&&(d.__html===f.__html||d.__html===e.innerHTML)||(e.innerHTML=d.__html),n.__k=[];else if(f&&(e.innerHTML=""),S("template"===n.type?e.content:e,v(h)?h:[h],n,o,l,"foreignObject"==w?"http://www.w3.org/1999/xhtml":_,i,s,i?i[0]:o.__k&&j(o,0),u,c),null!=i)for(a=i.length;a--;)g(i[a]);u||(a="value","progress"==w&&null==y?e.removeAttribute("value"):void 0===y||y===e[a]&&("progress"!=w||y)&&("option"!=w||y===q[a])||E(e,a,y,q[a],_),a="checked",void 0!==b&&b!==e[a]&&E(e,a,b,q[a],_))}return e}(o.__e,n,o,l,_,i,s,c,a);return(d=r.diffed)&&d(n),128&n.__u?void 0:u}function H(e,n,t){for(var o=0;o<t.length;o++)T(t[o],t[++o],t[++o]);r.__c&&r.__c(n,e),e.some(function(n){try{e=n.__h,n.__h=[],e.some(function(e){e.call(n)})}catch(e){r.__e(e,n.__v)}})}function T(e,n,t){try{if("function"==typeof e){var o="function"==typeof e.__u;o&&e.__u(),o&&null==n||(e.__u=e(n))}else e.current=n}catch(e){r.__e(e,t)}}function $(e,n,t){return this.constructor(e,t)}function A(e,n,o){var l,_,i;n==document&&(n=document.documentElement),r.__&&r.__(e,n),l=n.__k,_=[],i=[],D(n,e=n.__k=b(k,null,[e]),l||p,p,n.namespaceURI,l?null:n.firstChild?t.call(n.childNodes):null,_,l?l.__e:n.firstChild,!1,i),H(_,e,i)}function I(e,n,r){var o,l,_,i,s=y({},e.props);for(_ in e.type&&e.type.defaultProps&&(i=e.type.defaultProps),n)"key"==_?o=n[_]:"ref"==_?l=n[_]:s[_]=void 0===n[_]&&void 0!==i?i[_]:n[_];return arguments.length>2&&(s.children=arguments.length>3?t.call(arguments,2):r),q(e.type,s,o||e.key,l||e.ref,null)}function M(e){function n(e){var t,r;return this.getChildContext||(t=new Set,(r={})[n.__c]=this,this.getChildContext=function(){return r},this.componentWillUnmount=function(){t=null},this.shouldComponentUpdate=function(e){this.props.value!==e.value&&t.forEach(function(e){e.__e=!0,N(e)})},this.sub=function(e){t.add(e);var n=e.componentWillUnmount;e.componentWillUnmount=function(){t&&t.delete(e),n&&n.call(e)}}),e.children}return n.__c="__cC"+f++,n.__=e,n.Provider=n.__l=(n.Consumer=function(e,n){return e.children(n)}).contextType=n,n}t=h.slice,r={__e:function(e,n,t,r){for(var o,l,_;n=n.__;)if((o=n.__c)&&!o.__)try{if((l=o.constructor)&&null!=l.getDerivedStateFromError&&(o.setState(l.getDerivedStateFromError(e)),_=o.__d),null!=o.componentDidCatch&&(o.componentDidCatch(e,r||{}),_=o.__d),_)return o.__E=o}catch(n){e=n}throw e}},o=0,w.prototype.setState=function(e,n){var t;t=null!=this.__s&&this.__s!==this.state?this.__s:this.__s=y({},this.state),"function"==typeof e&&(e=e(y({},t),this.props)),e&&y(t,e),null!=e&&this.__v&&(n&&this._sb.push(n),N(this))},w.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),N(this))},w.prototype.render=k,l=[],i="function"==typeof Promise?Promise.prototype.then.bind(Promise.resolve()):setTimeout,s=function(e,n){return e.__v.__b-n.__v.__b},C.__r=0,u=/(PointerCapture)$|Capture$/i,c=0,a=U(!1),d=U(!0),f=0;var R,L,O,F,W=0,B=[],V=r,Q=V.__b,z=V.__r,J=V.diffed,Z=V.__c,Y=V.unmount,G=V.__;function K(e,n){V.__h&&V.__h(L,e,W||n),W=0;var t=L.__H||(L.__H={__:[],__h:[]});return e>=t.__.length&&t.__.push({}),t.__[e]}function X(e){return W=1,function(e,n,t){var r=K(R++,2);if(r.t=e,!r.__c&&(r.__=[ec(void 0,n),function(e){var n=r.__N?r.__N[0]:r.__[0],t=r.t(n,e);n!==t&&(r.__N=[t,r.__[1]],r.__c.setState({}))}],r.__c=L,!L.__f)){var o=function(e,n,t){if(!r.__c.__H)return!0;var o=r.__c.__H.__.filter(function(e){return!!e.__c});if(o.every(function(e){return!e.__N}))return!l||l.call(this,e,n,t);var _=r.__c.props!==e;return o.forEach(function(e){if(e.__N){var n=e.__[0];e.__=e.__N,e.__N=void 0,n!==e.__[0]&&(_=!0)}}),l&&l.call(this,e,n,t)||_};L.__f=!0;var l=L.shouldComponentUpdate,_=L.componentWillUpdate;L.componentWillUpdate=function(e,n,t){if(this.__e){var r=l;l=void 0,o(e,n,t),l=r}_&&_.call(this,e,n,t)},L.shouldComponentUpdate=o}return r.__N||r.__}(ec,e)}function ee(e,n){var t=K(R++,3);!V.__s&&eu(t.__H,n)&&(t.__=e,t.u=n,L.__H.__h.push(t))}function en(e){return W=5,et(function(){return{current:e}},[])}function et(e,n){var t=K(R++,7);return eu(t.__H,n)&&(t.__=e(),t.__H=n,t.__h=e),t.__}function er(e,n){return W=8,et(function(){return e},n)}function eo(e){var n=L.context[e.__c],t=K(R++,9);return t.c=e,n?(null==t.__&&(t.__=!0,n.sub(L)),n.props.value):e.__}function el(){for(var e;e=B.shift();)if(e.__P&&e.__H)try{e.__H.__h.forEach(ei),e.__H.__h.forEach(es),e.__H.__h=[]}catch(n){e.__H.__h=[],V.__e(n,e.__v)}}V.__b=function(e){L=null,Q&&Q(e)},V.__=function(e,n){e&&n.__k&&n.__k.__m&&(e.__m=n.__k.__m),G&&G(e,n)},V.__r=function(e){z&&z(e),R=0;var n=(L=e.__c).__H;n&&(O===L?(n.__h=[],L.__h=[],n.__.forEach(function(e){e.__N&&(e.__=e.__N),e.u=e.__N=void 0})):(n.__h.forEach(ei),n.__h.forEach(es),n.__h=[],R=0)),O=L},V.diffed=function(e){J&&J(e);var n=e.__c;n&&n.__H&&(n.__H.__h.length&&(1!==B.push(n)&&F===V.requestAnimationFrame||((F=V.requestAnimationFrame)||function(e){var n,t=function(){clearTimeout(r),e_&&cancelAnimationFrame(n),setTimeout(e)},r=setTimeout(t,100);e_&&(n=requestAnimationFrame(t))})(el)),n.__H.__.forEach(function(e){e.u&&(e.__H=e.u),e.u=void 0})),O=L=null},V.__c=function(e,n){n.some(function(e){try{e.__h.forEach(ei),e.__h=e.__h.filter(function(e){return!e.__||es(e)})}catch(t){n.some(function(e){e.__h&&(e.__h=[])}),n=[],V.__e(t,e.__v)}}),Z&&Z(e,n)},V.unmount=function(e){Y&&Y(e);var n,t=e.__c;t&&t.__H&&(t.__H.__.forEach(function(e){try{ei(e)}catch(e){n=e}}),t.__H=void 0,n&&V.__e(n,t.__v))};var e_="function"==typeof requestAnimationFrame;function ei(e){var n=L,t=e.__c;"function"==typeof t&&(e.__c=void 0,t()),L=n}function es(e){var n=L;e.__c=e.__(),L=n}function eu(e,n){return!e||e.length!==n.length||n.some(function(n,t){return n!==e[t]})}function ec(e,n){return"function"==typeof n?n(e):n}function ea(e,n){for(var t in n)e[t]=n[t];return e}function ed(e,n){for(var t in e)if("__source"!==t&&!(t in n))return!0;for(var r in n)if("__source"!==r&&e[r]!==n[r])return!0;return!1}function ef(e,n){this.props=e,this.context=n}function ep(e,n){function t(e){var t=this.props.ref,r=t==e.ref;return!r&&t&&(t.call?t(null):t.current=null),n?!n(this.props,e)||!r:ed(this.props,e)}function r(n){return this.shouldComponentUpdate=t,b(e,n)}return r.displayName="Memo("+(e.displayName||e.name)+")",r.prototype.isReactComponent=!0,r.__f=!0,r}(ef.prototype=new w).isPureReactComponent=!0,ef.prototype.shouldComponentUpdate=function(e,n){return ed(this.props,e)||ed(this.state,n)};var eh=r.__b;r.__b=function(e){e.type&&e.type.__f&&e.ref&&(e.props.ref=e.ref,e.ref=null),eh&&eh(e)};var em="undefined"!=typeof Symbol&&Symbol.for&&Symbol.for("react.forward_ref")||3911,ev=r.__e;r.__e=function(e,n,t,r){if(e.then){for(var o,l=n;l=l.__;)if((o=l.__c)&&o.__c)return null==n.__e&&(n.__e=t.__e,n.__k=t.__k),o.__c(e,n)}ev(e,n,t,r)};var ey=r.unmount;function eg(){this.__u=0,this.o=null,this.__b=null}function eb(e){var n=e.__.__c;return n&&n.__a&&n.__a(e)}function eq(){this.i=null,this.l=null}r.unmount=function(e){var n=e.__c;n&&n.__R&&n.__R(),n&&32&e.__u&&(e.type=null),ey&&ey(e)},(eg.prototype=new w).__c=function(e,n){var t=n.__c,r=this;null==r.o&&(r.o=[]),r.o.push(t);var o=eb(r.__v),l=!1,_=function(){l||(l=!0,t.__R=null,o?o(i):i())};t.__R=_;var i=function(){if(!--r.__u){if(r.state.__a){var e,n=r.state.__a;r.__v.__k[0]=function e(n,t,r){return n&&r&&(n.__v=null,n.__k=n.__k&&n.__k.map(function(n){return e(n,t,r)}),n.__c&&n.__c.__P===t&&(n.__e&&r.appendChild(n.__e),n.__c.__e=!0,n.__c.__P=r)),n}(n,n.__c.__P,n.__c.__O)}for(r.setState({__a:r.__b=null});e=r.o.pop();)e.forceUpdate()}};r.__u++||32&n.__u||r.setState({__a:r.__b=r.__v.__k[0]}),e.then(_,_)},eg.prototype.componentWillUnmount=function(){this.o=[]},eg.prototype.render=function(e,n){if(this.__b){if(this.__v.__k){var t=document.createElement("div"),r=this.__v.__k[0].__c;this.__v.__k[0]=function e(n,t,r){return n&&(n.__c&&n.__c.__H&&(n.__c.__H.__.forEach(function(e){"function"==typeof e.__c&&e.__c()}),n.__c.__H=null),null!=(n=ea({},n)).__c&&(n.__c.__P===r&&(n.__c.__P=t),n.__c=null),n.__k=n.__k&&n.__k.map(function(n){return e(n,t,r)})),n}(this.__b,t,r.__O=r.__P)}this.__b=null}var o=n.__a&&b(k,null,e.fallback);return o&&(o.__u&=-33),[b(k,null,n.__a?null:e.children),o]};var ek=function(e,n,t){if(++t[1]===t[0]&&e.l.delete(n),e.props.revealOrder&&("t"!==e.props.revealOrder[0]||!e.l.size))for(t=e.i;t;){for(;t.length>3;)t.pop()();if(t[1]<t[0])break;e.i=t=t[2]}};(eq.prototype=new w).__a=function(e){var n=this,t=eb(n.__v),r=n.l.get(e);return r[0]++,function(o){var l=function(){n.props.revealOrder?(r.push(o),ek(n,e,r)):o()};t?t(l):l()}},eq.prototype.render=function(e){this.i=null,this.l=new Map;var n=x(e.children);e.revealOrder&&"b"===e.revealOrder[0]&&n.reverse();for(var t=n.length;t--;)this.l.set(n[t],this.i=[1,0,this.i]);return e.children},eq.prototype.componentDidUpdate=eq.prototype.componentDidMount=function(){var e=this;this.l.forEach(function(n,t){ek(e,t,n)})};var ew="undefined"!=typeof Symbol&&Symbol.for&&Symbol.for("react.element")||60103,ej=/^(?:accent|alignment|arabic|baseline|cap|clip(?!PathU)|color|dominant|fill|flood|font|glyph(?!R)|horiz|image(!S)|letter|lighting|marker(?!H|W|U)|overline|paint|pointer|shape|stop|strikethrough|stroke|text(?!L)|transform|underline|unicode|units|v|vector|vert|word|writing|x(?!C))[A-Z]/,eN=/^on(Ani|Tra|Tou|BeforeInp|Compo)/,eC=/[A-Z0-9]/g,eS="undefined"!=typeof document;w.prototype.isReactComponent={},["componentWillMount","componentWillReceiveProps","componentWillUpdate"].forEach(function(e){Object.defineProperty(w.prototype,e,{configurable:!0,get:function(){return this["UNSAFE_"+e]},set:function(n){Object.defineProperty(this,e,{configurable:!0,writable:!0,value:n})}})});var ex=r.event;function eP(){}function eE(){return this.cancelBubble}function eU(){return this.defaultPrevented}r.event=function(e){return ex&&(e=ex(e)),e.persist=eP,e.isPropagationStopped=eE,e.isDefaultPrevented=eU,e.nativeEvent=e};var eD={enumerable:!1,configurable:!0,get:function(){return this.class}},eH=r.vnode;r.vnode=function(e){"string"==typeof e.type&&function(e){var n=e.props,t=e.type,r={},o=-1===t.indexOf("-");for(var l in n){var _=n[l];if(!("value"===l&&"defaultValue"in n&&null==_||eS&&"children"===l&&"noscript"===t||"class"===l||"className"===l)){var i,s=l.toLowerCase();"defaultValue"===l&&"value"in n&&null==n.value?l="value":"download"===l&&!0===_?_="":"translate"===s&&"no"===_?_=!1:"o"===s[0]&&"n"===s[1]?"ondoubleclick"===s?l="ondblclick":"onchange"!==s||"input"!==t&&"textarea"!==t||(i=n.type,("undefined"!=typeof Symbol&&"symbol"==typeof Symbol()?/fil|che|rad/:/fil|che|ra/).test(i))?"onfocus"===s?l="onfocusin":"onblur"===s?l="onfocusout":eN.test(l)&&(l=s):s=l="oninput":o&&ej.test(l)?l=l.replace(eC,"-$&").toLowerCase():null===_&&(_=void 0),"oninput"===s&&r[l=s]&&(l="oninputCapture"),r[l]=_}}"select"==t&&r.multiple&&Array.isArray(r.value)&&(r.value=x(n.children).forEach(function(e){e.props.selected=-1!=r.value.indexOf(e.props.value)})),"select"==t&&null!=r.defaultValue&&(r.value=x(n.children).forEach(function(e){e.props.selected=r.multiple?-1!=r.defaultValue.indexOf(e.props.value):r.defaultValue==e.props.value})),n.class&&!n.className?(r.class=n.class,Object.defineProperty(r,"className",eD)):(n.className&&!n.class||n.class&&n.className)&&(r.class=r.className=n.className),e.props=r}(e),e.$$typeof=ew,eH&&eH(e)};var eT=r.__r;r.__r=function(e){eT&&eT(e),e.__c};var e$=r.diffed;r.diffed=function(e){e$&&e$(e);var n=e.props,t=e.__e;null!=t&&"textarea"===e.type&&"value"in n&&n.value!==t.value&&(t.value=null==n.value?"":n.value)};var eA=0;function eI(e,n,t,o,l,_){n||(n={});var i,s,u=n;if("ref"in u)for(s in u={},n)"ref"==s?i=n[s]:u[s]=n[s];var c={type:e,props:u,key:t,ref:i,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--eA,__i:-1,__u:0,__source:l,__self:_};if("function"==typeof e&&(i=e.defaultProps))for(s in i)void 0===u[s]&&(u[s]=i[s]);return r.vnode&&r.vnode(c),c}let eM=ep(e=>{let{contexts:n,children:t}=e;return n.reduceRight((e,n)=>(function(e){return e&&e.$$typeof===ew?I.apply(null,arguments):e})(n,{children:e}),t)}),eR=ep(()=>eI("footer",{className:"dsqjs-footer-container",children:eI("p",{className:"dsqjs-footer",children:["Powered by ",eI("a",{className:"dsqjs-disqus-logo",href:"https://disqus.com",target:"_blank",rel:"external nofollow noopener noreferrer"})," ","&"," ",eI("a",{className:"dsqjs-dsqjs-logo",href:"https://disqusjs.skk.moe",target:"_blank",children:"DisqusJS"})]})}));var eL={dsqjs:"__dsqjs_1l1du3"};let eO=function(e,n){ee(()=>{let n=new AbortController,t=e(n.signal);return()=>{n.abort(),null==t||t()}},n)},eF=()=>{};function eW(e){let n=M(e),t=M(eF);return[r=>{let{children:o}=r,[l,_]=X(e);return eI(n.Provider,{value:l,children:eI(t.Provider,{value:_,children:o})})},()=>eo(n),()=>eo(t),n]}let[eB,eV,eQ]=eW(function(){{let e=localStorage.getItem("dsqjs_mode");if("dsqjs"===e||"disqus"===e)return e}return null}());function ez(){let e=eQ();return er(n=>{e(n),Promise.resolve(()=>{null===n?localStorage.removeItem("dsqjs_mode"):localStorage.setItem("dsqjs_mode",n)})},[e])}let[eJ,eZ,eY]=eW(!1),eG=ep(({isError:e,isLoading:n,...t})=>{let r=et(()=>e?"加载失败,请重试":n?"正在加载...":"加载更多评论",[e,n]);return eI("a",{...t,id:"dsqjs-load-more",className:"dsqjs-load-more "+(e?"is-error":""),role:"button",children:r})}),eK=ep(({children:e})=>{let n=ez();return eI("a",{id:"dsqjs-force-disqus",className:"dsqjs-msg-btn",onClick:()=>n("disqus"),children:e})}),eX=ep(({children:e})=>{let n=ez();return eI("a",{id:"dsqjs-test-disqus",className:"dsqjs-msg-btn",onClick:()=>n(null),role:"button",children:e})}),e0=ep(({children:e})=>{let n=ez();return eI("a",{id:"dsqjs-force-dsqjs",className:"dsqjs-msg-btn",onClick:()=>n("dsqjs"),role:"button",children:e})}),e1=ep(({children:e})=>{let n=eY();return eI("a",{id:"dsqjs-reload-dsqjs",className:"dsqjs-msg-btn",onClick:()=>n(!1),role:"button",children:e})}),[e2,e3,e9]=eW(null),e8=function(e,n){var t=K(R++,4);!V.__s&&eu(t.__H,n)&&(t.__=e,t.u=n,L.__h.push(t))},e4="disqus_thread",e6="dsq-embed-scr",e5=ep(({shortname:e,identifier:n,url:t,title:r})=>{let o=e9(),[l,_]=X(!1);return e8(()=>o(null)),ee(()=>{let o=()=>{{var e;window.disqus_config=void 0;let n=document.getElementById(e6);n&&(document.head.removeChild(n),n.remove()),null===(e=window.DISQUS)||void 0===e||e.reset({});try{delete window.DISQUS}catch(e){window.DISQUS=void 0}let t=document.getElementById(e4);if(t)for(;t.hasChildNodes();)t.firstChild&&t.firstChild.remove();document.querySelectorAll('link[href*="disquscdn.com/next"], link[href*="disqus.com/next"], script[src*="disquscdn.com/next/embed"], script[src*="disqus.com/count-data.js"], iframe[title="Disqus"]').forEach(e=>e.remove())}};window.disqus_shortname!==e&&o();let l=()=>function(){n&&(this.page.identifier=n),t&&(this.page.url=t),r&&(this.page.title=r),this.callbacks.onReady=[()=>_(!0)]};if(window.DISQUS&&document.getElementById(e6))window.DISQUS.reset({reload:!0,config:l()});else{window.disqus_config=l(),window.disqus_shortname=e;let n=document.createElement("script");n.id=e6,n.src=`https://${e}.disqus.com/embed.js`,n.async=!0,document.head.appendChild(n)}return o},[e,n,t,r]),eI(k,{children:[eI("div",{id:e4,children:["评论完整模式加载中... 如果长时间无法加载,请针对 disq.us | disquscdn.com | disqus.com 启用代理,或切换至"," ",eI(e0,{children:"评论基础模式"})]}),!l&&eI("div",{id:"dsqjs-msg",children:["评论完整模式加载中... 如果长时间无法加载,请针对 disq.us | disquscdn.com | disqus.com 启用代理,或切换至"," ",eI(e0,{children:"评论基础模式"})]})]})}),e7=ep(()=>eI("div",{id:"dsqjs-msg",children:["评论基础模式加载失败,请"," ",eI(e1,{children:"重载"})," ","或"," ",eI(eX,{children:"尝试完整 Disqus 模式"})]})),ne=ep(()=>eI("div",{id:"dsqjs-msg",children:["当前 Thread 尚未创建。是否切换至"," ",eI(eK,{children:"完整 Disqus 模式"}),"?"]})),nn=ep(({text:e})=>eI("p",{className:"dsqjs-no-comment",children:e}));function nt(e,n){let t=new URL(n);return t.searchParams.set("api_key",e),fetch(t.href).then(e=>e.json())}let nr=e=>new Date(e).getTime(),no=null;function nl(e){let n=e.replaceAll("a.disquscdn.com","c.disquscdn.com").replaceAll(/https?:\/\/disq.us\/url\?url=(.+)%3A[\w-]+&cuid=\d+/g,(e,n)=>decodeURIComponent(n));no||(no=new DOMParser);let t=no.parseFromString(n,"text/html");return t.querySelectorAll("script").forEach(e=>e.remove()),t.querySelectorAll("a").forEach(e=>{e.target="_blank",e.rel="external noopener nofollow noreferrer"}),t.body.innerHTML}let n_=new Date().getTimezoneOffset(),ni=e=>(e+"").padStart(2,"0");function ns(e){return new Promise((n,t)=>{let r=new Image,o=setTimeout(()=>{i(),t()},3e3);function l(){clearTimeout(o),i(),n()}function _(){clearTimeout(o),i(),t()}function i(){r.removeEventListener("load",l),r.removeEventListener("error",_),r.remove()}r.addEventListener("error",_),r.addEventListener("load",l),r.src=`https://${e}/favicon.ico?${Date.now()}=${Date.now()}`})}let nu=M(null),nc=nu.Provider;function na(){let e=eo(nu);if(!e)throw TypeError("<ConfigProvider /> is missing");return e}function nd({comment:e,children:n,nesting:t}){let{admin:r,adminLabel:o}=na(),l=e.author.profileUrl,_=nl(e.author.avatar.cache),i=eI("img",{alt:e.author.username,src:_});return eI("li",{id:"comment-"+e.id,children:[eI("div",{className:"dsqjs-post-item dsqjs-clearfix",children:[eI("div",{className:"dsqjs-post-avatar",children:l?eI("a",{href:l,target:"_blank",rel:"noreferrer noopenner nofollow external",children:i}):i}),eI("div",{className:"dsqjs-post-body",children:[eI("div",{className:"dsqjs-post-header",children:[l?eI("span",{className:"dsqjs-post-author",children:eI("a",{href:l,target:"_blank",rel:"noreferrer noopenner nofollow external",children:e.author.name})}):eI("span",{className:"dsqjs-post-author",children:e.author.name}),r===e.author.username&&eI("span",{className:"dsqjs-admin-badge",children:o})," ",eI("span",{className:"dsqjs-bullet"})," ",e.createdAt&&eI("span",{className:"dsqjs-meta",children:eI("time",{children:function(e){let n=new Date(nr(e)-60*n_*1e3);return`${n.getFullYear()}-${ni(n.getMonth()+1)}-${ni(n.getDate())} ${ni(n.getHours())}:${ni(n.getMinutes())}`}(e.createdAt)})})]}),e.isDeleted?eI("div",{className:"dsqjs-post-content",children:eI("small",{children:"此评论已被删除"})}):eI("div",{className:"dsqjs-post-content",dangerouslySetInnerHTML:{__html:nl(e.message)}})]})]}),eI(nf,{nesting:t,children:n}),e.hasMore&&eI("p",{className:"dsqjs-has-more",children:["切换至 ",eI(eK,{children:"完整 Disqus 模式"})," 显示更多回复"]})]})}function nf({children:e,nesting:n=1}){let{nesting:t=4}=na();return e&&0!==e.length?eI("ul",{className:"dsqjs-post-list "+(n<t?"dsqjs-children":""),children:e.map(e=>b(nd,{...e,key:e.comment.id}))}):null}function np({comments:e}){return eI("ul",{className:"dsqjs-post-list",id:"dsqjs-post-container",children:et(()=>{let n=[],t=[];return e.map((e,n)=>({i:n,p:e.parent,d:nr(e.createdAt)})).sort((e,n)=>e.p&&n.p?e.d-n.d:0).forEach(({i:r})=>{(e[r].parent?t:n).push(e[r])}),n.map(e=>(function e(n,t,r){return{comment:n,children:function(n,t,r){if(0===n.length)return null;let o=[];return n.forEach(l=>{l.parent===t&&o.unshift(e(l,n,r))}),o}(t,Number(n.id),r+1),nesting:r+1}})(e,t,0))},[e]).map(e=>b(nd,{...e,key:e.comment.id}))})}let nh=(n=Math.random,(e,t)=>Math.floor(n()*(t-e+1))+e),nm=function(e){return 1===e.length?e[0]:e[nh(0,e.length-1)]};function nv(e){return et(()=>Array.isArray(e)?nm(e):e,[e])}let[ny,ng,nb]=eW(function(){{let e=localStorage.getItem("dsqjs_sort");if("popular"===e||"asc"===e||"desc"===e)return e}return null}());function nq({sortType:e,onChange:n,checked:t,title:r,label:o}){return eI(k,{children:[eI("input",{className:"dsqjs-order-radio",id:"dsqjs-order-"+e,type:"radio",name:"comment-order",value:e,onChange:n,checked:t}),eI("label",{className:"dsqjs-order-label",htmlFor:"dsqjs-order-"+e,title:r,children:o})]})}let nk=ep(()=>{let e=ng(),n=nb();return eI("div",{className:"dsqjs-order",children:[eI(nq,{checked:"desc"===e||null===e,sortType:"desc",title:"按从新到旧",label:"最新",onChange:er(()=>n("desc"),[n])}),eI(nq,{checked:"asc"===e,sortType:"asc",title:"按从旧到新",label:"最早",onChange:er(()=>n("asc"),[n])}),eI(nq,{checked:"popular"===e,sortType:"popular",title:"按评分从高到低",label:"最佳",onChange:er(()=>n("popular"),[n])})]})}),nw=ep(({totalComments:e,siteName:n})=>eI("header",{className:"dsqjs-header",id:"dsqjs-header",children:eI("nav",{className:"dsqjs-nav dsqjs-clearfix",children:[eI("ul",{children:[eI("li",{className:"dsqjs-nav-tab dsqjs-tab-active",children:eI("span",{children:[e," Comments"]})}),eI("li",{className:"dsqjs-nav-tab",children:n})]}),eI(nk,{})]})}));function nj({id:e}){let{apikey:n,shortname:t,api:r}=na(),o=en(nv(n)),[l,_]=X([]),i=eY(),s=ng(),[u,c]=X(!1),[a,d]=X(!1),f=er(async(n=!1)=>{if(!e)return;c(!0),d(!1);let u=n?null:l[l.length-1];if(u&&!u.cursor.hasNext)return;let a=`${r}3.0/threads/listPostsThreaded?forum=${t}&thread=${e}&order=${null!=s?s:"desc"}${0!==l.length&&(null==u?void 0:u.cursor.next)?"&cursor="+encodeURIComponent(u.cursor.next):""}`,f=()=>{n?i(!0):d(!0),c(!1)};try{let e=await nt(o.current,a);0===e.code?(_(t=>(n?[]:t).concat(e)),c(!1)):f()}catch(e){f()}},[e,l,r,t,s,i]),p=er(()=>f(!0),[f]),h=er(()=>f(!1),[f]);!function(e,n){let[t,r]=X(n=[...n]),o=n.length!==t.length;for(let e=0;e<n.length&&!o;e+=1)t[e]!==n[e]&&(o=!0);o&&(r(n),e())}(p,[e,s]),function(e){let n=en();n.current||(n.current=e())}(p);let m=et(()=>l.filter(Boolean).flatMap(e=>e.response),[l]);if(l.length>0){var v;return eI(k,{children:[eI(np,{comments:m}),(null===(v=l[l.length-1])||void 0===v?void 0:v.cursor.hasNext)&&eI(eG,{isLoading:u,isError:a,onClick:u?void 0:h})]})}return null}function nN(){let{apikey:e,identifier:n,shortname:t,api:r,siteName:o,nocomment:l}=na(),_=en(nv(e)),[i,s]=X(null),u=eY(),c=null!=n?n:document.location.origin+document.location.pathname+document.location.search,a=er(async()=>{try{let e=await nt(_.current,`${r}3.0/threads/list.json?forum=${encodeURIComponent(t)}&thread=${encodeURIComponent("ident:"+c)}`);0===e.code?s(e):u(!0)}catch(e){u(!0)}},[r,_,c,u,s,t]),d=e9(),f=en(null);if(ee(()=>{let e=eI(k,{children:[eI(eX,{children:"尝试完整 Disqus 模式"})," | ",eI(eK,{children:"强制完整 Disqus 模式"})]});f.current===c?d(eI(k,{children:["你可能无法访问 Disqus,已启用评论基础模式。如需完整体验请针对 disq.us | disquscdn.com | disqus.com 启用代理并"," ",e]})):(d(eI(k,{children:["评论基础模式加载中... 如需完整体验请针对 disq.us | disquscdn.com | disqus.com 启用代理并"," ",e]})),f.current=c,a())},[i,a,c,d,t,r]),!i)return null;if(1!==i.response.length)return eI(ne,{});let p=i.response[0],h=p.posts;return eI(k,{children:[eI(nw,{totalComments:h,siteName:null!=o?o:""}),0===h?eI(nn,{text:null!=l?l:"这里空荡荡的,一个人都没有"}):eI(nj,{id:p.id})]})}function nC(){let e=e9(),n=eV(),t=ez(),{shortname:r,identifier:o,url:l,title:_}=na();eO(o=>{"disqus"!==n&&"dsqjs"!==n&&(e("正在检查 Disqus 能否访问..."),Promise.all(["disqus.com",`${r}.disqus.com`].map(ns)).then(()=>{o.aborted||t("disqus")}).catch(()=>{o.aborted||t("dsqjs")}))},[n,t,e,r]);let i=eZ(),s=e3();return i?eI(e7,{}):eI(k,{children:[null!=s&&eI("div",{id:"dsqjs-msg",children:s}),"disqus"===n&&eI(e5,{shortname:r,identifier:o,url:l,title:_}),"dsqjs"===n&&eI(nN,{})]})}let nS=function(e){function n(n){var t=ea({},n);return delete t.ref,e(t,n.ref||null)}return n.$$typeof=em,n.render=n,n.prototype.isReactComponent=n.__f=!0,n.displayName="ForwardRef("+(e.displayName||e.name)+")",n}(({shortname:e,siteName:n,identifier:t,url:r,title:o,api:l,apikey:_,nesting:i,nocomment:s,admin:u,adminLabel:c,className:a,...d},f)=>{let p=et(()=>[eI(nc,{value:{shortname:e,siteName:n,identifier:t,url:r,title:o,api:l,apikey:_,nesting:i,nocomment:s,admin:u,adminLabel:c}},"config"),eI(eB,{},"mode"),eI(ny,{},"sortType"),eI(eJ,{},"hasError"),eI(e2,{},"msg")],[u,c,l,_,t,i,s,e,n,o,r]);return!function(){let[e,n]=X(!1);return ee(()=>{n(!0)},[]),e}()?null:eI("div",{ref:f,...d,className:`${eL.dsqjs} ${null!=a?a:""}`,children:eI(eM,{contexts:p,children:eI("section",{id:"dsqjs",children:[eI(nC,{}),eI(eR,{})]})})})});class nx{render(e){let n;(n=e?"string"==typeof e?document.querySelector(e):e:document.getElementById("disqusjs"))&&(this.container=n,A(eI(nS,{...this.config}),n))}destroy(){this.container&&A(null,this.container)}constructor(n){e(this,"config",void 0),e(this,"container",void 0),this.config=n}}export{nx as default};