streamlit-nightly 1.42.3.dev20250302__py2.py3-none-any.whl → 1.43.1.dev20250306__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/commands/navigation.py +138 -98
- streamlit/components/v1/component_arrow.py +3 -1
- streamlit/config.py +33 -11
- streamlit/dataframe_util.py +12 -4
- streamlit/elements/lib/built_in_chart_utils.py +3 -3
- streamlit/elements/lib/pandas_styler_utils.py +4 -4
- streamlit/elements/map.py +4 -2
- streamlit/elements/media.py +4 -2
- streamlit/elements/widgets/button.py +92 -28
- streamlit/elements/widgets/data_editor.py +4 -4
- streamlit/proto/ClientState_pb2.py +5 -5
- streamlit/proto/ClientState_pb2.pyi +7 -2
- streamlit/proto/NewSession_pb2.py +16 -16
- streamlit/proto/NewSession_pb2.pyi +8 -3
- streamlit/runtime/caching/hashing.py +1 -1
- streamlit/runtime/context.py +9 -0
- streamlit/static/index.html +1 -1
- streamlit/static/static/js/{FileDownload.esm.MU0nAJxt.js → FileDownload.esm.D90ZPlvX.js} +1 -1
- streamlit/static/static/js/{FileHelper.D-6vwsT7.js → FileHelper.B7wMHnJf.js} +1 -1
- streamlit/static/static/js/{FormClearHelper.DzssExOY.js → FormClearHelper.DiTttn8n.js} +1 -1
- streamlit/static/static/js/{Hooks.X18-6oCR.js → Hooks.DlsrQbRk.js} +1 -1
- streamlit/static/static/js/{InputInstructions.DMffPiri.js → InputInstructions.DABeMich.js} +1 -1
- streamlit/static/static/js/{ProgressBar.REkskfZ6.js → ProgressBar.B0_wzszZ.js} +2 -2
- streamlit/static/static/js/{RenderInPortalIfExists.CaN0JvX5.js → RenderInPortalIfExists.Ct3yXHYV.js} +1 -1
- streamlit/static/static/js/{Toolbar.BNy6-0V9.js → Toolbar.BhJd2eBO.js} +1 -1
- streamlit/static/static/js/{base-input.DDph5ZTh.js → base-input.BT0Fve4h.js} +1 -1
- streamlit/static/static/js/{checkbox.YfIvYeNy.js → checkbox.DytiXgc4.js} +2 -2
- streamlit/static/static/js/{createSuper.AWf9GP6U.js → createSuper.Dey_Nchq.js} +1 -1
- streamlit/static/static/js/{data-grid-overlay-editor.BLYw7T13.js → data-grid-overlay-editor.DHaS0Xdu.js} +1 -1
- streamlit/static/static/js/{downloader.nl_vIzBu.js → downloader.CpXHg7_L.js} +1 -1
- streamlit/static/static/js/{es6.BK9dY4sJ.js → es6.B12jZN2H.js} +2 -2
- streamlit/static/static/js/{iframeResizer.contentWindow.DPzfRlbi.js → iframeResizer.contentWindow.Dp7IrKgg.js} +1 -1
- streamlit/static/static/js/{index._yUNqU9v.js → index.3smrX8Wb.js} +1 -1
- streamlit/static/static/js/index.6GcOZfbK.js +1 -0
- streamlit/static/static/js/index.9aouXH1R.js +1 -0
- streamlit/static/static/js/{index.DYowKMte.js → index.B0Dq5tyz.js} +1 -1
- streamlit/static/static/js/index.B0vUg2Y3.js +1 -0
- streamlit/static/static/js/index.BEjwL3_Z.js +1 -0
- streamlit/static/static/js/{index.CD9aQBDI.js → index.BFTv_Z_e.js} +1 -1
- streamlit/static/static/js/{index.BXoSWEhJ.js → index.BWJyhyqF.js} +1 -1
- streamlit/static/static/js/{index.6viEYUdA.js → index.Bb8aDqLI.js} +1 -1
- streamlit/static/static/js/{index.7RV95eQw.js → index.Bd3HEJHM.js} +53 -53
- streamlit/static/static/js/index.BpUFb67U.js +1 -0
- streamlit/static/static/js/{index.DFLL-J15.js → index.BpcIvL5C.js} +135 -171
- streamlit/static/static/js/{index.D6Y5ypee.js → index.BtGwo9mt.js} +1 -1
- streamlit/static/static/js/{index.QWADtOoc.js → index.Bx2jHxuL.js} +1 -1
- streamlit/static/static/js/{index.DIMh2slz.js → index.C8NedCpe.js} +2 -2
- streamlit/static/static/js/{index.Bc52-u2S.js → index.C8i44-aA.js} +1 -1
- streamlit/static/static/js/{index.3wDnIhs1.js → index.CCzbz0re.js} +1 -1
- streamlit/static/static/js/{index.ba5plLt2.js → index.CKTE0OmI.js} +1 -1
- streamlit/static/static/js/{index.D5WhGmsx.js → index.Chro-AQL.js} +1 -1
- streamlit/static/static/js/{index.C3J9I4Qy.js → index.D1pT2XNV.js} +1 -1
- streamlit/static/static/js/{index.DVJzE2M1.js → index.D2zBv6ha.js} +1 -1
- streamlit/static/static/js/{index.DwT5qUSO.js → index.D6F98iFW.js} +1 -1
- streamlit/static/static/js/{index.DMsLuMo4.js → index.DDLiQS9D.js} +1 -1
- streamlit/static/static/js/{index.K_eBGdkn.js → index.DVFO4dUf.js} +1 -1
- streamlit/static/static/js/index.DcZtLSnI.js +1 -0
- streamlit/static/static/js/index.Dnp2nMgW.js +1 -0
- streamlit/static/static/js/{index.BuZyz96w.js → index.DpvAFLbG.js} +1 -1
- streamlit/static/static/js/{index.D_ANlHT-.js → index.Jj9qMZu5.js} +1 -1
- streamlit/static/static/js/{index.R376rgCp.js → index.SSx319oy.js} +1 -1
- streamlit/static/static/js/{index.BN9xLPzN.js → index.U8Sox-zm.js} +1 -1
- streamlit/static/static/js/{index.Du8FKb6_.js → index.VRF0kACr.js} +5 -5
- streamlit/static/static/js/{index.BqqfaHV9.js → index.d4FK8xGd.js} +2 -2
- streamlit/static/static/js/index.ep0QJQk3.js +203 -0
- streamlit/static/static/js/index.f0VnAfoO.js +1 -0
- streamlit/static/static/js/index.l49xBSOh.js +73 -0
- streamlit/static/static/js/{index.CoX57Z0X.js → index.v5B-faMq.js} +1 -1
- streamlit/static/static/js/{index.B4JhHRj2.js → index.ydk_VgsB.js} +1 -1
- streamlit/static/static/js/{input.CS80Xua3.js → input.D6h4j3mu.js} +2 -2
- streamlit/static/static/js/{memory.CQi1cX_3.js → memory.BE4D3Ruc.js} +1 -1
- streamlit/static/static/js/{mergeWith.DJ7CCTEU.js → mergeWith.CfZBFCuT.js} +1 -1
- streamlit/static/static/js/{number-overlay-editor.AKoeruM9.js → number-overlay-editor.BGuXja4w.js} +1 -1
- streamlit/static/static/js/{possibleConstructorReturn.Bwr97hsW.js → possibleConstructorReturn.GfM_znXN.js} +1 -1
- streamlit/static/static/js/{sandbox.e5w1ytIc.js → sandbox.SNug_eHS.js} +1 -1
- streamlit/static/static/js/{textarea.CzJ9CBYF.js → textarea.C9gOMijs.js} +2 -2
- streamlit/static/static/js/{timepicker.BfekZ8nu.js → timepicker.DnkicraE.js} +1 -1
- streamlit/static/static/js/{toConsumableArray.CcdFZhvv.js → toConsumableArray.CwiePuJG.js} +1 -1
- streamlit/static/static/js/{uniqueId.Cyxi17MX.js → uniqueId.BzT4v6M6.js} +1 -1
- streamlit/static/static/js/{useBasicWidgetState.D5X8duhc.js → useBasicWidgetState.DKA7kWgD.js} +1 -1
- streamlit/static/static/js/{useOnInputChange.yxiBziRU.js → useOnInputChange.mkVXolML.js} +1 -1
- streamlit/static/static/js/{withFullScreenWrapper.Bq7KZt-c.js → withFullScreenWrapper.CfWBIrsM.js} +1 -1
- {streamlit_nightly-1.42.3.dev20250302.dist-info → streamlit_nightly-1.43.1.dev20250306.dist-info}/METADATA +1 -1
- {streamlit_nightly-1.42.3.dev20250302.dist-info → streamlit_nightly-1.43.1.dev20250306.dist-info}/RECORD +88 -88
- streamlit/static/static/js/index.-uuuxAE7.js +0 -203
- streamlit/static/static/js/index.BrWH5gNy.js +0 -1
- streamlit/static/static/js/index.Bx0Be8iF.js +0 -73
- streamlit/static/static/js/index.C2ER1qQG.js +0 -1
- streamlit/static/static/js/index.CTymsTTB.js +0 -1
- streamlit/static/static/js/index.CV1vqu8X.js +0 -1
- streamlit/static/static/js/index.Cf6Pj8Jt.js +0 -1
- streamlit/static/static/js/index.HMmByEVP.js +0 -1
- streamlit/static/static/js/index.T6yaPTmV.js +0 -1
- streamlit/static/static/js/index.kIzrb8qK.js +0 -1
- {streamlit_nightly-1.42.3.dev20250302.data → streamlit_nightly-1.43.1.dev20250306.data}/scripts/streamlit.cmd +0 -0
- {streamlit_nightly-1.42.3.dev20250302.dist-info → streamlit_nightly-1.43.1.dev20250306.dist-info}/WHEEL +0 -0
- {streamlit_nightly-1.42.3.dev20250302.dist-info → streamlit_nightly-1.43.1.dev20250306.dist-info}/entry_points.txt +0 -0
- {streamlit_nightly-1.42.3.dev20250302.dist-info → streamlit_nightly-1.43.1.dev20250306.dist-info}/top_level.txt +0 -0
@@ -1 +0,0 @@
|
|
1
|
-
import{n as t,b3 as k,I as b,b4 as s,b5 as l,j as n,r as v,b6 as C,b7 as B,b8 as S}from"./index.DFLL-J15.js";function x(o,i){switch(o){case s.XSMALL:return{padding:`${i.spacing.twoXS} ${i.spacing.sm}`,fontSize:i.fontSizes.sm};case s.SMALL:return{padding:`${i.spacing.twoXS} ${i.spacing.md}`};case s.LARGE:return{padding:`${i.spacing.md} ${i.spacing.md}`};default:return{padding:`${i.spacing.xs} ${i.spacing.md}`}}}const u=t("a",{target:"e11ko9n80"})(({fluidWidth:o,size:i,theme:r})=>({display:"inline-flex",alignItems:"center",justifyContent:"center",fontWeight:r.fontWeights.normal,padding:`${r.spacing.xs} ${r.spacing.md}`,borderRadius:r.radii.default,minHeight:r.sizes.minElementHeight,margin:0,lineHeight:r.lineHeights.base,color:r.colors.primary,textDecoration:"none",width:o?"100%":"auto",userSelect:"none","&:visited":{color:r.colors.primary},"&:focus":{outline:"none"},"&:focus-visible":{boxShadow:`0 0 0 0.2rem ${b(r.colors.primary,.5)}`},"&:hover":{textDecoration:"none"},"&:active":{textDecoration:"none"},...x(i,r)})),L=t(u,{target:"e11ko9n81"})(({theme:o})=>({backgroundColor:o.colors.primary,color:o.colors.white,border:`${o.sizes.borderWidth} solid ${o.colors.primary}`,"&:hover":{backgroundColor:k(o.colors.primary,.05),color:o.colors.white},"&:active":{backgroundColor:"transparent",color:o.colors.primary},"&:visited:not(:active)":{color:o.colors.white},"&[disabled], &[disabled]:hover, &[disabled]:active, &[disabled]:visited":{borderColor:o.colors.borderColor,backgroundColor:o.colors.transparent,color:o.colors.fadedText40,cursor:"not-allowed"}})),$=t(u,{target:"e11ko9n82"})(({theme:o})=>({backgroundColor:o.colors.lightenedBg05,color:o.colors.bodyText,border:`${o.sizes.borderWidth} solid ${o.colors.borderColor}`,"&:visited":{color:o.colors.bodyText},"&:hover":{borderColor:o.colors.primary,color:o.colors.primary},"&:active":{color:o.colors.white,borderColor:o.colors.primary,backgroundColor:o.colors.primary},"&:focus:not(:active)":{borderColor:o.colors.primary,color:o.colors.primary},"&[disabled], &[disabled]:hover, &[disabled]:active":{borderColor:o.colors.borderColor,backgroundColor:o.colors.transparent,color:o.colors.fadedText40,cursor:"not-allowed"}})),w=t(u,{target:"e11ko9n83"})(({theme:o})=>({padding:o.spacing.none,backgroundColor:o.colors.transparent,color:o.colors.bodyText,border:"none","&:visited":{color:o.colors.bodyText},"&:hover":{color:o.colors.primary},"&:active":{color:o.colors.primary},"&:focus":{outline:"none"},"&:focus-visible":{color:o.colors.primary,boxShadow:`0 0 0 0.2rem ${b(o.colors.primary,.5)}`},"&[disabled], &[disabled]:hover, &[disabled]:active":{backgroundColor:o.colors.transparent,color:o.colors.fadedText40,cursor:"not-allowed"}}));function T({kind:o,size:i,disabled:r,fluidWidth:a,children:c,autoFocus:d,href:p,rel:g,target:y,onClick:f}){let e=L;return o===l.SECONDARY?e=$:o===l.TERTIARY&&(e=w),n(e,{kind:o,size:i||s.MEDIUM,fluidWidth:a||!1,disabled:r||!1,autoFocus:d||!1,href:p,target:y,rel:g,onClick:f,tabIndex:r?-1:0,"data-testid":`stBaseLinkButton-${o}`,children:c})}function z(o){const{disabled:i,element:r}=o;let a=l.SECONDARY;r.type==="primary"?a=l.PRIMARY:r.type==="tertiary"&&(a=l.TERTIARY);const c=d=>{o.disabled&&d.preventDefault()};return n(S,{className:"stLinkButton","data-testid":"stLinkButton",children:n(C,{help:r.help,children:n(T,{kind:a,size:s.SMALL,disabled:i,onClick:c,fluidWidth:r.useContainerWidth||!!r.help,href:r.url,target:"_blank",rel:"noreferrer","aria-disabled":i,children:n(B,{icon:r.icon,label:r.label})})})})}const A=v.memo(z);export{A as default};
|
@@ -1,73 +0,0 @@
|
|
1
|
-
import{r as u,E as $,_ as H,aW as ut,bk as Ht,bl as Vt,bm as jt,L as G,N as X,R as yt,aD as Gt,n as x,bn as Xt,B as N,j as v,bo as qt,b5 as Yt,bp as Kt,bq as Jt,as as Qt,y as Zt,br as Z,G as te,aA as ee,bs as ie,bt as se,ba as ne,bu as re}from"./index.DFLL-J15.js";import{u as oe,F as ae}from"./FormClearHelper.DzssExOY.js";import{T as le,a as pt}from"./Toolbar.BNy6-0V9.js";import{u as ce}from"./Hooks.X18-6oCR.js";import{c as de}from"./createDownloadLinkElement.DZMwyjvU.js";import{F as he,D as ue}from"./FileDownload.esm.MU0nAJxt.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 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 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"}))});St.displayName="Pause";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 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"}))});Ct.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 z 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=S=>{if(S.preventDefault(),S.stopPropagation(),d&&Date.now()-b<o)return;const D=S.clientX,T=S.clientY,M=D-h,A=T-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,T-O),h=D,m=T}},w=S=>{if(f){const D=S.clientX,T=S.clientY,M=t.getBoundingClientRect(),{left:A,top:I}=M;r==null||r(D-A,T-I)}c()},y=S=>{S.relatedTarget&&S.relatedTarget!==document.documentElement||w(S)},P=S=>{f&&(S.stopPropagation(),S.preventDefault())},W=S=>{f&&S.preventDefault()};document.addEventListener("pointermove",g),document.addEventListener("pointerup",w),document.addEventListener("pointerout",y),document.addEventListener("pointercancel",y),document.addEventListener("touchmove",W,{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",W),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
|
-
<style${i?` nonce="${i}"`:""}>
|
3
|
-
:host {
|
4
|
-
user-select: none;
|
5
|
-
min-width: 1px;
|
6
|
-
}
|
7
|
-
:host audio {
|
8
|
-
display: block;
|
9
|
-
width: 100%;
|
10
|
-
}
|
11
|
-
:host .scroll {
|
12
|
-
overflow-x: auto;
|
13
|
-
overflow-y: hidden;
|
14
|
-
width: 100%;
|
15
|
-
position: relative;
|
16
|
-
}
|
17
|
-
:host .noScrollbar {
|
18
|
-
scrollbar-color: transparent;
|
19
|
-
scrollbar-width: none;
|
20
|
-
}
|
21
|
-
:host .noScrollbar::-webkit-scrollbar {
|
22
|
-
display: none;
|
23
|
-
-webkit-appearance: none;
|
24
|
-
}
|
25
|
-
:host .wrapper {
|
26
|
-
position: relative;
|
27
|
-
overflow: visible;
|
28
|
-
z-index: 2;
|
29
|
-
}
|
30
|
-
:host .canvases {
|
31
|
-
min-height: ${this.getHeight(this.options.height,this.options.splitChannels)}px;
|
32
|
-
}
|
33
|
-
:host .canvases > div {
|
34
|
-
position: relative;
|
35
|
-
}
|
36
|
-
:host canvas {
|
37
|
-
display: block;
|
38
|
-
position: absolute;
|
39
|
-
top: 0;
|
40
|
-
image-rendering: pixelated;
|
41
|
-
}
|
42
|
-
:host .progress {
|
43
|
-
pointer-events: none;
|
44
|
-
position: absolute;
|
45
|
-
z-index: 2;
|
46
|
-
top: 0;
|
47
|
-
left: 0;
|
48
|
-
width: 0;
|
49
|
-
height: 100%;
|
50
|
-
overflow: hidden;
|
51
|
-
}
|
52
|
-
:host .progress > div {
|
53
|
-
position: relative;
|
54
|
-
}
|
55
|
-
:host .cursor {
|
56
|
-
pointer-events: none;
|
57
|
-
position: absolute;
|
58
|
-
z-index: 5;
|
59
|
-
top: 0;
|
60
|
-
left: 0;
|
61
|
-
height: 100%;
|
62
|
-
border-radius: 2px;
|
63
|
-
}
|
64
|
-
</style>
|
65
|
-
|
66
|
-
<div class="scroll" part="scroll">
|
67
|
-
<div class="wrapper" part="wrapper">
|
68
|
-
<div class="canvases" part="canvases"></div>
|
69
|
-
<div class="progress" part="progress"></div>
|
70
|
-
<div class="cursor" part="cursor"></div>
|
71
|
-
</div>
|
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 W=0;W<=o;W++){const S=Math.round(W*b);if(S>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=S,y=0,P=0}const D=Math.abs(n[W]||0),T=Math.abs(a[W]||0);D>y&&(y=D),T>P&&(P=T)}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(z.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(W=>{const S=Math.floor(w/c*W.length),D=Math.floor((w+y)/c*W.length);return W.slice(S,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>z.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)})))})}}z.MAX_CANVAS_WIDTH=8e3,z.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 z(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 Se=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]},Ce=(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})),Wt=x("div",{target:"etzg8g85"})({width:"100%",textAlign:"center",overflow:"hidden"}),Dt=x("span",{target:"etzg8g86"})(({theme:s})=>({color:s.colors.bodyText})),We=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"})),Te=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}})),Tt=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=()=>N(Wt,{children:[v(Dt,{children:"This app would like to use your microphone."})," ",v(We,{href:qt,children:"Learn how to allow access."})]}),Oe=()=>v(De,{children:v(Te,{})}),Be=4,Ne=4,ze=4,Ue=8,Fe=0,j="00:00",bt=s=>{const t=Math.floor(s/1e3),e=Math.floor(t/60),i=Math.floor(e/60),r=t%60,n=e%60,a=r.toString().padStart(2,"0"),o=n.toString().padStart(2,"0"),d=i.toString().padStart(2,"0");return e<60?`${o}:${a}`:`${d}:${o}:${a}`},_=({onClick:s,disabled:t,ariaLabel:e,iconContent:i})=>v(Jt,{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(Tt,{children:t?v(_,{onClick:e,disabled:s,ariaLabel:"Pause",iconContent:St}):v(_,{onClick:e,disabled:s,ariaLabel:"Play",iconContent:Ct})}),He=({disabled:s,startRecording:t})=>v(ke,{children:v(_,{onClick:t,disabled:s,ariaLabel:"Record",iconContent:wt})}),Ve=({onClick:s})=>v(Tt,{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"})}):N(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=Qt.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(Wt,{children:v(Dt,{children:"An error has occurred, please try again."})}),Je=({element:s,uploadClient:t,widgetMgr:e,fragmentId:i,disabled:r})=>{var ht;const n=Zt(),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}),[,W]=u.useState(0),S=()=>{W(C=>C+1)},[D,T]=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 C=>{nt(!0),X(L)&&e.setFormsWithUploadsInProgress(new Set([L]));let R;if(C.type==="audio/wav"?R=C:R=await qe(C),!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),Se({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 Q=_t[0];Q&&Q.fileUrl.deleteUrl&&p(Q.fileUrl.deleteUrl)}).finally(()=>{X(L)&&e.setFormsWithUploadsInProgress(new Set),nt(!1)})},[P,t,e,rt,L,i,p]),B=u.useCallback(({updateWidgetManager:C,deleteFile:R})=>{G(o)||G(l)||(P(null),o.empty(),R&&t.deleteFile(l),p(null),T(j),A(j),C&&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 C=new ae;return C.manageFormClearListener(e,L,()=>B({updateWidgetManager:!0,deleteFile:!1})),()=>C.disconnect()},[L,B,e]);const at=u.useCallback(()=>{if(c.current===null)return;const C=F.create({container:c.current,waveColor:y?Z(n.colors.fadedText40,n.colors.secondaryBg):n.colors.primary,progressColor:n.colors.bodyText,height:te(n.sizes.largestElementHeight)-2*Be,barWidth:Ne,barGap:ze,barRadius:Ue,cursorWidth:Fe,url:y??void 0});C.on("timeupdate",k=>{T(bt(k*1e3))}),C.on("pause",()=>{S()});const R=C.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(C),m(R),()=>{C&&C.destroy(),R&&R.destroy()}},[ot]);u.useEffect(()=>at(),[at]),u.useEffect(()=>{ee(a,n)||o==null||o.setOptions({waveColor:y?Z(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),S())},[o]),Lt=u.useCallback(async()=>{let C=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),C=k}})).catch(R=>{At(!0)}),kt(!0)),!(!h||!C||!o)&&(o.setOptions({waveColor:n.colors.primary}),y&&B({updateWidgetManager:!1,deleteFile:!0}),h.startRecording({deviceId:C}).then(()=>{S()}))},[g,h,n,o,y,B,st]),Ot=u.useCallback(()=>{h&&(h.stopRecording(),o==null||o.setOptions({waveColor:Z(n.colors.fadedText40,n.colors.secondaryBg)}))},[h,o,n]),Bt=Ce(y,"recording.wav"),J=!!(h!=null&&h.isRecording()),lt=!!(o!=null&&o.isPlaying()),Nt=J||lt,ct=!J&&!y&&!O,zt=O||ct||Y,dt=r||O;return N(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})})}),N(vt,{children:[N(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:J,isPlaying:lt,isUploading:Mt,isError:Y,recordingUrlExists:!!y,startRecording:Lt,stopRecording:Ot,onClickPlayPause:It,onClear:()=>{B({updateWidgetManager:!1,deleteFile:!0}),K(!1)},disabled:dt}),N(Ee,{children:[Y&&v(Ke,{}),ct&&v(Oe,{}),O&&v(Le,{}),v(xe,{"data-testid":"stAudioInputWaveSurfer",ref:c,show:!zt})]}),v(Pe,{isPlayingOrRecording:Nt,"data-testid":"stAudioInputWaveformTimeCode",children:I?D:M})]})]})},ri=u.memo(Je);export{ri as default};
|
@@ -1 +0,0 @@
|
|
1
|
-
import{r as g,E as z,_ as C,n as d,G as $,B as p,j as n,bp as m,bq as f,b4 as j,b5 as y,cp as O,cq as q,aZ as G,F as _,bi as K,R as Y,aA as Z,bk as J,L as h,bm as Q,bl as ee,bs as te,bF as ie,bt as se,ba as le,bu as ae}from"./index.DFLL-J15.js";import{a as x}from"./index.C88pvD_q.js";import{F as ne}from"./FormClearHelper.DzssExOY.js";import{g as b,F,b as oe,D as re,I as de,C as ce,a as pe,s as ge}from"./FileHelper.D-6vwsT7.js";import{S as ue,P as he}from"./ProgressBar.REkskfZ6.js";import{u as me}from"./Hooks.X18-6oCR.js";import{U}from"./UploadFileInfo.C-jY39rj.js";var M=g.forwardRef(function(e,s){var t={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return g.createElement(z,C({iconAttrs:t,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},e,{ref:s}),g.createElement("path",{fill:"none",d:"M0 0h24v24H0V0z"}),g.createElement("path",{d:"M19.35 10.04A7.49 7.49 0 0012 4C9.11 4 6.6 5.64 5.35 8.04A5.994 5.994 0 000 14c0 3.31 2.69 6 6 6h13c2.76 0 5-2.24 5-5 0-2.64-2.05-4.78-4.65-4.96zM19 18H6c-2.21 0-4-1.79-4-4 0-2.05 1.53-3.76 3.56-3.97l1.07-.11.5-.95A5.469 5.469 0 0112 6c2.62 0 4.88 1.86 5.39 4.43l.3 1.5 1.53.11A2.98 2.98 0 0122 15c0 1.65-1.35 3-3 3zM8 13h2.55v3h2.9v-3H16l-4-4z"}))});M.displayName="CloudUpload";var B=g.forwardRef(function(e,s){var t={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return g.createElement(z,C({iconAttrs:t,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},e,{ref:s}),g.createElement("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z"}))});B.displayName="Error";const V=d("section",{target:"e17y52ym0"})(({isDisabled:e,theme:s})=>({display:"flex",alignItems:"center",padding:s.spacing.lg,backgroundColor:s.colors.secondaryBg,borderRadius:s.radii.default,border:s.colors.widgetBorderColor?`${s.sizes.borderWidth} solid ${s.colors.widgetBorderColor}`:void 0,":focus":{outline:"none"},":focus-visible":{boxShadow:`0 0 0 1px ${s.colors.primary}`},color:e?s.colors.gray:s.colors.bodyText})),D=d("div",{target:"e17y52ym1"})({marginRight:"auto",alignItems:"center",display:"flex"}),P=d("span",{target:"e17y52ym2"})(({theme:e})=>({color:e.colors.darkenedBgMix100,marginRight:e.spacing.lg})),fe=d("span",{target:"e17y52ym3"})(({theme:e})=>({marginBottom:e.spacing.twoXS})),ye=d("div",{target:"e17y52ym4"})({display:"flex",flexDirection:"column"}),L=d("div",{target:"e17y52ym5"})(({theme:e})=>({left:0,right:0,lineHeight:e.lineHeights.tight,paddingTop:e.spacing.md,paddingLeft:e.spacing.lg,paddingRight:e.spacing.lg})),Fe=d("ul",{target:"e17y52ym6"})(({theme:e})=>({listStyleType:"none",margin:e.spacing.none,padding:e.spacing.none})),A=d("li",{target:"e17y52ym7"})(({theme:e})=>({margin:e.spacing.none,padding:e.spacing.none})),E=d("div",{target:"e17y52ym8"})(({theme:e})=>({display:"flex",alignItems:"baseline",flex:1,paddingLeft:e.spacing.lg,overflow:"hidden"})),W=d("div",{target:"e17y52ym9"})(({theme:e})=>({marginRight:e.spacing.sm,marginBottom:e.spacing.twoXS,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"})),k=d("div",{target:"e17y52ym10"})(({theme:e})=>({display:"flex",alignItems:"center",marginBottom:e.spacing.twoXS})),Se=d("span",{target:"e17y52ym11"})(({theme:e})=>({marginRight:e.spacing.twoXS})),Ue=d("div",{target:"e17y52ym12"})(({theme:e})=>({display:"flex",padding:e.spacing.twoXS,color:e.colors.darkenedBgMix100})),R=d("small",{target:"e17y52ym13"})(({theme:e})=>({color:e.colors.danger,fontSize:e.fontSizes.sm,height:e.fontSizes.sm,lineHeight:e.fontSizes.sm,display:"flex",alignItems:"center",whiteSpace:"nowrap"})),N=d("span",{target:"e17y52ym14"})({}),we=e=>({[V]:{display:"flex",flexDirection:"column",alignItems:"flex-start"},[D]:{marginBottom:e.spacing.lg},[P]:{display:"none"},[L]:{paddingRight:e.spacing.lg},[k]:{maxWidth:"inherit",flex:1,alignItems:"flex-start",marginBottom:e.spacing.sm},[W]:{width:e.sizes.full},[E]:{flexDirection:"column"},[R]:{height:"auto",whiteSpace:"initial"},[N]:{display:"none"},[A]:{margin:e.spacing.none,padding:e.spacing.none}}),xe=d("div",{target:"e17y52ym15"})(({theme:e,width:s})=>{if(s<$("23rem"))return we(e)});var I;(function(e){e.DANGER="danger"})(I||(I={}));const w=d("small",{target:"ejh2rmr0"})(({kind:e,theme:s})=>{const{danger:t,fadedText60:i}=s.colors;return{color:e==="danger"?t:i,fontSize:s.fontSizes.sm,lineHeight:s.lineHeights.tight}}),Ie=({multiple:e,acceptedExtensions:s,maxSizeBytes:t})=>p(D,{"data-testid":"stFileUploaderDropzoneInstructions",children:[n(P,{children:n(m,{content:M,size:"threeXL"})}),p(ye,{children:[p(fe,{children:["Drag and drop file",e?"s":""," here"]}),p(w,{children:[`Limit ${b(t,F.Byte,0)} per file`,s.length?` • ${s.map(i=>i.replace(/^\./,"").toUpperCase()).join(", ")}`:null]})]})]}),ve=({onDrop:e,multiple:s,acceptedExtensions:t,maxSizeBytes:i,disabled:l,label:o})=>n(re,{onDrop:e,multiple:s,accept:oe(t),maxSize:i,disabled:l,useFsAccessApi:!1,children:({getRootProps:a,getInputProps:r})=>p(V,{...a(),"data-testid":"stFileUploaderDropzone",isDisabled:l,"aria-label":o,children:[n("input",{"data-testid":"stFileUploaderDropzoneInput",...r()}),n(Ie,{multiple:s,acceptedExtensions:t,maxSizeBytes:i}),n(f,{kind:y.SECONDARY,disabled:l,size:j.SMALL,children:"Browse files"})]})}),ze=d("div",{target:"egc9vxm0"})(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",paddingBottom:e.spacing.twoXS,marginBottom:e.spacing.twoXS})),Ce=d("div",{target:"egc9vxm1"})(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"center",color:e.colors.fadedText40})),be=({currentPage:e,totalPages:s,onNext:t,onPrevious:i})=>p(ze,{"data-testid":"stFileUploaderPagination",children:[n(w,{children:`Showing page ${e} of ${s}`}),p(Ce,{children:[n(f,{onClick:i,kind:y.MINIMAL,children:n(m,{content:O,size:"xl"})}),n(f,{onClick:t,kind:y.MINIMAL,children:n(m,{content:q,size:"xl"})})]})]}),v=(e,s)=>Math.ceil(e.length/s),Me=e=>G(({pageSize:t,items:i,resetOnAdd:l,...o})=>{const[a,r]=g.useState(0),[c,S]=g.useState(v(i,t)),u=me(i);g.useEffect(()=>{u&&u.length!==i.length&&S(v(i,t)),u&&u.length<i.length?l&&r(0):a+1>=c&&r(c-1)},[i,a,t,u,l,c]);const T=()=>{r(Math.min(a+1,c-1))},H=()=>{r(Math.max(0,a-1))},X=i.slice(a*t,a*t+t);return p(_,{children:[n(e,{items:X,...o}),i.length>t?n(be,{pageSize:t,totalPages:c,currentPage:a+1,onNext:T,onPrevious:H}):null]})},e),Be=({fileInfo:e})=>e.status.type==="uploading"?n(he,{value:e.status.progress,size:ue.SMALL}):e.status.type==="error"?p(R,{children:[n(Se,{"data-testid":"stFileUploaderFileErrorMessage",children:e.status.errorMessage}),n(N,{children:n(m,{content:B,size:"lg"})})]}):e.status.type==="uploaded"?n(w,{children:b(e.size,F.Byte)}):null,Ve=({fileInfo:e,onDelete:s})=>p(k,{className:"stFileUploaderFile","data-testid":"stFileUploaderFile",children:[n(Ue,{children:n(m,{content:de,size:"twoXL"})}),p(E,{className:"stFileUploaderFileData",children:[n(W,{className:"stFileUploaderFileName","data-testid":"stFileUploaderFileName",title:e.name,children:e.name}),n(Be,{fileInfo:e})]}),n("div",{"data-testid":"stFileUploaderDeleteBtn",children:n(f,{onClick:()=>s(e.id),kind:y.MINIMAL,children:n(m,{content:ce,size:"lg"})})})]}),De=({items:e,onDelete:s})=>n(Fe,{children:e.map(t=>n(A,{children:n(Ve,{fileInfo:t,onDelete:s})},t.id))}),Pe=Me(De),Le=e=>n(L,{children:n(Pe,{...e})});class Ae extends Y.PureComponent{constructor(s){super(s),this.formClearHelper=new ne,this.localFileIdCounter=1,this.forceUpdatingStatus=!1,this.componentDidUpdate=()=>{if(this.status!=="ready")return;const t=this.createWidgetValue(),{element:i,widgetMgr:l,fragmentId:o}=this.props,a=l.getFileUploaderStateValue(i);Z(t,a)||l.setFileUploaderStateValue(i,t,{fromUi:!0},o)},this.reset=()=>{this.setState({files:[]})},this.dropHandler=(t,i)=>{const{element:l}=this.props,{multipleFiles:o}=l;if(!o&&t.length===0&&i.length>1){const a=i.findIndex(r=>r.errors.length===1&&r.errors[0].code==="too-many-files");a>=0&&(t.push(i[a].file),i.splice(a,1))}if(this.props.uploadClient.fetchFileURLs(t).then(a=>{if(!o&&t.length>0){const r=this.state.files.find(c=>c.status.type!=="error");r&&(this.forceUpdatingStatus=!0,this.deleteFile(r.id),this.forceUpdatingStatus=!1)}J(a,t).forEach(([r,c])=>{this.uploadFile(r,c)})}).catch(a=>{this.addFiles(t.map(r=>new U(r.name,r.size,this.nextLocalFileId(),{type:"error",errorMessage:a})))}),i.length>0){const a=i.map(r=>pe(r,this.nextLocalFileId(),this.maxUploadSizeInBytes));this.addFiles(a)}},this.uploadFile=(t,i)=>{const l=x.CancelToken.source(),o=new U(i.name,i.size,this.nextLocalFileId(),{type:"uploading",cancelToken:l,progress:1});this.addFile(o),this.props.uploadClient.uploadFile(this.props.element,t.uploadUrl,i,a=>this.onUploadProgress(a,o.id),l.token).then(()=>this.onUploadComplete(o.id,t)).catch(a=>{x.isCancel(a)||this.updateFile(o.id,o.setStatus({type:"error",errorMessage:a?a.toString():"Unknown error"}))})},this.onUploadComplete=(t,i)=>{const l=this.getFile(t);h(l)||l.status.type!=="uploading"||this.updateFile(l.id,l.setStatus({type:"uploaded",fileId:i.fileId,fileUrls:i}))},this.deleteFile=t=>{const i=this.getFile(t);h(i)||(i.status.type==="uploading"&&i.status.cancelToken.cancel(),i.status.type==="uploaded"&&i.status.fileUrls.deleteUrl&&this.props.uploadClient.deleteFile(i.status.fileUrls.deleteUrl),this.removeFile(t))},this.addFile=t=>{this.setState(i=>({files:[...i.files,t]}))},this.addFiles=t=>{this.setState(i=>({files:[...i.files,...t]}))},this.removeFile=t=>{this.setState(i=>({files:i.files.filter(l=>l.id!==t)}))},this.getFile=t=>this.state.files.find(i=>i.id===t),this.updateFile=(t,i)=>{this.setState(l=>({files:l.files.map(o=>o.id===t?i:o)}))},this.onUploadProgress=(t,i)=>{const l=this.getFile(i);if(h(l)||l.status.type!=="uploading")return;const o=Math.round(t.loaded*100/t.total);l.status.progress!==o&&this.updateFile(i,l.setStatus({type:"uploading",cancelToken:l.status.cancelToken,progress:o}))},this.onFormCleared=()=>{this.setState({files:[]},()=>{const t=this.createWidgetValue();if(h(t))return;const{widgetMgr:i,element:l,fragmentId:o}=this.props;i.setFileUploaderStateValue(l,t,{fromUi:!0},o)})},this.state=this.initialValue}get initialValue(){const s={files:[],newestServerFileId:0},{widgetMgr:t,element:i}=this.props,l=t.getFileUploaderStateValue(i);if(h(l))return s;const{uploadedFileInfo:o}=l;return h(o)||o.length===0?s:{files:o.map(a=>{const r=a.name,c=a.size,S=a.fileId,u=a.fileUrls;return new U(r,c,this.nextLocalFileId(),{type:"uploaded",fileId:S,fileUrls:u})})}}componentWillUnmount(){this.formClearHelper.disconnect()}get maxUploadSizeInBytes(){const s=this.props.element.maxUploadSizeMb;return ge(s,F.Megabyte,F.Byte)}get status(){const s=t=>t.status.type==="uploading";return this.state.files.some(s)||this.forceUpdatingStatus?"updating":"ready"}componentDidMount(){const s=this.createWidgetValue(),{element:t,widgetMgr:i,fragmentId:l}=this.props;i.getFileUploaderStateValue(t)===void 0&&i.setFileUploaderStateValue(t,s,{fromUi:!1},l)}createWidgetValue(){const s=this.state.files.filter(t=>t.status.type==="uploaded").map(t=>{const{name:i,size:l,status:o}=t,{fileId:a,fileUrls:r}=o;return new Q({fileId:a,fileUrls:r,name:i,size:l})});return new ee({uploadedFileInfo:s})}render(){var c;const{files:s}=this.state,{element:t,disabled:i,widgetMgr:l,width:o}=this.props,a=t.type;this.formClearHelper.manageFormClearListener(l,t.formId,this.onFormCleared);const r=s.slice().reverse();return p(xe,{className:"stFileUploader","data-testid":"stFileUploader",width:o,children:[n(ae,{label:t.label,disabled:i,labelVisibility:te((c=t.labelVisibility)==null?void 0:c.value),children:t.help&&n(ie,{children:n(se,{content:t.help,placement:le.TOP_RIGHT})})}),n(ve,{onDrop:this.dropHandler,multiple:t.multipleFiles,acceptedExtensions:a,maxSizeBytes:this.maxUploadSizeInBytes,label:t.label,disabled:i}),r.length>0&&n(Le,{items:r,pageSize:3,onDelete:this.deleteFile,resetOnAdd:!0})]})}nextLocalFileId(){return this.localFileIdCounter++}}const Xe=K(g.memo(Ae));export{Xe as default};
|
@@ -1 +0,0 @@
|
|
1
|
-
import{n as V,bi as U,r as i,bj as P,j as l}from"./index.DFLL-J15.js";const R=V("iframe",{target:"eymnmwl0"})(({theme:a})=>({colorScheme:"normal",border:"none",padding:a.spacing.none,margin:a.spacing.none,width:"100%",aspectRatio:"16 / 9"})),w=528;function A({element:a,width:f,endpoints:m,elementMgr:c}){const n=i.useRef(null),{type:E,url:p,startTime:o,subtitles:y,endTime:d,loop:u,autoplay:T,muted:h}=a,S=i.useMemo(()=>{if(!a.id)return!0;const e=c.getElementState(a.id,"preventAutoplay");return e||c.setElementState(a.id,"preventAutoplay",!0),e??!1},[a.id,c]);i.useEffect(()=>{n.current&&(n.current.currentTime=o)},[o]),i.useEffect(()=>{const e=n.current,t=()=>{e&&(e.currentTime=a.startTime)};return e&&e.addEventListener("loadedmetadata",t),()=>{e&&e.removeEventListener("loadedmetadata",t)}},[a]),i.useEffect(()=>{const e=n.current;if(!e)return;let t=!1;const s=()=>{d>0&&e.currentTime>=d&&(u?(e.currentTime=o||0,e.play()):t||(t=!0,e.pause()))};return d>0&&e.addEventListener("timeupdate",s),()=>{e&&d>0&&e.removeEventListener("timeupdate",s)}},[d,u,o]),i.useEffect(()=>{const e=n.current;if(!e)return;const t=()=>{u&&(e.currentTime=o||0,e.play())};return e.addEventListener("ended",t),()=>{e&&e.removeEventListener("ended",t)}},[u,o]);const g=e=>{const{startTime:t,endTime:s,loop:L,autoplay:b,muted:N}=a,r=new URL(e);if(t&&!isNaN(t)&&r.searchParams.append("start",t.toString()),s&&!isNaN(s)&&r.searchParams.append("end",s.toString()),L){r.searchParams.append("loop","1");const v=r.pathname.split("/").pop();v&&r.searchParams.append("playlist",v)}return b&&r.searchParams.append("autoplay","1"),N&&r.searchParams.append("mute","1"),r.toString()};return E===P.Type.YOUTUBE_IFRAME?l(R,{className:"stVideo","data-testid":"stVideo",title:p,src:g(p),allow:"autoplay; encrypted-media",allowFullScreen:!0}):l("video",{className:"stVideo","data-testid":"stVideo",ref:n,controls:!0,muted:h,autoPlay:T&&!S,src:m.buildMediaURL(p),style:{width:f,height:f===0?w:void 0},crossOrigin:void 0,children:y&&y.map((e,t)=>l("track",{kind:"captions",src:m.buildMediaURL(`${e.url}`),label:`${e.label}`,default:t===0},t))})}const $=U(i.memo(A));export{$ as default};
|
@@ -1 +0,0 @@
|
|
1
|
-
import{r as l,E as $,_ as N,n as u,A as mt,y as A,j as n,ba as Q,bv as vt,B as z,bq as Z,b5 as tt,bp as H,a$ as yt,bG as wt,bk as Ct,bH as I,bt as It,F as et,bh as xt,bI as bt,L as R,bm as St,bl as zt}from"./index.DFLL-J15.js";import{g as Ft,F as V,C as Et,I as Ut,E as Ht,a as Tt,s as Bt,u as Dt,b as Rt}from"./FileHelper.D-6vwsT7.js";import{I as Lt}from"./InputInstructions.DMffPiri.js";import{i as Mt}from"./inputUtils.CQWz5UKz.js";import{a as J}from"./index.C88pvD_q.js";import{U as ot}from"./UploadFileInfo.C-jY39rj.js";import{T as kt}from"./textarea.CzJ9CBYF.js";import"./base-input.DDph5ZTh.js";var nt=l.forwardRef(function(t,e){var r={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return l.createElement($,N({iconAttrs:r,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},t,{ref:e}),l.createElement("path",{fill:"none",d:"M0 0h24v24H0V0z"}),l.createElement("path",{d:"M16.5 6v11.5c0 2.21-1.79 4-4 4s-4-1.79-4-4V5a2.5 2.5 0 015 0v10.5c0 .55-.45 1-1 1s-1-.45-1-1V6H10v9.5a2.5 2.5 0 005 0V5c0-2.21-1.79-4-4-4S7 2.79 7 5v12.5c0 3.04 2.46 5.5 5.5 5.5s5.5-2.46 5.5-5.5V6h-1.5z"}))});nt.displayName="AttachFile";var at=l.forwardRef(function(t,e){var r={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return l.createElement($,N({iconAttrs:r,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},t,{ref:e}),l.createElement("path",{d:"M11 15h2v2h-2v-2zm0-8h2v6h-2V7zm.99-5C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"}))});at.displayName="ErrorOutline";var rt=l.forwardRef(function(t,e){var r={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return l.createElement($,N({iconAttrs:r,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},t,{ref:e}),l.createElement("rect",{width:24,height:24,fill:"none"}),l.createElement("path",{d:"M3 5.51v3.71c0 .46.31.86.76.97L11 12l-7.24 1.81c-.45.11-.76.51-.76.97v3.71c0 .72.73 1.2 1.39.92l15.42-6.49c.82-.34.82-1.5 0-1.84L4.39 4.58C3.73 4.31 3 4.79 3 5.51z"}))});rt.displayName="Send";const Vt=u("div",{target:"e1togvvn0"})("border:none;position:relative;display:flex;"),$t=u("div",{target:"e1togvvn1"})(({theme:t,extended:e})=>({border:`${t.sizes.borderWidth} solid`,borderColor:t.colors.widgetBorderColor??t.colors.transparent,borderRadius:t.radii.chatInput,backgroundColor:t.colors.secondaryBg,position:"relative",flexGrow:1,display:"flex",alignItems:"center",paddingLeft:t.spacing.lg,maxHeight:e?"none":t.sizes.minElementHeight,gap:t.spacing.sm,overflow:"hidden",":focus-within":{borderColor:t.colors.primary}})),Nt=u("button",{target:"e1togvvn2"})(({theme:t,disabled:e,extended:r})=>{const d=mt(t),[f,c]=d?[t.colors.gray60,t.colors.gray80]:[t.colors.gray80,t.colors.gray40];return{border:"none",backgroundColor:t.colors.transparent,borderTopRightRadius:r?"0":t.radii.chatInput,borderTopLeftRadius:r?t.radii.default:"0",borderBottomRightRadius:t.radii.chatInput,display:"inline-flex",alignItems:"center",justifyContent:"center",lineHeight:t.lineHeights.none,margin:t.spacing.none,padding:t.spacing.sm,color:e?f:c,pointerEvents:"auto","&:focus":{outline:"none"},":focus":{outline:"none"},"&:focus-visible":{backgroundColor:d?t.colors.gray10:t.colors.gray90},"&:hover":{color:t.colors.primary},"&:disabled, &:disabled:hover, &:disabled:active":{backgroundColor:t.colors.transparent,borderColor:t.colors.transparent,color:t.colors.gray,cursor:"not-allowed"}}}),At=u("div",{target:"e1togvvn3"})(({theme:t})=>({display:"flex",alignItems:"flex-end",height:"100%",position:"absolute",right:0,marginBottom:`-${t.sizes.borderWidth}`,pointerEvents:"none"})),Wt=u("div",{target:"e1togvvn4"})(({theme:t})=>({position:"absolute",bottom:"0px",right:`calc(${t.iconSizes.xl} + 2 * ${t.spacing.sm} + ${t.spacing.sm})`})),qt=u("div",{target:"ewqvugz0"})(({theme:t,height:e})=>({backgroundColor:t.colors.transparent,position:"absolute",left:0,bottom:0,minHeight:`max(${t.sizes.emptyDropdownHeight}, ${e})`,width:"100%",zIndex:t.zIndices.priority})),Pt=u("div",{target:"ewqvugz1"})(({theme:t,height:e})=>({border:`${t.sizes.borderWidth} solid`,borderColor:t.colors.primary,borderRadius:t.radii.chatInput,backgroundColor:t.colors.secondaryBg,color:t.colors.primary,display:"flex",alignItems:"center",justifyContent:"center",height:e,width:"100%",fontWeight:t.fontWeights.bold})),Ot=u("div",{target:"ewqvugz2"})(({theme:t,disabled:e})=>({display:"flex",alignItems:"top",height:"100%",marginTop:`-${t.sizes.borderWidth}`,cursor:e?"not-allowed":"auto"})),Kt=u("div",{target:"ewqvugz3"})(({disabled:t})=>({pointerEvents:t?"none":"auto"})),_t=u("div",{target:"ewqvugz4"})(({theme:t})=>({marginTop:"0.625em",marginLeft:t.spacing.sm,height:t.spacing.xl,width:t.sizes.borderWidth,backgroundColor:t.colors.fadedText20})),Xt=u("div",{target:"ewqvugz5"})(({theme:t})=>({left:0,right:0,lineHeight:t.lineHeights.tight,paddingLeft:t.spacing.sm,paddingRight:t.spacing.sm,overflowX:"auto"})),Gt=u("div",{target:"ewqvugz6"})(({})=>({display:"flex"})),jt=u("div",{target:"ewqvugz7"})(({})=>({flex:"0 0 auto"})),Yt=u("div",{target:"ewqvugz8"})(({theme:t})=>({display:"flex",alignItems:"center",padding:t.spacing.sm,gap:t.spacing.twoXS})),Jt=u("div",{target:"ewqvugz9"})(({theme:t})=>({color:t.colors.fadedText60})),Qt=u("div",{target:"ewqvugz10"})(({theme:t,fileStatus:e})=>({overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:e.type==="uploaded"?t.colors.bodyText:t.colors.fadedText60})),Zt=u("div",{target:"ewqvugz11"})(({theme:t})=>({marginRight:t.spacing.md,color:t.colors.fadedText60})),te=u("small",{target:"ewqvugz12"})(({theme:t})=>({display:"flex",alignItems:"center",maxHeight:t.sizes.smallElementHeight,color:t.colors.fadedText60,"& :hover":{color:t.colors.bodyText}}));function ee({children:t,content:e}){const r=A();return n(vt,{content:e,placement:Q.TOP,overrides:{Body:{style:{top:`-${r.sizes.minElementHeight}`}}},children:t})}const oe=({fileInfo:t})=>{const e=A(),{type:r}=t.status;switch(r){case"uploading":return n(wt,{usingCustomTheme:!1,"data-testid":"stChatInputFileIconSpinner",size:"lg",margin:"0",padding:"0"});case"error":return n(ee,{content:t.status.errorMessage,children:n(H,{color:e.colors.red,content:at,size:"lg"})});case"uploaded":return n(H,{content:Ut,size:"lg"});default:return yt(r),null}},ne=({fileInfo:t,onDelete:e})=>z(Yt,{className:"stChatInputFile","data-testid":"stChatInputFile",children:[n(Jt,{children:n(oe,{fileInfo:t})}),n(Qt,{className:"stChatInputFileName","data-testid":"stChatInputFileName",title:t.name,fileStatus:t.status,children:t.name}),n(Zt,{children:Ft(t.size,V.Byte)}),n(te,{"data-testid":"stChatInputDeleteBtn",children:n(Z,{onClick:()=>e(t.id),kind:tt.MINIMAL,children:n(H,{content:Et,size:"lg"})})})]}),ae=({items:t,onDelete:e})=>n(Xt,{"data-testid":"stChatUploadedFiles",children:n(Gt,{children:t.map(r=>n(jt,{children:n(ne,{fileInfo:r,onDelete:e})},r.id))})}),re=({getNextLocalFileId:t,addFiles:e,updateFile:r,uploadClient:d,element:f,onUploadProgress:c,onUploadComplete:m})=>(x,h)=>{const v=J.CancelToken.source(),g=new ot(h.name,h.size,t(),{type:"uploading",cancelToken:v,progress:1});e([g]),d.uploadFile({formId:"",...f},x.uploadUrl,h,p=>c(p,g.id),v.token).then(()=>m(g.id,x)).catch(p=>{J.isCancel(p)||r(g.id,g.setStatus({type:"error",errorMessage:p?p.toString():"Unknown error"}))})},ie=({acceptMultipleFiles:t,maxFileSize:e,uploadClient:r,uploadFile:d,addFiles:f,getNextLocalFileId:c,deleteExistingFiles:m,onUploadComplete:x})=>(h,v)=>{if(!t&&h.length===0&&v.length>1){const g=v.findIndex(p=>{var y;return((y=p.errors)==null?void 0:y[0].code)===Ht.TooManyFiles});g>=0&&(h.push(v[g].file),v.splice(g,1))}if(!t&&h.length>0&&m(),r.fetchFileURLs(h).then(g=>{Ct(g,h).forEach(([p,y])=>{d(p,y)})}).catch(g=>{f(h.map(p=>new ot(p.name,p.size,c(),{type:"error",errorMessage:g})))}),v.length>0){const g=v.map(p=>Tt(p,c(),e));f(g)}x()},se=({getRootProps:t,getInputProps:e,acceptFile:r,disabled:d,theme:f})=>z(Ot,{disabled:d,children:[z(Kt,{"data-testid":"stChatInputFileUploadButton",disabled:d,...t(),children:[n("input",{...e()}),n(It,{content:`Upload or drag and drop ${r===I.Multiple?"files":"a file"}`,placement:Q.TOP,onMouseEnterDelay:500,children:n(Z,{kind:tt.MINIMAL,disabled:d,children:n(H,{content:nt,size:"lg",color:d?f.colors.fadedText40:f.colors.fadedText60})})})]}),n(_t,{})]}),le=({getRootProps:t,getInputProps:e,acceptFile:r,inputHeight:d})=>z(et,{children:[n(qt,{height:d,...t(),children:n("input",{...e()})}),n(Pt,{height:d,children:`Drag and drop ${r===I.Multiple?"files":"a file"} here`})]}),de=6.5,L=1,M=(t,e,r)=>r.map(d=>d.id===t?e:d),k=(t,e)=>e.find(r=>r.id===t);function ce({disabled:t,element:e,widgetMgr:r,fragmentId:d,uploadClient:f}){const c=A(),m=l.useRef(null),x=l.useRef(0),h=l.useRef({minHeight:0,maxHeight:0}),{values:[v],elementRef:g}=xt(l.useMemo(()=>["width"],[])),[p,y]=l.useState(!1),[F,B]=l.useState(e.default),[E,W]=l.useState(0),[T,it]=l.useState(!1),[b,S]=l.useState([]),[U,D]=l.useState(!1),C=bt(e.acceptFile),q=Bt(e.maxUploadSizeMb,V.Megabyte,V.Byte),P=l.useCallback(o=>S(a=>[...a,...o]),[]),O=l.useCallback(o=>{S(a=>{const s=k(o,a);return R(s)?a:(s.status.type==="uploading"&&s.status.cancelToken.cancel(),s.status.type==="uploaded"&&s.status.fileUrls.deleteUrl&&f.deleteFile(s.status.fileUrls.deleteUrl),a.filter(i=>i.id!==o))})},[f]),st=()=>{const o=b.filter(a=>a.status.type==="uploaded").map(a=>{const{name:s,size:i,status:w}=a,{fileId:ht,fileUrls:ft}=w;return new St({fileId:ht,fileUrls:ft,name:s,size:i})});return new zt({uploadedFileInfo:o})},K=()=>x.current++,lt=ie({acceptMultipleFiles:C===I.Multiple,maxFileSize:q,uploadClient:f,uploadFile:re({getNextLocalFileId:K,addFiles:P,updateFile:(o,a)=>{S(s=>M(o,a,s))},uploadClient:f,element:e,onUploadProgress:(o,a)=>{S(s=>{const i=k(a,s);if(R(i)||i.status.type!=="uploading")return s;const w=Math.round(o.loaded*100/o.total);return i.status.progress===w?s:M(a,i.setStatus({type:"uploading",cancelToken:i.status.cancelToken,progress:w}),s)})},onUploadComplete:(o,a)=>{S(s=>{const i=k(o,s);return R(i)||i.status.type!=="uploading"?s:M(i.id,i.setStatus({type:"uploaded",fileId:a.fileId,fileUrls:a}),s)})}}),addFiles:P,getNextLocalFileId:K,deleteExistingFiles:()=>b.forEach(o=>O(o.id)),onUploadComplete:()=>{m.current&&m.current.focus()}}),{getRootProps:_,getInputProps:X}=Dt({onDrop:lt,multiple:C===I.Multiple,accept:Rt(e.fileType),maxSize:q}),dt=()=>{let o=0;const{current:a}=m;if(a){const s=a.placeholder;a.placeholder="",a.style.height="auto",o=a.scrollHeight,a.placeholder=s,a.style.height=""}return o},G=()=>{if(m.current&&m.current.focus(),!p||t)return;const o={data:F,fileUploaderState:st()};r.setChatInputValue(e,o,{fromUi:!0},d),y(!1),S([]),B(""),W(0)},ct=o=>{const{metaKey:a,ctrlKey:s,shiftKey:i}=o;Mt(o)&&!i&&!s&&!a&&(o.preventDefault(),G())},pt=o=>{const{value:a}=o.target,{maxChars:s}=e;s!==0&&a.length>s||(B(a),W(dt()))};l.useEffect(()=>b.some(o=>o.status.type==="uploading")?y(!1):y(F!==""||b.length>0),[b,F]),l.useEffect(()=>{if(e.setValue){e.setValue=!1;const o=e.value||"";B(o)}},[e]),l.useEffect(()=>{if(m.current){const{offsetHeight:o}=m.current;h.current.minHeight=o,h.current.maxHeight=o*de}},[m]),l.useEffect(()=>{const o=i=>{var w;i.preventDefault(),i.stopPropagation(),!U&&((w=i.dataTransfer)!=null&&w.types.includes("Files"))&&D(!0)},a=i=>{i.preventDefault(),i.stopPropagation(),U&&(i.clientX<=0&&i.clientY<=0||i.clientX>=window.innerWidth&&i.clientY>=window.innerHeight)&&D(!1)},s=i=>{i.preventDefault(),i.stopPropagation(),U&&D(!1)};return window.addEventListener("dragover",o),window.addEventListener("drop",s),window.addEventListener("dragleave",a),()=>{window.removeEventListener("dragover",o),window.removeEventListener("drop",s),window.removeEventListener("dragleave",a)}},[U]),l.useEffect(()=>{const{minHeight:o}=h.current;it(E>0&&m.current?Math.abs(E-o)>L:!1)},[E]);const{placeholder:j,maxChars:ut}=e,{maxHeight:Y}=h.current,gt=C!==I.None&&U;return z(et,{children:[C===I.None?null:n(ae,{items:[...b],onDelete:O}),n(Vt,{className:"stChatInput","data-testid":"stChatInput",ref:g,children:gt?n(le,{getRootProps:_,getInputProps:X,acceptFile:C,inputHeight:T?`${E+L}px`:c.sizes.minElementHeight}):z($t,{extended:T,children:[C===I.None?null:n(se,{getRootProps:_,getInputProps:X,acceptFile:C,disabled:t,theme:c}),n(kt,{inputRef:m,value:F,placeholder:j,onChange:pt,onKeyDown:ct,"aria-label":j,disabled:t,rows:1,overrides:{Root:{style:{minHeight:c.sizes.minElementHeight,outline:"none",borderLeftWidth:"0",borderRightWidth:"0",borderTopWidth:"0",borderBottomWidth:"0"}},Input:{props:{"data-testid":"stChatInputTextArea"},style:{lineHeight:c.lineHeights.inputWidget,"::placeholder":{opacity:"0.7"},height:T?`${E+L}px`:"auto",maxHeight:Y?`${Y}px`:"none",paddingLeft:c.spacing.none,paddingBottom:c.spacing.sm,paddingTop:c.spacing.sm,paddingRight:`calc(${c.iconSizes.xl} + 2 * ${c.spacing.sm} + ${c.spacing.sm})`}}}}),v>c.breakpoints.hideWidgetDetails&&n(Wt,{children:n(Lt,{dirty:p,value:F,maxLength:ut,type:"chat",inForm:!1})}),n(At,{children:n(Nt,{onClick:G,disabled:!p||t,extended:T,"data-testid":"stChatInputSubmitButton",children:n(H,{content:rt,size:"xl",color:"inherit"})})})]})})]})}const we=l.memo(ce);export{we as default};
|
@@ -1 +0,0 @@
|
|
1
|
-
import{r as l,b5 as i,j as e,b6 as u,bq as d,b4 as B,b7 as c,b8 as b}from"./index.DFLL-J15.js";function m(n){const{disabled:s,element:t,widgetMgr:o,fragmentId:r}=n;let a=i.SECONDARY;return t.type==="primary"?a=i.PRIMARY:t.type==="tertiary"&&(a=i.TERTIARY),e(b,{className:"stButton","data-testid":"stButton",children:e(u,{help:t.help,children:e(d,{kind:a,size:B.SMALL,disabled:s,fluidWidth:t.useContainerWidth||!!t.help,onClick:()=>o.setTriggerValue(t,{fromUi:!0},r),children:e(c,{icon:t.icon,label:t.label})})})})}const f=l.memo(m);export{f as default};
|
@@ -1 +0,0 @@
|
|
1
|
-
import{n as s,r as f,R as g,aD as x,b9 as b,y as k,j as n,b6 as C,ba as L,B as v,D as w,aC as T}from"./index.DFLL-J15.js";const y=s("div",{target:"e1qwfq0"})({display:"flex",flexDirection:"column"}),S=s("a",{target:"e1qwfq1"})(({disabled:a,isCurrentPage:o,fluidWidth:l,theme:e})=>({textDecoration:"none",width:l?"100%":"fit-content",display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"flex-start",gap:e.spacing.sm,borderRadius:e.radii.default,paddingLeft:e.spacing.sm,paddingRight:e.spacing.sm,marginTop:e.spacing.threeXS,marginBottom:e.spacing.threeXS,lineHeight:e.lineHeights.menuItem,backgroundColor:o?e.colors.darkenedBgMix15:"transparent","&:hover":{backgroundColor:o?e.colors.darkenedBgMix25:e.colors.darkenedBgMix15},"&:active,&:visited,&:hover":{textDecoration:"none"},"&:focus":{outline:"none"},"&:focus-visible":{backgroundColor:e.colors.darkenedBgMix15},"@media print":{paddingLeft:e.spacing.none},...a?{borderColor:e.colors.borderColor,backgroundColor:e.colors.transparent,color:e.colors.fadedText40,cursor:"not-allowed","&:hover":{color:e.colors.fadedText40,backgroundColor:e.colors.transparent}}:{}})),h=s("span",{target:"e1qwfq2"})(({disabled:a,theme:o})=>({color:o.colors.bodyText,overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis",display:"table-cell",...a?{borderColor:o.colors.borderColor,backgroundColor:o.colors.transparent,color:o.colors.fadedText40,cursor:"not-allowed"}:{}}));function D(a,o){return a===null&&o?!0:a===null&&!o?!1:a===!0}function P(a){const{onPageChange:o,currentPageScriptHash:l}=g.useContext(x),e=g.useContext(b),{colors:i}=k(),{disabled:t,element:r}=a,u=D(r.useContainerWidth,e),c=l===r.pageScriptHash,p=d=>{r.external?t&&d.preventDefault():(d.preventDefault(),t||o(r.pageScriptHash))};return n("div",{className:"stPageLink","data-testid":"stPageLink",children:n(C,{help:r.help,placement:L.TOP_RIGHT,children:n(y,{children:v(S,{"data-testid":"stPageLink-NavLink",disabled:t,isCurrentPage:c,fluidWidth:u||!!r.help,href:r.page,target:r.external?"_blank":"",rel:"noreferrer",onClick:p,children:[r.icon&&n(w,{size:"lg",color:t?i.fadedText40:i.bodyText,iconValue:r.icon}),n(h,{disabled:t,children:n(T,{source:r.label,allowHTML:!1,isLabel:!0,boldLabel:c,largerLabel:!0,disableLinks:!0})})]})})})})}const H=f.memo(P);export{H as default};
|
@@ -1 +0,0 @@
|
|
1
|
-
import{r as u,R as f,aD as m,b5 as i,j as t,b6 as b,bq as B,b4 as p,b7 as D}from"./index.DFLL-J15.js";import{c as w}from"./createDownloadLinkElement.DZMwyjvU.js";function h(n,o,e){return w({enforceDownloadInNewTab:e,url:n.buildMediaURL(o),filename:""})}function R(n){const{disabled:o,element:e,widgetMgr:l,endpoints:s,fragmentId:r}=n,{libConfig:{enforceDownloadInNewTab:d=!1}}=f.useContext(m);let a=i.SECONDARY;e.type==="primary"?a=i.PRIMARY:e.type==="tertiary"&&(a=i.TERTIARY);const c=()=>{e.ignoreRerun||l.setTriggerValue(e,{fromUi:!0},r),h(s,e.url,d).click()};return t("div",{className:"stDownloadButton","data-testid":"stDownloadButton",children:t(b,{help:e.help,children:t(B,{kind:a,size:p.SMALL,disabled:o,onClick:c,fluidWidth:e.useContainerWidth||!!e.help,children:t(D,{icon:e.icon,label:e.label})})})})}const L=u.memo(R);export{L as default};
|
@@ -1 +0,0 @@
|
|
1
|
-
import{r as o,E as X,_ as q,cB as I,L as b,N as J,as as ut,n as x,y as ct,bh as dt,cr as pt,B as N,j as u,bs as ft,bF as bt,bt as mt,ba as gt,bu as ht,bp as G}from"./index.DFLL-J15.js";import{u as yt}from"./uniqueId.Cyxi17MX.js";import{u as It}from"./FormClearHelper.DzssExOY.js";import{I as Tt}from"./InputInstructions.DMffPiri.js";import{s as wt}from"./sprintf.D7DtBTRn.js";import{I as Ct}from"./input.CS80Xua3.js";import"./base-input.DDph5ZTh.js";var Q=o.forwardRef(function(t,e){var r={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return o.createElement(X,q({iconAttrs:r,iconVerticalAlign:"middle",iconViewBox:"0 0 8 8"},t,{ref:e}),o.createElement("path",{d:"M0 3v2h8V3H0z"}))});Q.displayName="Minus";var Y=o.forwardRef(function(t,e){var r={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return o.createElement(X,q({iconAttrs:r,iconVerticalAlign:"middle",iconViewBox:"0 0 8 8"},t,{ref:e}),o.createElement("path",{d:"M3 0v3H0v2h3v3h2V5h3V3H5V0H3z"}))});Y.displayName="Plus";const vt=ut.getLogger("NumberInput");function St(t){return b(t)||t===""?void 0:t}const z=({value:t,format:e,step:r,dataType:f})=>{if(b(t))return null;let n=St(e);if(b(n)&&J(r)){const d=r.toString();f===I.DataType.FLOAT&&r!==0&&d.includes(".")&&(n=`%0.${d.split(".")[1].length}f`)}if(b(n))return t.toString();try{return wt.sprintf(n,t)}catch(d){return vt.warn(`Error in sprintf(${n}, ${t}): ${d}`),String(t)}},Vt=(t,e,r)=>b(t)?!1:t-e>=r,kt=(t,e,r)=>b(t)?!1:t+e<=r,xt=t=>(t.element.dataType===I.DataType.INT?t.widgetMgr.getIntValue(t.element):t.widgetMgr.getDoubleValue(t.element))??t.element.default??null,M=({step:t,dataType:e})=>t||(e===I.DataType.INT?1:.01),Rt=x("div",{target:"e5tuigk0"})(({theme:t})=>({display:"flex",flexDirection:"row",flexWrap:"nowrap",alignItems:"center",height:t.sizes.minElementHeight,borderWidth:t.sizes.borderWidth,borderStyle:"solid",borderColor:t.colors.widgetBorderColor??t.colors.secondaryBg,transitionDuration:"200ms",transitionProperty:"border",transitionTimingFunction:"cubic-bezier(0.2, 0.8, 0.4, 1)",borderRadius:t.radii.default,overflow:"hidden","&.focused":{borderColor:t.colors.primary},input:{MozAppearance:"textfield","&::-webkit-inner-spin-button, &::-webkit-outer-spin-button":{WebkitAppearance:"none",margin:t.spacing.none}}})),Dt=x("div",{target:"e5tuigk1"})({display:"flex",flexDirection:"row",alignSelf:"stretch"}),K=x("button",{target:"e5tuigk2"})(({theme:t})=>({margin:t.spacing.none,border:"none",height:t.sizes.full,display:"flex",alignItems:"center",width:t.sizes.numberInputControlsWidth,justifyContent:"center",color:t.colors.bodyText,transition:"color 300ms, backgroundColor 300ms",backgroundColor:t.colors.secondaryBg,"&:hover:enabled, &:focus:enabled":{color:t.colors.white,backgroundColor:t.colors.primary,transition:"none",outline:"none"},"&:active":{outline:"none",border:"none"},"&:last-of-type":{borderTopRightRadius:t.radii.default,borderBottomRightRadius:t.radii.default},"&:disabled":{cursor:"not-allowed",color:t.colors.fadedText40}})),Et=x("div",{target:"e5tuigk3"})(({theme:t,clearable:e})=>({position:"absolute",marginRight:t.spacing.twoXS,left:0,right:`calc(${t.sizes.numberInputControlsWidth} * 2 + ${e?"1em":"0em"})`})),Ft=({disabled:t,element:e,widgetMgr:r,fragmentId:f})=>{var j;const n=ct(),{dataType:d,id:C,formId:p,default:B,format:W}=e,m=e.hasMin?e.min:-1/0,g=e.hasMax?e.max:1/0,{values:[L],elementRef:Z}=dt(o.useMemo(()=>["width"],[])),[s,tt]=o.useState(M(e)),A=xt({element:e,widgetMgr:r}),[h,T]=o.useState(!1),[i,w]=o.useState(A),[H,v]=o.useState(z({value:A,...e,step:s})),[P,U]=o.useState(!1),R=o.useRef(null),$=o.useRef(yt("number_input_")),S=Vt(i,s,m),V=kt(i,s,g),O=pt({formId:p}),et=O?r.allowFormEnterToSubmit(p):h,ot=P&&L>n.breakpoints.hideWidgetDetails;o.useEffect(()=>{tt(M({step:e.step,dataType:e.dataType}))},[e.dataType,e.step]);const l=o.useCallback(({value:a,source:c})=>{var y;if(J(a)&&(m>a||a>g))(y=R.current)==null||y.reportValidity();else{const k=a??B??null;switch(d){case I.DataType.INT:r.setIntValue({id:C,formId:p},k,c,f);break;case I.DataType.FLOAT:r.setDoubleValue({id:C,formId:p},k,c,f);break;default:throw new Error("Invalid data type")}T(!1),w(k),v(z({value:k,dataType:d,format:W,step:s}))}},[m,g,R,r,f,s,d,C,p,B,W]),rt=o.useCallback(()=>{h&&l({value:i,source:{fromUi:!0}}),U(!1)},[h,i,l]),nt=o.useCallback(()=>{U(!0)},[]),_=o.useCallback(()=>{const{value:a}=e;e.setValue=!1,w(a??null),v(z({value:a??null,...e,step:s})),l({value:a??null,source:{fromUi:!1}})},[e,s,l]);o.useEffect(()=>{e.setValue?_():l({value:i,source:{fromUi:!1}})},[]),e.setValue&&_();const D=b(e.default)&&!t,at=o.useCallback(()=>{const a=e.default??null;w(a),l({value:a,source:{fromUi:!0}})},[e]);It({element:e,widgetMgr:r,onFormCleared:at});const st=a=>{const{value:c}=a.target;if(c==="")T(!0),w(null),v(null);else{let y;e.dataType===I.DataType.INT?y=parseInt(c,10):y=parseFloat(c),T(!0),w(y),v(c)}},E=o.useCallback(()=>{V&&(T(!0),l({value:(i??m)+s,source:{fromUi:!0}}))},[i,m,s,V]),F=o.useCallback(()=>{S&&(T(!0),l({value:(i??g)-s,source:{fromUi:!0}}))},[i,g,s,S]),it=o.useCallback(a=>{const{key:c}=a;switch(c){case"ArrowUp":a.preventDefault(),E();break;case"ArrowDown":a.preventDefault(),F();break}},[E,F]),lt=o.useCallback(a=>{a.key==="Enter"&&(h&&l({value:i,source:{fromUi:!0}}),r.allowFormEnterToSubmit(p)&&r.submitForm(p,f))},[h,i,l,r,p,f]);return N("div",{className:"stNumberInput","data-testid":"stNumberInput",ref:Z,children:[u(ht,{label:e.label,disabled:t,labelVisibility:ft((j=e.labelVisibility)==null?void 0:j.value),htmlFor:$.current,children:e.help&&u(bt,{children:u(mt,{content:e.help,placement:gt.TOP_RIGHT})})}),N(Rt,{className:P?"focused":"","data-testid":"stNumberInputContainer",children:[u(Ct,{type:"number",inputRef:R,value:H??"",placeholder:e.placeholder,onBlur:rt,onFocus:nt,onChange:st,onKeyPress:lt,onKeyDown:it,clearable:D,clearOnEscape:D,disabled:t,"aria-label":e.label,id:$.current,overrides:{ClearIconContainer:{style:{padding:0}},ClearIcon:{props:{overrides:{Svg:{style:{color:n.colors.darkGray,padding:n.spacing.threeXS,height:n.sizes.clearIconSize,width:n.sizes.clearIconSize,":hover":{fill:n.colors.bodyText}}}}}},Input:{props:{"data-testid":"stNumberInputField",step:s,min:m,max:g,type:"number",inputMode:""},style:{lineHeight:n.lineHeights.inputWidget,paddingRight:n.spacing.sm,paddingLeft:n.spacing.sm,paddingBottom:n.spacing.sm,paddingTop:n.spacing.sm}},InputContainer:{style:()=>({borderTopRightRadius:0,borderBottomRightRadius:0})},Root:{style:{borderTopRightRadius:0,borderBottomRightRadius:0,borderTopLeftRadius:0,borderBottomLeftRadius:0,borderLeftWidth:0,borderRightWidth:0,borderTopWidth:0,borderBottomWidth:0,paddingRight:0}}}}),L>n.breakpoints.hideNumberInputControls&&N(Dt,{children:[u(K,{"data-testid":"stNumberInputStepDown",onClick:F,disabled:!S||t,tabIndex:-1,children:u(G,{content:Q,size:"xs",color:S?"inherit":n.colors.disabled})}),u(K,{"data-testid":"stNumberInputStepUp",onClick:E,disabled:!V||t,tabIndex:-1,children:u(G,{content:Y,size:"xs",color:V?"inherit":n.colors.disabled})})]})]}),ot&&u(Et,{clearable:D,children:u(Tt,{dirty:h,value:H??"",inForm:O,allowEnterToSubmit:et})})]})},Pt=o.memo(Ft);export{Pt as default};
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|