owncast/static/web/_next/static/chunks/6356-a15c3f8b525f2fe2.js

1 line
7.6 KiB
JavaScript
Raw Normal View History

2023-05-07 23:00:49 +03:00
"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6356],{36356:function(e,t,n){n.r(t),n.d(t,{default:function(){return M}});var r=n(87462),o=n(15671),a=n(43144),i=n(32531),s=n(73568),c=n(67294),u=n(4942),l=n(45987),p=n(74165),f=n(71002),d=n(15861),h=n(74902),v=n(94184),y=n.n(v),b=n(64217);function m(e){var t=e.responseText||e.response;if(!t)return t;try{return JSON.parse(t)}catch(e){return t}}function k(e){var t=new XMLHttpRequest;e.onProgress&&t.upload&&(t.upload.onprogress=function(t){t.total>0&&(t.percent=t.loaded/t.total*100),e.onProgress(t)});var n=new FormData;e.data&&Object.keys(e.data).forEach(function(t){var r=e.data[t];if(Array.isArray(r)){r.forEach(function(e){n.append("".concat(t,"[]"),e)});return}n.append(t,r)}),e.file instanceof Blob?n.append(e.filename,e.file,e.file.name):n.append(e.filename,e.file),t.onerror=function(t){e.onError(t)},t.onload=function(){if(t.status<200||t.status>=300){var n;return e.onError(((n=Error("cannot ".concat(e.method," ").concat(e.action," ").concat(t.status,"'"))).status=t.status,n.method=e.method,n.url=e.action,n),m(t))}return e.onSuccess(m(t),t)},t.open(e.method,e.action,!0),e.withCredentials&&"withCredentials"in t&&(t.withCredentials=!0);var r=e.headers||{};return null!==r["X-Requested-With"]&&t.setRequestHeader("X-Requested-With","XMLHttpRequest"),Object.keys(r).forEach(function(e){null!==r[e]&&t.setRequestHeader(e,r[e])}),t.send(n),{abort:function(){t.abort()}}}var w=+new Date,g=0;function C(){return"rc-upload-".concat(w,"-").concat(++g)}var E=n(80334),F=function(e,t){if(e&&t){var n=Array.isArray(t)?t:t.split(","),r=e.name||"",o=e.type||"",a=o.replace(/\/.*$/,"");return n.some(function(e){var t=e.trim();if(/^\*(\/\*)?$/.test(e))return!0;if("."===t.charAt(0)){var n=r.toLowerCase(),i=t.toLowerCase(),s=[i];return(".jpg"===i||".jpeg"===i)&&(s=[".jpg",".jpeg"]),s.some(function(e){return n.endsWith(e)})}return/\/\*$/.test(t)?a===t.replace(/\/.*$/,""):o===t||!!/^\w+$/.test(t)&&((0,E.ZP)(!1,"Upload takes an invalidate 'accept' type '".concat(t,"'.Skip for check.")),!0)})}return!0},Z=function(e,t,n){var r=function e(r,o){if(r.path=o||"",r.isFile)r.file(function(e){n(e)&&(r.fullPath&&!e.webkitRelativePath&&(Object.defineProperties(e,{webkitRelativePath:{writable:!0}}),e.webkitRelativePath=r.fullPath.replace(/^\//,""),Object.defineProperties(e,{webkitRelativePath:{writable:!1}})),t([e]))});else if(r.isDirectory){var a,i,s;a=function(t){t.forEach(function(t){e(t,"".concat(o).concat(r.name,"/"))})},i=r.createReader(),s=[],function e(){i.readEntries(function(t){var n=Array.prototype.slice.apply(t);s=s.concat(n),n.length?e():a(s)})}()}};e.forEach(function(e){r(e.webkitGetAsEntry())})},x=["component","prefixCls","className","disabled","id","style","multiple","accept","capture","children","directory","openFileDialogOnClick","onMouseEnter","onMouseLeave"],D=function(e){(0,i.Z)(n,e);var t=(0,s.Z)(n);function n(){(0,o.Z)(this,n);for(var e,r,a=arguments.length,i=Array(a),s=0;s<a;s++)i[s]=arguments[s];return(e=t.call.apply(t,[this].concat(i))).state={uid:C()},e.reqs={},e.fileInput=void 0,e._isMounted=void 0,e.onChange=function(t){var n=e.props,r=n.accept,o=n.directory,a=t.target.files,i=(0,h.Z)(a).filter(function(e){return!o||F(e,r)});e.uploadFiles(i),e.reset()},e.onClick=function(t){var n=e.fileInput;if(n){var r=e.props,o=r.children,a=r.onClick;if(o&&"button"===o.type){var i=n.parentNode;i.focus(),i.querySelector("button").blur()}n.click(),a&&a(t)}},e.onKeyDown=function(t){"Enter"===t.key&&e.onClick(t)},e.onFileDrop=function(t){var n=e.props.multiple;if(t.preventDefault(),"dragover"!==t.type){if(e.props.directory)Z(Array.prototype.slice.call(t.dataTransfer.items),e.uploadFiles,function(t){return F(t,e.props.accept)});else{var r=(0,h.Z)(t.dataTransfer.files).filter(function(t){return F(t,e.props.accept)});!1===n&&(r=r.slice(0,1)),e.uploadFiles(r)}}},e.uploadFiles=function(t){var n=(0,h.Z)(t);Promise.all(n.map(function(t){return t.uid=C(),e.processFile(t,n)})).then(function(t){var n=e.props.onBatchStart;null==n||n(t.map(function(e){return{file:e.origin,parsedFile:e.parsedFile