ghost 6.10.0 → 6.10.2
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/components/tryghost-i18n-6.10.2.tgz +0 -0
- package/content/themes/source/package.json +1 -1
- package/core/built/admin/assets/{CodeEditorView-avhpDVun.js → CodeEditorView-CgVIQxmb.js} +1 -1
- package/core/built/admin/assets/{chunk.524.708d129c7c4a327ba326.js → chunk.524.66c2b8aaa85914aa68c6.js} +6 -6
- package/core/built/admin/assets/{chunk.582.1e0d013c463825d91e5d.js → chunk.582.cb9ad6e8e02d0def5dd4.js} +9 -9
- package/core/built/admin/assets/{index-D57ukS8_.js → index-Boa1XhLV.js} +1 -1
- package/core/built/admin/assets/{index-C9M06iP5.js → index-DDtqNLO1.js} +1 -1
- package/core/built/admin/assets/{index-CPcmd2_W.js → index-DVmEWo2g.js} +1846 -1846
- package/core/built/admin/assets/{index-BQbH4Lu1.js → index-DhA1mzuZ.js} +1 -1
- package/core/built/admin/assets/{modals-Co2NGwBG.js → modals-C1gy87DF.js} +1 -1
- package/core/built/admin/assets/posts/posts.js +41938 -38576
- package/core/built/admin/assets/stats/stats.js +9 -1
- package/core/built/admin/index-forward.html +3 -3
- package/core/built/admin/index.html +2 -2
- package/core/server/adapters/storage/S3Storage.js +7 -2
- package/core/server/adapters/storage/S3Storage.ts +11 -3
- package/package.json +3 -3
- package/tsconfig.tsbuildinfo +1 -1
- package/components/tryghost-i18n-6.10.0.tgz +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as c}from"./index-CPcmd2_W.js";const z=(n,t)=>n==null?t:t==null?n:Math.max(n,t),C=new WeakMap,ut={onUpdate(n,t,e){if(C.set(e,void 0),!e.computedTrend)return;const i=t.integer.concat(t.fraction).filter(o=>o.type==="integer"||o.type==="fraction"),s=n.integer.concat(n.fraction).filter(o=>o.type==="integer"||o.type==="fraction"),r=i.find(o=>!s.find(l=>l.pos===o.pos&&l.value===o.value)),a=s.find(o=>!i.find(l=>o.pos===l.pos&&o.value===l.value));C.set(e,z(r?.pos,a?.pos))},getDelta(n,t,e){const i=n-t,s=C.get(e.flow);if(!i&&s!=null&&s>=e.pos)return e.length*e.flow.computedTrend}},y=(n,t,e)=>{const i=document.createElement(n),[s,r]=Array.isArray(t)?[void 0,t]:[t,e];return s&&Object.assign(i,s),r?.forEach(a=>i.appendChild(a)),i},J=(n,t)=>{var e;return t==="left"?n.offsetLeft:(((e=n.offsetParent instanceof HTMLElement?n.offsetParent:null)==null?void 0:e.offsetWidth)??0)-n.offsetWidth-n.offsetLeft},G=n=>n.offsetWidth>0&&n.offsetHeight>0,Y=(n,t)=>{!customElements.get(n)&&customElements.define(n,t)};function Z(n,t,{reverse:e=!1}={}){const i=n.length;for(let s=e?i-1:0;e?s>=0:s<i;e?s--:s++)t(n[s],s)}function q(n,t,e,i){const s=t.formatToParts(n);e&&s.unshift({type:"prefix",value:e}),i&&s.push({type:"suffix",value:i});const r=[],a=[],o=[],l=[],u={},p=d=>`${d}:${u[d]=(u[d]??-1)+1}`;let f="",m=!1,g=!1;for(const d of s){f+=d.value;const h=d.type==="minusSign"||d.type==="plusSign"?"sign":d.type;h==="integer"?(m=!0,a.push(...d.value.split("").map(A=>({type:h,value:parseInt(A)})))):h==="group"?a.push({type:h,value:d.value}):h==="decimal"?(g=!0,o.push({type:h,value:d.value,key:p(h)})):h==="fraction"?o.push(...d.value.split("").map(A=>({type:h,value:parseInt(A),key:p(h),pos:-1-u[h]}))):(m||g?l:r).push({type:h,value:d.value,key:p(h)})}const M=[];for(let d=a.length-1;d>=0;d--){const h=a[d];M.unshift(h.type==="integer"?{...h,key:p(h.type),pos:u[h.type]}:{...h,key:p(h.type)})}return{pre:r,integer:M,fraction:o,post:l,valueAsString:f,value:typeof n=="string"?parseFloat(n):n}}const Q=String.raw,K=(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0})(),tt=typeof CSS<"u"&&CSS.supports&&CSS.supports("line-height","mod(1,1)"),w=typeof matchMedia<"u"?matchMedia("(prefers-reduced-motion: reduce)"):null,E="--_number-flow-d-opacity",U="--_number-flow-d-width",R="--_number-flow-dx",k="--_number-flow-d",et=(()=>{try{return CSS.registerProperty({name:E,syntax:"<number>",inherits:!1,initialValue:"0"}),CSS.registerProperty({name:R,syntax:"<length>",inherits:!0,initialValue:"0px"}),CSS.registerProperty({name:U,syntax:"<number>",inherits:!1,initialValue:"0"}),CSS.registerProperty({name:k,syntax:"<number>",inherits:!0,initialValue:"0"}),!0}catch{return!1}})(),it="var(--number-flow-char-height, 1em)",v="var(--number-flow-mask-height, 0.25em)",N=`calc(${v} / 2)`,$="var(--number-flow-mask-width, 0.5em)",_=`calc(${$} / var(--scale-x))`,b="#000 0, transparent 71%",P=Q`:host{display:inline-block;direction:ltr;white-space:nowrap;isolation:isolate;line-height:${it} !important}.number,.number__inner{display:inline-block;transform-origin:left top}:host([data-will-change]) :is(.number,.number__inner,.section,.digit,.digit__num,.symbol){will-change:transform}.number{--scale-x:calc(1 + var(${U}) / var(--width));transform:translateX(var(${R})) scaleX(var(--scale-x));margin:0 calc(-1 * ${$});position:relative;-webkit-mask-image:linear-gradient(to right,transparent 0,#000 ${_},#000 calc(100% - ${_}),transparent ),linear-gradient(to bottom,transparent 0,#000 ${v},#000 calc(100% - ${v}),transparent 100% ),radial-gradient(at bottom right,${b}),radial-gradient(at bottom left,${b}),radial-gradient(at top left,${b}),radial-gradient(at top right,${b});-webkit-mask-size:100% calc(100% - ${v} * 2),calc(100% - ${_} * 2) 100%,${_} ${v},${_} ${v},${_} ${v},${_} ${v};-webkit-mask-position:center,center,top left,top right,bottom right,bottom left;-webkit-mask-repeat:no-repeat}.number__inner{padding:${N} ${$};transform:scaleX(calc(1 / var(--scale-x))) translateX(calc(-1 * var(${R})))}:host > :not(.number){z-index:5}.section,.symbol{display:inline-block;position:relative;isolation:isolate}.section::after{content:'\200b';display:inline-block}.section--justify-left{transform-origin:center left}.section--justify-right{transform-origin:center right}.section > [inert],.symbol > [inert]{margin:0 !important;position:absolute !important;z-index:-1}.digit{display:inline-block;position:relative;--c:var(--current) + var(${k})}.digit__num,.number .section::after{padding:${N} 0}.digit__num{display:inline-block;--offset-raw:mod(var(--length) + var(--n) - mod(var(--c),var(--length)),var(--length));--offset:calc( var(--offset-raw) - var(--length) * round(down,var(--offset-raw) / (var(--length) / 2),1) );--y:clamp(-100%,var(--offset) * 100%,100%);transform:translateY(var(--y))}.digit__num[inert]{position:absolute;top:0;left:50%;transform:translateX(-50%) translateY(var(--y))}.digit:not(.is-spinning) .digit__num[inert]{display:none}.symbol__value{display:inline-block;mix-blend-mode:plus-lighter;white-space:pre}.section--justify-left .symbol > [inert]{left:0}.section--justify-right .symbol > [inert]{right:0}.animate-presence{opacity:calc(1 + var(${E}))}`,st=HTMLElement,B=tt&&K&&et;let S;class I extends st{constructor(){super(),this.created=!1,this.batched=!1;const{animated:t,...e}=this.constructor.defaultProps;this._animated=this.computedAnimated=t,Object.assign(this,e)}get animated(){return this._animated}set animated(t){var e;this.animated!==t&&(this._animated=t,(e=this.shadowRoot)==null||e.getAnimations().forEach(i=>i.finish()))}set data(t){var e;if(t==null)return;const{pre:i,integer:s,fraction:r,post:a,value:o}=t;if(this.created){const l=this._data;this._data=t,this.computedTrend=typeof this.trend=="function"?this.trend(l.value,o):this.trend,this.computedAnimated=B&&this._animated&&(!this.respectMotionPreference||!(w!=null&&w.matches))&&G(this),(e=this.plugins)==null||e.forEach(u=>{var p;return(p=u.onUpdate)==null?void 0:p.call(u,t,l,this)}),this.batched||this.willUpdate(),this._pre.update(i),this._num.update({integer:s,fraction:r}),this._post.update(a),this.batched||this.didUpdate()}else{this._data=t,this.attachShadow({mode:"open"});try{this._internals??(this._internals=this.attachInternals()),this._internals.role="img"}catch{}if(typeof CSSStyleSheet<"u"&&this.shadowRoot.adoptedStyleSheets)S||(S=new CSSStyleSheet,S.replaceSync(P)),this.shadowRoot.adoptedStyleSheets=[S];else{const l=document.createElement("style");l.textContent=P,this.shadowRoot.appendChild(l)}this._pre=new F(this,i,{justify:"right",part:"left"}),this.shadowRoot.appendChild(this._pre.el),this._num=new nt(this,s,r),this.shadowRoot.appendChild(this._num.el),this._post=new F(this,a,{justify:"left",part:"right"}),this.shadowRoot.appendChild(this._post.el),this.created=!0}try{this._internals.ariaLabel=t.valueAsString}catch{}}willUpdate(){this._pre.willUpdate(),this._num.willUpdate(),this._post.willUpdate()}didUpdate(){if(!this.computedAnimated)return;this._abortAnimationsFinish?this._abortAnimationsFinish.abort():this.dispatchEvent(new Event("animationsstart")),this._pre.didUpdate(),this._num.didUpdate(),this._post.didUpdate();const t=new AbortController;Promise.all(this.shadowRoot.getAnimations().map(e=>e.finished)).then(()=>{t.signal.aborted||(this.dispatchEvent(new Event("animationsfinish")),this._abortAnimationsFinish=void 0)}),this._abortAnimationsFinish=t}}I.defaultProps={transformTiming:{duration:900,easing:"linear(0,.005,.019,.039,.066,.096,.129,.165,.202,.24,.278,.316,.354,.39,.426,.461,.494,.526,.557,.586,.614,.64,.665,.689,.711,.731,.751,.769,.786,.802,.817,.831,.844,.856,.867,.877,.887,.896,.904,.912,.919,.925,.931,.937,.942,.947,.951,.955,.959,.962,.965,.968,.971,.973,.976,.978,.98,.981,.983,.984,.986,.987,.988,.989,.99,.991,.992,.992,.993,.994,.994,.995,.995,.996,.996,.9963,.9967,.9969,.9972,.9975,.9977,.9979,.9981,.9982,.9984,.9985,.9987,.9988,.9989,1)"},spinTiming:void 0,opacityTiming:{duration:450,easing:"ease-out"},animated:!0,trend:(n,t)=>Math.sign(t-n),respectMotionPreference:!0,plugins:void 0,digits:void 0};class nt{constructor(t,e,i,{className:s,...r}={}){this.flow=t,this._integer=new L(t,e,{justify:"right",part:"integer"}),this._fraction=new L(t,i,{justify:"left",part:"fraction"}),this._inner=y("span",{className:"number__inner"},[this._integer.el,this._fraction.el]),this.el=y("span",{...r,part:"number",className:`number ${s??""}`},[this._inner])}willUpdate(){this._prevWidth=this.el.offsetWidth,this._prevLeft=this.el.getBoundingClientRect().left,this._integer.willUpdate(),this._fraction.willUpdate()}update({integer:t,fraction:e}){this._integer.update(t),this._fraction.update(e)}didUpdate(){const t=this.el.getBoundingClientRect();this._integer.didUpdate(),this._fraction.didUpdate();const e=this._prevLeft-t.left,i=this.el.offsetWidth,s=this._prevWidth-i;this.el.style.setProperty("--width",String(i)),this.el.animate({[R]:[`${e}px`,"0px"],[U]:[s,0]},{...this.flow.transformTiming,composite:"accumulate"})}}class D{constructor(t,e,{justify:i,className:s,...r},a){this.flow=t,this.children=new Map,this.onCharRemove=l=>()=>{this.children.delete(l)},this.justify=i;const o=e.map(l=>this.addChar(l).el);this.el=y("span",{...r,className:`section section--justify-${i} ${s??""}`},a?a(o):o)}addChar(t,{startDigitsAtZero:e=!1,...i}={}){const s=t.type==="integer"||t.type==="fraction"?new X(this,t.type,e?0:t.value,t.pos,{...i,onRemove:this.onCharRemove(t.key)}):new at(this,t.type,t.value,{...i,onRemove:this.onCharRemove(t.key)});return this.children.set(t.key,s),s}unpop(t){t.el.removeAttribute("inert"),t.el.style.top="",t.el.style[this.justify]=""}pop(t){t.forEach(e=>{e.el.style.top=`${e.el.offsetTop}px`,e.el.style[this.justify]=`${J(e.el,this.justify)}px`}),t.forEach(e=>{e.el.setAttribute("inert",""),e.present=!1})}addNewAndUpdateExisting(t){const e=new Map,i=new Map,s=this.justify==="left",r=s?"prepend":"append";if(Z(t,a=>{let o;this.children.has(a.key)?(o=this.children.get(a.key),i.set(a,o),this.unpop(o),o.present=!0):(o=this.addChar(a,{startDigitsAtZero:!0,animateIn:!0}),e.set(a,o)),this.el[r](o.el)},{reverse:s}),this.flow.computedAnimated){const a=this.el.getBoundingClientRect();e.forEach(o=>{o.willUpdate(a)})}e.forEach((a,o)=>{a.update(o.value)}),i.forEach((a,o)=>{a.update(o.value)})}willUpdate(){const t=this.el.getBoundingClientRect();this._prevOffset=t[this.justify],this.children.forEach(e=>e.willUpdate(t))}didUpdate(){const t=this.el.getBoundingClientRect();this.children.forEach(s=>s.didUpdate(t));const e=t[this.justify],i=this._prevOffset-e;i&&this.children.size&&this.el.animate({transform:[`translateX(${i}px)`,"none"]},{...this.flow.transformTiming,composite:"accumulate"})}}class L extends D{update(t){const e=new Map;this.children.forEach((i,s)=>{t.find(r=>r.key===s)||e.set(s,i),this.unpop(i)}),this.addNewAndUpdateExisting(t),e.forEach(i=>{i instanceof X&&i.update(0)}),this.pop(e)}}class F extends D{update(t){const e=new Map;this.children.forEach((i,s)=>{t.find(r=>r.key===s)||e.set(s,i)}),this.pop(e),this.addNewAndUpdateExisting(t)}}class x{constructor(t,e,{onRemove:i,animateIn:s=!1}={}){this.flow=t,this.el=e,this._present=!0,this._remove=()=>{var r;this.el.remove(),(r=this._onRemove)==null||r.call(this)},this.el.classList.add("animate-presence"),this.flow.computedAnimated&&s&&this.el.animate({[E]:[-.9999,0]},{...this.flow.opacityTiming,composite:"accumulate"}),this._onRemove=i}get present(){return this._present}set present(t){if(this._present!==t){if(this._present=t,t?this.el.removeAttribute("inert"):this.el.setAttribute("inert",""),!this.flow.computedAnimated){t||this._remove();return}this.el.style.setProperty("--_number-flow-d-opacity",t?"0":"-.999"),this.el.animate({[E]:t?[-.9999,0]:[.999,0]},{...this.flow.opacityTiming,composite:"accumulate"}),t?this.flow.removeEventListener("animationsfinish",this._remove):this.flow.addEventListener("animationsfinish",this._remove,{once:!0})}}}class W extends x{constructor(t,e,i,s){super(t.flow,i,s),this.section=t,this.value=e,this.el=i}}class X extends W{constructor(t,e,i,s,r){var a,o;const l=(((o=(a=t.flow.digits)==null?void 0:a[s])==null?void 0:o.max)??9)+1,u=Array.from({length:l}).map((f,m)=>{const g=y("span",{className:"digit__num"},[document.createTextNode(String(m))]);return m!==i&&g.setAttribute("inert",""),g.style.setProperty("--n",String(m)),g}),p=y("span",{part:`digit ${e}-digit`,className:"digit"},u);p.style.setProperty("--current",String(i)),p.style.setProperty("--length",String(l)),super(t,i,p,r),this.pos=s,this._onAnimationsFinish=()=>{this.el.classList.remove("is-spinning")},this._numbers=u,this.length=l}willUpdate(t){const e=this.el.getBoundingClientRect();this._prevValue=this.value;const i=e[this.section.justify]-t[this.section.justify],s=e.width/2;this._prevCenter=this.section.justify==="left"?i+s:i-s}update(t){this.el.style.setProperty("--current",String(t)),this._numbers.forEach((e,i)=>i===t?e.removeAttribute("inert"):e.setAttribute("inert","")),this.value=t}didUpdate(t){const e=this.el.getBoundingClientRect(),i=e[this.section.justify]-t[this.section.justify],s=e.width/2,r=this.section.justify==="left"?i+s:i-s,a=this._prevCenter-r;a&&this.el.animate({transform:[`translateX(${a}px)`,"none"]},{...this.flow.transformTiming,composite:"accumulate"});const o=this.getDelta();o&&(this.el.classList.add("is-spinning"),this.el.animate({[k]:[-o,0]},{...this.flow.spinTiming??this.flow.transformTiming,composite:"accumulate"}),this.flow.addEventListener("animationsfinish",this._onAnimationsFinish,{once:!0}))}getDelta(){var t;if(this.flow.plugins)for(const s of this.flow.plugins){const r=(t=s.getDelta)==null?void 0:t.call(s,this.value,this._prevValue,this);if(r!=null)return r}const e=this.value-this._prevValue,i=this.flow.computedTrend||Math.sign(e);return i<0&&this.value>this._prevValue?this.value-this.length-this._prevValue:i>0&&this.value<this._prevValue?this.length-this._prevValue+this.value:e}}class at extends W{constructor(t,e,i,s){const r=y("span",{className:"symbol__value",textContent:i});super(t,i,y("span",{part:`symbol ${e}`,className:"symbol"},[r]),s),this.type=e,this._children=new Map,this._onChildRemove=a=>()=>{this._children.delete(a)},this._children.set(i,new x(this.flow,r,{onRemove:this._onChildRemove(i)}))}willUpdate(t){if(this.type==="decimal")return;const e=this.el.getBoundingClientRect();this._prevOffset=e[this.section.justify]-t[this.section.justify]}update(t){if(this.value!==t){const e=this._children.get(this.value);e&&(e.present=!1);const i=this._children.get(t);if(i)i.present=!0;else{const s=y("span",{className:"symbol__value",textContent:t});this.el.appendChild(s),this._children.set(t,new x(this.flow,s,{animateIn:!0,onRemove:this._onChildRemove(t)}))}}this.value=t}didUpdate(t){if(this.type==="decimal")return;const e=this.el.getBoundingClientRect()[this.section.justify]-t[this.section.justify],i=this._prevOffset-e;i&&this.el.animate({transform:[`translateX(${i}px)`,"none"]},{...this.flow.transformTiming,composite:"accumulate"})}}const rt=parseInt(c.version.match(/^(\d+)\./)?.[1]),j=rt>=19,ot=["data","digits"];class T extends I{attributeChangedCallback(t,e,i){this[t]=JSON.parse(i)}}T.observedAttributes=j?[]:ot;Y("number-flow-react",T);const lt={},O=j?n=>n:JSON.stringify;function V(n){const{transformTiming:t,spinTiming:e,opacityTiming:i,animated:s,respectMotionPreference:r,trend:a,plugins:o,...l}=n;return[{transformTiming:t,spinTiming:e,opacityTiming:i,animated:s,respectMotionPreference:r,trend:a,plugins:o},l]}class ht extends c.Component{updateProperties(t){if(!this.el)return;this.el.batched=!this.props.isolate;const[e]=V(this.props);Object.entries(e).forEach(([i,s])=>{this.el[i]=s??T.defaultProps[i]}),t?.onAnimationsStart&&this.el.removeEventListener("animationsstart",t.onAnimationsStart),this.props.onAnimationsStart&&this.el.addEventListener("animationsstart",this.props.onAnimationsStart),t?.onAnimationsFinish&&this.el.removeEventListener("animationsfinish",t.onAnimationsFinish),this.props.onAnimationsFinish&&this.el.addEventListener("animationsfinish",this.props.onAnimationsFinish)}componentDidMount(){this.updateProperties(),j&&this.el&&(this.el.digits=this.props.digits,this.el.data=this.props.data)}getSnapshotBeforeUpdate(t){if(this.updateProperties(t),t.data!==this.props.data){if(this.props.group)return this.props.group.willUpdate(),()=>this.props.group?.didUpdate();if(!this.props.isolate)return this.el?.willUpdate(),()=>this.el?.didUpdate()}return null}componentDidUpdate(t,e,i){i?.()}handleRef(t){this.props.innerRef&&(this.props.innerRef.current=t),this.el=t}render(){const[t,{innerRef:e,className:i,data:s,willChange:r,isolate:a,group:o,digits:l,onAnimationsStart:u,onAnimationsFinish:p,...f}]=V(this.props);return c.createElement("number-flow-react",{ref:this.handleRef,"data-will-change":r?"":void 0,class:i,...f,dangerouslySetInnerHTML:{__html:""},suppressHydrationWarning:!0,digits:O(l),data:O(s)})}constructor(t){super(t),this.handleRef=this.handleRef.bind(this)}}const ft=c.forwardRef(function({value:t,locales:e,format:i,prefix:s,suffix:r,...a},o){c.useImperativeHandle(o,()=>l.current,[]);const l=c.useRef(),u=c.useContext(H);u?.useRegister(l);const p=c.useMemo(()=>e?JSON.stringify(e):"",[e]),f=c.useMemo(()=>i?JSON.stringify(i):"",[i]),m=c.useMemo(()=>{const g=lt[`${p}:${f}`]??=new Intl.NumberFormat(e,i);return q(t,g,s,r)},[t,p,f,s,r]);return c.createElement(ht,{...a,group:u,data:m,innerRef:l})}),H=c.createContext(void 0);function mt({children:n}){const t=c.useRef(new Set),e=c.useRef(!1),i=c.useRef(new WeakMap),s=c.useMemo(()=>({useRegister(r){c.useEffect(()=>(t.current.add(r),()=>{t.current.delete(r)}),[])},willUpdate(){e.current||(e.current=!0,t.current.forEach(r=>{const a=r.current;!a||!a.created||(a.willUpdate(),i.current.set(a,!0))}))},didUpdate(){t.current.forEach(r=>{const a=r.current;!a||!i.current.get(a)||(a.didUpdate(),i.current.delete(a))}),e.current=!1}}),[]);return c.createElement(H.Provider,{value:s},n)}const ct=()=>c.useSyncExternalStore(()=>()=>{},()=>B,()=>!1),dt=()=>c.useSyncExternalStore(n=>(w?.addEventListener("change",n),()=>w?.removeEventListener("change",n)),()=>w.matches,()=>!1);function gt({respectMotionPreference:n=!0}={}){const t=ct(),e=dt();return t&&(!n||!e)}export{T as NumberFlowElement,mt as NumberFlowGroup,ut as continuous,ft as default,gt as useCanAnimate,ct as useIsSupported,dt as usePrefersReducedMotion};
|
|
1
|
+
import{r as c}from"./index-DVmEWo2g.js";const z=(n,t)=>n==null?t:t==null?n:Math.max(n,t),C=new WeakMap,ut={onUpdate(n,t,e){if(C.set(e,void 0),!e.computedTrend)return;const i=t.integer.concat(t.fraction).filter(o=>o.type==="integer"||o.type==="fraction"),s=n.integer.concat(n.fraction).filter(o=>o.type==="integer"||o.type==="fraction"),r=i.find(o=>!s.find(l=>l.pos===o.pos&&l.value===o.value)),a=s.find(o=>!i.find(l=>o.pos===l.pos&&o.value===l.value));C.set(e,z(r?.pos,a?.pos))},getDelta(n,t,e){const i=n-t,s=C.get(e.flow);if(!i&&s!=null&&s>=e.pos)return e.length*e.flow.computedTrend}},y=(n,t,e)=>{const i=document.createElement(n),[s,r]=Array.isArray(t)?[void 0,t]:[t,e];return s&&Object.assign(i,s),r?.forEach(a=>i.appendChild(a)),i},J=(n,t)=>{var e;return t==="left"?n.offsetLeft:(((e=n.offsetParent instanceof HTMLElement?n.offsetParent:null)==null?void 0:e.offsetWidth)??0)-n.offsetWidth-n.offsetLeft},G=n=>n.offsetWidth>0&&n.offsetHeight>0,Y=(n,t)=>{!customElements.get(n)&&customElements.define(n,t)};function Z(n,t,{reverse:e=!1}={}){const i=n.length;for(let s=e?i-1:0;e?s>=0:s<i;e?s--:s++)t(n[s],s)}function q(n,t,e,i){const s=t.formatToParts(n);e&&s.unshift({type:"prefix",value:e}),i&&s.push({type:"suffix",value:i});const r=[],a=[],o=[],l=[],u={},p=d=>`${d}:${u[d]=(u[d]??-1)+1}`;let f="",m=!1,g=!1;for(const d of s){f+=d.value;const h=d.type==="minusSign"||d.type==="plusSign"?"sign":d.type;h==="integer"?(m=!0,a.push(...d.value.split("").map(A=>({type:h,value:parseInt(A)})))):h==="group"?a.push({type:h,value:d.value}):h==="decimal"?(g=!0,o.push({type:h,value:d.value,key:p(h)})):h==="fraction"?o.push(...d.value.split("").map(A=>({type:h,value:parseInt(A),key:p(h),pos:-1-u[h]}))):(m||g?l:r).push({type:h,value:d.value,key:p(h)})}const M=[];for(let d=a.length-1;d>=0;d--){const h=a[d];M.unshift(h.type==="integer"?{...h,key:p(h.type),pos:u[h.type]}:{...h,key:p(h.type)})}return{pre:r,integer:M,fraction:o,post:l,valueAsString:f,value:typeof n=="string"?parseFloat(n):n}}const Q=String.raw,K=(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0})(),tt=typeof CSS<"u"&&CSS.supports&&CSS.supports("line-height","mod(1,1)"),w=typeof matchMedia<"u"?matchMedia("(prefers-reduced-motion: reduce)"):null,E="--_number-flow-d-opacity",U="--_number-flow-d-width",R="--_number-flow-dx",k="--_number-flow-d",et=(()=>{try{return CSS.registerProperty({name:E,syntax:"<number>",inherits:!1,initialValue:"0"}),CSS.registerProperty({name:R,syntax:"<length>",inherits:!0,initialValue:"0px"}),CSS.registerProperty({name:U,syntax:"<number>",inherits:!1,initialValue:"0"}),CSS.registerProperty({name:k,syntax:"<number>",inherits:!0,initialValue:"0"}),!0}catch{return!1}})(),it="var(--number-flow-char-height, 1em)",v="var(--number-flow-mask-height, 0.25em)",N=`calc(${v} / 2)`,$="var(--number-flow-mask-width, 0.5em)",_=`calc(${$} / var(--scale-x))`,b="#000 0, transparent 71%",P=Q`:host{display:inline-block;direction:ltr;white-space:nowrap;isolation:isolate;line-height:${it} !important}.number,.number__inner{display:inline-block;transform-origin:left top}:host([data-will-change]) :is(.number,.number__inner,.section,.digit,.digit__num,.symbol){will-change:transform}.number{--scale-x:calc(1 + var(${U}) / var(--width));transform:translateX(var(${R})) scaleX(var(--scale-x));margin:0 calc(-1 * ${$});position:relative;-webkit-mask-image:linear-gradient(to right,transparent 0,#000 ${_},#000 calc(100% - ${_}),transparent ),linear-gradient(to bottom,transparent 0,#000 ${v},#000 calc(100% - ${v}),transparent 100% ),radial-gradient(at bottom right,${b}),radial-gradient(at bottom left,${b}),radial-gradient(at top left,${b}),radial-gradient(at top right,${b});-webkit-mask-size:100% calc(100% - ${v} * 2),calc(100% - ${_} * 2) 100%,${_} ${v},${_} ${v},${_} ${v},${_} ${v};-webkit-mask-position:center,center,top left,top right,bottom right,bottom left;-webkit-mask-repeat:no-repeat}.number__inner{padding:${N} ${$};transform:scaleX(calc(1 / var(--scale-x))) translateX(calc(-1 * var(${R})))}:host > :not(.number){z-index:5}.section,.symbol{display:inline-block;position:relative;isolation:isolate}.section::after{content:'\200b';display:inline-block}.section--justify-left{transform-origin:center left}.section--justify-right{transform-origin:center right}.section > [inert],.symbol > [inert]{margin:0 !important;position:absolute !important;z-index:-1}.digit{display:inline-block;position:relative;--c:var(--current) + var(${k})}.digit__num,.number .section::after{padding:${N} 0}.digit__num{display:inline-block;--offset-raw:mod(var(--length) + var(--n) - mod(var(--c),var(--length)),var(--length));--offset:calc( var(--offset-raw) - var(--length) * round(down,var(--offset-raw) / (var(--length) / 2),1) );--y:clamp(-100%,var(--offset) * 100%,100%);transform:translateY(var(--y))}.digit__num[inert]{position:absolute;top:0;left:50%;transform:translateX(-50%) translateY(var(--y))}.digit:not(.is-spinning) .digit__num[inert]{display:none}.symbol__value{display:inline-block;mix-blend-mode:plus-lighter;white-space:pre}.section--justify-left .symbol > [inert]{left:0}.section--justify-right .symbol > [inert]{right:0}.animate-presence{opacity:calc(1 + var(${E}))}`,st=HTMLElement,B=tt&&K&&et;let S;class I extends st{constructor(){super(),this.created=!1,this.batched=!1;const{animated:t,...e}=this.constructor.defaultProps;this._animated=this.computedAnimated=t,Object.assign(this,e)}get animated(){return this._animated}set animated(t){var e;this.animated!==t&&(this._animated=t,(e=this.shadowRoot)==null||e.getAnimations().forEach(i=>i.finish()))}set data(t){var e;if(t==null)return;const{pre:i,integer:s,fraction:r,post:a,value:o}=t;if(this.created){const l=this._data;this._data=t,this.computedTrend=typeof this.trend=="function"?this.trend(l.value,o):this.trend,this.computedAnimated=B&&this._animated&&(!this.respectMotionPreference||!(w!=null&&w.matches))&&G(this),(e=this.plugins)==null||e.forEach(u=>{var p;return(p=u.onUpdate)==null?void 0:p.call(u,t,l,this)}),this.batched||this.willUpdate(),this._pre.update(i),this._num.update({integer:s,fraction:r}),this._post.update(a),this.batched||this.didUpdate()}else{this._data=t,this.attachShadow({mode:"open"});try{this._internals??(this._internals=this.attachInternals()),this._internals.role="img"}catch{}if(typeof CSSStyleSheet<"u"&&this.shadowRoot.adoptedStyleSheets)S||(S=new CSSStyleSheet,S.replaceSync(P)),this.shadowRoot.adoptedStyleSheets=[S];else{const l=document.createElement("style");l.textContent=P,this.shadowRoot.appendChild(l)}this._pre=new F(this,i,{justify:"right",part:"left"}),this.shadowRoot.appendChild(this._pre.el),this._num=new nt(this,s,r),this.shadowRoot.appendChild(this._num.el),this._post=new F(this,a,{justify:"left",part:"right"}),this.shadowRoot.appendChild(this._post.el),this.created=!0}try{this._internals.ariaLabel=t.valueAsString}catch{}}willUpdate(){this._pre.willUpdate(),this._num.willUpdate(),this._post.willUpdate()}didUpdate(){if(!this.computedAnimated)return;this._abortAnimationsFinish?this._abortAnimationsFinish.abort():this.dispatchEvent(new Event("animationsstart")),this._pre.didUpdate(),this._num.didUpdate(),this._post.didUpdate();const t=new AbortController;Promise.all(this.shadowRoot.getAnimations().map(e=>e.finished)).then(()=>{t.signal.aborted||(this.dispatchEvent(new Event("animationsfinish")),this._abortAnimationsFinish=void 0)}),this._abortAnimationsFinish=t}}I.defaultProps={transformTiming:{duration:900,easing:"linear(0,.005,.019,.039,.066,.096,.129,.165,.202,.24,.278,.316,.354,.39,.426,.461,.494,.526,.557,.586,.614,.64,.665,.689,.711,.731,.751,.769,.786,.802,.817,.831,.844,.856,.867,.877,.887,.896,.904,.912,.919,.925,.931,.937,.942,.947,.951,.955,.959,.962,.965,.968,.971,.973,.976,.978,.98,.981,.983,.984,.986,.987,.988,.989,.99,.991,.992,.992,.993,.994,.994,.995,.995,.996,.996,.9963,.9967,.9969,.9972,.9975,.9977,.9979,.9981,.9982,.9984,.9985,.9987,.9988,.9989,1)"},spinTiming:void 0,opacityTiming:{duration:450,easing:"ease-out"},animated:!0,trend:(n,t)=>Math.sign(t-n),respectMotionPreference:!0,plugins:void 0,digits:void 0};class nt{constructor(t,e,i,{className:s,...r}={}){this.flow=t,this._integer=new L(t,e,{justify:"right",part:"integer"}),this._fraction=new L(t,i,{justify:"left",part:"fraction"}),this._inner=y("span",{className:"number__inner"},[this._integer.el,this._fraction.el]),this.el=y("span",{...r,part:"number",className:`number ${s??""}`},[this._inner])}willUpdate(){this._prevWidth=this.el.offsetWidth,this._prevLeft=this.el.getBoundingClientRect().left,this._integer.willUpdate(),this._fraction.willUpdate()}update({integer:t,fraction:e}){this._integer.update(t),this._fraction.update(e)}didUpdate(){const t=this.el.getBoundingClientRect();this._integer.didUpdate(),this._fraction.didUpdate();const e=this._prevLeft-t.left,i=this.el.offsetWidth,s=this._prevWidth-i;this.el.style.setProperty("--width",String(i)),this.el.animate({[R]:[`${e}px`,"0px"],[U]:[s,0]},{...this.flow.transformTiming,composite:"accumulate"})}}class D{constructor(t,e,{justify:i,className:s,...r},a){this.flow=t,this.children=new Map,this.onCharRemove=l=>()=>{this.children.delete(l)},this.justify=i;const o=e.map(l=>this.addChar(l).el);this.el=y("span",{...r,className:`section section--justify-${i} ${s??""}`},a?a(o):o)}addChar(t,{startDigitsAtZero:e=!1,...i}={}){const s=t.type==="integer"||t.type==="fraction"?new X(this,t.type,e?0:t.value,t.pos,{...i,onRemove:this.onCharRemove(t.key)}):new at(this,t.type,t.value,{...i,onRemove:this.onCharRemove(t.key)});return this.children.set(t.key,s),s}unpop(t){t.el.removeAttribute("inert"),t.el.style.top="",t.el.style[this.justify]=""}pop(t){t.forEach(e=>{e.el.style.top=`${e.el.offsetTop}px`,e.el.style[this.justify]=`${J(e.el,this.justify)}px`}),t.forEach(e=>{e.el.setAttribute("inert",""),e.present=!1})}addNewAndUpdateExisting(t){const e=new Map,i=new Map,s=this.justify==="left",r=s?"prepend":"append";if(Z(t,a=>{let o;this.children.has(a.key)?(o=this.children.get(a.key),i.set(a,o),this.unpop(o),o.present=!0):(o=this.addChar(a,{startDigitsAtZero:!0,animateIn:!0}),e.set(a,o)),this.el[r](o.el)},{reverse:s}),this.flow.computedAnimated){const a=this.el.getBoundingClientRect();e.forEach(o=>{o.willUpdate(a)})}e.forEach((a,o)=>{a.update(o.value)}),i.forEach((a,o)=>{a.update(o.value)})}willUpdate(){const t=this.el.getBoundingClientRect();this._prevOffset=t[this.justify],this.children.forEach(e=>e.willUpdate(t))}didUpdate(){const t=this.el.getBoundingClientRect();this.children.forEach(s=>s.didUpdate(t));const e=t[this.justify],i=this._prevOffset-e;i&&this.children.size&&this.el.animate({transform:[`translateX(${i}px)`,"none"]},{...this.flow.transformTiming,composite:"accumulate"})}}class L extends D{update(t){const e=new Map;this.children.forEach((i,s)=>{t.find(r=>r.key===s)||e.set(s,i),this.unpop(i)}),this.addNewAndUpdateExisting(t),e.forEach(i=>{i instanceof X&&i.update(0)}),this.pop(e)}}class F extends D{update(t){const e=new Map;this.children.forEach((i,s)=>{t.find(r=>r.key===s)||e.set(s,i)}),this.pop(e),this.addNewAndUpdateExisting(t)}}class x{constructor(t,e,{onRemove:i,animateIn:s=!1}={}){this.flow=t,this.el=e,this._present=!0,this._remove=()=>{var r;this.el.remove(),(r=this._onRemove)==null||r.call(this)},this.el.classList.add("animate-presence"),this.flow.computedAnimated&&s&&this.el.animate({[E]:[-.9999,0]},{...this.flow.opacityTiming,composite:"accumulate"}),this._onRemove=i}get present(){return this._present}set present(t){if(this._present!==t){if(this._present=t,t?this.el.removeAttribute("inert"):this.el.setAttribute("inert",""),!this.flow.computedAnimated){t||this._remove();return}this.el.style.setProperty("--_number-flow-d-opacity",t?"0":"-.999"),this.el.animate({[E]:t?[-.9999,0]:[.999,0]},{...this.flow.opacityTiming,composite:"accumulate"}),t?this.flow.removeEventListener("animationsfinish",this._remove):this.flow.addEventListener("animationsfinish",this._remove,{once:!0})}}}class W extends x{constructor(t,e,i,s){super(t.flow,i,s),this.section=t,this.value=e,this.el=i}}class X extends W{constructor(t,e,i,s,r){var a,o;const l=(((o=(a=t.flow.digits)==null?void 0:a[s])==null?void 0:o.max)??9)+1,u=Array.from({length:l}).map((f,m)=>{const g=y("span",{className:"digit__num"},[document.createTextNode(String(m))]);return m!==i&&g.setAttribute("inert",""),g.style.setProperty("--n",String(m)),g}),p=y("span",{part:`digit ${e}-digit`,className:"digit"},u);p.style.setProperty("--current",String(i)),p.style.setProperty("--length",String(l)),super(t,i,p,r),this.pos=s,this._onAnimationsFinish=()=>{this.el.classList.remove("is-spinning")},this._numbers=u,this.length=l}willUpdate(t){const e=this.el.getBoundingClientRect();this._prevValue=this.value;const i=e[this.section.justify]-t[this.section.justify],s=e.width/2;this._prevCenter=this.section.justify==="left"?i+s:i-s}update(t){this.el.style.setProperty("--current",String(t)),this._numbers.forEach((e,i)=>i===t?e.removeAttribute("inert"):e.setAttribute("inert","")),this.value=t}didUpdate(t){const e=this.el.getBoundingClientRect(),i=e[this.section.justify]-t[this.section.justify],s=e.width/2,r=this.section.justify==="left"?i+s:i-s,a=this._prevCenter-r;a&&this.el.animate({transform:[`translateX(${a}px)`,"none"]},{...this.flow.transformTiming,composite:"accumulate"});const o=this.getDelta();o&&(this.el.classList.add("is-spinning"),this.el.animate({[k]:[-o,0]},{...this.flow.spinTiming??this.flow.transformTiming,composite:"accumulate"}),this.flow.addEventListener("animationsfinish",this._onAnimationsFinish,{once:!0}))}getDelta(){var t;if(this.flow.plugins)for(const s of this.flow.plugins){const r=(t=s.getDelta)==null?void 0:t.call(s,this.value,this._prevValue,this);if(r!=null)return r}const e=this.value-this._prevValue,i=this.flow.computedTrend||Math.sign(e);return i<0&&this.value>this._prevValue?this.value-this.length-this._prevValue:i>0&&this.value<this._prevValue?this.length-this._prevValue+this.value:e}}class at extends W{constructor(t,e,i,s){const r=y("span",{className:"symbol__value",textContent:i});super(t,i,y("span",{part:`symbol ${e}`,className:"symbol"},[r]),s),this.type=e,this._children=new Map,this._onChildRemove=a=>()=>{this._children.delete(a)},this._children.set(i,new x(this.flow,r,{onRemove:this._onChildRemove(i)}))}willUpdate(t){if(this.type==="decimal")return;const e=this.el.getBoundingClientRect();this._prevOffset=e[this.section.justify]-t[this.section.justify]}update(t){if(this.value!==t){const e=this._children.get(this.value);e&&(e.present=!1);const i=this._children.get(t);if(i)i.present=!0;else{const s=y("span",{className:"symbol__value",textContent:t});this.el.appendChild(s),this._children.set(t,new x(this.flow,s,{animateIn:!0,onRemove:this._onChildRemove(t)}))}}this.value=t}didUpdate(t){if(this.type==="decimal")return;const e=this.el.getBoundingClientRect()[this.section.justify]-t[this.section.justify],i=this._prevOffset-e;i&&this.el.animate({transform:[`translateX(${i}px)`,"none"]},{...this.flow.transformTiming,composite:"accumulate"})}}const rt=parseInt(c.version.match(/^(\d+)\./)?.[1]),j=rt>=19,ot=["data","digits"];class T extends I{attributeChangedCallback(t,e,i){this[t]=JSON.parse(i)}}T.observedAttributes=j?[]:ot;Y("number-flow-react",T);const lt={},O=j?n=>n:JSON.stringify;function V(n){const{transformTiming:t,spinTiming:e,opacityTiming:i,animated:s,respectMotionPreference:r,trend:a,plugins:o,...l}=n;return[{transformTiming:t,spinTiming:e,opacityTiming:i,animated:s,respectMotionPreference:r,trend:a,plugins:o},l]}class ht extends c.Component{updateProperties(t){if(!this.el)return;this.el.batched=!this.props.isolate;const[e]=V(this.props);Object.entries(e).forEach(([i,s])=>{this.el[i]=s??T.defaultProps[i]}),t?.onAnimationsStart&&this.el.removeEventListener("animationsstart",t.onAnimationsStart),this.props.onAnimationsStart&&this.el.addEventListener("animationsstart",this.props.onAnimationsStart),t?.onAnimationsFinish&&this.el.removeEventListener("animationsfinish",t.onAnimationsFinish),this.props.onAnimationsFinish&&this.el.addEventListener("animationsfinish",this.props.onAnimationsFinish)}componentDidMount(){this.updateProperties(),j&&this.el&&(this.el.digits=this.props.digits,this.el.data=this.props.data)}getSnapshotBeforeUpdate(t){if(this.updateProperties(t),t.data!==this.props.data){if(this.props.group)return this.props.group.willUpdate(),()=>this.props.group?.didUpdate();if(!this.props.isolate)return this.el?.willUpdate(),()=>this.el?.didUpdate()}return null}componentDidUpdate(t,e,i){i?.()}handleRef(t){this.props.innerRef&&(this.props.innerRef.current=t),this.el=t}render(){const[t,{innerRef:e,className:i,data:s,willChange:r,isolate:a,group:o,digits:l,onAnimationsStart:u,onAnimationsFinish:p,...f}]=V(this.props);return c.createElement("number-flow-react",{ref:this.handleRef,"data-will-change":r?"":void 0,class:i,...f,dangerouslySetInnerHTML:{__html:""},suppressHydrationWarning:!0,digits:O(l),data:O(s)})}constructor(t){super(t),this.handleRef=this.handleRef.bind(this)}}const ft=c.forwardRef(function({value:t,locales:e,format:i,prefix:s,suffix:r,...a},o){c.useImperativeHandle(o,()=>l.current,[]);const l=c.useRef(),u=c.useContext(H);u?.useRegister(l);const p=c.useMemo(()=>e?JSON.stringify(e):"",[e]),f=c.useMemo(()=>i?JSON.stringify(i):"",[i]),m=c.useMemo(()=>{const g=lt[`${p}:${f}`]??=new Intl.NumberFormat(e,i);return q(t,g,s,r)},[t,p,f,s,r]);return c.createElement(ht,{...a,group:u,data:m,innerRef:l})}),H=c.createContext(void 0);function mt({children:n}){const t=c.useRef(new Set),e=c.useRef(!1),i=c.useRef(new WeakMap),s=c.useMemo(()=>({useRegister(r){c.useEffect(()=>(t.current.add(r),()=>{t.current.delete(r)}),[])},willUpdate(){e.current||(e.current=!0,t.current.forEach(r=>{const a=r.current;!a||!a.created||(a.willUpdate(),i.current.set(a,!0))}))},didUpdate(){t.current.forEach(r=>{const a=r.current;!a||!i.current.get(a)||(a.didUpdate(),i.current.delete(a))}),e.current=!1}}),[]);return c.createElement(H.Provider,{value:s},n)}const ct=()=>c.useSyncExternalStore(()=>()=>{},()=>B,()=>!1),dt=()=>c.useSyncExternalStore(n=>(w?.addEventListener("change",n),()=>w?.removeEventListener("change",n)),()=>w.matches,()=>!1);function gt({respectMotionPreference:n=!0}={}){const t=ct(),e=dt();return t&&(!n||!e)}export{T as NumberFlowElement,mt as NumberFlowGroup,ut as continuous,ft as default,gt as useCanAnimate,ct as useIsSupported,dt as usePrefersReducedMotion};
|