"use strict";(globalThis.webpackChunk_tsparticles_wordpress=globalThis.webpackChunk_tsparticles_wordpress||[]).push([[6711],{6711:(t,e,i)=>{i.d(e,{loadCanvasMaskPlugin:()=>p});class s{constructor(){this.color=!0,this.opacity=!1}load(t){t&&(void 0!==t.color&&(this.color=t.color),void 0!==t.opacity&&(this.opacity=t.opacity))}}var o=i(9201);class n{constructor(){this.filter=t=>t.a>0,this.offset=4}load(t){if(t){if(void 0!==t.filter)if((0,o.HD)(t.filter)){if(Object.hasOwn(window,t.filter)){const e=window[t.filter];(0,o.mf)(e)&&(this.filter=e)}}else this.filter=t.filter;void 0!==t.offset&&(this.offset=t.offset)}}}class a{constructor(){this.src=""}load(t){t&&void 0!==t.src&&(this.src=t.src)}}class l{constructor(){this.family="sans-serif",this.size=100}load(t){t&&(void 0!==t.family&&(this.family=t.family),void 0!==t.size&&(this.size=t.size),void 0!==t.style&&(this.style=t.style),void 0!==t.variant&&(this.variant=t.variant),void 0!==t.weight&&(this.weight=t.weight))}}class r{constructor(){this.separator="\n",this.spacing=10}load(t){t&&(void 0!==t.separator&&(this.separator=t.separator),void 0!==t.spacing&&(this.spacing=t.spacing))}}class c{constructor(){this.color="#000000",this.font=new l,this.lines=new r,this.text=""}load(t){t&&(void 0!==t.color&&(this.color=t.color),this.font.load(t.font),this.lines.load(t.lines),void 0!==t.text&&(this.text=t.text))}}class h{constructor(){this.enable=!1,this.override=new s,this.pixels=new n,this.position={x:50,y:50},this.scale=1}load(t){t&&(void 0!==t.element&&t.element instanceof HTMLCanvasElement&&(this.element=t.element),void 0!==t.enable&&(this.enable=t.enable),t.image&&(this.image||(this.image=new a),this.image.load(t.image)),this.pixels.load(t.pixels),t.position&&(this.position={x:t.position.x??this.position.x,y:t.position.y??this.position.y}),this.override.load(t.override),void 0!==t.scale&&(this.scale=t.scale),void 0!==t.selector&&(this.selector=t.selector),t.text&&(this.text||(this.text=new c),this.text.load(t.text)))}}function d(t,e,i,s=!0){const o=t.getImageData(0,0,e.width,e.height).data;s&&t.clearRect(0,0,e.width,e.height);const n=[];for(let t=0;t<o.length;t+=i){const s=t/i,a={x:s%e.width,y:Math.floor(s/e.width)};n[a.y]||(n[a.y]=[]),n[a.y][a.x]={r:o[t],g:o[t+1],b:o[t+2],a:o[t+3]/255}}return{pixels:n,width:Math.min(...n.map((t=>t.length))),height:n.length}}const f=t=>[...Array(t).keys()];class g{constructor(t,e){this._container=t,this._engine=e}async init(){const t=this._container,e=t.actualOptions.canvasMask;if(!e?.enable)return;let i={pixels:[],height:0,width:0};const s=e.pixels.offset;if(e.image){const t=e.image.src;if(!t)return;i=await function(t,e){const i=new Image;i.crossOrigin="Anonymous";const s=new Promise(((t,s)=>{i.onerror=s,i.onload=()=>{const n=document.createElement("canvas");n.width=i.width,n.height=i.height;const a=n.getContext("2d");if(!a)return s(new Error(`${o.gK} Could not get canvas context`));a.drawImage(i,0,0,i.width,i.height,0,0,n.width,n.height),t(d(a,n,e))}}));return i.src=t,s}(t,s)}else if(e.text){const t=function(t,e){const i=document.createElement("canvas"),s=i.getContext("2d"),{font:n,text:a,lines:l,color:r}=t;if(!a||!s)return;const c=a.split(l.separator),h=(0,o.hj)(n.size)?`${n.size}px`:n.size,f=[];let g=0,u=0;for(const t of c){s.font=`${n.style||""} ${n.variant||""} ${n.weight||""} ${h} ${n.family}`;const e=s.measureText(t),i={measure:e,text:t,height:e.actualBoundingBoxAscent+e.actualBoundingBoxDescent,width:e.width};g=Math.max(g||0,i.width),u+=i.height+l.spacing,f.push(i)}i.width=g,i.height=u;let p=0;for(const t of f)s.font=`${n.style||""} ${n.variant||""} ${n.weight||""} ${h} ${n.family}`,s.fillStyle=r,s.fillText(t.text,0,p+t.measure.actualBoundingBoxAscent),p+=t.height+l.spacing;return d(s,i,e)}(e.text,s);if(!t)return;i=t}else if(e.element||e.selector){const t=e.element||e.selector&&document.querySelector(e.selector);if(!t)return;const o=t.getContext("2d");if(!o)return;i=d(o,t,s)}!function(t,e,i,s,n,a){const{height:l,width:r}=e,c=l*r,h=function(t){for(let e=t.length-1;e>=0;e--){const i=Math.floor((0,o.sZ)()*e);[t[e],t[i]]=[t[i],t[e]]}return t}(f(c)),d=Math.min(c,t.actualOptions.particles.number.value),g=t.canvas.size;let u=0;const p=g.width*i.x/100-r*s/2,w=g.height*i.y/100-l*s/2;for(;u<d&&h.length;){const i=h.pop()||0,o={x:i%r,y:Math.floor(i/r)},l=e.pixels[o.y][o.x];if(!a(l))continue;const c={x:o.x*s+p,y:o.y*s+w},d={};n.color&&(d.color={value:l}),n.opacity&&(d.opacity={value:l.a}),t.particles.addParticle(c,d),u++}}(t,i,e.position,e.scale,e.override,e.pixels.filter)}}class u{constructor(t){this.id="canvasMask",this._engine=t}getPlugin(t){return new g(t,this._engine)}loadOptions(t,e){if(!this.needsPlugin(t)&&!this.needsPlugin(e))return;let i=t.canvasMask;void 0===i?.load&&(t.canvasMask=i=new h),i.load(e?.canvasMask)}needsPlugin(t){return t?.canvasMask?.enable??!1}}async function p(t,e=!0){await t.addPlugin(new u(t),e)}}}]);