{"ast":null,"code":"function getError(option, xhr) {\n var msg = \"cannot \".concat(option.method, \" \").concat(option.action, \" \").concat(xhr.status, \"'\");\n var err = new Error(msg);\n err.status = xhr.status;\n err.method = option.method;\n err.url = option.action;\n return err;\n}\nfunction getBody(xhr) {\n var text = xhr.responseText || xhr.response;\n if (!text) {\n return text;\n }\n try {\n return JSON.parse(text);\n } catch (e) {\n return text;\n }\n}\nexport default function upload(option) {\n // eslint-disable-next-line no-undef\n var xhr = new XMLHttpRequest();\n if (option.onProgress && xhr.upload) {\n xhr.upload.onprogress = function progress(e) {\n if (e.total > 0) {\n e.percent = e.loaded / e.total * 100;\n }\n option.onProgress(e);\n };\n }\n\n // eslint-disable-next-line no-undef\n var formData = new FormData();\n if (option.data) {\n Object.keys(option.data).forEach(function (key) {\n var value = option.data[key];\n // support key-value array data\n if (Array.isArray(value)) {\n value.forEach(function (item) {\n // { list: [ 11, 22 ] }\n // formData.append('list[]', 11);\n formData.append(\"\".concat(key, \"[]\"), item);\n });\n return;\n }\n formData.append(key, value);\n });\n }\n\n // eslint-disable-next-line no-undef\n if (option.file instanceof Blob) {\n formData.append(option.filename, option.file, option.file.name);\n } else {\n formData.append(option.filename, option.file);\n }\n xhr.onerror = function error(e) {\n option.onError(e);\n };\n xhr.onload = function onload() {\n // allow success when 2xx status\n // see https://github.com/react-component/upload/issues/34\n if (xhr.status < 200 || xhr.status >= 300) {\n return option.onError(getError(option, xhr), getBody(xhr));\n }\n return option.onSuccess(getBody(xhr), xhr);\n };\n xhr.open(option.method, option.action, true);\n\n // Has to be after `.open()`. See https://github.com/enyo/dropzone/issues/179\n if (option.withCredentials && 'withCredentials' in xhr) {\n xhr.withCredentials = true;\n }\n var headers = option.headers || {};\n\n // when set headers['X-Requested-With'] = null , can close default XHR header\n // see https://github.com/react-component/upload/issues/33\n if (headers['X-Requested-With'] !== null) {\n xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');\n }\n Object.keys(headers).forEach(function (h) {\n if (headers[h] !== null) {\n xhr.setRequestHeader(h, headers[h]);\n }\n });\n xhr.send(formData);\n return {\n abort: function abort() {\n xhr.abort();\n }\n };\n}","map":{"version":3,"names":["getError","option","xhr","msg","concat","method","action","status","err","Error","url","getBody","text","responseText","response","JSON","parse","e","upload","XMLHttpRequest","onProgress","onprogress","progress","total","percent","loaded","formData","FormData","data","Object","keys","forEach","key","value","Array","isArray","item","append","file","Blob","filename","name","onerror","error","onError","onload","onSuccess","open","withCredentials","headers","setRequestHeader","h","send","abort"],"sources":["C:/Users/Аришина)/source/repos/PromoCursed/node_modules/rc-upload/es/request.js"],"sourcesContent":["function getError(option, xhr) {\n var msg = \"cannot \".concat(option.method, \" \").concat(option.action, \" \").concat(xhr.status, \"'\");\n var err = new Error(msg);\n err.status = xhr.status;\n err.method = option.method;\n err.url = option.action;\n return err;\n}\nfunction getBody(xhr) {\n var text = xhr.responseText || xhr.response;\n if (!text) {\n return text;\n }\n try {\n return JSON.parse(text);\n } catch (e) {\n return text;\n }\n}\nexport default function upload(option) {\n // eslint-disable-next-line no-undef\n var xhr = new XMLHttpRequest();\n if (option.onProgress && xhr.upload) {\n xhr.upload.onprogress = function progress(e) {\n if (e.total > 0) {\n e.percent = e.loaded / e.total * 100;\n }\n option.onProgress(e);\n };\n }\n\n // eslint-disable-next-line no-undef\n var formData = new FormData();\n if (option.data) {\n Object.keys(option.data).forEach(function (key) {\n var value = option.data[key];\n // support key-value array data\n if (Array.isArray(value)) {\n value.forEach(function (item) {\n // { list: [ 11, 22 ] }\n // formData.append('list[]', 11);\n formData.append(\"\".concat(key, \"[]\"), item);\n });\n return;\n }\n formData.append(key, value);\n });\n }\n\n // eslint-disable-next-line no-undef\n if (option.file instanceof Blob) {\n formData.append(option.filename, option.file, option.file.name);\n } else {\n formData.append(option.filename, option.file);\n }\n xhr.onerror = function error(e) {\n option.onError(e);\n };\n xhr.onload = function onload() {\n // allow success when 2xx status\n // see https://github.com/react-component/upload/issues/34\n if (xhr.status < 200 || xhr.status >= 300) {\n return option.onError(getError(option, xhr), getBody(xhr));\n }\n return option.onSuccess(getBody(xhr), xhr);\n };\n xhr.open(option.method, option.action, true);\n\n // Has to be after `.open()`. See https://github.com/enyo/dropzone/issues/179\n if (option.withCredentials && 'withCredentials' in xhr) {\n xhr.withCredentials = true;\n }\n var headers = option.headers || {};\n\n // when set headers['X-Requested-With'] = null , can close default XHR header\n // see https://github.com/react-component/upload/issues/33\n if (headers['X-Requested-With'] !== null) {\n xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');\n }\n Object.keys(headers).forEach(function (h) {\n if (headers[h] !== null) {\n xhr.setRequestHeader(h, headers[h]);\n }\n });\n xhr.send(formData);\n return {\n abort: function abort() {\n xhr.abort();\n }\n };\n}"],"mappings":"AAAA,SAASA,QAAQA,CAACC,MAAM,EAAEC,GAAG,EAAE;EAC7B,IAAIC,GAAG,GAAG,SAAS,CAACC,MAAM,CAACH,MAAM,CAACI,MAAM,EAAE,GAAG,CAAC,CAACD,MAAM,CAACH,MAAM,CAACK,MAAM,EAAE,GAAG,CAAC,CAACF,MAAM,CAACF,GAAG,CAACK,MAAM,EAAE,GAAG,CAAC;EACjG,IAAIC,GAAG,GAAG,IAAIC,KAAK,CAACN,GAAG,CAAC;EACxBK,GAAG,CAACD,MAAM,GAAGL,GAAG,CAACK,MAAM;EACvBC,GAAG,CAACH,MAAM,GAAGJ,MAAM,CAACI,MAAM;EAC1BG,GAAG,CAACE,GAAG,GAAGT,MAAM,CAACK,MAAM;EACvB,OAAOE,GAAG;AACZ;AACA,SAASG,OAAOA,CAACT,GAAG,EAAE;EACpB,IAAIU,IAAI,GAAGV,GAAG,CAACW,YAAY,IAAIX,GAAG,CAACY,QAAQ;EAC3C,IAAI,CAACF,IAAI,EAAE;IACT,OAAOA,IAAI;EACb;EACA,IAAI;IACF,OAAOG,IAAI,CAACC,KAAK,CAACJ,IAAI,CAAC;EACzB,CAAC,CAAC,OAAOK,CAAC,EAAE;IACV,OAAOL,IAAI;EACb;AACF;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