@stlite/desktop 0.96.0 → 0.97.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/bin/dump_artifacts.js +1 -1
- package/build/assets/{ErrorOutline.esm-_LuTQzkr-BFWi9Uuj.js → ErrorOutline.esm-lsdlHF0t-DG4LSxex.js} +1 -1
- package/build/assets/{FileDownload.esm-CUqXYNk4-DieQ2Qle.js → FileDownload.esm-B67hf_fm-CYQKuYJG.js} +1 -1
- package/build/assets/FileHelper-CfZ5yPb2-CNHTcjh9.js +5 -0
- package/build/assets/{FormClearHelper-C58X4iX0-CI3cpm91.js → FormClearHelper-XrLdNEJa-DVEjd1cV.js} +1 -1
- package/build/assets/{InputInstructions-BSpH125g-CSupbuK3.js → InputInstructions-UPXPLzmg-Q7bu80af.js} +2 -2
- package/build/assets/Particles-BG5hjQKX-C7A0Knla.js +1 -0
- package/build/assets/{ProgressBar-CQHaVJeY-Bo6RDYz5.js → ProgressBar-E3DTwBEC-BjaNqN1B.js} +2 -2
- package/build/assets/StreamlitSyntaxHighlighter-CzihVVQU-DKtwdTjA.js +9 -0
- package/build/assets/TableChart.esm-DTCdMC22-C2aHYx-P.js +1 -0
- package/build/assets/Toolbar-DencJ98c--L3IVNu_.js +1 -0
- package/build/assets/UploadFileInfo-DdcsXhjv-m2CBXl3F.js +1 -0
- package/build/assets/WidgetLabelHelpIconInline-DFAc7fKv-BB1k3kRL.js +1 -0
- package/build/assets/_baseAssignValue-D2hePX0_-CX8WO6Yp.js +1 -0
- package/build/assets/{base-input-CAXjxi6E-LJzeEbPm.js → base-input-BPl9JMAl-yC1GT4Gd.js} +3 -3
- package/build/assets/{checkbox-OEhCo8NJ-C1rXZb97.js → checkbox-BCtTdZut-CgBE95kP.js} +2 -2
- package/build/assets/createDownloadLinkElement-D-zJ1ZGH-MUElf4MM.js +1 -0
- package/build/assets/createSuper-Csct9QVD-vLz3pY3G.js +1 -0
- package/build/assets/data-grid-overlay-editor-58Vv1cYM-BTQbyoqC.js +1 -0
- package/build/assets/{downloader-DcCTL3Wz-Dj-02g6N.js → downloader-DcCTL3Wz-CCWe5qlA.js} +1 -1
- package/build/assets/{embed-DJe7ZhON-C4OnDOK-.js → embed-4M_Y1tyc-DYkZAF8O.js} +14 -14
- package/build/assets/{es6--XPcqeHG-2BbC2xK9.js → es6--XPcqeHG-7ATg0sOb.js} +2 -2
- package/build/assets/formatMoment-DEtsTHwA-BeQagUzn.js +1 -0
- package/build/assets/formatNumber-ep44bWil-jKcj-W8C.js +1 -0
- package/build/assets/iconPosition-D6yC8Xnj-BF1h45AJ.js +1 -0
- package/build/assets/iframeResizer.contentWindow-nTwp-zqr-CtsMNeCZ.js +1 -0
- package/build/assets/index--TzMnXzp-DAvnEXlj.js +1 -0
- package/build/assets/index--qHBza9B-Cw3TTMgu.js +1 -0
- package/build/assets/index-B-mlHTWW-DxFrd5NG.js +1 -0
- package/build/assets/{index-Cbq5ClnA-Ct1ftt5G.js → index-B-vlNoRi-Cx4hHKp7.js} +1 -1
- package/build/assets/{index-CF9SDiIL-0Yw8O39Y.js → index-B7jXK8tg-DQuHfWI9.js} +1 -1
- package/build/assets/index-BFmSYBo1-C1-2gL1R.js +2 -0
- package/build/assets/{index-Cp-N8m1m-CSwdpflI.js → index-BIskStic-GEaJjVf4.js} +3 -3
- package/build/assets/index-BmOxzNZt-CNMeXzFc.js +1 -0
- package/build/assets/{index-DfPnrVLL-B6NKOBTt.js → index-BmPxToPj-BM0EGyRT.js} +1 -1
- package/build/assets/index-BmXuG0WA-D_Ql4e0d.js +3 -0
- package/build/assets/index-BtV4cH-G-DZqE8EFk.js +1 -0
- package/build/assets/index-BwXCTp7d-CbCsXHhb.js +6 -0
- package/build/assets/index-BwaRZjpn-BcW7Mc-p.js +1 -0
- package/build/assets/index-BzkAb_Ru-BoJQq1Du.js +1 -0
- package/build/assets/{index-NPM6VaN3-C-0cbqN2.js → index-C5pyI-9n-BoqvCp9L.js} +1 -1
- package/build/assets/index-CHTMxzEE-CdrOqTD2.js +1 -0
- package/build/assets/index-CJJUSpBk-Cjx3_stH.js +2 -0
- package/build/assets/{index-Bck9VlwE-zB2PlFuX.js → index-CWwI7Day-CBbcYz7C.js} +3 -3
- package/build/assets/{index-DttfDE80-GomZzukD.js → index-CYKyPdc--DXQt2pbH.js} +1 -1
- package/build/assets/index-CYavJtAA-CEB9mFy5.js +11 -0
- package/build/assets/index-C_AtJDfm-C2sFKVUp.js +1 -0
- package/build/assets/index-Cc93rxqK-qmLHI1ce.js +1 -0
- package/build/assets/index-CgwImjw9-vhGwcoU0.js +1 -0
- package/build/assets/{index-CY18be0x-Bq4JW-41.js → index-CiGWj_Vp-n6pbS_He.js} +1 -1
- package/build/assets/index-Cp9lKUfY-DCgJbJZE.js +1 -0
- package/build/assets/index-CrLOtTTY-_bXB7Npw.js +2 -0
- package/build/assets/{index-BHN72E4J-BztQAHMJ.js → index-CuAftQdk-D76l7Kt4.js} +1 -1
- package/build/assets/{index-R0bDPfYF-CRQIdCoC.js → index-D0DUjycF-DZpBbVrj.js} +2 -2
- package/build/assets/index-D1pkaPju-DGUZOgpo.js +1 -0
- package/build/assets/index-D6IEgvdJ-B-rltr1-.js +1 -0
- package/build/assets/index-D9TZavtE.css +1 -0
- package/build/assets/{index-BwqdV017-BaIzlXlX.js → index-DQ7wfL_P-DAp2jN40.js} +2 -2
- package/build/assets/{index-BrYfiXJ9-D7No2wma.js → index-DR-j-FYy-DJdOMdE8.js} +1 -1
- package/build/assets/index-DUNdG0N4-BKyH_Fci.js +2 -0
- package/build/assets/index-Df-1Z3LJ-bsVAaBS1.js +1 -0
- package/build/assets/index-Dfye6cAn-CH-9suNF.js +1 -0
- package/build/assets/index-DhMU6AlU-DzPhysZa.js +3789 -0
- package/build/assets/index-DjAHjI25-oZ9XAxp1.js +27 -0
- package/build/assets/index-DlPzHASD-B0KSeIYY.js +1 -0
- package/build/assets/index-DrLK8ov3-Stod2ydK.js +2 -0
- package/build/assets/index-DtFJwl5H-Dn2VZIyI.js +1 -0
- package/build/assets/{index-CJA4Tdig-Rs7zFCTh.js → index-DuZXLtJ1-BxktJ87b.js} +1 -1
- package/build/assets/index-H5hDyygX-DMvEgj-E.js +1 -0
- package/build/assets/index-LD7yKakY-9tfSlqzu.js +1 -0
- package/build/assets/index-LeNVxf2A-B46Z4XAZ.js +1 -0
- package/build/assets/index-QsvFitQg-IS60zSNc.js +1 -0
- package/build/assets/index-YCKUmi7k-wKVbmOTE.js +1 -0
- package/build/assets/index-f_0uAugs-KaRkqnk8.js +1 -0
- package/build/assets/index-nhNM5UeG.js +185 -0
- package/build/assets/index-pi_S-NOw-DHRw2FEx.js +198 -0
- package/build/assets/index-saRTHQRt-Cep0ox_U.js +1 -0
- package/build/assets/{input-5gXdrXd2-J6HaBKjM.js → input-BZGQFBY5-B-EqzVpf.js} +2 -2
- package/build/assets/{main-DvFfgny--BkQIK2a9.js → main-DD_nsVBV-B-nG1zNN.js} +1 -1
- package/build/assets/{memory-B3L1Fctl-mli5o0A1.js → memory-B3L1Fctl-Dwxd_AN8.js} +1 -1
- package/build/assets/number-overlay-editor--_WCmOH8-DebLrQQ4.js +9 -0
- package/build/assets/numbro-CBbENDeu-C6X7Pww4.js +1 -0
- package/build/assets/{pandasStylerUtils-BvB3vP-L-D9viw-G9.js → pandasStylerUtils-DlCnQunN-DDd07kWa.js} +1 -1
- package/build/assets/possibleConstructorReturn-i7eTFBhJ-BnzuGOIJ.js +1 -0
- package/build/assets/record-CvRL89xC-Cpipd1Kv.js +1 -0
- package/build/assets/{sandbox-ChAzL-i--CSnZJIg8.js → sandbox-ChAzL-i--CrJOWfYj.js} +1 -1
- package/build/assets/{styled-components-DkuYntx5-DrGZZlKf.js → styled-components-Dq_iSDU9-i1eh3pWs.js} +1 -1
- package/build/assets/{timepicker-BMxsIjZb-Uq5-wJ6H.js → timepicker-CL-801So-Sc5MVKGZ.js} +3 -3
- package/build/assets/toConsumableArray-CCohTQYb-ClE5WF0y.js +3 -0
- package/build/assets/uniqueId-CWWNkcH4-CJJowNJ2.js +1 -0
- package/build/assets/{useBasicWidgetState-CzHHKP20-CGMCneWD.js → useBasicWidgetState-BYeS5Lnw-COvJBdtg.js} +1 -1
- package/build/assets/{useIntlLocale-5C0LAQxq-ow_F-T5t.js → useIntlLocale-D1zv6Q2y-BpOVDRdF.js} +9 -9
- package/build/assets/{useTextInputAutoExpand-BMCOrWKx-DmoV3o2_.js → useTextInputAutoExpand-DEesfW0v-Cv12Lx8Q.js} +2 -2
- package/build/assets/{useUpdateUiValue-BtVkPggP-4VTS40xs.js → useUpdateUiValue-DDoOKBFH-DrpUtoEl.js} +1 -1
- package/build/assets/{useWaveformController-DuJh2iwj-BQGl9KsR.js → useWaveformController-Betfr4kn-B9JLTJ93.js} +1 -1
- package/build/assets/wavesurfer.esm-idh1jvYE-D4Wwdy60.js +74 -0
- package/build/assets/withCalculatedWidth-ZZ9bYZZd-CtbnrMaD.js +1 -0
- package/build/assets/{withFullScreenWrapper-wajYPLRg-e8FnO2xN.js → withFullScreenWrapper-B-PKqZVg-DWJ8sEV7.js} +1 -1
- package/build/index.html +2 -2
- package/package.json +3 -3
- package/wheels/streamlit-1.53.1-cp313-none-any.whl +0 -0
- package/build/assets/FileHelper-DbeeBEs5-Co0d-OBP.js +0 -5
- package/build/assets/Particles-6ak5Hlgw-4VTgCETZ.js +0 -1
- package/build/assets/StreamlitSyntaxHighlighter-DSYWFRjz-B77VB7yz.js +0 -8
- package/build/assets/Toolbar-Cr9ArNQU-D5-awBnv.js +0 -1
- package/build/assets/UploadFileInfo-B5SttewO-BfvME59S.js +0 -1
- package/build/assets/_baseAssignValue-3fAevQ7t-BOcc6F75.js +0 -1
- package/build/assets/createDownloadLinkElement-CbRjLJ8e-NbV49OP9.js +0 -1
- package/build/assets/createSuper-bIcQlS98-B8MWK81T.js +0 -1
- package/build/assets/data-grid-overlay-editor-DbHL3o_S-CiO7EIHu.js +0 -1
- package/build/assets/iframeResizer.contentWindow-9ByjY9IM-BBpPzlnE.js +0 -1
- package/build/assets/index-10RiWKwV-Cn-PcXb4.js +0 -3
- package/build/assets/index-47jAZmzN-8ZV_muwb.js +0 -1
- package/build/assets/index-99W3Zegr-DhiLonYo.js +0 -1
- package/build/assets/index-BGCCnxH2-jQwb1QhH.js +0 -1
- package/build/assets/index-BSOGSXpv-Bd9gyoUy.js +0 -27
- package/build/assets/index-BVhYQGzc-Do7aV0dQ.js +0 -1
- package/build/assets/index-BVuioNdm-CVDd_GaD.js +0 -1
- package/build/assets/index-BYGDMULw-4dwQq_lE.js +0 -1
- package/build/assets/index-B_94eI3S-ADuW4ppz.js +0 -6
- package/build/assets/index-Bdi0ug4X.js +0 -181
- package/build/assets/index-C6MBr137-B6bz_i6a.js +0 -1
- package/build/assets/index-CAtZcI5--D0BcKLsl.js +0 -2
- package/build/assets/index-CFA5JkEa-DUK-7VD7.js +0 -1
- package/build/assets/index-CaWaI2PT-DvorZu2G.js +0 -2
- package/build/assets/index-CceTm1nk-D-m7sDsR.js +0 -1
- package/build/assets/index-CucLKMvI-CdFsTlcF.js +0 -1
- package/build/assets/index-CxZCITs0-CLi85oo1.js +0 -1
- package/build/assets/index-D3vT_IC--BZlisRXs.js +0 -3789
- package/build/assets/index-D5L-gN8f-Bny7-WhK.js +0 -11
- package/build/assets/index-D7zRUNKG-2cwkh8qP.js +0 -1
- package/build/assets/index-D8RPh1xj-BLIXkU4c.js +0 -1
- package/build/assets/index-DNE2UpRK-CMtd92Tg.js +0 -1
- package/build/assets/index-D_5mY4iN-C3O2lE89.js +0 -1
- package/build/assets/index-DnTjZ9IR.css +0 -1
- package/build/assets/index-Do4wh7Iw-cPdQGRDQ.js +0 -1
- package/build/assets/index-DwedDN1c-C-Y3cCQP.js +0 -1
- package/build/assets/index-Fvxtopfe-CxLnCat0.js +0 -1
- package/build/assets/index-G4vqu33f-DO7BfNY6.js +0 -1
- package/build/assets/index-KWOwopwF-CN_5PcLU.js +0 -2
- package/build/assets/index-Q4xI4OhR-D81jje-l.js +0 -1
- package/build/assets/index-R1QyBsfg-tcyjJ4fb.js +0 -1
- package/build/assets/index-YOustUZZ-CX09XTf8.js +0 -2
- package/build/assets/index-b6W2ubHd-BapgUWLx.js +0 -1
- package/build/assets/index-h-ZgFEXT-DdL6EMUv.js +0 -2
- package/build/assets/index-lGTf3abu-B6CGTEed.js +0 -1
- package/build/assets/index-nXfHwIms-cOwCevci.js +0 -198
- package/build/assets/index-tU7dWFCN-DURbp79P.js +0 -1
- package/build/assets/inherits-Byw8NQvD-DdaLbWVP.js +0 -1
- package/build/assets/number-overlay-editor-BQ0qCmxT-5g_cUv4i.js +0 -9
- package/build/assets/record-DJsfODTt-CK8X1liM.js +0 -1
- package/build/assets/slicedToArray-CrkrjOeW-7_omneg6.js +0 -2
- package/build/assets/toConsumableArray-BpgQ3N5A-AHKfFeLf.js +0 -2
- package/build/assets/uniqueId-BrCTHDA7-CGglDaT_.js +0 -1
- package/build/assets/unsupportedIterableToArray-CFN3yOc2-C4SckrTc.js +0 -1
- package/build/assets/wavesurfer.esm-CzjpjtNs-CtBzisOM.js +0 -74
- package/build/assets/withCalculatedWidth-C0lBnc3E-BAFtxM9t.js +0 -1
- package/wheels/streamlit-1.52.2-cp313-none-any.whl +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as a,O as W,ck as I,cF as M,cG as L,m as p,aR as O,al as V,bC as $,an as j,ao as B,B as E,co as F,cH as H,cr as P,cI as k,cm as A,cJ as N,cK as D,cL as K}from"./index-Bdi0ug4X.js";import{S as U}from"./useBasicWidgetState-CzHHKP20-CGMCneWD.js";import{c as G}from"./_baseIndexOf-OsCSwRmV--aVpkM1d.js";import"./FormClearHelper-C58X4iX0-CI3cpm91.js";function Y(o,t){var n=o==null?0:o.length;return!!n&&G(o,t,0)>-1}var _=200;function q(o,t,n,u){var e=-1,m=Y,r=!0,g=o.length,l=[],f=t.length;if(!g)return l;t.length>=_&&(m=K,r=!1,t=new D(t));e:for(;++e<g;){var s=o[e],c=s;if(s=s!==0?s:0,r&&c===c){for(var h=f;h--;)if(t[h]===c)continue e;l.push(s)}else m(t,c,u)||l.push(s)}return l}var J=M(function(o,t){return N(o)?q(o,t):[]});const X=E("div",{target:"e6zijwc0"})(({theme:o})=>({"span[aria-disabled='true']":{background:o.colors.fadedText05}}),""),Z=(o,t)=>o.getStringArrayValue(t),Q=o=>o.default.map(t=>o.options[t])??null,ee=o=>o.rawValues??null,te=(o,t,n,u)=>{t.setStringArrayValue(o,n.value,{fromUi:n.fromUi},u)},oe=o=>{const{element:t,widgetMgr:n,fragmentId:u}=o,e=W(),m=a.useContext(I),[r,g]=U({getStateFromWidgetMgr:Z,getDefaultStateFromProto:Q,getCurrStateFromProto:ee,updateWidgetMgrState:te,element:t,widgetMgr:n,fragmentId:u}),l=t.maxSelections>0&&r.length>=t.maxSelections,f=a.useMemo(()=>{if(t.maxSelections===0)return"No results";if(r.length===t.maxSelections){const i=t.maxSelections!==1?"options":"option";return`You can only select up to ${t.maxSelections} ${i}. Remove an option first.`}return"No results"},[t.maxSelections,r.length]),s=a.useCallback(i=>{switch(i.type){case"remove":return J(r,i.option?.value);case"clear":return[];case"select":return r.concat([i.option?.value]);default:throw new Error(`State transition is unknown: ${i.type}`)}},[r]),c=a.useCallback(i=>{t.maxSelections&&i.type==="select"&&r.length>=t.maxSelections||g({value:s(i),fromUi:!0})},[t.maxSelections,s,g,r.length]),{options:h}=t,{placeholder:y,disabled:v,selectOptions:C,inputReadOnly:z,valuesToUiMulti:S,createFilterOptions:x}=L({options:h,isMulti:!0,acceptNewOptions:t.acceptNewOptions??!1,placeholderInput:t.placeholder}),R=a.useCallback((i,d)=>l?[]:x(r)(i,d),[x,l,r]),b=o.disabled||v,w=a.useMemo(()=>S(r),[S,r]),T=a.useMemo(()=>{const i=e.fontSizes.baseFontSize*1.6+14;return`${Math.round(i*4.25)}px`},[e.fontSizes.baseFontSize]);return p.jsxs("div",{className:"stMultiSelect","data-testid":"stMultiSelect",children:[p.jsx(O,{label:t.label,disabled:b,labelVisibility:V(t.labelVisibility?.value),children:t.help&&p.jsx($,{children:p.jsx(j,{content:t.help,placement:B.TOP_RIGHT})})}),p.jsx(X,{children:p.jsx(F,{creatable:t.acceptNewOptions??!1,options:C,labelKey:"label",valueKey:"value","aria-label":t.label,placeholder:y,type:k.select,multi:!0,onChange:c,value:w,disabled:b,size:"compact",noResultsMsg:f,filterOptions:R,closeOnSelect:!1,ignoreCase:!1,overrides:{Popover:{props:{ignoreBoundary:m,overrides:{Body:{style:()=>({marginTop:e.spacing.px})}}}},SelectArrow:{component:P,props:{style:{cursor:"pointer"},overrides:{Svg:{style:()=>({width:e.iconSizes.xl,height:e.iconSizes.xl})}}}},IconsContainer:{style:()=>({paddingRight:e.spacing.sm})},ControlContainer:{style:({$isFocused:i})=>{const d=A(e.colors,i);return{maxHeight:T,minHeight:e.sizes.minElementHeight,borderLeftWidth:e.sizes.borderWidth,borderRightWidth:e.sizes.borderWidth,borderTopWidth:e.sizes.borderWidth,borderBottomWidth:e.sizes.borderWidth,borderTopColor:d,borderRightColor:d,borderBottomColor:d,borderLeftColor:d}}},Placeholder:{style:()=>({flex:"inherit",color:b?e.colors.fadedText40:e.colors.fadedText60})},ValueContainer:{style:()=>({overflowY:"auto",paddingLeft:e.spacing.sm,paddingTop:e.spacing.none,paddingBottom:e.spacing.none,paddingRight:e.spacing.none})},ClearIcon:{props:{overrides:{Svg:{style:{color:e.colors.grayTextColor,padding:e.spacing.threeXS,height:e.sizes.clearIconSize,width:e.sizes.clearIconSize,cursor:"pointer",":hover":{fill:e.colors.bodyText}}}}}},SearchIcon:{style:{color:e.colors.grayTextColor}},Tag:{props:{overrides:{Root:{style:{fontWeight:e.fontWeights.normal,borderTopLeftRadius:e.radii.md,borderTopRightRadius:e.radii.md,borderBottomRightRadius:e.radii.md,borderBottomLeftRadius:e.radii.md,fontSize:e.fontSizes.md,paddingLeft:e.spacing.sm,marginLeft:e.spacing.none,marginRight:e.spacing.sm,height:`calc(${e.sizes.minElementHeight} - 2 * ${e.spacing.xs})`,maxWidth:`calc(100% - ${e.spacing.lg})`,cursor:"default !important"}},Action:{style:{paddingLeft:0}},ActionIcon:{props:{overrides:{Svg:{style:{width:"0.625em",height:"0.625em"}}}}}}}},MultiValue:{props:{overrides:{Root:{style:{fontSize:e.fontSizes.sm}}}}},Input:{props:{readOnly:z}},Dropdown:{component:H}}})})]})},ne=a.memo(oe);export{ne as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{bQ as f,bR as u,bS as a,a7 as c}from"./index-Bdi0ug4X.js";function l(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function n(t,e){for(var o=0;o<e.length;o++){var r=e[o];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,f(r.key),r)}}function y(t,e,o){return e&&n(t.prototype,e),o&&n(t,o),Object.defineProperty(t,"prototype",{writable:!1}),t}function b(t,e){if(e&&(a(e)=="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return c(t)}function i(t){return i=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},i(t)}function s(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&u(t,e)}export{i as a,s as b,y as l,l as p,b as y};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import{r as I,Q as Y}from"./index-Bdi0ug4X.js";import{f as Ie}from"./index-nXfHwIms-cOwCevci.js";import"./withFullScreenWrapper-wajYPLRg-e8FnO2xN.js";import"./Toolbar-Cr9ArNQU-D5-awBnv.js";import"./FormClearHelper-C58X4iX0-CI3cpm91.js";import"./moment-CU6QKNej-DcQX_LE0.js";import"./pandasStylerUtils-BvB3vP-L-D9viw-G9.js";import"./_baseIndexOf-OsCSwRmV--aVpkM1d.js";import"./sprintf-D5E86llw-6tzWM3a-.js";import"./_baseAssignValue-3fAevQ7t-BOcc6F75.js";import"./index-CVld_lKx-CBWAU0gM.js";import"./main-DvFfgny--BkQIK2a9.js";import"./checkbox-OEhCo8NJ-C1rXZb97.js";import"./createDownloadLinkElement-CbRjLJ8e-NbV49OP9.js";import"./slicedToArray-CrkrjOeW-7_omneg6.js";import"./unsupportedIterableToArray-CFN3yOc2-C4SckrTc.js";import"./inherits-Byw8NQvD-DdaLbWVP.js";import"./createSuper-bIcQlS98-B8MWK81T.js";import"./toConsumableArray-BpgQ3N5A-AHKfFeLf.js";import"./FileDownload.esm-CUqXYNk4-DieQ2Qle.js";const je=Ie("div")({name:"NumberOverlayEditorStyle",class:"gdg-n15fjm3e",propsAsIs:!1});function he(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var a=0,n=Object.getOwnPropertySymbols(e);a<n.length;a++)t.indexOf(n[a])<0&&Object.prototype.propertyIsEnumerable.call(e,n[a])&&(r[n[a]]=e[n[a]]);return r}var re;(function(e){e.event="event",e.props="prop"})(re||(re={}));function H(){}function Be(e){var t,r=void 0;return function(){for(var n=[],a=arguments.length;a--;)n[a]=arguments[a];return t&&n.length===t.length&&n.every(function(u,l){return u===t[l]})||(t=n,r=e.apply(void 0,n)),r}}function ae(e){return!!(e||"").match(/\d/)}function X(e){return e==null}function Fe(e){return typeof e=="number"&&isNaN(e)}function Se(e){return X(e)||Fe(e)||typeof e=="number"&&!isFinite(e)}function be(e){return e.replace(/[-[\]/{}()*+?.\\^$|]/g,"\\$&")}function Me(e){switch(e){case"lakh":return/(\d+?)(?=(\d\d)+(\d)(?!\d))(\.\d+)?/g;case"wan":return/(\d)(?=(\d{4})+(?!\d))/g;case"thousand":default:return/(\d)(?=(\d{3})+(?!\d))/g}}function ke(e,t,r){var n=Me(r),a=e.search(/[1-9]/);return a=a===-1?e.length:a,e.substring(0,a)+e.substring(a,e.length).replace(n,"$1"+t)}function We(e){var t=I.useRef(e);t.current=e;var r=I.useRef(function(){for(var n=[],a=arguments.length;a--;)n[a]=arguments[a];return t.current.apply(t,n)});return r.current}function fe(e,t){t===void 0&&(t=!0);var r=e[0]==="-",n=r&&t;e=e.replace("-","");var a=e.split("."),u=a[0],l=a[1]||"";return{beforeDecimal:u,afterDecimal:l,hasNegation:r,addNegation:n}}function Ke(e){if(!e)return e;var t=e[0]==="-";t&&(e=e.substring(1,e.length));var r=e.split("."),n=r[0].replace(/^0+/,"")||"0",a=r[1]||"";return(t?"-":"")+n+(a?"."+a:"")}function ye(e,t,r){for(var n="",a=r?"0":"",u=0;u<=t-1;u++)n+=e[u]||a;return n}function de(e,t){return Array(t+1).join(e)}function Ve(e){var t=e+"",r=t[0]==="-"?"-":"";r&&(t=t.substring(1));var n=t.split(/[eE]/g),a=n[0],u=n[1];if(u=Number(u),!u)return r+a;a=a.replace(".","");var l=1+u,g=a.length;return l<0?a="0."+de("0",Math.abs(l))+a:l>=g?a=a+de("0",l-g):a=(a.substring(0,l)||"0")+"."+a.substring(l),r+a}function me(e,t,r){if(["","-"].indexOf(e)!==-1)return e;var n=(e.indexOf(".")!==-1||r)&&t,a=fe(e),u=a.beforeDecimal,l=a.afterDecimal,g=a.hasNegation,h=parseFloat("0."+(l||"0")),S=l.length<=t?"0."+l:h.toFixed(t),p=S.split("."),v=u;u&&Number(p[0])&&(v=u.split("").reverse().reduce(function(O,E,m){return O.length>m?(Number(O[0])+Number(E)).toString()+O.substring(1,O.length):E+O},p[0]));var V=ye(p[1]||"",t,r),b=g?"-":"",c=n?".":"";return""+b+v+c+V}function $(e,t){if(e.value=e.value,e!==null){if(e.createTextRange){var r=e.createTextRange();return r.move("character",t),r.select(),!0}return e.selectionStart||e.selectionStart===0?(e.focus(),e.setSelectionRange(t,t),!0):(e.focus(),!1)}}var we=Be(function(e,t){for(var r=0,n=0,a=e.length,u=t.length;e[r]===t[r]&&r<a;)r++;for(;e[a-1-n]===t[u-1-n]&&u-n>r&&a-n>r;)n++;return{from:{start:r,end:a-n},to:{start:r,end:u-n}}}),Le=function(e,t){var r=Math.min(e.selectionStart,t);return{from:{start:r,end:e.selectionEnd},to:{start:r,end:t}}};function Pe(e,t,r){return Math.min(Math.max(e,t),r)}function ce(e){return Math.max(e.selectionStart,e.selectionEnd)}function Ue(){return typeof navigator<"u"&&!(navigator.platform&&/iPhone|iPod/.test(navigator.platform))}function _e(e){return{from:{start:0,end:0},to:{start:0,end:e.length},lastValue:""}}function qe(e){var t=e.currentValue,r=e.formattedValue,n=e.currentValueIndex,a=e.formattedValueIndex;return t[n]===r[a]}function Ge(e,t,r,n,a,u,l){l===void 0&&(l=qe);var g=a.findIndex(function(K){return K}),h=e.slice(0,g);!t&&!r.startsWith(h)&&(t=h,r=h+r,n=n+h.length);for(var S=r.length,p=e.length,v={},V=new Array(S),b=0;b<S;b++){V[b]=-1;for(var c=0,O=p;c<O;c++){var E=l({currentValue:r,lastValue:t,formattedValue:e,currentValueIndex:b,formattedValueIndex:c});if(E&&v[c]!==!0){V[b]=c,v[c]=!0;break}}}for(var m=n;m<S&&(V[m]===-1||!u(r[m]));)m++;var j=m===S||V[m]===-1?p:V[m];for(m=n-1;m>0&&V[m]===-1;)m--;var B=m===-1||V[m]===-1?0:V[m]+1;return B>j?j:n-B<j-n?B:j}function ge(e,t,r,n){var a=e.length;if(t=Pe(t,0,a),n==="left"){for(;t>=0&&!r[t];)t--;t===-1&&(t=r.indexOf(!0))}else{for(;t<=a&&!r[t];)t++;t>a&&(t=r.lastIndexOf(!0))}return t===-1&&(t=a),t}function He(e){for(var t=Array.from({length:e.length+1}).map(function(){return!0}),r=0,n=t.length;r<n;r++)t[r]=!!(ae(e[r])||ae(e[r-1]));return t}function xe(e,t,r,n,a,u){u===void 0&&(u=H);var l=We(function(c,O){var E,m;return Se(c)?(m="",E=""):typeof c=="number"||O?(m=typeof c=="number"?Ve(c):c,E=n(m)):(m=a(c,void 0),E=n(m)),{formattedValue:E,numAsString:m}}),g=I.useState(function(){return l(X(e)?t:e,r)}),h=g[0],S=g[1],p=function(c,O){c.formattedValue!==h.formattedValue&&S({formattedValue:c.formattedValue,numAsString:c.value}),u(c,O)},v=e,V=r;X(e)&&(v=h.numAsString,V=!0);var b=l(v,V);return I.useMemo(function(){S(b)},[b.formattedValue]),[h,p]}function Ze(e){return e.replace(/[^0-9]/g,"")}function Je(e){return e}function $e(e){var t=e.type;t===void 0&&(t="text");var r=e.displayType;r===void 0&&(r="input");var n=e.customInput,a=e.renderText,u=e.getInputRef,l=e.format;l===void 0&&(l=Je);var g=e.removeFormatting;g===void 0&&(g=Ze);var h=e.defaultValue,S=e.valueIsNumericString,p=e.onValueChange,v=e.isAllowed,V=e.onChange;V===void 0&&(V=H);var b=e.onKeyDown;b===void 0&&(b=H);var c=e.onMouseUp;c===void 0&&(c=H);var O=e.onFocus;O===void 0&&(O=H);var E=e.onBlur;E===void 0&&(E=H);var m=e.value,j=e.getCaretBoundary;j===void 0&&(j=He);var B=e.isValidInputCharacter;B===void 0&&(B=ae);var K=e.isCharacterSame,M=he(e,["type","displayType","customInput","renderText","getInputRef","format","removeFormatting","defaultValue","valueIsNumericString","onValueChange","isAllowed","onChange","onKeyDown","onMouseUp","onFocus","onBlur","value","getCaretBoundary","isValidInputCharacter","isCharacterSame"]),Z=xe(m,h,!!S,l,g,p),L=Z[0],w=L.formattedValue,k=L.numAsString,J=Z[1],W=I.useRef(),U=I.useRef({formattedValue:w,numAsString:k}),_=function(o,i){U.current={formattedValue:o.formattedValue,numAsString:o.value},J(o,i)},z=I.useState(!1),ee=z[0],d=z[1],s=I.useRef(null),x=I.useRef({setCaretTimeout:null,focusTimeout:null});I.useEffect(function(){return d(!0),function(){clearTimeout(x.current.setCaretTimeout),clearTimeout(x.current.focusTimeout)}},[]);var A=l,C=function(o,i){var f=parseFloat(i);return{formattedValue:o,value:i,floatValue:isNaN(f)?void 0:f}},T=function(o,i,f){o.selectionStart===0&&o.selectionEnd===o.value.length||($(o,i),x.current.setCaretTimeout=setTimeout(function(){o.value===f&&o.selectionStart!==i&&$(o,i)},0))},R=function(o,i,f){return ge(o,i,j(o),f)},Q=function(o,i,f){var D=j(i),F=Ge(i,w,o,f,D,B,K);return F=ge(i,F,D),F},oe=function(o){var i=o.formattedValue;i===void 0&&(i="");var f=o.input,D=o.source,F=o.event,N=o.numAsString,y;if(f){var P=o.inputValue||f.value,q=ce(f);f.value=i,y=Q(P,i,q),y!==void 0&&T(f,y,i)}i!==w&&_(C(i,N),{event:F,source:D})};I.useEffect(function(){var o=U.current,i=o.formattedValue,f=o.numAsString;(w!==i||k!==f)&&_(C(w,k),{event:void 0,source:re.props})},[w,k]);var te=s.current?ce(s.current):void 0,ne=typeof window<"u"?I.useLayoutEffect:I.useEffect;ne(function(){var o=s.current;if(w!==U.current.formattedValue&&o){var i=Q(U.current.formattedValue,w,te);o.value=w,T(o,i,w)}},[w]);var ie=function(o,i,f){var D=i.target,F=W.current?Le(W.current,D.selectionEnd):we(w,o),N=Object.assign(Object.assign({},F),{lastValue:w}),y=g(o,N),P=A(y);if(y=g(P,void 0),v&&!v(C(P,y))){var q=i.target,G=ce(q),se=Q(o,w,G);return q.value=w,T(q,se,w),!1}return oe({formattedValue:P,numAsString:y,inputValue:o,event:i,source:f,input:i.target}),!0},le=function(o,i){i===void 0&&(i=0);var f=o.selectionStart,D=o.selectionEnd;W.current={selectionStart:f,selectionEnd:D+i}},Ne=function(o){var i=o.target,f=i.value,D=ie(f,o,re.event);D&&V(o),W.current=void 0},Oe=function(o){var i=o.target,f=o.key,D=i.selectionStart,F=i.selectionEnd,N=i.value;N===void 0&&(N="");var y;f==="ArrowLeft"||f==="Backspace"?y=Math.max(D-1,0):f==="ArrowRight"?y=Math.min(D+1,N.length):f==="Delete"&&(y=D);var P=0;f==="Delete"&&D===F&&(P=1);var q=f==="ArrowLeft"||f==="ArrowRight";if(y===void 0||D!==F&&!q){b(o),le(i,P);return}var G=y;if(q){var se=f==="ArrowLeft"?"left":"right";G=R(N,y,se),G!==y&&o.preventDefault()}else f==="Delete"&&!B(N[y])?G=R(N,y,"right"):f==="Backspace"&&!B(N[y])&&(G=R(N,y,"left"));G!==y&&T(i,G,N),b(o),le(i,P)},Ee=function(o){var i=o.target,f=function(){var D=i.selectionStart,F=i.selectionEnd,N=i.value;if(N===void 0&&(N=""),D===F){var y=R(N,D);y!==D&&T(i,y,N)}};f(),requestAnimationFrame(function(){f()}),c(o),le(i)},Te=function(o){o.persist&&o.persist();var i=o.target,f=o.currentTarget;s.current=i,x.current.focusTimeout=setTimeout(function(){var D=i.selectionStart,F=i.selectionEnd,N=i.value;N===void 0&&(N="");var y=R(N,D);y!==D&&!(D===0&&F===N.length)&&T(i,y,N),O(Object.assign(Object.assign({},o),{currentTarget:f}))},0)},Ae=function(o){s.current=null,clearTimeout(x.current.focusTimeout),clearTimeout(x.current.setCaretTimeout),E(o)},Ce=ee&&Ue()?"numeric":void 0,ve=Object.assign({inputMode:Ce},M,{type:t,value:w,onChange:Ne,onKeyDown:Oe,onMouseUp:Ee,onFocus:Te,onBlur:Ae});if(r==="text")return a?Y.createElement(Y.Fragment,null,a(w,M)||null):Y.createElement("span",Object.assign({},M,{ref:u}),w);if(n){var Re=n;return Y.createElement(Re,Object.assign({},ve,{ref:u}))}return Y.createElement("input",Object.assign({},ve,{ref:u}))}function pe(e,t){var r=t.decimalScale,n=t.fixedDecimalScale,a=t.prefix;a===void 0&&(a="");var u=t.suffix;u===void 0&&(u="");var l=t.allowNegative,g=t.thousandsGroupStyle;if(g===void 0&&(g="thousand"),e===""||e==="-")return e;var h=ue(t),S=h.thousandSeparator,p=h.decimalSeparator,v=r!==0&&e.indexOf(".")!==-1||r&&n,V=fe(e,l),b=V.beforeDecimal,c=V.afterDecimal,O=V.addNegation;return r!==void 0&&(c=ye(c,r,!!n)),S&&(b=ke(b,S,g)),a&&(b=a+b),u&&(c=c+u),O&&(b="-"+b),e=b+(v&&p||"")+c,e}function ue(e){var t=e.decimalSeparator;t===void 0&&(t=".");var r=e.thousandSeparator,n=e.allowedDecimalSeparators;return r===!0&&(r=","),n||(n=[t,"."]),{decimalSeparator:t,thousandSeparator:r,allowedDecimalSeparators:n}}function ze(e,t){e===void 0&&(e="");var r=new RegExp("(-)"),n=new RegExp("(-)(.)*(-)"),a=r.test(e),u=n.test(e);return e=e.replace(/-/g,""),a&&!u&&t&&(e="-"+e),e}function Qe(e,t){return new RegExp("(^-)|[0-9]|"+be(e),"g")}function Ye(e,t,r){return e===""?!0:!t?.match(/\d/)&&!r?.match(/\d/)&&typeof e=="string"&&!isNaN(Number(e))}function Xe(e,t,r){var n;t===void 0&&(t=_e(e));var a=r.allowNegative,u=r.prefix;u===void 0&&(u="");var l=r.suffix;l===void 0&&(l="");var g=r.decimalScale,h=t.from,S=t.to,p=S.start,v=S.end,V=ue(r),b=V.allowedDecimalSeparators,c=V.decimalSeparator,O=e[v]===c;if(ae(e)&&(e===u||e===l)&&t.lastValue==="")return e;if(v-p===1&&b.indexOf(e[p])!==-1){var E=g===0?"":c;e=e.substring(0,p)+E+e.substring(p+1,e.length)}var m=function(s,x,A){var C=!1,T=!1;u.startsWith("-")?C=!1:s.startsWith("--")?(C=!1,T=!0):l.startsWith("-")&&s.length===l.length?C=!1:s[0]==="-"&&(C=!0);var R=C?1:0;return T&&(R=2),R&&(s=s.substring(R),x-=R,A-=R),{value:s,start:x,end:A,hasNegation:C}},j=m(e,p,v),B=j.hasNegation;n=j,e=n.value,p=n.start,v=n.end;var K=m(t.lastValue,h.start,h.end),M=K.start,Z=K.end,L=K.value,w=e.substring(p,v);e.length&&L.length&&(M>L.length-l.length||Z<u.length)&&!(w&&l.startsWith(w))&&(e=L);var k=0;e.startsWith(u)?k+=u.length:p<u.length&&(k=p),e=e.substring(k),v-=k;var J=e.length,W=e.length-l.length;e.endsWith(l)?J=W:(v>W||v>e.length-l.length)&&(J=v),e=e.substring(0,J),e=ze(B?"-"+e:e,a),e=(e.match(Qe(c))||[]).join("");var U=e.indexOf(c);e=e.replace(new RegExp(be(c),"g"),function(s,x){return x===U?".":""});var _=fe(e,a),z=_.beforeDecimal,ee=_.afterDecimal,d=_.addNegation;return S.end-S.start<h.end-h.start&&z===""&&O&&!parseFloat(ee)&&(e=d?"-":""),e}function et(e,t){var r=t.prefix;r===void 0&&(r="");var n=t.suffix;n===void 0&&(n="");var a=Array.from({length:e.length+1}).map(function(){return!0}),u=e[0]==="-";a.fill(!1,0,r.length+(u?1:0));var l=e.length;return a.fill(!1,l-n.length+1,l+1),a}function tt(e){var t=ue(e),r=t.thousandSeparator,n=t.decimalSeparator,a=e.prefix;a===void 0&&(a="");var u=e.allowNegative;if(u===void 0&&(u=!0),r===n)throw new Error(`
|
|
2
|
-
Decimal separator can't be same as thousand separator.
|
|
3
|
-
thousandSeparator: `+r+` (thousandSeparator = {true} is same as thousandSeparator = ",")
|
|
4
|
-
decimalSeparator: `+n+` (default value for decimalSeparator is .)
|
|
5
|
-
`);return a.startsWith("-")&&u&&(console.error(`
|
|
6
|
-
Prefix can't start with '-' when allowNegative is true.
|
|
7
|
-
prefix: `+a+`
|
|
8
|
-
allowNegative: `+u+`
|
|
9
|
-
`),u=!1),Object.assign(Object.assign({},e),{allowNegative:u})}function rt(e){e=tt(e),e.decimalSeparator,e.allowedDecimalSeparators,e.thousandsGroupStyle;var t=e.suffix,r=e.allowNegative,n=e.allowLeadingZeros,a=e.onKeyDown;a===void 0&&(a=H);var u=e.onBlur;u===void 0&&(u=H);var l=e.thousandSeparator,g=e.decimalScale,h=e.fixedDecimalScale,S=e.prefix;S===void 0&&(S="");var p=e.defaultValue,v=e.value,V=e.valueIsNumericString,b=e.onValueChange,c=he(e,["decimalSeparator","allowedDecimalSeparators","thousandsGroupStyle","suffix","allowNegative","allowLeadingZeros","onKeyDown","onBlur","thousandSeparator","decimalScale","fixedDecimalScale","prefix","defaultValue","value","valueIsNumericString","onValueChange"]),O=ue(e),E=O.decimalSeparator,m=O.allowedDecimalSeparators,j=function(d){return pe(d,e)},B=function(d,s){return Xe(d,s,e)},K=X(v)?p:v,M=V??Ye(K,S,t);X(v)?X(p)||(M=M||typeof p=="number"):M=M||typeof v=="number";var Z=function(d){return Se(d)?d:(typeof d=="number"&&(d=Ve(d)),M&&typeof g=="number"?me(d,g,!!h):d)},L=xe(Z(v),Z(p),!!M,j,B,b),w=L[0],k=w.numAsString,J=w.formattedValue,W=L[1],U=function(d){var s=d.target,x=d.key,A=s.selectionStart,C=s.selectionEnd,T=s.value;if(T===void 0&&(T=""),(x==="Backspace"||x==="Delete")&&C<S.length){d.preventDefault();return}if(A!==C){a(d);return}x==="Backspace"&&T[0]==="-"&&A===S.length+1&&r&&$(s,1),g&&h&&(x==="Backspace"&&T[A-1]===E?($(s,A-1),d.preventDefault()):x==="Delete"&&T[A]===E&&d.preventDefault()),m?.includes(x)&&T[A]===E&&$(s,A+1);var R=l===!0?",":l;x==="Backspace"&&T[A-1]===R&&$(s,A-1),x==="Delete"&&T[A]===R&&$(s,A+1),a(d)},_=function(d){var s=k;if(s.match(/\d/g)||(s=""),n||(s=Ke(s)),h&&g&&(s=me(s,g,h)),s!==k){var x=pe(s,e);W({formattedValue:x,value:s,floatValue:parseFloat(s)},{event:d,source:re.event})}u(d)},z=function(d){return d===E?!0:ae(d)},ee=function(d){var s=d.currentValue,x=d.lastValue,A=d.formattedValue,C=d.currentValueIndex,T=d.formattedValueIndex,R=s[C],Q=A[T],oe=we(x,s),te=oe.to,ne=function(ie){return B(ie).indexOf(".")+S.length};return v===0&&h&&g&&s[te.start]===E&&ne(s)<C&&ne(A)>T?!1:C>=te.start&&C<te.end&&m&&m.includes(R)&&Q===E?!0:R===Q};return Object.assign(Object.assign({},c),{value:J,valueIsNumericString:!1,isValidInputCharacter:z,isCharacterSame:ee,onValueChange:W,format:j,removeFormatting:B,getCaretBoundary:function(d){return et(d,e)},onKeyDown:U,onBlur:_})}function at(e){var t=rt(e);return Y.createElement($e,Object.assign({},t))}function De(){return Intl.NumberFormat()?.formatToParts(1.1)?.find(e=>e.type==="decimal")?.value??"."}function nt(){return De()==="."?",":"."}const Nt=e=>{const{value:t,onChange:r,disabled:n,highlight:a,validatedSelection:u,fixedDecimals:l,allowNegative:g,thousandSeparator:h,decimalSeparator:S}=e,p=I.useRef();return I.useLayoutEffect(()=>{if(u!==void 0){const v=typeof u=="number"?[u,null]:u;p.current?.setSelectionRange(v[0],v[1])}},[u]),I.createElement(je,null,I.createElement(at,{autoFocus:!0,getInputRef:p,className:"gdg-input",onFocus:v=>v.target.setSelectionRange(a?0:v.target.value.length,v.target.value.length),disabled:n===!0,decimalScale:l,allowNegative:g,thousandSeparator:h??nt(),decimalSeparator:S??De(),value:Object.is(t,-0)?"-":t??"",onValueChange:r}))};export{Nt as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
function w(v,i,t,e){return new(t||(t=Promise))(function(r,o){function s(c){try{a(e.next(c))}catch(d){o(d)}}function n(c){try{a(e.throw(c))}catch(d){o(d)}}function a(c){var d;c.done?r(c.value):(d=c.value,d instanceof t?d:new t(function(m){m(d)})).then(s,n)}a((e=e.apply(v,[])).next())})}class g{constructor(){this.listeners={}}on(i,t,e){if(this.listeners[i]||(this.listeners[i]=new Set),e?.once){const r=(...o)=>{this.un(i,r),t(...o)};return this.listeners[i].add(r),()=>this.un(i,r)}return this.listeners[i].add(t),()=>this.un(i,t)}un(i,t){var e;(e=this.listeners[i])===null||e===void 0||e.delete(t)}once(i,t){return this.on(i,t,{once:!0})}unAll(){this.listeners={}}emit(i,...t){this.listeners[i]&&this.listeners[i].forEach(e=>e(...t))}}class b extends g{constructor(i){super(),this.subscriptions=[],this.isDestroyed=!1,this.options=i}onInit(){}_init(i){this.isDestroyed&&(this.subscriptions=[],this.isDestroyed=!1),this.wavesurfer=i,this.onInit()}destroy(){this.emit("destroy"),this.subscriptions.forEach(i=>i()),this.subscriptions=[],this.isDestroyed=!0,this.wavesurfer=void 0}}class y extends g{constructor(){super(...arguments),this.animationFrameId=null,this.isRunning=!1}start(){if(this.isRunning)return;this.isRunning=!0;const i=()=>{this.isRunning&&(this.emit("tick"),this.animationFrameId=requestAnimationFrame(i))};i()}stop(){this.isRunning=!1,this.animationFrameId!==null&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null)}destroy(){this.stop()}}const D=["audio/webm","audio/wav","audio/mpeg","audio/mp4","audio/mp3"];class W extends b{constructor(i){var t,e,r,o,s,n;super(Object.assign(Object.assign({},i),{audioBitsPerSecond:(t=i.audioBitsPerSecond)!==null&&t!==void 0?t:128e3,scrollingWaveform:(e=i.scrollingWaveform)!==null&&e!==void 0&&e,scrollingWaveformWindow:(r=i.scrollingWaveformWindow)!==null&&r!==void 0?r:5,continuousWaveform:(o=i.continuousWaveform)!==null&&o!==void 0&&o,renderRecordedAudio:(s=i.renderRecordedAudio)===null||s===void 0||s,mediaRecorderTimeslice:(n=i.mediaRecorderTimeslice)!==null&&n!==void 0?n:void 0})),this.stream=null,this.mediaRecorder=null,this.dataWindow=null,this.isWaveformPaused=!1,this.lastStartTime=0,this.lastDuration=0,this.duration=0,this.micStream=null,this.recordedBlobUrl=null,this.timer=new y,this.subscriptions.push(this.timer.on("tick",()=>{const a=performance.now()-this.lastStartTime;this.duration=this.isPaused()?this.duration:this.lastDuration+a,this.emit("record-progress",this.duration)}))}static create(i){return new W(i||{})}renderMicStream(i){var t;const e=new AudioContext,r=e.createMediaStreamSource(i),o=e.createAnalyser();r.connect(o),this.options.continuousWaveform&&(o.fftSize=32);const s=o.frequencyBinCount,n=new Float32Array(s);let a=0;this.wavesurfer&&((t=this.originalOptions)!==null&&t!==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 d,m,p,f;if(!this.isWaveformPaused){if(o.getFloatTimeDomainData(n),this.options.scrollingWaveform){const l=Math.floor((this.options.scrollingWaveformWindow||0)*e.sampleRate),h=Math.min(l,this.dataWindow?this.dataWindow.length+s:s),u=new Float32Array(l);if(this.dataWindow){const R=Math.max(0,l-this.dataWindow.length);u.set(this.dataWindow.slice(-h+s),R)}u.set(n,l-s),this.dataWindow=u}else if(this.options.continuousWaveform){if(!this.dataWindow){const h=this.options.continuousWaveformDuration?Math.round(100*this.options.continuousWaveformDuration):((m=(d=this.wavesurfer)===null||d===void 0?void 0:d.getWidth())!==null&&m!==void 0?m:0)*window.devicePixelRatio;this.dataWindow=new Float32Array(h)}let l=0;for(let h=0;h<s;h++){const u=Math.abs(n[h]);u>l&&(l=u)}if(a+1>this.dataWindow.length){const h=new Float32Array(2*this.dataWindow.length);h.set(this.dataWindow,0),this.dataWindow=h}this.dataWindow[a]=l,a++}else this.dataWindow=n;if(this.wavesurfer){const l=((f=(p=this.dataWindow)===null||p===void 0?void 0:p.length)!==null&&f!==void 0?f:0)/100;this.wavesurfer.load("",[this.dataWindow],this.options.scrollingWaveform?this.options.scrollingWaveformWindow:l).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(h=>{console.error("Error rendering real-time recording data:",h)})}}},10);return{onDestroy:()=>{clearInterval(c),r?.disconnect(),e?.close()},onEnd:()=>{this.isWaveformPaused=!0,this.stopMic()}}}startMic(i){return w(this,void 0,void 0,function*(){let t;this.micStream&&this.stopMic();try{t=yield navigator.mediaDevices.getUserMedia({audio:i==null||i})}catch(r){throw new Error("Error accessing the microphone: "+r.message)}const e=this.renderMicStream(t);return this.micStream=e,this.unsubscribeDestroy=this.once("destroy",e.onDestroy),this.unsubscribeRecordEnd=this.once("record-end",e.onEnd),this.stream=t,t})}stopMic(){var i,t,e;(i=this.micStream)===null||i===void 0||i.onDestroy(),(t=this.unsubscribeDestroy)===null||t===void 0||t.call(this),(e=this.unsubscribeRecordEnd)===null||e===void 0||e.call(this),this.micStream=null,this.unsubscribeDestroy=void 0,this.unsubscribeRecordEnd=void 0,this.stream&&(this.stream.getTracks().forEach(r=>r.stop()),this.stream=null,this.mediaRecorder=null)}startRecording(i){return w(this,void 0,void 0,function*(){const t=this.stream||(yield this.startMic(i));this.dataWindow=null;const e=this.mediaRecorder||new MediaRecorder(t,{mimeType:this.options.mimeType||D.find(s=>MediaRecorder.isTypeSupported(s)),audioBitsPerSecond:this.options.audioBitsPerSecond});this.mediaRecorder=e,this.stopRecording();const r=[];e.ondataavailable=s=>{s.data.size>0&&r.push(s.data),this.emit("record-data-available",s.data)};const o=s=>{var n;const a=new Blob(r,{type:e.mimeType});this.emit(s,a),this.options.renderRecordedAudio&&(this.applyOriginalOptionsIfNeeded(),this.recordedBlobUrl&&URL.revokeObjectURL(this.recordedBlobUrl),this.recordedBlobUrl=URL.createObjectURL(a),(n=this.wavesurfer)===null||n===void 0||n.load(this.recordedBlobUrl))};e.onpause=()=>o("record-pause"),e.onstop=()=>o("record-end"),e.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 i;return((i=this.mediaRecorder)===null||i===void 0?void 0:i.state)==="recording"}isPaused(){var i;return((i=this.mediaRecorder)===null||i===void 0?void 0:i.state)==="paused"}isActive(){var i;return((i=this.mediaRecorder)===null||i===void 0?void 0:i.state)!=="inactive"}stopRecording(){var i;this.isActive()&&((i=this.mediaRecorder)===null||i===void 0||i.stop(),this.timer.stop())}pauseRecording(){var i,t;this.isRecording()&&(this.isWaveformPaused=!0,(i=this.mediaRecorder)===null||i===void 0||i.requestData(),(t=this.mediaRecorder)===null||t===void 0||t.pause(),this.timer.stop(),this.lastDuration=this.duration)}resumeRecording(){var i;this.isPaused()&&(this.isWaveformPaused=!1,(i=this.mediaRecorder)===null||i===void 0||i.resume(),this.timer.start(),this.lastStartTime=performance.now(),this.emit("record-resume"))}static getAvailableAudioDevices(){return w(this,void 0,void 0,function*(){return navigator.mediaDevices.enumerateDevices().then(i=>i.filter(t=>t.kind==="audioinput"))})}destroy(){this.applyOriginalOptionsIfNeeded(),super.destroy(),this.stopRecording(),this.stopMic(),this.recordedBlobUrl&&(URL.revokeObjectURL(this.recordedBlobUrl),this.recordedBlobUrl=null)}applyOriginalOptionsIfNeeded(){this.wavesurfer&&this.originalOptions&&(this.wavesurfer.setOptions(this.originalOptions),delete this.originalOptions)}}export{W as default};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{r as o,I as m,_ as p}from"./index-Bdi0ug4X.js";import{a as y}from"./unsupportedIterableToArray-CFN3yOc2-C4SckrTc.js";var d=o.forwardRef(function(r,e){var t={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return o.createElement(m,p({iconAttrs:t,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},r,{ref:e}),o.createElement("path",{fill:"none",d:"M0 0h24v24H0V0z"}),o.createElement("path",{d:"M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12 19 6.41z"}))});d.displayName="Close";function h(r){if(Array.isArray(r))return r}function b(r,e){var t=r==null?null:typeof Symbol<"u"&&r[Symbol.iterator]||r["@@iterator"];if(t!=null){var i,u,f,a,l=[],n=!0,c=!1;try{if(f=(t=t.call(r)).next,e===0){if(Object(t)!==t)return;n=!1}else for(;!(n=(i=f.call(t)).done)&&(l.push(i.value),l.length!==e);n=!0);}catch(s){c=!0,u=s}finally{try{if(!n&&t.return!=null&&(a=t.return(),Object(a)!==a))return}finally{if(c)throw u}}return l}}function v(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
2
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function E(r,e){return h(r)||b(r,e)||y(r,e)||v()}export{E as A,d as p};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{a as t,o}from"./unsupportedIterableToArray-CFN3yOc2-C4SckrTc.js";function n(r){if(Array.isArray(r))return o(r)}function e(r){if(typeof Symbol<"u"&&r[Symbol.iterator]!=null||r["@@iterator"]!=null)return Array.from(r)}function a(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
2
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function l(r){return n(r)||e(r)||t(r)||a()}export{l};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{bg as n}from"./index-Bdi0ug4X.js";var o=0;function i(r){var t=++o;return n(r)+t}export{i as u};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
function n(r,e){(e==null||e>r.length)&&(e=r.length);for(var t=0,o=Array(e);t<e;t++)o[t]=r[t];return o}function a(r,e){if(r){if(typeof r=="string")return n(r,e);var t={}.toString.call(r).slice(8,-1);return t==="Object"&&r.constructor&&(t=r.constructor.name),t==="Map"||t==="Set"?Array.from(r):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?n(r,e):void 0}}export{a,n as o};
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
function C(l,t,e,i){return new(e||(e=Promise))(function(s,n){function a(r){try{h(i.next(r))}catch(o){n(o)}}function c(r){try{h(i.throw(r))}catch(o){n(o)}}function h(r){var o;r.done?s(r.value):(o=r.value,o instanceof e?o:new e(function(p){p(o)})).then(a,c)}h((i=i.apply(l,t||[])).next())})}class T{constructor(){this.listeners={}}on(t,e,i){if(this.listeners[t]||(this.listeners[t]=new Set),i?.once){const s=(...n)=>{this.un(t,s),e(...n)};return this.listeners[t].add(s),()=>this.un(t,s)}return this.listeners[t].add(e),()=>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 L={decode:function(l,t){return C(this,void 0,void 0,function*(){const e=new AudioContext({sampleRate:t});try{return yield e.decodeAudioData(l)}finally{e.close()}})},createBuffer:function(l,t){if(!l||l.length===0)throw new Error("channelData must be a non-empty array");if(t<=0)throw new Error("duration must be greater than 0");if(typeof l[0]=="number"&&(l=[l]),!l[0]||l[0].length===0)throw new Error("channelData must contain non-empty channel arrays");(function(i){const s=i[0];if(s.some(n=>n>1||n<-1)){const n=s.length;let a=0;for(let c=0;c<n;c++){const h=Math.abs(s[c]);h>a&&(a=h)}for(const c of i)for(let h=0;h<n;h++)c[h]/=a}})(l);const e=l.map(i=>i instanceof Float32Array?i:Float32Array.from(i));return{duration:t,length:e[0].length,sampleRate:e[0].length/t,numberOfChannels:e.length,getChannelData:i=>{const s=e[i];if(!s)throw new Error(`Channel ${i} not found`);return s},copyFromChannel:AudioBuffer.prototype.copyFromChannel,copyToChannel:AudioBuffer.prototype.copyToChannel}}};function X(l,t){const e=t.xmlns?document.createElementNS(t.xmlns,l):document.createElement(l);for(const[i,s]of Object.entries(t))if(i==="children"&&s)for(const[n,a]of Object.entries(s))a instanceof Node?e.appendChild(a):typeof a=="string"?e.appendChild(document.createTextNode(a)):e.appendChild(X(n,a));else i==="style"?Object.assign(e.style,s):i==="textContent"?e.textContent=s:e.setAttribute(i,s.toString());return e}function _(l,t,e){const i=X(l,t||{});return e?.appendChild(i),i}var V=Object.freeze({__proto__:null,createElement:_,default:_});const Y={fetchBlob:function(l,t,e){return C(this,void 0,void 0,function*(){const i=yield fetch(l,e);if(i.status>=400)throw new Error(`Failed to fetch ${l}: ${i.status} (${i.statusText})`);return(function(s,n){C(this,void 0,void 0,function*(){if(!s.body||!s.headers)return;const a=s.body.getReader(),c=Number(s.headers.get("Content-Length"))||0;let h=0;const r=o=>{h+=o?.length||0;const p=Math.round(h/c*100);n(p)};try{for(;;){const o=yield a.read();if(o.done)break;r(o.value)}}catch(o){console.warn("Progress tracking error:",o)}})})(i.clone(),t),i.blob()})}};class J extends T{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 s=e instanceof Blob&&(this.canPlayType(e.type)||!t)?URL.createObjectURL(e):t;if(i&&this.media.removeAttribute("src"),s||t)try{this.media.src=s}catch{this.media.src=t}}destroy(){this.isExternalMedia||(this.media.pause(),this.revokeSrc(),this.media.removeAttribute("src"),this.media.load(),this.media.remove())}setMediaElement(t){this.media=t}play(){return C(this,void 0,void 0,function*(){try{return yield this.media.play()}catch(t){if(t instanceof DOMException&&t.name==="AbortError")return;throw t}})}pause(){this.media.pause()}isPlaying(){return!this.media.paused&&!this.media.ended}setTime(t){this.media.currentTime=Math.max(0,Math.min(t,this.getDuration()))}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)}}function A(l){return l<0?0:l>1?1:l}function K({maxTop:l,maxBottom:t,halfHeight:e,vScale:i}){const s=Math.round(l*e*i);return{topHeight:s,totalHeight:s+Math.round(t*e*i)||1}}function Q({barAlign:l,halfHeight:t,topHeight:e,totalHeight:i,canvasHeight:s}){return l==="top"?0:l==="bottom"?s-i:t-e}function I(l,t,e){const i=t-l.left,s=e-l.top;return[i/l.width,s/l.height]}function U(l){return!!(l.barWidth||l.barGap||l.barAlign)}function $(l,t){if(!U(t))return l;const e=t.barWidth||.5,i=e+(t.barGap||e/2);return i===0?l:Math.floor(l/i)*i}function F({scrollLeft:l,totalWidth:t,numCanvases:e}){if(t===0)return[0];const i=l/t,s=Math.floor(i*e);return[s-1,s,s+1]}function j({scrollLeft:l,clientWidth:t,scrollWidth:e}){return e===0?{startX:0,endX:0}:{startX:l/e,endX:(l+t)/e}}class Z extends T{constructor(t,e){super(),this.timeouts=[],this.isScrollable=!1,this.audioData=null,this.resizeObserver=null,this.lastContainerWidth=0,this.isDragging=!1,this.subscriptions=[],this.unsubscribeOnScroll=[],this.dragUnsubscribe=null,this.subscriptions=[],this.options=t;const i=this.parentFromOptionsContainer(t.container);this.parent=i;const[s,n]=this.initHtml();i.appendChild(s),this.container=s,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(){if(this.wrapper.addEventListener("click",t=>{const e=this.wrapper.getBoundingClientRect(),[i,s]=I(e,t.clientX,t.clientY);this.emit("click",i,s)}),this.wrapper.addEventListener("dblclick",t=>{const e=this.wrapper.getBoundingClientRect(),[i,s]=I(e,t.clientX,t.clientY);this.emit("dblclick",i,s)}),this.options.dragToSeek!==!0&&typeof this.options.dragToSeek!="object"||this.initDrag(),this.scrollContainer.addEventListener("scroll",()=>{const{scrollLeft:t,scrollWidth:e,clientWidth:i}=this.scrollContainer,{startX:s,endX:n}=j({scrollLeft:t,scrollWidth:e,clientWidth:i});this.emit("scroll",s,n,t,t+i)}),typeof ResizeObserver=="function"){const t=this.createDelay(100);this.resizeObserver=new ResizeObserver(()=>{t().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(),this.emit("resize"))}initDrag(){this.dragUnsubscribe||(this.dragUnsubscribe=(function(t,e,i,s,n=3,a=0,c=100){if(!t)return()=>{};const h=new Map,r=matchMedia("(pointer: coarse)").matches;let o=()=>{};const p=m=>{if(m.button!==a||(h.set(m.pointerId,m),h.size>1))return;let d=m.clientX,u=m.clientY,v=!1;const g=Date.now(),P=f=>{if(f.defaultPrevented||h.size>1||r&&Date.now()-g<c)return;const w=f.clientX,E=f.clientY,D=w-d,k=E-u;if(v||Math.abs(D)>n||Math.abs(k)>n){f.preventDefault(),f.stopPropagation();const R=t.getBoundingClientRect(),{left:W,top:M}=R;v||(i?.(d-W,u-M),v=!0),e(D,k,w-W,E-M),d=w,u=E}},S=f=>{if(h.delete(f.pointerId),v){const w=f.clientX,E=f.clientY,D=t.getBoundingClientRect(),{left:k,top:R}=D;s?.(w-k,E-R)}o()},y=f=>{h.delete(f.pointerId),f.relatedTarget&&f.relatedTarget!==document.documentElement||S(f)},x=f=>{v&&(f.stopPropagation(),f.preventDefault())},b=f=>{f.defaultPrevented||h.size>1||v&&f.preventDefault()};document.addEventListener("pointermove",P),document.addEventListener("pointerup",S),document.addEventListener("pointerout",y),document.addEventListener("pointercancel",y),document.addEventListener("touchmove",b,{passive:!1}),document.addEventListener("click",x,{capture:!0}),o=()=>{document.removeEventListener("pointermove",P),document.removeEventListener("pointerup",S),document.removeEventListener("pointerout",y),document.removeEventListener("pointercancel",y),document.removeEventListener("touchmove",b),setTimeout(()=>{document.removeEventListener("click",x,{capture:!0})},10)}};return t.addEventListener("pointerdown",p),()=>{o(),t.removeEventListener("pointerdown",p),h.clear()}})(this.wrapper,(t,e,i)=>{const s=this.wrapper.getBoundingClientRect().width;this.emit("drag",A(i/s))},t=>{this.isDragging=!0;const e=this.wrapper.getBoundingClientRect().width;this.emit("dragstart",A(t/e))},t=>{this.isDragging=!1;const e=this.wrapper.getBoundingClientRect().width;this.emit("dragend",A(t/e))}),this.subscriptions.push(this.dragUnsubscribe))}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
|
-
pointer-events: none;
|
|
33
|
-
}
|
|
34
|
-
:host .canvases > div {
|
|
35
|
-
position: relative;
|
|
36
|
-
}
|
|
37
|
-
:host canvas {
|
|
38
|
-
display: block;
|
|
39
|
-
position: absolute;
|
|
40
|
-
top: 0;
|
|
41
|
-
image-rendering: pixelated;
|
|
42
|
-
}
|
|
43
|
-
:host .progress {
|
|
44
|
-
pointer-events: none;
|
|
45
|
-
position: absolute;
|
|
46
|
-
z-index: 2;
|
|
47
|
-
top: 0;
|
|
48
|
-
left: 0;
|
|
49
|
-
width: 0;
|
|
50
|
-
height: 100%;
|
|
51
|
-
overflow: hidden;
|
|
52
|
-
}
|
|
53
|
-
:host .progress > div {
|
|
54
|
-
position: relative;
|
|
55
|
-
}
|
|
56
|
-
:host .cursor {
|
|
57
|
-
pointer-events: none;
|
|
58
|
-
position: absolute;
|
|
59
|
-
z-index: 5;
|
|
60
|
-
top: 0;
|
|
61
|
-
left: 0;
|
|
62
|
-
height: 100%;
|
|
63
|
-
border-radius: 2px;
|
|
64
|
-
}
|
|
65
|
-
</style>
|
|
66
|
-
|
|
67
|
-
<div class="scroll" part="scroll">
|
|
68
|
-
<div class="wrapper" part="wrapper">
|
|
69
|
-
<div class="canvases" part="canvases"></div>
|
|
70
|
-
<div class="progress" part="progress"></div>
|
|
71
|
-
<div class="cursor" part="cursor"></div>
|
|
72
|
-
</div>
|
|
73
|
-
</div>
|
|
74
|
-
`,[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;this.subscriptions.forEach(e=>e()),this.container.remove(),this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null),(t=this.unsubscribeOnScroll)===null||t===void 0||t.forEach(e=>e()),this.unsubscribeOnScroll=[]}createDelay(t=10){let e,i;const s=()=>{e&&(clearTimeout(e),e=void 0),i&&(i(),i=void 0)};return this.timeouts.push(s),()=>new Promise((n,a)=>{s(),i=a,e=setTimeout(()=>{e=void 0,i=void 0,n()},t)})}getHeight(t,e){var i;const s=((i=this.audioData)===null||i===void 0?void 0:i.numberOfChannels)||1;return(function({optionsHeight:n,optionsSplitChannels:a,parentHeight:c,numberOfChannels:h,defaultHeight:r=128}){if(n==null)return r;const o=Number(n);if(!isNaN(o))return o;if(n==="auto"){const p=c||r;return a?.every(m=>!m.overlay)?p/h:p}return r})({optionsHeight:t,optionsSplitChannels:e,parentHeight:this.parent.clientHeight,numberOfChannels:s,defaultHeight:128})}convertColorValues(t){return(function(e,i){if(!Array.isArray(e))return e||"";if(e.length===0)return"#999";if(e.length<2)return e[0]||"";const s=document.createElement("canvas"),n=s.getContext("2d"),a=s.height*i,c=n.createLinearGradient(0,0,0,a||i),h=1/(e.length-1);return e.forEach((r,o)=>{c.addColorStop(o*h,r)}),c})(t,this.getPixelRatio())}getPixelRatio(){return t=window.devicePixelRatio,Math.max(1,t||1);var t}renderBarWaveform(t,e,i,s){const{width:n,height:a}=i.canvas,{halfHeight:c,barWidth:h,barRadius:r,barIndexScale:o,barSpacing:p}=(function({width:d,height:u,length:v,options:g,pixelRatio:P}){const S=u/2,y=g.barWidth?g.barWidth*P:1,x=g.barGap?g.barGap*P:g.barWidth?y/2:0,b=y+x||1;return{halfHeight:S,barWidth:y,barGap:x,barRadius:g.barRadius||0,barIndexScale:v>0?d/b/v:0,barSpacing:b}})({width:n,height:a,length:(t[0]||[]).length,options:e,pixelRatio:this.getPixelRatio()}),m=(function({channelData:d,barIndexScale:u,barSpacing:v,barWidth:g,halfHeight:P,vScale:S,canvasHeight:y,barAlign:x}){const b=d[0]||[],f=d[1]||b,w=b.length,E=[];let D=0,k=0,R=0;for(let W=0;W<=w;W++){const M=Math.round(W*u);if(M>D){const{topHeight:q,totalHeight:z}=K({maxTop:k,maxBottom:R,halfHeight:P,vScale:S}),G=Q({barAlign:x,halfHeight:P,topHeight:q,totalHeight:z,canvasHeight:y});E.push({x:D*v,y:G,width:g,height:z}),D=M,k=0,R=0}const N=Math.abs(b[W]||0),B=Math.abs(f[W]||0);N>k&&(k=N),B>R&&(R=B)}return E})({channelData:t,barIndexScale:o,barSpacing:p,barWidth:h,halfHeight:c,vScale:s,canvasHeight:a,barAlign:e.barAlign});i.beginPath();for(const d of m)r&&"roundRect"in i?i.roundRect(d.x,d.y,d.width,d.height,r):i.rect(d.x,d.y,d.width,d.height);i.fill(),i.closePath()}renderLineWaveform(t,e,i,s){const{width:n,height:a}=i.canvas,c=(function({channelData:h,width:r,height:o,vScale:p}){const m=o/2,d=h[0]||[];return[d,h[1]||d].map((u,v)=>{const g=u.length,P=g?r/g:0,S=m,y=v===0?-1:1,x=[{x:0,y:S}];let b=0,f=0;for(let w=0;w<=g;w++){const E=Math.round(w*P);if(E>b){const k=S+(Math.round(f*m*p)||1)*y;x.push({x:b,y:k}),b=E,f=0}const D=Math.abs(u[w]||0);D>f&&(f=D)}return x.push({x:b,y:S}),x})})({channelData:t,width:n,height:a,vScale:s});i.beginPath();for(const h of c)if(h.length){i.moveTo(h[0].x,h[0].y);for(let r=1;r<h.length;r++){const o=h[r];i.lineTo(o.x,o.y)}}i.fill(),i.closePath()}renderWaveform(t,e,i){if(i.fillStyle=this.convertColorValues(e.waveColor),e.renderFunction)return void e.renderFunction(t,i);const s=(function({channelData:n,barHeight:a,normalize:c}){var h;const r=a||1;if(!c)return r;const o=n[0];if(!o||o.length===0)return r;let p=0;for(let m=0;m<o.length;m++){const d=(h=o[m])!==null&&h!==void 0?h:0,u=Math.abs(d);u>p&&(p=u)}return p?r/p:r})({channelData:t,barHeight:e.barHeight,normalize:e.normalize});U(e)?this.renderBarWaveform(t,e,i,s):this.renderLineWaveform(t,e,i,s)}renderSingleCanvas(t,e,i,s,n,a,c){const h=this.getPixelRatio(),r=document.createElement("canvas");r.width=Math.round(i*h),r.height=Math.round(s*h),r.style.width=`${i}px`,r.style.height=`${s}px`,r.style.left=`${Math.round(n)}px`,a.appendChild(r);const o=r.getContext("2d");if(e.renderFunction?(o.fillStyle=this.convertColorValues(e.waveColor),e.renderFunction(t,o)):this.renderWaveform(t,e,o),r.width>0&&r.height>0){const p=r.cloneNode(),m=p.getContext("2d");m.drawImage(r,0,0),m.globalCompositeOperation="source-in",m.fillStyle=this.convertColorValues(e.progressColor),m.fillRect(0,0,r.width,r.height),c.appendChild(p)}}renderMultiCanvas(t,e,i,s,n,a){const c=this.getPixelRatio(),{clientWidth:h}=this.scrollContainer,r=i/c,o=(function({clientWidth:u,totalWidth:v,options:g}){return $(Math.min(8e3,u,v),g)})({clientWidth:h,totalWidth:r,options:e});let p={};if(o===0)return;const m=u=>{if(u<0||u>=d||p[u])return;p[u]=!0;const v=u*o;let g=Math.min(r-v,o);if(g=$(g,e),g<=0)return;const P=(function({channelData:S,offset:y,clampedWidth:x,totalWidth:b}){return S.map(f=>{const w=Math.floor(y/b*f.length),E=Math.floor((y+x)/b*f.length);return f.slice(w,E)})})({channelData:t,offset:v,clampedWidth:g,totalWidth:r});this.renderSingleCanvas(P,e,g,s,v,n,a)},d=Math.ceil(r/o);if(!this.isScrollable){for(let u=0;u<d;u++)m(u);return}if(F({scrollLeft:this.scrollContainer.scrollLeft,totalWidth:r,numCanvases:d}).forEach(u=>m(u)),d>1){const u=this.on("scroll",()=>{const{scrollLeft:v}=this.scrollContainer;Object.keys(p).length>10&&(n.innerHTML="",a.innerHTML="",p={}),F({scrollLeft:v,totalWidth:r,numCanvases:d}).forEach(g=>m(g))});this.unsubscribeOnScroll.push(u)}}renderChannel(t,e,i,s){var{overlay:n}=e,a=(function(o,p){var m={};for(var d in o)Object.prototype.hasOwnProperty.call(o,d)&&p.indexOf(d)<0&&(m[d]=o[d]);if(o!=null&&typeof Object.getOwnPropertySymbols=="function"){var u=0;for(d=Object.getOwnPropertySymbols(o);u<d.length;u++)p.indexOf(d[u])<0&&Object.prototype.propertyIsEnumerable.call(o,d[u])&&(m[d[u]]=o[d[u]])}return m})(e,["overlay"]);const c=document.createElement("div"),h=this.getHeight(a.height,a.splitChannels);c.style.height=`${h}px`,n&&s>0&&(c.style.marginTop=`-${h}px`),this.canvasWrapper.style.minHeight=`${h}px`,this.canvasWrapper.appendChild(c);const r=c.cloneNode();this.progressWrapper.appendChild(r),this.renderMultiCanvas(t,a,i,h,c,r)}render(t){return C(this,void 0,void 0,function*(){var e;this.timeouts.forEach(r=>r()),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(),s=this.scrollContainer.clientWidth,{scrollWidth:n,isScrollable:a,useParentWidth:c,width:h}=(function({duration:r,minPxPerSec:o=0,parentWidth:p,fillParent:m,pixelRatio:d}){const u=Math.ceil(r*o),v=u>p,g=!!(m&&!v);return{scrollWidth:u,isScrollable:v,useParentWidth:g,width:(g?p:u)*d}})({duration:t.duration,minPxPerSec:this.options.minPxPerSec||0,parentWidth:s,fillParent:this.options.fillParent,pixelRatio:i});if(this.isScrollable=a,this.wrapper.style.width=c?"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 r=0;r<t.numberOfChannels;r++){const o=Object.assign(Object.assign({},this.options),(e=this.options.splitChannels)===null||e===void 0?void 0:e[r]);this.renderChannel([t.getChannelData(r)],o,h,r)}else{const r=[t.getChannelData(0)];t.numberOfChannels>1&&r.push(t.getChannelData(1)),this.renderChannel(r,this.options,h,0)}Promise.resolve().then(()=>this.emit("rendered"))})}reRender(){if(this.unsubscribeOnScroll.forEach(i=>i()),this.unsubscribeOnScroll=[],!this.audioData)return;const{scrollWidth:t}=this.scrollContainer,{right:e}=this.progressWrapper.getBoundingClientRect();if(this.render(this.audioData),this.isScrollable&&t!==this.scrollContainer.scrollWidth){const{right:i}=this.progressWrapper.getBoundingClientRect(),s=(function(n){const a=2*n;return(a<0?Math.floor(a):Math.ceil(a))/2})(i-e);this.scrollContainer.scrollLeft+=s}}zoom(t){this.options.minPxPerSec=t,this.reRender()}scrollIntoView(t,e=!1){const{scrollLeft:i,scrollWidth:s,clientWidth:n}=this.scrollContainer,a=t*s,c=i,h=i+n,r=n/2;if(this.isDragging)a+30>h?this.scrollContainer.scrollLeft+=30:a-30<c&&(this.scrollContainer.scrollLeft-=30);else{(a<c||a>h)&&(this.scrollContainer.scrollLeft=a-(this.options.autoCenter?r:0));const o=a-i-r;e&&this.options.autoCenter&&o>0&&(this.scrollContainer.scrollLeft+=o)}{const o=this.scrollContainer.scrollLeft,{startX:p,endX:m}=j({scrollLeft:o,scrollWidth:s,clientWidth:n});this.emit("scroll",p,m,o,o+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=this.options.cursorWidth?`translateX(-${t*this.options.cursorWidth}px)`:"",this.isScrollable&&this.options.autoScroll&&this.scrollIntoView(t,e)}exportImage(t,e,i){return C(this,void 0,void 0,function*(){const s=this.canvasWrapper.querySelectorAll("canvas");if(!s.length)throw new Error("No waveform data");if(i==="dataURL"){const n=Array.from(s).map(a=>a.toDataURL(t,e));return Promise.resolve(n)}return Promise.all(Array.from(s).map(n=>new Promise((a,c)=>{n.toBlob(h=>{h?a(h):c(new Error("Could not export image"))},t,e)})))})}}class tt extends T{constructor(){super(...arguments),this.animationFrameId=null,this.isRunning=!1}start(){if(this.isRunning)return;this.isRunning=!0;const t=()=>{this.isRunning&&(this.emit("tick"),this.animationFrameId=requestAnimationFrame(t))};t()}stop(){this.isRunning=!1,this.animationFrameId!==null&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null)}destroy(){this.stop()}}class H extends T{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 C(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())}).catch(e=>{console.error("WebAudioPlayer load error:",e)})}_play(){if(!this.paused)return;this.paused=!1,this.bufferNode&&(this.bufferNode.onended=null,this.bufferNode.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 t=this.playedDuration*this._playbackRate;(t>=this.duration||t<0)&&(t=0,this.playedDuration=0),this.bufferNode.start(this.audioContext.currentTime,t),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 C(this,void 0,void 0,function*(){this.paused&&(this._play(),this.emit("play"))})}pause(){this.paused||(this._pause(),this.emit("pause"))}stopAt(t){const e=t-this.currentTime,i=this.bufferNode;i?.stop(this.audioContext.currentTime+e),i?.addEventListener("ended",()=>{i===this.bufferNode&&(this.bufferNode=null,this.pause())},{once:!0})}setSinkId(t){return C(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}removeAttribute(t){switch(t){case"src":this.src="";break;case"playbackRate":this.playbackRate=0;break;case"currentTime":this.currentTime=0;break;case"duration":this.duration=0;break;case"volume":this.volume=0;break;case"muted":this.muted=!1}}}const et={waveColor:"#999",progressColor:"#555",cursorWidth:1,minPxPerSec:0,fillParent:!0,interact:!0,dragToSeek:!1,autoScroll:!0,autoCenter:!0,sampleRate:8e3};class O extends J{static create(t){return new O(t)}constructor(t){const e=t.media||(t.backend==="WebAudio"?new H:void 0);super({media:e,mediaControls:t.mediaControls,autoplay:t.autoplay,playbackRate:t.audioRate}),this.plugins=[],this.decodedData=null,this.stopAtPosition=null,this.subscriptions=[],this.mediaSubscriptions=[],this.abortController=null,this.options=Object.assign({},et,t),this.timer=new tt;const i=e?void 0:this.getMediaElement();this.renderer=new Z(this.options,i),this.initPlayerEvents(),this.initRendererEvents(),this.initTimerEvents(),this.initPlugins();const s=this.options.url||this.getSrc()||"";Promise.resolve().then(()=>{this.emit("init");const{peaks:n,duration:a}=this.options;(s||n&&a)&&this.load(s,n,a).catch(c=>{this.emit("error",c instanceof Error?c:new Error(String(c)))})})}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),this.stopAtPosition!=null&&this.isPlaying()&&t>=this.stopAtPosition&&this.pause()}}))}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.stopAtPosition=null}),this.onMediaEvent("emptied",()=>{this.timer.stop(),this.stopAtPosition=null}),this.onMediaEvent("ended",()=>{this.emit("timeupdate",this.getDuration()),this.emit("finish"),this.stopAtPosition=null}),this.onMediaEvent("seeking",()=>{this.emit("seeking",this.getCurrentTime())}),this.onMediaEvent("error",()=>{var t;this.emit("error",(t=this.getMediaElement().error)!==null&&t!==void 0?t:new Error("Media error")),this.stopAtPosition=null}))}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,s)=>{const n=this.getDuration();this.emit("scroll",t*n,e*n,i,s)}),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)}),this.renderer.on("resize",()=>{this.emit("resize")}));{let t;const e=this.renderer.on("drag",i=>{var s;if(!this.options.interact)return;this.renderer.renderProgress(i),clearTimeout(t);let n=0;const a=this.options.dragToSeek;this.isPlaying()?n=0:a===!0?n=200:a&&typeof a=="object"&&(n=(s=a.debounceTime)!==null&&s!==void 0?s:200),t=setTimeout(()=>{this.seekTo(i)},n),this.emit("interaction",i*this.getDuration()),this.emit("drag",i)});this.subscriptions.push(()=>{clearTimeout(t),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),t.duration&&!t.peaks&&(this.decodedData=L.createBuffer(this.exportPeaks(),t.duration)),t.peaks&&t.duration&&(this.decodedData=L.createBuffer(t.peaks,t.duration)),this.renderer.setOptions(this.options),t.audioRate&&this.setPlaybackRate(t.audioRate),t.mediaControls!=null&&(this.getMediaElement().controls=t.mediaControls)}registerPlugin(t){if(this.plugins.includes(t))return t;t._init(this),this.plugins.push(t);const e=t.once("destroy",()=>{this.plugins=this.plugins.filter(i=>i!==t),this.subscriptions=this.subscriptions.filter(i=>i!==e)});return this.subscriptions.push(e),t}unregisterPlugin(t){this.plugins=this.plugins.filter(e=>e!==t),t.destroy()}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,s){return C(this,void 0,void 0,function*(){var n;if(this.emit("load",t),!this.options.media&&this.isPlaying()&&this.pause(),this.decodedData=null,this.stopAtPosition=null,(n=this.abortController)===null||n===void 0||n.abort(),this.abortController=null,!e&&!i){const c=this.options.fetchParams||{};window.AbortController&&!c.signal&&(this.abortController=new AbortController,c.signal=this.abortController.signal);const h=o=>this.emit("loading",o);e=yield Y.fetchBlob(t,h,c);const r=this.options.blobMimeType;r&&(e=new Blob([e],{type:r}))}this.setSrc(t,e);const a=yield new Promise(c=>{const h=s||this.getDuration();h?c(h):this.mediaSubscriptions.push(this.onMediaEvent("loadedmetadata",()=>c(this.getDuration()),{once:!0}))});if(!t&&!e){const c=this.getMediaElement();c instanceof H&&(c.duration=a)}if(i)this.decodedData=L.createBuffer(i,a||0);else if(e){const c=yield e.arrayBuffer();this.decodedData=yield L.decode(c,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 C(this,void 0,void 0,function*(){try{return yield this.loadAudio(t,void 0,e,i)}catch(s){throw this.emit("error",s),s}})}loadBlob(t,e,i){return C(this,void 0,void 0,function*(){try{return yield this.loadAudio("",t,e,i)}catch(s){throw this.emit("error",s),s}})}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 s=Math.min(t,this.decodedData.numberOfChannels),n=[];for(let a=0;a<s;a++){const c=this.decodedData.getChannelData(a),h=[],r=c.length/e;for(let o=0;o<e;o++){const p=c.slice(Math.floor(o*r),Math.ceil((o+1)*r));let m=0;for(let d=0;d<p.length;d++){const u=p[d];Math.abs(u)>Math.abs(m)&&(m=u)}h.push(Math.round(m*i)/i)}n.push(h)}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){this.stopAtPosition=null,super.setTime(t),this.updateProgress(t),this.emit("timeupdate",t)}seekTo(t){const e=this.getDuration()*t;this.setTime(e)}play(t,e){const i=Object.create(null,{play:{get:()=>super.play}});return C(this,void 0,void 0,function*(){t!=null&&this.setTime(t);const s=yield i.play.call(this);return e!=null&&(this.media instanceof H?this.media.stopAt(e):this.stopAtPosition=e),s})}playPause(){return C(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 C(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()}}O.BasePlugin=class extends T{constructor(l){super(),this.subscriptions=[],this.isDestroyed=!1,this.options=l}onInit(){}_init(l){this.isDestroyed&&(this.subscriptions=[],this.isDestroyed=!1),this.wavesurfer=l,this.onInit()}destroy(){this.emit("destroy"),this.subscriptions.forEach(l=>l()),this.subscriptions=[],this.isDestroyed=!0,this.wavesurfer=void 0}},O.dom=V;export{O as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{bl as o,K as r,m as t,ae as c}from"./index-Bdi0ug4X.js";const m=e=>{const s=a=>{const{width:i,elementRef:n}=r();return t.jsx(c,{ref:n,children:t.jsx(e,{...a,width:i})})};return s.displayName=`withCalculatedWidth(${e.displayName||e.name})`,o(s,e)};export{m as o};
|
|
Binary file
|