koishi-plugin-bilibili-notify
Version:
Koishi bilibili notify plugin
15 lines • 11.4 kB
JavaScript
/**
* Minified by jsDelivr using Terser v5.39.0.
* Original file: /npm/wordcloud@1.1.2/src/wordcloud2.js
*
* Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
*/
/*!
* wordcloud2.js
* http://timdream.org/wordcloud2.js/
*
* Copyright 2011 - 2019 Tim Guan-tin Chien and contributors.
* Released under the MIT license
*/
;window.setImmediate||(window.setImmediate=window.msSetImmediate||window.webkitSetImmediate||window.mozSetImmediate||window.oSetImmediate||function(){if(!window.postMessage||!window.addEventListener)return null;var t=[void 0],e="zero-timeout-message";return window.addEventListener("message",(function(a){if("string"==typeof a.data&&a.data.substr(0,20)===e){a.stopImmediatePropagation();var r=parseInt(a.data.substr(20),36);t[r]&&(t[r](),t[r]=void 0)}}),!0),window.clearImmediate=function(e){t[e]&&(t[e]=void 0)},function(a){var r=t.length;return t.push(a),window.postMessage(e+r.toString(36),"*"),r}}()||function(t){window.setTimeout(t,0)}),window.clearImmediate||(window.clearImmediate=window.msClearImmediate||window.webkitClearImmediate||window.mozClearImmediate||window.oClearImmediate||function(t){window.clearTimeout(t)}),function(t){var e=function(){var t=document.createElement("canvas");if(!t||!t.getContext)return!1;var e=t.getContext("2d");return!!e&&(!!e.getImageData&&(!!e.fillText&&(!!Array.prototype.some&&!!Array.prototype.push)))}(),a=function(){if(e){for(var t,a,r=document.createElement("canvas").getContext("2d"),i=20;i;){if(r.font=i.toString(10)+"px sans-serif",r.measureText("W").width===t&&r.measureText("m").width===a)return i+1;t=r.measureText("W").width,a=r.measureText("m").width,i--}return 0}}(),r=function(t){for(var e,a,r=t.length;r;)e=Math.floor(Math.random()*r),a=t[--r],t[r]=t[e],t[e]=a;return t},i=function(t,i){if(e){Array.isArray(t)||(t=[t]),t.forEach((function(e,a){if("string"==typeof e){if(t[a]=document.getElementById(e),!t[a])throw new Error("The element id specified is not found.")}else if(!e.tagName&&!e.appendChild)throw new Error("You must pass valid HTML elements, or ID of the element.")}));var o={list:[],fontFamily:'"Trebuchet MS", "Heiti TC", "微軟正黑體", "Arial Unicode MS", "Droid Fallback Sans", sans-serif',fontWeight:"normal",color:"random-dark",minSize:0,weightFactor:1,clearCanvas:!0,backgroundColor:"#fff",gridSize:8,drawOutOfBound:!1,shrinkToFit:!1,origin:null,drawMask:!1,maskColor:"rgba(255,0,0,0.3)",maskGapWidth:.3,wait:0,abortThreshold:0,abort:function(){},minRotation:-Math.PI/2,maxRotation:Math.PI/2,rotationSteps:0,shuffle:!0,rotateRatio:.1,shape:"circle",ellipticity:.65,classes:null,hover:null,click:null};if(i)for(var n in i)n in o&&(o[n]=i[n]);if("function"!=typeof o.weightFactor){var s=o.weightFactor;o.weightFactor=function(t){return t*s}}if("function"!=typeof o.shape)switch(o.shape){case"circle":default:o.shape="circle";break;case"cardioid":o.shape=function(t){return 1-Math.sin(t)};break;case"diamond":o.shape=function(t){var e=t%(2*Math.PI/4);return 1/(Math.cos(e)+Math.sin(e))};break;case"square":o.shape=function(t){return Math.min(1/Math.abs(Math.cos(t)),1/Math.abs(Math.sin(t)))};break;case"triangle-forward":o.shape=function(t){var e=t%(2*Math.PI/3);return 1/(Math.cos(e)+Math.sqrt(3)*Math.sin(e))};break;case"triangle":case"triangle-upright":o.shape=function(t){var e=(t+3*Math.PI/2)%(2*Math.PI/3);return 1/(Math.cos(e)+Math.sqrt(3)*Math.sin(e))};break;case"pentagon":o.shape=function(t){var e=(t+.955)%(2*Math.PI/5);return 1/(Math.cos(e)+.726543*Math.sin(e))};break;case"star":o.shape=function(t){var e=(t+.955)%(2*Math.PI/10);return(t+.955)%(2*Math.PI/5)-2*Math.PI/10>=0?1/(Math.cos(2*Math.PI/10-e)+3.07768*Math.sin(2*Math.PI/10-e)):1/(Math.cos(e)+3.07768*Math.sin(e))}}o.gridSize=Math.max(Math.floor(o.gridSize),4);var f,l,d,c,h,u,m,w,g=o.gridSize,v=g-o.maskGapWidth,M=Math.abs(o.maxRotation-o.minRotation),p=Math.abs(Math.floor(o.rotationSteps)),x=Math.min(o.maxRotation,o.minRotation);switch(o.color){case"random-dark":m=function(){return A(10,50)};break;case"random-light":m=function(){return A(50,90)};break;default:"function"==typeof o.color&&(m=o.color)}"function"==typeof o.fontWeight&&(w=o.fontWeight);var b=null;"function"==typeof o.classes&&(b=o.classes);var T,k=!1,I=[],y=function(t){var e,a,r=t.currentTarget,i=r.getBoundingClientRect();t.touches?(e=t.touches[0].clientX,a=t.touches[0].clientY):(e=t.clientX,a=t.clientY);var o=e-i.left,n=a-i.top,s=Math.floor(o*(r.width/i.width||1)/g),f=Math.floor(n*(r.height/i.height||1)/g);return I[s][f]},C=function(t){var e=y(t);T!==e&&(T=e,e?o.hover(e.item,e.dimension,t):o.hover(void 0,void 0,t))},S=function(t){var e=y(t);e&&(o.click(e.item,e.dimension,t),t.preventDefault())},E=[],F=function(t){if(E[t])return E[t];var e=8*t,a=e,r=[];for(0===t&&r.push([c[0],c[1],0]);a--;){var i=1;"circle"!==o.shape&&(i=o.shape(a/e*2*Math.PI)),r.push([c[0]+t*i*Math.cos(-a/e*2*Math.PI),c[1]+t*i*Math.sin(-a/e*2*Math.PI)*o.ellipticity,a/e*2*Math.PI])}return E[t]=r,r},P=function(){return o.abortThreshold>0&&(new Date).getTime()-u>o.abortThreshold},R=function(e,a,r,i,o){if(!(e>=l||a>=d||e<0||a<0)){if(f[e][a]=!1,r)t[0].getContext("2d").fillRect(e*g,a*g,v,v);k&&(I[e][a]={item:o,dimension:i})}},O=function e(i){var n,s,c;Array.isArray(i)?(n=i[0],s=i[1]):(n=i.word,s=i.weight,c=i.attributes);var u=0===o.rotateRatio||Math.random()>o.rotateRatio?0:0===M?x:p>0?x+Math.floor(Math.random()*p)*M/(p-1):x+Math.random()*M,v=function(t,e,r){var i=o.weightFactor(e);if(i<=o.minSize)return!1;var n,s=1;i<a&&(s=function(){for(var t=2;t*i<a;)t+=2;return t}()),n=w?w(t,e,i):o.fontWeight;var f=document.createElement("canvas"),l=f.getContext("2d",{willReadFrequently:!0});l.font=n+" "+(i*s).toString(10)+"px "+o.fontFamily;var d=l.measureText(t).width/s,c=Math.max(i*s,l.measureText("m").width,l.measureText("W").width)/s,h=d+2*c,u=3*c,m=Math.ceil(h/g),v=Math.ceil(u/g);h=m*g,u=v*g;var M=-d/2,p=.4*-c,x=Math.ceil((h*Math.abs(Math.sin(r))+u*Math.abs(Math.cos(r)))/g),b=Math.ceil((h*Math.abs(Math.cos(r))+u*Math.abs(Math.sin(r)))/g),T=b*g,k=x*g;f.setAttribute("width",T),f.setAttribute("height",k),l.scale(1/s,1/s),l.translate(T*s/2,k*s/2),l.rotate(-r),l.font=n+" "+(i*s).toString(10)+"px "+o.fontFamily,l.fillStyle="#000",l.textBaseline="middle",l.fillText(t,M*s,(p+.5*i)*s);var I=l.getImageData(0,0,T,k).data;if(P())return!1;for(var y,C,S,E=[],F=b,R=[x/2,b/2,x/2,b/2];F--;)for(y=x;y--;){S=g;t:for(;S--;)for(C=g;C--;)if(I[4*((y*g+S)*T+(F*g+C))+3]){E.push([F,y]),F<R[3]&&(R[3]=F),F>R[1]&&(R[1]=F),y<R[0]&&(R[0]=y),y>R[2]&&(R[2]=y);break t}}return{mu:s,occupied:E,bounds:R,gw:b,gh:x,fillTextOffsetX:M,fillTextOffsetY:p,fillTextWidth:d,fillTextHeight:c,fontSize:i}}(n,s,u);if(!v)return!1;if(P())return!1;if(!o.drawOutOfBound&&!o.shrinkToFit){var T=v.bounds;if(T[1]-T[3]+1>l||T[2]-T[0]+1>d)return!1}for(var I=h+1,y=function(e){var a=Math.floor(e[0]-v.gw/2),r=Math.floor(e[1]-v.gh/2);v.gw,v.gh;return!!function(t,e,a,r,i){for(var n=i.length;n--;){var s=t+i[n][0],c=e+i[n][1];if(s>=l||c>=d||s<0||c<0){if(!o.drawOutOfBound)return!1}else if(!f[s][c])return!1}return!0}(a,r,0,0,v.occupied)&&(function(e,a,r,i,n,s,f,l,d){var c,h,u,v=r.fontSize;c=m?m(i,n,v,s,f):o.color,h=w?w(i,n,v):o.fontWeight,u=b?b(i,n,v):o.classes,t.forEach((function(t){if(t.getContext){var n=t.getContext("2d"),s=r.mu;n.save(),n.scale(1/s,1/s),n.font=h+" "+(v*s).toString(10)+"px "+o.fontFamily,n.fillStyle=c,n.translate((e+r.gw/2)*g*s,(a+r.gh/2)*g*s),0!==l&&n.rotate(-l),n.textBaseline="middle",n.fillText(i,r.fillTextOffsetX*s,(r.fillTextOffsetY+.5*v)*s),n.restore()}else{var f=document.createElement("span"),m="";m="rotate("+-l/Math.PI*180+"deg) ",1!==r.mu&&(m+="translateX(-"+r.fillTextWidth/4+"px) scale("+1/r.mu+")");var w={position:"absolute",display:"block",font:h+" "+v*r.mu+"px "+o.fontFamily,left:(e+r.gw/2)*g+r.fillTextOffsetX+"px",top:(a+r.gh/2)*g+r.fillTextOffsetY+"px",width:r.fillTextWidth+"px",height:r.fillTextHeight+"px",lineHeight:v+"px",whiteSpace:"nowrap",transform:m,webkitTransform:m,msTransform:m,transformOrigin:"50% 40%",webkitTransformOrigin:"50% 40%",msTransformOrigin:"50% 40%"};for(var M in c&&(w.color=c),f.textContent=i,w)f.style[M]=w[M];if(d)for(var p in d)f.setAttribute(p,d[p]);u&&(f.className+=u),t.appendChild(f)}}))}(a,r,v,n,s,h-I,e[2],u,c),function(e,a,r,i,n,s){var f,c,h=n.occupied,u=o.drawMask;if(u&&((f=t[0].getContext("2d")).save(),f.fillStyle=o.maskColor),k){var m=n.bounds;c={x:(e+m[3])*g,y:(a+m[0])*g,w:(m[1]-m[3]+1)*g,h:(m[2]-m[0]+1)*g}}for(var w=h.length;w--;){var v=e+h[w][0],M=a+h[w][1];v>=l||M>=d||v<0||M<0||R(v,M,u,c,s)}u&&f.restore()}(a,r,0,0,v,i),!0)};I--;){var C=F(h-I);if(o.shuffle&&(C=[].concat(C),r(C)),C.some(y))return!0}return!!o.shrinkToFit&&(Array.isArray(i)?i[1]=3*i[1]/4:i.weight=3*i.weight/4,e(i))},z=function(e,a,r){if(a)return!t.some((function(t){var a=new CustomEvent(e,{detail:r||{}});return!t.dispatchEvent(a)}),this);t.forEach((function(t){var a=new CustomEvent(e,{detail:r||{}});t.dispatchEvent(a)}),this)};!function(){var e=t[0];if(e.getContext)l=Math.ceil(e.width/g),d=Math.ceil(e.height/g);else{var a=e.getBoundingClientRect();l=Math.ceil(a.width/g),d=Math.ceil(a.height/g)}if(z("wordcloudstart",!0)){var r,i,n,s,m;if(c=o.origin?[o.origin[0]/g,o.origin[1]/g]:[l/2,d/2],h=Math.floor(Math.sqrt(l*l+d*d)),f=[],!e.getContext||o.clearCanvas)for(t.forEach((function(t){if(t.getContext){var e=t.getContext("2d");e.fillStyle=o.backgroundColor,e.clearRect(0,0,l*(g+1),d*(g+1)),e.fillRect(0,0,l*(g+1),d*(g+1))}else t.textContent="",t.style.backgroundColor=o.backgroundColor,t.style.position="relative"})),r=l;r--;)for(f[r]=[],i=d;i--;)f[r][i]=!0;else{var w=document.createElement("canvas").getContext("2d");w.fillStyle=o.backgroundColor,w.fillRect(0,0,1,1);var v,M,p=w.getImageData(0,0,1,1).data,x=e.getContext("2d").getImageData(0,0,l*g,d*g).data;for(r=l;r--;)for(f[r]=[],i=d;i--;){M=g;t:for(;M--;)for(v=g;v--;)for(n=4;n--;)if(x[4*((i*g+M)*l*g+(r*g+v))+n]!==p[n]){f[r][i]=!1;break t}!1!==f[r][i]&&(f[r][i]=!0)}x=w=p=void 0}if(o.hover||o.click){for(k=!0,r=l+1;r--;)I[r]=[];o.hover&&e.addEventListener("mousemove",C),o.click&&(e.addEventListener("click",S),e.style.webkitTapHighlightColor="rgba(0, 0, 0, 0)"),e.addEventListener("wordcloudstart",(function t(){e.removeEventListener("wordcloudstart",t),e.removeEventListener("mousemove",C),e.removeEventListener("click",S),T=void 0}))}n=0,0!==o.wait?(s=window.setTimeout,m=window.clearTimeout):(s=window.setImmediate,m=window.clearImmediate);var b=function(e,a){t.forEach((function(t){t.removeEventListener(e,a)}),this)},y=function t(){b("wordcloudstart",t),m(E)};!function(e,a){t.forEach((function(t){t.addEventListener(e,a)}),this)}("wordcloudstart",y);var E=s((function t(){if(n>=o.list.length)return m(E),z("wordcloudstop",!1),void b("wordcloudstart",y);u=(new Date).getTime();var e=O(o.list[n]),a=!z("wordclouddrawn",!0,{item:o.list[n],drawn:e});if(P()||a)return m(E),o.abort(),z("wordcloudabort",!1),z("wordcloudstop",!1),void b("wordcloudstart",y);n++,E=s(t,o.wait)}),o.wait)}}()}function A(t,e){return"hsl("+(360*Math.random()).toFixed()+","+(30*Math.random()+70).toFixed()+"%,"+(Math.random()*(e-t)+t).toFixed()+"%)"}};i.isSupported=e,i.minFontSize=a,"function"==typeof define&&define.amd?(t.WordCloud=i,define("wordcloud",[],(function(){return i}))):"undefined"!=typeof module&&module.exports?module.exports=i:t.WordCloud=i}(this);
//# sourceMappingURL=/sm/17285da6aeb6fe7b274092d2bc30636118c0f9bda249638730ef2e0e61d54dcf.map