streamlit-nightly 1.39.1.dev20241021__py2.py3-none-any.whl → 1.39.1.dev20241023__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/elements/widgets/button_group.py +18 -18
- streamlit/static/asset-manifest.json +5 -5
- streamlit/static/index.html +1 -1
- streamlit/static/static/js/223.2359dae5.chunk.js +1 -0
- streamlit/static/static/js/{3224.86a6ba35.chunk.js → 3224.a04b49ba.chunk.js} +1 -1
- streamlit/static/static/js/9993.5b55b4c2.chunk.js +1 -0
- streamlit/static/static/js/main.c508d2af.js +28 -0
- streamlit/web/server/component_request_handler.py +1 -1
- {streamlit_nightly-1.39.1.dev20241021.dist-info → streamlit_nightly-1.39.1.dev20241023.dist-info}/METADATA +1 -1
- {streamlit_nightly-1.39.1.dev20241021.dist-info → streamlit_nightly-1.39.1.dev20241023.dist-info}/RECORD +15 -15
- streamlit/static/static/js/223.ad5699f4.chunk.js +0 -1
- streamlit/static/static/js/6073.192808c1.chunk.js +0 -1
- streamlit/static/static/js/main.62a02ffe.js +0 -28
- /streamlit/static/static/js/{main.62a02ffe.js.LICENSE.txt → main.c508d2af.js.LICENSE.txt} +0 -0
- {streamlit_nightly-1.39.1.dev20241021.data → streamlit_nightly-1.39.1.dev20241023.data}/scripts/streamlit.cmd +0 -0
- {streamlit_nightly-1.39.1.dev20241021.dist-info → streamlit_nightly-1.39.1.dev20241023.dist-info}/WHEEL +0 -0
- {streamlit_nightly-1.39.1.dev20241021.dist-info → streamlit_nightly-1.39.1.dev20241023.dist-info}/entry_points.txt +0 -0
- {streamlit_nightly-1.39.1.dev20241021.dist-info → streamlit_nightly-1.39.1.dev20241023.dist-info}/top_level.txt +0 -0
@@ -51,7 +51,7 @@ class ComponentRequestHandler(tornado.web.RequestHandler):
|
|
51
51
|
# follow symlinks to get an accurate normalized path
|
52
52
|
component_root = os.path.realpath(component_root)
|
53
53
|
filename = "/".join(parts[1:])
|
54
|
-
abspath = os.path.
|
54
|
+
abspath = os.path.normpath(os.path.join(component_root, filename))
|
55
55
|
|
56
56
|
# Do NOT expose anything outside of the component root.
|
57
57
|
if os.path.commonpath([component_root, abspath]) != component_root:
|
@@ -107,7 +107,7 @@ streamlit/elements/lib/utils.py,sha256=8VVty4Jd99ynSxjKKqVnEaVsFydBX2m2s24fIdkGg
|
|
107
107
|
streamlit/elements/widgets/__init__.py,sha256=Vrf1yVMOcTyhUPnYvsfyeL96Vpd5z8KoSV5ZzTcTQgU,616
|
108
108
|
streamlit/elements/widgets/audio_input.py,sha256=KroApvExRV13-yrJ-C6JrUh-GC2JIWttvsK6nhJXxyE,9757
|
109
109
|
streamlit/elements/widgets/button.py,sha256=jTU7WGHpmZMzc-Gw1DxCfaSIQKtpdN6AHPM7rTirpbg,35986
|
110
|
-
streamlit/elements/widgets/button_group.py,sha256=
|
110
|
+
streamlit/elements/widgets/button_group.py,sha256=You6meqlHA5kbATpzcmglJPhVYvTDPJzeVSY3uL5e8o,35368
|
111
111
|
streamlit/elements/widgets/camera_input.py,sha256=Hw0TyeehVa4LSvUsERoNjh1pYHXuarw19r0gTCVxyBY,8593
|
112
112
|
streamlit/elements/widgets/chat.py,sha256=L7LFirsBih6jFOWIJJMvVh_1xlltD0g-ZsTp8QhxGPk,14326
|
113
113
|
streamlit/elements/widgets/checkbox.py,sha256=Y9kXtleUdGibdpu1MVs2x_Gj-cLRkxVIc8ji0oBeLJs,11188
|
@@ -347,9 +347,9 @@ streamlit/runtime/state/safe_session_state.py,sha256=WLFFyMtP4F19TWWBarKtSP942Ie
|
|
347
347
|
streamlit/runtime/state/session_state.py,sha256=SMBWsSZY29jAgL3QfX4xvJr9aLCNrHHUz9AmosX7FlQ,28850
|
348
348
|
streamlit/runtime/state/session_state_proxy.py,sha256=IWF43f6UWL4KyxNWF3aTv1sbykNI2hI5UsPF2UIfpdE,5524
|
349
349
|
streamlit/runtime/state/widgets.py,sha256=r5XOgHBh9AqS52rgKGgDXFGnkdY6ObUJBSSUBqkzTK8,5319
|
350
|
-
streamlit/static/asset-manifest.json,sha256=
|
350
|
+
streamlit/static/asset-manifest.json,sha256=CNJn1RSOkjut-FCjpU4q_-O6pkWiOeoe6XhUCIvgM4M,14713
|
351
351
|
streamlit/static/favicon.png,sha256=if5cVgw7azxKOvV5FpGixga7JLn23rfnHcy1CdWI1-E,1019
|
352
|
-
streamlit/static/index.html,sha256=
|
352
|
+
streamlit/static/index.html,sha256=6cTxuh8m_7tMkJhWoYVBJoY27Hq6B9b5ofg45X7VSUg,891
|
353
353
|
streamlit/static/static/css/4096.8b8f33d6.chunk.css,sha256=4m2lbj1eVFXSaGCRBHZNhqyRz-4Ce9KogjJPxIq6On8,33275
|
354
354
|
streamlit/static/static/css/9943.d452238e.chunk.css,sha256=B69nSRvppH7uO-_kso_XSGce7SJOCm8ZD1GB9g6fttA,12038
|
355
355
|
streamlit/static/static/css/main.5513bd04.css,sha256=9vuriEsFvHDyAwsI3vtBY9PNL8UOjqGwWZ4lZHsdFzw,29356
|
@@ -358,10 +358,10 @@ streamlit/static/static/js/1101.13462bff.chunk.js,sha256=Iu-ECFDUDJJ14X1UQR4KIqt
|
|
358
358
|
streamlit/static/static/js/1260.dc193a5e.chunk.js,sha256=Xm4rj0pmMBuJ81DSUJY8RR4iqteyXF4OavQ6AegsqKk,10999
|
359
359
|
streamlit/static/static/js/1674.86aea8e0.chunk.js,sha256=g2RyDOrwFlJImiNgHT8Yo_LVDjfqRV5DHDhXK_IYdQE,9236
|
360
360
|
streamlit/static/static/js/1674.86aea8e0.chunk.js.LICENSE.txt,sha256=426lVBKMW2FKu5BqnSDpZnhms1QqJZ-nDvqwC62w-Z8,479
|
361
|
-
streamlit/static/static/js/223.
|
361
|
+
streamlit/static/static/js/223.2359dae5.chunk.js,sha256=QSBOzn0nC-VViJW5bSdwAWp_7VI-_JgELrhMQdM-aEM,15452
|
362
362
|
streamlit/static/static/js/245.f99a075b.chunk.js,sha256=Uh-JbxYM-u3OWNz4ic9QpO1-ctFk64sER5Y61FUIYwQ,16029
|
363
363
|
streamlit/static/static/js/2627.2462a014.chunk.js,sha256=PdOFzDOJSqybqqZpNdX3C-QzWLq7SuVcMjhY--a7mJA,21253
|
364
|
-
streamlit/static/static/js/3224.
|
364
|
+
streamlit/static/static/js/3224.a04b49ba.chunk.js,sha256=0z1RX1ZDDy4egCCqcr6N5sbOFXnh-CxxuZ5qwL5yW1k,15373
|
365
365
|
streamlit/static/static/js/3389.71902a75.chunk.js,sha256=rmAaytiYyUUn62JwB0cWuq8XlufugjELi3FkHfwri0Y,2263290
|
366
366
|
streamlit/static/static/js/3391.7aba08a0.chunk.js,sha256=UwAjzqpjIayXO5WqVNvDCtg4KTmFpaOtpPSVLJYSTWA,2177
|
367
367
|
streamlit/static/static/js/3471.de4b25a2.chunk.js,sha256=v46A9eVjvhxYsBZ6SFG6wRg94XAccGQn6xA3q7sIluE,2698
|
@@ -384,7 +384,6 @@ streamlit/static/static/js/5764.5a55e5be.chunk.js,sha256=EXfo-JRIKlOsXU91rI9-4Nu
|
|
384
384
|
streamlit/static/static/js/5828.f8572ba4.chunk.js,sha256=KrgzrwMJj70Ou4vPwvpeUEd-E7fKQUKUGK_y6wGkEf8,2272
|
385
385
|
streamlit/static/static/js/583.61ac7fde.chunk.js,sha256=ZNm9WsrrmRUjAJPKbaBwKDxJeXYgp3Prip_YtHMU3Nc,3252
|
386
386
|
streamlit/static/static/js/5849.e92568db.chunk.js,sha256=2ay_pWGuk6Y26KeBbfMGqGzOJWBCpuqN9Y3MGN8CPG0,22834
|
387
|
-
streamlit/static/static/js/6073.192808c1.chunk.js,sha256=aFAGqEXyyLDqeR2G2rAkMhZQQEKpY643ew439AWBMFg,40343
|
388
387
|
streamlit/static/static/js/6088.cf24e25c.chunk.js,sha256=7rVWAzP5oDH4aAJrS-YpRYeFTUIz_40aKJcgHhlxoqU,21141
|
389
388
|
streamlit/static/static/js/6141.d2879825.chunk.js,sha256=1thDcPIyU3rnFInTd2gUU4O0XqpLVqANd1G4tbvESJE,1190
|
390
389
|
streamlit/static/static/js/6198.956025ac.chunk.js,sha256=M8auCVk5IHkZg39jS43Ix7QyPAx87dv0MyXhEPkAlmc,3660955
|
@@ -419,8 +418,9 @@ streamlit/static/static/js/9528.a58c0ad2.chunk.js,sha256=LCX8VwyKfm9gr9lIAvz5d-8
|
|
419
418
|
streamlit/static/static/js/954.88014372.chunk.js,sha256=iM-oVcorvEnZJzzEem6IrtXG6U63FfXPupeoIxFK92U,8769
|
420
419
|
streamlit/static/static/js/9923.2bb9616f.chunk.js,sha256=EtTxhVpm_jY8E23uFAg-00WCnbvi1zXVRAky8JxbMaI,3579
|
421
420
|
streamlit/static/static/js/9943.54dc52f7.chunk.js,sha256=__dBNdmwDa6eZ3IwppDYRvXWnBWfwKeRHCvHl6imidw,49465
|
422
|
-
streamlit/static/static/js/
|
423
|
-
streamlit/static/static/js/main.
|
421
|
+
streamlit/static/static/js/9993.5b55b4c2.chunk.js,sha256=uJI1SGarpF5Lc12L6nzoWCAPNtWOYmW6m6pf4tt_RkI,40386
|
422
|
+
streamlit/static/static/js/main.c508d2af.js,sha256=6GU-aCGM7BYXBoWjd9eyfiEUc123ltXRIHCIWQ5G5fo,4481463
|
423
|
+
streamlit/static/static/js/main.c508d2af.js.LICENSE.txt,sha256=vcwWCW5VNoALG8YyhU5k8oDUNAwYisMZfiZ8X1cvtWk,4730
|
424
424
|
streamlit/static/static/media/KaTeX_AMS-Regular.73ea273a72f4aca30ca5.woff2,sha256=DN04fJWQoan5eUVgAi27WWVKfYbxh6oMgUla1C06cwg,28076
|
425
425
|
streamlit/static/static/media/KaTeX_AMS-Regular.853be92419a6c3766b9a.ttf,sha256=aFNIQLz90r_7bw6N60hoTdAefwTqKBMmdXevuQbeHRM,63632
|
426
426
|
streamlit/static/static/media/KaTeX_AMS-Regular.d562e886c52f12660a41.woff,sha256=MNqR6EyJP4deJSaJ-uvcWQsocRReitx_mp1NvYzgslE,33516
|
@@ -534,7 +534,7 @@ streamlit/web/cli.py,sha256=a5d_KIyFsOI2bzE8pPcyVhIvbt5jlxT850RKfquyYuU,11268
|
|
534
534
|
streamlit/web/server/__init__.py,sha256=w4TFcV0OjM5zx8ej7oThRIyB6gq3kqdt45XBk1zkRWo,1080
|
535
535
|
streamlit/web/server/app_static_file_handler.py,sha256=HQwZXzv2LMv0Kuq9gQYfHCS7midNJWj5us7Dt1UOvUY,3110
|
536
536
|
streamlit/web/server/browser_websocket_handler.py,sha256=rcOCOfzs1cgkipT-8drKBVdxMsJDwihRccaOea3KYqU,7950
|
537
|
-
streamlit/web/server/component_request_handler.py,sha256=
|
537
|
+
streamlit/web/server/component_request_handler.py,sha256=nPgLavJe4Guk49YvlSkTc-wfJhY6EaJBd96UD6aMBqc,4415
|
538
538
|
streamlit/web/server/media_file_handler.py,sha256=2KfzPnMN1RstMtI4fs0PD0vFiFrWMyKL0q7LfWJLYZ4,5270
|
539
539
|
streamlit/web/server/routes.py,sha256=dylD7VM9cyd6znQew1cCGHdSJx1zJ-JSXLhqMzqmpjs,10263
|
540
540
|
streamlit/web/server/server.py,sha256=OV1rZto9AmAOGllVoc4N25ZCPDSaERNJQOTKmrWwtZs,15398
|
@@ -542,9 +542,9 @@ streamlit/web/server/server_util.py,sha256=ioIHkXNlA_ujj2Q3isziM8r5glKxgK2JZRoCD
|
|
542
542
|
streamlit/web/server/stats_request_handler.py,sha256=e144zIhzLTB1PN4CwTCxElCoWMuo9IsBEPex2exHCQ0,3641
|
543
543
|
streamlit/web/server/upload_file_request_handler.py,sha256=ftyKpARrUjOpRcFETIXuoTyOG_mo-ToOw5NI0y_W4lE,5003
|
544
544
|
streamlit/web/server/websocket_headers.py,sha256=uUxypj04ondEC4ocBiYCndX_N06Zwe1Mt690Vupe08Y,2232
|
545
|
-
streamlit_nightly-1.39.1.
|
546
|
-
streamlit_nightly-1.39.1.
|
547
|
-
streamlit_nightly-1.39.1.
|
548
|
-
streamlit_nightly-1.39.1.
|
549
|
-
streamlit_nightly-1.39.1.
|
550
|
-
streamlit_nightly-1.39.1.
|
545
|
+
streamlit_nightly-1.39.1.dev20241023.data/scripts/streamlit.cmd,sha256=ZEYM3vBJSp-k7vwSJ3ba5NzEk9-qHdSeLvGYAAe1mMw,676
|
546
|
+
streamlit_nightly-1.39.1.dev20241023.dist-info/METADATA,sha256=3spvH3I7YXJ_KAA8434j36JlnOfSB3kGA63H7xRDmyI,8512
|
547
|
+
streamlit_nightly-1.39.1.dev20241023.dist-info/WHEEL,sha256=TJ49d73sNs10F0aze1W_bTW2P_X7-F4YXOlBqoqA-jY,109
|
548
|
+
streamlit_nightly-1.39.1.dev20241023.dist-info/entry_points.txt,sha256=uNJ4DwGNXEhOK0USwSNanjkYyR-Bk7eYQbJFDrWyOgY,53
|
549
|
+
streamlit_nightly-1.39.1.dev20241023.dist-info/top_level.txt,sha256=V3FhKbm7G2LnR0s4SytavrjIPNIhvcsAGXfYHAwtQzw,10
|
550
|
+
streamlit_nightly-1.39.1.dev20241023.dist-info/RECORD,,
|
@@ -1 +0,0 @@
|
|
1
|
-
"use strict";(self.webpackChunk_streamlit_app=self.webpackChunk_streamlit_app||[]).push([[223],{40223:(e,t,o)=>{o.r(t),o.d(t,{default:()=>Se});var i=o(58878),n=o(86411),r=o(83614),l=o(34679),s=o(93594),a=o(78477),c=o(8151),d=o(68994),h=o(16795),u=o(29669);var g=o(85850),m=o(59323),p=o(4494),f=o(53124),b=o.n(f),v=o(32782),x=o(67253),y=o(1780),C=o(84152),w=o(6240),S=o(90782);const j=e=>{let{error:t,width:o,deltaType:i}=e;return t instanceof k?(0,S.jsx)(w.A,{width:o,name:"No Mapbox token provided",message:(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)("p",{children:["To use ",(0,S.jsxs)("code",{children:["st.",i]})," or ",(0,S.jsx)("code",{children:"st.map"})," you need to set up a Mapbox access token."]}),(0,S.jsxs)("p",{children:["To get a token, create an account at"," ",(0,S.jsx)("a",{href:"https://mapbox.com",children:"https://mapbox.com"}),". It's free for moderate usage levels!"]}),(0,S.jsxs)("p",{children:["Once you have a token, just set it using the Streamlit config option ",(0,S.jsx)("code",{children:"mapbox.token"})," and don't forget to restart your Streamlit server at this point if it's still running, then reload this tab."]}),(0,S.jsxs)("p",{children:["See"," ",(0,S.jsx)("a",{href:"https://docs.streamlit.io/develop/api-reference/configuration/config.toml",children:"our documentation"})," ","for more info on how to set config options."]})]})}):t instanceof F?(0,S.jsx)(w.A,{width:o,name:"Error fetching Streamlit Mapbox token",message:(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)("p",{children:"This app requires an internet connection."}),(0,S.jsx)("p",{children:"Please check your connection and try again."}),(0,S.jsxs)("p",{children:["If you think this is a bug, please file bug report"," ",(0,S.jsx)("a",{href:"https://github.com/streamlit/streamlit/issues/new/choose",children:"here"}),"."]})]})}):(0,S.jsx)(w.A,{width:o,name:"Error fetching Streamlit Mapbox token",message:t.message})};class k extends Error{}class F extends Error{}const A="https://data.streamlit.io/tokens.json",M="mapbox",T=e=>t=>{class o extends i.PureComponent{constructor(o){super(o),this.context=void 0,this.initMapboxToken=async()=>{try{const e=await v.A.get(A),{[M]:t}=e.data;if(!t)throw new Error(`Missing token ${M}`);this.setState({mapboxToken:t,isFetching:!1})}catch(e){const t=(0,x.$)(e);throw this.setState({mapboxTokenError:t,isFetching:!1}),new F(`${t.message} (${A})`)}},this.render=()=>{const{mapboxToken:o,mapboxTokenError:i,isFetching:n}=this.state,{width:r}=this.props;return i?(0,S.jsx)(j,{width:r,error:i,deltaType:e}):n?(0,S.jsx)(y.E,{element:u.EA.create({style:u.EA.SkeletonStyle.ELEMENT})}):(0,S.jsx)(t,{...this.props,mapboxToken:o,width:r})},this.state={isFetching:!0,mapboxToken:void 0,mapboxTokenError:void 0}}componentDidMount(){const e=this.props.element.mapboxToken||this.context.libConfig.mapboxToken;e?this.setState({mapboxToken:e,isFetching:!1}):this.initMapboxToken()}}return o.displayName=`withMapboxToken(${t.displayName||t.name})`,o.contextType=C.n,b()(o,t)};var E=o(89653);const I=(0,E.A)("div",{target:"e1az0zs51"})((e=>{let{width:t,height:o}=e;return{position:"relative",height:o,width:t}}),""),N=(0,E.A)("div",{target:"e1az0zs50"})((e=>{let{theme:t}=e;return{position:"absolute",right:"2.625rem",top:t.spacing.md,zIndex:t.zIndices.priority,".mapboxgl-ctrl.mapboxgl-ctrl-group":{overflow:"hidden",background:t.colors.bgColor},"button:not(:disabled)":{background:t.colors.bgColor,"& + button":{borderTopColor:t.colors.secondaryBg},"&.mapboxgl-ctrl-icon:hover":{backgroundColor:t.colors.darkenedBgMix25},"& span":{filter:(0,h.iq)(t)?"":"invert(100%)"}}}}),"");var O=o(21640),L=o(71034),$=o.n(L),W=o(32735);var z=o(3101),V=o(71279),_=o(95237),D=o(19507),B=o(89428),P=o(28246),U=o(54340),J=o(66643);const X={classes:{...P,...o(43539),...J,...o(41260),...V.bE},functions:{colorBins:_.A,colorCategories:D.A,colorContinuous:B.A}},q=new U.A({configuration:X});var G=o(39017),K=o(86044),R=o(94514),Z=o(10623),H=o(55296),Q=o(97091),Y=o(25479),ee=o(16249),te=o(46909),oe=o(56605),ie=o(48754),ne=o(16389),re=o(57741),le=o(82111),se=o(40973),ae=o(34632),ce=o(34895),de=o(77277),he=o(39481),ue=o(47605);const ge={[ne.A.layerName]:["getFillColor"],[re.A.layerName]:["getFillColor"],[le.A.layerName]:["getFillColor"],[se.A.layerName]:["getFillColor"],[ae.A.layerName]:["getFillColor"],[ce.A.layerName]:["getFillColor"],[de.A.layerName]:["getColor"],[G.A.layerName]:["getTargetColor","getSourceColor"],[K.A.layerName]:["getFillColor"],[R.A.layerName]:["getFillColor"],[Z.A.layerName]:["getColor"],[H.A.layerName]:["getColor"],[Q.A.layerName]:["getColor"],[Y.A.layerName]:["getColor"],[ee.A.layerName]:["getFillColor"],[te.A.layerName]:["getFillColor","getColor","getLineColor"],[oe.A.layerName]:["getFillColor"],[ie.A.layerName]:["getColor"],[he.A.layerName]:["getColor"],[ue.A.layerName]:["getColor"]},me=e=>{let{isSelected:t,object:o,objectInfo:i,opacity:n,originalFillFunction:r}=e;const l=(e=>{let{object:t,objectInfo:o,originalFillFunction:i}=e;const n="function"===typeof i?i(t,o):i;if(Array.isArray(n))return[n[0]||0,n[1]||0,n[2]||0,n[3]||255];if("string"===typeof n&&n.startsWith("@@=")){const e=q.convert({originalColor:n}).originalColor(t);return[e[0]||0,e[1]||0,e[2]||0,e[3]||255]}return null})({object:o,objectInfo:i,originalFillFunction:r});if(!l)return null;let s=0;return s=t?Math.max("number"===typeof l[3]?l[3]:n,n):Math.min("number"===typeof l[3]?l[3]:n,n),[l[0]||0,l[1]||0,l[2]||0,s]},pe={selection:{indices:{},objects:{}}},fe=(e,t)=>{const o=t.match(/{(.*?)}/g);return o&&o.forEach((o=>{const i=o.substring(1,o.length-1);e.object.hasOwnProperty(i)?t=t.replace(o,e.object[i]):e.object.hasOwnProperty("properties")&&e.object.properties.hasOwnProperty(i)&&(t=t.replace(o,e.object.properties[i]))})),t};function be(e,t){if(!t.id)return pe;const o=e.getElementState(t.id,"selection");return null!==o&&void 0!==o?o:pe}function ve(e,t){if(!t.id)return pe;const o=e.getStringValue(t),i=o?O.A.parse(o):null;return null!==i&&void 0!==i?i:pe}function xe(e,t,o,i){e.id&&t.setStringValue(e,JSON.stringify(o.value),{fromUi:o.fromUi},i)}const ye=e=>{var t;const{height:o,width:n,expanded:r}=(0,m.i)(p.T),{element:l,fragmentId:s,isLightTheme:a,theme:c,widgetMgr:d}=e,{selectionMode:h,tooltip:u,useContainerWidth:g}=l,f=null!==r&&void 0!==r&&r,[b,v]=(0,z._)({element:l,getDefaultState:be,getStateFromWidgetMgr:ve,updateWidgetMgrState:xe,widgetMgr:d,fragmentId:s}),[x,y]=(0,i.useState)({bearing:0,pitch:0,zoom:11}),{height:C,width:w}=(e=>{let{container:t,element:o,heightFallback:n="auto",isFullScreen:r,shouldUseContainerWidth:l,widthFallback:s="auto"}=e;return{width:(0,i.useMemo)((()=>l||r?"100%":o.width||t.width||s),[t.width,o.width,r,l,s]),height:(0,i.useMemo)((()=>r&&t.height?t.height:o.height||t.height||n),[r,o.height,t.height,n])}})({element:l,isFullScreen:f,shouldUseContainerWidth:g,container:{height:o,width:n},heightFallback:(null===(t=x.initialViewState)||void 0===t?void 0:t.height)||500}),[S,j]=(0,i.useState)({}),k=h[0],F=void 0!==k,A=F&&Object.keys(b.selection.indices).length>0,M=(0,i.useMemo)((()=>Object.freeze(O.A.parse(l.json))),[f,a,l.json]),T=(0,i.useMemo)((()=>{const e={...M};if(e.mapStyle||(e.mapStyle=`mapbox://styles/mapbox/${a?"light":"dark"}-v9`),e.layers){const t=Object.values(b.selection.indices).some((e=>null===e||void 0===e?void 0:e.length)),o=e.layers.some((e=>Object.hasOwn(e,"pickable")));e.layers=e.layers.map((e=>{var i,n;if(!e||Array.isArray(e)||!F)return e;o||(e.pickable=!0);const r=`${e.id||null}`,l=(null===b||void 0===b||null===(i=b.selection)||void 0===i||null===(n=i.indices)||void 0===n?void 0:n[r])||[],s=ge[e["@@type"]];if(!s)return e;const a={...e};return s.forEach((o=>{var i;a.updateTriggers={[o]:[...(null===(i=a.updateTriggers)||void 0===i?void 0:i[o])||[],l,t]};const n=!t,r=e[o];if(n||!r)return a;const s=Math.floor(102),d=(0,W.Du)(c.colors.primary),h=[d[0],d[1],d[2],255],u=(0,W.Du)(c.colors.gray20),g=[u[0],u[1],u[2],s];a[o]=(e,t)=>(e=>{let{isSelected:t,object:o,objectInfo:i,originalFillFunction:n,selectedColor:r,selectedOpacity:l=255,unselectedColor:s,unselectedOpacity:a=Math.floor(102)}=e;return t?me({opacity:l,isSelected:!0,object:o,objectInfo:i,originalFillFunction:n})||r:me({opacity:a,isSelected:!1,object:o,objectInfo:i,originalFillFunction:n})||s})({isSelected:l.includes(t.index),object:e,objectInfo:t,originalFillFunction:r,selectedColor:h,unselectedColor:g,selectedOpacity:255,unselectedOpacity:s})})),a}))}return null===e||void 0===e||delete e.views,q.convert(e)}),[b.selection.indices,a,F,M,c.colors.gray20,c.colors.primary]);(0,i.useEffect)((()=>{if(!$()(T.initialViewState,S)){const e=Object.keys(T.initialViewState).reduce(((e,t)=>T.initialViewState[t]===S[t]?e:{...e,[t]:T.initialViewState[t]}),{});y({...x,...e}),j(T.initialViewState)}}),[T.initialViewState,S,x]);const E=(0,i.useCallback)((e=>{if(!e||!e.object||!u)return null;const t=O.A.parse(u);return t.html?t.html=fe(e,t.html):t.text=fe(e,t.text),t}),[u]),I=(0,i.useCallback)((e=>{let{viewState:t}=e;y(t)}),[y]);return{createTooltip:E,data:b,deck:T,hasActiveSelection:A,height:C,isSelectionModeActivated:F,onViewStateChange:I,selectionMode:k,setSelection:v,viewState:x,width:w}};o(93298);(0,a.mk)([l.y,s.B]);const Ce=pe.selection,we=[],Se=T("st.pydeck_chart")((e=>{const{disabled:t,disableFullscreenMode:o,element:l,fragmentId:s,mapboxToken:a,widgetMgr:f}=e,{mapboxToken:b}=l,v=(0,c.u)(),{expanded:x,expand:y,collapse:C}=(0,m.i)(p.T),{createTooltip:w,data:j,deck:k,hasActiveSelection:F,height:A,isSelectionModeActivated:M,onViewStateChange:T,selectionMode:E,setSelection:O,viewState:L,width:$}=ye({element:l,fragmentId:s,isLightTheme:(0,h.iq)(v),theme:v,widgetMgr:f}),[W,z]=(0,i.useState)(!1);(0,i.useEffect)((()=>{z(!0)}),[]);const V=(0,i.useCallback)((e=>{var t;if(void 0===E)return;const{index:o,object:i}=e,n=`${(null===(t=e.layer)||void 0===t?void 0:t.id)||null}`,r=j,l=-1===o,s=(()=>{if(l)return Ce;switch(E){case u.Xw.SelectionMode.SINGLE_OBJECT:var e;return(null===(e=r.selection.indices[n])||void 0===e?void 0:e[0])===o?Ce:{indices:{[`${n}`]:[o]},objects:{[`${n}`]:[i]}};case u.Xw.SelectionMode.MULTI_OBJECT:{const e=new Map(((null===r||void 0===r||null===(t=r.selection)||void 0===t||null===(s=t.indices)||void 0===s?void 0:s[n])||[]).map(((e,t)=>{var o,i,l;return[e,null===(o=r.selection)||void 0===o||null===(i=o.objects)||void 0===i||null===(l=i[n])||void 0===l?void 0:l[t]]})));if(e.has(o)?e.delete(o):e.set(o,i),0===e.size){const{[n]:e,...t}=r.selection.indices,{[n]:o,...i}=r.selection.objects;return{indices:t,objects:i}}return{indices:{...r.selection.indices,[`${n}`]:Array.from(e.keys())},objects:{...r.selection.objects,[`${n}`]:Array.from(e.values())}}}default:throw(e=>{throw new Error(`Reached a branch with non-exhaustive item: ${e}`)})(E),new Error("Invalid selection mode")}var t,s})();JSON.stringify(s)!==JSON.stringify(r.selection)&&O({fromUi:!0,value:{selection:s}})}),[E,j,O]),_=(0,i.useCallback)((()=>{O({value:{selection:Ce},fromUi:!0})}),[O]);return(0,S.jsxs)(I,{className:"stDeckGlJsonChart","data-testid":"stDeckGlJsonChart",width:$,height:A,children:[(0,S.jsx)(g.A,{isFullScreen:x,disableFullscreenMode:o,onExpand:y,onCollapse:C,target:I,locked:!(!F||t)||void 0,children:F&&!t&&(0,S.jsx)(g.K,{label:"Clear selection",onClick:_,icon:d.b})}),(0,S.jsxs)(n.A,{viewState:L,onViewStateChange:T,height:A,width:$,layers:W?k.layers:we,getTooltip:w,ContextProvider:r.wZ.Provider,controller:!0,onClick:M&&!t?V:void 0,children:[(0,S.jsx)(r.b,{height:A,width:$,mapStyle:k.mapStyle&&("string"===typeof k.mapStyle?k.mapStyle:k.mapStyle[0]),mapboxApiAccessToken:b||a}),(0,S.jsx)(N,{children:(0,S.jsx)(r.ov,{"data-testid":"stDeckGlJsonChartZoomButton",showCompass:!1})})]})]})}))},85850:(e,t,o)=>{o.d(t,{K:()=>b,A:()=>v});o(58878);var i=o(8151),n=o(12274),r=o(63186),l=o(4629),s=o(997),a=o(36459),c=o(84720),d=o(64611),h=o(89653),u=o(16795);const g="-2.4rem",m=(0,h.A)("div",{target:"e2wxzia1"})((e=>{let{theme:t,locked:o,target:i}=e;return{padding:`${t.spacing.sm} 0 ${t.spacing.sm} ${t.spacing.sm}`,position:"absolute",top:o?g:"-1rem",right:t.spacing.none,transition:"none",...!o&&{opacity:0,"&:active, &:focus-visible, &:hover":{transition:"opacity 150ms 100ms, top 100ms 100ms",opacity:1,top:g},...i&&{[`${i}:hover &, ${i}:active &, ${i}:focus-visible &`]:{transition:"opacity 150ms 100ms, top 100ms 100ms",opacity:1,top:g}}}}}),""),p=(0,h.A)("div",{target:"e2wxzia0"})((e=>{let{theme:t}=e;return{color:(0,u.iq)(t)?t.colors.fadedText60:t.colors.bodyText,display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"flex-end",boxShadow:"1px 2px 8px rgba(0, 0, 0, 0.08)",borderRadius:t.radii.default,backgroundColor:t.colors.lightenedBg05,width:"fit-content",zIndex:t.zIndices.sidebar+1}}),"");var f=o(90782);function b(e){let{label:t,show_label:o,icon:n,onClick:r}=e;const h=(0,i.u)(),u=o?t:"";return(0,f.jsx)("div",{"data-testid":"stElementToolbarButton",children:(0,f.jsx)(s.A,{content:(0,f.jsx)(l.Ay,{source:t,allowHTML:!1,style:{fontSize:h.fontSizes.sm}}),placement:s.W.TOP,onMouseEnterDelay:1e3,inline:!0,children:(0,f.jsxs)(a.Ay,{onClick:e=>{r&&r(),e.stopPropagation()},kind:c.KX.ELEMENT_TOOLBAR,"aria-label":t,children:[n&&(0,f.jsx)(d.A,{content:n,size:"md",testid:"stElementToolbarButtonIcon"}),u&&(0,f.jsx)("span",{children:u})]})})})}const v=e=>{let{onExpand:t,onCollapse:o,isFullScreen:i,locked:l,children:s,target:a,disableFullscreenMode:c}=e;return(0,f.jsx)(m,{className:"stElementToolbar","data-testid":"stElementToolbar",locked:l||i,target:a,children:(0,f.jsxs)(p,{children:[s,t&&!c&&!i&&(0,f.jsx)(b,{label:"Fullscreen",icon:n.g,onClick:()=>t()}),o&&!c&&i&&(0,f.jsx)(b,{label:"Close fullscreen",icon:r.Q,onClick:()=>o()})]})})}},34752:(e,t,o)=>{o.d(t,{X:()=>l,o:()=>r});var i=o(58878),n=o(25571);class r{constructor(){this.formClearListener=void 0,this.lastWidgetMgr=void 0,this.lastFormId=void 0}manageFormClearListener(e,t,o){(0,n.se)(this.formClearListener)&&this.lastWidgetMgr===e&&this.lastFormId===t||(this.disconnect(),(0,n._L)(t)&&(this.formClearListener=e.addFormClearedListener(t,o),this.lastWidgetMgr=e,this.lastFormId=t))}disconnect(){var e;null===(e=this.formClearListener)||void 0===e||e.disconnect(),this.formClearListener=void 0,this.lastWidgetMgr=void 0,this.lastFormId=void 0}}function l(e){let{element:t,widgetMgr:o,onFormCleared:r}=e;(0,i.useEffect)((()=>{if(!(0,n._L)(t.formId))return;const e=o.addFormClearedListener(t.formId,r);return()=>{e.disconnect()}}),[t,o,r])}},3101:(e,t,o)=>{o.d(t,{_:()=>l,t:()=>s});var i=o(58878),n=o(34752),r=o(25571);function l(e){let{getStateFromWidgetMgr:t,getDefaultState:o,updateWidgetMgrState:l,element:s,widgetMgr:a,fragmentId:c,onFormCleared:d}=e;const[h,u]=(0,i.useState)((()=>{var e;return null!==(e=t(a,s))&&void 0!==e?e:o(a,s)})),[g,m]=(0,i.useState)({value:h,fromUi:!1});(0,i.useEffect)((()=>{(0,r.hX)(g)||(m(null),u(g.value),l(s,a,g,c))}),[g,l,s,a,c]);const p=(0,i.useCallback)((()=>{m({value:o(a,s),fromUi:!0}),null===d||void 0===d||d()}),[m,s,o,a,d]);return(0,n.X)({widgetMgr:a,element:s,onFormCleared:p}),[h,m]}function s(e){let{getStateFromWidgetMgr:t,getDefaultStateFromProto:o,getCurrStateFromProto:n,updateWidgetMgrState:r,element:s,widgetMgr:a,fragmentId:c,onFormCleared:d}=e;const h=(0,i.useCallback)(((e,t)=>o(t)),[o]),[u,g]=l({getStateFromWidgetMgr:t,getDefaultState:h,updateWidgetMgrState:r,element:s,widgetMgr:a,fragmentId:c,onFormCleared:d});return(0,i.useEffect)((()=>{s.setValue&&(s.setValue=!1,g({value:n(s),fromUi:!1}))}),[s,n,g]),[u,g]}}}]);
|
@@ -1 +0,0 @@
|
|
1
|
-
"use strict";(self.webpackChunk_streamlit_app=self.webpackChunk_streamlit_app||[]).push([[6073],{95241:(t,e,i)=>{i.d(e,{e:()=>o});var r=i(68102),n=i(58878),s=i(68622),o=n.forwardRef((function(t,e){return n.createElement(s.I,(0,r.A)({iconAttrs:{fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"},iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},t,{ref:e}),n.createElement("path",{fill:"none",d:"M0 0h24v24H0V0z"}),n.createElement("path",{d:"M16 9v10H8V9h8m-1.5-6h-5l-1 1H5v2h14V4h-3.5l-1-1zM18 7H6v12c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7z"}))}));o.displayName="Delete"},50248:(t,e,i)=>{i.d(e,{f:()=>o});var r=i(68102),n=i(58878),s=i(68622),o=n.forwardRef((function(t,e){return n.createElement(s.I,(0,r.A)({iconAttrs:{fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"},iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},t,{ref:e}),n.createElement("path",{fill:"none",d:"M0 0h24v24H0V0z"}),n.createElement("path",{d:"M19 9h-4V3H9v6H5l7 7 7-7zm-8 2V5h2v6h1.17L12 13.17 9.83 11H11zm-6 7h14v2H5z"}))}));o.displayName="Download"},12274:(t,e,i)=>{i.d(e,{g:()=>o});var r=i(68102),n=i(58878),s=i(68622),o=n.forwardRef((function(t,e){return n.createElement(s.I,(0,r.A)({iconAttrs:{fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"},iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},t,{ref:e}),n.createElement("path",{fill:"none",d:"M0 0h24v24H0V0z"}),n.createElement("path",{d:"M7 14H5v5h5v-2H7v-3zm-2-4h2V7h3V5H5v5zm12 7h-3v2h5v-5h-2v3zM14 5v2h3v3h2V5h-5z"}))}));o.displayName="Fullscreen"},63186:(t,e,i)=>{i.d(e,{Q:()=>o});var r=i(68102),n=i(58878),s=i(68622),o=n.forwardRef((function(t,e){return n.createElement(s.I,(0,r.A)({iconAttrs:{fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"},iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},t,{ref:e}),n.createElement("path",{fill:"none",d:"M0 0h24v24H0V0z"}),n.createElement("path",{d:"M5 16h3v3h2v-5H5v2zm3-8H5v2h5V5H8v3zm6 11h2v-3h3v-2h-5v5zm2-11V5h-2v5h5V8h-3z"}))}));o.displayName="FullscreenExit"},96626:(t,e,i)=>{i.d(e,{G:()=>o});var r=i(68102),n=i(58878),s=i(68622),o=n.forwardRef((function(t,e){return n.createElement(s.I,(0,r.A)({iconAttrs:{fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"},iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},t,{ref:e}),n.createElement("g",{fill:"none"},n.createElement("rect",{width:24,height:24}),n.createElement("rect",{width:24,height:24}),n.createElement("rect",{width:24,height:24})),n.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"}),n.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"}))}));o.displayName="Mic"},37789:(t,e,i)=>{i.d(e,{v:()=>o});var r=i(68102),n=i(58878),s=i(68622),o=n.forwardRef((function(t,e){return n.createElement(s.I,(0,r.A)({iconAttrs:{fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"},iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},t,{ref:e}),n.createElement("rect",{width:24,height:24,fill:"none"}),n.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"}))}));o.displayName="Pause"},14757:(t,e,i)=>{i.d(e,{S:()=>o});var r=i(68102),n=i(58878),s=i(68622),o=n.forwardRef((function(t,e){return n.createElement(s.I,(0,r.A)({iconAttrs:{fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"},iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},t,{ref:e}),n.createElement("rect",{width:24,height:24,fill:"none"}),n.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"}))}));o.displayName="PlayArrow"},88685:(t,e,i)=>{i.d(e,{C:()=>o});var r=i(68102),n=i(58878),s=i(68622),o=n.forwardRef((function(t,e){return n.createElement(s.I,(0,r.A)({iconAttrs:{fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"},iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},t,{ref:e}),n.createElement("path",{fill:"none",d:"M0 0h24v24H0V0z"}),n.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"}))}));o.displayName="Refresh"},34783:(t,e,i)=>{i.d(e,{X:()=>o});var r=i(68102),n=i(58878),s=i(68622),o=n.forwardRef((function(t,e){return n.createElement(s.I,(0,r.A)({iconAttrs:{fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"},iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},t,{ref:e}),n.createElement("g",{fill:"none"},n.createElement("rect",{width:24,height:24}),n.createElement("rect",{width:24,height:24})),n.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"}))}));o.displayName="StopCircle"},56146:(t,e,i)=>{function r(t,e,i,r){return new(i||(i=Promise))((function(n,s){function o(t){try{h(r.next(t))}catch(t){s(t)}}function a(t){try{h(r.throw(t))}catch(t){s(t)}}function h(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(o,a)}h((r=r.apply(t,e||[])).next())}))}i.d(e,{A:()=>h}),"function"==typeof SuppressedError&&SuppressedError;class n{constructor(){this.listeners={}}on(t,e,i){if(this.listeners[t]||(this.listeners[t]=new Set),this.listeners[t].add(e),null==i?void 0:i.once){const i=()=>{this.un(t,i),this.un(t,e)};return this.on(t,i),i}return()=>this.un(t,e)}un(t,e){var i;null===(i=this.listeners[t])||void 0===i||i.delete(e)}once(t,e){return this.on(t,e,{once:!0})}unAll(){this.listeners={}}emit(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),r=1;r<e;r++)i[r-1]=arguments[r];this.listeners[t]&&this.listeners[t].forEach((t=>t(...i)))}}class s extends n{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 o extends n{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 a=["audio/webm","audio/wav","audio/mpeg","audio/mp4","audio/mp3"];class h extends s{constructor(t){var e,i,r,n,s;super(Object.assign(Object.assign({},t),{audioBitsPerSecond:null!==(e=t.audioBitsPerSecond)&&void 0!==e?e:128e3,scrollingWaveform:null!==(i=t.scrollingWaveform)&&void 0!==i&&i,scrollingWaveformWindow:null!==(r=t.scrollingWaveformWindow)&&void 0!==r?r:5,renderRecordedAudio:null===(n=t.renderRecordedAudio)||void 0===n||n,mediaRecorderTimeslice:null!==(s=t.mediaRecorderTimeslice)&&void 0!==s?s: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 o,this.subscriptions.push(this.timer.on("tick",(()=>{const t=performance.now()-this.lastStartTime;this.duration=this.isPaused()?this.duration:this.lastDuration+t,this.emit("record-progress",this.duration)})))}static create(t){return new h(t||{})}renderMicStream(t){const e=new AudioContext,i=e.createMediaStreamSource(t),r=e.createAnalyser();i.connect(r);const n=r.frequencyBinCount,s=new Float32Array(n);let o;const a=Math.floor((this.options.scrollingWaveformWindow||0)*e.sampleRate),h=()=>{var t;if(this.isWaveformPaused)return void(o=requestAnimationFrame(h));if(r.getFloatTimeDomainData(s),this.options.scrollingWaveform){const t=Math.min(a,this.dataWindow?this.dataWindow.length+n:n),e=new Float32Array(a);if(this.dataWindow){const i=Math.max(0,a-this.dataWindow.length);e.set(this.dataWindow.slice(-t+n),i)}e.set(s,a-n),this.dataWindow=e}else this.dataWindow=s;const e=this.options.scrollingWaveformWindow;this.wavesurfer&&(null!==(t=this.originalOptions)&&void 0!==t||(this.originalOptions={cursorWidth:this.wavesurfer.options.cursorWidth,interact:this.wavesurfer.options.interact}),this.wavesurfer.options.cursorWidth=0,this.wavesurfer.options.interact=!1,this.wavesurfer.load("",[this.dataWindow],e)),o=requestAnimationFrame(h)};return h(),{onDestroy:()=>{cancelAnimationFrame(o),null==i||i.disconnect(),null==e||e.close()},onEnd:()=>{this.isWaveformPaused=!0,cancelAnimationFrame(o),this.stopMic()}}}startMic(t){return r(this,void 0,void 0,(function*(){let e;try{e=yield navigator.mediaDevices.getUserMedia({audio:!(null==t?void 0:t.deviceId)||{deviceId:t.deviceId}})}catch(e){throw new Error("Error accessing the microphone: "+e.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 r(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||a.find((t=>MediaRecorder.isTypeSupported(t))),audioBitsPerSecond:this.options.audioBitsPerSecond});this.mediaRecorder=i,this.stopRecording();const r=[];i.ondataavailable=t=>{t.data.size>0&&r.push(t.data),this.emit("record-data-available",t.data)};const n=t=>{var e;const n=new Blob(r,{type:i.mimeType});this.emit(t,n),this.options.renderRecordedAudio&&(this.applyOriginalOptionsIfNeeded(),null===(e=this.wavesurfer)||void 0===e||e.load(URL.createObjectURL(n)))};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"recording"===(null===(t=this.mediaRecorder)||void 0===t?void 0:t.state)}isPaused(){var t;return"paused"===(null===(t=this.mediaRecorder)||void 0===t?void 0:t.state)}isActive(){var t;return"inactive"!==(null===(t=this.mediaRecorder)||void 0===t?void 0:t.state)}stopRecording(){var t;this.isActive()&&(null===(t=this.mediaRecorder)||void 0===t||t.stop(),this.timer.stop())}pauseRecording(){var t,e;this.isRecording()&&(this.isWaveformPaused=!0,null===(t=this.mediaRecorder)||void 0===t||t.requestData(),null===(e=this.mediaRecorder)||void 0===e||e.pause(),this.timer.stop(),this.lastDuration=this.duration)}resumeRecording(){var t;this.isPaused()&&(this.isWaveformPaused=!1,null===(t=this.mediaRecorder)||void 0===t||t.resume(),this.timer.start(),this.lastStartTime=performance.now(),this.emit("record-resume"))}static getAvailableAudioDevices(){return r(this,void 0,void 0,(function*(){return navigator.mediaDevices.enumerateDevices().then((t=>t.filter((t=>"audioinput"===t.kind))))}))}destroy(){this.applyOriginalOptionsIfNeeded(),super.destroy(),this.stopRecording(),this.stopMic()}applyOriginalOptionsIfNeeded(){this.wavesurfer&&this.originalOptions&&(this.wavesurfer.options.cursorWidth=this.originalOptions.cursorWidth,this.wavesurfer.options.interact=this.originalOptions.interact,delete this.originalOptions)}}},19613:(t,e,i)=>{function r(t,e,i,r){return new(i||(i=Promise))((function(n,s){function o(t){try{h(r.next(t))}catch(t){s(t)}}function a(t){try{h(r.throw(t))}catch(t){s(t)}}function h(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(o,a)}h((r=r.apply(t,e||[])).next())}))}i.d(e,{A:()=>v}),"function"==typeof SuppressedError&&SuppressedError;class n{constructor(){this.listeners={}}on(t,e,i){if(this.listeners[t]||(this.listeners[t]=new Set),this.listeners[t].add(e),null==i?void 0:i.once){const i=()=>{this.un(t,i),this.un(t,e)};return this.on(t,i),i}return()=>this.un(t,e)}un(t,e){var i;null===(i=this.listeners[t])||void 0===i||i.delete(e)}once(t,e){return this.on(t,e,{once:!0})}unAll(){this.listeners={}}emit(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),r=1;r<e;r++)i[r-1]=arguments[r];this.listeners[t]&&this.listeners[t].forEach((t=>t(...i)))}}const s={decode:function(t,e){return r(this,void 0,void 0,(function*(){const i=new AudioContext({sampleRate:e});return i.decodeAudioData(t).finally((()=>i.close()))}))},createBuffer:function(t,e){return"number"==typeof t[0]&&(t=[t]),function(t){const e=t[0];if(e.some((t=>t>1||t<-1))){const i=e.length;let r=0;for(let t=0;t<i;t++){const i=Math.abs(e[t]);i>r&&(r=i)}for(const e of t)for(let t=0;t<i;t++)e[t]/=r}}(t),{duration:e,length:t[0].length,sampleRate:t[0].length/e,numberOfChannels:t.length,getChannelData:e=>null==t?void 0:t[e],copyFromChannel:AudioBuffer.prototype.copyFromChannel,copyToChannel:AudioBuffer.prototype.copyToChannel}}};function o(t,e){const i=e.xmlns?document.createElementNS(e.xmlns,t):document.createElement(t);for(const[r,n]of Object.entries(e))if("children"===r)for(const[t,s]of Object.entries(e))"string"==typeof s?i.appendChild(document.createTextNode(s)):i.appendChild(o(t,s));else"style"===r?Object.assign(i.style,n):"textContent"===r?i.textContent=n:i.setAttribute(r,n.toString());return i}function a(t,e,i){const r=o(t,e||{});return null==i||i.appendChild(r),r}var h=Object.freeze({__proto__:null,createElement:a,default:a});const l={fetchBlob:function(t,e,i){return r(this,void 0,void 0,(function*(){const n=yield fetch(t,i);if(n.status>=400)throw new Error(`Failed to fetch ${t}: ${n.status} (${n.statusText})`);return function(t,e){r(this,void 0,void 0,(function*(){if(!t.body||!t.headers)return;const i=t.body.getReader(),n=Number(t.headers.get("Content-Length"))||0;let s=0;const o=t=>r(this,void 0,void 0,(function*(){s+=(null==t?void 0:t.length)||0;const i=Math.round(s/n*100);e(i)})),a=()=>r(this,void 0,void 0,(function*(){let t;try{t=yield i.read()}catch(t){return}t.done||(o(t.value),yield a())}));a()}))}(n.clone(),e),n.blob()}))}};class d extends n{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),null!=t.playbackRate&&this.onMediaEvent("canplay",(()=>{null!=t.playbackRate&&(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(e){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 r(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){null!=e&&(this.media.preservesPitch=e),this.media.playbackRate=t}getMediaElement(){return this.media}setSinkId(t){return this.media.setSinkId(t)}}class c extends n{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("string"==typeof t?e=document.querySelector(t):t instanceof HTMLElement&&(e=t),!e)throw new Error("Container not found");return e}initEvents(){const t=t=>{const e=this.wrapper.getBoundingClientRect(),i=t.clientX-e.left,r=t.clientY-e.top;return[i/e.width,r/e.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)})),!0!==this.options.dragToSeek&&"object"!=typeof this.options.dragToSeek||this.initDrag(),this.scrollContainer.addEventListener("scroll",(()=>{const{scrollLeft:t,scrollWidth:e,clientWidth:i}=this.scrollContainer,r=t/e,n=(t+i)/e;this.emit("scroll",r,n,t,t+i)})),"function"==typeof ResizeObserver){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&&"auto"!==this.options.height||(this.lastContainerWidth=t,this.reRender())}initDrag(){this.subscriptions.push(function(t,e,i,r){let n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:3,s=arguments.length>5&&void 0!==arguments[5]?arguments[5]:0,o=arguments.length>6&&void 0!==arguments[6]?arguments[6]:100;if(!t)return()=>{};const a=matchMedia("(pointer: coarse)").matches;let h=()=>{};const l=l=>{if(l.button!==s)return;l.preventDefault(),l.stopPropagation();let d=l.clientX,c=l.clientY,u=!1;const p=Date.now(),m=r=>{if(r.preventDefault(),r.stopPropagation(),a&&Date.now()-p<o)return;const s=r.clientX,h=r.clientY,l=s-d,m=h-c;if(u||Math.abs(l)>n||Math.abs(m)>n){const r=t.getBoundingClientRect(),{left:n,top:o}=r;u||(null==i||i(d-n,c-o),u=!0),e(l,m,s-n,h-o),d=s,c=h}},v=e=>{if(u){const i=e.clientX,n=e.clientY,s=t.getBoundingClientRect(),{left:o,top:a}=s;null==r||r(i-o,n-a)}h()},f=t=>{t.relatedTarget&&t.relatedTarget!==document.documentElement||v(t)},g=t=>{u&&(t.stopPropagation(),t.preventDefault())},b=t=>{u&&t.preventDefault()};document.addEventListener("pointermove",m),document.addEventListener("pointerup",v),document.addEventListener("pointerout",f),document.addEventListener("pointercancel",f),document.addEventListener("touchmove",b,{passive:!1}),document.addEventListener("click",g,{capture:!0}),h=()=>{document.removeEventListener("pointermove",m),document.removeEventListener("pointerup",v),document.removeEventListener("pointerout",f),document.removeEventListener("pointercancel",f),document.removeEventListener("touchmove",b),setTimeout((()=>{document.removeEventListener("click",g,{capture:!0})}),10)}};return t.addEventListener("pointerdown",l),()=>{h(),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=(null===(i=this.audioData)||void 0===i?void 0:i.numberOfChannels)||1;if(null==t)return 128;if(!isNaN(Number(t)))return Number(t);if("auto"===t){const t=this.parent.clientHeight||128;return(null==e?void 0:e.every((t=>!t.overlay)))?t/r:t}return 128}initHtml(){const t=document.createElement("div"),e=t.attachShadow({mode:"open"});return e.innerHTML=`\n <style>\n :host {\n user-select: none;\n min-width: 1px;\n }\n :host audio {\n display: block;\n width: 100%;\n }\n :host .scroll {\n overflow-x: auto;\n overflow-y: hidden;\n width: 100%;\n position: relative;\n }\n :host .noScrollbar {\n scrollbar-color: transparent;\n scrollbar-width: none;\n }\n :host .noScrollbar::-webkit-scrollbar {\n display: none;\n -webkit-appearance: none;\n }\n :host .wrapper {\n position: relative;\n overflow: visible;\n z-index: 2;\n }\n :host .canvases {\n min-height: ${this.getHeight(this.options.height,this.options.splitChannels)}px;\n }\n :host .canvases > div {\n position: relative;\n }\n :host canvas {\n display: block;\n position: absolute;\n top: 0;\n image-rendering: pixelated;\n }\n :host .progress {\n pointer-events: none;\n position: absolute;\n z-index: 2;\n top: 0;\n left: 0;\n width: 0;\n height: 100%;\n overflow: hidden;\n }\n :host .progress > div {\n position: relative;\n }\n :host .cursor {\n pointer-events: none;\n position: absolute;\n z-index: 5;\n top: 0;\n left: 0;\n height: 100%;\n border-radius: 2px;\n }\n </style>\n\n <div class="scroll" part="scroll">\n <div class="wrapper" part="wrapper">\n <div class="canvases" part="canvases"></div>\n <div class="progress" part="progress"></div>\n <div class="cursor" part="cursor"></div>\n </div>\n </div>\n `,[t,e]}setOptions(t){if(this.options.container!==t.container){const e=this.parentFromOptionsContainer(t.container);e.appendChild(this.container),this.parent=e}!0!==t.dragToSeek&&"object"!=typeof this.options.dragToSeek||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((t=>t())),this.container.remove(),null===(t=this.resizeObserver)||void 0===t||t.disconnect(),null===(e=this.unsubscribeOnScroll)||void 0===e||e.call(this)}createDelay(){let t,e,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:10;const r=()=>{t&&clearTimeout(t),e&&e()};return this.timeouts.push(r),()=>new Promise(((n,s)=>{r(),e=s,t=setTimeout((()=>{t=void 0,e=void 0,n()}),i)}))}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),s=1/(t.length-1);return t.forEach(((t,e)=>{const i=e*s;n.addColorStop(i,t)})),n}getPixelRatio(){return Math.max(1,window.devicePixelRatio||1)}renderBarWaveform(t,e,i,r){const n=t[0],s=t[1]||t[0],o=n.length,{width:a,height:h}=i.canvas,l=h/2,d=this.getPixelRatio(),c=e.barWidth?e.barWidth*d:1,u=e.barGap?e.barGap*d:e.barWidth?c/2:0,p=e.barRadius||0,m=a/(c+u)/o,v=p&&"roundRect"in i?"roundRect":"rect";i.beginPath();let f=0,g=0,b=0;for(let y=0;y<=o;y++){const t=Math.round(y*m);if(t>f){const n=Math.round(g*l*r),s=n+Math.round(b*l*r)||1;let o=l-n;"top"===e.barAlign?o=0:"bottom"===e.barAlign&&(o=h-s),i[v](f*(c+u),o,c,s,p),f=t,g=0,b=0}const o=Math.abs(n[y]||0),a=Math.abs(s[y]||0);o>g&&(g=o),a>b&&(b=a)}i.fill(),i.closePath()}renderLineWaveform(t,e,i,r){const n=e=>{const n=t[e]||t[0],s=n.length,{height:o}=i.canvas,a=o/2,h=i.canvas.width/s;i.moveTo(0,a);let l=0,d=0;for(let t=0;t<=s;t++){const s=Math.round(t*h);if(s>l){const t=a+(Math.round(d*a*r)||1)*(0===e?-1:1);i.lineTo(l,t),l=s,d=0}const o=Math.abs(n[t]||0);o>d&&(d=o)}i.lineTo(l,a)};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 e=Array.from(t[0]).reduce(((t,e)=>Math.max(t,Math.abs(e))),0);r=e?1/e: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,s,o){const a=this.getPixelRatio(),h=document.createElement("canvas");h.width=Math.round(i*a),h.height=Math.round(r*a),h.style.width=`${i}px`,h.style.height=`${r}px`,h.style.left=`${Math.round(n)}px`,s.appendChild(h);const l=h.getContext("2d");if(this.renderWaveform(t,e,l),h.width>0&&h.height>0){const t=h.cloneNode(),i=t.getContext("2d");i.drawImage(h,0,0),i.globalCompositeOperation="source-in",i.fillStyle=this.convertColorValues(e.progressColor),i.fillRect(0,0,h.width,h.height),o.appendChild(t)}}renderMultiCanvas(t,e,i,r,n,s){const o=this.getPixelRatio(),{clientWidth:a}=this.scrollContainer;if(a*o>=i)return void this.renderSingleCanvas(t,e,a,r,0,n,s);const h=i/o;let l=Math.min(c.MAX_CANVAS_WIDTH,a,h),d={};if(e.barWidth||e.barGap){const t=e.barWidth||.5,i=t+(e.barGap||t/2);l%i!=0&&(l=Math.floor(l/i)*i)}const u=i=>{if(i<0||i>=p)return;if(d[i])return;d[i]=!0;const o=i*l,a=Math.min(h-o,l);if(a<=0)return;const c=t.map((t=>{const e=Math.floor(o/h*t.length),i=Math.floor((o+a)/h*t.length);return t.slice(e,i)}));this.renderSingleCanvas(c,e,a,r,o,n,s)},p=Math.ceil(h/l),m=this.scrollContainer.scrollLeft/h,v=Math.floor(m*p);u(v-1),u(v),u(v+1),p>1&&(this.unsubscribeOnScroll=this.on("scroll",(()=>{const{scrollLeft:t}=this.scrollContainer,e=Math.floor(t/h*p);Object.keys(d).length>c.MAX_NODES&&(n.innerHTML="",s.innerHTML="",d={}),u(e-1),u(e),u(e+1)})))}renderChannel(t,e,i,r){var{overlay:n}=e,s=function(t,e){var i={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(i[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(r=Object.getOwnPropertySymbols(t);n<r.length;n++)e.indexOf(r[n])<0&&Object.prototype.propertyIsEnumerable.call(t,r[n])&&(i[r[n]]=t[r[n]])}return i}(e,["overlay"]);const o=document.createElement("div"),a=this.getHeight(s.height,s.splitChannels);o.style.height=`${a}px`,n&&r>0&&(o.style.marginTop=`-${a}px`),this.canvasWrapper.style.minHeight=`${a}px`,this.canvasWrapper.appendChild(o);const h=o.cloneNode();this.progressWrapper.appendChild(h),this.renderMultiCanvas(t,s,i,a,o,h)}render(t){return r(this,void 0,void 0,(function*(){var e;this.timeouts.forEach((t=>t())),this.timeouts=[],this.canvasWrapper.innerHTML="",this.progressWrapper.innerHTML="",null!=this.options.width&&(this.scrollContainer.style.width="number"==typeof this.options.width?`${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 s=this.options.fillParent&&!this.isScrollable,o=(s?r:n)*i;if(this.wrapper.style.width=s?"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 a=0;a<t.numberOfChannels;a++){const i=Object.assign(Object.assign({},this.options),null===(e=this.options.splitChannels)||void 0===e?void 0:e[a]);this.renderChannel([t.getChannelData(a)],i,o,a)}else{const e=[t.getChannelData(0)];t.numberOfChannels>1&&e.push(t.getChannelData(1)),this.renderChannel(e,this.options,o,0)}Promise.resolve().then((()=>this.emit("rendered")))}))}reRender(){var t;if(null===(t=this.unsubscribeOnScroll)||void 0===t||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:t}=this.progressWrapper.getBoundingClientRect();let e=t-i;e*=2,e=e<0?Math.floor(e):Math.ceil(e),e/=2,this.scrollContainer.scrollLeft+=e}}zoom(t){this.options.minPxPerSec=t,this.reRender()}scrollIntoView(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const{scrollLeft:i,scrollWidth:r,clientWidth:n}=this.scrollContainer,s=t*r,o=i,a=i+n,h=n/2;if(this.isDragging){const t=30;s+t>a?this.scrollContainer.scrollLeft+=t:s-t<o&&(this.scrollContainer.scrollLeft-=t)}else{(s<o||s>a)&&(this.scrollContainer.scrollLeft=s-(this.options.autoCenter?h:0));const t=s-i-h;e&&this.options.autoCenter&&t>0&&(this.scrollContainer.scrollLeft+=Math.min(t,10))}{const t=this.scrollContainer.scrollLeft,e=t/r,i=(t+n)/r;this.emit("scroll",e,i,t,t+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(-${100===Math.round(i)?this.options.cursorWidth:0}px)`,this.isScrollable&&this.options.autoScroll&&this.scrollIntoView(t,e)}exportImage(t,e,i){return r(this,void 0,void 0,(function*(){const r=this.canvasWrapper.querySelectorAll("canvas");if(!r.length)throw new Error("No waveform data");if("dataURL"===i){const i=Array.from(r).map((i=>i.toDataURL(t,e)));return Promise.resolve(i)}return Promise.all(Array.from(r).map((i=>new Promise(((r,n)=>{i.toBlob((t=>{t?r(t):n(new Error("Could not export image"))}),t,e)})))))}))}}c.MAX_CANVAS_WIDTH=8e3,c.MAX_NODES=10;class u extends n{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 p extends n{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]: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 r(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,null===(t=this.bufferNode)||void 0===t||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,null===(t=this.bufferNode)||void 0===t||t.stop(),this.playedDuration+=this.audioContext.currentTime-this.playStartTime}play(){return r(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;null===(e=this.bufferNode)||void 0===e||e.stop(this.audioContext.currentTime+r),null===(i=this.bufferNode)||void 0===i||i.addEventListener("ended",(()=>{this.bufferNode=null,this.pause()}),{once:!0})}setSinkId(t){return r(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 null!==(t=this._duration)&&void 0!==t?t:(null===(e=this.buffer)||void 0===e?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 m={waveColor:"#999",progressColor:"#555",cursorWidth:1,minPxPerSec:0,fillParent:!0,interact:!0,dragToSeek:!1,autoScroll:!0,autoCenter:!0,sampleRate:8e3};class v extends d{static create(t){return new v(t)}constructor(t){const e=t.media||("WebAudio"===t.backend?new p: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({},m,t),this.timer=new u;const i=e?void 0:this.getMediaElement();this.renderer=new c(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:t,duration:e}=this.options;(r||t&&e)&&this.load(r,t,e).catch((()=>null))}))}updateProgress(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]: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:!0===this.options.dragToSeek?i=200:"object"==typeof this.options.dragToSeek&&void 0!==this.options.dragToSeek&&(i=this.options.dragToSeek.debounceTime),t=setTimeout((()=>{this.seekTo(e)}),i),this.emit("interaction",e*this.getDuration()),this.emit("drag",e)})))}}initPlugins(){var t;(null===(t=this.options.plugins)||void 0===t?void 0:t.length)&&this.options.plugins.forEach((t=>{this.registerPlugin(t)}))}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),null!=t.mediaControls&&(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,n){return r(this,void 0,void 0,(function*(){var r;if(this.emit("load",t),!this.options.media&&this.isPlaying()&&this.pause(),this.decodedData=null,!e&&!i){const i=this.options.fetchParams||{};window.AbortController&&!i.signal&&(this.abortController=new AbortController,i.signal=null===(r=this.abortController)||void 0===r?void 0:r.signal);const n=t=>this.emit("loading",t);e=yield l.fetchBlob(t,n,i)}this.setSrc(t,e);const o=yield new Promise((t=>{const e=n||this.getDuration();e?t(e):this.mediaSubscriptions.push(this.onMediaEvent("loadedmetadata",(()=>t(this.getDuration())),{once:!0}))}));if(!t&&!e){const t=this.getMediaElement();t instanceof p&&(t.duration=o)}if(i)this.decodedData=s.createBuffer(i,o||0);else if(e){const t=yield e.arrayBuffer();this.decodedData=yield s.decode(t,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 r(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 r(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(){let{channels:t=2,maxLength:e=8e3,precision:i=1e4}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!this.decodedData)throw new Error("The audio has not been decoded yet");const r=Math.min(t,this.decodedData.numberOfChannels),n=[];for(let s=0;s<r;s++){const t=this.decodedData.getChannelData(s),r=[],o=t.length/e;for(let n=0;n<e;n++){const e=t.slice(Math.floor(n*o),Math.ceil((n+1)*o));let s=0;for(let t=0;t<e.length;t++){const i=e[t];Math.abs(i)>Math.abs(s)&&(s=i)}r.push(Math.round(s*i)/i)}n.push(r)}return n}getDuration(){let t=super.getDuration()||0;return 0!==t&&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 r(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 r(this,arguments,void 0,(function(){var t=this;let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"image/png",i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"dataURL";return function*(){return t.renderer.exportImage(e,i,r)}()}))}destroy(){var t;this.emit("destroy"),null===(t=this.abortController)||void 0===t||t.abort(),this.plugins.forEach((t=>t.destroy())),this.subscriptions.forEach((t=>t())),this.unsubscribePlayerEvents(),this.timer.destroy(),this.renderer.destroy(),super.destroy()}}v.BasePlugin=class extends n{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()))}},v.dom=h}}]);
|