mirror of
https://github.com/owncast/owncast.git
synced 2025-01-05 08:07:58 +03:00
1 line
No EOL
15 KiB
JavaScript
Vendored
1 line
No EOL
15 KiB
JavaScript
Vendored
"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[5560],{15560:function(e,t,n){n.r(t),n.d(t,{default:function(){return y}});var r=n(4942),a=n(74902),u=n(97685),o=n(71002),l=n(67294),i=n(94184),c=n.n(i),s=n(96774),f=n.n(s),d=n(21770),v=n(87462),g=n(45987),m=n(1413),h=n(15105),p=l.createContext({min:0,max:0,direction:"ltr",step:1,includedStart:0,includedEnd:0,tabIndex:0});function getDirectionStyle(e,t,n,r){var a=(t-n)/(r-n),u={};switch(e){case"rtl":u.right="".concat(100*a,"%"),u.transform="translateX(50%)";break;case"btt":u.bottom="".concat(100*a,"%"),u.transform="translateY(50%)";break;case"ttb":u.top="".concat(100*a,"%"),u.transform="translateY(-50%)";break;default:u.left="".concat(100*a,"%"),u.transform="translateX(-50%)"}return u}function getIndex(e,t){return Array.isArray(e)?e[t]:e}var b=["prefixCls","value","valueIndex","onStartMove","style","render","dragging","onOffsetChange"],M=l.forwardRef(function(e,t){var n,a,u=e.prefixCls,o=e.value,i=e.valueIndex,s=e.onStartMove,f=e.style,d=e.render,M=e.dragging,x=e.onOffsetChange,C=(0,g.Z)(e,b),y=l.useContext(p),k=y.min,E=y.max,Z=y.direction,S=y.disabled,V=y.range,I=y.tabIndex,D=y.ariaLabelForHandle,w=y.ariaLabelledByForHandle,T=y.ariaValueTextFormatterForHandle,F="".concat(u,"-handle"),onInternalStartMove=function(e){S||s(e,i)},L=getDirectionStyle(Z,o,k,E),P=l.createElement("div",(0,v.Z)({ref:t,className:c()(F,(n={},(0,r.Z)(n,"".concat(F,"-").concat(i+1),V),(0,r.Z)(n,"".concat(F,"-dragging"),M),n)),style:(0,m.Z)((0,m.Z)({},L),f),onMouseDown:onInternalStartMove,onTouchStart:onInternalStartMove,onKeyDown:function(e){if(!S){var t=null;switch(e.which||e.keyCode){case h.Z.LEFT:t="ltr"===Z||"btt"===Z?-1:1;break;case h.Z.RIGHT:t="ltr"===Z||"btt"===Z?1:-1;break;case h.Z.UP:t="ttb"!==Z?1:-1;break;case h.Z.DOWN:t="ttb"!==Z?-1:1;break;case h.Z.HOME:t="min";break;case h.Z.END:t="max";break;case h.Z.PAGE_UP:t=2;break;case h.Z.PAGE_DOWN:t=-2}null!==t&&(e.preventDefault(),x(t,i))}},tabIndex:S?null:getIndex(I,i),role:"slider","aria-valuemin":k,"aria-valuemax":E,"aria-valuenow":o,"aria-disabled":S,"aria-label":getIndex(D,i),"aria-labelledby":getIndex(w,i),"aria-valuetext":null===(a=getIndex(T,i))||void 0===a?void 0:a(o)},C));return d&&(P=d(P,{index:i,prefixCls:u,value:o,dragging:M})),P}),x=["prefixCls","style","onStartMove","onOffsetChange","values","handleRender","draggingIndex"],C=l.forwardRef(function(e,t){var n=e.prefixCls,r=e.style,a=e.onStartMove,u=e.onOffsetChange,o=e.values,i=e.handleRender,c=e.draggingIndex,s=(0,g.Z)(e,x),f=l.useRef({});return l.useImperativeHandle(t,function(){return{focus:function(e){var t;null===(t=f.current[e])||void 0===t||t.focus()}}}),l.createElement(l.Fragment,null,o.map(function(e,t){return l.createElement(M,(0,v.Z)({ref:function(e){e?f.current[t]=e:delete f.current[t]},dragging:c===t,prefixCls:n,style:getIndex(r,t),key:t,value:e,valueIndex:t,onStartMove:a,onOffsetChange:u,render:i},s))}))});function getPosition(e){var t="touches"in e?e.touches[0]:e;return{pageX:t.pageX,pageY:t.pageY}}function useDrag(e,t,n,r,o,i,c,s,f){var d=l.useState(null),v=(0,u.Z)(d,2),g=v[0],m=v[1],h=l.useState(-1),p=(0,u.Z)(h,2),b=p[0],M=p[1],x=l.useState(n),C=(0,u.Z)(x,2),y=C[0],k=C[1],E=l.useState(n),Z=(0,u.Z)(E,2),S=Z[0],V=Z[1],I=l.useRef(null),D=l.useRef(null);l.useEffect(function(){-1===b&&k(n)},[n,b]),l.useEffect(function(){return function(){document.removeEventListener("mousemove",I.current),document.removeEventListener("mouseup",D.current),document.removeEventListener("touchmove",I.current),document.removeEventListener("touchend",D.current)}},[]);var flushValues=function(e,t){y.some(function(t,n){return t!==e[n]})&&(void 0!==t&&m(t),k(e),c(e))},updateCacheValue=function(e,t){if(-1===e){var n=S[0],u=S[S.length-1],l=r-n,c=t*(o-r);c=i(n+(c=Math.min(c=Math.max(c,l),o-u)))-n,flushValues(S.map(function(e){return e+c}))}else{var s=(0,a.Z)(y);s[e]=S[e];var d=f(s,(o-r)*t,e,"dist");flushValues(d.values,d.value)}},w=l.useRef(updateCacheValue);return w.current=updateCacheValue,[b,g,l.useMemo(function(){var e=(0,a.Z)(n).sort(function(e,t){return e-t}),t=(0,a.Z)(y).sort(function(e,t){return e-t});return e.every(function(e,n){return e===t[n]})?y:n},[n,y]),function(r,a){r.stopPropagation();var u=n[a];M(a),m(u),V(n);var o=getPosition(r),l=o.pageX,i=o.pageY,onMouseMove=function(n){n.preventDefault();var r,u=getPosition(n),o=u.pageX,c=u.pageY,s=o-l,f=c-i,d=e.current.getBoundingClientRect(),v=d.width,g=d.height;switch(t){case"btt":r=-f/g;break;case"ttb":r=f/g;break;case"rtl":r=-s/v;break;default:r=s/v}w.current(a,r)},onMouseUp=function onMouseUp(e){e.preventDefault(),document.removeEventListener("mouseup",onMouseUp),document.removeEventListener("mousemove",onMouseMove),document.removeEventListener("touchend",onMouseUp),document.removeEventListener("touchmove",onMouseMove),I.current=null,D.current=null,M(-1),s()};document.addEventListener("mouseup",onMouseUp),document.addEventListener("mousemove",onMouseMove),document.addEventListener("touchend",onMouseUp),document.addEventListener("touchmove",onMouseMove),I.current=onMouseMove,D.current=onMouseUp}]}function Track(e){var t=e.prefixCls,n=e.style,r=e.start,a=e.end,u=e.index,o=e.onStartMove,i=l.useContext(p),s=i.direction,f=i.min,d=i.max,v=i.disabled,g=i.range,h="".concat(t,"-track"),b=(r-f)/(d-f),M=(a-f)/(d-f),onInternalStartMove=function(e){!v&&o&&o(e,-1)},x={};switch(s){case"rtl":x.right="".concat(100*b,"%"),x.width="".concat(100*M-100*b,"%");break;case"btt":x.bottom="".concat(100*b,"%"),x.height="".concat(100*M-100*b,"%");break;case"ttb":x.top="".concat(100*b,"%"),x.height="".concat(100*M-100*b,"%");break;default:x.left="".concat(100*b,"%"),x.width="".concat(100*M-100*b,"%")}return l.createElement("div",{className:c()(h,g&&"".concat(h,"-").concat(u+1)),style:(0,m.Z)((0,m.Z)({},x),n),onMouseDown:onInternalStartMove,onTouchStart:onInternalStartMove})}function Tracks(e){var t=e.prefixCls,n=e.style,r=e.values,a=e.startPoint,u=e.onStartMove,o=l.useContext(p),i=o.included,c=o.range,s=o.min,f=l.useMemo(function(){if(!c){if(0===r.length)return[];var e=null!=a?a:s,t=r[0];return[{start:Math.min(e,t),end:Math.max(e,t)}]}for(var n=[],u=0;u<r.length-1;u+=1)n.push({start:r[u],end:r[u+1]});return n},[r,c,a,s]);return i?f.map(function(e,r){var a=e.start,o=e.end;return l.createElement(Track,{index:r,prefixCls:t,style:getIndex(n,r),start:a,end:o,key:r,onStartMove:u})}):null}function Mark(e){var t=e.prefixCls,n=e.style,a=e.children,u=e.value,o=e.onClick,i=l.useContext(p),s=i.min,f=i.max,d=i.direction,v=i.includedStart,g=i.includedEnd,h=i.included,b="".concat(t,"-text"),M=getDirectionStyle(d,u,s,f);return l.createElement("span",{className:c()(b,(0,r.Z)({},"".concat(b,"-active"),h&&v<=u&&u<=g)),style:(0,m.Z)((0,m.Z)({},M),n),onMouseDown:function(e){e.stopPropagation()},onClick:function(){o(u)}},a)}function Marks(e){var t=e.prefixCls,n=e.marks,r=e.onClick,a="".concat(t,"-mark");return n.length?l.createElement("div",{className:a},n.map(function(e){var t=e.value,n=e.style,u=e.label;return l.createElement(Mark,{key:t,prefixCls:a,style:n,value:t,onClick:r},u)})):null}function Dot(e){var t=e.prefixCls,n=e.value,a=e.style,u=e.activeStyle,o=l.useContext(p),i=o.min,s=o.max,f=o.direction,d=o.included,v=o.includedStart,g=o.includedEnd,h="".concat(t,"-dot"),b=d&&v<=n&&n<=g,M=(0,m.Z)((0,m.Z)({},getDirectionStyle(f,n,i,s)),"function"==typeof a?a(n):a);return b&&(M=(0,m.Z)((0,m.Z)({},M),"function"==typeof u?u(n):u)),l.createElement("span",{className:c()(h,(0,r.Z)({},"".concat(h,"-active"),b)),style:M})}function Steps(e){var t=e.prefixCls,n=e.marks,r=e.dots,a=e.style,u=e.activeStyle,o=l.useContext(p),i=o.min,c=o.max,s=o.step,f=l.useMemo(function(){var e=new Set;if(n.forEach(function(t){e.add(t.value)}),r&&null!==s)for(var t=i;t<=c;)e.add(t),t+=s;return Array.from(e)},[i,c,s,r,n]);return l.createElement("div",{className:"".concat(t,"-step")},f.map(function(e){return l.createElement(Dot,{prefixCls:t,key:e,value:e,style:a,activeStyle:u})}))}function useOffset(e,t,n,r,u,o){var i=l.useCallback(function(n){return isFinite(n),Math.max(e,Math.min(t,n))},[e,t]),c=l.useCallback(function(r){if(null!==n){var a=e+Math.round((i(r)-e)/n)*n,getDecimal=function(e){return(String(e).split(".")[1]||"").length},u=Math.max(getDecimal(n),getDecimal(t),getDecimal(e)),o=Number(a.toFixed(u));return e<=o&&o<=t?o:null}return null},[n,e,t,i]),s=l.useCallback(function(a){var u=i(a),o=r.map(function(e){return e.value});null!==n&&o.push(c(a)),o.push(e,t);var l=o[0],s=t-e;return o.forEach(function(e){var t=Math.abs(u-e);t<=s&&(l=e,s=t)}),l},[e,t,r,n,i,c]),offsetValue=function offsetValue(u,o,l){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"unit";if("number"==typeof o){var s,f=u[l],d=f+o,v=[];r.forEach(function(e){v.push(e.value)}),v.push(e,t),v.push(c(f));var g=o>0?1:-1;"unit"===i?v.push(c(f+g*n)):v.push(c(d)),v=v.filter(function(e){return null!==e}).filter(function(e){return o<0?e<=f:e>=f}),"unit"===i&&(v=v.filter(function(e){return e!==f}));var m="unit"===i?f:d,h=Math.abs((s=v[0])-m);if(v.forEach(function(e){var t=Math.abs(e-m);t<h&&(s=e,h=t)}),void 0===s)return o<0?e:t;if("dist"===i)return s;if(Math.abs(o)>1){var p=(0,a.Z)(u);return p[l]=s,offsetValue(p,o-g,l,i)}return s}return"min"===o?e:"max"===o?t:void 0},offsetChangedValue=function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"unit",a=e[n],u=offsetValue(e,t,n,r);return{value:u,changed:u!==a}},needPush=function(e){return null===o&&0===e||"number"==typeof o&&e<o};return[s,function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"unit",a=e.map(s),l=a[n],i=offsetValue(a,t,n,r);if(a[n]=i,!1===u){var c=o||0;n>0&&a[n-1]!==l&&(a[n]=Math.max(a[n],a[n-1]+c)),n<a.length-1&&a[n+1]!==l&&(a[n]=Math.min(a[n],a[n+1]-c))}else if("number"==typeof o||null===o){for(var f=n+1;f<a.length;f+=1)for(var d=!0;needPush(a[f]-a[f-1])&&d;){var v=offsetChangedValue(a,1,f);a[f]=v.value,d=v.changed}for(var g=n;g>0;g-=1)for(var m=!0;needPush(a[g]-a[g-1])&&m;){var h=offsetChangedValue(a,-1,g-1);a[g-1]=h.value,m=h.changed}for(var p=a.length-1;p>0;p-=1)for(var b=!0;needPush(a[p]-a[p-1])&&b;){var M=offsetChangedValue(a,-1,p-1);a[p-1]=M.value,b=M.changed}for(var x=0;x<a.length-1;x+=1)for(var C=!0;needPush(a[x+1]-a[x])&&C;){var y=offsetChangedValue(a,1,x+1);a[x+1]=y.value,C=y.changed}}return{value:a[n],values:a}}]}n(80334);var y=l.forwardRef(function(e,t){var n,i=e.prefixCls,s=void 0===i?"rc-slider":i,v=e.className,g=e.style,m=e.disabled,h=void 0!==m&&m,b=e.autoFocus,M=e.onFocus,x=e.onBlur,y=e.min,k=void 0===y?0:y,E=e.max,Z=void 0===E?100:E,S=e.step,V=void 0===S?1:S,I=e.value,D=e.defaultValue,w=e.range,T=e.count,F=e.onChange,L=e.onBeforeChange,P=e.onAfterChange,R=e.allowCross,N=e.pushable,O=void 0!==N&&N,H=e.draggableTrack,U=e.reverse,A=e.vertical,B=e.included,X=void 0===B||B,Y=e.startPoint,_=e.trackStyle,G=e.handleStyle,j=e.railStyle,W=e.dotStyle,z=e.activeDotStyle,K=e.marks,q=e.dots,J=e.handleRender,Q=e.tabIndex,$=void 0===Q?0:Q,ee=e.ariaLabelForHandle,et=e.ariaLabelledByForHandle,en=e.ariaValueTextFormatterForHandle,er=l.useRef(),ea=l.useRef(),eu=l.useMemo(function(){return A?U?"ttb":"btt":U?"rtl":"ltr"},[U,A]),eo=l.useMemo(function(){return isFinite(k)?k:0},[k]),el=l.useMemo(function(){return isFinite(Z)?Z:100},[Z]),ei=l.useMemo(function(){return null!==V&&V<=0?1:V},[V]),ec=l.useMemo(function(){return!0===O?ei:O>=0&&O},[O,ei]),es=l.useMemo(function(){return Object.keys(K||{}).map(function(e){var t=K[e],n={value:Number(e)};return t&&"object"===(0,o.Z)(t)&&!l.isValidElement(t)&&("label"in t||"style"in t)?(n.style=t.style,n.label=t.label):n.label=t,n}).filter(function(e){var t=e.label;return t||"number"==typeof t}).sort(function(e,t){return e.value-t.value})},[K]),ef=useOffset(eo,el,ei,es,void 0===R||R,ec),ed=(0,u.Z)(ef,2),ev=ed[0],eg=ed[1],em=(0,d.Z)(D,{value:I}),eh=(0,u.Z)(em,2),ep=eh[0],eb=eh[1],eM=l.useMemo(function(){var e=null==ep?[]:Array.isArray(ep)?ep:[ep],t=(0,u.Z)(e,1)[0],n=void 0===t?eo:t,r=null===ep?[]:[n];if(w){if(r=(0,a.Z)(e),T||void 0===ep){var o,l=T>=0?T+1:2;for(r=r.slice(0,l);r.length<l;)r.push(null!==(o=r[r.length-1])&&void 0!==o?o:eo)}r.sort(function(e,t){return e-t})}return r.forEach(function(e,t){r[t]=ev(e)}),r},[ep,w,eo,T,ev]),ex=l.useRef(eM);ex.current=eM;var getTriggerValue=function(e){return w?e:e[0]},triggerChange=function(e){var t=(0,a.Z)(e).sort(function(e,t){return e-t});F&&!f()(t,ex.current)&&F(getTriggerValue(t)),eb(t)},changeToCloseValue=function(e){if(!h){var t=0,n=el-eo;eM.forEach(function(r,a){var u=Math.abs(e-r);u<=n&&(n=u,t=a)});var r=(0,a.Z)(eM);r[t]=e,w&&!eM.length&&void 0===T&&r.push(e),null==L||L(getTriggerValue(r)),triggerChange(r),null==P||P(getTriggerValue(r))}},eC=l.useState(null),ey=(0,u.Z)(eC,2),ek=ey[0],eE=ey[1];l.useEffect(function(){if(null!==ek){var e=eM.indexOf(ek);e>=0&&er.current.focus(e)}eE(null)},[ek]);var eZ=l.useMemo(function(){return(!H||null!==ei)&&H},[H,ei]),eS=useDrag(ea,eu,eM,eo,el,ev,triggerChange,function(){null==P||P(getTriggerValue(ex.current))},eg),eV=(0,u.Z)(eS,4),eI=eV[0],eD=eV[1],ew=eV[2],eT=eV[3],onStartMove=function(e,t){eT(e,t),null==L||L(getTriggerValue(ex.current))},eF=-1!==eI;l.useEffect(function(){if(!eF){var e=eM.lastIndexOf(eD);er.current.focus(e)}},[eF]);var eL=l.useMemo(function(){return(0,a.Z)(ew).sort(function(e,t){return e-t})},[ew]),eP=l.useMemo(function(){return w?[eL[0],eL[eL.length-1]]:[eo,eL[0]]},[eL,w,eo]),eR=(0,u.Z)(eP,2),eN=eR[0],eO=eR[1];l.useImperativeHandle(t,function(){return{focus:function(){er.current.focus(0)},blur:function(){var e=document.activeElement;ea.current.contains(e)&&(null==e||e.blur())}}}),l.useEffect(function(){b&&er.current.focus(0)},[]);var eH=l.useMemo(function(){return{min:eo,max:el,direction:eu,disabled:h,step:ei,included:X,includedStart:eN,includedEnd:eO,range:w,tabIndex:$,ariaLabelForHandle:ee,ariaLabelledByForHandle:et,ariaValueTextFormatterForHandle:en}},[eo,el,eu,h,ei,X,eN,eO,w,$,ee,et,en]);return l.createElement(p.Provider,{value:eH},l.createElement("div",{ref:ea,className:c()(s,v,(n={},(0,r.Z)(n,"".concat(s,"-disabled"),h),(0,r.Z)(n,"".concat(s,"-vertical"),A),(0,r.Z)(n,"".concat(s,"-horizontal"),!A),(0,r.Z)(n,"".concat(s,"-with-marks"),es.length),n)),style:g,onMouseDown:function(e){e.preventDefault();var t,n=ea.current.getBoundingClientRect(),r=n.width,a=n.height,u=n.left,o=n.top,l=n.bottom,i=n.right,c=e.clientX,s=e.clientY;switch(eu){case"btt":t=(l-s)/a;break;case"ttb":t=(s-o)/a;break;case"rtl":t=(i-c)/r;break;default:t=(c-u)/r}changeToCloseValue(ev(eo+t*(el-eo)))}},l.createElement("div",{className:"".concat(s,"-rail"),style:j}),l.createElement(Tracks,{prefixCls:s,style:_,values:eL,startPoint:Y,onStartMove:eZ?onStartMove:null}),l.createElement(Steps,{prefixCls:s,marks:es,dots:q,style:W,activeStyle:z}),l.createElement(C,{ref:er,prefixCls:s,style:G,values:ew,draggingIndex:eI,onStartMove:onStartMove,onOffsetChange:function(e,t){if(!h){var n=eg(eM,e,t);null==L||L(getTriggerValue(eM)),triggerChange(n.values),null==P||P(getTriggerValue(n.values)),eE(n.value)}},onFocus:M,onBlur:x,handleRender:J}),l.createElement(Marks,{prefixCls:s,marks:es,onClick:changeToCloseValue})))})}}]); |