streamlit-nightly 1.44.2.dev20250415__py3-none-any.whl → 1.44.2.dev20250416__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.
Files changed (78) hide show
  1. streamlit/__init__.py +5 -1
  2. streamlit/elements/lib/file_uploader_utils.py +3 -2
  3. streamlit/static/index.html +1 -1
  4. streamlit/static/static/js/{ErrorOutline.esm.DpSDsEwX.js → ErrorOutline.esm.BYHxp3m6.js} +1 -1
  5. streamlit/static/static/js/{FileDownload.esm.DRAkCta9.js → FileDownload.esm.ApdK5yXz.js} +1 -1
  6. streamlit/static/static/js/{FileHelper.B8weo4vC.js → FileHelper.GdWJakHI.js} +1 -1
  7. streamlit/static/static/js/{FormClearHelper.D-LphorD.js → FormClearHelper.DJyHVHSH.js} +1 -1
  8. streamlit/static/static/js/{Hooks.Bi7tTkGd.js → Hooks.ChGPcfs_.js} +1 -1
  9. streamlit/static/static/js/{InputInstructions.CfaxjFap.js → InputInstructions.BXUos__H.js} +1 -1
  10. streamlit/static/static/js/{ProgressBar.B4UgMGDS.js → ProgressBar.OOqvhQG5.js} +1 -1
  11. streamlit/static/static/js/{RenderInPortalIfExists.Cyv8zNLx.js → RenderInPortalIfExists.CyUrss_J.js} +1 -1
  12. streamlit/static/static/js/{Toolbar.CCh_4t83.js → Toolbar.BHMuD9RK.js} +1 -1
  13. streamlit/static/static/js/{base-input.DQIDgbB-.js → base-input.DDkkgpGf.js} +1 -1
  14. streamlit/static/static/js/{checkbox.CFH_6mHD.js → checkbox.MhC8ubRB.js} +1 -1
  15. streamlit/static/static/js/{createSuper.D4-ztb_I.js → createSuper.CqhU4QuZ.js} +1 -1
  16. streamlit/static/static/js/{data-grid-overlay-editor.Bh5xenBN.js → data-grid-overlay-editor.BBwX0oOt.js} +1 -1
  17. streamlit/static/static/js/{downloader.BLirGk7N.js → downloader.DXPcTUFo.js} +1 -1
  18. streamlit/static/static/js/{es6.an6cInSd.js → es6.CEXDu3sA.js} +2 -2
  19. streamlit/static/static/js/{iframeResizer.contentWindow.BqW3H8tT.js → iframeResizer.contentWindow.DWm0kUUF.js} +1 -1
  20. streamlit/static/static/js/{index.B4mz1g3p.js → index.6b1mTySV.js} +1 -1
  21. streamlit/static/static/js/{index.Czs3SnEY.js → index.B-O_wE0K.js} +1 -1
  22. streamlit/static/static/js/{index.DN_iIZPM.js → index.B06gV0xU.js} +1 -1
  23. streamlit/static/static/js/{index.BX7m08G2.js → index.B09m8ltk.js} +1 -1
  24. streamlit/static/static/js/{index.BNrCbTAI.js → index.B1th2sQW.js} +1 -1
  25. streamlit/static/static/js/{index.Bh4ilwGH.js → index.BN-Cqjtr.js} +1 -1
  26. streamlit/static/static/js/{index.BBeK6_p7.js → index.BU77_yo5.js} +1 -1
  27. streamlit/static/static/js/{index.DlLtTPOa.js → index.BYF0MjVi.js} +1 -1
  28. streamlit/static/static/js/{index.BqDL9XdN.js → index.BghhhCL1.js} +2 -2
  29. streamlit/static/static/js/{index.DPHQ-k-c.js → index.BlpjlGOL.js} +1 -1
  30. streamlit/static/static/js/{index.D84g5Ioc.js → index.BmtdqFfB.js} +1 -1
  31. streamlit/static/static/js/{index.BEVtO2Ts.js → index.C6wX31--.js} +1 -1
  32. streamlit/static/static/js/{index.Bg2Se7Yz.js → index.CPLoBLa6.js} +1 -1
  33. streamlit/static/static/js/index.Ch1zIHG2.js +1 -0
  34. streamlit/static/static/js/{index.RaDZFZ7O.js → index.CsUhYot_.js} +1 -1
  35. streamlit/static/static/js/{index.ONaU2JWb.js → index.Cwa6nJdn.js} +1 -1
  36. streamlit/static/static/js/{index.DIzecMyl.js → index.CwjEdNBc.js} +1 -1
  37. streamlit/static/static/js/{index.fQ7ekjBK.js → index.Cy9Ir-PP.js} +1 -1
  38. streamlit/static/static/js/{index.j2U8rE_N.js → index.D0O2ysfC.js} +1 -1
  39. streamlit/static/static/js/{index.BP4BAODr.js → index.D3-O5hIV.js} +1 -1
  40. streamlit/static/static/js/{index.B1VulLzc.js → index.DCKU7zCS.js} +49 -49
  41. streamlit/static/static/js/{index.BLr_rSka.js → index.DEkTRzl5.js} +1 -1
  42. streamlit/static/static/js/{index.Byb6VTEN.js → index.DY1To1KX.js} +1 -1
  43. streamlit/static/static/js/{index.DeV1lu7_.js → index.DcRGK1Fw.js} +1 -1
  44. streamlit/static/static/js/{index.BGqvY5qt.js → index.DqnbRXDR.js} +1 -1
  45. streamlit/static/static/js/{index.Dx6BIgX5.js → index.DvU9hkdF.js} +1 -1
  46. streamlit/static/static/js/{index.VmnqRsXk.js → index.DzihNvNB.js} +1 -1
  47. streamlit/static/static/js/{index.BiulHWQY.js → index.F3n9jlGK.js} +1 -1
  48. streamlit/static/static/js/{index.Woz42eYH.js → index.HNkSYNRg.js} +1 -1
  49. streamlit/static/static/js/{index.7EHeCBEL.js → index.W-ibDLkH.js} +1 -1
  50. streamlit/static/static/js/{index.CTgm0tf2.js → index.XtneMYik.js} +1 -1
  51. streamlit/static/static/js/{index.DxkrGZ4c.js → index.YLN-j6r-.js} +1 -1
  52. streamlit/static/static/js/{index.XbFLAb00.js → index.a9NsHJhQ.js} +1 -1
  53. streamlit/static/static/js/{index.BFGrALdH.js → index.b1kLMo8r.js} +1 -1
  54. streamlit/static/static/js/{index.BC2K_mou.js → index.iO67MDAb.js} +1 -1
  55. streamlit/static/static/js/{index.B4f6JJgu.js → index.mAm8TEUm.js} +1 -1
  56. streamlit/static/static/js/{index.B7TWpGOg.js → index.xQw12X8c.js} +5 -5
  57. streamlit/static/static/js/{input.BlFR_aSs.js → input.D00LElK2.js} +1 -1
  58. streamlit/static/static/js/{memory.CIFxKzYD.js → memory.CGCErNWl.js} +1 -1
  59. streamlit/static/static/js/{mergeWith.DkWqXWlC.js → mergeWith.DPocir3h.js} +1 -1
  60. streamlit/static/static/js/{number-overlay-editor.C_GJSWmK.js → number-overlay-editor.C9aaVRxu.js} +1 -1
  61. streamlit/static/static/js/{possibleConstructorReturn.6fU7Ey-A.js → possibleConstructorReturn.DXXsz__z.js} +1 -1
  62. streamlit/static/static/js/{sandbox.sXki2ZXo.js → sandbox.Br2VBN1F.js} +1 -1
  63. streamlit/static/static/js/{textarea.7d3kK4wj.js → textarea.CQnqAl1g.js} +1 -1
  64. streamlit/static/static/js/{timepicker.x_jFErWh.js → timepicker.BmIoDoBw.js} +1 -1
  65. streamlit/static/static/js/{toConsumableArray.BPJIfTVP.js → toConsumableArray.CfCqHWaY.js} +1 -1
  66. streamlit/static/static/js/{uniqueId.wPSWLsMO.js → uniqueId._zK6ugwW.js} +1 -1
  67. streamlit/static/static/js/{useBasicWidgetState.BGHxUZDu.js → useBasicWidgetState.C_V8mPrP.js} +1 -1
  68. streamlit/static/static/js/{useOnInputChange.l7dUdah_.js → useOnInputChange.5wieT2fD.js} +1 -1
  69. streamlit/static/static/js/{withFullScreenWrapper.BkB-qCNh.js → withFullScreenWrapper.mszDqn7s.js} +1 -1
  70. streamlit/type_util.py +0 -1
  71. streamlit/user_info.py +44 -5
  72. {streamlit_nightly-1.44.2.dev20250415.dist-info → streamlit_nightly-1.44.2.dev20250416.dist-info}/METADATA +1 -1
  73. {streamlit_nightly-1.44.2.dev20250415.dist-info → streamlit_nightly-1.44.2.dev20250416.dist-info}/RECORD +77 -77
  74. streamlit/static/static/js/index.2o-NgFGe.js +0 -1
  75. {streamlit_nightly-1.44.2.dev20250415.data → streamlit_nightly-1.44.2.dev20250416.data}/scripts/streamlit.cmd +0 -0
  76. {streamlit_nightly-1.44.2.dev20250415.dist-info → streamlit_nightly-1.44.2.dev20250416.dist-info}/WHEEL +0 -0
  77. {streamlit_nightly-1.44.2.dev20250415.dist-info → streamlit_nightly-1.44.2.dev20250416.dist-info}/entry_points.txt +0 -0
  78. {streamlit_nightly-1.44.2.dev20250415.dist-info → streamlit_nightly-1.44.2.dev20250416.dist-info}/top_level.txt +0 -0
