arpeggi-framer-components 0.0.39 → 0.0.40

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/dist/index.umd.js CHANGED
@@ -66,5 +66,5 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
66
66
  *
67
67
  * This source code is licensed under the MIT license found in the
68
68
  * LICENSE file in the root directory of this source tree.
69
- */var yo;function Il(){return yo||(yo=1,process.env.NODE_ENV!=="production"&&function(){typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error);var e=w,t=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function i(A){{for(var k=arguments.length,v=new Array(k>1?k-1:0),O=1;O<k;O++)v[O-1]=arguments[O];n("error",A,v)}}function n(A,k,v){{var O=t.ReactDebugCurrentFrame,L=O.getStackAddendum();L!==""&&(k+="%s",v=v.concat([L]));var j=v.map(function(Y){return String(Y)});j.unshift("Warning: "+k),Function.prototype.apply.call(console[A],console,j)}}function r(A,k){return A===k&&(A!==0||1/A===1/k)||A!==A&&k!==k}var o=typeof Object.is=="function"?Object.is:r,a=e.useState,s=e.useEffect,c=e.useLayoutEffect,p=e.useDebugValue,l=!1,u=!1;function f(A,k,v){l||e.startTransition!==void 0&&(l=!0,i("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."));var O=k();if(!u){var L=k();o(O,L)||(i("The result of getSnapshot should be cached to avoid an infinite loop"),u=!0)}var j=a({inst:{value:O,getSnapshot:k}}),Y=j[0].inst,K=j[1];return c(function(){Y.value=O,Y.getSnapshot=k,x(Y)&&K({inst:Y})},[A,O,k]),s(function(){x(Y)&&K({inst:Y});var re=function(){x(Y)&&K({inst:Y})};return A(re)},[A]),p(O),O}function x(A){var k=A.getSnapshot,v=A.value;try{var O=k();return!o(v,O)}catch{return!0}}function h(A,k,v){return k()}var g=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",E=!g,m=E?h:f,C=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:m;ai.useSyncExternalStore=C,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error)}()),ai}var bo;function Bl(){return bo||(bo=1,process.env.NODE_ENV==="production"?xn.exports=Pl():xn.exports=Il()),xn.exports}var wo=Bl();const et=()=>{},je=et(),si=Object,H=e=>e===je,$e=e=>typeof e=="function",Ne=(e,t)=>({...e,...t}),Ll=e=>$e(e.then),vn=new WeakMap;let Ml=0;const Bt=e=>{const t=typeof e,i=e&&e.constructor,n=i==Date;let r,o;if(si(e)===e&&!n&&i!=RegExp){if(r=vn.get(e),r)return r;if(r=++Ml+"~",vn.set(e,r),i==Array){for(r="@",o=0;o<e.length;o++)r+=Bt(e[o])+",";vn.set(e,r)}if(i==si){r="#";const a=si.keys(e).sort();for(;!H(o=a.pop());)H(e[o])||(r+=o+":"+Bt(e[o])+",");vn.set(e,r)}}else r=n?e.toJSON():t=="symbol"?e.toString():t=="string"?JSON.stringify(e):""+e;return r},Ge=new WeakMap,ci={},gn={},li="undefined",hn=typeof window!=li,pi=typeof document!=li,zl=()=>hn&&typeof window.requestAnimationFrame!=li,ui=(e,t)=>{const i=Ge.get(e);return[()=>!H(t)&&e.get(t)||ci,n=>{if(!H(t)){const r=e.get(t);t in gn||(gn[t]=r),i[5](t,Ne(r,n),r||ci)}},i[6],()=>!H(t)&&t in gn?gn[t]:!H(t)&&e.get(t)||ci]};let di=!0;const $l=()=>di,[fi,mi]=hn&&window.addEventListener?[window.addEventListener.bind(window),window.removeEventListener.bind(window)]:[et,et],Nl=()=>{const e=pi&&document.visibilityState;return H(e)||e!=="hidden"},ql=e=>(pi&&document.addEventListener("visibilitychange",e),fi("focus",e),()=>{pi&&document.removeEventListener("visibilitychange",e),mi("focus",e)}),Wl=e=>{const t=()=>{di=!0,e()},i=()=>{di=!1};return fi("online",t),fi("offline",i),()=>{mi("online",t),mi("offline",i)}},Ul={isOnline:$l,isVisible:Nl},Vl={initFocus:ql,initReconnect:Wl},Lt=!w.useId,dt=!hn||"Deno"in window,Eo=e=>zl()?window.requestAnimationFrame(e):setTimeout(e,1),tt=dt?w.useEffect:w.useLayoutEffect,xi=typeof navigator<"u"&&navigator.connection,So=!dt&&xi&&(["slow-2g","2g"].includes(xi.effectiveType)||xi.saveData),Mt=e=>{if($e(e))try{e=e()}catch{e=""}const t=e;return e=typeof e=="string"?e:(Array.isArray(e)?e.length:e)?Bt(e):"",[e,t]};let Hl=0;const Et=()=>++Hl,To=0,Ro=1,ko=2;var Ye={__proto__:null,ERROR_REVALIDATE_EVENT:3,FOCUS_EVENT:To,MUTATE_EVENT:ko,RECONNECT_EVENT:Ro};async function vi(...e){const[t,i,n,r]=e,o=Ne({populateCache:!0,throwOnError:!0},typeof r=="boolean"?{revalidate:r}:r||{});let a=o.populateCache;const s=o.rollbackOnError;let c=o.optimisticData;const p=f=>typeof s=="function"?s(f):s!==!1,l=o.throwOnError;if($e(i)){const f=i,x=[],h=t.keys();for(const g of h)!/^\$(inf|sub)\$/.test(g)&&f(t.get(g)._k)&&x.push(g);return Promise.all(x.map(u))}return u(i);async function u(f){const[x]=Mt(f);if(!x)return;const[h,g]=ui(t,x),[E,m,C,A]=Ge.get(t),k=()=>{const Q=E[x];return($e(o.revalidate)?o.revalidate(h().data,f):o.revalidate!==!1)&&(delete C[x],delete A[x],Q&&Q[0])?Q[0](ko).then(()=>h().data):h().data};if(e.length<3)return k();let v=n,O;const L=Et();m[x]=[L,0];const j=!H(c),Y=h(),K=Y.data,re=Y._c,oe=H(re)?K:re;if(j&&(c=$e(c)?c(oe,K):c,g({data:c,_c:oe})),$e(v))try{v=v(oe)}catch(Q){O=Q}if(v&&Ll(v))if(v=await v.catch(Q=>{O=Q}),L!==m[x][0]){if(O)throw O;return v}else O&&j&&p(O)&&(a=!0,g({data:oe,_c:je}));if(a&&!O)if($e(a)){const Q=a(v,oe);g({data:Q,error:je,_c:je})}else g({data:v,error:je,_c:je});if(m[x][1]=Et(),Promise.resolve(k()).then(()=>{g({_c:je})}),O){if(l)throw O;return}return v}}const Co=(e,t)=>{for(const i in e)e[i][0]&&e[i][0](t)},Gl=(e,t)=>{if(!Ge.has(e)){const i=Ne(Vl,t),n={},r=vi.bind(je,e);let o=et;const a={},s=(l,u)=>{const f=a[l]||[];return a[l]=f,f.push(u),()=>f.splice(f.indexOf(u),1)},c=(l,u,f)=>{e.set(l,u);const x=a[l];if(x)for(const h of x)h(u,f)},p=()=>{if(!Ge.has(e)&&(Ge.set(e,[n,{},{},{},r,c,s]),!dt)){const l=i.initFocus(setTimeout.bind(je,Co.bind(je,n,To))),u=i.initReconnect(setTimeout.bind(je,Co.bind(je,n,Ro)));o=()=>{l&&l(),u&&u(),Ge.delete(e)}}};return p(),[e,r,p,o]}return[e,Ge.get(e)[4]]},Yl=(e,t,i,n,r)=>{const o=i.errorRetryCount,a=r.retryCount,s=~~((Math.random()+.5)*(1<<(a<8?a:8)))*i.errorRetryInterval;!H(o)&&a>o||setTimeout(n,s,r)},Kl=(e,t)=>Bt(e)==Bt(t),[Oo,Jl]=Gl(new Map),Xl=Ne({onLoadingSlow:et,onSuccess:et,onError:et,onErrorRetry:Yl,onDiscarded:et,revalidateOnFocus:!0,revalidateOnReconnect:!0,revalidateIfStale:!0,shouldRetryOnError:!0,errorRetryInterval:So?1e4:5e3,focusThrottleInterval:5*1e3,dedupingInterval:2*1e3,loadingTimeout:So?5e3:3e3,compare:Kl,isPaused:()=>!1,cache:Oo,mutate:Jl,fallback:{}},Ul),Zl=(e,t)=>{const i=Ne(e,t);if(t){const{use:n,fallback:r}=e,{use:o,fallback:a}=t;n&&o&&(i.use=n.concat(o)),r&&a&&(i.fallback=Ne(r,a))}return i},Ql=w.createContext({}),ep="$inf$",_o=hn&&window.__SWR_DEVTOOLS_USE__,tp=_o?window.__SWR_DEVTOOLS_USE__:[],np=()=>{_o&&(window.__SWR_DEVTOOLS_REACT__=w)},Ao=e=>$e(e[1])?[e[0],e[1],e[2]||{}]:[e[0],null,(e[1]===null?e[2]:e[1])||{}],jo=()=>Ne(Xl,w.useContext(Ql)),ip=e=>(t,i,n)=>e(t,i&&((...o)=>{const[a]=Mt(t),[,,,s]=Ge.get(Oo);if(a.startsWith(ep))return i(...o);const c=s[a];return H(c)?i(...o):(delete s[a],c)}),n),rp=tp.concat(ip),Do=e=>function(...i){const n=jo(),[r,o,a]=Ao(i),s=Zl(n,a);let c=e;const{use:p}=s,l=(p||[]).concat(rp);for(let u=l.length;u--;)c=l[u](c);return c(r,o||s.fetcher||null,s)},Fo=(e,t,i)=>{const n=t[e]||(t[e]=[]);return n.push(i),()=>{const r=n.indexOf(i);r>=0&&(n[r]=n[n.length-1],n.pop())}},op=(e,t)=>(...i)=>{const[n,r,o]=Ao(i),a=(o.use||[]).concat(t);return e(n,r,{...o,use:a})};np();const Po=w.use||(e=>{if(e.status==="pending")throw e;if(e.status==="fulfilled")return e.value;throw e.status==="rejected"?e.reason:(e.status="pending",e.then(t=>{e.status="fulfilled",e.value=t},t=>{e.status="rejected",e.reason=t}),e)}),gi={dedupe:!0},ap=Do((e,t,i)=>{const{cache:n,compare:r,suspense:o,fallbackData:a,revalidateOnMount:s,revalidateIfStale:c,refreshInterval:p,refreshWhenHidden:l,refreshWhenOffline:u,keepPreviousData:f}=i,[x,h,g,E]=Ge.get(n),[m,C]=Mt(e),A=w.useRef(!1),k=w.useRef(!1),v=w.useRef(m),O=w.useRef(t),L=w.useRef(i),j=()=>L.current,Y=()=>j().isVisible()&&j().isOnline(),[K,re,oe,Q]=ui(n,m),U=w.useRef({}).current,le=H(a)?i.fallback[m]:a,xe=(b,I)=>{for(const ee in U){const V=ee;if(V==="data"){if(!r(b[V],I[V])&&(!H(b[V])||!r(J,I[V])))return!1}else if(I[V]!==b[V])return!1}return!0},we=w.useMemo(()=>{const b=!m||!t?!1:H(s)?j().isPaused()||o?!1:H(c)?!0:c:s,I=ie=>{const Te=Ne(ie);return delete Te._k,b?{isValidating:!0,isLoading:!0,...Te}:Te},ee=K(),V=Q(),ve=I(ee),ke=ee===V?ve:I(V);let ne=ve;return[()=>{const ie=I(K());return xe(ie,ne)?(ne.data=ie.data,ne.isLoading=ie.isLoading,ne.isValidating=ie.isValidating,ne.error=ie.error,ne):(ne=ie,ie)},()=>ke]},[n,m]),ce=wo.useSyncExternalStore(w.useCallback(b=>oe(m,(I,ee)=>{xe(ee,I)||b()}),[n,m]),we[0],we[1]),he=!A.current,T=x[m]&&x[m].length>0,_=ce.data,M=H(_)?le:_,W=ce.error,N=w.useRef(M),J=f?H(_)?N.current:_:M,$=T&&!H(W)?!1:he&&!H(s)?s:j().isPaused()?!1:o?H(M)?!1:c:H(M)||c,P=!!(m&&t&&he&&$),G=H(ce.isValidating)?P:ce.isValidating,X=H(ce.isLoading)?P:ce.isLoading,q=w.useCallback(async b=>{const I=O.current;if(!m||!I||k.current||j().isPaused())return!1;let ee,V,ve=!0;const ke=b||{},ne=!g[m]||!ke.dedupe,ie=()=>Lt?!k.current&&m===v.current&&A.current:m===v.current,Te={isValidating:!1,isLoading:!1},Je=()=>{re(Te)},Ue=()=>{const S=g[m];S&&S[1]===V&&delete g[m]},Xe={isValidating:!0};H(K().data)&&(Xe.isLoading=!0);try{if(ne&&(re(Xe),i.loadingTimeout&&H(K().data)&&setTimeout(()=>{ve&&ie()&&j().onLoadingSlow(m,i)},i.loadingTimeout),g[m]=[I(C),Et()]),[ee,V]=g[m],ee=await ee,ne&&setTimeout(Ue,i.dedupingInterval),!g[m]||g[m][1]!==V)return ne&&ie()&&j().onDiscarded(m),!1;Te.error=je;const S=h[m];if(!H(S)&&(V<=S[0]||V<=S[1]||S[1]===0))return Je(),ne&&ie()&&j().onDiscarded(m),!1;const D=K().data;Te.data=r(D,ee)?D:ee,ne&&ie()&&j().onSuccess(ee,m,i)}catch(S){Ue();const D=j(),{shouldRetryOnError:ue}=D;D.isPaused()||(Te.error=S,ne&&ie()&&(D.onError(S,m,D),(ue===!0||$e(ue)&&ue(S))&&(!j().revalidateOnFocus||!j().revalidateOnReconnect||Y())&&D.onErrorRetry(S,m,D,ye=>{const Ce=x[m];Ce&&Ce[0]&&Ce[0](Ye.ERROR_REVALIDATE_EVENT,ye)},{retryCount:(ke.retryCount||0)+1,dedupe:!0})))}return ve=!1,Je(),!0},[m,n]),Ee=w.useCallback((...b)=>vi(n,v.current,...b),[]);if(tt(()=>{O.current=t,L.current=i,H(_)||(N.current=_)}),tt(()=>{if(!m)return;const b=q.bind(je,gi);let I=0;const V=Fo(m,x,(ve,ke={})=>{if(ve==Ye.FOCUS_EVENT){const ne=Date.now();j().revalidateOnFocus&&ne>I&&Y()&&(I=ne+j().focusThrottleInterval,b())}else if(ve==Ye.RECONNECT_EVENT)j().revalidateOnReconnect&&Y()&&b();else{if(ve==Ye.MUTATE_EVENT)return q();if(ve==Ye.ERROR_REVALIDATE_EVENT)return q(ke)}});return k.current=!1,v.current=m,A.current=!0,re({_k:C}),$&&(H(M)||dt?b():Eo(b)),()=>{k.current=!0,V()}},[m]),tt(()=>{let b;function I(){const V=$e(p)?p(K().data):p;V&&b!==-1&&(b=setTimeout(ee,V))}function ee(){!K().error&&(l||j().isVisible())&&(u||j().isOnline())?q(gi).then(I):I()}return I(),()=>{b&&(clearTimeout(b),b=-1)}},[p,l,u,m]),w.useDebugValue(J),o&&H(M)&&m){if(!Lt&&dt)throw new Error("Fallback data is required when using suspense in SSR.");O.current=t,L.current=i,k.current=!1;const b=E[m];if(!H(b)){const I=Ee(b);Po(I)}if(H(W)){const I=q(gi);H(J)||(I.status="fulfilled",I.value=!0),Po(I)}else throw W}return{mutate:Ee,get data(){return U.data=!0,J},get error(){return U.error=!0,W},get isValidating(){return U.isValidating=!0,G},get isLoading(){return U.isLoading=!0,X}}}),Io=w.use||(e=>{if(e.status==="pending")throw e;if(e.status==="fulfilled")return e.value;throw e.status==="rejected"?e.reason:(e.status="pending",e.then(t=>{e.status="fulfilled",e.value=t},t=>{e.status="rejected",e.reason=t}),e)}),hi={dedupe:!0},sp=Do((e,t,i)=>{const{cache:n,compare:r,suspense:o,fallbackData:a,revalidateOnMount:s,revalidateIfStale:c,refreshInterval:p,refreshWhenHidden:l,refreshWhenOffline:u,keepPreviousData:f}=i,[x,h,g,E]=Ge.get(n),[m,C]=Mt(e),A=w.useRef(!1),k=w.useRef(!1),v=w.useRef(m),O=w.useRef(t),L=w.useRef(i),j=()=>L.current,Y=()=>j().isVisible()&&j().isOnline(),[K,re,oe,Q]=ui(n,m),U=w.useRef({}).current,le=H(a)?i.fallback[m]:a,xe=(b,I)=>{for(const ee in U){const V=ee;if(V==="data"){if(!r(b[V],I[V])&&(!H(b[V])||!r(J,I[V])))return!1}else if(I[V]!==b[V])return!1}return!0},we=w.useMemo(()=>{const b=!m||!t?!1:H(s)?j().isPaused()||o?!1:H(c)?!0:c:s,I=ie=>{const Te=Ne(ie);return delete Te._k,b?{isValidating:!0,isLoading:!0,...Te}:Te},ee=K(),V=Q(),ve=I(ee),ke=ee===V?ve:I(V);let ne=ve;return[()=>{const ie=I(K());return xe(ie,ne)?(ne.data=ie.data,ne.isLoading=ie.isLoading,ne.isValidating=ie.isValidating,ne.error=ie.error,ne):(ne=ie,ie)},()=>ke]},[n,m]),ce=wo.useSyncExternalStore(w.useCallback(b=>oe(m,(I,ee)=>{xe(ee,I)||b()}),[n,m]),we[0],we[1]),he=!A.current,T=x[m]&&x[m].length>0,_=ce.data,M=H(_)?le:_,W=ce.error,N=w.useRef(M),J=f?H(_)?N.current:_:M,$=T&&!H(W)?!1:he&&!H(s)?s:j().isPaused()?!1:o?H(M)?!1:c:H(M)||c,P=!!(m&&t&&he&&$),G=H(ce.isValidating)?P:ce.isValidating,X=H(ce.isLoading)?P:ce.isLoading,q=w.useCallback(async b=>{const I=O.current;if(!m||!I||k.current||j().isPaused())return!1;let ee,V,ve=!0;const ke=b||{},ne=!g[m]||!ke.dedupe,ie=()=>Lt?!k.current&&m===v.current&&A.current:m===v.current,Te={isValidating:!1,isLoading:!1},Je=()=>{re(Te)},Ue=()=>{const S=g[m];S&&S[1]===V&&delete g[m]},Xe={isValidating:!0};H(K().data)&&(Xe.isLoading=!0);try{if(ne&&(re(Xe),i.loadingTimeout&&H(K().data)&&setTimeout(()=>{ve&&ie()&&j().onLoadingSlow(m,i)},i.loadingTimeout),g[m]=[I(C),Et()]),[ee,V]=g[m],ee=await ee,ne&&setTimeout(Ue,i.dedupingInterval),!g[m]||g[m][1]!==V)return ne&&ie()&&j().onDiscarded(m),!1;Te.error=je;const S=h[m];if(!H(S)&&(V<=S[0]||V<=S[1]||S[1]===0))return Je(),ne&&ie()&&j().onDiscarded(m),!1;const D=K().data;Te.data=r(D,ee)?D:ee,ne&&ie()&&j().onSuccess(ee,m,i)}catch(S){Ue();const D=j(),{shouldRetryOnError:ue}=D;D.isPaused()||(Te.error=S,ne&&ie()&&(D.onError(S,m,D),(ue===!0||$e(ue)&&ue(S))&&(!j().revalidateOnFocus||!j().revalidateOnReconnect||Y())&&D.onErrorRetry(S,m,D,ye=>{const Ce=x[m];Ce&&Ce[0]&&Ce[0](Ye.ERROR_REVALIDATE_EVENT,ye)},{retryCount:(ke.retryCount||0)+1,dedupe:!0})))}return ve=!1,Je(),!0},[m,n]),Ee=w.useCallback((...b)=>vi(n,v.current,...b),[]);if(tt(()=>{O.current=t,L.current=i,H(_)||(N.current=_)}),tt(()=>{if(!m)return;const b=q.bind(je,hi);let I=0;const V=Fo(m,x,(ve,ke={})=>{if(ve==Ye.FOCUS_EVENT){const ne=Date.now();j().revalidateOnFocus&&ne>I&&Y()&&(I=ne+j().focusThrottleInterval,b())}else if(ve==Ye.RECONNECT_EVENT)j().revalidateOnReconnect&&Y()&&b();else{if(ve==Ye.MUTATE_EVENT)return q();if(ve==Ye.ERROR_REVALIDATE_EVENT)return q(ke)}});return k.current=!1,v.current=m,A.current=!0,re({_k:C}),$&&(H(M)||dt?b():Eo(b)),()=>{k.current=!0,V()}},[m]),tt(()=>{let b;function I(){const V=$e(p)?p(K().data):p;V&&b!==-1&&(b=setTimeout(ee,V))}function ee(){!K().error&&(l||j().isVisible())&&(u||j().isOnline())?q(hi).then(I):I()}return I(),()=>{b&&(clearTimeout(b),b=-1)}},[p,l,u,m]),w.useDebugValue(J),o&&H(M)&&m){if(!Lt&&dt)throw new Error("Fallback data is required when using suspense in SSR.");O.current=t,L.current=i,k.current=!1;const b=E[m];if(!H(b)){const I=Ee(b);Io(I)}if(H(W)){const I=q(hi);H(J)||(I.status="fulfilled",I.value=!0),Io(I)}else throw W}return{mutate:Ee,get data(){return U.data=!0,J},get error(){return U.error=!0,W},get isValidating(){return U.isValidating=!0,G},get isLoading(){return U.isLoading=!0,X}}}),Bo=Lt?e=>{e()}:w.startTransition,cp=e=>{const[,t]=w.useState({}),i=w.useRef(!1),n=w.useRef(e),r=w.useRef({data:!1,error:!1,isValidating:!1}),o=w.useCallback(a=>{let s=!1;const c=n.current;for(const p in a){const l=p;c[l]!==a[l]&&(c[l]=a[l],r.current[l]&&(s=!0))}s&&!i.current&&t({})},[]);return tt(()=>(i.current=!1,()=>{i.current=!0})),[n,r.current,o]},lp=op(sp,()=>(e,t,i={})=>{const{mutate:n}=jo(),r=w.useRef(e),o=w.useRef(t),a=w.useRef(i),s=w.useRef(0),[c,p,l]=cp({data:je,error:je,isMutating:!1}),u=c.current,f=w.useCallback(async(h,g)=>{const[E,m]=Mt(r.current);if(!o.current)throw new Error("Can’t trigger the mutation: missing fetcher.");if(!E)throw new Error("Can’t trigger the mutation: missing key.");const C=Ne(Ne({populateCache:!1,throwOnError:!0},a.current),g),A=Et();s.current=A,l({isMutating:!0});try{const k=await n(E,o.current(m,{arg:h}),Ne(C,{throwOnError:!0}));return s.current<=A&&(Bo(()=>l({data:k,isMutating:!1,error:void 0})),C.onSuccess==null||C.onSuccess.call(C,k,E,C)),k}catch(k){if(s.current<=A&&(Bo(()=>l({error:k,isMutating:!1})),C.onError==null||C.onError.call(C,k,E,C),C.throwOnError))throw k}},[]),x=w.useCallback(()=>{s.current=Et(),l({data:je,error:je,isMutating:!1})},[]);return tt(()=>{r.current=e,o.current=t,a.current=i}),{trigger:f,reset:x,get data(){return p.data=!0,u.data},get error(){return p.error=!0,u.error},get isMutating(){return p.isMutating=!0,u.isMutating}}}),pp=e=>{const t=r=>typeof r=="object"&&!(r instanceof Date)&&!(r instanceof File)&&r!==null,i=(r,o,a)=>{for(const s in o){const c=o[s];t(c)?i(`${r}[${s}]`,c,a):c!==void 0&&a.append(`${r}[${s}]`,c===null?"":c)}},n=new FormData;for(const r in e){const o=e[r];o instanceof File?n.append(r,o,o.name):o!==void 0&&(t(o)?i(r,o,n):n.append(r,o===null?"":o))}return n},up=_e("div",{"--progress":"-100%",height:"4px",width:"100%",background:"rgba(255, 255, 255, 0.1)",borderRadius:"12px",position:"relative",overflow:"hidden"}),dp=_e("div",{height:"100%",width:"100%",background:"#ffffff",transform:"translateX(var(--progress))",borderRadius:"12px"}),nt={Root:up,Bar:dp};function yn(e,t,i){for(let n=0;n<e.length;++n)t[i+n]=e.charCodeAt(n)}function bn(e,t,i){e=Math.floor(e),t[i+0]=e&255,t[i+1]=e>>8&255}function ft(e,t,i){e=Math.floor(e),t[i+0]=e&255,t[i+1]=e>>8&255,t[i+2]=e>>16&255,t[i+3]=e>>24&255}function fp(e){const t=new ArrayBuffer(4);return new Float32Array(t)[0]=e,new Uint32Array(t)[0]|0}function mp(e,t,i,n){let r=0,o=0;const a=e.length,s=e.numberOfChannels;let c,p;for(r=0;r<a;++r)for(o=0;o<s;++o)if(c=e.getChannelData(o),n===16)p=c[r]*32768,p=Math.max(-32768,Math.min(p,32767)),bn(p,t,i),i+=2;else if(n===32)p=fp(c[r]),ft(p,t,i),i+=4;else{console.log("Invalid bit depth for PCM encoding.");return}}async function xp(e,t){let i=e instanceof Blob?e:new Blob(e);const n=URL.createObjectURL(i),o=await(await fetch(n)).arrayBuffer();return await new AudioContext(t).decodeAudioData(o)}async function vp(e,t=!1){const i=e.length,n=e.numberOfChannels,r=e.sampleRate,o=t?32:16,a=o/8,s=r*n*o/8,c=n*o/8,p=i*n*a,u=44+p,f=new Uint8Array(u),x=16,h=p,g=4+(8+x)+(8+h);return yn("RIFF",f,0),ft(g,f,4),yn("WAVE",f,8),yn("fmt ",f,12),ft(x,f,16),bn(t?3:1,f,20),bn(n,f,22),ft(r,f,24),ft(s,f,28),bn(c,f,32),ft(o,f,34),yn("data",f,36),ft(h,f,40),mp(e,f,44,o),new Blob([f],{type:"audio/wave"})}async function gp(e,t=!1,i){const n=await xp(e,i);return vp(n,t)}const hp=128;class yp{constructor(){En(this,"mediaRecorder",null);En(this,"stream",null);En(this,"__data",null)}async checkMicrophonePermission(){var n;return!!(await((n=navigator==null?void 0:navigator.mediaDevices)==null?void 0:n.enumerateDevices())).find(r=>r.kind==="audioinput"&&!!r.label)}async startRecording(){var t;if(((t=this.mediaRecorder)==null?void 0:t.state)==="recording")return!0;try{this.stream=await navigator.mediaDevices.getUserMedia({audio:!0,video:!1}),this.mediaRecorder=new MediaRecorder(this.stream,{bitsPerSecond:hp*1e3}),this.mediaRecorder.ondataavailable=i=>this.__data=i.data}catch(i){return console.error(i),!1}return this.mediaRecorder.start(),!0}stopRecording(){return new Promise(t=>{var i;if(((i=this.mediaRecorder)==null?void 0:i.state)!=="recording"){t(!0);return}this.mediaRecorder.stop(),this.mediaRecorder.onstop=()=>{var n;(n=this.stream)==null||n.getTracks().forEach(r=>r.stop()),this.mediaRecorder=null,this.stream=null,t(!0)}})}async getWavBlob(){return this.__data?await gp(this.__data):null}}const wn=new yp,yi="Recording.wav",Lo=1500,bp=e=>{const[t,i]=w.useState(!1),[n,r]=w.useState(!1),[o,a]=w.useState(!1);return w.useEffect(()=>{var p;const c=async()=>{wn.checkMicrophonePermission().then(i)};return c(),(p=navigator==null?void 0:navigator.mediaDevices)==null||p.addEventListener("devicechange",c),()=>{var l;return(l=navigator==null?void 0:navigator.mediaDevices)==null?void 0:l.removeEventListener("devicechange",c)}},[]),{hasMicAccess:t,isRecording:n,hasMinTimeElapsed:o,handleClick:async()=>{if(n){if(!o)return;r(!1),a(!1),await wn.stopRecording();const p=await wn.getWavBlob();if(!p){console.log("Failed to get audio blob",p);return}const l=new File([p],yi,{type:"audio/mpeg",lastModified:Date.now()});e.onFileUpdate(l);return}const c=await wn.startRecording();r(c),setTimeout(()=>{a(!0)},Lo)}}},Mo=Ae.create({baseURL:"https://arpeggi.io/api/v2/"}),wp=async(e,{arg:t})=>{var n;return(await Mo.post("/ml-inference-jobs",pp({soundFile:t.file,type:"audio",voiceModelId:t.voiceModelId,strapiDemoId:t.strapiDemoId,metadata:{isRecordedAudio:((n=t.file)==null?void 0:n.name)===yi}}),{params:{type:"audio"}})).data},Ep=async e=>e===null?null:(await Mo.get(e)).data,Sp=e=>{const t=e>0;return ap(t?`/ml-inference-jobs/${e}`:null,Ep,{refreshInterval:i=>(i==null?void 0:i.jobStatus)==="success"?0:1e3})},Tp=()=>{const[e,t]=w.useState(void 0),[i,n]=w.useState(void 0),[r,o]=w.useState(0),[a,s]=w.useState(0),{data:c,isLoading:p}=Sp(r),{trigger:l,isMutating:u}=lp("/ml-inference-jobs",wp);return{demoId:e,setDemoId:t,file:i,setFile:n,mlijId:r,setMlijId:o,voiceModelId:a,setVoiceModelId:s,data:c,isLoading:p,handleSelectVoice:async h=>{!i&&!e||(o(0),s(h),l({file:i,strapiDemoId:e,voiceModelId:h},{onSuccess:g=>{console.log("created mlij",g),o(g.id)}}))},reset:()=>{t(void 0),n(void 0),o(0),s(0)},isMutating:u}},zo=w.createContext({}),zt=()=>w.useContext(zo),Rp=({children:e})=>{const t=Tp();return z.jsx(jr,{children:z.jsx(zo.Provider,{value:t,children:e})})},kp=_e("button",{background:"#ffffff",flexShrink:0,borderRadius:"12px",width:"64px",height:"64px",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",border:"none",outline:"none",transition:"background 0.2s ease-in-out, transform 0.2s ease-in-out",color:"#000000","& > svg":{width:"24px",height:"24px"},"&:hover":{background:"#ffffff99",transform:"scale(1.05)"},"&:active":{background:"#ffffffcc"},"&:disabled":{background:"rgba(255, 255, 255, 0.3)",transform:"none",cursor:"not-allowed"}}),Cp=_e("div",{fontSize:"11px",lineHeight:"14px",fontFamily:'"General Sans Medium", "General Sans Medium Placeholder", sans-serif',color:"#ffffff",textTransform:"uppercase",letterSpacing:"2.2px",fontWeight:400}),Op=e=>{var c;const{data:t,isMutating:i}=zt(),n=(c=t==null?void 0:t.lossyOutputFile)==null?void 0:c.url,{player:r,playPause:o}=Un(n),a=w.useRef(null),s=w.useRef();return w.useEffect(()=>{if(!r.isPlaying)return()=>{cancelAnimationFrame(s.current)};const p=()=>{var u;const l=r.audioRef.current.currentTime/r.audioRef.current.duration;(u=a.current)==null||u.style.setProperty("--progress",`${-100+l*100}%`),s.current=requestAnimationFrame(p)};return s.current=requestAnimationFrame(p),()=>{cancelAnimationFrame(s.current)}},[r.isPlaying,r.audioRef]),z.jsxs(Le,{row:!0,align:"center",flex:"1",gap:"16",...e,children:[z.jsx(kp,{onClick:o,disabled:r.isLoading||!n,children:z.jsxs(Ie,{children:[z.jsx(Ie.If,{isTrue:r.isLoading||(t==null?void 0:t.jobStatus)==="running"||i,children:z.jsx(kr,{})}),z.jsx(Ie.If,{isTrue:r.isPlaying,children:z.jsx(Cr,{})}),z.jsx(Ie.Else,{children:z.jsx(Or,{})})]})}),z.jsxs(Le,{flex:"1",column:!0,gap:"12",children:[z.jsx(Cp,{children:z.jsxs(Ie,{children:[z.jsx(Ie.If,{isTrue:(t==null?void 0:t.jobStatus)==="running",children:"Converting audio"}),z.jsx(Ie.If,{isTrue:i,children:"Uploading audio"}),z.jsx(Ie.Else,{children:"Converted audio"})]})}),z.jsx(nt.Root,{ref:a,children:z.jsx(nt.Bar,{})})]})]})},_p=30,$o=e=>{const t=w.useRef(),i=w.useRef(null);return w.useEffect(()=>{let n=0;return t.current=setInterval(()=>{var o;n+=e;let r=Math.round(Math.atan(n)/(Math.PI/2)*100*1e3)/1e3;(o=i.current)==null||o.style.setProperty("--progress",`${-100+r}%`)},50),()=>clearInterval(t.current)},[]),i},Ap=()=>{const e=$o(.1);return z.jsx(nt.Root,{ref:e,children:z.jsx(nt.Bar,{})})},jp=()=>z.jsx(nt.Root,{children:z.jsx(nt.Bar,{})}),Dp=()=>z.jsx(nt.Root,{style:{"--progress":"0%"},children:z.jsx(nt.Bar,{})}),Fp=()=>{const{data:e}=zt();return e?e.jobStatus==="success"?z.jsx(Dp,{}):z.jsx(Ap,{},e==null?void 0:e.id):z.jsx(jp,{})},Pp=1,Ip=100*1024*1024,Bp=1,Lp=({children:e})=>{const{setFile:t}=zt(),i=n=>t(n[0]);return z.jsx(Rr,{files:[],onFileAccepted:i,maxFileCount:Pp,maxSizeBytes:Ip,minSizeBytes:Bp,maxDurationS:_p,children:e})},Mp=_e(Le,{width:"100%",height:"100%",display:"flex",overflow:"hidden",borderRadius:"16px",background:"#ffffff10",flexDirection:"column",alignItems:"stretch",justifyContent:"center"}),zp=_e(Le,{paddingTop:"32px",paddingBottom:"16px",alignItems:"center",display:"flex",justifyContent:"center",fontSize:"22px",lineHeight:"1.4em",letterSpacing:"0.01em",fontFamily:'"General Sans Medium", "General Sans Medium Placeholder", sans-serif',color:"rgba(255, 255, 255, 0.9)",fontWeight:500}),$p=_e(Le,{flex:1,gap:"12px",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"32px"}),Np=_e(Le,{borderTop:"1px solid #ffffff10",display:"flex",alignItems:"center",justifyContent:"center",padding:"12px"}),qp=_e("div",{padding:"20px",background:"rgba(255, 255, 255, 0.03)",border:"1px solid transparent",borderRadius:"12px",display:"flex",alignItems:"center",gap:"10px",cursor:"pointer",transition:"background 0.2s ease-in-out","&:hover":{background:"rgba(255, 255, 255, 0.06)"},"&:active":{background:"rgba(255, 255, 255, 0.1)",borderColor:"rgba(255, 255, 255, 0.1)"},variants:{selected:{true:{background:"rgba(255, 255, 255, 0.1)",borderColor:"rgba(255, 255, 255, 0.1)"}}}}),Wp=_e("div",{fontSize:"16px",lineHeight:"1.2em",fontFamily:'"General Sans Medium", "General Sans Medium Placeholder", sans-serif',color:"rgba(255, 255, 255, 0.9)",fontWeight:400}),Up=_e("button",{border:"none",background:"transparent",cursor:"pointer",padding:"0",margin:"0",width:"32px",height:"32px",display:"flex",alignItems:"center",justifyContent:"center","& > svg":{width:"24px",height:"24px"},color:"#ffffff",position:"relative",transition:"transform 0.2s ease-in-out","&:hover":{transform:"scale(1.1)"}}),Vp=_e("button",{border:"none",background:"rgba(255, 255, 255, 1)",fontSize:"11px",lineHeight:"14px",fontFamily:'"General Sans Medium", "General Sans Medium Placeholder", sans-serif',color:"rgba(0, 0, 0, 1)",textTransform:"uppercase",letterSpacing:"2.2px",fontWeight:400,display:"flex",alignItems:"center",justifyContent:"center",padding:"14px 24px",borderRadius:"8px",cursor:"pointer",transition:"all 0.2s ease-in-out","&:hover":{background:"rgba(255, 255, 255, 0.9)",transform:"scale(1.05)"},"&:active":{background:"rgba(255, 255, 255, 0.8)",transform:"scale(0.95)"},"&:disabled":{background:"rgba(255, 255, 255, 0.2)",transform:"none",cursor:"not-allowed"}}),Hp=({demo:e,onSelect:t,selected:i})=>{const{playPause:n,player:r}=Un(e.audioUrl);return z.jsxs(qp,{onClick:()=>t(e.id),selected:i,children:[z.jsx(Up,{onClick:n,disabled:r.isLoading,children:z.jsxs(Ie,{children:[z.jsx(Ie.If,{isTrue:r.isLoading,children:z.jsx(kr,{})}),z.jsx(Ie.If,{isTrue:r.isPlaying,children:z.jsx(Cr,{})}),z.jsx(Ie.Else,{children:z.jsx(Or,{})})]})}),z.jsx(Wp,{children:e.label})]})},Gp=({demos:e})=>{const{setDemoId:t,demoId:i}=zt(),[n,r]=w.useState(i);return z.jsxs(Mp,{children:[z.jsx(zp,{children:"Select demo audio"}),z.jsx($p,{children:z.jsx(Le,{column:!0,css:{maxWidth:"724px"},children:e.map(o=>z.jsx(Hp,{demo:o,onSelect:r,selected:n===o.id},o.id))})}),z.jsx(Np,{children:z.jsx(Vp,{onClick:()=>t(n),children:"Next"})})]})};pe.AudioFilePickerRoot=Rr,pe.Box=Le,pe.ConvertStep=rc,pe.DemoPicker=Gp,pe.FilePicker=Lp,pe.GuestConvertProvider=Rp,pe.InferenceProgress=Fp,pe.MIN_RECORDING_LENGTH_MS=Lo,pe.PlayButton=Op,pe.PlayerProvider=jr,pe.RECORDED_AUDIO_NAME=yi,pe.useAudioFilePickerContext=Xs,pe.useFakeProgress=$o,pe.useGuestConvertContext=zt,pe.useMediaQuery=Zo,pe.usePlayback=Un,pe.usePlayer=Ar,pe.usePlayerControls=pc,pe.useRecorder=bp,Object.defineProperty(pe,Symbol.toStringTag,{value:"Module"})});
69
+ */var yo;function Il(){return yo||(yo=1,process.env.NODE_ENV!=="production"&&function(){typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error);var e=w,t=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function i(A){{for(var k=arguments.length,v=new Array(k>1?k-1:0),O=1;O<k;O++)v[O-1]=arguments[O];n("error",A,v)}}function n(A,k,v){{var O=t.ReactDebugCurrentFrame,L=O.getStackAddendum();L!==""&&(k+="%s",v=v.concat([L]));var j=v.map(function(Y){return String(Y)});j.unshift("Warning: "+k),Function.prototype.apply.call(console[A],console,j)}}function r(A,k){return A===k&&(A!==0||1/A===1/k)||A!==A&&k!==k}var o=typeof Object.is=="function"?Object.is:r,a=e.useState,s=e.useEffect,c=e.useLayoutEffect,p=e.useDebugValue,l=!1,u=!1;function f(A,k,v){l||e.startTransition!==void 0&&(l=!0,i("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."));var O=k();if(!u){var L=k();o(O,L)||(i("The result of getSnapshot should be cached to avoid an infinite loop"),u=!0)}var j=a({inst:{value:O,getSnapshot:k}}),Y=j[0].inst,K=j[1];return c(function(){Y.value=O,Y.getSnapshot=k,x(Y)&&K({inst:Y})},[A,O,k]),s(function(){x(Y)&&K({inst:Y});var re=function(){x(Y)&&K({inst:Y})};return A(re)},[A]),p(O),O}function x(A){var k=A.getSnapshot,v=A.value;try{var O=k();return!o(v,O)}catch{return!0}}function h(A,k,v){return k()}var g=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",E=!g,m=E?h:f,C=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:m;ai.useSyncExternalStore=C,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error)}()),ai}var bo;function Bl(){return bo||(bo=1,process.env.NODE_ENV==="production"?xn.exports=Pl():xn.exports=Il()),xn.exports}var wo=Bl();const et=()=>{},je=et(),si=Object,H=e=>e===je,$e=e=>typeof e=="function",Ne=(e,t)=>({...e,...t}),Ll=e=>$e(e.then),vn=new WeakMap;let Ml=0;const Bt=e=>{const t=typeof e,i=e&&e.constructor,n=i==Date;let r,o;if(si(e)===e&&!n&&i!=RegExp){if(r=vn.get(e),r)return r;if(r=++Ml+"~",vn.set(e,r),i==Array){for(r="@",o=0;o<e.length;o++)r+=Bt(e[o])+",";vn.set(e,r)}if(i==si){r="#";const a=si.keys(e).sort();for(;!H(o=a.pop());)H(e[o])||(r+=o+":"+Bt(e[o])+",");vn.set(e,r)}}else r=n?e.toJSON():t=="symbol"?e.toString():t=="string"?JSON.stringify(e):""+e;return r},Ge=new WeakMap,ci={},gn={},li="undefined",hn=typeof window!=li,pi=typeof document!=li,zl=()=>hn&&typeof window.requestAnimationFrame!=li,ui=(e,t)=>{const i=Ge.get(e);return[()=>!H(t)&&e.get(t)||ci,n=>{if(!H(t)){const r=e.get(t);t in gn||(gn[t]=r),i[5](t,Ne(r,n),r||ci)}},i[6],()=>!H(t)&&t in gn?gn[t]:!H(t)&&e.get(t)||ci]};let di=!0;const $l=()=>di,[fi,mi]=hn&&window.addEventListener?[window.addEventListener.bind(window),window.removeEventListener.bind(window)]:[et,et],Nl=()=>{const e=pi&&document.visibilityState;return H(e)||e!=="hidden"},ql=e=>(pi&&document.addEventListener("visibilitychange",e),fi("focus",e),()=>{pi&&document.removeEventListener("visibilitychange",e),mi("focus",e)}),Wl=e=>{const t=()=>{di=!0,e()},i=()=>{di=!1};return fi("online",t),fi("offline",i),()=>{mi("online",t),mi("offline",i)}},Ul={isOnline:$l,isVisible:Nl},Vl={initFocus:ql,initReconnect:Wl},Lt=!w.useId,dt=!hn||"Deno"in window,Eo=e=>zl()?window.requestAnimationFrame(e):setTimeout(e,1),tt=dt?w.useEffect:w.useLayoutEffect,xi=typeof navigator<"u"&&navigator.connection,So=!dt&&xi&&(["slow-2g","2g"].includes(xi.effectiveType)||xi.saveData),Mt=e=>{if($e(e))try{e=e()}catch{e=""}const t=e;return e=typeof e=="string"?e:(Array.isArray(e)?e.length:e)?Bt(e):"",[e,t]};let Hl=0;const Et=()=>++Hl,To=0,Ro=1,ko=2;var Ye={__proto__:null,ERROR_REVALIDATE_EVENT:3,FOCUS_EVENT:To,MUTATE_EVENT:ko,RECONNECT_EVENT:Ro};async function vi(...e){const[t,i,n,r]=e,o=Ne({populateCache:!0,throwOnError:!0},typeof r=="boolean"?{revalidate:r}:r||{});let a=o.populateCache;const s=o.rollbackOnError;let c=o.optimisticData;const p=f=>typeof s=="function"?s(f):s!==!1,l=o.throwOnError;if($e(i)){const f=i,x=[],h=t.keys();for(const g of h)!/^\$(inf|sub)\$/.test(g)&&f(t.get(g)._k)&&x.push(g);return Promise.all(x.map(u))}return u(i);async function u(f){const[x]=Mt(f);if(!x)return;const[h,g]=ui(t,x),[E,m,C,A]=Ge.get(t),k=()=>{const Q=E[x];return($e(o.revalidate)?o.revalidate(h().data,f):o.revalidate!==!1)&&(delete C[x],delete A[x],Q&&Q[0])?Q[0](ko).then(()=>h().data):h().data};if(e.length<3)return k();let v=n,O;const L=Et();m[x]=[L,0];const j=!H(c),Y=h(),K=Y.data,re=Y._c,oe=H(re)?K:re;if(j&&(c=$e(c)?c(oe,K):c,g({data:c,_c:oe})),$e(v))try{v=v(oe)}catch(Q){O=Q}if(v&&Ll(v))if(v=await v.catch(Q=>{O=Q}),L!==m[x][0]){if(O)throw O;return v}else O&&j&&p(O)&&(a=!0,g({data:oe,_c:je}));if(a&&!O)if($e(a)){const Q=a(v,oe);g({data:Q,error:je,_c:je})}else g({data:v,error:je,_c:je});if(m[x][1]=Et(),Promise.resolve(k()).then(()=>{g({_c:je})}),O){if(l)throw O;return}return v}}const Co=(e,t)=>{for(const i in e)e[i][0]&&e[i][0](t)},Gl=(e,t)=>{if(!Ge.has(e)){const i=Ne(Vl,t),n={},r=vi.bind(je,e);let o=et;const a={},s=(l,u)=>{const f=a[l]||[];return a[l]=f,f.push(u),()=>f.splice(f.indexOf(u),1)},c=(l,u,f)=>{e.set(l,u);const x=a[l];if(x)for(const h of x)h(u,f)},p=()=>{if(!Ge.has(e)&&(Ge.set(e,[n,{},{},{},r,c,s]),!dt)){const l=i.initFocus(setTimeout.bind(je,Co.bind(je,n,To))),u=i.initReconnect(setTimeout.bind(je,Co.bind(je,n,Ro)));o=()=>{l&&l(),u&&u(),Ge.delete(e)}}};return p(),[e,r,p,o]}return[e,Ge.get(e)[4]]},Yl=(e,t,i,n,r)=>{const o=i.errorRetryCount,a=r.retryCount,s=~~((Math.random()+.5)*(1<<(a<8?a:8)))*i.errorRetryInterval;!H(o)&&a>o||setTimeout(n,s,r)},Kl=(e,t)=>Bt(e)==Bt(t),[Oo,Jl]=Gl(new Map),Xl=Ne({onLoadingSlow:et,onSuccess:et,onError:et,onErrorRetry:Yl,onDiscarded:et,revalidateOnFocus:!0,revalidateOnReconnect:!0,revalidateIfStale:!0,shouldRetryOnError:!0,errorRetryInterval:So?1e4:5e3,focusThrottleInterval:5*1e3,dedupingInterval:2*1e3,loadingTimeout:So?5e3:3e3,compare:Kl,isPaused:()=>!1,cache:Oo,mutate:Jl,fallback:{}},Ul),Zl=(e,t)=>{const i=Ne(e,t);if(t){const{use:n,fallback:r}=e,{use:o,fallback:a}=t;n&&o&&(i.use=n.concat(o)),r&&a&&(i.fallback=Ne(r,a))}return i},Ql=w.createContext({}),ep="$inf$",_o=hn&&window.__SWR_DEVTOOLS_USE__,tp=_o?window.__SWR_DEVTOOLS_USE__:[],np=()=>{_o&&(window.__SWR_DEVTOOLS_REACT__=w)},Ao=e=>$e(e[1])?[e[0],e[1],e[2]||{}]:[e[0],null,(e[1]===null?e[2]:e[1])||{}],jo=()=>Ne(Xl,w.useContext(Ql)),ip=e=>(t,i,n)=>e(t,i&&((...o)=>{const[a]=Mt(t),[,,,s]=Ge.get(Oo);if(a.startsWith(ep))return i(...o);const c=s[a];return H(c)?i(...o):(delete s[a],c)}),n),rp=tp.concat(ip),Do=e=>function(...i){const n=jo(),[r,o,a]=Ao(i),s=Zl(n,a);let c=e;const{use:p}=s,l=(p||[]).concat(rp);for(let u=l.length;u--;)c=l[u](c);return c(r,o||s.fetcher||null,s)},Fo=(e,t,i)=>{const n=t[e]||(t[e]=[]);return n.push(i),()=>{const r=n.indexOf(i);r>=0&&(n[r]=n[n.length-1],n.pop())}},op=(e,t)=>(...i)=>{const[n,r,o]=Ao(i),a=(o.use||[]).concat(t);return e(n,r,{...o,use:a})};np();const Po=w.use||(e=>{if(e.status==="pending")throw e;if(e.status==="fulfilled")return e.value;throw e.status==="rejected"?e.reason:(e.status="pending",e.then(t=>{e.status="fulfilled",e.value=t},t=>{e.status="rejected",e.reason=t}),e)}),gi={dedupe:!0},ap=Do((e,t,i)=>{const{cache:n,compare:r,suspense:o,fallbackData:a,revalidateOnMount:s,revalidateIfStale:c,refreshInterval:p,refreshWhenHidden:l,refreshWhenOffline:u,keepPreviousData:f}=i,[x,h,g,E]=Ge.get(n),[m,C]=Mt(e),A=w.useRef(!1),k=w.useRef(!1),v=w.useRef(m),O=w.useRef(t),L=w.useRef(i),j=()=>L.current,Y=()=>j().isVisible()&&j().isOnline(),[K,re,oe,Q]=ui(n,m),U=w.useRef({}).current,le=H(a)?i.fallback[m]:a,xe=(b,I)=>{for(const ee in U){const V=ee;if(V==="data"){if(!r(b[V],I[V])&&(!H(b[V])||!r(J,I[V])))return!1}else if(I[V]!==b[V])return!1}return!0},we=w.useMemo(()=>{const b=!m||!t?!1:H(s)?j().isPaused()||o?!1:H(c)?!0:c:s,I=ie=>{const Te=Ne(ie);return delete Te._k,b?{isValidating:!0,isLoading:!0,...Te}:Te},ee=K(),V=Q(),ve=I(ee),ke=ee===V?ve:I(V);let ne=ve;return[()=>{const ie=I(K());return xe(ie,ne)?(ne.data=ie.data,ne.isLoading=ie.isLoading,ne.isValidating=ie.isValidating,ne.error=ie.error,ne):(ne=ie,ie)},()=>ke]},[n,m]),ce=wo.useSyncExternalStore(w.useCallback(b=>oe(m,(I,ee)=>{xe(ee,I)||b()}),[n,m]),we[0],we[1]),he=!A.current,T=x[m]&&x[m].length>0,_=ce.data,M=H(_)?le:_,W=ce.error,N=w.useRef(M),J=f?H(_)?N.current:_:M,$=T&&!H(W)?!1:he&&!H(s)?s:j().isPaused()?!1:o?H(M)?!1:c:H(M)||c,P=!!(m&&t&&he&&$),G=H(ce.isValidating)?P:ce.isValidating,X=H(ce.isLoading)?P:ce.isLoading,q=w.useCallback(async b=>{const I=O.current;if(!m||!I||k.current||j().isPaused())return!1;let ee,V,ve=!0;const ke=b||{},ne=!g[m]||!ke.dedupe,ie=()=>Lt?!k.current&&m===v.current&&A.current:m===v.current,Te={isValidating:!1,isLoading:!1},Je=()=>{re(Te)},Ue=()=>{const S=g[m];S&&S[1]===V&&delete g[m]},Xe={isValidating:!0};H(K().data)&&(Xe.isLoading=!0);try{if(ne&&(re(Xe),i.loadingTimeout&&H(K().data)&&setTimeout(()=>{ve&&ie()&&j().onLoadingSlow(m,i)},i.loadingTimeout),g[m]=[I(C),Et()]),[ee,V]=g[m],ee=await ee,ne&&setTimeout(Ue,i.dedupingInterval),!g[m]||g[m][1]!==V)return ne&&ie()&&j().onDiscarded(m),!1;Te.error=je;const S=h[m];if(!H(S)&&(V<=S[0]||V<=S[1]||S[1]===0))return Je(),ne&&ie()&&j().onDiscarded(m),!1;const D=K().data;Te.data=r(D,ee)?D:ee,ne&&ie()&&j().onSuccess(ee,m,i)}catch(S){Ue();const D=j(),{shouldRetryOnError:ue}=D;D.isPaused()||(Te.error=S,ne&&ie()&&(D.onError(S,m,D),(ue===!0||$e(ue)&&ue(S))&&(!j().revalidateOnFocus||!j().revalidateOnReconnect||Y())&&D.onErrorRetry(S,m,D,ye=>{const Ce=x[m];Ce&&Ce[0]&&Ce[0](Ye.ERROR_REVALIDATE_EVENT,ye)},{retryCount:(ke.retryCount||0)+1,dedupe:!0})))}return ve=!1,Je(),!0},[m,n]),Ee=w.useCallback((...b)=>vi(n,v.current,...b),[]);if(tt(()=>{O.current=t,L.current=i,H(_)||(N.current=_)}),tt(()=>{if(!m)return;const b=q.bind(je,gi);let I=0;const V=Fo(m,x,(ve,ke={})=>{if(ve==Ye.FOCUS_EVENT){const ne=Date.now();j().revalidateOnFocus&&ne>I&&Y()&&(I=ne+j().focusThrottleInterval,b())}else if(ve==Ye.RECONNECT_EVENT)j().revalidateOnReconnect&&Y()&&b();else{if(ve==Ye.MUTATE_EVENT)return q();if(ve==Ye.ERROR_REVALIDATE_EVENT)return q(ke)}});return k.current=!1,v.current=m,A.current=!0,re({_k:C}),$&&(H(M)||dt?b():Eo(b)),()=>{k.current=!0,V()}},[m]),tt(()=>{let b;function I(){const V=$e(p)?p(K().data):p;V&&b!==-1&&(b=setTimeout(ee,V))}function ee(){!K().error&&(l||j().isVisible())&&(u||j().isOnline())?q(gi).then(I):I()}return I(),()=>{b&&(clearTimeout(b),b=-1)}},[p,l,u,m]),w.useDebugValue(J),o&&H(M)&&m){if(!Lt&&dt)throw new Error("Fallback data is required when using suspense in SSR.");O.current=t,L.current=i,k.current=!1;const b=E[m];if(!H(b)){const I=Ee(b);Po(I)}if(H(W)){const I=q(gi);H(J)||(I.status="fulfilled",I.value=!0),Po(I)}else throw W}return{mutate:Ee,get data(){return U.data=!0,J},get error(){return U.error=!0,W},get isValidating(){return U.isValidating=!0,G},get isLoading(){return U.isLoading=!0,X}}}),Io=w.use||(e=>{if(e.status==="pending")throw e;if(e.status==="fulfilled")return e.value;throw e.status==="rejected"?e.reason:(e.status="pending",e.then(t=>{e.status="fulfilled",e.value=t},t=>{e.status="rejected",e.reason=t}),e)}),hi={dedupe:!0},sp=Do((e,t,i)=>{const{cache:n,compare:r,suspense:o,fallbackData:a,revalidateOnMount:s,revalidateIfStale:c,refreshInterval:p,refreshWhenHidden:l,refreshWhenOffline:u,keepPreviousData:f}=i,[x,h,g,E]=Ge.get(n),[m,C]=Mt(e),A=w.useRef(!1),k=w.useRef(!1),v=w.useRef(m),O=w.useRef(t),L=w.useRef(i),j=()=>L.current,Y=()=>j().isVisible()&&j().isOnline(),[K,re,oe,Q]=ui(n,m),U=w.useRef({}).current,le=H(a)?i.fallback[m]:a,xe=(b,I)=>{for(const ee in U){const V=ee;if(V==="data"){if(!r(b[V],I[V])&&(!H(b[V])||!r(J,I[V])))return!1}else if(I[V]!==b[V])return!1}return!0},we=w.useMemo(()=>{const b=!m||!t?!1:H(s)?j().isPaused()||o?!1:H(c)?!0:c:s,I=ie=>{const Te=Ne(ie);return delete Te._k,b?{isValidating:!0,isLoading:!0,...Te}:Te},ee=K(),V=Q(),ve=I(ee),ke=ee===V?ve:I(V);let ne=ve;return[()=>{const ie=I(K());return xe(ie,ne)?(ne.data=ie.data,ne.isLoading=ie.isLoading,ne.isValidating=ie.isValidating,ne.error=ie.error,ne):(ne=ie,ie)},()=>ke]},[n,m]),ce=wo.useSyncExternalStore(w.useCallback(b=>oe(m,(I,ee)=>{xe(ee,I)||b()}),[n,m]),we[0],we[1]),he=!A.current,T=x[m]&&x[m].length>0,_=ce.data,M=H(_)?le:_,W=ce.error,N=w.useRef(M),J=f?H(_)?N.current:_:M,$=T&&!H(W)?!1:he&&!H(s)?s:j().isPaused()?!1:o?H(M)?!1:c:H(M)||c,P=!!(m&&t&&he&&$),G=H(ce.isValidating)?P:ce.isValidating,X=H(ce.isLoading)?P:ce.isLoading,q=w.useCallback(async b=>{const I=O.current;if(!m||!I||k.current||j().isPaused())return!1;let ee,V,ve=!0;const ke=b||{},ne=!g[m]||!ke.dedupe,ie=()=>Lt?!k.current&&m===v.current&&A.current:m===v.current,Te={isValidating:!1,isLoading:!1},Je=()=>{re(Te)},Ue=()=>{const S=g[m];S&&S[1]===V&&delete g[m]},Xe={isValidating:!0};H(K().data)&&(Xe.isLoading=!0);try{if(ne&&(re(Xe),i.loadingTimeout&&H(K().data)&&setTimeout(()=>{ve&&ie()&&j().onLoadingSlow(m,i)},i.loadingTimeout),g[m]=[I(C),Et()]),[ee,V]=g[m],ee=await ee,ne&&setTimeout(Ue,i.dedupingInterval),!g[m]||g[m][1]!==V)return ne&&ie()&&j().onDiscarded(m),!1;Te.error=je;const S=h[m];if(!H(S)&&(V<=S[0]||V<=S[1]||S[1]===0))return Je(),ne&&ie()&&j().onDiscarded(m),!1;const D=K().data;Te.data=r(D,ee)?D:ee,ne&&ie()&&j().onSuccess(ee,m,i)}catch(S){Ue();const D=j(),{shouldRetryOnError:ue}=D;D.isPaused()||(Te.error=S,ne&&ie()&&(D.onError(S,m,D),(ue===!0||$e(ue)&&ue(S))&&(!j().revalidateOnFocus||!j().revalidateOnReconnect||Y())&&D.onErrorRetry(S,m,D,ye=>{const Ce=x[m];Ce&&Ce[0]&&Ce[0](Ye.ERROR_REVALIDATE_EVENT,ye)},{retryCount:(ke.retryCount||0)+1,dedupe:!0})))}return ve=!1,Je(),!0},[m,n]),Ee=w.useCallback((...b)=>vi(n,v.current,...b),[]);if(tt(()=>{O.current=t,L.current=i,H(_)||(N.current=_)}),tt(()=>{if(!m)return;const b=q.bind(je,hi);let I=0;const V=Fo(m,x,(ve,ke={})=>{if(ve==Ye.FOCUS_EVENT){const ne=Date.now();j().revalidateOnFocus&&ne>I&&Y()&&(I=ne+j().focusThrottleInterval,b())}else if(ve==Ye.RECONNECT_EVENT)j().revalidateOnReconnect&&Y()&&b();else{if(ve==Ye.MUTATE_EVENT)return q();if(ve==Ye.ERROR_REVALIDATE_EVENT)return q(ke)}});return k.current=!1,v.current=m,A.current=!0,re({_k:C}),$&&(H(M)||dt?b():Eo(b)),()=>{k.current=!0,V()}},[m]),tt(()=>{let b;function I(){const V=$e(p)?p(K().data):p;V&&b!==-1&&(b=setTimeout(ee,V))}function ee(){!K().error&&(l||j().isVisible())&&(u||j().isOnline())?q(hi).then(I):I()}return I(),()=>{b&&(clearTimeout(b),b=-1)}},[p,l,u,m]),w.useDebugValue(J),o&&H(M)&&m){if(!Lt&&dt)throw new Error("Fallback data is required when using suspense in SSR.");O.current=t,L.current=i,k.current=!1;const b=E[m];if(!H(b)){const I=Ee(b);Io(I)}if(H(W)){const I=q(hi);H(J)||(I.status="fulfilled",I.value=!0),Io(I)}else throw W}return{mutate:Ee,get data(){return U.data=!0,J},get error(){return U.error=!0,W},get isValidating(){return U.isValidating=!0,G},get isLoading(){return U.isLoading=!0,X}}}),Bo=Lt?e=>{e()}:w.startTransition,cp=e=>{const[,t]=w.useState({}),i=w.useRef(!1),n=w.useRef(e),r=w.useRef({data:!1,error:!1,isValidating:!1}),o=w.useCallback(a=>{let s=!1;const c=n.current;for(const p in a){const l=p;c[l]!==a[l]&&(c[l]=a[l],r.current[l]&&(s=!0))}s&&!i.current&&t({})},[]);return tt(()=>(i.current=!1,()=>{i.current=!0})),[n,r.current,o]},lp=op(sp,()=>(e,t,i={})=>{const{mutate:n}=jo(),r=w.useRef(e),o=w.useRef(t),a=w.useRef(i),s=w.useRef(0),[c,p,l]=cp({data:je,error:je,isMutating:!1}),u=c.current,f=w.useCallback(async(h,g)=>{const[E,m]=Mt(r.current);if(!o.current)throw new Error("Can’t trigger the mutation: missing fetcher.");if(!E)throw new Error("Can’t trigger the mutation: missing key.");const C=Ne(Ne({populateCache:!1,throwOnError:!0},a.current),g),A=Et();s.current=A,l({isMutating:!0});try{const k=await n(E,o.current(m,{arg:h}),Ne(C,{throwOnError:!0}));return s.current<=A&&(Bo(()=>l({data:k,isMutating:!1,error:void 0})),C.onSuccess==null||C.onSuccess.call(C,k,E,C)),k}catch(k){if(s.current<=A&&(Bo(()=>l({error:k,isMutating:!1})),C.onError==null||C.onError.call(C,k,E,C),C.throwOnError))throw k}},[]),x=w.useCallback(()=>{s.current=Et(),l({data:je,error:je,isMutating:!1})},[]);return tt(()=>{r.current=e,o.current=t,a.current=i}),{trigger:f,reset:x,get data(){return p.data=!0,u.data},get error(){return p.error=!0,u.error},get isMutating(){return p.isMutating=!0,u.isMutating}}}),pp=e=>{const t=r=>typeof r=="object"&&!(r instanceof Date)&&!(r instanceof File)&&r!==null,i=(r,o,a)=>{for(const s in o){const c=o[s];t(c)?i(`${r}[${s}]`,c,a):c!==void 0&&a.append(`${r}[${s}]`,c===null?"":c)}},n=new FormData;for(const r in e){const o=e[r];o instanceof File?n.append(r,o,o.name):o!==void 0&&(t(o)?i(r,o,n):n.append(r,o===null?"":o))}return n},up=_e("div",{"--progress":"-100%",height:"4px",width:"100%",background:"rgba(255, 255, 255, 0.1)",borderRadius:"12px",position:"relative",overflow:"hidden"}),dp=_e("div",{height:"100%",width:"100%",background:"#ffffff",transform:"translateX(var(--progress))",borderRadius:"12px"}),nt={Root:up,Bar:dp};function yn(e,t,i){for(let n=0;n<e.length;++n)t[i+n]=e.charCodeAt(n)}function bn(e,t,i){e=Math.floor(e),t[i+0]=e&255,t[i+1]=e>>8&255}function ft(e,t,i){e=Math.floor(e),t[i+0]=e&255,t[i+1]=e>>8&255,t[i+2]=e>>16&255,t[i+3]=e>>24&255}function fp(e){const t=new ArrayBuffer(4);return new Float32Array(t)[0]=e,new Uint32Array(t)[0]|0}function mp(e,t,i,n){let r=0,o=0;const a=e.length,s=e.numberOfChannels;let c,p;for(r=0;r<a;++r)for(o=0;o<s;++o)if(c=e.getChannelData(o),n===16)p=c[r]*32768,p=Math.max(-32768,Math.min(p,32767)),bn(p,t,i),i+=2;else if(n===32)p=fp(c[r]),ft(p,t,i),i+=4;else{console.log("Invalid bit depth for PCM encoding.");return}}async function xp(e,t){let i=e instanceof Blob?e:new Blob(e);const n=URL.createObjectURL(i),o=await(await fetch(n)).arrayBuffer();return await new AudioContext(t).decodeAudioData(o)}async function vp(e,t=!1){const i=e.length,n=e.numberOfChannels,r=e.sampleRate,o=t?32:16,a=o/8,s=r*n*o/8,c=n*o/8,p=i*n*a,u=44+p,f=new Uint8Array(u),x=16,h=p,g=4+(8+x)+(8+h);return yn("RIFF",f,0),ft(g,f,4),yn("WAVE",f,8),yn("fmt ",f,12),ft(x,f,16),bn(t?3:1,f,20),bn(n,f,22),ft(r,f,24),ft(s,f,28),bn(c,f,32),ft(o,f,34),yn("data",f,36),ft(h,f,40),mp(e,f,44,o),new Blob([f],{type:"audio/wave"})}async function gp(e,t=!1,i){const n=await xp(e,i);return vp(n,t)}const hp=128;class yp{constructor(){En(this,"mediaRecorder",null);En(this,"stream",null);En(this,"__data",null)}async checkMicrophonePermission(){var n;return!!(await((n=navigator==null?void 0:navigator.mediaDevices)==null?void 0:n.enumerateDevices())).find(r=>r.kind==="audioinput"&&!!r.label)}async startRecording(){var t;if(((t=this.mediaRecorder)==null?void 0:t.state)==="recording")return!0;try{this.stream=await navigator.mediaDevices.getUserMedia({audio:!0,video:!1}),this.mediaRecorder=new MediaRecorder(this.stream,{bitsPerSecond:hp*1e3}),this.mediaRecorder.ondataavailable=i=>this.__data=i.data}catch(i){return console.error(i),!1}return this.mediaRecorder.start(),!0}stopRecording(){return new Promise(t=>{var i;if(((i=this.mediaRecorder)==null?void 0:i.state)!=="recording"){t(!0);return}this.mediaRecorder.stop(),this.mediaRecorder.onstop=()=>{var n;(n=this.stream)==null||n.getTracks().forEach(r=>r.stop()),this.mediaRecorder=null,this.stream=null,t(!0)}})}async getWavBlob(){return this.__data?await gp(this.__data):null}}const wn=new yp,yi="Recording.wav",Lo=1500,bp=e=>{const[t,i]=w.useState(!1),[n,r]=w.useState(!1),[o,a]=w.useState(!1);return w.useEffect(()=>{var p;const c=async()=>{wn.checkMicrophonePermission().then(i)};return c(),(p=navigator==null?void 0:navigator.mediaDevices)==null||p.addEventListener("devicechange",c),()=>{var l;return(l=navigator==null?void 0:navigator.mediaDevices)==null?void 0:l.removeEventListener("devicechange",c)}},[]),{hasMicAccess:t,isRecording:n,hasMinTimeElapsed:o,handleClick:async()=>{if(n){if(!o)return;r(!1),a(!1),await wn.stopRecording();const p=await wn.getWavBlob();if(!p){console.log("Failed to get audio blob",p);return}const l=new File([p],yi,{type:"audio/mpeg",lastModified:Date.now()});e.onFileUpdate(l);return}const c=await wn.startRecording();r(c),setTimeout(()=>{a(!0)},Lo)}}},Mo=Ae.create({baseURL:"https://arpeggi.io/api/v2/"}),wp=async(e,{arg:t})=>{var n;return(await Mo.post("/ml-inference-jobs",pp({soundFile:t.file,type:"audio",voiceModelId:t.voiceModelId,strapiDemoId:t.strapiDemoId,metadata:{isRecordedAudio:((n=t.file)==null?void 0:n.name)===yi}}),{params:{type:"audio"}})).data},Ep=async e=>e===null?null:(await Mo.get(e)).data,Sp=e=>{const t=e>0;return ap(t?`/ml-inference-jobs/${e}`:null,Ep,{refreshInterval:i=>(i==null?void 0:i.jobStatus)==="success"?0:1e3})},Tp=()=>{const[e,t]=w.useState("file"),[i,n]=w.useState(void 0),[r,o]=w.useState(void 0),[a,s]=w.useState(0),[c,p]=w.useState(0),{data:l,isLoading:u}=Sp(a),{trigger:f,isMutating:x}=lp("/ml-inference-jobs",wp);return{demoId:i,setDemoId:n,file:r,setFile:o,mlijId:a,setMlijId:s,voiceModelId:c,setVoiceModelId:p,data:l,isLoading:u,handleSelectVoice:async E=>{!r&&!i||(s(0),p(E),f({file:r,strapiDemoId:i,voiceModelId:E},{onSuccess:m=>{console.log("created mlij",m),s(m.id)}}))},reset:()=>{t("file"),n(void 0),o(void 0),s(0),p(0)},isMutating:x,step:e,setStep:t}},zo=w.createContext({}),zt=()=>w.useContext(zo),Rp=({children:e})=>{const t=Tp();return z.jsx(jr,{children:z.jsx(zo.Provider,{value:t,children:e})})},kp=_e("button",{background:"#ffffff",flexShrink:0,borderRadius:"12px",width:"64px",height:"64px",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",border:"none",outline:"none",transition:"background 0.2s ease-in-out, transform 0.2s ease-in-out",color:"#000000","& > svg":{width:"24px",height:"24px"},"&:hover":{background:"#ffffff99",transform:"scale(1.05)"},"&:active":{background:"#ffffffcc"},"&:disabled":{background:"rgba(255, 255, 255, 0.3)",transform:"none",cursor:"not-allowed"}}),Cp=_e("div",{fontSize:"11px",lineHeight:"14px",fontFamily:'"General Sans Medium", "General Sans Medium Placeholder", sans-serif',color:"#ffffff",textTransform:"uppercase",letterSpacing:"2.2px",fontWeight:400}),Op=e=>{var c;const{data:t,isMutating:i}=zt(),n=(c=t==null?void 0:t.lossyOutputFile)==null?void 0:c.url,{player:r,playPause:o}=Un(n),a=w.useRef(null),s=w.useRef();return w.useEffect(()=>{if(!r.isPlaying)return()=>{cancelAnimationFrame(s.current)};const p=()=>{var u;const l=r.audioRef.current.currentTime/r.audioRef.current.duration;(u=a.current)==null||u.style.setProperty("--progress",`${-100+l*100}%`),s.current=requestAnimationFrame(p)};return s.current=requestAnimationFrame(p),()=>{cancelAnimationFrame(s.current)}},[r.isPlaying,r.audioRef]),z.jsxs(Le,{row:!0,align:"center",flex:"1",gap:"16",...e,children:[z.jsx(kp,{onClick:o,disabled:r.isLoading||!n,children:z.jsxs(Ie,{children:[z.jsx(Ie.If,{isTrue:r.isLoading||(t==null?void 0:t.jobStatus)==="running"||i,children:z.jsx(kr,{})}),z.jsx(Ie.If,{isTrue:r.isPlaying,children:z.jsx(Cr,{})}),z.jsx(Ie.Else,{children:z.jsx(Or,{})})]})}),z.jsxs(Le,{flex:"1",column:!0,gap:"12",children:[z.jsx(Cp,{children:z.jsxs(Ie,{children:[z.jsx(Ie.If,{isTrue:(t==null?void 0:t.jobStatus)==="running",children:"Converting audio"}),z.jsx(Ie.If,{isTrue:i,children:"Uploading audio"}),z.jsx(Ie.Else,{children:"Converted audio"})]})}),z.jsx(nt.Root,{ref:a,children:z.jsx(nt.Bar,{})})]})]})},_p=30,$o=e=>{const t=w.useRef(),i=w.useRef(null);return w.useEffect(()=>{let n=0;return t.current=setInterval(()=>{var o;n+=e;let r=Math.round(Math.atan(n)/(Math.PI/2)*100*1e3)/1e3;(o=i.current)==null||o.style.setProperty("--progress",`${-100+r}%`)},50),()=>clearInterval(t.current)},[]),i},Ap=()=>{const e=$o(.1);return z.jsx(nt.Root,{ref:e,children:z.jsx(nt.Bar,{})})},jp=()=>z.jsx(nt.Root,{children:z.jsx(nt.Bar,{})}),Dp=()=>z.jsx(nt.Root,{style:{"--progress":"0%"},children:z.jsx(nt.Bar,{})}),Fp=()=>{const{data:e}=zt();return e?e.jobStatus==="success"?z.jsx(Dp,{}):z.jsx(Ap,{},e==null?void 0:e.id):z.jsx(jp,{})},Pp=1,Ip=100*1024*1024,Bp=1,Lp=({children:e})=>{const{setFile:t}=zt(),i=n=>t(n[0]);return z.jsx(Rr,{files:[],onFileAccepted:i,maxFileCount:Pp,maxSizeBytes:Ip,minSizeBytes:Bp,maxDurationS:_p,children:e})},Mp=_e(Le,{width:"100%",height:"100%",display:"flex",overflow:"hidden",borderRadius:"16px",background:"#ffffff10",flexDirection:"column",alignItems:"stretch",justifyContent:"center"}),zp=_e(Le,{paddingTop:"32px",paddingBottom:"16px",alignItems:"center",display:"flex",justifyContent:"center",fontSize:"22px",lineHeight:"1.4em",letterSpacing:"0.01em",fontFamily:'"General Sans Medium", "General Sans Medium Placeholder", sans-serif',color:"rgba(255, 255, 255, 0.9)",fontWeight:500}),$p=_e(Le,{flex:1,gap:"12px",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"32px"}),Np=_e(Le,{borderTop:"1px solid #ffffff10",display:"flex",alignItems:"center",justifyContent:"center",padding:"12px"}),qp=_e("div",{padding:"20px",background:"rgba(255, 255, 255, 0.03)",border:"1px solid transparent",borderRadius:"12px",display:"flex",alignItems:"center",gap:"10px",cursor:"pointer",transition:"background 0.2s ease-in-out","&:hover":{background:"rgba(255, 255, 255, 0.06)"},"&:active":{background:"rgba(255, 255, 255, 0.1)",borderColor:"rgba(255, 255, 255, 0.1)"},variants:{selected:{true:{background:"rgba(255, 255, 255, 0.1)",borderColor:"rgba(255, 255, 255, 0.1)"}}}}),Wp=_e("div",{fontSize:"16px",lineHeight:"1.2em",fontFamily:'"General Sans Medium", "General Sans Medium Placeholder", sans-serif',color:"rgba(255, 255, 255, 0.9)",fontWeight:400}),Up=_e("button",{border:"none",background:"transparent",cursor:"pointer",padding:"0",margin:"0",width:"32px",height:"32px",display:"flex",alignItems:"center",justifyContent:"center","& > svg":{width:"24px",height:"24px"},color:"#ffffff",position:"relative",transition:"transform 0.2s ease-in-out","&:hover":{transform:"scale(1.1)"}}),Vp=_e("button",{border:"none",background:"rgba(255, 255, 255, 1)",fontSize:"11px",lineHeight:"14px",fontFamily:'"General Sans Medium", "General Sans Medium Placeholder", sans-serif',color:"rgba(0, 0, 0, 1)",textTransform:"uppercase",letterSpacing:"2.2px",fontWeight:400,display:"flex",alignItems:"center",justifyContent:"center",padding:"14px 24px",borderRadius:"8px",cursor:"pointer",transition:"all 0.2s ease-in-out","&:hover":{background:"rgba(255, 255, 255, 0.9)",transform:"scale(1.05)"},"&:active":{background:"rgba(255, 255, 255, 0.8)",transform:"scale(0.95)"},"&:disabled":{background:"rgba(255, 255, 255, 0.2)",transform:"none",cursor:"not-allowed"}}),Hp=({demo:e,onSelect:t,selected:i})=>{const{playPause:n,player:r}=Un(e.audioUrl);return z.jsxs(qp,{onClick:()=>t(e.id),selected:i,children:[z.jsx(Up,{onClick:n,disabled:r.isLoading,children:z.jsxs(Ie,{children:[z.jsx(Ie.If,{isTrue:r.isLoading,children:z.jsx(kr,{})}),z.jsx(Ie.If,{isTrue:r.isPlaying,children:z.jsx(Cr,{})}),z.jsx(Ie.Else,{children:z.jsx(Or,{})})]})}),z.jsx(Wp,{children:e.label})]})},Gp=({demos:e})=>{const{setDemoId:t,demoId:i}=zt(),[n,r]=w.useState(i);return z.jsxs(Mp,{children:[z.jsx(zp,{children:"Select demo audio"}),z.jsx($p,{children:z.jsx(Le,{column:!0,css:{maxWidth:"724px"},children:e.map(o=>z.jsx(Hp,{demo:o,onSelect:r,selected:n===o.id},o.id))})}),z.jsx(Np,{children:z.jsx(Vp,{onClick:()=>t(n),children:"Next"})})]})};pe.AudioFilePickerRoot=Rr,pe.Box=Le,pe.ConvertStep=rc,pe.DemoPicker=Gp,pe.FilePicker=Lp,pe.GuestConvertProvider=Rp,pe.InferenceProgress=Fp,pe.MIN_RECORDING_LENGTH_MS=Lo,pe.PlayButton=Op,pe.PlayerProvider=jr,pe.RECORDED_AUDIO_NAME=yi,pe.useAudioFilePickerContext=Xs,pe.useFakeProgress=$o,pe.useGuestConvertContext=zt,pe.useMediaQuery=Zo,pe.usePlayback=Un,pe.usePlayer=Ar,pe.usePlayerControls=pc,pe.useRecorder=bp,Object.defineProperty(pe,Symbol.toStringTag,{value:"Module"})});
70
70
  //# sourceMappingURL=index.umd.js.map