import { __commonJS } from "./chunk-Y2F7D3TJ.js"; // ../../../../document/九亿商城/jy/jiuyi2/node_modules/tim-upload-plugin/index.js var require_tim_upload_plugin = __commonJS({ "../../../../document/九亿商城/jy/jiuyi2/node_modules/tim-upload-plugin/index.js"(exports, module) { !function(e, t) { "object" == typeof exports && "undefined" != typeof module ? module.exports = t() : "function" == typeof define && define.amd ? define(t) : (e = e || self).TIMUploadPlugin = t(); }(exports, function() { function e(e2, t2) { var o2 = Object.keys(e2); if (Object.getOwnPropertySymbols) { var n2 = Object.getOwnPropertySymbols(e2); t2 && (n2 = n2.filter(function(t3) { return Object.getOwnPropertyDescriptor(e2, t3).enumerable; })), o2.push.apply(o2, n2); } return o2; } function t(t2) { for (var o2 = 1; o2 < arguments.length; o2++) { var n2 = null != arguments[o2] ? arguments[o2] : {}; o2 % 2 ? e(Object(n2), true).forEach(function(e2) { s(t2, e2, n2[e2]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(t2, Object.getOwnPropertyDescriptors(n2)) : e(Object(n2)).forEach(function(e2) { Object.defineProperty(t2, e2, Object.getOwnPropertyDescriptor(n2, e2)); }); } return t2; } function o(e2) { return (o = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(e3) { return typeof e3; } : function(e3) { return e3 && "function" == typeof Symbol && e3.constructor === Symbol && e3 !== Symbol.prototype ? "symbol" : typeof e3; })(e2); } function n(e2, t2) { if (!(e2 instanceof t2)) throw new TypeError("Cannot call a class as a function"); } function r(e2, t2) { for (var o2 = 0; o2 < t2.length; o2++) { var n2 = t2[o2]; n2.enumerable = n2.enumerable || false, n2.configurable = true, "value" in n2 && (n2.writable = true), Object.defineProperty(e2, n2.key, n2); } } function a(e2, t2, o2) { return t2 && r(e2.prototype, t2), o2 && r(e2, o2), Object.defineProperty(e2, "prototype", { writable: false }), e2; } function s(e2, t2, o2) { return t2 in e2 ? Object.defineProperty(e2, t2, { value: o2, enumerable: true, configurable: true, writable: true }) : e2[t2] = o2, e2; } function i(e2, t2) { if (null == e2) return {}; var o2, n2, r2 = function(e3, t3) { if (null == e3) return {}; var o3, n3, r3 = {}, a3 = Object.keys(e3); for (n3 = 0; n3 < a3.length; n3++) o3 = a3[n3], t3.indexOf(o3) >= 0 || (r3[o3] = e3[o3]); return r3; }(e2, t2); if (Object.getOwnPropertySymbols) { var a2 = Object.getOwnPropertySymbols(e2); for (n2 = 0; n2 < a2.length; n2++) o2 = a2[n2], t2.indexOf(o2) >= 0 || Object.prototype.propertyIsEnumerable.call(e2, o2) && (r2[o2] = e2[o2]); } return r2; } var u = "undefined" != typeof global ? global : "undefined" != typeof self ? self : "undefined" != typeof window ? window : {}, l = "undefined" != typeof wx && "function" == typeof wx.getSystemInfoSync && Boolean(wx.getSystemInfoSync().fontSizeSetting), f = "undefined" != typeof qq && "function" == typeof qq.getSystemInfoSync && Boolean(qq.getSystemInfoSync().fontSizeSetting), c = "undefined" != typeof tt && "function" == typeof tt.getSystemInfoSync && Boolean(tt.getSystemInfoSync().fontSizeSetting), d = "undefined" != typeof swan && "function" == typeof swan.getSystemInfoSync && Boolean(swan.getSystemInfoSync().fontSizeSetting), p = "undefined" != typeof my && "function" == typeof my.getSystemInfoSync && Boolean(my.getSystemInfoSync().fontSizeSetting), y = "undefined" != typeof uni && "undefined" == typeof window && "function" == typeof uni.requireNativePlugin, h = y && "ios" === uni.getDeviceInfo().platform.toLocaleLowerCase(), g = (y && uni.getDeviceInfo().platform.toLocaleLowerCase(), l || f || c || d || p || y), m = void 0 !== u && (void 0 !== u.nativeModuleProxy || void 0 !== u.ReactNative), v = f ? qq : c ? tt : d ? swan : p ? my : l ? wx : y ? uni : {}, b = function(e2) { if ("object" !== o(e2) || null === e2) return false; var t2 = Object.getPrototypeOf(e2); if (null === t2) return true; for (var n2 = t2; null !== Object.getPrototypeOf(n2); ) n2 = Object.getPrototypeOf(n2); return t2 === n2; }; function w(e2) { if (null == e2) return true; if ("boolean" == typeof e2) return false; if ("number" == typeof e2) return 0 === e2; if ("string" == typeof e2) return 0 === e2.length; if ("function" == typeof e2) return 0 === e2.length; if (Array.isArray(e2)) return 0 === e2.length; if (e2 instanceof Error) return "" === e2.message; if (b(e2)) { for (var t2 in e2) if (Object.prototype.hasOwnProperty.call(e2, t2)) return false; return true; } return false; } var O = function() { function e2() { n(this, e2), this._n = "WebRequest"; } return a(e2, [{ key: "request", value: function(e3, o2) { var n2 = this, r2 = "".concat(this._n, ".request"), a2 = e3.downloadUrl || "", s2 = (e3.method || "PUT").toUpperCase(), i2 = e3.url; if (console.log("%c tim-upload-plugin %c", "background:#0abf5b; padding:1px; border-radius:3px; color: #fff", "background:transparent", "".concat(r2, " URL:").concat(i2)), e3.qs) { var u2 = function(e4) { var t2 = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : "&", o3 = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : "="; return w(e4) ? "" : b(e4) ? Object.keys(e4).map(function(n3) { var r3 = encodeURIComponent(n3) + o3; return Array.isArray(e4[n3]) ? e4[n3].map(function(e5) { return r3 + encodeURIComponent(e5); }).join(t2) : r3 + encodeURIComponent(e4[n3]); }).filter(Boolean).join(t2) : void 0; }(e3.qs); u2 && (i2 += "".concat(-1 === i2.indexOf("?") ? "?" : "&").concat(u2)); } var l2 = new XMLHttpRequest(); l2.open(s2, i2, true), l2.responseType = e3.dataType || "text"; var f2 = e3.headers || {}; if (e3.uploadByIP && (f2 = t(t({}, f2), {}, { host: e3.uploadIP })), !w(f2)) for (var c2 in f2) f2.hasOwnProperty(c2) && "content-length" !== c2.toLowerCase() && "user-agent" !== c2.toLowerCase() && "origin" !== c2.toLowerCase() && "host" !== c2.toLowerCase() && l2.setRequestHeader(c2, f2[c2]); return l2.onload = function() { if (200 === l2.status) o2(null, n2._xhrRes(l2, n2._xhrBody(l2, a2, e3.uploadByIP && e3.uploadIP), f2)); else { if (e3.uploadIP && -1 === e3.url.indexOf(e3.uploadIP)) return e3.url = function(e4, t3) { return e4.replace(/^http(s)?:\/\/(.*?)\//, "https://".concat(t3, "/")); }(e3.url, e3.uploadIP), e3.uploadByIP = true, n2.request(e3, o2); var t2 = { code: l2.status, message: JSON.stringify(l2.responseText) }; o2(t2, n2._xhrRes(l2, n2._xhrBody(l2, a2, e3.uploadByIP && e3.uploadIP), f2)); } }, l2.onerror = function(t2) { var r3 = n2._xhrBody(l2, a2, e3.uploadByIP && e3.uploadIP), s3 = { code: l2.status, message: JSON.stringify(l2.responseText) }; r3 || l2.statusText || 0 !== l2.status || (t2.message = "CORS blocked or network error"), o2(s3, n2._xhrRes(l2, r3)), s3 = null; }, e3.onProgress && l2.upload && (l2.upload.onprogress = function(t2) { var o3 = t2.total, n3 = t2.loaded, r3 = Math.floor(100 * n3 / o3); e3.onProgress({ total: o3, loaded: n3, percent: (r3 >= 100 ? 100 : r3) / 100 }); }), l2.send(e3.resources), l2; } }, { key: "_xhrRes", value: function(e3, t2) { var o2 = {}; return e3.getAllResponseHeaders().trim().split("\n").forEach(function(e4) { if (e4) { var t3 = e4.indexOf(":"), n2 = e4.substr(0, t3).trim().toLowerCase(), r2 = e4.substr(t3 + 1).trim(); o2[n2] = r2; } }), { statusCode: e3.status, statusMessage: e3.statusText, headers: o2, data: t2 }; } }, { key: "_xhrBody", value: function(e3, t2, o2) { return 200 === e3.status && t2 ? { location: t2, uploadIP: o2 } : { response: e3.responseText, uploadIP: o2 }; } }]), e2; }(), S = ["unknown", "image", "video", "audio", "log"], P = ["name"], I = function() { function e2() { n(this, e2); } return a(e2, [{ key: "request", value: function(e3, o2) { var n2 = this, r2 = e3.resources, a2 = void 0 === r2 ? "" : r2, s2 = e3.headers, u2 = void 0 === s2 ? {} : s2, l2 = e3.url, f2 = e3.downloadUrl, c2 = void 0 === f2 ? "" : f2, d2 = l2, y2 = null, g2 = c2.match(/^(https?:\/\/[^/]+\/)([^/]*\/?)(.*)$/), m2 = decodeURIComponent(g2[3]), b2 = m2.indexOf("?") > -1 ? m2.split("?")[0] : m2, w2 = { key: e3.fileKey ? e3.fileKey : b2, success_action_status: 200, "Content-Type": "" }, O2 = {}; if (h) { var I2 = l2.split("?sign="); if (I2.length > 1) { var C2 = I2[1]; d2 = "".concat(I2[0], "?sign=").concat(encodeURIComponent("".concat(C2))), O2.sign = decodeURIComponent(C2), O2.signature = decodeURIComponent(C2); } } var k = { url: d2, header: u2, name: "file", filePath: a2, formData: t(t({}, w2), O2), timeout: e3.timeout || 3e5 }; if (p) { var x = k; x.name; k = t(t({}, i(x, P)), {}, { fileName: "file", fileType: S[e3.fileType] }); } return (y2 = v.uploadFile(t(t({}, k), {}, { success: function(e4) { n2._handleResponse({ response: e4, downloadUrl: c2, callback: o2 }); }, fail: function(e4) { n2._handleResponse({ response: e4, downloadUrl: c2, callback: o2 }); } }))).onProgressUpdate && y2.onProgressUpdate(function(t2) { e3.onProgress && e3.onProgress({ total: t2.totalBytesExpectedToSend, loaded: t2.totalBytesSent, percent: Math.floor(t2.progress) / 100 }); }), y2; } }, { key: "_handleResponse", value: function(e3) { var o2 = e3.downloadUrl, n2 = e3.response, r2 = e3.callback, a2 = n2.header, s2 = {}; if (a2) for (var i2 in a2) a2.hasOwnProperty(i2) && (s2[i2.toLowerCase()] = a2[i2]); var u2 = +n2.statusCode; 200 === u2 ? r2(null, { statusCode: u2, headers: s2, data: t(t({}, n2.data), {}, { location: o2 }) }) : r2({ code: u2, message: JSON.stringify(n2.data) }, { statusCode: u2, headers: s2, data: void 0 }); } }]), e2; }(), C = function() { function e2() { n(this, e2); } return a(e2, [{ key: "request", value: function(e3, t2) { var o2 = this, n2 = e3.resources, r2 = void 0 === n2 ? "" : n2, a2 = e3.fileKey, s2 = void 0 === a2 ? "" : a2, i2 = e3.url, u2 = e3.downloadUrl, l2 = void 0 === u2 ? "" : u2, f2 = new FormData(); f2.append("key", s2), f2.append("success_action_status", 200), f2.append("file", { uri: r2, type: "application/octet-stream", name: "uploaded_file" }), fetch(i2, { method: "POST", headers: { "Content-Type": "multipart/form-data" }, body: f2 }).then(function(e4) { o2._handleResponse({ response: e4, downloadUrl: l2, callback: t2 }); }).catch(function(e4) { o2._handleResponse({ response: e4, downloadUrl: l2, callback: t2 }); }); } }, { key: "_handleResponse", value: function(e3) { var t2 = e3.downloadUrl, o2 = e3.response, n2 = e3.callback, r2 = o2.headers, a2 = o2.status, s2 = r2 && r2.map || {}; 200 === a2 ? n2(null, { statusCode: 200, headers: s2, data: { location: t2 } }) : n2({ code: a2, message: JSON.stringify(o2) }, { statusCode: a2, headers: s2, data: void 0 }); } }]), e2; }(); return function() { function e2() { n(this, e2), this.retry = 1, this.tryCount = 0, this.systemClockOffset = 0, this.httpRequest = g ? new I() : m ? new C() : new O(), console.log("TIMUploadPlugin.VERSION: ".concat("1.4.1")); } return a(e2, [{ key: "uploadFile", value: function(e3, t2) { var o2 = this; return this.httpRequest.request(e3, function(n2, r2) { n2 && o2.tryCount < o2.retry && o2.allowRetry(n2) ? (o2.tryCount++, o2.uploadFile(e3, t2)) : (o2.tryCount = 0, t2(n2, r2)); }); } }, { key: "allowRetry", value: function(e3) { var t2 = false, o2 = false; if (e3) { var n2 = e3.headers && (e3.headers.date || e3.headers.Date) || e3.error && e3.error.ServerTime; try { var r2 = e3.error && e3.error.Code, a2 = e3.error && e3.error.Message; ("RequestTimeTooSkewed" === r2 || "AccessDenied" === r2 && "Request has expired" === a2) && (o2 = true); } catch (u2) { } if (o2 && n2) { var s2 = Date.now(), i2 = Date.parse(n2); Math.abs(s2 + this.systemClockOffset - i2) >= 3e4 && (this.systemClockOffset = i2 - s2, t2 = true); } else 5 === Math.floor(e3.statusCode / 100) && (t2 = true); } return t2; } }], [{ key: "getVersion", value: function() { return "1.4.1"; } }]), e2; }(); }); } }); export default require_tim_upload_plugin(); //# sourceMappingURL=tim-upload-plugin.js.map