@@ -1,2 +1,2 @@
1
- import{bv as q,bw as J,r as f,bx as Q,z as Y,by as s,j as S,C as ee,br as te,bz as re,bs as ne,ba as oe,bA as ie,bt as ae,bp as ue,b5 as C,b4 as W,b7 as le}from"./index.B1VulLzc.js";import{a as ce}from"./useBasicWidgetState.BGHxUZDu.js";import"./FormClearHelper.D-LphorD.js";var se={secondary:"secondary"},G={default:"default"},fe={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!==G.default?"-".concat(n.sizing.scale100):"-0.5px";return{display:"flex",marginLeft:o,marginRight:o}});z.displayName="StyledRoot";z.displayName="StyledRoot";function j(e){"@babel/helpers - typeof";return j=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},j(e)}function M(){return M=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},M.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 pe(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){N(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 de(e,t){return me(e)||he(e,t)||be(e,t)||ye()}function ye(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
1
+ import{bv as q,bw as J,r as f,bx as Q,z as Y,by as s,j as S,C as ee,br as te,bz as re,bs as ne,ba as oe,bA as ie,bt as ae,bp as ue,b5 as C,b4 as W,b7 as le}from"./index.DCKU7zCS.js";import{a as ce}from"./useBasicWidgetState.C_V8mPrP.js";import"./FormClearHelper.DJyHVHSH.js";var se={secondary:"secondary"},G={default:"default"},fe={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!==G.default?"-".concat(n.sizing.scale100):"-0.5px";return{display:"flex",marginLeft:o,marginRight:o}});z.displayName="StyledRoot";z.displayName="StyledRoot";function j(e){"@babel/helpers - typeof";return j=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},j(e)}function M(){return M=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},M.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 pe(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){N(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 de(e,t){return me(e)||he(e,t)||be(e,t)||ye()}function ye(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
2
2
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function be(e,t){if(e){if(typeof e=="string")return X(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 X(e,t)}}function X(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 he(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,p;try{for(r=r.call(e);!(o=(a=r.next()).done)&&(n.push(a.value),!(t&&n.length===t));o=!0);}catch(c){i=!0,p=c}finally{try{!o&&r.return!=null&&r.return()}finally{if(i)throw p}}return n}}function me(e){if(Array.isArray(e))return e}function ge(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function ve(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 Se(e,t,r){return t&&ve(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function Oe(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&&$(e,t)}function $(e,t){return $=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,o){return n.__proto__=o,n},$(e,t)}function Ee(e){var t=we();return function(){var n=A(e),o;if(t){var i=A(this).constructor;o=Reflect.construct(n,arguments,i)}else o=n.apply(this,arguments);return _e(this,o)}}function _e(e,t){if(t&&(j(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 we(){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 A(e){return A=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},A(e)}function N(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Le(e,t){return!Array.isArray(e)&&typeof e!="number"?!1:Array.isArray(e)?e.includes(t):e===t}var F=function(e){Oe(r,e);var t=Ee(r);function r(){var n;ge(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)),N(K(n),"childRefs",{}),n}return Se(r,[{key:"render",value:function(){var o=this,i=this.props,a=i.overrides,p=a===void 0?{}:a,c=i.mode,P=c===void 0?k.checkbox:c,d=i.children,y=i.selected,h=i.disabled,l=i.onClick,_=i.kind,m=i.shape,w=i.size,I=J(p.Root,z),O=de(I,2),E=O[0],L=O[1],H=this.props["aria-label"]||this.props.ariaLabel,g=P===k.radio,V=f.Children.count(d);return f.createElement(Q.Consumer,null,function(Z){return f.createElement(E,M({"aria-label":H||Z.buttongroup.ariaLabel,"data-baseweb":"button-group",role:g?"radiogroup":"group",$shape:m,$length:d.length},L),f.Children.map(d,function(b,R){if(!f.isValidElement(b))return null;var T=b.props.isSelected?b.props.isSelected:Le(y,R);return g&&(o.childRefs[R]=f.createRef()),f.cloneElement(b,{disabled:h||b.props.disabled,isSelected:T,ref:g?o.childRefs[R]:void 0,tabIndex:!g||T||g&&(!y||y===-1)&&R===0?0:-1,onKeyDown:function(u){if(g){var v=Number(y)?Number(y):0;if(u.key==="ArrowUp"||u.key==="ArrowLeft"){u.preventDefault&&u.preventDefault();var B=v-1<0?V-1:v-1;l&&l(u,B),o.childRefs[B].current&&o.childRefs[B].current.focus()}if(u.key==="ArrowDown"||u.key==="ArrowRight"){u.preventDefault&&u.preventDefault();var D=v+1>V-1?0:v+1;l&&l(u,D),o.childRefs[D].current&&o.childRefs[D].current.focus()}}},kind:_,onClick:function(u){h||(b.props.onClick&&b.props.onClick(u),l&&l(u,R))},shape:m,size:w,overrides:pe({BaseButton:{style:function(u){var v=u.$theme;return d.length===1?{}:m!==G.default?{marginLeft:v.sizing.scale100,marginRight:v.sizing.scale100}:{marginLeft:"0.5px",marginRight:"0.5px"}},props:{"aria-checked":T,role:g?"radio":"checkbox"}}},b.props.overrides)})}))})}}]),r}(f.Component);N(F,"defaultProps",{disabled:!1,onClick:function(){},shape:G.default,size:fe.default,kind:se.secondary});function Re(e,t){return t.includes(e)?t.filter(r=>r!==e):[...t,e]}function Ce(e,t,r){return e==s.ClickMode.MULTI_SELECT?Re(t,r??[]):r!=null&&r.includes(t)?[]:[t]}function Pe(e){return e.length===0?-1:e[0]}function ke(e,t,r,n){t.setIntArrayValue(e,r.value,{fromUi:r.fromUi},n)}function Ae(e,t,r){const n=r===s.Style.PILLS?C.PILLS:r===s.Style.BORDERLESS?C.BORDERLESS_ICON:C.SEGMENTED_CONTROL,o=r===s.Style.BORDERLESS?W.XSMALL:W.MEDIUM,i=n===C.PILLS||n===C.SEGMENTED_CONTROL,a=r===s.Style.BORDERLESS?"lg":"base";return{element:S(le,{icon:t,label:e,iconSize:a,useSmallerFont:i}),kind:n,size:o}}function Ie(e,t,r,n){return r.indexOf(n)>-1?!0:t!==s.ClickMode.SINGLE_SELECT||e!==s.SelectionVisualization.ALL_UP_TO_SELECTED?!1:r.length>0&&n<r[0]}function Te(e,t){return e&&(t=`${t}Active`),t}function Be(e,t){const r={flexWrap:"wrap",maxWidth:"fit-content"};switch(e){case s.Style.BORDERLESS:return{...r,columnGap:t.threeXS,rowGap:t.threeXS};case s.Style.PILLS:return{...r,columnGap:t.twoXS,rowGap:t.twoXS};case s.Style.SEGMENTED_CONTROL:return{...r,columnGap:t.none,rowGap:t.twoXS,"::after":{content:"''",flex:1e4}};default:return r}}function De(e,t,r,n,o,i){const a=Ie(r,n,o,t);let p=e.content,c=e.contentIcon;return a&&(p=e.selectedContent?e.selectedContent:p,c=e.selectedContentIcon?e.selectedContentIcon:c),f.forwardRef(function(d,y){const{element:h,kind:l,size:_}=Ae(p??"",c??void 0,i),m=Te(!!(a&&!e.selectedContent&&!e.selectedContentIcon),l);return S(ue,{...d,size:_,kind:m,children:h})})}function je(e,t){return e.getIntArrayValue(t)}function Me(e){return e.default??null}function $e(e){return e.value??null}function Ge(e){const{disabled:t,element:r,fragmentId:n,widgetMgr:o}=e,{clickMode:i,options:a,selectionVisualization:p,style:c,label:P,labelVisibility:d,help:y}=r,h=Y(),[l,_]=ce({getStateFromWidgetMgr:je,getDefaultStateFromProto:Me,getCurrStateFromProto:$e,updateWidgetMgrState:ke,element:r,widgetMgr:o,fragmentId:n}),m=(O,E)=>{const L=Ce(i,E,l);_({value:L,fromUi:!0})};let w;i===s.ClickMode.SINGLE_SELECT?w=k.radio:i===s.ClickMode.MULTI_SELECT&&(w=k.checkbox);const I=f.useMemo(()=>a.map((O,E)=>{const L=De(O,E,p,i,l,c);return S(L,{},`${O.content}-${E}`)}),[i,a,p,c,l]);return ee("div",{className:"stButtonGroup","data-testid":"stButtonGroup",children:[S(ae,{label:P,disabled:t,labelVisibility:te((d==null?void 0:d.value)??ie.LabelVisibilityOptions.COLLAPSED),children:y&&S(re,{children:S(ne,{content:y,placement:oe.TOP})})}),S(F,{disabled:t,mode:w,onClick:m,selected:i===s.ClickMode.MULTI_SELECT?l:Pe(l),overrides:{Root:{style:f.useCallback(()=>Be(c,h.spacing),[c,h.spacing])}},children:I})]})}const Ue=f.memo(Ge);export{Ue as default};
@@ -1,4 +1,4 @@
1
- import{r as reactExports,j as jsx}from"./index.B1VulLzc.js";/*!
1
+ import{r as reactExports,j as jsx}from"./index.DCKU7zCS.js";/*!
2
2
  * Copyright (c) 2012 - 2022, Anaconda, Inc., and Bokeh Contributors
3
3
  * All rights reserved.
4
4
  *
@@ -1,2 +1,2 @@
1
- import{n as jt,r as Et,j as st,F as Vt}from"./index.B1VulLzc.js";/*! @license DOMPurify 3.2.5 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.2.5/LICENSE */const{entries:gt,setPrototypeOf:lt,isFrozen:$t,getPrototypeOf:qt,getOwnPropertyDescriptor:Kt}=Object;let{freeze:S,seal:y,create:At}=Object,{apply:Ce,construct:we}=typeof Reflect<"u"&&Reflect;S||(S=function(n){return n});y||(y=function(n){return n});Ce||(Ce=function(n,s,l){return n.apply(s,l)});we||(we=function(n,s){return new n(...s)});const se=R(Array.prototype.forEach),Zt=R(Array.prototype.lastIndexOf),ct=R(Array.prototype.pop),V=R(Array.prototype.push),Jt=R(Array.prototype.splice),ce=R(String.prototype.toLowerCase),be=R(String.prototype.toString),ft=R(String.prototype.match),$=R(String.prototype.replace),Qt=R(String.prototype.indexOf),en=R(String.prototype.trim),L=R(Object.prototype.hasOwnProperty),h=R(RegExp.prototype.test),q=tn(TypeError);function R(a){return function(n){n instanceof RegExp&&(n.lastIndex=0);for(var s=arguments.length,l=new Array(s>1?s-1:0),T=1;T<s;T++)l[T-1]=arguments[T];return Ce(a,n,l)}}function tn(a){return function(){for(var n=arguments.length,s=new Array(n),l=0;l<n;l++)s[l]=arguments[l];return we(a,s)}}function r(a,n){let s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:ce;lt&&lt(a,null);let l=n.length;for(;l--;){let T=n[l];if(typeof T=="string"){const D=s(T);D!==T&&($t(n)||(n[l]=D),T=D)}a[T]=!0}return a}function nn(a){for(let n=0;n<a.length;n++)L(a,n)||(a[n]=null);return a}function w(a){const n=At(null);for(const[s,l]of gt(a))L(a,s)&&(Array.isArray(l)?n[s]=nn(l):l&&typeof l=="object"&&l.constructor===Object?n[s]=w(l):n[s]=l);return n}function K(a,n){for(;a!==null;){const l=Kt(a,n);if(l){if(l.get)return R(l.get);if(typeof l.value=="function")return R(l.value)}a=qt(a)}function s(){return null}return s}const ut=S(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","section","select","shadow","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),Ne=S(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","filter","font","g","glyph","glyphref","hkern","image","line","lineargradient","marker","mask","metadata","mpath","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),De=S(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),on=S(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),Ie=S(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),an=S(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),mt=S(["#text"]),pt=S(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","face","for","headers","height","hidden","high","href","hreflang","id","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns","slot"]),Me=S(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),dt=S(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),le=S(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),rn=y(/\{\{[\w\W]*|[\w\W]*\}\}/gm),sn=y(/<%[\w\W]*|[\w\W]*%>/gm),ln=y(/\$\{[\w\W]*/gm),cn=y(/^data-[\-\w.\u00B7-\uFFFF]+$/),fn=y(/^aria-[\-\w]+$/),ht=y(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),un=y(/^(?:\w+script|data):/i),mn=y(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),St=y(/^html$/i),pn=y(/^[a-z][.\w]*(-[.\w]+)+$/i);var Tt=Object.freeze({__proto__:null,ARIA_ATTR:fn,ATTR_WHITESPACE:mn,CUSTOM_ELEMENT:pn,DATA_ATTR:cn,DOCTYPE_NAME:St,ERB_EXPR:sn,IS_ALLOWED_URI:ht,IS_SCRIPT_OR_DATA:un,MUSTACHE_EXPR:rn,TMPLIT_EXPR:ln});const Z={element:1,text:3,progressingInstruction:7,comment:8,document:9},dn=function(){return typeof window>"u"?null:window},Tn=function(n,s){if(typeof n!="object"||typeof n.createPolicy!="function")return null;let l=null;const T="data-tt-policy-suffix";s&&s.hasAttribute(T)&&(l=s.getAttribute(T));const D="dompurify"+(l?"#"+l:"");try{return n.createPolicy(D,{createHTML(x){return x},createScriptURL(x){return x}})}catch{return console.warn("TrustedTypes policy "+D+" could not be created."),null}},_t=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function Rt(){let a=arguments.length>0&&arguments[0]!==void 0?arguments[0]:dn();const n=i=>Rt(i);if(n.version="3.2.5",n.removed=[],!a||!a.document||a.document.nodeType!==Z.document||!a.Element)return n.isSupported=!1,n;let{document:s}=a;const l=s,T=l.currentScript,{DocumentFragment:D,HTMLTemplateElement:x,Node:fe,Element:ke,NodeFilter:z,NamedNodeMap:Ot=a.NamedNodeMap||a.MozNamedAttrMap,HTMLFormElement:yt,DOMParser:Lt,trustedTypes:J}=a,G=ke.prototype,bt=K(G,"cloneNode"),Nt=K(G,"remove"),Dt=K(G,"nextSibling"),It=K(G,"childNodes"),Q=K(G,"parentNode");if(typeof x=="function"){const i=s.createElement("template");i.content&&i.content.ownerDocument&&(s=i.content.ownerDocument)}let E,W="";const{implementation:ue,createNodeIterator:Mt,createDocumentFragment:Ct,getElementsByTagName:wt}=s,{importNode:xt}=l;let g=_t();n.isSupported=typeof gt=="function"&&typeof Q=="function"&&ue&&ue.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:me,ERB_EXPR:pe,TMPLIT_EXPR:de,DATA_ATTR:Pt,ARIA_ATTR:kt,IS_SCRIPT_OR_DATA:vt,ATTR_WHITESPACE:ve,CUSTOM_ELEMENT:Ut}=Tt;let{IS_ALLOWED_URI:Ue}=Tt,u=null;const Fe=r({},[...ut,...Ne,...De,...Ie,...mt]);let p=null;const He=r({},[...pt,...Me,...dt,...le]);let f=Object.seal(At(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),B=null,Te=null,ze=!0,_e=!0,Ge=!1,We=!0,P=!1,Ee=!0,C=!1,ge=!1,Ae=!1,k=!1,ee=!1,te=!1,Be=!0,Ye=!1;const Ft="user-content-";let he=!0,Y=!1,v={},U=null;const Xe=r({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let je=null;const Ve=r({},["audio","video","img","source","image","track"]);let Se=null;const $e=r({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),ne="http://www.w3.org/1998/Math/MathML",oe="http://www.w3.org/2000/svg",I="http://www.w3.org/1999/xhtml";let F=I,Re=!1,Oe=null;const Ht=r({},[ne,oe,I],be);let ie=r({},["mi","mo","mn","ms","mtext"]),ae=r({},["annotation-xml"]);const zt=r({},["title","style","font","a","script"]);let X=null;const Gt=["application/xhtml+xml","text/html"],Wt="text/html";let m=null,H=null;const Bt=s.createElement("form"),qe=function(e){return e instanceof RegExp||e instanceof Function},ye=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(H&&H===e)){if((!e||typeof e!="object")&&(e={}),e=w(e),X=Gt.indexOf(e.PARSER_MEDIA_TYPE)===-1?Wt:e.PARSER_MEDIA_TYPE,m=X==="application/xhtml+xml"?be:ce,u=L(e,"ALLOWED_TAGS")?r({},e.ALLOWED_TAGS,m):Fe,p=L(e,"ALLOWED_ATTR")?r({},e.ALLOWED_ATTR,m):He,Oe=L(e,"ALLOWED_NAMESPACES")?r({},e.ALLOWED_NAMESPACES,be):Ht,Se=L(e,"ADD_URI_SAFE_ATTR")?r(w($e),e.ADD_URI_SAFE_ATTR,m):$e,je=L(e,"ADD_DATA_URI_TAGS")?r(w(Ve),e.ADD_DATA_URI_TAGS,m):Ve,U=L(e,"FORBID_CONTENTS")?r({},e.FORBID_CONTENTS,m):Xe,B=L(e,"FORBID_TAGS")?r({},e.FORBID_TAGS,m):{},Te=L(e,"FORBID_ATTR")?r({},e.FORBID_ATTR,m):{},v=L(e,"USE_PROFILES")?e.USE_PROFILES:!1,ze=e.ALLOW_ARIA_ATTR!==!1,_e=e.ALLOW_DATA_ATTR!==!1,Ge=e.ALLOW_UNKNOWN_PROTOCOLS||!1,We=e.ALLOW_SELF_CLOSE_IN_ATTR!==!1,P=e.SAFE_FOR_TEMPLATES||!1,Ee=e.SAFE_FOR_XML!==!1,C=e.WHOLE_DOCUMENT||!1,k=e.RETURN_DOM||!1,ee=e.RETURN_DOM_FRAGMENT||!1,te=e.RETURN_TRUSTED_TYPE||!1,Ae=e.FORCE_BODY||!1,Be=e.SANITIZE_DOM!==!1,Ye=e.SANITIZE_NAMED_PROPS||!1,he=e.KEEP_CONTENT!==!1,Y=e.IN_PLACE||!1,Ue=e.ALLOWED_URI_REGEXP||ht,F=e.NAMESPACE||I,ie=e.MATHML_TEXT_INTEGRATION_POINTS||ie,ae=e.HTML_INTEGRATION_POINTS||ae,f=e.CUSTOM_ELEMENT_HANDLING||{},e.CUSTOM_ELEMENT_HANDLING&&qe(e.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(f.tagNameCheck=e.CUSTOM_ELEMENT_HANDLING.tagNameCheck),e.CUSTOM_ELEMENT_HANDLING&&qe(e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(f.attributeNameCheck=e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),e.CUSTOM_ELEMENT_HANDLING&&typeof e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(f.allowCustomizedBuiltInElements=e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),P&&(_e=!1),ee&&(k=!0),v&&(u=r({},mt),p=[],v.html===!0&&(r(u,ut),r(p,pt)),v.svg===!0&&(r(u,Ne),r(p,Me),r(p,le)),v.svgFilters===!0&&(r(u,De),r(p,Me),r(p,le)),v.mathMl===!0&&(r(u,Ie),r(p,dt),r(p,le))),e.ADD_TAGS&&(u===Fe&&(u=w(u)),r(u,e.ADD_TAGS,m)),e.ADD_ATTR&&(p===He&&(p=w(p)),r(p,e.ADD_ATTR,m)),e.ADD_URI_SAFE_ATTR&&r(Se,e.ADD_URI_SAFE_ATTR,m),e.FORBID_CONTENTS&&(U===Xe&&(U=w(U)),r(U,e.FORBID_CONTENTS,m)),he&&(u["#text"]=!0),C&&r(u,["html","head","body"]),u.table&&(r(u,["tbody"]),delete B.tbody),e.TRUSTED_TYPES_POLICY){if(typeof e.TRUSTED_TYPES_POLICY.createHTML!="function")throw q('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof e.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw q('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');E=e.TRUSTED_TYPES_POLICY,W=E.createHTML("")}else E===void 0&&(E=Tn(J,T)),E!==null&&typeof W=="string"&&(W=E.createHTML(""));S&&S(e),H=e}},Ke=r({},[...Ne,...De,...on]),Ze=r({},[...Ie,...an]),Yt=function(e){let t=Q(e);(!t||!t.tagName)&&(t={namespaceURI:F,tagName:"template"});const o=ce(e.tagName),c=ce(t.tagName);return Oe[e.namespaceURI]?e.namespaceURI===oe?t.namespaceURI===I?o==="svg":t.namespaceURI===ne?o==="svg"&&(c==="annotation-xml"||ie[c]):!!Ke[o]:e.namespaceURI===ne?t.namespaceURI===I?o==="math":t.namespaceURI===oe?o==="math"&&ae[c]:!!Ze[o]:e.namespaceURI===I?t.namespaceURI===oe&&!ae[c]||t.namespaceURI===ne&&!ie[c]?!1:!Ze[o]&&(zt[o]||!Ke[o]):!!(X==="application/xhtml+xml"&&Oe[e.namespaceURI]):!1},b=function(e){V(n.removed,{element:e});try{Q(e).removeChild(e)}catch{Nt(e)}},re=function(e,t){try{V(n.removed,{attribute:t.getAttributeNode(e),from:t})}catch{V(n.removed,{attribute:null,from:t})}if(t.removeAttribute(e),e==="is")if(k||ee)try{b(t)}catch{}else try{t.setAttribute(e,"")}catch{}},Je=function(e){let t=null,o=null;if(Ae)e="<remove></remove>"+e;else{const d=ft(e,/^[\r\n\t ]+/);o=d&&d[0]}X==="application/xhtml+xml"&&F===I&&(e='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+e+"</body></html>");const c=E?E.createHTML(e):e;if(F===I)try{t=new Lt().parseFromString(c,X)}catch{}if(!t||!t.documentElement){t=ue.createDocument(F,"template",null);try{t.documentElement.innerHTML=Re?W:c}catch{}}const _=t.body||t.documentElement;return e&&o&&_.insertBefore(s.createTextNode(o),_.childNodes[0]||null),F===I?wt.call(t,C?"html":"body")[0]:C?t.documentElement:_},Qe=function(e){return Mt.call(e.ownerDocument||e,e,z.SHOW_ELEMENT|z.SHOW_COMMENT|z.SHOW_TEXT|z.SHOW_PROCESSING_INSTRUCTION|z.SHOW_CDATA_SECTION,null)},Le=function(e){return e instanceof yt&&(typeof e.nodeName!="string"||typeof e.textContent!="string"||typeof e.removeChild!="function"||!(e.attributes instanceof Ot)||typeof e.removeAttribute!="function"||typeof e.setAttribute!="function"||typeof e.namespaceURI!="string"||typeof e.insertBefore!="function"||typeof e.hasChildNodes!="function")},et=function(e){return typeof fe=="function"&&e instanceof fe};function M(i,e,t){se(i,o=>{o.call(n,e,t,H)})}const tt=function(e){let t=null;if(M(g.beforeSanitizeElements,e,null),Le(e))return b(e),!0;const o=m(e.nodeName);if(M(g.uponSanitizeElement,e,{tagName:o,allowedTags:u}),e.hasChildNodes()&&!et(e.firstElementChild)&&h(/<[/\w!]/g,e.innerHTML)&&h(/<[/\w!]/g,e.textContent)||e.nodeType===Z.progressingInstruction||Ee&&e.nodeType===Z.comment&&h(/<[/\w]/g,e.data))return b(e),!0;if(!u[o]||B[o]){if(!B[o]&&ot(o)&&(f.tagNameCheck instanceof RegExp&&h(f.tagNameCheck,o)||f.tagNameCheck instanceof Function&&f.tagNameCheck(o)))return!1;if(he&&!U[o]){const c=Q(e)||e.parentNode,_=It(e)||e.childNodes;if(_&&c){const d=_.length;for(let O=d-1;O>=0;--O){const N=bt(_[O],!0);N.__removalCount=(e.__removalCount||0)+1,c.insertBefore(N,Dt(e))}}}return b(e),!0}return e instanceof ke&&!Yt(e)||(o==="noscript"||o==="noembed"||o==="noframes")&&h(/<\/no(script|embed|frames)/i,e.innerHTML)?(b(e),!0):(P&&e.nodeType===Z.text&&(t=e.textContent,se([me,pe,de],c=>{t=$(t,c," ")}),e.textContent!==t&&(V(n.removed,{element:e.cloneNode()}),e.textContent=t)),M(g.afterSanitizeElements,e,null),!1)},nt=function(e,t,o){if(Be&&(t==="id"||t==="name")&&(o in s||o in Bt))return!1;if(!(_e&&!Te[t]&&h(Pt,t))){if(!(ze&&h(kt,t))){if(!p[t]||Te[t]){if(!(ot(e)&&(f.tagNameCheck instanceof RegExp&&h(f.tagNameCheck,e)||f.tagNameCheck instanceof Function&&f.tagNameCheck(e))&&(f.attributeNameCheck instanceof RegExp&&h(f.attributeNameCheck,t)||f.attributeNameCheck instanceof Function&&f.attributeNameCheck(t))||t==="is"&&f.allowCustomizedBuiltInElements&&(f.tagNameCheck instanceof RegExp&&h(f.tagNameCheck,o)||f.tagNameCheck instanceof Function&&f.tagNameCheck(o))))return!1}else if(!Se[t]){if(!h(Ue,$(o,ve,""))){if(!((t==="src"||t==="xlink:href"||t==="href")&&e!=="script"&&Qt(o,"data:")===0&&je[e])){if(!(Ge&&!h(vt,$(o,ve,"")))){if(o)return!1}}}}}}return!0},ot=function(e){return e!=="annotation-xml"&&ft(e,Ut)},it=function(e){M(g.beforeSanitizeAttributes,e,null);const{attributes:t}=e;if(!t||Le(e))return;const o={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:p,forceKeepAttr:void 0};let c=t.length;for(;c--;){const _=t[c],{name:d,namespaceURI:O,value:N}=_,j=m(d);let A=d==="value"?N:en(N);if(o.attrName=j,o.attrValue=A,o.keepAttr=!0,o.forceKeepAttr=void 0,M(g.uponSanitizeAttribute,e,o),A=o.attrValue,Ye&&(j==="id"||j==="name")&&(re(d,e),A=Ft+A),Ee&&h(/((--!?|])>)|<\/(style|title)/i,A)){re(d,e);continue}if(o.forceKeepAttr||(re(d,e),!o.keepAttr))continue;if(!We&&h(/\/>/i,A)){re(d,e);continue}P&&se([me,pe,de],rt=>{A=$(A,rt," ")});const at=m(e.nodeName);if(nt(at,j,A)){if(E&&typeof J=="object"&&typeof J.getAttributeType=="function"&&!O)switch(J.getAttributeType(at,j)){case"TrustedHTML":{A=E.createHTML(A);break}case"TrustedScriptURL":{A=E.createScriptURL(A);break}}try{O?e.setAttributeNS(O,d,A):e.setAttribute(d,A),Le(e)?b(e):ct(n.removed)}catch{}}}M(g.afterSanitizeAttributes,e,null)},Xt=function i(e){let t=null;const o=Qe(e);for(M(g.beforeSanitizeShadowDOM,e,null);t=o.nextNode();)M(g.uponSanitizeShadowNode,t,null),tt(t),it(t),t.content instanceof D&&i(t.content);M(g.afterSanitizeShadowDOM,e,null)};return n.sanitize=function(i){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},t=null,o=null,c=null,_=null;if(Re=!i,Re&&(i="<!-->"),typeof i!="string"&&!et(i))if(typeof i.toString=="function"){if(i=i.toString(),typeof i!="string")throw q("dirty is not a string, aborting")}else throw q("toString is not a function");if(!n.isSupported)return i;if(ge||ye(e),n.removed=[],typeof i=="string"&&(Y=!1),Y){if(i.nodeName){const N=m(i.nodeName);if(!u[N]||B[N])throw q("root node is forbidden and cannot be sanitized in-place")}}else if(i instanceof fe)t=Je("<!---->"),o=t.ownerDocument.importNode(i,!0),o.nodeType===Z.element&&o.nodeName==="BODY"||o.nodeName==="HTML"?t=o:t.appendChild(o);else{if(!k&&!P&&!C&&i.indexOf("<")===-1)return E&&te?E.createHTML(i):i;if(t=Je(i),!t)return k?null:te?W:""}t&&Ae&&b(t.firstChild);const d=Qe(Y?i:t);for(;c=d.nextNode();)tt(c),it(c),c.content instanceof D&&Xt(c.content);if(Y)return i;if(k){if(ee)for(_=Ct.call(t.ownerDocument);t.firstChild;)_.appendChild(t.firstChild);else _=t;return(p.shadowroot||p.shadowrootmode)&&(_=xt.call(l,_,!0)),_}let O=C?t.outerHTML:t.innerHTML;return C&&u["!doctype"]&&t.ownerDocument&&t.ownerDocument.doctype&&t.ownerDocument.doctype.name&&h(St,t.ownerDocument.doctype.name)&&(O="<!DOCTYPE "+t.ownerDocument.doctype.name+`>
1
+ import{n as jt,r as Et,j as st,F as Vt}from"./index.DCKU7zCS.js";/*! @license DOMPurify 3.2.5 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.2.5/LICENSE */const{entries:gt,setPrototypeOf:lt,isFrozen:$t,getPrototypeOf:qt,getOwnPropertyDescriptor:Kt}=Object;let{freeze:S,seal:y,create:At}=Object,{apply:Ce,construct:we}=typeof Reflect<"u"&&Reflect;S||(S=function(n){return n});y||(y=function(n){return n});Ce||(Ce=function(n,s,l){return n.apply(s,l)});we||(we=function(n,s){return new n(...s)});const se=R(Array.prototype.forEach),Zt=R(Array.prototype.lastIndexOf),ct=R(Array.prototype.pop),V=R(Array.prototype.push),Jt=R(Array.prototype.splice),ce=R(String.prototype.toLowerCase),be=R(String.prototype.toString),ft=R(String.prototype.match),$=R(String.prototype.replace),Qt=R(String.prototype.indexOf),en=R(String.prototype.trim),L=R(Object.prototype.hasOwnProperty),h=R(RegExp.prototype.test),q=tn(TypeError);function R(a){return function(n){n instanceof RegExp&&(n.lastIndex=0);for(var s=arguments.length,l=new Array(s>1?s-1:0),T=1;T<s;T++)l[T-1]=arguments[T];return Ce(a,n,l)}}function tn(a){return function(){for(var n=arguments.length,s=new Array(n),l=0;l<n;l++)s[l]=arguments[l];return we(a,s)}}function r(a,n){let s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:ce;lt&&lt(a,null);let l=n.length;for(;l--;){let T=n[l];if(typeof T=="string"){const D=s(T);D!==T&&($t(n)||(n[l]=D),T=D)}a[T]=!0}return a}function nn(a){for(let n=0;n<a.length;n++)L(a,n)||(a[n]=null);return a}function w(a){const n=At(null);for(const[s,l]of gt(a))L(a,s)&&(Array.isArray(l)?n[s]=nn(l):l&&typeof l=="object"&&l.constructor===Object?n[s]=w(l):n[s]=l);return n}function K(a,n){for(;a!==null;){const l=Kt(a,n);if(l){if(l.get)return R(l.get);if(typeof l.value=="function")return R(l.value)}a=qt(a)}function s(){return null}return s}const ut=S(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","section","select","shadow","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),Ne=S(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","filter","font","g","glyph","glyphref","hkern","image","line","lineargradient","marker","mask","metadata","mpath","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),De=S(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),on=S(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),Ie=S(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),an=S(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),mt=S(["#text"]),pt=S(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","face","for","headers","height","hidden","high","href","hreflang","id","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns","slot"]),Me=S(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),dt=S(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),le=S(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),rn=y(/\{\{[\w\W]*|[\w\W]*\}\}/gm),sn=y(/<%[\w\W]*|[\w\W]*%>/gm),ln=y(/\$\{[\w\W]*/gm),cn=y(/^data-[\-\w.\u00B7-\uFFFF]+$/),fn=y(/^aria-[\-\w]+$/),ht=y(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),un=y(/^(?:\w+script|data):/i),mn=y(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),St=y(/^html$/i),pn=y(/^[a-z][.\w]*(-[.\w]+)+$/i);var Tt=Object.freeze({__proto__:null,ARIA_ATTR:fn,ATTR_WHITESPACE:mn,CUSTOM_ELEMENT:pn,DATA_ATTR:cn,DOCTYPE_NAME:St,ERB_EXPR:sn,IS_ALLOWED_URI:ht,IS_SCRIPT_OR_DATA:un,MUSTACHE_EXPR:rn,TMPLIT_EXPR:ln});const Z={element:1,text:3,progressingInstruction:7,comment:8,document:9},dn=function(){return typeof window>"u"?null:window},Tn=function(n,s){if(typeof n!="object"||typeof n.createPolicy!="function")return null;let l=null;const T="data-tt-policy-suffix";s&&s.hasAttribute(T)&&(l=s.getAttribute(T));const D="dompurify"+(l?"#"+l:"");try{return n.createPolicy(D,{createHTML(x){return x},createScriptURL(x){return x}})}catch{return console.warn("TrustedTypes policy "+D+" could not be created."),null}},_t=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function Rt(){let a=arguments.length>0&&arguments[0]!==void 0?arguments[0]:dn();const n=i=>Rt(i);if(n.version="3.2.5",n.removed=[],!a||!a.document||a.document.nodeType!==Z.document||!a.Element)return n.isSupported=!1,n;let{document:s}=a;const l=s,T=l.currentScript,{DocumentFragment:D,HTMLTemplateElement:x,Node:fe,Element:ke,NodeFilter:z,NamedNodeMap:Ot=a.NamedNodeMap||a.MozNamedAttrMap,HTMLFormElement:yt,DOMParser:Lt,trustedTypes:J}=a,G=ke.prototype,bt=K(G,"cloneNode"),Nt=K(G,"remove"),Dt=K(G,"nextSibling"),It=K(G,"childNodes"),Q=K(G,"parentNode");if(typeof x=="function"){const i=s.createElement("template");i.content&&i.content.ownerDocument&&(s=i.content.ownerDocument)}let E,W="";const{implementation:ue,createNodeIterator:Mt,createDocumentFragment:Ct,getElementsByTagName:wt}=s,{importNode:xt}=l;let g=_t();n.isSupported=typeof gt=="function"&&typeof Q=="function"&&ue&&ue.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:me,ERB_EXPR:pe,TMPLIT_EXPR:de,DATA_ATTR:Pt,ARIA_ATTR:kt,IS_SCRIPT_OR_DATA:vt,ATTR_WHITESPACE:ve,CUSTOM_ELEMENT:Ut}=Tt;let{IS_ALLOWED_URI:Ue}=Tt,u=null;const Fe=r({},[...ut,...Ne,...De,...Ie,...mt]);let p=null;const He=r({},[...pt,...Me,...dt,...le]);let f=Object.seal(At(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),B=null,Te=null,ze=!0,_e=!0,Ge=!1,We=!0,P=!1,Ee=!0,C=!1,ge=!1,Ae=!1,k=!1,ee=!1,te=!1,Be=!0,Ye=!1;const Ft="user-content-";let he=!0,Y=!1,v={},U=null;const Xe=r({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let je=null;const Ve=r({},["audio","video","img","source","image","track"]);let Se=null;const $e=r({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),ne="http://www.w3.org/1998/Math/MathML",oe="http://www.w3.org/2000/svg",I="http://www.w3.org/1999/xhtml";let F=I,Re=!1,Oe=null;const Ht=r({},[ne,oe,I],be);let ie=r({},["mi","mo","mn","ms","mtext"]),ae=r({},["annotation-xml"]);const zt=r({},["title","style","font","a","script"]);let X=null;const Gt=["application/xhtml+xml","text/html"],Wt="text/html";let m=null,H=null;const Bt=s.createElement("form"),qe=function(e){return e instanceof RegExp||e instanceof Function},ye=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(H&&H===e)){if((!e||typeof e!="object")&&(e={}),e=w(e),X=Gt.indexOf(e.PARSER_MEDIA_TYPE)===-1?Wt:e.PARSER_MEDIA_TYPE,m=X==="application/xhtml+xml"?be:ce,u=L(e,"ALLOWED_TAGS")?r({},e.ALLOWED_TAGS,m):Fe,p=L(e,"ALLOWED_ATTR")?r({},e.ALLOWED_ATTR,m):He,Oe=L(e,"ALLOWED_NAMESPACES")?r({},e.ALLOWED_NAMESPACES,be):Ht,Se=L(e,"ADD_URI_SAFE_ATTR")?r(w($e),e.ADD_URI_SAFE_ATTR,m):$e,je=L(e,"ADD_DATA_URI_TAGS")?r(w(Ve),e.ADD_DATA_URI_TAGS,m):Ve,U=L(e,"FORBID_CONTENTS")?r({},e.FORBID_CONTENTS,m):Xe,B=L(e,"FORBID_TAGS")?r({},e.FORBID_TAGS,m):{},Te=L(e,"FORBID_ATTR")?r({},e.FORBID_ATTR,m):{},v=L(e,"USE_PROFILES")?e.USE_PROFILES:!1,ze=e.ALLOW_ARIA_ATTR!==!1,_e=e.ALLOW_DATA_ATTR!==!1,Ge=e.ALLOW_UNKNOWN_PROTOCOLS||!1,We=e.ALLOW_SELF_CLOSE_IN_ATTR!==!1,P=e.SAFE_FOR_TEMPLATES||!1,Ee=e.SAFE_FOR_XML!==!1,C=e.WHOLE_DOCUMENT||!1,k=e.RETURN_DOM||!1,ee=e.RETURN_DOM_FRAGMENT||!1,te=e.RETURN_TRUSTED_TYPE||!1,Ae=e.FORCE_BODY||!1,Be=e.SANITIZE_DOM!==!1,Ye=e.SANITIZE_NAMED_PROPS||!1,he=e.KEEP_CONTENT!==!1,Y=e.IN_PLACE||!1,Ue=e.ALLOWED_URI_REGEXP||ht,F=e.NAMESPACE||I,ie=e.MATHML_TEXT_INTEGRATION_POINTS||ie,ae=e.HTML_INTEGRATION_POINTS||ae,f=e.CUSTOM_ELEMENT_HANDLING||{},e.CUSTOM_ELEMENT_HANDLING&&qe(e.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(f.tagNameCheck=e.CUSTOM_ELEMENT_HANDLING.tagNameCheck),e.CUSTOM_ELEMENT_HANDLING&&qe(e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(f.attributeNameCheck=e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),e.CUSTOM_ELEMENT_HANDLING&&typeof e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(f.allowCustomizedBuiltInElements=e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),P&&(_e=!1),ee&&(k=!0),v&&(u=r({},mt),p=[],v.html===!0&&(r(u,ut),r(p,pt)),v.svg===!0&&(r(u,Ne),r(p,Me),r(p,le)),v.svgFilters===!0&&(r(u,De),r(p,Me),r(p,le)),v.mathMl===!0&&(r(u,Ie),r(p,dt),r(p,le))),e.ADD_TAGS&&(u===Fe&&(u=w(u)),r(u,e.ADD_TAGS,m)),e.ADD_ATTR&&(p===He&&(p=w(p)),r(p,e.ADD_ATTR,m)),e.ADD_URI_SAFE_ATTR&&r(Se,e.ADD_URI_SAFE_ATTR,m),e.FORBID_CONTENTS&&(U===Xe&&(U=w(U)),r(U,e.FORBID_CONTENTS,m)),he&&(u["#text"]=!0),C&&r(u,["html","head","body"]),u.table&&(r(u,["tbody"]),delete B.tbody),e.TRUSTED_TYPES_POLICY){if(typeof e.TRUSTED_TYPES_POLICY.createHTML!="function")throw q('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof e.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw q('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');E=e.TRUSTED_TYPES_POLICY,W=E.createHTML("")}else E===void 0&&(E=Tn(J,T)),E!==null&&typeof W=="string"&&(W=E.createHTML(""));S&&S(e),H=e}},Ke=r({},[...Ne,...De,...on]),Ze=r({},[...Ie,...an]),Yt=function(e){let t=Q(e);(!t||!t.tagName)&&(t={namespaceURI:F,tagName:"template"});const o=ce(e.tagName),c=ce(t.tagName);return Oe[e.namespaceURI]?e.namespaceURI===oe?t.namespaceURI===I?o==="svg":t.namespaceURI===ne?o==="svg"&&(c==="annotation-xml"||ie[c]):!!Ke[o]:e.namespaceURI===ne?t.namespaceURI===I?o==="math":t.namespaceURI===oe?o==="math"&&ae[c]:!!Ze[o]:e.namespaceURI===I?t.namespaceURI===oe&&!ae[c]||t.namespaceURI===ne&&!ie[c]?!1:!Ze[o]&&(zt[o]||!Ke[o]):!!(X==="application/xhtml+xml"&&Oe[e.namespaceURI]):!1},b=function(e){V(n.removed,{element:e});try{Q(e).removeChild(e)}catch{Nt(e)}},re=function(e,t){try{V(n.removed,{attribute:t.getAttributeNode(e),from:t})}catch{V(n.removed,{attribute:null,from:t})}if(t.removeAttribute(e),e==="is")if(k||ee)try{b(t)}catch{}else try{t.setAttribute(e,"")}catch{}},Je=function(e){let t=null,o=null;if(Ae)e="<remove></remove>"+e;else{const d=ft(e,/^[\r\n\t ]+/);o=d&&d[0]}X==="application/xhtml+xml"&&F===I&&(e='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+e+"</body></html>");const c=E?E.createHTML(e):e;if(F===I)try{t=new Lt().parseFromString(c,X)}catch{}if(!t||!t.documentElement){t=ue.createDocument(F,"template",null);try{t.documentElement.innerHTML=Re?W:c}catch{}}const _=t.body||t.documentElement;return e&&o&&_.insertBefore(s.createTextNode(o),_.childNodes[0]||null),F===I?wt.call(t,C?"html":"body")[0]:C?t.documentElement:_},Qe=function(e){return Mt.call(e.ownerDocument||e,e,z.SHOW_ELEMENT|z.SHOW_COMMENT|z.SHOW_TEXT|z.SHOW_PROCESSING_INSTRUCTION|z.SHOW_CDATA_SECTION,null)},Le=function(e){return e instanceof yt&&(typeof e.nodeName!="string"||typeof e.textContent!="string"||typeof e.removeChild!="function"||!(e.attributes instanceof Ot)||typeof e.removeAttribute!="function"||typeof e.setAttribute!="function"||typeof e.namespaceURI!="string"||typeof e.insertBefore!="function"||typeof e.hasChildNodes!="function")},et=function(e){return typeof fe=="function"&&e instanceof fe};function M(i,e,t){se(i,o=>{o.call(n,e,t,H)})}const tt=function(e){let t=null;if(M(g.beforeSanitizeElements,e,null),Le(e))return b(e),!0;const o=m(e.nodeName);if(M(g.uponSanitizeElement,e,{tagName:o,allowedTags:u}),e.hasChildNodes()&&!et(e.firstElementChild)&&h(/<[/\w!]/g,e.innerHTML)&&h(/<[/\w!]/g,e.textContent)||e.nodeType===Z.progressingInstruction||Ee&&e.nodeType===Z.comment&&h(/<[/\w]/g,e.data))return b(e),!0;if(!u[o]||B[o]){if(!B[o]&&ot(o)&&(f.tagNameCheck instanceof RegExp&&h(f.tagNameCheck,o)||f.tagNameCheck instanceof Function&&f.tagNameCheck(o)))return!1;if(he&&!U[o]){const c=Q(e)||e.parentNode,_=It(e)||e.childNodes;if(_&&c){const d=_.length;for(let O=d-1;O>=0;--O){const N=bt(_[O],!0);N.__removalCount=(e.__removalCount||0)+1,c.insertBefore(N,Dt(e))}}}return b(e),!0}return e instanceof ke&&!Yt(e)||(o==="noscript"||o==="noembed"||o==="noframes")&&h(/<\/no(script|embed|frames)/i,e.innerHTML)?(b(e),!0):(P&&e.nodeType===Z.text&&(t=e.textContent,se([me,pe,de],c=>{t=$(t,c," ")}),e.textContent!==t&&(V(n.removed,{element:e.cloneNode()}),e.textContent=t)),M(g.afterSanitizeElements,e,null),!1)},nt=function(e,t,o){if(Be&&(t==="id"||t==="name")&&(o in s||o in Bt))return!1;if(!(_e&&!Te[t]&&h(Pt,t))){if(!(ze&&h(kt,t))){if(!p[t]||Te[t]){if(!(ot(e)&&(f.tagNameCheck instanceof RegExp&&h(f.tagNameCheck,e)||f.tagNameCheck instanceof Function&&f.tagNameCheck(e))&&(f.attributeNameCheck instanceof RegExp&&h(f.attributeNameCheck,t)||f.attributeNameCheck instanceof Function&&f.attributeNameCheck(t))||t==="is"&&f.allowCustomizedBuiltInElements&&(f.tagNameCheck instanceof RegExp&&h(f.tagNameCheck,o)||f.tagNameCheck instanceof Function&&f.tagNameCheck(o))))return!1}else if(!Se[t]){if(!h(Ue,$(o,ve,""))){if(!((t==="src"||t==="xlink:href"||t==="href")&&e!=="script"&&Qt(o,"data:")===0&&je[e])){if(!(Ge&&!h(vt,$(o,ve,"")))){if(o)return!1}}}}}}return!0},ot=function(e){return e!=="annotation-xml"&&ft(e,Ut)},it=function(e){M(g.beforeSanitizeAttributes,e,null);const{attributes:t}=e;if(!t||Le(e))return;const o={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:p,forceKeepAttr:void 0};let c=t.length;for(;c--;){const _=t[c],{name:d,namespaceURI:O,value:N}=_,j=m(d);let A=d==="value"?N:en(N);if(o.attrName=j,o.attrValue=A,o.keepAttr=!0,o.forceKeepAttr=void 0,M(g.uponSanitizeAttribute,e,o),A=o.attrValue,Ye&&(j==="id"||j==="name")&&(re(d,e),A=Ft+A),Ee&&h(/((--!?|])>)|<\/(style|title)/i,A)){re(d,e);continue}if(o.forceKeepAttr||(re(d,e),!o.keepAttr))continue;if(!We&&h(/\/>/i,A)){re(d,e);continue}P&&se([me,pe,de],rt=>{A=$(A,rt," ")});const at=m(e.nodeName);if(nt(at,j,A)){if(E&&typeof J=="object"&&typeof J.getAttributeType=="function"&&!O)switch(J.getAttributeType(at,j)){case"TrustedHTML":{A=E.createHTML(A);break}case"TrustedScriptURL":{A=E.createScriptURL(A);break}}try{O?e.setAttributeNS(O,d,A):e.setAttribute(d,A),Le(e)?b(e):ct(n.removed)}catch{}}}M(g.afterSanitizeAttributes,e,null)},Xt=function i(e){let t=null;const o=Qe(e);for(M(g.beforeSanitizeShadowDOM,e,null);t=o.nextNode();)M(g.uponSanitizeShadowNode,t,null),tt(t),it(t),t.content instanceof D&&i(t.content);M(g.afterSanitizeShadowDOM,e,null)};return n.sanitize=function(i){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},t=null,o=null,c=null,_=null;if(Re=!i,Re&&(i="<!-->"),typeof i!="string"&&!et(i))if(typeof i.toString=="function"){if(i=i.toString(),typeof i!="string")throw q("dirty is not a string, aborting")}else throw q("toString is not a function");if(!n.isSupported)return i;if(ge||ye(e),n.removed=[],typeof i=="string"&&(Y=!1),Y){if(i.nodeName){const N=m(i.nodeName);if(!u[N]||B[N])throw q("root node is forbidden and cannot be sanitized in-place")}}else if(i instanceof fe)t=Je("<!---->"),o=t.ownerDocument.importNode(i,!0),o.nodeType===Z.element&&o.nodeName==="BODY"||o.nodeName==="HTML"?t=o:t.appendChild(o);else{if(!k&&!P&&!C&&i.indexOf("<")===-1)return E&&te?E.createHTML(i):i;if(t=Je(i),!t)return k?null:te?W:""}t&&Ae&&b(t.firstChild);const d=Qe(Y?i:t);for(;c=d.nextNode();)tt(c),it(c),c.content instanceof D&&Xt(c.content);if(Y)return i;if(k){if(ee)for(_=Ct.call(t.ownerDocument);t.firstChild;)_.appendChild(t.firstChild);else _=t;return(p.shadowroot||p.shadowrootmode)&&(_=xt.call(l,_,!0)),_}let O=C?t.outerHTML:t.innerHTML;return C&&u["!doctype"]&&t.ownerDocument&&t.ownerDocument.doctype&&t.ownerDocument.doctype.name&&h(St,t.ownerDocument.doctype.name)&&(O="<!DOCTYPE "+t.ownerDocument.doctype.name+`>
2
2
  `+O),P&&se([me,pe,de],N=>{O=$(O,N," ")}),E&&te?E.createHTML(O):O},n.setConfig=function(){let i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};ye(i),ge=!0},n.clearConfig=function(){H=null,ge=!1},n.isValidAttribute=function(i,e,t){H||ye({});const o=m(i),c=m(e);return nt(o,c,t)},n.addHook=function(i,e){typeof e=="function"&&V(g[i],e)},n.removeHook=function(i,e){if(e!==void 0){const t=Zt(g[i],e);return t===-1?void 0:Jt(g[i],t,1)[0]}return ct(g[i])},n.removeHooks=function(i){g[i]=[]},n.removeAllHooks=function(){g=_t()},n}var Pe=Rt();const _n=jt("div",{target:"ez8s6cm0"})({width:"100%"}),xe="data-temp-href-target";Pe.addHook("beforeSanitizeAttributes",function(a){a instanceof HTMLElement&&a.hasAttribute("target")&&a.getAttribute("target")==="_blank"&&a.setAttribute(xe,"_blank")});Pe.addHook("afterSanitizeAttributes",function(a){a instanceof HTMLElement&&a.hasAttribute(xe)&&(a.setAttribute("target","_blank"),a.setAttribute("rel","noopener noreferrer"),a.removeAttribute(xe))});const En=a=>{const n={USE_PROFILES:{html:!0},FORCE_BODY:!0};return Pe.sanitize(a,n)};function gn({element:a}){const{body:n}=a,s=Et.useMemo(()=>En(n),[n]);return st(Vt,{children:s&&st(_n,{className:"stHtml","data-testid":"stHtml",dangerouslySetInnerHTML:{__html:s}})})}const hn=Et.memo(gn);export{hn as default};
@@ -1 +1 @@
1
- import{r as i,E as J,_ as Q,n as g,B as ht,z as W,j as n,ba as Z,bu as ft,C as F,bp as tt,b5 as et,bo as T,a$ as mt,bG as yt,bj as Ct,bH as I,bs as vt,F as ot,bh as It,bI as bt,M as $,bl as xt,bk as wt}from"./index.B1VulLzc.js";import{g as St,F as N,C as Ft,I as Et,E as Ut,a as zt,s as Tt,u as Ht,b as Bt}from"./FileHelper.B8weo4vC.js";import{I as Dt}from"./InputInstructions.CfaxjFap.js";import{i as Rt}from"./inputUtils.CQWz5UKz.js";import{E as Lt}from"./ErrorOutline.esm.DpSDsEwX.js";import{a as q}from"./index.t--hEgTQ.js";import{U as nt}from"./UploadFileInfo.C-jY39rj.js";import{T as $t}from"./textarea.7d3kK4wj.js";import"./base-input.DQIDgbB-.js";var at=i.forwardRef(function(t,e){var s={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return i.createElement(J,Q({iconAttrs:s,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},t,{ref:e}),i.createElement("path",{fill:"none",d:"M0 0h24v24H0V0z"}),i.createElement("path",{d:"M16.5 6v11.5c0 2.21-1.79 4-4 4s-4-1.79-4-4V5a2.5 2.5 0 015 0v10.5c0 .55-.45 1-1 1s-1-.45-1-1V6H10v9.5a2.5 2.5 0 005 0V5c0-2.21-1.79-4-4-4S7 2.79 7 5v12.5c0 3.04 2.46 5.5 5.5 5.5s5.5-2.46 5.5-5.5V6h-1.5z"}))});at.displayName="AttachFile";var rt=i.forwardRef(function(t,e){var s={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return i.createElement(J,Q({iconAttrs:s,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},t,{ref:e}),i.createElement("rect",{width:24,height:24,fill:"none"}),i.createElement("path",{d:"M3 5.51v3.71c0 .46.31.86.76.97L11 12l-7.24 1.81c-.45.11-.76.51-.76.97v3.71c0 .72.73 1.2 1.39.92l15.42-6.49c.82-.34.82-1.5 0-1.84L4.39 4.58C3.73 4.31 3 4.79 3 5.51z"}))});rt.displayName="Send";const kt=g("div",{target:"e1togvvn0"})("border:none;position:relative;display:flex;"),Mt=g("div",{target:"e1togvvn1"})(({theme:t,extended:e})=>({border:`${t.sizes.borderWidth} solid`,borderColor:t.colors.widgetBorderColor??t.colors.transparent,borderRadius:t.radii.chatInput,backgroundColor:t.colors.secondaryBg,position:"relative",flexGrow:1,display:"flex",alignItems:"center",paddingLeft:t.spacing.lg,maxHeight:e?"none":t.sizes.minElementHeight,gap:t.spacing.sm,overflow:"hidden",":focus-within":{borderColor:t.colors.primary}})),Vt=g("button",{target:"e1togvvn2"})(({theme:t,disabled:e,extended:s})=>{const p=ht(t),[f,u]=p?[t.colors.gray60,t.colors.gray80]:[t.colors.gray80,t.colors.gray40];return{border:"none",backgroundColor:t.colors.transparent,borderTopRightRadius:s?"0":t.radii.chatInput,borderTopLeftRadius:s?t.radii.default:"0",borderBottomRightRadius:t.radii.chatInput,display:"inline-flex",alignItems:"center",justifyContent:"center",lineHeight:t.lineHeights.none,margin:t.spacing.none,padding:t.spacing.sm,color:e?f:u,pointerEvents:"auto","&:focus":{outline:"none"},":focus":{outline:"none"},"&:focus-visible":{backgroundColor:p?t.colors.gray10:t.colors.gray90},"&:hover":{color:t.colors.primary},"&:disabled, &:disabled:hover, &:disabled:active":{backgroundColor:t.colors.transparent,borderColor:t.colors.transparent,color:t.colors.gray,cursor:"not-allowed"}}}),Nt=g("div",{target:"e1togvvn3"})(({theme:t})=>({display:"flex",alignItems:"flex-end",height:"100%",position:"absolute",right:0,marginBottom:`-${t.sizes.borderWidth}`,pointerEvents:"none"})),Wt=g("div",{target:"e1togvvn4"})(({theme:t})=>({position:"absolute",bottom:"0px",right:`calc(${t.iconSizes.xl} + 2 * ${t.spacing.sm} + ${t.spacing.sm})`})),At=g("div",{target:"e15560op0"})(({theme:t,height:e})=>({backgroundColor:t.colors.transparent,position:"absolute",left:0,bottom:0,minHeight:`max(${t.sizes.emptyDropdownHeight}, ${e})`,width:"100%",zIndex:t.zIndices.priority})),Pt=g("div",{target:"e15560op1"})(({theme:t,height:e})=>({border:`${t.sizes.borderWidth} solid`,borderColor:t.colors.primary,borderRadius:t.radii.chatInput,backgroundColor:t.colors.secondaryBg,color:t.colors.primary,display:"flex",alignItems:"center",justifyContent:"center",height:e,width:"100%",fontWeight:t.fontWeights.bold})),Kt=g("div",{target:"e15560op2"})(({theme:t,disabled:e})=>({display:"flex",alignItems:"top",height:"100%",marginTop:`-${t.sizes.borderWidth}`,cursor:e?"not-allowed":"auto"})),Ot=g("div",{target:"e15560op3"})(({disabled:t})=>({pointerEvents:t?"none":"auto"})),_t=g("div",{target:"e15560op4"})(({theme:t})=>({marginTop:"0.625em",marginLeft:t.spacing.sm,height:t.spacing.xl,width:t.sizes.borderWidth,backgroundColor:t.colors.fadedText20})),Xt=g("div",{target:"e15560op5"})(({theme:t})=>({left:0,right:0,lineHeight:t.lineHeights.tight,paddingLeft:t.spacing.sm,paddingRight:t.spacing.sm,overflowX:"auto"})),Gt=g("div",{target:"e15560op6"})({display:"flex"}),jt=g("div",{target:"e15560op7"})({flex:"0 0 auto"}),Yt=g("div",{target:"e15560op8"})(({theme:t})=>({display:"flex",alignItems:"center",padding:t.spacing.sm,gap:t.spacing.twoXS})),qt=g("div",{target:"e15560op9"})(({theme:t})=>({color:t.colors.fadedText60})),Jt=g("div",{target:"e15560op10"})(({theme:t,fileStatus:e})=>({overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:e.type==="uploaded"?t.colors.bodyText:t.colors.fadedText60})),Qt=g("div",{target:"e15560op11"})(({theme:t})=>({marginRight:t.spacing.md,color:t.colors.fadedText60})),Zt=g("small",{target:"e15560op12"})(({theme:t})=>({display:"flex",alignItems:"center",maxHeight:t.sizes.smallElementHeight,color:t.colors.fadedText60,"& :hover":{color:t.colors.bodyText}}));function te({children:t,content:e}){const s=W();return n(ft,{content:e,placement:Z.TOP,overrides:{Body:{style:{top:`-${s.sizes.minElementHeight}`}}},children:t})}const ee=({fileInfo:t})=>{const e=W(),{type:s}=t.status;switch(s){case"uploading":return n(yt,{usingCustomTheme:!1,"data-testid":"stChatInputFileIconSpinner",size:"lg",margin:"0",padding:"0"});case"error":return n(te,{content:t.status.errorMessage,children:n(T,{color:e.colors.red,content:Lt,size:"lg"})});case"uploaded":return n(T,{content:Et,size:"lg"});default:return mt(s),null}},oe=({fileInfo:t,onDelete:e})=>F(Yt,{className:"stChatInputFile","data-testid":"stChatInputFile",children:[n(qt,{children:n(ee,{fileInfo:t})}),n(Jt,{className:"stChatInputFileName","data-testid":"stChatInputFileName",title:t.name,fileStatus:t.status,children:t.name}),n(Qt,{children:St(t.size,N.Byte)}),n(Zt,{"data-testid":"stChatInputDeleteBtn",children:n(tt,{onClick:()=>e(t.id),kind:et.MINIMAL,children:n(T,{content:Ft,size:"lg"})})})]}),ne=i.memo(oe),ae=({items:t,onDelete:e})=>n(Xt,{"data-testid":"stChatUploadedFiles",children:n(Gt,{children:t.map(s=>n(jt,{children:n(ne,{fileInfo:s,onDelete:e})},s.id))})}),re=i.memo(ae),ie=({getNextLocalFileId:t,addFiles:e,updateFile:s,uploadClient:p,element:f,onUploadProgress:u,onUploadComplete:C})=>(b,d)=>{const m=q.CancelToken.source(),c=new nt(d.name,d.size,t(),{type:"uploading",cancelToken:m,progress:1});e([c]),p.uploadFile({formId:"",...f},b.uploadUrl,d,h=>u(h,c.id),m.token).then(()=>C(c.id,b)).catch(h=>{q.isCancel(h)||s(c.id,c.setStatus({type:"error",errorMessage:h?h.toString():"Unknown error"}))})},se=({acceptMultipleFiles:t,maxFileSize:e,uploadClient:s,uploadFile:p,addFiles:f,getNextLocalFileId:u,deleteExistingFiles:C,onUploadComplete:b})=>(d,m)=>{if(!t&&d.length===0&&m.length>1){const c=m.findIndex(h=>{var x;return((x=h.errors)==null?void 0:x[0].code)===Ut.TooManyFiles});c>=0&&(d.push(m[c].file),m.splice(c,1))}if(!t&&d.length>0&&C(),s.fetchFileURLs(d).then(c=>{Ct(c,d).forEach(([h,x])=>{p(h,x)})}).catch(c=>{f(d.map(h=>new nt(h.name,h.size,u(),{type:"error",errorMessage:c})))}),m.length>0){const c=m.map(h=>zt(h,u(),e));f(c)}b()},le=({getRootProps:t,getInputProps:e,acceptFile:s,disabled:p,theme:f})=>F(Kt,{disabled:p,children:[F(Ot,{"data-testid":"stChatInputFileUploadButton",disabled:p,...t(),children:[n("input",{...e()}),n(vt,{content:`Upload or drag and drop ${s===I.Multiple?"files":"a file"}`,placement:Z.TOP,onMouseEnterDelay:500,children:n(tt,{kind:et.MINIMAL,disabled:p,children:n(T,{content:at,size:"lg",color:p?f.colors.fadedText40:f.colors.fadedText60})})})]}),n(_t,{})]}),de=i.memo(le),ce=({getRootProps:t,getInputProps:e,acceptFile:s,inputHeight:p})=>F(ot,{children:[n(At,{height:p,...t(),children:n("input",{...e()})}),n(Pt,{height:p,children:`Drag and drop ${s===I.Multiple?"files":"a file"} here`})]}),pe=i.memo(ce),ue=6.5,k=1,M=(t,e,s)=>s.map(p=>p.id===t?e:p),V=(t,e)=>e.find(s=>s.id===t);function ge({disabled:t,element:e,widgetMgr:s,fragmentId:p,uploadClient:f}){const u=W(),{placeholder:C,maxChars:b}=e,d=i.useRef(null),m=i.useRef(0),c=i.useRef({minHeight:0,maxHeight:0}),[h,x]=It(),[E,B]=i.useState(e.default),[U,D]=i.useState(0),[H,it]=i.useState(!1),[w,S]=i.useState([]),[z,R]=i.useState(!1),L=i.useMemo(()=>w.some(o=>o.status.type==="uploading")?!1:E!==""||w.length>0,[w,E]),v=bt(e.acceptFile),A=Tt(e.maxUploadSizeMb,N.Megabyte,N.Byte),P=i.useCallback(o=>S(a=>[...a,...o]),[]),K=i.useCallback(o=>{S(a=>{const l=V(o,a);return $(l)?a:(l.status.type==="uploading"&&l.status.cancelToken.cancel(),l.status.type==="uploaded"&&l.status.fileUrls.deleteUrl&&f.deleteFile(l.status.fileUrls.deleteUrl),a.filter(r=>r.id!==o))})},[f]),st=()=>{const o=w.filter(a=>a.status.type==="uploaded").map(a=>{const{name:l,size:r,status:y}=a,{fileId:ut,fileUrls:gt}=y;return new xt({fileId:ut,fileUrls:gt,name:l,size:r})});return new wt({uploadedFileInfo:o})},O=()=>m.current++,lt=se({acceptMultipleFiles:v===I.Multiple,maxFileSize:A,uploadClient:f,uploadFile:ie({getNextLocalFileId:O,addFiles:P,updateFile:(o,a)=>{S(l=>M(o,a,l))},uploadClient:f,element:e,onUploadProgress:(o,a)=>{S(l=>{const r=V(a,l);if($(r)||r.status.type!=="uploading")return l;const y=Math.round(o.loaded*100/o.total);return r.status.progress===y?l:M(a,r.setStatus({type:"uploading",cancelToken:r.status.cancelToken,progress:y}),l)})},onUploadComplete:(o,a)=>{S(l=>{const r=V(o,l);return $(r)||r.status.type!=="uploading"?l:M(r.id,r.setStatus({type:"uploaded",fileId:a.fileId,fileUrls:a}),l)})}}),addFiles:P,getNextLocalFileId:O,deleteExistingFiles:()=>w.forEach(o=>K(o.id)),onUploadComplete:()=>{d.current&&d.current.focus()}}),{getRootProps:_,getInputProps:X}=Ht({onDrop:lt,multiple:v===I.Multiple,accept:Bt(e.fileType),maxSize:A}),G=()=>{let o=0;const{current:a}=d;return a&&(a.style.height="auto",o=a.scrollHeight,a.style.height=""),o},j=()=>{if(d.current&&d.current.focus(),!L||t)return;const o={data:E,fileUploaderState:st()};s.setChatInputValue(e,o,{fromUi:!0},p),S([]),B(""),D(0)},dt=o=>{const{metaKey:a,ctrlKey:l,shiftKey:r}=o;Rt(o)&&!r&&!l&&!a&&(o.preventDefault(),j())},ct=o=>{const{value:a}=o.target,{maxChars:l}=e;l!==0&&a.length>l||(B(a),D(G()))};i.useEffect(()=>{if(e.setValue){e.setValue=!1;const o=e.value||"";B(o)}},[e]),i.useLayoutEffect(()=>{if(d.current){const{offsetHeight:o}=d.current;c.current.minHeight=o,c.current.maxHeight=o*ue}},[d]),i.useEffect(()=>{const o=r=>{var y;r.preventDefault(),r.stopPropagation(),!z&&((y=r.dataTransfer)!=null&&y.types.includes("Files"))&&R(!0)},a=r=>{r.preventDefault(),r.stopPropagation(),z&&(r.clientX<=0&&r.clientY<=0||r.clientX>=window.innerWidth&&r.clientY>=window.innerHeight)&&R(!1)},l=r=>{r.preventDefault(),r.stopPropagation(),z&&R(!1)};return window.addEventListener("dragover",o),window.addEventListener("drop",l),window.addEventListener("dragleave",a),()=>{window.removeEventListener("dragover",o),window.removeEventListener("drop",l),window.removeEventListener("dragleave",a)}},[z]),i.useLayoutEffect(()=>{const{minHeight:o}=c.current;it(U>0&&d.current?Math.abs(U-o)>k:!1)},[U]),i.useLayoutEffect(()=>{D(G())},[C]);const{maxHeight:Y}=c.current,pt=v!==I.None&&z;return F(ot,{children:[v===I.None?null:n(re,{items:[...w],onDelete:K}),n(kt,{className:"stChatInput","data-testid":"stChatInput",ref:x,children:pt?n(pe,{getRootProps:_,getInputProps:X,acceptFile:v,inputHeight:H?`${U+k}px`:u.sizes.minElementHeight}):F(Mt,{extended:H,children:[v===I.None?null:n(de,{getRootProps:_,getInputProps:X,acceptFile:v,disabled:t,theme:u}),n($t,{inputRef:d,value:E,placeholder:C,onChange:ct,onKeyDown:dt,"aria-label":C,disabled:t,rows:1,overrides:{Root:{style:{minHeight:u.sizes.minElementHeight,outline:"none",borderLeftWidth:"0",borderRightWidth:"0",borderTopWidth:"0",borderBottomWidth:"0",borderTopLeftRadius:"0",borderTopRightRadius:"0",borderBottomRightRadius:"0",borderBottomLeftRadius:"0"}},Input:{props:{"data-testid":"stChatInputTextArea"},style:{lineHeight:u.lineHeights.inputWidget,"::placeholder":{opacity:"0.7"},height:H?`${U+k}px`:"auto",maxHeight:Y?`${Y}px`:"none",paddingLeft:u.spacing.none,paddingBottom:u.spacing.sm,paddingTop:u.spacing.sm,paddingRight:`calc(${u.iconSizes.xl} + 2 * ${u.spacing.sm} + ${u.spacing.sm})`}}}}),h>u.breakpoints.hideWidgetDetails&&n(Wt,{children:n(Dt,{dirty:L,value:E,maxLength:b,type:"chat",inForm:!1})}),n(Nt,{children:n(Vt,{onClick:j,disabled:!L||t,extended:H,"data-testid":"stChatInputSubmitButton",children:n(T,{content:rt,size:"xl",color:"inherit"})})})]})})]})}const we=i.memo(ge);export{we as default};
1
+ import{r as i,E as J,_ as Q,n as g,B as ht,z as W,j as n,ba as Z,bu as ft,C as F,bp as tt,b5 as et,bo as T,a$ as mt,bG as yt,bj as Ct,bH as I,bs as vt,F as ot,bh as It,bI as bt,M as $,bl as xt,bk as wt}from"./index.DCKU7zCS.js";import{g as St,F as N,C as Ft,I as Et,E as Ut,a as zt,s as Tt,u as Ht,b as Bt}from"./FileHelper.GdWJakHI.js";import{I as Dt}from"./InputInstructions.BXUos__H.js";import{i as Rt}from"./inputUtils.CQWz5UKz.js";import{E as Lt}from"./ErrorOutline.esm.BYHxp3m6.js";import{a as q}from"./index.t--hEgTQ.js";import{U as nt}from"./UploadFileInfo.C-jY39rj.js";import{T as $t}from"./textarea.CQnqAl1g.js";import"./base-input.DDkkgpGf.js";var at=i.forwardRef(function(t,e){var s={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return i.createElement(J,Q({iconAttrs:s,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},t,{ref:e}),i.createElement("path",{fill:"none",d:"M0 0h24v24H0V0z"}),i.createElement("path",{d:"M16.5 6v11.5c0 2.21-1.79 4-4 4s-4-1.79-4-4V5a2.5 2.5 0 015 0v10.5c0 .55-.45 1-1 1s-1-.45-1-1V6H10v9.5a2.5 2.5 0 005 0V5c0-2.21-1.79-4-4-4S7 2.79 7 5v12.5c0 3.04 2.46 5.5 5.5 5.5s5.5-2.46 5.5-5.5V6h-1.5z"}))});at.displayName="AttachFile";var rt=i.forwardRef(function(t,e){var s={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return i.createElement(J,Q({iconAttrs:s,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},t,{ref:e}),i.createElement("rect",{width:24,height:24,fill:"none"}),i.createElement("path",{d:"M3 5.51v3.71c0 .46.31.86.76.97L11 12l-7.24 1.81c-.45.11-.76.51-.76.97v3.71c0 .72.73 1.2 1.39.92l15.42-6.49c.82-.34.82-1.5 0-1.84L4.39 4.58C3.73 4.31 3 4.79 3 5.51z"}))});rt.displayName="Send";const kt=g("div",{target:"e1togvvn0"})("border:none;position:relative;display:flex;"),Mt=g("div",{target:"e1togvvn1"})(({theme:t,extended:e})=>({border:`${t.sizes.borderWidth} solid`,borderColor:t.colors.widgetBorderColor??t.colors.transparent,borderRadius:t.radii.chatInput,backgroundColor:t.colors.secondaryBg,position:"relative",flexGrow:1,display:"flex",alignItems:"center",paddingLeft:t.spacing.lg,maxHeight:e?"none":t.sizes.minElementHeight,gap:t.spacing.sm,overflow:"hidden",":focus-within":{borderColor:t.colors.primary}})),Vt=g("button",{target:"e1togvvn2"})(({theme:t,disabled:e,extended:s})=>{const p=ht(t),[f,u]=p?[t.colors.gray60,t.colors.gray80]:[t.colors.gray80,t.colors.gray40];return{border:"none",backgroundColor:t.colors.transparent,borderTopRightRadius:s?"0":t.radii.chatInput,borderTopLeftRadius:s?t.radii.default:"0",borderBottomRightRadius:t.radii.chatInput,display:"inline-flex",alignItems:"center",justifyContent:"center",lineHeight:t.lineHeights.none,margin:t.spacing.none,padding:t.spacing.sm,color:e?f:u,pointerEvents:"auto","&:focus":{outline:"none"},":focus":{outline:"none"},"&:focus-visible":{backgroundColor:p?t.colors.gray10:t.colors.gray90},"&:hover":{color:t.colors.primary},"&:disabled, &:disabled:hover, &:disabled:active":{backgroundColor:t.colors.transparent,borderColor:t.colors.transparent,color:t.colors.gray,cursor:"not-allowed"}}}),Nt=g("div",{target:"e1togvvn3"})(({theme:t})=>({display:"flex",alignItems:"flex-end",height:"100%",position:"absolute",right:0,marginBottom:`-${t.sizes.borderWidth}`,pointerEvents:"none"})),Wt=g("div",{target:"e1togvvn4"})(({theme:t})=>({position:"absolute",bottom:"0px",right:`calc(${t.iconSizes.xl} + 2 * ${t.spacing.sm} + ${t.spacing.sm})`})),At=g("div",{target:"e15560op0"})(({theme:t,height:e})=>({backgroundColor:t.colors.transparent,position:"absolute",left:0,bottom:0,minHeight:`max(${t.sizes.emptyDropdownHeight}, ${e})`,width:"100%",zIndex:t.zIndices.priority})),Pt=g("div",{target:"e15560op1"})(({theme:t,height:e})=>({border:`${t.sizes.borderWidth} solid`,borderColor:t.colors.primary,borderRadius:t.radii.chatInput,backgroundColor:t.colors.secondaryBg,color:t.colors.primary,display:"flex",alignItems:"center",justifyContent:"center",height:e,width:"100%",fontWeight:t.fontWeights.bold})),Kt=g("div",{target:"e15560op2"})(({theme:t,disabled:e})=>({display:"flex",alignItems:"top",height:"100%",marginTop:`-${t.sizes.borderWidth}`,cursor:e?"not-allowed":"auto"})),Ot=g("div",{target:"e15560op3"})(({disabled:t})=>({pointerEvents:t?"none":"auto"})),_t=g("div",{target:"e15560op4"})(({theme:t})=>({marginTop:"0.625em",marginLeft:t.spacing.sm,height:t.spacing.xl,width:t.sizes.borderWidth,backgroundColor:t.colors.fadedText20})),Xt=g("div",{target:"e15560op5"})(({theme:t})=>({left:0,right:0,lineHeight:t.lineHeights.tight,paddingLeft:t.spacing.sm,paddingRight:t.spacing.sm,overflowX:"auto"})),Gt=g("div",{target:"e15560op6"})({display:"flex"}),jt=g("div",{target:"e15560op7"})({flex:"0 0 auto"}),Yt=g("div",{target:"e15560op8"})(({theme:t})=>({display:"flex",alignItems:"center",padding:t.spacing.sm,gap:t.spacing.twoXS})),qt=g("div",{target:"e15560op9"})(({theme:t})=>({color:t.colors.fadedText60})),Jt=g("div",{target:"e15560op10"})(({theme:t,fileStatus:e})=>({overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:e.type==="uploaded"?t.colors.bodyText:t.colors.fadedText60})),Qt=g("div",{target:"e15560op11"})(({theme:t})=>({marginRight:t.spacing.md,color:t.colors.fadedText60})),Zt=g("small",{target:"e15560op12"})(({theme:t})=>({display:"flex",alignItems:"center",maxHeight:t.sizes.smallElementHeight,color:t.colors.fadedText60,"& :hover":{color:t.colors.bodyText}}));function te({children:t,content:e}){const s=W();return n(ft,{content:e,placement:Z.TOP,overrides:{Body:{style:{top:`-${s.sizes.minElementHeight}`}}},children:t})}const ee=({fileInfo:t})=>{const e=W(),{type:s}=t.status;switch(s){case"uploading":return n(yt,{usingCustomTheme:!1,"data-testid":"stChatInputFileIconSpinner",size:"lg",margin:"0",padding:"0"});case"error":return n(te,{content:t.status.errorMessage,children:n(T,{color:e.colors.red,content:Lt,size:"lg"})});case"uploaded":return n(T,{content:Et,size:"lg"});default:return mt(s),null}},oe=({fileInfo:t,onDelete:e})=>F(Yt,{className:"stChatInputFile","data-testid":"stChatInputFile",children:[n(qt,{children:n(ee,{fileInfo:t})}),n(Jt,{className:"stChatInputFileName","data-testid":"stChatInputFileName",title:t.name,fileStatus:t.status,children:t.name}),n(Qt,{children:St(t.size,N.Byte)}),n(Zt,{"data-testid":"stChatInputDeleteBtn",children:n(tt,{onClick:()=>e(t.id),kind:et.MINIMAL,children:n(T,{content:Ft,size:"lg"})})})]}),ne=i.memo(oe),ae=({items:t,onDelete:e})=>n(Xt,{"data-testid":"stChatUploadedFiles",children:n(Gt,{children:t.map(s=>n(jt,{children:n(ne,{fileInfo:s,onDelete:e})},s.id))})}),re=i.memo(ae),ie=({getNextLocalFileId:t,addFiles:e,updateFile:s,uploadClient:p,element:f,onUploadProgress:u,onUploadComplete:C})=>(b,d)=>{const m=q.CancelToken.source(),c=new nt(d.name,d.size,t(),{type:"uploading",cancelToken:m,progress:1});e([c]),p.uploadFile({formId:"",...f},b.uploadUrl,d,h=>u(h,c.id),m.token).then(()=>C(c.id,b)).catch(h=>{q.isCancel(h)||s(c.id,c.setStatus({type:"error",errorMessage:h?h.toString():"Unknown error"}))})},se=({acceptMultipleFiles:t,maxFileSize:e,uploadClient:s,uploadFile:p,addFiles:f,getNextLocalFileId:u,deleteExistingFiles:C,onUploadComplete:b})=>(d,m)=>{if(!t&&d.length===0&&m.length>1){const c=m.findIndex(h=>{var x;return((x=h.errors)==null?void 0:x[0].code)===Ut.TooManyFiles});c>=0&&(d.push(m[c].file),m.splice(c,1))}if(!t&&d.length>0&&C(),s.fetchFileURLs(d).then(c=>{Ct(c,d).forEach(([h,x])=>{p(h,x)})}).catch(c=>{f(d.map(h=>new nt(h.name,h.size,u(),{type:"error",errorMessage:c})))}),m.length>0){const c=m.map(h=>zt(h,u(),e));f(c)}b()},le=({getRootProps:t,getInputProps:e,acceptFile:s,disabled:p,theme:f})=>F(Kt,{disabled:p,children:[F(Ot,{"data-testid":"stChatInputFileUploadButton",disabled:p,...t(),children:[n("input",{...e()}),n(vt,{content:`Upload or drag and drop ${s===I.Multiple?"files":"a file"}`,placement:Z.TOP,onMouseEnterDelay:500,children:n(tt,{kind:et.MINIMAL,disabled:p,children:n(T,{content:at,size:"lg",color:p?f.colors.fadedText40:f.colors.fadedText60})})})]}),n(_t,{})]}),de=i.memo(le),ce=({getRootProps:t,getInputProps:e,acceptFile:s,inputHeight:p})=>F(ot,{children:[n(At,{height:p,...t(),children:n("input",{...e()})}),n(Pt,{height:p,children:`Drag and drop ${s===I.Multiple?"files":"a file"} here`})]}),pe=i.memo(ce),ue=6.5,k=1,M=(t,e,s)=>s.map(p=>p.id===t?e:p),V=(t,e)=>e.find(s=>s.id===t);function ge({disabled:t,element:e,widgetMgr:s,fragmentId:p,uploadClient:f}){const u=W(),{placeholder:C,maxChars:b}=e,d=i.useRef(null),m=i.useRef(0),c=i.useRef({minHeight:0,maxHeight:0}),[h,x]=It(),[E,B]=i.useState(e.default),[U,D]=i.useState(0),[H,it]=i.useState(!1),[w,S]=i.useState([]),[z,R]=i.useState(!1),L=i.useMemo(()=>w.some(o=>o.status.type==="uploading")?!1:E!==""||w.length>0,[w,E]),v=bt(e.acceptFile),A=Tt(e.maxUploadSizeMb,N.Megabyte,N.Byte),P=i.useCallback(o=>S(a=>[...a,...o]),[]),K=i.useCallback(o=>{S(a=>{const l=V(o,a);return $(l)?a:(l.status.type==="uploading"&&l.status.cancelToken.cancel(),l.status.type==="uploaded"&&l.status.fileUrls.deleteUrl&&f.deleteFile(l.status.fileUrls.deleteUrl),a.filter(r=>r.id!==o))})},[f]),st=()=>{const o=w.filter(a=>a.status.type==="uploaded").map(a=>{const{name:l,size:r,status:y}=a,{fileId:ut,fileUrls:gt}=y;return new xt({fileId:ut,fileUrls:gt,name:l,size:r})});return new wt({uploadedFileInfo:o})},O=()=>m.current++,lt=se({acceptMultipleFiles:v===I.Multiple,maxFileSize:A,uploadClient:f,uploadFile:ie({getNextLocalFileId:O,addFiles:P,updateFile:(o,a)=>{S(l=>M(o,a,l))},uploadClient:f,element:e,onUploadProgress:(o,a)=>{S(l=>{const r=V(a,l);if($(r)||r.status.type!=="uploading")return l;const y=Math.round(o.loaded*100/o.total);return r.status.progress===y?l:M(a,r.setStatus({type:"uploading",cancelToken:r.status.cancelToken,progress:y}),l)})},onUploadComplete:(o,a)=>{S(l=>{const r=V(o,l);return $(r)||r.status.type!=="uploading"?l:M(r.id,r.setStatus({type:"uploaded",fileId:a.fileId,fileUrls:a}),l)})}}),addFiles:P,getNextLocalFileId:O,deleteExistingFiles:()=>w.forEach(o=>K(o.id)),onUploadComplete:()=>{d.current&&d.current.focus()}}),{getRootProps:_,getInputProps:X}=Ht({onDrop:lt,multiple:v===I.Multiple,accept:Bt(e.fileType),maxSize:A}),G=()=>{let o=0;const{current:a}=d;return a&&(a.style.height="auto",o=a.scrollHeight,a.style.height=""),o},j=()=>{if(d.current&&d.current.focus(),!L||t)return;const o={data:E,fileUploaderState:st()};s.setChatInputValue(e,o,{fromUi:!0},p),S([]),B(""),D(0)},dt=o=>{const{metaKey:a,ctrlKey:l,shiftKey:r}=o;Rt(o)&&!r&&!l&&!a&&(o.preventDefault(),j())},ct=o=>{const{value:a}=o.target,{maxChars:l}=e;l!==0&&a.length>l||(B(a),D(G()))};i.useEffect(()=>{if(e.setValue){e.setValue=!1;const o=e.value||"";B(o)}},[e]),i.useLayoutEffect(()=>{if(d.current){const{offsetHeight:o}=d.current;c.current.minHeight=o,c.current.maxHeight=o*ue}},[d]),i.useEffect(()=>{const o=r=>{var y;r.preventDefault(),r.stopPropagation(),!z&&((y=r.dataTransfer)!=null&&y.types.includes("Files"))&&R(!0)},a=r=>{r.preventDefault(),r.stopPropagation(),z&&(r.clientX<=0&&r.clientY<=0||r.clientX>=window.innerWidth&&r.clientY>=window.innerHeight)&&R(!1)},l=r=>{r.preventDefault(),r.stopPropagation(),z&&R(!1)};return window.addEventListener("dragover",o),window.addEventListener("drop",l),window.addEventListener("dragleave",a),()=>{window.removeEventListener("dragover",o),window.removeEventListener("drop",l),window.removeEventListener("dragleave",a)}},[z]),i.useLayoutEffect(()=>{const{minHeight:o}=c.current;it(U>0&&d.current?Math.abs(U-o)>k:!1)},[U]),i.useLayoutEffect(()=>{D(G())},[C]);const{maxHeight:Y}=c.current,pt=v!==I.None&&z;return F(ot,{children:[v===I.None?null:n(re,{items:[...w],onDelete:K}),n(kt,{className:"stChatInput","data-testid":"stChatInput",ref:x,children:pt?n(pe,{getRootProps:_,getInputProps:X,acceptFile:v,inputHeight:H?`${U+k}px`:u.sizes.minElementHeight}):F(Mt,{extended:H,children:[v===I.None?null:n(de,{getRootProps:_,getInputProps:X,acceptFile:v,disabled:t,theme:u}),n($t,{inputRef:d,value:E,placeholder:C,onChange:ct,onKeyDown:dt,"aria-label":C,disabled:t,rows:1,overrides:{Root:{style:{minHeight:u.sizes.minElementHeight,outline:"none",borderLeftWidth:"0",borderRightWidth:"0",borderTopWidth:"0",borderBottomWidth:"0",borderTopLeftRadius:"0",borderTopRightRadius:"0",borderBottomRightRadius:"0",borderBottomLeftRadius:"0"}},Input:{props:{"data-testid":"stChatInputTextArea"},style:{lineHeight:u.lineHeights.inputWidget,"::placeholder":{opacity:"0.7"},height:H?`${U+k}px`:"auto",maxHeight:Y?`${Y}px`:"none",paddingLeft:u.spacing.none,paddingBottom:u.spacing.sm,paddingTop:u.spacing.sm,paddingRight:`calc(${u.iconSizes.xl} + 2 * ${u.spacing.sm} + ${u.spacing.sm})`}}}}),h>u.breakpoints.hideWidgetDetails&&n(Wt,{children:n(Dt,{dirty:L,value:E,maxLength:b,type:"chat",inForm:!1})}),n(Nt,{children:n(Vt,{onClick:j,disabled:!L||t,extended:H,"data-testid":"stChatInputSubmitButton",children:n(T,{content:rt,size:"xl",color:"inherit"})})})]})})]})}const we=i.memo(ge);export{we as default};
@@ -1,4 +1,4 @@
1
- import{r as u,E as $,_ as H,aW as mt,bj as Ht,bk as Vt,bl as jt,M as X,O as q,R as yt,aD as Gt,n as P,bm as Xt,C as z,j as v,bn as qt,b5 as Yt,bo as Kt,bp as Jt,l as Qt,z as Zt,bq as tt,H as te,aA as ee,br as ie,bs as se,ba as ne,bt as re}from"./index.B1VulLzc.js";import{u as oe,F as ae}from"./FormClearHelper.D-LphorD.js";import{T as le,a as ft}from"./Toolbar.CCh_4t83.js";import{u as ce}from"./Hooks.Bi7tTkGd.js";import{c as de}from"./createDownloadLinkElement.DZMwyjvU.js";import{F as he,D as ue}from"./FileDownload.esm.DRAkCta9.js";var wt=u.forwardRef(function(s,t){var e={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return u.createElement($,H({iconAttrs:e,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},s,{ref:t}),u.createElement("g",{fill:"none"},u.createElement("rect",{width:24,height:24}),u.createElement("rect",{width:24,height:24}),u.createElement("rect",{width:24,height:24})),u.createElement("path",{d:"M12 14c1.66 0 3-1.34 3-3V5c0-1.66-1.34-3-3-3S9 3.34 9 5v6c0 1.66 1.34 3 3 3z"}),u.createElement("path",{d:"M17 11c0 2.76-2.24 5-5 5s-5-2.24-5-5H5c0 3.53 2.61 6.43 6 6.92V21h2v-3.08c3.39-.49 6-3.39 6-6.92h-2z"}))});wt.displayName="Mic";var St=u.forwardRef(function(s,t){var e={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return u.createElement($,H({iconAttrs:e,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},s,{ref:t}),u.createElement("rect",{width:24,height:24,fill:"none"}),u.createElement("path",{d:"M8 19c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2s-2 .9-2 2v10c0 1.1.9 2 2 2zm6-12v10c0 1.1.9 2 2 2s2-.9 2-2V7c0-1.1-.9-2-2-2s-2 .9-2 2z"}))});St.displayName="Pause";var Ct=u.forwardRef(function(s,t){var e={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return u.createElement($,H({iconAttrs:e,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},s,{ref:t}),u.createElement("rect",{width:24,height:24,fill:"none"}),u.createElement("path",{d:"M8 6.82v10.36c0 .79.87 1.27 1.54.84l8.14-5.18a1 1 0 000-1.69L9.54 5.98A.998.998 0 008 6.82z"}))});Ct.displayName="PlayArrow";var Et=u.forwardRef(function(s,t){var e={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return u.createElement($,H({iconAttrs:e,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},s,{ref:t}),u.createElement("path",{fill:"none",d:"M0 0h24v24H0V0z"}),u.createElement("path",{d:"M17.65 6.35a7.95 7.95 0 00-6.48-2.31c-3.67.37-6.69 3.35-7.1 7.02C3.52 15.91 7.27 20 12 20a7.98 7.98 0 007.21-4.56c.32-.67-.16-1.44-.9-1.44-.37 0-.72.2-.88.53a5.994 5.994 0 01-6.8 3.31c-2.22-.49-4.01-2.3-4.48-4.52A6.002 6.002 0 0112 6c1.66 0 3.14.69 4.22 1.78l-1.51 1.51c-.63.63-.19 1.71.7 1.71H19c.55 0 1-.45 1-1V6.41c0-.89-1.08-1.34-1.71-.71l-.64.65z"}))});Et.displayName="Refresh";var Rt=u.forwardRef(function(s,t){var e={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return u.createElement($,H({iconAttrs:e,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},s,{ref:t}),u.createElement("g",{fill:"none"},u.createElement("rect",{width:24,height:24}),u.createElement("rect",{width:24,height:24})),u.createElement("path",{fillRule:"evenodd",d:"M9 16h6c.55 0 1-.45 1-1V9c0-.55-.45-1-1-1H9c-.55 0-1 .45-1 1v6c0 .55.45 1 1 1zm3-14C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2z"}))});Rt.displayName="StopCircle";function R(s,t,e,i){return new(e||(e=Promise))(function(n,r){function a(c){try{d(i.next(c))}catch(l){r(l)}}function o(c){try{d(i.throw(c))}catch(l){r(l)}}function d(c){var l;c.done?n(c.value):(l=c.value,l instanceof e?l:new e(function(p){p(l)})).then(a,o)}d((i=i.apply(s,t||[])).next())})}let V=class{constructor(){this.listeners={}}on(t,e,i){if(this.listeners[t]||(this.listeners[t]=new Set),this.listeners[t].add(e),i==null?void 0:i.once){const n=()=>{this.un(t,n),this.un(t,e)};return this.on(t,n),n}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(s,t){return R(this,void 0,void 0,function*(){const e=new AudioContext({sampleRate:t});return e.decodeAudioData(s).finally(()=>e.close())})},createBuffer:function(s,t){return typeof s[0]=="number"&&(s=[s]),function(e){const i=e[0];if(i.some(n=>n>1||n<-1)){const n=i.length;let r=0;for(let a=0;a<n;a++){const o=Math.abs(i[a]);o>r&&(r=o)}for(const a of e)for(let o=0;o<n;o++)a[o]/=r}}(s),{duration:t,length:s[0].length,sampleRate:s[0].length/t,numberOfChannels:s.length,getChannelData:e=>s==null?void 0:s[e],copyFromChannel:AudioBuffer.prototype.copyFromChannel,copyToChannel:AudioBuffer.prototype.copyToChannel}}};function Pt(s,t){const e=t.xmlns?document.createElementNS(t.xmlns,s):document.createElement(s);for(const[i,n]of Object.entries(t))if(i==="children")for(const[r,a]of Object.entries(t))typeof a=="string"?e.appendChild(document.createTextNode(a)):e.appendChild(Pt(r,a));else i==="style"?Object.assign(e.style,n):i==="textContent"?e.textContent=n:e.setAttribute(i,n.toString());return e}function gt(s,t,e){const i=Pt(s,t||{});return e==null||e.appendChild(i),i}var pe=Object.freeze({__proto__:null,createElement:gt,default:gt});const me={fetchBlob:function(s,t,e){return R(this,void 0,void 0,function*(){const i=yield fetch(s,e);if(i.status>=400)throw new Error(`Failed to fetch ${s}: ${i.status} (${i.statusText})`);return function(n,r){R(this,void 0,void 0,function*(){if(!n.body||!n.headers)return;const a=n.body.getReader(),o=Number(n.headers.get("Content-Length"))||0;let d=0;const c=p=>R(this,void 0,void 0,function*(){d+=(p==null?void 0:p.length)||0;const h=Math.round(d/o*100);r(h)}),l=()=>R(this,void 0,void 0,function*(){let p;try{p=yield a.read()}catch{return}p.done||(c(p.value),yield l())});l()})}(i.clone(),t),i.blob()})}};class fe extends V{constructor(t){super(),this.isExternalMedia=!1,t.media?(this.media=t.media,this.isExternalMedia=!0):this.media=document.createElement("audio"),t.mediaControls&&(this.media.controls=!0),t.autoplay&&(this.media.autoplay=!0),t.playbackRate!=null&&this.onMediaEvent("canplay",()=>{t.playbackRate!=null&&(this.media.playbackRate=t.playbackRate)},{once:!0})}onMediaEvent(t,e,i){return this.media.addEventListener(t,e,i),()=>this.media.removeEventListener(t,e,i)}getSrc(){return this.media.currentSrc||this.media.src||""}revokeSrc(){const t=this.getSrc();t.startsWith("blob:")&&URL.revokeObjectURL(t)}canPlayType(t){return this.media.canPlayType(t)!==""}setSrc(t,e){const i=this.getSrc();if(t&&i===t)return;this.revokeSrc();const n=e instanceof Blob&&(this.canPlayType(e.type)||!t)?URL.createObjectURL(e):t;i&&(this.media.src="");try{this.media.src=n}catch{this.media.src=t}}destroy(){this.isExternalMedia||(this.media.pause(),this.media.remove(),this.revokeSrc(),this.media.src="",this.media.load())}setMediaElement(t){this.media=t}play(){return R(this,void 0,void 0,function*(){return this.media.play()})}pause(){this.media.pause()}isPlaying(){return!this.media.paused&&!this.media.ended}setTime(t){this.media.currentTime=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 N extends V{constructor(t,e){super(),this.timeouts=[],this.isScrollable=!1,this.audioData=null,this.resizeObserver=null,this.lastContainerWidth=0,this.isDragging=!1,this.subscriptions=[],this.unsubscribeOnScroll=[],this.subscriptions=[],this.options=t;const i=this.parentFromOptionsContainer(t.container);this.parent=i;const[n,r]=this.initHtml();i.appendChild(n),this.container=n,this.scrollContainer=r.querySelector(".scroll"),this.wrapper=r.querySelector(".wrapper"),this.canvasWrapper=r.querySelector(".canvases"),this.progressWrapper=r.querySelector(".progress"),this.cursor=r.querySelector(".cursor"),e&&r.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(),n=e.clientX-i.left,r=e.clientY-i.top;return[n/i.width,r/i.height]};if(this.wrapper.addEventListener("click",e=>{const[i,n]=t(e);this.emit("click",i,n)}),this.wrapper.addEventListener("dblclick",e=>{const[i,n]=t(e);this.emit("dblclick",i,n)}),this.options.dragToSeek!==!0&&typeof this.options.dragToSeek!="object"||this.initDrag(),this.scrollContainer.addEventListener("scroll",()=>{const{scrollLeft:e,scrollWidth:i,clientWidth:n}=this.scrollContainer,r=e/i,a=(e+n)/i;this.emit("scroll",r,a,e,e+n)}),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,n,r=3,a=0,o=100){if(!t)return()=>{};const d=matchMedia("(pointer: coarse)").matches;let c=()=>{};const l=p=>{if(p.button!==a)return;p.preventDefault(),p.stopPropagation();let h=p.clientX,m=p.clientY,f=!1;const b=Date.now(),g=w=>{if(w.preventDefault(),w.stopPropagation(),d&&Date.now()-b<o)return;const A=w.clientX,T=w.clientY,k=A-h,W=T-m;if(f||Math.abs(k)>r||Math.abs(W)>r){const I=t.getBoundingClientRect(),{left:U,top:L}=I;f||(i==null||i(h-U,m-L),f=!0),e(k,W,A-U,T-L),h=A,m=T}},S=w=>{if(f){const A=w.clientX,T=w.clientY,k=t.getBoundingClientRect(),{left:W,top:I}=k;n==null||n(A-W,T-I)}c()},y=w=>{w.relatedTarget&&w.relatedTarget!==document.documentElement||S(w)},x=w=>{f&&(w.stopPropagation(),w.preventDefault())},D=w=>{f&&w.preventDefault()};document.addEventListener("pointermove",g),document.addEventListener("pointerup",S),document.addEventListener("pointerout",y),document.addEventListener("pointercancel",y),document.addEventListener("touchmove",D,{passive:!1}),document.addEventListener("click",x,{capture:!0}),c=()=>{document.removeEventListener("pointermove",g),document.removeEventListener("pointerup",S),document.removeEventListener("pointerout",y),document.removeEventListener("pointercancel",y),document.removeEventListener("touchmove",D),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 n=((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 r=this.parent.clientHeight||128;return e!=null&&e.every(a=>!a.overlay)?r/n:r}return 128}initHtml(){const t=document.createElement("div"),e=t.attachShadow({mode:"open"}),i=this.options.cspNonce&&typeof this.options.cspNonce=="string"?this.options.cspNonce.replace(/"/g,""):"";return e.innerHTML=`
1
+ import{r as u,E as $,_ as H,aW as mt,bj as Ht,bk as Vt,bl as jt,M as X,O as q,R as yt,aD as Gt,n as P,bm as Xt,C as N,j as v,bn as qt,b5 as Yt,bo as Kt,bp as Jt,l as Qt,z as Zt,bq as tt,H as te,aA as ee,br as ie,bs as se,ba as ne,bt as re}from"./index.DCKU7zCS.js";import{u as oe,F as ae}from"./FormClearHelper.DJyHVHSH.js";import{T as le,a as ft}from"./Toolbar.BHMuD9RK.js";import{u as ce}from"./Hooks.ChGPcfs_.js";import{c as de}from"./createDownloadLinkElement.DZMwyjvU.js";import{F as he,D as ue}from"./FileDownload.esm.ApdK5yXz.js";var wt=u.forwardRef(function(s,t){var e={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return u.createElement($,H({iconAttrs:e,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},s,{ref:t}),u.createElement("g",{fill:"none"},u.createElement("rect",{width:24,height:24}),u.createElement("rect",{width:24,height:24}),u.createElement("rect",{width:24,height:24})),u.createElement("path",{d:"M12 14c1.66 0 3-1.34 3-3V5c0-1.66-1.34-3-3-3S9 3.34 9 5v6c0 1.66 1.34 3 3 3z"}),u.createElement("path",{d:"M17 11c0 2.76-2.24 5-5 5s-5-2.24-5-5H5c0 3.53 2.61 6.43 6 6.92V21h2v-3.08c3.39-.49 6-3.39 6-6.92h-2z"}))});wt.displayName="Mic";var St=u.forwardRef(function(s,t){var e={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return u.createElement($,H({iconAttrs:e,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},s,{ref:t}),u.createElement("rect",{width:24,height:24,fill:"none"}),u.createElement("path",{d:"M8 19c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2s-2 .9-2 2v10c0 1.1.9 2 2 2zm6-12v10c0 1.1.9 2 2 2s2-.9 2-2V7c0-1.1-.9-2-2-2s-2 .9-2 2z"}))});St.displayName="Pause";var Ct=u.forwardRef(function(s,t){var e={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return u.createElement($,H({iconAttrs:e,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},s,{ref:t}),u.createElement("rect",{width:24,height:24,fill:"none"}),u.createElement("path",{d:"M8 6.82v10.36c0 .79.87 1.27 1.54.84l8.14-5.18a1 1 0 000-1.69L9.54 5.98A.998.998 0 008 6.82z"}))});Ct.displayName="PlayArrow";var Et=u.forwardRef(function(s,t){var e={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return u.createElement($,H({iconAttrs:e,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},s,{ref:t}),u.createElement("path",{fill:"none",d:"M0 0h24v24H0V0z"}),u.createElement("path",{d:"M17.65 6.35a7.95 7.95 0 00-6.48-2.31c-3.67.37-6.69 3.35-7.1 7.02C3.52 15.91 7.27 20 12 20a7.98 7.98 0 007.21-4.56c.32-.67-.16-1.44-.9-1.44-.37 0-.72.2-.88.53a5.994 5.994 0 01-6.8 3.31c-2.22-.49-4.01-2.3-4.48-4.52A6.002 6.002 0 0112 6c1.66 0 3.14.69 4.22 1.78l-1.51 1.51c-.63.63-.19 1.71.7 1.71H19c.55 0 1-.45 1-1V6.41c0-.89-1.08-1.34-1.71-.71l-.64.65z"}))});Et.displayName="Refresh";var Rt=u.forwardRef(function(s,t){var e={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return u.createElement($,H({iconAttrs:e,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},s,{ref:t}),u.createElement("g",{fill:"none"},u.createElement("rect",{width:24,height:24}),u.createElement("rect",{width:24,height:24})),u.createElement("path",{fillRule:"evenodd",d:"M9 16h6c.55 0 1-.45 1-1V9c0-.55-.45-1-1-1H9c-.55 0-1 .45-1 1v6c0 .55.45 1 1 1zm3-14C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2z"}))});Rt.displayName="StopCircle";function R(s,t,e,i){return new(e||(e=Promise))(function(n,r){function a(c){try{d(i.next(c))}catch(l){r(l)}}function o(c){try{d(i.throw(c))}catch(l){r(l)}}function d(c){var l;c.done?n(c.value):(l=c.value,l instanceof e?l:new e(function(p){p(l)})).then(a,o)}d((i=i.apply(s,t||[])).next())})}let V=class{constructor(){this.listeners={}}on(t,e,i){if(this.listeners[t]||(this.listeners[t]=new Set),this.listeners[t].add(e),i==null?void 0:i.once){const n=()=>{this.un(t,n),this.un(t,e)};return this.on(t,n),n}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(s,t){return R(this,void 0,void 0,function*(){const e=new AudioContext({sampleRate:t});return e.decodeAudioData(s).finally(()=>e.close())})},createBuffer:function(s,t){return typeof s[0]=="number"&&(s=[s]),function(e){const i=e[0];if(i.some(n=>n>1||n<-1)){const n=i.length;let r=0;for(let a=0;a<n;a++){const o=Math.abs(i[a]);o>r&&(r=o)}for(const a of e)for(let o=0;o<n;o++)a[o]/=r}}(s),{duration:t,length:s[0].length,sampleRate:s[0].length/t,numberOfChannels:s.length,getChannelData:e=>s==null?void 0:s[e],copyFromChannel:AudioBuffer.prototype.copyFromChannel,copyToChannel:AudioBuffer.prototype.copyToChannel}}};function Pt(s,t){const e=t.xmlns?document.createElementNS(t.xmlns,s):document.createElement(s);for(const[i,n]of Object.entries(t))if(i==="children")for(const[r,a]of Object.entries(t))typeof a=="string"?e.appendChild(document.createTextNode(a)):e.appendChild(Pt(r,a));else i==="style"?Object.assign(e.style,n):i==="textContent"?e.textContent=n:e.setAttribute(i,n.toString());return e}function gt(s,t,e){const i=Pt(s,t||{});return e==null||e.appendChild(i),i}var pe=Object.freeze({__proto__:null,createElement:gt,default:gt});const me={fetchBlob:function(s,t,e){return R(this,void 0,void 0,function*(){const i=yield fetch(s,e);if(i.status>=400)throw new Error(`Failed to fetch ${s}: ${i.status} (${i.statusText})`);return function(n,r){R(this,void 0,void 0,function*(){if(!n.body||!n.headers)return;const a=n.body.getReader(),o=Number(n.headers.get("Content-Length"))||0;let d=0;const c=p=>R(this,void 0,void 0,function*(){d+=(p==null?void 0:p.length)||0;const h=Math.round(d/o*100);r(h)}),l=()=>R(this,void 0,void 0,function*(){let p;try{p=yield a.read()}catch{return}p.done||(c(p.value),yield l())});l()})}(i.clone(),t),i.blob()})}};class fe extends V{constructor(t){super(),this.isExternalMedia=!1,t.media?(this.media=t.media,this.isExternalMedia=!0):this.media=document.createElement("audio"),t.mediaControls&&(this.media.controls=!0),t.autoplay&&(this.media.autoplay=!0),t.playbackRate!=null&&this.onMediaEvent("canplay",()=>{t.playbackRate!=null&&(this.media.playbackRate=t.playbackRate)},{once:!0})}onMediaEvent(t,e,i){return this.media.addEventListener(t,e,i),()=>this.media.removeEventListener(t,e,i)}getSrc(){return this.media.currentSrc||this.media.src||""}revokeSrc(){const t=this.getSrc();t.startsWith("blob:")&&URL.revokeObjectURL(t)}canPlayType(t){return this.media.canPlayType(t)!==""}setSrc(t,e){const i=this.getSrc();if(t&&i===t)return;this.revokeSrc();const n=e instanceof Blob&&(this.canPlayType(e.type)||!t)?URL.createObjectURL(e):t;i&&(this.media.src="");try{this.media.src=n}catch{this.media.src=t}}destroy(){this.isExternalMedia||(this.media.pause(),this.media.remove(),this.revokeSrc(),this.media.src="",this.media.load())}setMediaElement(t){this.media=t}play(){return R(this,void 0,void 0,function*(){return this.media.play()})}pause(){this.media.pause()}isPlaying(){return!this.media.paused&&!this.media.ended}setTime(t){this.media.currentTime=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[n,r]=this.initHtml();i.appendChild(n),this.container=n,this.scrollContainer=r.querySelector(".scroll"),this.wrapper=r.querySelector(".wrapper"),this.canvasWrapper=r.querySelector(".canvases"),this.progressWrapper=r.querySelector(".progress"),this.cursor=r.querySelector(".cursor"),e&&r.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(),n=e.clientX-i.left,r=e.clientY-i.top;return[n/i.width,r/i.height]};if(this.wrapper.addEventListener("click",e=>{const[i,n]=t(e);this.emit("click",i,n)}),this.wrapper.addEventListener("dblclick",e=>{const[i,n]=t(e);this.emit("dblclick",i,n)}),this.options.dragToSeek!==!0&&typeof this.options.dragToSeek!="object"||this.initDrag(),this.scrollContainer.addEventListener("scroll",()=>{const{scrollLeft:e,scrollWidth:i,clientWidth:n}=this.scrollContainer,r=e/i,a=(e+n)/i;this.emit("scroll",r,a,e,e+n)}),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,n,r=3,a=0,o=100){if(!t)return()=>{};const d=matchMedia("(pointer: coarse)").matches;let c=()=>{};const l=p=>{if(p.button!==a)return;p.preventDefault(),p.stopPropagation();let h=p.clientX,m=p.clientY,f=!1;const b=Date.now(),g=w=>{if(w.preventDefault(),w.stopPropagation(),d&&Date.now()-b<o)return;const A=w.clientX,T=w.clientY,k=A-h,W=T-m;if(f||Math.abs(k)>r||Math.abs(W)>r){const I=t.getBoundingClientRect(),{left:F,top:L}=I;f||(i==null||i(h-F,m-L),f=!0),e(k,W,A-F,T-L),h=A,m=T}},S=w=>{if(f){const A=w.clientX,T=w.clientY,k=t.getBoundingClientRect(),{left:W,top:I}=k;n==null||n(A-W,T-I)}c()},y=w=>{w.relatedTarget&&w.relatedTarget!==document.documentElement||S(w)},x=w=>{f&&(w.stopPropagation(),w.preventDefault())},D=w=>{f&&w.preventDefault()};document.addEventListener("pointermove",g),document.addEventListener("pointerup",S),document.addEventListener("pointerout",y),document.addEventListener("pointercancel",y),document.addEventListener("touchmove",D,{passive:!1}),document.addEventListener("click",x,{capture:!0}),c=()=>{document.removeEventListener("pointermove",g),document.removeEventListener("pointerup",S),document.removeEventListener("pointerout",y),document.removeEventListener("pointercancel",y),document.removeEventListener("touchmove",D),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 n=((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 r=this.parent.clientHeight||128;return e!=null&&e.every(a=>!a.overlay)?r/n:r}return 128}initHtml(){const t=document.createElement("div"),e=t.attachShadow({mode:"open"}),i=this.options.cspNonce&&typeof this.options.cspNonce=="string"?this.options.cspNonce.replace(/"/g,""):"";return e.innerHTML=`
2
2
  <style${i?` nonce="${i}"`:""}>
3
3
  :host {
4
4
  user-select: none;
@@ -70,4 +70,4 @@ import{r as u,E as $,_ as H,aW as mt,bj as Ht,bk as Vt,bl as jt,M as X,O as q,R
70
70
  <div class="cursor" part="cursor"></div>
71
71
  </div>
72
72
  </div>
73
- `,[t,e]}setOptions(t){if(this.options.container!==t.container){const e=this.parentFromOptionsContainer(t.container);e.appendChild(this.container),this.parent=e}t.dragToSeek!==!0&&typeof this.options.dragToSeek!="object"||this.initDrag(),this.options=t,this.reRender()}getWrapper(){return this.wrapper}getWidth(){return this.scrollContainer.clientWidth}getScroll(){return this.scrollContainer.scrollLeft}setScroll(t){this.scrollContainer.scrollLeft=t}setScrollPercentage(t){const{scrollWidth:e}=this.scrollContainer,i=e*t;this.setScroll(i)}destroy(){var t,e;this.subscriptions.forEach(i=>i()),this.container.remove(),(t=this.resizeObserver)===null||t===void 0||t.disconnect(),(e=this.unsubscribeOnScroll)===null||e===void 0||e.forEach(i=>i()),this.unsubscribeOnScroll=[]}createDelay(t=10){let e,i;const n=()=>{e&&clearTimeout(e),i&&i()};return this.timeouts.push(n),()=>new Promise((r,a)=>{n(),i=a,e=setTimeout(()=>{e=void 0,i=void 0,r()},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"),n=e.height*(window.devicePixelRatio||1),r=i.createLinearGradient(0,0,0,n),a=1/(t.length-1);return t.forEach((o,d)=>{const c=d*a;r.addColorStop(c,o)}),r}getPixelRatio(){return Math.max(1,window.devicePixelRatio||1)}renderBarWaveform(t,e,i,n){const r=t[0],a=t[1]||t[0],o=r.length,{width:d,height:c}=i.canvas,l=c/2,p=this.getPixelRatio(),h=e.barWidth?e.barWidth*p:1,m=e.barGap?e.barGap*p:e.barWidth?h/2:0,f=e.barRadius||0,b=d/(h+m)/o,g=f&&"roundRect"in i?"roundRect":"rect";i.beginPath();let S=0,y=0,x=0;for(let D=0;D<=o;D++){const w=Math.round(D*b);if(w>S){const k=Math.round(y*l*n),W=k+Math.round(x*l*n)||1;let I=l-k;e.barAlign==="top"?I=0:e.barAlign==="bottom"&&(I=c-W),i[g](S*(h+m),I,h,W,f),S=w,y=0,x=0}const A=Math.abs(r[D]||0),T=Math.abs(a[D]||0);A>y&&(y=A),T>x&&(x=T)}i.fill(),i.closePath()}renderLineWaveform(t,e,i,n){const r=a=>{const o=t[a]||t[0],d=o.length,{height:c}=i.canvas,l=c/2,p=i.canvas.width/d;i.moveTo(0,l);let h=0,m=0;for(let f=0;f<=d;f++){const b=Math.round(f*p);if(b>h){const S=l+(Math.round(m*l*n)||1)*(a===0?-1:1);i.lineTo(h,S),h=b,m=0}const g=Math.abs(o[f]||0);g>m&&(m=g)}i.lineTo(h,l)};i.beginPath(),r(0),r(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 n=e.barHeight||1;if(e.normalize){const r=Array.from(t[0]).reduce((a,o)=>Math.max(a,Math.abs(o)),0);n=r?1/r:1}e.barWidth||e.barGap||e.barAlign?this.renderBarWaveform(t,e,i,n):this.renderLineWaveform(t,e,i,n)}renderSingleCanvas(t,e,i,n,r,a,o){const d=this.getPixelRatio(),c=document.createElement("canvas");c.width=Math.round(i*d),c.height=Math.round(n*d),c.style.width=`${i}px`,c.style.height=`${n}px`,c.style.left=`${Math.round(r)}px`,a.appendChild(c);const l=c.getContext("2d");if(this.renderWaveform(t,e,l),c.width>0&&c.height>0){const p=c.cloneNode(),h=p.getContext("2d");h.drawImage(c,0,0),h.globalCompositeOperation="source-in",h.fillStyle=this.convertColorValues(e.progressColor),h.fillRect(0,0,c.width,c.height),o.appendChild(p)}}renderMultiCanvas(t,e,i,n,r,a){const o=this.getPixelRatio(),{clientWidth:d}=this.scrollContainer,c=i/o;let l=Math.min(N.MAX_CANVAS_WIDTH,d,c),p={};if(l===0)return;if(e.barWidth||e.barGap){const g=e.barWidth||.5,S=g+(e.barGap||g/2);l%S!=0&&(l=Math.floor(l/S)*S)}const h=g=>{if(g<0||g>=m||p[g])return;p[g]=!0;const S=g*l,y=Math.min(c-S,l);if(y<=0)return;const x=t.map(D=>{const w=Math.floor(S/c*D.length),A=Math.floor((S+y)/c*D.length);return D.slice(w,A)});this.renderSingleCanvas(x,e,y,n,S,r,a)},m=Math.ceil(c/l);if(!this.isScrollable){for(let g=0;g<m;g++)h(g);return}const f=this.scrollContainer.scrollLeft/c,b=Math.floor(f*m);if(h(b-1),h(b),h(b+1),m>1){const g=this.on("scroll",()=>{const{scrollLeft:S}=this.scrollContainer,y=Math.floor(S/c*m);Object.keys(p).length>N.MAX_NODES&&(r.innerHTML="",a.innerHTML="",p={}),h(y-1),h(y),h(y+1)});this.unsubscribeOnScroll.push(g)}}renderChannel(t,e,i,n){var{overlay:r}=e,a=function(l,p){var h={};for(var m in l)Object.prototype.hasOwnProperty.call(l,m)&&p.indexOf(m)<0&&(h[m]=l[m]);if(l!=null&&typeof Object.getOwnPropertySymbols=="function"){var f=0;for(m=Object.getOwnPropertySymbols(l);f<m.length;f++)p.indexOf(m[f])<0&&Object.prototype.propertyIsEnumerable.call(l,m[f])&&(h[m[f]]=l[m[f]])}return h}(e,["overlay"]);const o=document.createElement("div"),d=this.getHeight(a.height,a.splitChannels);o.style.height=`${d}px`,r&&n>0&&(o.style.marginTop=`-${d}px`),this.canvasWrapper.style.minHeight=`${d}px`,this.canvasWrapper.appendChild(o);const c=o.cloneNode();this.progressWrapper.appendChild(c),this.renderMultiCanvas(t,a,i,d,o,c)}render(t){return R(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(),n=this.scrollContainer.clientWidth,r=Math.ceil(t.duration*(this.options.minPxPerSec||0));this.isScrollable=r>n;const a=this.options.fillParent&&!this.isScrollable,o=(a?n:r)*i;if(this.wrapper.style.width=a?"100%":`${r}px`,this.scrollContainer.style.overflowX=this.isScrollable?"auto":"hidden",this.scrollContainer.classList.toggle("noScrollbar",!!this.options.hideScrollbar),this.cursor.style.backgroundColor=`${this.options.cursorColor||this.options.progressColor}`,this.cursor.style.width=`${this.options.cursorWidth}px`,this.audioData=t,this.emit("render"),this.options.splitChannels)for(let d=0;d<t.numberOfChannels;d++){const c=Object.assign(Object.assign({},this.options),(e=this.options.splitChannels)===null||e===void 0?void 0:e[d]);this.renderChannel([t.getChannelData(d)],c,o,d)}else{const d=[t.getChannelData(0)];t.numberOfChannels>1&&d.push(t.getChannelData(1)),this.renderChannel(d,this.options,o,0)}Promise.resolve().then(()=>this.emit("rendered"))})}reRender(){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 n=i-e;n*=2,n=n<0?Math.floor(n):Math.ceil(n),n/=2,this.scrollContainer.scrollLeft+=n}}zoom(t){this.options.minPxPerSec=t,this.reRender()}scrollIntoView(t,e=!1){const{scrollLeft:i,scrollWidth:n,clientWidth:r}=this.scrollContainer,a=t*n,o=i,d=i+r,c=r/2;if(this.isDragging)a+30>d?this.scrollContainer.scrollLeft+=30:a-30<o&&(this.scrollContainer.scrollLeft-=30);else{(a<o||a>d)&&(this.scrollContainer.scrollLeft=a-(this.options.autoCenter?c:0));const l=a-i-c;e&&this.options.autoCenter&&l>0&&(this.scrollContainer.scrollLeft+=Math.min(l,10))}{const l=this.scrollContainer.scrollLeft,p=l/n,h=(l+r)/n;this.emit("scroll",p,h,l,l+r)}}renderProgress(t,e){if(isNaN(t))return;const i=100*t;this.canvasWrapper.style.clipPath=`polygon(${i}% 0, 100% 0, 100% 100%, ${i}% 100%)`,this.progressWrapper.style.width=`${i}%`,this.cursor.style.left=`${i}%`,this.cursor.style.transform=`translateX(-${Math.round(i)===100?this.options.cursorWidth:0}px)`,this.isScrollable&&this.options.autoScroll&&this.scrollIntoView(t,e)}exportImage(t,e,i){return R(this,void 0,void 0,function*(){const n=this.canvasWrapper.querySelectorAll("canvas");if(!n.length)throw new Error("No waveform data");if(i==="dataURL"){const r=Array.from(n).map(a=>a.toDataURL(t,e));return Promise.resolve(r)}return Promise.all(Array.from(n).map(r=>new Promise((a,o)=>{r.toBlob(d=>{d?a(d):o(new Error("Could not export image"))},t,e)})))})}}N.MAX_CANVAS_WIDTH=8e3,N.MAX_NODES=10;class ge extends V{constructor(){super(...arguments),this.unsubscribe=()=>{}}start(){this.unsubscribe=this.on("tick",()=>{requestAnimationFrame(()=>{this.emit("tick")})}),this.emit("tick")}stop(){this.unsubscribe()}destroy(){this.unsubscribe()}}class 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 R(this,void 0,void 0,function*(){})}get src(){return this.currentSrc}set src(t){if(this.currentSrc=t,this._duration=void 0,!t)return this.buffer=null,void this.emit("emptied");fetch(t).then(e=>{if(e.status>=400)throw new Error(`Failed to fetch ${t}: ${e.status} (${e.statusText})`);return e.arrayBuffer()}).then(e=>this.currentSrc!==t?null:this.audioContext.decodeAudioData(e)).then(e=>{this.currentSrc===t&&(this.buffer=e,this.emit("loadedmetadata"),this.emit("canplay"),this.autoplay&&this.play())})}_play(){var t;if(!this.paused)return;this.paused=!1,(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 R(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==null||i.stop(this.audioContext.currentTime+e),i==null||i.addEventListener("ended",()=>{i===this.bufferNode&&(this.bufferNode=null,this.pause())},{once:!0})}setSinkId(t){return R(this,void 0,void 0,function*(){return this.audioContext.setSinkId(t)})}get playbackRate(){return this._playbackRate}set playbackRate(t){this._playbackRate=t,this.bufferNode&&(this.bufferNode.playbackRate.value=t)}get currentTime(){return(this.paused?this.playedDuration:this.playedDuration+(this.audioContext.currentTime-this.playStartTime))*this._playbackRate}set currentTime(t){const e=!this.paused;e&&this._pause(),this.playedDuration=t/this._playbackRate,e&&this._play(),this.emit("seeking"),this.emit("timeupdate")}get duration(){var t,e;return(t=this._duration)!==null&&t!==void 0?t:((e=this.buffer)===null||e===void 0?void 0:e.duration)||0}set duration(t){this._duration=t}get volume(){return this.gainNode.gain.value}set volume(t){this.gainNode.gain.value=t,this.emit("volumechange")}get muted(){return this._muted}set muted(t){this._muted!==t&&(this._muted=t,this._muted?this.gainNode.disconnect():this.gainNode.connect(this.audioContext.destination))}canPlayType(t){return/^(audio|video)\//.test(t)}getGainNode(){return this.gainNode}getChannelData(){const t=[];if(!this.buffer)return t;const e=this.buffer.numberOfChannels;for(let i=0;i<e;i++)t.push(this.buffer.getChannelData(i));return t}}const ve={waveColor:"#999",progressColor:"#555",cursorWidth:1,minPxPerSec:0,fillParent:!0,interact:!0,dragToSeek:!1,autoScroll:!0,autoCenter:!0,sampleRate:8e3};class F extends fe{static create(t){return new F(t)}constructor(t){const e=t.media||(t.backend==="WebAudio"?new 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({},ve,t),this.timer=new ge;const i=e?void 0:this.getMediaElement();this.renderer=new N(this.options,i),this.initPlayerEvents(),this.initRendererEvents(),this.initTimerEvents(),this.initPlugins();const n=this.options.url||this.getSrc()||"";Promise.resolve().then(()=>{this.emit("init");const{peaks:r,duration:a}=this.options;(n||r&&a)&&this.load(n,r,a).catch(()=>null)})}updateProgress(t=this.getCurrentTime()){return this.renderer.renderProgress(t/this.getDuration(),this.isPlaying()),t}initTimerEvents(){this.subscriptions.push(this.timer.on("tick",()=>{if(!this.isSeeking()){const t=this.updateProgress();this.emit("timeupdate",t),this.emit("audioprocess",t),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,n)=>{const r=this.getDuration();this.emit("scroll",t*r,e*r,i,n)}),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){return t._init(this),this.plugins.push(t),this.subscriptions.push(t.once("destroy",()=>{this.plugins=this.plugins.filter(e=>e!==t)})),t}getWrapper(){return this.renderer.getWrapper()}getWidth(){return this.renderer.getWidth()}getScroll(){return this.renderer.getScroll()}setScroll(t){return this.renderer.setScroll(t)}setScrollTime(t){const e=t/this.getDuration();this.renderer.setScrollPercentage(e)}getActivePlugins(){return this.plugins}loadAudio(t,e,i,n){return R(this,void 0,void 0,function*(){var r;if(this.emit("load",t),!this.options.media&&this.isPlaying()&&this.pause(),this.decodedData=null,this.stopAtPosition=null,!e&&!i){const o=this.options.fetchParams||{};window.AbortController&&!o.signal&&(this.abortController=new AbortController,o.signal=(r=this.abortController)===null||r===void 0?void 0:r.signal);const d=l=>this.emit("loading",l);e=yield me.fetchBlob(t,d,o);const c=this.options.blobMimeType;c&&(e=new Blob([e],{type:c}))}this.setSrc(t,e);const a=yield new Promise(o=>{const d=n||this.getDuration();d?o(d):this.mediaSubscriptions.push(this.onMediaEvent("loadedmetadata",()=>o(this.getDuration()),{once:!0}))});if(!t&&!e){const o=this.getMediaElement();o instanceof et&&(o.duration=a)}if(i)this.decodedData=j.createBuffer(i,a||0);else if(e){const o=yield e.arrayBuffer();this.decodedData=yield j.decode(o,this.options.sampleRate)}this.decodedData&&(this.emit("decode",this.getDuration()),this.renderer.render(this.decodedData)),this.emit("ready",this.getDuration())})}load(t,e,i){return R(this,void 0,void 0,function*(){try{return yield this.loadAudio(t,void 0,e,i)}catch(n){throw this.emit("error",n),n}})}loadBlob(t,e,i){return R(this,void 0,void 0,function*(){try{return yield this.loadAudio("",t,e,i)}catch(n){throw this.emit("error",n),n}})}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 n=Math.min(t,this.decodedData.numberOfChannels),r=[];for(let a=0;a<n;a++){const o=this.decodedData.getChannelData(a),d=[],c=o.length/e;for(let l=0;l<e;l++){const p=o.slice(Math.floor(l*c),Math.ceil((l+1)*c));let h=0;for(let m=0;m<p.length;m++){const f=p[m];Math.abs(f)>Math.abs(h)&&(h=f)}d.push(Math.round(h*i)/i)}r.push(d)}return r}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 R(this,void 0,void 0,function*(){t!=null&&this.setTime(t);const n=yield i.play.call(this);return e!=null&&(this.media instanceof et?this.media.stopAt(e):this.stopAtPosition=e),n})}playPause(){return R(this,void 0,void 0,function*(){return this.isPlaying()?this.pause():this.play()})}stop(){this.pause(),this.setTime(0)}skip(t){this.setTime(this.getCurrentTime()+t)}empty(){this.load("",[[0]],.001)}setMediaElement(t){this.unsubscribePlayerEvents(),super.setMediaElement(t),this.initPlayerEvents()}exportImage(){return R(this,arguments,void 0,function*(t="image/png",e=1,i="dataURL"){return this.renderer.exportImage(t,e,i)})}destroy(){var t;this.emit("destroy"),(t=this.abortController)===null||t===void 0||t.abort(),this.plugins.forEach(e=>e.destroy()),this.subscriptions.forEach(e=>e()),this.unsubscribePlayerEvents(),this.timer.destroy(),this.renderer.destroy(),super.destroy()}}F.BasePlugin=class extends V{constructor(s){super(),this.subscriptions=[],this.options=s}onInit(){}_init(s){this.wavesurfer=s,this.onInit()}destroy(){this.emit("destroy"),this.subscriptions.forEach(s=>s())}},F.dom=pe;function it(s,t,e,i){return new(e||(e=Promise))(function(n,r){function a(c){try{d(i.next(c))}catch(l){r(l)}}function o(c){try{d(i.throw(c))}catch(l){r(l)}}function d(c){var l;c.done?n(c.value):(l=c.value,l instanceof e?l:new e(function(p){p(l)})).then(a,o)}d((i=i.apply(s,[])).next())})}class xt{constructor(){this.listeners={}}on(t,e,i){if(this.listeners[t]||(this.listeners[t]=new Set),this.listeners[t].add(e),i==null?void 0:i.once){const n=()=>{this.un(t,n),this.un(t,e)};return this.on(t,n),n}return()=>this.un(t,e)}un(t,e){var i;(i=this.listeners[t])===null||i===void 0||i.delete(e)}once(t,e){return this.on(t,e,{once:!0})}unAll(){this.listeners={}}emit(t,...e){this.listeners[t]&&this.listeners[t].forEach(i=>i(...e))}}class be extends xt{constructor(t){super(),this.subscriptions=[],this.options=t}onInit(){}_init(t){this.wavesurfer=t,this.onInit()}destroy(){this.emit("destroy"),this.subscriptions.forEach(t=>t())}}class ye extends xt{constructor(){super(...arguments),this.unsubscribe=()=>{}}start(){this.unsubscribe=this.on("tick",()=>{requestAnimationFrame(()=>{this.emit("tick")})}),this.emit("tick")}stop(){this.unsubscribe()}destroy(){this.unsubscribe()}}const we=["audio/webm","audio/wav","audio/mpeg","audio/mp4","audio/mp3"];class Y extends be{constructor(t){var e,i,n,r,a,o;super(Object.assign(Object.assign({},t),{audioBitsPerSecond:(e=t.audioBitsPerSecond)!==null&&e!==void 0?e:128e3,scrollingWaveform:(i=t.scrollingWaveform)!==null&&i!==void 0&&i,scrollingWaveformWindow:(n=t.scrollingWaveformWindow)!==null&&n!==void 0?n:5,continuousWaveform:(r=t.continuousWaveform)!==null&&r!==void 0&&r,renderRecordedAudio:(a=t.renderRecordedAudio)===null||a===void 0||a,mediaRecorderTimeslice:(o=t.mediaRecorderTimeslice)!==null&&o!==void 0?o:void 0})),this.stream=null,this.mediaRecorder=null,this.dataWindow=null,this.isWaveformPaused=!1,this.lastStartTime=0,this.lastDuration=0,this.duration=0,this.timer=new ye,this.subscriptions.push(this.timer.on("tick",()=>{const d=performance.now()-this.lastStartTime;this.duration=this.isPaused()?this.duration:this.lastDuration+d,this.emit("record-progress",this.duration)}))}static create(t){return new Y(t||{})}renderMicStream(t){var e;const i=new AudioContext,n=i.createMediaStreamSource(t),r=i.createAnalyser();n.connect(r),this.options.continuousWaveform&&(r.fftSize=32);const a=r.frequencyBinCount,o=new Float32Array(a);let d=0;this.wavesurfer&&((e=this.originalOptions)!==null&&e!==void 0||(this.originalOptions=Object.assign({},this.wavesurfer.options)),this.wavesurfer.options.interact=!1,this.options.scrollingWaveform&&(this.wavesurfer.options.cursorWidth=0));const c=setInterval(()=>{var l,p,h,m;if(!this.isWaveformPaused){if(r.getFloatTimeDomainData(o),this.options.scrollingWaveform){const f=Math.floor((this.options.scrollingWaveformWindow||0)*i.sampleRate),b=Math.min(f,this.dataWindow?this.dataWindow.length+a:a),g=new Float32Array(f);if(this.dataWindow){const S=Math.max(0,f-this.dataWindow.length);g.set(this.dataWindow.slice(-b+a),S)}g.set(o,f-a),this.dataWindow=g}else if(this.options.continuousWaveform){if(!this.dataWindow){const b=this.options.continuousWaveformDuration?Math.round(100*this.options.continuousWaveformDuration):((p=(l=this.wavesurfer)===null||l===void 0?void 0:l.getWidth())!==null&&p!==void 0?p:0)*window.devicePixelRatio;this.dataWindow=new Float32Array(b)}let f=0;for(let b=0;b<a;b++){const g=Math.abs(o[b]);g>f&&(f=g)}if(d+1>this.dataWindow.length){const b=new Float32Array(2*this.dataWindow.length);b.set(this.dataWindow,0),this.dataWindow=b}this.dataWindow[d]=f,d++}else this.dataWindow=o;if(this.wavesurfer){const f=((m=(h=this.dataWindow)===null||h===void 0?void 0:h.length)!==null&&m!==void 0?m:0)/100;this.wavesurfer.load("",[this.dataWindow],this.options.scrollingWaveform?this.options.scrollingWaveformWindow:f).then(()=>{this.wavesurfer&&this.options.continuousWaveform&&(this.wavesurfer.setTime(this.getDuration()/1e3),this.wavesurfer.options.minPxPerSec||this.wavesurfer.setOptions({minPxPerSec:this.wavesurfer.getWidth()/this.wavesurfer.getDuration()}))}).catch(b=>{console.error("Error rendering real-time recording data:",b)})}}},10);return{onDestroy:()=>{clearInterval(c),n==null||n.disconnect(),i==null||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.deviceId)||{deviceId:t.deviceId}})}catch(r){throw new Error("Error accessing the microphone: "+r.message)}const{onDestroy:i,onEnd:n}=this.renderMicStream(e);return this.subscriptions.push(this.once("destroy",i)),this.subscriptions.push(this.once("record-end",n)),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||we.find(a=>MediaRecorder.isTypeSupported(a)),audioBitsPerSecond:this.options.audioBitsPerSecond});this.mediaRecorder=i,this.stopRecording();const n=[];i.ondataavailable=a=>{a.data.size>0&&n.push(a.data),this.emit("record-data-available",a.data)};const r=a=>{var o;const d=new Blob(n,{type:i.mimeType});this.emit(a,d),this.options.renderRecordedAudio&&(this.applyOriginalOptionsIfNeeded(),(o=this.wavesurfer)===null||o===void 0||o.load(URL.createObjectURL(d)))};i.onpause=()=>r("record-pause"),i.onstop=()=>r("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 Se=async({files:s,uploadClient:t,widgetMgr:e,widgetInfo:i,fragmentId:n})=>{let r=[];try{r=await t.fetchFileURLs(s)}catch(c){return{successfulUploads:[],failedUploads:s.map(l=>({file:l,error:mt(c)}))}}const a=Ht(s,r),o=[],d=[];return await Promise.all(a.map(async([c,l])=>{if(!c||!l||!l.uploadUrl||!l.fileId)return{file:c,fileUrl:l,error:new Error("No upload URL found")};try{await t.uploadFile({id:l.fileId,formId:i.formId||""},l.uploadUrl,c),o.push({fileUrl:l,file:c})}catch(p){const h=mt(p);d.push({file:c,error:h})}})),e.setFileUploaderStateValue(i,new Vt({uploadedFileInfo:o.map(({file:c,fileUrl:l})=>new jt({fileId:l.fileId,fileUrls:l,name:c.name,size:c.size}))}),{fromUi:!0},n),{successfulUploads:o,failedUploads:d}},st=({widgetMgr:s,id:t,formId:e,key:i,defaultValue:n})=>{u.useEffect(()=>{const l=s.getElementState(t,i);X(l)&&q(n)&&s.setElementState(t,i,n)},[s,t,i,n]);const[r,a]=u.useState(s.getElementState(t,i)??n),o=u.useCallback(l=>{s.setElementState(t,i,l),a(l)},[s,t,i]),d=u.useMemo(()=>({formId:e||""}),[e]),c=u.useCallback(()=>o(n),[n,o]);return oe({element:d,widgetMgr:s,onFormCleared:c}),[r,o]},Ce=(s,t)=>{const{libConfig:{enforceDownloadInNewTab:e=!1}}=yt.useContext(Gt);return u.useCallback(()=>{if(!s)return;const n=de({enforceDownloadInNewTab:e,url:s,filename:t});n.style.display="none",document.body.appendChild(n),n.click(),document.body.removeChild(n)},[s,e,t])},Ee=P("div",{target:"etzg8g80"})(),vt=P("div",{target:"etzg8g81"})(({theme:s})=>({height:s.sizes.largestElementHeight,width:"100%",background:s.colors.secondaryBg,borderRadius:s.radii.default,marginBottom:s.spacing.twoXS,display:"flex",alignItems:"center",position:"relative",paddingLeft:s.spacing.xs,paddingRight:s.spacing.sm,border:s.colors.widgetBorderColor?`${s.sizes.borderWidth} solid ${s.colors.widgetBorderColor}`:void 0})),Re=P("div",{target:"etzg8g82"})({flex:1}),Pe=P("div",{target:"etzg8g83"})(({show:s})=>({display:s?"block":"none"})),xe=P("span",{target:"etzg8g84"})(({theme:s,isPlayingOrRecording:t})=>({margin:s.spacing.sm,fontFamily:s.fonts.monospace,color:t?s.colors.bodyText:s.colors.fadedText60,backgroundColor:s.colors.secondaryBg,fontSize:s.fontSizes.sm})),Dt=P("div",{target:"etzg8g85"})({width:"100%",textAlign:"center",overflow:"hidden"}),At=P("span",{target:"etzg8g86"})(({theme:s})=>({color:s.colors.bodyText})),De=P("a",{target:"etzg8g87"})(({theme:s})=>({color:s.colors.link,textDecoration:"underline"})),Ae=P("div",{target:"etzg8g88"})(({theme:s})=>({height:s.sizes.largestElementHeight,display:"flex",justifyContent:"center",alignItems:"center"})),Te=P("div",{target:"etzg8g89"})(({theme:s})=>{const t="0.625em";return{opacity:.2,width:"100%",height:t,backgroundSize:t,backgroundImage:`radial-gradient(${s.colors.fadedText10} 40%, transparent 40%)`,backgroundRepeat:"repeat"}}),We=P("span",{target:"etzg8g810"})(({theme:s})=>({"& > button":{color:s.colors.primary,padding:s.spacing.threeXS},"& > button:hover, & > button:focus":{color:s.colors.red}})),Me=P("span",{target:"etzg8g811"})(({theme:s})=>({"& > button":{padding:s.spacing.threeXS,color:s.colors.fadedText40},"& > button:hover, & > button:focus":{color:s.colors.primary}})),Tt=P("span",{target:"etzg8g812"})(({theme:s})=>({"& > button":{padding:s.spacing.threeXS,color:s.colors.fadedText60},"& > button:hover, & > button:focus":{color:s.colors.bodyText}})),nt=P("div",{target:"etzg8g813"})(({theme:s})=>({display:"flex",justifyContent:"center",alignItems:"center",flexGrow:0,flexShrink:1,padding:s.spacing.xs,gap:s.spacing.twoXS,marginRight:s.spacing.twoXS})),ke=P("div",{target:"etzg8g814"})(({theme:s})=>({marginLeft:s.spacing.sm})),Ie=P(Xt,{target:"etzg8g815"})(({theme:s})=>({fontSize:s.fontSizes.sm,width:s.sizes.spinnerSize,height:s.sizes.spinnerSize,borderWidth:s.sizes.spinnerThickness,justifyContents:"center",padding:s.spacing.none,margin:s.spacing.none,borderColor:s.colors.borderColor,borderTopColor:s.colors.secondary,flexGrow:0,flexShrink:0})),Oe=()=>z(Dt,{children:[v(At,{children:"This app would like to use your microphone."})," ",v(De,{href:qt,children:"Learn how to allow access."})]}),Le=u.memo(Oe),Be=()=>v(Ae,{children:v(Te,{})}),ze=u.memo(Be),Ne=4,Ue=4,Fe=4,_e=8,$e=0,G="00:00",bt=s=>{const t=Math.floor(s/1e3),e=Math.floor(t/60),i=Math.floor(e/60),n=t%60,r=e%60,a=n.toString().padStart(2,"0"),o=r.toString().padStart(2,"0"),d=i.toString().padStart(2,"0");return e<60?`${o}:${a}`:`${d}:${o}:${a}`},_=({onClick:s,disabled:t,ariaLabel:e,iconContent:i})=>v(Jt,{kind:Yt.BORDERLESS_ICON,onClick:s,disabled:t,"aria-label":e,containerWidth:!0,"data-testid":"stAudioInputActionButton",children:v(Kt,{content:i,size:"lg",color:"inherit"})}),He=({disabled:s,stopRecording:t})=>v(We,{children:v(_,{onClick:t,disabled:s,ariaLabel:"Stop recording",iconContent:Rt})}),Ve=({disabled:s,isPlaying:t,onClickPlayPause:e})=>v(Tt,{children:t?v(_,{onClick:e,disabled:s,ariaLabel:"Pause",iconContent:St}):v(_,{onClick:e,disabled:s,ariaLabel:"Play",iconContent:Ct})}),je=({disabled:s,startRecording:t})=>v(Me,{children:v(_,{onClick:t,disabled:s,ariaLabel:"Record",iconContent:wt})}),Ge=({onClick:s})=>v(Tt,{children:v(_,{disabled:!1,onClick:s,ariaLabel:"Reset",iconContent:Et})}),Xe=({disabled:s,isRecording:t,isPlaying:e,isUploading:i,isError:n,recordingUrlExists:r,startRecording:a,stopRecording:o,onClickPlayPause:d,onClear:c})=>n?v(nt,{children:v(Ge,{onClick:c})}):i?v(nt,{children:v(Ie,{"aria-label":"Uploading"})}):z(nt,{children:[t?v(He,{disabled:s,stopRecording:o}):v(je,{disabled:s,startRecording:a}),r&&v(Ve,{disabled:s,isPlaying:e,onClickPlayPause:d})]}),qe=u.memo(Xe),Ye=Qt.getLogger("convertAudioToWav");async function Ke(s){const t=new window.AudioContext,e=await s.arrayBuffer();let i;try{i=await t.decodeAudioData(e)}catch(m){Ye.error(m);return}const n=44,r=i.numberOfChannels,a=i.sampleRate,o=i.length*r*2+n,d=new ArrayBuffer(o),c=new DataView(d),l={0:{type:"string",value:"RIFF"},4:{type:"uint32",value:o-8},8:{type:"string",value:"WAVE"},12:{type:"string",value:"fmt "},16:{type:"uint32",value:16},20:{type:"uint16",value:1},22:{type:"uint16",value:r},24:{type:"uint32",value:a},28:{type:"uint32",value:a*r*2},32:{type:"uint16",value:r*2},34:{type:"uint16",value:16},36:{type:"string",value:"data"},40:{type:"uint32",value:i.length*r*2}};Object.entries(l).forEach(([m,{type:f,value:b}])=>{const g=parseInt(m,10);f==="string"?Je(c,g,b):f==="uint32"?c.setUint32(g,b,!0):f==="uint16"&&c.setUint16(g,b,!0)});let p=n;for(let m=0;m<i.length;m++)for(let f=0;f<r;f++){const b=Math.max(-1,Math.min(1,i.getChannelData(f)[m]));c.setInt16(p,b*32767,!0),p+=2}const h=new Uint8Array(d);return new Blob([h],{type:"audio/wav"})}function Je(s,t,e){for(let i=0;i<e.length;i++)s.setUint8(t+i,e.charCodeAt(i))}const Qe=()=>v(Dt,{children:v(At,{children:"An error has occurred, please try again."})}),Ze=u.memo(Qe),ti=({element:s,uploadClient:t,widgetMgr:e,fragmentId:i,disabled:n})=>{var pt;const r=Zt(),a=ce(r),[o,d]=u.useState(null),c=yt.useRef(null),[l,p]=st({widgetMgr:e,id:s.id,key:"deleteFileUrl",defaultValue:null}),[h,m]=u.useState(null),[f,b]=u.useState([]),[g,S]=u.useState(null),[y,x]=st({widgetMgr:e,id:s.id,key:"recordingUrl",defaultValue:null}),[,D]=u.useState(0),w=()=>{D(C=>C+1)},[A,T]=u.useState(G),[k,W]=st({widgetMgr:e,id:s.id,formId:s.formId,key:"recordingTime",defaultValue:G}),[I,U]=u.useState(!1),[L,Wt]=u.useState(!1),[rt,Mt]=u.useState(!1),[kt,ot]=u.useState(!1),[K,J]=u.useState(!1),at=s.id,O=s.formId,lt=u.useCallback(async C=>{ot(!0),q(O)&&e.setFormsWithUploadsInProgress(new Set([O]));let E;if(C.type==="audio/wav"?E=C:E=await Ke(C),!E){J(!0);return}const M=URL.createObjectURL(E),Ut=new Date().toISOString().slice(0,16).replace(":","-"),Ft=new File([E],`${Ut}_audio.wav`,{type:E.type});x(M),Se({files:[Ft],uploadClient:t,widgetMgr:e,widgetInfo:{id:at,formId:O},fragmentId:i}).then(({successfulUploads:_t,failedUploads:$t})=>{if($t.length>0){J(!0);return}const Z=_t[0];Z&&Z.fileUrl.deleteUrl&&p(Z.fileUrl.deleteUrl)}).finally(()=>{q(O)&&e.setFormsWithUploadsInProgress(new Set),ot(!1)})},[x,t,e,at,O,i,p]),B=u.useCallback(({updateWidgetManager:C,deleteFile:E})=>{X(o)||X(l)||(x(null),o.empty(),E&&t.deleteFile(l),p(null),T(G),W(G),C&&e.setFileUploaderStateValue(s,{},{fromUi:!0},i),U(!1),q(y)&&URL.revokeObjectURL(y))},[l,y,t,o,s,e,i,W,x,p]);u.useEffect(()=>{if(X(O))return;const C=new ae;return C.manageFormClearListener(e,O,()=>B({updateWidgetManager:!0,deleteFile:!1})),()=>C.disconnect()},[O,B,e]);const ct=u.useCallback(()=>{if(c.current===null)return;const C=F.create({container:c.current,waveColor:y?tt(r.colors.fadedText40,r.colors.secondaryBg):r.colors.primary,progressColor:r.colors.bodyText,height:te(r.sizes.largestElementHeight)-2*Ne,barWidth:Ue,barGap:Fe,barRadius:_e,cursorWidth:$e,url:y??void 0});C.on("timeupdate",M=>{T(bt(M*1e3))}),C.on("pause",()=>{w()});const E=C.registerPlugin(Y.create({scrollingWaveform:!1,renderRecordedAudio:!0}));return E.on("record-end",async M=>{lt(M)}),E.on("record-progress",M=>{W(bt(M))}),d(C),m(E),()=>{C&&C.destroy(),E&&E.destroy()}},[lt]);u.useEffect(()=>ct(),[ct]),u.useEffect(()=>{ee(a,r)||o==null||o.setOptions({waveColor:y?tt(r.colors.fadedText40,r.colors.secondaryBg):r.colors.primary,progressColor:r.colors.bodyText})},[r,a,y,o]);const It=u.useCallback(()=>{o&&(o.playPause(),U(!0),w())},[o]),Ot=u.useCallback(async()=>{let C=g;rt||(await navigator.mediaDevices.getUserMedia({audio:!0}).then(()=>Y.getAvailableAudioDevices().then(E=>{if(b(E),E.length>0){const{deviceId:M}=E[0];S(M),C=M}})).catch(E=>{Wt(!0)}),Mt(!0)),!(!h||!C||!o)&&(o.setOptions({waveColor:r.colors.primary}),y&&B({updateWidgetManager:!1,deleteFile:!0}),h.startRecording({deviceId:C}).then(()=>{w()}))},[g,h,r,o,y,B,rt]),Lt=u.useCallback(()=>{h&&(h.stopRecording(),o==null||o.setOptions({waveColor:tt(r.colors.fadedText40,r.colors.secondaryBg)}))},[h,o,r]),Bt=Ce(y,"recording.wav"),Q=!!(h!=null&&h.isRecording()),dt=!!(o!=null&&o.isPlaying()),zt=Q||dt,ht=!Q&&!y&&!L,Nt=L||ht||K,ut=n||L;return z(Ee,{className:"stAudioInput","data-testid":"stAudioInput",children:[v(re,{label:s.label,disabled:ut,labelVisibility:ie((pt=s.labelVisibility)==null?void 0:pt.value),children:s.help&&v(ke,{children:v(se,{content:s.help,placement:ne.TOP})})}),z(vt,{children:[z(le,{isFullScreen:!1,disableFullscreenMode:!0,target:vt,children:[y&&v(ft,{label:"Download as WAV",icon:he,onClick:()=>Bt()}),l&&v(ft,{label:"Clear recording",icon:ue,onClick:()=>B({updateWidgetManager:!0,deleteFile:!0})})]}),v(qe,{isRecording:Q,isPlaying:dt,isUploading:kt,isError:K,recordingUrlExists:!!y,startRecording:Ot,stopRecording:Lt,onClickPlayPause:It,onClear:()=>{B({updateWidgetManager:!1,deleteFile:!0}),J(!1)},disabled:ut}),z(Re,{children:[K&&v(Ze,{}),ht&&v(ze,{}),L&&v(Le,{}),v(Pe,{"data-testid":"stAudioInputWaveSurfer",ref:c,show:!Nt})]}),v(xe,{isPlayingOrRecording:zt,"data-testid":"stAudioInputWaveformTimeCode",children:I?A:k})]})]})},li=u.memo(ti);export{li as default};
73
+ `,[t,e]}setOptions(t){if(this.options.container!==t.container){const e=this.parentFromOptionsContainer(t.container);e.appendChild(this.container),this.parent=e}t.dragToSeek!==!0&&typeof this.options.dragToSeek!="object"||this.initDrag(),this.options=t,this.reRender()}getWrapper(){return this.wrapper}getWidth(){return this.scrollContainer.clientWidth}getScroll(){return this.scrollContainer.scrollLeft}setScroll(t){this.scrollContainer.scrollLeft=t}setScrollPercentage(t){const{scrollWidth:e}=this.scrollContainer,i=e*t;this.setScroll(i)}destroy(){var t,e;this.subscriptions.forEach(i=>i()),this.container.remove(),(t=this.resizeObserver)===null||t===void 0||t.disconnect(),(e=this.unsubscribeOnScroll)===null||e===void 0||e.forEach(i=>i()),this.unsubscribeOnScroll=[]}createDelay(t=10){let e,i;const n=()=>{e&&clearTimeout(e),i&&i()};return this.timeouts.push(n),()=>new Promise((r,a)=>{n(),i=a,e=setTimeout(()=>{e=void 0,i=void 0,r()},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"),n=e.height*(window.devicePixelRatio||1),r=i.createLinearGradient(0,0,0,n),a=1/(t.length-1);return t.forEach((o,d)=>{const c=d*a;r.addColorStop(c,o)}),r}getPixelRatio(){return Math.max(1,window.devicePixelRatio||1)}renderBarWaveform(t,e,i,n){const r=t[0],a=t[1]||t[0],o=r.length,{width:d,height:c}=i.canvas,l=c/2,p=this.getPixelRatio(),h=e.barWidth?e.barWidth*p:1,m=e.barGap?e.barGap*p:e.barWidth?h/2:0,f=e.barRadius||0,b=d/(h+m)/o,g=f&&"roundRect"in i?"roundRect":"rect";i.beginPath();let S=0,y=0,x=0;for(let D=0;D<=o;D++){const w=Math.round(D*b);if(w>S){const k=Math.round(y*l*n),W=k+Math.round(x*l*n)||1;let I=l-k;e.barAlign==="top"?I=0:e.barAlign==="bottom"&&(I=c-W),i[g](S*(h+m),I,h,W,f),S=w,y=0,x=0}const A=Math.abs(r[D]||0),T=Math.abs(a[D]||0);A>y&&(y=A),T>x&&(x=T)}i.fill(),i.closePath()}renderLineWaveform(t,e,i,n){const r=a=>{const o=t[a]||t[0],d=o.length,{height:c}=i.canvas,l=c/2,p=i.canvas.width/d;i.moveTo(0,l);let h=0,m=0;for(let f=0;f<=d;f++){const b=Math.round(f*p);if(b>h){const S=l+(Math.round(m*l*n)||1)*(a===0?-1:1);i.lineTo(h,S),h=b,m=0}const g=Math.abs(o[f]||0);g>m&&(m=g)}i.lineTo(h,l)};i.beginPath(),r(0),r(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 n=e.barHeight||1;if(e.normalize){const r=Array.from(t[0]).reduce((a,o)=>Math.max(a,Math.abs(o)),0);n=r?1/r:1}e.barWidth||e.barGap||e.barAlign?this.renderBarWaveform(t,e,i,n):this.renderLineWaveform(t,e,i,n)}renderSingleCanvas(t,e,i,n,r,a,o){const d=this.getPixelRatio(),c=document.createElement("canvas");c.width=Math.round(i*d),c.height=Math.round(n*d),c.style.width=`${i}px`,c.style.height=`${n}px`,c.style.left=`${Math.round(r)}px`,a.appendChild(c);const l=c.getContext("2d");if(this.renderWaveform(t,e,l),c.width>0&&c.height>0){const p=c.cloneNode(),h=p.getContext("2d");h.drawImage(c,0,0),h.globalCompositeOperation="source-in",h.fillStyle=this.convertColorValues(e.progressColor),h.fillRect(0,0,c.width,c.height),o.appendChild(p)}}renderMultiCanvas(t,e,i,n,r,a){const o=this.getPixelRatio(),{clientWidth:d}=this.scrollContainer,c=i/o;let l=Math.min(U.MAX_CANVAS_WIDTH,d,c),p={};if(l===0)return;if(e.barWidth||e.barGap){const g=e.barWidth||.5,S=g+(e.barGap||g/2);l%S!=0&&(l=Math.floor(l/S)*S)}const h=g=>{if(g<0||g>=m||p[g])return;p[g]=!0;const S=g*l,y=Math.min(c-S,l);if(y<=0)return;const x=t.map(D=>{const w=Math.floor(S/c*D.length),A=Math.floor((S+y)/c*D.length);return D.slice(w,A)});this.renderSingleCanvas(x,e,y,n,S,r,a)},m=Math.ceil(c/l);if(!this.isScrollable){for(let g=0;g<m;g++)h(g);return}const f=this.scrollContainer.scrollLeft/c,b=Math.floor(f*m);if(h(b-1),h(b),h(b+1),m>1){const g=this.on("scroll",()=>{const{scrollLeft:S}=this.scrollContainer,y=Math.floor(S/c*m);Object.keys(p).length>U.MAX_NODES&&(r.innerHTML="",a.innerHTML="",p={}),h(y-1),h(y),h(y+1)});this.unsubscribeOnScroll.push(g)}}renderChannel(t,e,i,n){var{overlay:r}=e,a=function(l,p){var h={};for(var m in l)Object.prototype.hasOwnProperty.call(l,m)&&p.indexOf(m)<0&&(h[m]=l[m]);if(l!=null&&typeof Object.getOwnPropertySymbols=="function"){var f=0;for(m=Object.getOwnPropertySymbols(l);f<m.length;f++)p.indexOf(m[f])<0&&Object.prototype.propertyIsEnumerable.call(l,m[f])&&(h[m[f]]=l[m[f]])}return h}(e,["overlay"]);const o=document.createElement("div"),d=this.getHeight(a.height,a.splitChannels);o.style.height=`${d}px`,r&&n>0&&(o.style.marginTop=`-${d}px`),this.canvasWrapper.style.minHeight=`${d}px`,this.canvasWrapper.appendChild(o);const c=o.cloneNode();this.progressWrapper.appendChild(c),this.renderMultiCanvas(t,a,i,d,o,c)}render(t){return R(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(),n=this.scrollContainer.clientWidth,r=Math.ceil(t.duration*(this.options.minPxPerSec||0));this.isScrollable=r>n;const a=this.options.fillParent&&!this.isScrollable,o=(a?n:r)*i;if(this.wrapper.style.width=a?"100%":`${r}px`,this.scrollContainer.style.overflowX=this.isScrollable?"auto":"hidden",this.scrollContainer.classList.toggle("noScrollbar",!!this.options.hideScrollbar),this.cursor.style.backgroundColor=`${this.options.cursorColor||this.options.progressColor}`,this.cursor.style.width=`${this.options.cursorWidth}px`,this.audioData=t,this.emit("render"),this.options.splitChannels)for(let d=0;d<t.numberOfChannels;d++){const c=Object.assign(Object.assign({},this.options),(e=this.options.splitChannels)===null||e===void 0?void 0:e[d]);this.renderChannel([t.getChannelData(d)],c,o,d)}else{const d=[t.getChannelData(0)];t.numberOfChannels>1&&d.push(t.getChannelData(1)),this.renderChannel(d,this.options,o,0)}Promise.resolve().then(()=>this.emit("rendered"))})}reRender(){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 n=i-e;n*=2,n=n<0?Math.floor(n):Math.ceil(n),n/=2,this.scrollContainer.scrollLeft+=n}}zoom(t){this.options.minPxPerSec=t,this.reRender()}scrollIntoView(t,e=!1){const{scrollLeft:i,scrollWidth:n,clientWidth:r}=this.scrollContainer,a=t*n,o=i,d=i+r,c=r/2;if(this.isDragging)a+30>d?this.scrollContainer.scrollLeft+=30:a-30<o&&(this.scrollContainer.scrollLeft-=30);else{(a<o||a>d)&&(this.scrollContainer.scrollLeft=a-(this.options.autoCenter?c:0));const l=a-i-c;e&&this.options.autoCenter&&l>0&&(this.scrollContainer.scrollLeft+=Math.min(l,10))}{const l=this.scrollContainer.scrollLeft,p=l/n,h=(l+r)/n;this.emit("scroll",p,h,l,l+r)}}renderProgress(t,e){if(isNaN(t))return;const i=100*t;this.canvasWrapper.style.clipPath=`polygon(${i}% 0, 100% 0, 100% 100%, ${i}% 100%)`,this.progressWrapper.style.width=`${i}%`,this.cursor.style.left=`${i}%`,this.cursor.style.transform=`translateX(-${Math.round(i)===100?this.options.cursorWidth:0}px)`,this.isScrollable&&this.options.autoScroll&&this.scrollIntoView(t,e)}exportImage(t,e,i){return R(this,void 0,void 0,function*(){const n=this.canvasWrapper.querySelectorAll("canvas");if(!n.length)throw new Error("No waveform data");if(i==="dataURL"){const r=Array.from(n).map(a=>a.toDataURL(t,e));return Promise.resolve(r)}return Promise.all(Array.from(n).map(r=>new Promise((a,o)=>{r.toBlob(d=>{d?a(d):o(new Error("Could not export image"))},t,e)})))})}}U.MAX_CANVAS_WIDTH=8e3,U.MAX_NODES=10;class ge extends V{constructor(){super(...arguments),this.unsubscribe=()=>{}}start(){this.unsubscribe=this.on("tick",()=>{requestAnimationFrame(()=>{this.emit("tick")})}),this.emit("tick")}stop(){this.unsubscribe()}destroy(){this.unsubscribe()}}class 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 R(this,void 0,void 0,function*(){})}get src(){return this.currentSrc}set src(t){if(this.currentSrc=t,this._duration=void 0,!t)return this.buffer=null,void this.emit("emptied");fetch(t).then(e=>{if(e.status>=400)throw new Error(`Failed to fetch ${t}: ${e.status} (${e.statusText})`);return e.arrayBuffer()}).then(e=>this.currentSrc!==t?null:this.audioContext.decodeAudioData(e)).then(e=>{this.currentSrc===t&&(this.buffer=e,this.emit("loadedmetadata"),this.emit("canplay"),this.autoplay&&this.play())})}_play(){var t;if(!this.paused)return;this.paused=!1,(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 R(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==null||i.stop(this.audioContext.currentTime+e),i==null||i.addEventListener("ended",()=>{i===this.bufferNode&&(this.bufferNode=null,this.pause())},{once:!0})}setSinkId(t){return R(this,void 0,void 0,function*(){return this.audioContext.setSinkId(t)})}get playbackRate(){return this._playbackRate}set playbackRate(t){this._playbackRate=t,this.bufferNode&&(this.bufferNode.playbackRate.value=t)}get currentTime(){return(this.paused?this.playedDuration:this.playedDuration+(this.audioContext.currentTime-this.playStartTime))*this._playbackRate}set currentTime(t){const e=!this.paused;e&&this._pause(),this.playedDuration=t/this._playbackRate,e&&this._play(),this.emit("seeking"),this.emit("timeupdate")}get duration(){var t,e;return(t=this._duration)!==null&&t!==void 0?t:((e=this.buffer)===null||e===void 0?void 0:e.duration)||0}set duration(t){this._duration=t}get volume(){return this.gainNode.gain.value}set volume(t){this.gainNode.gain.value=t,this.emit("volumechange")}get muted(){return this._muted}set muted(t){this._muted!==t&&(this._muted=t,this._muted?this.gainNode.disconnect():this.gainNode.connect(this.audioContext.destination))}canPlayType(t){return/^(audio|video)\//.test(t)}getGainNode(){return this.gainNode}getChannelData(){const t=[];if(!this.buffer)return t;const e=this.buffer.numberOfChannels;for(let i=0;i<e;i++)t.push(this.buffer.getChannelData(i));return t}}const ve={waveColor:"#999",progressColor:"#555",cursorWidth:1,minPxPerSec:0,fillParent:!0,interact:!0,dragToSeek:!1,autoScroll:!0,autoCenter:!0,sampleRate:8e3};class z extends fe{static create(t){return new z(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({},ve,t),this.timer=new ge;const i=e?void 0:this.getMediaElement();this.renderer=new U(this.options,i),this.initPlayerEvents(),this.initRendererEvents(),this.initTimerEvents(),this.initPlugins();const n=this.options.url||this.getSrc()||"";Promise.resolve().then(()=>{this.emit("init");const{peaks:r,duration:a}=this.options;(n||r&&a)&&this.load(n,r,a).catch(()=>null)})}updateProgress(t=this.getCurrentTime()){return this.renderer.renderProgress(t/this.getDuration(),this.isPlaying()),t}initTimerEvents(){this.subscriptions.push(this.timer.on("tick",()=>{if(!this.isSeeking()){const t=this.updateProgress();this.emit("timeupdate",t),this.emit("audioprocess",t),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,n)=>{const r=this.getDuration();this.emit("scroll",t*r,e*r,i,n)}),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){return t._init(this),this.plugins.push(t),this.subscriptions.push(t.once("destroy",()=>{this.plugins=this.plugins.filter(e=>e!==t)})),t}getWrapper(){return this.renderer.getWrapper()}getWidth(){return this.renderer.getWidth()}getScroll(){return this.renderer.getScroll()}setScroll(t){return this.renderer.setScroll(t)}setScrollTime(t){const e=t/this.getDuration();this.renderer.setScrollPercentage(e)}getActivePlugins(){return this.plugins}loadAudio(t,e,i,n){return R(this,void 0,void 0,function*(){var r;if(this.emit("load",t),!this.options.media&&this.isPlaying()&&this.pause(),this.decodedData=null,this.stopAtPosition=null,!e&&!i){const o=this.options.fetchParams||{};window.AbortController&&!o.signal&&(this.abortController=new AbortController,o.signal=(r=this.abortController)===null||r===void 0?void 0:r.signal);const d=l=>this.emit("loading",l);e=yield me.fetchBlob(t,d,o);const c=this.options.blobMimeType;c&&(e=new Blob([e],{type:c}))}this.setSrc(t,e);const a=yield new Promise(o=>{const d=n||this.getDuration();d?o(d):this.mediaSubscriptions.push(this.onMediaEvent("loadedmetadata",()=>o(this.getDuration()),{once:!0}))});if(!t&&!e){const o=this.getMediaElement();o instanceof et&&(o.duration=a)}if(i)this.decodedData=j.createBuffer(i,a||0);else if(e){const o=yield e.arrayBuffer();this.decodedData=yield j.decode(o,this.options.sampleRate)}this.decodedData&&(this.emit("decode",this.getDuration()),this.renderer.render(this.decodedData)),this.emit("ready",this.getDuration())})}load(t,e,i){return R(this,void 0,void 0,function*(){try{return yield this.loadAudio(t,void 0,e,i)}catch(n){throw this.emit("error",n),n}})}loadBlob(t,e,i){return R(this,void 0,void 0,function*(){try{return yield this.loadAudio("",t,e,i)}catch(n){throw this.emit("error",n),n}})}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 n=Math.min(t,this.decodedData.numberOfChannels),r=[];for(let a=0;a<n;a++){const o=this.decodedData.getChannelData(a),d=[],c=o.length/e;for(let l=0;l<e;l++){const p=o.slice(Math.floor(l*c),Math.ceil((l+1)*c));let h=0;for(let m=0;m<p.length;m++){const f=p[m];Math.abs(f)>Math.abs(h)&&(h=f)}d.push(Math.round(h*i)/i)}r.push(d)}return r}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 R(this,void 0,void 0,function*(){t!=null&&this.setTime(t);const n=yield i.play.call(this);return e!=null&&(this.media instanceof et?this.media.stopAt(e):this.stopAtPosition=e),n})}playPause(){return R(this,void 0,void 0,function*(){return this.isPlaying()?this.pause():this.play()})}stop(){this.pause(),this.setTime(0)}skip(t){this.setTime(this.getCurrentTime()+t)}empty(){this.load("",[[0]],.001)}setMediaElement(t){this.unsubscribePlayerEvents(),super.setMediaElement(t),this.initPlayerEvents()}exportImage(){return R(this,arguments,void 0,function*(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()}}z.BasePlugin=class extends V{constructor(s){super(),this.subscriptions=[],this.options=s}onInit(){}_init(s){this.wavesurfer=s,this.onInit()}destroy(){this.emit("destroy"),this.subscriptions.forEach(s=>s())}},z.dom=pe;function it(s,t,e,i){return new(e||(e=Promise))(function(n,r){function a(c){try{d(i.next(c))}catch(l){r(l)}}function o(c){try{d(i.throw(c))}catch(l){r(l)}}function d(c){var l;c.done?n(c.value):(l=c.value,l instanceof e?l:new e(function(p){p(l)})).then(a,o)}d((i=i.apply(s,[])).next())})}class xt{constructor(){this.listeners={}}on(t,e,i){if(this.listeners[t]||(this.listeners[t]=new Set),this.listeners[t].add(e),i==null?void 0:i.once){const n=()=>{this.un(t,n),this.un(t,e)};return this.on(t,n),n}return()=>this.un(t,e)}un(t,e){var i;(i=this.listeners[t])===null||i===void 0||i.delete(e)}once(t,e){return this.on(t,e,{once:!0})}unAll(){this.listeners={}}emit(t,...e){this.listeners[t]&&this.listeners[t].forEach(i=>i(...e))}}class be extends xt{constructor(t){super(),this.subscriptions=[],this.options=t}onInit(){}_init(t){this.wavesurfer=t,this.onInit()}destroy(){this.emit("destroy"),this.subscriptions.forEach(t=>t())}}class ye extends xt{constructor(){super(...arguments),this.unsubscribe=()=>{}}start(){this.unsubscribe=this.on("tick",()=>{requestAnimationFrame(()=>{this.emit("tick")})}),this.emit("tick")}stop(){this.unsubscribe()}destroy(){this.unsubscribe()}}const we=["audio/webm","audio/wav","audio/mpeg","audio/mp4","audio/mp3"];class Y extends be{constructor(t){var e,i,n,r,a,o;super(Object.assign(Object.assign({},t),{audioBitsPerSecond:(e=t.audioBitsPerSecond)!==null&&e!==void 0?e:128e3,scrollingWaveform:(i=t.scrollingWaveform)!==null&&i!==void 0&&i,scrollingWaveformWindow:(n=t.scrollingWaveformWindow)!==null&&n!==void 0?n:5,continuousWaveform:(r=t.continuousWaveform)!==null&&r!==void 0&&r,renderRecordedAudio:(a=t.renderRecordedAudio)===null||a===void 0||a,mediaRecorderTimeslice:(o=t.mediaRecorderTimeslice)!==null&&o!==void 0?o:void 0})),this.stream=null,this.mediaRecorder=null,this.dataWindow=null,this.isWaveformPaused=!1,this.lastStartTime=0,this.lastDuration=0,this.duration=0,this.timer=new ye,this.subscriptions.push(this.timer.on("tick",()=>{const d=performance.now()-this.lastStartTime;this.duration=this.isPaused()?this.duration:this.lastDuration+d,this.emit("record-progress",this.duration)}))}static create(t){return new Y(t||{})}renderMicStream(t){var e;const i=new AudioContext,n=i.createMediaStreamSource(t),r=i.createAnalyser();n.connect(r),this.options.continuousWaveform&&(r.fftSize=32);const a=r.frequencyBinCount,o=new Float32Array(a);let d=0;this.wavesurfer&&((e=this.originalOptions)!==null&&e!==void 0||(this.originalOptions=Object.assign({},this.wavesurfer.options)),this.wavesurfer.options.interact=!1,this.options.scrollingWaveform&&(this.wavesurfer.options.cursorWidth=0));const c=setInterval(()=>{var l,p,h,m;if(!this.isWaveformPaused){if(r.getFloatTimeDomainData(o),this.options.scrollingWaveform){const f=Math.floor((this.options.scrollingWaveformWindow||0)*i.sampleRate),b=Math.min(f,this.dataWindow?this.dataWindow.length+a:a),g=new Float32Array(f);if(this.dataWindow){const S=Math.max(0,f-this.dataWindow.length);g.set(this.dataWindow.slice(-b+a),S)}g.set(o,f-a),this.dataWindow=g}else if(this.options.continuousWaveform){if(!this.dataWindow){const b=this.options.continuousWaveformDuration?Math.round(100*this.options.continuousWaveformDuration):((p=(l=this.wavesurfer)===null||l===void 0?void 0:l.getWidth())!==null&&p!==void 0?p:0)*window.devicePixelRatio;this.dataWindow=new Float32Array(b)}let f=0;for(let b=0;b<a;b++){const g=Math.abs(o[b]);g>f&&(f=g)}if(d+1>this.dataWindow.length){const b=new Float32Array(2*this.dataWindow.length);b.set(this.dataWindow,0),this.dataWindow=b}this.dataWindow[d]=f,d++}else this.dataWindow=o;if(this.wavesurfer){const f=((m=(h=this.dataWindow)===null||h===void 0?void 0:h.length)!==null&&m!==void 0?m:0)/100;this.wavesurfer.load("",[this.dataWindow],this.options.scrollingWaveform?this.options.scrollingWaveformWindow:f).then(()=>{this.wavesurfer&&this.options.continuousWaveform&&(this.wavesurfer.setTime(this.getDuration()/1e3),this.wavesurfer.options.minPxPerSec||this.wavesurfer.setOptions({minPxPerSec:this.wavesurfer.getWidth()/this.wavesurfer.getDuration()}))}).catch(b=>{console.error("Error rendering real-time recording data:",b)})}}},10);return{onDestroy:()=>{clearInterval(c),n==null||n.disconnect(),i==null||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.deviceId)||{deviceId:t.deviceId}})}catch(r){throw new Error("Error accessing the microphone: "+r.message)}const{onDestroy:i,onEnd:n}=this.renderMicStream(e);return this.subscriptions.push(this.once("destroy",i)),this.subscriptions.push(this.once("record-end",n)),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||we.find(a=>MediaRecorder.isTypeSupported(a)),audioBitsPerSecond:this.options.audioBitsPerSecond});this.mediaRecorder=i,this.stopRecording();const n=[];i.ondataavailable=a=>{a.data.size>0&&n.push(a.data),this.emit("record-data-available",a.data)};const r=a=>{var o;const d=new Blob(n,{type:i.mimeType});this.emit(a,d),this.options.renderRecordedAudio&&(this.applyOriginalOptionsIfNeeded(),(o=this.wavesurfer)===null||o===void 0||o.load(URL.createObjectURL(d)))};i.onpause=()=>r("record-pause"),i.onstop=()=>r("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 Se=async({files:s,uploadClient:t,widgetMgr:e,widgetInfo:i,fragmentId:n})=>{let r=[];try{r=await t.fetchFileURLs(s)}catch(c){return{successfulUploads:[],failedUploads:s.map(l=>({file:l,error:mt(c)}))}}const a=Ht(s,r),o=[],d=[];return await Promise.all(a.map(async([c,l])=>{if(!c||!l||!l.uploadUrl||!l.fileId)return{file:c,fileUrl:l,error:new Error("No upload URL found")};try{await t.uploadFile({id:l.fileId,formId:i.formId||""},l.uploadUrl,c),o.push({fileUrl:l,file:c})}catch(p){const h=mt(p);d.push({file:c,error:h})}})),e.setFileUploaderStateValue(i,new Vt({uploadedFileInfo:o.map(({file:c,fileUrl:l})=>new jt({fileId:l.fileId,fileUrls:l,name:c.name,size:c.size}))}),{fromUi:!0},n),{successfulUploads:o,failedUploads:d}},st=({widgetMgr:s,id:t,formId:e,key:i,defaultValue:n})=>{u.useEffect(()=>{const l=s.getElementState(t,i);X(l)&&q(n)&&s.setElementState(t,i,n)},[s,t,i,n]);const[r,a]=u.useState(s.getElementState(t,i)??n),o=u.useCallback(l=>{s.setElementState(t,i,l),a(l)},[s,t,i]),d=u.useMemo(()=>({formId:e||""}),[e]),c=u.useCallback(()=>o(n),[n,o]);return oe({element:d,widgetMgr:s,onFormCleared:c}),[r,o]},Ce=(s,t)=>{const{libConfig:{enforceDownloadInNewTab:e=!1}}=yt.useContext(Gt);return u.useCallback(()=>{if(!s)return;const n=de({enforceDownloadInNewTab:e,url:s,filename:t});n.style.display="none",document.body.appendChild(n),n.click(),document.body.removeChild(n)},[s,e,t])},Ee=P("div",{target:"e1f2vvgs0"})(),vt=P("div",{target:"e1f2vvgs1"})(({theme:s})=>({height:s.sizes.largestElementHeight,width:"100%",background:s.colors.secondaryBg,borderRadius:s.radii.default,marginBottom:s.spacing.twoXS,display:"flex",alignItems:"center",position:"relative",paddingLeft:s.spacing.xs,paddingRight:s.spacing.sm,border:s.colors.widgetBorderColor?`${s.sizes.borderWidth} solid ${s.colors.widgetBorderColor}`:void 0})),Re=P("div",{target:"e1f2vvgs2"})({flex:1}),Pe=P("div",{target:"e1f2vvgs3"})(({show:s})=>({display:s?"block":"none"})),xe=P("span",{target:"e1f2vvgs4"})(({theme:s,isPlayingOrRecording:t})=>({margin:s.spacing.sm,fontFamily:s.fonts.monospace,color:t?s.colors.bodyText:s.colors.fadedText60,backgroundColor:s.colors.secondaryBg,fontSize:s.fontSizes.sm})),Dt=P("div",{target:"e1f2vvgs5"})({width:"100%",textAlign:"center",overflow:"hidden"}),At=P("span",{target:"e1f2vvgs6"})(({theme:s})=>({color:s.colors.bodyText})),De=P("a",{target:"e1f2vvgs7"})(({theme:s})=>({color:s.colors.link,textDecoration:"underline"})),Ae=P("div",{target:"e1f2vvgs8"})(({theme:s})=>({height:s.sizes.largestElementHeight,display:"flex",justifyContent:"center",alignItems:"center"})),Te=P("div",{target:"e1f2vvgs9"})(({theme:s})=>{const t="0.625em";return{opacity:.2,width:"100%",height:t,backgroundSize:t,backgroundImage:`radial-gradient(${s.colors.fadedText10} 40%, transparent 40%)`,backgroundRepeat:"repeat"}}),We=P("span",{target:"e1f2vvgs10"})(({theme:s})=>({"& > button":{color:s.colors.primary,padding:s.spacing.threeXS},"& > button:hover, & > button:focus":{color:s.colors.red}})),Me=P("span",{target:"e1f2vvgs11"})(({theme:s})=>({"& > button":{padding:s.spacing.threeXS,color:s.colors.fadedText60},"& > button:hover, & > button:focus":{color:s.colors.bodyText}})),Tt=P("span",{target:"e1f2vvgs12"})(({theme:s})=>({"& > button":{padding:s.spacing.threeXS,color:s.colors.fadedText60},"& > button:hover, & > button:focus":{color:s.colors.bodyText}})),nt=P("div",{target:"e1f2vvgs13"})(({theme:s})=>({display:"flex",justifyContent:"center",alignItems:"center",flexGrow:0,flexShrink:1,padding:s.spacing.xs,gap:s.spacing.twoXS,marginRight:s.spacing.twoXS})),ke=P("div",{target:"e1f2vvgs14"})(({theme:s})=>({marginLeft:s.spacing.sm})),Ie=P(Xt,{target:"e1f2vvgs15"})(({theme:s})=>({fontSize:s.fontSizes.sm,width:s.sizes.spinnerSize,height:s.sizes.spinnerSize,borderWidth:s.sizes.spinnerThickness,justifyContents:"center",padding:s.spacing.none,margin:s.spacing.none,borderColor:s.colors.borderColor,borderTopColor:s.colors.secondary,flexGrow:0,flexShrink:0})),Oe=()=>N(Dt,{children:[v(At,{children:"This app would like to use your microphone."})," ",v(De,{href:qt,children:"Learn how to allow access."})]}),Le=u.memo(Oe),Be=()=>v(Ae,{children:v(Te,{})}),Ne=u.memo(Be),Ue=4,Fe=4,ze=4,_e=8,$e=0,G="00:00",bt=s=>{const t=Math.floor(s/1e3),e=Math.floor(t/60),i=Math.floor(e/60),n=t%60,r=e%60,a=n.toString().padStart(2,"0"),o=r.toString().padStart(2,"0"),d=i.toString().padStart(2,"0");return e<60?`${o}:${a}`:`${d}:${o}:${a}`},_=({onClick:s,disabled:t,ariaLabel:e,iconContent:i})=>v(Jt,{kind:Yt.BORDERLESS_ICON,onClick:s,disabled:t,"aria-label":e,containerWidth:!0,"data-testid":"stAudioInputActionButton",children:v(Kt,{content:i,size:"lg",color:"inherit"})}),He=({disabled:s,stopRecording:t})=>v(We,{children:v(_,{onClick:t,disabled:s,ariaLabel:"Stop recording",iconContent:Rt})}),Ve=({disabled:s,isPlaying:t,onClickPlayPause:e})=>v(Tt,{children:t?v(_,{onClick:e,disabled:s,ariaLabel:"Pause",iconContent:St}):v(_,{onClick:e,disabled:s,ariaLabel:"Play",iconContent:Ct})}),je=({disabled:s,startRecording:t})=>v(Me,{children:v(_,{onClick:t,disabled:s,ariaLabel:"Record",iconContent:wt})}),Ge=({onClick:s})=>v(Tt,{children:v(_,{disabled:!1,onClick:s,ariaLabel:"Reset",iconContent:Et})}),Xe=({disabled:s,isRecording:t,isPlaying:e,isUploading:i,isError:n,recordingUrlExists:r,startRecording:a,stopRecording:o,onClickPlayPause:d,onClear:c})=>n?v(nt,{children:v(Ge,{onClick:c})}):i?v(nt,{children:v(Ie,{"aria-label":"Uploading"})}):N(nt,{children:[t?v(He,{disabled:s,stopRecording:o}):v(je,{disabled:s,startRecording:a}),r&&v(Ve,{disabled:s,isPlaying:e,onClickPlayPause:d})]}),qe=u.memo(Xe),Ye=Qt.getLogger("convertAudioToWav");async function Ke(s){const t=new window.AudioContext,e=await s.arrayBuffer();let i;try{i=await t.decodeAudioData(e)}catch(m){Ye.error(m);return}const n=44,r=i.numberOfChannels,a=i.sampleRate,o=i.length*r*2+n,d=new ArrayBuffer(o),c=new DataView(d),l={0:{type:"string",value:"RIFF"},4:{type:"uint32",value:o-8},8:{type:"string",value:"WAVE"},12:{type:"string",value:"fmt "},16:{type:"uint32",value:16},20:{type:"uint16",value:1},22:{type:"uint16",value:r},24:{type:"uint32",value:a},28:{type:"uint32",value:a*r*2},32:{type:"uint16",value:r*2},34:{type:"uint16",value:16},36:{type:"string",value:"data"},40:{type:"uint32",value:i.length*r*2}};Object.entries(l).forEach(([m,{type:f,value:b}])=>{const g=parseInt(m,10);f==="string"?Je(c,g,b):f==="uint32"?c.setUint32(g,b,!0):f==="uint16"&&c.setUint16(g,b,!0)});let p=n;for(let m=0;m<i.length;m++)for(let f=0;f<r;f++){const b=Math.max(-1,Math.min(1,i.getChannelData(f)[m]));c.setInt16(p,b*32767,!0),p+=2}const h=new Uint8Array(d);return new Blob([h],{type:"audio/wav"})}function Je(s,t,e){for(let i=0;i<e.length;i++)s.setUint8(t+i,e.charCodeAt(i))}const Qe=()=>v(Dt,{children:v(At,{children:"An error has occurred, please try again."})}),Ze=u.memo(Qe),ti=({element:s,uploadClient:t,widgetMgr:e,fragmentId:i,disabled:n})=>{var pt;const r=Zt(),a=ce(r),[o,d]=u.useState(null),c=yt.useRef(null),[l,p]=st({widgetMgr:e,id:s.id,key:"deleteFileUrl",defaultValue:null}),[h,m]=u.useState(null),[f,b]=u.useState([]),[g,S]=u.useState(null),[y,x]=st({widgetMgr:e,id:s.id,key:"recordingUrl",defaultValue:null}),[,D]=u.useState(0),w=()=>{D(C=>C+1)},[A,T]=u.useState(G),[k,W]=st({widgetMgr:e,id:s.id,formId:s.formId,key:"recordingTime",defaultValue:G}),[I,F]=u.useState(!1),[L,Wt]=u.useState(!1),[rt,Mt]=u.useState(!1),[kt,ot]=u.useState(!1),[K,J]=u.useState(!1),at=s.id,O=s.formId,lt=u.useCallback(async C=>{ot(!0),q(O)&&e.setFormsWithUploadsInProgress(new Set([O]));let E;if(C.type==="audio/wav"?E=C:E=await Ke(C),!E){J(!0);return}const M=URL.createObjectURL(E),Ft=new Date().toISOString().slice(0,16).replace(":","-"),zt=new File([E],`${Ft}_audio.wav`,{type:E.type});x(M),Se({files:[zt],uploadClient:t,widgetMgr:e,widgetInfo:{id:at,formId:O},fragmentId:i}).then(({successfulUploads:_t,failedUploads:$t})=>{if($t.length>0){J(!0);return}const Z=_t[0];Z&&Z.fileUrl.deleteUrl&&p(Z.fileUrl.deleteUrl)}).finally(()=>{q(O)&&e.setFormsWithUploadsInProgress(new Set),ot(!1)})},[x,t,e,at,O,i,p]),B=u.useCallback(({updateWidgetManager:C,deleteFile:E})=>{X(o)||X(l)||(x(null),o.empty(),E&&t.deleteFile(l),p(null),T(G),W(G),C&&e.setFileUploaderStateValue(s,{},{fromUi:!0},i),F(!1),q(y)&&URL.revokeObjectURL(y))},[l,y,t,o,s,e,i,W,x,p]);u.useEffect(()=>{if(X(O))return;const C=new ae;return C.manageFormClearListener(e,O,()=>B({updateWidgetManager:!0,deleteFile:!1})),()=>C.disconnect()},[O,B,e]);const ct=u.useCallback(()=>{if(c.current===null)return;const C=z.create({container:c.current,waveColor:y?tt(r.colors.fadedText40,r.colors.secondaryBg):r.colors.primary,progressColor:r.colors.bodyText,height:te(r.sizes.largestElementHeight)-2*Ue,barWidth:Fe,barGap:ze,barRadius:_e,cursorWidth:$e,url:y??void 0});C.on("timeupdate",M=>{T(bt(M*1e3))}),C.on("pause",()=>{w()});const E=C.registerPlugin(Y.create({scrollingWaveform:!1,renderRecordedAudio:!0}));return E.on("record-end",async M=>{lt(M)}),E.on("record-progress",M=>{W(bt(M))}),d(C),m(E),()=>{C&&C.destroy(),E&&E.destroy()}},[lt]);u.useEffect(()=>ct(),[ct]),u.useEffect(()=>{ee(a,r)||o==null||o.setOptions({waveColor:y?tt(r.colors.fadedText40,r.colors.secondaryBg):r.colors.primary,progressColor:r.colors.bodyText})},[r,a,y,o]);const It=u.useCallback(()=>{o&&(o.playPause(),F(!0),w())},[o]),Ot=u.useCallback(async()=>{let C=g;rt||(await navigator.mediaDevices.getUserMedia({audio:!0}).then(()=>Y.getAvailableAudioDevices().then(E=>{if(b(E),E.length>0){const{deviceId:M}=E[0];S(M),C=M}})).catch(E=>{Wt(!0)}),Mt(!0)),!(!h||!C||!o)&&(o.setOptions({waveColor:r.colors.primary}),y&&B({updateWidgetManager:!1,deleteFile:!0}),h.startRecording({deviceId:C}).then(()=>{w()}))},[g,h,r,o,y,B,rt]),Lt=u.useCallback(()=>{h&&(h.stopRecording(),o==null||o.setOptions({waveColor:tt(r.colors.fadedText40,r.colors.secondaryBg)}))},[h,o,r]),Bt=Ce(y,"recording.wav"),Q=!!(h!=null&&h.isRecording()),dt=!!(o!=null&&o.isPlaying()),Nt=Q||dt,ht=!Q&&!y&&!L,Ut=L||ht||K,ut=n||L;return N(Ee,{className:"stAudioInput","data-testid":"stAudioInput",children:[v(re,{label:s.label,disabled:ut,labelVisibility:ie((pt=s.labelVisibility)==null?void 0:pt.value),children:s.help&&v(ke,{children:v(se,{content:s.help,placement:ne.TOP})})}),N(vt,{children:[N(le,{isFullScreen:!1,disableFullscreenMode:!0,target:vt,children:[y&&v(ft,{label:"Download as WAV",icon:he,onClick:()=>Bt()}),l&&v(ft,{label:"Clear recording",icon:ue,onClick:()=>B({updateWidgetManager:!0,deleteFile:!0})})]}),v(qe,{isRecording:Q,isPlaying:dt,isUploading:kt,isError:K,recordingUrlExists:!!y,startRecording:Ot,stopRecording:Lt,onClickPlayPause:It,onClear:()=>{B({updateWidgetManager:!1,deleteFile:!0}),J(!1)},disabled:ut}),N(Re,{children:[K&&v(Ze,{}),ht&&v(Ne,{}),L&&v(Le,{}),v(Pe,{"data-testid":"stAudioInputWaveSurfer",ref:c,show:!Ut})]}),v(xe,{isPlayingOrRecording:Nt,"data-testid":"stAudioInputWaveformTimeCode",children:I?A:k})]})]})},li=u.memo(ti);export{li as default};
@@ -1 +1 @@
1
- import{r as s,bh as U,z as k,cs as W,C as A,j as l,br as L,bF as P,bs as B,ba as D,bt as j}from"./index.B1VulLzc.js";import{u as _}from"./uniqueId.wPSWLsMO.js";import{u as w,a as K,b as O}from"./useOnInputChange.l7dUdah_.js";import{I as $}from"./InputInstructions.CfaxjFap.js";import{a as q}from"./useBasicWidgetState.BGHxUZDu.js";import{T as G}from"./textarea.7d3kK4wj.js";import"./inputUtils.CQWz5UKz.js";import"./FormClearHelper.D-LphorD.js";import"./base-input.DQIDgbB-.js";const x=(a,t)=>a.getStringValue(t)??t.default??null,N=a=>a.default??null,J=a=>a.value??null,Q=(a,t,o,u)=>{t.setStringValue(a,o.value,{fromUi:o.fromUi},u)},X=({disabled:a,element:t,widgetMgr:o,fragmentId:u})=>{var f;const p=s.useRef(_("text_area_")).current,[T,S]=U(),[r,n]=s.useState(!1),[C,b]=s.useState(!1),[i,d]=s.useState(()=>x(o,t)??null),I=s.useCallback(()=>{d(t.default??null),n(!0)},[t]),[y,c]=q({getStateFromWidgetMgr:x,getDefaultStateFromProto:N,getCurrStateFromProto:J,updateWidgetMgrState:Q,element:t,widgetMgr:o,fragmentId:u,onFormCleared:I});w(y,i,d,r);const e=k(),m=s.useCallback(()=>{n(!1),c({value:i,fromUi:!0})},[i,c]),F=s.useCallback(()=>{r&&m(),b(!1)},[r,m]),V=s.useCallback(()=>{b(!0)},[]),v=K({formId:t.formId,maxChars:t.maxChars,setDirty:n,setUiValue:d,setValueWithSource:c}),z=O(t.formId,m,r,o,u,!0),{height:g,placeholder:E,formId:h}=t,R=W({formId:h})?o.allowFormEnterToSubmit(h):r,H=C&&T>e.breakpoints.hideWidgetDetails;return A("div",{className:"stTextArea","data-testid":"stTextArea",ref:S,children:[l(j,{label:t.label,disabled:a,labelVisibility:L((f=t.labelVisibility)==null?void 0:f.value),htmlFor:p,children:t.help&&l(P,{children:l(B,{content:t.help,placement:D.TOP_RIGHT})})}),l(G,{value:i??"",placeholder:E,onBlur:F,onFocus:V,onChange:v,onKeyDown:z,"aria-label":t.label,disabled:a,id:p,overrides:{Input:{style:{lineHeight:e.lineHeights.inputWidget,height:g?`${g}px`:"",minHeight:e.sizes.largestElementHeight,resize:"vertical","::placeholder":{opacity:"0.7"},paddingRight:e.spacing.md,paddingLeft:e.spacing.md,paddingBottom:e.spacing.md,paddingTop:e.spacing.md}},Root:{props:{"data-testid":"stTextAreaRootElement"},style:{borderLeftWidth:e.sizes.borderWidth,borderRightWidth:e.sizes.borderWidth,borderTopWidth:e.sizes.borderWidth,borderBottomWidth:e.sizes.borderWidth}}}}),H&&l($,{dirty:r,value:i??"",maxLength:t.maxChars,type:"multiline",inForm:W({formId:h}),allowEnterToSubmit:R})]})},it=s.memo(X);export{it as default};
1
+ import{r as s,bh as U,z as k,cs as W,C as A,j as l,br as L,bF as P,bs as B,ba as D,bt as j}from"./index.DCKU7zCS.js";import{u as _}from"./uniqueId._zK6ugwW.js";import{u as w,a as K,b as O}from"./useOnInputChange.5wieT2fD.js";import{I as $}from"./InputInstructions.BXUos__H.js";import{a as q}from"./useBasicWidgetState.C_V8mPrP.js";import{T as G}from"./textarea.CQnqAl1g.js";import"./inputUtils.CQWz5UKz.js";import"./FormClearHelper.DJyHVHSH.js";import"./base-input.DDkkgpGf.js";const x=(a,t)=>a.getStringValue(t)??t.default??null,N=a=>a.default??null,J=a=>a.value??null,Q=(a,t,o,u)=>{t.setStringValue(a,o.value,{fromUi:o.fromUi},u)},X=({disabled:a,element:t,widgetMgr:o,fragmentId:u})=>{var f;const p=s.useRef(_("text_area_")).current,[T,S]=U(),[r,n]=s.useState(!1),[C,b]=s.useState(!1),[i,d]=s.useState(()=>x(o,t)??null),I=s.useCallback(()=>{d(t.default??null),n(!0)},[t]),[y,c]=q({getStateFromWidgetMgr:x,getDefaultStateFromProto:N,getCurrStateFromProto:J,updateWidgetMgrState:Q,element:t,widgetMgr:o,fragmentId:u,onFormCleared:I});w(y,i,d,r);const e=k(),m=s.useCallback(()=>{n(!1),c({value:i,fromUi:!0})},[i,c]),F=s.useCallback(()=>{r&&m(),b(!1)},[r,m]),V=s.useCallback(()=>{b(!0)},[]),v=K({formId:t.formId,maxChars:t.maxChars,setDirty:n,setUiValue:d,setValueWithSource:c}),z=O(t.formId,m,r,o,u,!0),{height:g,placeholder:E,formId:h}=t,R=W({formId:h})?o.allowFormEnterToSubmit(h):r,H=C&&T>e.breakpoints.hideWidgetDetails;return A("div",{className:"stTextArea","data-testid":"stTextArea",ref:S,children:[l(j,{label:t.label,disabled:a,labelVisibility:L((f=t.labelVisibility)==null?void 0:f.value),htmlFor:p,children:t.help&&l(P,{children:l(B,{content:t.help,placement:D.TOP_RIGHT})})}),l(G,{value:i??"",placeholder:E,onBlur:F,onFocus:V,onChange:v,onKeyDown:z,"aria-label":t.label,disabled:a,id:p,overrides:{Input:{style:{lineHeight:e.lineHeights.inputWidget,height:g?`${g}px`:"",minHeight:e.sizes.largestElementHeight,resize:"vertical","::placeholder":{opacity:"0.7"},paddingRight:e.spacing.md,paddingLeft:e.spacing.md,paddingBottom:e.spacing.md,paddingTop:e.spacing.md}},Root:{props:{"data-testid":"stTextAreaRootElement"},style:{borderLeftWidth:e.sizes.borderWidth,borderRightWidth:e.sizes.borderWidth,borderTopWidth:e.sizes.borderWidth,borderBottomWidth:e.sizes.borderWidth}}}}),H&&l($,{dirty:r,value:i??"",maxLength:t.maxChars,type:"multiline",inForm:W({formId:h}),allowEnterToSubmit:R})]})},it=s.memo(X);export{it as default};
@@ -1 +1 @@
1
- import{r as i,j as c,br as g,bP as b}from"./index.B1VulLzc.js";import{a as m}from"./useBasicWidgetState.BGHxUZDu.js";import"./FormClearHelper.D-LphorD.js";const f=(t,e)=>t.getStringValue(e),p=t=>t.default??null,C=t=>t.value??null,d=(t,e,r,o)=>{e.setStringValue(t,r.value,{fromUi:r.fromUi},o)},P=({element:t,disabled:e,widgetMgr:r,fragmentId:o})=>{var l;const[s,a]=m({getStateFromWidgetMgr:f,getDefaultStateFromProto:p,getCurrStateFromProto:C,updateWidgetMgrState:d,element:t,widgetMgr:r,fragmentId:o}),u=i.useCallback(n=>{a({value:n,fromUi:!0})},[a]);return c(b,{label:t.label,labelVisibility:g((l=t.labelVisibility)==null?void 0:l.value),help:t.help,onChange:u,disabled:e,value:s})},k=i.memo(P);export{k as default};
1
+ import{r as i,j as c,br as g,bP as b}from"./index.DCKU7zCS.js";import{a as m}from"./useBasicWidgetState.C_V8mPrP.js";import"./FormClearHelper.DJyHVHSH.js";const f=(t,e)=>t.getStringValue(e),p=t=>t.default??null,C=t=>t.value??null,d=(t,e,r,o)=>{e.setStringValue(t,r.value,{fromUi:r.fromUi},o)},P=({element:t,disabled:e,widgetMgr:r,fragmentId:o})=>{var l;const[s,a]=m({getStateFromWidgetMgr:f,getDefaultStateFromProto:p,getCurrStateFromProto:C,updateWidgetMgrState:d,element:t,widgetMgr:r,fragmentId:o}),u=i.useCallback(n=>{a({value:n,fromUi:!0})},[a]);return c(b,{label:t.label,labelVisibility:g((l=t.labelVisibility)==null?void 0:l.value),help:t.help,onChange:u,disabled:e,value:s})},k=i.memo(P);export{k as default};