Loading
function(e,t,n){"use strict";n.d(t,{Fk:()=>L,K_:()=>M,OH:()=>u,f9:()=>P});var r=n(64700),i=n(835245);function s(e,t){var n=e.x,r=e.y;return n>t.x&&n<t.x+t.width&&r>t.y&&r<t.y+t.height}function a(e,t,n,r){var i=t>0?-1:1,s=Math.abs(t);return .5*e*r*n*s*s*i}var o=function(){function e(e){this.id=e.id,this.position=e.position,this.velocity=e.velocity,this.rotation=e.rotation,this.dragCoefficient=e.dragCoefficient,this.airResistanceArea=e.airResistanceArea,this.size=e.size,this.opacity=e.opacity,this.spriteX=e.spriteX,this.spriteY=e.spriteY,this.spriteWidth=e.spriteWidth,this.spriteHeight=e.spriteHeight,this._lastUpdatedAt=Date.now()}return e.prototype.getNewForces=function(e,t){var n=e.wind*t,r=-e.gravity*t;return{x:n+a(this.dragCoefficient.x,this.velocity.x,this.airResistanceArea.x,e.density),y:r+a(this.dragCoefficient.y,this.velocity.y,this.airResistanceArea.y,e.density)}},e.prototype.update=function(e){var t=Date.now(),n=(t-this._lastUpdatedAt)/100;this.rotation.update(n),this.dragCoefficient.update(n);var r=this.getNewForces(e,n),i=r.x,s=r.y;this.velocity.update(n),this.velocity.x+=i,this.velocity.y+=s,this.position.update(n),this.position.x+=this.velocity.x*n,this.position.y+=this.velocity.y*n,this.size.update(n),this.opacity.update(n),this.opacity.value=Math.max(this.opacity.value,0),this._lastUpdatedAt=t},e.prototype.previewPositionUpdate=function(e,t){var n=t/100,r=this.velocity.previewUpdate(n),i=this.getNewForces(e,n),s=i.x,a=i.y;r.x+=s,r.y+=a;var o=this.position.previewUpdate(n);return o.x+=r.x*n,o.y+=r.y*n,o},e.prototype.draw=function(e,t){t.save(),t.globalAlpha=this.opacity.value,t.setTransform((new DOMMatrix).translateSelf(this.position.x*n.g.devicePixelRatio,this.position.y*n.g.devicePixelRatio).rotateSelf(this.rotation.x,this.rotation.y,this.rotation.z)),t.drawImage(e,this.spriteX,this.spriteY,this.spriteWidth,this.spriteHeight,-this.width/2*n.g.devicePixelRatio,-this.height/2*n.g.devicePixelRatio,this.width*n.g.devicePixelRatio,this.height*n.g.devicePixelRatio),t.restore()},e.prototype.shouldDestroy=function(e,t){return this.opacity.value<0||t.gravity>=0&&this.velocity.y<0&&this.position.y+this.height<0||t.gravity<=0&&this.velocity.y>0&&this.position.y-this.height>e.height||t.wind>=0&&this.velocity.x>0&&this.position.x-this.width>e.width||t.wind<=0&&this.velocity.x<0&&this.position.x+this.width<0},Object.defineProperty(e.prototype,"width",{get:function(){return this.size.x},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"height",{get:function(){return this.size.y},enumerable:!1,configurable:!0}),e.prototype.addForce=function(e){this.velocity.x+=e.x,this.velocity.y+=e.y},e}(),l={velocity:{type:"static",value:0},rotation:{type:"static",value:0},dragCoefficient:{type:"static",value:1.66},airResistanceArea:{type:"static",value:.001},opacity:{type:"static",value:1}},u=function(e){var t=void 0===e?{}:e,n=t.gravity,r=t.wind,i=t.density;this.gravity=-9.8,this.wind=0,this.density=1.2041,this.gravity=null!=n?n:this.gravity,this.wind=null!=r?r:this.wind,this.density=null!=i?i:this.density},c=function(e,t){return(c=Object.setPrototypeOf||({__proto__:[]})instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(e,t)};function d(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}c(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var _=function(){return(_=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)};function f(e,t,n,r){return new(n||(n=Promise))(function(i,s){function a(e){try{l(r.next(e))}catch(e){s(e)}}function o(e){try{l(r.throw(e))}catch(e){s(e)}}function l(e){var t;e.done?i(e.value):((t=e.value)instanceof n?t:new n(function(e){e(t)})).then(a,o)}l((r=r.apply(e,t||[])).next())})}function p(e,t){var n,r,i,s,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:o(0),throw:o(1),return:o(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function o(o){return function(l){return function(o){if(n)throw TypeError("Generator is already executing.");for(;s&&(s=0,o[0]&&(a=0)),a;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,l])}}}var h=function(e){this.value=e},m=function(){function e(e,t,n){this._x=e,this._y=n?e:t}return e.prototype.update=function(e){this._x.update(e),this._y.update(e)},e.prototype.previewUpdate=function(e){return{x:this._x.previewUpdate(e),y:this._y.previewUpdate(e)}},Object.defineProperty(e.prototype,"x",{get:function(){return this._x.value},set:function(e){this._x.value=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"y",{get:function(){return this._y.value},set:function(e){this._y.value=e},enumerable:!1,configurable:!0}),e}(),E=function(e){function t(t,n,r,i){var s=e.call(this,t,n,i)||this;return s._z=i?t:r,s}return d(t,e),t.prototype.update=function(t){e.prototype.update.call(this,t),this._z.update(t)},t.prototype.previewUpdate=function(t){var n=e.prototype.previewUpdate.call(this,t);return _(_({},n),{z:this._z.previewUpdate(t)})},Object.defineProperty(t.prototype,"z",{get:function(){return this._z.value},set:function(e){this._z.value=e},enumerable:!1,configurable:!0}),t}(m),g=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return d(t,e),t.prototype.update=function(){},t.prototype.previewUpdate=function(){return this.value},t}(h),A=function(e){function t(t,n){var r=e.call(this,t)||this;return r.addValue=n,r}return d(t,e),t.prototype.update=function(e){this.value=this.previewUpdate(e)},t.prototype.previewUpdate=function(e){return this.value+this.addValue*e},t}(h),I=function(e){function t(t,n,r,i,s,a){var o=e.call(this,t)||this;o.min=n,o.max=r,o.duration=i;var l=o.value/(o.max-o.min)*o.duration,u=isNaN(l)?0:l;return o.timePassed=u<0?o.duration-u:u,o.directionMultiplier=s,o.easingFunction=a,o}return d(t,e),t.prototype.update=function(e){var t=this.doUpdate(e),n=t[0],r=t[1],i=t[2];this.value=n,this.directionMultiplier=i,this.timePassed=r},t.prototype.previewUpdate=function(e){return this.doUpdate(e)[0]},t.prototype.doUpdate=function(e){var t=this.max-this.min,n=this.timePassed+e*this.directionMultiplier,r=Math.min(Math.max(n,0),this.duration),i=n<0||n>this.duration?-1*this.directionMultiplier:this.directionMultiplier,s=this.easingFunction(r,this.min,t,this.duration);return[isNaN(s)?0:s,r,i]},t}(h);function T(e,t){return e===t?e:Math.random()*(t-e+1)+e}function S(e){var t=Math.floor(T(0,e.length-1));return[e[t],t]}function y(e,t){return S([e,t])[0]}function v(e){return"number"==typeof e?{x:e,y:e}:e}function N(e){return"number"==typeof e?{x:e,y:e,z:e}:e}function C(e){return function(e){switch(e.type){case"static":return new g(e.value);case"static-random":return new g(T(e.minValue,e.maxValue));case"linear":return new A(e.value,e.addValue);case"linear-random":return new A(T(e.minValue,e.maxValue),T(e.minAddValue,e.maxAddValue));case"oscillating":return new I(e.value,e.start,e.final,e.duration,e.direction,e.easingFunction);case"oscillating-random":return new I(T(e.minValue,e.maxValue),T(e.minStart,e.maxStart),T(e.minFinal,e.maxFinal),T(e.minDuration,e.maxDuration),y(e.minDirection,e.maxDirection),S(e.easingFunctions)[0])}}(_(_({},e),{valueType:"number"}))}function R(e){return function(e){switch(e.type){case"static":var t=v(e.value);return new m(new g(t.x),new g(t.y),e.uniformVectorValues);case"static-random":var n=v(e.minValue),r=v(e.maxValue);return new m(new g(T(n.x,r.x)),new g(T(n.y,r.y)),e.uniformVectorValues);case"linear":t=v(e.value);var i=v(e.addValue);return new m(new A(t.x,i.x),new A(t.y,i.y),e.uniformVectorValues);case"linear-random":n=v(e.minValue),r=v(e.maxValue);var s=v(e.minAddValue),a=v(e.maxAddValue);return new m(new A(T(n.x,r.x),T(s.x,a.x)),new A(T(n.y,r.y),T(s.x,a.x)),e.uniformVectorValues);case"oscillating":t=v(e.value);var o=v(e.start),l=v(e.final),u=v(e.duration),c=v(e.direction);return new m(new I(t.x,o.x,l.x,u.x,c.x,e.easingFunction),new I(t.y,o.y,l.y,u.x,c.y,e.easingFunction),e.uniformVectorValues);case"oscillating-random":n=v(e.minValue),r=v(e.maxValue);var d=v(e.minStart),_=v(e.maxStart),f=v(e.minFinal),p=v(e.maxFinal),h=v(e.minDuration),E=v(e.maxDuration),N=v(e.minDirection),C=v(e.maxDirection);return new m(new I(T(n.x,r.x),T(d.x,_.x),T(f.x,p.x),T(h.x,E.x),y(N.x,C.x),S(e.easingFunctions)[0]),new I(T(n.y,r.y),T(d.y,_.y),T(f.y,p.y),T(h.y,E.y),y(N.y,C.y),S(e.easingFunctions)[0]),e.uniformVectorValues)}}(_(_({},e),{valueType:"Vector2"}))}function O(e){return function(e){switch(e.type){case"static":var t=N(e.value);return new E(new g(t.x),new g(t.y),new g(t.z),e.uniformVectorValues);case"static-random":var n=N(e.minValue),r=N(e.maxValue);return new E(new g(T(n.x,r.x)),new g(T(n.y,r.y)),new g(T(n.z,r.z)),e.uniformVectorValues);case"linear":t=N(e.value);var i=N(e.addValue);return new E(new A(t.x,i.x),new A(t.y,i.y),new A(t.z,i.z),e.uniformVectorValues);case"linear-random":n=N(e.minValue),r=N(e.maxValue);var s=N(e.minAddValue),a=N(e.maxAddValue);return new E(new A(T(n.x,r.x),T(s.x,a.x)),new A(T(n.y,r.y),T(s.y,a.y)),new A(T(n.z,r.z),T(s.z,a.z)),e.uniformVectorValues);case"oscillating":t=N(e.value);var o=N(e.start),l=N(e.final),u=N(e.duration),c=N(e.direction);return new E(new I(t.x,o.x,l.x,u.x,c.x,e.easingFunction),new I(t.y,o.y,l.y,u.z,c.y,e.easingFunction),new I(t.z,o.z,l.z,u.z,c.z,e.easingFunction),e.uniformVectorValues);case"oscillating-random":n=N(e.minValue),r=N(e.maxValue);var d=N(e.minStart),_=N(e.maxStart),f=N(e.minFinal),p=N(e.maxFinal),h=N(e.minDuration),m=N(e.maxDuration),v=N(e.minDirection),C=N(e.maxDirection);return new E(new I(T(n.x,r.x),T(d.x,_.x),T(f.x,p.x),T(h.x,m.x),y(v.x,C.x),S(e.easingFunctions)[0]),new I(T(n.y,r.y),T(d.y,_.y),T(f.y,p.y),T(h.y,m.y),y(v.y,C.y),S(e.easingFunctions)[0]),new I(T(n.z,r.z),T(d.z,_.z),T(f.z,p.z),T(h.z,m.z),y(v.z,C.z),S(e.easingFunctions)[0]),e.uniformVectorValues)}}(_(_({},e),{valueType:"Vector3"}))}function b(e,t,n,r,i){var s=function(e,t){return _(_({id:t},l),e)}(t,e),a=function(e,t){if(null!=e){var n=t.sprites.findIndex(function(t){var n,r;return n=t,"string"==typeof(r=e)?n.src===r&&n.colorize:n.src===r.src&&n.colorize===r.colorize});if(-1!==n)return[e,n]}return S(t.sprites)}(r,n),u=a[0],c=a[1],d=function(e,t,n){if(!function(e){return"string"==typeof e||e.colorize}(e))return 0;var r=null!=t?n.colors.findIndex(function(e){return e===t}):-1;return -1!==r?r:Math.floor(T(0,n.colors.length-1))}(null!=r?r:u,i,n);return new o({id:e,position:R(s.position),velocity:R(s.velocity),rotation:O(s.rotation),dragCoefficient:R(s.dragCoefficient),size:R(s.size),opacity:C(s.opacity),airResistanceArea:R(s.airResistanceArea),spriteX:d*n.spriteWidth+2*d,spriteY:c*n.spriteHeight+2*c,spriteWidth:n.spriteWidth,spriteHeight:n.spriteHeight})}function D(){var e=r.useRef(!1),t=r.useRef({}),n=r.useCallback(function(e){for(var n in t.current)t.current[n](e)},[]);return r.useEffect(function(){return function(){return n(!1)}},[n]),r.useMemo(function(){return{isReady:e.current,addReadyListener:function(n){var r=(0,i.A)();return t.current[r]=n,e.current&&n(e.current),r},removeReadyListener:function(e){delete t.current[e]},setIsReady:function(t){e.current=t,n(t)}}},[n])}var L=r.forwardRef(function(e,t){var a=e.className,o=e.environment,l=e.onClick,u=e.onMouseDown,c=e.onMouseMove,d=e.onMouseUp,f=e.onBeforeRender,p=e.onAfterRender,h=e.requestAnimationFrame,m=void 0===h?window.requestAnimationFrame:h,E=e.cancelAnimationFrame,g=void 0===E?window.cancelAnimationFrame:E,A=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&0>t.indexOf(r)&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(e);i<r.length;i++)0>t.indexOf(r[i])&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]])}return n}(e,["className","environment","onClick","onMouseDown","onMouseMove","onMouseUp","onBeforeRender","onAfterRender","requestAnimationFrame","cancelAnimationFrame"]),I=r.useRef(null),T=D(),S=T.isReady,y=T.addReadyListener,v=T.removeReadyListener,N=T.setIsReady,C=r.useRef(new Map),R=r.useRef(null),O=r.useRef(0),L=r.useRef(0),w=r.useCallback(function(){var e=I.current;if(null!=e){var t=e.getContext("2d");if(null!=t){t.clearRect(0,0,e.width,e.height),null==f||f(t),C.current.forEach(function(n,r){var i=n.confetti,s=n.spriteCanvas;i.update(o),i.draw(s,t),i.shouldDestroy(e,o)&&C.current.delete(r)}),null==p||p(t),C.current.size>0?R.current=m(w):(t.clearRect(0,0,e.width,e.height),R.current=null);var n=Date.now();0!==O.current&&(L.current=1e3/(n-O.current)),O.current=n}}},[o,p,f,m]);r.useEffect(function(){null!=R.current&&(g(R.current),R.current=m(w))},[g,w,m]);var M=r.useCallback(function(e,t){C.current.set(e.id,{confetti:e,spriteCanvas:t}),null==R.current&&w()},[w]),P=r.useCallback(function(e,t,n,r,s){var a,o=b(null!=(a=e.id)?a:(0,i.A)(),e,n,r,s);return M(o,t),o},[M]),x=r.useCallback(function(e){C.current.delete(e)},[]),k=r.useCallback(function(){return C.current.clear()},[]),U=r.useCallback(function(){return I.current},[]);r.useImperativeHandle(t,function(){return{createConfetti:P,addConfetti:M,deleteConfetti:x,clearConfetti:k,getCanvas:U,addReadyListener:y,removeReadyListener:v,isReady:S}},[P,M,x,k,U,y,v,S]);var G=r.useCallback(function(e,t){var n,r,i=t.clickHandler,a=t.mouseHandler;if(null!=i||null!=a){var l=null==(n=I.current)?void 0:n.getBoundingClientRect();if(null!=l){var u=function(e,t){if(null==t)throw Error("element should not be null");var n=t.getBoundingClientRect();return{x:e.clientX-n.left,y:e.clientY-n.top}}(e,I.current);if(s(u,{x:l.left,y:l.top,width:l.width,height:l.height})){if(null!=a)return a(e);if(null!=i){var c=-1e3/L.current*2,d=function(e,t){for(var n=0,r=Array.from(e.values());n<r.length;n++){var i=r[n];if(null!=i&&t(i))return i}return null}(C.current,function(e){var t=e.confetti,n=t.previewPositionUpdate(o,c);return s(u,{x:n.x-t.width/2,y:n.y-t.height/2,width:t.width,height:t.height})});i(e,null!=(r=null==d?void 0:d.confetti)?r:null)}}}}},[o]),F=r.useCallback(function(e){return G(e,{clickHandler:l})},[G,l]),V=r.useCallback(function(e){return G(e,{clickHandler:u})},[G,u]),B=r.useCallback(function(e){return G(e,{mouseHandler:c})},[G,c]),H=r.useCallback(function(e){return G(e,{mouseHandler:d})},[G,d]);return r.useEffect(function(){var e=function(e,t,n){null!=n&&window.addEventListener(e,t)};return e("click",F,l),e("mousedown",V,u),e("mousemove",B,c),e("mouseup",H,d),function(){window.removeEventListener("click",F),window.removeEventListener("mousedown",V),window.removeEventListener("mousemove",B),window.removeEventListener("mouseup",B)}},[F,V,B,H,l,u,c,d]),r.useEffect(function(){var e=I.current,t=new ResizeObserver(function(){!function(e){if(null!=e){var t=e.getBoundingClientRect(),r=t.width,i=t.height;e.width=r*n.g.devicePixelRatio,e.height=i*n.g.devicePixelRatio}}(I.current),N(!0)});return null!=e&&t.observe(e),function(){null!=e&&t.unobserve(e)}},[N]),r.createElement("canvas",_({},A,{className:a,ref:I}))}),w={display:"none",position:"absolute",width:0,height:0,left:"-100%"},M=r.forwardRef(function(e,t){var n=e.className,i=e.visible,s=void 0!==i&&i,a=e.sprites,o=e.colors,l=e.spriteWidth,u=e.spriteHeight,c=r.useRef(null),d=r.useRef([]),_=D(),h=_.isReady,m=_.addReadyListener,E=_.removeReadyListener,g=_.setIsReady;r.useImperativeHandle(t,function(){return{getCanvas:function(){return c.current},getCreateData:function(){return{sprites:d.current,colors:o,spriteWidth:l,spriteHeight:u}},addReadyListener:m,removeReadyListener:E,isReady:h}},[m,o,h,E,u,l]);var A=r.useCallback(function(){var e=c.current,t=null==e?void 0:e.getContext("2d",{willReadFrequently:!0});null!=t&&null!=e&&(t.clearRect(0,0,e.width,e.height),d.current.forEach(function(e,n){var r=function(r,i){var s=l*i+2*i,a=u*n+2*n;if(t.drawImage(e.image,s,a,l,u),null!=r){for(var o=t.getImageData(s,a,l,u),c=function(e){"#"===e[0]&&(e=e.slice(1));var t=parseInt(e,16);return{r:t>>16&255,g:t>>8&255,b:255&t}}(r),d=0;d<o.data.length;d+=4)o.data[d]=c.r,o.data[d+1]=c.g,o.data[d+2]=c.b;t.putImageData(o,s,a)}};e.colorize?o.forEach(function(e,t){return r(e,t)}):r(null,0)}))},[o,u,l]),I=r.useCallback(function(){var e=a.map(function(e){var t=new Image,n="string"==typeof e?e:e.src,r="string"==typeof e||e.colorize;t.src=n;var i=new Promise(function(e){t.onload=e});return{colorize:r,image:t,src:n,loadPromise:i}});return Promise.all(e.map(function(e){return e.loadPromise})).then(function(){d.current=e.map(function(e){return{colorize:e.colorize,image:e.image,src:e.src}})})},[a]),T=r.useCallback(function(){return f(void 0,void 0,void 0,function(){return p(this,function(e){switch(e.label){case 0:return[4,I()];case 1:return e.sent(),A(),g(!0),[2]}})})},[I,A,g]);return r.useEffect(function(){T()},[T]),r.useEffect(function(){null!=c.current&&(c.current.width=(l+2)*Math.max(o.length,1),c.current.height=(u+2)*a.length)},[o.length,u,l,a.length]),r.createElement("canvas",{ref:c,className:n,style:s?void 0:w})});function P(e,t){var n,i,s=r.useState(null!=(n=null==t?void 0:t.isReady)&&n),a=s[0],o=s[1],l=r.useState(null!=(i=null==e?void 0:e.isReady)&&i),u=l[0],c=l[1];r.useEffect(function(){var e=null==t?void 0:t.addReadyListener(o);return function(){null!=e&&(null==t||t.removeReadyListener(e))}},[t]),r.useEffect(function(){var t=null==e?void 0:e.addReadyListener(c);return function(){null!=t&&(null==e||e.removeReadyListener(t))}},[e]);var d=r.useCallback(function(n,r){var i=void 0===r?{}:r,s=i.sprite,a=i.color,o=null==t?void 0:t.getCreateData(),l=null==t?void 0:t.getCanvas();if(null!=l&&null!=o&&0!==o.sprites.length)return null==e?void 0:e.createConfetti(n,l,o,s,a)},[e,t]),_=r.useCallback(function(e,t,n){for(var r=[],i=0;i<t;i++){var s=d(e,n);s&&r.push(s)}return r},[d]),f=r.useCallback(function(n){var r=null==t?void 0:t.getCanvas();null!=r&&(null==e||e.addConfetti(n,r))},[e,t]),p=r.useCallback(function(t){null==e||e.deleteConfetti(t)},[e]),h=r.useCallback(function(){return null==e?void 0:e.clearConfetti()},[e]);return r.useMemo(function(){return{createConfetti:d,createMultipleConfetti:_,addConfetti:f,clearConfetti:h,deleteConfetti:p,isReady:null!=t&&null!=e&&u&&a}},[f,h,e,d,_,p,u,a,t])}}