masoneffect 2.0.11 → 2.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/core/typing/index.d.ts.map +1 -1
- package/dist/count/core/typing/index.d.ts.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +1 -1
- package/dist/react/count/core/typing/index.d.ts.map +1 -1
- package/dist/react/scrollFadeIn/core/typing/index.d.ts.map +1 -1
- package/dist/react/textToParticle/core/typing/index.d.ts.map +1 -1
- package/dist/react/typing/core/typing/index.d.ts.map +1 -1
- package/dist/react/typing/index.cjs +1 -1
- package/dist/react/typing/index.mjs +1 -1
- package/dist/scrollFadeIn/core/typing/index.d.ts.map +1 -1
- package/dist/svelte/index.cjs +1 -1
- package/dist/svelte/index.mjs +5 -3
- package/dist/svelte/typing/index.cjs +1 -1
- package/dist/svelte/typing/index.mjs +5 -3
- package/dist/textToParticle/core/typing/index.d.ts.map +1 -1
- package/dist/typing/core/typing/index.d.ts.map +1 -1
- package/dist/typing/index.cjs +1 -1
- package/dist/typing/index.mjs +1 -1
- package/dist/vue/index.cjs +1 -1
- package/dist/vue/index.mjs +5 -3
- package/dist/vue/typing/index.cjs +1 -1
- package/dist/vue/typing/index.mjs +5 -3
- package/package.json +1 -1
package/dist/svelte/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var t=Object.defineProperty,i=(i,e,n)=>((i,e,n)=>e in i?t(i,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):i[e]=n)(i,"symbol"!=typeof e?e+"":e,n);Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("svelte");function n(){}function s(t){return t()}function o(){return Object.create(null)}function r(t){t.forEach(s)}function a(t){return"function"==typeof t}function h(t,i){return t!=t?i==i:t!==i||t&&"object"==typeof t||"function"==typeof t}function l(t,i,e){t.$$.on_destroy.push(function(t,...i){if(null==t){for(const t of i)t(void 0);return n}const e=t.subscribe(...i);return e.unsubscribe?()=>e.unsubscribe():e}(i,e))}function c(t,i,e,n){return t[1]&&n?function(t,i){for(const e in i)t[e]=i[e];return t}(e.ctx.slice(),t[1](n(i))):e.ctx}function u(t,i,e){t.insertBefore(i,e||null)}function d(t){t.parentNode&&t.parentNode.removeChild(t)}function g(t){return document.createElement(t)}function f(t,i,e){null==e?t.removeAttribute(i):t.getAttribute(i)!==e&&t.setAttribute(i,e)}let p;function m(t){p=t}const y=[],x=[];let b=[];const v=[],M=Promise.resolve();let $=!1;function C(t){b.push(t)}const w=new Set;let R=0;function V(){if(0!==R)return;const t=p;do{try{for(;R<y.length;){const t=y[R];R++,m(t),T(t.$$)}}catch(i){throw y.length=0,R=0,i}for(m(null),y.length=0,R=0;x.length;)x.pop()();for(let t=0;t<b.length;t+=1){const i=b[t];w.has(i)||(w.add(i),i())}b.length=0}while(y.length);for(;v.length;)v.pop()();$=!1,w.clear(),m(t)}function T(t){if(null!==t.fragment){t.update(),r(t.before_update);const i=t.dirty;t.dirty=[-1],t.fragment&&t.fragment.p(t.ctx,i),t.after_update.forEach(C)}}const S=new Set;function P(t,i){t&&t.i&&(S.delete(t),t.i(i))}function D(t,i){const e=t.$$;null!==e.fragment&&(!function(t){const i=[],e=[];b.forEach(n=>-1===t.indexOf(n)?i.push(n):e.push(n)),e.forEach(t=>t()),b=i}(e.after_update),r(e.on_destroy),e.fragment&&e.fragment.d(i),e.on_destroy=e.fragment=null,e.ctx=[])}function I(t,i){-1===t.$$.dirty[0]&&(y.push(t),$||($=!0,M.then(V)),t.$$.dirty.fill(0)),t.$$.dirty[i/31|0]|=1<<i%31}function H(t,i,e,h,l,c,u=null,g=[-1]){const f=p;m(t);const y=t.$$={fragment:null,ctx:[],props:c,update:n,not_equal:l,bound:o(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(i.context||(f?f.$$.context:[])),callbacks:o(),dirty:g,skip_bound:!1,root:i.target||f.$$.root};u&&u(y.root);let x=!1;if(y.ctx=e?e(t,i.props||{},(i,e,...n)=>{const s=n.length?n[0]:e;return y.ctx&&l(y.ctx[i],y.ctx[i]=s)&&(!y.skip_bound&&y.bound[i]&&y.bound[i](s),x&&I(t,i)),e}):[],y.update(),x=!0,r(y.before_update),y.fragment=!!h&&h(y.ctx),i.target){if(i.hydrate){const t=(b=i.target,Array.from(b.childNodes));y.fragment&&y.fragment.l(t),t.forEach(d)}else y.fragment&&y.fragment.c();i.intro&&P(t.$$.fragment),function(t,i,e){const{fragment:n,after_update:o}=t.$$;n&&n.m(i,e),C(()=>{const i=t.$$.on_mount.map(s).filter(a);t.$$.on_destroy?t.$$.on_destroy.push(...i):r(i),t.$$.on_mount=[]}),o.forEach(C)}(t,i.target,i.anchor),V()}var b;m(f)}class O{constructor(){i(this,"$$"),i(this,"$$set")}$destroy(){D(this,1),this.$destroy=n}$on(t,i){if(!a(i))return n;const e=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return e.push(i),()=>{const t=e.indexOf(i);-1!==t&&e.splice(t,1)}}$set(t){var i;this.$$set&&(i=t,0!==Object.keys(i).length)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}}"undefined"!=typeof window&&(window.__svelte||(window.__svelte={v:new Set})).v.add("4");class F{constructor(t,i={}){this.container=t,this.options={threshold:i.threshold??.1,rootMargin:i.rootMargin??"0px",root:i.root??null,onVisible:i.onVisible,onHidden:i.onHidden},this.intersectionObserver=null,this.visibilityChangeHandler=null,this.isVisible=!1,this.isPageVisible="undefined"==typeof document||!document.hidden,this.setupIntersectionObserver(),this.setupPageVisibility()}setupIntersectionObserver(){if("undefined"==typeof window||void 0===window.IntersectionObserver)return this.isVisible=!0,void(this.isPageVisible&&this.options.onVisible&&this.options.onVisible());this.intersectionObserver=new IntersectionObserver(t=>{for(const i of t)i.target===this.container&&(i.isIntersecting?(this.isVisible=!0,this.isPageVisible&&this.options.onVisible&&this.options.onVisible()):(this.isVisible=!1,this.options.onHidden&&this.options.onHidden()))},{threshold:this.options.threshold,rootMargin:this.options.rootMargin,root:this.options.root||null}),this.intersectionObserver.observe(this.container)}setupPageVisibility(){"undefined"!=typeof document&&(this.visibilityChangeHandler=()=>{const t=this.isPageVisible;this.isPageVisible=!document.hidden,document.hidden?this.options.onHidden&&this.options.onHidden():t!==this.isPageVisible&&this.isVisible&&this.options.onVisible&&this.options.onVisible()},document.addEventListener("visibilitychange",this.visibilityChangeHandler),document.hidden&&this.isVisible&&this.options.onHidden&&this.options.onHidden())}getIsVisible(){return this.isVisible&&this.isPageVisible}updateOptions(t){this.options={...this.options,...t},this.intersectionObserver&&(this.intersectionObserver.disconnect(),this.intersectionObserver=null),this.setupIntersectionObserver()}destroy(){this.intersectionObserver&&(this.intersectionObserver.disconnect(),this.intersectionObserver=null),this.visibilityChangeHandler&&"undefined"!=typeof document&&(document.removeEventListener("visibilitychange",this.visibilityChangeHandler),this.visibilityChangeHandler=null)}}function E(t,i){let e=null;return function(...n){null!==e&&clearTimeout(e),e=setTimeout(()=>{e=null,t.apply(this,n)},i)}}class U{constructor(t,i={}){if(this.container="string"==typeof t?document.querySelector(t):t,!this.container)throw new Error("Container element not found");this.config={text:i.text||"mason effect",densityStep:i.densityStep??2,maxParticles:i.maxParticles??3200,pointSize:i.pointSize??.5,ease:i.ease??.05,repelRadius:i.repelRadius??150,repelStrength:i.repelStrength??1,particleColor:i.particleColor||"#fff",fontFamily:i.fontFamily||"Inter, system-ui, Arial",fontSize:i.fontSize||null,width:i.width||null,height:i.height||null,devicePixelRatio:i.devicePixelRatio??null,onReady:i.onReady||null,onUpdate:i.onUpdate||null},this.canvas=document.createElement("canvas");const e=this.canvas.getContext("2d",{willReadFrequently:!0});if(!e)throw new Error("Canvas context not available");this.ctx=e,this.container.appendChild(this.canvas),this.canvas.style.display="block",this.offCanvas=document.createElement("canvas");const n=this.offCanvas.getContext("2d",{willReadFrequently:!0});if(!n)throw new Error("Offscreen canvas context not available");this.offCtx=n,this.W=0,this.H=0,this.DPR=this.config.devicePixelRatio||Math.min(window.devicePixelRatio||1,1.8),this.particles=[],this.mouse={x:0,y:0,down:!1},this.animationId=null,this.isRunning=!1,this.visibilityManager=null,this.debounceDelay=i.debounceDelay??150;const s=this.handleResize.bind(this);this.handleResize=E(s,this.debounceDelay),this.handleMouseMove=this.handleMouseMove.bind(this),this.handleMouseLeave=this.handleMouseLeave.bind(this),this.handleMouseDown=this.handleMouseDown.bind(this),this.handleMouseUp=this.handleMouseUp.bind(this),this._debouncedMorph=E(this._morphInternal.bind(this),this.debounceDelay),this._debouncedUpdateConfig=E(this._updateConfigInternal.bind(this),this.debounceDelay),this.init()}init(){this.resize(),this.setupEventListeners(),this.setupVisibilityManager(),this.config.onReady&&this.config.onReady(this)}setupVisibilityManager(){this.visibilityManager=new F(this.container,{threshold:.1,onVisible:()=>{this.start()},onHidden:()=>{this.stop()}})}resize(){const t=this.container.getBoundingClientRect(),i=this.config.width||t.width||this.container.clientWidth||window.innerWidth,e=this.config.height||t.height||this.container.clientHeight||.7*window.innerHeight;if(i<=0||e<=0)return;this.W=Math.floor(i*this.DPR),this.H=Math.floor(e*this.DPR);const n=4096;if(this.W>n||this.H>n){const t=Math.min(n/this.W,n/this.H);this.W=Math.floor(this.W*t),this.H=Math.floor(this.H*t),this.DPR=this.DPR*t}this.canvas.width=this.W,this.canvas.height=this.H,this.canvas.style.width=i+"px",this.canvas.style.height=e+"px",this.W>0&&this.H>0&&(this.buildTargets(),this.particles.length||this.initParticles())}measureTextFit(t,i,e,n){this.offCtx.font=`400 ${t}px ${this.config.fontFamily}`;const s=i.split("\n"),o=t,r=.1*t,a=.05*t;let h=0;for(const c of s){if(0===c.length)continue;const t=this.offCtx.measureText(c).width+a*(c.length>0?c.length-1:0);h=Math.max(h,t)}const l=s.length>0?o*s.length+r*(s.length-1):o;return{width:h,height:l,fits:h<=e&&l<=n}}findOptimalFontSize(t,i,e,n){if(this.measureTextFit(n,t,i,e).fits)return n;if(n<=12)return 12;let s=12,o=n,r=12;for(;s<=o;){const n=Math.floor((s+o)/2);this.measureTextFit(n,t,i,e).fits?(r=n,s=n+1):o=n-1}return r}buildTargets(){if(this.W<=0||this.H<=0)return;const t=this.config.text;this.offCanvas.width=this.W,this.offCanvas.height=this.H,this.offCtx.clearRect(0,0,this.offCanvas.width,this.offCanvas.height);const i=Math.min(this.W,this.H),e=this.config.fontSize||Math.max(80,Math.floor(.18*i)),n=this.W-80,s=this.H-80,o=this.findOptimalFontSize(t,n,s,e);this.offCtx.fillStyle="#ffffff",this.offCtx.textAlign="center",this.offCtx.textBaseline="middle",this.offCtx.font=`400 ${o}px ${this.config.fontFamily}`;const r=t.split("\n"),a=o,h=.1*o,l=.05*o,c=r.length>0?a*r.length+h*(r.length-1):a;let u=this.H/2-c/2+a/2;for(const p of r){if(0===p.length){u+=a+h;continue}const t=p.split(""),i=this.offCtx.measureText(p).width+l*(t.length>0?t.length-1:0);let e=this.W/2-i/2;for(const n of t)this.offCtx.fillText(n,e+this.offCtx.measureText(n).width/2,u),e+=this.offCtx.measureText(n).width+l;u+=a+h}const d=Math.max(2,this.config.densityStep),g=this.offCtx.getImageData(0,0,this.W,this.H).data,f=[];for(let p=0;p<this.H;p+=d)for(let t=0;t<this.W;t+=d){const i=4*(p*this.W+t);g[i]+g[i+1]+g[i+2]>600&&f.push({x:t,y:p})}for(;f.length>this.config.maxParticles;)f.splice(Math.floor(Math.random()*f.length),1);if(this.particles.length<f.length){const t=f.length-this.particles.length;for(let i=0;i<t;i++)this.particles.push(this.makeParticle())}else this.particles.length>f.length&&(this.particles.length=f.length);for(let p=0;p<this.particles.length;p++){const t=this.particles[p],i=f[p];t.tx=i.x,t.ty=i.y}}makeParticle(){const t=Math.random()*this.W,i=Math.random()*this.H;return{x:t,y:i,vx:0,vy:0,tx:t,ty:i,initialX:t,initialY:i,j:Math.random()*Math.PI*2}}initParticles(){for(const t of this.particles){const i=Math.random()*this.W,e=Math.random()*this.H;t.x=i,t.y=e,t.vx=t.vy=0,t.initialX=i,t.initialY=e}}scatter(){for(const t of this.particles)void 0!==t.initialX&&void 0!==t.initialY?(t.tx=t.initialX,t.ty=t.initialY):(t.initialX=t.x,t.initialY=t.y,t.tx=t.initialX,t.ty=t.initialY)}morph(t){this._debouncedMorph(t)}_morphInternal(t){if(0!==this.W&&0!==this.H||this.resize(),"string"==typeof t)this.config.text=t,this.buildTargets();else if(t&&"object"==typeof t){const i=void 0!==t.text;this.config={...this.config,...t},i&&this.buildTargets()}else this.buildTargets()}update(){this.ctx.clearRect(0,0,this.W,this.H);for(const n of this.particles){let t=(n.tx-n.x)*this.config.ease,i=(n.ty-n.y)*this.config.ease;if(this.mouse.x||this.mouse.y){const e=n.x-this.mouse.x,s=n.y-this.mouse.y,o=e*e+s*s,r=this.config.repelRadius*this.DPR;if(o<r*r){const n=Math.sqrt(o)+1e-4,a=(this.mouse.down?-1:1)*this.config.repelStrength*(1-n/r);t+=e/n*a*6,i+=s/n*a*6}}n.j+=2,t+=.05*Math.cos(n.j),i+=.05*Math.sin(1.3*n.j),n.vx=(n.vx+t)*Math.random(),n.vy=(n.vy+i)*Math.random(),n.x+=n.vx,n.y+=n.vy}this.ctx.fillStyle=this.config.particleColor;const t=Math.min(this.W,this.H)/this.DPR,i=Math.max(.5,Math.min(2,t/1920)),e=this.config.pointSize*this.DPR*i;for(const n of this.particles)this.ctx.beginPath(),this.ctx.arc(n.x,n.y,e,0,2*Math.PI),this.ctx.fill();this.config.onUpdate&&this.config.onUpdate(this)}animate(){this.isRunning&&(this.update(),this.animationId=requestAnimationFrame(()=>this.animate()))}start(){this.isRunning||(this.isRunning=!0,this.animate())}stop(){this.isRunning=!1,this.animationId&&(cancelAnimationFrame(this.animationId),this.animationId=null)}setupEventListeners(){window.addEventListener("resize",this.handleResize),this.canvas.addEventListener("mousemove",this.handleMouseMove),this.canvas.addEventListener("mouseleave",this.handleMouseLeave),this.canvas.addEventListener("mousedown",this.handleMouseDown),window.addEventListener("mouseup",this.handleMouseUp)}removeEventListeners(){window.removeEventListener("resize",this.handleResize),this.canvas.removeEventListener("mousemove",this.handleMouseMove),this.canvas.removeEventListener("mouseleave",this.handleMouseLeave),this.canvas.removeEventListener("mousedown",this.handleMouseDown),window.removeEventListener("mouseup",this.handleMouseUp)}handleResize(){this.resize()}handleMouseMove(t){const i=this.canvas.getBoundingClientRect();this.mouse.x=(t.clientX-i.left)*this.DPR,this.mouse.y=(t.clientY-i.top)*this.DPR}handleMouseLeave(){this.mouse.x=this.mouse.y=0}handleMouseDown(){this.mouse.down=!0}handleMouseUp(){this.mouse.down=!1}updateConfig(t){this._debouncedUpdateConfig(t)}_updateConfigInternal(t){this.config={...this.config,...t},t.text&&this.buildTargets()}destroy(){this.stop(),this.removeEventListeners(),this.visibilityManager&&(this.visibilityManager.destroy(),this.visibilityManager=null),this.canvas&&this.canvas.parentNode&&this.canvas.parentNode.removeChild(this.canvas)}}const _={linear:t=>t};class z{constructor(t,i){if(this.container="string"==typeof t?document.querySelector(t):t,!this.container)throw new Error("Container element not found");this.config={targetValue:i.targetValue,duration:i.duration??2e3,startValue:i.startValue??0,enabled:i.enabled??!0,easing:i.easing??_.linear,threshold:i.threshold??.2,rootMargin:i.rootMargin??"0px 0px -100px 0px",triggerOnce:i.triggerOnce??!1,onUpdate:i.onUpdate||null,onComplete:i.onComplete||null},this.currentValue=this.config.startValue,this.startTime=null,this.animationFrameId=null,this.visibilityManager=null,this.isRunning=!1,this.hasTriggered=!1,this.init()}init(){this.updateDisplay(this.config.startValue),this.setupVisibilityManager()}setupVisibilityManager(){this.visibilityManager=new F(this.container,{threshold:this.config.threshold,rootMargin:this.config.rootMargin,onVisible:()=>{!this.hasTriggered&&this.config.enabled&&(this.hasTriggered=!0,this.start())},onHidden:()=>{!this.config.triggerOnce&&this.isRunning&&this.reset()}})}start(){if(this.isRunning)return;if(!this.config.enabled)return;this.isRunning=!0,this.startTime=null,this.currentValue=this.config.startValue,this.updateDisplay(this.currentValue);const t=i=>{null===this.startTime&&(this.startTime=i);const e=i-this.startTime,n=Math.min(e/this.config.duration,1),s=this.config.easing(n);this.currentValue=Math.floor(this.config.startValue+(this.config.targetValue-this.config.startValue)*s),this.updateDisplay(this.currentValue),this.config.onUpdate&&this.config.onUpdate(this.currentValue),n<1?this.animationFrameId=requestAnimationFrame(t):(this.currentValue=this.config.targetValue,this.updateDisplay(this.currentValue),this.isRunning=!1,this.config.onComplete&&this.config.onComplete())};this.animationFrameId=requestAnimationFrame(t)}stop(){this.isRunning=!1,null!==this.animationFrameId&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null)}reset(){this.stop(),this.currentValue=this.config.startValue,this.updateDisplay(this.currentValue),this.hasTriggered=!1,this.startTime=null}updateDisplay(t){this.container.textContent=this.formatNumber(t)}formatNumber(t){return Math.floor(t).toLocaleString()}updateConfig(t){const i=this.isRunning;this.stop(),this.config={...this.config,...t,onUpdate:void 0!==t.onUpdate?t.onUpdate:this.config.onUpdate,onComplete:void 0!==t.onComplete?t.onComplete:this.config.onComplete},void 0!==t.targetValue?(this.reset(),i&&this.config.enabled&&this.start()):i&&this.config.enabled&&this.start()}getValue(){return this.currentValue}destroy(){this.stop(),this.visibilityManager&&(this.visibilityManager.destroy(),this.visibilityManager=null)}}function L(t){const i=t.charCodeAt(0);if(i<44032||i>55203)return[t];const e=i-44032,n=Math.floor(e/588),s=Math.floor(e%588/28),o=e%28,r=["","ㄱ","ㄲ","ㄳ","ㄴ","ㄵ","ㄶ","ㄷ","ㄹ","ㄺ","ㄻ","ㄼ","ㄽ","ㄾ","ㄿ","ㅀ","ㅁ","ㅂ","ㅄ","ㅅ","ㅆ","ㅇ","ㅈ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"],a=[];return a.push(["ㄱ","ㄲ","ㄴ","ㄷ","ㄸ","ㄹ","ㅁ","ㅂ","ㅃ","ㅅ","ㅆ","ㅇ","ㅈ","ㅉ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"][n]),a.push(["ㅏ","ㅐ","ㅑ","ㅒ","ㅓ","ㅔ","ㅕ","ㅖ","ㅗ","ㅘ","ㅙ","ㅚ","ㅛ","ㅜ","ㅝ","ㅞ","ㅟ","ㅠ","ㅡ","ㅢ","ㅣ"][s]),o>0&&a.push(r[o]),a}function W(t,i,e){const n=["ㄱ","ㄲ","ㄴ","ㄷ","ㄸ","ㄹ","ㅁ","ㅂ","ㅃ","ㅅ","ㅆ","ㅇ","ㅈ","ㅉ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"].indexOf(t),s=["ㅏ","ㅐ","ㅑ","ㅒ","ㅓ","ㅔ","ㅕ","ㅖ","ㅗ","ㅘ","ㅙ","ㅚ","ㅛ","ㅜ","ㅝ","ㅞ","ㅟ","ㅠ","ㅡ","ㅢ","ㅣ"].indexOf(i),o=e?["","ㄱ","ㄲ","ㄳ","ㄴ","ㄵ","ㄶ","ㄷ","ㄹ","ㄺ","ㄻ","ㄼ","ㄽ","ㄾ","ㄿ","ㅀ","ㅁ","ㅂ","ㅄ","ㅅ","ㅆ","ㅇ","ㅈ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"].indexOf(e):0;if(-1===n||-1===s)return t+(i||"")+(e||"");const r=44032+21*n*28+28*s+o;return String.fromCharCode(r)}function N(t){const i=[],e=[];for(let n=0;n<t.length;n++){const s=t[n],o=s.charCodeAt(0),r=i.length;if(o>=44032&&o<=55203){const t=L(s);i.push(...t),e.push({start:r,end:i.length,isHangul:!0})}else i.push(s),e.push({start:r,end:i.length,isHangul:!1})}return{units:i,charUnitRanges:e}}class k{constructor(t,i){if(this.container="string"==typeof t?document.querySelector(t):t,!this.container)throw new Error("Container element not found");this.originalText=i.text,this.config={text:i.text,speed:i.speed??50,delay:i.delay??0,enabled:i.enabled??!0,threshold:i.threshold??.2,rootMargin:i.rootMargin??"0px 0px -100px 0px",triggerOnce:i.triggerOnce??!1,showCursor:i.showCursor??!0,cursorChar:i.cursorChar??"|",onUpdate:i.onUpdate||null,onComplete:i.onComplete||null};const e=N(this.config.text);this.textUnits=e.units,this.charUnitRanges=e.charUnitRanges,this.currentIndex=0,this.displayedText="",this.timeoutId=null,this.visibilityManager=null,this.isRunning=!1,this.hasTriggered=!1,this.init()}init(){this.updateDisplay(""),this.injectStyles(),this.setupVisibilityManager()}injectStyles(){if(document.getElementById("masoneffect-typing-styles"))return;const t=document.createElement("style");t.id="masoneffect-typing-styles",t.textContent="\n .typing-char {\n transition: opacity 0.2s ease-in;\n display: inline-block;\n }\n .typing-cursor {\n display: inline-block;\n }\n ",document.head.appendChild(t)}setupVisibilityManager(){this.visibilityManager=new F(this.container,{threshold:this.config.threshold,rootMargin:this.config.rootMargin,onVisible:()=>{!this.hasTriggered&&this.config.enabled&&(this.hasTriggered=!0,setTimeout(()=>this.start(),this.config.delay))},onHidden:()=>{}})}buildTextFromUnits(t){if(0===t)return"";let i="";for(let e=0;e<this.charUnitRanges.length;e++){const n=this.charUnitRanges[e];if(n.start>=t)break;const s=Math.min(t-n.start,n.end-n.start);if(s<=0)break;if(n.isHangul){const t=this.textUnits.slice(n.start,n.start+s);1===t.length?i+=t[0]:2===t.length?i+=W(t[0],t[1]):t.length>=3&&(i+=W(t[0],t[1],t[2]))}else s>0&&(i+=this.textUnits[n.start])}return i}start(){this.isRunning||(this.isRunning=!0,this.currentIndex=0,this.displayedText="",this.typeNext())}typeNext(){if(this.currentIndex>=this.textUnits.length)return this.isRunning=!1,this.config.showCursor&&this.updateDisplay(this.originalText),void(this.config.onComplete&&this.config.onComplete());this.displayedText=this.buildTextFromUnits(this.currentIndex+1);let t=this.displayedText;this.config.showCursor&&(t+=this.config.cursorChar),this.updateDisplay(t),this.config.onUpdate&&this.config.onUpdate(this.displayedText),this.currentIndex++,this.timeoutId=setTimeout(()=>{this.typeNext()},this.config.speed)}stop(){this.isRunning=!1,this.timeoutId&&(clearTimeout(this.timeoutId),this.timeoutId=null)}reset(){this.stop(),this.currentIndex=0,this.displayedText="",this.hasTriggered=!1,this.updateDisplay("")}updateDisplay(t){const i=t.replace(new RegExp(this.escapeHtml(this.config.cursorChar)+"$"),""),e=t.endsWith(this.config.cursorChar),n=(this.container.textContent||"").replace(new RegExp(this.config.cursorChar+"$"),"");let s="";for(let r=0;r<i.length;r++){const t=i[r];s+=r>=n.length?`<span class="typing-char typing-fade-in" style="opacity: 0;">${this.escapeHtml(t)}</span>`:`<span class="typing-char" style="opacity: 1;">${this.escapeHtml(t)}</span>`}e&&(s+=`<span class="typing-cursor">${this.escapeHtml(this.config.cursorChar)}</span>`),this.container.innerHTML=s;const o=this.container.querySelectorAll(".typing-fade-in");o.length>0&&requestAnimationFrame(()=>{o.forEach(t=>{t.style.opacity="1",t.classList.remove("typing-fade-in")})})}escapeHtml(t){const i=document.createElement("div");return i.textContent=t,i.innerHTML}setText(t){this.originalText=t,this.config.text=t;const i=N(t);this.textUnits=i.units,this.charUnitRanges=i.charUnitRanges,this.reset(),this.config.enabled&&setTimeout(()=>this.start(),this.config.delay)}destroy(){this.stop(),this.visibilityManager&&(this.visibilityManager.destroy(),this.visibilityManager=null)}}const A=t=>--t*t*t+1;class q{constructor(t,i={}){if(this.container="string"==typeof t?document.querySelector(t):t,!this.container)throw new Error("Container element not found");this.config={direction:i.direction??"bottom",distance:i.distance??"50px",duration:i.duration??800,threshold:i.threshold??.1,rootMargin:i.rootMargin??"0px",root:i.root??null,triggerOnce:i.triggerOnce??!1,enabled:i.enabled??!0,onStart:i.onStart||null,onComplete:i.onComplete||null},this.easing=A,this.visibilityManager=null,this.animationFrameId=null,this.startTime=null,this.isRunning=!1,this.hasTriggered=!1,this.initialTransform="",this.targetDistance=0,this.init()}init(){const t=window.getComputedStyle(this.container);this.initialTransform="none"!==t.transform?t.transform:this.container.style.transform||"",this.targetDistance=this.parseDistance(this.config.distance),this.setInitialPosition(),this.setupVisibilityManager()}parseDistance(t){const i=t.match(/^(-?\d+\.?\d*)(px|rem|em|%|vh|vw)$/);if(!i){return parseFloat(t)||50}const e=parseFloat(i[1]);switch(i[2]){case"px":default:return e;case"rem":case"em":return e*(parseFloat(getComputedStyle(document.documentElement).fontSize)||16);case"%":const t=this.container.getBoundingClientRect();return e/100*("top"===this.config.direction||"bottom"===this.config.direction?t.height:t.width);case"vh":return e/100*window.innerHeight;case"vw":return e/100*window.innerWidth}}setInitialPosition(){let t=0,i=0;switch(this.config.direction){case"top":i=-this.targetDistance;break;case"right":t=this.targetDistance;break;case"bottom":i=this.targetDistance;break;case"left":t=-this.targetDistance}const e=this.initialTransform||"",n=`translate(${t}px, ${i}px)`;this.container.style.transform=e&&"none"!==e?`${n} ${e}`:n,this.container.style.opacity="0",this.container.style.transition="none"}setupVisibilityManager(){this.visibilityManager=new F(this.container,{threshold:this.config.threshold,rootMargin:this.config.rootMargin,root:this.config.root,onVisible:()=>{this.config.enabled&&(this.config.triggerOnce&&this.hasTriggered||(this.hasTriggered=!0,this.start()))},onHidden:()=>{this.config.enabled&&(this.stop(),this.config.triggerOnce||(this.hasTriggered=!1),this.setInitialPosition())}})}start(){this.isRunning||(this.isRunning=!0,this.startTime=performance.now(),this.config.onStart&&this.config.onStart(),this.container.style.transition="none",this.animate())}animate(){if(!this.isRunning)return;const t=performance.now()-(this.startTime||0),i=Math.min(t/this.config.duration,1),e=this.easing(i);let n=0,s=0;switch(this.config.direction){case"top":s=-this.targetDistance*(1-e);break;case"right":n=this.targetDistance*(1-e);break;case"bottom":s=this.targetDistance*(1-e);break;case"left":n=-this.targetDistance*(1-e)}const o=this.initialTransform||"",r=`translate(${n}px, ${s}px)`;this.container.style.transform=o&&"none"!==o?`${r} ${o}`:r,this.container.style.opacity=String(e),i<1?this.animationFrameId=requestAnimationFrame(()=>this.animate()):this.complete()}complete(){this.isRunning=!1,this.initialTransform&&"none"!==this.initialTransform?this.container.style.transform=this.initialTransform:this.container.style.transform="",this.container.style.opacity="1",this.animationFrameId&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null),this.config.onComplete&&this.config.onComplete()}reset(){this.stop(),this.hasTriggered=!1,this.setInitialPosition()}stop(){this.isRunning=!1,this.animationFrameId&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null)}updateConfig(t){const i=this.isRunning;this.stop(),this.config={...this.config,...t,onStart:t.onStart??this.config.onStart,onComplete:t.onComplete??this.config.onComplete},t.distance&&(this.targetDistance=this.parseDistance(this.config.distance)),this.setInitialPosition(),void 0===t.threshold&&void 0===t.rootMargin&&void 0===t.root||(this.visibilityManager&&(this.visibilityManager.destroy(),this.visibilityManager=null),this.setupVisibilityManager()),i&&this.config.enabled&&this.start()}destroy(){this.stop(),this.visibilityManager&&(this.visibilityManager.destroy(),this.visibilityManager=null),this.container.style.transform=this.initialTransform||"",this.container.style.opacity="",this.container.style.transition=""}}function j(t){let i;return{c(){i=g("div"),f(i,"class",t[0]),f(i,"style",t[1])},m(e,n){u(e,i,n),t[21](i)},p(t,[e]){1&e&&f(i,"class",t[0]),2&e&&f(i,"style",t[1])},i:n,o:n,d(e){e&&d(i),t[21](null)}}}function X(t,i,n){let{text:s="mason effect"}=i,{densityStep:o=2}=i,{maxParticles:r=3200}=i,{pointSize:a=.5}=i,{ease:h=.05}=i,{repelRadius:l=150}=i,{repelStrength:c=1}=i,{particleColor:u="#fff"}=i,{fontFamily:d="Inter, system-ui, Arial"}=i,{fontSize:g=null}=i,{width:f=null}=i,{height:p=null}=i,{devicePixelRatio:m=null}=i,{className:y=""}=i,{style:b={}}=i;const v=e.createEventDispatcher();let M,$=null;return e.onMount(()=>{if(!M)return;n(20,$=new U(M,{text:s,densityStep:o,maxParticles:r,pointSize:a,ease:h,repelRadius:l,repelStrength:c,particleColor:u,fontFamily:d,fontSize:g,width:f,height:p,devicePixelRatio:m,onReady:t=>{v("ready",t)},onUpdate:t=>{v("update",t)}}))}),e.onDestroy(()=>{$&&($.destroy(),n(20,$=null))}),t.$$set=t=>{"text"in t&&n(3,s=t.text),"densityStep"in t&&n(4,o=t.densityStep),"maxParticles"in t&&n(5,r=t.maxParticles),"pointSize"in t&&n(6,a=t.pointSize),"ease"in t&&n(7,h=t.ease),"repelRadius"in t&&n(8,l=t.repelRadius),"repelStrength"in t&&n(9,c=t.repelStrength),"particleColor"in t&&n(10,u=t.particleColor),"fontFamily"in t&&n(11,d=t.fontFamily),"fontSize"in t&&n(12,g=t.fontSize),"width"in t&&n(13,f=t.width),"height"in t&&n(14,p=t.height),"devicePixelRatio"in t&&n(15,m=t.devicePixelRatio),"className"in t&&n(0,y=t.className),"style"in t&&n(1,b=t.style)},t.$$.update=()=>{1114104&t.$$.dirty&&$&&$.updateConfig({text:s,densityStep:o,maxParticles:r,pointSize:a,ease:h,repelRadius:l,repelStrength:c,particleColor:u,fontFamily:d,fontSize:g,width:f,height:p,devicePixelRatio:m})},[y,b,M,s,o,r,a,h,l,c,u,d,g,f,p,m,function(t){$&&$.morph(t)},function(){$&&$.scatter()},function(t){$&&$.updateConfig(t)},function(){$&&($.destroy(),n(20,$=null))},$,function(t){x[t?"unshift":"push"](()=>{M=t,n(2,M)})}]}class Y extends O{constructor(t){super(),H(this,t,X,j,h,{text:3,densityStep:4,maxParticles:5,pointSize:6,ease:7,repelRadius:8,repelStrength:9,particleColor:10,fontFamily:11,fontSize:12,width:13,height:14,devicePixelRatio:15,className:0,style:1,morph:16,scatter:17,updateConfig:18,destroy:19})}get morph(){return this.$$.ctx[16]}get scatter(){return this.$$.ctx[17]}get updateConfig(){return this.$$.ctx[18]}get destroy(){return this.$$.ctx[19]}}function B(t){let i;return{c(){i=g("div"),f(i,"class",t[0]),f(i,"style",t[1])},m(e,n){u(e,i,n),t[18](i)},p(t,[e]){1&e&&f(i,"class",t[0]),2&e&&f(i,"style",t[1])},i:n,o:n,d(e){e&&d(i),t[18](null)}}}function G(t,i,n){let{targetValue:s=0}=i,{duration:o=2e3}=i,{startValue:r=0}=i,{enabled:a=!0}=i,{easing:h=t=>t}=i,{threshold:l=.2}=i,{rootMargin:c="0px 0px -100px 0px"}=i,{triggerOnce:u=!1}=i,{className:d=""}=i,{style:g={}}=i;const f=e.createEventDispatcher();let p,m=null;return e.onMount(()=>{if(!p)return;n(17,m=new z(p,{targetValue:s,duration:o,startValue:r,enabled:a,easing:h,threshold:l,rootMargin:c,triggerOnce:u,onUpdate:t=>{f("update",t)},onComplete:()=>{f("complete")}}))}),e.onDestroy(()=>{m&&(m.destroy(),n(17,m=null))}),t.$$set=t=>{"targetValue"in t&&n(3,s=t.targetValue),"duration"in t&&n(4,o=t.duration),"startValue"in t&&n(5,r=t.startValue),"enabled"in t&&n(6,a=t.enabled),"easing"in t&&n(7,h=t.easing),"threshold"in t&&n(8,l=t.threshold),"rootMargin"in t&&n(9,c=t.rootMargin),"triggerOnce"in t&&n(10,u=t.triggerOnce),"className"in t&&n(0,d=t.className),"style"in t&&n(1,g=t.style)},t.$$.update=()=>{133112&t.$$.dirty&&m&&m.updateConfig({targetValue:s,duration:o,startValue:r,enabled:a,easing:h,threshold:l,rootMargin:c,triggerOnce:u,onUpdate:t=>{f("update",t)},onComplete:()=>{f("complete")}})},[d,g,p,s,o,r,a,h,l,c,u,function(){m&&m.start()},function(){m&&m.stop()},function(){m&&m.reset()},function(){return m?m.getValue():0},function(t){m&&m.updateConfig(t)},function(){m&&(m.destroy(),n(17,m=null))},m,function(t){x[t?"unshift":"push"](()=>{p=t,n(2,p)})}]}function J(t){let i;return{c(){i=g("div"),f(i,"class",t[1]),f(i,"style",t[2])},m(e,n){u(e,i,n),t[8](i)},p:n,i:n,o:n,d(e){e&&d(i),t[8](null)}}}function K(t,i,n){let s,o;l(t,effect,t=>n(10,s=t)),l(t,props,t=>n(11,o=t));let{text:r,speed:a=50,delay:h=0,enabled:c=!0,threshold:u=.2,rootMargin:d="0px 0px -100px 0px",triggerOnce:g=!1,showCursor:f=!0,cursorChar:p="|",className:m="",style:y="",onUpdate:b,onComplete:v}=o(),M=null,$=null;return e.onMount(()=>{if(!M)return;$=new k(M,{text:r,speed:a,delay:h,enabled:c,threshold:u,rootMargin:d,triggerOnce:g,showCursor:f,cursorChar:p,onUpdate:b,onComplete:v})}),e.onDestroy(()=>{$&&($.destroy(),$=null)}),s(()=>{$&&r!==$.originalText&&$.setText(r)}),[M,m,y,function(){null==$||$.start()},function(){null==$||$.stop()},function(){null==$||$.reset()},function(t){null==$||$.setText(t)},function(){$&&($.destroy(),$=null)},function(t){x[t?"unshift":"push"](()=>{M=t,n(0,M)})}]}function Q(t){let i,e;const n=t[18].default,s=function(t,i,e,n){if(t){const s=c(t,i,e,n);return t[0](s)}}(n,t,t[17],null);return{c(){i=g("div"),s&&s.c(),f(i,"class",t[0]),f(i,"style",t[1])},m(n,o){u(n,i,o),s&&s.m(i,null),t[19](i),e=!0},p(t,[o]){var r,a;s&&s.p&&(!e||131072&o)&&function(t,i,e,n,s,o){if(s){const r=c(i,e,n,o);t.p(r,s)}}(s,n,t,t[17],e?(r=n,a=t[17],r[2],a.dirty):function(t){if(t.ctx.length>32){const i=[],e=t.ctx.length/32;for(let t=0;t<e;t++)i[t]=-1;return i}return-1}(t[17]),null),(!e||1&o)&&f(i,"class",t[0]),(!e||2&o)&&f(i,"style",t[1])},i(t){e||(P(s,t),e=!0)},o(t){!function(t,i){if(t&&t.o){if(S.has(t))return;S.add(t),(void 0).c.push(()=>{S.delete(t)}),t.o(i)}}(s,t),e=!1},d(e){e&&d(i),s&&s.d(e),t[19](null)}}}function Z(t,i,n){let{$$slots:s={},$$scope:o}=i,{direction:r="bottom"}=i,{distance:a="50px"}=i,{duration:h=800}=i,{threshold:l=.1}=i,{rootMargin:c="0px"}=i,{root:u=null}=i,{triggerOnce:d=!1}=i,{enabled:g=!0}=i,{className:f=""}=i,{style:p={}}=i;const m=e.createEventDispatcher();let y,b=null;return e.onMount(()=>{if(!y)return;n(16,b=new q(y,{direction:r,distance:a,duration:h,threshold:l,rootMargin:c,root:u,triggerOnce:d,enabled:g,onStart:()=>{m("start")},onComplete:()=>{m("complete")}}))}),e.onDestroy(()=>{b&&(b.destroy(),n(16,b=null))}),t.$$set=t=>{"direction"in t&&n(3,r=t.direction),"distance"in t&&n(4,a=t.distance),"duration"in t&&n(5,h=t.duration),"threshold"in t&&n(6,l=t.threshold),"rootMargin"in t&&n(7,c=t.rootMargin),"root"in t&&n(8,u=t.root),"triggerOnce"in t&&n(9,d=t.triggerOnce),"enabled"in t&&n(10,g=t.enabled),"className"in t&&n(0,f=t.className),"style"in t&&n(1,p=t.style),"$$scope"in t&&n(17,o=t.$$scope)},t.$$.update=()=>{67576&t.$$.dirty&&b&&b.updateConfig({direction:r,distance:a,duration:h,threshold:l,rootMargin:c,root:u,triggerOnce:d,enabled:g,onStart:()=>{m("start")},onComplete:()=>{m("complete")}})},[f,p,y,r,a,h,l,c,u,d,g,function(){b&&b.start()},function(){b&&b.stop()},function(){b&&b.reset()},function(t){b&&b.updateConfig(t)},function(){b&&(b.destroy(),n(16,b=null))},b,o,s,function(t){x[t?"unshift":"push"](()=>{y=t,n(2,y)})}]}exports.Count=class extends O{constructor(t){super(),H(this,t,G,B,h,{targetValue:3,duration:4,startValue:5,enabled:6,easing:7,threshold:8,rootMargin:9,triggerOnce:10,className:0,style:1,start:11,stop:12,reset:13,getValue:14,updateConfig:15,destroy:16})}get start(){return this.$$.ctx[11]}get stop(){return this.$$.ctx[12]}get reset(){return this.$$.ctx[13]}get getValue(){return this.$$.ctx[14]}get updateConfig(){return this.$$.ctx[15]}get destroy(){return this.$$.ctx[16]}},exports.MasonEffect=Y,exports.ScrollFadeIn=class extends O{constructor(t){super(),H(this,t,Z,Q,h,{direction:3,distance:4,duration:5,threshold:6,rootMargin:7,root:8,triggerOnce:9,enabled:10,className:0,style:1,start:11,stop:12,reset:13,updateConfig:14,destroy:15})}get start(){return this.$$.ctx[11]}get stop(){return this.$$.ctx[12]}get reset(){return this.$$.ctx[13]}get updateConfig(){return this.$$.ctx[14]}get destroy(){return this.$$.ctx[15]}},exports.TextToParticle=Y,exports.Typing=class extends O{constructor(t){super(),H(this,t,K,J,h,{start:3,stop:4,reset:5,setText:6,destroy:7})}get start(){return this.$$.ctx[3]}get stop(){return this.$$.ctx[4]}get reset(){return this.$$.ctx[5]}get setText(){return this.$$.ctx[6]}get destroy(){return this.$$.ctx[7]}},exports.default=Y;
|
|
1
|
+
"use strict";var t=Object.defineProperty,i=(i,e,n)=>((i,e,n)=>e in i?t(i,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):i[e]=n)(i,"symbol"!=typeof e?e+"":e,n);Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("svelte");function n(){}function s(t){return t()}function o(){return Object.create(null)}function r(t){t.forEach(s)}function a(t){return"function"==typeof t}function h(t,i){return t!=t?i==i:t!==i||t&&"object"==typeof t||"function"==typeof t}function l(t,i,e){t.$$.on_destroy.push(function(t,...i){if(null==t){for(const t of i)t(void 0);return n}const e=t.subscribe(...i);return e.unsubscribe?()=>e.unsubscribe():e}(i,e))}function c(t,i,e,n){return t[1]&&n?function(t,i){for(const e in i)t[e]=i[e];return t}(e.ctx.slice(),t[1](n(i))):e.ctx}function u(t,i,e){t.insertBefore(i,e||null)}function d(t){t.parentNode&&t.parentNode.removeChild(t)}function g(t){return document.createElement(t)}function f(t,i,e){null==e?t.removeAttribute(i):t.getAttribute(i)!==e&&t.setAttribute(i,e)}let p;function m(t){p=t}const y=[],x=[];let b=[];const v=[],M=Promise.resolve();let $=!1;function C(t){b.push(t)}const w=new Set;let R=0;function V(){if(0!==R)return;const t=p;do{try{for(;R<y.length;){const t=y[R];R++,m(t),T(t.$$)}}catch(i){throw y.length=0,R=0,i}for(m(null),y.length=0,R=0;x.length;)x.pop()();for(let t=0;t<b.length;t+=1){const i=b[t];w.has(i)||(w.add(i),i())}b.length=0}while(y.length);for(;v.length;)v.pop()();$=!1,w.clear(),m(t)}function T(t){if(null!==t.fragment){t.update(),r(t.before_update);const i=t.dirty;t.dirty=[-1],t.fragment&&t.fragment.p(t.ctx,i),t.after_update.forEach(C)}}const S=new Set;function P(t,i){t&&t.i&&(S.delete(t),t.i(i))}function D(t,i){const e=t.$$;null!==e.fragment&&(!function(t){const i=[],e=[];b.forEach(n=>-1===t.indexOf(n)?i.push(n):e.push(n)),e.forEach(t=>t()),b=i}(e.after_update),r(e.on_destroy),e.fragment&&e.fragment.d(i),e.on_destroy=e.fragment=null,e.ctx=[])}function I(t,i){-1===t.$$.dirty[0]&&(y.push(t),$||($=!0,M.then(V)),t.$$.dirty.fill(0)),t.$$.dirty[i/31|0]|=1<<i%31}function H(t,i,e,h,l,c,u=null,g=[-1]){const f=p;m(t);const y=t.$$={fragment:null,ctx:[],props:c,update:n,not_equal:l,bound:o(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(i.context||(f?f.$$.context:[])),callbacks:o(),dirty:g,skip_bound:!1,root:i.target||f.$$.root};u&&u(y.root);let x=!1;if(y.ctx=e?e(t,i.props||{},(i,e,...n)=>{const s=n.length?n[0]:e;return y.ctx&&l(y.ctx[i],y.ctx[i]=s)&&(!y.skip_bound&&y.bound[i]&&y.bound[i](s),x&&I(t,i)),e}):[],y.update(),x=!0,r(y.before_update),y.fragment=!!h&&h(y.ctx),i.target){if(i.hydrate){const t=(b=i.target,Array.from(b.childNodes));y.fragment&&y.fragment.l(t),t.forEach(d)}else y.fragment&&y.fragment.c();i.intro&&P(t.$$.fragment),function(t,i,e){const{fragment:n,after_update:o}=t.$$;n&&n.m(i,e),C(()=>{const i=t.$$.on_mount.map(s).filter(a);t.$$.on_destroy?t.$$.on_destroy.push(...i):r(i),t.$$.on_mount=[]}),o.forEach(C)}(t,i.target,i.anchor),V()}var b;m(f)}class O{constructor(){i(this,"$$"),i(this,"$$set")}$destroy(){D(this,1),this.$destroy=n}$on(t,i){if(!a(i))return n;const e=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return e.push(i),()=>{const t=e.indexOf(i);-1!==t&&e.splice(t,1)}}$set(t){var i;this.$$set&&(i=t,0!==Object.keys(i).length)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}}"undefined"!=typeof window&&(window.__svelte||(window.__svelte={v:new Set})).v.add("4");class F{constructor(t,i={}){this.container=t,this.options={threshold:i.threshold??.1,rootMargin:i.rootMargin??"0px",root:i.root??null,onVisible:i.onVisible,onHidden:i.onHidden},this.intersectionObserver=null,this.visibilityChangeHandler=null,this.isVisible=!1,this.isPageVisible="undefined"==typeof document||!document.hidden,this.setupIntersectionObserver(),this.setupPageVisibility()}setupIntersectionObserver(){if("undefined"==typeof window||void 0===window.IntersectionObserver)return this.isVisible=!0,void(this.isPageVisible&&this.options.onVisible&&this.options.onVisible());this.intersectionObserver=new IntersectionObserver(t=>{for(const i of t)i.target===this.container&&(i.isIntersecting?(this.isVisible=!0,this.isPageVisible&&this.options.onVisible&&this.options.onVisible()):(this.isVisible=!1,this.options.onHidden&&this.options.onHidden()))},{threshold:this.options.threshold,rootMargin:this.options.rootMargin,root:this.options.root||null}),this.intersectionObserver.observe(this.container)}setupPageVisibility(){"undefined"!=typeof document&&(this.visibilityChangeHandler=()=>{const t=this.isPageVisible;this.isPageVisible=!document.hidden,document.hidden?this.options.onHidden&&this.options.onHidden():t!==this.isPageVisible&&this.isVisible&&this.options.onVisible&&this.options.onVisible()},document.addEventListener("visibilitychange",this.visibilityChangeHandler),document.hidden&&this.isVisible&&this.options.onHidden&&this.options.onHidden())}getIsVisible(){return this.isVisible&&this.isPageVisible}updateOptions(t){this.options={...this.options,...t},this.intersectionObserver&&(this.intersectionObserver.disconnect(),this.intersectionObserver=null),this.setupIntersectionObserver()}destroy(){this.intersectionObserver&&(this.intersectionObserver.disconnect(),this.intersectionObserver=null),this.visibilityChangeHandler&&"undefined"!=typeof document&&(document.removeEventListener("visibilitychange",this.visibilityChangeHandler),this.visibilityChangeHandler=null)}}function E(t,i){let e=null;return function(...n){null!==e&&clearTimeout(e),e=setTimeout(()=>{e=null,t.apply(this,n)},i)}}class U{constructor(t,i={}){if(this.container="string"==typeof t?document.querySelector(t):t,!this.container)throw new Error("Container element not found");this.config={text:i.text||"mason effect",densityStep:i.densityStep??2,maxParticles:i.maxParticles??3200,pointSize:i.pointSize??.5,ease:i.ease??.05,repelRadius:i.repelRadius??150,repelStrength:i.repelStrength??1,particleColor:i.particleColor||"#fff",fontFamily:i.fontFamily||"Inter, system-ui, Arial",fontSize:i.fontSize||null,width:i.width||null,height:i.height||null,devicePixelRatio:i.devicePixelRatio??null,onReady:i.onReady||null,onUpdate:i.onUpdate||null},this.canvas=document.createElement("canvas");const e=this.canvas.getContext("2d",{willReadFrequently:!0});if(!e)throw new Error("Canvas context not available");this.ctx=e,this.container.appendChild(this.canvas),this.canvas.style.display="block",this.offCanvas=document.createElement("canvas");const n=this.offCanvas.getContext("2d",{willReadFrequently:!0});if(!n)throw new Error("Offscreen canvas context not available");this.offCtx=n,this.W=0,this.H=0,this.DPR=this.config.devicePixelRatio||Math.min(window.devicePixelRatio||1,1.8),this.particles=[],this.mouse={x:0,y:0,down:!1},this.animationId=null,this.isRunning=!1,this.visibilityManager=null,this.debounceDelay=i.debounceDelay??150;const s=this.handleResize.bind(this);this.handleResize=E(s,this.debounceDelay),this.handleMouseMove=this.handleMouseMove.bind(this),this.handleMouseLeave=this.handleMouseLeave.bind(this),this.handleMouseDown=this.handleMouseDown.bind(this),this.handleMouseUp=this.handleMouseUp.bind(this),this._debouncedMorph=E(this._morphInternal.bind(this),this.debounceDelay),this._debouncedUpdateConfig=E(this._updateConfigInternal.bind(this),this.debounceDelay),this.init()}init(){this.resize(),this.setupEventListeners(),this.setupVisibilityManager(),this.config.onReady&&this.config.onReady(this)}setupVisibilityManager(){this.visibilityManager=new F(this.container,{threshold:.1,onVisible:()=>{this.start()},onHidden:()=>{this.stop()}})}resize(){const t=this.container.getBoundingClientRect(),i=this.config.width||t.width||this.container.clientWidth||window.innerWidth,e=this.config.height||t.height||this.container.clientHeight||.7*window.innerHeight;if(i<=0||e<=0)return;this.W=Math.floor(i*this.DPR),this.H=Math.floor(e*this.DPR);const n=4096;if(this.W>n||this.H>n){const t=Math.min(n/this.W,n/this.H);this.W=Math.floor(this.W*t),this.H=Math.floor(this.H*t),this.DPR=this.DPR*t}this.canvas.width=this.W,this.canvas.height=this.H,this.canvas.style.width=i+"px",this.canvas.style.height=e+"px",this.W>0&&this.H>0&&(this.buildTargets(),this.particles.length||this.initParticles())}measureTextFit(t,i,e,n){this.offCtx.font=`400 ${t}px ${this.config.fontFamily}`;const s=i.split("\n"),o=t,r=.1*t,a=.05*t;let h=0;for(const c of s){if(0===c.length)continue;const t=this.offCtx.measureText(c).width+a*(c.length>0?c.length-1:0);h=Math.max(h,t)}const l=s.length>0?o*s.length+r*(s.length-1):o;return{width:h,height:l,fits:h<=e&&l<=n}}findOptimalFontSize(t,i,e,n){if(this.measureTextFit(n,t,i,e).fits)return n;if(n<=12)return 12;let s=12,o=n,r=12;for(;s<=o;){const n=Math.floor((s+o)/2);this.measureTextFit(n,t,i,e).fits?(r=n,s=n+1):o=n-1}return r}buildTargets(){if(this.W<=0||this.H<=0)return;const t=this.config.text;this.offCanvas.width=this.W,this.offCanvas.height=this.H,this.offCtx.clearRect(0,0,this.offCanvas.width,this.offCanvas.height);const i=Math.min(this.W,this.H),e=this.config.fontSize||Math.max(80,Math.floor(.18*i)),n=this.W-80,s=this.H-80,o=this.findOptimalFontSize(t,n,s,e);this.offCtx.fillStyle="#ffffff",this.offCtx.textAlign="center",this.offCtx.textBaseline="middle",this.offCtx.font=`400 ${o}px ${this.config.fontFamily}`;const r=t.split("\n"),a=o,h=.1*o,l=.05*o,c=r.length>0?a*r.length+h*(r.length-1):a;let u=this.H/2-c/2+a/2;for(const p of r){if(0===p.length){u+=a+h;continue}const t=p.split(""),i=this.offCtx.measureText(p).width+l*(t.length>0?t.length-1:0);let e=this.W/2-i/2;for(const n of t)this.offCtx.fillText(n,e+this.offCtx.measureText(n).width/2,u),e+=this.offCtx.measureText(n).width+l;u+=a+h}const d=Math.max(2,this.config.densityStep),g=this.offCtx.getImageData(0,0,this.W,this.H).data,f=[];for(let p=0;p<this.H;p+=d)for(let t=0;t<this.W;t+=d){const i=4*(p*this.W+t);g[i]+g[i+1]+g[i+2]>600&&f.push({x:t,y:p})}for(;f.length>this.config.maxParticles;)f.splice(Math.floor(Math.random()*f.length),1);if(this.particles.length<f.length){const t=f.length-this.particles.length;for(let i=0;i<t;i++)this.particles.push(this.makeParticle())}else this.particles.length>f.length&&(this.particles.length=f.length);for(let p=0;p<this.particles.length;p++){const t=this.particles[p],i=f[p];t.tx=i.x,t.ty=i.y}}makeParticle(){const t=Math.random()*this.W,i=Math.random()*this.H;return{x:t,y:i,vx:0,vy:0,tx:t,ty:i,initialX:t,initialY:i,j:Math.random()*Math.PI*2}}initParticles(){for(const t of this.particles){const i=Math.random()*this.W,e=Math.random()*this.H;t.x=i,t.y=e,t.vx=t.vy=0,t.initialX=i,t.initialY=e}}scatter(){for(const t of this.particles)void 0!==t.initialX&&void 0!==t.initialY?(t.tx=t.initialX,t.ty=t.initialY):(t.initialX=t.x,t.initialY=t.y,t.tx=t.initialX,t.ty=t.initialY)}morph(t){this._debouncedMorph(t)}_morphInternal(t){if(0!==this.W&&0!==this.H||this.resize(),"string"==typeof t)this.config.text=t,this.buildTargets();else if(t&&"object"==typeof t){const i=void 0!==t.text;this.config={...this.config,...t},i&&this.buildTargets()}else this.buildTargets()}update(){this.ctx.clearRect(0,0,this.W,this.H);for(const n of this.particles){let t=(n.tx-n.x)*this.config.ease,i=(n.ty-n.y)*this.config.ease;if(this.mouse.x||this.mouse.y){const e=n.x-this.mouse.x,s=n.y-this.mouse.y,o=e*e+s*s,r=this.config.repelRadius*this.DPR;if(o<r*r){const n=Math.sqrt(o)+1e-4,a=(this.mouse.down?-1:1)*this.config.repelStrength*(1-n/r);t+=e/n*a*6,i+=s/n*a*6}}n.j+=2,t+=.05*Math.cos(n.j),i+=.05*Math.sin(1.3*n.j),n.vx=(n.vx+t)*Math.random(),n.vy=(n.vy+i)*Math.random(),n.x+=n.vx,n.y+=n.vy}this.ctx.fillStyle=this.config.particleColor;const t=Math.min(this.W,this.H)/this.DPR,i=Math.max(.5,Math.min(2,t/1920)),e=this.config.pointSize*this.DPR*i;for(const n of this.particles)this.ctx.beginPath(),this.ctx.arc(n.x,n.y,e,0,2*Math.PI),this.ctx.fill();this.config.onUpdate&&this.config.onUpdate(this)}animate(){this.isRunning&&(this.update(),this.animationId=requestAnimationFrame(()=>this.animate()))}start(){this.isRunning||(this.isRunning=!0,this.animate())}stop(){this.isRunning=!1,this.animationId&&(cancelAnimationFrame(this.animationId),this.animationId=null)}setupEventListeners(){window.addEventListener("resize",this.handleResize),this.canvas.addEventListener("mousemove",this.handleMouseMove),this.canvas.addEventListener("mouseleave",this.handleMouseLeave),this.canvas.addEventListener("mousedown",this.handleMouseDown),window.addEventListener("mouseup",this.handleMouseUp)}removeEventListeners(){window.removeEventListener("resize",this.handleResize),this.canvas.removeEventListener("mousemove",this.handleMouseMove),this.canvas.removeEventListener("mouseleave",this.handleMouseLeave),this.canvas.removeEventListener("mousedown",this.handleMouseDown),window.removeEventListener("mouseup",this.handleMouseUp)}handleResize(){this.resize()}handleMouseMove(t){const i=this.canvas.getBoundingClientRect();this.mouse.x=(t.clientX-i.left)*this.DPR,this.mouse.y=(t.clientY-i.top)*this.DPR}handleMouseLeave(){this.mouse.x=this.mouse.y=0}handleMouseDown(){this.mouse.down=!0}handleMouseUp(){this.mouse.down=!1}updateConfig(t){this._debouncedUpdateConfig(t)}_updateConfigInternal(t){this.config={...this.config,...t},t.text&&this.buildTargets()}destroy(){this.stop(),this.removeEventListeners(),this.visibilityManager&&(this.visibilityManager.destroy(),this.visibilityManager=null),this.canvas&&this.canvas.parentNode&&this.canvas.parentNode.removeChild(this.canvas)}}const _={linear:t=>t};class z{constructor(t,i){if(this.container="string"==typeof t?document.querySelector(t):t,!this.container)throw new Error("Container element not found");this.config={targetValue:i.targetValue,duration:i.duration??2e3,startValue:i.startValue??0,enabled:i.enabled??!0,easing:i.easing??_.linear,threshold:i.threshold??.2,rootMargin:i.rootMargin??"0px 0px -100px 0px",triggerOnce:i.triggerOnce??!1,onUpdate:i.onUpdate||null,onComplete:i.onComplete||null},this.currentValue=this.config.startValue,this.startTime=null,this.animationFrameId=null,this.visibilityManager=null,this.isRunning=!1,this.hasTriggered=!1,this.init()}init(){this.updateDisplay(this.config.startValue),this.setupVisibilityManager()}setupVisibilityManager(){this.visibilityManager=new F(this.container,{threshold:this.config.threshold,rootMargin:this.config.rootMargin,onVisible:()=>{!this.hasTriggered&&this.config.enabled&&(this.hasTriggered=!0,this.start())},onHidden:()=>{!this.config.triggerOnce&&this.isRunning&&this.reset()}})}start(){if(this.isRunning)return;if(!this.config.enabled)return;this.isRunning=!0,this.startTime=null,this.currentValue=this.config.startValue,this.updateDisplay(this.currentValue);const t=i=>{null===this.startTime&&(this.startTime=i);const e=i-this.startTime,n=Math.min(e/this.config.duration,1),s=this.config.easing(n);this.currentValue=Math.floor(this.config.startValue+(this.config.targetValue-this.config.startValue)*s),this.updateDisplay(this.currentValue),this.config.onUpdate&&this.config.onUpdate(this.currentValue),n<1?this.animationFrameId=requestAnimationFrame(t):(this.currentValue=this.config.targetValue,this.updateDisplay(this.currentValue),this.isRunning=!1,this.config.onComplete&&this.config.onComplete())};this.animationFrameId=requestAnimationFrame(t)}stop(){this.isRunning=!1,null!==this.animationFrameId&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null)}reset(){this.stop(),this.currentValue=this.config.startValue,this.updateDisplay(this.currentValue),this.hasTriggered=!1,this.startTime=null}updateDisplay(t){this.container.textContent=this.formatNumber(t)}formatNumber(t){return Math.floor(t).toLocaleString()}updateConfig(t){const i=this.isRunning;this.stop(),this.config={...this.config,...t,onUpdate:void 0!==t.onUpdate?t.onUpdate:this.config.onUpdate,onComplete:void 0!==t.onComplete?t.onComplete:this.config.onComplete},void 0!==t.targetValue?(this.reset(),i&&this.config.enabled&&this.start()):i&&this.config.enabled&&this.start()}getValue(){return this.currentValue}destroy(){this.stop(),this.visibilityManager&&(this.visibilityManager.destroy(),this.visibilityManager=null)}}function L(t){const i=t.charCodeAt(0);if(i<44032||i>55203)return[t];const e=i-44032,n=Math.floor(e/588),s=Math.floor(e%588/28),o=e%28,r=["","ㄱ","ㄲ","ㄳ","ㄴ","ㄵ","ㄶ","ㄷ","ㄹ","ㄺ","ㄻ","ㄼ","ㄽ","ㄾ","ㄿ","ㅀ","ㅁ","ㅂ","ㅄ","ㅅ","ㅆ","ㅇ","ㅈ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"],a=[];return a.push(["ㄱ","ㄲ","ㄴ","ㄷ","ㄸ","ㄹ","ㅁ","ㅂ","ㅃ","ㅅ","ㅆ","ㅇ","ㅈ","ㅉ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"][n]),a.push(["ㅏ","ㅐ","ㅑ","ㅒ","ㅓ","ㅔ","ㅕ","ㅖ","ㅗ","ㅘ","ㅙ","ㅚ","ㅛ","ㅜ","ㅝ","ㅞ","ㅟ","ㅠ","ㅡ","ㅢ","ㅣ"][s]),o>0&&a.push(r[o]),a}function W(t,i,e){const n=["ㄱ","ㄲ","ㄴ","ㄷ","ㄸ","ㄹ","ㅁ","ㅂ","ㅃ","ㅅ","ㅆ","ㅇ","ㅈ","ㅉ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"].indexOf(t),s=["ㅏ","ㅐ","ㅑ","ㅒ","ㅓ","ㅔ","ㅕ","ㅖ","ㅗ","ㅘ","ㅙ","ㅚ","ㅛ","ㅜ","ㅝ","ㅞ","ㅟ","ㅠ","ㅡ","ㅢ","ㅣ"].indexOf(i),o=e?["","ㄱ","ㄲ","ㄳ","ㄴ","ㄵ","ㄶ","ㄷ","ㄹ","ㄺ","ㄻ","ㄼ","ㄽ","ㄾ","ㄿ","ㅀ","ㅁ","ㅂ","ㅄ","ㅅ","ㅆ","ㅇ","ㅈ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"].indexOf(e):0;if(-1===n||-1===s)return t+(i||"")+(e||"");const r=44032+21*n*28+28*s+o;return String.fromCharCode(r)}function N(t){const i=[],e=[];for(let n=0;n<t.length;n++){const s=t[n],o=s.charCodeAt(0),r=i.length;if(o>=44032&&o<=55203){const t=L(s);i.push(...t),e.push({start:r,end:i.length,isHangul:!0})}else i.push(s),e.push({start:r,end:i.length,isHangul:!1})}return{units:i,charUnitRanges:e}}class k{constructor(t,i){if(this.container="string"==typeof t?document.querySelector(t):t,!this.container)throw new Error("Container element not found");this.originalText=i.text,this.config={text:i.text,speed:i.speed??50,delay:i.delay??0,enabled:i.enabled??!0,threshold:i.threshold??.2,rootMargin:i.rootMargin??"0px 0px -100px 0px",triggerOnce:i.triggerOnce??!1,showCursor:i.showCursor??!0,cursorChar:i.cursorChar??"|",onUpdate:i.onUpdate||null,onComplete:i.onComplete||null};const e=N(this.config.text);this.textUnits=e.units,this.charUnitRanges=e.charUnitRanges,this.currentIndex=0,this.displayedText="",this.timeoutId=null,this.visibilityManager=null,this.isRunning=!1,this.hasTriggered=!1,this.init()}init(){this.updateDisplay(""),this.injectStyles(),this.setupVisibilityManager()}injectStyles(){if(document.getElementById("masoneffect-typing-styles"))return;const t=document.createElement("style");t.id="masoneffect-typing-styles",t.textContent="\n .typing-char {\n transition: opacity 0.3s ease-in;\n display: inline-block;\n }\n .typing-cursor {\n display: inline-block;\n }\n ",document.head.appendChild(t),this.container.style.whiteSpace="pre-wrap"}setupVisibilityManager(){this.visibilityManager=new F(this.container,{threshold:this.config.threshold,rootMargin:this.config.rootMargin,onVisible:()=>{!this.hasTriggered&&this.config.enabled&&(this.hasTriggered=!0,setTimeout(()=>this.start(),this.config.delay))},onHidden:()=>{}})}buildTextFromUnits(t){if(0===t)return"";let i="";for(let e=0;e<this.charUnitRanges.length;e++){const n=this.charUnitRanges[e];if(n.start>=t)break;const s=Math.min(t-n.start,n.end-n.start);if(s<=0)break;if(n.isHangul){const t=this.textUnits.slice(n.start,n.start+s);1===t.length?i+=t[0]:2===t.length?i+=W(t[0],t[1]):t.length>=3&&(i+=W(t[0],t[1],t[2]))}else s>0&&(i+=this.textUnits[n.start])}return i}start(){this.isRunning||(this.isRunning=!0,this.currentIndex=0,this.displayedText="",this.typeNext())}typeNext(){if(this.currentIndex>=this.textUnits.length)return this.isRunning=!1,this.config.showCursor&&this.updateDisplay(this.originalText),void(this.config.onComplete&&this.config.onComplete());this.displayedText=this.buildTextFromUnits(this.currentIndex+1);let t=this.displayedText;this.config.showCursor&&(t+=this.config.cursorChar),this.updateDisplay(t),this.config.onUpdate&&this.config.onUpdate(this.displayedText),this.currentIndex++,this.timeoutId=setTimeout(()=>{this.typeNext()},this.config.speed)}stop(){this.isRunning=!1,this.timeoutId&&(clearTimeout(this.timeoutId),this.timeoutId=null)}reset(){this.stop(),this.currentIndex=0,this.displayedText="",this.hasTriggered=!1,this.updateDisplay("")}updateDisplay(t){const i=t.replace(new RegExp(this.escapeHtml(this.config.cursorChar)+"$"),""),e=t.endsWith(this.config.cursorChar),n=(this.container.textContent||"").replace(new RegExp(this.config.cursorChar+"$"),"");let s="";for(let r=0;r<i.length;r++){const t=i[r],e=r>=n.length,o=" "===t?" ":this.escapeHtml(t);s+=e?`<span class="typing-char typing-fade-in" style="opacity: 0;">${o}</span>`:`<span class="typing-char" style="opacity: 1;">${o}</span>`}e&&(s+=`<span class="typing-cursor">${this.escapeHtml(this.config.cursorChar)}</span>`),this.container.innerHTML=s;const o=this.container.querySelectorAll(".typing-fade-in");o.length>0&&requestAnimationFrame(()=>{o.forEach(t=>{t.style.opacity="1",t.classList.remove("typing-fade-in")})})}escapeHtml(t){const i=document.createElement("div");return i.textContent=t,i.innerHTML}setText(t){this.originalText=t,this.config.text=t;const i=N(t);this.textUnits=i.units,this.charUnitRanges=i.charUnitRanges,this.reset(),this.config.enabled&&setTimeout(()=>this.start(),this.config.delay)}destroy(){this.stop(),this.visibilityManager&&(this.visibilityManager.destroy(),this.visibilityManager=null)}}const A=t=>--t*t*t+1;class q{constructor(t,i={}){if(this.container="string"==typeof t?document.querySelector(t):t,!this.container)throw new Error("Container element not found");this.config={direction:i.direction??"bottom",distance:i.distance??"50px",duration:i.duration??800,threshold:i.threshold??.1,rootMargin:i.rootMargin??"0px",root:i.root??null,triggerOnce:i.triggerOnce??!1,enabled:i.enabled??!0,onStart:i.onStart||null,onComplete:i.onComplete||null},this.easing=A,this.visibilityManager=null,this.animationFrameId=null,this.startTime=null,this.isRunning=!1,this.hasTriggered=!1,this.initialTransform="",this.targetDistance=0,this.init()}init(){const t=window.getComputedStyle(this.container);this.initialTransform="none"!==t.transform?t.transform:this.container.style.transform||"",this.targetDistance=this.parseDistance(this.config.distance),this.setInitialPosition(),this.setupVisibilityManager()}parseDistance(t){const i=t.match(/^(-?\d+\.?\d*)(px|rem|em|%|vh|vw)$/);if(!i){return parseFloat(t)||50}const e=parseFloat(i[1]);switch(i[2]){case"px":default:return e;case"rem":case"em":return e*(parseFloat(getComputedStyle(document.documentElement).fontSize)||16);case"%":const t=this.container.getBoundingClientRect();return e/100*("top"===this.config.direction||"bottom"===this.config.direction?t.height:t.width);case"vh":return e/100*window.innerHeight;case"vw":return e/100*window.innerWidth}}setInitialPosition(){let t=0,i=0;switch(this.config.direction){case"top":i=-this.targetDistance;break;case"right":t=this.targetDistance;break;case"bottom":i=this.targetDistance;break;case"left":t=-this.targetDistance}const e=this.initialTransform||"",n=`translate(${t}px, ${i}px)`;this.container.style.transform=e&&"none"!==e?`${n} ${e}`:n,this.container.style.opacity="0",this.container.style.transition="none"}setupVisibilityManager(){this.visibilityManager=new F(this.container,{threshold:this.config.threshold,rootMargin:this.config.rootMargin,root:this.config.root,onVisible:()=>{this.config.enabled&&(this.config.triggerOnce&&this.hasTriggered||(this.hasTriggered=!0,this.start()))},onHidden:()=>{this.config.enabled&&(this.stop(),this.config.triggerOnce||(this.hasTriggered=!1),this.setInitialPosition())}})}start(){this.isRunning||(this.isRunning=!0,this.startTime=performance.now(),this.config.onStart&&this.config.onStart(),this.container.style.transition="none",this.animate())}animate(){if(!this.isRunning)return;const t=performance.now()-(this.startTime||0),i=Math.min(t/this.config.duration,1),e=this.easing(i);let n=0,s=0;switch(this.config.direction){case"top":s=-this.targetDistance*(1-e);break;case"right":n=this.targetDistance*(1-e);break;case"bottom":s=this.targetDistance*(1-e);break;case"left":n=-this.targetDistance*(1-e)}const o=this.initialTransform||"",r=`translate(${n}px, ${s}px)`;this.container.style.transform=o&&"none"!==o?`${r} ${o}`:r,this.container.style.opacity=String(e),i<1?this.animationFrameId=requestAnimationFrame(()=>this.animate()):this.complete()}complete(){this.isRunning=!1,this.initialTransform&&"none"!==this.initialTransform?this.container.style.transform=this.initialTransform:this.container.style.transform="",this.container.style.opacity="1",this.animationFrameId&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null),this.config.onComplete&&this.config.onComplete()}reset(){this.stop(),this.hasTriggered=!1,this.setInitialPosition()}stop(){this.isRunning=!1,this.animationFrameId&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null)}updateConfig(t){const i=this.isRunning;this.stop(),this.config={...this.config,...t,onStart:t.onStart??this.config.onStart,onComplete:t.onComplete??this.config.onComplete},t.distance&&(this.targetDistance=this.parseDistance(this.config.distance)),this.setInitialPosition(),void 0===t.threshold&&void 0===t.rootMargin&&void 0===t.root||(this.visibilityManager&&(this.visibilityManager.destroy(),this.visibilityManager=null),this.setupVisibilityManager()),i&&this.config.enabled&&this.start()}destroy(){this.stop(),this.visibilityManager&&(this.visibilityManager.destroy(),this.visibilityManager=null),this.container.style.transform=this.initialTransform||"",this.container.style.opacity="",this.container.style.transition=""}}function j(t){let i;return{c(){i=g("div"),f(i,"class",t[0]),f(i,"style",t[1])},m(e,n){u(e,i,n),t[21](i)},p(t,[e]){1&e&&f(i,"class",t[0]),2&e&&f(i,"style",t[1])},i:n,o:n,d(e){e&&d(i),t[21](null)}}}function X(t,i,n){let{text:s="mason effect"}=i,{densityStep:o=2}=i,{maxParticles:r=3200}=i,{pointSize:a=.5}=i,{ease:h=.05}=i,{repelRadius:l=150}=i,{repelStrength:c=1}=i,{particleColor:u="#fff"}=i,{fontFamily:d="Inter, system-ui, Arial"}=i,{fontSize:g=null}=i,{width:f=null}=i,{height:p=null}=i,{devicePixelRatio:m=null}=i,{className:y=""}=i,{style:b={}}=i;const v=e.createEventDispatcher();let M,$=null;return e.onMount(()=>{if(!M)return;n(20,$=new U(M,{text:s,densityStep:o,maxParticles:r,pointSize:a,ease:h,repelRadius:l,repelStrength:c,particleColor:u,fontFamily:d,fontSize:g,width:f,height:p,devicePixelRatio:m,onReady:t=>{v("ready",t)},onUpdate:t=>{v("update",t)}}))}),e.onDestroy(()=>{$&&($.destroy(),n(20,$=null))}),t.$$set=t=>{"text"in t&&n(3,s=t.text),"densityStep"in t&&n(4,o=t.densityStep),"maxParticles"in t&&n(5,r=t.maxParticles),"pointSize"in t&&n(6,a=t.pointSize),"ease"in t&&n(7,h=t.ease),"repelRadius"in t&&n(8,l=t.repelRadius),"repelStrength"in t&&n(9,c=t.repelStrength),"particleColor"in t&&n(10,u=t.particleColor),"fontFamily"in t&&n(11,d=t.fontFamily),"fontSize"in t&&n(12,g=t.fontSize),"width"in t&&n(13,f=t.width),"height"in t&&n(14,p=t.height),"devicePixelRatio"in t&&n(15,m=t.devicePixelRatio),"className"in t&&n(0,y=t.className),"style"in t&&n(1,b=t.style)},t.$$.update=()=>{1114104&t.$$.dirty&&$&&$.updateConfig({text:s,densityStep:o,maxParticles:r,pointSize:a,ease:h,repelRadius:l,repelStrength:c,particleColor:u,fontFamily:d,fontSize:g,width:f,height:p,devicePixelRatio:m})},[y,b,M,s,o,r,a,h,l,c,u,d,g,f,p,m,function(t){$&&$.morph(t)},function(){$&&$.scatter()},function(t){$&&$.updateConfig(t)},function(){$&&($.destroy(),n(20,$=null))},$,function(t){x[t?"unshift":"push"](()=>{M=t,n(2,M)})}]}class Y extends O{constructor(t){super(),H(this,t,X,j,h,{text:3,densityStep:4,maxParticles:5,pointSize:6,ease:7,repelRadius:8,repelStrength:9,particleColor:10,fontFamily:11,fontSize:12,width:13,height:14,devicePixelRatio:15,className:0,style:1,morph:16,scatter:17,updateConfig:18,destroy:19})}get morph(){return this.$$.ctx[16]}get scatter(){return this.$$.ctx[17]}get updateConfig(){return this.$$.ctx[18]}get destroy(){return this.$$.ctx[19]}}function B(t){let i;return{c(){i=g("div"),f(i,"class",t[0]),f(i,"style",t[1])},m(e,n){u(e,i,n),t[18](i)},p(t,[e]){1&e&&f(i,"class",t[0]),2&e&&f(i,"style",t[1])},i:n,o:n,d(e){e&&d(i),t[18](null)}}}function G(t,i,n){let{targetValue:s=0}=i,{duration:o=2e3}=i,{startValue:r=0}=i,{enabled:a=!0}=i,{easing:h=t=>t}=i,{threshold:l=.2}=i,{rootMargin:c="0px 0px -100px 0px"}=i,{triggerOnce:u=!1}=i,{className:d=""}=i,{style:g={}}=i;const f=e.createEventDispatcher();let p,m=null;return e.onMount(()=>{if(!p)return;n(17,m=new z(p,{targetValue:s,duration:o,startValue:r,enabled:a,easing:h,threshold:l,rootMargin:c,triggerOnce:u,onUpdate:t=>{f("update",t)},onComplete:()=>{f("complete")}}))}),e.onDestroy(()=>{m&&(m.destroy(),n(17,m=null))}),t.$$set=t=>{"targetValue"in t&&n(3,s=t.targetValue),"duration"in t&&n(4,o=t.duration),"startValue"in t&&n(5,r=t.startValue),"enabled"in t&&n(6,a=t.enabled),"easing"in t&&n(7,h=t.easing),"threshold"in t&&n(8,l=t.threshold),"rootMargin"in t&&n(9,c=t.rootMargin),"triggerOnce"in t&&n(10,u=t.triggerOnce),"className"in t&&n(0,d=t.className),"style"in t&&n(1,g=t.style)},t.$$.update=()=>{133112&t.$$.dirty&&m&&m.updateConfig({targetValue:s,duration:o,startValue:r,enabled:a,easing:h,threshold:l,rootMargin:c,triggerOnce:u,onUpdate:t=>{f("update",t)},onComplete:()=>{f("complete")}})},[d,g,p,s,o,r,a,h,l,c,u,function(){m&&m.start()},function(){m&&m.stop()},function(){m&&m.reset()},function(){return m?m.getValue():0},function(t){m&&m.updateConfig(t)},function(){m&&(m.destroy(),n(17,m=null))},m,function(t){x[t?"unshift":"push"](()=>{p=t,n(2,p)})}]}function J(t){let i;return{c(){i=g("div"),f(i,"class",t[1]),f(i,"style",t[2])},m(e,n){u(e,i,n),t[8](i)},p:n,i:n,o:n,d(e){e&&d(i),t[8](null)}}}function K(t,i,n){let s,o;l(t,effect,t=>n(10,s=t)),l(t,props,t=>n(11,o=t));let{text:r,speed:a=50,delay:h=0,enabled:c=!0,threshold:u=.2,rootMargin:d="0px 0px -100px 0px",triggerOnce:g=!1,showCursor:f=!0,cursorChar:p="|",className:m="",style:y="",onUpdate:b,onComplete:v}=o(),M=null,$=null;return e.onMount(()=>{if(!M)return;$=new k(M,{text:r,speed:a,delay:h,enabled:c,threshold:u,rootMargin:d,triggerOnce:g,showCursor:f,cursorChar:p,onUpdate:b,onComplete:v})}),e.onDestroy(()=>{$&&($.destroy(),$=null)}),s(()=>{$&&r!==$.originalText&&$.setText(r)}),[M,m,y,function(){null==$||$.start()},function(){null==$||$.stop()},function(){null==$||$.reset()},function(t){null==$||$.setText(t)},function(){$&&($.destroy(),$=null)},function(t){x[t?"unshift":"push"](()=>{M=t,n(0,M)})}]}function Q(t){let i,e;const n=t[18].default,s=function(t,i,e,n){if(t){const s=c(t,i,e,n);return t[0](s)}}(n,t,t[17],null);return{c(){i=g("div"),s&&s.c(),f(i,"class",t[0]),f(i,"style",t[1])},m(n,o){u(n,i,o),s&&s.m(i,null),t[19](i),e=!0},p(t,[o]){var r,a;s&&s.p&&(!e||131072&o)&&function(t,i,e,n,s,o){if(s){const r=c(i,e,n,o);t.p(r,s)}}(s,n,t,t[17],e?(r=n,a=t[17],r[2],a.dirty):function(t){if(t.ctx.length>32){const i=[],e=t.ctx.length/32;for(let t=0;t<e;t++)i[t]=-1;return i}return-1}(t[17]),null),(!e||1&o)&&f(i,"class",t[0]),(!e||2&o)&&f(i,"style",t[1])},i(t){e||(P(s,t),e=!0)},o(t){!function(t,i){if(t&&t.o){if(S.has(t))return;S.add(t),(void 0).c.push(()=>{S.delete(t)}),t.o(i)}}(s,t),e=!1},d(e){e&&d(i),s&&s.d(e),t[19](null)}}}function Z(t,i,n){let{$$slots:s={},$$scope:o}=i,{direction:r="bottom"}=i,{distance:a="50px"}=i,{duration:h=800}=i,{threshold:l=.1}=i,{rootMargin:c="0px"}=i,{root:u=null}=i,{triggerOnce:d=!1}=i,{enabled:g=!0}=i,{className:f=""}=i,{style:p={}}=i;const m=e.createEventDispatcher();let y,b=null;return e.onMount(()=>{if(!y)return;n(16,b=new q(y,{direction:r,distance:a,duration:h,threshold:l,rootMargin:c,root:u,triggerOnce:d,enabled:g,onStart:()=>{m("start")},onComplete:()=>{m("complete")}}))}),e.onDestroy(()=>{b&&(b.destroy(),n(16,b=null))}),t.$$set=t=>{"direction"in t&&n(3,r=t.direction),"distance"in t&&n(4,a=t.distance),"duration"in t&&n(5,h=t.duration),"threshold"in t&&n(6,l=t.threshold),"rootMargin"in t&&n(7,c=t.rootMargin),"root"in t&&n(8,u=t.root),"triggerOnce"in t&&n(9,d=t.triggerOnce),"enabled"in t&&n(10,g=t.enabled),"className"in t&&n(0,f=t.className),"style"in t&&n(1,p=t.style),"$$scope"in t&&n(17,o=t.$$scope)},t.$$.update=()=>{67576&t.$$.dirty&&b&&b.updateConfig({direction:r,distance:a,duration:h,threshold:l,rootMargin:c,root:u,triggerOnce:d,enabled:g,onStart:()=>{m("start")},onComplete:()=>{m("complete")}})},[f,p,y,r,a,h,l,c,u,d,g,function(){b&&b.start()},function(){b&&b.stop()},function(){b&&b.reset()},function(t){b&&b.updateConfig(t)},function(){b&&(b.destroy(),n(16,b=null))},b,o,s,function(t){x[t?"unshift":"push"](()=>{y=t,n(2,y)})}]}exports.Count=class extends O{constructor(t){super(),H(this,t,G,B,h,{targetValue:3,duration:4,startValue:5,enabled:6,easing:7,threshold:8,rootMargin:9,triggerOnce:10,className:0,style:1,start:11,stop:12,reset:13,getValue:14,updateConfig:15,destroy:16})}get start(){return this.$$.ctx[11]}get stop(){return this.$$.ctx[12]}get reset(){return this.$$.ctx[13]}get getValue(){return this.$$.ctx[14]}get updateConfig(){return this.$$.ctx[15]}get destroy(){return this.$$.ctx[16]}},exports.MasonEffect=Y,exports.ScrollFadeIn=class extends O{constructor(t){super(),H(this,t,Z,Q,h,{direction:3,distance:4,duration:5,threshold:6,rootMargin:7,root:8,triggerOnce:9,enabled:10,className:0,style:1,start:11,stop:12,reset:13,updateConfig:14,destroy:15})}get start(){return this.$$.ctx[11]}get stop(){return this.$$.ctx[12]}get reset(){return this.$$.ctx[13]}get updateConfig(){return this.$$.ctx[14]}get destroy(){return this.$$.ctx[15]}},exports.TextToParticle=Y,exports.Typing=class extends O{constructor(t){super(),H(this,t,K,J,h,{start:3,stop:4,reset:5,setText:6,destroy:7})}get start(){return this.$$.ctx[3]}get stop(){return this.$$.ctx[4]}get reset(){return this.$$.ctx[5]}get setText(){return this.$$.ctx[6]}get destroy(){return this.$$.ctx[7]}},exports.default=Y;
|
package/dist/svelte/index.mjs
CHANGED
|
@@ -1080,7 +1080,7 @@ class Typing {
|
|
|
1080
1080
|
style.id = "masoneffect-typing-styles";
|
|
1081
1081
|
style.textContent = `
|
|
1082
1082
|
.typing-char {
|
|
1083
|
-
transition: opacity 0.
|
|
1083
|
+
transition: opacity 0.3s ease-in;
|
|
1084
1084
|
display: inline-block;
|
|
1085
1085
|
}
|
|
1086
1086
|
.typing-cursor {
|
|
@@ -1088,6 +1088,7 @@ class Typing {
|
|
|
1088
1088
|
}
|
|
1089
1089
|
`;
|
|
1090
1090
|
document.head.appendChild(style);
|
|
1091
|
+
this.container.style.whiteSpace = "pre-wrap";
|
|
1091
1092
|
}
|
|
1092
1093
|
setupVisibilityManager() {
|
|
1093
1094
|
this.visibilityManager = new VisibilityManager(this.container, {
|
|
@@ -1189,10 +1190,11 @@ class Typing {
|
|
|
1189
1190
|
for (let i = 0; i < textWithoutCursor.length; i++) {
|
|
1190
1191
|
const char = textWithoutCursor[i];
|
|
1191
1192
|
const isNewChar = i >= previousTextWithoutCursor.length;
|
|
1193
|
+
const displayChar = char === " " ? " " : this.escapeHtml(char);
|
|
1192
1194
|
if (isNewChar) {
|
|
1193
|
-
html += `<span class="typing-char typing-fade-in" style="opacity: 0;">${
|
|
1195
|
+
html += `<span class="typing-char typing-fade-in" style="opacity: 0;">${displayChar}</span>`;
|
|
1194
1196
|
} else {
|
|
1195
|
-
html += `<span class="typing-char" style="opacity: 1;">${
|
|
1197
|
+
html += `<span class="typing-char" style="opacity: 1;">${displayChar}</span>`;
|
|
1196
1198
|
}
|
|
1197
1199
|
}
|
|
1198
1200
|
if (hasCursor) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var t=Object.defineProperty,e=(e,i,n)=>((e,i,n)=>i in e?t(e,i,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[i]=n)(e,"symbol"!=typeof i?i+"":i,n);const i=require("svelte");function n(){}function s(t){return t()}function o(){return Object.create(null)}function r(t){t.forEach(s)}function h(t){return"function"==typeof t}function l(t,e){return t!=t?e==e:t!==e||t&&"object"==typeof t||"function"==typeof t}function a(t,e,i){t.$$.on_destroy.push(function(t,...e){if(null==t){for(const t of e)t(void 0);return n}const i=t.subscribe(...e);return i.unsubscribe?()=>i.unsubscribe():i}(e,i))}function c(t){t.parentNode&&t.parentNode.removeChild(t)}function u(t,e,i){null==i?t.removeAttribute(e):t.getAttribute(e)!==i&&t.setAttribute(e,i)}let d;function p(t){d=t}const g=[],f=[];let y=[];const b=[],m=Promise.resolve();let x=!1;function $(t){y.push(t)}const v=new Set;let C=0;function w(){if(0!==C)return;const t=d;do{try{for(;C<g.length;){const t=g[C];C++,p(t),V(t.$$)}}catch(e){throw g.length=0,C=0,e}for(p(null),g.length=0,C=0;f.length;)f.pop()();for(let t=0;t<y.length;t+=1){const e=y[t];v.has(e)||(v.add(e),e())}y.length=0}while(g.length);for(;b.length;)b.pop()();x=!1,v.clear(),p(t)}function V(t){if(null!==t.fragment){t.update(),r(t.before_update);const e=t.dirty;t.dirty=[-1],t.fragment&&t.fragment.p(t.ctx,e),t.after_update.forEach($)}}const O=new Set;function T(t,e){const i=t.$$;null!==i.fragment&&(!function(t){const e=[],i=[];y.forEach(n=>-1===t.indexOf(n)?e.push(n):i.push(n)),i.forEach(t=>t()),y=e}(i.after_update),r(i.on_destroy),i.fragment&&i.fragment.d(e),i.on_destroy=i.fragment=null,i.ctx=[])}function _(t,e){-1===t.$$.dirty[0]&&(g.push(t),x||(x=!0,m.then(w)),t.$$.dirty.fill(0)),t.$$.dirty[e/31|0]|=1<<e%31}function H(t,e,i,l,a,u,g=null,f=[-1]){const y=d;p(t);const b=t.$$={fragment:null,ctx:[],props:u,update:n,not_equal:a,bound:o(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(e.context||(y?y.$$.context:[])),callbacks:o(),dirty:f,skip_bound:!1,root:e.target||y.$$.root};g&&g(b.root);let m=!1;if(b.ctx=i?i(t,e.props||{},(e,i,...n)=>{const s=n.length?n[0]:i;return b.ctx&&a(b.ctx[e],b.ctx[e]=s)&&(!b.skip_bound&&b.bound[e]&&b.bound[e](s),m&&_(t,e)),i}):[],b.update(),m=!0,r(b.before_update),b.fragment=!!l&&l(b.ctx),e.target){if(e.hydrate){const t=(C=e.target,Array.from(C.childNodes));b.fragment&&b.fragment.l(t),t.forEach(c)}else b.fragment&&b.fragment.c();e.intro&&((x=t.$$.fragment)&&x.i&&(O.delete(x),x.i(v))),function(t,e,i){const{fragment:n,after_update:o}=t.$$;n&&n.m(e,i),$(()=>{const e=t.$$.on_mount.map(s).filter(h);t.$$.on_destroy?t.$$.on_destroy.push(...e):r(e),t.$$.on_mount=[]}),o.forEach($)}(t,e.target,e.anchor),w()}var x,v,C;p(y)}class M{constructor(){e(this,"$$"),e(this,"$$set")}$destroy(){T(this,1),this.$destroy=n}$on(t,e){if(!h(e))return n;const i=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return i.push(e),()=>{const t=i.indexOf(e);-1!==t&&i.splice(t,1)}}$set(t){var e;this.$$set&&(e=t,0!==Object.keys(e).length)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}}"undefined"!=typeof window&&(window.__svelte||(window.__svelte={v:new Set})).v.add("4");class U{constructor(t,e={}){this.container=t,this.options={threshold:e.threshold??.1,rootMargin:e.rootMargin??"0px",root:e.root??null,onVisible:e.onVisible,onHidden:e.onHidden},this.intersectionObserver=null,this.visibilityChangeHandler=null,this.isVisible=!1,this.isPageVisible="undefined"==typeof document||!document.hidden,this.setupIntersectionObserver(),this.setupPageVisibility()}setupIntersectionObserver(){if("undefined"==typeof window||void 0===window.IntersectionObserver)return this.isVisible=!0,void(this.isPageVisible&&this.options.onVisible&&this.options.onVisible());this.intersectionObserver=new IntersectionObserver(t=>{for(const e of t)e.target===this.container&&(e.isIntersecting?(this.isVisible=!0,this.isPageVisible&&this.options.onVisible&&this.options.onVisible()):(this.isVisible=!1,this.options.onHidden&&this.options.onHidden()))},{threshold:this.options.threshold,rootMargin:this.options.rootMargin,root:this.options.root||null}),this.intersectionObserver.observe(this.container)}setupPageVisibility(){"undefined"!=typeof document&&(this.visibilityChangeHandler=()=>{const t=this.isPageVisible;this.isPageVisible=!document.hidden,document.hidden?this.options.onHidden&&this.options.onHidden():t!==this.isPageVisible&&this.isVisible&&this.options.onVisible&&this.options.onVisible()},document.addEventListener("visibilitychange",this.visibilityChangeHandler),document.hidden&&this.isVisible&&this.options.onHidden&&this.options.onHidden())}getIsVisible(){return this.isVisible&&this.isPageVisible}updateOptions(t){this.options={...this.options,...t},this.intersectionObserver&&(this.intersectionObserver.disconnect(),this.intersectionObserver=null),this.setupIntersectionObserver()}destroy(){this.intersectionObserver&&(this.intersectionObserver.disconnect(),this.intersectionObserver=null),this.visibilityChangeHandler&&"undefined"!=typeof document&&(document.removeEventListener("visibilitychange",this.visibilityChangeHandler),this.visibilityChangeHandler=null)}}function I(t){const e=t.charCodeAt(0);if(e<44032||e>55203)return[t];const i=e-44032,n=Math.floor(i/588),s=Math.floor(i%588/28),o=i%28,r=["","ㄱ","ㄲ","ㄳ","ㄴ","ㄵ","ㄶ","ㄷ","ㄹ","ㄺ","ㄻ","ㄼ","ㄽ","ㄾ","ㄿ","ㅀ","ㅁ","ㅂ","ㅄ","ㅅ","ㅆ","ㅇ","ㅈ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"],h=[];return h.push(["ㄱ","ㄲ","ㄴ","ㄷ","ㄸ","ㄹ","ㅁ","ㅂ","ㅃ","ㅅ","ㅆ","ㅇ","ㅈ","ㅉ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"][n]),h.push(["ㅏ","ㅐ","ㅑ","ㅒ","ㅓ","ㅔ","ㅕ","ㅖ","ㅗ","ㅘ","ㅙ","ㅚ","ㅛ","ㅜ","ㅝ","ㅞ","ㅟ","ㅠ","ㅡ","ㅢ","ㅣ"][s]),o>0&&h.push(r[o]),h}function E(t,e,i){const n=["ㄱ","ㄲ","ㄴ","ㄷ","ㄸ","ㄹ","ㅁ","ㅂ","ㅃ","ㅅ","ㅆ","ㅇ","ㅈ","ㅉ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"].indexOf(t),s=["ㅏ","ㅐ","ㅑ","ㅒ","ㅓ","ㅔ","ㅕ","ㅖ","ㅗ","ㅘ","ㅙ","ㅚ","ㅛ","ㅜ","ㅝ","ㅞ","ㅟ","ㅠ","ㅡ","ㅢ","ㅣ"].indexOf(e),o=i?["","ㄱ","ㄲ","ㄳ","ㄴ","ㄵ","ㄶ","ㄷ","ㄹ","ㄺ","ㄻ","ㄼ","ㄽ","ㄾ","ㄿ","ㅀ","ㅁ","ㅂ","ㅄ","ㅅ","ㅆ","ㅇ","ㅈ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"].indexOf(i):0;if(-1===n||-1===s)return t+(e||"")+(i||"");const r=44032+21*n*28+28*s+o;return String.fromCharCode(r)}function R(t){const e=[],i=[];for(let n=0;n<t.length;n++){const s=t[n],o=s.charCodeAt(0),r=e.length;if(o>=44032&&o<=55203){const t=I(s);e.push(...t),i.push({start:r,end:e.length,isHangul:!0})}else e.push(s),i.push({start:r,end:e.length,isHangul:!1})}return{units:e,charUnitRanges:i}}class k{constructor(t,e){if(this.container="string"==typeof t?document.querySelector(t):t,!this.container)throw new Error("Container element not found");this.originalText=e.text,this.config={text:e.text,speed:e.speed??50,delay:e.delay??0,enabled:e.enabled??!0,threshold:e.threshold??.2,rootMargin:e.rootMargin??"0px 0px -100px 0px",triggerOnce:e.triggerOnce??!1,showCursor:e.showCursor??!0,cursorChar:e.cursorChar??"|",onUpdate:e.onUpdate||null,onComplete:e.onComplete||null};const i=R(this.config.text);this.textUnits=i.units,this.charUnitRanges=i.charUnitRanges,this.currentIndex=0,this.displayedText="",this.timeoutId=null,this.visibilityManager=null,this.isRunning=!1,this.hasTriggered=!1,this.init()}init(){this.updateDisplay(""),this.injectStyles(),this.setupVisibilityManager()}injectStyles(){if(document.getElementById("masoneffect-typing-styles"))return;const t=document.createElement("style");t.id="masoneffect-typing-styles",t.textContent="\n .typing-char {\n transition: opacity 0.2s ease-in;\n display: inline-block;\n }\n .typing-cursor {\n display: inline-block;\n }\n ",document.head.appendChild(t)}setupVisibilityManager(){this.visibilityManager=new U(this.container,{threshold:this.config.threshold,rootMargin:this.config.rootMargin,onVisible:()=>{!this.hasTriggered&&this.config.enabled&&(this.hasTriggered=!0,setTimeout(()=>this.start(),this.config.delay))},onHidden:()=>{}})}buildTextFromUnits(t){if(0===t)return"";let e="";for(let i=0;i<this.charUnitRanges.length;i++){const n=this.charUnitRanges[i];if(n.start>=t)break;const s=Math.min(t-n.start,n.end-n.start);if(s<=0)break;if(n.isHangul){const t=this.textUnits.slice(n.start,n.start+s);1===t.length?e+=t[0]:2===t.length?e+=E(t[0],t[1]):t.length>=3&&(e+=E(t[0],t[1],t[2]))}else s>0&&(e+=this.textUnits[n.start])}return e}start(){this.isRunning||(this.isRunning=!0,this.currentIndex=0,this.displayedText="",this.typeNext())}typeNext(){if(this.currentIndex>=this.textUnits.length)return this.isRunning=!1,this.config.showCursor&&this.updateDisplay(this.originalText),void(this.config.onComplete&&this.config.onComplete());this.displayedText=this.buildTextFromUnits(this.currentIndex+1);let t=this.displayedText;this.config.showCursor&&(t+=this.config.cursorChar),this.updateDisplay(t),this.config.onUpdate&&this.config.onUpdate(this.displayedText),this.currentIndex++,this.timeoutId=setTimeout(()=>{this.typeNext()},this.config.speed)}stop(){this.isRunning=!1,this.timeoutId&&(clearTimeout(this.timeoutId),this.timeoutId=null)}reset(){this.stop(),this.currentIndex=0,this.displayedText="",this.hasTriggered=!1,this.updateDisplay("")}updateDisplay(t){const e=t.replace(new RegExp(this.escapeHtml(this.config.cursorChar)+"$"),""),i=t.endsWith(this.config.cursorChar),n=(this.container.textContent||"").replace(new RegExp(this.config.cursorChar+"$"),"");let s="";for(let r=0;r<e.length;r++){const t=e[r];s+=r>=n.length?`<span class="typing-char typing-fade-in" style="opacity: 0;">${this.escapeHtml(t)}</span>`:`<span class="typing-char" style="opacity: 1;">${this.escapeHtml(t)}</span>`}i&&(s+=`<span class="typing-cursor">${this.escapeHtml(this.config.cursorChar)}</span>`),this.container.innerHTML=s;const o=this.container.querySelectorAll(".typing-fade-in");o.length>0&&requestAnimationFrame(()=>{o.forEach(t=>{t.style.opacity="1",t.classList.remove("typing-fade-in")})})}escapeHtml(t){const e=document.createElement("div");return e.textContent=t,e.innerHTML}setText(t){this.originalText=t,this.config.text=t;const e=R(t);this.textUnits=e.units,this.charUnitRanges=e.charUnitRanges,this.reset(),this.config.enabled&&setTimeout(()=>this.start(),this.config.delay)}destroy(){this.stop(),this.visibilityManager&&(this.visibilityManager.destroy(),this.visibilityManager=null)}}function P(t){let e;return{c(){var i;i="div",e=document.createElement(i),u(e,"class",t[1]),u(e,"style",t[2])},m(i,n){!function(t,e,i){t.insertBefore(e,i||null)}(i,e,n),t[8](e)},p:n,i:n,o:n,d(i){i&&c(e),t[8](null)}}}function A(t,e,n){let s,o;a(t,effect,t=>n(10,s=t)),a(t,props,t=>n(11,o=t));let{text:r,speed:h=50,delay:l=0,enabled:c=!0,threshold:u=.2,rootMargin:d="0px 0px -100px 0px",triggerOnce:p=!1,showCursor:g=!0,cursorChar:y="|",className:b="",style:m="",onUpdate:x,onComplete:$}=o(),v=null,C=null;return i.onMount(()=>{if(!v)return;C=new k(v,{text:r,speed:h,delay:l,enabled:c,threshold:u,rootMargin:d,triggerOnce:p,showCursor:g,cursorChar:y,onUpdate:x,onComplete:$})}),i.onDestroy(()=>{C&&(C.destroy(),C=null)}),s(()=>{C&&r!==C.originalText&&C.setText(r)}),[v,b,m,function(){null==C||C.start()},function(){null==C||C.stop()},function(){null==C||C.reset()},function(t){null==C||C.setText(t)},function(){C&&(C.destroy(),C=null)},function(t){f[t?"unshift":"push"](()=>{v=t,n(0,v)})}]}module.exports=class extends M{constructor(t){super(),H(this,t,A,P,l,{start:3,stop:4,reset:5,setText:6,destroy:7})}get start(){return this.$$.ctx[3]}get stop(){return this.$$.ctx[4]}get reset(){return this.$$.ctx[5]}get setText(){return this.$$.ctx[6]}get destroy(){return this.$$.ctx[7]}};
|
|
1
|
+
"use strict";var t=Object.defineProperty,e=(e,i,n)=>((e,i,n)=>i in e?t(e,i,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[i]=n)(e,"symbol"!=typeof i?i+"":i,n);const i=require("svelte");function n(){}function s(t){return t()}function o(){return Object.create(null)}function r(t){t.forEach(s)}function h(t){return"function"==typeof t}function l(t,e){return t!=t?e==e:t!==e||t&&"object"==typeof t||"function"==typeof t}function a(t,e,i){t.$$.on_destroy.push(function(t,...e){if(null==t){for(const t of e)t(void 0);return n}const i=t.subscribe(...e);return i.unsubscribe?()=>i.unsubscribe():i}(e,i))}function c(t){t.parentNode&&t.parentNode.removeChild(t)}function u(t,e,i){null==i?t.removeAttribute(e):t.getAttribute(e)!==i&&t.setAttribute(e,i)}let d;function p(t){d=t}const g=[],f=[];let y=[];const b=[],m=Promise.resolve();let x=!1;function $(t){y.push(t)}const v=new Set;let C=0;function w(){if(0!==C)return;const t=d;do{try{for(;C<g.length;){const t=g[C];C++,p(t),V(t.$$)}}catch(e){throw g.length=0,C=0,e}for(p(null),g.length=0,C=0;f.length;)f.pop()();for(let t=0;t<y.length;t+=1){const e=y[t];v.has(e)||(v.add(e),e())}y.length=0}while(g.length);for(;b.length;)b.pop()();x=!1,v.clear(),p(t)}function V(t){if(null!==t.fragment){t.update(),r(t.before_update);const e=t.dirty;t.dirty=[-1],t.fragment&&t.fragment.p(t.ctx,e),t.after_update.forEach($)}}const O=new Set;function T(t,e){const i=t.$$;null!==i.fragment&&(!function(t){const e=[],i=[];y.forEach(n=>-1===t.indexOf(n)?e.push(n):i.push(n)),i.forEach(t=>t()),y=e}(i.after_update),r(i.on_destroy),i.fragment&&i.fragment.d(e),i.on_destroy=i.fragment=null,i.ctx=[])}function _(t,e){-1===t.$$.dirty[0]&&(g.push(t),x||(x=!0,m.then(w)),t.$$.dirty.fill(0)),t.$$.dirty[e/31|0]|=1<<e%31}function H(t,e,i,l,a,u,g=null,f=[-1]){const y=d;p(t);const b=t.$$={fragment:null,ctx:[],props:u,update:n,not_equal:a,bound:o(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(e.context||(y?y.$$.context:[])),callbacks:o(),dirty:f,skip_bound:!1,root:e.target||y.$$.root};g&&g(b.root);let m=!1;if(b.ctx=i?i(t,e.props||{},(e,i,...n)=>{const s=n.length?n[0]:i;return b.ctx&&a(b.ctx[e],b.ctx[e]=s)&&(!b.skip_bound&&b.bound[e]&&b.bound[e](s),m&&_(t,e)),i}):[],b.update(),m=!0,r(b.before_update),b.fragment=!!l&&l(b.ctx),e.target){if(e.hydrate){const t=(C=e.target,Array.from(C.childNodes));b.fragment&&b.fragment.l(t),t.forEach(c)}else b.fragment&&b.fragment.c();e.intro&&((x=t.$$.fragment)&&x.i&&(O.delete(x),x.i(v))),function(t,e,i){const{fragment:n,after_update:o}=t.$$;n&&n.m(e,i),$(()=>{const e=t.$$.on_mount.map(s).filter(h);t.$$.on_destroy?t.$$.on_destroy.push(...e):r(e),t.$$.on_mount=[]}),o.forEach($)}(t,e.target,e.anchor),w()}var x,v,C;p(y)}class M{constructor(){e(this,"$$"),e(this,"$$set")}$destroy(){T(this,1),this.$destroy=n}$on(t,e){if(!h(e))return n;const i=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return i.push(e),()=>{const t=i.indexOf(e);-1!==t&&i.splice(t,1)}}$set(t){var e;this.$$set&&(e=t,0!==Object.keys(e).length)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}}"undefined"!=typeof window&&(window.__svelte||(window.__svelte={v:new Set})).v.add("4");class U{constructor(t,e={}){this.container=t,this.options={threshold:e.threshold??.1,rootMargin:e.rootMargin??"0px",root:e.root??null,onVisible:e.onVisible,onHidden:e.onHidden},this.intersectionObserver=null,this.visibilityChangeHandler=null,this.isVisible=!1,this.isPageVisible="undefined"==typeof document||!document.hidden,this.setupIntersectionObserver(),this.setupPageVisibility()}setupIntersectionObserver(){if("undefined"==typeof window||void 0===window.IntersectionObserver)return this.isVisible=!0,void(this.isPageVisible&&this.options.onVisible&&this.options.onVisible());this.intersectionObserver=new IntersectionObserver(t=>{for(const e of t)e.target===this.container&&(e.isIntersecting?(this.isVisible=!0,this.isPageVisible&&this.options.onVisible&&this.options.onVisible()):(this.isVisible=!1,this.options.onHidden&&this.options.onHidden()))},{threshold:this.options.threshold,rootMargin:this.options.rootMargin,root:this.options.root||null}),this.intersectionObserver.observe(this.container)}setupPageVisibility(){"undefined"!=typeof document&&(this.visibilityChangeHandler=()=>{const t=this.isPageVisible;this.isPageVisible=!document.hidden,document.hidden?this.options.onHidden&&this.options.onHidden():t!==this.isPageVisible&&this.isVisible&&this.options.onVisible&&this.options.onVisible()},document.addEventListener("visibilitychange",this.visibilityChangeHandler),document.hidden&&this.isVisible&&this.options.onHidden&&this.options.onHidden())}getIsVisible(){return this.isVisible&&this.isPageVisible}updateOptions(t){this.options={...this.options,...t},this.intersectionObserver&&(this.intersectionObserver.disconnect(),this.intersectionObserver=null),this.setupIntersectionObserver()}destroy(){this.intersectionObserver&&(this.intersectionObserver.disconnect(),this.intersectionObserver=null),this.visibilityChangeHandler&&"undefined"!=typeof document&&(document.removeEventListener("visibilitychange",this.visibilityChangeHandler),this.visibilityChangeHandler=null)}}function I(t){const e=t.charCodeAt(0);if(e<44032||e>55203)return[t];const i=e-44032,n=Math.floor(i/588),s=Math.floor(i%588/28),o=i%28,r=["","ㄱ","ㄲ","ㄳ","ㄴ","ㄵ","ㄶ","ㄷ","ㄹ","ㄺ","ㄻ","ㄼ","ㄽ","ㄾ","ㄿ","ㅀ","ㅁ","ㅂ","ㅄ","ㅅ","ㅆ","ㅇ","ㅈ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"],h=[];return h.push(["ㄱ","ㄲ","ㄴ","ㄷ","ㄸ","ㄹ","ㅁ","ㅂ","ㅃ","ㅅ","ㅆ","ㅇ","ㅈ","ㅉ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"][n]),h.push(["ㅏ","ㅐ","ㅑ","ㅒ","ㅓ","ㅔ","ㅕ","ㅖ","ㅗ","ㅘ","ㅙ","ㅚ","ㅛ","ㅜ","ㅝ","ㅞ","ㅟ","ㅠ","ㅡ","ㅢ","ㅣ"][s]),o>0&&h.push(r[o]),h}function E(t,e,i){const n=["ㄱ","ㄲ","ㄴ","ㄷ","ㄸ","ㄹ","ㅁ","ㅂ","ㅃ","ㅅ","ㅆ","ㅇ","ㅈ","ㅉ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"].indexOf(t),s=["ㅏ","ㅐ","ㅑ","ㅒ","ㅓ","ㅔ","ㅕ","ㅖ","ㅗ","ㅘ","ㅙ","ㅚ","ㅛ","ㅜ","ㅝ","ㅞ","ㅟ","ㅠ","ㅡ","ㅢ","ㅣ"].indexOf(e),o=i?["","ㄱ","ㄲ","ㄳ","ㄴ","ㄵ","ㄶ","ㄷ","ㄹ","ㄺ","ㄻ","ㄼ","ㄽ","ㄾ","ㄿ","ㅀ","ㅁ","ㅂ","ㅄ","ㅅ","ㅆ","ㅇ","ㅈ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"].indexOf(i):0;if(-1===n||-1===s)return t+(e||"")+(i||"");const r=44032+21*n*28+28*s+o;return String.fromCharCode(r)}function R(t){const e=[],i=[];for(let n=0;n<t.length;n++){const s=t[n],o=s.charCodeAt(0),r=e.length;if(o>=44032&&o<=55203){const t=I(s);e.push(...t),i.push({start:r,end:e.length,isHangul:!0})}else e.push(s),i.push({start:r,end:e.length,isHangul:!1})}return{units:e,charUnitRanges:i}}class k{constructor(t,e){if(this.container="string"==typeof t?document.querySelector(t):t,!this.container)throw new Error("Container element not found");this.originalText=e.text,this.config={text:e.text,speed:e.speed??50,delay:e.delay??0,enabled:e.enabled??!0,threshold:e.threshold??.2,rootMargin:e.rootMargin??"0px 0px -100px 0px",triggerOnce:e.triggerOnce??!1,showCursor:e.showCursor??!0,cursorChar:e.cursorChar??"|",onUpdate:e.onUpdate||null,onComplete:e.onComplete||null};const i=R(this.config.text);this.textUnits=i.units,this.charUnitRanges=i.charUnitRanges,this.currentIndex=0,this.displayedText="",this.timeoutId=null,this.visibilityManager=null,this.isRunning=!1,this.hasTriggered=!1,this.init()}init(){this.updateDisplay(""),this.injectStyles(),this.setupVisibilityManager()}injectStyles(){if(document.getElementById("masoneffect-typing-styles"))return;const t=document.createElement("style");t.id="masoneffect-typing-styles",t.textContent="\n .typing-char {\n transition: opacity 0.3s ease-in;\n display: inline-block;\n }\n .typing-cursor {\n display: inline-block;\n }\n ",document.head.appendChild(t),this.container.style.whiteSpace="pre-wrap"}setupVisibilityManager(){this.visibilityManager=new U(this.container,{threshold:this.config.threshold,rootMargin:this.config.rootMargin,onVisible:()=>{!this.hasTriggered&&this.config.enabled&&(this.hasTriggered=!0,setTimeout(()=>this.start(),this.config.delay))},onHidden:()=>{}})}buildTextFromUnits(t){if(0===t)return"";let e="";for(let i=0;i<this.charUnitRanges.length;i++){const n=this.charUnitRanges[i];if(n.start>=t)break;const s=Math.min(t-n.start,n.end-n.start);if(s<=0)break;if(n.isHangul){const t=this.textUnits.slice(n.start,n.start+s);1===t.length?e+=t[0]:2===t.length?e+=E(t[0],t[1]):t.length>=3&&(e+=E(t[0],t[1],t[2]))}else s>0&&(e+=this.textUnits[n.start])}return e}start(){this.isRunning||(this.isRunning=!0,this.currentIndex=0,this.displayedText="",this.typeNext())}typeNext(){if(this.currentIndex>=this.textUnits.length)return this.isRunning=!1,this.config.showCursor&&this.updateDisplay(this.originalText),void(this.config.onComplete&&this.config.onComplete());this.displayedText=this.buildTextFromUnits(this.currentIndex+1);let t=this.displayedText;this.config.showCursor&&(t+=this.config.cursorChar),this.updateDisplay(t),this.config.onUpdate&&this.config.onUpdate(this.displayedText),this.currentIndex++,this.timeoutId=setTimeout(()=>{this.typeNext()},this.config.speed)}stop(){this.isRunning=!1,this.timeoutId&&(clearTimeout(this.timeoutId),this.timeoutId=null)}reset(){this.stop(),this.currentIndex=0,this.displayedText="",this.hasTriggered=!1,this.updateDisplay("")}updateDisplay(t){const e=t.replace(new RegExp(this.escapeHtml(this.config.cursorChar)+"$"),""),i=t.endsWith(this.config.cursorChar),n=(this.container.textContent||"").replace(new RegExp(this.config.cursorChar+"$"),"");let s="";for(let r=0;r<e.length;r++){const t=e[r],i=r>=n.length,o=" "===t?" ":this.escapeHtml(t);s+=i?`<span class="typing-char typing-fade-in" style="opacity: 0;">${o}</span>`:`<span class="typing-char" style="opacity: 1;">${o}</span>`}i&&(s+=`<span class="typing-cursor">${this.escapeHtml(this.config.cursorChar)}</span>`),this.container.innerHTML=s;const o=this.container.querySelectorAll(".typing-fade-in");o.length>0&&requestAnimationFrame(()=>{o.forEach(t=>{t.style.opacity="1",t.classList.remove("typing-fade-in")})})}escapeHtml(t){const e=document.createElement("div");return e.textContent=t,e.innerHTML}setText(t){this.originalText=t,this.config.text=t;const e=R(t);this.textUnits=e.units,this.charUnitRanges=e.charUnitRanges,this.reset(),this.config.enabled&&setTimeout(()=>this.start(),this.config.delay)}destroy(){this.stop(),this.visibilityManager&&(this.visibilityManager.destroy(),this.visibilityManager=null)}}function P(t){let e;return{c(){var i;i="div",e=document.createElement(i),u(e,"class",t[1]),u(e,"style",t[2])},m(i,n){!function(t,e,i){t.insertBefore(e,i||null)}(i,e,n),t[8](e)},p:n,i:n,o:n,d(i){i&&c(e),t[8](null)}}}function S(t,e,n){let s,o;a(t,effect,t=>n(10,s=t)),a(t,props,t=>n(11,o=t));let{text:r,speed:h=50,delay:l=0,enabled:c=!0,threshold:u=.2,rootMargin:d="0px 0px -100px 0px",triggerOnce:p=!1,showCursor:g=!0,cursorChar:y="|",className:b="",style:m="",onUpdate:x,onComplete:$}=o(),v=null,C=null;return i.onMount(()=>{if(!v)return;C=new k(v,{text:r,speed:h,delay:l,enabled:c,threshold:u,rootMargin:d,triggerOnce:p,showCursor:g,cursorChar:y,onUpdate:x,onComplete:$})}),i.onDestroy(()=>{C&&(C.destroy(),C=null)}),s(()=>{C&&r!==C.originalText&&C.setText(r)}),[v,b,m,function(){null==C||C.start()},function(){null==C||C.stop()},function(){null==C||C.reset()},function(t){null==C||C.setText(t)},function(){C&&(C.destroy(),C=null)},function(t){f[t?"unshift":"push"](()=>{v=t,n(0,v)})}]}module.exports=class extends M{constructor(t){super(),H(this,t,S,P,l,{start:3,stop:4,reset:5,setText:6,destroy:7})}get start(){return this.$$.ctx[3]}get stop(){return this.$$.ctx[4]}get reset(){return this.$$.ctx[5]}get setText(){return this.$$.ctx[6]}get destroy(){return this.$$.ctx[7]}};
|
|
@@ -485,7 +485,7 @@ class Typing {
|
|
|
485
485
|
style.id = "masoneffect-typing-styles";
|
|
486
486
|
style.textContent = `
|
|
487
487
|
.typing-char {
|
|
488
|
-
transition: opacity 0.
|
|
488
|
+
transition: opacity 0.3s ease-in;
|
|
489
489
|
display: inline-block;
|
|
490
490
|
}
|
|
491
491
|
.typing-cursor {
|
|
@@ -493,6 +493,7 @@ class Typing {
|
|
|
493
493
|
}
|
|
494
494
|
`;
|
|
495
495
|
document.head.appendChild(style);
|
|
496
|
+
this.container.style.whiteSpace = "pre-wrap";
|
|
496
497
|
}
|
|
497
498
|
setupVisibilityManager() {
|
|
498
499
|
this.visibilityManager = new VisibilityManager(this.container, {
|
|
@@ -594,10 +595,11 @@ class Typing {
|
|
|
594
595
|
for (let i = 0; i < textWithoutCursor.length; i++) {
|
|
595
596
|
const char = textWithoutCursor[i];
|
|
596
597
|
const isNewChar = i >= previousTextWithoutCursor.length;
|
|
598
|
+
const displayChar = char === " " ? " " : this.escapeHtml(char);
|
|
597
599
|
if (isNewChar) {
|
|
598
|
-
html += `<span class="typing-char typing-fade-in" style="opacity: 0;">${
|
|
600
|
+
html += `<span class="typing-char typing-fade-in" style="opacity: 0;">${displayChar}</span>`;
|
|
599
601
|
} else {
|
|
600
|
-
html += `<span class="typing-char" style="opacity: 1;">${
|
|
602
|
+
html += `<span class="typing-char" style="opacity: 1;">${displayChar}</span>`;
|
|
601
603
|
}
|
|
602
604
|
}
|
|
603
605
|
if (hasCursor) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/core/typing/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAElE,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,UAAU,CAAC,EAAE,MAAM,IAAI,CAAC;CACzB;AAyFD,qBAAa,MAAM;IACjB,SAAS,EAAE,WAAW,CAAC;IACvB,MAAM,EAAE,QAAQ,CAAC,IAAI,CAAC,aAAa,EAAE,UAAU,GAAG,YAAY,CAAC,CAAC,GAAG;QACjE,QAAQ,EAAE,aAAa,CAAC,UAAU,CAAC,CAAC;QACpC,UAAU,EAAE,aAAa,CAAC,YAAY,CAAC,CAAC;KACzC,CAAC;IACF,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,cAAc,EAAE,KAAK,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;IACzE,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,UAAU,CAAC,OAAO,UAAU,CAAC,GAAG,IAAI,CAAC;IAChD,iBAAiB,EAAE,iBAAiB,GAAG,IAAI,CAAC;IAC5C,SAAS,EAAE,OAAO,CAAC;IACnB,YAAY,EAAE,OAAO,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;gBAET,SAAS,EAAE,WAAW,GAAG,MAAM,EAAE,OAAO,EAAE,aAAa;IA6CnE,IAAI,IAAI,IAAI;IAWZ,OAAO,CAAC,YAAY;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/core/typing/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAElE,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,UAAU,CAAC,EAAE,MAAM,IAAI,CAAC;CACzB;AAyFD,qBAAa,MAAM;IACjB,SAAS,EAAE,WAAW,CAAC;IACvB,MAAM,EAAE,QAAQ,CAAC,IAAI,CAAC,aAAa,EAAE,UAAU,GAAG,YAAY,CAAC,CAAC,GAAG;QACjE,QAAQ,EAAE,aAAa,CAAC,UAAU,CAAC,CAAC;QACpC,UAAU,EAAE,aAAa,CAAC,YAAY,CAAC,CAAC;KACzC,CAAC;IACF,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,cAAc,EAAE,KAAK,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;IACzE,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,UAAU,CAAC,OAAO,UAAU,CAAC,GAAG,IAAI,CAAC;IAChD,iBAAiB,EAAE,iBAAiB,GAAG,IAAI,CAAC;IAC5C,SAAS,EAAE,OAAO,CAAC;IACnB,YAAY,EAAE,OAAO,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;gBAET,SAAS,EAAE,WAAW,GAAG,MAAM,EAAE,OAAO,EAAE,aAAa;IA6CnE,IAAI,IAAI,IAAI;IAWZ,OAAO,CAAC,YAAY;IAuBpB,sBAAsB,IAAI,IAAI;IAmB9B,OAAO,CAAC,kBAAkB;IAgD1B,KAAK,IAAI,IAAI;IASb,QAAQ,IAAI,IAAI;IAuChB,IAAI,IAAI,IAAI;IAQZ,KAAK,IAAI,IAAI;IAQb,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAiDjC,OAAO,CAAC,UAAU;IAOlB,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAa9B,OAAO,IAAI,IAAI;CAOhB;AAGD,eAAe,MAAM,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/core/typing/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAElE,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,UAAU,CAAC,EAAE,MAAM,IAAI,CAAC;CACzB;AAyFD,qBAAa,MAAM;IACjB,SAAS,EAAE,WAAW,CAAC;IACvB,MAAM,EAAE,QAAQ,CAAC,IAAI,CAAC,aAAa,EAAE,UAAU,GAAG,YAAY,CAAC,CAAC,GAAG;QACjE,QAAQ,EAAE,aAAa,CAAC,UAAU,CAAC,CAAC;QACpC,UAAU,EAAE,aAAa,CAAC,YAAY,CAAC,CAAC;KACzC,CAAC;IACF,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,cAAc,EAAE,KAAK,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;IACzE,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,UAAU,CAAC,OAAO,UAAU,CAAC,GAAG,IAAI,CAAC;IAChD,iBAAiB,EAAE,iBAAiB,GAAG,IAAI,CAAC;IAC5C,SAAS,EAAE,OAAO,CAAC;IACnB,YAAY,EAAE,OAAO,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;gBAET,SAAS,EAAE,WAAW,GAAG,MAAM,EAAE,OAAO,EAAE,aAAa;IA6CnE,IAAI,IAAI,IAAI;IAWZ,OAAO,CAAC,YAAY;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/core/typing/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAElE,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,UAAU,CAAC,EAAE,MAAM,IAAI,CAAC;CACzB;AAyFD,qBAAa,MAAM;IACjB,SAAS,EAAE,WAAW,CAAC;IACvB,MAAM,EAAE,QAAQ,CAAC,IAAI,CAAC,aAAa,EAAE,UAAU,GAAG,YAAY,CAAC,CAAC,GAAG;QACjE,QAAQ,EAAE,aAAa,CAAC,UAAU,CAAC,CAAC;QACpC,UAAU,EAAE,aAAa,CAAC,YAAY,CAAC,CAAC;KACzC,CAAC;IACF,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,cAAc,EAAE,KAAK,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;IACzE,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,UAAU,CAAC,OAAO,UAAU,CAAC,GAAG,IAAI,CAAC;IAChD,iBAAiB,EAAE,iBAAiB,GAAG,IAAI,CAAC;IAC5C,SAAS,EAAE,OAAO,CAAC;IACnB,YAAY,EAAE,OAAO,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;gBAET,SAAS,EAAE,WAAW,GAAG,MAAM,EAAE,OAAO,EAAE,aAAa;IA6CnE,IAAI,IAAI,IAAI;IAWZ,OAAO,CAAC,YAAY;IAuBpB,sBAAsB,IAAI,IAAI;IAmB9B,OAAO,CAAC,kBAAkB;IAgD1B,KAAK,IAAI,IAAI;IASb,QAAQ,IAAI,IAAI;IAuChB,IAAI,IAAI,IAAI;IAQZ,KAAK,IAAI,IAAI;IAQb,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAiDjC,OAAO,CAAC,UAAU;IAOlB,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAa9B,OAAO,IAAI,IAAI;CAOhB;AAGD,eAAe,MAAM,CAAC"}
|
package/dist/typing/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,"t",{value:!0});class t{constructor(t,s={}){this.container=t,this.options={threshold:s.threshold??.1,rootMargin:s.rootMargin??"0px",root:s.root??null,onVisible:s.onVisible,onHidden:s.onHidden},this.intersectionObserver=null,this.visibilityChangeHandler=null,this.isVisible=!1,this.isPageVisible="undefined"==typeof document||!document.hidden,this.setupIntersectionObserver(),this.setupPageVisibility()}setupIntersectionObserver(){if("undefined"==typeof window||void 0===window.IntersectionObserver)return this.isVisible=!0,void(this.isPageVisible&&this.options.onVisible&&this.options.onVisible());this.intersectionObserver=new IntersectionObserver(t=>{for(const s of t)s.target===this.container&&(s.isIntersecting?(this.isVisible=!0,this.isPageVisible&&this.options.onVisible&&this.options.onVisible()):(this.isVisible=!1,this.options.onHidden&&this.options.onHidden()))},{threshold:this.options.threshold,rootMargin:this.options.rootMargin,root:this.options.root||null}),this.intersectionObserver.observe(this.container)}setupPageVisibility(){"undefined"!=typeof document&&(this.visibilityChangeHandler=()=>{const t=this.isPageVisible;this.isPageVisible=!document.hidden,document.hidden?this.options.onHidden&&this.options.onHidden():t!==this.isPageVisible&&this.isVisible&&this.options.onVisible&&this.options.onVisible()},document.addEventListener("visibilitychange",this.visibilityChangeHandler),document.hidden&&this.isVisible&&this.options.onHidden&&this.options.onHidden())}getIsVisible(){return this.isVisible&&this.isPageVisible}updateOptions(t){this.options={...this.options,...t},this.intersectionObserver&&(this.intersectionObserver.disconnect(),this.intersectionObserver=null),this.setupIntersectionObserver()}destroy(){this.intersectionObserver&&(this.intersectionObserver.disconnect(),this.intersectionObserver=null),this.visibilityChangeHandler&&"undefined"!=typeof document&&(document.removeEventListener("visibilitychange",this.visibilityChangeHandler),this.visibilityChangeHandler=null)}}function s(t){const s=t.charCodeAt(0);if(s<44032||s>55203)return[t];const i=s-44032,h=Math.floor(i/588),n=Math.floor(i%588/28),e=i%28,o=[];return o.push(["ㄱ","ㄲ","ㄴ","ㄷ","ㄸ","ㄹ","ㅁ","ㅂ","ㅃ","ㅅ","ㅆ","ㅇ","ㅈ","ㅉ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"][h]),o.push(["ㅏ","ㅐ","ㅑ","ㅒ","ㅓ","ㅔ","ㅕ","ㅖ","ㅗ","ㅘ","ㅙ","ㅚ","ㅛ","ㅜ","ㅝ","ㅞ","ㅟ","ㅠ","ㅡ","ㅢ","ㅣ"][n]),e>0&&o.push(["","ㄱ","ㄲ","ㄳ","ㄴ","ㄵ","ㄶ","ㄷ","ㄹ","ㄺ","ㄻ","ㄼ","ㄽ","ㄾ","ㄿ","ㅀ","ㅁ","ㅂ","ㅄ","ㅅ","ㅆ","ㅇ","ㅈ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"][e]),o}function i(t,s,i){const h=["ㄱ","ㄲ","ㄴ","ㄷ","ㄸ","ㄹ","ㅁ","ㅂ","ㅃ","ㅅ","ㅆ","ㅇ","ㅈ","ㅉ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"].indexOf(t),n=["ㅏ","ㅐ","ㅑ","ㅒ","ㅓ","ㅔ","ㅕ","ㅖ","ㅗ","ㅘ","ㅙ","ㅚ","ㅛ","ㅜ","ㅝ","ㅞ","ㅟ","ㅠ","ㅡ","ㅢ","ㅣ"].indexOf(s),e=i?["","ㄱ","ㄲ","ㄳ","ㄴ","ㄵ","ㄶ","ㄷ","ㄹ","ㄺ","ㄻ","ㄼ","ㄽ","ㄾ","ㄿ","ㅀ","ㅁ","ㅂ","ㅄ","ㅅ","ㅆ","ㅇ","ㅈ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"].indexOf(i):0;if(-1===h||-1===n)return t+(s||"")+(i||"");const o=44032+21*h*28+28*n+e;return String.fromCharCode(o)}function h(t){const i=[],h=[];for(let n=0;n<t.length;n++){const e=t[n],o=e.charCodeAt(0),r=i.length;if(o>=44032&&o<=55203){const t=s(e);i.push(...t),h.push({start:r,end:i.length,isHangul:!0})}else i.push(e),h.push({start:r,end:i.length,isHangul:!1})}return{units:i,charUnitRanges:h}}class n{constructor(t,s){if(this.container="string"==typeof t?document.querySelector(t):t,!this.container)throw new Error("Container element not found");this.originalText=s.text,this.config={text:s.text,speed:s.speed??50,delay:s.delay??0,enabled:s.enabled??!0,threshold:s.threshold??.2,rootMargin:s.rootMargin??"0px 0px -100px 0px",triggerOnce:s.triggerOnce??!1,showCursor:s.showCursor??!0,cursorChar:s.cursorChar??"|",onUpdate:s.onUpdate||null,onComplete:s.onComplete||null};const i=h(this.config.text);this.textUnits=i.units,this.charUnitRanges=i.charUnitRanges,this.currentIndex=0,this.displayedText="",this.timeoutId=null,this.visibilityManager=null,this.isRunning=!1,this.hasTriggered=!1,this.init()}init(){this.updateDisplay(""),this.injectStyles(),this.setupVisibilityManager()}injectStyles(){if(document.getElementById("masoneffect-typing-styles"))return;const t=document.createElement("style");t.id="masoneffect-typing-styles",t.textContent="\n .typing-char {\n transition: opacity 0.
|
|
1
|
+
Object.defineProperty(exports,"t",{value:!0});class t{constructor(t,s={}){this.container=t,this.options={threshold:s.threshold??.1,rootMargin:s.rootMargin??"0px",root:s.root??null,onVisible:s.onVisible,onHidden:s.onHidden},this.intersectionObserver=null,this.visibilityChangeHandler=null,this.isVisible=!1,this.isPageVisible="undefined"==typeof document||!document.hidden,this.setupIntersectionObserver(),this.setupPageVisibility()}setupIntersectionObserver(){if("undefined"==typeof window||void 0===window.IntersectionObserver)return this.isVisible=!0,void(this.isPageVisible&&this.options.onVisible&&this.options.onVisible());this.intersectionObserver=new IntersectionObserver(t=>{for(const s of t)s.target===this.container&&(s.isIntersecting?(this.isVisible=!0,this.isPageVisible&&this.options.onVisible&&this.options.onVisible()):(this.isVisible=!1,this.options.onHidden&&this.options.onHidden()))},{threshold:this.options.threshold,rootMargin:this.options.rootMargin,root:this.options.root||null}),this.intersectionObserver.observe(this.container)}setupPageVisibility(){"undefined"!=typeof document&&(this.visibilityChangeHandler=()=>{const t=this.isPageVisible;this.isPageVisible=!document.hidden,document.hidden?this.options.onHidden&&this.options.onHidden():t!==this.isPageVisible&&this.isVisible&&this.options.onVisible&&this.options.onVisible()},document.addEventListener("visibilitychange",this.visibilityChangeHandler),document.hidden&&this.isVisible&&this.options.onHidden&&this.options.onHidden())}getIsVisible(){return this.isVisible&&this.isPageVisible}updateOptions(t){this.options={...this.options,...t},this.intersectionObserver&&(this.intersectionObserver.disconnect(),this.intersectionObserver=null),this.setupIntersectionObserver()}destroy(){this.intersectionObserver&&(this.intersectionObserver.disconnect(),this.intersectionObserver=null),this.visibilityChangeHandler&&"undefined"!=typeof document&&(document.removeEventListener("visibilitychange",this.visibilityChangeHandler),this.visibilityChangeHandler=null)}}function s(t){const s=t.charCodeAt(0);if(s<44032||s>55203)return[t];const i=s-44032,h=Math.floor(i/588),n=Math.floor(i%588/28),e=i%28,o=[];return o.push(["ㄱ","ㄲ","ㄴ","ㄷ","ㄸ","ㄹ","ㅁ","ㅂ","ㅃ","ㅅ","ㅆ","ㅇ","ㅈ","ㅉ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"][h]),o.push(["ㅏ","ㅐ","ㅑ","ㅒ","ㅓ","ㅔ","ㅕ","ㅖ","ㅗ","ㅘ","ㅙ","ㅚ","ㅛ","ㅜ","ㅝ","ㅞ","ㅟ","ㅠ","ㅡ","ㅢ","ㅣ"][n]),e>0&&o.push(["","ㄱ","ㄲ","ㄳ","ㄴ","ㄵ","ㄶ","ㄷ","ㄹ","ㄺ","ㄻ","ㄼ","ㄽ","ㄾ","ㄿ","ㅀ","ㅁ","ㅂ","ㅄ","ㅅ","ㅆ","ㅇ","ㅈ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"][e]),o}function i(t,s,i){const h=["ㄱ","ㄲ","ㄴ","ㄷ","ㄸ","ㄹ","ㅁ","ㅂ","ㅃ","ㅅ","ㅆ","ㅇ","ㅈ","ㅉ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"].indexOf(t),n=["ㅏ","ㅐ","ㅑ","ㅒ","ㅓ","ㅔ","ㅕ","ㅖ","ㅗ","ㅘ","ㅙ","ㅚ","ㅛ","ㅜ","ㅝ","ㅞ","ㅟ","ㅠ","ㅡ","ㅢ","ㅣ"].indexOf(s),e=i?["","ㄱ","ㄲ","ㄳ","ㄴ","ㄵ","ㄶ","ㄷ","ㄹ","ㄺ","ㄻ","ㄼ","ㄽ","ㄾ","ㄿ","ㅀ","ㅁ","ㅂ","ㅄ","ㅅ","ㅆ","ㅇ","ㅈ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"].indexOf(i):0;if(-1===h||-1===n)return t+(s||"")+(i||"");const o=44032+21*h*28+28*n+e;return String.fromCharCode(o)}function h(t){const i=[],h=[];for(let n=0;n<t.length;n++){const e=t[n],o=e.charCodeAt(0),r=i.length;if(o>=44032&&o<=55203){const t=s(e);i.push(...t),h.push({start:r,end:i.length,isHangul:!0})}else i.push(e),h.push({start:r,end:i.length,isHangul:!1})}return{units:i,charUnitRanges:h}}class n{constructor(t,s){if(this.container="string"==typeof t?document.querySelector(t):t,!this.container)throw new Error("Container element not found");this.originalText=s.text,this.config={text:s.text,speed:s.speed??50,delay:s.delay??0,enabled:s.enabled??!0,threshold:s.threshold??.2,rootMargin:s.rootMargin??"0px 0px -100px 0px",triggerOnce:s.triggerOnce??!1,showCursor:s.showCursor??!0,cursorChar:s.cursorChar??"|",onUpdate:s.onUpdate||null,onComplete:s.onComplete||null};const i=h(this.config.text);this.textUnits=i.units,this.charUnitRanges=i.charUnitRanges,this.currentIndex=0,this.displayedText="",this.timeoutId=null,this.visibilityManager=null,this.isRunning=!1,this.hasTriggered=!1,this.init()}init(){this.updateDisplay(""),this.injectStyles(),this.setupVisibilityManager()}injectStyles(){if(document.getElementById("masoneffect-typing-styles"))return;const t=document.createElement("style");t.id="masoneffect-typing-styles",t.textContent="\n .typing-char {\n transition: opacity 0.3s ease-in;\n display: inline-block;\n }\n .typing-cursor {\n display: inline-block;\n }\n ",document.head.appendChild(t),this.container.style.whiteSpace="pre-wrap"}setupVisibilityManager(){this.visibilityManager=new t(this.container,{threshold:this.config.threshold,rootMargin:this.config.rootMargin,onVisible:()=>{!this.hasTriggered&&this.config.enabled&&(this.hasTriggered=!0,setTimeout(()=>this.start(),this.config.delay))},onHidden:()=>{}})}buildTextFromUnits(t){if(0===t)return"";let s="";for(let h=0;h<this.charUnitRanges.length;h++){const n=this.charUnitRanges[h];if(n.start>=t)break;const e=Math.min(t-n.start,n.end-n.start);if(e<=0)break;if(n.isHangul){const t=this.textUnits.slice(n.start,n.start+e);1===t.length?s+=t[0]:2===t.length?s+=i(t[0],t[1]):t.length>=3&&(s+=i(t[0],t[1],t[2]))}else e>0&&(s+=this.textUnits[n.start])}return s}start(){this.isRunning||(this.isRunning=!0,this.currentIndex=0,this.displayedText="",this.typeNext())}typeNext(){if(this.currentIndex>=this.textUnits.length)return this.isRunning=!1,this.config.showCursor&&this.updateDisplay(this.originalText),void(this.config.onComplete&&this.config.onComplete());this.displayedText=this.buildTextFromUnits(this.currentIndex+1);let t=this.displayedText;this.config.showCursor&&(t+=this.config.cursorChar),this.updateDisplay(t),this.config.onUpdate&&this.config.onUpdate(this.displayedText),this.currentIndex++,this.timeoutId=setTimeout(()=>{this.typeNext()},this.config.speed)}stop(){this.isRunning=!1,this.timeoutId&&(clearTimeout(this.timeoutId),this.timeoutId=null)}reset(){this.stop(),this.currentIndex=0,this.displayedText="",this.hasTriggered=!1,this.updateDisplay("")}updateDisplay(t){const s=t.replace(new RegExp(this.escapeHtml(this.config.cursorChar)+"$"),""),i=t.endsWith(this.config.cursorChar),h=(this.container.textContent||"").replace(new RegExp(this.config.cursorChar+"$"),"");let n="";for(let t=0;t<s.length;t++){const i=s[t],e=t>=h.length,o=" "===i?" ":this.escapeHtml(i);n+=e?`<span class="typing-char typing-fade-in" style="opacity: 0;">${o}</span>`:`<span class="typing-char" style="opacity: 1;">${o}</span>`}i&&(n+=`<span class="typing-cursor">${this.escapeHtml(this.config.cursorChar)}</span>`),this.container.innerHTML=n;const e=this.container.querySelectorAll(".typing-fade-in");e.length>0&&requestAnimationFrame(()=>{e.forEach(t=>{t.style.opacity="1",t.classList.remove("typing-fade-in")})})}escapeHtml(t){const s=document.createElement("div");return s.textContent=t,s.innerHTML}setText(t){this.originalText=t,this.config.text=t;const s=h(t);this.textUnits=s.units,this.charUnitRanges=s.charUnitRanges,this.reset(),this.config.enabled&&setTimeout(()=>this.start(),this.config.delay)}destroy(){this.stop(),this.visibilityManager&&(this.visibilityManager.destroy(),this.visibilityManager=null)}}exports.Typing=n,exports.default=n;
|
package/dist/typing/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
class t{constructor(t,s={}){this.container=t,this.options={threshold:s.threshold??.1,rootMargin:s.rootMargin??"0px",root:s.root??null,onVisible:s.onVisible,onHidden:s.onHidden},this.intersectionObserver=null,this.visibilityChangeHandler=null,this.isVisible=!1,this.isPageVisible="undefined"==typeof document||!document.hidden,this.setupIntersectionObserver(),this.setupPageVisibility()}setupIntersectionObserver(){if("undefined"==typeof window||void 0===window.IntersectionObserver)return this.isVisible=!0,void(this.isPageVisible&&this.options.onVisible&&this.options.onVisible());this.intersectionObserver=new IntersectionObserver(t=>{for(const s of t)s.target===this.container&&(s.isIntersecting?(this.isVisible=!0,this.isPageVisible&&this.options.onVisible&&this.options.onVisible()):(this.isVisible=!1,this.options.onHidden&&this.options.onHidden()))},{threshold:this.options.threshold,rootMargin:this.options.rootMargin,root:this.options.root||null}),this.intersectionObserver.observe(this.container)}setupPageVisibility(){"undefined"!=typeof document&&(this.visibilityChangeHandler=()=>{const t=this.isPageVisible;this.isPageVisible=!document.hidden,document.hidden?this.options.onHidden&&this.options.onHidden():t!==this.isPageVisible&&this.isVisible&&this.options.onVisible&&this.options.onVisible()},document.addEventListener("visibilitychange",this.visibilityChangeHandler),document.hidden&&this.isVisible&&this.options.onHidden&&this.options.onHidden())}getIsVisible(){return this.isVisible&&this.isPageVisible}updateOptions(t){this.options={...this.options,...t},this.intersectionObserver&&(this.intersectionObserver.disconnect(),this.intersectionObserver=null),this.setupIntersectionObserver()}destroy(){this.intersectionObserver&&(this.intersectionObserver.disconnect(),this.intersectionObserver=null),this.visibilityChangeHandler&&"undefined"!=typeof document&&(document.removeEventListener("visibilitychange",this.visibilityChangeHandler),this.visibilityChangeHandler=null)}}function s(t){const s=t.charCodeAt(0);if(s<44032||s>55203)return[t];const i=s-44032,h=Math.floor(i/588),n=Math.floor(i%588/28),e=i%28,o=[];return o.push(["ㄱ","ㄲ","ㄴ","ㄷ","ㄸ","ㄹ","ㅁ","ㅂ","ㅃ","ㅅ","ㅆ","ㅇ","ㅈ","ㅉ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"][h]),o.push(["ㅏ","ㅐ","ㅑ","ㅒ","ㅓ","ㅔ","ㅕ","ㅖ","ㅗ","ㅘ","ㅙ","ㅚ","ㅛ","ㅜ","ㅝ","ㅞ","ㅟ","ㅠ","ㅡ","ㅢ","ㅣ"][n]),e>0&&o.push(["","ㄱ","ㄲ","ㄳ","ㄴ","ㄵ","ㄶ","ㄷ","ㄹ","ㄺ","ㄻ","ㄼ","ㄽ","ㄾ","ㄿ","ㅀ","ㅁ","ㅂ","ㅄ","ㅅ","ㅆ","ㅇ","ㅈ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"][e]),o}function i(t,s,i){const h=["ㄱ","ㄲ","ㄴ","ㄷ","ㄸ","ㄹ","ㅁ","ㅂ","ㅃ","ㅅ","ㅆ","ㅇ","ㅈ","ㅉ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"].indexOf(t),n=["ㅏ","ㅐ","ㅑ","ㅒ","ㅓ","ㅔ","ㅕ","ㅖ","ㅗ","ㅘ","ㅙ","ㅚ","ㅛ","ㅜ","ㅝ","ㅞ","ㅟ","ㅠ","ㅡ","ㅢ","ㅣ"].indexOf(s),e=i?["","ㄱ","ㄲ","ㄳ","ㄴ","ㄵ","ㄶ","ㄷ","ㄹ","ㄺ","ㄻ","ㄼ","ㄽ","ㄾ","ㄿ","ㅀ","ㅁ","ㅂ","ㅄ","ㅅ","ㅆ","ㅇ","ㅈ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"].indexOf(i):0;if(-1===h||-1===n)return t+(s||"")+(i||"");const o=44032+21*h*28+28*n+e;return String.fromCharCode(o)}function h(t){const i=[],h=[];for(let n=0;n<t.length;n++){const e=t[n],o=e.charCodeAt(0),r=i.length;if(o>=44032&&o<=55203){const t=s(e);i.push(...t),h.push({start:r,end:i.length,isHangul:!0})}else i.push(e),h.push({start:r,end:i.length,isHangul:!1})}return{units:i,charUnitRanges:h}}class n{constructor(t,s){if(this.container="string"==typeof t?document.querySelector(t):t,!this.container)throw new Error("Container element not found");this.originalText=s.text,this.config={text:s.text,speed:s.speed??50,delay:s.delay??0,enabled:s.enabled??!0,threshold:s.threshold??.2,rootMargin:s.rootMargin??"0px 0px -100px 0px",triggerOnce:s.triggerOnce??!1,showCursor:s.showCursor??!0,cursorChar:s.cursorChar??"|",onUpdate:s.onUpdate||null,onComplete:s.onComplete||null};const i=h(this.config.text);this.textUnits=i.units,this.charUnitRanges=i.charUnitRanges,this.currentIndex=0,this.displayedText="",this.timeoutId=null,this.visibilityManager=null,this.isRunning=!1,this.hasTriggered=!1,this.init()}init(){this.updateDisplay(""),this.injectStyles(),this.setupVisibilityManager()}injectStyles(){if(document.getElementById("masoneffect-typing-styles"))return;const t=document.createElement("style");t.id="masoneffect-typing-styles",t.textContent="\n .typing-char {\n transition: opacity 0.
|
|
1
|
+
class t{constructor(t,s={}){this.container=t,this.options={threshold:s.threshold??.1,rootMargin:s.rootMargin??"0px",root:s.root??null,onVisible:s.onVisible,onHidden:s.onHidden},this.intersectionObserver=null,this.visibilityChangeHandler=null,this.isVisible=!1,this.isPageVisible="undefined"==typeof document||!document.hidden,this.setupIntersectionObserver(),this.setupPageVisibility()}setupIntersectionObserver(){if("undefined"==typeof window||void 0===window.IntersectionObserver)return this.isVisible=!0,void(this.isPageVisible&&this.options.onVisible&&this.options.onVisible());this.intersectionObserver=new IntersectionObserver(t=>{for(const s of t)s.target===this.container&&(s.isIntersecting?(this.isVisible=!0,this.isPageVisible&&this.options.onVisible&&this.options.onVisible()):(this.isVisible=!1,this.options.onHidden&&this.options.onHidden()))},{threshold:this.options.threshold,rootMargin:this.options.rootMargin,root:this.options.root||null}),this.intersectionObserver.observe(this.container)}setupPageVisibility(){"undefined"!=typeof document&&(this.visibilityChangeHandler=()=>{const t=this.isPageVisible;this.isPageVisible=!document.hidden,document.hidden?this.options.onHidden&&this.options.onHidden():t!==this.isPageVisible&&this.isVisible&&this.options.onVisible&&this.options.onVisible()},document.addEventListener("visibilitychange",this.visibilityChangeHandler),document.hidden&&this.isVisible&&this.options.onHidden&&this.options.onHidden())}getIsVisible(){return this.isVisible&&this.isPageVisible}updateOptions(t){this.options={...this.options,...t},this.intersectionObserver&&(this.intersectionObserver.disconnect(),this.intersectionObserver=null),this.setupIntersectionObserver()}destroy(){this.intersectionObserver&&(this.intersectionObserver.disconnect(),this.intersectionObserver=null),this.visibilityChangeHandler&&"undefined"!=typeof document&&(document.removeEventListener("visibilitychange",this.visibilityChangeHandler),this.visibilityChangeHandler=null)}}function s(t){const s=t.charCodeAt(0);if(s<44032||s>55203)return[t];const i=s-44032,h=Math.floor(i/588),n=Math.floor(i%588/28),e=i%28,o=[];return o.push(["ㄱ","ㄲ","ㄴ","ㄷ","ㄸ","ㄹ","ㅁ","ㅂ","ㅃ","ㅅ","ㅆ","ㅇ","ㅈ","ㅉ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"][h]),o.push(["ㅏ","ㅐ","ㅑ","ㅒ","ㅓ","ㅔ","ㅕ","ㅖ","ㅗ","ㅘ","ㅙ","ㅚ","ㅛ","ㅜ","ㅝ","ㅞ","ㅟ","ㅠ","ㅡ","ㅢ","ㅣ"][n]),e>0&&o.push(["","ㄱ","ㄲ","ㄳ","ㄴ","ㄵ","ㄶ","ㄷ","ㄹ","ㄺ","ㄻ","ㄼ","ㄽ","ㄾ","ㄿ","ㅀ","ㅁ","ㅂ","ㅄ","ㅅ","ㅆ","ㅇ","ㅈ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"][e]),o}function i(t,s,i){const h=["ㄱ","ㄲ","ㄴ","ㄷ","ㄸ","ㄹ","ㅁ","ㅂ","ㅃ","ㅅ","ㅆ","ㅇ","ㅈ","ㅉ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"].indexOf(t),n=["ㅏ","ㅐ","ㅑ","ㅒ","ㅓ","ㅔ","ㅕ","ㅖ","ㅗ","ㅘ","ㅙ","ㅚ","ㅛ","ㅜ","ㅝ","ㅞ","ㅟ","ㅠ","ㅡ","ㅢ","ㅣ"].indexOf(s),e=i?["","ㄱ","ㄲ","ㄳ","ㄴ","ㄵ","ㄶ","ㄷ","ㄹ","ㄺ","ㄻ","ㄼ","ㄽ","ㄾ","ㄿ","ㅀ","ㅁ","ㅂ","ㅄ","ㅅ","ㅆ","ㅇ","ㅈ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"].indexOf(i):0;if(-1===h||-1===n)return t+(s||"")+(i||"");const o=44032+21*h*28+28*n+e;return String.fromCharCode(o)}function h(t){const i=[],h=[];for(let n=0;n<t.length;n++){const e=t[n],o=e.charCodeAt(0),r=i.length;if(o>=44032&&o<=55203){const t=s(e);i.push(...t),h.push({start:r,end:i.length,isHangul:!0})}else i.push(e),h.push({start:r,end:i.length,isHangul:!1})}return{units:i,charUnitRanges:h}}class n{constructor(t,s){if(this.container="string"==typeof t?document.querySelector(t):t,!this.container)throw new Error("Container element not found");this.originalText=s.text,this.config={text:s.text,speed:s.speed??50,delay:s.delay??0,enabled:s.enabled??!0,threshold:s.threshold??.2,rootMargin:s.rootMargin??"0px 0px -100px 0px",triggerOnce:s.triggerOnce??!1,showCursor:s.showCursor??!0,cursorChar:s.cursorChar??"|",onUpdate:s.onUpdate||null,onComplete:s.onComplete||null};const i=h(this.config.text);this.textUnits=i.units,this.charUnitRanges=i.charUnitRanges,this.currentIndex=0,this.displayedText="",this.timeoutId=null,this.visibilityManager=null,this.isRunning=!1,this.hasTriggered=!1,this.init()}init(){this.updateDisplay(""),this.injectStyles(),this.setupVisibilityManager()}injectStyles(){if(document.getElementById("masoneffect-typing-styles"))return;const t=document.createElement("style");t.id="masoneffect-typing-styles",t.textContent="\n .typing-char {\n transition: opacity 0.3s ease-in;\n display: inline-block;\n }\n .typing-cursor {\n display: inline-block;\n }\n ",document.head.appendChild(t),this.container.style.whiteSpace="pre-wrap"}setupVisibilityManager(){this.visibilityManager=new t(this.container,{threshold:this.config.threshold,rootMargin:this.config.rootMargin,onVisible:()=>{!this.hasTriggered&&this.config.enabled&&(this.hasTriggered=!0,setTimeout(()=>this.start(),this.config.delay))},onHidden:()=>{}})}buildTextFromUnits(t){if(0===t)return"";let s="";for(let h=0;h<this.charUnitRanges.length;h++){const n=this.charUnitRanges[h];if(n.start>=t)break;const e=Math.min(t-n.start,n.end-n.start);if(e<=0)break;if(n.isHangul){const t=this.textUnits.slice(n.start,n.start+e);1===t.length?s+=t[0]:2===t.length?s+=i(t[0],t[1]):t.length>=3&&(s+=i(t[0],t[1],t[2]))}else e>0&&(s+=this.textUnits[n.start])}return s}start(){this.isRunning||(this.isRunning=!0,this.currentIndex=0,this.displayedText="",this.typeNext())}typeNext(){if(this.currentIndex>=this.textUnits.length)return this.isRunning=!1,this.config.showCursor&&this.updateDisplay(this.originalText),void(this.config.onComplete&&this.config.onComplete());this.displayedText=this.buildTextFromUnits(this.currentIndex+1);let t=this.displayedText;this.config.showCursor&&(t+=this.config.cursorChar),this.updateDisplay(t),this.config.onUpdate&&this.config.onUpdate(this.displayedText),this.currentIndex++,this.timeoutId=setTimeout(()=>{this.typeNext()},this.config.speed)}stop(){this.isRunning=!1,this.timeoutId&&(clearTimeout(this.timeoutId),this.timeoutId=null)}reset(){this.stop(),this.currentIndex=0,this.displayedText="",this.hasTriggered=!1,this.updateDisplay("")}updateDisplay(t){const s=t.replace(new RegExp(this.escapeHtml(this.config.cursorChar)+"$"),""),i=t.endsWith(this.config.cursorChar),h=(this.container.textContent||"").replace(new RegExp(this.config.cursorChar+"$"),"");let n="";for(let t=0;t<s.length;t++){const i=s[t],e=t>=h.length,o=" "===i?" ":this.escapeHtml(i);n+=e?`<span class="typing-char typing-fade-in" style="opacity: 0;">${o}</span>`:`<span class="typing-char" style="opacity: 1;">${o}</span>`}i&&(n+=`<span class="typing-cursor">${this.escapeHtml(this.config.cursorChar)}</span>`),this.container.innerHTML=n;const e=this.container.querySelectorAll(".typing-fade-in");e.length>0&&requestAnimationFrame(()=>{e.forEach(t=>{t.style.opacity="1",t.classList.remove("typing-fade-in")})})}escapeHtml(t){const s=document.createElement("div");return s.textContent=t,s.innerHTML}setText(t){this.originalText=t,this.config.text=t;const s=h(t);this.textUnits=s.units,this.charUnitRanges=s.charUnitRanges,this.reset(),this.config.enabled&&setTimeout(()=>this.start(),this.config.delay)}destroy(){this.stop(),this.visibilityManager&&(this.visibilityManager.destroy(),this.visibilityManager=null)}}export{n as Typing,n as default};
|
package/dist/vue/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("vue");class e{constructor(t,e={}){this.container=t,this.options={threshold:e.threshold??.1,rootMargin:e.rootMargin??"0px",root:e.root??null,onVisible:e.onVisible,onHidden:e.onHidden},this.intersectionObserver=null,this.visibilityChangeHandler=null,this.isVisible=!1,this.isPageVisible="undefined"==typeof document||!document.hidden,this.setupIntersectionObserver(),this.setupPageVisibility()}setupIntersectionObserver(){if("undefined"==typeof window||void 0===window.IntersectionObserver)return this.isVisible=!0,void(this.isPageVisible&&this.options.onVisible&&this.options.onVisible());this.intersectionObserver=new IntersectionObserver(t=>{for(const e of t)e.target===this.container&&(e.isIntersecting?(this.isVisible=!0,this.isPageVisible&&this.options.onVisible&&this.options.onVisible()):(this.isVisible=!1,this.options.onHidden&&this.options.onHidden()))},{threshold:this.options.threshold,rootMargin:this.options.rootMargin,root:this.options.root||null}),this.intersectionObserver.observe(this.container)}setupPageVisibility(){"undefined"!=typeof document&&(this.visibilityChangeHandler=()=>{const t=this.isPageVisible;this.isPageVisible=!document.hidden,document.hidden?this.options.onHidden&&this.options.onHidden():t!==this.isPageVisible&&this.isVisible&&this.options.onVisible&&this.options.onVisible()},document.addEventListener("visibilitychange",this.visibilityChangeHandler),document.hidden&&this.isVisible&&this.options.onHidden&&this.options.onHidden())}getIsVisible(){return this.isVisible&&this.isPageVisible}updateOptions(t){this.options={...this.options,...t},this.intersectionObserver&&(this.intersectionObserver.disconnect(),this.intersectionObserver=null),this.setupIntersectionObserver()}destroy(){this.intersectionObserver&&(this.intersectionObserver.disconnect(),this.intersectionObserver=null),this.visibilityChangeHandler&&"undefined"!=typeof document&&(document.removeEventListener("visibilitychange",this.visibilityChangeHandler),this.visibilityChangeHandler=null)}}function i(t,e){let i=null;return function(...n){null!==i&&clearTimeout(i),i=setTimeout(()=>{i=null,t.apply(this,n)},e)}}class n{constructor(t,e={}){if(this.container="string"==typeof t?document.querySelector(t):t,!this.container)throw new Error("Container element not found");this.config={text:e.text||"mason effect",densityStep:e.densityStep??2,maxParticles:e.maxParticles??3200,pointSize:e.pointSize??.5,ease:e.ease??.05,repelRadius:e.repelRadius??150,repelStrength:e.repelStrength??1,particleColor:e.particleColor||"#fff",fontFamily:e.fontFamily||"Inter, system-ui, Arial",fontSize:e.fontSize||null,width:e.width||null,height:e.height||null,devicePixelRatio:e.devicePixelRatio??null,onReady:e.onReady||null,onUpdate:e.onUpdate||null},this.canvas=document.createElement("canvas");const n=this.canvas.getContext("2d",{willReadFrequently:!0});if(!n)throw new Error("Canvas context not available");this.ctx=n,this.container.appendChild(this.canvas),this.canvas.style.display="block",this.offCanvas=document.createElement("canvas");const s=this.offCanvas.getContext("2d",{willReadFrequently:!0});if(!s)throw new Error("Offscreen canvas context not available");this.offCtx=s,this.W=0,this.H=0,this.DPR=this.config.devicePixelRatio||Math.min(window.devicePixelRatio||1,1.8),this.particles=[],this.mouse={x:0,y:0,down:!1},this.animationId=null,this.isRunning=!1,this.visibilityManager=null,this.debounceDelay=e.debounceDelay??150;const o=this.handleResize.bind(this);this.handleResize=i(o,this.debounceDelay),this.handleMouseMove=this.handleMouseMove.bind(this),this.handleMouseLeave=this.handleMouseLeave.bind(this),this.handleMouseDown=this.handleMouseDown.bind(this),this.handleMouseUp=this.handleMouseUp.bind(this),this._debouncedMorph=i(this._morphInternal.bind(this),this.debounceDelay),this._debouncedUpdateConfig=i(this._updateConfigInternal.bind(this),this.debounceDelay),this.init()}init(){this.resize(),this.setupEventListeners(),this.setupVisibilityManager(),this.config.onReady&&this.config.onReady(this)}setupVisibilityManager(){this.visibilityManager=new e(this.container,{threshold:.1,onVisible:()=>{this.start()},onHidden:()=>{this.stop()}})}resize(){const t=this.container.getBoundingClientRect(),e=this.config.width||t.width||this.container.clientWidth||window.innerWidth,i=this.config.height||t.height||this.container.clientHeight||.7*window.innerHeight;if(e<=0||i<=0)return;this.W=Math.floor(e*this.DPR),this.H=Math.floor(i*this.DPR);const n=4096;if(this.W>n||this.H>n){const t=Math.min(n/this.W,n/this.H);this.W=Math.floor(this.W*t),this.H=Math.floor(this.H*t),this.DPR=this.DPR*t}this.canvas.width=this.W,this.canvas.height=this.H,this.canvas.style.width=e+"px",this.canvas.style.height=i+"px",this.W>0&&this.H>0&&(this.buildTargets(),this.particles.length||this.initParticles())}measureTextFit(t,e,i,n){this.offCtx.font=`400 ${t}px ${this.config.fontFamily}`;const s=e.split("\n"),o=t,a=.1*t,r=.05*t;let l=0;for(const d of s){if(0===d.length)continue;const t=this.offCtx.measureText(d).width+r*(d.length>0?d.length-1:0);l=Math.max(l,t)}const h=s.length>0?o*s.length+a*(s.length-1):o;return{width:l,height:h,fits:l<=i&&h<=n}}findOptimalFontSize(t,e,i,n){if(this.measureTextFit(n,t,e,i).fits)return n;if(n<=12)return 12;let s=12,o=n,a=12;for(;s<=o;){const n=Math.floor((s+o)/2);this.measureTextFit(n,t,e,i).fits?(a=n,s=n+1):o=n-1}return a}buildTargets(){if(this.W<=0||this.H<=0)return;const t=this.config.text;this.offCanvas.width=this.W,this.offCanvas.height=this.H,this.offCtx.clearRect(0,0,this.offCanvas.width,this.offCanvas.height);const e=Math.min(this.W,this.H),i=this.config.fontSize||Math.max(80,Math.floor(.18*e)),n=this.W-80,s=this.H-80,o=this.findOptimalFontSize(t,n,s,i);this.offCtx.fillStyle="#ffffff",this.offCtx.textAlign="center",this.offCtx.textBaseline="middle",this.offCtx.font=`400 ${o}px ${this.config.fontFamily}`;const a=t.split("\n"),r=o,l=.1*o,h=.05*o,d=a.length>0?r*a.length+l*(a.length-1):r;let c=this.H/2-d/2+r/2;for(const f of a){if(0===f.length){c+=r+l;continue}const t=f.split(""),e=this.offCtx.measureText(f).width+h*(t.length>0?t.length-1:0);let i=this.W/2-e/2;for(const n of t)this.offCtx.fillText(n,i+this.offCtx.measureText(n).width/2,c),i+=this.offCtx.measureText(n).width+h;c+=r+l}const u=Math.max(2,this.config.densityStep),g=this.offCtx.getImageData(0,0,this.W,this.H).data,p=[];for(let f=0;f<this.H;f+=u)for(let t=0;t<this.W;t+=u){const e=4*(f*this.W+t);g[e]+g[e+1]+g[e+2]>600&&p.push({x:t,y:f})}for(;p.length>this.config.maxParticles;)p.splice(Math.floor(Math.random()*p.length),1);if(this.particles.length<p.length){const t=p.length-this.particles.length;for(let e=0;e<t;e++)this.particles.push(this.makeParticle())}else this.particles.length>p.length&&(this.particles.length=p.length);for(let f=0;f<this.particles.length;f++){const t=this.particles[f],e=p[f];t.tx=e.x,t.ty=e.y}}makeParticle(){const t=Math.random()*this.W,e=Math.random()*this.H;return{x:t,y:e,vx:0,vy:0,tx:t,ty:e,initialX:t,initialY:e,j:Math.random()*Math.PI*2}}initParticles(){for(const t of this.particles){const e=Math.random()*this.W,i=Math.random()*this.H;t.x=e,t.y=i,t.vx=t.vy=0,t.initialX=e,t.initialY=i}}scatter(){for(const t of this.particles)void 0!==t.initialX&&void 0!==t.initialY?(t.tx=t.initialX,t.ty=t.initialY):(t.initialX=t.x,t.initialY=t.y,t.tx=t.initialX,t.ty=t.initialY)}morph(t){this._debouncedMorph(t)}_morphInternal(t){if(0!==this.W&&0!==this.H||this.resize(),"string"==typeof t)this.config.text=t,this.buildTargets();else if(t&&"object"==typeof t){const e=void 0!==t.text;this.config={...this.config,...t},e&&this.buildTargets()}else this.buildTargets()}update(){this.ctx.clearRect(0,0,this.W,this.H);for(const n of this.particles){let t=(n.tx-n.x)*this.config.ease,e=(n.ty-n.y)*this.config.ease;if(this.mouse.x||this.mouse.y){const i=n.x-this.mouse.x,s=n.y-this.mouse.y,o=i*i+s*s,a=this.config.repelRadius*this.DPR;if(o<a*a){const n=Math.sqrt(o)+1e-4,r=(this.mouse.down?-1:1)*this.config.repelStrength*(1-n/a);t+=i/n*r*6,e+=s/n*r*6}}n.j+=2,t+=.05*Math.cos(n.j),e+=.05*Math.sin(1.3*n.j),n.vx=(n.vx+t)*Math.random(),n.vy=(n.vy+e)*Math.random(),n.x+=n.vx,n.y+=n.vy}this.ctx.fillStyle=this.config.particleColor;const t=Math.min(this.W,this.H)/this.DPR,e=Math.max(.5,Math.min(2,t/1920)),i=this.config.pointSize*this.DPR*e;for(const n of this.particles)this.ctx.beginPath(),this.ctx.arc(n.x,n.y,i,0,2*Math.PI),this.ctx.fill();this.config.onUpdate&&this.config.onUpdate(this)}animate(){this.isRunning&&(this.update(),this.animationId=requestAnimationFrame(()=>this.animate()))}start(){this.isRunning||(this.isRunning=!0,this.animate())}stop(){this.isRunning=!1,this.animationId&&(cancelAnimationFrame(this.animationId),this.animationId=null)}setupEventListeners(){window.addEventListener("resize",this.handleResize),this.canvas.addEventListener("mousemove",this.handleMouseMove),this.canvas.addEventListener("mouseleave",this.handleMouseLeave),this.canvas.addEventListener("mousedown",this.handleMouseDown),window.addEventListener("mouseup",this.handleMouseUp)}removeEventListeners(){window.removeEventListener("resize",this.handleResize),this.canvas.removeEventListener("mousemove",this.handleMouseMove),this.canvas.removeEventListener("mouseleave",this.handleMouseLeave),this.canvas.removeEventListener("mousedown",this.handleMouseDown),window.removeEventListener("mouseup",this.handleMouseUp)}handleResize(){this.resize()}handleMouseMove(t){const e=this.canvas.getBoundingClientRect();this.mouse.x=(t.clientX-e.left)*this.DPR,this.mouse.y=(t.clientY-e.top)*this.DPR}handleMouseLeave(){this.mouse.x=this.mouse.y=0}handleMouseDown(){this.mouse.down=!0}handleMouseUp(){this.mouse.down=!1}updateConfig(t){this._debouncedUpdateConfig(t)}_updateConfigInternal(t){this.config={...this.config,...t},t.text&&this.buildTargets()}destroy(){this.stop(),this.removeEventListeners(),this.visibilityManager&&(this.visibilityManager.destroy(),this.visibilityManager=null),this.canvas&&this.canvas.parentNode&&this.canvas.parentNode.removeChild(this.canvas)}}const s={linear:t=>t};class o{constructor(t,e){if(this.container="string"==typeof t?document.querySelector(t):t,!this.container)throw new Error("Container element not found");this.config={targetValue:e.targetValue,duration:e.duration??2e3,startValue:e.startValue??0,enabled:e.enabled??!0,easing:e.easing??s.linear,threshold:e.threshold??.2,rootMargin:e.rootMargin??"0px 0px -100px 0px",triggerOnce:e.triggerOnce??!1,onUpdate:e.onUpdate||null,onComplete:e.onComplete||null},this.currentValue=this.config.startValue,this.startTime=null,this.animationFrameId=null,this.visibilityManager=null,this.isRunning=!1,this.hasTriggered=!1,this.init()}init(){this.updateDisplay(this.config.startValue),this.setupVisibilityManager()}setupVisibilityManager(){this.visibilityManager=new e(this.container,{threshold:this.config.threshold,rootMargin:this.config.rootMargin,onVisible:()=>{!this.hasTriggered&&this.config.enabled&&(this.hasTriggered=!0,this.start())},onHidden:()=>{!this.config.triggerOnce&&this.isRunning&&this.reset()}})}start(){if(this.isRunning)return;if(!this.config.enabled)return;this.isRunning=!0,this.startTime=null,this.currentValue=this.config.startValue,this.updateDisplay(this.currentValue);const t=e=>{null===this.startTime&&(this.startTime=e);const i=e-this.startTime,n=Math.min(i/this.config.duration,1),s=this.config.easing(n);this.currentValue=Math.floor(this.config.startValue+(this.config.targetValue-this.config.startValue)*s),this.updateDisplay(this.currentValue),this.config.onUpdate&&this.config.onUpdate(this.currentValue),n<1?this.animationFrameId=requestAnimationFrame(t):(this.currentValue=this.config.targetValue,this.updateDisplay(this.currentValue),this.isRunning=!1,this.config.onComplete&&this.config.onComplete())};this.animationFrameId=requestAnimationFrame(t)}stop(){this.isRunning=!1,null!==this.animationFrameId&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null)}reset(){this.stop(),this.currentValue=this.config.startValue,this.updateDisplay(this.currentValue),this.hasTriggered=!1,this.startTime=null}updateDisplay(t){this.container.textContent=this.formatNumber(t)}formatNumber(t){return Math.floor(t).toLocaleString()}updateConfig(t){const e=this.isRunning;this.stop(),this.config={...this.config,...t,onUpdate:void 0!==t.onUpdate?t.onUpdate:this.config.onUpdate,onComplete:void 0!==t.onComplete?t.onComplete:this.config.onComplete},void 0!==t.targetValue?(this.reset(),e&&this.config.enabled&&this.start()):e&&this.config.enabled&&this.start()}getValue(){return this.currentValue}destroy(){this.stop(),this.visibilityManager&&(this.visibilityManager.destroy(),this.visibilityManager=null)}}function a(t){const e=t.charCodeAt(0);if(e<44032||e>55203)return[t];const i=e-44032,n=Math.floor(i/588),s=Math.floor(i%588/28),o=i%28,a=["","ㄱ","ㄲ","ㄳ","ㄴ","ㄵ","ㄶ","ㄷ","ㄹ","ㄺ","ㄻ","ㄼ","ㄽ","ㄾ","ㄿ","ㅀ","ㅁ","ㅂ","ㅄ","ㅅ","ㅆ","ㅇ","ㅈ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"],r=[];return r.push(["ㄱ","ㄲ","ㄴ","ㄷ","ㄸ","ㄹ","ㅁ","ㅂ","ㅃ","ㅅ","ㅆ","ㅇ","ㅈ","ㅉ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"][n]),r.push(["ㅏ","ㅐ","ㅑ","ㅒ","ㅓ","ㅔ","ㅕ","ㅖ","ㅗ","ㅘ","ㅙ","ㅚ","ㅛ","ㅜ","ㅝ","ㅞ","ㅟ","ㅠ","ㅡ","ㅢ","ㅣ"][s]),o>0&&r.push(a[o]),r}function r(t,e,i){const n=["ㄱ","ㄲ","ㄴ","ㄷ","ㄸ","ㄹ","ㅁ","ㅂ","ㅃ","ㅅ","ㅆ","ㅇ","ㅈ","ㅉ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"].indexOf(t),s=["ㅏ","ㅐ","ㅑ","ㅒ","ㅓ","ㅔ","ㅕ","ㅖ","ㅗ","ㅘ","ㅙ","ㅚ","ㅛ","ㅜ","ㅝ","ㅞ","ㅟ","ㅠ","ㅡ","ㅢ","ㅣ"].indexOf(e),o=i?["","ㄱ","ㄲ","ㄳ","ㄴ","ㄵ","ㄶ","ㄷ","ㄹ","ㄺ","ㄻ","ㄼ","ㄽ","ㄾ","ㄿ","ㅀ","ㅁ","ㅂ","ㅄ","ㅅ","ㅆ","ㅇ","ㅈ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"].indexOf(i):0;if(-1===n||-1===s)return t+(e||"")+(i||"");const a=44032+21*n*28+28*s+o;return String.fromCharCode(a)}function l(t){const e=[],i=[];for(let n=0;n<t.length;n++){const s=t[n],o=s.charCodeAt(0),r=e.length;if(o>=44032&&o<=55203){const t=a(s);e.push(...t),i.push({start:r,end:e.length,isHangul:!0})}else e.push(s),i.push({start:r,end:e.length,isHangul:!1})}return{units:e,charUnitRanges:i}}class h{constructor(t,e){if(this.container="string"==typeof t?document.querySelector(t):t,!this.container)throw new Error("Container element not found");this.originalText=e.text,this.config={text:e.text,speed:e.speed??50,delay:e.delay??0,enabled:e.enabled??!0,threshold:e.threshold??.2,rootMargin:e.rootMargin??"0px 0px -100px 0px",triggerOnce:e.triggerOnce??!1,showCursor:e.showCursor??!0,cursorChar:e.cursorChar??"|",onUpdate:e.onUpdate||null,onComplete:e.onComplete||null};const i=l(this.config.text);this.textUnits=i.units,this.charUnitRanges=i.charUnitRanges,this.currentIndex=0,this.displayedText="",this.timeoutId=null,this.visibilityManager=null,this.isRunning=!1,this.hasTriggered=!1,this.init()}init(){this.updateDisplay(""),this.injectStyles(),this.setupVisibilityManager()}injectStyles(){if(document.getElementById("masoneffect-typing-styles"))return;const t=document.createElement("style");t.id="masoneffect-typing-styles",t.textContent="\n .typing-char {\n transition: opacity 0.2s ease-in;\n display: inline-block;\n }\n .typing-cursor {\n display: inline-block;\n }\n ",document.head.appendChild(t)}setupVisibilityManager(){this.visibilityManager=new e(this.container,{threshold:this.config.threshold,rootMargin:this.config.rootMargin,onVisible:()=>{!this.hasTriggered&&this.config.enabled&&(this.hasTriggered=!0,setTimeout(()=>this.start(),this.config.delay))},onHidden:()=>{}})}buildTextFromUnits(t){if(0===t)return"";let e="";for(let i=0;i<this.charUnitRanges.length;i++){const n=this.charUnitRanges[i];if(n.start>=t)break;const s=Math.min(t-n.start,n.end-n.start);if(s<=0)break;if(n.isHangul){const t=this.textUnits.slice(n.start,n.start+s);1===t.length?e+=t[0]:2===t.length?e+=r(t[0],t[1]):t.length>=3&&(e+=r(t[0],t[1],t[2]))}else s>0&&(e+=this.textUnits[n.start])}return e}start(){this.isRunning||(this.isRunning=!0,this.currentIndex=0,this.displayedText="",this.typeNext())}typeNext(){if(this.currentIndex>=this.textUnits.length)return this.isRunning=!1,this.config.showCursor&&this.updateDisplay(this.originalText),void(this.config.onComplete&&this.config.onComplete());this.displayedText=this.buildTextFromUnits(this.currentIndex+1);let t=this.displayedText;this.config.showCursor&&(t+=this.config.cursorChar),this.updateDisplay(t),this.config.onUpdate&&this.config.onUpdate(this.displayedText),this.currentIndex++,this.timeoutId=setTimeout(()=>{this.typeNext()},this.config.speed)}stop(){this.isRunning=!1,this.timeoutId&&(clearTimeout(this.timeoutId),this.timeoutId=null)}reset(){this.stop(),this.currentIndex=0,this.displayedText="",this.hasTriggered=!1,this.updateDisplay("")}updateDisplay(t){const e=t.replace(new RegExp(this.escapeHtml(this.config.cursorChar)+"$"),""),i=t.endsWith(this.config.cursorChar),n=(this.container.textContent||"").replace(new RegExp(this.config.cursorChar+"$"),"");let s="";for(let a=0;a<e.length;a++){const t=e[a];s+=a>=n.length?`<span class="typing-char typing-fade-in" style="opacity: 0;">${this.escapeHtml(t)}</span>`:`<span class="typing-char" style="opacity: 1;">${this.escapeHtml(t)}</span>`}i&&(s+=`<span class="typing-cursor">${this.escapeHtml(this.config.cursorChar)}</span>`),this.container.innerHTML=s;const o=this.container.querySelectorAll(".typing-fade-in");o.length>0&&requestAnimationFrame(()=>{o.forEach(t=>{t.style.opacity="1",t.classList.remove("typing-fade-in")})})}escapeHtml(t){const e=document.createElement("div");return e.textContent=t,e.innerHTML}setText(t){this.originalText=t,this.config.text=t;const e=l(t);this.textUnits=e.units,this.charUnitRanges=e.charUnitRanges,this.reset(),this.config.enabled&&setTimeout(()=>this.start(),this.config.delay)}destroy(){this.stop(),this.visibilityManager&&(this.visibilityManager.destroy(),this.visibilityManager=null)}}const d=t=>--t*t*t+1;class c{constructor(t,e={}){if(this.container="string"==typeof t?document.querySelector(t):t,!this.container)throw new Error("Container element not found");this.config={direction:e.direction??"bottom",distance:e.distance??"50px",duration:e.duration??800,threshold:e.threshold??.1,rootMargin:e.rootMargin??"0px",root:e.root??null,triggerOnce:e.triggerOnce??!1,enabled:e.enabled??!0,onStart:e.onStart||null,onComplete:e.onComplete||null},this.easing=d,this.visibilityManager=null,this.animationFrameId=null,this.startTime=null,this.isRunning=!1,this.hasTriggered=!1,this.initialTransform="",this.targetDistance=0,this.init()}init(){const t=window.getComputedStyle(this.container);this.initialTransform="none"!==t.transform?t.transform:this.container.style.transform||"",this.targetDistance=this.parseDistance(this.config.distance),this.setInitialPosition(),this.setupVisibilityManager()}parseDistance(t){const e=t.match(/^(-?\d+\.?\d*)(px|rem|em|%|vh|vw)$/);if(!e){return parseFloat(t)||50}const i=parseFloat(e[1]);switch(e[2]){case"px":default:return i;case"rem":case"em":return i*(parseFloat(getComputedStyle(document.documentElement).fontSize)||16);case"%":const t=this.container.getBoundingClientRect();return i/100*("top"===this.config.direction||"bottom"===this.config.direction?t.height:t.width);case"vh":return i/100*window.innerHeight;case"vw":return i/100*window.innerWidth}}setInitialPosition(){let t=0,e=0;switch(this.config.direction){case"top":e=-this.targetDistance;break;case"right":t=this.targetDistance;break;case"bottom":e=this.targetDistance;break;case"left":t=-this.targetDistance}const i=this.initialTransform||"",n=`translate(${t}px, ${e}px)`;this.container.style.transform=i&&"none"!==i?`${n} ${i}`:n,this.container.style.opacity="0",this.container.style.transition="none"}setupVisibilityManager(){this.visibilityManager=new e(this.container,{threshold:this.config.threshold,rootMargin:this.config.rootMargin,root:this.config.root,onVisible:()=>{this.config.enabled&&(this.config.triggerOnce&&this.hasTriggered||(this.hasTriggered=!0,this.start()))},onHidden:()=>{this.config.enabled&&(this.stop(),this.config.triggerOnce||(this.hasTriggered=!1),this.setInitialPosition())}})}start(){this.isRunning||(this.isRunning=!0,this.startTime=performance.now(),this.config.onStart&&this.config.onStart(),this.container.style.transition="none",this.animate())}animate(){if(!this.isRunning)return;const t=performance.now()-(this.startTime||0),e=Math.min(t/this.config.duration,1),i=this.easing(e);let n=0,s=0;switch(this.config.direction){case"top":s=-this.targetDistance*(1-i);break;case"right":n=this.targetDistance*(1-i);break;case"bottom":s=this.targetDistance*(1-i);break;case"left":n=-this.targetDistance*(1-i)}const o=this.initialTransform||"",a=`translate(${n}px, ${s}px)`;this.container.style.transform=o&&"none"!==o?`${a} ${o}`:a,this.container.style.opacity=String(i),e<1?this.animationFrameId=requestAnimationFrame(()=>this.animate()):this.complete()}complete(){this.isRunning=!1,this.initialTransform&&"none"!==this.initialTransform?this.container.style.transform=this.initialTransform:this.container.style.transform="",this.container.style.opacity="1",this.animationFrameId&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null),this.config.onComplete&&this.config.onComplete()}reset(){this.stop(),this.hasTriggered=!1,this.setInitialPosition()}stop(){this.isRunning=!1,this.animationFrameId&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null)}updateConfig(t){const e=this.isRunning;this.stop(),this.config={...this.config,...t,onStart:t.onStart??this.config.onStart,onComplete:t.onComplete??this.config.onComplete},t.distance&&(this.targetDistance=this.parseDistance(this.config.distance)),this.setInitialPosition(),void 0===t.threshold&&void 0===t.rootMargin&&void 0===t.root||(this.visibilityManager&&(this.visibilityManager.destroy(),this.visibilityManager=null),this.setupVisibilityManager()),e&&this.config.enabled&&this.start()}destroy(){this.stop(),this.visibilityManager&&(this.visibilityManager.destroy(),this.visibilityManager=null),this.container.style.transform=this.initialTransform||"",this.container.style.opacity="",this.container.style.transition=""}}const u=t.defineComponent({__name:"TextToParticle",props:{className:{default:""},style:{default:()=>({})},text:{default:"mason effect"},densityStep:{default:2},maxParticles:{default:3200},pointSize:{default:.5},ease:{default:.05},repelRadius:{default:150},repelStrength:{default:1},particleColor:{default:"#fff"},fontFamily:{default:"Inter, system-ui, Arial"},fontSize:{default:null},width:{default:null},height:{default:null},devicePixelRatio:{default:null},debounceDelay:{},onReady:{type:Function,default:null},onUpdate:{type:Function,default:null}},emits:["ready","update"],setup(e,{expose:i,emit:s}){const o=e,a=s,r=t.ref(null);let l=null;return t.watch(()=>[o.text,o.densityStep,o.maxParticles,o.pointSize,o.ease,o.repelRadius,o.repelStrength,o.particleColor,o.fontFamily,o.fontSize,o.width,o.height,o.devicePixelRatio],()=>{l&&l.updateConfig({text:o.text,densityStep:o.densityStep,maxParticles:o.maxParticles,pointSize:o.pointSize,ease:o.ease,repelRadius:o.repelRadius,repelStrength:o.repelStrength,particleColor:o.particleColor,fontFamily:o.fontFamily,fontSize:o.fontSize,width:o.width,height:o.height,devicePixelRatio:o.devicePixelRatio})}),t.onMounted(()=>{(()=>{if(!r.value)return;const t={text:o.text,densityStep:o.densityStep,maxParticles:o.maxParticles,pointSize:o.pointSize,ease:o.ease,repelRadius:o.repelRadius,repelStrength:o.repelStrength,particleColor:o.particleColor,fontFamily:o.fontFamily,fontSize:o.fontSize,width:o.width,height:o.height,devicePixelRatio:o.devicePixelRatio,onReady:t=>{o.onReady&&o.onReady(t),a("ready",t)},onUpdate:t=>{o.onUpdate&&o.onUpdate(t),a("update",t)}};l=new n(r.value,t)})()}),t.onBeforeUnmount(()=>{l&&(l.destroy(),l=null)}),i({morph:t=>{l&&l.morph(t)},scatter:()=>{l&&l.scatter()},updateConfig:t=>{l&&l.updateConfig(t)},destroy:()=>{l&&(l.destroy(),l=null)}}),(i,n)=>(t.openBlock(),t.createElementBlock("div",{ref_key:"container",ref:r,class:t.normalizeClass(e.className),style:t.normalizeStyle(e.style)},null,6))}}),g=t.defineComponent({__name:"Count",props:{className:{default:""},style:{default:()=>({})},targetValue:{default:0},duration:{default:2e3},startValue:{default:0},enabled:{type:Boolean,default:!0},easing:{type:Function,default:()=>t=>t},threshold:{default:.2},rootMargin:{default:"0px 0px -100px 0px"},triggerOnce:{type:Boolean,default:!1},onUpdate:{type:Function,default:null},onComplete:{type:Function,default:null}},emits:["update","complete"],setup(e,{expose:i,emit:n}){const s=e,a=n,r=t.ref(null);let l=null;return t.watch(()=>[s.targetValue,s.duration,s.startValue,s.enabled,s.easing,s.threshold,s.rootMargin,s.triggerOnce],()=>{l&&l.updateConfig({targetValue:s.targetValue,duration:s.duration,startValue:s.startValue,enabled:s.enabled,easing:s.easing,threshold:s.threshold,rootMargin:s.rootMargin,triggerOnce:s.triggerOnce,onUpdate:t=>{s.onUpdate&&s.onUpdate(t),a("update",t)},onComplete:()=>{s.onComplete&&s.onComplete(),a("complete")}})}),t.onMounted(()=>{(()=>{if(!r.value)return;const t={targetValue:s.targetValue,duration:s.duration,startValue:s.startValue,enabled:s.enabled,easing:s.easing,threshold:s.threshold,rootMargin:s.rootMargin,triggerOnce:s.triggerOnce,onUpdate:t=>{s.onUpdate&&s.onUpdate(t),a("update",t)},onComplete:()=>{s.onComplete&&s.onComplete(),a("complete")}};l=new o(r.value,t)})()}),t.onBeforeUnmount(()=>{l&&(l.destroy(),l=null)}),i({start:()=>{l&&l.start()},stop:()=>{l&&l.stop()},reset:()=>{l&&l.reset()},getValue:()=>l?l.getValue():0,updateConfig:t=>{l&&l.updateConfig(t)},destroy:()=>{l&&(l.destroy(),l=null)}}),(i,n)=>(t.openBlock(),t.createElementBlock("div",{ref_key:"container",ref:r,class:t.normalizeClass(e.className),style:t.normalizeStyle(e.style)},null,6))}}),p=t.defineComponent({__name:"Typing",props:{className:{},style:{},onUpdate:{},onComplete:{},text:{},speed:{default:50},delay:{default:0},enabled:{type:Boolean,default:!0},threshold:{default:.2},rootMargin:{default:"0px 0px -100px 0px"},triggerOnce:{type:Boolean,default:!1},showCursor:{type:Boolean,default:!0},cursorChar:{default:"|"}},setup(e,{expose:i}){const n=e,s=t.ref(null),o=t.ref(null);return t.onMounted(()=>{if(!s.value)return;const t={text:n.text,speed:n.speed,delay:n.delay,enabled:n.enabled,threshold:n.threshold,rootMargin:n.rootMargin,triggerOnce:n.triggerOnce,showCursor:n.showCursor,cursorChar:n.cursorChar,onUpdate:n.onUpdate,onComplete:n.onComplete};o.value=new h(s.value,t)}),t.onUnmounted(()=>{o.value&&(o.value.destroy(),o.value=null)}),t.watch(()=>n.text,t=>{o.value&&t!==o.value.originalText&&o.value.setText(t)}),i({start:()=>{var t;return null==(t=o.value)?void 0:t.start()},stop:()=>{var t;return null==(t=o.value)?void 0:t.stop()},reset:()=>{var t;return null==(t=o.value)?void 0:t.reset()},setText:t=>{var e;return null==(e=o.value)?void 0:e.setText(t)},destroy:()=>{o.value&&(o.value.destroy(),o.value=null)}}),(i,n)=>(t.openBlock(),t.createElementBlock("div",{ref_key:"containerRef",ref:s,class:t.normalizeClass(e.className),style:t.normalizeStyle(e.style)},null,6))}}),f=t.defineComponent({__name:"ScrollFadeIn",props:{className:{default:""},style:{default:()=>({})},direction:{default:"bottom"},distance:{default:"50px"},duration:{default:800},threshold:{default:.1},rootMargin:{default:"0px"},root:{default:null},triggerOnce:{type:Boolean,default:!1},enabled:{type:Boolean,default:!0},onStart:{type:Function,default:null},onComplete:{type:Function,default:null}},emits:["start","complete"],setup(e,{expose:i,emit:n}){const s=e,o=n,a=t.ref(null);let r=null;return t.watch(()=>[s.direction,s.distance,s.duration,s.threshold,s.rootMargin,s.root,s.triggerOnce,s.enabled],()=>{r&&r.updateConfig({direction:s.direction,distance:s.distance,duration:s.duration,threshold:s.threshold,rootMargin:s.rootMargin,root:s.root,triggerOnce:s.triggerOnce,enabled:s.enabled,onStart:()=>{s.onStart&&s.onStart(),o("start")},onComplete:()=>{s.onComplete&&s.onComplete(),o("complete")}})}),t.onMounted(()=>{(()=>{if(!a.value)return;const t={direction:s.direction,distance:s.distance,duration:s.duration,threshold:s.threshold,rootMargin:s.rootMargin,root:s.root,triggerOnce:s.triggerOnce,enabled:s.enabled,onStart:()=>{s.onStart&&s.onStart(),o("start")},onComplete:()=>{s.onComplete&&s.onComplete(),o("complete")}};r=new c(a.value,t)})()}),t.onBeforeUnmount(()=>{r&&(r.destroy(),r=null)}),i({start:()=>{r&&r.start()},stop:()=>{r&&r.stop()},reset:()=>{r&&r.reset()},updateConfig:t=>{r&&r.updateConfig(t)},destroy:()=>{r&&(r.destroy(),r=null)}}),(i,n)=>(t.openBlock(),t.createElementBlock("div",{ref_key:"container",ref:a,class:t.normalizeClass(e.className),style:t.normalizeStyle(e.style)},[t.renderSlot(i.$slots,"default")],6))}});exports.Count=g,exports.MasonEffect=u,exports.ScrollFadeIn=f,exports.TextToParticle=u,exports.Typing=p,exports.default=u;
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("vue");class e{constructor(t,e={}){this.container=t,this.options={threshold:e.threshold??.1,rootMargin:e.rootMargin??"0px",root:e.root??null,onVisible:e.onVisible,onHidden:e.onHidden},this.intersectionObserver=null,this.visibilityChangeHandler=null,this.isVisible=!1,this.isPageVisible="undefined"==typeof document||!document.hidden,this.setupIntersectionObserver(),this.setupPageVisibility()}setupIntersectionObserver(){if("undefined"==typeof window||void 0===window.IntersectionObserver)return this.isVisible=!0,void(this.isPageVisible&&this.options.onVisible&&this.options.onVisible());this.intersectionObserver=new IntersectionObserver(t=>{for(const e of t)e.target===this.container&&(e.isIntersecting?(this.isVisible=!0,this.isPageVisible&&this.options.onVisible&&this.options.onVisible()):(this.isVisible=!1,this.options.onHidden&&this.options.onHidden()))},{threshold:this.options.threshold,rootMargin:this.options.rootMargin,root:this.options.root||null}),this.intersectionObserver.observe(this.container)}setupPageVisibility(){"undefined"!=typeof document&&(this.visibilityChangeHandler=()=>{const t=this.isPageVisible;this.isPageVisible=!document.hidden,document.hidden?this.options.onHidden&&this.options.onHidden():t!==this.isPageVisible&&this.isVisible&&this.options.onVisible&&this.options.onVisible()},document.addEventListener("visibilitychange",this.visibilityChangeHandler),document.hidden&&this.isVisible&&this.options.onHidden&&this.options.onHidden())}getIsVisible(){return this.isVisible&&this.isPageVisible}updateOptions(t){this.options={...this.options,...t},this.intersectionObserver&&(this.intersectionObserver.disconnect(),this.intersectionObserver=null),this.setupIntersectionObserver()}destroy(){this.intersectionObserver&&(this.intersectionObserver.disconnect(),this.intersectionObserver=null),this.visibilityChangeHandler&&"undefined"!=typeof document&&(document.removeEventListener("visibilitychange",this.visibilityChangeHandler),this.visibilityChangeHandler=null)}}function i(t,e){let i=null;return function(...n){null!==i&&clearTimeout(i),i=setTimeout(()=>{i=null,t.apply(this,n)},e)}}class n{constructor(t,e={}){if(this.container="string"==typeof t?document.querySelector(t):t,!this.container)throw new Error("Container element not found");this.config={text:e.text||"mason effect",densityStep:e.densityStep??2,maxParticles:e.maxParticles??3200,pointSize:e.pointSize??.5,ease:e.ease??.05,repelRadius:e.repelRadius??150,repelStrength:e.repelStrength??1,particleColor:e.particleColor||"#fff",fontFamily:e.fontFamily||"Inter, system-ui, Arial",fontSize:e.fontSize||null,width:e.width||null,height:e.height||null,devicePixelRatio:e.devicePixelRatio??null,onReady:e.onReady||null,onUpdate:e.onUpdate||null},this.canvas=document.createElement("canvas");const n=this.canvas.getContext("2d",{willReadFrequently:!0});if(!n)throw new Error("Canvas context not available");this.ctx=n,this.container.appendChild(this.canvas),this.canvas.style.display="block",this.offCanvas=document.createElement("canvas");const s=this.offCanvas.getContext("2d",{willReadFrequently:!0});if(!s)throw new Error("Offscreen canvas context not available");this.offCtx=s,this.W=0,this.H=0,this.DPR=this.config.devicePixelRatio||Math.min(window.devicePixelRatio||1,1.8),this.particles=[],this.mouse={x:0,y:0,down:!1},this.animationId=null,this.isRunning=!1,this.visibilityManager=null,this.debounceDelay=e.debounceDelay??150;const o=this.handleResize.bind(this);this.handleResize=i(o,this.debounceDelay),this.handleMouseMove=this.handleMouseMove.bind(this),this.handleMouseLeave=this.handleMouseLeave.bind(this),this.handleMouseDown=this.handleMouseDown.bind(this),this.handleMouseUp=this.handleMouseUp.bind(this),this._debouncedMorph=i(this._morphInternal.bind(this),this.debounceDelay),this._debouncedUpdateConfig=i(this._updateConfigInternal.bind(this),this.debounceDelay),this.init()}init(){this.resize(),this.setupEventListeners(),this.setupVisibilityManager(),this.config.onReady&&this.config.onReady(this)}setupVisibilityManager(){this.visibilityManager=new e(this.container,{threshold:.1,onVisible:()=>{this.start()},onHidden:()=>{this.stop()}})}resize(){const t=this.container.getBoundingClientRect(),e=this.config.width||t.width||this.container.clientWidth||window.innerWidth,i=this.config.height||t.height||this.container.clientHeight||.7*window.innerHeight;if(e<=0||i<=0)return;this.W=Math.floor(e*this.DPR),this.H=Math.floor(i*this.DPR);const n=4096;if(this.W>n||this.H>n){const t=Math.min(n/this.W,n/this.H);this.W=Math.floor(this.W*t),this.H=Math.floor(this.H*t),this.DPR=this.DPR*t}this.canvas.width=this.W,this.canvas.height=this.H,this.canvas.style.width=e+"px",this.canvas.style.height=i+"px",this.W>0&&this.H>0&&(this.buildTargets(),this.particles.length||this.initParticles())}measureTextFit(t,e,i,n){this.offCtx.font=`400 ${t}px ${this.config.fontFamily}`;const s=e.split("\n"),o=t,a=.1*t,r=.05*t;let l=0;for(const d of s){if(0===d.length)continue;const t=this.offCtx.measureText(d).width+r*(d.length>0?d.length-1:0);l=Math.max(l,t)}const h=s.length>0?o*s.length+a*(s.length-1):o;return{width:l,height:h,fits:l<=i&&h<=n}}findOptimalFontSize(t,e,i,n){if(this.measureTextFit(n,t,e,i).fits)return n;if(n<=12)return 12;let s=12,o=n,a=12;for(;s<=o;){const n=Math.floor((s+o)/2);this.measureTextFit(n,t,e,i).fits?(a=n,s=n+1):o=n-1}return a}buildTargets(){if(this.W<=0||this.H<=0)return;const t=this.config.text;this.offCanvas.width=this.W,this.offCanvas.height=this.H,this.offCtx.clearRect(0,0,this.offCanvas.width,this.offCanvas.height);const e=Math.min(this.W,this.H),i=this.config.fontSize||Math.max(80,Math.floor(.18*e)),n=this.W-80,s=this.H-80,o=this.findOptimalFontSize(t,n,s,i);this.offCtx.fillStyle="#ffffff",this.offCtx.textAlign="center",this.offCtx.textBaseline="middle",this.offCtx.font=`400 ${o}px ${this.config.fontFamily}`;const a=t.split("\n"),r=o,l=.1*o,h=.05*o,d=a.length>0?r*a.length+l*(a.length-1):r;let c=this.H/2-d/2+r/2;for(const f of a){if(0===f.length){c+=r+l;continue}const t=f.split(""),e=this.offCtx.measureText(f).width+h*(t.length>0?t.length-1:0);let i=this.W/2-e/2;for(const n of t)this.offCtx.fillText(n,i+this.offCtx.measureText(n).width/2,c),i+=this.offCtx.measureText(n).width+h;c+=r+l}const u=Math.max(2,this.config.densityStep),g=this.offCtx.getImageData(0,0,this.W,this.H).data,p=[];for(let f=0;f<this.H;f+=u)for(let t=0;t<this.W;t+=u){const e=4*(f*this.W+t);g[e]+g[e+1]+g[e+2]>600&&p.push({x:t,y:f})}for(;p.length>this.config.maxParticles;)p.splice(Math.floor(Math.random()*p.length),1);if(this.particles.length<p.length){const t=p.length-this.particles.length;for(let e=0;e<t;e++)this.particles.push(this.makeParticle())}else this.particles.length>p.length&&(this.particles.length=p.length);for(let f=0;f<this.particles.length;f++){const t=this.particles[f],e=p[f];t.tx=e.x,t.ty=e.y}}makeParticle(){const t=Math.random()*this.W,e=Math.random()*this.H;return{x:t,y:e,vx:0,vy:0,tx:t,ty:e,initialX:t,initialY:e,j:Math.random()*Math.PI*2}}initParticles(){for(const t of this.particles){const e=Math.random()*this.W,i=Math.random()*this.H;t.x=e,t.y=i,t.vx=t.vy=0,t.initialX=e,t.initialY=i}}scatter(){for(const t of this.particles)void 0!==t.initialX&&void 0!==t.initialY?(t.tx=t.initialX,t.ty=t.initialY):(t.initialX=t.x,t.initialY=t.y,t.tx=t.initialX,t.ty=t.initialY)}morph(t){this._debouncedMorph(t)}_morphInternal(t){if(0!==this.W&&0!==this.H||this.resize(),"string"==typeof t)this.config.text=t,this.buildTargets();else if(t&&"object"==typeof t){const e=void 0!==t.text;this.config={...this.config,...t},e&&this.buildTargets()}else this.buildTargets()}update(){this.ctx.clearRect(0,0,this.W,this.H);for(const n of this.particles){let t=(n.tx-n.x)*this.config.ease,e=(n.ty-n.y)*this.config.ease;if(this.mouse.x||this.mouse.y){const i=n.x-this.mouse.x,s=n.y-this.mouse.y,o=i*i+s*s,a=this.config.repelRadius*this.DPR;if(o<a*a){const n=Math.sqrt(o)+1e-4,r=(this.mouse.down?-1:1)*this.config.repelStrength*(1-n/a);t+=i/n*r*6,e+=s/n*r*6}}n.j+=2,t+=.05*Math.cos(n.j),e+=.05*Math.sin(1.3*n.j),n.vx=(n.vx+t)*Math.random(),n.vy=(n.vy+e)*Math.random(),n.x+=n.vx,n.y+=n.vy}this.ctx.fillStyle=this.config.particleColor;const t=Math.min(this.W,this.H)/this.DPR,e=Math.max(.5,Math.min(2,t/1920)),i=this.config.pointSize*this.DPR*e;for(const n of this.particles)this.ctx.beginPath(),this.ctx.arc(n.x,n.y,i,0,2*Math.PI),this.ctx.fill();this.config.onUpdate&&this.config.onUpdate(this)}animate(){this.isRunning&&(this.update(),this.animationId=requestAnimationFrame(()=>this.animate()))}start(){this.isRunning||(this.isRunning=!0,this.animate())}stop(){this.isRunning=!1,this.animationId&&(cancelAnimationFrame(this.animationId),this.animationId=null)}setupEventListeners(){window.addEventListener("resize",this.handleResize),this.canvas.addEventListener("mousemove",this.handleMouseMove),this.canvas.addEventListener("mouseleave",this.handleMouseLeave),this.canvas.addEventListener("mousedown",this.handleMouseDown),window.addEventListener("mouseup",this.handleMouseUp)}removeEventListeners(){window.removeEventListener("resize",this.handleResize),this.canvas.removeEventListener("mousemove",this.handleMouseMove),this.canvas.removeEventListener("mouseleave",this.handleMouseLeave),this.canvas.removeEventListener("mousedown",this.handleMouseDown),window.removeEventListener("mouseup",this.handleMouseUp)}handleResize(){this.resize()}handleMouseMove(t){const e=this.canvas.getBoundingClientRect();this.mouse.x=(t.clientX-e.left)*this.DPR,this.mouse.y=(t.clientY-e.top)*this.DPR}handleMouseLeave(){this.mouse.x=this.mouse.y=0}handleMouseDown(){this.mouse.down=!0}handleMouseUp(){this.mouse.down=!1}updateConfig(t){this._debouncedUpdateConfig(t)}_updateConfigInternal(t){this.config={...this.config,...t},t.text&&this.buildTargets()}destroy(){this.stop(),this.removeEventListeners(),this.visibilityManager&&(this.visibilityManager.destroy(),this.visibilityManager=null),this.canvas&&this.canvas.parentNode&&this.canvas.parentNode.removeChild(this.canvas)}}const s={linear:t=>t};class o{constructor(t,e){if(this.container="string"==typeof t?document.querySelector(t):t,!this.container)throw new Error("Container element not found");this.config={targetValue:e.targetValue,duration:e.duration??2e3,startValue:e.startValue??0,enabled:e.enabled??!0,easing:e.easing??s.linear,threshold:e.threshold??.2,rootMargin:e.rootMargin??"0px 0px -100px 0px",triggerOnce:e.triggerOnce??!1,onUpdate:e.onUpdate||null,onComplete:e.onComplete||null},this.currentValue=this.config.startValue,this.startTime=null,this.animationFrameId=null,this.visibilityManager=null,this.isRunning=!1,this.hasTriggered=!1,this.init()}init(){this.updateDisplay(this.config.startValue),this.setupVisibilityManager()}setupVisibilityManager(){this.visibilityManager=new e(this.container,{threshold:this.config.threshold,rootMargin:this.config.rootMargin,onVisible:()=>{!this.hasTriggered&&this.config.enabled&&(this.hasTriggered=!0,this.start())},onHidden:()=>{!this.config.triggerOnce&&this.isRunning&&this.reset()}})}start(){if(this.isRunning)return;if(!this.config.enabled)return;this.isRunning=!0,this.startTime=null,this.currentValue=this.config.startValue,this.updateDisplay(this.currentValue);const t=e=>{null===this.startTime&&(this.startTime=e);const i=e-this.startTime,n=Math.min(i/this.config.duration,1),s=this.config.easing(n);this.currentValue=Math.floor(this.config.startValue+(this.config.targetValue-this.config.startValue)*s),this.updateDisplay(this.currentValue),this.config.onUpdate&&this.config.onUpdate(this.currentValue),n<1?this.animationFrameId=requestAnimationFrame(t):(this.currentValue=this.config.targetValue,this.updateDisplay(this.currentValue),this.isRunning=!1,this.config.onComplete&&this.config.onComplete())};this.animationFrameId=requestAnimationFrame(t)}stop(){this.isRunning=!1,null!==this.animationFrameId&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null)}reset(){this.stop(),this.currentValue=this.config.startValue,this.updateDisplay(this.currentValue),this.hasTriggered=!1,this.startTime=null}updateDisplay(t){this.container.textContent=this.formatNumber(t)}formatNumber(t){return Math.floor(t).toLocaleString()}updateConfig(t){const e=this.isRunning;this.stop(),this.config={...this.config,...t,onUpdate:void 0!==t.onUpdate?t.onUpdate:this.config.onUpdate,onComplete:void 0!==t.onComplete?t.onComplete:this.config.onComplete},void 0!==t.targetValue?(this.reset(),e&&this.config.enabled&&this.start()):e&&this.config.enabled&&this.start()}getValue(){return this.currentValue}destroy(){this.stop(),this.visibilityManager&&(this.visibilityManager.destroy(),this.visibilityManager=null)}}function a(t){const e=t.charCodeAt(0);if(e<44032||e>55203)return[t];const i=e-44032,n=Math.floor(i/588),s=Math.floor(i%588/28),o=i%28,a=["","ㄱ","ㄲ","ㄳ","ㄴ","ㄵ","ㄶ","ㄷ","ㄹ","ㄺ","ㄻ","ㄼ","ㄽ","ㄾ","ㄿ","ㅀ","ㅁ","ㅂ","ㅄ","ㅅ","ㅆ","ㅇ","ㅈ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"],r=[];return r.push(["ㄱ","ㄲ","ㄴ","ㄷ","ㄸ","ㄹ","ㅁ","ㅂ","ㅃ","ㅅ","ㅆ","ㅇ","ㅈ","ㅉ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"][n]),r.push(["ㅏ","ㅐ","ㅑ","ㅒ","ㅓ","ㅔ","ㅕ","ㅖ","ㅗ","ㅘ","ㅙ","ㅚ","ㅛ","ㅜ","ㅝ","ㅞ","ㅟ","ㅠ","ㅡ","ㅢ","ㅣ"][s]),o>0&&r.push(a[o]),r}function r(t,e,i){const n=["ㄱ","ㄲ","ㄴ","ㄷ","ㄸ","ㄹ","ㅁ","ㅂ","ㅃ","ㅅ","ㅆ","ㅇ","ㅈ","ㅉ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"].indexOf(t),s=["ㅏ","ㅐ","ㅑ","ㅒ","ㅓ","ㅔ","ㅕ","ㅖ","ㅗ","ㅘ","ㅙ","ㅚ","ㅛ","ㅜ","ㅝ","ㅞ","ㅟ","ㅠ","ㅡ","ㅢ","ㅣ"].indexOf(e),o=i?["","ㄱ","ㄲ","ㄳ","ㄴ","ㄵ","ㄶ","ㄷ","ㄹ","ㄺ","ㄻ","ㄼ","ㄽ","ㄾ","ㄿ","ㅀ","ㅁ","ㅂ","ㅄ","ㅅ","ㅆ","ㅇ","ㅈ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"].indexOf(i):0;if(-1===n||-1===s)return t+(e||"")+(i||"");const a=44032+21*n*28+28*s+o;return String.fromCharCode(a)}function l(t){const e=[],i=[];for(let n=0;n<t.length;n++){const s=t[n],o=s.charCodeAt(0),r=e.length;if(o>=44032&&o<=55203){const t=a(s);e.push(...t),i.push({start:r,end:e.length,isHangul:!0})}else e.push(s),i.push({start:r,end:e.length,isHangul:!1})}return{units:e,charUnitRanges:i}}class h{constructor(t,e){if(this.container="string"==typeof t?document.querySelector(t):t,!this.container)throw new Error("Container element not found");this.originalText=e.text,this.config={text:e.text,speed:e.speed??50,delay:e.delay??0,enabled:e.enabled??!0,threshold:e.threshold??.2,rootMargin:e.rootMargin??"0px 0px -100px 0px",triggerOnce:e.triggerOnce??!1,showCursor:e.showCursor??!0,cursorChar:e.cursorChar??"|",onUpdate:e.onUpdate||null,onComplete:e.onComplete||null};const i=l(this.config.text);this.textUnits=i.units,this.charUnitRanges=i.charUnitRanges,this.currentIndex=0,this.displayedText="",this.timeoutId=null,this.visibilityManager=null,this.isRunning=!1,this.hasTriggered=!1,this.init()}init(){this.updateDisplay(""),this.injectStyles(),this.setupVisibilityManager()}injectStyles(){if(document.getElementById("masoneffect-typing-styles"))return;const t=document.createElement("style");t.id="masoneffect-typing-styles",t.textContent="\n .typing-char {\n transition: opacity 0.3s ease-in;\n display: inline-block;\n }\n .typing-cursor {\n display: inline-block;\n }\n ",document.head.appendChild(t),this.container.style.whiteSpace="pre-wrap"}setupVisibilityManager(){this.visibilityManager=new e(this.container,{threshold:this.config.threshold,rootMargin:this.config.rootMargin,onVisible:()=>{!this.hasTriggered&&this.config.enabled&&(this.hasTriggered=!0,setTimeout(()=>this.start(),this.config.delay))},onHidden:()=>{}})}buildTextFromUnits(t){if(0===t)return"";let e="";for(let i=0;i<this.charUnitRanges.length;i++){const n=this.charUnitRanges[i];if(n.start>=t)break;const s=Math.min(t-n.start,n.end-n.start);if(s<=0)break;if(n.isHangul){const t=this.textUnits.slice(n.start,n.start+s);1===t.length?e+=t[0]:2===t.length?e+=r(t[0],t[1]):t.length>=3&&(e+=r(t[0],t[1],t[2]))}else s>0&&(e+=this.textUnits[n.start])}return e}start(){this.isRunning||(this.isRunning=!0,this.currentIndex=0,this.displayedText="",this.typeNext())}typeNext(){if(this.currentIndex>=this.textUnits.length)return this.isRunning=!1,this.config.showCursor&&this.updateDisplay(this.originalText),void(this.config.onComplete&&this.config.onComplete());this.displayedText=this.buildTextFromUnits(this.currentIndex+1);let t=this.displayedText;this.config.showCursor&&(t+=this.config.cursorChar),this.updateDisplay(t),this.config.onUpdate&&this.config.onUpdate(this.displayedText),this.currentIndex++,this.timeoutId=setTimeout(()=>{this.typeNext()},this.config.speed)}stop(){this.isRunning=!1,this.timeoutId&&(clearTimeout(this.timeoutId),this.timeoutId=null)}reset(){this.stop(),this.currentIndex=0,this.displayedText="",this.hasTriggered=!1,this.updateDisplay("")}updateDisplay(t){const e=t.replace(new RegExp(this.escapeHtml(this.config.cursorChar)+"$"),""),i=t.endsWith(this.config.cursorChar),n=(this.container.textContent||"").replace(new RegExp(this.config.cursorChar+"$"),"");let s="";for(let a=0;a<e.length;a++){const t=e[a],i=a>=n.length,o=" "===t?" ":this.escapeHtml(t);s+=i?`<span class="typing-char typing-fade-in" style="opacity: 0;">${o}</span>`:`<span class="typing-char" style="opacity: 1;">${o}</span>`}i&&(s+=`<span class="typing-cursor">${this.escapeHtml(this.config.cursorChar)}</span>`),this.container.innerHTML=s;const o=this.container.querySelectorAll(".typing-fade-in");o.length>0&&requestAnimationFrame(()=>{o.forEach(t=>{t.style.opacity="1",t.classList.remove("typing-fade-in")})})}escapeHtml(t){const e=document.createElement("div");return e.textContent=t,e.innerHTML}setText(t){this.originalText=t,this.config.text=t;const e=l(t);this.textUnits=e.units,this.charUnitRanges=e.charUnitRanges,this.reset(),this.config.enabled&&setTimeout(()=>this.start(),this.config.delay)}destroy(){this.stop(),this.visibilityManager&&(this.visibilityManager.destroy(),this.visibilityManager=null)}}const d=t=>--t*t*t+1;class c{constructor(t,e={}){if(this.container="string"==typeof t?document.querySelector(t):t,!this.container)throw new Error("Container element not found");this.config={direction:e.direction??"bottom",distance:e.distance??"50px",duration:e.duration??800,threshold:e.threshold??.1,rootMargin:e.rootMargin??"0px",root:e.root??null,triggerOnce:e.triggerOnce??!1,enabled:e.enabled??!0,onStart:e.onStart||null,onComplete:e.onComplete||null},this.easing=d,this.visibilityManager=null,this.animationFrameId=null,this.startTime=null,this.isRunning=!1,this.hasTriggered=!1,this.initialTransform="",this.targetDistance=0,this.init()}init(){const t=window.getComputedStyle(this.container);this.initialTransform="none"!==t.transform?t.transform:this.container.style.transform||"",this.targetDistance=this.parseDistance(this.config.distance),this.setInitialPosition(),this.setupVisibilityManager()}parseDistance(t){const e=t.match(/^(-?\d+\.?\d*)(px|rem|em|%|vh|vw)$/);if(!e){return parseFloat(t)||50}const i=parseFloat(e[1]);switch(e[2]){case"px":default:return i;case"rem":case"em":return i*(parseFloat(getComputedStyle(document.documentElement).fontSize)||16);case"%":const t=this.container.getBoundingClientRect();return i/100*("top"===this.config.direction||"bottom"===this.config.direction?t.height:t.width);case"vh":return i/100*window.innerHeight;case"vw":return i/100*window.innerWidth}}setInitialPosition(){let t=0,e=0;switch(this.config.direction){case"top":e=-this.targetDistance;break;case"right":t=this.targetDistance;break;case"bottom":e=this.targetDistance;break;case"left":t=-this.targetDistance}const i=this.initialTransform||"",n=`translate(${t}px, ${e}px)`;this.container.style.transform=i&&"none"!==i?`${n} ${i}`:n,this.container.style.opacity="0",this.container.style.transition="none"}setupVisibilityManager(){this.visibilityManager=new e(this.container,{threshold:this.config.threshold,rootMargin:this.config.rootMargin,root:this.config.root,onVisible:()=>{this.config.enabled&&(this.config.triggerOnce&&this.hasTriggered||(this.hasTriggered=!0,this.start()))},onHidden:()=>{this.config.enabled&&(this.stop(),this.config.triggerOnce||(this.hasTriggered=!1),this.setInitialPosition())}})}start(){this.isRunning||(this.isRunning=!0,this.startTime=performance.now(),this.config.onStart&&this.config.onStart(),this.container.style.transition="none",this.animate())}animate(){if(!this.isRunning)return;const t=performance.now()-(this.startTime||0),e=Math.min(t/this.config.duration,1),i=this.easing(e);let n=0,s=0;switch(this.config.direction){case"top":s=-this.targetDistance*(1-i);break;case"right":n=this.targetDistance*(1-i);break;case"bottom":s=this.targetDistance*(1-i);break;case"left":n=-this.targetDistance*(1-i)}const o=this.initialTransform||"",a=`translate(${n}px, ${s}px)`;this.container.style.transform=o&&"none"!==o?`${a} ${o}`:a,this.container.style.opacity=String(i),e<1?this.animationFrameId=requestAnimationFrame(()=>this.animate()):this.complete()}complete(){this.isRunning=!1,this.initialTransform&&"none"!==this.initialTransform?this.container.style.transform=this.initialTransform:this.container.style.transform="",this.container.style.opacity="1",this.animationFrameId&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null),this.config.onComplete&&this.config.onComplete()}reset(){this.stop(),this.hasTriggered=!1,this.setInitialPosition()}stop(){this.isRunning=!1,this.animationFrameId&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null)}updateConfig(t){const e=this.isRunning;this.stop(),this.config={...this.config,...t,onStart:t.onStart??this.config.onStart,onComplete:t.onComplete??this.config.onComplete},t.distance&&(this.targetDistance=this.parseDistance(this.config.distance)),this.setInitialPosition(),void 0===t.threshold&&void 0===t.rootMargin&&void 0===t.root||(this.visibilityManager&&(this.visibilityManager.destroy(),this.visibilityManager=null),this.setupVisibilityManager()),e&&this.config.enabled&&this.start()}destroy(){this.stop(),this.visibilityManager&&(this.visibilityManager.destroy(),this.visibilityManager=null),this.container.style.transform=this.initialTransform||"",this.container.style.opacity="",this.container.style.transition=""}}const u=t.defineComponent({__name:"TextToParticle",props:{className:{default:""},style:{default:()=>({})},text:{default:"mason effect"},densityStep:{default:2},maxParticles:{default:3200},pointSize:{default:.5},ease:{default:.05},repelRadius:{default:150},repelStrength:{default:1},particleColor:{default:"#fff"},fontFamily:{default:"Inter, system-ui, Arial"},fontSize:{default:null},width:{default:null},height:{default:null},devicePixelRatio:{default:null},debounceDelay:{},onReady:{type:Function,default:null},onUpdate:{type:Function,default:null}},emits:["ready","update"],setup(e,{expose:i,emit:s}){const o=e,a=s,r=t.ref(null);let l=null;return t.watch(()=>[o.text,o.densityStep,o.maxParticles,o.pointSize,o.ease,o.repelRadius,o.repelStrength,o.particleColor,o.fontFamily,o.fontSize,o.width,o.height,o.devicePixelRatio],()=>{l&&l.updateConfig({text:o.text,densityStep:o.densityStep,maxParticles:o.maxParticles,pointSize:o.pointSize,ease:o.ease,repelRadius:o.repelRadius,repelStrength:o.repelStrength,particleColor:o.particleColor,fontFamily:o.fontFamily,fontSize:o.fontSize,width:o.width,height:o.height,devicePixelRatio:o.devicePixelRatio})}),t.onMounted(()=>{(()=>{if(!r.value)return;const t={text:o.text,densityStep:o.densityStep,maxParticles:o.maxParticles,pointSize:o.pointSize,ease:o.ease,repelRadius:o.repelRadius,repelStrength:o.repelStrength,particleColor:o.particleColor,fontFamily:o.fontFamily,fontSize:o.fontSize,width:o.width,height:o.height,devicePixelRatio:o.devicePixelRatio,onReady:t=>{o.onReady&&o.onReady(t),a("ready",t)},onUpdate:t=>{o.onUpdate&&o.onUpdate(t),a("update",t)}};l=new n(r.value,t)})()}),t.onBeforeUnmount(()=>{l&&(l.destroy(),l=null)}),i({morph:t=>{l&&l.morph(t)},scatter:()=>{l&&l.scatter()},updateConfig:t=>{l&&l.updateConfig(t)},destroy:()=>{l&&(l.destroy(),l=null)}}),(i,n)=>(t.openBlock(),t.createElementBlock("div",{ref_key:"container",ref:r,class:t.normalizeClass(e.className),style:t.normalizeStyle(e.style)},null,6))}}),g=t.defineComponent({__name:"Count",props:{className:{default:""},style:{default:()=>({})},targetValue:{default:0},duration:{default:2e3},startValue:{default:0},enabled:{type:Boolean,default:!0},easing:{type:Function,default:()=>t=>t},threshold:{default:.2},rootMargin:{default:"0px 0px -100px 0px"},triggerOnce:{type:Boolean,default:!1},onUpdate:{type:Function,default:null},onComplete:{type:Function,default:null}},emits:["update","complete"],setup(e,{expose:i,emit:n}){const s=e,a=n,r=t.ref(null);let l=null;return t.watch(()=>[s.targetValue,s.duration,s.startValue,s.enabled,s.easing,s.threshold,s.rootMargin,s.triggerOnce],()=>{l&&l.updateConfig({targetValue:s.targetValue,duration:s.duration,startValue:s.startValue,enabled:s.enabled,easing:s.easing,threshold:s.threshold,rootMargin:s.rootMargin,triggerOnce:s.triggerOnce,onUpdate:t=>{s.onUpdate&&s.onUpdate(t),a("update",t)},onComplete:()=>{s.onComplete&&s.onComplete(),a("complete")}})}),t.onMounted(()=>{(()=>{if(!r.value)return;const t={targetValue:s.targetValue,duration:s.duration,startValue:s.startValue,enabled:s.enabled,easing:s.easing,threshold:s.threshold,rootMargin:s.rootMargin,triggerOnce:s.triggerOnce,onUpdate:t=>{s.onUpdate&&s.onUpdate(t),a("update",t)},onComplete:()=>{s.onComplete&&s.onComplete(),a("complete")}};l=new o(r.value,t)})()}),t.onBeforeUnmount(()=>{l&&(l.destroy(),l=null)}),i({start:()=>{l&&l.start()},stop:()=>{l&&l.stop()},reset:()=>{l&&l.reset()},getValue:()=>l?l.getValue():0,updateConfig:t=>{l&&l.updateConfig(t)},destroy:()=>{l&&(l.destroy(),l=null)}}),(i,n)=>(t.openBlock(),t.createElementBlock("div",{ref_key:"container",ref:r,class:t.normalizeClass(e.className),style:t.normalizeStyle(e.style)},null,6))}}),p=t.defineComponent({__name:"Typing",props:{className:{},style:{},onUpdate:{},onComplete:{},text:{},speed:{default:50},delay:{default:0},enabled:{type:Boolean,default:!0},threshold:{default:.2},rootMargin:{default:"0px 0px -100px 0px"},triggerOnce:{type:Boolean,default:!1},showCursor:{type:Boolean,default:!0},cursorChar:{default:"|"}},setup(e,{expose:i}){const n=e,s=t.ref(null),o=t.ref(null);return t.onMounted(()=>{if(!s.value)return;const t={text:n.text,speed:n.speed,delay:n.delay,enabled:n.enabled,threshold:n.threshold,rootMargin:n.rootMargin,triggerOnce:n.triggerOnce,showCursor:n.showCursor,cursorChar:n.cursorChar,onUpdate:n.onUpdate,onComplete:n.onComplete};o.value=new h(s.value,t)}),t.onUnmounted(()=>{o.value&&(o.value.destroy(),o.value=null)}),t.watch(()=>n.text,t=>{o.value&&t!==o.value.originalText&&o.value.setText(t)}),i({start:()=>{var t;return null==(t=o.value)?void 0:t.start()},stop:()=>{var t;return null==(t=o.value)?void 0:t.stop()},reset:()=>{var t;return null==(t=o.value)?void 0:t.reset()},setText:t=>{var e;return null==(e=o.value)?void 0:e.setText(t)},destroy:()=>{o.value&&(o.value.destroy(),o.value=null)}}),(i,n)=>(t.openBlock(),t.createElementBlock("div",{ref_key:"containerRef",ref:s,class:t.normalizeClass(e.className),style:t.normalizeStyle(e.style)},null,6))}}),f=t.defineComponent({__name:"ScrollFadeIn",props:{className:{default:""},style:{default:()=>({})},direction:{default:"bottom"},distance:{default:"50px"},duration:{default:800},threshold:{default:.1},rootMargin:{default:"0px"},root:{default:null},triggerOnce:{type:Boolean,default:!1},enabled:{type:Boolean,default:!0},onStart:{type:Function,default:null},onComplete:{type:Function,default:null}},emits:["start","complete"],setup(e,{expose:i,emit:n}){const s=e,o=n,a=t.ref(null);let r=null;return t.watch(()=>[s.direction,s.distance,s.duration,s.threshold,s.rootMargin,s.root,s.triggerOnce,s.enabled],()=>{r&&r.updateConfig({direction:s.direction,distance:s.distance,duration:s.duration,threshold:s.threshold,rootMargin:s.rootMargin,root:s.root,triggerOnce:s.triggerOnce,enabled:s.enabled,onStart:()=>{s.onStart&&s.onStart(),o("start")},onComplete:()=>{s.onComplete&&s.onComplete(),o("complete")}})}),t.onMounted(()=>{(()=>{if(!a.value)return;const t={direction:s.direction,distance:s.distance,duration:s.duration,threshold:s.threshold,rootMargin:s.rootMargin,root:s.root,triggerOnce:s.triggerOnce,enabled:s.enabled,onStart:()=>{s.onStart&&s.onStart(),o("start")},onComplete:()=>{s.onComplete&&s.onComplete(),o("complete")}};r=new c(a.value,t)})()}),t.onBeforeUnmount(()=>{r&&(r.destroy(),r=null)}),i({start:()=>{r&&r.start()},stop:()=>{r&&r.stop()},reset:()=>{r&&r.reset()},updateConfig:t=>{r&&r.updateConfig(t)},destroy:()=>{r&&(r.destroy(),r=null)}}),(i,n)=>(t.openBlock(),t.createElementBlock("div",{ref_key:"container",ref:a,class:t.normalizeClass(e.className),style:t.normalizeStyle(e.style)},[t.renderSlot(i.$slots,"default")],6))}});exports.Count=g,exports.MasonEffect=u,exports.ScrollFadeIn=f,exports.TextToParticle=u,exports.Typing=p,exports.default=u;
|