streamlit 1.47.1__py3-none-any.whl → 1.48.1__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/cli_util.py +1 -1
- streamlit/commands/echo.py +2 -2
- streamlit/commands/execution_control.py +1 -1
- streamlit/commands/page_config.py +16 -16
- streamlit/components/v1/component_arrow.py +4 -4
- streamlit/config.py +23 -5
- streamlit/connections/base_connection.py +2 -2
- streamlit/connections/snowflake_connection.py +2 -2
- streamlit/connections/sql_connection.py +4 -3
- streamlit/dataframe_util.py +1 -1
- streamlit/deprecation_util.py +20 -5
- streamlit/elements/arrow.py +105 -79
- streamlit/elements/deck_gl_json_chart.py +6 -6
- streamlit/elements/dialog_decorator.py +72 -17
- streamlit/elements/form.py +36 -7
- streamlit/elements/graphviz_chart.py +7 -0
- streamlit/elements/iframe.py +13 -22
- streamlit/elements/json.py +3 -3
- streamlit/elements/layouts.py +241 -75
- streamlit/elements/lib/built_in_chart_utils.py +11 -3
- streamlit/elements/lib/dialog.py +43 -0
- streamlit/elements/lib/file_uploader_utils.py +21 -2
- streamlit/elements/lib/layout_utils.py +88 -2
- streamlit/elements/lib/options_selector_utils.py +1 -1
- streamlit/elements/lib/utils.py +23 -3
- streamlit/elements/map.py +12 -11
- streamlit/elements/plotly_chart.py +21 -21
- streamlit/elements/pyplot.py +8 -4
- streamlit/elements/vega_charts.py +237 -143
- streamlit/elements/widgets/audio_input.py +2 -2
- streamlit/elements/widgets/button.py +147 -35
- streamlit/elements/widgets/button_group.py +9 -8
- streamlit/elements/widgets/camera_input.py +2 -2
- streamlit/elements/widgets/chat.py +8 -2
- streamlit/elements/widgets/checkbox.py +4 -4
- streamlit/elements/widgets/color_picker.py +2 -2
- streamlit/elements/widgets/data_editor.py +22 -15
- streamlit/elements/widgets/file_uploader.py +8 -2
- streamlit/elements/widgets/multiselect.py +27 -17
- streamlit/elements/widgets/number_input.py +2 -2
- streamlit/elements/widgets/radio.py +5 -4
- streamlit/elements/widgets/select_slider.py +8 -5
- streamlit/elements/widgets/selectbox.py +14 -4
- streamlit/elements/widgets/slider.py +59 -33
- streamlit/elements/widgets/text_widgets.py +4 -4
- streamlit/elements/widgets/time_widgets.py +4 -4
- streamlit/elements/write.py +9 -8
- streamlit/env_util.py +1 -1
- streamlit/errors.py +20 -4
- streamlit/file_util.py +1 -1
- streamlit/git_util.py +1 -1
- streamlit/logger.py +2 -2
- streamlit/proto/Block_pb2.py +39 -31
- streamlit/proto/Block_pb2.pyi +54 -3
- streamlit/proto/Button_pb2.py +4 -2
- streamlit/proto/Button_pb2.pyi +1 -0
- streamlit/proto/IFrame_pb2.py +8 -2
- streamlit/proto/IFrame_pb2.pyi +3 -0
- streamlit/runtime/caching/cache_data_api.py +15 -2
- streamlit/runtime/caching/cache_errors.py +1 -1
- streamlit/runtime/caching/cache_resource_api.py +24 -2
- streamlit/runtime/caching/cache_utils.py +6 -3
- streamlit/runtime/caching/hashing.py +6 -9
- streamlit/runtime/fragment.py +3 -2
- streamlit/runtime/runtime.py +19 -2
- streamlit/runtime/scriptrunner/script_runner.py +3 -3
- streamlit/runtime/state/common.py +2 -1
- streamlit/runtime/state/query_params.py +2 -1
- streamlit/runtime/state/session_state.py +1 -1
- streamlit/static/index.html +1 -1
- streamlit/static/manifest.json +231 -231
- streamlit/static/static/css/index.CQt5TjGB.css +1 -0
- streamlit/static/static/js/{ErrorOutline.esm.BEZPMjuG.js → ErrorOutline.esm.DjObtx4K.js} +1 -1
- streamlit/static/static/js/{FileDownload.esm.Dy1V9a2E.js → FileDownload.esm.Bz9nxNC5.js} +1 -1
- streamlit/static/static/js/{FileHelper.D0K06YBq.js → FileHelper.BrQvUXVD.js} +1 -1
- streamlit/static/static/js/{FormClearHelper.Cdw5Y7_m.js → FormClearHelper.DF4gFAOO.js} +1 -1
- streamlit/static/static/js/{Hooks.C_qx1sSw.js → Hooks.DEoLCfOE.js} +1 -1
- streamlit/static/static/js/{InputInstructions.D3IDU-eY.js → InputInstructions.D8zoMog9.js} +1 -1
- streamlit/static/static/js/Particles.CCFySwdL.js +1 -0
- streamlit/static/static/js/ProgressBar.COK9j1l0.js +2 -0
- streamlit/static/static/js/Toolbar.Dt4jIKlY.js +1 -0
- streamlit/static/static/js/{base-input.DMlw5p7n.js → base-input.BmvSaPd2.js} +4 -4
- streamlit/static/static/js/{checkbox.C7QR6llE.js → checkbox.Cgxgc0et.js} +2 -2
- streamlit/static/static/js/createDownloadLinkElement.ZaXNnPK4.js +1 -0
- streamlit/static/static/js/{createSuper.C5k_2vfB.js → createSuper.siQeagI2.js} +1 -1
- streamlit/static/static/js/data-grid-overlay-editor.Ct51iCb_.js +1 -0
- streamlit/static/static/js/{downloader.Nj6v3ioB.js → downloader.M6jQeNDf.js} +1 -1
- streamlit/static/static/js/{es6.CVz13CSz.js → es6.CMaUdEZ5.js} +2 -2
- streamlit/static/static/js/{iframeResizer.contentWindow.gZ8zjT0K.js → iframeResizer.contentWindow.C33BryyP.js} +1 -1
- streamlit/static/static/js/index.8GJD0eeD.js +1 -0
- streamlit/static/static/js/index.8QEYHMQD.js +1 -0
- streamlit/static/static/js/index.Ay41Wnu9.js +1 -0
- streamlit/static/static/js/index.BLiKiJ7_.js +1 -0
- streamlit/static/static/js/index.BT78cJmU.js +1 -0
- streamlit/static/static/js/index.BXDq9dj4.js +1 -0
- streamlit/static/static/js/index.BdGvnhlM.js +1 -0
- streamlit/static/static/js/index.BfasrT0d.js +1 -0
- streamlit/static/static/js/index.CCdtFMFG.js +1 -0
- streamlit/static/static/js/index.CFRGZDz1.js +1 -0
- streamlit/static/static/js/{index.MbqsiUV4.js → index.CFSFYiPA.js} +289 -289
- streamlit/static/static/js/{index.B2L574n6.js → index.CbdWnLqS.js} +3 -3
- streamlit/static/static/js/index.CeiIiXap.js +1 -0
- streamlit/static/static/js/index.CgZDfhN4.js +2 -0
- streamlit/static/static/js/{index.xfcNJBLM.js → index.Cqa4gqqN.js} +1 -1
- streamlit/static/static/js/index.CzX2xpyc.js +1 -0
- streamlit/static/static/js/index.D1EayrNh.js +73 -0
- streamlit/static/static/js/index.D1ErX5go.js +2 -0
- streamlit/static/static/js/{index.CTT2YqEU.js → index.D1jHqUJq.js} +1 -1
- streamlit/static/static/js/index.D5gweoL5.js +7 -0
- streamlit/static/static/js/index.DByVKZgq.js +1 -0
- streamlit/static/static/js/index.DEND45D1.js +3 -0
- streamlit/static/static/js/{index.CbQtRkVt.js → index.DKN5MVff.js} +162 -188
- streamlit/static/static/js/index.DfoxW1gP.js +3855 -0
- streamlit/static/static/js/index.Dtf1Ac0x.js +1 -0
- streamlit/static/static/js/index.DxrLhpeO.js +1 -0
- streamlit/static/static/js/{index.BSFzxMXi.js → index.J7o-_HIh.js} +1 -1
- streamlit/static/static/js/index.LU8juINp.js +197 -0
- streamlit/static/static/js/index.L_N2iylt.js +1 -0
- streamlit/static/static/js/{index.BscWuWHL.js → index.PZUX2kRz.js} +3 -3
- streamlit/static/static/js/index.ROjU6K0k.js +1 -0
- streamlit/static/static/js/index.WSNLkF94.js +1 -0
- streamlit/static/static/js/index.X5W3gJLn.js +1 -0
- streamlit/static/static/js/index.k9LYqfSL.js +1 -0
- streamlit/static/static/js/{index.D3wOJJsg.js → index.pnHtHv_c.js} +12 -12
- streamlit/static/static/js/index.tPUXqsfW.js +1 -0
- streamlit/static/static/js/index.tsvTLdio.js +12 -0
- streamlit/static/static/js/{input.D_45B0P-.js → input.DZd6EQlV.js} +2 -2
- streamlit/static/static/js/{memory.BmhrRyO2.js → memory.ptkfuI71.js} +1 -1
- streamlit/static/static/js/{mergeWith.DvOME7eH.js → mergeWith.GRNk8iwv.js} +1 -1
- streamlit/static/static/js/{number-overlay-editor.BRNxOzEZ.js → number-overlay-editor.DXS2qb1U.js} +1 -1
- streamlit/static/static/js/{possibleConstructorReturn.C5GiK_Ob.js → possibleConstructorReturn.Bd4ImlQ9.js} +1 -1
- streamlit/static/static/js/{sandbox.B-Q9S7vW.js → sandbox.DsH8LuID.js} +1 -1
- streamlit/static/static/js/{timepicker.DOMbfm_a.js → timepicker.QVekV78C.js} +1 -1
- streamlit/static/static/js/{toConsumableArray.CbNz0Ciu.js → toConsumableArray.BJvaP8gb.js} +1 -1
- streamlit/static/static/js/{uniqueId.-ygIU7IL.js → uniqueId.D_5M8Dgf.js} +1 -1
- streamlit/static/static/js/{useBasicWidgetState.Bx3VaRHk.js → useBasicWidgetState.DB3vMS9V.js} +1 -1
- streamlit/static/static/js/useTextInputAutoExpand.CBkGkaRt.js +2 -0
- streamlit/static/static/js/useUpdateUiValue.C7ZKpLQK.js +1 -0
- streamlit/static/static/js/withFullScreenWrapper.C-gXt0Rl.js +1 -0
- streamlit/temporary_directory.py +5 -3
- streamlit/testing/v1/app_test.py +4 -1
- streamlit/testing/v1/element_tree.py +4 -5
- streamlit/type_util.py +10 -3
- streamlit/user_info.py +6 -1
- streamlit/util.py +11 -1
- streamlit/watcher/local_sources_watcher.py +4 -3
- streamlit/web/bootstrap.py +18 -12
- streamlit/web/cli.py +2 -1
- streamlit/web/server/server.py +72 -21
- {streamlit-1.47.1.dist-info → streamlit-1.48.1.dist-info}/METADATA +14 -2
- {streamlit-1.47.1.dist-info → streamlit-1.48.1.dist-info}/RECORD +155 -155
- streamlit/static/static/css/index.CsLB_Bnz.css +0 -1
- streamlit/static/static/js/ProgressBar.EhJ_lCOf.js +0 -2
- streamlit/static/static/js/RenderInPortalIfExists.D6a0mMll.js +0 -1
- streamlit/static/static/js/Toolbar.D6yqQ65-.js +0 -1
- streamlit/static/static/js/createDownloadLinkElement.DZMwyjvU.js +0 -1
- streamlit/static/static/js/data-grid-overlay-editor.CoquyZNK.js +0 -1
- streamlit/static/static/js/index.B3n-pURl.js +0 -2
- streamlit/static/static/js/index.B9jJp9aE.js +0 -1
- streamlit/static/static/js/index.BBVtld-D.js +0 -1
- streamlit/static/static/js/index.BKHPnvYd.js +0 -1
- streamlit/static/static/js/index.B_1CXynz.js +0 -1
- streamlit/static/static/js/index.Bm1LklYO.js +0 -1
- streamlit/static/static/js/index.Byi6__iF.js +0 -1
- streamlit/static/static/js/index.BzJeMpQ-.js +0 -197
- streamlit/static/static/js/index.C4tw7-Cl.js +0 -2
- streamlit/static/static/js/index.CG0C49ex.js +0 -1
- streamlit/static/static/js/index.CMuSJPv-.js +0 -1
- streamlit/static/static/js/index.COPFcr_K.js +0 -3855
- streamlit/static/static/js/index.CU3TLDlu.js +0 -1
- streamlit/static/static/js/index.CVKKDwaf.js +0 -1
- streamlit/static/static/js/index.CWZeK3mV.js +0 -12
- streamlit/static/static/js/index.CWbiNJQl.js +0 -1
- streamlit/static/static/js/index.CWxefYP6.js +0 -73
- streamlit/static/static/js/index.DOdWa88b.js +0 -1
- streamlit/static/static/js/index.DXtnaPua.js +0 -1
- streamlit/static/static/js/index.DatDwFl3.js +0 -3
- streamlit/static/static/js/index.DeWYPvQR.js +0 -1
- streamlit/static/static/js/index.Do4vzIvK.js +0 -1
- streamlit/static/static/js/index.Dvrstlh8.js +0 -1
- streamlit/static/static/js/index.DvznfdF_.js +0 -1
- streamlit/static/static/js/index.U1vvXeGn.js +0 -1
- streamlit/static/static/js/index._WAuWRkp.js +0 -7
- streamlit/static/static/js/index.bwA9_eWC.js +0 -1
- streamlit/static/static/js/index.m1njXuKl.js +0 -1
- streamlit/static/static/js/index.mihWZKb1.js +0 -1
- streamlit/static/static/js/useOnInputChange.CDZx-L6q.js +0 -1
- streamlit/static/static/js/useTextInputAutoExpand.BuE9l5TG.js +0 -2
- streamlit/static/static/js/withFullScreenWrapper.DWXejOhQ.js +0 -1
- {streamlit-1.47.1.data → streamlit-1.48.1.data}/scripts/streamlit.cmd +0 -0
- {streamlit-1.47.1.dist-info → streamlit-1.48.1.dist-info}/WHEEL +0 -0
- {streamlit-1.47.1.dist-info → streamlit-1.48.1.dist-info}/entry_points.txt +0 -0
- {streamlit-1.47.1.dist-info → streamlit-1.48.1.dist-info}/top_level.txt +0 -0
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{
|
|
2
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Te(e,t){if(e){if(typeof e=="string")return ue(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return ue(e,t)}}function ue(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function xe(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var r=[],o=!0,i=!1,s,a;try{for(n=n.call(e);!(o=(s=n.next()).done)&&(r.push(s.value),!(t&&r.length===t));o=!0);}catch(c){i=!0,a=c}finally{try{!o&&n.return!=null&&n.return()}finally{if(i)throw a}}return r}}function Ae(e){if(Array.isArray(e))return e}function je(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function
|
|
3
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Ue(e,t){if(e){if(typeof e=="string")return ce(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return ce(e,t)}}function ce(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function Ge(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var r=[],o=!0,i=!1,s,a;try{for(n=n.call(e);!(o=(s=n.next()).done)&&(r.push(s.value),!(t&&r.length===t));o=!0);}catch(c){i=!0,a=c}finally{try{!o&&n.return!=null&&n.return()}finally{if(i)throw a}}return r}}function We(e){if(Array.isArray(e))return e}function qe(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Xe(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function
|
|
1
|
+
import{by as _,bR as ye,bz as $,r as u,ap as $e,aE as ne,j as R,bD as Re,bv as Oe,bc as _e,bw as Se,aJ as oe,aq as ie,cd as ae,bu as Pe}from"./index.DKN5MVff.js";import{a as we}from"./useBasicWidgetState.DB3vMS9V.js";import"./FormClearHelper.DF4gFAOO.js";var se={vertical:"vertical",horizontal:"horizontal"};function le(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),n.push.apply(n,r)}return n}function D(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?le(Object(n),!0).forEach(function(r){O(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):le(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function O(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var E=0,L=1,T=2;function z(e){return e.$isActive?T:e.$isHovered?L:E}function Me(e){var t=e.$theme.colors,n=e.$disabled,r=e.$checked,o=e.$isFocusVisible,i=e.$error;if(n)return t.tickFillDisabled;if(r)if(i)switch(z(e)){case E:return t.tickFillErrorSelected;case L:return t.tickFillErrorSelectedHover;case T:return t.tickFillErrorSelectedHoverActive}else switch(z(e)){case E:return t.tickFillSelected;case L:return t.tickFillSelectedHover;case T:return t.tickFillSelectedHoverActive}else return o?t.borderSelected:i?t.tickBorderError:t.tickBorder;return null}function ke(e){var t=e.$theme.colors;if(e.$disabled)return t.tickMarkFillDisabled;if(e.$checked)return t.tickMarkFill;if(e.$error)switch(z(e)){case E:return t.tickFillError;case L:return t.tickFillErrorHover;case T:return t.tickFillErrorHoverActive}else switch(z(e)){case E:return t.tickFill;case L:return t.tickFillHover;case T:return t.tickFillActive}}function Fe(e){var t=e.$labelPlacement,n=t===void 0?"":t,r=e.$theme,o;switch(n){case"top":o="Bottom";break;case"bottom":o="Top";break;case"left":o=r.direction==="rtl"?"Left":"Right";break;default:case"right":o=r.direction==="rtl"?"Right":"Left";break}var i=r.sizing,s=i.scale300;return O({},"padding".concat(o),s)}function Ie(e){var t=e.$disabled,n=e.$theme,r=n.colors;return t?r.contentSecondary:r.contentPrimary}var q=_("div",function(e){var t=e.$disabled,n=e.$align;return{display:"flex",flexWrap:"wrap",flexDirection:n==="horizontal"?"row":"column",alignItems:n==="horizontal"?"center":"flex-start",cursor:t?"not-allowed":"pointer","-webkit-tap-highlight-color":"transparent"}});q.displayName="RadioGroupRoot";q.displayName="RadioGroupRoot";var X=_("label",function(e){var t,n=e.$disabled,r=e.$hasDescription,o=e.$labelPlacement,i=e.$theme,s=e.$align,a=i.sizing,c=s==="horizontal",p=i.direction==="rtl"?"Left":"Right";return t={flexDirection:o==="top"||o==="bottom"?"column":"row",display:"flex",alignItems:"center",cursor:n?"not-allowed":"pointer",marginTop:a.scale200},O(t,"margin".concat(p),c?a.scale200:null),O(t,"marginBottom",r&&!c?null:a.scale200),t});X.displayName="Root";X.displayName="Root";var J=_("div",function(e){var t=e.$theme,n=t.animation,r=t.sizing;return{backgroundColor:ke(e),borderTopLeftRadius:"50%",borderTopRightRadius:"50%",borderBottomRightRadius:"50%",borderBottomLeftRadius:"50%",height:e.$checked?r.scale200:r.scale550,transitionDuration:n.timing200,transitionTimingFunction:n.easeOutCurve,width:e.$checked?r.scale200:r.scale550}});J.displayName="RadioMarkInner";J.displayName="RadioMarkInner";var K=_("div",function(e){var t=e.$theme,n=t.animation,r=t.sizing;return{alignItems:"center",backgroundColor:Me(e),borderTopLeftRadius:"50%",borderTopRightRadius:"50%",borderBottomRightRadius:"50%",borderBottomLeftRadius:"50%",boxShadow:e.$isFocusVisible&&e.$checked?"0 0 0 3px ".concat(e.$theme.colors.accent):"none",display:"flex",height:r.scale700,justifyContent:"center",marginTop:r.scale0,marginRight:r.scale0,marginBottom:r.scale0,marginLeft:r.scale0,outline:"none",verticalAlign:"middle",width:r.scale700,flexShrink:0,transitionDuration:n.timing200,transitionTimingFunction:n.easeOutCurve}});K.displayName="RadioMarkOuter";K.displayName="RadioMarkOuter";var Q=_("div",function(e){var t=e.$theme.typography;return D(D({verticalAlign:"middle"},Fe(e)),{},{color:Ie(e)},t.LabelMedium)});Q.displayName="Label";Q.displayName="Label";var Y=_("input",{width:0,height:0,marginTop:0,marginRight:0,marginBottom:0,marginLeft:0,paddingTop:0,paddingRight:0,paddingBottom:0,paddingLeft:0,clip:"rect(0 0 0 0)",position:"absolute"});Y.displayName="Input";Y.displayName="Input";var Z=_("div",function(e){var t,n=e.$theme,r=e.$align,o=r==="horizontal",i=n.direction==="rtl"?"Right":"Left",s=n.direction==="rtl"?"Left":"Right";return D(D({},n.typography.ParagraphSmall),{},(t={color:n.colors.contentSecondary,cursor:"auto"},O(t,"margin".concat(i),r==="horizontal"?null:n.sizing.scale900),O(t,"margin".concat(s),o?n.sizing.scale200:null),O(t,"maxWidth","240px"),t))});Z.displayName="Description";Z.displayName="Description";function N(e){"@babel/helpers - typeof";return N=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},N(e)}function V(){return V=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},V.apply(this,arguments)}function Ee(e,t){return Ae(e)||xe(e,t)||Te(e,t)||Le()}function Le(){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 Te(e,t){if(e){if(typeof e=="string")return ue(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return ue(e,t)}}function ue(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function xe(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var r=[],o=!0,i=!1,s,a;try{for(n=n.call(e);!(o=(s=n.next()).done)&&(r.push(s.value),!(t&&r.length===t));o=!0);}catch(c){i=!0,a=c}finally{try{!o&&n.return!=null&&n.return()}finally{if(i)throw a}}return r}}function Ae(e){if(Array.isArray(e))return e}function je(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function De(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function ze(e,t,n){return t&&De(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function Be(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&U(e,t)}function U(e,t){return U=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,o){return r.__proto__=o,r},U(e,t)}function Ce(e){var t=Ne();return function(){var r=B(e),o;if(t){var i=B(this).constructor;o=Reflect.construct(r,arguments,i)}else o=r.apply(this,arguments);return He(this,o)}}function He(e,t){if(t&&(N(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return A(e)}function A(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Ne(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function B(e){return B=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},B(e)}function j(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var pe=function(e){Be(n,e);var t=Ce(n);function n(){var r;je(this,n);for(var o=arguments.length,i=new Array(o),s=0;s<o;s++)i[s]=arguments[s];return r=t.call.apply(t,[this].concat(i)),j(A(r),"state",{isFocusVisible:!1,focusedRadioIndex:-1}),j(A(r),"handleFocus",function(a,c){ye(a)&&r.setState({isFocusVisible:!0}),r.setState({focusedRadioIndex:c}),r.props.onFocus&&r.props.onFocus(a)}),j(A(r),"handleBlur",function(a,c){r.state.isFocusVisible!==!1&&r.setState({isFocusVisible:!1}),r.setState({focusedRadioIndex:-1}),r.props.onBlur&&r.props.onBlur(a)}),r}return ze(n,[{key:"render",value:function(){var o=this,i=this.props.overrides,s=i===void 0?{}:i,a=$(s.RadioGroupRoot,q),c=Ee(a,2),p=c[0],b=c[1];return u.createElement(p,V({id:this.props.id,role:"radiogroup","aria-describedby":this.props["aria-describedby"],"aria-errormessage":this.props["aria-errormessage"],"aria-invalid":this.props.error||null,"aria-label":this.props["aria-label"],"aria-labelledby":this.props["aria-labelledby"],$align:this.props.align,$disabled:this.props.disabled,$error:this.props.error,$required:this.props.required},b),u.Children.map(this.props.children,function(f,l){if(!u.isValidElement(f))return null;var d=o.props.value===f.props.value;return u.cloneElement(f,{align:o.props.align,autoFocus:o.props.autoFocus,checked:d,disabled:o.props.disabled||f.props.disabled,error:o.props.error,isFocused:o.state.focusedRadioIndex===l,isFocusVisible:o.state.isFocusVisible,tabIndex:l===0&&!o.props.value||d?"0":"-1",labelPlacement:o.props.labelPlacement,name:o.props.name,onBlur:function(g){return o.handleBlur(g,l)},onFocus:function(g){return o.handleFocus(g,l)},onChange:o.props.onChange,onMouseEnter:o.props.onMouseEnter,onMouseLeave:o.props.onMouseLeave})}))}}]),n}(u.Component);j(pe,"defaultProps",{name:"",value:"",disabled:!1,autoFocus:!1,labelPlacement:"right",align:"vertical",error:!1,required:!1,onChange:function(){},onMouseEnter:function(){},onMouseLeave:function(){},onFocus:function(){},onBlur:function(){},overrides:{}});function G(e){"@babel/helpers - typeof";return G=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},G(e)}function y(){return y=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},y.apply(this,arguments)}function M(e,t){return We(e)||Ge(e,t)||Ue(e,t)||Ve()}function Ve(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
3
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Ue(e,t){if(e){if(typeof e=="string")return ce(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return ce(e,t)}}function ce(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function Ge(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var r=[],o=!0,i=!1,s,a;try{for(n=n.call(e);!(o=(s=n.next()).done)&&(r.push(s.value),!(t&&r.length===t));o=!0);}catch(c){i=!0,a=c}finally{try{!o&&n.return!=null&&n.return()}finally{if(i)throw a}}return r}}function We(e){if(Array.isArray(e))return e}function qe(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Xe(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function Je(e,t,n){return t&&Xe(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function Ke(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&W(e,t)}function W(e,t){return W=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,o){return r.__proto__=o,r},W(e,t)}function Qe(e){var t=Ze();return function(){var r=C(e),o;if(t){var i=C(this).constructor;o=Reflect.construct(r,arguments,i)}else o=r.apply(this,arguments);return Ye(this,o)}}function Ye(e,t){if(t&&(G(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return k(e)}function k(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Ze(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function C(e){return C=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},C(e)}function F(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function et(e){return e==="top"||e==="left"}function tt(e){return e==="bottom"||e==="right"}var rt=function(t){return t.stopPropagation()},fe=function(e){Ke(n,e);var t=Qe(n);function n(){var r;qe(this,n);for(var o=arguments.length,i=new Array(o),s=0;s<o;s++)i[s]=arguments[s];return r=t.call.apply(t,[this].concat(i)),F(k(r),"state",{isActive:!1,isHovered:!1}),F(k(r),"onMouseEnter",function(a){r.setState({isHovered:!0}),r.props.onMouseEnter&&r.props.onMouseEnter(a)}),F(k(r),"onMouseLeave",function(a){r.setState({isHovered:!1}),r.props.onMouseLeave&&r.props.onMouseLeave(a)}),F(k(r),"onMouseDown",function(a){r.setState({isActive:!0}),r.props.onMouseDown&&r.props.onMouseDown(a)}),F(k(r),"onMouseUp",function(a){r.setState({isActive:!1}),r.props.onMouseUp&&r.props.onMouseUp(a)}),r}return Je(n,[{key:"componentDidMount",value:function(){var o;this.props.autoFocus&&(o=this.props.inputRef)!==null&&o!==void 0&&o.current&&this.props.inputRef.current.focus()}},{key:"render",value:function(){var o=this.props.overrides,i=o===void 0?{}:o,s=$(i.Root,X),a=M(s,2),c=a[0],p=a[1],b=$(i.Label,Q),f=M(b,2),l=f[0],d=f[1],S=$(i.Input,Y),g=M(S,2),P=g[0],H=g[1],x=$(i.Description,Z),I=M(x,2),v=I[0],h=I[1],m=$(i.RadioMarkInner,J),ee=M(m,2),de=ee[0],he=ee[1],be=$(i.RadioMarkOuter,K),te=M(be,2),ge=te[0],ve=te[1],w={$align:this.props.align,$checked:this.props.checked,$disabled:this.props.disabled,$hasDescription:!!this.props.description,$isActive:this.state.isActive,$error:this.props.error,$isFocused:this.props.isFocused,$isFocusVisible:this.props.isFocused&&this.props.isFocusVisible,$isHovered:this.state.isHovered,$labelPlacement:this.props.labelPlacement,$required:this.props.required,$value:this.props.value},re=u.createElement(l,y({},w,d),this.props.containsInteractiveElement?u.createElement("div",{onClick:function(me){return me.preventDefault()}},this.props.children):this.props.children);return u.createElement(u.Fragment,null,u.createElement(c,y({"data-baseweb":"radio",onMouseEnter:this.onMouseEnter,onMouseLeave:this.onMouseLeave,onMouseDown:this.onMouseDown,onMouseUp:this.onMouseUp},w,p),et(this.props.labelPlacement)&&re,u.createElement(ge,y({},w,ve),u.createElement(de,y({},w,he))),u.createElement(P,y({"aria-invalid":this.props.error||null,checked:this.props.checked,disabled:this.props.disabled,name:this.props.name,onBlur:this.props.onBlur,onFocus:this.props.onFocus,onClick:rt,onChange:this.props.onChange,ref:this.props.inputRef,required:this.props.required,tabIndex:this.props.tabIndex,type:"radio",value:this.props.value},w,H)),tt(this.props.labelPlacement)&&re),!!this.props.description&&u.createElement(v,y({},w,h),this.props.description))}}]),n}(u.Component);F(fe,"defaultProps",{overrides:{},containsInteractiveElement:!1,checked:!1,disabled:!1,autoFocus:!1,inputRef:u.createRef(),align:"vertical",error:!1,onChange:function(){},onMouseEnter:function(){},onMouseLeave:function(){},onMouseDown:function(){},onMouseUp:function(){},onFocus:function(){},onBlur:function(){}});function nt(e){const t=parseFloat(e.sizes.checkbox),n=parseFloat(e.spacing.threeXS),r=ie(t.toString()),o=Math.round(r*.375);let i=Math.round(ie((t-n).toString()));return i>=r&&(i-=1),[ae(o,"px"),ae(i,"px")]}function ot({disabled:e,horizontal:t,value:n,onChange:r,options:o,captions:i,label:s,labelVisibility:a,help:c}){const[p,b]=u.useState(n??null);u.useEffect(()=>{n!==p&&b(n??null)},[n]);const f=u.useCallback(v=>{const h=parseInt(v.target.value,10);b(h),r(h)},[r]),l=$e(),d=i.length>0,S=o.length>0,g=S?o:["No options to select."],P=e||!S,H=v=>v==""&&t&&d?" ":v,[x,I]=nt(l);return ne("div",{className:"stRadio","data-testid":"stRadio",children:[R(Se,{label:s,disabled:P,labelVisibility:a,children:c&&R(Re,{children:R(Oe,{content:c,placement:_e.TOP_RIGHT})})}),R(pe,{onChange:f,value:p!==null?p.toString():void 0,disabled:P,align:t?se.horizontal:se.vertical,"aria-label":s,"data-testid":"stRadioGroup",overrides:{RadioGroupRoot:{style:{gap:d?l.spacing.sm:l.spacing.none,minHeight:l.sizes.minElementHeight}}},children:g.map((v,h)=>ne(fe,{value:h.toString(),overrides:{Root:{style:({$isFocusVisible:m})=>({marginBottom:l.spacing.none,marginTop:l.spacing.none,marginRight:d?l.spacing.sm:l.spacing.lg,paddingLeft:l.spacing.none,alignItems:"start",paddingRight:l.spacing.threeXS,backgroundColor:m?l.colors.darkenedBgMix25:""})},RadioMarkOuter:{style:({$checked:m})=>({width:l.sizes.checkbox,height:l.sizes.checkbox,marginTop:"0.35rem",marginRight:l.spacing.none,marginLeft:l.spacing.none,backgroundColor:m&&!P?l.colors.primary:l.colors.fadedText40})},RadioMarkInner:{style:({$checked:m})=>({height:m?x:I,width:m?x:I})},Label:{style:{color:P?l.colors.fadedText40:l.colors.bodyText,position:"relative",top:l.spacing.px}}},children:[R(oe,{source:v,allowHTML:!1,isLabel:!0,largerLabel:!0}),d&&R(oe,{source:H(i[h]),allowHTML:!1,isCaption:!0,isLabel:!0})]},h))})]})}const it=u.memo(ot);function at({disabled:e,element:t,widgetMgr:n,fragmentId:r}){const[o,i]=we({getStateFromWidgetMgr:st,getDefaultStateFromProto:lt,getCurrStateFromProto:ut,updateWidgetMgrState:ct,element:t,widgetMgr:n,fragmentId:r}),s=u.useCallback(d=>{i({value:d,fromUi:!0})},[i]),{horizontal:a,options:c,captions:p,label:b,labelVisibility:f,help:l}=t;return R(it,{label:b,onChange:s,options:c,captions:p,disabled:e,horizontal:a,labelVisibility:Pe(f?.value),value:o??null,help:l})}function st(e,t){return e.getIntValue(t)}function lt(e){return e.default??null}function ut(e){return e.value??null}function ct(e,t,n,r){t.setIntValue(e,n.value??null,{fromUi:n.fromUi},r)}const bt=u.memo(at);export{bt as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as d,E as w,_ as U,s as c,aq as q,aE as p,j as a,bq as m,br as F,b7 as _,b8 as S,bk as K,F as G,bJ as J,aA as Y,bm as Q,bK as z,D as h,b as f,bo as Z,bn as ee,bu as te,bL as ie,bv as le,bc as se,bw as ne}from"./index.DKN5MVff.js";import{F as ae}from"./FormClearHelper.DF4gFAOO.js";import{g as C,F as y,b as oe,D as re,I as de,C as ce,a as pe,s as ge}from"./FileHelper.BrQvUXVD.js";import{S as ue,P as he}from"./ProgressBar.COK9j1l0.js";import{u as me}from"./Hooks.DEoLCfOE.js";import{U as v}from"./UploadFileInfo.C-jY39rj.js";var b=d.forwardRef(function(e,l){var t={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return d.createElement(w,U({iconAttrs:t,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},e,{ref:l}),d.createElement("path",{fill:"none",d:"M0 0h24v24H0V0z"}),d.createElement("path",{d:"M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12l4.58-4.59z"}))});b.displayName="ChevronLeft";var M=d.forwardRef(function(e,l){var t={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return d.createElement(w,U({iconAttrs:t,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},e,{ref:l}),d.createElement("path",{fill:"none",d:"M0 0h24v24H0V0z"}),d.createElement("path",{d:"M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6-6-6z"}))});M.displayName="ChevronRight";var V=d.forwardRef(function(e,l){var t={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return d.createElement(w,U({iconAttrs:t,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},e,{ref:l}),d.createElement("path",{fill:"none",d:"M0 0h24v24H0V0z"}),d.createElement("path",{d:"M19.35 10.04A7.49 7.49 0 0012 4C9.11 4 6.6 5.64 5.35 8.04A5.994 5.994 0 000 14c0 3.31 2.69 6 6 6h13c2.76 0 5-2.24 5-5 0-2.64-2.05-4.78-4.65-4.96zM19 18H6c-2.21 0-4-1.79-4-4 0-2.05 1.53-3.76 3.56-3.97l1.07-.11.5-.95A5.469 5.469 0 0112 6c2.62 0 4.88 1.86 5.39 4.43l.3 1.5 1.53.11A2.98 2.98 0 0122 15c0 1.65-1.35 3-3 3zM8 13h2.55v3h2.9v-3H16l-4-4z"}))});V.displayName="CloudUpload";var B=d.forwardRef(function(e,l){var t={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return d.createElement(w,U({iconAttrs:t,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},e,{ref:l}),d.createElement("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z"}))});B.displayName="Error";const D=c("section",{target:"eamlidg0"})(({isDisabled:e,theme:l})=>({display:"flex",alignItems:"center",padding:l.spacing.lg,backgroundColor:l.colors.secondaryBg,borderRadius:l.radii.default,border:l.colors.widgetBorderColor?`${l.sizes.borderWidth} solid ${l.colors.widgetBorderColor}`:void 0,height:l.sizes.largestElementHeight,":focus":{outline:"none"},":focus-visible":{boxShadow:`0 0 0 1px ${l.colors.primary}`},cursor:e?"not-allowed":"pointer"})),L=c("div",{target:"eamlidg1"})({marginRight:"auto",alignItems:"center",display:"flex"}),E=c("span",{target:"eamlidg2"})(({theme:e})=>({color:e.colors.darkenedBgMix100,marginRight:e.spacing.lg})),P=c("span",{target:"eamlidg3"})(({theme:e,disabled:l})=>({color:l?e.colors.fadedText40:e.colors.bodyText})),fe=c("span",{target:"eamlidg4"})(({theme:e,disabled:l})=>({fontSize:e.fontSizes.sm,color:l?e.colors.fadedText40:e.colors.fadedText60})),Fe=c("div",{target:"eamlidg5"})({display:"flex",flexDirection:"column"}),A=c("div",{target:"eamlidg6"})(({theme:e})=>({left:0,right:0,lineHeight:e.lineHeights.tight,paddingTop:e.spacing.md,paddingLeft:e.spacing.lg,paddingRight:e.spacing.lg})),Se=c("ul",{target:"eamlidg7"})(({theme:e})=>({listStyleType:"none",margin:e.spacing.none,padding:e.spacing.none})),T=c("li",{target:"eamlidg8"})(({theme:e})=>({margin:e.spacing.none,padding:e.spacing.none})),H=c("div",{target:"eamlidg9"})(({theme:e})=>({display:"flex",alignItems:"baseline",flex:1,paddingLeft:e.spacing.lg,overflow:"hidden"})),N=c("div",{target:"eamlidg10"})(({theme:e})=>({marginRight:e.spacing.sm,marginBottom:e.spacing.twoXS,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"})),W=c("div",{target:"eamlidg11"})(({theme:e})=>({display:"flex",alignItems:"center",marginBottom:e.spacing.twoXS})),ye=c("span",{target:"eamlidg12"})(({theme:e})=>({marginRight:e.spacing.twoXS})),we=c("div",{target:"eamlidg13"})(({theme:e})=>({display:"flex",padding:e.spacing.twoXS,color:e.colors.darkenedBgMix100})),k=c("small",{target:"eamlidg14"})(({theme:e})=>({color:e.colors.red,fontSize:e.fontSizes.sm,height:e.fontSizes.sm,lineHeight:e.fontSizes.sm,display:"flex",alignItems:"center",whiteSpace:"nowrap"})),R=c("span",{target:"eamlidg15"})({}),Ue=e=>({[D]:{display:"flex",flexDirection:"column",alignItems:"flex-start",height:"auto"},[L]:{marginBottom:e.spacing.sm},[E]:{display:"none"},[P]:{marginBottom:e.spacing.twoXS},[A]:{paddingRight:e.spacing.lg},[W]:{maxWidth:"inherit",flex:1,alignItems:"flex-start",marginBottom:e.spacing.sm},[N]:{width:e.sizes.full},[H]:{flexDirection:"column"},[k]:{height:"auto",whiteSpace:"initial"},[R]:{display:"none"},[T]:{margin:e.spacing.none,padding:e.spacing.none}}),xe=c("div",{target:"eamlidg16"})(({theme:e,width:l})=>{if(l<q("23rem"))return Ue(e)}),ve=({multiple:e,acceptedExtensions:l,maxSizeBytes:t,disabled:i})=>p(L,{"data-testid":"stFileUploaderDropzoneInstructions",children:[a(E,{children:a(m,{content:V,size:"threeXL"})}),p(Fe,{children:[p(P,{disabled:i,children:["Drag and drop file",e?"s":""," here"]}),p(fe,{disabled:i,children:[`Limit ${C(t,y.Byte,0)} per file`,l.length?` • ${l.map(s=>s.replace(/^\./,"").toUpperCase()).join(", ")}`:null]})]})]}),ze=d.memo(ve),Ie=({onDrop:e,multiple:l,acceptedExtensions:t,maxSizeBytes:i,disabled:s,label:o})=>a(re,{onDrop:e,multiple:l,accept:oe(t),maxSize:i,disabled:s,useFsAccessApi:!1,children:({getRootProps:n,getInputProps:r})=>p(D,{...n(),"data-testid":"stFileUploaderDropzone",isDisabled:s,"aria-label":o,children:[a("input",{"data-testid":"stFileUploaderDropzoneInput",...r()}),a(ze,{multiple:l,acceptedExtensions:t,maxSizeBytes:i,disabled:s}),a(F,{kind:S.SECONDARY,disabled:s,size:_.SMALL,children:"Browse files"})]})}),Ce=d.memo(Ie),$=c("small",{target:"ejh2rmr0"})(({kind:e,theme:l})=>{const{danger:t,fadedText60:i}=l.colors;return{color:e==="danger"?t:i,fontSize:l.fontSizes.sm,lineHeight:l.lineHeights.tight}}),be=({fileInfo:e})=>e.status.type==="uploading"?a(he,{value:e.status.progress,size:ue.SMALL}):e.status.type==="error"?p(k,{children:[a(ye,{"data-testid":"stFileUploaderFileErrorMessage",children:e.status.errorMessage}),a(R,{children:a(m,{content:B,size:"lg"})})]}):e.status.type==="uploaded"?a($,{children:C(e.size,y.Byte)}):null,Me=({fileInfo:e,onDelete:l})=>p(W,{className:"stFileUploaderFile","data-testid":"stFileUploaderFile",children:[a(we,{children:a(m,{content:de,size:"twoXL"})}),p(H,{className:"stFileUploaderFileData",children:[a(N,{className:"stFileUploaderFileName","data-testid":"stFileUploaderFileName",title:e.name,children:e.name}),a(be,{fileInfo:e})]}),a("div",{"data-testid":"stFileUploaderDeleteBtn",children:a(F,{onClick:()=>l(e.id),kind:S.MINIMAL,children:a(m,{content:ce,size:"lg"})})})]}),Ve=d.memo(Me),Be=c("div",{target:"egc9vxm0"})(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",paddingBottom:e.spacing.twoXS,marginBottom:e.spacing.twoXS})),De=c("div",{target:"egc9vxm1"})(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"center",color:e.colors.fadedText40})),Le=({currentPage:e,totalPages:l,onNext:t,onPrevious:i})=>p(Be,{"data-testid":"stFileUploaderPagination",children:[a($,{children:`Showing page ${e} of ${l}`}),p(De,{children:[a(F,{onClick:i,kind:S.MINIMAL,children:a(m,{content:b,size:"xl"})}),a(F,{onClick:t,kind:S.MINIMAL,children:a(m,{content:M,size:"xl"})})]})]}),Ee=d.memo(Le),I=(e,l)=>Math.ceil(e.length/l),Pe=e=>K(({pageSize:t,items:i,resetOnAdd:s,...o})=>{const[n,r]=d.useState(0),[g,x]=d.useState(()=>I(i,t)),u=me(i);d.useEffect(()=>{u&&u.length!==i.length&&x(I(i,t)),u&&u.length<i.length?s&&r(0):n+1>=g&&r(g-1)},[i,n,t,u,s,g]);const X=()=>{r(Math.min(n+1,g-1))},O=()=>{r(Math.max(0,n-1))},j=i.slice(n*t,n*t+t);return p(G,{children:[a(e,{items:j,...o}),i.length>t?a(Ee,{pageSize:t,totalPages:g,currentPage:n+1,onNext:X,onPrevious:O}):null]})},e),Ae=({items:e,onDelete:l})=>a(Se,{children:e.map(t=>a(T,{children:a(Ve,{fileInfo:t,onDelete:l})},t.id))}),Te=Pe(Ae),He=e=>a(A,{children:a(Te,{...e})}),Ne=d.memo(He);class We extends d.PureComponent{constructor(l){super(l),this.formClearHelper=new ae,this.localFileIdCounter=1,this.forceUpdatingStatus=!1,this.componentDidUpdate=()=>{if(this.status!=="ready")return;const t=this.createWidgetValue(),{element:i,widgetMgr:s,fragmentId:o}=this.props,n=s.getFileUploaderStateValue(i);Y(t,n)||s.setFileUploaderStateValue(i,t,{fromUi:!0},o)},this.dropHandler=(t,i)=>{const{element:s}=this.props,{multipleFiles:o}=s;if(!o&&t.length===0&&i.length>1){const n=i.findIndex(r=>r.errors.length===1&&r.errors[0].code==="too-many-files");n>=0&&(t.push(i[n].file),i.splice(n,1))}if(this.props.uploadClient.fetchFileURLs(t).then(n=>{if(!o&&t.length>0){const r=this.state.files.find(g=>g.status.type!=="error");r&&(this.forceUpdatingStatus=!0,this.deleteFile(r.id),this.forceUpdatingStatus=!1)}Q(n,t).forEach(([r,g])=>{this.uploadFile(r,g)})}).catch(n=>{this.addFiles(t.map(r=>new v(r.name,r.size,this.nextLocalFileId(),{type:"error",errorMessage:n})))}),i.length>0){const n=i.map(r=>pe(r,this.nextLocalFileId(),this.maxUploadSizeInBytes));this.addFiles(n)}},this.uploadFile=(t,i)=>{const s=z.CancelToken.source(),o=new v(i.name,i.size,this.nextLocalFileId(),{type:"uploading",cancelToken:s,progress:1});this.addFile(o),this.props.uploadClient.uploadFile(this.props.element,t.uploadUrl,i,n=>this.onUploadProgress(n,o.id),s.token).then(()=>this.onUploadComplete(o.id,t)).catch(n=>{z.isCancel(n)||this.updateFile(o.id,o.setStatus({type:"error",errorMessage:n?n.toString():"Unknown error"}))})},this.onUploadComplete=(t,i)=>{const s=this.getFile(t);h(s)||s.status.type!=="uploading"||this.updateFile(s.id,s.setStatus({type:"uploaded",fileId:i.fileId,fileUrls:i}))},this.deleteFile=t=>{const i=this.getFile(t);h(i)||(i.status.type==="uploading"&&i.status.cancelToken.cancel(),i.status.type==="uploaded"&&i.status.fileUrls.deleteUrl&&this.props.uploadClient.deleteFile(i.status.fileUrls.deleteUrl),this.removeFile(t))},this.addFile=t=>{f.flushSync(()=>{this.setState(i=>({files:[...i.files,t]}))})},this.addFiles=t=>{f.flushSync(()=>{this.setState(i=>({files:[...i.files,...t]}))})},this.removeFile=t=>{f.flushSync(()=>{this.setState(i=>({files:i.files.filter(s=>s.id!==t)}))})},this.getFile=t=>this.state.files.find(i=>i.id===t),this.updateFile=(t,i)=>{f.flushSync(()=>{this.setState(s=>({files:s.files.map(o=>o.id===t?i:o)}))})},this.onUploadProgress=(t,i)=>{const s=this.getFile(i);if(h(s)||s.status.type!=="uploading")return;const o=Math.round(t.loaded*100/t.total);s.status.progress!==o&&this.updateFile(i,s.setStatus({type:"uploading",cancelToken:s.status.cancelToken,progress:o}))},this.onFormCleared=()=>{f.flushSync(()=>{this.setState({files:[]},()=>{const t=this.createWidgetValue();if(h(t))return;const{widgetMgr:i,element:s,fragmentId:o}=this.props;i.setFileUploaderStateValue(s,t,{fromUi:!0},o)})})},this.state=this.initialValue}get initialValue(){const l={files:[]},{widgetMgr:t,element:i}=this.props,s=t.getFileUploaderStateValue(i);if(h(s))return l;const{uploadedFileInfo:o}=s;return h(o)||o.length===0?l:{files:o.map(n=>{const r=n.name,g=n.size,x=n.fileId,u=n.fileUrls;return new v(r,g,this.nextLocalFileId(),{type:"uploaded",fileId:x,fileUrls:u})})}}componentWillUnmount(){this.formClearHelper.disconnect()}get maxUploadSizeInBytes(){const l=this.props.element.maxUploadSizeMb;return ge(l,y.Megabyte,y.Byte)}get status(){const l=t=>t.status.type==="uploading";return this.state.files.some(l)||this.forceUpdatingStatus?"updating":"ready"}componentDidMount(){const l=this.createWidgetValue(),{element:t,widgetMgr:i,fragmentId:s}=this.props;i.getFileUploaderStateValue(t)===void 0&&i.setFileUploaderStateValue(t,l,{fromUi:!1},s)}createWidgetValue(){const l=this.state.files.filter(t=>t.status.type==="uploaded").map(t=>{const{name:i,size:s,status:o}=t,{fileId:n,fileUrls:r}=o;return new Z({fileId:n,fileUrls:r,name:i,size:s})});return new ee({uploadedFileInfo:l})}render(){const{files:l}=this.state,{element:t,disabled:i,widgetMgr:s,width:o}=this.props,n=t.type;this.formClearHelper.manageFormClearListener(s,t.formId,this.onFormCleared);const r=l.slice().reverse();return p(xe,{className:"stFileUploader","data-testid":"stFileUploader",width:o,children:[a(ne,{label:t.label,disabled:i,labelVisibility:te(t.labelVisibility?.value),children:t.help&&a(ie,{children:a(le,{content:t.help,placement:se.TOP_RIGHT})})}),a(Ce,{onDrop:this.dropHandler,multiple:t.multipleFiles,acceptedExtensions:n,maxSizeBytes:this.maxUploadSizeInBytes,label:t.label,disabled:i}),r.length>0&&a(Ne,{items:r,pageSize:3,onDelete:this.deleteFile,resetOnAdd:!0})]})}nextLocalFileId(){return this.localFileIdCounter++}}const qe=J(d.memo(We));export{qe as default};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{by as q,bz as J,r as c,bA as Q,ap as Y,bB as ee,bC as l,j as E,aE as te,bu as re,bD as ne,bv as oe,bc as ie,bE as ae,bw as ue,bF as le,br as ce,b8 as P,b7 as x,ba as se}from"./index.DKN5MVff.js";import{a as fe}from"./useBasicWidgetState.DB3vMS9V.js";import"./FormClearHelper.DF4gFAOO.js";var pe={secondary:"secondary"},N={default:"default"},de={default:"default"},k=Object.freeze({radio:"radio",checkbox:"checkbox"}),z=q("div",function(e){var t=e.$shape,r=e.$length,n=e.$theme,o=r===1?void 0:t!==N.default?"-".concat(n.sizing.scale100):"-0.5px";return{display:"flex",marginLeft:o,marginRight:o}});z.displayName="StyledRoot";z.displayName="StyledRoot";function M(e){"@babel/helpers - typeof";return M=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},M(e)}function $(){return $=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},$.apply(this,arguments)}function X(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),r.push.apply(r,n)}return r}function ye(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?X(Object(r),!0).forEach(function(n){V(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):X(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function be(e,t){return ge(e)||Se(e,t)||me(e,t)||he()}function he(){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 me(e,t){if(e){if(typeof e=="string")return F(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return F(e,t)}}function F(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function Se(e,t){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var n=[],o=!0,i=!1,a,d;try{for(r=r.call(e);!(o=(a=r.next()).done)&&(n.push(a.value),!(t&&n.length===t));o=!0);}catch(s){i=!0,d=s}finally{try{!o&&r.return!=null&&r.return()}finally{if(i)throw d}}return n}}function ge(e){if(Array.isArray(e))return e}function ve(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Oe(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function Ee(e,t,r){return t&&Oe(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function _e(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&G(e,t)}function G(e,t){return G=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,o){return n.__proto__=o,n},G(e,t)}function we(e){var t=Re();return function(){var n=B(e),o;if(t){var i=B(this).constructor;o=Reflect.construct(n,arguments,i)}else o=n.apply(this,arguments);return Le(this,o)}}function Le(e,t){if(t&&(M(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return K(e)}function K(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Re(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function B(e){return B=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},B(e)}function V(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Ce(e,t){return!Array.isArray(e)&&typeof e!="number"?!1:Array.isArray(e)?e.includes(t):e===t}var H=function(e){_e(r,e);var t=we(r);function r(){var n;ve(this,r);for(var o=arguments.length,i=new Array(o),a=0;a<o;a++)i[a]=arguments[a];return n=t.call.apply(t,[this].concat(i)),V(K(n),"childRefs",{}),n}return Ee(r,[{key:"render",value:function(){var o=this,i=this.props,a=i.overrides,d=a===void 0?{}:a,s=i.mode,y=s===void 0?k.checkbox:s,g=i.children,b=i.selected,_=i.disabled,f=i.onClick,h=i.kind,v=i.shape,m=i.size,A=J(d.Root,z),w=be(A,2),I=w[0],R=w[1],L=this.props["aria-label"]||this.props.ariaLabel,p=y===k.radio,U=c.Children.count(g);return c.createElement(Q.Consumer,null,function(Z){return c.createElement(I,$({"aria-label":L||Z.buttongroup.ariaLabel,"data-baseweb":"button-group",role:p?"radiogroup":"group",$shape:v,$length:g.length},R),c.Children.map(g,function(S,C){if(!c.isValidElement(S))return null;var T=S.props.isSelected?S.props.isSelected:Ce(b,C);return p&&(o.childRefs[C]=c.createRef()),c.cloneElement(S,{disabled:_||S.props.disabled,isSelected:T,ref:p?o.childRefs[C]:void 0,tabIndex:!p||T||p&&(!b||b===-1)&&C===0?0:-1,onKeyDown:function(u){if(p){var O=Number(b)?Number(b):0;if(u.key==="ArrowUp"||u.key==="ArrowLeft"){u.preventDefault&&u.preventDefault();var D=O-1<0?U-1:O-1;f&&f(u,D),o.childRefs[D].current&&o.childRefs[D].current.focus()}if(u.key==="ArrowDown"||u.key==="ArrowRight"){u.preventDefault&&u.preventDefault();var j=O+1>U-1?0:O+1;f&&f(u,j),o.childRefs[j].current&&o.childRefs[j].current.focus()}}},kind:h,onClick:function(u){_||(S.props.onClick&&S.props.onClick(u),f&&f(u,C))},shape:v,size:m,overrides:ye({BaseButton:{style:function(u){var O=u.$theme;return g.length===1?{}:v!==N.default?{marginLeft:O.sizing.scale100,marginRight:O.sizing.scale100}:{marginLeft:"0.5px",marginRight:"0.5px"}},props:{"aria-checked":T,role:p?"radio":"checkbox"}}},S.props.overrides)})}))})}}]),r}(c.Component);V(H,"defaultProps",{disabled:!1,onClick:function(){},shape:N.default,size:de.default,kind:pe.secondary});function Pe(e,t){return t.includes(e)?t.filter(r=>r!==e):[...t,e]}function ke(e,t,r){return e==l.ClickMode.MULTI_SELECT?Pe(t,r??[]):r?.includes(t)?[]:[t]}function Be(e){return e.length===0?-1:e[0]}function Ae(e,t,r,n){t.setIntArrayValue(e,r.value,{fromUi:r.fromUi},n)}function Ie(e,t,r){const n=r===l.Style.PILLS?P.PILLS:r===l.Style.BORDERLESS?P.BORDERLESS_ICON:P.SEGMENTED_CONTROL,o=r===l.Style.BORDERLESS?x.XSMALL:x.MEDIUM,i=n===P.PILLS||n===P.SEGMENTED_CONTROL,a=r===l.Style.BORDERLESS?"lg":"base";return{element:E(se,{icon:t,label:e,iconSize:a,useSmallerFont:i}),kind:n,size:o}}function Te(e,t,r,n){return r.indexOf(n)>-1?!0:t!==l.ClickMode.SINGLE_SELECT||e!==l.SelectionVisualization.ALL_UP_TO_SELECTED?!1:r.length>0&&n<r[0]}function De(e,t){return e&&(t=`${t}Active`),t}function je(e,t,r){const n={flexWrap:"wrap",maxWidth:"100%",margin:"0 0"},o=r?"100%":"auto",i=r?{}:{content:"''",flex:1e4};switch(e){case l.Style.BORDERLESS:return{...n,columnGap:t.threeXS,rowGap:t.threeXS};case l.Style.PILLS:return{...n,columnGap:t.twoXS,rowGap:t.twoXS,width:o};case l.Style.SEGMENTED_CONTROL:return{...n,columnGap:t.none,rowGap:t.twoXS,"::after":i,width:o};default:return n}}function Me(e,t,r,n,o,i,a){const d=Te(r,n,o,t);let s=e.content,y=e.contentIcon;return d&&(s=e.selectedContent?e.selectedContent:s,y=e.selectedContentIcon?e.selectedContentIcon:y),c.forwardRef(function(b,_){const{element:f,kind:h,size:v}=Ie(s??"",y??void 0,i),m=De(!!(d&&!e.selectedContent&&!e.selectedContentIcon),h);return E(ce,{...b,size:v,kind:m,containerWidth:a,children:f})})}function $e(e,t){return e.getIntArrayValue(t)}function Ge(e){return e.default??null}function Ne(e){return e.value??null}function ze(e){const{disabled:t,element:r,fragmentId:n,widgetMgr:o,widthConfig:i}=e,{clickMode:a,options:d,selectionVisualization:s,style:y,label:g,labelVisibility:b,help:_}=r,f=Y(),[h,v]=fe({getStateFromWidgetMgr:$e,getDefaultStateFromProto:Ge,getCurrStateFromProto:Ne,updateWidgetMgrState:Ae,element:r,widgetMgr:o,fragmentId:n}),m=ee(i),A=(R,L)=>{const p=ke(a,L,h);v({value:p,fromUi:!0})};let w;a===l.ClickMode.SINGLE_SELECT?w=k.radio:a===l.ClickMode.MULTI_SELECT&&(w=k.checkbox);const I=c.useMemo(()=>d.map((R,L)=>{const p=Me(R,L,s,a,h,y,m);return E(p,{},`${R.content}-${L}`)}),[a,d,s,y,h,m]);return te(le,{className:"stButtonGroup","data-testid":"stButtonGroup",containerWidth:m,children:[E(ue,{label:g,disabled:t,labelVisibility:re(b?.value??ae.LabelVisibilityOptions.COLLAPSED),children:_&&E(ne,{children:E(oe,{content:_,placement:ie.TOP})})}),E(H,{disabled:t,mode:w,onClick:A,selected:a===l.ClickMode.MULTI_SELECT?h:Be(h),overrides:{Root:{style:c.useCallback(()=>je(y,f.spacing,m),[y,f.spacing,m])}},children:I})]})}const xe=c.memo(ze);export{xe as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as p,ap as k,aD as T,j as n,aE as y,bu as C,aJ as S,bD as L,bv as W,bc as B,bO as w,ax as R,bP as E,bQ as P}from"./index.DKN5MVff.js";import{a as $}from"./useBasicWidgetState.DB3vMS9V.js";import{a as v,L as X,S as m}from"./checkbox.Cgxgc0et.js";import"./FormClearHelper.DF4gFAOO.js";function H({element:e,disabled:a,widgetMgr:s,fragmentId:d}){const[f,g]=$({getStateFromWidgetMgr:M,getDefaultStateFromProto:V,getCurrStateFromProto:I,updateWidgetMgrState:j,element:e,widgetMgr:s,fragmentId:d}),x=p.useCallback(i=>{g({value:i.target.checked,fromUi:!0})},[g]),t=k(),{colors:o,spacing:h,sizes:r}=t,b=T(t),u=a?o.fadedText40:o.bodyText;return n(P,{className:"row-widget stCheckbox","data-testid":"stCheckbox",children:n(v,{checked:f,disabled:a,onChange:x,"aria-label":e.label,checkmarkType:e.type===E.StyleType.TOGGLE?m.toggle:m.default,labelPlacement:X.right,overrides:{Root:{style:({$isFocusVisible:i})=>({marginBottom:h.none,marginTop:h.none,backgroundColor:i?o.darkenedBgMix25:"",display:"flex",alignItems:"start"})},Toggle:{style:({$checked:i})=>{let c=b?o.bgColor:o.bodyText;return a&&(c=b?o.gray70:o.gray90),{width:`calc(${r.checkbox} - ${t.spacing.twoXS})`,height:`calc(${r.checkbox} - ${t.spacing.twoXS})`,transform:i?`translateX(${r.checkbox})`:"",backgroundColor:c,boxShadow:""}}},ToggleTrack:{style:({$checked:i,$isHovered:c})=>{let l=o.fadedText40;return c&&!a&&(l=o.fadedText20),i&&!a&&(l=o.primary),{marginRight:0,marginLeft:0,marginBottom:0,marginTop:t.spacing.twoXS,paddingLeft:t.spacing.threeXS,paddingRight:t.spacing.threeXS,width:`calc(2 * ${r.checkbox})`,minWidth:`calc(2 * ${r.checkbox})`,height:r.checkbox,minHeight:r.checkbox,borderBottomLeftRadius:t.radii.full,borderTopLeftRadius:t.radii.full,borderBottomRightRadius:t.radii.full,borderTopRightRadius:t.radii.full,backgroundColor:l}}},Checkmark:{style:({$isFocusVisible:i,$checked:c})=>{const l=c&&!a?o.primary:o.fadedText40;return{outline:0,width:r.checkbox,height:r.checkbox,marginTop:t.spacing.twoXS,marginLeft:0,marginBottom:0,boxShadow:i&&c?`0 0 0 0.2rem ${R(o.primary,.5)}`:"",borderLeftWidth:r.borderWidth,borderRightWidth:r.borderWidth,borderTopWidth:r.borderWidth,borderBottomWidth:r.borderWidth,borderLeftColor:l,borderRightColor:l,borderTopColor:l,borderBottomColor:l}}},Label:{style:{lineHeight:t.lineHeights.small,paddingLeft:t.spacing.sm,position:"relative",color:u}}},children:y(w,{visibility:C(e.labelVisibility?.value),"data-testid":"stWidgetLabel",children:[n(S,{source:e.label,allowHTML:!1,isLabel:!0,largerLabel:!0}),e.help&&n(L,{color:u,children:n(W,{content:e.help,placement:B.TOP_RIGHT})})]})})})}function M(e,a){return e.getBoolValue(a)}function V(e){return e.default??null}function I(e){return e.value??null}function j(e,a,s,d){a.setBoolValue(e,s.value,{fromUi:s.fromUi},d)}const U=p.memo(H);export{U as default};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import{r as h,E as z,_ as H,L as _t,D as q,H as X,bd as ut,bm as $t,bn as zt,bo as Ht,s as D,j as g,bp as Vt,aE as N,b8 as jt,bq as Gt,br as qt,l as Xt,bs as Yt,ap as Kt,bt as tt,aq as Jt,aA as Qt,bu as Zt,bv as te,bc as ee,bw as ie}from"./index.DKN5MVff.js";import{T as se,a as pt}from"./Toolbar.Dt4jIKlY.js";import{u as re,F as ne}from"./FormClearHelper.DF4gFAOO.js";import{c as oe}from"./createDownloadLinkElement.ZaXNnPK4.js";import{u as ae}from"./Hooks.DEoLCfOE.js";import{F as le,D as ce}from"./FileDownload.esm.Bz9nxNC5.js";var gt=h.forwardRef(function(r,t){var e={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return h.createElement(z,H({iconAttrs:e,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},r,{ref:t}),h.createElement("g",{fill:"none"},h.createElement("rect",{width:24,height:24}),h.createElement("rect",{width:24,height:24}),h.createElement("rect",{width:24,height:24})),h.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"}),h.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"}))});gt.displayName="Mic";var bt=h.forwardRef(function(r,t){var e={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return h.createElement(z,H({iconAttrs:e,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},r,{ref:t}),h.createElement("rect",{width:24,height:24,fill:"none"}),h.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"}))});bt.displayName="Pause";var yt=h.forwardRef(function(r,t){var e={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return h.createElement(z,H({iconAttrs:e,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},r,{ref:t}),h.createElement("rect",{width:24,height:24,fill:"none"}),h.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"}))});yt.displayName="PlayArrow";var wt=h.forwardRef(function(r,t){var e={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return h.createElement(z,H({iconAttrs:e,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},r,{ref:t}),h.createElement("path",{fill:"none",d:"M0 0h24v24H0V0z"}),h.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"}))});wt.displayName="Refresh";var St=h.forwardRef(function(r,t){var e={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return h.createElement(z,H({iconAttrs:e,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},r,{ref:t}),h.createElement("g",{fill:"none"},h.createElement("rect",{width:24,height:24}),h.createElement("rect",{width:24,height:24})),h.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"}))});St.displayName="StopCircle";function P(r,t,e,i){return new(e||(e=Promise))(function(s,n){function o(c){try{d(i.next(c))}catch(l){n(l)}}function a(c){try{d(i.throw(c))}catch(l){n(l)}}function d(c){var l;c.done?s(c.value):(l=c.value,l instanceof e?l:new e(function(p){p(l)})).then(o,a)}d((i=i.apply(r,t||[])).next())})}let V=class{constructor(){this.listeners={}}on(t,e,i){if(this.listeners[t]||(this.listeners[t]=new Set),this.listeners[t].add(e),i?.once){const s=()=>{this.un(t,s),this.un(t,e)};return this.on(t,s),s}return()=>this.un(t,e)}un(t,e){var i;(i=this.listeners[t])===null||i===void 0||i.delete(e)}once(t,e){return this.on(t,e,{once:!0})}unAll(){this.listeners={}}emit(t,...e){this.listeners[t]&&this.listeners[t].forEach(i=>i(...e))}};const j={decode:function(r,t){return P(this,void 0,void 0,function*(){const e=new AudioContext({sampleRate:t});return e.decodeAudioData(r).finally(()=>e.close())})},createBuffer:function(r,t){return typeof r[0]=="number"&&(r=[r]),function(e){const i=e[0];if(i.some(s=>s>1||s<-1)){const s=i.length;let n=0;for(let o=0;o<s;o++){const a=Math.abs(i[o]);a>n&&(n=a)}for(const o of e)for(let a=0;a<s;a++)o[a]/=n}}(r),{duration:t,length:r[0].length,sampleRate:r[0].length/t,numberOfChannels:r.length,getChannelData:e=>r?.[e],copyFromChannel:AudioBuffer.prototype.copyFromChannel,copyToChannel:AudioBuffer.prototype.copyToChannel}}};function Ct(r,t){const e=t.xmlns?document.createElementNS(t.xmlns,r):document.createElement(r);for(const[i,s]of Object.entries(t))if(i==="children"&&s)for(const[n,o]of Object.entries(s))o instanceof Node?e.appendChild(o):typeof o=="string"?e.appendChild(document.createTextNode(o)):e.appendChild(Ct(n,o));else i==="style"?Object.assign(e.style,s):i==="textContent"?e.textContent=s:e.setAttribute(i,s.toString());return e}function mt(r,t,e){const i=Ct(r,t||{});return e?.appendChild(i),i}var de=Object.freeze({__proto__:null,createElement:mt,default:mt});const he={fetchBlob:function(r,t,e){return P(this,void 0,void 0,function*(){const i=yield fetch(r,e);if(i.status>=400)throw new Error(`Failed to fetch ${r}: ${i.status} (${i.statusText})`);return function(s,n){P(this,void 0,void 0,function*(){if(!s.body||!s.headers)return;const o=s.body.getReader(),a=Number(s.headers.get("Content-Length"))||0;let d=0;const c=p=>P(this,void 0,void 0,function*(){d+=p?.length||0;const u=Math.round(d/a*100);n(u)}),l=()=>P(this,void 0,void 0,function*(){let p;try{p=yield o.read()}catch{return}p.done||(c(p.value),yield l())});l()})}(i.clone(),t),i.blob()})}};class ue extends V{constructor(t){super(),this.isExternalMedia=!1,t.media?(this.media=t.media,this.isExternalMedia=!0):this.media=document.createElement("audio"),t.mediaControls&&(this.media.controls=!0),t.autoplay&&(this.media.autoplay=!0),t.playbackRate!=null&&this.onMediaEvent("canplay",()=>{t.playbackRate!=null&&(this.media.playbackRate=t.playbackRate)},{once:!0})}onMediaEvent(t,e,i){return this.media.addEventListener(t,e,i),()=>this.media.removeEventListener(t,e,i)}getSrc(){return this.media.currentSrc||this.media.src||""}revokeSrc(){const t=this.getSrc();t.startsWith("blob:")&&URL.revokeObjectURL(t)}canPlayType(t){return this.media.canPlayType(t)!==""}setSrc(t,e){const i=this.getSrc();if(t&&i===t)return;this.revokeSrc();const 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.media.remove(),this.revokeSrc(),this.media.removeAttribute("src"),this.media.load())}setMediaElement(t){this.media=t}play(){return P(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)}}class U extends V{constructor(t,e){super(),this.timeouts=[],this.isScrollable=!1,this.audioData=null,this.resizeObserver=null,this.lastContainerWidth=0,this.isDragging=!1,this.subscriptions=[],this.unsubscribeOnScroll=[],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(){const t=e=>{const i=this.wrapper.getBoundingClientRect(),s=e.clientX-i.left,n=e.clientY-i.top;return[s/i.width,n/i.height]};if(this.wrapper.addEventListener("click",e=>{const[i,s]=t(e);this.emit("click",i,s)}),this.wrapper.addEventListener("dblclick",e=>{const[i,s]=t(e);this.emit("dblclick",i,s)}),this.options.dragToSeek!==!0&&typeof this.options.dragToSeek!="object"||this.initDrag(),this.scrollContainer.addEventListener("scroll",()=>{const{scrollLeft:e,scrollWidth:i,clientWidth:s}=this.scrollContainer,n=e/i,o=(e+s)/i;this.emit("scroll",n,o,e,e+s)}),typeof ResizeObserver=="function"){const e=this.createDelay(100);this.resizeObserver=new ResizeObserver(()=>{e().then(()=>this.onContainerResize()).catch(()=>{})}),this.resizeObserver.observe(this.scrollContainer)}}onContainerResize(){const t=this.parent.clientWidth;t===this.lastContainerWidth&&this.options.height!=="auto"||(this.lastContainerWidth=t,this.reRender())}initDrag(){this.subscriptions.push(function(t,e,i,s,n=3,o=0,a=100){if(!t)return()=>{};const d=matchMedia("(pointer: coarse)").matches;let c=()=>{};const l=p=>{if(p.button!==o)return;p.preventDefault(),p.stopPropagation();let u=p.clientX,m=p.clientY,f=!1;const y=Date.now(),v=w=>{if(w.preventDefault(),w.stopPropagation(),d&&Date.now()-y<a)return;const k=w.clientX,A=w.clientY,M=k-u,T=A-m;if(f||Math.abs(M)>n||Math.abs(T)>n){const O=t.getBoundingClientRect(),{left:F,top:L}=O;f||(i?.(u-F,m-L),f=!0),e(M,T,k-F,A-L),u=k,m=A}},S=w=>{if(f){const k=w.clientX,A=w.clientY,M=t.getBoundingClientRect(),{left:T,top:O}=M;s?.(k-T,A-O)}c()},b=w=>{w.relatedTarget&&w.relatedTarget!==document.documentElement||S(w)},x=w=>{f&&(w.stopPropagation(),w.preventDefault())},R=w=>{f&&w.preventDefault()};document.addEventListener("pointermove",v),document.addEventListener("pointerup",S),document.addEventListener("pointerout",b),document.addEventListener("pointercancel",b),document.addEventListener("touchmove",R,{passive:!1}),document.addEventListener("click",x,{capture:!0}),c=()=>{document.removeEventListener("pointermove",v),document.removeEventListener("pointerup",S),document.removeEventListener("pointerout",b),document.removeEventListener("pointercancel",b),document.removeEventListener("touchmove",R),setTimeout(()=>{document.removeEventListener("click",x,{capture:!0})},10)}};return t.addEventListener("pointerdown",l),()=>{c(),t.removeEventListener("pointerdown",l)}}(this.wrapper,(t,e,i)=>{this.emit("drag",Math.max(0,Math.min(1,i/this.wrapper.getBoundingClientRect().width)))},t=>{this.isDragging=!0,this.emit("dragstart",Math.max(0,Math.min(1,t/this.wrapper.getBoundingClientRect().width)))},t=>{this.isDragging=!1,this.emit("dragend",Math.max(0,Math.min(1,t/this.wrapper.getBoundingClientRect().width)))}))}getHeight(t,e){var i;const s=((i=this.audioData)===null||i===void 0?void 0:i.numberOfChannels)||1;if(t==null)return 128;if(!isNaN(Number(t)))return Number(t);if(t==="auto"){const n=this.parent.clientHeight||128;return e?.every(o=>!o.overlay)?n/s:n}return 128}initHtml(){const t=document.createElement("div"),e=t.attachShadow({mode:"open"}),i=this.options.cspNonce&&typeof this.options.cspNonce=="string"?this.options.cspNonce.replace(/"/g,""):"";return e.innerHTML=`
|
|
2
|
+
<style${i?` nonce="${i}"`:""}>
|
|
3
|
+
:host {
|
|
4
|
+
user-select: none;
|
|
5
|
+
min-width: 1px;
|
|
6
|
+
}
|
|
7
|
+
:host audio {
|
|
8
|
+
display: block;
|
|
9
|
+
width: 100%;
|
|
10
|
+
}
|
|
11
|
+
:host .scroll {
|
|
12
|
+
overflow-x: auto;
|
|
13
|
+
overflow-y: hidden;
|
|
14
|
+
width: 100%;
|
|
15
|
+
position: relative;
|
|
16
|
+
}
|
|
17
|
+
:host .noScrollbar {
|
|
18
|
+
scrollbar-color: transparent;
|
|
19
|
+
scrollbar-width: none;
|
|
20
|
+
}
|
|
21
|
+
:host .noScrollbar::-webkit-scrollbar {
|
|
22
|
+
display: none;
|
|
23
|
+
-webkit-appearance: none;
|
|
24
|
+
}
|
|
25
|
+
:host .wrapper {
|
|
26
|
+
position: relative;
|
|
27
|
+
overflow: visible;
|
|
28
|
+
z-index: 2;
|
|
29
|
+
}
|
|
30
|
+
:host .canvases {
|
|
31
|
+
min-height: ${this.getHeight(this.options.height,this.options.splitChannels)}px;
|
|
32
|
+
}
|
|
33
|
+
:host .canvases > div {
|
|
34
|
+
position: relative;
|
|
35
|
+
}
|
|
36
|
+
:host canvas {
|
|
37
|
+
display: block;
|
|
38
|
+
position: absolute;
|
|
39
|
+
top: 0;
|
|
40
|
+
image-rendering: pixelated;
|
|
41
|
+
}
|
|
42
|
+
:host .progress {
|
|
43
|
+
pointer-events: none;
|
|
44
|
+
position: absolute;
|
|
45
|
+
z-index: 2;
|
|
46
|
+
top: 0;
|
|
47
|
+
left: 0;
|
|
48
|
+
width: 0;
|
|
49
|
+
height: 100%;
|
|
50
|
+
overflow: hidden;
|
|
51
|
+
}
|
|
52
|
+
:host .progress > div {
|
|
53
|
+
position: relative;
|
|
54
|
+
}
|
|
55
|
+
:host .cursor {
|
|
56
|
+
pointer-events: none;
|
|
57
|
+
position: absolute;
|
|
58
|
+
z-index: 5;
|
|
59
|
+
top: 0;
|
|
60
|
+
left: 0;
|
|
61
|
+
height: 100%;
|
|
62
|
+
border-radius: 2px;
|
|
63
|
+
}
|
|
64
|
+
</style>
|
|
65
|
+
|
|
66
|
+
<div class="scroll" part="scroll">
|
|
67
|
+
<div class="wrapper" part="wrapper">
|
|
68
|
+
<div class="canvases" part="canvases"></div>
|
|
69
|
+
<div class="progress" part="progress"></div>
|
|
70
|
+
<div class="cursor" part="cursor"></div>
|
|
71
|
+
</div>
|
|
72
|
+
</div>
|
|
73
|
+
`,[t,e]}setOptions(t){if(this.options.container!==t.container){const e=this.parentFromOptionsContainer(t.container);e.appendChild(this.container),this.parent=e}t.dragToSeek!==!0&&typeof this.options.dragToSeek!="object"||this.initDrag(),this.options=t,this.reRender()}getWrapper(){return this.wrapper}getWidth(){return this.scrollContainer.clientWidth}getScroll(){return this.scrollContainer.scrollLeft}setScroll(t){this.scrollContainer.scrollLeft=t}setScrollPercentage(t){const{scrollWidth:e}=this.scrollContainer,i=e*t;this.setScroll(i)}destroy(){var t,e;this.subscriptions.forEach(i=>i()),this.container.remove(),(t=this.resizeObserver)===null||t===void 0||t.disconnect(),(e=this.unsubscribeOnScroll)===null||e===void 0||e.forEach(i=>i()),this.unsubscribeOnScroll=[]}createDelay(t=10){let e,i;const s=()=>{e&&clearTimeout(e),i&&i()};return this.timeouts.push(s),()=>new Promise((n,o)=>{s(),i=o,e=setTimeout(()=>{e=void 0,i=void 0,n()},t)})}convertColorValues(t){if(!Array.isArray(t))return t||"";if(t.length<2)return t[0]||"";const e=document.createElement("canvas"),i=e.getContext("2d"),s=e.height*(window.devicePixelRatio||1),n=i.createLinearGradient(0,0,0,s),o=1/(t.length-1);return t.forEach((a,d)=>{const c=d*o;n.addColorStop(c,a)}),n}getPixelRatio(){return Math.max(1,window.devicePixelRatio||1)}renderBarWaveform(t,e,i,s){const n=t[0],o=t[1]||t[0],a=n.length,{width:d,height:c}=i.canvas,l=c/2,p=this.getPixelRatio(),u=e.barWidth?e.barWidth*p:1,m=e.barGap?e.barGap*p:e.barWidth?u/2:0,f=e.barRadius||0,y=d/(u+m)/a,v=f&&"roundRect"in i?"roundRect":"rect";i.beginPath();let S=0,b=0,x=0;for(let R=0;R<=a;R++){const w=Math.round(R*y);if(w>S){const M=Math.round(b*l*s),T=M+Math.round(x*l*s)||1;let O=l-M;e.barAlign==="top"?O=0:e.barAlign==="bottom"&&(O=c-T),i[v](S*(u+m),O,u,T,f),S=w,b=0,x=0}const k=Math.abs(n[R]||0),A=Math.abs(o[R]||0);k>b&&(b=k),A>x&&(x=A)}i.fill(),i.closePath()}renderLineWaveform(t,e,i,s){const n=o=>{const a=t[o]||t[0],d=a.length,{height:c}=i.canvas,l=c/2,p=i.canvas.width/d;i.moveTo(0,l);let u=0,m=0;for(let f=0;f<=d;f++){const y=Math.round(f*p);if(y>u){const S=l+(Math.round(m*l*s)||1)*(o===0?-1:1);i.lineTo(u,S),u=y,m=0}const v=Math.abs(a[f]||0);v>m&&(m=v)}i.lineTo(u,l)};i.beginPath(),n(0),n(1),i.fill(),i.closePath()}renderWaveform(t,e,i){if(i.fillStyle=this.convertColorValues(e.waveColor),e.renderFunction)return void e.renderFunction(t,i);let s=e.barHeight||1;if(e.normalize){const n=Array.from(t[0]).reduce((o,a)=>Math.max(o,Math.abs(a)),0);s=n?1/n:1}e.barWidth||e.barGap||e.barAlign?this.renderBarWaveform(t,e,i,s):this.renderLineWaveform(t,e,i,s)}renderSingleCanvas(t,e,i,s,n,o,a){const d=this.getPixelRatio(),c=document.createElement("canvas");c.width=Math.round(i*d),c.height=Math.round(s*d),c.style.width=`${i}px`,c.style.height=`${s}px`,c.style.left=`${Math.round(n)}px`,o.appendChild(c);const l=c.getContext("2d");if(this.renderWaveform(t,e,l),c.width>0&&c.height>0){const p=c.cloneNode(),u=p.getContext("2d");u.drawImage(c,0,0),u.globalCompositeOperation="source-in",u.fillStyle=this.convertColorValues(e.progressColor),u.fillRect(0,0,c.width,c.height),a.appendChild(p)}}renderMultiCanvas(t,e,i,s,n,o){const a=this.getPixelRatio(),{clientWidth:d}=this.scrollContainer,c=i/a;let l=Math.min(U.MAX_CANVAS_WIDTH,d,c),p={};if(e.barWidth||e.barGap){const v=e.barWidth||.5,S=v+(e.barGap||v/2);l%S!=0&&(l=Math.floor(l/S)*S)}if(l===0)return;const u=v=>{if(v<0||v>=m||p[v])return;p[v]=!0;const S=v*l;let b=Math.min(c-S,l);if(e.barWidth||e.barGap){const R=e.barWidth||.5,w=R+(e.barGap||R/2);b=Math.floor(b/w)*w}if(b<=0)return;const x=t.map(R=>{const w=Math.floor(S/c*R.length),k=Math.floor((S+b)/c*R.length);return R.slice(w,k)});this.renderSingleCanvas(x,e,b,s,S,n,o)},m=Math.ceil(c/l);if(!this.isScrollable){for(let v=0;v<m;v++)u(v);return}const f=this.scrollContainer.scrollLeft/c,y=Math.floor(f*m);if(u(y-1),u(y),u(y+1),m>1){const v=this.on("scroll",()=>{const{scrollLeft:S}=this.scrollContainer,b=Math.floor(S/c*m);Object.keys(p).length>U.MAX_NODES&&(n.innerHTML="",o.innerHTML="",p={}),u(b-1),u(b),u(b+1)});this.unsubscribeOnScroll.push(v)}}renderChannel(t,e,i,s){var{overlay:n}=e,o=function(l,p){var u={};for(var m in l)Object.prototype.hasOwnProperty.call(l,m)&&p.indexOf(m)<0&&(u[m]=l[m]);if(l!=null&&typeof Object.getOwnPropertySymbols=="function"){var f=0;for(m=Object.getOwnPropertySymbols(l);f<m.length;f++)p.indexOf(m[f])<0&&Object.prototype.propertyIsEnumerable.call(l,m[f])&&(u[m[f]]=l[m[f]])}return u}(e,["overlay"]);const a=document.createElement("div"),d=this.getHeight(o.height,o.splitChannels);a.style.height=`${d}px`,n&&s>0&&(a.style.marginTop=`-${d}px`),this.canvasWrapper.style.minHeight=`${d}px`,this.canvasWrapper.appendChild(a);const c=a.cloneNode();this.progressWrapper.appendChild(c),this.renderMultiCanvas(t,o,i,d,a,c)}render(t){return P(this,void 0,void 0,function*(){var e;this.timeouts.forEach(d=>d()),this.timeouts=[],this.canvasWrapper.innerHTML="",this.progressWrapper.innerHTML="",this.options.width!=null&&(this.scrollContainer.style.width=typeof this.options.width=="number"?`${this.options.width}px`:this.options.width);const i=this.getPixelRatio(),s=this.scrollContainer.clientWidth,n=Math.ceil(t.duration*(this.options.minPxPerSec||0));this.isScrollable=n>s;const o=this.options.fillParent&&!this.isScrollable,a=(o?s:n)*i;if(this.wrapper.style.width=o?"100%":`${n}px`,this.scrollContainer.style.overflowX=this.isScrollable?"auto":"hidden",this.scrollContainer.classList.toggle("noScrollbar",!!this.options.hideScrollbar),this.cursor.style.backgroundColor=`${this.options.cursorColor||this.options.progressColor}`,this.cursor.style.width=`${this.options.cursorWidth}px`,this.audioData=t,this.emit("render"),this.options.splitChannels)for(let d=0;d<t.numberOfChannels;d++){const c=Object.assign(Object.assign({},this.options),(e=this.options.splitChannels)===null||e===void 0?void 0:e[d]);this.renderChannel([t.getChannelData(d)],c,a,d)}else{const d=[t.getChannelData(0)];t.numberOfChannels>1&&d.push(t.getChannelData(1)),this.renderChannel(d,this.options,a,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();let s=i-e;s*=2,s=s<0?Math.floor(s):Math.ceil(s),s/=2,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,o=t*s,a=i,d=i+n,c=n/2;if(this.isDragging)o+30>d?this.scrollContainer.scrollLeft+=30:o-30<a&&(this.scrollContainer.scrollLeft-=30);else{(o<a||o>d)&&(this.scrollContainer.scrollLeft=o-(this.options.autoCenter?c:0));const l=o-i-c;e&&this.options.autoCenter&&l>0&&(this.scrollContainer.scrollLeft+=Math.min(l,10))}{const l=this.scrollContainer.scrollLeft,p=l/s,u=(l+n)/s;this.emit("scroll",p,u,l,l+n)}}renderProgress(t,e){if(isNaN(t))return;const i=100*t;this.canvasWrapper.style.clipPath=`polygon(${i}% 0%, 100% 0%, 100% 100%, ${i}% 100%)`,this.progressWrapper.style.width=`${i}%`,this.cursor.style.left=`${i}%`,this.cursor.style.transform=this.options.cursorWidth?`translateX(-${t*this.options.cursorWidth}px)`:"",this.isScrollable&&this.options.autoScroll&&this.scrollIntoView(t,e)}exportImage(t,e,i){return P(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(o=>o.toDataURL(t,e));return Promise.resolve(n)}return Promise.all(Array.from(s).map(n=>new Promise((o,a)=>{n.toBlob(d=>{d?o(d):a(new Error("Could not export image"))},t,e)})))})}}U.MAX_CANVAS_WIDTH=8e3,U.MAX_NODES=10;class pe extends V{constructor(){super(...arguments),this.unsubscribe=()=>{}}start(){this.unsubscribe=this.on("tick",()=>{requestAnimationFrame(()=>{this.emit("tick")})}),this.emit("tick")}stop(){this.unsubscribe()}destroy(){this.unsubscribe()}}class et extends V{constructor(t=new AudioContext){super(),this.bufferNode=null,this.playStartTime=0,this.playedDuration=0,this._muted=!1,this._playbackRate=1,this._duration=void 0,this.buffer=null,this.currentSrc="",this.paused=!0,this.crossOrigin=null,this.seeking=!1,this.autoplay=!1,this.addEventListener=this.on,this.removeEventListener=this.un,this.audioContext=t,this.gainNode=this.audioContext.createGain(),this.gainNode.connect(this.audioContext.destination)}load(){return P(this,void 0,void 0,function*(){})}get src(){return this.currentSrc}set src(t){if(this.currentSrc=t,this._duration=void 0,!t)return this.buffer=null,void this.emit("emptied");fetch(t).then(e=>{if(e.status>=400)throw new Error(`Failed to fetch ${t}: ${e.status} (${e.statusText})`);return e.arrayBuffer()}).then(e=>this.currentSrc!==t?null:this.audioContext.decodeAudioData(e)).then(e=>{this.currentSrc===t&&(this.buffer=e,this.emit("loadedmetadata"),this.emit("canplay"),this.autoplay&&this.play())})}_play(){var t;if(!this.paused)return;this.paused=!1,(t=this.bufferNode)===null||t===void 0||t.disconnect(),this.bufferNode=this.audioContext.createBufferSource(),this.buffer&&(this.bufferNode.buffer=this.buffer),this.bufferNode.playbackRate.value=this._playbackRate,this.bufferNode.connect(this.gainNode);let e=this.playedDuration*this._playbackRate;(e>=this.duration||e<0)&&(e=0,this.playedDuration=0),this.bufferNode.start(this.audioContext.currentTime,e),this.playStartTime=this.audioContext.currentTime,this.bufferNode.onended=()=>{this.currentTime>=this.duration&&(this.pause(),this.emit("ended"))}}_pause(){var t;this.paused=!0,(t=this.bufferNode)===null||t===void 0||t.stop(),this.playedDuration+=this.audioContext.currentTime-this.playStartTime}play(){return P(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 P(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 me={waveColor:"#999",progressColor:"#555",cursorWidth:1,minPxPerSec:0,fillParent:!0,interact:!0,dragToSeek:!1,autoScroll:!0,autoCenter:!0,sampleRate:8e3};class _ extends ue{static create(t){return new _(t)}constructor(t){const e=t.media||(t.backend==="WebAudio"?new et: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({},me,t),this.timer=new pe;const i=e?void 0:this.getMediaElement();this.renderer=new U(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:o}=this.options;(s||n&&o)&&this.load(s,n,o).catch(()=>null)})}updateProgress(t=this.getCurrentTime()){return this.renderer.renderProgress(t/this.getDuration(),this.isPlaying()),t}initTimerEvents(){this.subscriptions.push(this.timer.on("tick",()=>{if(!this.isSeeking()){const t=this.updateProgress();this.emit("timeupdate",t),this.emit("audioprocess",t),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)}));{let t;this.subscriptions.push(this.renderer.on("drag",e=>{if(!this.options.interact)return;let i;this.renderer.renderProgress(e),clearTimeout(t),this.isPlaying()?i=0:this.options.dragToSeek===!0?i=200:typeof this.options.dragToSeek=="object"&&this.options.dragToSeek!==void 0&&(i=this.options.dragToSeek.debounceTime),t=setTimeout(()=>{this.seekTo(e)},i),this.emit("interaction",e*this.getDuration()),this.emit("drag",e)}))}}initPlugins(){var t;!((t=this.options.plugins)===null||t===void 0)&&t.length&&this.options.plugins.forEach(e=>{this.registerPlugin(e)})}unsubscribePlayerEvents(){this.mediaSubscriptions.forEach(t=>t()),this.mediaSubscriptions=[]}setOptions(t){this.options=Object.assign({},this.options,t),t.duration&&!t.peaks&&(this.decodedData=j.createBuffer(this.exportPeaks(),t.duration)),t.peaks&&t.duration&&(this.decodedData=j.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 P(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,!e&&!i){const a=this.options.fetchParams||{};window.AbortController&&!a.signal&&(this.abortController=new AbortController,a.signal=(n=this.abortController)===null||n===void 0?void 0:n.signal);const d=l=>this.emit("loading",l);e=yield he.fetchBlob(t,d,a);const c=this.options.blobMimeType;c&&(e=new Blob([e],{type:c}))}this.setSrc(t,e);const o=yield new Promise(a=>{const d=s||this.getDuration();d?a(d):this.mediaSubscriptions.push(this.onMediaEvent("loadedmetadata",()=>a(this.getDuration()),{once:!0}))});if(!t&&!e){const a=this.getMediaElement();a instanceof et&&(a.duration=o)}if(i)this.decodedData=j.createBuffer(i,o||0);else if(e){const a=yield e.arrayBuffer();this.decodedData=yield j.decode(a,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 P(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 P(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 o=0;o<s;o++){const a=this.decodedData.getChannelData(o),d=[],c=a.length/e;for(let l=0;l<e;l++){const p=a.slice(Math.floor(l*c),Math.ceil((l+1)*c));let u=0;for(let m=0;m<p.length;m++){const f=p[m];Math.abs(f)>Math.abs(u)&&(u=f)}d.push(Math.round(u*i)/i)}n.push(d)}return n}getDuration(){let t=super.getDuration()||0;return t!==0&&t!==1/0||!this.decodedData||(t=this.decodedData.duration),t}toggleInteraction(t){this.options.interact=t}setTime(t){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 P(this,void 0,void 0,function*(){t!=null&&this.setTime(t);const s=yield i.play.call(this);return e!=null&&(this.media instanceof et?this.media.stopAt(e):this.stopAtPosition=e),s})}playPause(){return P(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 P(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()}}_.BasePlugin=class extends V{constructor(r){super(),this.subscriptions=[],this.isDestroyed=!1,this.options=r}onInit(){}_init(r){this.isDestroyed&&(this.subscriptions=[],this.isDestroyed=!1),this.wavesurfer=r,this.onInit()}destroy(){this.emit("destroy"),this.subscriptions.forEach(r=>r()),this.subscriptions=[],this.isDestroyed=!0,this.wavesurfer=void 0}},_.dom=de;function it(r,t,e,i){return new(e||(e=Promise))(function(s,n){function o(c){try{d(i.next(c))}catch(l){n(l)}}function a(c){try{d(i.throw(c))}catch(l){n(l)}}function d(c){var l;c.done?s(c.value):(l=c.value,l instanceof e?l:new e(function(p){p(l)})).then(o,a)}d((i=i.apply(r,[])).next())})}class Et{constructor(){this.listeners={}}on(t,e,i){if(this.listeners[t]||(this.listeners[t]=new Set),this.listeners[t].add(e),i?.once){const s=()=>{this.un(t,s),this.un(t,e)};return this.on(t,s),s}return()=>this.un(t,e)}un(t,e){var i;(i=this.listeners[t])===null||i===void 0||i.delete(e)}once(t,e){return this.on(t,e,{once:!0})}unAll(){this.listeners={}}emit(t,...e){this.listeners[t]&&this.listeners[t].forEach(i=>i(...e))}}class fe extends Et{constructor(t){super(),this.subscriptions=[],this.isDestroyed=!1,this.options=t}onInit(){}_init(t){this.isDestroyed&&(this.subscriptions=[],this.isDestroyed=!1),this.wavesurfer=t,this.onInit()}destroy(){this.emit("destroy"),this.subscriptions.forEach(t=>t()),this.subscriptions=[],this.isDestroyed=!0,this.wavesurfer=void 0}}class ve extends Et{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 ge=["audio/webm","audio/wav","audio/mpeg","audio/mp4","audio/mp3"];class Y extends fe{constructor(t){var e,i,s,n,o,a;super(Object.assign(Object.assign({},t),{audioBitsPerSecond:(e=t.audioBitsPerSecond)!==null&&e!==void 0?e:128e3,scrollingWaveform:(i=t.scrollingWaveform)!==null&&i!==void 0&&i,scrollingWaveformWindow:(s=t.scrollingWaveformWindow)!==null&&s!==void 0?s:5,continuousWaveform:(n=t.continuousWaveform)!==null&&n!==void 0&&n,renderRecordedAudio:(o=t.renderRecordedAudio)===null||o===void 0||o,mediaRecorderTimeslice:(a=t.mediaRecorderTimeslice)!==null&&a!==void 0?a: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 ve,this.subscriptions.push(this.timer.on("tick",()=>{const d=performance.now()-this.lastStartTime;this.duration=this.isPaused()?this.duration:this.lastDuration+d,this.emit("record-progress",this.duration)}))}static create(t){return new Y(t||{})}renderMicStream(t){var e;const i=new AudioContext,s=i.createMediaStreamSource(t),n=i.createAnalyser();s.connect(n),this.options.continuousWaveform&&(n.fftSize=32);const o=n.frequencyBinCount,a=new Float32Array(o);let d=0;this.wavesurfer&&((e=this.originalOptions)!==null&&e!==void 0||(this.originalOptions=Object.assign({},this.wavesurfer.options)),this.wavesurfer.options.interact=!1,this.options.scrollingWaveform&&(this.wavesurfer.options.cursorWidth=0));const c=setInterval(()=>{var l,p,u,m;if(!this.isWaveformPaused){if(n.getFloatTimeDomainData(a),this.options.scrollingWaveform){const f=Math.floor((this.options.scrollingWaveformWindow||0)*i.sampleRate),y=Math.min(f,this.dataWindow?this.dataWindow.length+o:o),v=new Float32Array(f);if(this.dataWindow){const S=Math.max(0,f-this.dataWindow.length);v.set(this.dataWindow.slice(-y+o),S)}v.set(a,f-o),this.dataWindow=v}else if(this.options.continuousWaveform){if(!this.dataWindow){const y=this.options.continuousWaveformDuration?Math.round(100*this.options.continuousWaveformDuration):((p=(l=this.wavesurfer)===null||l===void 0?void 0:l.getWidth())!==null&&p!==void 0?p:0)*window.devicePixelRatio;this.dataWindow=new Float32Array(y)}let f=0;for(let y=0;y<o;y++){const v=Math.abs(a[y]);v>f&&(f=v)}if(d+1>this.dataWindow.length){const y=new Float32Array(2*this.dataWindow.length);y.set(this.dataWindow,0),this.dataWindow=y}this.dataWindow[d]=f,d++}else this.dataWindow=a;if(this.wavesurfer){const f=((m=(u=this.dataWindow)===null||u===void 0?void 0:u.length)!==null&&m!==void 0?m:0)/100;this.wavesurfer.load("",[this.dataWindow],this.options.scrollingWaveform?this.options.scrollingWaveformWindow:f).then(()=>{this.wavesurfer&&this.options.continuousWaveform&&(this.wavesurfer.setTime(this.getDuration()/1e3),this.wavesurfer.options.minPxPerSec||this.wavesurfer.setOptions({minPxPerSec:this.wavesurfer.getWidth()/this.wavesurfer.getDuration()}))}).catch(y=>{console.error("Error rendering real-time recording data:",y)})}}},10);return{onDestroy:()=>{clearInterval(c),s?.disconnect(),i?.close()},onEnd:()=>{this.isWaveformPaused=!0,clearInterval(c),this.stopMic()}}}startMic(t){return it(this,void 0,void 0,function*(){let e;try{e=yield navigator.mediaDevices.getUserMedia({audio:t==null||t})}catch(n){throw new Error("Error accessing the microphone: "+n.message)}const{onDestroy:i,onEnd:s}=this.renderMicStream(e);return this.subscriptions.push(this.once("destroy",i)),this.subscriptions.push(this.once("record-end",s)),this.stream=e,e})}stopMic(){this.stream&&(this.stream.getTracks().forEach(t=>t.stop()),this.stream=null,this.mediaRecorder=null)}startRecording(t){return it(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||ge.find(o=>MediaRecorder.isTypeSupported(o)),audioBitsPerSecond:this.options.audioBitsPerSecond});this.mediaRecorder=i,this.stopRecording();const s=[];i.ondataavailable=o=>{o.data.size>0&&s.push(o.data),this.emit("record-data-available",o.data)};const n=o=>{var a;const d=new Blob(s,{type:i.mimeType});this.emit(o,d),this.options.renderRecordedAudio&&(this.applyOriginalOptionsIfNeeded(),(a=this.wavesurfer)===null||a===void 0||a.load(URL.createObjectURL(d)))};i.onpause=()=>n("record-pause"),i.onstop=()=>n("record-end"),i.start(this.options.mediaRecorderTimeslice),this.lastStartTime=performance.now(),this.lastDuration=0,this.duration=0,this.isWaveformPaused=!1,this.timer.start(),this.emit("record-start")})}getDuration(){return this.duration}isRecording(){var t;return((t=this.mediaRecorder)===null||t===void 0?void 0:t.state)==="recording"}isPaused(){var t;return((t=this.mediaRecorder)===null||t===void 0?void 0:t.state)==="paused"}isActive(){var t;return((t=this.mediaRecorder)===null||t===void 0?void 0:t.state)!=="inactive"}stopRecording(){var t;this.isActive()&&((t=this.mediaRecorder)===null||t===void 0||t.stop(),this.timer.stop())}pauseRecording(){var t,e;this.isRecording()&&(this.isWaveformPaused=!0,(t=this.mediaRecorder)===null||t===void 0||t.requestData(),(e=this.mediaRecorder)===null||e===void 0||e.pause(),this.timer.stop(),this.lastDuration=this.duration)}resumeRecording(){var t;this.isPaused()&&(this.isWaveformPaused=!1,(t=this.mediaRecorder)===null||t===void 0||t.resume(),this.timer.start(),this.lastStartTime=performance.now(),this.emit("record-resume"))}static getAvailableAudioDevices(){return it(this,void 0,void 0,function*(){return navigator.mediaDevices.enumerateDevices().then(t=>t.filter(e=>e.kind==="audioinput"))})}destroy(){this.applyOriginalOptionsIfNeeded(),super.destroy(),this.stopRecording(),this.stopMic()}applyOriginalOptionsIfNeeded(){this.wavesurfer&&this.originalOptions&&(this.wavesurfer.setOptions(this.originalOptions),delete this.originalOptions)}}const be=(r,t)=>{const{libConfig:{enforceDownloadInNewTab:e=!1}}=h.useContext(_t);return h.useCallback(()=>{if(!r)return;const s=oe({enforceDownloadInNewTab:e,url:r,filename:t});s.style.display="none",document.body.appendChild(s),s.click(),document.body.removeChild(s)},[r,e,t])},st=({widgetMgr:r,id:t,formId:e,key:i,defaultValue:s})=>{h.useEffect(()=>{const l=r.getElementState(t,i);q(l)&&X(s)&&r.setElementState(t,i,s)},[r,t,i,s]);const[n,o]=h.useState(r.getElementState(t,i)??s),a=h.useCallback(l=>{r.setElementState(t,i,l),o(l)},[r,t,i]),d=h.useMemo(()=>({formId:e||""}),[e]),c=h.useCallback(()=>a(s),[s,a]);return re({element:d,widgetMgr:r,onFormCleared:c}),[n,a]},ye=async({files:r,uploadClient:t,widgetMgr:e,widgetInfo:i,fragmentId:s})=>{let n=[];try{n=await t.fetchFileURLs(r)}catch(c){return{successfulUploads:[],failedUploads:r.map(l=>({file:l,error:ut(c)}))}}const o=$t(r,n),a=[],d=[];return await Promise.all(o.map(async([c,l])=>{if(!c||!l||!l.uploadUrl||!l.fileId)return{file:c,fileUrl:l,error:new Error("No upload URL found")};try{await t.uploadFile({id:l.fileId,formId:i.formId||""},l.uploadUrl,c),a.push({fileUrl:l,file:c})}catch(p){const u=ut(p);d.push({file:c,error:u})}})),e.setFileUploaderStateValue(i,new zt({uploadedFileInfo:a.map(({file:c,fileUrl:l})=>new Ht({fileId:l.fileId,fileUrls:l,name:c.name,size:c.size}))}),{fromUi:!0},s),{successfulUploads:a,failedUploads:d}},we=D("div",{target:"e1vek2b60"})(),ft=D("div",{target:"e1vek2b61"})(({theme:r,disabled:t})=>({height:r.sizes.largestElementHeight,width:"100%",background:r.colors.secondaryBg,borderRadius:r.radii.default,marginBottom:r.spacing.twoXS,display:"flex",alignItems:"center",position:"relative",paddingLeft:r.spacing.xs,paddingRight:r.spacing.sm,border:r.colors.widgetBorderColor?`${r.sizes.borderWidth} solid ${r.colors.widgetBorderColor}`:void 0,cursor:t?"not-allowed":"auto"})),Se=D("div",{target:"e1vek2b62"})({flex:1}),Ce=D("div",{target:"e1vek2b63"})(({show:r})=>({display:r?"block":"none"})),Ee=D("span",{target:"e1vek2b64"})(({theme:r,isPlayingOrRecording:t,disabled:e})=>({margin:r.spacing.sm,fontFamily:r.fonts.monospace,color:e?r.colors.fadedText40:t?r.colors.bodyText:r.colors.fadedText60,backgroundColor:r.colors.secondaryBg,fontSize:r.fontSizes.sm})),Rt=D("div",{target:"e1vek2b65"})({width:"100%",textAlign:"center",overflow:"hidden"}),Pt=D("span",{target:"e1vek2b66"})(({theme:r})=>({color:r.colors.bodyText})),Re=D("a",{target:"e1vek2b67"})(({theme:r})=>({color:r.colors.link,textDecoration:r.linkUnderline?"underline":"none"})),Pe=D("div",{target:"e1vek2b68"})(({theme:r})=>({height:r.sizes.largestElementHeight,display:"flex",justifyContent:"center",alignItems:"center"})),De=D("div",{target:"e1vek2b69"})(({theme:r})=>{const t="0.625em";return{opacity:.2,width:"100%",height:t,backgroundSize:t,backgroundImage:`radial-gradient(${r.colors.fadedText10} 40%, transparent 40%)`,backgroundRepeat:"repeat"}}),xe=D("span",{target:"e1vek2b610"})(({theme:r})=>({"& > button":{color:r.colors.primary,padding:r.spacing.threeXS},"& > button:hover, & > button:focus":{color:r.colors.red}})),ke=D("span",{target:"e1vek2b611"})(({theme:r})=>({"& > button":{padding:r.spacing.threeXS,color:r.colors.fadedText60},"& > button:hover, & > button:focus":{color:r.colors.bodyText}})),Dt=D("span",{target:"e1vek2b612"})(({theme:r})=>({"& > button":{padding:r.spacing.threeXS,color:r.colors.fadedText60},"& > button:hover, & > button:focus":{color:r.colors.bodyText}})),rt=D("div",{target:"e1vek2b613"})(({theme:r})=>({display:"flex",justifyContent:"center",alignItems:"center",flexGrow:0,flexShrink:1,padding:r.spacing.xs,gap:r.spacing.twoXS,marginRight:r.spacing.twoXS})),Ae=D("div",{target:"e1vek2b614"})(({theme:r})=>({marginLeft:r.spacing.sm})),$=({onClick:r,disabled:t,ariaLabel:e,iconContent:i})=>g(qt,{kind:jt.BORDERLESS_ICON,onClick:r,disabled:t,"aria-label":e,containerWidth:!0,"data-testid":"stAudioInputActionButton",children:g(Gt,{content:i,size:"lg",color:"inherit"})}),Te=({disabled:r,stopRecording:t})=>g(xe,{children:g($,{onClick:t,disabled:r,ariaLabel:"Stop recording",iconContent:St})}),We=({disabled:r,isPlaying:t,onClickPlayPause:e})=>g(Dt,{children:t?g($,{onClick:e,disabled:r,ariaLabel:"Pause",iconContent:bt}):g($,{onClick:e,disabled:r,ariaLabel:"Play",iconContent:yt})}),Me=({disabled:r,startRecording:t})=>g(ke,{children:g($,{onClick:t,disabled:r,ariaLabel:"Record",iconContent:gt})}),Oe=({onClick:r})=>g(Dt,{children:g($,{disabled:!1,onClick:r,ariaLabel:"Reset",iconContent:wt})}),Ie=({disabled:r,isRecording:t,isPlaying:e,isUploading:i,isError:s,recordingUrlExists:n,startRecording:o,stopRecording:a,onClickPlayPause:d,onClear:c})=>s?g(rt,{children:g(Oe,{onClick:c})}):i?g(rt,{children:g(Vt,{"aria-label":"Uploading",size:"base",margin:"0",padding:"0"})}):N(rt,{children:[t?g(Te,{disabled:r,stopRecording:a}):g(Me,{disabled:r,startRecording:o}),n&&g(We,{disabled:r,isPlaying:e,onClickPlayPause:d})]}),Le=h.memo(Ie),Be=()=>g(Rt,{children:g(Pt,{children:"An error has occurred, please try again."})}),Ne=h.memo(Be),Ue=4,Fe=4,_e=4,$e=8,ze=0,G="00:00",He=Xt.getLogger("convertAudioToWav");async function Ve(r){const t=new window.AudioContext,e=await r.arrayBuffer();let i;try{i=await t.decodeAudioData(e)}catch(m){He.error(m);return}const s=44,n=i.numberOfChannels,o=i.sampleRate,a=i.length*n*2+s,d=new ArrayBuffer(a),c=new DataView(d),l={0:{type:"string",value:"RIFF"},4:{type:"uint32",value:a-8},8:{type:"string",value:"WAVE"},12:{type:"string",value:"fmt "},16:{type:"uint32",value:16},20:{type:"uint16",value:1},22:{type:"uint16",value:n},24:{type:"uint32",value:o},28:{type:"uint32",value:o*n*2},32:{type:"uint16",value:n*2},34:{type:"uint16",value:16},36:{type:"string",value:"data"},40:{type:"uint32",value:i.length*n*2}};Object.entries(l).forEach(([m,{type:f,value:y}])=>{const v=parseInt(m,10);f==="string"?je(c,v,y):f==="uint32"?c.setUint32(v,y,!0):f==="uint16"&&c.setUint16(v,y,!0)});let p=s;for(let m=0;m<i.length;m++)for(let f=0;f<n;f++){const y=Math.max(-1,Math.min(1,i.getChannelData(f)[m]));c.setInt16(p,y*32767,!0),p+=2}const u=new Uint8Array(d);return new Blob([u],{type:"audio/wav"})}function je(r,t,e){for(let i=0;i<e.length;i++)r.setUint8(t+i,e.charCodeAt(i))}const vt=r=>{const t=Math.floor(r/1e3),e=Math.floor(t/60),i=Math.floor(e/60),s=t%60,n=e%60,o=s.toString().padStart(2,"0"),a=n.toString().padStart(2,"0"),d=i.toString().padStart(2,"0");return e<60?`${a}:${o}`:`${d}:${a}:${o}`},Ge=()=>N(Rt,{children:[g(Pt,{children:"This app would like to use your microphone."})," ",g(Re,{href:Yt,rel:"noopener noreferrer",target:"_blank",children:"Learn how to allow access."})]}),qe=h.memo(Ge),Xe=()=>g(Pe,{children:g(De,{})}),Ye=h.memo(Xe),Ke=({element:r,uploadClient:t,widgetMgr:e,fragmentId:i,disabled:s})=>{const n=Kt(),o=ae(n),[a,d]=h.useState(null),c=h.useRef(null),[l,p]=st({widgetMgr:e,id:r.id,key:"deleteFileUrl",defaultValue:null}),[u,m]=h.useState(null),[f,y]=h.useState([]),[v,S]=h.useState(null),[b,x]=st({widgetMgr:e,id:r.id,key:"recordingUrl",defaultValue:null}),[,R]=h.useState(0),w=()=>{R(C=>C+1)},[k,A]=h.useState(G),[M,T]=st({widgetMgr:e,id:r.id,formId:r.formId,key:"recordingTime",defaultValue:G}),[O,F]=h.useState(!1),[L,xt]=h.useState(!1),[nt,kt]=h.useState(!1),[At,ot]=h.useState(!1),[K,J]=h.useState(!1),at=r.id,I=r.formId,lt=h.useCallback(async C=>{ot(!0),X(I)&&e.setFormsWithUploadsInProgress(new Set([I]));let E;if(C.type==="audio/wav"?E=C:E=await Ve(C),!E){J(!0);return}const W=URL.createObjectURL(E),Bt=new Date().toISOString().slice(0,16).replace(":","-"),Nt=new File([E],`${Bt}_audio.wav`,{type:E.type});x(W),ye({files:[Nt],uploadClient:t,widgetMgr:e,widgetInfo:{id:at,formId:I},fragmentId:i}).then(({successfulUploads:Ut,failedUploads:Ft})=>{if(Ft.length>0){J(!0);return}const Z=Ut[0];Z&&Z.fileUrl.deleteUrl&&p(Z.fileUrl.deleteUrl)}).finally(()=>{X(I)&&e.setFormsWithUploadsInProgress(new Set),ot(!1)})},[x,t,e,at,I,i,p]),B=h.useCallback(({updateWidgetManager:C,deleteFile:E})=>{q(a)||q(l)||(x(null),a.empty(),E&&t.deleteFile(l),p(null),A(G),T(G),C&&e.setFileUploaderStateValue(r,{},{fromUi:!0},i),F(!1),X(b)&&URL.revokeObjectURL(b))},[l,b,t,a,r,e,i,T,x,p]);h.useEffect(()=>{if(q(I))return;const C=new ne;return C.manageFormClearListener(e,I,()=>B({updateWidgetManager:!0,deleteFile:!1})),()=>C.disconnect()},[I,B,e]);const ct=h.useCallback(()=>{if(c.current===null)return;const C=_.create({container:c.current,waveColor:b?tt(n.colors.fadedText40,n.colors.secondaryBg):n.colors.primary,progressColor:n.colors.bodyText,height:Jt(n.sizes.largestElementHeight)-2*Ue,barWidth:Fe,barGap:_e,barRadius:$e,cursorWidth:ze,url:b??void 0});C.on("timeupdate",W=>{A(vt(W*1e3))}),C.on("pause",()=>{w()});const E=C.registerPlugin(Y.create({scrollingWaveform:!1,renderRecordedAudio:!0}));return E.on("record-end",W=>{lt(W)}),E.on("record-progress",W=>{T(vt(W))}),d(C),m(E),()=>{C&&C.destroy(),E&&E.destroy()}},[lt]);h.useEffect(()=>ct(),[ct]),h.useEffect(()=>{Qt(o,n)||a?.setOptions({waveColor:b?tt(n.colors.fadedText40,n.colors.secondaryBg):n.colors.primary,progressColor:n.colors.bodyText})},[n,o,b,a]);const Tt=h.useCallback(()=>{a&&(a.playPause(),F(!0),w())},[a]),Wt=h.useCallback(async()=>{let C=v;nt||(await navigator.mediaDevices.getUserMedia({audio:!0}).then(()=>Y.getAvailableAudioDevices().then(E=>{if(y(E),E.length>0){const{deviceId:W}=E[0];S(W),C=W}})).catch(E=>{xt(!0)}),kt(!0)),!(!u||!C||!a)&&(a.setOptions({waveColor:n.colors.primary}),b&&B({updateWidgetManager:!1,deleteFile:!0}),u.startRecording({deviceId:C}).then(()=>{w()}))},[v,u,n,a,b,B,nt]),Mt=h.useCallback(()=>{u&&(u.stopRecording(),a?.setOptions({waveColor:tt(n.colors.fadedText40,n.colors.secondaryBg)}))},[u,a,n]),Ot=be(b,"recording.wav"),Q=!!u?.isRecording(),dt=!!a?.isPlaying(),It=Q||dt,ht=!Q&&!b&&!L,Lt=L||ht||K;return N(we,{className:"stAudioInput","data-testid":"stAudioInput",children:[g(ie,{label:r.label,disabled:s,labelVisibility:Zt(r.labelVisibility?.value),children:r.help&&g(Ae,{children:g(te,{content:r.help,placement:ee.TOP})})}),N(ft,{disabled:s,children:[N(se,{isFullScreen:!1,disableFullscreenMode:!0,target:ft,children:[b&&g(pt,{label:"Download as WAV",icon:le,onClick:()=>Ot()}),l&&g(pt,{label:"Clear recording",icon:ce,onClick:()=>B({updateWidgetManager:!0,deleteFile:!0})})]}),g(Le,{isRecording:Q,isPlaying:dt,isUploading:At,isError:K,recordingUrlExists:!!b,startRecording:Wt,stopRecording:Mt,onClickPlayPause:Tt,onClear:()=>{B({updateWidgetManager:!1,deleteFile:!0}),J(!1)},disabled:s||L}),N(Se,{children:[K&&g(Ne,{}),ht&&g(Ye,{}),L&&g(qe,{}),g(Ce,{"data-testid":"stAudioInputWaveSurfer",ref:c,show:!Lt})]}),g(Ee,{isPlayingOrRecording:It,disabled:s,"data-testid":"stAudioInputWaveformTimeCode",children:O?k:M})]})]})},ri=h.memo(Ke);export{ri as default};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{e as We,by as J,r as x,c2 as ht,bR as gt,bz as G,c3 as pt,c4 as vt,s as Ke,ax as mt,bJ as bt,ap as yt,aS as Tt,cv as Ot,j as ae,aE as kt,bu as wt,bL as Rt,bv as St,bc as Mt,bw as _t,J as $t,cw as _e}from"./index.DKN5MVff.js";import{s as Fe}from"./sprintf.D7DtBTRn.js";import{a as Et}from"./useBasicWidgetState.DB3vMS9V.js";import"./FormClearHelper.DF4gFAOO.js";var se={},U={},ue={},ce={},je;function $e(){if(je)return ce;je=1,Object.defineProperty(ce,"__esModule",{value:!0}),ce.Direction=void 0;var e;return function(r){r.Right="to right",r.Left="to left",r.Down="to bottom",r.Up="to top"}(e||(ce.Direction=e={})),ce}var Ve;function Xe(){return Ve||(Ve=1,function(e){var r=ue&&ue.__spreadArray||function(i,s,c){if(c||arguments.length===2)for(var m=0,R=s.length,p;m<R;m++)(p||!(m in s))&&(p||(p=Array.prototype.slice.call(s,0,m)),p[m]=s[m]);return i.concat(p||Array.prototype.slice.call(s))};Object.defineProperty(e,"__esModule",{value:!0}),e.isIOS=e.useThumbOverlap=e.assertUnreachable=e.voidFn=e.getTrackBackground=e.replaceAt=e.schd=e.translate=e.getClosestThumbIndex=e.translateThumbs=e.getPaddingAndBorder=e.getMargin=e.checkInitialOverlap=e.checkValuesAgainstBoundaries=e.checkBoundaries=e.isVertical=e.relativeValue=e.normalizeValue=e.isStepDivisible=e.isTouchEvent=e.getStepDecimals=void 0;var n=We(),o=$e(),g=function(i){var s=i.toString().split(".")[1];return s?s.length:0};e.getStepDecimals=g;function _(i){return i.touches&&i.touches.length||i.changedTouches&&i.changedTouches.length}e.isTouchEvent=_;function u(i,s,c){var m=(s-i)/c,R=8,p=Number(m.toFixed(R));return parseInt(p.toString(),10)===p}e.isStepDivisible=u;function h(i,s,c,m,R,p,O){var $=1e11;if(i=Math.round(i*$)/$,!p){var D=O[s-1],I=O[s+1];if(D&&D>i)return D;if(I&&I<i)return I}if(i>m)return m;if(i<c)return c;var N=Math.floor(i*$-c*$)%Math.floor(R*$),V=Math.floor(i*$-Math.abs(N)),q=N===0?i:V/$,P=Math.abs(N/$)<R/2?q:q+R,B=(0,e.getStepDecimals)(R);return parseFloat(P.toFixed(B))}e.normalizeValue=h;function j(i,s,c){return(i-s)/(c-s)}e.relativeValue=j;function F(i){return i===o.Direction.Up||i===o.Direction.Down}e.isVertical=F;function A(i,s,c){if(s>=c)throw new RangeError("min (".concat(s,") is equal/bigger than max (").concat(c,")"));if(i<s)throw new RangeError("value (".concat(i,") is smaller than min (").concat(s,")"));if(i>c)throw new RangeError("value (".concat(i,") is bigger than max (").concat(c,")"))}e.checkBoundaries=A;function S(i,s,c){return i<s?s:i>c?c:i}e.checkValuesAgainstBoundaries=S;function y(i){if(!(i.length<2)&&!i.slice(1).every(function(s,c){return i[c]<=s}))throw new RangeError("values={[".concat(i,"]} needs to be sorted when allowOverlap={false}"))}e.checkInitialOverlap=y;function d(i){var s=window.getComputedStyle(i);return{top:parseInt(s["margin-top"],10),bottom:parseInt(s["margin-bottom"],10),left:parseInt(s["margin-left"],10),right:parseInt(s["margin-right"],10)}}e.getMargin=d;function t(i){var s=window.getComputedStyle(i);return{top:parseInt(s["padding-top"],10)+parseInt(s["border-top-width"],10),bottom:parseInt(s["padding-bottom"],10)+parseInt(s["border-bottom-width"],10),left:parseInt(s["padding-left"],10)+parseInt(s["border-left-width"],10),right:parseInt(s["padding-right"],10)+parseInt(s["border-right-width"],10)}}e.getPaddingAndBorder=t;function a(i,s,c){var m=c?-1:1;i.forEach(function(R,p){return v(R,m*s[p].x,s[p].y)})}e.translateThumbs=a;function l(i,s,c,m){for(var R=0,p=L(i[0],s,c,m),O=1;O<i.length;O++){var $=L(i[O],s,c,m);$<p&&(p=$,R=O)}return R}e.getClosestThumbIndex=l;function v(i,s,c){i.style.transform="translate(".concat(s,"px, ").concat(c,"px)")}e.translate=v;var f=function(i){var s=[],c=null,m=function(){for(var R=[],p=0;p<arguments.length;p++)R[p]=arguments[p];s=R,!c&&(c=requestAnimationFrame(function(){c=null,i.apply(void 0,s)}))};return m};e.schd=f;function b(i,s,c){var m=i.slice(0);return m[s]=c,m}e.replaceAt=b;function E(i){var s=i.values,c=i.colors,m=i.min,R=i.max,p=i.direction,O=p===void 0?o.Direction.Right:p,$=i.rtl,D=$===void 0?!1:$;D&&O===o.Direction.Right?O=o.Direction.Left:D&&o.Direction.Left&&(O=o.Direction.Right);var I=s.slice(0).sort(function(V,q){return V-q}).map(function(V){return(V-m)/(R-m)*100}),N=I.reduce(function(V,q,P){return"".concat(V,", ").concat(c[P]," ").concat(q,"%, ").concat(c[P+1]," ").concat(q,"%")},"");return"linear-gradient(".concat(O,", ").concat(c[0]," 0%").concat(N,", ").concat(c[c.length-1]," 100%)")}e.getTrackBackground=E;function k(){}e.voidFn=k;function T(i){throw new Error("Didn't expect to get here")}e.assertUnreachable=T;var w=function(i,s,c,m,R){R===void 0&&(R=function(O){return O});var p=Math.ceil(r([i],Array.from(i.children),!0).reduce(function(O,$){var D=Math.ceil($.getBoundingClientRect().width);if($.innerText&&$.innerText.includes(c)&&$.childElementCount===0){var I=$.cloneNode(!0);I.innerHTML=R(s.toFixed(m)),I.style.visibility="hidden",document.body.appendChild(I),D=Math.ceil(I.getBoundingClientRect().width),document.body.removeChild(I)}return D>O?D:O},i.getBoundingClientRect().width));return p},C=function(i,s,c,m,R,p,O){O===void 0&&(O=function(I){return I});var $=[],D=function(I){var N=w(c[I],m[I],R,p,O),V=s[I].x;s.forEach(function(q,P){var B=q.x,Z=w(c[P],m[P],R,p,O);I!==P&&(V>=B&&V<=B+Z||V+N>=B&&V+N<=B+Z)&&($.includes(P)||($.push(I),$.push(P),$=r(r([],$,!0),[I,P],!1),D(P)))})};return D(i),Array.from(new Set($.sort()))},M=function(i,s,c,m,R,p){m===void 0&&(m=.1),R===void 0&&(R=" - "),p===void 0&&(p=function(P){return P});var O=(0,e.getStepDecimals)(m),$=(0,n.useState)({}),D=$[0],I=$[1],N=(0,n.useState)(p(s[c].toFixed(O))),V=N[0],q=N[1];return(0,n.useEffect)(function(){if(i){var P=i.getThumbs();if(P.length<1)return;var B={},Z=i.getOffsets(),re=C(c,Z,P,s,R,O,p),le=p(s[c].toFixed(O));if(re.length){var Q=re.reduce(function(ee,oe,ge,pe){return ee.length?r(r([],ee,!0),[Z[pe[ge]].x],!1):[Z[pe[ge]].x]},[]);if(Math.min.apply(Math,Q)===Z[c].x){var de=[];re.forEach(function(ee){de.push(s[ee].toFixed(O))}),le=Array.from(new Set(de.sort(function(ee,oe){return parseFloat(ee)-parseFloat(oe)}))).map(p).join(R);var fe=Math.min.apply(Math,Q),he=Math.max.apply(Math,Q),Me=P[re[Q.indexOf(he)]].getBoundingClientRect().width;B.left="".concat(Math.abs(fe-(he+Me))/2,"px"),B.transform="translate(-50%, 0)"}else B.visibility="hidden"}q(le),I(B)}},[i,s]),[V,D]};e.useThumbOverlap=M;function L(i,s,c,m){var R=i.getBoundingClientRect(),p=R.left,O=R.top,$=R.width,D=R.height;return F(m)?Math.abs(c-(O+D/2)):Math.abs(s-(p+$/2))}var H=function(){var i,s=((i=navigator.userAgentData)===null||i===void 0?void 0:i.platform)||navigator.platform;return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(s)||navigator.userAgent.includes("Mac")&&"ontouchend"in document};e.isIOS=H}(ue)),ue}var ze;function It(){if(ze)return U;ze=1;var e=U&&U.__extends||function(){var S=function(y,d){return S=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,a){t.__proto__=a}||function(t,a){for(var l in a)Object.prototype.hasOwnProperty.call(a,l)&&(t[l]=a[l])},S(y,d)};return function(y,d){if(typeof d!="function"&&d!==null)throw new TypeError("Class extends value "+String(d)+" is not a constructor or null");S(y,d);function t(){this.constructor=y}y.prototype=d===null?Object.create(d):(t.prototype=d.prototype,new t)}}(),r=U&&U.__createBinding||(Object.create?function(S,y,d,t){t===void 0&&(t=d);var a=Object.getOwnPropertyDescriptor(y,d);(!a||("get"in a?!y.__esModule:a.writable||a.configurable))&&(a={enumerable:!0,get:function(){return y[d]}}),Object.defineProperty(S,t,a)}:function(S,y,d,t){t===void 0&&(t=d),S[t]=y[d]}),n=U&&U.__setModuleDefault||(Object.create?function(S,y){Object.defineProperty(S,"default",{enumerable:!0,value:y})}:function(S,y){S.default=y}),o=U&&U.__importStar||function(S){if(S&&S.__esModule)return S;var y={};if(S!=null)for(var d in S)d!=="default"&&Object.prototype.hasOwnProperty.call(S,d)&&r(y,S,d);return n(y,S),y},g=U&&U.__spreadArray||function(S,y,d){if(d||arguments.length===2)for(var t=0,a=y.length,l;t<a;t++)(l||!(t in y))&&(l||(l=Array.prototype.slice.call(y,0,t)),l[t]=y[t]);return S.concat(l||Array.prototype.slice.call(y))};Object.defineProperty(U,"__esModule",{value:!0});var _=o(We()),u=Xe(),h=$e(),j=["ArrowRight","ArrowUp","k","PageUp"],F=["ArrowLeft","ArrowDown","j","PageDown"],A=function(S){e(y,S);function y(d){var t=S.call(this,d)||this;if(t.trackRef=_.createRef(),t.thumbRefs=[],t.state={draggedTrackPos:[-1,-1],draggedThumbIndex:-1,thumbZIndexes:new Array(t.props.values.length).fill(0).map(function(a,l){return l}),isChanged:!1,markOffsets:[]},t.getOffsets=function(){var a=t.props,l=a.direction,v=a.values,f=a.min,b=a.max,E=t.trackRef.current;if(!E)return console.warn("No track element found."),[];var k=E.getBoundingClientRect(),T=(0,u.getPaddingAndBorder)(E);return t.getThumbs().map(function(w,C){var M={x:0,y:0},L=w.getBoundingClientRect(),H=(0,u.getMargin)(w);switch(l){case h.Direction.Right:return M.x=(H.left+T.left)*-1,M.y=((L.height-k.height)/2+T.top)*-1,M.x+=k.width*(0,u.relativeValue)(v[C],f,b)-L.width/2,M;case h.Direction.Left:return M.x=(H.right+T.right)*-1,M.y=((L.height-k.height)/2+T.top)*-1,M.x+=k.width-k.width*(0,u.relativeValue)(v[C],f,b)-L.width/2,M;case h.Direction.Up:return M.x=((L.width-k.width)/2+H.left+T.left)*-1,M.y=-T.left,M.y+=k.height-k.height*(0,u.relativeValue)(v[C],f,b)-L.height/2,M;case h.Direction.Down:return M.x=((L.width-k.width)/2+H.left+T.left)*-1,M.y=-T.left,M.y+=k.height*(0,u.relativeValue)(v[C],f,b)-L.height/2,M;default:return(0,u.assertUnreachable)(l)}})},t.getThumbs=function(){return t.trackRef&&t.trackRef.current?Array.from(t.trackRef.current.children).filter(function(a){return a.hasAttribute("aria-valuenow")}):(console.warn("No thumbs found in the track container. Did you forget to pass & spread the `props` param in renderTrack?"),[])},t.getTargetIndex=function(a){return t.getThumbs().findIndex(function(l){return l===a.target||l.contains(a.target)})},t.addTouchEvents=function(a){document.addEventListener("touchmove",t.schdOnTouchMove,{passive:!1}),document.addEventListener("touchend",t.schdOnEnd,{passive:!1}),document.addEventListener("touchcancel",t.schdOnEnd,{passive:!1})},t.addMouseEvents=function(a){document.addEventListener("mousemove",t.schdOnMouseMove),document.addEventListener("mouseup",t.schdOnEnd)},t.onMouseDownTrack=function(a){var l;if(!(a.button!==0||(0,u.isIOS)()))if(a.persist(),a.preventDefault(),t.addMouseEvents(a.nativeEvent),t.props.values.length>1&&t.props.draggableTrack){if(t.thumbRefs.some(function(f){var b;return(b=f.current)===null||b===void 0?void 0:b.contains(a.target)}))return;t.setState({draggedTrackPos:[a.clientX,a.clientY]},function(){return t.onMove(a.clientX,a.clientY)})}else{var v=(0,u.getClosestThumbIndex)(t.thumbRefs.map(function(f){return f.current}),a.clientX,a.clientY,t.props.direction);(l=t.thumbRefs[v].current)===null||l===void 0||l.focus(),t.setState({draggedThumbIndex:v},function(){return t.onMove(a.clientX,a.clientY)})}},t.onResize=function(){(0,u.translateThumbs)(t.getThumbs(),t.getOffsets(),t.props.rtl),t.calculateMarkOffsets()},t.onTouchStartTrack=function(a){var l;if(a.persist(),t.addTouchEvents(a.nativeEvent),t.props.values.length>1&&t.props.draggableTrack){if(t.thumbRefs.some(function(f){var b;return(b=f.current)===null||b===void 0?void 0:b.contains(a.target)}))return;t.setState({draggedTrackPos:[a.touches[0].clientX,a.touches[0].clientY]},function(){return t.onMove(a.touches[0].clientX,a.touches[0].clientY)})}else{var v=(0,u.getClosestThumbIndex)(t.thumbRefs.map(function(f){return f.current}),a.touches[0].clientX,a.touches[0].clientY,t.props.direction);(l=t.thumbRefs[v].current)===null||l===void 0||l.focus(),t.setState({draggedThumbIndex:v},function(){return t.onMove(a.touches[0].clientX,a.touches[0].clientY)})}},t.onMouseOrTouchStart=function(a){if(!t.props.disabled){var l=(0,u.isTouchEvent)(a);if(!(!l&&a.button!==0)){var v=t.getTargetIndex(a);v!==-1&&(l?t.addTouchEvents(a):t.addMouseEvents(a),t.setState({draggedThumbIndex:v,thumbZIndexes:t.state.thumbZIndexes.map(function(f,b){return b===v?Math.max.apply(Math,t.state.thumbZIndexes):f<=t.state.thumbZIndexes[v]?f:f-1})}))}}},t.onMouseMove=function(a){a.preventDefault(),t.onMove(a.clientX,a.clientY)},t.onTouchMove=function(a){a.preventDefault(),t.onMove(a.touches[0].clientX,a.touches[0].clientY)},t.onKeyDown=function(a){var l=t.props,v=l.values,f=l.onChange,b=l.step,E=l.rtl,k=l.direction,T=t.state.isChanged,w=t.getTargetIndex(a.nativeEvent),C=E||k===h.Direction.Left||k===h.Direction.Down?-1:1;w!==-1&&(j.includes(a.key)?(a.preventDefault(),t.setState({draggedThumbIndex:w,isChanged:!0}),f((0,u.replaceAt)(v,w,t.normalizeValue(v[w]+C*(a.key==="PageUp"?b*10:b),w)))):F.includes(a.key)?(a.preventDefault(),t.setState({draggedThumbIndex:w,isChanged:!0}),f((0,u.replaceAt)(v,w,t.normalizeValue(v[w]-C*(a.key==="PageDown"?b*10:b),w)))):a.key==="Tab"?t.setState({draggedThumbIndex:-1},function(){T&&t.fireOnFinalChange()}):T&&t.fireOnFinalChange())},t.onKeyUp=function(a){var l=t.state.isChanged;t.setState({draggedThumbIndex:-1},function(){l&&t.fireOnFinalChange()})},t.onMove=function(a,l){var v=t.state,f=v.draggedThumbIndex,b=v.draggedTrackPos,E=t.props,k=E.direction,T=E.min,w=E.max,C=E.onChange,M=E.values,L=E.step,H=E.rtl;if(f===-1&&b[0]===-1&&b[1]===-1)return null;var i=t.trackRef.current;if(!i)return null;var s=i.getBoundingClientRect(),c=(0,u.isVertical)(k)?s.height:s.width;if(b[0]!==-1&&b[1]!==-1){var m=a-b[0],R=l-b[1],p=0;switch(k){case h.Direction.Right:case h.Direction.Left:p=m/c*(w-T);break;case h.Direction.Down:case h.Direction.Up:p=R/c*(w-T);break;default:(0,u.assertUnreachable)(k)}if(H&&(p*=-1),Math.abs(p)>=L/2){for(var O=0;O<t.thumbRefs.length;O++){if(M[O]===w&&Math.sign(p)===1||M[O]===T&&Math.sign(p)===-1)return;var $=M[O]+p;$>w?p=w-M[O]:$<T&&(p=T-M[O])}for(var D=M.slice(0),O=0;O<t.thumbRefs.length;O++)D=(0,u.replaceAt)(D,O,t.normalizeValue(M[O]+p,O));t.setState({draggedTrackPos:[a,l]}),C(D)}}else{var I=0;switch(k){case h.Direction.Right:I=(a-s.left)/c*(w-T)+T;break;case h.Direction.Left:I=(c-(a-s.left))/c*(w-T)+T;break;case h.Direction.Down:I=(l-s.top)/c*(w-T)+T;break;case h.Direction.Up:I=(c-(l-s.top))/c*(w-T)+T;break;default:(0,u.assertUnreachable)(k)}H&&(I=w+T-I),Math.abs(M[f]-I)>=L/2&&C((0,u.replaceAt)(M,f,t.normalizeValue(I,f)))}},t.normalizeValue=function(a,l){var v=t.props,f=v.min,b=v.max,E=v.step,k=v.allowOverlap,T=v.values;return(0,u.normalizeValue)(a,l,f,b,E,k,T)},t.onEnd=function(a){if(a.preventDefault(),document.removeEventListener("mousemove",t.schdOnMouseMove),document.removeEventListener("touchmove",t.schdOnTouchMove),document.removeEventListener("mouseup",t.schdOnEnd),document.removeEventListener("touchend",t.schdOnEnd),document.removeEventListener("touchcancel",t.schdOnEnd),t.state.draggedThumbIndex===-1&&t.state.draggedTrackPos[0]===-1&&t.state.draggedTrackPos[1]===-1)return null;t.setState({draggedThumbIndex:-1,draggedTrackPos:[-1,-1]},function(){t.fireOnFinalChange()})},t.fireOnFinalChange=function(){t.setState({isChanged:!1});var a=t.props,l=a.onFinalChange,v=a.values;l&&l(v)},t.updateMarkRefs=function(a){if(!a.renderMark){t.numOfMarks=void 0,t.markRefs=void 0;return}t.numOfMarks=(a.max-a.min)/t.props.step,t.markRefs=[];for(var l=0;l<t.numOfMarks+1;l++)t.markRefs[l]=_.createRef()},t.calculateMarkOffsets=function(){if(!(!t.props.renderMark||!t.trackRef||!t.numOfMarks||!t.markRefs||t.trackRef.current===null)){for(var a=window.getComputedStyle(t.trackRef.current),l=parseInt(a.width,10),v=parseInt(a.height,10),f=parseInt(a.paddingLeft,10),b=parseInt(a.paddingTop,10),E=[],k=0;k<t.numOfMarks+1;k++){var T=9999,w=9999;if(t.markRefs[k].current){var C=t.markRefs[k].current.getBoundingClientRect();T=C.height,w=C.width}t.props.direction===h.Direction.Left||t.props.direction===h.Direction.Right?E.push([Math.round(l/t.numOfMarks*k+f-w/2),-Math.round((T-v)/2)]):E.push([Math.round(v/t.numOfMarks*k+b-T/2),-Math.round((w-l)/2)])}t.setState({markOffsets:E})}},d.step===0)throw new Error('"step" property should be a positive number');return t.schdOnMouseMove=(0,u.schd)(t.onMouseMove),t.schdOnTouchMove=(0,u.schd)(t.onTouchMove),t.schdOnEnd=(0,u.schd)(t.onEnd),t.thumbRefs=d.values.map(function(){return _.createRef()}),t.updateMarkRefs(d),t}return y.prototype.componentDidMount=function(){var d=this,t=this.props,a=t.values,l=t.min,v=t.step;this.resizeObserver=window.ResizeObserver?new window.ResizeObserver(this.onResize):{observe:function(){return window.addEventListener("resize",d.onResize)},unobserve:function(){return window.removeEventListener("resize",d.onResize)}},document.addEventListener("touchstart",this.onMouseOrTouchStart,{passive:!1}),document.addEventListener("mousedown",this.onMouseOrTouchStart,{passive:!1}),!this.props.allowOverlap&&(0,u.checkInitialOverlap)(this.props.values),this.props.values.forEach(function(f){return(0,u.checkBoundaries)(f,d.props.min,d.props.max)}),this.resizeObserver.observe(this.trackRef.current),(0,u.translateThumbs)(this.getThumbs(),this.getOffsets(),this.props.rtl),this.calculateMarkOffsets(),a.forEach(function(f){(0,u.isStepDivisible)(l,f,v)||console.warn("The `values` property is in conflict with the current `step`, `min`, and `max` properties. Please provide values that are accessible using the min, max, and step values.")})},y.prototype.componentDidUpdate=function(d,t){var a=this.props,l=a.max,v=a.min,f=a.step,b=a.values,E=a.rtl;(d.max!==l||d.min!==v||d.step!==f)&&this.updateMarkRefs(this.props),(0,u.translateThumbs)(this.getThumbs(),this.getOffsets(),E),(d.max!==l||d.min!==v||d.step!==f||t.markOffsets.length!==this.state.markOffsets.length)&&(this.calculateMarkOffsets(),b.forEach(function(k){(0,u.isStepDivisible)(v,k,f)||console.warn("The `values` property is in conflict with the current `step`, `min`, and `max` properties. Please provide values that are accessible using the min, max, and step values.")}))},y.prototype.componentWillUnmount=function(){var d={passive:!1};document.removeEventListener("mousedown",this.onMouseOrTouchStart,d),document.removeEventListener("mousemove",this.schdOnMouseMove),document.removeEventListener("touchmove",this.schdOnTouchMove),document.removeEventListener("touchstart",this.onMouseOrTouchStart),document.removeEventListener("mouseup",this.schdOnEnd),document.removeEventListener("touchend",this.schdOnEnd),this.resizeObserver.unobserve(this.trackRef.current)},y.prototype.render=function(){var d=this,t=this.props,a=t.label,l=t.labelledBy,v=t.renderTrack,f=t.renderThumb,b=t.renderMark,E=b===void 0?function(){return null}:b,k=t.values,T=t.min,w=t.max,C=t.allowOverlap,M=t.disabled,L=this.state,H=L.draggedThumbIndex,i=L.thumbZIndexes,s=L.markOffsets;return v({props:{style:{transform:"scale(1)",cursor:H>-1?"grabbing":this.props.draggableTrack?(0,u.isVertical)(this.props.direction)?"ns-resize":"ew-resize":k.length===1&&!M?"pointer":"inherit"},onMouseDown:M?u.voidFn:this.onMouseDownTrack,onTouchStart:M?u.voidFn:this.onTouchStartTrack,ref:this.trackRef},isDragged:this.state.draggedThumbIndex>-1,disabled:M,children:g(g([],s.map(function(c,m,R){return E({props:{style:d.props.direction===h.Direction.Left||d.props.direction===h.Direction.Right?{position:"absolute",left:"".concat(c[0],"px"),marginTop:"".concat(c[1],"px")}:{position:"absolute",top:"".concat(c[0],"px"),marginLeft:"".concat(c[1],"px")},key:"mark".concat(m),ref:d.markRefs[m]},index:m})}),!0),k.map(function(c,m){var R=d.state.draggedThumbIndex===m;return f({index:m,value:c,isDragged:R,props:{style:{position:"absolute",zIndex:i[m],cursor:M?"inherit":R?"grabbing":"grab",userSelect:"none",touchAction:"none",WebkitUserSelect:"none",MozUserSelect:"none",msUserSelect:"none"},key:m,tabIndex:M?void 0:0,"aria-valuemax":C?w:k[m+1]||w,"aria-valuemin":C?T:k[m-1]||T,"aria-valuenow":c,draggable:!1,ref:d.thumbRefs[m],"aria-label":a,"aria-labelledby":l,role:"slider",onKeyDown:M?u.voidFn:d.onKeyDown,onKeyUp:M?u.voidFn:d.onKeyUp}})}),!0)})},y.defaultProps={label:"Accessibility label",labelledBy:null,step:1,direction:h.Direction.Right,rtl:!1,disabled:!1,allowOverlap:!1,draggableTrack:!1,min:0,max:100},y}(_.Component);return U.default=A,U}var Ne;function xt(){return Ne||(Ne=1,function(e){var r=se&&se.__importDefault||function(_){return _&&_.__esModule?_:{default:_}};Object.defineProperty(e,"__esModule",{value:!0}),e.checkValuesAgainstBoundaries=e.relativeValue=e.useThumbOverlap=e.Direction=e.getTrackBackground=e.Range=void 0;var n=r(It());e.Range=n.default;var o=Xe();Object.defineProperty(e,"getTrackBackground",{enumerable:!0,get:function(){return o.getTrackBackground}}),Object.defineProperty(e,"useThumbOverlap",{enumerable:!0,get:function(){return o.useThumbOverlap}}),Object.defineProperty(e,"relativeValue",{enumerable:!0,get:function(){return o.relativeValue}}),Object.defineProperty(e,"checkValuesAgainstBoundaries",{enumerable:!0,get:function(){return o.checkValuesAgainstBoundaries}});var g=$e();Object.defineProperty(e,"Direction",{enumerable:!0,get:function(){return g.Direction}})}(se)),se}var Ye=xt();function Ue(e,r){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);r&&(o=o.filter(function(g){return Object.getOwnPropertyDescriptor(e,g).enumerable})),n.push.apply(n,o)}return n}function ve(e){for(var r=1;r<arguments.length;r++){var n=arguments[r]!=null?arguments[r]:{};r%2?Ue(Object(n),!0).forEach(function(o){Ct(e,o,n[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ue(Object(n)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(n,o))})}return e}function Ct(e,r,n){return r in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,e}var me=J("div",{position:"relative",width:"100%"});me.displayName="Root";me.displayName="Root";me.displayName="StyledRoot";var be=J("div",function(e){var r=e.$theme,n=e.$value,o=n===void 0?[]:n,g=e.$disabled,_=e.$isDragged,u=r.sizing,h="inherit";return g?h="not-allowed":_?h="grabbing":o.length===1&&(h="pointer"),{paddingTop:u.scale600,paddingBottom:u.scale600,paddingRight:u.scale600,paddingLeft:u.scale600,display:"flex",cursor:h,backgroundColor:r.colors.sliderTrackFill}});be.displayName="Track";be.displayName="Track";be.displayName="StyledTrack";var ye=J("div",function(e){var r=e.$theme,n=e.$value,o=n===void 0?[]:n,g=e.$min,_=e.$max,u=e.$disabled,h=r.colors,j=r.borders,F=r.direction,A=r.borders.useRoundedCorners?j.radius100:0;return{borderTopLeftRadius:A,borderTopRightRadius:A,borderBottomRightRadius:A,borderBottomLeftRadius:A,background:Ye.getTrackBackground({values:o,colors:o.length===1?[u?h.borderOpaque:h.primary,u?h.backgroundSecondary:h.borderOpaque]:[u?h.backgroundSecondary:h.borderOpaque,u?h.borderOpaque:h.primary,u?h.backgroundSecondary:h.borderOpaque],min:g||0,max:_||0,rtl:F==="rtl"}),height:"2px",width:"100%",alignSelf:"center",cursor:u?"not-allowed":"inherit"}});ye.displayName="InnerTrack";ye.displayName="InnerTrack";ye.displayName="StyledInnerTrack";var Te=J("div",function(e){return{width:"4px",height:"2px",backgroundColor:e.$theme.colors.backgroundPrimary,marginLeft:"16px"}});Te.displayName="Mark";Te.displayName="Mark";Te.displayName="StyledMark";var Oe=J("div",function(e){return ve(ve({},e.$theme.typography.font200),{},{color:e.$theme.colors.contentPrimary})});Oe.displayName="Tick";Oe.displayName="Tick";Oe.displayName="StyledTick";var ke=J("div",function(e){var r=e.$theme,n=r.sizing;return{display:"flex",justifyContent:"space-between",alignItems:"center",paddingRight:n.scale600,paddingLeft:n.scale600,paddingBottom:n.scale400}});ke.displayName="TickBar";ke.displayName="TickBar";ke.displayName="StyledTickBar";var we=J("div",function(e){var r=e.$theme,n=e.$value,o=n===void 0?[]:n,g=e.$thumbIndex,_=e.$disabled,u=o.length===2&&g===0,h=o.length===2&&g===1;return r.direction==="rtl"&&(h||u)&&(u=!u,h=!h),{height:"24px",width:"24px",borderTopLeftRadius:"24px",borderTopRightRadius:"24px",borderBottomLeftRadius:"24px",borderBottomRightRadius:"24px",display:"flex",justifyContent:"center",alignItems:"center",backgroundColor:_?r.colors.sliderHandleFillDisabled:r.colors.sliderHandleFill,outline:"none",boxShadow:e.$isFocusVisible?"0 0 0 3px ".concat(r.colors.accent):"0 1px 4px rgba(0, 0, 0, 0.12)",cursor:_?"not-allowed":"inherit"}});we.displayName="Thumb";we.displayName="Thumb";we.displayName="StyledThumb";var Re=J("div",function(e){var r=e.$disabled,n=e.$theme;return{position:"absolute",top:"-16px",width:"4px",height:"20px",backgroundColor:r?n.colors.sliderHandleFillDisabled:n.colors.sliderHandleInnerFill}});Re.displayName="InnerThumb";Re.displayName="InnerThumb";Re.displayName="StyledInnerThumb";var Se=J("div",function(e){var r=e.$disabled,n=e.$theme;return ve(ve({position:"absolute",top:"-".concat(n.sizing.scale1400)},n.typography.font200),{},{backgroundColor:r?n.colors.sliderHandleFillDisabled:n.colors.sliderHandleInnerFill,color:n.colors.contentInversePrimary,paddingLeft:n.sizing.scale600,paddingRight:n.sizing.scale600,paddingTop:n.sizing.scale500,paddingBottom:n.sizing.scale500,borderBottomLeftRadius:"48px",borderBottomRightRadius:"48px",borderTopLeftRadius:"48px",borderTopRightRadius:"48px",whiteSpace:"nowrap"})});Se.displayName="ThumbValue";Se.displayName="ThumbValue";Se.displayName="StyledThumbValue";function He(e,r){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);r&&(o=o.filter(function(g){return Object.getOwnPropertyDescriptor(e,g).enumerable})),n.push.apply(n,o)}return n}function Dt(e){for(var r=1;r<arguments.length;r++){var n=arguments[r]!=null?arguments[r]:{};r%2?He(Object(n),!0).forEach(function(o){Pt(e,o,n[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):He(Object(n)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(n,o))})}return e}function Pt(e,r,n){return r in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,e}function X(){return X=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var n=arguments[r];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e},X.apply(this,arguments)}function K(e,r){return Ft(e)||Lt(e,r)||At(e,r)||Bt()}function Bt(){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 At(e,r){if(e){if(typeof e=="string")return qe(e,r);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return qe(e,r)}}function qe(e,r){(r==null||r>e.length)&&(r=e.length);for(var n=0,o=new Array(r);n<r;n++)o[n]=e[n];return o}function Lt(e,r){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var o=[],g=!0,_=!1,u,h;try{for(n=n.call(e);!(g=(u=n.next()).done)&&(o.push(u.value),!(r&&o.length===r));g=!0);}catch(j){_=!0,h=j}finally{try{!g&&n.return!=null&&n.return()}finally{if(_)throw h}}return o}}function Ft(e){if(Array.isArray(e))return e}var jt=function(r){if(r.length>2||r.length===0)throw new Error("the value prop represents positions of thumbs, so its length can be only one or two");return r};function Vt(e){var r=e.overrides,n=r===void 0?{}:r,o=e.disabled,g=o===void 0?!1:o,_=e.marks,u=_===void 0?!1:_,h=e.onChange,j=h===void 0?function(){}:h,F=e.onFinalChange,A=F===void 0?function(){}:F,S=e.min,y=S===void 0?0:S,d=e.max,t=d===void 0?100:d,a=e.step,l=a===void 0?1:a,v=e.persistentThumb,f=v===void 0?!1:v,b=e.valueToLabel,E=b===void 0?function(Y){return Y}:b,k=e.value,T=x.useContext(ht),w=x.useState(!1),C=K(w,2),M=C[0],L=C[1],H=x.useState(!1),i=K(H,2),s=i[0],c=i[1],m=x.useState(!1),R=K(m,2),p=R[0],O=R[1],$=x.useState(-1),D=K($,2),I=D[0],N=D[1],V=x.useCallback(function(Y){gt(Y)&&O(!0);var z=Y.target.parentNode.firstChild===Y.target?0:1;N(z)},[]),q=x.useCallback(function(Y){p!==!1&&O(!1),N(-1)},[]),P=jt(k),B={$disabled:g,$step:l,$min:y,$max:t,$marks:u,$value:P,$isFocusVisible:p},Z=G(n.Root,me),re=K(Z,2),le=re[0],Q=re[1],de=G(n.Track,be),fe=K(de,2),he=fe[0],Me=fe[1],ee=G(n.InnerTrack,ye),oe=K(ee,2),ge=oe[0],pe=oe[1],Ze=G(n.Thumb,we),Ee=K(Ze,2),Ge=Ee[0],Je=Ee[1],Qe=G(n.InnerThumb,Re),Ie=K(Qe,2),et=Ie[0],tt=Ie[1],rt=G(n.ThumbValue,Se),xe=K(rt,2),nt=xe[0],at=xe[1],it=G(n.Tick,Oe),Ce=K(it,2),De=Ce[0],Pe=Ce[1],ot=G(n.TickBar,ke),Be=K(ot,2),st=Be[0],ut=Be[1],ct=G(n.Mark,Te),Ae=K(ct,2),lt=Ae[0],dt=Ae[1];return x.createElement(le,X({"data-baseweb":"slider"},B,Q,{onFocus:vt(Q,V),onBlur:pt(Q,q)}),x.createElement(Ye.Range,X({step:l,min:y,max:t,values:P,disabled:g,onChange:function(z){return j({value:z})},onFinalChange:function(z){return A({value:z})},rtl:T.direction==="rtl",renderTrack:function(z){var te=z.props,W=z.children,ne=z.isDragged;return x.createElement(he,X({onMouseDown:te.onMouseDown,onTouchStart:te.onTouchStart,$isDragged:ne},B,Me),x.createElement(ge,X({$isDragged:ne,ref:te.ref},B,pe),W))},renderThumb:function(z){var te=z.props,W=z.index,ne=z.isDragged,Le=f||(!!W&&s||!W&&M||ne)&&!g;return x.createElement(Ge,X({},te,{onMouseEnter:function(){W===0?L(!0):c(!0)},onMouseLeave:function(){W===0?L(!1):c(!1)},$thumbIndex:W,$isDragged:ne,style:Dt({},te.style)},B,Je,{$isFocusVisible:p&&I===W}),Le&&x.createElement(nt,X({$thumbIndex:W,$isDragged:ne},B,at),E(P[W])),Le&&x.createElement(et,X({$thumbIndex:W,$isDragged:ne},B,tt)))}},u?{renderMark:function(z){var te=z.props,W=z.index;return x.createElement(lt,X({$markIndex:W},te,B,dt))}}:{})),x.createElement(st,X({},B,ut),x.createElement(De,X({},B,Pe),E(y)),x.createElement(De,X({},B,Pe),E(t))))}const zt=Ke("div",{target:"e43yrtf0"})(({disabled:e,theme:r})=>({alignItems:"center",backgroundColor:e?r.colors.gray:r.colors.primary,borderTopLeftRadius:"100%",borderTopRightRadius:"100%",borderBottomLeftRadius:"100%",borderBottomRightRadius:"100%",borderTopStyle:"none",borderBottomStyle:"none",borderRightStyle:"none",borderLeftStyle:"none",boxShadow:"none",display:"flex",justifyContent:"center",height:r.sizes.sliderThumb,width:r.sizes.sliderThumb,":focus":{outline:"none"},":focus-visible":{boxShadow:`0 0 0 0.2rem ${mt(r.colors.primary,.5)}`}})),Nt=Ke("div",{target:"e43yrtf1"})(({disabled:e,theme:r})=>({fontFamily:r.genericFonts.bodyFont,fontSize:r.fontSizes.sm,color:e?r.colors.gray:r.colors.primary,top:"-1.6em",position:"absolute",whiteSpace:"nowrap",backgroundColor:r.colors.transparent,lineHeight:r.lineHeights.base,fontWeight:r.fontWeights.normal,pointerEvents:"none"})),Ut=200;function Ht({disabled:e,element:r,widgetMgr:n,fragmentId:o}){const[g,_]=Et({getStateFromWidgetMgr:qt,getDefaultStateFromProto:Wt,getCurrStateFromProto:Kt,updateWidgetMgrState:Xt,element:r,widgetMgr:n,fragmentId:o}),[u,h]=x.useState(g),j=x.useRef(null),[F]=x.useState([]),[A]=x.useState([]),S=yt(),y=u.map(f=>Zt(f,r)),d=r.label;x.useEffect(()=>{h(g)},[g]);const t=x.useCallback(Tt(Ut,f=>{_({value:f,fromUi:!0})}),[]),a=x.useCallback(({value:f})=>{h(f),t(f)},[t]),l=x.useCallback(x.forwardRef(function(b,E){const{$thumbIndex:k}=b,T=k||0;F[T]=E,A[T]||=x.createRef();const w=Ot(b,["role","style","aria-valuemax","aria-valuemin","aria-valuenow","tabIndex","onKeyUp","onKeyDown","onMouseEnter","onMouseLeave","draggable"]),C=y[T];return ae(zt,{...w,disabled:b.$disabled===!0,ref:F[T],"aria-valuetext":C,"aria-label":d,children:ae(Nt,{"data-testid":"stSliderThumbValue",disabled:b.$disabled===!0,ref:A[T],children:C})})}),[]);x.useEffect(()=>{A.map((w,C)=>{w.current&&(w.current.innerText=y[C])}),F.map((w,C)=>{w.current&&w.current.setAttribute("aria-valuetext",y[C])});const f=j.current??null,b=F[0].current,E=F[1]?.current,k=A[0].current,T=A[1]?.current;Jt(f,b,E,k,T)});const v=x.useCallback(({$disabled:f})=>({height:S.spacing.twoXS,...f?{background:S.colors.darkenedBgMix25}:{}}),[S.colors.darkenedBgMix25,S.spacing.twoXS]);return kt("div",{ref:j,className:"stSlider","data-testid":"stSlider",children:[ae(_t,{label:r.label,disabled:e,labelVisibility:wt(r.labelVisibility?.value),children:r.help&&ae(Rt,{children:ae(St,{content:r.help,placement:Mt.TOP_RIGHT})})}),ae(Vt,{min:r.min,max:r.max,step:r.step,value:Gt(u,r),onChange:a,disabled:e,overrides:{Thumb:l,Track:{style:{backgroundColor:"none !important",paddingLeft:S.spacing.none,paddingRight:S.spacing.none,paddingTop:`calc((${S.sizes.minElementHeight} - ${S.spacing.twoXS}) / 2)`,paddingBottom:`calc((${S.sizes.minElementHeight} - ${S.spacing.twoXS}) / 2)`}},InnerTrack:{style:v},TickBar:()=>null}})]})}function qt(e,r){return e.getDoubleArrayValue(r)}function Wt(e){return e.default}function Kt(e){return e.value}function Xt(e,r,n,o){r.setDoubleArrayValue(e,n.value,{fromUi:n.fromUi},o)}function Yt(e){const{dataType:r}=e;return r===_e.DataType.DATETIME||r===_e.DataType.DATE||r===_e.DataType.TIME}function Zt(e,r){const{format:n,options:o}=r;return Yt(r)?$t.utc(e/1e3).format(n):o.length>0?Fe.sprintf(n,o[e]):Fe.sprintf(n,e)}function Gt(e,r){const{min:n,max:o}=r;let g=e[0],_=e.length>1?e[1]:e[0];return g>_&&(g=_),g<n&&(g=n),g>o&&(g=o),_<n&&(_=n),_>o&&(_=o),e.length>1?[g,_]:[g]}function Jt(e,r,n,o,g){!e||!r||!o||(ie(e,r,o),n&&g&&(ie(e,n,g),Qt(e,r,n,o,g)))}function ie(e,r,n){const o=e.getBoundingClientRect(),g=r.getBoundingClientRect(),_=n.getBoundingClientRect(),u=g.left+g.width/2,h=u-_.width/2<o.left,j=u+_.width/2>o.right;n.style.left=h?"0":"",n.style.right=j?"0":""}function Qt(e,r,n,o,g){const u=e.getBoundingClientRect(),h=r.getBoundingClientRect(),j=n.getBoundingClientRect(),F=o.getBoundingClientRect(),A=g.getBoundingClientRect(),S=u.left+u.width/2,y=h.left+h.width/2,d=j.left+j.width/2,t=y-F.width/2>=u.left,a=d+A.width/2<=u.right,l=h.left-F.width>=u.left,v=j.right+A.width<=u.right,f=t?F.width/2:F.width,b=a?A.width/2:A.width,E=y+f;if(d-b-E>24){ie(e,r,o),ie(e,n,g);return}if(l&&v){o.style.left="",o.style.right=`${Math.round(h.width)}px`,g.style.left=`${Math.round(j.width)}px`,g.style.right="";return}y<S?(ie(e,r,o),g.style.left=`${Math.round(y+f+24-d)}px`,g.style.right=""):(ie(e,n,g),o.style.left="",o.style.right=`${-Math.round(d-b-24-y)}px`)}const ar=bt(x.memo(Ht));export{ar as default};
|