streamlit-nightly 1.42.1.dev20250206__py2.py3-none-any.whl → 1.42.1.dev20250208__py2.py3-none-any.whl
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.
- streamlit/auth_util.py +8 -0
- streamlit/config.py +18 -1
- streamlit/proto/NewSession_pb2.pyi +4 -1
- streamlit/runtime/app_session.py +35 -15
- streamlit/runtime/caching/cache_utils.py +1 -1
- streamlit/static/index.html +1 -1
- streamlit/static/static/js/{FileDownload.esm.DwBO4CPU.js → FileDownload.esm.D9415avj.js} +1 -1
- streamlit/static/static/js/FileDropzone.Cd515bsy.js +5 -0
- streamlit/static/static/js/{FormClearHelper.LI0uGKXr.js → FormClearHelper.BBpErIGP.js} +1 -1
- streamlit/static/static/js/{Hooks.Dic60qKO.js → Hooks.CeSTXIj2.js} +1 -1
- streamlit/static/static/js/{InputInstructions.BVSrSzyM.js → InputInstructions.BU5Td5cJ.js} +1 -1
- streamlit/static/static/js/{ProgressBar.CiuIhn-j.js → ProgressBar.J2QhvKtD.js} +1 -1
- streamlit/static/static/js/{RenderInPortalIfExists.DXoPwgJm.js → RenderInPortalIfExists.BbbrvJaa.js} +1 -1
- streamlit/static/static/js/{Toolbar.Bws727nN.js → Toolbar.D-hUr0RX.js} +1 -1
- streamlit/static/static/js/{base-input.BG3_mR5a.js → base-input.CNkkCv4B.js} +1 -1
- streamlit/static/static/js/{createSuper.BF6PuRKW.js → createSuper.DHhKMTIx.js} +1 -1
- streamlit/static/static/js/{data-grid-overlay-editor.Bv759UXp.js → data-grid-overlay-editor.CRylpesE.js} +1 -1
- streamlit/static/static/js/{downloader.CVHmveIJ.js → downloader.D_08g5mI.js} +1 -1
- streamlit/static/static/js/{es6.CKbvqIhx.js → es6.B-Rq6ajt.js} +2 -2
- streamlit/static/static/js/{iframeResizer.contentWindow.BkEeeo8L.js → iframeResizer.contentWindow.CFL3MAVr.js} +1 -1
- streamlit/static/static/js/{index.C583HQPW.js → index.-SmXSkUY.js} +1 -1
- streamlit/static/static/js/{index.gthzAzzy.js → index.9wBA4A4f.js} +5 -5
- streamlit/static/static/js/{index.D0P1HMA1.js → index.B-4MHYvl.js} +1 -1
- streamlit/static/static/js/{index.DRYIN7K5.js → index.B0xfT3p4.js} +1 -1
- streamlit/static/static/js/{index.BKVJ1VBu.js → index.B2evntzQ.js} +1 -1
- streamlit/static/static/js/{index.DMae4Z-0.js → index.B9q8XlSH.js} +1 -1
- streamlit/static/static/js/{index.BOaiJM1y.js → index.BA5ubsQA.js} +1 -1
- streamlit/static/static/js/{index.DC0pyGdw.js → index.BCYuLMdi.js} +1 -1
- streamlit/static/static/js/{index.DI1n7tF5.js → index.BNrZwkh1.js} +1 -1
- streamlit/static/static/js/{index.C7ShUXWu.js → index.BVbWPXFU.js} +1 -1
- streamlit/static/static/js/{index.DET-MvNj.js → index.BevO9CYu.js} +2 -2
- streamlit/static/static/js/{index.BOWcB5X0.js → index.BlcNB-sY.js} +1 -1
- streamlit/static/static/js/{index.UxOzm9KZ.js → index.BpmrfDoR.js} +1 -1
- streamlit/static/static/js/{index.DC2ac6Nk.js → index.BqePTNWb.js} +1 -1
- streamlit/static/static/js/{index.ezIYG9hW.js → index.Bw9RDCaH.js} +2 -2
- streamlit/static/static/js/{index.CLsR30iv.js → index.C-_AHUSz.js} +1 -1
- streamlit/static/static/js/{index.y9PB-mTp.js → index.CEWcZMdD.js} +1 -1
- streamlit/static/static/js/{index.C07oOjJI.js → index.CEj-S3PF.js} +1 -1
- streamlit/static/static/js/{index.e9DSvZ6b.js → index.CFtAnwvU.js} +1 -1
- streamlit/static/static/js/{index.Cs3niYHd.js → index.CMcCB4vg.js} +1 -1
- streamlit/static/static/js/{index.VkiSji1p.js → index.CQ_wmqnz.js} +1 -1
- streamlit/static/static/js/{index.TDbcj-aD.js → index.CuNiy4LB.js} +1 -1
- streamlit/static/static/js/{index.C4CvtPIA.js → index.CvADzqCD.js} +1 -1
- streamlit/static/static/js/{index.CYyMatnb.js → index.D94jjl7_.js} +1 -1
- streamlit/static/static/js/{index.CIUGbfN-.js → index.D9M0iUu5.js} +1 -1
- streamlit/static/static/js/{index.Gdr5urlE.js → index.DPs04g4h.js} +1 -1
- streamlit/static/static/js/{index.--2AyPrU.js → index.DWIf4xZP.js} +1 -1
- streamlit/static/static/js/{index.D4zWkike.js → index.DYHaq5Cw.js} +22 -22
- streamlit/static/static/js/{index.BkPpT8KL.js → index.DfCewjMv.js} +1 -1
- streamlit/static/static/js/{index.C_i45xvQ.js → index.DgwklVRJ.js} +1 -1
- streamlit/static/static/js/{index.DZhFuLsM.js → index.DwWMkgFE.js} +1 -1
- streamlit/static/static/js/{index.B5Uxprvt.js → index.JSS70wsq.js} +1 -1
- streamlit/static/static/js/{index.CfBMTPce.js → index.Yr32ts47.js} +1 -1
- streamlit/static/static/js/{index.BImYg1mO.js → index.i2uLxrqv.js} +1 -1
- streamlit/static/static/js/{index.DvjJSBT_.js → index.joQNIDux.js} +1 -1
- streamlit/static/static/js/{index.DCUW0b-w.js → index.pzjWTi64.js} +1 -1
- streamlit/static/static/js/{index.lxFhX6K1.js → index.zzxJWhBg.js} +1 -1
- streamlit/static/static/js/{input.ekQXAXS2.js → input.Dbc83Str.js} +1 -1
- streamlit/static/static/js/{memory.CzhWwr8k.js → memory.BzHgTb9i.js} +1 -1
- streamlit/static/static/js/{mergeWith.CjWtfLVK.js → mergeWith.BCa1_PWb.js} +1 -1
- streamlit/static/static/js/{number-overlay-editor.CFFRhwzv.js → number-overlay-editor.CtUWknLp.js} +1 -1
- streamlit/static/static/js/{possibleConstructorReturn.BiMrneUm.js → possibleConstructorReturn.DGVrr2j8.js} +1 -1
- streamlit/static/static/js/{sandbox.B1Cwdby0.js → sandbox.C20zasAf.js} +1 -1
- streamlit/static/static/js/{textarea.BYQOUi7u.js → textarea.BeRVLTOp.js} +1 -1
- streamlit/static/static/js/{timepicker.BbVkXpKf.js → timepicker.DyU-jgSC.js} +1 -1
- streamlit/static/static/js/{toConsumableArray.eNZZBqsg.js → toConsumableArray.D4FxxWIg.js} +1 -1
- streamlit/static/static/js/{uniqueId.Ci60uueL.js → uniqueId.CAAlIP1-.js} +1 -1
- streamlit/static/static/js/{useBasicWidgetState.BJ0FCAzu.js → useBasicWidgetState.C207Y3_O.js} +1 -1
- streamlit/static/static/js/{useOnInputChange.xhIvlf7z.js → useOnInputChange.CsqRc0X0.js} +1 -1
- streamlit/static/static/js/{withFullScreenWrapper.CKNKx70m.js → withFullScreenWrapper.DwHjQb3H.js} +1 -1
- {streamlit_nightly-1.42.1.dev20250206.dist-info → streamlit_nightly-1.42.1.dev20250208.dist-info}/METADATA +1 -1
- {streamlit_nightly-1.42.1.dev20250206.dist-info → streamlit_nightly-1.42.1.dev20250208.dist-info}/RECORD +76 -76
- streamlit/static/static/js/FileDropzone.l_rm_qyP.js +0 -5
- {streamlit_nightly-1.42.1.dev20250206.data → streamlit_nightly-1.42.1.dev20250208.data}/scripts/streamlit.cmd +0 -0
- {streamlit_nightly-1.42.1.dev20250206.dist-info → streamlit_nightly-1.42.1.dev20250208.dist-info}/WHEEL +0 -0
- {streamlit_nightly-1.42.1.dev20250206.dist-info → streamlit_nightly-1.42.1.dev20250208.dist-info}/entry_points.txt +0 -0
- {streamlit_nightly-1.42.1.dev20250206.dist-info → streamlit_nightly-1.42.1.dev20250208.dist-info}/top_level.txt +0 -0
@@ -1,2 +1,2 @@
|
|
1
|
-
import{d as U,r as w,bw as ee,bY as pt,bJ as vt,bx as Q,bZ as mt,b_ as bt,n as be,ay as yt,y as Tt,aN as kt,z as Ue,j as ae,R as He,cm as Ot,bs as wt,bF as Rt,bt as St,bc as Mt,bu as _t,N as $t,cn as Ee}from"./index.gthzAzzy.js";import{s as We}from"./sprintf.C-r3gIuM.js";import{a as Et}from"./useBasicWidgetState.BJ0FCAzu.js";import"./FormClearHelper.LI0uGKXr.js";var xe={},Ce={},De={},ce={};Object.defineProperty(ce,"__esModule",{value:!0});ce.Direction=void 0;var Ke;(function(t){t.Right="to right",t.Left="to left",t.Down="to bottom",t.Up="to top"})(Ke||(ce.Direction=Ke={}));(function(t){var r=U&&U.__spreadArray||function(o,u,l){if(l||arguments.length===2)for(var p=0,b=u.length,g;p<b;p++)(g||!(p in u))&&(g||(g=Array.prototype.slice.call(u,0,p)),g[p]=u[p]);return o.concat(g||Array.prototype.slice.call(u))};Object.defineProperty(t,"__esModule",{value:!0}),t.isIOS=t.useThumbOverlap=t.assertUnreachable=t.voidFn=t.getTrackBackground=t.replaceAt=t.schd=t.translate=t.getClosestThumbIndex=t.translateThumbs=t.getPaddingAndBorder=t.getMargin=t.checkInitialOverlap=t.checkValuesAgainstBoundaries=t.checkBoundaries=t.isVertical=t.relativeValue=t.normalizeValue=t.isStepDivisible=t.isTouchEvent=t.getStepDecimals=void 0;var n=w,e=ce,a=function(o){var u=o.toString().split(".")[1];return u?u.length:0};t.getStepDecimals=a;function i(o){return o.touches&&o.touches.length||o.changedTouches&&o.changedTouches.length}t.isTouchEvent=i;function s(o,u,l){var p=(u-o)/l,b=8,g=Number(p.toFixed(b));return parseInt(g.toString(),10)===g}t.isStepDivisible=s;function c(o,u,l,p,b,g,T){var k=1e11;if(o=Math.round(o*k)/k,!g){var C=T[u-1],_=T[u+1];if(C&&C>o)return C;if(_&&_<o)return _}if(o>p)return p;if(o<l)return l;var N=Math.floor(o*k-l*k)%Math.floor(b*k),j=Math.floor(o*k-Math.abs(N)),W=N===0?o:j/k,E=Math.abs(N/k)<b/2?W:W+b,I=(0,t.getStepDecimals)(b);return parseFloat(E.toFixed(I))}t.normalizeValue=c;function f(o,u,l){return(o-u)/(l-u)}t.relativeValue=f;function y(o){return o===e.Direction.Up||o===e.Direction.Down}t.isVertical=y;function d(o,u,l){if(u>=l)throw new RangeError("min (".concat(u,") is equal/bigger than max (").concat(l,")"));if(o<u)throw new RangeError("value (".concat(o,") is smaller than min (").concat(u,")"));if(o>l)throw new RangeError("value (".concat(o,") is bigger than max (").concat(l,")"))}t.checkBoundaries=d;function h(o,u,l){return o<u?u:o>l?l:o}t.checkValuesAgainstBoundaries=h;function v(o){if(!(o.length<2)&&!o.slice(1).every(function(u,l){return o[l]<=u}))throw new RangeError("values={[".concat(o,"]} needs to be sorted when allowOverlap={false}"))}t.checkInitialOverlap=v;function R(o){var u=window.getComputedStyle(o);return{top:parseInt(u["margin-top"],10),bottom:parseInt(u["margin-bottom"],10),left:parseInt(u["margin-left"],10),right:parseInt(u["margin-right"],10)}}t.getMargin=R;function m(o){var u=window.getComputedStyle(o);return{top:parseInt(u["padding-top"],10)+parseInt(u["border-top-width"],10),bottom:parseInt(u["padding-bottom"],10)+parseInt(u["border-bottom-width"],10),left:parseInt(u["padding-left"],10)+parseInt(u["border-left-width"],10),right:parseInt(u["padding-right"],10)+parseInt(u["border-right-width"],10)}}t.getPaddingAndBorder=m;function S(o,u,l){var p=l?-1:1;o.forEach(function(b,g){return L(b,p*u[g].x,u[g].y)})}t.translateThumbs=S;function B(o,u,l,p){for(var b=0,g=F(o[0],u,l,p),T=1;T<o.length;T++){var k=F(o[T],u,l,p);k<g&&(g=k,b=T)}return b}t.getClosestThumbIndex=B;function L(o,u,l){o.style.transform="translate(".concat(u,"px, ").concat(l,"px)")}t.translate=L;var D=function(o){var u=[],l=null,p=function(){for(var b=[],g=0;g<arguments.length;g++)b[g]=arguments[g];u=b,!l&&(l=requestAnimationFrame(function(){l=null,o.apply(void 0,u)}))};return p};t.schd=D;function M(o,u,l){var p=o.slice(0);return p[u]=l,p}t.replaceAt=M;function $(o){var u=o.values,l=o.colors,p=o.min,b=o.max,g=o.direction,T=g===void 0?e.Direction.Right:g,k=o.rtl,C=k===void 0?!1:k;C&&T===e.Direction.Right?T=e.Direction.Left:C&&e.Direction.Left&&(T=e.Direction.Right);var _=u.slice(0).sort(function(j,W){return j-W}).map(function(j){return(j-p)/(b-p)*100}),N=_.reduce(function(j,W,E){return"".concat(j,", ").concat(l[E]," ").concat(W,"%, ").concat(l[E+1]," ").concat(W,"%")},"");return"linear-gradient(".concat(T,", ").concat(l[0]," 0%").concat(N,", ").concat(l[l.length-1]," 100%)")}t.getTrackBackground=$;function H(){}t.voidFn=H;function A(o){throw new Error("Didn't expect to get here")}t.assertUnreachable=A;var x=function(o,u,l,p,b){b===void 0&&(b=function(T){return T});var g=Math.ceil(r([o],Array.from(o.children),!0).reduce(function(T,k){var C=Math.ceil(k.getBoundingClientRect().width);if(k.innerText&&k.innerText.includes(l)&&k.childElementCount===0){var _=k.cloneNode(!0);_.innerHTML=b(u.toFixed(p)),_.style.visibility="hidden",document.body.appendChild(_),C=Math.ceil(_.getBoundingClientRect().width),document.body.removeChild(_)}return C>T?C:T},o.getBoundingClientRect().width));return g},G=function(o,u,l,p,b,g,T){T===void 0&&(T=function(_){return _});var k=[],C=function(_){var N=x(l[_],p[_],b,g,T),j=u[_].x;u.forEach(function(W,E){var I=W.x,J=x(l[E],p[E],b,g,T);_!==E&&(j>=I&&j<=I+J||j+N>=I&&j+N<=I+J)&&(k.includes(E)||(k.push(_),k.push(E),k=r(r([],k,!0),[_,E],!1),C(E)))})};return C(o),Array.from(new Set(k.sort()))},X=function(o,u,l,p,b,g){p===void 0&&(p=.1),b===void 0&&(b=" - "),g===void 0&&(g=function(E){return E});var T=(0,t.getStepDecimals)(p),k=(0,n.useState)({}),C=k[0],_=k[1],N=(0,n.useState)(g(u[l].toFixed(T))),j=N[0],W=N[1];return(0,n.useEffect)(function(){if(o){var E=o.getThumbs();if(E.length<1)return;var I={},J=o.getOffsets(),ie=G(l,J,E,u,b,T,g),le=g(u[l].toFixed(T));if(ie.length){var te=ie.reduce(function(re,ue,ge,pe){return re.length?r(r([],re,!0),[J[pe[ge]].x],!1):[J[pe[ge]].x]},[]);if(Math.min.apply(Math,te)===J[l].x){var de=[];ie.forEach(function(re){de.push(u[re].toFixed(T))}),le=Array.from(new Set(de.sort(function(re,ue){return parseFloat(re)-parseFloat(ue)}))).map(g).join(b);var fe=Math.min.apply(Math,te),he=Math.max.apply(Math,te),$e=E[ie[te.indexOf(he)]].getBoundingClientRect().width;I.left="".concat(Math.abs(fe-(he+$e))/2,"px"),I.transform="translate(-50%, 0)"}else I.visibility="hidden"}W(le),_(I)}},[o,u]),[j,C]};t.useThumbOverlap=X;function F(o,u,l,p){var b=o.getBoundingClientRect(),g=b.left,T=b.top,k=b.width,C=b.height;return y(p)?Math.abs(l-(T+C/2)):Math.abs(u-(g+k/2))}var V=function(){var o,u=((o=navigator.userAgentData)===null||o===void 0?void 0:o.platform)||navigator.platform;return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(u)||navigator.userAgent.includes("Mac")&&"ontouchend"in document};t.isIOS=V})(De);var It=U&&U.__extends||function(){var t=function(r,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,a){e.__proto__=a}||function(e,a){for(var i in a)Object.prototype.hasOwnProperty.call(a,i)&&(e[i]=a[i])},t(r,n)};return function(r,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");t(r,n);function e(){this.constructor=r}r.prototype=n===null?Object.create(n):(e.prototype=n.prototype,new e)}}(),xt=U&&U.__createBinding||(Object.create?function(t,r,n,e){e===void 0&&(e=n);var a=Object.getOwnPropertyDescriptor(r,n);(!a||("get"in a?!r.__esModule:a.writable||a.configurable))&&(a={enumerable:!0,get:function(){return r[n]}}),Object.defineProperty(t,e,a)}:function(t,r,n,e){e===void 0&&(e=n),t[e]=r[n]}),Ct=U&&U.__setModuleDefault||(Object.create?function(t,r){Object.defineProperty(t,"default",{enumerable:!0,value:r})}:function(t,r){t.default=r}),Dt=U&&U.__importStar||function(t){if(t&&t.__esModule)return t;var r={};if(t!=null)for(var n in t)n!=="default"&&Object.prototype.hasOwnProperty.call(t,n)&&xt(r,t,n);return Ct(r,t),r},Ye=U&&U.__spreadArray||function(t,r,n){if(n||arguments.length===2)for(var e=0,a=r.length,i;e<a;e++)(i||!(e in r))&&(i||(i=Array.prototype.slice.call(r,0,e)),i[e]=r[e]);return t.concat(i||Array.prototype.slice.call(r))};Object.defineProperty(Ce,"__esModule",{value:!0});var ve=Dt(w),O=De,P=ce,Pt=["ArrowRight","ArrowUp","k","PageUp"],Bt=["ArrowLeft","ArrowDown","j","PageDown"],At=function(t){It(r,t);function r(n){var e=t.call(this,n)||this;if(e.trackRef=ve.createRef(),e.thumbRefs=[],e.state={draggedTrackPos:[-1,-1],draggedThumbIndex:-1,thumbZIndexes:new Array(e.props.values.length).fill(0).map(function(a,i){return i}),isChanged:!1,markOffsets:[]},e.getOffsets=function(){var a=e.props,i=a.direction,s=a.values,c=a.min,f=a.max,y=e.trackRef.current;if(!y)return console.warn("No track element found."),[];var d=y.getBoundingClientRect(),h=(0,O.getPaddingAndBorder)(y);return e.getThumbs().map(function(v,R){var m={x:0,y:0},S=v.getBoundingClientRect(),B=(0,O.getMargin)(v);switch(i){case P.Direction.Right:return m.x=(B.left+h.left)*-1,m.y=((S.height-d.height)/2+h.top)*-1,m.x+=d.width*(0,O.relativeValue)(s[R],c,f)-S.width/2,m;case P.Direction.Left:return m.x=(B.right+h.right)*-1,m.y=((S.height-d.height)/2+h.top)*-1,m.x+=d.width-d.width*(0,O.relativeValue)(s[R],c,f)-S.width/2,m;case P.Direction.Up:return m.x=((S.width-d.width)/2+B.left+h.left)*-1,m.y=-h.left,m.y+=d.height-d.height*(0,O.relativeValue)(s[R],c,f)-S.height/2,m;case P.Direction.Down:return m.x=((S.width-d.width)/2+B.left+h.left)*-1,m.y=-h.left,m.y+=d.height*(0,O.relativeValue)(s[R],c,f)-S.height/2,m;default:return(0,O.assertUnreachable)(i)}})},e.getThumbs=function(){return e.trackRef&&e.trackRef.current?Array.from(e.trackRef.current.children).filter(function(a){return a.hasAttribute("aria-valuenow")}):(console.warn("No thumbs found in the track container. Did you forget to pass & spread the `props` param in renderTrack?"),[])},e.getTargetIndex=function(a){return e.getThumbs().findIndex(function(i){return i===a.target||i.contains(a.target)})},e.addTouchEvents=function(a){document.addEventListener("touchmove",e.schdOnTouchMove,{passive:!1}),document.addEventListener("touchend",e.schdOnEnd,{passive:!1}),document.addEventListener("touchcancel",e.schdOnEnd,{passive:!1})},e.addMouseEvents=function(a){document.addEventListener("mousemove",e.schdOnMouseMove),document.addEventListener("mouseup",e.schdOnEnd)},e.onMouseDownTrack=function(a){var i;if(!(a.button!==0||(0,O.isIOS)()))if(a.persist(),a.preventDefault(),e.addMouseEvents(a.nativeEvent),e.props.values.length>1&&e.props.draggableTrack){if(e.thumbRefs.some(function(c){var f;return(f=c.current)===null||f===void 0?void 0:f.contains(a.target)}))return;e.setState({draggedTrackPos:[a.clientX,a.clientY]},function(){return e.onMove(a.clientX,a.clientY)})}else{var s=(0,O.getClosestThumbIndex)(e.thumbRefs.map(function(c){return c.current}),a.clientX,a.clientY,e.props.direction);(i=e.thumbRefs[s].current)===null||i===void 0||i.focus(),e.setState({draggedThumbIndex:s},function(){return e.onMove(a.clientX,a.clientY)})}},e.onResize=function(){(0,O.translateThumbs)(e.getThumbs(),e.getOffsets(),e.props.rtl),e.calculateMarkOffsets()},e.onTouchStartTrack=function(a){var i;if(a.persist(),e.addTouchEvents(a.nativeEvent),e.props.values.length>1&&e.props.draggableTrack){if(e.thumbRefs.some(function(c){var f;return(f=c.current)===null||f===void 0?void 0:f.contains(a.target)}))return;e.setState({draggedTrackPos:[a.touches[0].clientX,a.touches[0].clientY]},function(){return e.onMove(a.touches[0].clientX,a.touches[0].clientY)})}else{var s=(0,O.getClosestThumbIndex)(e.thumbRefs.map(function(c){return c.current}),a.touches[0].clientX,a.touches[0].clientY,e.props.direction);(i=e.thumbRefs[s].current)===null||i===void 0||i.focus(),e.setState({draggedThumbIndex:s},function(){return e.onMove(a.touches[0].clientX,a.touches[0].clientY)})}},e.onMouseOrTouchStart=function(a){if(!e.props.disabled){var i=(0,O.isTouchEvent)(a);if(!(!i&&a.button!==0)){var s=e.getTargetIndex(a);s!==-1&&(i?e.addTouchEvents(a):e.addMouseEvents(a),e.setState({draggedThumbIndex:s,thumbZIndexes:e.state.thumbZIndexes.map(function(c,f){return f===s?Math.max.apply(Math,e.state.thumbZIndexes):c<=e.state.thumbZIndexes[s]?c:c-1})}))}}},e.onMouseMove=function(a){a.preventDefault(),e.onMove(a.clientX,a.clientY)},e.onTouchMove=function(a){a.preventDefault(),e.onMove(a.touches[0].clientX,a.touches[0].clientY)},e.onKeyDown=function(a){var i=e.props,s=i.values,c=i.onChange,f=i.step,y=i.rtl,d=i.direction,h=e.state.isChanged,v=e.getTargetIndex(a.nativeEvent),R=y||d===P.Direction.Left||d===P.Direction.Down?-1:1;v!==-1&&(Pt.includes(a.key)?(a.preventDefault(),e.setState({draggedThumbIndex:v,isChanged:!0}),c((0,O.replaceAt)(s,v,e.normalizeValue(s[v]+R*(a.key==="PageUp"?f*10:f),v)))):Bt.includes(a.key)?(a.preventDefault(),e.setState({draggedThumbIndex:v,isChanged:!0}),c((0,O.replaceAt)(s,v,e.normalizeValue(s[v]-R*(a.key==="PageDown"?f*10:f),v)))):a.key==="Tab"?e.setState({draggedThumbIndex:-1},function(){h&&e.fireOnFinalChange()}):h&&e.fireOnFinalChange())},e.onKeyUp=function(a){var i=e.state.isChanged;e.setState({draggedThumbIndex:-1},function(){i&&e.fireOnFinalChange()})},e.onMove=function(a,i){var s=e.state,c=s.draggedThumbIndex,f=s.draggedTrackPos,y=e.props,d=y.direction,h=y.min,v=y.max,R=y.onChange,m=y.values,S=y.step,B=y.rtl;if(c===-1&&f[0]===-1&&f[1]===-1)return null;var L=e.trackRef.current;if(!L)return null;var D=L.getBoundingClientRect(),M=(0,O.isVertical)(d)?D.height:D.width;if(f[0]!==-1&&f[1]!==-1){var $=a-f[0],H=i-f[1],A=0;switch(d){case P.Direction.Right:case P.Direction.Left:A=$/M*(v-h);break;case P.Direction.Down:case P.Direction.Up:A=H/M*(v-h);break;default:(0,O.assertUnreachable)(d)}if(B&&(A*=-1),Math.abs(A)>=S/2){for(var x=0;x<e.thumbRefs.length;x++){if(m[x]===v&&Math.sign(A)===1||m[x]===h&&Math.sign(A)===-1)return;var G=m[x]+A;G>v?A=v-m[x]:G<h&&(A=h-m[x])}for(var X=m.slice(0),x=0;x<e.thumbRefs.length;x++)X=(0,O.replaceAt)(X,x,e.normalizeValue(m[x]+A,x));e.setState({draggedTrackPos:[a,i]}),R(X)}}else{var F=0;switch(d){case P.Direction.Right:F=(a-D.left)/M*(v-h)+h;break;case P.Direction.Left:F=(M-(a-D.left))/M*(v-h)+h;break;case P.Direction.Down:F=(i-D.top)/M*(v-h)+h;break;case P.Direction.Up:F=(M-(i-D.top))/M*(v-h)+h;break;default:(0,O.assertUnreachable)(d)}B&&(F=v+h-F),Math.abs(m[c]-F)>=S/2&&R((0,O.replaceAt)(m,c,e.normalizeValue(F,c)))}},e.normalizeValue=function(a,i){var s=e.props,c=s.min,f=s.max,y=s.step,d=s.allowOverlap,h=s.values;return(0,O.normalizeValue)(a,i,c,f,y,d,h)},e.onEnd=function(a){if(a.preventDefault(),document.removeEventListener("mousemove",e.schdOnMouseMove),document.removeEventListener("touchmove",e.schdOnTouchMove),document.removeEventListener("mouseup",e.schdOnEnd),document.removeEventListener("touchend",e.schdOnEnd),document.removeEventListener("touchcancel",e.schdOnEnd),e.state.draggedThumbIndex===-1&&e.state.draggedTrackPos[0]===-1&&e.state.draggedTrackPos[1]===-1)return null;e.setState({draggedThumbIndex:-1,draggedTrackPos:[-1,-1]},function(){e.fireOnFinalChange()})},e.fireOnFinalChange=function(){e.setState({isChanged:!1});var a=e.props,i=a.onFinalChange,s=a.values;i&&i(s)},e.updateMarkRefs=function(a){if(!a.renderMark){e.numOfMarks=void 0,e.markRefs=void 0;return}e.numOfMarks=(a.max-a.min)/e.props.step,e.markRefs=[];for(var i=0;i<e.numOfMarks+1;i++)e.markRefs[i]=ve.createRef()},e.calculateMarkOffsets=function(){if(!(!e.props.renderMark||!e.trackRef||!e.numOfMarks||!e.markRefs||e.trackRef.current===null)){for(var a=window.getComputedStyle(e.trackRef.current),i=parseInt(a.width,10),s=parseInt(a.height,10),c=parseInt(a.paddingLeft,10),f=parseInt(a.paddingTop,10),y=[],d=0;d<e.numOfMarks+1;d++){var h=9999,v=9999;if(e.markRefs[d].current){var R=e.markRefs[d].current.getBoundingClientRect();h=R.height,v=R.width}e.props.direction===P.Direction.Left||e.props.direction===P.Direction.Right?y.push([Math.round(i/e.numOfMarks*d+c-v/2),-Math.round((h-s)/2)]):y.push([Math.round(s/e.numOfMarks*d+f-h/2),-Math.round((v-i)/2)])}e.setState({markOffsets:y})}},n.step===0)throw new Error('"step" property should be a positive number');return e.schdOnMouseMove=(0,O.schd)(e.onMouseMove),e.schdOnTouchMove=(0,O.schd)(e.onTouchMove),e.schdOnEnd=(0,O.schd)(e.onEnd),e.thumbRefs=n.values.map(function(){return ve.createRef()}),e.updateMarkRefs(n),e}return r.prototype.componentDidMount=function(){var n=this,e=this.props,a=e.values,i=e.min,s=e.step;this.resizeObserver=window.ResizeObserver?new window.ResizeObserver(this.onResize):{observe:function(){return window.addEventListener("resize",n.onResize)},unobserve:function(){return window.removeEventListener("resize",n.onResize)}},document.addEventListener("touchstart",this.onMouseOrTouchStart,{passive:!1}),document.addEventListener("mousedown",this.onMouseOrTouchStart,{passive:!1}),!this.props.allowOverlap&&(0,O.checkInitialOverlap)(this.props.values),this.props.values.forEach(function(c){return(0,O.checkBoundaries)(c,n.props.min,n.props.max)}),this.resizeObserver.observe(this.trackRef.current),(0,O.translateThumbs)(this.getThumbs(),this.getOffsets(),this.props.rtl),this.calculateMarkOffsets(),a.forEach(function(c){(0,O.isStepDivisible)(i,c,s)||console.warn("The `values` property is in conflict with the current `step`, `min`, and `max` properties. Please provide values that are accessible using the min, max, and step values.")})},r.prototype.componentDidUpdate=function(n,e){var a=this.props,i=a.max,s=a.min,c=a.step,f=a.values,y=a.rtl;(n.max!==i||n.min!==s||n.step!==c)&&this.updateMarkRefs(this.props),(0,O.translateThumbs)(this.getThumbs(),this.getOffsets(),y),(n.max!==i||n.min!==s||n.step!==c||e.markOffsets.length!==this.state.markOffsets.length)&&(this.calculateMarkOffsets(),f.forEach(function(d){(0,O.isStepDivisible)(s,d,c)||console.warn("The `values` property is in conflict with the current `step`, `min`, and `max` properties. Please provide values that are accessible using the min, max, and step values.")}))},r.prototype.componentWillUnmount=function(){var n={passive:!1};document.removeEventListener("mousedown",this.onMouseOrTouchStart,n),document.removeEventListener("mousemove",this.schdOnMouseMove),document.removeEventListener("touchmove",this.schdOnTouchMove),document.removeEventListener("touchstart",this.onMouseOrTouchStart),document.removeEventListener("mouseup",this.schdOnEnd),document.removeEventListener("touchend",this.schdOnEnd),this.resizeObserver.unobserve(this.trackRef.current)},r.prototype.render=function(){var n=this,e=this.props,a=e.label,i=e.labelledBy,s=e.renderTrack,c=e.renderThumb,f=e.renderMark,y=f===void 0?function(){return null}:f,d=e.values,h=e.min,v=e.max,R=e.allowOverlap,m=e.disabled,S=this.state,B=S.draggedThumbIndex,L=S.thumbZIndexes,D=S.markOffsets;return s({props:{style:{transform:"scale(1)",cursor:B>-1?"grabbing":this.props.draggableTrack?(0,O.isVertical)(this.props.direction)?"ns-resize":"ew-resize":d.length===1&&!m?"pointer":"inherit"},onMouseDown:m?O.voidFn:this.onMouseDownTrack,onTouchStart:m?O.voidFn:this.onTouchStartTrack,ref:this.trackRef},isDragged:this.state.draggedThumbIndex>-1,disabled:m,children:Ye(Ye([],D.map(function(M,$,H){return y({props:{style:n.props.direction===P.Direction.Left||n.props.direction===P.Direction.Right?{position:"absolute",left:"".concat(M[0],"px"),marginTop:"".concat(M[1],"px")}:{position:"absolute",top:"".concat(M[0],"px"),marginLeft:"".concat(M[1],"px")},key:"mark".concat($),ref:n.markRefs[$]},index:$})}),!0),d.map(function(M,$){var H=n.state.draggedThumbIndex===$;return c({index:$,value:M,isDragged:H,props:{style:{position:"absolute",zIndex:L[$],cursor:m?"inherit":H?"grabbing":"grab",userSelect:"none",touchAction:"none",WebkitUserSelect:"none",MozUserSelect:"none",msUserSelect:"none"},key:$,tabIndex:m?void 0:0,"aria-valuemax":R?v:d[$+1]||v,"aria-valuemin":R?h:d[$-1]||h,"aria-valuenow":M,draggable:!1,ref:n.thumbRefs[$],"aria-label":a,"aria-labelledby":i,role:"slider",onKeyDown:m?O.voidFn:n.onKeyDown,onKeyUp:m?O.voidFn:n.onKeyUp}})}),!0)})},r.defaultProps={label:"Accessibility label",labelledBy:null,step:1,direction:P.Direction.Right,rtl:!1,disabled:!1,allowOverlap:!1,draggableTrack:!1,min:0,max:100},r}(ve.Component);Ce.default=At;(function(t){var r=U&&U.__importDefault||function(i){return i&&i.__esModule?i:{default:i}};Object.defineProperty(t,"__esModule",{value:!0}),t.checkValuesAgainstBoundaries=t.relativeValue=t.useThumbOverlap=t.Direction=t.getTrackBackground=t.Range=void 0;var n=r(Ce);t.Range=n.default;var e=De;Object.defineProperty(t,"getTrackBackground",{enumerable:!0,get:function(){return e.getTrackBackground}}),Object.defineProperty(t,"useThumbOverlap",{enumerable:!0,get:function(){return e.useThumbOverlap}}),Object.defineProperty(t,"relativeValue",{enumerable:!0,get:function(){return e.relativeValue}}),Object.defineProperty(t,"checkValuesAgainstBoundaries",{enumerable:!0,get:function(){return e.checkValuesAgainstBoundaries}});var a=ce;Object.defineProperty(t,"Direction",{enumerable:!0,get:function(){return a.Direction}})})(xe);function Ze(t,r){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var e=Object.getOwnPropertySymbols(t);r&&(e=e.filter(function(a){return Object.getOwnPropertyDescriptor(t,a).enumerable})),n.push.apply(n,e)}return n}function me(t){for(var r=1;r<arguments.length;r++){var n=arguments[r]!=null?arguments[r]:{};r%2?Ze(Object(n),!0).forEach(function(e){Ft(t,e,n[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Ze(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))})}return t}function Ft(t,r,n){return r in t?Object.defineProperty(t,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[r]=n,t}var ye=ee("div",{position:"relative",width:"100%"});ye.displayName="Root";ye.displayName="Root";ye.displayName="StyledRoot";var Te=ee("div",function(t){var r=t.$theme,n=t.$value,e=n===void 0?[]:n,a=t.$disabled,i=t.$isDragged,s=r.sizing,c="inherit";return a?c="not-allowed":i?c="grabbing":e.length===1&&(c="pointer"),{paddingTop:s.scale600,paddingBottom:s.scale600,paddingRight:s.scale600,paddingLeft:s.scale600,display:"flex",cursor:c,backgroundColor:r.colors.sliderTrackFill}});Te.displayName="Track";Te.displayName="Track";Te.displayName="StyledTrack";var ke=ee("div",function(t){var r=t.$theme,n=t.$value,e=n===void 0?[]:n,a=t.$min,i=t.$max,s=t.$disabled,c=r.colors,f=r.borders,y=r.direction,d=r.borders.useRoundedCorners?f.radius100:0;return{borderTopLeftRadius:d,borderTopRightRadius:d,borderBottomRightRadius:d,borderBottomLeftRadius:d,background:xe.getTrackBackground({values:e,colors:e.length===1?[s?c.borderOpaque:c.primary,s?c.backgroundSecondary:c.borderOpaque]:[s?c.backgroundSecondary:c.borderOpaque,s?c.borderOpaque:c.primary,s?c.backgroundSecondary:c.borderOpaque],min:a||0,max:i||0,rtl:y==="rtl"}),height:"2px",width:"100%",alignSelf:"center",cursor:s?"not-allowed":"inherit"}});ke.displayName="InnerTrack";ke.displayName="InnerTrack";ke.displayName="StyledInnerTrack";var Oe=ee("div",function(t){return{width:"4px",height:"2px",backgroundColor:t.$theme.colors.backgroundPrimary,marginLeft:"16px"}});Oe.displayName="Mark";Oe.displayName="Mark";Oe.displayName="StyledMark";var we=ee("div",function(t){return me(me({},t.$theme.typography.font200),{},{color:t.$theme.colors.contentPrimary})});we.displayName="Tick";we.displayName="Tick";we.displayName="StyledTick";var Re=ee("div",function(t){var r=t.$theme,n=r.sizing;return{display:"flex",justifyContent:"space-between",alignItems:"center",paddingRight:n.scale600,paddingLeft:n.scale600,paddingBottom:n.scale400}});Re.displayName="TickBar";Re.displayName="TickBar";Re.displayName="StyledTickBar";var Se=ee("div",function(t){var r=t.$theme,n=t.$value,e=n===void 0?[]:n,a=t.$thumbIndex,i=t.$disabled,s=e.length===2&&a===0,c=e.length===2&&a===1;return r.direction==="rtl"&&(c||s)&&(s=!s,c=!c),{height:"24px",width:"24px",borderTopLeftRadius:"24px",borderTopRightRadius:"24px",borderBottomLeftRadius:"24px",borderBottomRightRadius:"24px",display:"flex",justifyContent:"center",alignItems:"center",backgroundColor:i?r.colors.sliderHandleFillDisabled:r.colors.sliderHandleFill,outline:"none",boxShadow:t.$isFocusVisible?"0 0 0 3px ".concat(r.colors.accent):"0 1px 4px rgba(0, 0, 0, 0.12)",cursor:i?"not-allowed":"inherit"}});Se.displayName="Thumb";Se.displayName="Thumb";Se.displayName="StyledThumb";var Me=ee("div",function(t){var r=t.$disabled,n=t.$theme;return{position:"absolute",top:"-16px",width:"4px",height:"20px",backgroundColor:r?n.colors.sliderHandleFillDisabled:n.colors.sliderHandleInnerFill}});Me.displayName="InnerThumb";Me.displayName="InnerThumb";Me.displayName="StyledInnerThumb";var _e=ee("div",function(t){var r=t.$disabled,n=t.$theme;return me(me({position:"absolute",top:"-".concat(n.sizing.scale1400)},n.typography.font200),{},{backgroundColor:r?n.colors.sliderHandleFillDisabled:n.colors.sliderHandleInnerFill,color:n.colors.contentInversePrimary,paddingLeft:n.sizing.scale600,paddingRight:n.sizing.scale600,paddingTop:n.sizing.scale500,paddingBottom:n.sizing.scale500,borderBottomLeftRadius:"48px",borderBottomRightRadius:"48px",borderTopLeftRadius:"48px",borderTopRightRadius:"48px",whiteSpace:"nowrap"})});_e.displayName="ThumbValue";_e.displayName="ThumbValue";_e.displayName="StyledThumbValue";function qe(t,r){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var e=Object.getOwnPropertySymbols(t);r&&(e=e.filter(function(a){return Object.getOwnPropertyDescriptor(t,a).enumerable})),n.push.apply(n,e)}return n}function Lt(t){for(var r=1;r<arguments.length;r++){var n=arguments[r]!=null?arguments[r]:{};r%2?qe(Object(n),!0).forEach(function(e){jt(t,e,n[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):qe(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))})}return t}function jt(t,r,n){return r in t?Object.defineProperty(t,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[r]=n,t}function Z(){return Z=Object.assign?Object.assign.bind():function(t){for(var r=1;r<arguments.length;r++){var n=arguments[r];for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])}return t},Z.apply(this,arguments)}function Y(t,r){return Ut(t)||Nt(t,r)||Vt(t,r)||zt()}function zt(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
1
|
+
import{d as U,r as w,bw as ee,bY as pt,bJ as vt,bx as Q,bZ as mt,b_ as bt,n as be,az as yt,y as Tt,aN as kt,z as Ue,j as ae,R as He,cm as Ot,bs as wt,bF as Rt,bt as St,bc as Mt,bu as _t,O as $t,cn as Ee}from"./index.9wBA4A4f.js";import{s as We}from"./sprintf.C-r3gIuM.js";import{a as Et}from"./useBasicWidgetState.C207Y3_O.js";import"./FormClearHelper.BBpErIGP.js";var xe={},Ce={},De={},ce={};Object.defineProperty(ce,"__esModule",{value:!0});ce.Direction=void 0;var Ke;(function(t){t.Right="to right",t.Left="to left",t.Down="to bottom",t.Up="to top"})(Ke||(ce.Direction=Ke={}));(function(t){var r=U&&U.__spreadArray||function(o,u,l){if(l||arguments.length===2)for(var p=0,b=u.length,g;p<b;p++)(g||!(p in u))&&(g||(g=Array.prototype.slice.call(u,0,p)),g[p]=u[p]);return o.concat(g||Array.prototype.slice.call(u))};Object.defineProperty(t,"__esModule",{value:!0}),t.isIOS=t.useThumbOverlap=t.assertUnreachable=t.voidFn=t.getTrackBackground=t.replaceAt=t.schd=t.translate=t.getClosestThumbIndex=t.translateThumbs=t.getPaddingAndBorder=t.getMargin=t.checkInitialOverlap=t.checkValuesAgainstBoundaries=t.checkBoundaries=t.isVertical=t.relativeValue=t.normalizeValue=t.isStepDivisible=t.isTouchEvent=t.getStepDecimals=void 0;var n=w,e=ce,a=function(o){var u=o.toString().split(".")[1];return u?u.length:0};t.getStepDecimals=a;function i(o){return o.touches&&o.touches.length||o.changedTouches&&o.changedTouches.length}t.isTouchEvent=i;function s(o,u,l){var p=(u-o)/l,b=8,g=Number(p.toFixed(b));return parseInt(g.toString(),10)===g}t.isStepDivisible=s;function c(o,u,l,p,b,g,T){var k=1e11;if(o=Math.round(o*k)/k,!g){var C=T[u-1],_=T[u+1];if(C&&C>o)return C;if(_&&_<o)return _}if(o>p)return p;if(o<l)return l;var N=Math.floor(o*k-l*k)%Math.floor(b*k),j=Math.floor(o*k-Math.abs(N)),W=N===0?o:j/k,E=Math.abs(N/k)<b/2?W:W+b,I=(0,t.getStepDecimals)(b);return parseFloat(E.toFixed(I))}t.normalizeValue=c;function f(o,u,l){return(o-u)/(l-u)}t.relativeValue=f;function y(o){return o===e.Direction.Up||o===e.Direction.Down}t.isVertical=y;function d(o,u,l){if(u>=l)throw new RangeError("min (".concat(u,") is equal/bigger than max (").concat(l,")"));if(o<u)throw new RangeError("value (".concat(o,") is smaller than min (").concat(u,")"));if(o>l)throw new RangeError("value (".concat(o,") is bigger than max (").concat(l,")"))}t.checkBoundaries=d;function h(o,u,l){return o<u?u:o>l?l:o}t.checkValuesAgainstBoundaries=h;function v(o){if(!(o.length<2)&&!o.slice(1).every(function(u,l){return o[l]<=u}))throw new RangeError("values={[".concat(o,"]} needs to be sorted when allowOverlap={false}"))}t.checkInitialOverlap=v;function R(o){var u=window.getComputedStyle(o);return{top:parseInt(u["margin-top"],10),bottom:parseInt(u["margin-bottom"],10),left:parseInt(u["margin-left"],10),right:parseInt(u["margin-right"],10)}}t.getMargin=R;function m(o){var u=window.getComputedStyle(o);return{top:parseInt(u["padding-top"],10)+parseInt(u["border-top-width"],10),bottom:parseInt(u["padding-bottom"],10)+parseInt(u["border-bottom-width"],10),left:parseInt(u["padding-left"],10)+parseInt(u["border-left-width"],10),right:parseInt(u["padding-right"],10)+parseInt(u["border-right-width"],10)}}t.getPaddingAndBorder=m;function S(o,u,l){var p=l?-1:1;o.forEach(function(b,g){return L(b,p*u[g].x,u[g].y)})}t.translateThumbs=S;function B(o,u,l,p){for(var b=0,g=F(o[0],u,l,p),T=1;T<o.length;T++){var k=F(o[T],u,l,p);k<g&&(g=k,b=T)}return b}t.getClosestThumbIndex=B;function L(o,u,l){o.style.transform="translate(".concat(u,"px, ").concat(l,"px)")}t.translate=L;var D=function(o){var u=[],l=null,p=function(){for(var b=[],g=0;g<arguments.length;g++)b[g]=arguments[g];u=b,!l&&(l=requestAnimationFrame(function(){l=null,o.apply(void 0,u)}))};return p};t.schd=D;function M(o,u,l){var p=o.slice(0);return p[u]=l,p}t.replaceAt=M;function $(o){var u=o.values,l=o.colors,p=o.min,b=o.max,g=o.direction,T=g===void 0?e.Direction.Right:g,k=o.rtl,C=k===void 0?!1:k;C&&T===e.Direction.Right?T=e.Direction.Left:C&&e.Direction.Left&&(T=e.Direction.Right);var _=u.slice(0).sort(function(j,W){return j-W}).map(function(j){return(j-p)/(b-p)*100}),N=_.reduce(function(j,W,E){return"".concat(j,", ").concat(l[E]," ").concat(W,"%, ").concat(l[E+1]," ").concat(W,"%")},"");return"linear-gradient(".concat(T,", ").concat(l[0]," 0%").concat(N,", ").concat(l[l.length-1]," 100%)")}t.getTrackBackground=$;function H(){}t.voidFn=H;function A(o){throw new Error("Didn't expect to get here")}t.assertUnreachable=A;var x=function(o,u,l,p,b){b===void 0&&(b=function(T){return T});var g=Math.ceil(r([o],Array.from(o.children),!0).reduce(function(T,k){var C=Math.ceil(k.getBoundingClientRect().width);if(k.innerText&&k.innerText.includes(l)&&k.childElementCount===0){var _=k.cloneNode(!0);_.innerHTML=b(u.toFixed(p)),_.style.visibility="hidden",document.body.appendChild(_),C=Math.ceil(_.getBoundingClientRect().width),document.body.removeChild(_)}return C>T?C:T},o.getBoundingClientRect().width));return g},G=function(o,u,l,p,b,g,T){T===void 0&&(T=function(_){return _});var k=[],C=function(_){var N=x(l[_],p[_],b,g,T),j=u[_].x;u.forEach(function(W,E){var I=W.x,J=x(l[E],p[E],b,g,T);_!==E&&(j>=I&&j<=I+J||j+N>=I&&j+N<=I+J)&&(k.includes(E)||(k.push(_),k.push(E),k=r(r([],k,!0),[_,E],!1),C(E)))})};return C(o),Array.from(new Set(k.sort()))},X=function(o,u,l,p,b,g){p===void 0&&(p=.1),b===void 0&&(b=" - "),g===void 0&&(g=function(E){return E});var T=(0,t.getStepDecimals)(p),k=(0,n.useState)({}),C=k[0],_=k[1],N=(0,n.useState)(g(u[l].toFixed(T))),j=N[0],W=N[1];return(0,n.useEffect)(function(){if(o){var E=o.getThumbs();if(E.length<1)return;var I={},J=o.getOffsets(),ie=G(l,J,E,u,b,T,g),le=g(u[l].toFixed(T));if(ie.length){var te=ie.reduce(function(re,ue,ge,pe){return re.length?r(r([],re,!0),[J[pe[ge]].x],!1):[J[pe[ge]].x]},[]);if(Math.min.apply(Math,te)===J[l].x){var de=[];ie.forEach(function(re){de.push(u[re].toFixed(T))}),le=Array.from(new Set(de.sort(function(re,ue){return parseFloat(re)-parseFloat(ue)}))).map(g).join(b);var fe=Math.min.apply(Math,te),he=Math.max.apply(Math,te),$e=E[ie[te.indexOf(he)]].getBoundingClientRect().width;I.left="".concat(Math.abs(fe-(he+$e))/2,"px"),I.transform="translate(-50%, 0)"}else I.visibility="hidden"}W(le),_(I)}},[o,u]),[j,C]};t.useThumbOverlap=X;function F(o,u,l,p){var b=o.getBoundingClientRect(),g=b.left,T=b.top,k=b.width,C=b.height;return y(p)?Math.abs(l-(T+C/2)):Math.abs(u-(g+k/2))}var V=function(){var o,u=((o=navigator.userAgentData)===null||o===void 0?void 0:o.platform)||navigator.platform;return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(u)||navigator.userAgent.includes("Mac")&&"ontouchend"in document};t.isIOS=V})(De);var It=U&&U.__extends||function(){var t=function(r,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,a){e.__proto__=a}||function(e,a){for(var i in a)Object.prototype.hasOwnProperty.call(a,i)&&(e[i]=a[i])},t(r,n)};return function(r,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");t(r,n);function e(){this.constructor=r}r.prototype=n===null?Object.create(n):(e.prototype=n.prototype,new e)}}(),xt=U&&U.__createBinding||(Object.create?function(t,r,n,e){e===void 0&&(e=n);var a=Object.getOwnPropertyDescriptor(r,n);(!a||("get"in a?!r.__esModule:a.writable||a.configurable))&&(a={enumerable:!0,get:function(){return r[n]}}),Object.defineProperty(t,e,a)}:function(t,r,n,e){e===void 0&&(e=n),t[e]=r[n]}),Ct=U&&U.__setModuleDefault||(Object.create?function(t,r){Object.defineProperty(t,"default",{enumerable:!0,value:r})}:function(t,r){t.default=r}),Dt=U&&U.__importStar||function(t){if(t&&t.__esModule)return t;var r={};if(t!=null)for(var n in t)n!=="default"&&Object.prototype.hasOwnProperty.call(t,n)&&xt(r,t,n);return Ct(r,t),r},Ye=U&&U.__spreadArray||function(t,r,n){if(n||arguments.length===2)for(var e=0,a=r.length,i;e<a;e++)(i||!(e in r))&&(i||(i=Array.prototype.slice.call(r,0,e)),i[e]=r[e]);return t.concat(i||Array.prototype.slice.call(r))};Object.defineProperty(Ce,"__esModule",{value:!0});var ve=Dt(w),O=De,P=ce,Pt=["ArrowRight","ArrowUp","k","PageUp"],Bt=["ArrowLeft","ArrowDown","j","PageDown"],At=function(t){It(r,t);function r(n){var e=t.call(this,n)||this;if(e.trackRef=ve.createRef(),e.thumbRefs=[],e.state={draggedTrackPos:[-1,-1],draggedThumbIndex:-1,thumbZIndexes:new Array(e.props.values.length).fill(0).map(function(a,i){return i}),isChanged:!1,markOffsets:[]},e.getOffsets=function(){var a=e.props,i=a.direction,s=a.values,c=a.min,f=a.max,y=e.trackRef.current;if(!y)return console.warn("No track element found."),[];var d=y.getBoundingClientRect(),h=(0,O.getPaddingAndBorder)(y);return e.getThumbs().map(function(v,R){var m={x:0,y:0},S=v.getBoundingClientRect(),B=(0,O.getMargin)(v);switch(i){case P.Direction.Right:return m.x=(B.left+h.left)*-1,m.y=((S.height-d.height)/2+h.top)*-1,m.x+=d.width*(0,O.relativeValue)(s[R],c,f)-S.width/2,m;case P.Direction.Left:return m.x=(B.right+h.right)*-1,m.y=((S.height-d.height)/2+h.top)*-1,m.x+=d.width-d.width*(0,O.relativeValue)(s[R],c,f)-S.width/2,m;case P.Direction.Up:return m.x=((S.width-d.width)/2+B.left+h.left)*-1,m.y=-h.left,m.y+=d.height-d.height*(0,O.relativeValue)(s[R],c,f)-S.height/2,m;case P.Direction.Down:return m.x=((S.width-d.width)/2+B.left+h.left)*-1,m.y=-h.left,m.y+=d.height*(0,O.relativeValue)(s[R],c,f)-S.height/2,m;default:return(0,O.assertUnreachable)(i)}})},e.getThumbs=function(){return e.trackRef&&e.trackRef.current?Array.from(e.trackRef.current.children).filter(function(a){return a.hasAttribute("aria-valuenow")}):(console.warn("No thumbs found in the track container. Did you forget to pass & spread the `props` param in renderTrack?"),[])},e.getTargetIndex=function(a){return e.getThumbs().findIndex(function(i){return i===a.target||i.contains(a.target)})},e.addTouchEvents=function(a){document.addEventListener("touchmove",e.schdOnTouchMove,{passive:!1}),document.addEventListener("touchend",e.schdOnEnd,{passive:!1}),document.addEventListener("touchcancel",e.schdOnEnd,{passive:!1})},e.addMouseEvents=function(a){document.addEventListener("mousemove",e.schdOnMouseMove),document.addEventListener("mouseup",e.schdOnEnd)},e.onMouseDownTrack=function(a){var i;if(!(a.button!==0||(0,O.isIOS)()))if(a.persist(),a.preventDefault(),e.addMouseEvents(a.nativeEvent),e.props.values.length>1&&e.props.draggableTrack){if(e.thumbRefs.some(function(c){var f;return(f=c.current)===null||f===void 0?void 0:f.contains(a.target)}))return;e.setState({draggedTrackPos:[a.clientX,a.clientY]},function(){return e.onMove(a.clientX,a.clientY)})}else{var s=(0,O.getClosestThumbIndex)(e.thumbRefs.map(function(c){return c.current}),a.clientX,a.clientY,e.props.direction);(i=e.thumbRefs[s].current)===null||i===void 0||i.focus(),e.setState({draggedThumbIndex:s},function(){return e.onMove(a.clientX,a.clientY)})}},e.onResize=function(){(0,O.translateThumbs)(e.getThumbs(),e.getOffsets(),e.props.rtl),e.calculateMarkOffsets()},e.onTouchStartTrack=function(a){var i;if(a.persist(),e.addTouchEvents(a.nativeEvent),e.props.values.length>1&&e.props.draggableTrack){if(e.thumbRefs.some(function(c){var f;return(f=c.current)===null||f===void 0?void 0:f.contains(a.target)}))return;e.setState({draggedTrackPos:[a.touches[0].clientX,a.touches[0].clientY]},function(){return e.onMove(a.touches[0].clientX,a.touches[0].clientY)})}else{var s=(0,O.getClosestThumbIndex)(e.thumbRefs.map(function(c){return c.current}),a.touches[0].clientX,a.touches[0].clientY,e.props.direction);(i=e.thumbRefs[s].current)===null||i===void 0||i.focus(),e.setState({draggedThumbIndex:s},function(){return e.onMove(a.touches[0].clientX,a.touches[0].clientY)})}},e.onMouseOrTouchStart=function(a){if(!e.props.disabled){var i=(0,O.isTouchEvent)(a);if(!(!i&&a.button!==0)){var s=e.getTargetIndex(a);s!==-1&&(i?e.addTouchEvents(a):e.addMouseEvents(a),e.setState({draggedThumbIndex:s,thumbZIndexes:e.state.thumbZIndexes.map(function(c,f){return f===s?Math.max.apply(Math,e.state.thumbZIndexes):c<=e.state.thumbZIndexes[s]?c:c-1})}))}}},e.onMouseMove=function(a){a.preventDefault(),e.onMove(a.clientX,a.clientY)},e.onTouchMove=function(a){a.preventDefault(),e.onMove(a.touches[0].clientX,a.touches[0].clientY)},e.onKeyDown=function(a){var i=e.props,s=i.values,c=i.onChange,f=i.step,y=i.rtl,d=i.direction,h=e.state.isChanged,v=e.getTargetIndex(a.nativeEvent),R=y||d===P.Direction.Left||d===P.Direction.Down?-1:1;v!==-1&&(Pt.includes(a.key)?(a.preventDefault(),e.setState({draggedThumbIndex:v,isChanged:!0}),c((0,O.replaceAt)(s,v,e.normalizeValue(s[v]+R*(a.key==="PageUp"?f*10:f),v)))):Bt.includes(a.key)?(a.preventDefault(),e.setState({draggedThumbIndex:v,isChanged:!0}),c((0,O.replaceAt)(s,v,e.normalizeValue(s[v]-R*(a.key==="PageDown"?f*10:f),v)))):a.key==="Tab"?e.setState({draggedThumbIndex:-1},function(){h&&e.fireOnFinalChange()}):h&&e.fireOnFinalChange())},e.onKeyUp=function(a){var i=e.state.isChanged;e.setState({draggedThumbIndex:-1},function(){i&&e.fireOnFinalChange()})},e.onMove=function(a,i){var s=e.state,c=s.draggedThumbIndex,f=s.draggedTrackPos,y=e.props,d=y.direction,h=y.min,v=y.max,R=y.onChange,m=y.values,S=y.step,B=y.rtl;if(c===-1&&f[0]===-1&&f[1]===-1)return null;var L=e.trackRef.current;if(!L)return null;var D=L.getBoundingClientRect(),M=(0,O.isVertical)(d)?D.height:D.width;if(f[0]!==-1&&f[1]!==-1){var $=a-f[0],H=i-f[1],A=0;switch(d){case P.Direction.Right:case P.Direction.Left:A=$/M*(v-h);break;case P.Direction.Down:case P.Direction.Up:A=H/M*(v-h);break;default:(0,O.assertUnreachable)(d)}if(B&&(A*=-1),Math.abs(A)>=S/2){for(var x=0;x<e.thumbRefs.length;x++){if(m[x]===v&&Math.sign(A)===1||m[x]===h&&Math.sign(A)===-1)return;var G=m[x]+A;G>v?A=v-m[x]:G<h&&(A=h-m[x])}for(var X=m.slice(0),x=0;x<e.thumbRefs.length;x++)X=(0,O.replaceAt)(X,x,e.normalizeValue(m[x]+A,x));e.setState({draggedTrackPos:[a,i]}),R(X)}}else{var F=0;switch(d){case P.Direction.Right:F=(a-D.left)/M*(v-h)+h;break;case P.Direction.Left:F=(M-(a-D.left))/M*(v-h)+h;break;case P.Direction.Down:F=(i-D.top)/M*(v-h)+h;break;case P.Direction.Up:F=(M-(i-D.top))/M*(v-h)+h;break;default:(0,O.assertUnreachable)(d)}B&&(F=v+h-F),Math.abs(m[c]-F)>=S/2&&R((0,O.replaceAt)(m,c,e.normalizeValue(F,c)))}},e.normalizeValue=function(a,i){var s=e.props,c=s.min,f=s.max,y=s.step,d=s.allowOverlap,h=s.values;return(0,O.normalizeValue)(a,i,c,f,y,d,h)},e.onEnd=function(a){if(a.preventDefault(),document.removeEventListener("mousemove",e.schdOnMouseMove),document.removeEventListener("touchmove",e.schdOnTouchMove),document.removeEventListener("mouseup",e.schdOnEnd),document.removeEventListener("touchend",e.schdOnEnd),document.removeEventListener("touchcancel",e.schdOnEnd),e.state.draggedThumbIndex===-1&&e.state.draggedTrackPos[0]===-1&&e.state.draggedTrackPos[1]===-1)return null;e.setState({draggedThumbIndex:-1,draggedTrackPos:[-1,-1]},function(){e.fireOnFinalChange()})},e.fireOnFinalChange=function(){e.setState({isChanged:!1});var a=e.props,i=a.onFinalChange,s=a.values;i&&i(s)},e.updateMarkRefs=function(a){if(!a.renderMark){e.numOfMarks=void 0,e.markRefs=void 0;return}e.numOfMarks=(a.max-a.min)/e.props.step,e.markRefs=[];for(var i=0;i<e.numOfMarks+1;i++)e.markRefs[i]=ve.createRef()},e.calculateMarkOffsets=function(){if(!(!e.props.renderMark||!e.trackRef||!e.numOfMarks||!e.markRefs||e.trackRef.current===null)){for(var a=window.getComputedStyle(e.trackRef.current),i=parseInt(a.width,10),s=parseInt(a.height,10),c=parseInt(a.paddingLeft,10),f=parseInt(a.paddingTop,10),y=[],d=0;d<e.numOfMarks+1;d++){var h=9999,v=9999;if(e.markRefs[d].current){var R=e.markRefs[d].current.getBoundingClientRect();h=R.height,v=R.width}e.props.direction===P.Direction.Left||e.props.direction===P.Direction.Right?y.push([Math.round(i/e.numOfMarks*d+c-v/2),-Math.round((h-s)/2)]):y.push([Math.round(s/e.numOfMarks*d+f-h/2),-Math.round((v-i)/2)])}e.setState({markOffsets:y})}},n.step===0)throw new Error('"step" property should be a positive number');return e.schdOnMouseMove=(0,O.schd)(e.onMouseMove),e.schdOnTouchMove=(0,O.schd)(e.onTouchMove),e.schdOnEnd=(0,O.schd)(e.onEnd),e.thumbRefs=n.values.map(function(){return ve.createRef()}),e.updateMarkRefs(n),e}return r.prototype.componentDidMount=function(){var n=this,e=this.props,a=e.values,i=e.min,s=e.step;this.resizeObserver=window.ResizeObserver?new window.ResizeObserver(this.onResize):{observe:function(){return window.addEventListener("resize",n.onResize)},unobserve:function(){return window.removeEventListener("resize",n.onResize)}},document.addEventListener("touchstart",this.onMouseOrTouchStart,{passive:!1}),document.addEventListener("mousedown",this.onMouseOrTouchStart,{passive:!1}),!this.props.allowOverlap&&(0,O.checkInitialOverlap)(this.props.values),this.props.values.forEach(function(c){return(0,O.checkBoundaries)(c,n.props.min,n.props.max)}),this.resizeObserver.observe(this.trackRef.current),(0,O.translateThumbs)(this.getThumbs(),this.getOffsets(),this.props.rtl),this.calculateMarkOffsets(),a.forEach(function(c){(0,O.isStepDivisible)(i,c,s)||console.warn("The `values` property is in conflict with the current `step`, `min`, and `max` properties. Please provide values that are accessible using the min, max, and step values.")})},r.prototype.componentDidUpdate=function(n,e){var a=this.props,i=a.max,s=a.min,c=a.step,f=a.values,y=a.rtl;(n.max!==i||n.min!==s||n.step!==c)&&this.updateMarkRefs(this.props),(0,O.translateThumbs)(this.getThumbs(),this.getOffsets(),y),(n.max!==i||n.min!==s||n.step!==c||e.markOffsets.length!==this.state.markOffsets.length)&&(this.calculateMarkOffsets(),f.forEach(function(d){(0,O.isStepDivisible)(s,d,c)||console.warn("The `values` property is in conflict with the current `step`, `min`, and `max` properties. Please provide values that are accessible using the min, max, and step values.")}))},r.prototype.componentWillUnmount=function(){var n={passive:!1};document.removeEventListener("mousedown",this.onMouseOrTouchStart,n),document.removeEventListener("mousemove",this.schdOnMouseMove),document.removeEventListener("touchmove",this.schdOnTouchMove),document.removeEventListener("touchstart",this.onMouseOrTouchStart),document.removeEventListener("mouseup",this.schdOnEnd),document.removeEventListener("touchend",this.schdOnEnd),this.resizeObserver.unobserve(this.trackRef.current)},r.prototype.render=function(){var n=this,e=this.props,a=e.label,i=e.labelledBy,s=e.renderTrack,c=e.renderThumb,f=e.renderMark,y=f===void 0?function(){return null}:f,d=e.values,h=e.min,v=e.max,R=e.allowOverlap,m=e.disabled,S=this.state,B=S.draggedThumbIndex,L=S.thumbZIndexes,D=S.markOffsets;return s({props:{style:{transform:"scale(1)",cursor:B>-1?"grabbing":this.props.draggableTrack?(0,O.isVertical)(this.props.direction)?"ns-resize":"ew-resize":d.length===1&&!m?"pointer":"inherit"},onMouseDown:m?O.voidFn:this.onMouseDownTrack,onTouchStart:m?O.voidFn:this.onTouchStartTrack,ref:this.trackRef},isDragged:this.state.draggedThumbIndex>-1,disabled:m,children:Ye(Ye([],D.map(function(M,$,H){return y({props:{style:n.props.direction===P.Direction.Left||n.props.direction===P.Direction.Right?{position:"absolute",left:"".concat(M[0],"px"),marginTop:"".concat(M[1],"px")}:{position:"absolute",top:"".concat(M[0],"px"),marginLeft:"".concat(M[1],"px")},key:"mark".concat($),ref:n.markRefs[$]},index:$})}),!0),d.map(function(M,$){var H=n.state.draggedThumbIndex===$;return c({index:$,value:M,isDragged:H,props:{style:{position:"absolute",zIndex:L[$],cursor:m?"inherit":H?"grabbing":"grab",userSelect:"none",touchAction:"none",WebkitUserSelect:"none",MozUserSelect:"none",msUserSelect:"none"},key:$,tabIndex:m?void 0:0,"aria-valuemax":R?v:d[$+1]||v,"aria-valuemin":R?h:d[$-1]||h,"aria-valuenow":M,draggable:!1,ref:n.thumbRefs[$],"aria-label":a,"aria-labelledby":i,role:"slider",onKeyDown:m?O.voidFn:n.onKeyDown,onKeyUp:m?O.voidFn:n.onKeyUp}})}),!0)})},r.defaultProps={label:"Accessibility label",labelledBy:null,step:1,direction:P.Direction.Right,rtl:!1,disabled:!1,allowOverlap:!1,draggableTrack:!1,min:0,max:100},r}(ve.Component);Ce.default=At;(function(t){var r=U&&U.__importDefault||function(i){return i&&i.__esModule?i:{default:i}};Object.defineProperty(t,"__esModule",{value:!0}),t.checkValuesAgainstBoundaries=t.relativeValue=t.useThumbOverlap=t.Direction=t.getTrackBackground=t.Range=void 0;var n=r(Ce);t.Range=n.default;var e=De;Object.defineProperty(t,"getTrackBackground",{enumerable:!0,get:function(){return e.getTrackBackground}}),Object.defineProperty(t,"useThumbOverlap",{enumerable:!0,get:function(){return e.useThumbOverlap}}),Object.defineProperty(t,"relativeValue",{enumerable:!0,get:function(){return e.relativeValue}}),Object.defineProperty(t,"checkValuesAgainstBoundaries",{enumerable:!0,get:function(){return e.checkValuesAgainstBoundaries}});var a=ce;Object.defineProperty(t,"Direction",{enumerable:!0,get:function(){return a.Direction}})})(xe);function Ze(t,r){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var e=Object.getOwnPropertySymbols(t);r&&(e=e.filter(function(a){return Object.getOwnPropertyDescriptor(t,a).enumerable})),n.push.apply(n,e)}return n}function me(t){for(var r=1;r<arguments.length;r++){var n=arguments[r]!=null?arguments[r]:{};r%2?Ze(Object(n),!0).forEach(function(e){Ft(t,e,n[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Ze(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))})}return t}function Ft(t,r,n){return r in t?Object.defineProperty(t,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[r]=n,t}var ye=ee("div",{position:"relative",width:"100%"});ye.displayName="Root";ye.displayName="Root";ye.displayName="StyledRoot";var Te=ee("div",function(t){var r=t.$theme,n=t.$value,e=n===void 0?[]:n,a=t.$disabled,i=t.$isDragged,s=r.sizing,c="inherit";return a?c="not-allowed":i?c="grabbing":e.length===1&&(c="pointer"),{paddingTop:s.scale600,paddingBottom:s.scale600,paddingRight:s.scale600,paddingLeft:s.scale600,display:"flex",cursor:c,backgroundColor:r.colors.sliderTrackFill}});Te.displayName="Track";Te.displayName="Track";Te.displayName="StyledTrack";var ke=ee("div",function(t){var r=t.$theme,n=t.$value,e=n===void 0?[]:n,a=t.$min,i=t.$max,s=t.$disabled,c=r.colors,f=r.borders,y=r.direction,d=r.borders.useRoundedCorners?f.radius100:0;return{borderTopLeftRadius:d,borderTopRightRadius:d,borderBottomRightRadius:d,borderBottomLeftRadius:d,background:xe.getTrackBackground({values:e,colors:e.length===1?[s?c.borderOpaque:c.primary,s?c.backgroundSecondary:c.borderOpaque]:[s?c.backgroundSecondary:c.borderOpaque,s?c.borderOpaque:c.primary,s?c.backgroundSecondary:c.borderOpaque],min:a||0,max:i||0,rtl:y==="rtl"}),height:"2px",width:"100%",alignSelf:"center",cursor:s?"not-allowed":"inherit"}});ke.displayName="InnerTrack";ke.displayName="InnerTrack";ke.displayName="StyledInnerTrack";var Oe=ee("div",function(t){return{width:"4px",height:"2px",backgroundColor:t.$theme.colors.backgroundPrimary,marginLeft:"16px"}});Oe.displayName="Mark";Oe.displayName="Mark";Oe.displayName="StyledMark";var we=ee("div",function(t){return me(me({},t.$theme.typography.font200),{},{color:t.$theme.colors.contentPrimary})});we.displayName="Tick";we.displayName="Tick";we.displayName="StyledTick";var Re=ee("div",function(t){var r=t.$theme,n=r.sizing;return{display:"flex",justifyContent:"space-between",alignItems:"center",paddingRight:n.scale600,paddingLeft:n.scale600,paddingBottom:n.scale400}});Re.displayName="TickBar";Re.displayName="TickBar";Re.displayName="StyledTickBar";var Se=ee("div",function(t){var r=t.$theme,n=t.$value,e=n===void 0?[]:n,a=t.$thumbIndex,i=t.$disabled,s=e.length===2&&a===0,c=e.length===2&&a===1;return r.direction==="rtl"&&(c||s)&&(s=!s,c=!c),{height:"24px",width:"24px",borderTopLeftRadius:"24px",borderTopRightRadius:"24px",borderBottomLeftRadius:"24px",borderBottomRightRadius:"24px",display:"flex",justifyContent:"center",alignItems:"center",backgroundColor:i?r.colors.sliderHandleFillDisabled:r.colors.sliderHandleFill,outline:"none",boxShadow:t.$isFocusVisible?"0 0 0 3px ".concat(r.colors.accent):"0 1px 4px rgba(0, 0, 0, 0.12)",cursor:i?"not-allowed":"inherit"}});Se.displayName="Thumb";Se.displayName="Thumb";Se.displayName="StyledThumb";var Me=ee("div",function(t){var r=t.$disabled,n=t.$theme;return{position:"absolute",top:"-16px",width:"4px",height:"20px",backgroundColor:r?n.colors.sliderHandleFillDisabled:n.colors.sliderHandleInnerFill}});Me.displayName="InnerThumb";Me.displayName="InnerThumb";Me.displayName="StyledInnerThumb";var _e=ee("div",function(t){var r=t.$disabled,n=t.$theme;return me(me({position:"absolute",top:"-".concat(n.sizing.scale1400)},n.typography.font200),{},{backgroundColor:r?n.colors.sliderHandleFillDisabled:n.colors.sliderHandleInnerFill,color:n.colors.contentInversePrimary,paddingLeft:n.sizing.scale600,paddingRight:n.sizing.scale600,paddingTop:n.sizing.scale500,paddingBottom:n.sizing.scale500,borderBottomLeftRadius:"48px",borderBottomRightRadius:"48px",borderTopLeftRadius:"48px",borderTopRightRadius:"48px",whiteSpace:"nowrap"})});_e.displayName="ThumbValue";_e.displayName="ThumbValue";_e.displayName="StyledThumbValue";function qe(t,r){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var e=Object.getOwnPropertySymbols(t);r&&(e=e.filter(function(a){return Object.getOwnPropertyDescriptor(t,a).enumerable})),n.push.apply(n,e)}return n}function Lt(t){for(var r=1;r<arguments.length;r++){var n=arguments[r]!=null?arguments[r]:{};r%2?qe(Object(n),!0).forEach(function(e){jt(t,e,n[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):qe(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))})}return t}function jt(t,r,n){return r in t?Object.defineProperty(t,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[r]=n,t}function Z(){return Z=Object.assign?Object.assign.bind():function(t){for(var r=1;r<arguments.length;r++){var n=arguments[r];for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])}return t},Z.apply(this,arguments)}function Y(t,r){return Ut(t)||Nt(t,r)||Vt(t,r)||zt()}function zt(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
2
2
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Vt(t,r){if(t){if(typeof t=="string")return Ge(t,r);var n=Object.prototype.toString.call(t).slice(8,-1);if(n==="Object"&&t.constructor&&(n=t.constructor.name),n==="Map"||n==="Set")return Array.from(t);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Ge(t,r)}}function Ge(t,r){(r==null||r>t.length)&&(r=t.length);for(var n=0,e=new Array(r);n<r;n++)e[n]=t[n];return e}function Nt(t,r){var n=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(n!=null){var e=[],a=!0,i=!1,s,c;try{for(n=n.call(t);!(a=(s=n.next()).done)&&(e.push(s.value),!(r&&e.length===r));a=!0);}catch(f){i=!0,c=f}finally{try{!a&&n.return!=null&&n.return()}finally{if(i)throw c}}return e}}function Ut(t){if(Array.isArray(t))return t}var Ht=function(r){if(r.length>2||r.length===0)throw new Error("the value prop represents positions of thumbs, so its length can be only one or two");return r};function Wt(t){var r=t.overrides,n=r===void 0?{}:r,e=t.disabled,a=e===void 0?!1:e,i=t.marks,s=i===void 0?!1:i,c=t.onChange,f=c===void 0?function(){}:c,y=t.onFinalChange,d=y===void 0?function(){}:y,h=t.min,v=h===void 0?0:h,R=t.max,m=R===void 0?100:R,S=t.step,B=S===void 0?1:S,L=t.persistentThumb,D=L===void 0?!1:L,M=t.valueToLabel,$=M===void 0?function(q){return q}:M,H=t.value,A=w.useContext(pt),x=w.useState(!1),G=Y(x,2),X=G[0],F=G[1],V=w.useState(!1),o=Y(V,2),u=o[0],l=o[1],p=w.useState(!1),b=Y(p,2),g=b[0],T=b[1],k=w.useState(-1),C=Y(k,2),_=C[0],N=C[1],j=w.useCallback(function(q){vt(q)&&T(!0);var z=q.target.parentNode.firstChild===q.target?0:1;N(z)},[]),W=w.useCallback(function(q){g!==!1&&T(!1),N(-1)},[]),E=Ht(H),I={$disabled:a,$step:B,$min:v,$max:m,$marks:s,$value:E,$isFocusVisible:g},J=Q(n.Root,ye),ie=Y(J,2),le=ie[0],te=ie[1],de=Q(n.Track,Te),fe=Y(de,2),he=fe[0],$e=fe[1],re=Q(n.InnerTrack,ke),ue=Y(re,2),ge=ue[0],pe=ue[1],Je=Q(n.Thumb,Se),Pe=Y(Je,2),Qe=Pe[0],et=Pe[1],tt=Q(n.InnerThumb,Me),Be=Y(tt,2),rt=Be[0],nt=Be[1],at=Q(n.ThumbValue,_e),Ae=Y(at,2),it=Ae[0],ot=Ae[1],st=Q(n.Tick,we),Fe=Y(st,2),Le=Fe[0],je=Fe[1],ct=Q(n.TickBar,Re),ze=Y(ct,2),ut=ze[0],lt=ze[1],dt=Q(n.Mark,Oe),Ve=Y(dt,2),ft=Ve[0],ht=Ve[1];return w.createElement(le,Z({"data-baseweb":"slider"},I,te,{onFocus:mt(te,j),onBlur:bt(te,W)}),w.createElement(xe.Range,Z({step:B,min:v,max:m,values:E,disabled:a,onChange:function(z){return f({value:z})},onFinalChange:function(z){return d({value:z})},rtl:A.direction==="rtl",renderTrack:function(z){var ne=z.props,K=z.children,oe=z.isDragged;return w.createElement(he,Z({onMouseDown:ne.onMouseDown,onTouchStart:ne.onTouchStart,$isDragged:oe},I,$e),w.createElement(ge,Z({$isDragged:oe,ref:ne.ref},I,pe),K))},renderThumb:function(z){var ne=z.props,K=z.index,oe=z.isDragged,Ne=D||(!!K&&u||!K&&X||oe)&&!a;return w.createElement(Qe,Z({},ne,{onMouseEnter:function(){K===0?F(!0):l(!0)},onMouseLeave:function(){K===0?F(!1):l(!1)},$thumbIndex:K,$isDragged:oe,style:Lt({},ne.style)},I,et,{$isFocusVisible:g&&_===K}),Ne&&w.createElement(it,Z({$thumbIndex:K,$isDragged:oe},I,ot),$(E[K])),Ne&&w.createElement(rt,Z({$thumbIndex:K,$isDragged:oe},I,nt)))}},s?{renderMark:function(z){var ne=z.props,K=z.index;return w.createElement(ft,Z({$markIndex:K},ne,I,ht))}}:{})),w.createElement(ut,Z({},I,lt),w.createElement(Le,Z({},I,je),$(v)),w.createElement(Le,Z({},I,je),$(m))))}const Kt=be("div",{target:"e8lt0n70"})(({disabled:t,theme:r})=>({alignItems:"center",backgroundColor:t?r.colors.gray:r.colors.primary,borderTopLeftRadius:"100%",borderTopRightRadius:"100%",borderBottomLeftRadius:"100%",borderBottomRightRadius:"100%",borderTopStyle:"none",borderBottomStyle:"none",borderRightStyle:"none",borderLeftStyle:"none",boxShadow:"none",display:"flex",justifyContent:"center",height:r.sizes.sliderThumb,width:r.sizes.sliderThumb,":focus":{outline:"none"},":focus-visible":{boxShadow:`0 0 0 0.2rem ${yt(r.colors.primary,.5)}`}})),Yt=be("div",{target:"e8lt0n71"})(({disabled:t,theme:r})=>({fontFamily:r.genericFonts.codeFont,fontSize:r.fontSizes.sm,color:t?r.colors.gray:r.colors.primary,top:"-1.6em",position:"absolute",whiteSpace:"nowrap",backgroundColor:r.colors.transparent,lineHeight:r.lineHeights.base,fontWeight:r.fontWeights.normal,pointerEvents:"none"})),Zt=be("div",{target:"e8lt0n72"})(({theme:t})=>({fontSize:t.fontSizes.sm,paddingBottom:t.spacing.none,paddingLeft:t.spacing.none,paddingRight:t.spacing.none,paddingTop:"0.65em",justifyContent:"space-between",alignItems:"center",display:"flex"})),Xe=be("div",{target:"e8lt0n73"})(({disabled:t,theme:r})=>({lineHeight:r.lineHeights.base,fontWeight:r.fontWeights.normal,fontFamily:r.genericFonts.codeFont,color:t?r.colors.fadedText40:"inherit"})),qt=200;function Gt({disabled:t,element:r,widgetMgr:n,width:e,fragmentId:a}){var F;const[i,s]=Et({getStateFromWidgetMgr:Xt,getDefaultStateFromProto:Jt,getCurrStateFromProto:Qt,updateWidgetMgrState:er,element:r,widgetMgr:n,fragmentId:a}),[c,f]=w.useState(i),y=w.useRef(null),[d]=w.useState([]),[h]=w.useState([]),{colors:v,fonts:R,fontSizes:m,spacing:S}=Tt(),B={width:e},L=c.map(V=>Ie(V,r)),D=Ie(r.min,r),M=Ie(r.max,r),$=r.label;w.useEffect(()=>{f(i)},[i]);const H=w.useCallback(kt(qt,V=>{s({value:V,fromUi:!0})}),[]),A=w.useCallback(({value:V})=>{f(V),H(V)},[H]),x=w.useCallback(()=>Ue(Zt,{"data-testid":"stSliderTickBar",children:[ae(Xe,{disabled:t,"data-testid":"stSliderTickBarMin",children:D}),ae(Xe,{disabled:t,"data-testid":"stSliderTickBarMax",children:M})]}),[D,M,t]),G=w.useCallback(He.forwardRef(function(o,u){const{$thumbIndex:l}=o,p=l||0;d[p]=u,h[p]||(h[p]=He.createRef());const b=Ot(o,["role","style","aria-valuemax","aria-valuemin","aria-valuenow","tabIndex","onKeyUp","onKeyDown","onMouseEnter","onMouseLeave","draggable"]),g=L[p];return ae(Kt,{...b,disabled:o.$disabled===!0,ref:d[p],"aria-valuetext":g,"aria-label":$,children:ae(Yt,{"data-testid":"stSliderThumbValue",disabled:o.$disabled===!0,ref:h[p],children:g})})}),[]);w.useEffect(()=>{var b,g;h.map((T,k)=>{T.current&&(T.current.innerText=L[k])}),d.map((T,k)=>{T.current&&T.current.setAttribute("aria-valuetext",L[k])});const V=y.current??null,o=d[0].current,u=(b=d[1])==null?void 0:b.current,l=h[0].current,p=(g=h[1])==null?void 0:g.current;nr(V,o,u,l,p)});const X=w.useCallback(({$disabled:V})=>({height:S.twoXS,...V?{background:v.darkenedBgMix25}:{}}),[v,S]);return Ue("div",{ref:y,className:"stSlider","data-testid":"stSlider",style:B,children:[ae(_t,{label:r.label,disabled:t,labelVisibility:wt((F=r.labelVisibility)==null?void 0:F.value),children:r.help&&ae(Rt,{children:ae(St,{content:r.help,placement:Mt.TOP_RIGHT})})}),ae(Wt,{min:r.min,max:r.max,step:r.step,value:rr(c,r),onChange:A,disabled:t,overrides:{Thumb:G,Tick:{style:{fontFamily:R.monospace}},Track:{style:{backgroundColor:"none !important",paddingBottom:S.none,paddingLeft:S.none,paddingRight:S.none,paddingTop:`calc(${m.sm} * 1.35)`}},InnerTrack:{style:X},TickBar:x}})]})}function Xt(t,r){return t.getDoubleArrayValue(r)}function Jt(t){return t.default}function Qt(t){return t.value}function er(t,r,n,e){r.setDoubleArrayValue(t,n.value,{fromUi:n.fromUi},e)}function tr(t){const{dataType:r}=t;return r===Ee.DataType.DATETIME||r===Ee.DataType.DATE||r===Ee.DataType.TIME}function Ie(t,r){const{format:n,options:e}=r;return tr(r)?$t.utc(t/1e3).format(n):e.length>0?We.sprintf(n,e[t]):We.sprintf(n,t)}function rr(t,r){const{min:n,max:e}=r;let a=t[0],i=t.length>1?t[1]:t[0];return a>i&&(a=i),a<n&&(a=n),a>e&&(a=e),i<n&&(i=n),i>e&&(i=e),t.length>1?[a,i]:[a]}function nr(t,r,n,e,a){!t||!r||!e||(se(t,r,e),n&&a&&(se(t,n,a),ar(t,r,n,e,a)))}function se(t,r,n){const e=t.getBoundingClientRect(),a=r.getBoundingClientRect(),i=n.getBoundingClientRect(),s=a.left+a.width/2,c=s-i.width/2<e.left,f=s+i.width/2>e.right;n.style.left=c?"0":"",n.style.right=f?"0":""}function ar(t,r,n,e,a){const s=t.getBoundingClientRect(),c=r.getBoundingClientRect(),f=n.getBoundingClientRect(),y=e.getBoundingClientRect(),d=a.getBoundingClientRect(),h=s.left+s.width/2,v=c.left+c.width/2,R=f.left+f.width/2,m=v-y.width/2>=s.left,S=R+d.width/2<=s.right,B=c.left-y.width>=s.left,L=f.right+d.width<=s.right,D=m?y.width/2:y.width,M=S?d.width/2:d.width,$=v+D;if(R-M-$>24){se(t,r,e),se(t,n,a);return}if(B&&L){e.style.left="",e.style.right=`${Math.round(c.width)}px`,a.style.left=`${Math.round(f.width)}px`,a.style.right="";return}v<h?(se(t,r,e),a.style.left=`${Math.round(v+D+24-R)}px`,a.style.right=""):(se(t,n,a),e.style.left="",e.style.right=`${-Math.round(R-M-24-v)}px`)}const ur=w.memo(Gt);export{ur as default};
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import{r as u,E as $,_ as H,a$ as ut,bk as Ht,bl as Vt,bm as jt,J as G,M as X,R as yt,aF as Gt,n as x,bn as Xt,z,j as v,bo as qt,b8 as Yt,bp as Jt,bq as Kt,al as Zt,y as Qt,br as Q,az as te,aC as ee,bs as ie,bt as se,bc as ne,bu as re}from"./index.gthzAzzy.js";import{u as oe,F as ae}from"./FormClearHelper.LI0uGKXr.js";import{T as le,a as pt}from"./Toolbar.Bws727nN.js";import{u as ce}from"./Hooks.Dic60qKO.js";import{c as de}from"./createDownloadLinkElement.DZMwyjvU.js";import{F as he,D as ue}from"./FileDownload.esm.DwBO4CPU.js";var wt=u.forwardRef(function(s,t){var e={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return u.createElement($,H({iconAttrs:e,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},s,{ref:t}),u.createElement("g",{fill:"none"},u.createElement("rect",{width:24,height:24}),u.createElement("rect",{width:24,height:24}),u.createElement("rect",{width:24,height:24})),u.createElement("path",{d:"M12 14c1.66 0 3-1.34 3-3V5c0-1.66-1.34-3-3-3S9 3.34 9 5v6c0 1.66 1.34 3 3 3z"}),u.createElement("path",{d:"M17 11c0 2.76-2.24 5-5 5s-5-2.24-5-5H5c0 3.53 2.61 6.43 6 6.92V21h2v-3.08c3.39-.49 6-3.39 6-6.92h-2z"}))});wt.displayName="Mic";var Ct=u.forwardRef(function(s,t){var e={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return u.createElement($,H({iconAttrs:e,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},s,{ref:t}),u.createElement("rect",{width:24,height:24,fill:"none"}),u.createElement("path",{d:"M8 19c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2s-2 .9-2 2v10c0 1.1.9 2 2 2zm6-12v10c0 1.1.9 2 2 2s2-.9 2-2V7c0-1.1-.9-2-2-2s-2 .9-2 2z"}))});Ct.displayName="Pause";var St=u.forwardRef(function(s,t){var e={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return u.createElement($,H({iconAttrs:e,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},s,{ref:t}),u.createElement("rect",{width:24,height:24,fill:"none"}),u.createElement("path",{d:"M8 6.82v10.36c0 .79.87 1.27 1.54.84l8.14-5.18a1 1 0 000-1.69L9.54 5.98A.998.998 0 008 6.82z"}))});St.displayName="PlayArrow";var Rt=u.forwardRef(function(s,t){var e={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return u.createElement($,H({iconAttrs:e,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},s,{ref:t}),u.createElement("path",{fill:"none",d:"M0 0h24v24H0V0z"}),u.createElement("path",{d:"M17.65 6.35a7.95 7.95 0 00-6.48-2.31c-3.67.37-6.69 3.35-7.1 7.02C3.52 15.91 7.27 20 12 20a7.98 7.98 0 007.21-4.56c.32-.67-.16-1.44-.9-1.44-.37 0-.72.2-.88.53a5.994 5.994 0 01-6.8 3.31c-2.22-.49-4.01-2.3-4.48-4.52A6.002 6.002 0 0112 6c1.66 0 3.14.69 4.22 1.78l-1.51 1.51c-.63.63-.19 1.71.7 1.71H19c.55 0 1-.45 1-1V6.41c0-.89-1.08-1.34-1.71-.71l-.64.65z"}))});Rt.displayName="Refresh";var Et=u.forwardRef(function(s,t){var e={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return u.createElement($,H({iconAttrs:e,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},s,{ref:t}),u.createElement("g",{fill:"none"},u.createElement("rect",{width:24,height:24}),u.createElement("rect",{width:24,height:24})),u.createElement("path",{fillRule:"evenodd",d:"M9 16h6c.55 0 1-.45 1-1V9c0-.55-.45-1-1-1H9c-.55 0-1 .45-1 1v6c0 .55.45 1 1 1zm3-14C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2z"}))});Et.displayName="StopCircle";function E(s,t,e,i){return new(e||(e=Promise))(function(r,n){function a(c){try{d(i.next(c))}catch(l){n(l)}}function o(c){try{d(i.throw(c))}catch(l){n(l)}}function d(c){var l;c.done?r(c.value):(l=c.value,l instanceof e?l:new e(function(p){p(l)})).then(a,o)}d((i=i.apply(s,t||[])).next())})}let V=class{constructor(){this.listeners={}}on(t,e,i){if(this.listeners[t]||(this.listeners[t]=new Set),this.listeners[t].add(e),i==null?void 0:i.once){const r=()=>{this.un(t,r),this.un(t,e)};return this.on(t,r),r}return()=>this.un(t,e)}un(t,e){var i;(i=this.listeners[t])===null||i===void 0||i.delete(e)}once(t,e){return this.on(t,e,{once:!0})}unAll(){this.listeners={}}emit(t,...e){this.listeners[t]&&this.listeners[t].forEach(i=>i(...e))}};const mt={decode:function(s,t){return E(this,void 0,void 0,function*(){const e=new AudioContext({sampleRate:t});return e.decodeAudioData(s).finally(()=>e.close())})},createBuffer:function(s,t){return typeof s[0]=="number"&&(s=[s]),function(e){const i=e[0];if(i.some(r=>r>1||r<-1)){const r=i.length;let n=0;for(let a=0;a<r;a++){const o=Math.abs(i[a]);o>n&&(n=o)}for(const a of e)for(let o=0;o<r;o++)a[o]/=n}}(s),{duration:t,length:s[0].length,sampleRate:s[0].length/t,numberOfChannels:s.length,getChannelData:e=>s==null?void 0:s[e],copyFromChannel:AudioBuffer.prototype.copyFromChannel,copyToChannel:AudioBuffer.prototype.copyToChannel}}};function xt(s,t){const e=t.xmlns?document.createElementNS(t.xmlns,s):document.createElement(s);for(const[i,r]of Object.entries(t))if(i==="children")for(const[n,a]of Object.entries(t))typeof a=="string"?e.appendChild(document.createTextNode(a)):e.appendChild(xt(n,a));else i==="style"?Object.assign(e.style,r):i==="textContent"?e.textContent=r:e.setAttribute(i,r.toString());return e}function ft(s,t,e){const i=xt(s,t||{});return e==null||e.appendChild(i),i}var pe=Object.freeze({__proto__:null,createElement:ft,default:ft});const me={fetchBlob:function(s,t,e){return E(this,void 0,void 0,function*(){const i=yield fetch(s,e);if(i.status>=400)throw new Error(`Failed to fetch ${s}: ${i.status} (${i.statusText})`);return function(r,n){E(this,void 0,void 0,function*(){if(!r.body||!r.headers)return;const a=r.body.getReader(),o=Number(r.headers.get("Content-Length"))||0;let d=0;const c=p=>E(this,void 0,void 0,function*(){d+=(p==null?void 0:p.length)||0;const h=Math.round(d/o*100);n(h)}),l=()=>E(this,void 0,void 0,function*(){let p;try{p=yield a.read()}catch{return}p.done||(c(p.value),yield l())});l()})}(i.clone(),t),i.blob()})}};class fe extends V{constructor(t){super(),this.isExternalMedia=!1,t.media?(this.media=t.media,this.isExternalMedia=!0):this.media=document.createElement("audio"),t.mediaControls&&(this.media.controls=!0),t.autoplay&&(this.media.autoplay=!0),t.playbackRate!=null&&this.onMediaEvent("canplay",()=>{t.playbackRate!=null&&(this.media.playbackRate=t.playbackRate)},{once:!0})}onMediaEvent(t,e,i){return this.media.addEventListener(t,e,i),()=>this.media.removeEventListener(t,e,i)}getSrc(){return this.media.currentSrc||this.media.src||""}revokeSrc(){const t=this.getSrc();t.startsWith("blob:")&&URL.revokeObjectURL(t)}canPlayType(t){return this.media.canPlayType(t)!==""}setSrc(t,e){const i=this.getSrc();if(t&&i===t)return;this.revokeSrc();const r=e instanceof Blob&&(this.canPlayType(e.type)||!t)?URL.createObjectURL(e):t;try{this.media.src=r}catch{this.media.src=t}}destroy(){this.media.pause(),this.isExternalMedia||(this.media.remove(),this.revokeSrc(),this.media.src="",this.media.load())}setMediaElement(t){this.media=t}play(){return E(this,void 0,void 0,function*(){return this.media.play()})}pause(){this.media.pause()}isPlaying(){return!this.media.paused&&!this.media.ended}setTime(t){this.media.currentTime=t}getDuration(){return this.media.duration}getCurrentTime(){return this.media.currentTime}getVolume(){return this.media.volume}setVolume(t){this.media.volume=t}getMuted(){return this.media.muted}setMuted(t){this.media.muted=t}getPlaybackRate(){return this.media.playbackRate}isSeeking(){return this.media.seeking}setPlaybackRate(t,e){e!=null&&(this.media.preservesPitch=e),this.media.playbackRate=t}getMediaElement(){return this.media}setSinkId(t){return this.media.setSinkId(t)}}class N extends V{constructor(t,e){super(),this.timeouts=[],this.isScrollable=!1,this.audioData=null,this.resizeObserver=null,this.lastContainerWidth=0,this.isDragging=!1,this.subscriptions=[],this.subscriptions=[],this.options=t;const i=this.parentFromOptionsContainer(t.container);this.parent=i;const[r,n]=this.initHtml();i.appendChild(r),this.container=r,this.scrollContainer=n.querySelector(".scroll"),this.wrapper=n.querySelector(".wrapper"),this.canvasWrapper=n.querySelector(".canvases"),this.progressWrapper=n.querySelector(".progress"),this.cursor=n.querySelector(".cursor"),e&&n.appendChild(e),this.initEvents()}parentFromOptionsContainer(t){let e;if(typeof t=="string"?e=document.querySelector(t):t instanceof HTMLElement&&(e=t),!e)throw new Error("Container not found");return e}initEvents(){const t=e=>{const i=this.wrapper.getBoundingClientRect(),r=e.clientX-i.left,n=e.clientY-i.top;return[r/i.width,n/i.height]};if(this.wrapper.addEventListener("click",e=>{const[i,r]=t(e);this.emit("click",i,r)}),this.wrapper.addEventListener("dblclick",e=>{const[i,r]=t(e);this.emit("dblclick",i,r)}),this.options.dragToSeek!==!0&&typeof this.options.dragToSeek!="object"||this.initDrag(),this.scrollContainer.addEventListener("scroll",()=>{const{scrollLeft:e,scrollWidth:i,clientWidth:r}=this.scrollContainer,n=e/i,a=(e+r)/i;this.emit("scroll",n,a,e,e+r)}),typeof ResizeObserver=="function"){const e=this.createDelay(100);this.resizeObserver=new ResizeObserver(()=>{e().then(()=>this.onContainerResize()).catch(()=>{})}),this.resizeObserver.observe(this.scrollContainer)}}onContainerResize(){const t=this.parent.clientWidth;t===this.lastContainerWidth&&this.options.height!=="auto"||(this.lastContainerWidth=t,this.reRender())}initDrag(){this.subscriptions.push(function(t,e,i,r,n=3,a=0,o=100){if(!t)return()=>{};const d=matchMedia("(pointer: coarse)").matches;let c=()=>{};const l=p=>{if(p.button!==a)return;p.preventDefault(),p.stopPropagation();let h=p.clientX,m=p.clientY,f=!1;const b=Date.now(),g=C=>{if(C.preventDefault(),C.stopPropagation(),d&&Date.now()-b<o)return;const D=C.clientX,W=C.clientY,M=D-h,A=W-m;if(f||Math.abs(M)>n||Math.abs(A)>n){const I=t.getBoundingClientRect(),{left:U,top:O}=I;f||(i==null||i(h-U,m-O),f=!0),e(M,A,D-U,W-O),h=D,m=W}},w=C=>{if(f){const D=C.clientX,W=C.clientY,M=t.getBoundingClientRect(),{left:A,top:I}=M;r==null||r(D-A,W-I)}c()},y=C=>{C.relatedTarget&&C.relatedTarget!==document.documentElement||w(C)},P=C=>{f&&(C.stopPropagation(),C.preventDefault())},T=C=>{f&&C.preventDefault()};document.addEventListener("pointermove",g),document.addEventListener("pointerup",w),document.addEventListener("pointerout",y),document.addEventListener("pointercancel",y),document.addEventListener("touchmove",T,{passive:!1}),document.addEventListener("click",P,{capture:!0}),c=()=>{document.removeEventListener("pointermove",g),document.removeEventListener("pointerup",w),document.removeEventListener("pointerout",y),document.removeEventListener("pointercancel",y),document.removeEventListener("touchmove",T),setTimeout(()=>{document.removeEventListener("click",P,{capture:!0})},10)}};return t.addEventListener("pointerdown",l),()=>{c(),t.removeEventListener("pointerdown",l)}}(this.wrapper,(t,e,i)=>{this.emit("drag",Math.max(0,Math.min(1,i/this.wrapper.getBoundingClientRect().width)))},t=>{this.isDragging=!0,this.emit("dragstart",Math.max(0,Math.min(1,t/this.wrapper.getBoundingClientRect().width)))},t=>{this.isDragging=!1,this.emit("dragend",Math.max(0,Math.min(1,t/this.wrapper.getBoundingClientRect().width)))}))}getHeight(t,e){var i;const r=((i=this.audioData)===null||i===void 0?void 0:i.numberOfChannels)||1;if(t==null)return 128;if(!isNaN(Number(t)))return Number(t);if(t==="auto"){const n=this.parent.clientHeight||128;return e!=null&&e.every(a=>!a.overlay)?n/r:n}return 128}initHtml(){const t=document.createElement("div"),e=t.attachShadow({mode:"open"}),i=this.options.cspNonce&&typeof this.options.cspNonce=="string"?this.options.cspNonce.replace(/"/g,""):"";return e.innerHTML=`
|
1
|
+
import{r as u,E as $,_ as H,a$ as ut,bk as Ht,bl as Vt,bm as jt,K as G,N as X,R as yt,aF as Gt,n as x,bn as Xt,z,j as v,bo as qt,b8 as Yt,bp as Kt,bq as Zt,am as Jt,y as Qt,br as Q,C as te,aC as ee,bs as ie,bt as se,bc as ne,bu as re}from"./index.9wBA4A4f.js";import{u as oe,F as ae}from"./FormClearHelper.BBpErIGP.js";import{T as le,a as pt}from"./Toolbar.D-hUr0RX.js";import{u as ce}from"./Hooks.CeSTXIj2.js";import{c as de}from"./createDownloadLinkElement.DZMwyjvU.js";import{F as he,D as ue}from"./FileDownload.esm.D9415avj.js";var wt=u.forwardRef(function(s,t){var e={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return u.createElement($,H({iconAttrs:e,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},s,{ref:t}),u.createElement("g",{fill:"none"},u.createElement("rect",{width:24,height:24}),u.createElement("rect",{width:24,height:24}),u.createElement("rect",{width:24,height:24})),u.createElement("path",{d:"M12 14c1.66 0 3-1.34 3-3V5c0-1.66-1.34-3-3-3S9 3.34 9 5v6c0 1.66 1.34 3 3 3z"}),u.createElement("path",{d:"M17 11c0 2.76-2.24 5-5 5s-5-2.24-5-5H5c0 3.53 2.61 6.43 6 6.92V21h2v-3.08c3.39-.49 6-3.39 6-6.92h-2z"}))});wt.displayName="Mic";var Ct=u.forwardRef(function(s,t){var e={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return u.createElement($,H({iconAttrs:e,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},s,{ref:t}),u.createElement("rect",{width:24,height:24,fill:"none"}),u.createElement("path",{d:"M8 19c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2s-2 .9-2 2v10c0 1.1.9 2 2 2zm6-12v10c0 1.1.9 2 2 2s2-.9 2-2V7c0-1.1-.9-2-2-2s-2 .9-2 2z"}))});Ct.displayName="Pause";var St=u.forwardRef(function(s,t){var e={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return u.createElement($,H({iconAttrs:e,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},s,{ref:t}),u.createElement("rect",{width:24,height:24,fill:"none"}),u.createElement("path",{d:"M8 6.82v10.36c0 .79.87 1.27 1.54.84l8.14-5.18a1 1 0 000-1.69L9.54 5.98A.998.998 0 008 6.82z"}))});St.displayName="PlayArrow";var Rt=u.forwardRef(function(s,t){var e={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return u.createElement($,H({iconAttrs:e,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},s,{ref:t}),u.createElement("path",{fill:"none",d:"M0 0h24v24H0V0z"}),u.createElement("path",{d:"M17.65 6.35a7.95 7.95 0 00-6.48-2.31c-3.67.37-6.69 3.35-7.1 7.02C3.52 15.91 7.27 20 12 20a7.98 7.98 0 007.21-4.56c.32-.67-.16-1.44-.9-1.44-.37 0-.72.2-.88.53a5.994 5.994 0 01-6.8 3.31c-2.22-.49-4.01-2.3-4.48-4.52A6.002 6.002 0 0112 6c1.66 0 3.14.69 4.22 1.78l-1.51 1.51c-.63.63-.19 1.71.7 1.71H19c.55 0 1-.45 1-1V6.41c0-.89-1.08-1.34-1.71-.71l-.64.65z"}))});Rt.displayName="Refresh";var Et=u.forwardRef(function(s,t){var e={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return u.createElement($,H({iconAttrs:e,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},s,{ref:t}),u.createElement("g",{fill:"none"},u.createElement("rect",{width:24,height:24}),u.createElement("rect",{width:24,height:24})),u.createElement("path",{fillRule:"evenodd",d:"M9 16h6c.55 0 1-.45 1-1V9c0-.55-.45-1-1-1H9c-.55 0-1 .45-1 1v6c0 .55.45 1 1 1zm3-14C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2z"}))});Et.displayName="StopCircle";function E(s,t,e,i){return new(e||(e=Promise))(function(r,n){function a(c){try{d(i.next(c))}catch(l){n(l)}}function o(c){try{d(i.throw(c))}catch(l){n(l)}}function d(c){var l;c.done?r(c.value):(l=c.value,l instanceof e?l:new e(function(p){p(l)})).then(a,o)}d((i=i.apply(s,t||[])).next())})}let V=class{constructor(){this.listeners={}}on(t,e,i){if(this.listeners[t]||(this.listeners[t]=new Set),this.listeners[t].add(e),i==null?void 0:i.once){const r=()=>{this.un(t,r),this.un(t,e)};return this.on(t,r),r}return()=>this.un(t,e)}un(t,e){var i;(i=this.listeners[t])===null||i===void 0||i.delete(e)}once(t,e){return this.on(t,e,{once:!0})}unAll(){this.listeners={}}emit(t,...e){this.listeners[t]&&this.listeners[t].forEach(i=>i(...e))}};const mt={decode:function(s,t){return E(this,void 0,void 0,function*(){const e=new AudioContext({sampleRate:t});return e.decodeAudioData(s).finally(()=>e.close())})},createBuffer:function(s,t){return typeof s[0]=="number"&&(s=[s]),function(e){const i=e[0];if(i.some(r=>r>1||r<-1)){const r=i.length;let n=0;for(let a=0;a<r;a++){const o=Math.abs(i[a]);o>n&&(n=o)}for(const a of e)for(let o=0;o<r;o++)a[o]/=n}}(s),{duration:t,length:s[0].length,sampleRate:s[0].length/t,numberOfChannels:s.length,getChannelData:e=>s==null?void 0:s[e],copyFromChannel:AudioBuffer.prototype.copyFromChannel,copyToChannel:AudioBuffer.prototype.copyToChannel}}};function xt(s,t){const e=t.xmlns?document.createElementNS(t.xmlns,s):document.createElement(s);for(const[i,r]of Object.entries(t))if(i==="children")for(const[n,a]of Object.entries(t))typeof a=="string"?e.appendChild(document.createTextNode(a)):e.appendChild(xt(n,a));else i==="style"?Object.assign(e.style,r):i==="textContent"?e.textContent=r:e.setAttribute(i,r.toString());return e}function ft(s,t,e){const i=xt(s,t||{});return e==null||e.appendChild(i),i}var pe=Object.freeze({__proto__:null,createElement:ft,default:ft});const me={fetchBlob:function(s,t,e){return E(this,void 0,void 0,function*(){const i=yield fetch(s,e);if(i.status>=400)throw new Error(`Failed to fetch ${s}: ${i.status} (${i.statusText})`);return function(r,n){E(this,void 0,void 0,function*(){if(!r.body||!r.headers)return;const a=r.body.getReader(),o=Number(r.headers.get("Content-Length"))||0;let d=0;const c=p=>E(this,void 0,void 0,function*(){d+=(p==null?void 0:p.length)||0;const h=Math.round(d/o*100);n(h)}),l=()=>E(this,void 0,void 0,function*(){let p;try{p=yield a.read()}catch{return}p.done||(c(p.value),yield l())});l()})}(i.clone(),t),i.blob()})}};class fe extends V{constructor(t){super(),this.isExternalMedia=!1,t.media?(this.media=t.media,this.isExternalMedia=!0):this.media=document.createElement("audio"),t.mediaControls&&(this.media.controls=!0),t.autoplay&&(this.media.autoplay=!0),t.playbackRate!=null&&this.onMediaEvent("canplay",()=>{t.playbackRate!=null&&(this.media.playbackRate=t.playbackRate)},{once:!0})}onMediaEvent(t,e,i){return this.media.addEventListener(t,e,i),()=>this.media.removeEventListener(t,e,i)}getSrc(){return this.media.currentSrc||this.media.src||""}revokeSrc(){const t=this.getSrc();t.startsWith("blob:")&&URL.revokeObjectURL(t)}canPlayType(t){return this.media.canPlayType(t)!==""}setSrc(t,e){const i=this.getSrc();if(t&&i===t)return;this.revokeSrc();const r=e instanceof Blob&&(this.canPlayType(e.type)||!t)?URL.createObjectURL(e):t;try{this.media.src=r}catch{this.media.src=t}}destroy(){this.media.pause(),this.isExternalMedia||(this.media.remove(),this.revokeSrc(),this.media.src="",this.media.load())}setMediaElement(t){this.media=t}play(){return E(this,void 0,void 0,function*(){return this.media.play()})}pause(){this.media.pause()}isPlaying(){return!this.media.paused&&!this.media.ended}setTime(t){this.media.currentTime=t}getDuration(){return this.media.duration}getCurrentTime(){return this.media.currentTime}getVolume(){return this.media.volume}setVolume(t){this.media.volume=t}getMuted(){return this.media.muted}setMuted(t){this.media.muted=t}getPlaybackRate(){return this.media.playbackRate}isSeeking(){return this.media.seeking}setPlaybackRate(t,e){e!=null&&(this.media.preservesPitch=e),this.media.playbackRate=t}getMediaElement(){return this.media}setSinkId(t){return this.media.setSinkId(t)}}class N extends V{constructor(t,e){super(),this.timeouts=[],this.isScrollable=!1,this.audioData=null,this.resizeObserver=null,this.lastContainerWidth=0,this.isDragging=!1,this.subscriptions=[],this.subscriptions=[],this.options=t;const i=this.parentFromOptionsContainer(t.container);this.parent=i;const[r,n]=this.initHtml();i.appendChild(r),this.container=r,this.scrollContainer=n.querySelector(".scroll"),this.wrapper=n.querySelector(".wrapper"),this.canvasWrapper=n.querySelector(".canvases"),this.progressWrapper=n.querySelector(".progress"),this.cursor=n.querySelector(".cursor"),e&&n.appendChild(e),this.initEvents()}parentFromOptionsContainer(t){let e;if(typeof t=="string"?e=document.querySelector(t):t instanceof HTMLElement&&(e=t),!e)throw new Error("Container not found");return e}initEvents(){const t=e=>{const i=this.wrapper.getBoundingClientRect(),r=e.clientX-i.left,n=e.clientY-i.top;return[r/i.width,n/i.height]};if(this.wrapper.addEventListener("click",e=>{const[i,r]=t(e);this.emit("click",i,r)}),this.wrapper.addEventListener("dblclick",e=>{const[i,r]=t(e);this.emit("dblclick",i,r)}),this.options.dragToSeek!==!0&&typeof this.options.dragToSeek!="object"||this.initDrag(),this.scrollContainer.addEventListener("scroll",()=>{const{scrollLeft:e,scrollWidth:i,clientWidth:r}=this.scrollContainer,n=e/i,a=(e+r)/i;this.emit("scroll",n,a,e,e+r)}),typeof ResizeObserver=="function"){const e=this.createDelay(100);this.resizeObserver=new ResizeObserver(()=>{e().then(()=>this.onContainerResize()).catch(()=>{})}),this.resizeObserver.observe(this.scrollContainer)}}onContainerResize(){const t=this.parent.clientWidth;t===this.lastContainerWidth&&this.options.height!=="auto"||(this.lastContainerWidth=t,this.reRender())}initDrag(){this.subscriptions.push(function(t,e,i,r,n=3,a=0,o=100){if(!t)return()=>{};const d=matchMedia("(pointer: coarse)").matches;let c=()=>{};const l=p=>{if(p.button!==a)return;p.preventDefault(),p.stopPropagation();let h=p.clientX,m=p.clientY,f=!1;const b=Date.now(),g=C=>{if(C.preventDefault(),C.stopPropagation(),d&&Date.now()-b<o)return;const D=C.clientX,W=C.clientY,M=D-h,A=W-m;if(f||Math.abs(M)>n||Math.abs(A)>n){const I=t.getBoundingClientRect(),{left:U,top:O}=I;f||(i==null||i(h-U,m-O),f=!0),e(M,A,D-U,W-O),h=D,m=W}},w=C=>{if(f){const D=C.clientX,W=C.clientY,M=t.getBoundingClientRect(),{left:A,top:I}=M;r==null||r(D-A,W-I)}c()},y=C=>{C.relatedTarget&&C.relatedTarget!==document.documentElement||w(C)},P=C=>{f&&(C.stopPropagation(),C.preventDefault())},T=C=>{f&&C.preventDefault()};document.addEventListener("pointermove",g),document.addEventListener("pointerup",w),document.addEventListener("pointerout",y),document.addEventListener("pointercancel",y),document.addEventListener("touchmove",T,{passive:!1}),document.addEventListener("click",P,{capture:!0}),c=()=>{document.removeEventListener("pointermove",g),document.removeEventListener("pointerup",w),document.removeEventListener("pointerout",y),document.removeEventListener("pointercancel",y),document.removeEventListener("touchmove",T),setTimeout(()=>{document.removeEventListener("click",P,{capture:!0})},10)}};return t.addEventListener("pointerdown",l),()=>{c(),t.removeEventListener("pointerdown",l)}}(this.wrapper,(t,e,i)=>{this.emit("drag",Math.max(0,Math.min(1,i/this.wrapper.getBoundingClientRect().width)))},t=>{this.isDragging=!0,this.emit("dragstart",Math.max(0,Math.min(1,t/this.wrapper.getBoundingClientRect().width)))},t=>{this.isDragging=!1,this.emit("dragend",Math.max(0,Math.min(1,t/this.wrapper.getBoundingClientRect().width)))}))}getHeight(t,e){var i;const r=((i=this.audioData)===null||i===void 0?void 0:i.numberOfChannels)||1;if(t==null)return 128;if(!isNaN(Number(t)))return Number(t);if(t==="auto"){const n=this.parent.clientHeight||128;return e!=null&&e.every(a=>!a.overlay)?n/r:n}return 128}initHtml(){const t=document.createElement("div"),e=t.attachShadow({mode:"open"}),i=this.options.cspNonce&&typeof this.options.cspNonce=="string"?this.options.cspNonce.replace(/"/g,""):"";return e.innerHTML=`
|
2
2
|
<style${i?` nonce="${i}"`:""}>
|
3
3
|
:host {
|
4
4
|
user-select: none;
|
@@ -70,4 +70,4 @@ import{r as u,E as $,_ as H,a$ as ut,bk as Ht,bl as Vt,bm as jt,J as G,M as X,R
|
|
70
70
|
<div class="cursor" part="cursor"></div>
|
71
71
|
</div>
|
72
72
|
</div>
|
73
|
-
`,[t,e]}setOptions(t){if(this.options.container!==t.container){const e=this.parentFromOptionsContainer(t.container);e.appendChild(this.container),this.parent=e}t.dragToSeek!==!0&&typeof this.options.dragToSeek!="object"||this.initDrag(),this.options=t,this.reRender()}getWrapper(){return this.wrapper}getWidth(){return this.scrollContainer.clientWidth}getScroll(){return this.scrollContainer.scrollLeft}setScroll(t){this.scrollContainer.scrollLeft=t}setScrollPercentage(t){const{scrollWidth:e}=this.scrollContainer,i=e*t;this.setScroll(i)}destroy(){var t,e;this.subscriptions.forEach(i=>i()),this.container.remove(),(t=this.resizeObserver)===null||t===void 0||t.disconnect(),(e=this.unsubscribeOnScroll)===null||e===void 0||e.call(this)}createDelay(t=10){let e,i;const r=()=>{e&&clearTimeout(e),i&&i()};return this.timeouts.push(r),()=>new Promise((n,a)=>{r(),i=a,e=setTimeout(()=>{e=void 0,i=void 0,n()},t)})}convertColorValues(t){if(!Array.isArray(t))return t||"";if(t.length<2)return t[0]||"";const e=document.createElement("canvas"),i=e.getContext("2d"),r=e.height*(window.devicePixelRatio||1),n=i.createLinearGradient(0,0,0,r),a=1/(t.length-1);return t.forEach((o,d)=>{const c=d*a;n.addColorStop(c,o)}),n}getPixelRatio(){return Math.max(1,window.devicePixelRatio||1)}renderBarWaveform(t,e,i,r){const n=t[0],a=t[1]||t[0],o=n.length,{width:d,height:c}=i.canvas,l=c/2,p=this.getPixelRatio(),h=e.barWidth?e.barWidth*p:1,m=e.barGap?e.barGap*p:e.barWidth?h/2:0,f=e.barRadius||0,b=d/(h+m)/o,g=f&&"roundRect"in i?"roundRect":"rect";i.beginPath();let w=0,y=0,P=0;for(let T=0;T<=o;T++){const C=Math.round(T*b);if(C>w){const M=Math.round(y*l*r),A=M+Math.round(P*l*r)||1;let I=l-M;e.barAlign==="top"?I=0:e.barAlign==="bottom"&&(I=c-A),i[g](w*(h+m),I,h,A,f),w=C,y=0,P=0}const D=Math.abs(n[T]||0),W=Math.abs(a[T]||0);D>y&&(y=D),W>P&&(P=W)}i.fill(),i.closePath()}renderLineWaveform(t,e,i,r){const n=a=>{const o=t[a]||t[0],d=o.length,{height:c}=i.canvas,l=c/2,p=i.canvas.width/d;i.moveTo(0,l);let h=0,m=0;for(let f=0;f<=d;f++){const b=Math.round(f*p);if(b>h){const w=l+(Math.round(m*l*r)||1)*(a===0?-1:1);i.lineTo(h,w),h=b,m=0}const g=Math.abs(o[f]||0);g>m&&(m=g)}i.lineTo(h,l)};i.beginPath(),n(0),n(1),i.fill(),i.closePath()}renderWaveform(t,e,i){if(i.fillStyle=this.convertColorValues(e.waveColor),e.renderFunction)return void e.renderFunction(t,i);let r=e.barHeight||1;if(e.normalize){const n=Array.from(t[0]).reduce((a,o)=>Math.max(a,Math.abs(o)),0);r=n?1/n:1}e.barWidth||e.barGap||e.barAlign?this.renderBarWaveform(t,e,i,r):this.renderLineWaveform(t,e,i,r)}renderSingleCanvas(t,e,i,r,n,a,o){const d=this.getPixelRatio(),c=document.createElement("canvas");c.width=Math.round(i*d),c.height=Math.round(r*d),c.style.width=`${i}px`,c.style.height=`${r}px`,c.style.left=`${Math.round(n)}px`,a.appendChild(c);const l=c.getContext("2d");if(this.renderWaveform(t,e,l),c.width>0&&c.height>0){const p=c.cloneNode(),h=p.getContext("2d");h.drawImage(c,0,0),h.globalCompositeOperation="source-in",h.fillStyle=this.convertColorValues(e.progressColor),h.fillRect(0,0,c.width,c.height),o.appendChild(p)}}renderMultiCanvas(t,e,i,r,n,a){const o=this.getPixelRatio(),{clientWidth:d}=this.scrollContainer,c=i/o;let l=Math.min(N.MAX_CANVAS_WIDTH,d,c),p={};if(e.barWidth||e.barGap){const g=e.barWidth||.5,w=g+(e.barGap||g/2);l%w!=0&&(l=Math.floor(l/w)*w)}const h=g=>{if(g<0||g>=m||p[g])return;p[g]=!0;const w=g*l,y=Math.min(c-w,l);if(y<=0)return;const P=t.map(T=>{const C=Math.floor(w/c*T.length),D=Math.floor((w+y)/c*T.length);return T.slice(C,D)});this.renderSingleCanvas(P,e,y,r,w,n,a)},m=Math.ceil(c/l);if(!this.isScrollable){for(let g=0;g<m;g++)h(g);return}const f=this.scrollContainer.scrollLeft/c,b=Math.floor(f*m);h(b-1),h(b),h(b+1),m>1&&(this.unsubscribeOnScroll=this.on("scroll",()=>{const{scrollLeft:g}=this.scrollContainer,w=Math.floor(g/c*m);Object.keys(p).length>N.MAX_NODES&&(n.innerHTML="",a.innerHTML="",p={}),h(w-1),h(w),h(w+1)}))}renderChannel(t,e,i,r){var{overlay:n}=e,a=function(l,p){var h={};for(var m in l)Object.prototype.hasOwnProperty.call(l,m)&&p.indexOf(m)<0&&(h[m]=l[m]);if(l!=null&&typeof Object.getOwnPropertySymbols=="function"){var f=0;for(m=Object.getOwnPropertySymbols(l);f<m.length;f++)p.indexOf(m[f])<0&&Object.prototype.propertyIsEnumerable.call(l,m[f])&&(h[m[f]]=l[m[f]])}return h}(e,["overlay"]);const o=document.createElement("div"),d=this.getHeight(a.height,a.splitChannels);o.style.height=`${d}px`,n&&r>0&&(o.style.marginTop=`-${d}px`),this.canvasWrapper.style.minHeight=`${d}px`,this.canvasWrapper.appendChild(o);const c=o.cloneNode();this.progressWrapper.appendChild(c),this.renderMultiCanvas(t,a,i,d,o,c)}render(t){return E(this,void 0,void 0,function*(){var e;this.timeouts.forEach(d=>d()),this.timeouts=[],this.canvasWrapper.innerHTML="",this.progressWrapper.innerHTML="",this.options.width!=null&&(this.scrollContainer.style.width=typeof this.options.width=="number"?`${this.options.width}px`:this.options.width);const i=this.getPixelRatio(),r=this.scrollContainer.clientWidth,n=Math.ceil(t.duration*(this.options.minPxPerSec||0));this.isScrollable=n>r;const a=this.options.fillParent&&!this.isScrollable,o=(a?r:n)*i;if(this.wrapper.style.width=a?"100%":`${n}px`,this.scrollContainer.style.overflowX=this.isScrollable?"auto":"hidden",this.scrollContainer.classList.toggle("noScrollbar",!!this.options.hideScrollbar),this.cursor.style.backgroundColor=`${this.options.cursorColor||this.options.progressColor}`,this.cursor.style.width=`${this.options.cursorWidth}px`,this.audioData=t,this.emit("render"),this.options.splitChannels)for(let d=0;d<t.numberOfChannels;d++){const c=Object.assign(Object.assign({},this.options),(e=this.options.splitChannels)===null||e===void 0?void 0:e[d]);this.renderChannel([t.getChannelData(d)],c,o,d)}else{const d=[t.getChannelData(0)];t.numberOfChannels>1&&d.push(t.getChannelData(1)),this.renderChannel(d,this.options,o,0)}Promise.resolve().then(()=>this.emit("rendered"))})}reRender(){var t;if((t=this.unsubscribeOnScroll)===null||t===void 0||t.call(this),delete this.unsubscribeOnScroll,!this.audioData)return;const{scrollWidth:e}=this.scrollContainer,{right:i}=this.progressWrapper.getBoundingClientRect();if(this.render(this.audioData),this.isScrollable&&e!==this.scrollContainer.scrollWidth){const{right:r}=this.progressWrapper.getBoundingClientRect();let n=r-i;n*=2,n=n<0?Math.floor(n):Math.ceil(n),n/=2,this.scrollContainer.scrollLeft+=n}}zoom(t){this.options.minPxPerSec=t,this.reRender()}scrollIntoView(t,e=!1){const{scrollLeft:i,scrollWidth:r,clientWidth:n}=this.scrollContainer,a=t*r,o=i,d=i+n,c=n/2;if(this.isDragging)a+30>d?this.scrollContainer.scrollLeft+=30:a-30<o&&(this.scrollContainer.scrollLeft-=30);else{(a<o||a>d)&&(this.scrollContainer.scrollLeft=a-(this.options.autoCenter?c:0));const l=a-i-c;e&&this.options.autoCenter&&l>0&&(this.scrollContainer.scrollLeft+=Math.min(l,10))}{const l=this.scrollContainer.scrollLeft,p=l/r,h=(l+n)/r;this.emit("scroll",p,h,l,l+n)}}renderProgress(t,e){if(isNaN(t))return;const i=100*t;this.canvasWrapper.style.clipPath=`polygon(${i}% 0, 100% 0, 100% 100%, ${i}% 100%)`,this.progressWrapper.style.width=`${i}%`,this.cursor.style.left=`${i}%`,this.cursor.style.transform=`translateX(-${Math.round(i)===100?this.options.cursorWidth:0}px)`,this.isScrollable&&this.options.autoScroll&&this.scrollIntoView(t,e)}exportImage(t,e,i){return E(this,void 0,void 0,function*(){const r=this.canvasWrapper.querySelectorAll("canvas");if(!r.length)throw new Error("No waveform data");if(i==="dataURL"){const n=Array.from(r).map(a=>a.toDataURL(t,e));return Promise.resolve(n)}return Promise.all(Array.from(r).map(n=>new Promise((a,o)=>{n.toBlob(d=>{d?a(d):o(new Error("Could not export image"))},t,e)})))})}}N.MAX_CANVAS_WIDTH=8e3,N.MAX_NODES=10;class ge extends V{constructor(){super(...arguments),this.unsubscribe=()=>{}}start(){this.unsubscribe=this.on("tick",()=>{requestAnimationFrame(()=>{this.emit("tick")})}),this.emit("tick")}stop(){this.unsubscribe()}destroy(){this.unsubscribe()}}class gt extends V{constructor(t=new AudioContext){super(),this.bufferNode=null,this.playStartTime=0,this.playedDuration=0,this._muted=!1,this._playbackRate=1,this._duration=void 0,this.buffer=null,this.currentSrc="",this.paused=!0,this.crossOrigin=null,this.seeking=!1,this.autoplay=!1,this.addEventListener=this.on,this.removeEventListener=this.un,this.audioContext=t,this.gainNode=this.audioContext.createGain(),this.gainNode.connect(this.audioContext.destination)}load(){return E(this,void 0,void 0,function*(){})}get src(){return this.currentSrc}set src(t){if(this.currentSrc=t,this._duration=void 0,!t)return this.buffer=null,void this.emit("emptied");fetch(t).then(e=>{if(e.status>=400)throw new Error(`Failed to fetch ${t}: ${e.status} (${e.statusText})`);return e.arrayBuffer()}).then(e=>this.currentSrc!==t?null:this.audioContext.decodeAudioData(e)).then(e=>{this.currentSrc===t&&(this.buffer=e,this.emit("loadedmetadata"),this.emit("canplay"),this.autoplay&&this.play())})}_play(){var t;if(!this.paused)return;this.paused=!1,(t=this.bufferNode)===null||t===void 0||t.disconnect(),this.bufferNode=this.audioContext.createBufferSource(),this.buffer&&(this.bufferNode.buffer=this.buffer),this.bufferNode.playbackRate.value=this._playbackRate,this.bufferNode.connect(this.gainNode);let e=this.playedDuration*this._playbackRate;e>=this.duration&&(e=0,this.playedDuration=0),this.bufferNode.start(this.audioContext.currentTime,e),this.playStartTime=this.audioContext.currentTime,this.bufferNode.onended=()=>{this.currentTime>=this.duration&&(this.pause(),this.emit("ended"))}}_pause(){var t;this.paused=!0,(t=this.bufferNode)===null||t===void 0||t.stop(),this.playedDuration+=this.audioContext.currentTime-this.playStartTime}play(){return E(this,void 0,void 0,function*(){this.paused&&(this._play(),this.emit("play"))})}pause(){this.paused||(this._pause(),this.emit("pause"))}stopAt(t){var e,i;const r=t-this.currentTime;(e=this.bufferNode)===null||e===void 0||e.stop(this.audioContext.currentTime+r),(i=this.bufferNode)===null||i===void 0||i.addEventListener("ended",()=>{this.bufferNode=null,this.pause()},{once:!0})}setSinkId(t){return E(this,void 0,void 0,function*(){return this.audioContext.setSinkId(t)})}get playbackRate(){return this._playbackRate}set playbackRate(t){this._playbackRate=t,this.bufferNode&&(this.bufferNode.playbackRate.value=t)}get currentTime(){return(this.paused?this.playedDuration:this.playedDuration+(this.audioContext.currentTime-this.playStartTime))*this._playbackRate}set currentTime(t){const e=!this.paused;e&&this._pause(),this.playedDuration=t/this._playbackRate,e&&this._play(),this.emit("seeking"),this.emit("timeupdate")}get duration(){var t,e;return(t=this._duration)!==null&&t!==void 0?t:((e=this.buffer)===null||e===void 0?void 0:e.duration)||0}set duration(t){this._duration=t}get volume(){return this.gainNode.gain.value}set volume(t){this.gainNode.gain.value=t,this.emit("volumechange")}get muted(){return this._muted}set muted(t){this._muted!==t&&(this._muted=t,this._muted?this.gainNode.disconnect():this.gainNode.connect(this.audioContext.destination))}canPlayType(t){return/^(audio|video)\//.test(t)}getGainNode(){return this.gainNode}getChannelData(){const t=[];if(!this.buffer)return t;const e=this.buffer.numberOfChannels;for(let i=0;i<e;i++)t.push(this.buffer.getChannelData(i));return t}}const ve={waveColor:"#999",progressColor:"#555",cursorWidth:1,minPxPerSec:0,fillParent:!0,interact:!0,dragToSeek:!1,autoScroll:!0,autoCenter:!0,sampleRate:8e3};class F extends fe{static create(t){return new F(t)}constructor(t){const e=t.media||(t.backend==="WebAudio"?new gt:void 0);super({media:e,mediaControls:t.mediaControls,autoplay:t.autoplay,playbackRate:t.audioRate}),this.plugins=[],this.decodedData=null,this.subscriptions=[],this.mediaSubscriptions=[],this.abortController=null,this.options=Object.assign({},ve,t),this.timer=new ge;const i=e?void 0:this.getMediaElement();this.renderer=new N(this.options,i),this.initPlayerEvents(),this.initRendererEvents(),this.initTimerEvents(),this.initPlugins();const r=this.options.url||this.getSrc()||"";Promise.resolve().then(()=>{this.emit("init");const{peaks:n,duration:a}=this.options;(r||n&&a)&&this.load(r,n,a).catch(()=>null)})}updateProgress(t=this.getCurrentTime()){return this.renderer.renderProgress(t/this.getDuration(),this.isPlaying()),t}initTimerEvents(){this.subscriptions.push(this.timer.on("tick",()=>{if(!this.isSeeking()){const t=this.updateProgress();this.emit("timeupdate",t),this.emit("audioprocess",t)}}))}initPlayerEvents(){this.isPlaying()&&(this.emit("play"),this.timer.start()),this.mediaSubscriptions.push(this.onMediaEvent("timeupdate",()=>{const t=this.updateProgress();this.emit("timeupdate",t)}),this.onMediaEvent("play",()=>{this.emit("play"),this.timer.start()}),this.onMediaEvent("pause",()=>{this.emit("pause"),this.timer.stop()}),this.onMediaEvent("emptied",()=>{this.timer.stop()}),this.onMediaEvent("ended",()=>{this.emit("finish")}),this.onMediaEvent("seeking",()=>{this.emit("seeking",this.getCurrentTime())}),this.onMediaEvent("error",t=>{this.emit("error",t.error)}))}initRendererEvents(){this.subscriptions.push(this.renderer.on("click",(t,e)=>{this.options.interact&&(this.seekTo(t),this.emit("interaction",t*this.getDuration()),this.emit("click",t,e))}),this.renderer.on("dblclick",(t,e)=>{this.emit("dblclick",t,e)}),this.renderer.on("scroll",(t,e,i,r)=>{const n=this.getDuration();this.emit("scroll",t*n,e*n,i,r)}),this.renderer.on("render",()=>{this.emit("redraw")}),this.renderer.on("rendered",()=>{this.emit("redrawcomplete")}),this.renderer.on("dragstart",t=>{this.emit("dragstart",t)}),this.renderer.on("dragend",t=>{this.emit("dragend",t)}));{let t;this.subscriptions.push(this.renderer.on("drag",e=>{if(!this.options.interact)return;let i;this.renderer.renderProgress(e),clearTimeout(t),this.isPlaying()?i=0:this.options.dragToSeek===!0?i=200:typeof this.options.dragToSeek=="object"&&this.options.dragToSeek!==void 0&&(i=this.options.dragToSeek.debounceTime),t=setTimeout(()=>{this.seekTo(e)},i),this.emit("interaction",e*this.getDuration()),this.emit("drag",e)}))}}initPlugins(){var t;!((t=this.options.plugins)===null||t===void 0)&&t.length&&this.options.plugins.forEach(e=>{this.registerPlugin(e)})}unsubscribePlayerEvents(){this.mediaSubscriptions.forEach(t=>t()),this.mediaSubscriptions=[]}setOptions(t){this.options=Object.assign({},this.options,t),this.renderer.setOptions(this.options),t.audioRate&&this.setPlaybackRate(t.audioRate),t.mediaControls!=null&&(this.getMediaElement().controls=t.mediaControls)}registerPlugin(t){return t._init(this),this.plugins.push(t),this.subscriptions.push(t.once("destroy",()=>{this.plugins=this.plugins.filter(e=>e!==t)})),t}getWrapper(){return this.renderer.getWrapper()}getWidth(){return this.renderer.getWidth()}getScroll(){return this.renderer.getScroll()}setScroll(t){return this.renderer.setScroll(t)}setScrollTime(t){const e=t/this.getDuration();this.renderer.setScrollPercentage(e)}getActivePlugins(){return this.plugins}loadAudio(t,e,i,r){return E(this,void 0,void 0,function*(){var n;if(this.emit("load",t),!this.options.media&&this.isPlaying()&&this.pause(),this.decodedData=null,!e&&!i){const o=this.options.fetchParams||{};window.AbortController&&!o.signal&&(this.abortController=new AbortController,o.signal=(n=this.abortController)===null||n===void 0?void 0:n.signal);const d=c=>this.emit("loading",c);e=yield me.fetchBlob(t,d,o)}this.setSrc(t,e);const a=yield new Promise(o=>{const d=r||this.getDuration();d?o(d):this.mediaSubscriptions.push(this.onMediaEvent("loadedmetadata",()=>o(this.getDuration()),{once:!0}))});if(!t&&!e){const o=this.getMediaElement();o instanceof gt&&(o.duration=a)}if(i)this.decodedData=mt.createBuffer(i,a||0);else if(e){const o=yield e.arrayBuffer();this.decodedData=yield mt.decode(o,this.options.sampleRate)}this.decodedData&&(this.emit("decode",this.getDuration()),this.renderer.render(this.decodedData)),this.emit("ready",this.getDuration())})}load(t,e,i){return E(this,void 0,void 0,function*(){try{return yield this.loadAudio(t,void 0,e,i)}catch(r){throw this.emit("error",r),r}})}loadBlob(t,e,i){return E(this,void 0,void 0,function*(){try{return yield this.loadAudio("",t,e,i)}catch(r){throw this.emit("error",r),r}})}zoom(t){if(!this.decodedData)throw new Error("No audio loaded");this.renderer.zoom(t),this.emit("zoom",t)}getDecodedData(){return this.decodedData}exportPeaks({channels:t=2,maxLength:e=8e3,precision:i=1e4}={}){if(!this.decodedData)throw new Error("The audio has not been decoded yet");const r=Math.min(t,this.decodedData.numberOfChannels),n=[];for(let a=0;a<r;a++){const o=this.decodedData.getChannelData(a),d=[],c=o.length/e;for(let l=0;l<e;l++){const p=o.slice(Math.floor(l*c),Math.ceil((l+1)*c));let h=0;for(let m=0;m<p.length;m++){const f=p[m];Math.abs(f)>Math.abs(h)&&(h=f)}d.push(Math.round(h*i)/i)}n.push(d)}return n}getDuration(){let t=super.getDuration()||0;return t!==0&&t!==1/0||!this.decodedData||(t=this.decodedData.duration),t}toggleInteraction(t){this.options.interact=t}setTime(t){super.setTime(t),this.updateProgress(t),this.emit("timeupdate",t)}seekTo(t){const e=this.getDuration()*t;this.setTime(e)}playPause(){return E(this,void 0,void 0,function*(){return this.isPlaying()?this.pause():this.play()})}stop(){this.pause(),this.setTime(0)}skip(t){this.setTime(this.getCurrentTime()+t)}empty(){this.load("",[[0]],.001)}setMediaElement(t){this.unsubscribePlayerEvents(),super.setMediaElement(t),this.initPlayerEvents()}exportImage(){return E(this,arguments,void 0,function*(t="image/png",e=1,i="dataURL"){return this.renderer.exportImage(t,e,i)})}destroy(){var t;this.emit("destroy"),(t=this.abortController)===null||t===void 0||t.abort(),this.plugins.forEach(e=>e.destroy()),this.subscriptions.forEach(e=>e()),this.unsubscribePlayerEvents(),this.timer.destroy(),this.renderer.destroy(),super.destroy()}}F.BasePlugin=class extends V{constructor(s){super(),this.subscriptions=[],this.options=s}onInit(){}_init(s){this.wavesurfer=s,this.onInit()}destroy(){this.emit("destroy"),this.subscriptions.forEach(s=>s())}},F.dom=pe;function tt(s,t,e,i){return new(e||(e=Promise))(function(r,n){function a(c){try{d(i.next(c))}catch(l){n(l)}}function o(c){try{d(i.throw(c))}catch(l){n(l)}}function d(c){var l;c.done?r(c.value):(l=c.value,l instanceof e?l:new e(function(p){p(l)})).then(a,o)}d((i=i.apply(s,[])).next())})}class Pt{constructor(){this.listeners={}}on(t,e,i){if(this.listeners[t]||(this.listeners[t]=new Set),this.listeners[t].add(e),i==null?void 0:i.once){const r=()=>{this.un(t,r),this.un(t,e)};return this.on(t,r),r}return()=>this.un(t,e)}un(t,e){var i;(i=this.listeners[t])===null||i===void 0||i.delete(e)}once(t,e){return this.on(t,e,{once:!0})}unAll(){this.listeners={}}emit(t,...e){this.listeners[t]&&this.listeners[t].forEach(i=>i(...e))}}class be extends Pt{constructor(t){super(),this.subscriptions=[],this.options=t}onInit(){}_init(t){this.wavesurfer=t,this.onInit()}destroy(){this.emit("destroy"),this.subscriptions.forEach(t=>t())}}class ye extends Pt{constructor(){super(...arguments),this.unsubscribe=()=>{}}start(){this.unsubscribe=this.on("tick",()=>{requestAnimationFrame(()=>{this.emit("tick")})}),this.emit("tick")}stop(){this.unsubscribe()}destroy(){this.unsubscribe()}}const we=["audio/webm","audio/wav","audio/mpeg","audio/mp4","audio/mp3"];class q extends be{constructor(t){var e,i,r,n,a,o;super(Object.assign(Object.assign({},t),{audioBitsPerSecond:(e=t.audioBitsPerSecond)!==null&&e!==void 0?e:128e3,scrollingWaveform:(i=t.scrollingWaveform)!==null&&i!==void 0&&i,scrollingWaveformWindow:(r=t.scrollingWaveformWindow)!==null&&r!==void 0?r:5,continuousWaveform:(n=t.continuousWaveform)!==null&&n!==void 0&&n,renderRecordedAudio:(a=t.renderRecordedAudio)===null||a===void 0||a,mediaRecorderTimeslice:(o=t.mediaRecorderTimeslice)!==null&&o!==void 0?o:void 0})),this.stream=null,this.mediaRecorder=null,this.dataWindow=null,this.isWaveformPaused=!1,this.lastStartTime=0,this.lastDuration=0,this.duration=0,this.timer=new ye,this.subscriptions.push(this.timer.on("tick",()=>{const d=performance.now()-this.lastStartTime;this.duration=this.isPaused()?this.duration:this.lastDuration+d,this.emit("record-progress",this.duration)}))}static create(t){return new q(t||{})}renderMicStream(t){var e;const i=new AudioContext,r=i.createMediaStreamSource(t),n=i.createAnalyser();r.connect(n),this.options.continuousWaveform&&(n.fftSize=32);const a=n.frequencyBinCount,o=new Float32Array(a);let d=0;this.wavesurfer&&((e=this.originalOptions)!==null&&e!==void 0||(this.originalOptions=Object.assign({},this.wavesurfer.options)),this.wavesurfer.options.interact=!1,this.options.scrollingWaveform&&(this.wavesurfer.options.cursorWidth=0));const c=setInterval(()=>{var l,p,h,m;if(!this.isWaveformPaused){if(n.getFloatTimeDomainData(o),this.options.scrollingWaveform){const f=Math.floor((this.options.scrollingWaveformWindow||0)*i.sampleRate),b=Math.min(f,this.dataWindow?this.dataWindow.length+a:a),g=new Float32Array(f);if(this.dataWindow){const w=Math.max(0,f-this.dataWindow.length);g.set(this.dataWindow.slice(-b+a),w)}g.set(o,f-a),this.dataWindow=g}else if(this.options.continuousWaveform){if(!this.dataWindow){const b=this.options.continuousWaveformDuration?Math.round(100*this.options.continuousWaveformDuration):((p=(l=this.wavesurfer)===null||l===void 0?void 0:l.getWidth())!==null&&p!==void 0?p:0)*window.devicePixelRatio;this.dataWindow=new Float32Array(b)}let f=0;for(let b=0;b<a;b++){const g=Math.abs(o[b]);g>f&&(f=g)}if(d+1>this.dataWindow.length){const b=new Float32Array(2*this.dataWindow.length);b.set(this.dataWindow,0),this.dataWindow=b}this.dataWindow[d]=f,d++}else this.dataWindow=o;if(this.wavesurfer){const f=((m=(h=this.dataWindow)===null||h===void 0?void 0:h.length)!==null&&m!==void 0?m:0)/100;this.wavesurfer.load("",[this.dataWindow],this.options.scrollingWaveform?this.options.scrollingWaveformWindow:f).then(()=>{this.wavesurfer&&this.options.continuousWaveform&&(this.wavesurfer.setTime(this.getDuration()/1e3),this.wavesurfer.options.minPxPerSec||this.wavesurfer.setOptions({minPxPerSec:this.wavesurfer.getWidth()/this.wavesurfer.getDuration()}))}).catch(b=>{console.error("Error rendering real-time recording data:",b)})}}},10);return{onDestroy:()=>{clearInterval(c),r==null||r.disconnect(),i==null||i.close()},onEnd:()=>{this.isWaveformPaused=!0,clearInterval(c),this.stopMic()}}}startMic(t){return tt(this,void 0,void 0,function*(){let e;try{e=yield navigator.mediaDevices.getUserMedia({audio:!(t!=null&&t.deviceId)||{deviceId:t.deviceId}})}catch(n){throw new Error("Error accessing the microphone: "+n.message)}const{onDestroy:i,onEnd:r}=this.renderMicStream(e);return this.subscriptions.push(this.once("destroy",i)),this.subscriptions.push(this.once("record-end",r)),this.stream=e,e})}stopMic(){this.stream&&(this.stream.getTracks().forEach(t=>t.stop()),this.stream=null,this.mediaRecorder=null)}startRecording(t){return tt(this,void 0,void 0,function*(){const e=this.stream||(yield this.startMic(t));this.dataWindow=null;const i=this.mediaRecorder||new MediaRecorder(e,{mimeType:this.options.mimeType||we.find(a=>MediaRecorder.isTypeSupported(a)),audioBitsPerSecond:this.options.audioBitsPerSecond});this.mediaRecorder=i,this.stopRecording();const r=[];i.ondataavailable=a=>{a.data.size>0&&r.push(a.data),this.emit("record-data-available",a.data)};const n=a=>{var o;const d=new Blob(r,{type:i.mimeType});this.emit(a,d),this.options.renderRecordedAudio&&(this.applyOriginalOptionsIfNeeded(),(o=this.wavesurfer)===null||o===void 0||o.load(URL.createObjectURL(d)))};i.onpause=()=>n("record-pause"),i.onstop=()=>n("record-end"),i.start(this.options.mediaRecorderTimeslice),this.lastStartTime=performance.now(),this.lastDuration=0,this.duration=0,this.isWaveformPaused=!1,this.timer.start(),this.emit("record-start")})}getDuration(){return this.duration}isRecording(){var t;return((t=this.mediaRecorder)===null||t===void 0?void 0:t.state)==="recording"}isPaused(){var t;return((t=this.mediaRecorder)===null||t===void 0?void 0:t.state)==="paused"}isActive(){var t;return((t=this.mediaRecorder)===null||t===void 0?void 0:t.state)!=="inactive"}stopRecording(){var t;this.isActive()&&((t=this.mediaRecorder)===null||t===void 0||t.stop(),this.timer.stop())}pauseRecording(){var t,e;this.isRecording()&&(this.isWaveformPaused=!0,(t=this.mediaRecorder)===null||t===void 0||t.requestData(),(e=this.mediaRecorder)===null||e===void 0||e.pause(),this.timer.stop(),this.lastDuration=this.duration)}resumeRecording(){var t;this.isPaused()&&(this.isWaveformPaused=!1,(t=this.mediaRecorder)===null||t===void 0||t.resume(),this.timer.start(),this.lastStartTime=performance.now(),this.emit("record-resume"))}static getAvailableAudioDevices(){return tt(this,void 0,void 0,function*(){return navigator.mediaDevices.enumerateDevices().then(t=>t.filter(e=>e.kind==="audioinput"))})}destroy(){this.applyOriginalOptionsIfNeeded(),super.destroy(),this.stopRecording(),this.stopMic()}applyOriginalOptionsIfNeeded(){this.wavesurfer&&this.originalOptions&&(this.wavesurfer.setOptions(this.originalOptions),delete this.originalOptions)}}const Ce=async({files:s,uploadClient:t,widgetMgr:e,widgetInfo:i,fragmentId:r})=>{let n=[];try{n=await t.fetchFileURLs(s)}catch(c){return{successfulUploads:[],failedUploads:s.map(l=>({file:l,error:ut(c)}))}}const a=Ht(s,n),o=[],d=[];return await Promise.all(a.map(async([c,l])=>{if(!c||!l||!l.uploadUrl||!l.fileId)return{file:c,fileUrl:l,error:new Error("No upload URL found")};try{await t.uploadFile({id:l.fileId,formId:i.formId||""},l.uploadUrl,c),o.push({fileUrl:l,file:c})}catch(p){const h=ut(p);d.push({file:c,error:h})}})),e.setFileUploaderStateValue(i,new Vt({uploadedFileInfo:o.map(({file:c,fileUrl:l})=>new jt({fileId:l.fileId,fileUrls:l,name:c.name,size:c.size}))}),{fromUi:!0},r),{successfulUploads:o,failedUploads:d}},et=({widgetMgr:s,id:t,formId:e,key:i,defaultValue:r})=>{u.useEffect(()=>{const l=s.getElementState(t,i);G(l)&&X(r)&&s.setElementState(t,i,r)},[s,t,i,r]);const[n,a]=u.useState(s.getElementState(t,i)??r),o=u.useCallback(l=>{s.setElementState(t,i,l),a(l)},[s,t,i]),d=u.useMemo(()=>({formId:e||""}),[e]),c=u.useCallback(()=>o(r),[r,o]);return oe({element:d,widgetMgr:s,onFormCleared:c}),[n,o]},Se=(s,t)=>{const{libConfig:{enforceDownloadInNewTab:e=!1}}=yt.useContext(Gt);return u.useCallback(()=>{if(!s)return;const r=de({enforceDownloadInNewTab:e,url:s,filename:t});r.style.display="none",document.body.appendChild(r),r.click(),document.body.removeChild(r)},[s,e,t])},Re=x("div",{target:"etzg8g80"})(),vt=x("div",{target:"etzg8g81"})(({theme:s})=>({height:s.sizes.largestElementHeight,width:"100%",background:s.colors.secondaryBg,borderRadius:s.radii.default,marginBottom:s.spacing.twoXS,display:"flex",alignItems:"center",position:"relative",paddingLeft:s.spacing.xs,paddingRight:s.spacing.sm,border:s.colors.widgetBorderColor?`${s.sizes.borderWidth} solid ${s.colors.widgetBorderColor}`:void 0})),Ee=x("div",{target:"etzg8g82"})({flex:1}),xe=x("div",{target:"etzg8g83"})(({show:s})=>({display:s?"block":"none"})),Pe=x("span",{target:"etzg8g84"})(({theme:s,isPlayingOrRecording:t})=>({margin:s.spacing.sm,fontFamily:s.fonts.monospace,color:t?s.colors.bodyText:s.colors.fadedText60,backgroundColor:s.colors.secondaryBg,fontSize:s.fontSizes.sm})),Tt=x("div",{target:"etzg8g85"})({width:"100%",textAlign:"center",overflow:"hidden"}),Dt=x("span",{target:"etzg8g86"})(({theme:s})=>({color:s.colors.bodyText})),Te=x("a",{target:"etzg8g87"})(({theme:s})=>({color:s.colors.link,textDecoration:"underline"})),De=x("div",{target:"etzg8g88"})(({theme:s})=>({height:s.sizes.largestElementHeight,display:"flex",justifyContent:"center",alignItems:"center"})),We=x("div",{target:"etzg8g89"})(({theme:s})=>{const t="0.625em";return{opacity:.2,width:"100%",height:t,backgroundSize:t,backgroundImage:`radial-gradient(${s.colors.fadedText10} 40%, transparent 40%)`,backgroundRepeat:"repeat"}}),Ae=x("span",{target:"etzg8g810"})(({theme:s})=>({"& > button":{color:s.colors.primary,padding:s.spacing.threeXS},"& > button:hover, & > button:focus":{color:s.colors.red}})),ke=x("span",{target:"etzg8g811"})(({theme:s})=>({"& > button":{padding:s.spacing.threeXS,color:s.colors.fadedText40},"& > button:hover, & > button:focus":{color:s.colors.primary}})),Wt=x("span",{target:"etzg8g812"})(({theme:s})=>({"& > button":{padding:s.spacing.threeXS,color:s.colors.fadedText60},"& > button:hover, & > button:focus":{color:s.colors.bodyText}})),it=x("div",{target:"etzg8g813"})(({theme:s})=>({display:"flex",justifyContent:"center",alignItems:"center",flexGrow:0,flexShrink:1,padding:s.spacing.xs,gap:s.spacing.twoXS,marginRight:s.spacing.twoXS})),Me=x("div",{target:"etzg8g814"})(({theme:s})=>({marginLeft:s.spacing.sm})),Ie=x(Xt,{target:"etzg8g815"})(({theme:s})=>({fontSize:s.fontSizes.sm,width:s.sizes.spinnerSize,height:s.sizes.spinnerSize,borderWidth:s.sizes.spinnerThickness,justifyContents:"center",padding:s.spacing.none,margin:s.spacing.none,borderColor:s.colors.borderColor,borderTopColor:s.colors.secondary,flexGrow:0,flexShrink:0})),Le=()=>z(Tt,{children:[v(Dt,{children:"This app would like to use your microphone."})," ",v(Te,{href:qt,children:"Learn how to allow access."})]}),Oe=()=>v(De,{children:v(We,{})}),Be=4,ze=4,Ne=4,Ue=8,Fe=0,j="00:00",bt=s=>new Date(s).toLocaleTimeString(void 0,{minute:"2-digit",second:"2-digit",timeZone:"UTC"}),_=({onClick:s,disabled:t,ariaLabel:e,iconContent:i})=>v(Kt,{kind:Yt.BORDERLESS_ICON,onClick:s,disabled:t,"aria-label":e,fluidWidth:!0,"data-testid":"stAudioInputActionButton",children:v(Jt,{content:i,size:"lg",color:"inherit"})}),_e=({disabled:s,stopRecording:t})=>v(Ae,{children:v(_,{onClick:t,disabled:s,ariaLabel:"Stop recording",iconContent:Et})}),$e=({disabled:s,isPlaying:t,onClickPlayPause:e})=>v(Wt,{children:t?v(_,{onClick:e,disabled:s,ariaLabel:"Pause",iconContent:Ct}):v(_,{onClick:e,disabled:s,ariaLabel:"Play",iconContent:St})}),He=({disabled:s,startRecording:t})=>v(ke,{children:v(_,{onClick:t,disabled:s,ariaLabel:"Record",iconContent:wt})}),Ve=({onClick:s})=>v(Wt,{children:v(_,{disabled:!1,onClick:s,ariaLabel:"Reset",iconContent:Rt})}),je=({disabled:s,isRecording:t,isPlaying:e,isUploading:i,isError:r,recordingUrlExists:n,startRecording:a,stopRecording:o,onClickPlayPause:d,onClear:c})=>r?v(it,{children:v(Ve,{onClick:c})}):i?v(it,{children:v(Ie,{"aria-label":"Uploading"})}):z(it,{children:[t?v(_e,{disabled:s,stopRecording:o}):v(He,{disabled:s,startRecording:a}),n&&v($e,{disabled:s,isPlaying:e,onClickPlayPause:d})]}),Ge=u.memo(je),Xe=Zt.getLogger("convertAudioToWav");async function qe(s){const t=new window.AudioContext,e=await s.arrayBuffer();let i;try{i=await t.decodeAudioData(e)}catch(m){Xe.error(m);return}const r=44,n=i.numberOfChannels,a=i.sampleRate,o=i.length*n*2+r,d=new ArrayBuffer(o),c=new DataView(d),l={0:{type:"string",value:"RIFF"},4:{type:"uint32",value:o-8},8:{type:"string",value:"WAVE"},12:{type:"string",value:"fmt "},16:{type:"uint32",value:16},20:{type:"uint16",value:1},22:{type:"uint16",value:n},24:{type:"uint32",value:a},28:{type:"uint32",value:a*n*2},32:{type:"uint16",value:n*2},34:{type:"uint16",value:16},36:{type:"string",value:"data"},40:{type:"uint32",value:i.length*n*2}};Object.entries(l).forEach(([m,{type:f,value:b}])=>{const g=parseInt(m,10);f==="string"?Ye(c,g,b):f==="uint32"?c.setUint32(g,b,!0):f==="uint16"&&c.setUint16(g,b,!0)});let p=r;for(let m=0;m<i.length;m++)for(let f=0;f<n;f++){const b=Math.max(-1,Math.min(1,i.getChannelData(f)[m]));c.setInt16(p,b*32767,!0),p+=2}const h=new Uint8Array(d);return new Blob([h],{type:"audio/wav"})}function Ye(s,t,e){for(let i=0;i<e.length;i++)s.setUint8(t+i,e.charCodeAt(i))}const Je=()=>v(Tt,{children:v(Dt,{children:"An error has occurred, please try again."})}),Ke=({element:s,uploadClient:t,widgetMgr:e,fragmentId:i,disabled:r})=>{var ht;const n=Qt(),a=ce(n),[o,d]=u.useState(null),c=yt.useRef(null),[l,p]=et({widgetMgr:e,id:s.id,key:"deleteFileUrl",defaultValue:null}),[h,m]=u.useState(null),[f,b]=u.useState([]),[g,w]=u.useState(null),[y,P]=et({widgetMgr:e,id:s.id,key:"recordingUrl",defaultValue:null}),[,T]=u.useState(0),C=()=>{T(S=>S+1)},[D,W]=u.useState(j),[M,A]=et({widgetMgr:e,id:s.id,formId:s.formId,key:"recordingTime",defaultValue:j}),[I,U]=u.useState(!1),[O,At]=u.useState(!1),[st,kt]=u.useState(!1),[Mt,nt]=u.useState(!1),[Y,J]=u.useState(!1),rt=s.id,L=s.formId,ot=u.useCallback(async S=>{nt(!0),X(L)&&e.setFormsWithUploadsInProgress(new Set([L]));let R;if(S.type==="audio/wav"?R=S:R=await qe(S),!R){J(!0);return}const k=URL.createObjectURL(R),Ut=new Date().toISOString().slice(0,16).replace(":","-"),Ft=new File([R],`${Ut}_audio.wav`,{type:R.type});P(k),Ce({files:[Ft],uploadClient:t,widgetMgr:e,widgetInfo:{id:rt,formId:L},fragmentId:i}).then(({successfulUploads:_t,failedUploads:$t})=>{if($t.length>0){J(!0);return}const Z=_t[0];Z&&Z.fileUrl.deleteUrl&&p(Z.fileUrl.deleteUrl)}).finally(()=>{X(L)&&e.setFormsWithUploadsInProgress(new Set),nt(!1)})},[P,t,e,rt,L,i,p]),B=u.useCallback(({updateWidgetManager:S,deleteFile:R})=>{G(o)||G(l)||(P(null),o.empty(),R&&t.deleteFile(l),p(null),W(j),A(j),S&&e.setFileUploaderStateValue(s,{},{fromUi:!0},i),U(!1),X(y)&&URL.revokeObjectURL(y))},[l,y,t,o,s,e,i,A,P,p]);u.useEffect(()=>{if(G(L))return;const S=new ae;return S.manageFormClearListener(e,L,()=>B({updateWidgetManager:!0,deleteFile:!1})),()=>S.disconnect()},[L,B,e]);const at=u.useCallback(()=>{if(c.current===null)return;const S=F.create({container:c.current,waveColor:y?Q(n.colors.fadedText40,n.colors.secondaryBg):n.colors.primary,progressColor:n.colors.bodyText,height:te(n.sizes.largestElementHeight)-2*Be,barWidth:ze,barGap:Ne,barRadius:Ue,cursorWidth:Fe,url:y??void 0});S.on("timeupdate",k=>{W(bt(k*1e3))}),S.on("pause",()=>{C()});const R=S.registerPlugin(q.create({scrollingWaveform:!1,renderRecordedAudio:!0}));return R.on("record-end",async k=>{ot(k)}),R.on("record-progress",k=>{A(bt(k))}),d(S),m(R),()=>{S&&S.destroy(),R&&R.destroy()}},[ot]);u.useEffect(()=>at(),[at]),u.useEffect(()=>{ee(a,n)||o==null||o.setOptions({waveColor:y?Q(n.colors.fadedText40,n.colors.secondaryBg):n.colors.primary,progressColor:n.colors.bodyText})},[n,a,y,o]);const It=u.useCallback(()=>{o&&(o.playPause(),U(!0),C())},[o]),Lt=u.useCallback(async()=>{let S=g;st||(await navigator.mediaDevices.getUserMedia({audio:!0}).then(()=>q.getAvailableAudioDevices().then(R=>{if(b(R),R.length>0){const{deviceId:k}=R[0];w(k),S=k}})).catch(R=>{At(!0)}),kt(!0)),!(!h||!S||!o)&&(o.setOptions({waveColor:n.colors.primary}),y&&B({updateWidgetManager:!1,deleteFile:!0}),h.startRecording({deviceId:S}).then(()=>{C()}))},[g,h,n,o,y,B,st]),Ot=u.useCallback(()=>{h&&(h.stopRecording(),o==null||o.setOptions({waveColor:Q(n.colors.fadedText40,n.colors.secondaryBg)}))},[h,o,n]),Bt=Se(y,"recording.wav"),K=!!(h!=null&&h.isRecording()),lt=!!(o!=null&&o.isPlaying()),zt=K||lt,ct=!K&&!y&&!O,Nt=O||ct||Y,dt=r||O;return z(Re,{className:"stAudioInput","data-testid":"stAudioInput",children:[v(re,{label:s.label,disabled:dt,labelVisibility:ie((ht=s.labelVisibility)==null?void 0:ht.value),children:s.help&&v(Me,{children:v(se,{content:s.help,placement:ne.TOP})})}),z(vt,{children:[z(le,{isFullScreen:!1,disableFullscreenMode:!0,target:vt,children:[y&&v(pt,{label:"Download as WAV",icon:he,onClick:()=>Bt()}),l&&v(pt,{label:"Clear recording",icon:ue,onClick:()=>B({updateWidgetManager:!0,deleteFile:!0})})]}),v(Ge,{isRecording:K,isPlaying:lt,isUploading:Mt,isError:Y,recordingUrlExists:!!y,startRecording:Lt,stopRecording:Ot,onClickPlayPause:It,onClear:()=>{B({updateWidgetManager:!1,deleteFile:!0}),J(!1)},disabled:dt}),z(Ee,{children:[Y&&v(Je,{}),ct&&v(Oe,{}),O&&v(Le,{}),v(xe,{"data-testid":"stAudioInputWaveSurfer",ref:c,show:!Nt})]}),v(Pe,{isPlayingOrRecording:zt,"data-testid":"stAudioInputWaveformTimeCode",children:I?D:M})]})]})},ri=u.memo(Ke);export{ri as default};
|
73
|
+
`,[t,e]}setOptions(t){if(this.options.container!==t.container){const e=this.parentFromOptionsContainer(t.container);e.appendChild(this.container),this.parent=e}t.dragToSeek!==!0&&typeof this.options.dragToSeek!="object"||this.initDrag(),this.options=t,this.reRender()}getWrapper(){return this.wrapper}getWidth(){return this.scrollContainer.clientWidth}getScroll(){return this.scrollContainer.scrollLeft}setScroll(t){this.scrollContainer.scrollLeft=t}setScrollPercentage(t){const{scrollWidth:e}=this.scrollContainer,i=e*t;this.setScroll(i)}destroy(){var t,e;this.subscriptions.forEach(i=>i()),this.container.remove(),(t=this.resizeObserver)===null||t===void 0||t.disconnect(),(e=this.unsubscribeOnScroll)===null||e===void 0||e.call(this)}createDelay(t=10){let e,i;const r=()=>{e&&clearTimeout(e),i&&i()};return this.timeouts.push(r),()=>new Promise((n,a)=>{r(),i=a,e=setTimeout(()=>{e=void 0,i=void 0,n()},t)})}convertColorValues(t){if(!Array.isArray(t))return t||"";if(t.length<2)return t[0]||"";const e=document.createElement("canvas"),i=e.getContext("2d"),r=e.height*(window.devicePixelRatio||1),n=i.createLinearGradient(0,0,0,r),a=1/(t.length-1);return t.forEach((o,d)=>{const c=d*a;n.addColorStop(c,o)}),n}getPixelRatio(){return Math.max(1,window.devicePixelRatio||1)}renderBarWaveform(t,e,i,r){const n=t[0],a=t[1]||t[0],o=n.length,{width:d,height:c}=i.canvas,l=c/2,p=this.getPixelRatio(),h=e.barWidth?e.barWidth*p:1,m=e.barGap?e.barGap*p:e.barWidth?h/2:0,f=e.barRadius||0,b=d/(h+m)/o,g=f&&"roundRect"in i?"roundRect":"rect";i.beginPath();let w=0,y=0,P=0;for(let T=0;T<=o;T++){const C=Math.round(T*b);if(C>w){const M=Math.round(y*l*r),A=M+Math.round(P*l*r)||1;let I=l-M;e.barAlign==="top"?I=0:e.barAlign==="bottom"&&(I=c-A),i[g](w*(h+m),I,h,A,f),w=C,y=0,P=0}const D=Math.abs(n[T]||0),W=Math.abs(a[T]||0);D>y&&(y=D),W>P&&(P=W)}i.fill(),i.closePath()}renderLineWaveform(t,e,i,r){const n=a=>{const o=t[a]||t[0],d=o.length,{height:c}=i.canvas,l=c/2,p=i.canvas.width/d;i.moveTo(0,l);let h=0,m=0;for(let f=0;f<=d;f++){const b=Math.round(f*p);if(b>h){const w=l+(Math.round(m*l*r)||1)*(a===0?-1:1);i.lineTo(h,w),h=b,m=0}const g=Math.abs(o[f]||0);g>m&&(m=g)}i.lineTo(h,l)};i.beginPath(),n(0),n(1),i.fill(),i.closePath()}renderWaveform(t,e,i){if(i.fillStyle=this.convertColorValues(e.waveColor),e.renderFunction)return void e.renderFunction(t,i);let r=e.barHeight||1;if(e.normalize){const n=Array.from(t[0]).reduce((a,o)=>Math.max(a,Math.abs(o)),0);r=n?1/n:1}e.barWidth||e.barGap||e.barAlign?this.renderBarWaveform(t,e,i,r):this.renderLineWaveform(t,e,i,r)}renderSingleCanvas(t,e,i,r,n,a,o){const d=this.getPixelRatio(),c=document.createElement("canvas");c.width=Math.round(i*d),c.height=Math.round(r*d),c.style.width=`${i}px`,c.style.height=`${r}px`,c.style.left=`${Math.round(n)}px`,a.appendChild(c);const l=c.getContext("2d");if(this.renderWaveform(t,e,l),c.width>0&&c.height>0){const p=c.cloneNode(),h=p.getContext("2d");h.drawImage(c,0,0),h.globalCompositeOperation="source-in",h.fillStyle=this.convertColorValues(e.progressColor),h.fillRect(0,0,c.width,c.height),o.appendChild(p)}}renderMultiCanvas(t,e,i,r,n,a){const o=this.getPixelRatio(),{clientWidth:d}=this.scrollContainer,c=i/o;let l=Math.min(N.MAX_CANVAS_WIDTH,d,c),p={};if(e.barWidth||e.barGap){const g=e.barWidth||.5,w=g+(e.barGap||g/2);l%w!=0&&(l=Math.floor(l/w)*w)}const h=g=>{if(g<0||g>=m||p[g])return;p[g]=!0;const w=g*l,y=Math.min(c-w,l);if(y<=0)return;const P=t.map(T=>{const C=Math.floor(w/c*T.length),D=Math.floor((w+y)/c*T.length);return T.slice(C,D)});this.renderSingleCanvas(P,e,y,r,w,n,a)},m=Math.ceil(c/l);if(!this.isScrollable){for(let g=0;g<m;g++)h(g);return}const f=this.scrollContainer.scrollLeft/c,b=Math.floor(f*m);h(b-1),h(b),h(b+1),m>1&&(this.unsubscribeOnScroll=this.on("scroll",()=>{const{scrollLeft:g}=this.scrollContainer,w=Math.floor(g/c*m);Object.keys(p).length>N.MAX_NODES&&(n.innerHTML="",a.innerHTML="",p={}),h(w-1),h(w),h(w+1)}))}renderChannel(t,e,i,r){var{overlay:n}=e,a=function(l,p){var h={};for(var m in l)Object.prototype.hasOwnProperty.call(l,m)&&p.indexOf(m)<0&&(h[m]=l[m]);if(l!=null&&typeof Object.getOwnPropertySymbols=="function"){var f=0;for(m=Object.getOwnPropertySymbols(l);f<m.length;f++)p.indexOf(m[f])<0&&Object.prototype.propertyIsEnumerable.call(l,m[f])&&(h[m[f]]=l[m[f]])}return h}(e,["overlay"]);const o=document.createElement("div"),d=this.getHeight(a.height,a.splitChannels);o.style.height=`${d}px`,n&&r>0&&(o.style.marginTop=`-${d}px`),this.canvasWrapper.style.minHeight=`${d}px`,this.canvasWrapper.appendChild(o);const c=o.cloneNode();this.progressWrapper.appendChild(c),this.renderMultiCanvas(t,a,i,d,o,c)}render(t){return E(this,void 0,void 0,function*(){var e;this.timeouts.forEach(d=>d()),this.timeouts=[],this.canvasWrapper.innerHTML="",this.progressWrapper.innerHTML="",this.options.width!=null&&(this.scrollContainer.style.width=typeof this.options.width=="number"?`${this.options.width}px`:this.options.width);const i=this.getPixelRatio(),r=this.scrollContainer.clientWidth,n=Math.ceil(t.duration*(this.options.minPxPerSec||0));this.isScrollable=n>r;const a=this.options.fillParent&&!this.isScrollable,o=(a?r:n)*i;if(this.wrapper.style.width=a?"100%":`${n}px`,this.scrollContainer.style.overflowX=this.isScrollable?"auto":"hidden",this.scrollContainer.classList.toggle("noScrollbar",!!this.options.hideScrollbar),this.cursor.style.backgroundColor=`${this.options.cursorColor||this.options.progressColor}`,this.cursor.style.width=`${this.options.cursorWidth}px`,this.audioData=t,this.emit("render"),this.options.splitChannels)for(let d=0;d<t.numberOfChannels;d++){const c=Object.assign(Object.assign({},this.options),(e=this.options.splitChannels)===null||e===void 0?void 0:e[d]);this.renderChannel([t.getChannelData(d)],c,o,d)}else{const d=[t.getChannelData(0)];t.numberOfChannels>1&&d.push(t.getChannelData(1)),this.renderChannel(d,this.options,o,0)}Promise.resolve().then(()=>this.emit("rendered"))})}reRender(){var t;if((t=this.unsubscribeOnScroll)===null||t===void 0||t.call(this),delete this.unsubscribeOnScroll,!this.audioData)return;const{scrollWidth:e}=this.scrollContainer,{right:i}=this.progressWrapper.getBoundingClientRect();if(this.render(this.audioData),this.isScrollable&&e!==this.scrollContainer.scrollWidth){const{right:r}=this.progressWrapper.getBoundingClientRect();let n=r-i;n*=2,n=n<0?Math.floor(n):Math.ceil(n),n/=2,this.scrollContainer.scrollLeft+=n}}zoom(t){this.options.minPxPerSec=t,this.reRender()}scrollIntoView(t,e=!1){const{scrollLeft:i,scrollWidth:r,clientWidth:n}=this.scrollContainer,a=t*r,o=i,d=i+n,c=n/2;if(this.isDragging)a+30>d?this.scrollContainer.scrollLeft+=30:a-30<o&&(this.scrollContainer.scrollLeft-=30);else{(a<o||a>d)&&(this.scrollContainer.scrollLeft=a-(this.options.autoCenter?c:0));const l=a-i-c;e&&this.options.autoCenter&&l>0&&(this.scrollContainer.scrollLeft+=Math.min(l,10))}{const l=this.scrollContainer.scrollLeft,p=l/r,h=(l+n)/r;this.emit("scroll",p,h,l,l+n)}}renderProgress(t,e){if(isNaN(t))return;const i=100*t;this.canvasWrapper.style.clipPath=`polygon(${i}% 0, 100% 0, 100% 100%, ${i}% 100%)`,this.progressWrapper.style.width=`${i}%`,this.cursor.style.left=`${i}%`,this.cursor.style.transform=`translateX(-${Math.round(i)===100?this.options.cursorWidth:0}px)`,this.isScrollable&&this.options.autoScroll&&this.scrollIntoView(t,e)}exportImage(t,e,i){return E(this,void 0,void 0,function*(){const r=this.canvasWrapper.querySelectorAll("canvas");if(!r.length)throw new Error("No waveform data");if(i==="dataURL"){const n=Array.from(r).map(a=>a.toDataURL(t,e));return Promise.resolve(n)}return Promise.all(Array.from(r).map(n=>new Promise((a,o)=>{n.toBlob(d=>{d?a(d):o(new Error("Could not export image"))},t,e)})))})}}N.MAX_CANVAS_WIDTH=8e3,N.MAX_NODES=10;class ge extends V{constructor(){super(...arguments),this.unsubscribe=()=>{}}start(){this.unsubscribe=this.on("tick",()=>{requestAnimationFrame(()=>{this.emit("tick")})}),this.emit("tick")}stop(){this.unsubscribe()}destroy(){this.unsubscribe()}}class gt extends V{constructor(t=new AudioContext){super(),this.bufferNode=null,this.playStartTime=0,this.playedDuration=0,this._muted=!1,this._playbackRate=1,this._duration=void 0,this.buffer=null,this.currentSrc="",this.paused=!0,this.crossOrigin=null,this.seeking=!1,this.autoplay=!1,this.addEventListener=this.on,this.removeEventListener=this.un,this.audioContext=t,this.gainNode=this.audioContext.createGain(),this.gainNode.connect(this.audioContext.destination)}load(){return E(this,void 0,void 0,function*(){})}get src(){return this.currentSrc}set src(t){if(this.currentSrc=t,this._duration=void 0,!t)return this.buffer=null,void this.emit("emptied");fetch(t).then(e=>{if(e.status>=400)throw new Error(`Failed to fetch ${t}: ${e.status} (${e.statusText})`);return e.arrayBuffer()}).then(e=>this.currentSrc!==t?null:this.audioContext.decodeAudioData(e)).then(e=>{this.currentSrc===t&&(this.buffer=e,this.emit("loadedmetadata"),this.emit("canplay"),this.autoplay&&this.play())})}_play(){var t;if(!this.paused)return;this.paused=!1,(t=this.bufferNode)===null||t===void 0||t.disconnect(),this.bufferNode=this.audioContext.createBufferSource(),this.buffer&&(this.bufferNode.buffer=this.buffer),this.bufferNode.playbackRate.value=this._playbackRate,this.bufferNode.connect(this.gainNode);let e=this.playedDuration*this._playbackRate;e>=this.duration&&(e=0,this.playedDuration=0),this.bufferNode.start(this.audioContext.currentTime,e),this.playStartTime=this.audioContext.currentTime,this.bufferNode.onended=()=>{this.currentTime>=this.duration&&(this.pause(),this.emit("ended"))}}_pause(){var t;this.paused=!0,(t=this.bufferNode)===null||t===void 0||t.stop(),this.playedDuration+=this.audioContext.currentTime-this.playStartTime}play(){return E(this,void 0,void 0,function*(){this.paused&&(this._play(),this.emit("play"))})}pause(){this.paused||(this._pause(),this.emit("pause"))}stopAt(t){var e,i;const r=t-this.currentTime;(e=this.bufferNode)===null||e===void 0||e.stop(this.audioContext.currentTime+r),(i=this.bufferNode)===null||i===void 0||i.addEventListener("ended",()=>{this.bufferNode=null,this.pause()},{once:!0})}setSinkId(t){return E(this,void 0,void 0,function*(){return this.audioContext.setSinkId(t)})}get playbackRate(){return this._playbackRate}set playbackRate(t){this._playbackRate=t,this.bufferNode&&(this.bufferNode.playbackRate.value=t)}get currentTime(){return(this.paused?this.playedDuration:this.playedDuration+(this.audioContext.currentTime-this.playStartTime))*this._playbackRate}set currentTime(t){const e=!this.paused;e&&this._pause(),this.playedDuration=t/this._playbackRate,e&&this._play(),this.emit("seeking"),this.emit("timeupdate")}get duration(){var t,e;return(t=this._duration)!==null&&t!==void 0?t:((e=this.buffer)===null||e===void 0?void 0:e.duration)||0}set duration(t){this._duration=t}get volume(){return this.gainNode.gain.value}set volume(t){this.gainNode.gain.value=t,this.emit("volumechange")}get muted(){return this._muted}set muted(t){this._muted!==t&&(this._muted=t,this._muted?this.gainNode.disconnect():this.gainNode.connect(this.audioContext.destination))}canPlayType(t){return/^(audio|video)\//.test(t)}getGainNode(){return this.gainNode}getChannelData(){const t=[];if(!this.buffer)return t;const e=this.buffer.numberOfChannels;for(let i=0;i<e;i++)t.push(this.buffer.getChannelData(i));return t}}const ve={waveColor:"#999",progressColor:"#555",cursorWidth:1,minPxPerSec:0,fillParent:!0,interact:!0,dragToSeek:!1,autoScroll:!0,autoCenter:!0,sampleRate:8e3};class F extends fe{static create(t){return new F(t)}constructor(t){const e=t.media||(t.backend==="WebAudio"?new gt:void 0);super({media:e,mediaControls:t.mediaControls,autoplay:t.autoplay,playbackRate:t.audioRate}),this.plugins=[],this.decodedData=null,this.subscriptions=[],this.mediaSubscriptions=[],this.abortController=null,this.options=Object.assign({},ve,t),this.timer=new ge;const i=e?void 0:this.getMediaElement();this.renderer=new N(this.options,i),this.initPlayerEvents(),this.initRendererEvents(),this.initTimerEvents(),this.initPlugins();const r=this.options.url||this.getSrc()||"";Promise.resolve().then(()=>{this.emit("init");const{peaks:n,duration:a}=this.options;(r||n&&a)&&this.load(r,n,a).catch(()=>null)})}updateProgress(t=this.getCurrentTime()){return this.renderer.renderProgress(t/this.getDuration(),this.isPlaying()),t}initTimerEvents(){this.subscriptions.push(this.timer.on("tick",()=>{if(!this.isSeeking()){const t=this.updateProgress();this.emit("timeupdate",t),this.emit("audioprocess",t)}}))}initPlayerEvents(){this.isPlaying()&&(this.emit("play"),this.timer.start()),this.mediaSubscriptions.push(this.onMediaEvent("timeupdate",()=>{const t=this.updateProgress();this.emit("timeupdate",t)}),this.onMediaEvent("play",()=>{this.emit("play"),this.timer.start()}),this.onMediaEvent("pause",()=>{this.emit("pause"),this.timer.stop()}),this.onMediaEvent("emptied",()=>{this.timer.stop()}),this.onMediaEvent("ended",()=>{this.emit("finish")}),this.onMediaEvent("seeking",()=>{this.emit("seeking",this.getCurrentTime())}),this.onMediaEvent("error",t=>{this.emit("error",t.error)}))}initRendererEvents(){this.subscriptions.push(this.renderer.on("click",(t,e)=>{this.options.interact&&(this.seekTo(t),this.emit("interaction",t*this.getDuration()),this.emit("click",t,e))}),this.renderer.on("dblclick",(t,e)=>{this.emit("dblclick",t,e)}),this.renderer.on("scroll",(t,e,i,r)=>{const n=this.getDuration();this.emit("scroll",t*n,e*n,i,r)}),this.renderer.on("render",()=>{this.emit("redraw")}),this.renderer.on("rendered",()=>{this.emit("redrawcomplete")}),this.renderer.on("dragstart",t=>{this.emit("dragstart",t)}),this.renderer.on("dragend",t=>{this.emit("dragend",t)}));{let t;this.subscriptions.push(this.renderer.on("drag",e=>{if(!this.options.interact)return;let i;this.renderer.renderProgress(e),clearTimeout(t),this.isPlaying()?i=0:this.options.dragToSeek===!0?i=200:typeof this.options.dragToSeek=="object"&&this.options.dragToSeek!==void 0&&(i=this.options.dragToSeek.debounceTime),t=setTimeout(()=>{this.seekTo(e)},i),this.emit("interaction",e*this.getDuration()),this.emit("drag",e)}))}}initPlugins(){var t;!((t=this.options.plugins)===null||t===void 0)&&t.length&&this.options.plugins.forEach(e=>{this.registerPlugin(e)})}unsubscribePlayerEvents(){this.mediaSubscriptions.forEach(t=>t()),this.mediaSubscriptions=[]}setOptions(t){this.options=Object.assign({},this.options,t),this.renderer.setOptions(this.options),t.audioRate&&this.setPlaybackRate(t.audioRate),t.mediaControls!=null&&(this.getMediaElement().controls=t.mediaControls)}registerPlugin(t){return t._init(this),this.plugins.push(t),this.subscriptions.push(t.once("destroy",()=>{this.plugins=this.plugins.filter(e=>e!==t)})),t}getWrapper(){return this.renderer.getWrapper()}getWidth(){return this.renderer.getWidth()}getScroll(){return this.renderer.getScroll()}setScroll(t){return this.renderer.setScroll(t)}setScrollTime(t){const e=t/this.getDuration();this.renderer.setScrollPercentage(e)}getActivePlugins(){return this.plugins}loadAudio(t,e,i,r){return E(this,void 0,void 0,function*(){var n;if(this.emit("load",t),!this.options.media&&this.isPlaying()&&this.pause(),this.decodedData=null,!e&&!i){const o=this.options.fetchParams||{};window.AbortController&&!o.signal&&(this.abortController=new AbortController,o.signal=(n=this.abortController)===null||n===void 0?void 0:n.signal);const d=c=>this.emit("loading",c);e=yield me.fetchBlob(t,d,o)}this.setSrc(t,e);const a=yield new Promise(o=>{const d=r||this.getDuration();d?o(d):this.mediaSubscriptions.push(this.onMediaEvent("loadedmetadata",()=>o(this.getDuration()),{once:!0}))});if(!t&&!e){const o=this.getMediaElement();o instanceof gt&&(o.duration=a)}if(i)this.decodedData=mt.createBuffer(i,a||0);else if(e){const o=yield e.arrayBuffer();this.decodedData=yield mt.decode(o,this.options.sampleRate)}this.decodedData&&(this.emit("decode",this.getDuration()),this.renderer.render(this.decodedData)),this.emit("ready",this.getDuration())})}load(t,e,i){return E(this,void 0,void 0,function*(){try{return yield this.loadAudio(t,void 0,e,i)}catch(r){throw this.emit("error",r),r}})}loadBlob(t,e,i){return E(this,void 0,void 0,function*(){try{return yield this.loadAudio("",t,e,i)}catch(r){throw this.emit("error",r),r}})}zoom(t){if(!this.decodedData)throw new Error("No audio loaded");this.renderer.zoom(t),this.emit("zoom",t)}getDecodedData(){return this.decodedData}exportPeaks({channels:t=2,maxLength:e=8e3,precision:i=1e4}={}){if(!this.decodedData)throw new Error("The audio has not been decoded yet");const r=Math.min(t,this.decodedData.numberOfChannels),n=[];for(let a=0;a<r;a++){const o=this.decodedData.getChannelData(a),d=[],c=o.length/e;for(let l=0;l<e;l++){const p=o.slice(Math.floor(l*c),Math.ceil((l+1)*c));let h=0;for(let m=0;m<p.length;m++){const f=p[m];Math.abs(f)>Math.abs(h)&&(h=f)}d.push(Math.round(h*i)/i)}n.push(d)}return n}getDuration(){let t=super.getDuration()||0;return t!==0&&t!==1/0||!this.decodedData||(t=this.decodedData.duration),t}toggleInteraction(t){this.options.interact=t}setTime(t){super.setTime(t),this.updateProgress(t),this.emit("timeupdate",t)}seekTo(t){const e=this.getDuration()*t;this.setTime(e)}playPause(){return E(this,void 0,void 0,function*(){return this.isPlaying()?this.pause():this.play()})}stop(){this.pause(),this.setTime(0)}skip(t){this.setTime(this.getCurrentTime()+t)}empty(){this.load("",[[0]],.001)}setMediaElement(t){this.unsubscribePlayerEvents(),super.setMediaElement(t),this.initPlayerEvents()}exportImage(){return E(this,arguments,void 0,function*(t="image/png",e=1,i="dataURL"){return this.renderer.exportImage(t,e,i)})}destroy(){var t;this.emit("destroy"),(t=this.abortController)===null||t===void 0||t.abort(),this.plugins.forEach(e=>e.destroy()),this.subscriptions.forEach(e=>e()),this.unsubscribePlayerEvents(),this.timer.destroy(),this.renderer.destroy(),super.destroy()}}F.BasePlugin=class extends V{constructor(s){super(),this.subscriptions=[],this.options=s}onInit(){}_init(s){this.wavesurfer=s,this.onInit()}destroy(){this.emit("destroy"),this.subscriptions.forEach(s=>s())}},F.dom=pe;function tt(s,t,e,i){return new(e||(e=Promise))(function(r,n){function a(c){try{d(i.next(c))}catch(l){n(l)}}function o(c){try{d(i.throw(c))}catch(l){n(l)}}function d(c){var l;c.done?r(c.value):(l=c.value,l instanceof e?l:new e(function(p){p(l)})).then(a,o)}d((i=i.apply(s,[])).next())})}class Pt{constructor(){this.listeners={}}on(t,e,i){if(this.listeners[t]||(this.listeners[t]=new Set),this.listeners[t].add(e),i==null?void 0:i.once){const r=()=>{this.un(t,r),this.un(t,e)};return this.on(t,r),r}return()=>this.un(t,e)}un(t,e){var i;(i=this.listeners[t])===null||i===void 0||i.delete(e)}once(t,e){return this.on(t,e,{once:!0})}unAll(){this.listeners={}}emit(t,...e){this.listeners[t]&&this.listeners[t].forEach(i=>i(...e))}}class be extends Pt{constructor(t){super(),this.subscriptions=[],this.options=t}onInit(){}_init(t){this.wavesurfer=t,this.onInit()}destroy(){this.emit("destroy"),this.subscriptions.forEach(t=>t())}}class ye extends Pt{constructor(){super(...arguments),this.unsubscribe=()=>{}}start(){this.unsubscribe=this.on("tick",()=>{requestAnimationFrame(()=>{this.emit("tick")})}),this.emit("tick")}stop(){this.unsubscribe()}destroy(){this.unsubscribe()}}const we=["audio/webm","audio/wav","audio/mpeg","audio/mp4","audio/mp3"];class q extends be{constructor(t){var e,i,r,n,a,o;super(Object.assign(Object.assign({},t),{audioBitsPerSecond:(e=t.audioBitsPerSecond)!==null&&e!==void 0?e:128e3,scrollingWaveform:(i=t.scrollingWaveform)!==null&&i!==void 0&&i,scrollingWaveformWindow:(r=t.scrollingWaveformWindow)!==null&&r!==void 0?r:5,continuousWaveform:(n=t.continuousWaveform)!==null&&n!==void 0&&n,renderRecordedAudio:(a=t.renderRecordedAudio)===null||a===void 0||a,mediaRecorderTimeslice:(o=t.mediaRecorderTimeslice)!==null&&o!==void 0?o:void 0})),this.stream=null,this.mediaRecorder=null,this.dataWindow=null,this.isWaveformPaused=!1,this.lastStartTime=0,this.lastDuration=0,this.duration=0,this.timer=new ye,this.subscriptions.push(this.timer.on("tick",()=>{const d=performance.now()-this.lastStartTime;this.duration=this.isPaused()?this.duration:this.lastDuration+d,this.emit("record-progress",this.duration)}))}static create(t){return new q(t||{})}renderMicStream(t){var e;const i=new AudioContext,r=i.createMediaStreamSource(t),n=i.createAnalyser();r.connect(n),this.options.continuousWaveform&&(n.fftSize=32);const a=n.frequencyBinCount,o=new Float32Array(a);let d=0;this.wavesurfer&&((e=this.originalOptions)!==null&&e!==void 0||(this.originalOptions=Object.assign({},this.wavesurfer.options)),this.wavesurfer.options.interact=!1,this.options.scrollingWaveform&&(this.wavesurfer.options.cursorWidth=0));const c=setInterval(()=>{var l,p,h,m;if(!this.isWaveformPaused){if(n.getFloatTimeDomainData(o),this.options.scrollingWaveform){const f=Math.floor((this.options.scrollingWaveformWindow||0)*i.sampleRate),b=Math.min(f,this.dataWindow?this.dataWindow.length+a:a),g=new Float32Array(f);if(this.dataWindow){const w=Math.max(0,f-this.dataWindow.length);g.set(this.dataWindow.slice(-b+a),w)}g.set(o,f-a),this.dataWindow=g}else if(this.options.continuousWaveform){if(!this.dataWindow){const b=this.options.continuousWaveformDuration?Math.round(100*this.options.continuousWaveformDuration):((p=(l=this.wavesurfer)===null||l===void 0?void 0:l.getWidth())!==null&&p!==void 0?p:0)*window.devicePixelRatio;this.dataWindow=new Float32Array(b)}let f=0;for(let b=0;b<a;b++){const g=Math.abs(o[b]);g>f&&(f=g)}if(d+1>this.dataWindow.length){const b=new Float32Array(2*this.dataWindow.length);b.set(this.dataWindow,0),this.dataWindow=b}this.dataWindow[d]=f,d++}else this.dataWindow=o;if(this.wavesurfer){const f=((m=(h=this.dataWindow)===null||h===void 0?void 0:h.length)!==null&&m!==void 0?m:0)/100;this.wavesurfer.load("",[this.dataWindow],this.options.scrollingWaveform?this.options.scrollingWaveformWindow:f).then(()=>{this.wavesurfer&&this.options.continuousWaveform&&(this.wavesurfer.setTime(this.getDuration()/1e3),this.wavesurfer.options.minPxPerSec||this.wavesurfer.setOptions({minPxPerSec:this.wavesurfer.getWidth()/this.wavesurfer.getDuration()}))}).catch(b=>{console.error("Error rendering real-time recording data:",b)})}}},10);return{onDestroy:()=>{clearInterval(c),r==null||r.disconnect(),i==null||i.close()},onEnd:()=>{this.isWaveformPaused=!0,clearInterval(c),this.stopMic()}}}startMic(t){return tt(this,void 0,void 0,function*(){let e;try{e=yield navigator.mediaDevices.getUserMedia({audio:!(t!=null&&t.deviceId)||{deviceId:t.deviceId}})}catch(n){throw new Error("Error accessing the microphone: "+n.message)}const{onDestroy:i,onEnd:r}=this.renderMicStream(e);return this.subscriptions.push(this.once("destroy",i)),this.subscriptions.push(this.once("record-end",r)),this.stream=e,e})}stopMic(){this.stream&&(this.stream.getTracks().forEach(t=>t.stop()),this.stream=null,this.mediaRecorder=null)}startRecording(t){return tt(this,void 0,void 0,function*(){const e=this.stream||(yield this.startMic(t));this.dataWindow=null;const i=this.mediaRecorder||new MediaRecorder(e,{mimeType:this.options.mimeType||we.find(a=>MediaRecorder.isTypeSupported(a)),audioBitsPerSecond:this.options.audioBitsPerSecond});this.mediaRecorder=i,this.stopRecording();const r=[];i.ondataavailable=a=>{a.data.size>0&&r.push(a.data),this.emit("record-data-available",a.data)};const n=a=>{var o;const d=new Blob(r,{type:i.mimeType});this.emit(a,d),this.options.renderRecordedAudio&&(this.applyOriginalOptionsIfNeeded(),(o=this.wavesurfer)===null||o===void 0||o.load(URL.createObjectURL(d)))};i.onpause=()=>n("record-pause"),i.onstop=()=>n("record-end"),i.start(this.options.mediaRecorderTimeslice),this.lastStartTime=performance.now(),this.lastDuration=0,this.duration=0,this.isWaveformPaused=!1,this.timer.start(),this.emit("record-start")})}getDuration(){return this.duration}isRecording(){var t;return((t=this.mediaRecorder)===null||t===void 0?void 0:t.state)==="recording"}isPaused(){var t;return((t=this.mediaRecorder)===null||t===void 0?void 0:t.state)==="paused"}isActive(){var t;return((t=this.mediaRecorder)===null||t===void 0?void 0:t.state)!=="inactive"}stopRecording(){var t;this.isActive()&&((t=this.mediaRecorder)===null||t===void 0||t.stop(),this.timer.stop())}pauseRecording(){var t,e;this.isRecording()&&(this.isWaveformPaused=!0,(t=this.mediaRecorder)===null||t===void 0||t.requestData(),(e=this.mediaRecorder)===null||e===void 0||e.pause(),this.timer.stop(),this.lastDuration=this.duration)}resumeRecording(){var t;this.isPaused()&&(this.isWaveformPaused=!1,(t=this.mediaRecorder)===null||t===void 0||t.resume(),this.timer.start(),this.lastStartTime=performance.now(),this.emit("record-resume"))}static getAvailableAudioDevices(){return tt(this,void 0,void 0,function*(){return navigator.mediaDevices.enumerateDevices().then(t=>t.filter(e=>e.kind==="audioinput"))})}destroy(){this.applyOriginalOptionsIfNeeded(),super.destroy(),this.stopRecording(),this.stopMic()}applyOriginalOptionsIfNeeded(){this.wavesurfer&&this.originalOptions&&(this.wavesurfer.setOptions(this.originalOptions),delete this.originalOptions)}}const Ce=async({files:s,uploadClient:t,widgetMgr:e,widgetInfo:i,fragmentId:r})=>{let n=[];try{n=await t.fetchFileURLs(s)}catch(c){return{successfulUploads:[],failedUploads:s.map(l=>({file:l,error:ut(c)}))}}const a=Ht(s,n),o=[],d=[];return await Promise.all(a.map(async([c,l])=>{if(!c||!l||!l.uploadUrl||!l.fileId)return{file:c,fileUrl:l,error:new Error("No upload URL found")};try{await t.uploadFile({id:l.fileId,formId:i.formId||""},l.uploadUrl,c),o.push({fileUrl:l,file:c})}catch(p){const h=ut(p);d.push({file:c,error:h})}})),e.setFileUploaderStateValue(i,new Vt({uploadedFileInfo:o.map(({file:c,fileUrl:l})=>new jt({fileId:l.fileId,fileUrls:l,name:c.name,size:c.size}))}),{fromUi:!0},r),{successfulUploads:o,failedUploads:d}},et=({widgetMgr:s,id:t,formId:e,key:i,defaultValue:r})=>{u.useEffect(()=>{const l=s.getElementState(t,i);G(l)&&X(r)&&s.setElementState(t,i,r)},[s,t,i,r]);const[n,a]=u.useState(s.getElementState(t,i)??r),o=u.useCallback(l=>{s.setElementState(t,i,l),a(l)},[s,t,i]),d=u.useMemo(()=>({formId:e||""}),[e]),c=u.useCallback(()=>o(r),[r,o]);return oe({element:d,widgetMgr:s,onFormCleared:c}),[n,o]},Se=(s,t)=>{const{libConfig:{enforceDownloadInNewTab:e=!1}}=yt.useContext(Gt);return u.useCallback(()=>{if(!s)return;const r=de({enforceDownloadInNewTab:e,url:s,filename:t});r.style.display="none",document.body.appendChild(r),r.click(),document.body.removeChild(r)},[s,e,t])},Re=x("div",{target:"etzg8g80"})(),vt=x("div",{target:"etzg8g81"})(({theme:s})=>({height:s.sizes.largestElementHeight,width:"100%",background:s.colors.secondaryBg,borderRadius:s.radii.default,marginBottom:s.spacing.twoXS,display:"flex",alignItems:"center",position:"relative",paddingLeft:s.spacing.xs,paddingRight:s.spacing.sm,border:s.colors.widgetBorderColor?`${s.sizes.borderWidth} solid ${s.colors.widgetBorderColor}`:void 0})),Ee=x("div",{target:"etzg8g82"})({flex:1}),xe=x("div",{target:"etzg8g83"})(({show:s})=>({display:s?"block":"none"})),Pe=x("span",{target:"etzg8g84"})(({theme:s,isPlayingOrRecording:t})=>({margin:s.spacing.sm,fontFamily:s.fonts.monospace,color:t?s.colors.bodyText:s.colors.fadedText60,backgroundColor:s.colors.secondaryBg,fontSize:s.fontSizes.sm})),Tt=x("div",{target:"etzg8g85"})({width:"100%",textAlign:"center",overflow:"hidden"}),Dt=x("span",{target:"etzg8g86"})(({theme:s})=>({color:s.colors.bodyText})),Te=x("a",{target:"etzg8g87"})(({theme:s})=>({color:s.colors.link,textDecoration:"underline"})),De=x("div",{target:"etzg8g88"})(({theme:s})=>({height:s.sizes.largestElementHeight,display:"flex",justifyContent:"center",alignItems:"center"})),We=x("div",{target:"etzg8g89"})(({theme:s})=>{const t="0.625em";return{opacity:.2,width:"100%",height:t,backgroundSize:t,backgroundImage:`radial-gradient(${s.colors.fadedText10} 40%, transparent 40%)`,backgroundRepeat:"repeat"}}),Ae=x("span",{target:"etzg8g810"})(({theme:s})=>({"& > button":{color:s.colors.primary,padding:s.spacing.threeXS},"& > button:hover, & > button:focus":{color:s.colors.red}})),ke=x("span",{target:"etzg8g811"})(({theme:s})=>({"& > button":{padding:s.spacing.threeXS,color:s.colors.fadedText40},"& > button:hover, & > button:focus":{color:s.colors.primary}})),Wt=x("span",{target:"etzg8g812"})(({theme:s})=>({"& > button":{padding:s.spacing.threeXS,color:s.colors.fadedText60},"& > button:hover, & > button:focus":{color:s.colors.bodyText}})),it=x("div",{target:"etzg8g813"})(({theme:s})=>({display:"flex",justifyContent:"center",alignItems:"center",flexGrow:0,flexShrink:1,padding:s.spacing.xs,gap:s.spacing.twoXS,marginRight:s.spacing.twoXS})),Me=x("div",{target:"etzg8g814"})(({theme:s})=>({marginLeft:s.spacing.sm})),Ie=x(Xt,{target:"etzg8g815"})(({theme:s})=>({fontSize:s.fontSizes.sm,width:s.sizes.spinnerSize,height:s.sizes.spinnerSize,borderWidth:s.sizes.spinnerThickness,justifyContents:"center",padding:s.spacing.none,margin:s.spacing.none,borderColor:s.colors.borderColor,borderTopColor:s.colors.secondary,flexGrow:0,flexShrink:0})),Le=()=>z(Tt,{children:[v(Dt,{children:"This app would like to use your microphone."})," ",v(Te,{href:qt,children:"Learn how to allow access."})]}),Oe=()=>v(De,{children:v(We,{})}),Be=4,ze=4,Ne=4,Ue=8,Fe=0,j="00:00",bt=s=>new Date(s).toLocaleTimeString(void 0,{minute:"2-digit",second:"2-digit",timeZone:"UTC"}),_=({onClick:s,disabled:t,ariaLabel:e,iconContent:i})=>v(Zt,{kind:Yt.BORDERLESS_ICON,onClick:s,disabled:t,"aria-label":e,fluidWidth:!0,"data-testid":"stAudioInputActionButton",children:v(Kt,{content:i,size:"lg",color:"inherit"})}),_e=({disabled:s,stopRecording:t})=>v(Ae,{children:v(_,{onClick:t,disabled:s,ariaLabel:"Stop recording",iconContent:Et})}),$e=({disabled:s,isPlaying:t,onClickPlayPause:e})=>v(Wt,{children:t?v(_,{onClick:e,disabled:s,ariaLabel:"Pause",iconContent:Ct}):v(_,{onClick:e,disabled:s,ariaLabel:"Play",iconContent:St})}),He=({disabled:s,startRecording:t})=>v(ke,{children:v(_,{onClick:t,disabled:s,ariaLabel:"Record",iconContent:wt})}),Ve=({onClick:s})=>v(Wt,{children:v(_,{disabled:!1,onClick:s,ariaLabel:"Reset",iconContent:Rt})}),je=({disabled:s,isRecording:t,isPlaying:e,isUploading:i,isError:r,recordingUrlExists:n,startRecording:a,stopRecording:o,onClickPlayPause:d,onClear:c})=>r?v(it,{children:v(Ve,{onClick:c})}):i?v(it,{children:v(Ie,{"aria-label":"Uploading"})}):z(it,{children:[t?v(_e,{disabled:s,stopRecording:o}):v(He,{disabled:s,startRecording:a}),n&&v($e,{disabled:s,isPlaying:e,onClickPlayPause:d})]}),Ge=u.memo(je),Xe=Jt.getLogger("convertAudioToWav");async function qe(s){const t=new window.AudioContext,e=await s.arrayBuffer();let i;try{i=await t.decodeAudioData(e)}catch(m){Xe.error(m);return}const r=44,n=i.numberOfChannels,a=i.sampleRate,o=i.length*n*2+r,d=new ArrayBuffer(o),c=new DataView(d),l={0:{type:"string",value:"RIFF"},4:{type:"uint32",value:o-8},8:{type:"string",value:"WAVE"},12:{type:"string",value:"fmt "},16:{type:"uint32",value:16},20:{type:"uint16",value:1},22:{type:"uint16",value:n},24:{type:"uint32",value:a},28:{type:"uint32",value:a*n*2},32:{type:"uint16",value:n*2},34:{type:"uint16",value:16},36:{type:"string",value:"data"},40:{type:"uint32",value:i.length*n*2}};Object.entries(l).forEach(([m,{type:f,value:b}])=>{const g=parseInt(m,10);f==="string"?Ye(c,g,b):f==="uint32"?c.setUint32(g,b,!0):f==="uint16"&&c.setUint16(g,b,!0)});let p=r;for(let m=0;m<i.length;m++)for(let f=0;f<n;f++){const b=Math.max(-1,Math.min(1,i.getChannelData(f)[m]));c.setInt16(p,b*32767,!0),p+=2}const h=new Uint8Array(d);return new Blob([h],{type:"audio/wav"})}function Ye(s,t,e){for(let i=0;i<e.length;i++)s.setUint8(t+i,e.charCodeAt(i))}const Ke=()=>v(Tt,{children:v(Dt,{children:"An error has occurred, please try again."})}),Ze=({element:s,uploadClient:t,widgetMgr:e,fragmentId:i,disabled:r})=>{var ht;const n=Qt(),a=ce(n),[o,d]=u.useState(null),c=yt.useRef(null),[l,p]=et({widgetMgr:e,id:s.id,key:"deleteFileUrl",defaultValue:null}),[h,m]=u.useState(null),[f,b]=u.useState([]),[g,w]=u.useState(null),[y,P]=et({widgetMgr:e,id:s.id,key:"recordingUrl",defaultValue:null}),[,T]=u.useState(0),C=()=>{T(S=>S+1)},[D,W]=u.useState(j),[M,A]=et({widgetMgr:e,id:s.id,formId:s.formId,key:"recordingTime",defaultValue:j}),[I,U]=u.useState(!1),[O,At]=u.useState(!1),[st,kt]=u.useState(!1),[Mt,nt]=u.useState(!1),[Y,K]=u.useState(!1),rt=s.id,L=s.formId,ot=u.useCallback(async S=>{nt(!0),X(L)&&e.setFormsWithUploadsInProgress(new Set([L]));let R;if(S.type==="audio/wav"?R=S:R=await qe(S),!R){K(!0);return}const k=URL.createObjectURL(R),Ut=new Date().toISOString().slice(0,16).replace(":","-"),Ft=new File([R],`${Ut}_audio.wav`,{type:R.type});P(k),Ce({files:[Ft],uploadClient:t,widgetMgr:e,widgetInfo:{id:rt,formId:L},fragmentId:i}).then(({successfulUploads:_t,failedUploads:$t})=>{if($t.length>0){K(!0);return}const J=_t[0];J&&J.fileUrl.deleteUrl&&p(J.fileUrl.deleteUrl)}).finally(()=>{X(L)&&e.setFormsWithUploadsInProgress(new Set),nt(!1)})},[P,t,e,rt,L,i,p]),B=u.useCallback(({updateWidgetManager:S,deleteFile:R})=>{G(o)||G(l)||(P(null),o.empty(),R&&t.deleteFile(l),p(null),W(j),A(j),S&&e.setFileUploaderStateValue(s,{},{fromUi:!0},i),U(!1),X(y)&&URL.revokeObjectURL(y))},[l,y,t,o,s,e,i,A,P,p]);u.useEffect(()=>{if(G(L))return;const S=new ae;return S.manageFormClearListener(e,L,()=>B({updateWidgetManager:!0,deleteFile:!1})),()=>S.disconnect()},[L,B,e]);const at=u.useCallback(()=>{if(c.current===null)return;const S=F.create({container:c.current,waveColor:y?Q(n.colors.fadedText40,n.colors.secondaryBg):n.colors.primary,progressColor:n.colors.bodyText,height:te(n.sizes.largestElementHeight)-2*Be,barWidth:ze,barGap:Ne,barRadius:Ue,cursorWidth:Fe,url:y??void 0});S.on("timeupdate",k=>{W(bt(k*1e3))}),S.on("pause",()=>{C()});const R=S.registerPlugin(q.create({scrollingWaveform:!1,renderRecordedAudio:!0}));return R.on("record-end",async k=>{ot(k)}),R.on("record-progress",k=>{A(bt(k))}),d(S),m(R),()=>{S&&S.destroy(),R&&R.destroy()}},[ot]);u.useEffect(()=>at(),[at]),u.useEffect(()=>{ee(a,n)||o==null||o.setOptions({waveColor:y?Q(n.colors.fadedText40,n.colors.secondaryBg):n.colors.primary,progressColor:n.colors.bodyText})},[n,a,y,o]);const It=u.useCallback(()=>{o&&(o.playPause(),U(!0),C())},[o]),Lt=u.useCallback(async()=>{let S=g;st||(await navigator.mediaDevices.getUserMedia({audio:!0}).then(()=>q.getAvailableAudioDevices().then(R=>{if(b(R),R.length>0){const{deviceId:k}=R[0];w(k),S=k}})).catch(R=>{At(!0)}),kt(!0)),!(!h||!S||!o)&&(o.setOptions({waveColor:n.colors.primary}),y&&B({updateWidgetManager:!1,deleteFile:!0}),h.startRecording({deviceId:S}).then(()=>{C()}))},[g,h,n,o,y,B,st]),Ot=u.useCallback(()=>{h&&(h.stopRecording(),o==null||o.setOptions({waveColor:Q(n.colors.fadedText40,n.colors.secondaryBg)}))},[h,o,n]),Bt=Se(y,"recording.wav"),Z=!!(h!=null&&h.isRecording()),lt=!!(o!=null&&o.isPlaying()),zt=Z||lt,ct=!Z&&!y&&!O,Nt=O||ct||Y,dt=r||O;return z(Re,{className:"stAudioInput","data-testid":"stAudioInput",children:[v(re,{label:s.label,disabled:dt,labelVisibility:ie((ht=s.labelVisibility)==null?void 0:ht.value),children:s.help&&v(Me,{children:v(se,{content:s.help,placement:ne.TOP})})}),z(vt,{children:[z(le,{isFullScreen:!1,disableFullscreenMode:!0,target:vt,children:[y&&v(pt,{label:"Download as WAV",icon:he,onClick:()=>Bt()}),l&&v(pt,{label:"Clear recording",icon:ue,onClick:()=>B({updateWidgetManager:!0,deleteFile:!0})})]}),v(Ge,{isRecording:Z,isPlaying:lt,isUploading:Mt,isError:Y,recordingUrlExists:!!y,startRecording:Lt,stopRecording:Ot,onClickPlayPause:It,onClear:()=>{B({updateWidgetManager:!1,deleteFile:!0}),K(!1)},disabled:dt}),z(Ee,{children:[Y&&v(Ke,{}),ct&&v(Oe,{}),O&&v(Le,{}),v(xe,{"data-testid":"stAudioInputWaveSurfer",ref:c,show:!Nt})]}),v(Pe,{isPlayingOrRecording:zt,"data-testid":"stAudioInputWaveformTimeCode",children:I?D:M})]})]})},ri=u.memo(Ze);export{ri as default};
|
@@ -1,4 +1,4 @@
|
|
1
|
-
var xL=Object.defineProperty;var wL=(t,e,r)=>e in t?xL(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var U=(t,e,r)=>wL(t,typeof e!="symbol"?e+"":e,r);import{g as oA,r as it,ao as Wt,p as $e,d as VM,aV as yu,_ as jM,j as ms,z as Ll,aW as Gy,F as aE,aX as Wy,aY as lE,aZ as TL,aF as EL,a_ as SL,a$ as CL,n as HM,C as GM,b0 as T1,b1 as cE,aC as PL,y as IL,b2 as ML,b3 as uE}from"./index.gthzAzzy.js";import{_ as Gn,a as RL,C as BL}from"./toConsumableArray.eNZZBqsg.js";import{b as Fu,a as Lu,_ as l2,c as Gd,d as c2}from"./possibleConstructorReturn.BiMrneUm.js";import{a as OL,T as DL}from"./Toolbar.Bws727nN.js";import{u as WM,E as XM,w as FL}from"./withFullScreenWrapper.CKNKx70m.js";import{u as LL}from"./useBasicWidgetState.BJ0FCAzu.js";import{u as kL,s as NL}from"./threshold.B8r8f5kt.js";import{a as UL}from"./axios.upsvKRUO.js";import"./FormClearHelper.LI0uGKXr.js";import"./value.iufjd77T.js";function zL(t,e){for(var r=0;r<e.length;r++){const i=e[r];if(typeof i!="string"&&!Array.isArray(i)){for(const n in i)if(n!=="default"&&!(n in t)){const o=Object.getOwnPropertyDescriptor(i,n);o&&Object.defineProperty(t,n,o.get?o:{enumerable:!0,get:()=>i[n]})}}}return Object.freeze(Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}))}async function aA(t,e,r,i){return i._parse(t,e,r,i)}function Ni(t,e){if(!t)throw new Error(e||"loader assertion failed.")}const v_=!!(typeof process!="object"||String(process)!=="[object process]"||process.browser),hE=typeof process<"u"&&process.version&&/v([0-9]*)/.exec(process.version);hE&&parseFloat(hE[1]);const tg=globalThis,Wf=globalThis.process||{},VL=globalThis.navigator||{};function qM(t){var i,n;if(typeof window<"u"&&((i=window.process)==null?void 0:i.type)==="renderer"||typeof process<"u"&&((n=process.versions)!=null&&n.electron))return!0;const r=typeof navigator<"u"&&navigator.userAgent;return!!(r&&r.indexOf("Electron")>=0)}function ku(){return!(typeof process=="object"&&String(process)==="[object process]"&&!(process!=null&&process.browser))||qM()}function jL(t){return ku()?qM()?"Electron":(VL.userAgent||"").indexOf("Edge")>-1?"Edge":globalThis.chrome?"Chrome":globalThis.safari?"Safari":globalThis.mozInnerScreenX?"Firefox":"Unknown":"Node"}const $M="4.0.7";function HL(t){try{const e=window[t],r="__storage_test__";return e.setItem(r,r),e.removeItem(r),e}catch{return null}}class WL{constructor(e,r,i="sessionStorage"){this.storage=HL(i),this.id=e,this.config=r,this._loadConfiguration()}getConfiguration(){return this.config}setConfiguration(e){if(Object.assign(this.config,e),this.storage){const r=JSON.stringify(this.config);this.storage.setItem(this.id,r)}}_loadConfiguration(){let e={};if(this.storage){const r=this.storage.getItem(this.id);e=r?JSON.parse(r):{}}return Object.assign(this.config,e),this}}function XL(t){let e;return t<10?e=`${t.toFixed(2)}ms`:t<100?e=`${t.toFixed(1)}ms`:t<1e3?e=`${t.toFixed(0)}ms`:e=`${(t/1e3).toFixed(2)}s`,e}function qL(t,e=8){const r=Math.max(e-t.length,0);return`${" ".repeat(r)}${t}`}var mm;(function(t){t[t.BLACK=30]="BLACK",t[t.RED=31]="RED",t[t.GREEN=32]="GREEN",t[t.YELLOW=33]="YELLOW",t[t.BLUE=34]="BLUE",t[t.MAGENTA=35]="MAGENTA",t[t.CYAN=36]="CYAN",t[t.WHITE=37]="WHITE",t[t.BRIGHT_BLACK=90]="BRIGHT_BLACK",t[t.BRIGHT_RED=91]="BRIGHT_RED",t[t.BRIGHT_GREEN=92]="BRIGHT_GREEN",t[t.BRIGHT_YELLOW=93]="BRIGHT_YELLOW",t[t.BRIGHT_BLUE=94]="BRIGHT_BLUE",t[t.BRIGHT_MAGENTA=95]="BRIGHT_MAGENTA",t[t.BRIGHT_CYAN=96]="BRIGHT_CYAN",t[t.BRIGHT_WHITE=97]="BRIGHT_WHITE"})(mm||(mm={}));const $L=10;function fE(t){return typeof t!="string"?t:(t=t.toUpperCase(),mm[t]||mm.WHITE)}function ZL(t,e,r){return!ku&&typeof t=="string"&&(e&&(t=`\x1B[${fE(e)}m${t}\x1B[39m`),r&&(t=`\x1B[${fE(r)+$L}m${t}\x1B[49m`)),t}function KL(t,e=["constructor"]){const r=Object.getPrototypeOf(t),i=Object.getOwnPropertyNames(r),n=t;for(const o of i){const s=n[o];typeof s=="function"&&(e.find(f=>o===f)||(n[o]=s.bind(t)))}}function u2(t,e){if(!t)throw new Error("Assertion failed")}function Xf(){var e,r,i;let t;if(ku()&&tg.performance)t=(r=(e=tg==null?void 0:tg.performance)==null?void 0:e.now)==null?void 0:r.call(e);else if("hrtime"in Wf){const n=(i=Wf==null?void 0:Wf.hrtime)==null?void 0:i.call(Wf);t=n[0]*1e3+n[1]/1e6}else t=Date.now();return t}const qf={debug:ku()&&console.debug||console.log,log:console.log,info:console.info,warn:console.warn,error:console.error},YL={enabled:!0,level:0};function $f(){}const dE={},AE={once:!0};class lA{constructor({id:e}={id:""}){this.VERSION=$M,this._startTs=Xf(),this._deltaTs=Xf(),this.userData={},this.LOG_THROTTLE_TIMEOUT=0,this.id=e,this.userData={},this._storage=new WL(`__probe-${this.id}__`,YL),this.timeStamp(`${this.id} started`),KL(this),Object.seal(this)}set level(e){this.setLevel(e)}get level(){return this.getLevel()}isEnabled(){return this._storage.config.enabled}getLevel(){return this._storage.config.level}getTotal(){return Number((Xf()-this._startTs).toPrecision(10))}getDelta(){return Number((Xf()-this._deltaTs).toPrecision(10))}set priority(e){this.level=e}get priority(){return this.level}getPriority(){return this.level}enable(e=!0){return this._storage.setConfiguration({enabled:e}),this}setLevel(e){return this._storage.setConfiguration({level:e}),this}get(e){return this._storage.config[e]}set(e,r){this._storage.setConfiguration({[e]:r})}settings(){console.table?console.table(this._storage.config):console.log(this._storage.config)}assert(e,r){if(!e)throw new Error(r||"Assertion failed")}warn(e){return this._getLogFunction(0,e,qf.warn,arguments,AE)}error(e){return this._getLogFunction(0,e,qf.error,arguments)}deprecated(e,r){return this.warn(`\`${e}\` is deprecated and will be removed in a later version. Use \`${r}\` instead`)}removed(e,r){return this.error(`\`${e}\` has been removed. Use \`${r}\` instead`)}probe(e,r){return this._getLogFunction(e,r,qf.log,arguments,{time:!0,once:!0})}log(e,r){return this._getLogFunction(e,r,qf.debug,arguments)}info(e,r){return this._getLogFunction(e,r,console.info,arguments)}once(e,r){return this._getLogFunction(e,r,qf.debug||qf.info,arguments,AE)}table(e,r,i){return r?this._getLogFunction(e,r,console.table||$f,i&&[i],{tag:QL(r)}):$f}time(e,r){return this._getLogFunction(e,r,console.time?console.time:console.info)}timeEnd(e,r){return this._getLogFunction(e,r,console.timeEnd?console.timeEnd:console.info)}timeStamp(e,r){return this._getLogFunction(e,r,console.timeStamp||$f)}group(e,r,i={collapsed:!1}){const n=pE({logLevel:e,message:r,opts:i}),{collapsed:o}=i;return n.method=(o?console.groupCollapsed:console.group)||console.info,this._getLogFunction(n)}groupCollapsed(e,r,i={}){return this.group(e,r,Object.assign({},i,{collapsed:!0}))}groupEnd(e){return this._getLogFunction(e,"",console.groupEnd||$f)}withGroup(e,r,i){this.group(e,r)();try{i()}finally{this.groupEnd(e)()}}trace(){console.trace&&console.trace()}_shouldLog(e){return this.isEnabled()&&this.getLevel()>=ZM(e)}_getLogFunction(e,r,i,n,o){if(this._shouldLog(e)){o=pE({logLevel:e,message:r,args:n,opts:o}),i=i||o.method,u2(i),o.total=this.getTotal(),o.delta=this.getDelta(),this._deltaTs=Xf();const s=o.tag||o.message;if(o.once&&s)if(!dE[s])dE[s]=Xf();else return $f;return r=JL(this.id,o.message,o),i.bind(console,r,...o.args)}return $f}}lA.VERSION=$M;function ZM(t){if(!t)return 0;let e;switch(typeof t){case"number":e=t;break;case"object":e=t.logLevel||t.priority||0;break;default:return 0}return u2(Number.isFinite(e)&&e>=0),e}function pE(t){const{logLevel:e,message:r}=t;t.logLevel=ZM(e);const i=t.args?Array.from(t.args):[];for(;i.length&&i.shift()!==r;);switch(typeof e){case"string":case"function":r!==void 0&&i.unshift(r),t.message=e;break;case"object":Object.assign(t,e);break}typeof t.message=="function"&&(t.message=t.message());const n=typeof t.message;return u2(n==="string"||n==="object"),Object.assign(t,{args:i},t.opts)}function JL(t,e,r){if(typeof e=="string"){const i=r.time?qL(XL(r.total)):"";e=r.time?`${t}: ${i} ${e}`:`${t}: ${e}`,e=ZL(e,r.color,r.background)}return e}function QL(t){for(const e in t)for(const r in t[e])return r||"untitled";return"empty"}globalThis.probe={};const KM=new lA({id:"@probe.gl/log"});function YM(t,e){return JM(t||{},e)}function JM(t,e,r=0){if(r>3)return e;const i={...t};for(const[n,o]of Object.entries(e))o&&typeof o=="object"&&!Array.isArray(o)?i[n]=JM(i[n]||{},e[n],r+1):i[n]=e[n];return i}function ek(t){var e;globalThis.loaders||(globalThis.loaders={}),(e=globalThis.loaders).modules||(e.modules={}),Object.assign(globalThis.loaders.modules,t)}function tk(t){var r,i;return((i=(r=globalThis.loaders)==null?void 0:r.modules)==null?void 0:i[t])||null}const rk="latest";function ik(){var t;return(t=globalThis._loadersgl_)!=null&&t.version||(globalThis._loadersgl_=globalThis._loadersgl_||{},globalThis._loadersgl_.version="4.2.4"),globalThis._loadersgl_.version}const QM=ik();function Pc(t,e){if(!t)throw new Error(e||"loaders.gl assertion failed.")}const Sa=typeof process!="object"||String(process)!=="[object process]"||process.browser,h2=typeof importScripts=="function",nk=typeof window<"u"&&typeof window.orientation<"u",gE=typeof process<"u"&&process.version&&/v([0-9]*)/.exec(process.version);gE&&parseFloat(gE[1]);class sk{constructor(e,r){U(this,"name");U(this,"workerThread");U(this,"isRunning",!0);U(this,"result");U(this,"_resolve",()=>{});U(this,"_reject",()=>{});this.name=e,this.workerThread=r,this.result=new Promise((i,n)=>{this._resolve=i,this._reject=n})}postMessage(e,r){this.workerThread.postMessage({source:"loaders.gl",type:e,payload:r})}done(e){Pc(this.isRunning),this.isRunning=!1,this._resolve(e)}error(e){Pc(this.isRunning),this.isRunning=!1,this._reject(e)}}class Xy{terminate(){}}const qy=new Map;function ok(t){Pc(t.source&&!t.url||!t.source&&t.url);let e=qy.get(t.source||t.url);return e||(t.url&&(e=ak(t.url),qy.set(t.url,e)),t.source&&(e=eR(t.source),qy.set(t.source,e))),Pc(e),e}function ak(t){if(!t.startsWith("http"))return t;const e=lk(t);return eR(e)}function eR(t){const e=new Blob([t],{type:"application/javascript"});return URL.createObjectURL(e)}function lk(t){return`try {
|
1
|
+
var xL=Object.defineProperty;var wL=(t,e,r)=>e in t?xL(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var U=(t,e,r)=>wL(t,typeof e!="symbol"?e+"":e,r);import{g as oA,r as it,ap as Wt,p as $e,d as VM,aV as yu,_ as jM,j as ms,z as Ll,aW as Gy,F as aE,aX as Wy,aY as lE,aZ as TL,aF as EL,a_ as SL,a$ as CL,n as HM,G as GM,b0 as T1,b1 as cE,aC as PL,y as IL,b2 as ML,b3 as uE}from"./index.9wBA4A4f.js";import{_ as Gn,a as RL,C as BL}from"./toConsumableArray.D4FxxWIg.js";import{b as Fu,a as Lu,_ as l2,c as Gd,d as c2}from"./possibleConstructorReturn.DGVrr2j8.js";import{a as OL,T as DL}from"./Toolbar.D-hUr0RX.js";import{u as WM,E as XM,w as FL}from"./withFullScreenWrapper.DwHjQb3H.js";import{u as LL}from"./useBasicWidgetState.C207Y3_O.js";import{u as kL,s as NL}from"./threshold.B8r8f5kt.js";import{a as UL}from"./axios.upsvKRUO.js";import"./FormClearHelper.BBpErIGP.js";import"./value.iufjd77T.js";function zL(t,e){for(var r=0;r<e.length;r++){const i=e[r];if(typeof i!="string"&&!Array.isArray(i)){for(const n in i)if(n!=="default"&&!(n in t)){const o=Object.getOwnPropertyDescriptor(i,n);o&&Object.defineProperty(t,n,o.get?o:{enumerable:!0,get:()=>i[n]})}}}return Object.freeze(Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}))}async function aA(t,e,r,i){return i._parse(t,e,r,i)}function Ni(t,e){if(!t)throw new Error(e||"loader assertion failed.")}const v_=!!(typeof process!="object"||String(process)!=="[object process]"||process.browser),hE=typeof process<"u"&&process.version&&/v([0-9]*)/.exec(process.version);hE&&parseFloat(hE[1]);const tg=globalThis,Wf=globalThis.process||{},VL=globalThis.navigator||{};function qM(t){var i,n;if(typeof window<"u"&&((i=window.process)==null?void 0:i.type)==="renderer"||typeof process<"u"&&((n=process.versions)!=null&&n.electron))return!0;const r=typeof navigator<"u"&&navigator.userAgent;return!!(r&&r.indexOf("Electron")>=0)}function ku(){return!(typeof process=="object"&&String(process)==="[object process]"&&!(process!=null&&process.browser))||qM()}function jL(t){return ku()?qM()?"Electron":(VL.userAgent||"").indexOf("Edge")>-1?"Edge":globalThis.chrome?"Chrome":globalThis.safari?"Safari":globalThis.mozInnerScreenX?"Firefox":"Unknown":"Node"}const $M="4.0.7";function HL(t){try{const e=window[t],r="__storage_test__";return e.setItem(r,r),e.removeItem(r),e}catch{return null}}class WL{constructor(e,r,i="sessionStorage"){this.storage=HL(i),this.id=e,this.config=r,this._loadConfiguration()}getConfiguration(){return this.config}setConfiguration(e){if(Object.assign(this.config,e),this.storage){const r=JSON.stringify(this.config);this.storage.setItem(this.id,r)}}_loadConfiguration(){let e={};if(this.storage){const r=this.storage.getItem(this.id);e=r?JSON.parse(r):{}}return Object.assign(this.config,e),this}}function XL(t){let e;return t<10?e=`${t.toFixed(2)}ms`:t<100?e=`${t.toFixed(1)}ms`:t<1e3?e=`${t.toFixed(0)}ms`:e=`${(t/1e3).toFixed(2)}s`,e}function qL(t,e=8){const r=Math.max(e-t.length,0);return`${" ".repeat(r)}${t}`}var mm;(function(t){t[t.BLACK=30]="BLACK",t[t.RED=31]="RED",t[t.GREEN=32]="GREEN",t[t.YELLOW=33]="YELLOW",t[t.BLUE=34]="BLUE",t[t.MAGENTA=35]="MAGENTA",t[t.CYAN=36]="CYAN",t[t.WHITE=37]="WHITE",t[t.BRIGHT_BLACK=90]="BRIGHT_BLACK",t[t.BRIGHT_RED=91]="BRIGHT_RED",t[t.BRIGHT_GREEN=92]="BRIGHT_GREEN",t[t.BRIGHT_YELLOW=93]="BRIGHT_YELLOW",t[t.BRIGHT_BLUE=94]="BRIGHT_BLUE",t[t.BRIGHT_MAGENTA=95]="BRIGHT_MAGENTA",t[t.BRIGHT_CYAN=96]="BRIGHT_CYAN",t[t.BRIGHT_WHITE=97]="BRIGHT_WHITE"})(mm||(mm={}));const $L=10;function fE(t){return typeof t!="string"?t:(t=t.toUpperCase(),mm[t]||mm.WHITE)}function ZL(t,e,r){return!ku&&typeof t=="string"&&(e&&(t=`\x1B[${fE(e)}m${t}\x1B[39m`),r&&(t=`\x1B[${fE(r)+$L}m${t}\x1B[49m`)),t}function KL(t,e=["constructor"]){const r=Object.getPrototypeOf(t),i=Object.getOwnPropertyNames(r),n=t;for(const o of i){const s=n[o];typeof s=="function"&&(e.find(f=>o===f)||(n[o]=s.bind(t)))}}function u2(t,e){if(!t)throw new Error("Assertion failed")}function Xf(){var e,r,i;let t;if(ku()&&tg.performance)t=(r=(e=tg==null?void 0:tg.performance)==null?void 0:e.now)==null?void 0:r.call(e);else if("hrtime"in Wf){const n=(i=Wf==null?void 0:Wf.hrtime)==null?void 0:i.call(Wf);t=n[0]*1e3+n[1]/1e6}else t=Date.now();return t}const qf={debug:ku()&&console.debug||console.log,log:console.log,info:console.info,warn:console.warn,error:console.error},YL={enabled:!0,level:0};function $f(){}const dE={},AE={once:!0};class lA{constructor({id:e}={id:""}){this.VERSION=$M,this._startTs=Xf(),this._deltaTs=Xf(),this.userData={},this.LOG_THROTTLE_TIMEOUT=0,this.id=e,this.userData={},this._storage=new WL(`__probe-${this.id}__`,YL),this.timeStamp(`${this.id} started`),KL(this),Object.seal(this)}set level(e){this.setLevel(e)}get level(){return this.getLevel()}isEnabled(){return this._storage.config.enabled}getLevel(){return this._storage.config.level}getTotal(){return Number((Xf()-this._startTs).toPrecision(10))}getDelta(){return Number((Xf()-this._deltaTs).toPrecision(10))}set priority(e){this.level=e}get priority(){return this.level}getPriority(){return this.level}enable(e=!0){return this._storage.setConfiguration({enabled:e}),this}setLevel(e){return this._storage.setConfiguration({level:e}),this}get(e){return this._storage.config[e]}set(e,r){this._storage.setConfiguration({[e]:r})}settings(){console.table?console.table(this._storage.config):console.log(this._storage.config)}assert(e,r){if(!e)throw new Error(r||"Assertion failed")}warn(e){return this._getLogFunction(0,e,qf.warn,arguments,AE)}error(e){return this._getLogFunction(0,e,qf.error,arguments)}deprecated(e,r){return this.warn(`\`${e}\` is deprecated and will be removed in a later version. Use \`${r}\` instead`)}removed(e,r){return this.error(`\`${e}\` has been removed. Use \`${r}\` instead`)}probe(e,r){return this._getLogFunction(e,r,qf.log,arguments,{time:!0,once:!0})}log(e,r){return this._getLogFunction(e,r,qf.debug,arguments)}info(e,r){return this._getLogFunction(e,r,console.info,arguments)}once(e,r){return this._getLogFunction(e,r,qf.debug||qf.info,arguments,AE)}table(e,r,i){return r?this._getLogFunction(e,r,console.table||$f,i&&[i],{tag:QL(r)}):$f}time(e,r){return this._getLogFunction(e,r,console.time?console.time:console.info)}timeEnd(e,r){return this._getLogFunction(e,r,console.timeEnd?console.timeEnd:console.info)}timeStamp(e,r){return this._getLogFunction(e,r,console.timeStamp||$f)}group(e,r,i={collapsed:!1}){const n=pE({logLevel:e,message:r,opts:i}),{collapsed:o}=i;return n.method=(o?console.groupCollapsed:console.group)||console.info,this._getLogFunction(n)}groupCollapsed(e,r,i={}){return this.group(e,r,Object.assign({},i,{collapsed:!0}))}groupEnd(e){return this._getLogFunction(e,"",console.groupEnd||$f)}withGroup(e,r,i){this.group(e,r)();try{i()}finally{this.groupEnd(e)()}}trace(){console.trace&&console.trace()}_shouldLog(e){return this.isEnabled()&&this.getLevel()>=ZM(e)}_getLogFunction(e,r,i,n,o){if(this._shouldLog(e)){o=pE({logLevel:e,message:r,args:n,opts:o}),i=i||o.method,u2(i),o.total=this.getTotal(),o.delta=this.getDelta(),this._deltaTs=Xf();const s=o.tag||o.message;if(o.once&&s)if(!dE[s])dE[s]=Xf();else return $f;return r=JL(this.id,o.message,o),i.bind(console,r,...o.args)}return $f}}lA.VERSION=$M;function ZM(t){if(!t)return 0;let e;switch(typeof t){case"number":e=t;break;case"object":e=t.logLevel||t.priority||0;break;default:return 0}return u2(Number.isFinite(e)&&e>=0),e}function pE(t){const{logLevel:e,message:r}=t;t.logLevel=ZM(e);const i=t.args?Array.from(t.args):[];for(;i.length&&i.shift()!==r;);switch(typeof e){case"string":case"function":r!==void 0&&i.unshift(r),t.message=e;break;case"object":Object.assign(t,e);break}typeof t.message=="function"&&(t.message=t.message());const n=typeof t.message;return u2(n==="string"||n==="object"),Object.assign(t,{args:i},t.opts)}function JL(t,e,r){if(typeof e=="string"){const i=r.time?qL(XL(r.total)):"";e=r.time?`${t}: ${i} ${e}`:`${t}: ${e}`,e=ZL(e,r.color,r.background)}return e}function QL(t){for(const e in t)for(const r in t[e])return r||"untitled";return"empty"}globalThis.probe={};const KM=new lA({id:"@probe.gl/log"});function YM(t,e){return JM(t||{},e)}function JM(t,e,r=0){if(r>3)return e;const i={...t};for(const[n,o]of Object.entries(e))o&&typeof o=="object"&&!Array.isArray(o)?i[n]=JM(i[n]||{},e[n],r+1):i[n]=e[n];return i}function ek(t){var e;globalThis.loaders||(globalThis.loaders={}),(e=globalThis.loaders).modules||(e.modules={}),Object.assign(globalThis.loaders.modules,t)}function tk(t){var r,i;return((i=(r=globalThis.loaders)==null?void 0:r.modules)==null?void 0:i[t])||null}const rk="latest";function ik(){var t;return(t=globalThis._loadersgl_)!=null&&t.version||(globalThis._loadersgl_=globalThis._loadersgl_||{},globalThis._loadersgl_.version="4.2.4"),globalThis._loadersgl_.version}const QM=ik();function Pc(t,e){if(!t)throw new Error(e||"loaders.gl assertion failed.")}const Sa=typeof process!="object"||String(process)!=="[object process]"||process.browser,h2=typeof importScripts=="function",nk=typeof window<"u"&&typeof window.orientation<"u",gE=typeof process<"u"&&process.version&&/v([0-9]*)/.exec(process.version);gE&&parseFloat(gE[1]);class sk{constructor(e,r){U(this,"name");U(this,"workerThread");U(this,"isRunning",!0);U(this,"result");U(this,"_resolve",()=>{});U(this,"_reject",()=>{});this.name=e,this.workerThread=r,this.result=new Promise((i,n)=>{this._resolve=i,this._reject=n})}postMessage(e,r){this.workerThread.postMessage({source:"loaders.gl",type:e,payload:r})}done(e){Pc(this.isRunning),this.isRunning=!1,this._resolve(e)}error(e){Pc(this.isRunning),this.isRunning=!1,this._reject(e)}}class Xy{terminate(){}}const qy=new Map;function ok(t){Pc(t.source&&!t.url||!t.source&&t.url);let e=qy.get(t.source||t.url);return e||(t.url&&(e=ak(t.url),qy.set(t.url,e)),t.source&&(e=eR(t.source),qy.set(t.source,e))),Pc(e),e}function ak(t){if(!t.startsWith("http"))return t;const e=lk(t);return eR(e)}function eR(t){const e=new Blob([t],{type:"application/javascript"});return URL.createObjectURL(e)}function lk(t){return`try {
|
2
2
|
importScripts('${t}');
|
3
3
|
} catch (error) {
|
4
4
|
console.error(error);
|