diff --git a/auto-listing-facebook-marketplace/auto-listing-facebook-marketplace/background.js b/auto-listing-facebook-marketplace/auto-listing-facebook-marketplace/background.js index f9be6f7..d6752f6 100644 --- a/auto-listing-facebook-marketplace/auto-listing-facebook-marketplace/background.js +++ b/auto-listing-facebook-marketplace/auto-listing-facebook-marketplace/background.js @@ -1 +1 @@ -function O(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}var E={exports:{}},_;function L(){return _||(_=1,function(s){var e=Object.prototype.hasOwnProperty,t="~";function a(){}Object.create&&(a.prototype=Object.create(null),new a().__proto__||(t=!1));function l(h,i,n){this.fn=h,this.context=i,this.once=n||!1}function u(h,i,n,r,y){if(typeof n!="function")throw new TypeError("The listener must be a function");var c=new l(n,r||h,y),m=t?t+i:i;return h._events[m]?h._events[m].fn?h._events[m]=[h._events[m],c]:h._events[m].push(c):(h._events[m]=c,h._eventsCount++),h}function f(h,i){--h._eventsCount===0?h._events=new a:delete h._events[i]}function d(){this._events=new a,this._eventsCount=0}d.prototype.eventNames=function(){var i=[],n,r;if(this._eventsCount===0)return i;for(r in n=this._events)e.call(n,r)&&i.push(t?r.slice(1):r);return Object.getOwnPropertySymbols?i.concat(Object.getOwnPropertySymbols(n)):i},d.prototype.listeners=function(i){var n=t?t+i:i,r=this._events[n];if(!r)return[];if(r.fn)return[r.fn];for(var y=0,c=r.length,m=new Array(c);yglobalThis.DOMException===void 0?new S(s):new DOMException(s),T=s=>{const e=s.reason===void 0?x("This operation was aborted."):s.reason;return e instanceof Error?e:x(e)};function q(s,e){const{milliseconds:t,fallback:a,message:l,customTimers:u={setTimeout,clearTimeout}}=e;let f,d;const i=new Promise((n,r)=>{if(typeof t!="number"||Math.sign(t)!==1)throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${t}\``);if(e.signal){const{signal:c}=e;c.aborted&&r(T(c)),d=()=>{r(T(c))},c.addEventListener("abort",d,{once:!0})}if(t===Number.POSITIVE_INFINITY){s.then(n,r);return}const y=new C;f=u.setTimeout.call(void 0,()=>{if(a){try{n(a())}catch(c){r(c)}return}typeof s.cancel=="function"&&s.cancel(),l===!1?n():l instanceof Error?r(l):(y.message=l??`Promise timed out after ${t} milliseconds`,r(y))},t),(async()=>{try{n(await s)}catch(c){r(c)}})()}).finally(()=>{i.clear(),d&&e.signal&&e.signal.removeEventListener("abort",d)});return i.clear=()=>{u.clearTimeout.call(void 0,f),f=void 0},i}function z(s,e,t){let a=0,l=s.length;for(;l>0;){const u=Math.trunc(l/2);let f=a+u;t(s[f],e)<=0?(a=++f,l-=u+1):l=u}return a}class ${#e=[];enqueue(e,t){t={priority:0,...t};const a={priority:t.priority,id:t.id,run:e};if(this.size===0||this.#e[this.size-1].priority>=t.priority){this.#e.push(a);return}const l=z(this.#e,a,(u,f)=>f.priority-u.priority);this.#e.splice(l,0,a)}setPriority(e,t){const a=this.#e.findIndex(u=>u.id===e);if(a===-1)throw new ReferenceError(`No promise function with the id "${e}" exists in the queue.`);const[l]=this.#e.splice(a,1);this.enqueue(l.run,{priority:t,id:e})}dequeue(){return this.#e.shift()?.run}filter(e){return this.#e.filter(t=>t.priority===e.priority).map(t=>t.run)}get size(){return this.#e.length}}class k extends A{#e;#o;#s=0;#d;#a;#m=0;#r;#u;#t;#v;#n=0;#c;#i;#y;#b=1n;timeout;constructor(e){if(super(),e={carryoverConcurrencyCount:!1,intervalCap:Number.POSITIVE_INFINITY,interval:0,concurrency:Number.POSITIVE_INFINITY,autoStart:!0,queueClass:$,...e},!(typeof e.intervalCap=="number"&&e.intervalCap>=1))throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${e.intervalCap?.toString()??""}\` (${typeof e.intervalCap})`);if(e.interval===void 0||!(Number.isFinite(e.interval)&&e.interval>=0))throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${e.interval?.toString()??""}\` (${typeof e.interval})`);this.#e=e.carryoverConcurrencyCount,this.#o=e.intervalCap===Number.POSITIVE_INFINITY||e.interval===0,this.#d=e.intervalCap,this.#a=e.interval,this.#t=new e.queueClass,this.#v=e.queueClass,this.concurrency=e.concurrency,this.timeout=e.timeout,this.#y=e.throwOnTimeout===!0,this.#i=e.autoStart===!1}get#g(){return this.#o||this.#s{this.#_()},t)),!0}return!1}#h(){if(this.#t.size===0)return this.#r&&clearInterval(this.#r),this.#r=void 0,this.emit("empty"),this.#n===0&&this.emit("idle"),!1;if(!this.#i){const e=!this.#x;if(this.#g&&this.#E){const t=this.#t.dequeue();return t?(this.emit("active"),t(),e&&this.#p(),!0):!1}}return!1}#p(){this.#o||this.#r!==void 0||(this.#r=setInterval(()=>{this.#w()},this.#a),this.#m=Date.now()+this.#a)}#w(){this.#s===0&&this.#n===0&&this.#r&&(clearInterval(this.#r),this.#r=void 0),this.#s=this.#e?this.#n:0,this.#l()}#l(){for(;this.#h(););}get concurrency(){return this.#c}set concurrency(e){if(!(typeof e=="number"&&e>=1))throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${e}\` (${typeof e})`);this.#c=e,this.#l()}async#T(e){return new Promise((t,a)=>{e.addEventListener("abort",()=>{a(e.reason)},{once:!0})})}setPriority(e,t){this.#t.setPriority(e,t)}async add(e,t={}){return t.id??=(this.#b++).toString(),t={timeout:this.timeout,throwOnTimeout:this.#y,...t},new Promise((a,l)=>{this.#t.enqueue(async()=>{this.#n++,this.#s++;try{t.signal?.throwIfAborted();let u=e({signal:t.signal});t.timeout&&(u=q(Promise.resolve(u),{milliseconds:t.timeout})),t.signal&&(u=Promise.race([u,this.#T(t.signal)]));const f=await u;a(f),this.emit("completed",f)}catch(u){if(u instanceof C&&!t.throwOnTimeout){a();return}l(u),this.emit("error",u)}finally{this.#I()}},t),this.emit("add"),this.#h()})}async addAll(e,t){return Promise.all(e.map(async a=>this.add(a,t)))}start(){return this.#i?(this.#i=!1,this.#l(),this):this}pause(){this.#i=!0}clear(){this.#t=new this.#v}async onEmpty(){this.#t.size!==0&&await this.#f("empty")}async onSizeLessThan(e){this.#t.sizethis.#t.size{const l=()=>{t&&!t()||(this.off(e,l),a())};this.on(e,l)})}get size(){return this.#t.size}sizeBy(e){return this.#t.filter(e).length}get pending(){return this.#n}get isPaused(){return this.#i}}let I=[];const D=new k({concurrency:1});chrome.runtime.onConnect.addListener(s=>{I.push(s),s.onDisconnect.addListener(()=>{I=I.filter(e=>e!==s)})});(()=>{const s=new EventSource("http://localhost:4000/api/v1/products/publist-stream");s.onmessage=e=>{const t=JSON.parse(e.data);console.log("New event:",t),D.add(()=>M(t))},s.onerror=e=>{console.error("EventSource failed:",e)}})();async function M(s){return new Promise(e=>{chrome.tabs.create({url:"https://www.facebook.com/marketplace/create/item",active:!0},t=>{if(!t?.id)return e();const a=t.id,l=f=>{f.sender?.tab?.id===a&&(f.postMessage({type:"publist-event",payload:s}),chrome.runtime.onConnect.removeListener(l))};chrome.runtime.onConnect.addListener(l);const u=f=>{f===a&&(chrome.tabs.onRemoved.removeListener(u),e())};chrome.tabs.onRemoved.addListener(u)})})}chrome.runtime.onMessage.addListener((s,e)=>{if(s.type==="close-tab"){const t=e.tab?.id;t&&chrome.tabs.remove(t)}}); +function O(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}var E={exports:{}},T;function L(){return T||(T=1,function(s){var e=Object.prototype.hasOwnProperty,t="~";function a(){}Object.create&&(a.prototype=Object.create(null),new a().__proto__||(t=!1));function c(u,i,r){this.fn=u,this.context=i,this.once=r||!1}function l(u,i,r,n,p){if(typeof r!="function")throw new TypeError("The listener must be a function");var f=new c(r,n||u,p),d=t?t+i:i;return u._events[d]?u._events[d].fn?u._events[d]=[u._events[d],f]:u._events[d].push(f):(u._events[d]=f,u._eventsCount++),u}function v(u,i){--u._eventsCount===0?u._events=new a:delete u._events[i]}function h(){this._events=new a,this._eventsCount=0}h.prototype.eventNames=function(){var i=[],r,n;if(this._eventsCount===0)return i;for(n in r=this._events)e.call(r,n)&&i.push(t?n.slice(1):n);return Object.getOwnPropertySymbols?i.concat(Object.getOwnPropertySymbols(r)):i},h.prototype.listeners=function(i){var r=t?t+i:i,n=this._events[r];if(!n)return[];if(n.fn)return[n.fn];for(var p=0,f=n.length,d=new Array(f);pglobalThis.DOMException===void 0?new S(s):new DOMException(s),x=s=>{const e=s.reason===void 0?_("This operation was aborted."):s.reason;return e instanceof Error?e:_(e)};function q(s,e){const{milliseconds:t,fallback:a,message:c,customTimers:l={setTimeout,clearTimeout}}=e;let v,h;const i=new Promise((r,n)=>{if(typeof t!="number"||Math.sign(t)!==1)throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${t}\``);if(e.signal){const{signal:f}=e;f.aborted&&n(x(f)),h=()=>{n(x(f))},f.addEventListener("abort",h,{once:!0})}if(t===Number.POSITIVE_INFINITY){s.then(r,n);return}const p=new C;v=l.setTimeout.call(void 0,()=>{if(a){try{r(a())}catch(f){n(f)}return}typeof s.cancel=="function"&&s.cancel(),c===!1?r():c instanceof Error?n(c):(p.message=c??`Promise timed out after ${t} milliseconds`,n(p))},t),(async()=>{try{r(await s)}catch(f){n(f)}})()}).finally(()=>{i.clear(),h&&e.signal&&e.signal.removeEventListener("abort",h)});return i.clear=()=>{l.clearTimeout.call(void 0,v),v=void 0},i}function z(s,e,t){let a=0,c=s.length;for(;c>0;){const l=Math.trunc(c/2);let v=a+l;t(s[v],e)<=0?(a=++v,c-=l+1):c=l}return a}class ${#e=[];enqueue(e,t){t={priority:0,...t};const a={priority:t.priority,id:t.id,run:e};if(this.size===0||this.#e[this.size-1].priority>=t.priority){this.#e.push(a);return}const c=z(this.#e,a,(l,v)=>v.priority-l.priority);this.#e.splice(c,0,a)}setPriority(e,t){const a=this.#e.findIndex(l=>l.id===e);if(a===-1)throw new ReferenceError(`No promise function with the id "${e}" exists in the queue.`);const[c]=this.#e.splice(a,1);this.enqueue(c.run,{priority:t,id:e})}dequeue(){return this.#e.shift()?.run}filter(e){return this.#e.filter(t=>t.priority===e.priority).map(t=>t.run)}get size(){return this.#e.length}}class k extends A{#e;#o;#s=0;#d;#a;#m=0;#r;#u;#t;#v;#n=0;#c;#i;#p;#b=1n;timeout;constructor(e){if(super(),e={carryoverConcurrencyCount:!1,intervalCap:Number.POSITIVE_INFINITY,interval:0,concurrency:Number.POSITIVE_INFINITY,autoStart:!0,queueClass:$,...e},!(typeof e.intervalCap=="number"&&e.intervalCap>=1))throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${e.intervalCap?.toString()??""}\` (${typeof e.intervalCap})`);if(e.interval===void 0||!(Number.isFinite(e.interval)&&e.interval>=0))throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${e.interval?.toString()??""}\` (${typeof e.interval})`);this.#e=e.carryoverConcurrencyCount,this.#o=e.intervalCap===Number.POSITIVE_INFINITY||e.interval===0,this.#d=e.intervalCap,this.#a=e.interval,this.#t=new e.queueClass,this.#v=e.queueClass,this.concurrency=e.concurrency,this.timeout=e.timeout,this.#p=e.throwOnTimeout===!0,this.#i=e.autoStart===!1}get#g(){return this.#o||this.#s{this.#T()},t)),!0}return!1}#l(){if(this.#t.size===0)return this.#r&&clearInterval(this.#r),this.#r=void 0,this.emit("empty"),this.#n===0&&this.emit("idle"),!1;if(!this.#i){const e=!this.#_;if(this.#g&&this.#E){const t=this.#t.dequeue();return t?(this.emit("active"),t(),e&&this.#y(),!0):!1}}return!1}#y(){this.#o||this.#r!==void 0||(this.#r=setInterval(()=>{this.#w()},this.#a),this.#m=Date.now()+this.#a)}#w(){this.#s===0&&this.#n===0&&this.#r&&(clearInterval(this.#r),this.#r=void 0),this.#s=this.#e?this.#n:0,this.#h()}#h(){for(;this.#l(););}get concurrency(){return this.#c}set concurrency(e){if(!(typeof e=="number"&&e>=1))throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${e}\` (${typeof e})`);this.#c=e,this.#h()}async#x(e){return new Promise((t,a)=>{e.addEventListener("abort",()=>{a(e.reason)},{once:!0})})}setPriority(e,t){this.#t.setPriority(e,t)}async add(e,t={}){return t.id??=(this.#b++).toString(),t={timeout:this.timeout,throwOnTimeout:this.#p,...t},new Promise((a,c)=>{this.#t.enqueue(async()=>{this.#n++,this.#s++;try{t.signal?.throwIfAborted();let l=e({signal:t.signal});t.timeout&&(l=q(Promise.resolve(l),{milliseconds:t.timeout})),t.signal&&(l=Promise.race([l,this.#x(t.signal)]));const v=await l;a(v),this.emit("completed",v)}catch(l){if(l instanceof C&&!t.throwOnTimeout){a();return}c(l),this.emit("error",l)}finally{this.#I()}},t),this.emit("add"),this.#l()})}async addAll(e,t){return Promise.all(e.map(async a=>this.add(a,t)))}start(){return this.#i?(this.#i=!1,this.#h(),this):this}pause(){this.#i=!0}clear(){this.#t=new this.#v}async onEmpty(){this.#t.size!==0&&await this.#f("empty")}async onSizeLessThan(e){this.#t.sizethis.#t.size{const c=()=>{t&&!t()||(this.off(e,c),a())};this.on(e,c)})}get size(){return this.#t.size}sizeBy(e){return this.#t.filter(e).length}get pending(){return this.#n}get isPaused(){return this.#i}}let I=[];const D=new k({concurrency:1});chrome.runtime.onConnect.addListener(s=>{I.push(s),s.onDisconnect.addListener(()=>{I=I.filter(e=>e!==s)})});(()=>{const s=new EventSource("http://localhost:4000/api/v1/products/publist-stream");s.onmessage=e=>{const t=JSON.parse(e.data);console.log("New event:",t),D.add(()=>F(t,3e4))},s.onerror=e=>{console.error("EventSource failed:",e)}})();async function F(s,e=5*60*1e3){return new Promise(t=>{chrome.tabs.create({url:"https://www.facebook.com/marketplace/create/item",active:!0},a=>{if(!a?.id)return t();const c=a.id;let l=!1;const v=()=>{l||(l=!0,chrome.runtime.onConnect.removeListener(h),chrome.tabs.onRemoved.removeListener(u),clearTimeout(i),t())},h=r=>{r.sender?.tab?.id===c&&(r.postMessage({type:"publist-event",payload:s}),chrome.runtime.onConnect.removeListener(h))};chrome.runtime.onConnect.addListener(h);const u=r=>{r===c&&v()};chrome.tabs.onRemoved.addListener(u);const i=setTimeout(()=>{console.warn(`Tab ${c} timeout (${e}ms) - auto resolve`),c&&chrome.tabs.remove(c),v()},e)})})}chrome.runtime.onMessage.addListener((s,e)=>{if(s.type==="close-tab"){const t=e.tab?.id;t&&chrome.tabs.remove(t)}}); diff --git a/auto-listing-facebook-marketplace/auto-listing-facebook-marketplace/content.js b/auto-listing-facebook-marketplace/auto-listing-facebook-marketplace/content.js index 270be5c..25d18f9 100644 --- a/auto-listing-facebook-marketplace/auto-listing-facebook-marketplace/content.js +++ b/auto-listing-facebook-marketplace/auto-listing-facebook-marketplace/content.js @@ -1,6 +1,6 @@ -function S(e){return new Promise(t=>setTimeout(t,e))}function Ne(e,t){return function(){return e.apply(t,arguments)}}const{toString:nt}=Object.prototype,{getPrototypeOf:fe}=Object,{iterator:G,toStringTag:Le}=Symbol,Z=(e=>t=>{const n=nt.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),_=e=>(e=e.toLowerCase(),t=>Z(t)===e),Q=e=>t=>typeof t===e,{isArray:j}=Array,M=Q("undefined");function rt(e){return e!==null&&!M(e)&&e.constructor!==null&&!M(e.constructor)&&x(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const Be=_("ArrayBuffer");function it(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&Be(e.buffer),t}const st=Q("string"),x=Q("function"),Fe=Q("number"),Y=e=>e!==null&&typeof e=="object",ot=e=>e===!0||e===!1,J=e=>{if(Z(e)!=="object")return!1;const t=fe(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Le in e)&&!(G in e)},at=_("Date"),ct=_("File"),lt=_("Blob"),dt=_("FileList"),ut=e=>Y(e)&&x(e.pipe),ft=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||x(e.append)&&((t=Z(e))==="formdata"||t==="object"&&x(e.toString)&&e.toString()==="[object FormData]"))},pt=_("URLSearchParams"),[ht,mt,vt,wt]=["ReadableStream","Request","Response","Headers"].map(_),yt=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function H(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let r,i;if(typeof e!="object"&&(e=[e]),j(e))for(r=0,i=e.length;r0;)if(i=n[r],t===i.toLowerCase())return i;return null}const k=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,Ue=e=>!M(e)&&e!==k;function oe(){const{caseless:e}=Ue(this)&&this||{},t={},n=(r,i)=>{const s=e&&ke(t,i)||i;J(t[s])&&J(r)?t[s]=oe(t[s],r):J(r)?t[s]=oe({},r):j(r)?t[s]=r.slice():t[s]=r};for(let r=0,i=arguments.length;r(H(t,(i,s)=>{n&&x(i)?e[s]=Ne(i,n):e[s]=i},{allOwnKeys:r}),e),Et=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),gt=(e,t,n,r)=>{e.prototype=Object.create(t.prototype,r),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),n&&Object.assign(e.prototype,n)},Rt=(e,t,n,r)=>{let i,s,o;const c={};if(t=t||{},e==null)return t;do{for(i=Object.getOwnPropertyNames(e),s=i.length;s-- >0;)o=i[s],(!r||r(o,e,t))&&!c[o]&&(t[o]=e[o],c[o]=!0);e=n!==!1&&fe(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},St=(e,t,n)=>{e=String(e),(n===void 0||n>e.length)&&(n=e.length),n-=t.length;const r=e.indexOf(t,n);return r!==-1&&r===n},Tt=e=>{if(!e)return null;if(j(e))return e;let t=e.length;if(!Fe(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},Ot=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&fe(Uint8Array)),At=(e,t)=>{const r=(e&&e[G]).call(e);let i;for(;(i=r.next())&&!i.done;){const s=i.value;t.call(e,s[0],s[1])}},xt=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},Ct=_("HTMLFormElement"),Pt=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,i){return r.toUpperCase()+i}),ve=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),_t=_("RegExp"),De=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};H(n,(i,s)=>{let o;(o=t(i,s,e))!==!1&&(r[s]=o||i)}),Object.defineProperties(e,r)},Nt=e=>{De(e,(t,n)=>{if(x(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=e[n];if(x(r)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")})}})},Lt=(e,t)=>{const n={},r=i=>{i.forEach(s=>{n[s]=!0})};return j(e)?r(e):r(String(e).split(t)),n},Bt=()=>{},Ft=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function kt(e){return!!(e&&x(e.append)&&e[Le]==="FormData"&&e[G])}const Ut=e=>{const t=new Array(10),n=(r,i)=>{if(Y(r)){if(t.indexOf(r)>=0)return;if(!("toJSON"in r)){t[i]=r;const s=j(r)?[]:{};return H(r,(o,c)=>{const u=n(o,i+1);!M(u)&&(s[c]=u)}),t[i]=void 0,s}}return r};return n(e,0)},Dt=_("AsyncFunction"),jt=e=>e&&(Y(e)||x(e))&&x(e.then)&&x(e.catch),je=((e,t)=>e?setImmediate:t?((n,r)=>(k.addEventListener("message",({source:i,data:s})=>{i===k&&s===n&&r.length&&r.shift()()},!1),i=>{r.push(i),k.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",x(k.postMessage)),It=typeof queueMicrotask<"u"?queueMicrotask.bind(k):typeof process<"u"&&process.nextTick||je,qt=e=>e!=null&&x(e[G]),a={isArray:j,isArrayBuffer:Be,isBuffer:rt,isFormData:ft,isArrayBufferView:it,isString:st,isNumber:Fe,isBoolean:ot,isObject:Y,isPlainObject:J,isReadableStream:ht,isRequest:mt,isResponse:vt,isHeaders:wt,isUndefined:M,isDate:at,isFile:ct,isBlob:lt,isRegExp:_t,isFunction:x,isStream:ut,isURLSearchParams:pt,isTypedArray:Ot,isFileList:dt,forEach:H,merge:oe,extend:bt,trim:yt,stripBOM:Et,inherits:gt,toFlatObject:Rt,kindOf:Z,kindOfTest:_,endsWith:St,toArray:Tt,forEachEntry:At,matchAll:xt,isHTMLForm:Ct,hasOwnProperty:ve,hasOwnProp:ve,reduceDescriptors:De,freezeMethods:Nt,toObjectSet:Lt,toCamelCase:Pt,noop:Bt,toFiniteNumber:Ft,findKey:ke,global:k,isContextDefined:Ue,isSpecCompliantForm:kt,toJSONObject:Ut,isAsyncFn:Dt,isThenable:jt,setImmediate:je,asap:It,isIterable:qt};function m(e,t,n,r,i){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),i&&(this.response=i,this.status=i.status?i.status:null)}a.inherits(m,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:a.toJSONObject(this.config),code:this.code,status:this.status}}});const Ie=m.prototype,qe={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(e=>{qe[e]={value:e}});Object.defineProperties(m,qe);Object.defineProperty(Ie,"isAxiosError",{value:!0});m.from=(e,t,n,r,i,s)=>{const o=Object.create(Ie);return a.toFlatObject(e,o,function(u){return u!==Error.prototype},c=>c!=="isAxiosError"),m.call(o,e.message,t,n,r,i),o.cause=e,o.name=e.name,s&&Object.assign(o,s),o};const Mt=null;function ae(e){return a.isPlainObject(e)||a.isArray(e)}function Me(e){return a.endsWith(e,"[]")?e.slice(0,-2):e}function we(e,t,n){return e?e.concat(t).map(function(i,s){return i=Me(i),!n&&s?"["+i+"]":i}).join(n?".":""):t}function Ht(e){return a.isArray(e)&&!e.some(ae)}const $t=a.toFlatObject(a,{},null,function(t){return/^is[A-Z]/.test(t)});function ee(e,t,n){if(!a.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,n=a.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(v,h){return!a.isUndefined(h[v])});const r=n.metaTokens,i=n.visitor||d,s=n.dots,o=n.indexes,u=(n.Blob||typeof Blob<"u"&&Blob)&&a.isSpecCompliantForm(t);if(!a.isFunction(i))throw new TypeError("visitor must be a function");function l(f){if(f===null)return"";if(a.isDate(f))return f.toISOString();if(a.isBoolean(f))return f.toString();if(!u&&a.isBlob(f))throw new m("Blob is not supported. Use a Buffer instead.");return a.isArrayBuffer(f)||a.isTypedArray(f)?u&&typeof Blob=="function"?new Blob([f]):Buffer.from(f):f}function d(f,v,h){let b=f;if(f&&!h&&typeof f=="object"){if(a.endsWith(v,"{}"))v=r?v:v.slice(0,-2),f=JSON.stringify(f);else if(a.isArray(f)&&Ht(f)||(a.isFileList(f)||a.endsWith(v,"[]"))&&(b=a.toArray(f)))return v=Me(v),b.forEach(function(T,L){!(a.isUndefined(T)||T===null)&&t.append(o===!0?we([v],L,s):o===null?v:v+"[]",l(T))}),!1}return ae(f)?!0:(t.append(we(h,v,s),l(f)),!1)}const p=[],w=Object.assign($t,{defaultVisitor:d,convertValue:l,isVisitable:ae});function g(f,v){if(!a.isUndefined(f)){if(p.indexOf(f)!==-1)throw Error("Circular reference detected in "+v.join("."));p.push(f),a.forEach(f,function(b,R){(!(a.isUndefined(b)||b===null)&&i.call(t,b,a.isString(R)?R.trim():R,v,w))===!0&&g(b,v?v.concat(R):[R])}),p.pop()}}if(!a.isObject(e))throw new TypeError("data must be an object");return g(e),t}function ye(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function pe(e,t){this._pairs=[],e&&ee(e,this,t)}const He=pe.prototype;He.append=function(t,n){this._pairs.push([t,n])};He.toString=function(t){const n=t?function(r){return t.call(this,r,ye)}:ye;return this._pairs.map(function(i){return n(i[0])+"="+n(i[1])},"").join("&")};function zt(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function $e(e,t,n){if(!t)return e;const r=n&&n.encode||zt;a.isFunction(n)&&(n={serialize:n});const i=n&&n.serialize;let s;if(i?s=i(t,n):s=a.isURLSearchParams(t)?t.toString():new pe(t,n).toString(r),s){const o=e.indexOf("#");o!==-1&&(e=e.slice(0,o)),e+=(e.indexOf("?")===-1?"?":"&")+s}return e}class be{constructor(){this.handlers=[]}use(t,n,r){return this.handlers.push({fulfilled:t,rejected:n,synchronous:r?r.synchronous:!1,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){a.forEach(this.handlers,function(r){r!==null&&t(r)})}}const ze={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},Jt=typeof URLSearchParams<"u"?URLSearchParams:pe,Vt=typeof FormData<"u"?FormData:null,Kt=typeof Blob<"u"?Blob:null,Wt={isBrowser:!0,classes:{URLSearchParams:Jt,FormData:Vt,Blob:Kt},protocols:["http","https","file","blob","url","data"]},he=typeof window<"u"&&typeof document<"u",ce=typeof navigator=="object"&&navigator||void 0,Xt=he&&(!ce||["ReactNative","NativeScript","NS"].indexOf(ce.product)<0),Gt=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",Zt=he&&window.location.href||"http://localhost",Qt=Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:he,hasStandardBrowserEnv:Xt,hasStandardBrowserWebWorkerEnv:Gt,navigator:ce,origin:Zt},Symbol.toStringTag,{value:"Module"})),O={...Qt,...Wt};function Yt(e,t){return ee(e,new O.classes.URLSearchParams,Object.assign({visitor:function(n,r,i,s){return O.isNode&&a.isBuffer(n)?(this.append(r,n.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)}},t))}function en(e){return a.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function tn(e){const t={},n=Object.keys(e);let r;const i=n.length;let s;for(r=0;r=n.length;return o=!o&&a.isArray(i)?i.length:o,u?(a.hasOwnProp(i,o)?i[o]=[i[o],r]:i[o]=r,!c):((!i[o]||!a.isObject(i[o]))&&(i[o]=[]),t(n,r,i[o],s)&&a.isArray(i[o])&&(i[o]=tn(i[o])),!c)}if(a.isFormData(e)&&a.isFunction(e.entries)){const n={};return a.forEachEntry(e,(r,i)=>{t(en(r),i,n,0)}),n}return null}function nn(e,t,n){if(a.isString(e))try{return(t||JSON.parse)(e),a.trim(e)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(e)}const $={transitional:ze,adapter:["xhr","http","fetch"],transformRequest:[function(t,n){const r=n.getContentType()||"",i=r.indexOf("application/json")>-1,s=a.isObject(t);if(s&&a.isHTMLForm(t)&&(t=new FormData(t)),a.isFormData(t))return i?JSON.stringify(Je(t)):t;if(a.isArrayBuffer(t)||a.isBuffer(t)||a.isStream(t)||a.isFile(t)||a.isBlob(t)||a.isReadableStream(t))return t;if(a.isArrayBufferView(t))return t.buffer;if(a.isURLSearchParams(t))return n.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let c;if(s){if(r.indexOf("application/x-www-form-urlencoded")>-1)return Yt(t,this.formSerializer).toString();if((c=a.isFileList(t))||r.indexOf("multipart/form-data")>-1){const u=this.env&&this.env.FormData;return ee(c?{"files[]":t}:t,u&&new u,this.formSerializer)}}return s||i?(n.setContentType("application/json",!1),nn(t)):t}],transformResponse:[function(t){const n=this.transitional||$.transitional,r=n&&n.forcedJSONParsing,i=this.responseType==="json";if(a.isResponse(t)||a.isReadableStream(t))return t;if(t&&a.isString(t)&&(r&&!this.responseType||i)){const o=!(n&&n.silentJSONParsing)&&i;try{return JSON.parse(t)}catch(c){if(o)throw c.name==="SyntaxError"?m.from(c,m.ERR_BAD_RESPONSE,this,null,this.response):c}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:O.classes.FormData,Blob:O.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};a.forEach(["delete","get","head","post","put","patch"],e=>{$.headers[e]={}});const rn=a.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),sn=e=>{const t={};let n,r,i;return e&&e.split(` -`).forEach(function(o){i=o.indexOf(":"),n=o.substring(0,i).trim().toLowerCase(),r=o.substring(i+1).trim(),!(!n||t[n]&&rn[n])&&(n==="set-cookie"?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)}),t},Ee=Symbol("internals");function q(e){return e&&String(e).trim().toLowerCase()}function V(e){return e===!1||e==null?e:a.isArray(e)?e.map(V):String(e)}function on(e){const t=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let r;for(;r=n.exec(e);)t[r[1]]=r[2];return t}const an=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function re(e,t,n,r,i){if(a.isFunction(r))return r.call(this,t,n);if(i&&(t=n),!!a.isString(t)){if(a.isString(r))return t.indexOf(r)!==-1;if(a.isRegExp(r))return r.test(t)}}function cn(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,n,r)=>n.toUpperCase()+r)}function ln(e,t){const n=a.toCamelCase(" "+t);["get","set","has"].forEach(r=>{Object.defineProperty(e,r+n,{value:function(i,s,o){return this[r].call(this,t,i,s,o)},configurable:!0})})}let C=class{constructor(t){t&&this.set(t)}set(t,n,r){const i=this;function s(c,u,l){const d=q(u);if(!d)throw new Error("header name must be a non-empty string");const p=a.findKey(i,d);(!p||i[p]===void 0||l===!0||l===void 0&&i[p]!==!1)&&(i[p||u]=V(c))}const o=(c,u)=>a.forEach(c,(l,d)=>s(l,d,u));if(a.isPlainObject(t)||t instanceof this.constructor)o(t,n);else if(a.isString(t)&&(t=t.trim())&&!an(t))o(sn(t),n);else if(a.isObject(t)&&a.isIterable(t)){let c={},u,l;for(const d of t){if(!a.isArray(d))throw TypeError("Object iterator must return a key-value pair");c[l=d[0]]=(u=c[l])?a.isArray(u)?[...u,d[1]]:[u,d[1]]:d[1]}o(c,n)}else t!=null&&s(n,t,r);return this}get(t,n){if(t=q(t),t){const r=a.findKey(this,t);if(r){const i=this[r];if(!n)return i;if(n===!0)return on(i);if(a.isFunction(n))return n.call(this,i,r);if(a.isRegExp(n))return n.exec(i);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,n){if(t=q(t),t){const r=a.findKey(this,t);return!!(r&&this[r]!==void 0&&(!n||re(this,this[r],r,n)))}return!1}delete(t,n){const r=this;let i=!1;function s(o){if(o=q(o),o){const c=a.findKey(r,o);c&&(!n||re(r,r[c],c,n))&&(delete r[c],i=!0)}}return a.isArray(t)?t.forEach(s):s(t),i}clear(t){const n=Object.keys(this);let r=n.length,i=!1;for(;r--;){const s=n[r];(!t||re(this,this[s],s,t,!0))&&(delete this[s],i=!0)}return i}normalize(t){const n=this,r={};return a.forEach(this,(i,s)=>{const o=a.findKey(r,s);if(o){n[o]=V(i),delete n[s];return}const c=t?cn(s):String(s).trim();c!==s&&delete n[s],n[c]=V(i),r[c]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const n=Object.create(null);return a.forEach(this,(r,i)=>{r!=null&&r!==!1&&(n[i]=t&&a.isArray(r)?r.join(", "):r)}),n}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,n])=>t+": "+n).join(` -`)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...n){const r=new this(t);return n.forEach(i=>r.set(i)),r}static accessor(t){const r=(this[Ee]=this[Ee]={accessors:{}}).accessors,i=this.prototype;function s(o){const c=q(o);r[c]||(ln(i,o),r[c]=!0)}return a.isArray(t)?t.forEach(s):s(t),this}};C.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);a.reduceDescriptors(C.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(r){this[n]=r}}});a.freezeMethods(C);function ie(e,t){const n=this||$,r=t||n,i=C.from(r.headers);let s=r.data;return a.forEach(e,function(c){s=c.call(n,s,i.normalize(),t?t.status:void 0)}),i.normalize(),s}function Ve(e){return!!(e&&e.__CANCEL__)}function I(e,t,n){m.call(this,e??"canceled",m.ERR_CANCELED,t,n),this.name="CanceledError"}a.inherits(I,m,{__CANCEL__:!0});function Ke(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new m("Request failed with status code "+n.status,[m.ERR_BAD_REQUEST,m.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function dn(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function un(e,t){e=e||10;const n=new Array(e),r=new Array(e);let i=0,s=0,o;return t=t!==void 0?t:1e3,function(u){const l=Date.now(),d=r[s];o||(o=l),n[i]=u,r[i]=l;let p=s,w=0;for(;p!==i;)w+=n[p++],p=p%e;if(i=(i+1)%e,i===s&&(s=(s+1)%e),l-o{n=d,i=null,s&&(clearTimeout(s),s=null),e.apply(null,l)};return[(...l)=>{const d=Date.now(),p=d-n;p>=r?o(l,d):(i=l,s||(s=setTimeout(()=>{s=null,o(i)},r-p)))},()=>i&&o(i)]}const W=(e,t,n=3)=>{let r=0;const i=un(50,250);return fn(s=>{const o=s.loaded,c=s.lengthComputable?s.total:void 0,u=o-r,l=i(u),d=o<=c;r=o;const p={loaded:o,total:c,progress:c?o/c:void 0,bytes:u,rate:l||void 0,estimated:l&&c&&d?(c-o)/l:void 0,event:s,lengthComputable:c!=null,[t?"download":"upload"]:!0};e(p)},n)},ge=(e,t)=>{const n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},Re=e=>(...t)=>a.asap(()=>e(...t)),pn=O.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,O.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(O.origin),O.navigator&&/(msie|trident)/i.test(O.navigator.userAgent)):()=>!0,hn=O.hasStandardBrowserEnv?{write(e,t,n,r,i,s){const o=[e+"="+encodeURIComponent(t)];a.isNumber(n)&&o.push("expires="+new Date(n).toGMTString()),a.isString(r)&&o.push("path="+r),a.isString(i)&&o.push("domain="+i),s===!0&&o.push("secure"),document.cookie=o.join("; ")},read(e){const t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(e){this.write(e,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function mn(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function vn(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function We(e,t,n){let r=!mn(t);return e&&(r||n==!1)?vn(e,t):t}const Se=e=>e instanceof C?{...e}:e;function D(e,t){t=t||{};const n={};function r(l,d,p,w){return a.isPlainObject(l)&&a.isPlainObject(d)?a.merge.call({caseless:w},l,d):a.isPlainObject(d)?a.merge({},d):a.isArray(d)?d.slice():d}function i(l,d,p,w){if(a.isUndefined(d)){if(!a.isUndefined(l))return r(void 0,l,p,w)}else return r(l,d,p,w)}function s(l,d){if(!a.isUndefined(d))return r(void 0,d)}function o(l,d){if(a.isUndefined(d)){if(!a.isUndefined(l))return r(void 0,l)}else return r(void 0,d)}function c(l,d,p){if(p in t)return r(l,d);if(p in e)return r(void 0,l)}const u={url:s,method:s,data:s,baseURL:o,transformRequest:o,transformResponse:o,paramsSerializer:o,timeout:o,timeoutMessage:o,withCredentials:o,withXSRFToken:o,adapter:o,responseType:o,xsrfCookieName:o,xsrfHeaderName:o,onUploadProgress:o,onDownloadProgress:o,decompress:o,maxContentLength:o,maxBodyLength:o,beforeRedirect:o,transport:o,httpAgent:o,httpsAgent:o,cancelToken:o,socketPath:o,responseEncoding:o,validateStatus:c,headers:(l,d,p)=>i(Se(l),Se(d),p,!0)};return a.forEach(Object.keys(Object.assign({},e,t)),function(d){const p=u[d]||i,w=p(e[d],t[d],d);a.isUndefined(w)&&p!==c||(n[d]=w)}),n}const Xe=e=>{const t=D({},e);let{data:n,withXSRFToken:r,xsrfHeaderName:i,xsrfCookieName:s,headers:o,auth:c}=t;t.headers=o=C.from(o),t.url=$e(We(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),c&&o.set("Authorization","Basic "+btoa((c.username||"")+":"+(c.password?unescape(encodeURIComponent(c.password)):"")));let u;if(a.isFormData(n)){if(O.hasStandardBrowserEnv||O.hasStandardBrowserWebWorkerEnv)o.setContentType(void 0);else if((u=o.getContentType())!==!1){const[l,...d]=u?u.split(";").map(p=>p.trim()).filter(Boolean):[];o.setContentType([l||"multipart/form-data",...d].join("; "))}}if(O.hasStandardBrowserEnv&&(r&&a.isFunction(r)&&(r=r(t)),r||r!==!1&&pn(t.url))){const l=i&&s&&hn.read(s);l&&o.set(i,l)}return t},wn=typeof XMLHttpRequest<"u",yn=wn&&function(e){return new Promise(function(n,r){const i=Xe(e);let s=i.data;const o=C.from(i.headers).normalize();let{responseType:c,onUploadProgress:u,onDownloadProgress:l}=i,d,p,w,g,f;function v(){g&&g(),f&&f(),i.cancelToken&&i.cancelToken.unsubscribe(d),i.signal&&i.signal.removeEventListener("abort",d)}let h=new XMLHttpRequest;h.open(i.method.toUpperCase(),i.url,!0),h.timeout=i.timeout;function b(){if(!h)return;const T=C.from("getAllResponseHeaders"in h&&h.getAllResponseHeaders()),A={data:!c||c==="text"||c==="json"?h.responseText:h.response,status:h.status,statusText:h.statusText,headers:T,config:e,request:h};Ke(function(F){n(F),v()},function(F){r(F),v()},A),h=null}"onloadend"in h?h.onloadend=b:h.onreadystatechange=function(){!h||h.readyState!==4||h.status===0&&!(h.responseURL&&h.responseURL.indexOf("file:")===0)||setTimeout(b)},h.onabort=function(){h&&(r(new m("Request aborted",m.ECONNABORTED,e,h)),h=null)},h.onerror=function(){r(new m("Network Error",m.ERR_NETWORK,e,h)),h=null},h.ontimeout=function(){let L=i.timeout?"timeout of "+i.timeout+"ms exceeded":"timeout exceeded";const A=i.transitional||ze;i.timeoutErrorMessage&&(L=i.timeoutErrorMessage),r(new m(L,A.clarifyTimeoutError?m.ETIMEDOUT:m.ECONNABORTED,e,h)),h=null},s===void 0&&o.setContentType(null),"setRequestHeader"in h&&a.forEach(o.toJSON(),function(L,A){h.setRequestHeader(A,L)}),a.isUndefined(i.withCredentials)||(h.withCredentials=!!i.withCredentials),c&&c!=="json"&&(h.responseType=i.responseType),l&&([w,f]=W(l,!0),h.addEventListener("progress",w)),u&&h.upload&&([p,g]=W(u),h.upload.addEventListener("progress",p),h.upload.addEventListener("loadend",g)),(i.cancelToken||i.signal)&&(d=T=>{h&&(r(!T||T.type?new I(null,e,h):T),h.abort(),h=null)},i.cancelToken&&i.cancelToken.subscribe(d),i.signal&&(i.signal.aborted?d():i.signal.addEventListener("abort",d)));const R=dn(i.url);if(R&&O.protocols.indexOf(R)===-1){r(new m("Unsupported protocol "+R+":",m.ERR_BAD_REQUEST,e));return}h.send(s||null)})},bn=(e,t)=>{const{length:n}=e=e?e.filter(Boolean):[];if(t||n){let r=new AbortController,i;const s=function(l){if(!i){i=!0,c();const d=l instanceof Error?l:this.reason;r.abort(d instanceof m?d:new I(d instanceof Error?d.message:d))}};let o=t&&setTimeout(()=>{o=null,s(new m(`timeout ${t} of ms exceeded`,m.ETIMEDOUT))},t);const c=()=>{e&&(o&&clearTimeout(o),o=null,e.forEach(l=>{l.unsubscribe?l.unsubscribe(s):l.removeEventListener("abort",s)}),e=null)};e.forEach(l=>l.addEventListener("abort",s));const{signal:u}=r;return u.unsubscribe=()=>a.asap(c),u}},En=function*(e,t){let n=e.byteLength;if(n{const i=gn(e,t);let s=0,o,c=u=>{o||(o=!0,r&&r(u))};return new ReadableStream({async pull(u){try{const{done:l,value:d}=await i.next();if(l){c(),u.close();return}let p=d.byteLength;if(n){let w=s+=p;n(w)}u.enqueue(new Uint8Array(d))}catch(l){throw c(l),l}},cancel(u){return c(u),i.return()}},{highWaterMark:2})},te=typeof fetch=="function"&&typeof Request=="function"&&typeof Response=="function",Ge=te&&typeof ReadableStream=="function",Sn=te&&(typeof TextEncoder=="function"?(e=>t=>e.encode(t))(new TextEncoder):async e=>new Uint8Array(await new Response(e).arrayBuffer())),Ze=(e,...t)=>{try{return!!e(...t)}catch{return!1}},Tn=Ge&&Ze(()=>{let e=!1;const t=new Request(O.origin,{body:new ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type");return e&&!t}),Oe=64*1024,le=Ge&&Ze(()=>a.isReadableStream(new Response("").body)),X={stream:le&&(e=>e.body)};te&&(e=>{["text","arrayBuffer","blob","formData","stream"].forEach(t=>{!X[t]&&(X[t]=a.isFunction(e[t])?n=>n[t]():(n,r)=>{throw new m(`Response type '${t}' is not supported`,m.ERR_NOT_SUPPORT,r)})})})(new Response);const On=async e=>{if(e==null)return 0;if(a.isBlob(e))return e.size;if(a.isSpecCompliantForm(e))return(await new Request(O.origin,{method:"POST",body:e}).arrayBuffer()).byteLength;if(a.isArrayBufferView(e)||a.isArrayBuffer(e))return e.byteLength;if(a.isURLSearchParams(e)&&(e=e+""),a.isString(e))return(await Sn(e)).byteLength},An=async(e,t)=>{const n=a.toFiniteNumber(e.getContentLength());return n??On(t)},xn=te&&(async e=>{let{url:t,method:n,data:r,signal:i,cancelToken:s,timeout:o,onDownloadProgress:c,onUploadProgress:u,responseType:l,headers:d,withCredentials:p="same-origin",fetchOptions:w}=Xe(e);l=l?(l+"").toLowerCase():"text";let g=bn([i,s&&s.toAbortSignal()],o),f;const v=g&&g.unsubscribe&&(()=>{g.unsubscribe()});let h;try{if(u&&Tn&&n!=="get"&&n!=="head"&&(h=await An(d,r))!==0){let A=new Request(t,{method:"POST",body:r,duplex:"half"}),B;if(a.isFormData(r)&&(B=A.headers.get("content-type"))&&d.setContentType(B),A.body){const[F,z]=ge(h,W(Re(u)));r=Te(A.body,Oe,F,z)}}a.isString(p)||(p=p?"include":"omit");const b="credentials"in Request.prototype;f=new Request(t,{...w,signal:g,method:n.toUpperCase(),headers:d.normalize().toJSON(),body:r,duplex:"half",credentials:b?p:void 0});let R=await fetch(f,w);const T=le&&(l==="stream"||l==="response");if(le&&(c||T&&v)){const A={};["status","statusText","headers"].forEach(me=>{A[me]=R[me]});const B=a.toFiniteNumber(R.headers.get("content-length")),[F,z]=c&&ge(B,W(Re(c),!0))||[];R=new Response(Te(R.body,Oe,F,()=>{z&&z(),v&&v()}),A)}l=l||"text";let L=await X[a.findKey(X,l)||"text"](R,e);return!T&&v&&v(),await new Promise((A,B)=>{Ke(A,B,{data:L,headers:C.from(R.headers),status:R.status,statusText:R.statusText,config:e,request:f})})}catch(b){throw v&&v(),b&&b.name==="TypeError"&&/Load failed|fetch/i.test(b.message)?Object.assign(new m("Network Error",m.ERR_NETWORK,e,f),{cause:b.cause||b}):m.from(b,b&&b.code,e,f)}}),de={http:Mt,xhr:yn,fetch:xn};a.forEach(de,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const Ae=e=>`- ${e}`,Cn=e=>a.isFunction(e)||e===null||e===!1,Qe={getAdapter:e=>{e=a.isArray(e)?e:[e];const{length:t}=e;let n,r;const i={};for(let s=0;s`adapter ${c} `+(u===!1?"is not supported by the environment":"is not available in the build"));let o=t?s.length>1?`since : +function S(e){return new Promise(t=>setTimeout(t,e))}function Ne(e,t){return function(){return e.apply(t,arguments)}}const{toString:nt}=Object.prototype,{getPrototypeOf:fe}=Object,{iterator:G,toStringTag:ke}=Symbol,Z=(e=>t=>{const n=nt.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),P=e=>(e=e.toLowerCase(),t=>Z(t)===e),Q=e=>t=>typeof t===e,{isArray:j}=Array,M=Q("undefined");function it(e){return e!==null&&!M(e)&&e.constructor!==null&&!M(e.constructor)&&x(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const Be=P("ArrayBuffer");function rt(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&Be(e.buffer),t}const st=Q("string"),x=Q("function"),Le=Q("number"),Y=e=>e!==null&&typeof e=="object",ot=e=>e===!0||e===!1,J=e=>{if(Z(e)!=="object")return!1;const t=fe(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(ke in e)&&!(G in e)},at=P("Date"),dt=P("File"),ct=P("Blob"),lt=P("FileList"),ut=e=>Y(e)&&x(e.pipe),ft=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||x(e.append)&&((t=Z(e))==="formdata"||t==="object"&&x(e.toString)&&e.toString()==="[object FormData]"))},pt=P("URLSearchParams"),[ht,vt,mt,wt]=["ReadableStream","Request","Response","Headers"].map(P),yt=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function H(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let i,r;if(typeof e!="object"&&(e=[e]),j(e))for(i=0,r=e.length;i0;)if(r=n[i],t===r.toLowerCase())return r;return null}const F=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,Ue=e=>!M(e)&&e!==F;function oe(){const{caseless:e}=Ue(this)&&this||{},t={},n=(i,r)=>{const s=e&&Fe(t,r)||r;J(t[s])&&J(i)?t[s]=oe(t[s],i):J(i)?t[s]=oe({},i):j(i)?t[s]=i.slice():t[s]=i};for(let i=0,r=arguments.length;i(H(t,(r,s)=>{n&&x(r)?e[s]=Ne(r,n):e[s]=r},{allOwnKeys:i}),e),Et=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),gt=(e,t,n,i)=>{e.prototype=Object.create(t.prototype,i),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),n&&Object.assign(e.prototype,n)},Rt=(e,t,n,i)=>{let r,s,o;const d={};if(t=t||{},e==null)return t;do{for(r=Object.getOwnPropertyNames(e),s=r.length;s-- >0;)o=r[s],(!i||i(o,e,t))&&!d[o]&&(t[o]=e[o],d[o]=!0);e=n!==!1&&fe(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},St=(e,t,n)=>{e=String(e),(n===void 0||n>e.length)&&(n=e.length),n-=t.length;const i=e.indexOf(t,n);return i!==-1&&i===n},Tt=e=>{if(!e)return null;if(j(e))return e;let t=e.length;if(!Le(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},Ot=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&fe(Uint8Array)),At=(e,t)=>{const i=(e&&e[G]).call(e);let r;for(;(r=i.next())&&!r.done;){const s=r.value;t.call(e,s[0],s[1])}},_t=(e,t)=>{let n;const i=[];for(;(n=e.exec(t))!==null;)i.push(n);return i},xt=P("HTMLFormElement"),Ct=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,i,r){return i.toUpperCase()+r}),me=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),Pt=P("RegExp"),De=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),i={};H(n,(r,s)=>{let o;(o=t(r,s,e))!==!1&&(i[s]=o||r)}),Object.defineProperties(e,i)},Nt=e=>{De(e,(t,n)=>{if(x(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const i=e[n];if(x(i)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")})}})},kt=(e,t)=>{const n={},i=r=>{r.forEach(s=>{n[s]=!0})};return j(e)?i(e):i(String(e).split(t)),n},Bt=()=>{},Lt=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function Ft(e){return!!(e&&x(e.append)&&e[ke]==="FormData"&&e[G])}const Ut=e=>{const t=new Array(10),n=(i,r)=>{if(Y(i)){if(t.indexOf(i)>=0)return;if(!("toJSON"in i)){t[r]=i;const s=j(i)?[]:{};return H(i,(o,d)=>{const u=n(o,r+1);!M(u)&&(s[d]=u)}),t[r]=void 0,s}}return i};return n(e,0)},Dt=P("AsyncFunction"),jt=e=>e&&(Y(e)||x(e))&&x(e.then)&&x(e.catch),je=((e,t)=>e?setImmediate:t?((n,i)=>(F.addEventListener("message",({source:r,data:s})=>{r===F&&s===n&&i.length&&i.shift()()},!1),r=>{i.push(r),F.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",x(F.postMessage)),It=typeof queueMicrotask<"u"?queueMicrotask.bind(F):typeof process<"u"&&process.nextTick||je,qt=e=>e!=null&&x(e[G]),a={isArray:j,isArrayBuffer:Be,isBuffer:it,isFormData:ft,isArrayBufferView:rt,isString:st,isNumber:Le,isBoolean:ot,isObject:Y,isPlainObject:J,isReadableStream:ht,isRequest:vt,isResponse:mt,isHeaders:wt,isUndefined:M,isDate:at,isFile:dt,isBlob:ct,isRegExp:Pt,isFunction:x,isStream:ut,isURLSearchParams:pt,isTypedArray:Ot,isFileList:lt,forEach:H,merge:oe,extend:bt,trim:yt,stripBOM:Et,inherits:gt,toFlatObject:Rt,kindOf:Z,kindOfTest:P,endsWith:St,toArray:Tt,forEachEntry:At,matchAll:_t,isHTMLForm:xt,hasOwnProperty:me,hasOwnProp:me,reduceDescriptors:De,freezeMethods:Nt,toObjectSet:kt,toCamelCase:Ct,noop:Bt,toFiniteNumber:Lt,findKey:Fe,global:F,isContextDefined:Ue,isSpecCompliantForm:Ft,toJSONObject:Ut,isAsyncFn:Dt,isThenable:jt,setImmediate:je,asap:It,isIterable:qt};function v(e,t,n,i,r){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),n&&(this.config=n),i&&(this.request=i),r&&(this.response=r,this.status=r.status?r.status:null)}a.inherits(v,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:a.toJSONObject(this.config),code:this.code,status:this.status}}});const Ie=v.prototype,qe={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(e=>{qe[e]={value:e}});Object.defineProperties(v,qe);Object.defineProperty(Ie,"isAxiosError",{value:!0});v.from=(e,t,n,i,r,s)=>{const o=Object.create(Ie);return a.toFlatObject(e,o,function(u){return u!==Error.prototype},d=>d!=="isAxiosError"),v.call(o,e.message,t,n,i,r),o.cause=e,o.name=e.name,s&&Object.assign(o,s),o};const Mt=null;function ae(e){return a.isPlainObject(e)||a.isArray(e)}function Me(e){return a.endsWith(e,"[]")?e.slice(0,-2):e}function we(e,t,n){return e?e.concat(t).map(function(r,s){return r=Me(r),!n&&s?"["+r+"]":r}).join(n?".":""):t}function Ht(e){return a.isArray(e)&&!e.some(ae)}const $t=a.toFlatObject(a,{},null,function(t){return/^is[A-Z]/.test(t)});function ee(e,t,n){if(!a.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,n=a.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(m,h){return!a.isUndefined(h[m])});const i=n.metaTokens,r=n.visitor||l,s=n.dots,o=n.indexes,u=(n.Blob||typeof Blob<"u"&&Blob)&&a.isSpecCompliantForm(t);if(!a.isFunction(r))throw new TypeError("visitor must be a function");function c(f){if(f===null)return"";if(a.isDate(f))return f.toISOString();if(a.isBoolean(f))return f.toString();if(!u&&a.isBlob(f))throw new v("Blob is not supported. Use a Buffer instead.");return a.isArrayBuffer(f)||a.isTypedArray(f)?u&&typeof Blob=="function"?new Blob([f]):Buffer.from(f):f}function l(f,m,h){let b=f;if(f&&!h&&typeof f=="object"){if(a.endsWith(m,"{}"))m=i?m:m.slice(0,-2),f=JSON.stringify(f);else if(a.isArray(f)&&Ht(f)||(a.isFileList(f)||a.endsWith(m,"[]"))&&(b=a.toArray(f)))return m=Me(m),b.forEach(function(T,k){!(a.isUndefined(T)||T===null)&&t.append(o===!0?we([m],k,s):o===null?m:m+"[]",c(T))}),!1}return ae(f)?!0:(t.append(we(h,m,s),c(f)),!1)}const p=[],w=Object.assign($t,{defaultVisitor:l,convertValue:c,isVisitable:ae});function g(f,m){if(!a.isUndefined(f)){if(p.indexOf(f)!==-1)throw Error("Circular reference detected in "+m.join("."));p.push(f),a.forEach(f,function(b,R){(!(a.isUndefined(b)||b===null)&&r.call(t,b,a.isString(R)?R.trim():R,m,w))===!0&&g(b,m?m.concat(R):[R])}),p.pop()}}if(!a.isObject(e))throw new TypeError("data must be an object");return g(e),t}function ye(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(i){return t[i]})}function pe(e,t){this._pairs=[],e&&ee(e,this,t)}const He=pe.prototype;He.append=function(t,n){this._pairs.push([t,n])};He.toString=function(t){const n=t?function(i){return t.call(this,i,ye)}:ye;return this._pairs.map(function(r){return n(r[0])+"="+n(r[1])},"").join("&")};function zt(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function $e(e,t,n){if(!t)return e;const i=n&&n.encode||zt;a.isFunction(n)&&(n={serialize:n});const r=n&&n.serialize;let s;if(r?s=r(t,n):s=a.isURLSearchParams(t)?t.toString():new pe(t,n).toString(i),s){const o=e.indexOf("#");o!==-1&&(e=e.slice(0,o)),e+=(e.indexOf("?")===-1?"?":"&")+s}return e}class be{constructor(){this.handlers=[]}use(t,n,i){return this.handlers.push({fulfilled:t,rejected:n,synchronous:i?i.synchronous:!1,runWhen:i?i.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){a.forEach(this.handlers,function(i){i!==null&&t(i)})}}const ze={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},Jt=typeof URLSearchParams<"u"?URLSearchParams:pe,Vt=typeof FormData<"u"?FormData:null,Kt=typeof Blob<"u"?Blob:null,Wt={isBrowser:!0,classes:{URLSearchParams:Jt,FormData:Vt,Blob:Kt},protocols:["http","https","file","blob","url","data"]},he=typeof window<"u"&&typeof document<"u",de=typeof navigator=="object"&&navigator||void 0,Xt=he&&(!de||["ReactNative","NativeScript","NS"].indexOf(de.product)<0),Gt=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",Zt=he&&window.location.href||"http://localhost",Qt=Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:he,hasStandardBrowserEnv:Xt,hasStandardBrowserWebWorkerEnv:Gt,navigator:de,origin:Zt},Symbol.toStringTag,{value:"Module"})),O={...Qt,...Wt};function Yt(e,t){return ee(e,new O.classes.URLSearchParams,Object.assign({visitor:function(n,i,r,s){return O.isNode&&a.isBuffer(n)?(this.append(i,n.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)}},t))}function en(e){return a.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function tn(e){const t={},n=Object.keys(e);let i;const r=n.length;let s;for(i=0;i=n.length;return o=!o&&a.isArray(r)?r.length:o,u?(a.hasOwnProp(r,o)?r[o]=[r[o],i]:r[o]=i,!d):((!r[o]||!a.isObject(r[o]))&&(r[o]=[]),t(n,i,r[o],s)&&a.isArray(r[o])&&(r[o]=tn(r[o])),!d)}if(a.isFormData(e)&&a.isFunction(e.entries)){const n={};return a.forEachEntry(e,(i,r)=>{t(en(i),r,n,0)}),n}return null}function nn(e,t,n){if(a.isString(e))try{return(t||JSON.parse)(e),a.trim(e)}catch(i){if(i.name!=="SyntaxError")throw i}return(n||JSON.stringify)(e)}const $={transitional:ze,adapter:["xhr","http","fetch"],transformRequest:[function(t,n){const i=n.getContentType()||"",r=i.indexOf("application/json")>-1,s=a.isObject(t);if(s&&a.isHTMLForm(t)&&(t=new FormData(t)),a.isFormData(t))return r?JSON.stringify(Je(t)):t;if(a.isArrayBuffer(t)||a.isBuffer(t)||a.isStream(t)||a.isFile(t)||a.isBlob(t)||a.isReadableStream(t))return t;if(a.isArrayBufferView(t))return t.buffer;if(a.isURLSearchParams(t))return n.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let d;if(s){if(i.indexOf("application/x-www-form-urlencoded")>-1)return Yt(t,this.formSerializer).toString();if((d=a.isFileList(t))||i.indexOf("multipart/form-data")>-1){const u=this.env&&this.env.FormData;return ee(d?{"files[]":t}:t,u&&new u,this.formSerializer)}}return s||r?(n.setContentType("application/json",!1),nn(t)):t}],transformResponse:[function(t){const n=this.transitional||$.transitional,i=n&&n.forcedJSONParsing,r=this.responseType==="json";if(a.isResponse(t)||a.isReadableStream(t))return t;if(t&&a.isString(t)&&(i&&!this.responseType||r)){const o=!(n&&n.silentJSONParsing)&&r;try{return JSON.parse(t)}catch(d){if(o)throw d.name==="SyntaxError"?v.from(d,v.ERR_BAD_RESPONSE,this,null,this.response):d}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:O.classes.FormData,Blob:O.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};a.forEach(["delete","get","head","post","put","patch"],e=>{$.headers[e]={}});const rn=a.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),sn=e=>{const t={};let n,i,r;return e&&e.split(` +`).forEach(function(o){r=o.indexOf(":"),n=o.substring(0,r).trim().toLowerCase(),i=o.substring(r+1).trim(),!(!n||t[n]&&rn[n])&&(n==="set-cookie"?t[n]?t[n].push(i):t[n]=[i]:t[n]=t[n]?t[n]+", "+i:i)}),t},Ee=Symbol("internals");function q(e){return e&&String(e).trim().toLowerCase()}function V(e){return e===!1||e==null?e:a.isArray(e)?e.map(V):String(e)}function on(e){const t=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let i;for(;i=n.exec(e);)t[i[1]]=i[2];return t}const an=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function ie(e,t,n,i,r){if(a.isFunction(i))return i.call(this,t,n);if(r&&(t=n),!!a.isString(t)){if(a.isString(i))return t.indexOf(i)!==-1;if(a.isRegExp(i))return i.test(t)}}function dn(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,n,i)=>n.toUpperCase()+i)}function cn(e,t){const n=a.toCamelCase(" "+t);["get","set","has"].forEach(i=>{Object.defineProperty(e,i+n,{value:function(r,s,o){return this[i].call(this,t,r,s,o)},configurable:!0})})}let C=class{constructor(t){t&&this.set(t)}set(t,n,i){const r=this;function s(d,u,c){const l=q(u);if(!l)throw new Error("header name must be a non-empty string");const p=a.findKey(r,l);(!p||r[p]===void 0||c===!0||c===void 0&&r[p]!==!1)&&(r[p||u]=V(d))}const o=(d,u)=>a.forEach(d,(c,l)=>s(c,l,u));if(a.isPlainObject(t)||t instanceof this.constructor)o(t,n);else if(a.isString(t)&&(t=t.trim())&&!an(t))o(sn(t),n);else if(a.isObject(t)&&a.isIterable(t)){let d={},u,c;for(const l of t){if(!a.isArray(l))throw TypeError("Object iterator must return a key-value pair");d[c=l[0]]=(u=d[c])?a.isArray(u)?[...u,l[1]]:[u,l[1]]:l[1]}o(d,n)}else t!=null&&s(n,t,i);return this}get(t,n){if(t=q(t),t){const i=a.findKey(this,t);if(i){const r=this[i];if(!n)return r;if(n===!0)return on(r);if(a.isFunction(n))return n.call(this,r,i);if(a.isRegExp(n))return n.exec(r);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,n){if(t=q(t),t){const i=a.findKey(this,t);return!!(i&&this[i]!==void 0&&(!n||ie(this,this[i],i,n)))}return!1}delete(t,n){const i=this;let r=!1;function s(o){if(o=q(o),o){const d=a.findKey(i,o);d&&(!n||ie(i,i[d],d,n))&&(delete i[d],r=!0)}}return a.isArray(t)?t.forEach(s):s(t),r}clear(t){const n=Object.keys(this);let i=n.length,r=!1;for(;i--;){const s=n[i];(!t||ie(this,this[s],s,t,!0))&&(delete this[s],r=!0)}return r}normalize(t){const n=this,i={};return a.forEach(this,(r,s)=>{const o=a.findKey(i,s);if(o){n[o]=V(r),delete n[s];return}const d=t?dn(s):String(s).trim();d!==s&&delete n[s],n[d]=V(r),i[d]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const n=Object.create(null);return a.forEach(this,(i,r)=>{i!=null&&i!==!1&&(n[r]=t&&a.isArray(i)?i.join(", "):i)}),n}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,n])=>t+": "+n).join(` +`)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...n){const i=new this(t);return n.forEach(r=>i.set(r)),i}static accessor(t){const i=(this[Ee]=this[Ee]={accessors:{}}).accessors,r=this.prototype;function s(o){const d=q(o);i[d]||(cn(r,o),i[d]=!0)}return a.isArray(t)?t.forEach(s):s(t),this}};C.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);a.reduceDescriptors(C.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(i){this[n]=i}}});a.freezeMethods(C);function re(e,t){const n=this||$,i=t||n,r=C.from(i.headers);let s=i.data;return a.forEach(e,function(d){s=d.call(n,s,r.normalize(),t?t.status:void 0)}),r.normalize(),s}function Ve(e){return!!(e&&e.__CANCEL__)}function I(e,t,n){v.call(this,e??"canceled",v.ERR_CANCELED,t,n),this.name="CanceledError"}a.inherits(I,v,{__CANCEL__:!0});function Ke(e,t,n){const i=n.config.validateStatus;!n.status||!i||i(n.status)?e(n):t(new v("Request failed with status code "+n.status,[v.ERR_BAD_REQUEST,v.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function ln(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function un(e,t){e=e||10;const n=new Array(e),i=new Array(e);let r=0,s=0,o;return t=t!==void 0?t:1e3,function(u){const c=Date.now(),l=i[s];o||(o=c),n[r]=u,i[r]=c;let p=s,w=0;for(;p!==r;)w+=n[p++],p=p%e;if(r=(r+1)%e,r===s&&(s=(s+1)%e),c-o{n=l,r=null,s&&(clearTimeout(s),s=null),e.apply(null,c)};return[(...c)=>{const l=Date.now(),p=l-n;p>=i?o(c,l):(r=c,s||(s=setTimeout(()=>{s=null,o(r)},i-p)))},()=>r&&o(r)]}const W=(e,t,n=3)=>{let i=0;const r=un(50,250);return fn(s=>{const o=s.loaded,d=s.lengthComputable?s.total:void 0,u=o-i,c=r(u),l=o<=d;i=o;const p={loaded:o,total:d,progress:d?o/d:void 0,bytes:u,rate:c||void 0,estimated:c&&d&&l?(d-o)/c:void 0,event:s,lengthComputable:d!=null,[t?"download":"upload"]:!0};e(p)},n)},ge=(e,t)=>{const n=e!=null;return[i=>t[0]({lengthComputable:n,total:e,loaded:i}),t[1]]},Re=e=>(...t)=>a.asap(()=>e(...t)),pn=O.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,O.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(O.origin),O.navigator&&/(msie|trident)/i.test(O.navigator.userAgent)):()=>!0,hn=O.hasStandardBrowserEnv?{write(e,t,n,i,r,s){const o=[e+"="+encodeURIComponent(t)];a.isNumber(n)&&o.push("expires="+new Date(n).toGMTString()),a.isString(i)&&o.push("path="+i),a.isString(r)&&o.push("domain="+r),s===!0&&o.push("secure"),document.cookie=o.join("; ")},read(e){const t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(e){this.write(e,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function vn(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function mn(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function We(e,t,n){let i=!vn(t);return e&&(i||n==!1)?mn(e,t):t}const Se=e=>e instanceof C?{...e}:e;function D(e,t){t=t||{};const n={};function i(c,l,p,w){return a.isPlainObject(c)&&a.isPlainObject(l)?a.merge.call({caseless:w},c,l):a.isPlainObject(l)?a.merge({},l):a.isArray(l)?l.slice():l}function r(c,l,p,w){if(a.isUndefined(l)){if(!a.isUndefined(c))return i(void 0,c,p,w)}else return i(c,l,p,w)}function s(c,l){if(!a.isUndefined(l))return i(void 0,l)}function o(c,l){if(a.isUndefined(l)){if(!a.isUndefined(c))return i(void 0,c)}else return i(void 0,l)}function d(c,l,p){if(p in t)return i(c,l);if(p in e)return i(void 0,c)}const u={url:s,method:s,data:s,baseURL:o,transformRequest:o,transformResponse:o,paramsSerializer:o,timeout:o,timeoutMessage:o,withCredentials:o,withXSRFToken:o,adapter:o,responseType:o,xsrfCookieName:o,xsrfHeaderName:o,onUploadProgress:o,onDownloadProgress:o,decompress:o,maxContentLength:o,maxBodyLength:o,beforeRedirect:o,transport:o,httpAgent:o,httpsAgent:o,cancelToken:o,socketPath:o,responseEncoding:o,validateStatus:d,headers:(c,l,p)=>r(Se(c),Se(l),p,!0)};return a.forEach(Object.keys(Object.assign({},e,t)),function(l){const p=u[l]||r,w=p(e[l],t[l],l);a.isUndefined(w)&&p!==d||(n[l]=w)}),n}const Xe=e=>{const t=D({},e);let{data:n,withXSRFToken:i,xsrfHeaderName:r,xsrfCookieName:s,headers:o,auth:d}=t;t.headers=o=C.from(o),t.url=$e(We(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),d&&o.set("Authorization","Basic "+btoa((d.username||"")+":"+(d.password?unescape(encodeURIComponent(d.password)):"")));let u;if(a.isFormData(n)){if(O.hasStandardBrowserEnv||O.hasStandardBrowserWebWorkerEnv)o.setContentType(void 0);else if((u=o.getContentType())!==!1){const[c,...l]=u?u.split(";").map(p=>p.trim()).filter(Boolean):[];o.setContentType([c||"multipart/form-data",...l].join("; "))}}if(O.hasStandardBrowserEnv&&(i&&a.isFunction(i)&&(i=i(t)),i||i!==!1&&pn(t.url))){const c=r&&s&&hn.read(s);c&&o.set(r,c)}return t},wn=typeof XMLHttpRequest<"u",yn=wn&&function(e){return new Promise(function(n,i){const r=Xe(e);let s=r.data;const o=C.from(r.headers).normalize();let{responseType:d,onUploadProgress:u,onDownloadProgress:c}=r,l,p,w,g,f;function m(){g&&g(),f&&f(),r.cancelToken&&r.cancelToken.unsubscribe(l),r.signal&&r.signal.removeEventListener("abort",l)}let h=new XMLHttpRequest;h.open(r.method.toUpperCase(),r.url,!0),h.timeout=r.timeout;function b(){if(!h)return;const T=C.from("getAllResponseHeaders"in h&&h.getAllResponseHeaders()),A={data:!d||d==="text"||d==="json"?h.responseText:h.response,status:h.status,statusText:h.statusText,headers:T,config:e,request:h};Ke(function(L){n(L),m()},function(L){i(L),m()},A),h=null}"onloadend"in h?h.onloadend=b:h.onreadystatechange=function(){!h||h.readyState!==4||h.status===0&&!(h.responseURL&&h.responseURL.indexOf("file:")===0)||setTimeout(b)},h.onabort=function(){h&&(i(new v("Request aborted",v.ECONNABORTED,e,h)),h=null)},h.onerror=function(){i(new v("Network Error",v.ERR_NETWORK,e,h)),h=null},h.ontimeout=function(){let k=r.timeout?"timeout of "+r.timeout+"ms exceeded":"timeout exceeded";const A=r.transitional||ze;r.timeoutErrorMessage&&(k=r.timeoutErrorMessage),i(new v(k,A.clarifyTimeoutError?v.ETIMEDOUT:v.ECONNABORTED,e,h)),h=null},s===void 0&&o.setContentType(null),"setRequestHeader"in h&&a.forEach(o.toJSON(),function(k,A){h.setRequestHeader(A,k)}),a.isUndefined(r.withCredentials)||(h.withCredentials=!!r.withCredentials),d&&d!=="json"&&(h.responseType=r.responseType),c&&([w,f]=W(c,!0),h.addEventListener("progress",w)),u&&h.upload&&([p,g]=W(u),h.upload.addEventListener("progress",p),h.upload.addEventListener("loadend",g)),(r.cancelToken||r.signal)&&(l=T=>{h&&(i(!T||T.type?new I(null,e,h):T),h.abort(),h=null)},r.cancelToken&&r.cancelToken.subscribe(l),r.signal&&(r.signal.aborted?l():r.signal.addEventListener("abort",l)));const R=ln(r.url);if(R&&O.protocols.indexOf(R)===-1){i(new v("Unsupported protocol "+R+":",v.ERR_BAD_REQUEST,e));return}h.send(s||null)})},bn=(e,t)=>{const{length:n}=e=e?e.filter(Boolean):[];if(t||n){let i=new AbortController,r;const s=function(c){if(!r){r=!0,d();const l=c instanceof Error?c:this.reason;i.abort(l instanceof v?l:new I(l instanceof Error?l.message:l))}};let o=t&&setTimeout(()=>{o=null,s(new v(`timeout ${t} of ms exceeded`,v.ETIMEDOUT))},t);const d=()=>{e&&(o&&clearTimeout(o),o=null,e.forEach(c=>{c.unsubscribe?c.unsubscribe(s):c.removeEventListener("abort",s)}),e=null)};e.forEach(c=>c.addEventListener("abort",s));const{signal:u}=i;return u.unsubscribe=()=>a.asap(d),u}},En=function*(e,t){let n=e.byteLength;if(n{const r=gn(e,t);let s=0,o,d=u=>{o||(o=!0,i&&i(u))};return new ReadableStream({async pull(u){try{const{done:c,value:l}=await r.next();if(c){d(),u.close();return}let p=l.byteLength;if(n){let w=s+=p;n(w)}u.enqueue(new Uint8Array(l))}catch(c){throw d(c),c}},cancel(u){return d(u),r.return()}},{highWaterMark:2})},te=typeof fetch=="function"&&typeof Request=="function"&&typeof Response=="function",Ge=te&&typeof ReadableStream=="function",Sn=te&&(typeof TextEncoder=="function"?(e=>t=>e.encode(t))(new TextEncoder):async e=>new Uint8Array(await new Response(e).arrayBuffer())),Ze=(e,...t)=>{try{return!!e(...t)}catch{return!1}},Tn=Ge&&Ze(()=>{let e=!1;const t=new Request(O.origin,{body:new ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type");return e&&!t}),Oe=64*1024,ce=Ge&&Ze(()=>a.isReadableStream(new Response("").body)),X={stream:ce&&(e=>e.body)};te&&(e=>{["text","arrayBuffer","blob","formData","stream"].forEach(t=>{!X[t]&&(X[t]=a.isFunction(e[t])?n=>n[t]():(n,i)=>{throw new v(`Response type '${t}' is not supported`,v.ERR_NOT_SUPPORT,i)})})})(new Response);const On=async e=>{if(e==null)return 0;if(a.isBlob(e))return e.size;if(a.isSpecCompliantForm(e))return(await new Request(O.origin,{method:"POST",body:e}).arrayBuffer()).byteLength;if(a.isArrayBufferView(e)||a.isArrayBuffer(e))return e.byteLength;if(a.isURLSearchParams(e)&&(e=e+""),a.isString(e))return(await Sn(e)).byteLength},An=async(e,t)=>{const n=a.toFiniteNumber(e.getContentLength());return n??On(t)},_n=te&&(async e=>{let{url:t,method:n,data:i,signal:r,cancelToken:s,timeout:o,onDownloadProgress:d,onUploadProgress:u,responseType:c,headers:l,withCredentials:p="same-origin",fetchOptions:w}=Xe(e);c=c?(c+"").toLowerCase():"text";let g=bn([r,s&&s.toAbortSignal()],o),f;const m=g&&g.unsubscribe&&(()=>{g.unsubscribe()});let h;try{if(u&&Tn&&n!=="get"&&n!=="head"&&(h=await An(l,i))!==0){let A=new Request(t,{method:"POST",body:i,duplex:"half"}),B;if(a.isFormData(i)&&(B=A.headers.get("content-type"))&&l.setContentType(B),A.body){const[L,z]=ge(h,W(Re(u)));i=Te(A.body,Oe,L,z)}}a.isString(p)||(p=p?"include":"omit");const b="credentials"in Request.prototype;f=new Request(t,{...w,signal:g,method:n.toUpperCase(),headers:l.normalize().toJSON(),body:i,duplex:"half",credentials:b?p:void 0});let R=await fetch(f,w);const T=ce&&(c==="stream"||c==="response");if(ce&&(d||T&&m)){const A={};["status","statusText","headers"].forEach(ve=>{A[ve]=R[ve]});const B=a.toFiniteNumber(R.headers.get("content-length")),[L,z]=d&&ge(B,W(Re(d),!0))||[];R=new Response(Te(R.body,Oe,L,()=>{z&&z(),m&&m()}),A)}c=c||"text";let k=await X[a.findKey(X,c)||"text"](R,e);return!T&&m&&m(),await new Promise((A,B)=>{Ke(A,B,{data:k,headers:C.from(R.headers),status:R.status,statusText:R.statusText,config:e,request:f})})}catch(b){throw m&&m(),b&&b.name==="TypeError"&&/Load failed|fetch/i.test(b.message)?Object.assign(new v("Network Error",v.ERR_NETWORK,e,f),{cause:b.cause||b}):v.from(b,b&&b.code,e,f)}}),le={http:Mt,xhr:yn,fetch:_n};a.forEach(le,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const Ae=e=>`- ${e}`,xn=e=>a.isFunction(e)||e===null||e===!1,Qe={getAdapter:e=>{e=a.isArray(e)?e:[e];const{length:t}=e;let n,i;const r={};for(let s=0;s`adapter ${d} `+(u===!1?"is not supported by the environment":"is not available in the build"));let o=t?s.length>1?`since : `+s.map(Ae).join(` -`):" "+Ae(s[0]):"as no adapter specified";throw new m("There is no suitable adapter to dispatch the request "+o,"ERR_NOT_SUPPORT")}return r},adapters:de};function se(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new I(null,e)}function xe(e){return se(e),e.headers=C.from(e.headers),e.data=ie.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),Qe.getAdapter(e.adapter||$.adapter)(e).then(function(r){return se(e),r.data=ie.call(e,e.transformResponse,r),r.headers=C.from(r.headers),r},function(r){return Ve(r)||(se(e),r&&r.response&&(r.response.data=ie.call(e,e.transformResponse,r.response),r.response.headers=C.from(r.response.headers))),Promise.reject(r)})}const Ye="1.10.0",ne={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{ne[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const Ce={};ne.transitional=function(t,n,r){function i(s,o){return"[Axios v"+Ye+"] Transitional option '"+s+"'"+o+(r?". "+r:"")}return(s,o,c)=>{if(t===!1)throw new m(i(o," has been removed"+(n?" in "+n:"")),m.ERR_DEPRECATED);return n&&!Ce[o]&&(Ce[o]=!0,console.warn(i(o," has been deprecated since v"+n+" and will be removed in the near future"))),t?t(s,o,c):!0}};ne.spelling=function(t){return(n,r)=>(console.warn(`${r} is likely a misspelling of ${t}`),!0)};function Pn(e,t,n){if(typeof e!="object")throw new m("options must be an object",m.ERR_BAD_OPTION_VALUE);const r=Object.keys(e);let i=r.length;for(;i-- >0;){const s=r[i],o=t[s];if(o){const c=e[s],u=c===void 0||o(c,s,e);if(u!==!0)throw new m("option "+s+" must be "+u,m.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new m("Unknown option "+s,m.ERR_BAD_OPTION)}}const K={assertOptions:Pn,validators:ne},N=K.validators;let U=class{constructor(t){this.defaults=t||{},this.interceptors={request:new be,response:new be}}async request(t,n){try{return await this._request(t,n)}catch(r){if(r instanceof Error){let i={};Error.captureStackTrace?Error.captureStackTrace(i):i=new Error;const s=i.stack?i.stack.replace(/^.+\n/,""):"";try{r.stack?s&&!String(r.stack).endsWith(s.replace(/^.+\n.+\n/,""))&&(r.stack+=` -`+s):r.stack=s}catch{}}throw r}}_request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=D(this.defaults,n);const{transitional:r,paramsSerializer:i,headers:s}=n;r!==void 0&&K.assertOptions(r,{silentJSONParsing:N.transitional(N.boolean),forcedJSONParsing:N.transitional(N.boolean),clarifyTimeoutError:N.transitional(N.boolean)},!1),i!=null&&(a.isFunction(i)?n.paramsSerializer={serialize:i}:K.assertOptions(i,{encode:N.function,serialize:N.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),K.assertOptions(n,{baseUrl:N.spelling("baseURL"),withXsrfToken:N.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let o=s&&a.merge(s.common,s[n.method]);s&&a.forEach(["delete","get","head","post","put","patch","common"],f=>{delete s[f]}),n.headers=C.concat(o,s);const c=[];let u=!0;this.interceptors.request.forEach(function(v){typeof v.runWhen=="function"&&v.runWhen(n)===!1||(u=u&&v.synchronous,c.unshift(v.fulfilled,v.rejected))});const l=[];this.interceptors.response.forEach(function(v){l.push(v.fulfilled,v.rejected)});let d,p=0,w;if(!u){const f=[xe.bind(this),void 0];for(f.unshift.apply(f,c),f.push.apply(f,l),w=f.length,d=Promise.resolve(n);p{if(!r._listeners)return;let s=r._listeners.length;for(;s-- >0;)r._listeners[s](i);r._listeners=null}),this.promise.then=i=>{let s;const o=new Promise(c=>{r.subscribe(c),s=c}).then(i);return o.cancel=function(){r.unsubscribe(s)},o},t(function(s,o,c){r.reason||(r.reason=new I(s,o,c),n(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const n=this._listeners.indexOf(t);n!==-1&&this._listeners.splice(n,1)}toAbortSignal(){const t=new AbortController,n=r=>{t.abort(r)};return this.subscribe(n),t.signal.unsubscribe=()=>this.unsubscribe(n),t.signal}static source(){let t;return{token:new et(function(i){t=i}),cancel:t}}};function Nn(e){return function(n){return e.apply(null,n)}}function Ln(e){return a.isObject(e)&&e.isAxiosError===!0}const ue={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(ue).forEach(([e,t])=>{ue[t]=e});function tt(e){const t=new U(e),n=Ne(U.prototype.request,t);return a.extend(n,U.prototype,t,{allOwnKeys:!0}),a.extend(n,t,null,{allOwnKeys:!0}),n.create=function(i){return tt(D(e,i))},n}const E=tt($);E.Axios=U;E.CanceledError=I;E.CancelToken=_n;E.isCancel=Ve;E.VERSION=Ye;E.toFormData=ee;E.AxiosError=m;E.Cancel=E.CanceledError;E.all=function(t){return Promise.all(t)};E.spread=Nn;E.isAxiosError=Ln;E.mergeConfig=D;E.AxiosHeaders=C;E.formToJSON=e=>Je(a.isHTMLForm(e)?new FormData(e):e);E.getAdapter=Qe.getAdapter;E.HttpStatusCode=ue;E.default=E;const{Axios:zn,AxiosError:Jn,CanceledError:Vn,isCancel:Kn,CancelToken:Wn,VERSION:Xn,all:Gn,Cancel:Zn,isAxiosError:Qn,spread:Yn,toFormData:er,AxiosHeaders:tr,HttpStatusCode:nr,formToJSON:rr,getAdapter:ir,mergeConfig:sr}=E,Bn=E.create({baseURL:"http://localhost:4000/api/v1",headers:{"Content-Type":"application/json"}});class Fn{base64ToFile(t,n,r){const i=t.includes(",")?t.split(",")[1]:t,s=atob(i),o=new ArrayBuffer(s.length),c=new Uint8Array(o);for(let l=0;l{let s=0;const o=()=>{const c=document.evaluate(t,document,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue;if(c instanceof HTMLElement){i(c);return}s++,s{const o=new FileReader;o.onloadend=()=>{typeof o.result=="string"?i(o.result.split(",")[1]):s("Không thể đọc dữ liệu ảnh")},o.onerror=s,o.readAsDataURL(r)})}getImageExtension(t){try{const r=new URL(t).pathname.match(/\.([a-zA-Z0-9]+)$/);return r?r[1].toLowerCase():null}catch{const i=t.split("?")[0].match(/\.([a-zA-Z0-9]+)$/);return i?i[1].toLowerCase():null}}imageLocalToBase64(t){return new Promise((n,r)=>{try{const i=chrome.runtime.getURL(`${t}`);fetch(i).then(s=>s.blob()).then(s=>{const o=new FileReader;o.onloadend=()=>n(o.result),o.onerror=r,o.readAsDataURL(s)}).catch(r)}catch(i){r(i)}})}scrollToElement(t,n="smooth"){t&&t.scrollIntoView({behavior:n,block:"center",inline:"nearest"})}getElementPointCoores(t){if(!t)return null;const n=t.getBoundingClientRect(),r=n.left+n.width/2,i=n.top+n.height/2;return{x:r,y:i}}setInputValue(t,n){t&&(t.value=n,t.dispatchEvent(new Event("input",{bubbles:!0})),t.dispatchEvent(new Event("change",{bubbles:!0})))}writeToInput=async(t,n)=>{const r=await this.getElementByXPath(n);if(!r)throw new Error("Xpath is not found with value: "+t);this.scrollToElement(r),this.clickByPoint(r),this.setInputValue(r,t)};pressEnter(t){if(!t)throw new Error("Textarea not found:",t);t.focus(),["keydown","keypress","keyup"].forEach(n=>{t.dispatchEvent(new KeyboardEvent(n,{key:"Enter",code:"Enter",keyCode:13,which:13,bubbles:!0,cancelable:!0}))})}}const y=new Fn,P={file__image_input:'input[type="file"]',title_input:"/html/body/div[1]/div/div[1]/div/div[3]/div/div/div[1]/div[1]/div[1]/div/div[2]/div[1]/div[2]/div/div/div[5]/div/div/div/label/div/input",price_input:"/html/body/div[1]/div/div[1]/div/div[3]/div/div/div[1]/div[1]/div[1]/div/div[3]/div[1]/div[2]/div/div/div[6]/div/div/div/label/div/input",brand_input:"/html/body/div[1]/div/div[1]/div/div[3]/div/div/div[1]/div[1]/div[1]/div/div[3]/div[1]/div[2]/div/div/div[9]/div/div/div[2]/div/div/div/label/div/input",description_input:"/html/body/div[1]/div/div[1]/div/div[3]/div/div/div[1]/div[1]/div[1]/div/div[3]/div[1]/div[2]/div/div/div[9]/div/div/div[3]/div/div/div/label/div/div/textarea",sku_input:"/html/body/div[1]/div/div[1]/div/div[3]/div/div/div[1]/div[1]/div[1]/div/div[3]/div[1]/div[2]/div/div/div[9]/div/div/div[6]/div/div/div[1]/label/div/input",category_select:{wraper:"/html/body/div[1]/div/div[1]/div/div[3]/div/div/div[1]/div[1]/div[1]/div/div[3]/div[1]/div[2]/div/div/div[7]/div/div/div/div",container:"/html/body/div[1]/div/div[1]/div/div[3]/div/div/div[2]/div/div/div[1]/div[1]/div/div/div/div/div/span/div"},condition_select:{wraper:"/html/body/div[1]/div/div[1]/div/div[3]/div/div/div[1]/div[1]/div[1]/div/div[3]/div[1]/div[2]/div/div/div[8]/div/div/div/div",container:"/html/body/div[1]/div/div[1]/div/div[3]/div/div/div[2]/div/div/div[1]/div[1]/div/div/div/div/div[1]/div"},tags_input:{input:"/html/body/div[1]/div/div[1]/div/div[3]/div/div/div[1]/div[1]/div[1]/div/div[3]/div[1]/div[2]/div/div/div[9]/div/div/div[5]/div/div/div/div[1]/label/div/div/div[2]/div/textarea"},location_select:{input:"/html/body/div[1]/div/div[1]/div/div[3]/div/div/div[1]/div[1]/div[1]/div/div[3]/div[1]/div[2]/div/div/div[9]/div/div/div[7]/div/div/div/div/div/div/div/div/label/div[2]/input",wraper:"/html/body/div[1]/div/div[1]/div/div[3]/div/div/div[1]/div[1]/div[1]/div/div[3]/div[1]/div[2]/div/div/div[9]/div/div/div[7]/div/div/div/div/div/div/div/div",container:"/html/body/div[1]/div/div[1]/div/div[3]/div/div/div[2]/div/div/div[1]/div[1]/div/ul"},next_btn:"/html/body/div[1]/div/div[1]/div/div[3]/div/div/div[1]/div[1]/div[1]/div/div[5]/div/div/div"},kn=async e=>{const t=new DataTransfer;for(const r of e.images){console.log("Base64:",r.slice(0,50)+"...");const i=y.base64ToFile(r,e.sku,y.getImageExtension(r)||"jpg");t.items.add(i)}const n=document.querySelector(P.file__image_input);n?(n.files=t.files,n.dispatchEvent(new Event("change",{bubbles:!0}))):console.error("Không tìm thấy input[type='file']")},Pe=async(e,t)=>{const n=await y.getElementByXPath(t.wraper);if(!n)throw new Error("Wrapper xpath not found");y.scrollToElement(n),y.clickByPoint(n),await S(400);const r=await y.getElementByXPath(t.container);if(!r)throw new Error("Container xpath not found");const i=Array.from(r.children).find(s=>s.textContent?.trim().toLocaleLowerCase()===e.toLocaleLowerCase());if(!i)throw new Error(`No child found with text "${e}"`);y.scrollToElement(i),await S(200),y.clickByPoint(i)},Un=async(e,{input:t,...n})=>{await y.writeToInput(e,t),await S(400);const r=await y.getElementByXPath(n.container);if(!r)throw new Error("Container xpath not found");y.scrollToElement(r);const i=Array.from(r.children).find(s=>s.textContent?.trim().toLocaleLowerCase().includes(e.toLocaleLowerCase()));if(!i)throw new Error(`No child found with text "${e}"`);y.scrollToElement(i),await S(200),y.clickByPoint(i)},Dn=async(e,t)=>{const n=await y.getElementByXPath(t.input);if(!n)throw new Error("Input is not found");y.scrollToElement(n),await S(200);for(const r of e)y.writeToInput(r,t.input),await S(200),y.pressEnter(n)},_e=async(e,t)=>{const{data:n}=await Bn({url:"products/publist-finish/"+e.id,method:"POST",data:t});return n},jn=async()=>{const e=await y.getElementByXPath(P.next_btn);if(!e)throw new Error("Next button is not found");y.clickByPoint(e)},In=async e=>(console.log({item:e}),await S(1e3),await kn(e),await S(400),y.writeToInput(e.title,P.title_input),await S(400),y.writeToInput(String(e.price),P.price_input),await S(400),await Pe(e.category,P.category_select),await S(400),await Pe(e.condition,P.condition_select),e.brand&&(await S(400),y.writeToInput(e.brand,P.brand_input)),await S(400),await y.writeToInput(e.description,P.description_input),await S(400),await Dn(e.tags,P.tags_input),await S(400),y.writeToInput(e.sku,P.sku_input),e?.location&&(await S(400),await Un(e.location,P.location_select)),await S(400),await jn(),!0),qn=async e=>{await S(2e3),chrome.runtime.sendMessage({type:"close-tab",payload:e})},Mn=chrome.runtime.connect();Mn.onMessage.addListener(async e=>{if(e.type==="publist-event"){const t=e.payload;if(!t)return;console.log("Received new product event:",t);try{await S(2e3),await In(t)}catch(n){await _e(t,{error:n.message,published:!1})}finally{await _e(t,{published:!0}),await qn(t)}}}); +`):" "+Ae(s[0]):"as no adapter specified";throw new v("There is no suitable adapter to dispatch the request "+o,"ERR_NOT_SUPPORT")}return i},adapters:le};function se(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new I(null,e)}function _e(e){return se(e),e.headers=C.from(e.headers),e.data=re.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),Qe.getAdapter(e.adapter||$.adapter)(e).then(function(i){return se(e),i.data=re.call(e,e.transformResponse,i),i.headers=C.from(i.headers),i},function(i){return Ve(i)||(se(e),i&&i.response&&(i.response.data=re.call(e,e.transformResponse,i.response),i.response.headers=C.from(i.response.headers))),Promise.reject(i)})}const Ye="1.10.0",ne={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{ne[e]=function(i){return typeof i===e||"a"+(t<1?"n ":" ")+e}});const xe={};ne.transitional=function(t,n,i){function r(s,o){return"[Axios v"+Ye+"] Transitional option '"+s+"'"+o+(i?". "+i:"")}return(s,o,d)=>{if(t===!1)throw new v(r(o," has been removed"+(n?" in "+n:"")),v.ERR_DEPRECATED);return n&&!xe[o]&&(xe[o]=!0,console.warn(r(o," has been deprecated since v"+n+" and will be removed in the near future"))),t?t(s,o,d):!0}};ne.spelling=function(t){return(n,i)=>(console.warn(`${i} is likely a misspelling of ${t}`),!0)};function Cn(e,t,n){if(typeof e!="object")throw new v("options must be an object",v.ERR_BAD_OPTION_VALUE);const i=Object.keys(e);let r=i.length;for(;r-- >0;){const s=i[r],o=t[s];if(o){const d=e[s],u=d===void 0||o(d,s,e);if(u!==!0)throw new v("option "+s+" must be "+u,v.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new v("Unknown option "+s,v.ERR_BAD_OPTION)}}const K={assertOptions:Cn,validators:ne},N=K.validators;let U=class{constructor(t){this.defaults=t||{},this.interceptors={request:new be,response:new be}}async request(t,n){try{return await this._request(t,n)}catch(i){if(i instanceof Error){let r={};Error.captureStackTrace?Error.captureStackTrace(r):r=new Error;const s=r.stack?r.stack.replace(/^.+\n/,""):"";try{i.stack?s&&!String(i.stack).endsWith(s.replace(/^.+\n.+\n/,""))&&(i.stack+=` +`+s):i.stack=s}catch{}}throw i}}_request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=D(this.defaults,n);const{transitional:i,paramsSerializer:r,headers:s}=n;i!==void 0&&K.assertOptions(i,{silentJSONParsing:N.transitional(N.boolean),forcedJSONParsing:N.transitional(N.boolean),clarifyTimeoutError:N.transitional(N.boolean)},!1),r!=null&&(a.isFunction(r)?n.paramsSerializer={serialize:r}:K.assertOptions(r,{encode:N.function,serialize:N.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),K.assertOptions(n,{baseUrl:N.spelling("baseURL"),withXsrfToken:N.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let o=s&&a.merge(s.common,s[n.method]);s&&a.forEach(["delete","get","head","post","put","patch","common"],f=>{delete s[f]}),n.headers=C.concat(o,s);const d=[];let u=!0;this.interceptors.request.forEach(function(m){typeof m.runWhen=="function"&&m.runWhen(n)===!1||(u=u&&m.synchronous,d.unshift(m.fulfilled,m.rejected))});const c=[];this.interceptors.response.forEach(function(m){c.push(m.fulfilled,m.rejected)});let l,p=0,w;if(!u){const f=[_e.bind(this),void 0];for(f.unshift.apply(f,d),f.push.apply(f,c),w=f.length,l=Promise.resolve(n);p{if(!i._listeners)return;let s=i._listeners.length;for(;s-- >0;)i._listeners[s](r);i._listeners=null}),this.promise.then=r=>{let s;const o=new Promise(d=>{i.subscribe(d),s=d}).then(r);return o.cancel=function(){i.unsubscribe(s)},o},t(function(s,o,d){i.reason||(i.reason=new I(s,o,d),n(i.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const n=this._listeners.indexOf(t);n!==-1&&this._listeners.splice(n,1)}toAbortSignal(){const t=new AbortController,n=i=>{t.abort(i)};return this.subscribe(n),t.signal.unsubscribe=()=>this.unsubscribe(n),t.signal}static source(){let t;return{token:new et(function(r){t=r}),cancel:t}}};function Nn(e){return function(n){return e.apply(null,n)}}function kn(e){return a.isObject(e)&&e.isAxiosError===!0}const ue={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(ue).forEach(([e,t])=>{ue[t]=e});function tt(e){const t=new U(e),n=Ne(U.prototype.request,t);return a.extend(n,U.prototype,t,{allOwnKeys:!0}),a.extend(n,t,null,{allOwnKeys:!0}),n.create=function(r){return tt(D(e,r))},n}const E=tt($);E.Axios=U;E.CanceledError=I;E.CancelToken=Pn;E.isCancel=Ve;E.VERSION=Ye;E.toFormData=ee;E.AxiosError=v;E.Cancel=E.CanceledError;E.all=function(t){return Promise.all(t)};E.spread=Nn;E.isAxiosError=kn;E.mergeConfig=D;E.AxiosHeaders=C;E.formToJSON=e=>Je(a.isHTMLForm(e)?new FormData(e):e);E.getAdapter=Qe.getAdapter;E.HttpStatusCode=ue;E.default=E;const{Axios:zn,AxiosError:Jn,CanceledError:Vn,isCancel:Kn,CancelToken:Wn,VERSION:Xn,all:Gn,Cancel:Zn,isAxiosError:Qn,spread:Yn,toFormData:ei,AxiosHeaders:ti,HttpStatusCode:ni,formToJSON:ii,getAdapter:ri,mergeConfig:si}=E,Bn=E.create({baseURL:"http://localhost:4000/api/v1",headers:{"Content-Type":"application/json"}});class Ln{base64ToFile(t,n,i){const r=t.includes(",")?t.split(",")[1]:t,s=atob(r),o=new ArrayBuffer(s.length),d=new Uint8Array(o);for(let c=0;c{let o=0,d=!1;const u=()=>{const c=document.evaluate(d&&r?r:t,document,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue;if(c instanceof HTMLElement){s(c);return}o++,o{const o=new FileReader;o.onloadend=()=>{typeof o.result=="string"?r(o.result.split(",")[1]):s("Không thể đọc dữ liệu ảnh")},o.onerror=s,o.readAsDataURL(i)})}getImageExtension(t){try{const i=new URL(t).pathname.match(/\.([a-zA-Z0-9]+)$/);return i?i[1].toLowerCase():null}catch{const r=t.split("?")[0].match(/\.([a-zA-Z0-9]+)$/);return r?r[1].toLowerCase():null}}imageLocalToBase64(t){return new Promise((n,i)=>{try{const r=chrome.runtime.getURL(`${t}`);fetch(r).then(s=>s.blob()).then(s=>{const o=new FileReader;o.onloadend=()=>n(o.result),o.onerror=i,o.readAsDataURL(s)}).catch(i)}catch(r){i(r)}})}scrollToElement(t,n="smooth"){t&&t.scrollIntoView({behavior:n,block:"center",inline:"nearest"})}getElementPointCoores(t){if(!t)return null;const n=t.getBoundingClientRect(),i=n.left+n.width/2,r=n.top+n.height/2;return{x:i,y:r}}setInputValue(t,n){t&&(t.value=n,t.dispatchEvent(new Event("input",{bubbles:!0})),t.dispatchEvent(new Event("change",{bubbles:!0})))}writeToInput=async(t,n,i)=>{const r=await this.getElementByXPath(n,{xpathFallback:i});if(!r)throw new Error("Xpath is not found with value: "+t);this.scrollToElement(r),this.clickByPoint(r),this.setInputValue(r,t)};pressEnter(t){if(!t)throw new Error("Textarea not found:",t);t.focus(),["keydown","keypress","keyup"].forEach(n=>{t.dispatchEvent(new KeyboardEvent(n,{key:"Enter",code:"Enter",keyCode:13,which:13,bubbles:!0,cancelable:!0}))})}}const y=new Ln,_={file__image_input:'input[type="file"]',title_input:"/html/body/div[1]/div/div[1]/div/div[3]/div/div/div[1]/div[1]/div[1]/div/div[2]/div[1]/div[2]/div/div/div[5]/div/div/div/label/div/input",price_input:"/html/body/div[1]/div/div[1]/div/div[3]/div/div/div[1]/div[1]/div[1]/div/div[3]/div[1]/div[2]/div/div/div[6]/div/div/div/label/div/input",brand_input:"/html/body/div[1]/div/div[1]/div/div[3]/div/div/div[1]/div[1]/div[1]/div/div[3]/div[1]/div[2]/div/div/div[9]/div/div/div[2]/div/div/div/label/div/input",brand_input_fallback:"/html/body/div[1]/div/div[1]/div/div[3]/div/div/div[1]/div[1]/div[1]/div/div[3]/div[1]/div[2]/div/div/div[10]/div/div/div[2]/div/div/div/label/div/input",description_input:"/html/body/div[1]/div/div[1]/div/div[3]/div/div/div[1]/div[1]/div[1]/div/div[3]/div[1]/div[2]/div/div/div[9]/div/div/div[3]/div/div/div/label/div/div/textarea",description_input_falback:"/html/body/div[1]/div/div[1]/div/div[3]/div/div/div[1]/div[1]/div[1]/div/div[3]/div[1]/div[2]/div/div/div[10]/div/div/div[3]/div/div/div/label/div/div/textarea",sku_input:"/html/body/div[1]/div/div[1]/div/div[3]/div/div/div[1]/div[1]/div[1]/div/div[3]/div[1]/div[2]/div/div/div[9]/div/div/div[6]/div/div/div[1]/label/div/input",sku_input_fallback:"/html/body/div[1]/div/div[1]/div/div[3]/div/div/div[1]/div[1]/div[1]/div/div[3]/div[1]/div[2]/div/div/div[10]/div/div/div[6]/div/div/div[1]/label/div/input",category_select:{wraper:"/html/body/div[1]/div/div[1]/div/div[3]/div/div/div[1]/div[1]/div[1]/div/div[3]/div[1]/div[2]/div/div/div[7]/div/div/div/div",container:"/html/body/div[1]/div/div[1]/div/div[3]/div/div/div[2]/div/div/div[1]/div[1]/div/div/div/div/div/span/div"},condition_select:{wraper:"/html/body/div[1]/div/div[1]/div/div[3]/div/div/div[1]/div[1]/div[1]/div/div[3]/div[1]/div[2]/div/div/div[8]/div/div/div/div",container:"/html/body/div[1]/div/div[1]/div/div[3]/div/div/div[2]/div/div/div[1]/div[1]/div/div/div/div/div[1]/div"},tags_input:{input:"/html/body/div[1]/div/div[1]/div/div[3]/div/div/div[1]/div[1]/div[1]/div/div[3]/div[1]/div[2]/div/div/div[9]/div/div/div[5]/div/div/div/div[1]/label/div/div/div[2]/div/textarea",input_falback:"/html/body/div[1]/div/div[1]/div/div[3]/div/div/div[1]/div[1]/div[1]/div/div[3]/div[1]/div[2]/div/div/div[10]/div/div/div[5]/div/div/div/div[1]/label/div/div/div[2]/div/textarea"},location_select:{input:"/html/body/div[1]/div/div[1]/div/div[3]/div/div/div[1]/div[1]/div[1]/div/div[3]/div[1]/div[2]/div/div/div[9]/div/div/div[7]/div/div/div/div/div/div/div/div/label/div[2]/input",input_fallback:"/html/body/div[1]/div/div[1]/div/div[3]/div/div/div[1]/div[1]/div[1]/div/div[3]/div[1]/div[2]/div/div/div[10]/div/div/div[7]/div/div/div/div/div/div/div/div/label/div[2]/input",wraper:"/html/body/div[1]/div/div[1]/div/div[3]/div/div/div[1]/div[1]/div[1]/div/div[3]/div[1]/div[2]/div/div/div[9]/div/div/div[7]/div/div/div/div/div/div/div/div",container:"/html/body/div[1]/div/div[1]/div/div[3]/div/div/div[2]/div/div/div[1]/div[1]/div/ul",container_fallback:"/html/body/div[1]/div/div[1]/div/div[3]/div/div/div[2]/div/div/div[1]/div[1]/div/ul"},next_btn:"/html/body/div[1]/div/div[1]/div/div[3]/div/div/div[1]/div[1]/div[1]/div/div[5]/div/div/div"},Fn=async e=>{const t=new DataTransfer;for(const i of e.images){const r=await y.imageUrlToBase64(i);console.log("Base64:",i.slice(0,50)+"...");const s=y.base64ToFile(r,e.sku,y.getImageExtension(i)||"jpg");t.items.add(s)}const n=document.querySelector(_.file__image_input);n?(n.files=t.files,n.dispatchEvent(new Event("change",{bubbles:!0}))):console.error("Không tìm thấy input[type='file']")},Ce=async(e,t)=>{const n=await y.getElementByXPath(t.wraper);if(!n)throw new Error("Wrapper xpath not found");y.scrollToElement(n),y.clickByPoint(n),await S(200);const i=await y.getElementByXPath(t.container);if(!i)throw new Error("Container xpath not found");const r=Array.from(i.children).find(s=>s.textContent?.trim().toLocaleLowerCase().replace(/–/g,"-").includes(e.toLocaleLowerCase()));if(!r)throw new Error(`No child found with text "${e}"`);y.scrollToElement(r),await S(200),y.clickByPoint(r)},Un=async(e,{input:t,...n})=>{await y.writeToInput(e,t,n.input_fallback),await S(200);const i=await y.getElementByXPath(n.container,{xpathFallback:n.container_fallback});if(!i)throw new Error("Container xpath not found");y.scrollToElement(i);const r=Array.from(i.children).find(s=>s.textContent?.trim().toLocaleLowerCase().includes(e.toLocaleLowerCase()));if(!r)throw new Error(`No child found with text "${e}"`);y.scrollToElement(r),await S(200),y.clickByPoint(r)},Dn=async(e,t)=>{const n=await y.getElementByXPath(t.input,{xpathFallback:t?.input_falback});if(!n)throw new Error("Input is not found");y.scrollToElement(n),await S(200);for(const i of e)await y.writeToInput(i,t.input,t?.input_falback),await S(200),y.pressEnter(n)},Pe=async(e,t)=>{const{data:n}=await Bn({url:"products/publist-finish/"+e.id,method:"POST",data:t});return n},jn=async()=>{const e=await y.getElementByXPath(_.next_btn);if(!e)throw new Error("Next button is not found");y.clickByPoint(e)},In=async e=>(console.log({item:e}),await S(1e3),await Fn(e),await S(200),y.writeToInput(e.title,_.title_input),await S(200),y.writeToInput(String(e.price),_.price_input),await S(200),await Ce(e.category,_.category_select),await S(200),await Ce(e.condition,_.condition_select),e.brand&&(await S(200),await y.writeToInput(e.brand,_.brand_input,_.brand_input_fallback)),await S(200),await y.writeToInput(e.description,_.description_input,_.description_input_falback),await S(200),await Dn(e.tags,_.tags_input),await S(200),await y.writeToInput(e.sku,_.sku_input,_.sku_input_fallback),e?.location&&(await S(200),await Un(e.location,_.location_select)),await S(200),await jn(),!0),qn=async e=>{await S(1e3),chrome.runtime.sendMessage({type:"close-tab",payload:e})},Mn=chrome.runtime.connect();Mn.onMessage.addListener(async e=>{if(e.type==="publist-event"){const t=e.payload;if(!t)return;console.log("Received new product event:",t);try{await S(500),await In(t)}catch(n){await Pe(t,{error:n.message,published:!1})}finally{await Pe(t,{published:!0}),await qn(t)}}}); diff --git a/auto-listing-facebook-marketplace/src/background.ts b/auto-listing-facebook-marketplace/src/background.ts index 634b5ed..202336e 100644 --- a/auto-listing-facebook-marketplace/src/background.ts +++ b/auto-listing-facebook-marketplace/src/background.ts @@ -18,7 +18,7 @@ chrome.runtime.onConnect.addListener((port) => { evtSource.onmessage = (event) => { const data = JSON.parse(event.data); console.log("New event:", data); - queue.add(() => handlePublish(data)); + queue.add(() => handlePublish(data, 30000)); }; evtSource.onerror = (err) => { @@ -27,7 +27,7 @@ chrome.runtime.onConnect.addListener((port) => { })(); // eslint-disable-next-line @typescript-eslint/no-explicit-any -async function handlePublish(data: any) { +async function handlePublish(data: any, timeoutMs = 5 * 60 * 1000) { return new Promise((resolve) => { chrome.tabs.create( { url: "https://www.facebook.com/marketplace/create/item", active: true }, @@ -35,6 +35,16 @@ async function handlePublish(data: any) { if (!tab?.id) return resolve(); const tabId = tab.id; + let resolved = false; + const cleanup = () => { + if (resolved) return; + resolved = true; + chrome.runtime.onConnect.removeListener(onConnectListener); + chrome.tabs.onRemoved.removeListener(onTabClosed); + clearTimeout(timeoutId); + resolve(); + }; + const onConnectListener = (port: chrome.runtime.Port) => { if (port.sender?.tab?.id === tabId) { port.postMessage({ type: "publist-event", payload: data }); @@ -45,11 +55,17 @@ async function handlePublish(data: any) { const onTabClosed = (closedTabId: number) => { if (closedTabId === tabId) { - chrome.tabs.onRemoved.removeListener(onTabClosed); - resolve(); // Chỉ resolve khi tab này đã đóng + cleanup(); } }; chrome.tabs.onRemoved.addListener(onTabClosed); + + // Timeout tùy chỉnh + const timeoutId = setTimeout(() => { + console.warn(`Tab ${tabId} timeout (${timeoutMs}ms) - auto resolve`); + if (tabId) chrome.tabs.remove(tabId); + cleanup(); + }, timeoutMs); } ); }); diff --git a/auto-listing-facebook-marketplace/src/content.ts b/auto-listing-facebook-marketplace/src/content.ts index 2d1e663..10800b6 100644 --- a/auto-listing-facebook-marketplace/src/content.ts +++ b/auto-listing-facebook-marketplace/src/content.ts @@ -11,10 +11,16 @@ const selectors = { "/html/body/div[1]/div/div[1]/div/div[3]/div/div/div[1]/div[1]/div[1]/div/div[3]/div[1]/div[2]/div/div/div[6]/div/div/div/label/div/input", brand_input: "/html/body/div[1]/div/div[1]/div/div[3]/div/div/div[1]/div[1]/div[1]/div/div[3]/div[1]/div[2]/div/div/div[9]/div/div/div[2]/div/div/div/label/div/input", + brand_input_fallback: + "/html/body/div[1]/div/div[1]/div/div[3]/div/div/div[1]/div[1]/div[1]/div/div[3]/div[1]/div[2]/div/div/div[10]/div/div/div[2]/div/div/div/label/div/input", description_input: "/html/body/div[1]/div/div[1]/div/div[3]/div/div/div[1]/div[1]/div[1]/div/div[3]/div[1]/div[2]/div/div/div[9]/div/div/div[3]/div/div/div/label/div/div/textarea", + description_input_falback: + "/html/body/div[1]/div/div[1]/div/div[3]/div/div/div[1]/div[1]/div[1]/div/div[3]/div[1]/div[2]/div/div/div[10]/div/div/div[3]/div/div/div/label/div/div/textarea", sku_input: "/html/body/div[1]/div/div[1]/div/div[3]/div/div/div[1]/div[1]/div[1]/div/div[3]/div[1]/div[2]/div/div/div[9]/div/div/div[6]/div/div/div[1]/label/div/input", + sku_input_fallback: + "/html/body/div[1]/div/div[1]/div/div[3]/div/div/div[1]/div[1]/div[1]/div/div[3]/div[1]/div[2]/div/div/div[10]/div/div/div[6]/div/div/div[1]/label/div/input", category_select: { wraper: "/html/body/div[1]/div/div[1]/div/div[3]/div/div/div[1]/div[1]/div[1]/div/div[3]/div[1]/div[2]/div/div/div[7]/div/div/div/div", @@ -30,6 +36,8 @@ const selectors = { tags_input: { input: "/html/body/div[1]/div/div[1]/div/div[3]/div/div/div[1]/div[1]/div[1]/div/div[3]/div[1]/div[2]/div/div/div[9]/div/div/div[5]/div/div/div/div[1]/label/div/div/div[2]/div/textarea", + input_falback: + "/html/body/div[1]/div/div[1]/div/div[3]/div/div/div[1]/div[1]/div[1]/div/div[3]/div[1]/div[2]/div/div/div[10]/div/div/div[5]/div/div/div/div[1]/label/div/div/div[2]/div/textarea", plus_btn: "/html/body/div[1]/div/div[1]/div/div[3]/div/div/div[1]/div[1]/div[1]/div/div[3]/div[1]/div[2]/div/div/div[9]/div/div/div[5]/div/div/div/div[1]/label/div/div/div[2]/div[2]", }, @@ -37,10 +45,14 @@ const selectors = { location_select: { input: "/html/body/div[1]/div/div[1]/div/div[3]/div/div/div[1]/div[1]/div[1]/div/div[3]/div[1]/div[2]/div/div/div[9]/div/div/div[7]/div/div/div/div/div/div/div/div/label/div[2]/input", + input_fallback: + "/html/body/div[1]/div/div[1]/div/div[3]/div/div/div[1]/div[1]/div[1]/div/div[3]/div[1]/div[2]/div/div/div[10]/div/div/div[7]/div/div/div/div/div/div/div/div/label/div[2]/input", wraper: "/html/body/div[1]/div/div[1]/div/div[3]/div/div/div[1]/div[1]/div[1]/div/div[3]/div[1]/div[2]/div/div/div[9]/div/div/div[7]/div/div/div/div/div/div/div/div", container: "/html/body/div[1]/div/div[1]/div/div[3]/div/div/div[2]/div/div/div[1]/div[1]/div/ul", + container_fallback: + "/html/body/div[1]/div/div[1]/div/div[3]/div/div/div[2]/div/div/div[1]/div[1]/div/ul", }, next_btn: "/html/body/div[1]/div/div[1]/div/div[3]/div/div/div[1]/div[1]/div[1]/div/div[5]/div/div/div", @@ -48,31 +60,31 @@ const selectors = { "/html/body/div[1]/div/div[1]/div/div[3]/div/div/div[1]/div[1]/div[1]/div/div[4]/div[2]/div/div", }; -const getData = async () => { - return new Promise((rev, rej) => { - const url = chrome.runtime.getURL("data.json"); +// const getData = async () => { +// return new Promise((rev, rej) => { +// const url = chrome.runtime.getURL("data.json"); - fetch(url) - .then((res) => res.json()) - .then((data) => { - rev(data as IItem[]); - }) - .catch((err) => { - rej(err); - }); - }); -}; +// fetch(url) +// .then((res) => res.json()) +// .then((data) => { +// rev(data as IItem[]); +// }) +// .catch((err) => { +// rej(err); +// }); +// }); +// }; const uploadImages = async (item: IItem) => { // Tạo DataTransfer để giả lập FileList const dt: DataTransfer = new DataTransfer(); for (const image of item.images) { - // const base64 = await thiefService.imageLocalToBase64(image); + const base64 = await thiefService.imageUrlToBase64(image); console.log("Base64:", image.slice(0, 50) + "..."); const file = thiefService.base64ToFile( - image, + base64, item.sku, thiefService.getImageExtension(image) || "jpg" ); @@ -106,15 +118,17 @@ const chooseSelect = async ( thiefService.scrollToElement(el); thiefService.clickByPoint(el); - await delay(400); + await delay(200); const container = await thiefService.getElementByXPath(xpaths.container); if (!container) throw new Error("Container xpath not found"); // Tìm phần tử con có nội dung giống value - const matchingChild = Array.from(container.children).find( - (child) => - child.textContent?.trim().toLocaleLowerCase() === - value.toLocaleLowerCase() + const matchingChild = Array.from(container.children).find((child) => + child.textContent + ?.trim() + .toLocaleLowerCase() + .replace(/–/g, "-") + .includes(value.toLocaleLowerCase()) ) as HTMLElement | undefined; if (!matchingChild) throw new Error(`No child found with text "${value}"`); @@ -127,13 +141,24 @@ const chooseSelect = async ( const chooseLocation = async ( value: string, - { input, ...xpaths }: { wraper: string; container: string; input: string } + { + input, + ...xpaths + }: { + wraper: string; + container: string; + container_fallback?: string; + input: string; + input_fallback?: string; + } ) => { - await thiefService.writeToInput(value, input); + await thiefService.writeToInput(value, input, xpaths.input_fallback); - await delay(400); + await delay(200); - const container = await thiefService.getElementByXPath(xpaths.container); + const container = await thiefService.getElementByXPath(xpaths.container, { + xpathFallback: xpaths.container_fallback, + }); if (!container) throw new Error("Container xpath not found"); thiefService.scrollToElement(container); @@ -156,9 +181,11 @@ const chooseLocation = async ( const writeTags = async ( tags: string[], - xpaths: { input: string; plus_btn: string } + xpaths: { input: string; input_falback?: string; plus_btn: string } ) => { - const input = await thiefService.getElementByXPath(xpaths.input); + const input = await thiefService.getElementByXPath(xpaths.input, { + xpathFallback: xpaths?.input_falback, + }); if (!input) throw new Error("Input is not found"); @@ -166,7 +193,7 @@ const writeTags = async ( await delay(200); for (const tag of tags) { - thiefService.writeToInput(tag, xpaths.input); + await thiefService.writeToInput(tag, xpaths.input, xpaths?.input_falback); await delay(200); @@ -218,60 +245,72 @@ const handle = async (item: IItem) => { // B1. Upload images await uploadImages(item); - await delay(400); + await delay(200); // B2. Write title thiefService.writeToInput(item.title, selectors.title_input); - await delay(400); + await delay(200); // B3. Write price thiefService.writeToInput(String(item.price), selectors.price_input); - await delay(400); + await delay(200); // B4. Select category await chooseSelect(item.category, selectors.category_select); - await delay(400); + await delay(200); // B5. Select condition await chooseSelect(item.condition, selectors.condition_select); if (item.brand) { - await delay(400); - // B3. Write price - thiefService.writeToInput(item.brand, selectors.brand_input); + await delay(200); + // B6. Write brand + await thiefService.writeToInput( + item.brand, + selectors.brand_input, + selectors.brand_input_fallback + ); } - await delay(400); - // B3. Write price + await delay(200); + // B7. Write description await thiefService.writeToInput( item.description, - selectors.description_input + selectors.description_input, + selectors.description_input_falback ); - await delay(400); + await delay(200); await writeTags(item.tags, selectors.tags_input); - await delay(400); - // B3. Write price - thiefService.writeToInput(item.sku, selectors.sku_input); + await delay(200); + // B8. Write sku + await thiefService.writeToInput( + item.sku, + selectors.sku_input, + selectors.sku_input_fallback + ); if (item?.location) { - await delay(400); + await delay(200); await chooseLocation(item.location, selectors.location_select); } - await delay(400); + await delay(200); await clickNext(); - // await delay(400); + if (import.meta.env.ENV === "prod") { + await delay(200); + await clickPublist(); + } return true; }; const closeTab = async (data: IItem) => { - await delay(2000); + await delay(1000); chrome.runtime.sendMessage({ type: "close-tab", @@ -292,7 +331,7 @@ port.onMessage.addListener(async (message) => { // data.images = ["images/1.png", "images/2.png"]; try { - await delay(2000); + await delay(500); await handle(data); } catch (error) { await finistPublist(data, { @@ -306,3 +345,15 @@ port.onMessage.addListener(async (message) => { } } }); + +// async function init() { +// const { data } = await axios.get("products/27"); + +// if (!data.data) return; + +// const item = data.data as IItem; + +// await handle(item); +// } + +// init(); diff --git a/auto-listing-facebook-marketplace/src/services/thief.service.ts b/auto-listing-facebook-marketplace/src/services/thief.service.ts index c429641..86010f2 100644 --- a/auto-listing-facebook-marketplace/src/services/thief.service.ts +++ b/auto-listing-facebook-marketplace/src/services/thief.service.ts @@ -34,15 +34,19 @@ class ThiefService { async getElementByXPath( xpath: string, - retryCount: number = 3, - delay: number = 400 + { + retryCount = 2, + delay = 100, + xpathFallback, + }: { retryCount?: number; delay?: number; xpathFallback?: string } = {} ): Promise { return new Promise((resolve) => { let attempts = 0; + let usingFallback = false; const tryFind = () => { const el: Node | null = document.evaluate( - xpath, + usingFallback && xpathFallback ? xpathFallback : xpath, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, @@ -58,7 +62,13 @@ class ThiefService { if (attempts < retryCount) { setTimeout(tryFind, delay); } else { - resolve(null); + if (!usingFallback && xpathFallback) { + usingFallback = true; + attempts = 0; + setTimeout(tryFind, delay); + } else { + resolve(null); + } } }; @@ -151,8 +161,14 @@ class ThiefService { el.dispatchEvent(new Event("change", { bubbles: true })); } - writeToInput = async (value: string, xpath: string) => { - const el = (await this.getElementByXPath(xpath)) as HTMLInputElement; + writeToInput = async ( + value: string, + xpath: string, + xpathFallback?: string + ) => { + const el = (await this.getElementByXPath(xpath, { + xpathFallback, + })) as HTMLInputElement; if (!el) throw new Error("Xpath is not found with value: " + value); diff --git a/client/app/components/core/data-table.tsx b/client/app/components/core/data-table.tsx index 1cb1335..7878974 100644 --- a/client/app/components/core/data-table.tsx +++ b/client/app/components/core/data-table.tsx @@ -1673,7 +1673,7 @@ export function DataTable>({
handleSearchChange(e.target.value)} onKeyPress={handleSearchKeyPress} diff --git a/client/app/routes/products/components/modals/product-modal.tsx b/client/app/routes/products/components/modals/product-modal.tsx index f3ee4a4..9bff7d5 100644 --- a/client/app/routes/products/components/modals/product-modal.tsx +++ b/client/app/routes/products/components/modals/product-modal.tsx @@ -98,6 +98,7 @@ export default function ProductModal({ const watchedTags = form.watch("tags"); const conditions = ["New", "Used - like new", "Used - good", "Used - fair"]; + const categories = ["Tools"]; const handleImageUpload = (e: React.ChangeEvent) => { const files = e.target.files; @@ -356,7 +357,23 @@ export default function ProductModal({ Category * - + {/* */} + + @@ -379,7 +396,7 @@ export default function ProductModal({ {conditions.map((c) => ( - + {c} ))} diff --git a/client/app/routes/products/list.tsx b/client/app/routes/products/list.tsx index 07e46ab..3d4eec0 100644 --- a/client/app/routes/products/list.tsx +++ b/client/app/routes/products/list.tsx @@ -4,6 +4,7 @@ import { useMutation, useQuery } from "@tanstack/react-query"; import _ from "lodash"; import { Archive, + Check, Download, HistoryIcon, Plus, @@ -12,6 +13,7 @@ import { Trash2, UploadCloud, UserPlus, + X, } from "lucide-react"; import { useEffect, useMemo, useRef, useState } from "react"; import { useSearchParams } from "react-router"; @@ -119,6 +121,11 @@ export default function List() { ); }, }, + { + key: "condition", + label: "Condition", + displayType: "badge", + }, { key: "brand", label: "Brand", @@ -135,6 +142,26 @@ export default function List() { displayType: "datetime", sortable: true, }, + { + key: "histories", + label: "Published", + displayType: "custom", + render(value, row) { + return ( +
+ {row.histories.some((item) => item.published) ? ( + + ) : ( + + )} +
+ ); + }, + }, ]; const filterOptions: FilterOption[] = [ @@ -144,9 +171,19 @@ export default function List() { type: "text" as const, }, { - key: "created_at", - label: "Created at", - type: "dateRange" as const, + key: "sku", + label: "Sku", + type: "text" as const, + }, + { + key: "description", + label: "Description", + type: "text" as const, + }, + { + key: "title", + label: "Title", + type: "text" as const, }, ]; @@ -158,7 +195,7 @@ export default function List() { variant: "destructive" as const, action: handleBulkDelete, confirmMessage: - "Are you sure you want to delete the selected users? This action cannot be undone.", + "Are you sure you want to delete the selected products? This action cannot be undone.", }, ]; @@ -232,7 +269,7 @@ export default function List() { publistMutation.mutateAsync(data), // gọi function để trả về promise { loading: "Loading...", - success: (result) => `${result.name} toast has been added`, + success: (result) => `${data?.title} toast has been added`, error: "Error", } ); diff --git a/server/package-lock.json b/server/package-lock.json index 2b63613..b8ebb71 100644 --- a/server/package-lock.json +++ b/server/package-lock.json @@ -21,12 +21,14 @@ "@nestjs/platform-express": "^11.1.5", "@nestjs/throttler": "^6.4.0", "@nestjs/typeorm": "^11.0.0", + "axios": "^1.11.0", "bcrypt": "^6.0.0", "cache-manager": "^7.0.1", "cacheable": "^1.10.2", "class-transformer": "^0.5.1", "class-validator": "^0.14.2", "cookie-parser": "^1.4.7", + "file-type": "^21.0.0", "helmet": "^8.1.0", "image-size": "^2.0.2", "lodash": "^4.17.21", @@ -5202,7 +5204,6 @@ "version": "0.4.0", "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==", - "dev": true, "license": "MIT" }, "node_modules/atomic-sleep": { @@ -5226,6 +5227,17 @@ "fastq": "^1.17.1" } }, + "node_modules/axios": { + "version": "1.11.0", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.11.0.tgz", + "integrity": "sha512-1Lx3WLFQWm3ooKDYZD1eXmoGO9fxYQjrycfHFC8P0sCfQVXyROp0p9PFWBehewBOdCwHc+f/b8I0fMto5eSfwA==", + "license": "MIT", + "dependencies": { + "follow-redirects": "^1.15.6", + "form-data": "^4.0.4", + "proxy-from-env": "^1.1.0" + } + }, "node_modules/b4a": { "version": "1.6.7", "resolved": "https://registry.npmjs.org/b4a/-/b4a-1.6.7.tgz", @@ -6012,7 +6024,6 @@ "version": "1.0.8", "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", - "dev": true, "license": "MIT", "dependencies": { "delayed-stream": "~1.0.0" @@ -6363,7 +6374,6 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", - "dev": true, "license": "MIT", "engines": { "node": ">=0.4.0" @@ -6618,7 +6628,6 @@ "version": "2.1.0", "resolved": "https://registry.npmjs.org/es-set-tostringtag/-/es-set-tostringtag-2.1.0.tgz", "integrity": "sha512-j6vWzfrGVfyXxge+O0x5sh6cvxAog0a/4Rdd2K36zCMV5eJ+/+tOAngRO8cODMNWbVRdVlmGZQL2YS3yR8bIUA==", - "dev": true, "license": "MIT", "dependencies": { "es-errors": "^1.3.0", @@ -7488,6 +7497,26 @@ "dev": true, "license": "ISC" }, + "node_modules/follow-redirects": { + "version": "1.15.11", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.11.tgz", + "integrity": "sha512-deG2P0JfjrTxl50XGCDyfI97ZGVCxIpfKYmfyrQ54n5FO/0gfIES8C/Psl6kWVDolizcaaxZJnTS0QSMxvnsBQ==", + "funding": [ + { + "type": "individual", + "url": "https://github.com/sponsors/RubenVerborgh" + } + ], + "license": "MIT", + "engines": { + "node": ">=4.0" + }, + "peerDependenciesMeta": { + "debug": { + "optional": true + } + } + }, "node_modules/foreground-child": { "version": "3.3.1", "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-3.3.1.tgz", @@ -7533,10 +7562,9 @@ } }, "node_modules/form-data": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.3.tgz", - "integrity": "sha512-qsITQPfmvMOSAdeyZ+12I1c+CKSstAFAwu+97zrnWAbIr5u8wfsExUzCesVLC8NgHuRUqNN4Zy6UPWUTRGslcA==", - "dev": true, + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.4.tgz", + "integrity": "sha512-KrGhL9Q4zjj0kiUt5OO4Mr/A/jlI2jDYs5eHBpYHPcBEVSiipAvn2Ko2HnPe20rmcuuvMHNdZFp+4IlGTMF0Ow==", "license": "MIT", "dependencies": { "asynckit": "^0.4.0", @@ -7563,7 +7591,6 @@ "version": "1.52.0", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", - "dev": true, "license": "MIT", "engines": { "node": ">= 0.6" @@ -7573,7 +7600,6 @@ "version": "2.1.35", "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", - "dev": true, "license": "MIT", "dependencies": { "mime-db": "1.52.0" @@ -7911,7 +7937,6 @@ "version": "1.0.2", "resolved": "https://registry.npmjs.org/has-tostringtag/-/has-tostringtag-1.0.2.tgz", "integrity": "sha512-NqADB8VjPFLM2V0VvHUewwwsw0ZWBaIdgo+ieHtK3hasLz4qeCRjYcqfB6AQrBggRKppKF8L52/VqdVsO47Dlw==", - "dev": true, "license": "MIT", "dependencies": { "has-symbols": "^1.0.3" @@ -10716,6 +10741,12 @@ "node": ">= 0.10" } }, + "node_modules/proxy-from-env": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", + "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==", + "license": "MIT" + }, "node_modules/punycode": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", diff --git a/server/package.json b/server/package.json index 9190f7e..0b55672 100644 --- a/server/package.json +++ b/server/package.json @@ -37,12 +37,14 @@ "@nestjs/platform-express": "^11.1.5", "@nestjs/throttler": "^6.4.0", "@nestjs/typeorm": "^11.0.0", + "axios": "^1.11.0", "bcrypt": "^6.0.0", "cache-manager": "^7.0.1", "cacheable": "^1.10.2", "class-transformer": "^0.5.1", "class-validator": "^0.14.2", "cookie-parser": "^1.4.7", + "file-type": "^21.0.0", "helmet": "^8.1.0", "image-size": "^2.0.2", "lodash": "^4.17.21", diff --git a/server/public/medias/products/ewwgwegew/product-1754970446337.png b/server/public/medias/products/ewwgwegew/product-1754970446337.png deleted file mode 100644 index fa72e2e..0000000 Binary files a/server/public/medias/products/ewwgwegew/product-1754970446337.png and /dev/null differ diff --git a/server/public/medias/products/ewwgwegew/product-1754970446343.png b/server/public/medias/products/ewwgwegew/product-1754970446343.png deleted file mode 100644 index 6d59e9b..0000000 Binary files a/server/public/medias/products/ewwgwegew/product-1754970446343.png and /dev/null differ diff --git a/server/public/medias/products/gewgwegewewg/product-1755066754690.png b/server/public/medias/products/gewgwegewewg/product-1755066754690.png new file mode 100644 index 0000000..a1e48aa Binary files /dev/null and b/server/public/medias/products/gewgwegewewg/product-1755066754690.png differ diff --git a/server/public/medias/products/gwegwgwegewgew/product-1754988109416.png b/server/public/medias/products/gwegwgwegewgew/product-1754988109416.png deleted file mode 100644 index 6d59e9b..0000000 Binary files a/server/public/medias/products/gwegwgwegewgew/product-1754988109416.png and /dev/null differ diff --git a/server/public/medias/products/tesstsees/product-1754961983572.png b/server/public/medias/products/tesstsees/product-1754961983572.png deleted file mode 100644 index 6d59e9b..0000000 Binary files a/server/public/medias/products/tesstsees/product-1754961983572.png and /dev/null differ diff --git a/server/public/medias/products/tesstsees/product-1754961983579.png b/server/public/medias/products/tesstsees/product-1754961983579.png deleted file mode 100644 index 8772d49..0000000 Binary files a/server/public/medias/products/tesstsees/product-1754961983579.png and /dev/null differ diff --git a/server/public/medias/products/testessse/product-1755066484846.png b/server/public/medias/products/testessse/product-1755066484846.png new file mode 100644 index 0000000..6f25e90 Binary files /dev/null and b/server/public/medias/products/testessse/product-1755066484846.png differ diff --git a/server/public/medias/products/testssss/product-1755065436688.png b/server/public/medias/products/testssss/product-1755065436688.png new file mode 100644 index 0000000..ac45bee Binary files /dev/null and b/server/public/medias/products/testssss/product-1755065436688.png differ diff --git a/server/public/medias/products/testssss/product-1755065436701.png b/server/public/medias/products/testssss/product-1755065436701.png new file mode 100644 index 0000000..b174a9b Binary files /dev/null and b/server/public/medias/products/testssss/product-1755065436701.png differ diff --git a/server/public/medias/products/wegwegwe/product-1754987864481.png b/server/public/medias/products/wegwegwe/product-1754987864481.png deleted file mode 100644 index 8772d49..0000000 Binary files a/server/public/medias/products/wegwegwe/product-1754987864481.png and /dev/null differ diff --git a/server/public/medias/products/wegwegwe/product-1754987864493.png b/server/public/medias/products/wegwegwe/product-1754987864493.png deleted file mode 100644 index cd0fd11..0000000 Binary files a/server/public/medias/products/wegwegwe/product-1754987864493.png and /dev/null differ diff --git a/server/public/medias/products/wegwegwegw/product-1754988224001.png b/server/public/medias/products/wegwegwegw/product-1754988224001.png deleted file mode 100644 index 7b620cf..0000000 Binary files a/server/public/medias/products/wegwegwegw/product-1754988224001.png and /dev/null differ diff --git a/server/public/medias/products/wegwegwewe/product-1755067588211.png b/server/public/medias/products/wegwegwewe/product-1755067588211.png new file mode 100644 index 0000000..b338f16 Binary files /dev/null and b/server/public/medias/products/wegwegwewe/product-1755067588211.png differ diff --git a/server/public/medias/products/wegwgwegwe/product-1754970566003.png b/server/public/medias/products/wegwgwegwe/product-1754970566003.png deleted file mode 100644 index cd0fd11..0000000 Binary files a/server/public/medias/products/wegwgwegwe/product-1754970566003.png and /dev/null differ diff --git a/server/public/medias/products/wgwgwegwe/product-1755047952582.png b/server/public/medias/products/wgwgwegwe/product-1755047952582.png new file mode 100644 index 0000000..2735d7a Binary files /dev/null and b/server/public/medias/products/wgwgwegwe/product-1755047952582.png differ diff --git a/server/public/medias/products/wqfqwfqwfq/product-1754902919876.png b/server/public/medias/products/wqfqwfqwfq/product-1754902919876.png deleted file mode 100644 index cd0fd11..0000000 Binary files a/server/public/medias/products/wqfqwfqwfq/product-1754902919876.png and /dev/null differ diff --git a/server/src/modules/medias/medias.service.ts b/server/src/modules/medias/medias.service.ts index cd7b9d4..382a902 100644 --- a/server/src/modules/medias/medias.service.ts +++ b/server/src/modules/medias/medias.service.ts @@ -3,7 +3,8 @@ import { writeFile } from 'fs/promises'; import * as fs from 'fs'; import * as path from 'path'; import sizeOf from 'image-size'; - +import { promises } from 'fs'; +import axios from 'axios'; @Injectable() export class MediasService { private ROOT_MEDIA_FOLDER = './public'; @@ -75,11 +76,97 @@ export class MediasService { }; } - async removeAvatar(avatar: string): Promise { - if (!avatar) return; + async saveBufferImage( + buffer: Buffer, + filenamePrefix = 'image', + folder: string, + maxSizeInMB = 2, + mimeType: string = 'png', + ): Promise<{ + filename: string; + filepath: string; + url: string; + mimetype: string; + width?: number; + height?: number; + sizeInKB: number; + }> { + const sizeInBytes = buffer.length; + const sizeInMB = sizeInBytes / (1024 * 1024); + if (sizeInMB > maxSizeInMB) { + throw new BadRequestException(`Ảnh vượt quá giới hạn ${maxSizeInMB}MB`); + } + const sizeInKB = Math.round(sizeInBytes / 1024); - // Luôn xử lý path bắt đầu từ 'medias/avatars' - const relativePath = path.join('medias/avatars', avatar); // ✅ chính xác từ input: khangpn/avatar-xxx.jpg + // Tạo thư mục nếu chưa có + const fullPath = path.join(this.ROOT_MEDIA_FOLDER, folder); + if (!fs.existsSync(fullPath)) { + await promises.mkdir(fullPath, { recursive: true }); + } + + // Tạo tên file + const fileNameOnly = `${filenamePrefix}-${Date.now()}.${mimeType}`; + const filepath = path.join(fullPath, fileNameOnly); + + // Ghi file + await writeFile(filepath, buffer); + + // Lấy kích thước ảnh + let dimensions: { width?: number; height?: number } = {}; + try { + dimensions = sizeOf(buffer); + } catch (_) { + // Không lấy được kích thước thì thôi + } + + // Tạo url tương đối (giả sử serve public tại /uploads) + const relativeUrl = path.join(folder, fileNameOnly).replace(/\\/g, '/'); + + return { + filename: fileNameOnly, + filepath, + url: `/uploads/${relativeUrl}`, + mimetype: mimeType, + sizeInKB, + width: dimensions.width, + height: dimensions.height, + }; + } + + async downloadImageAndSave( + url: string, + folder: string, + path: string, + ): Promise<{ + filename: string; + filepath: string; + url: string; + mimetype: string; + width?: number; + height?: number; + sizeInKB: number; + }> { + try { + const response = await axios.get(url, { + responseType: 'arraybuffer', + }); + + const buffer = Buffer.from(response.data); + + const filename = await this.saveBufferImage(buffer, folder, path); + + return filename; + } catch (error) { + console.warn('Failed to download image:', url, error); + throw error; + } + } + + async removeMediasFolder(filepath: string, folder: string): Promise { + if (!filepath) return; + + // Luôn xử lý path bắt đầu từ 'medias/filepaths' + const relativePath = path.join('medias/' + folder, filepath); // ✅ chính xác từ input: khangpn/avatar-xxx.jpg const fullPath = path.join(this.ROOT_MEDIA_FOLDER, relativePath); const rootPath = path.resolve(this.ROOT_MEDIA_FOLDER); diff --git a/server/src/modules/products/products.service.ts b/server/src/modules/products/products.service.ts index 9bc664a..3ea9dfa 100644 --- a/server/src/modules/products/products.service.ts +++ b/server/src/modules/products/products.service.ts @@ -1,22 +1,24 @@ import { Product } from '@/entities/product.entity'; +import { PublistHistory } from '@/entities/publist-history.entity'; import CoreService from '@/system/core/core-service'; import { SystemLang } from '@/system/lang/system.lang'; import AppResponse from '@/system/response/ktq-response'; +import { urlToBase64 } from '@/ultils/fn'; import { BadRequestException, Injectable, NotFoundException, } from '@nestjs/common'; import { InjectRepository } from '@nestjs/typeorm'; +import { plainToClass } from 'class-transformer'; +import { isURL } from 'class-validator'; import { fromEvent, map, Observable } from 'rxjs'; import { Repository } from 'typeorm'; import { EventsService } from '../events/events.service'; import { MediasService } from '../medias/medias.service'; import { CreateProductDto } from './dtos/create-product.dto'; import { PublistFinishDto } from './dtos/publist-finish.dto'; -import { PublistHistory } from '@/entities/publist-history.entity'; -import { plainToClass } from 'class-transformer'; -import { urlToBase64 } from '@/ultils/fn'; +import { Request } from 'express'; @Injectable() export class ProductsService extends CoreService { @@ -36,10 +38,14 @@ export class ProductsService extends CoreService { super( repo, { - sortableColumns: ['id'], + sortableColumns: ['id', 'description', 'title', 'sku', 'created_at'], defaultSortBy: [['id', 'DESC']], filterableColumns: { id: true, + description: true, + title: true, + sku: true, + created_at: true, }, relations: { histories: true, @@ -49,20 +55,48 @@ export class ProductsService extends CoreService { ); } + protected async afterDelete( + id: number, + data: Partial, + req: Request, + ): Promise { + // Xóa avatar nếu có + if (data.images?.length) { + for (const image of data.images) { + await this.mediasService.removeMediasFolder( + `${data.title.toLowerCase().replaceAll(' ', '-')}/${image}` as string, + 'products', + ); + } + } + } + async create(data: CreateProductDto): Promise { - // Tạo entity từ DTO const product = this.repo.create(data); - if (data.images && data.images.some((image) => image.startsWith('data'))) { + if (data.images && data.images.length) { const newImages = []; - for (const image of data.images) { - const result = await this.mediasService.saveBase64Image( - image as string, - 'product', - `medias/products/${data.title.toLowerCase().replaceAll(' ', '-')}`, - ); - newImages.push(result.filename); + for (const image of data.images) { + if (image.startsWith('data:')) { + const result = await this.mediasService.saveBase64Image( + image, + 'product', + `medias/products/${data.title.toLowerCase().replaceAll(' ', '-')}`, + ); + newImages.push(result.filename); + } else if ( + isURL(image, { require_host: true, require_protocol: true }) + ) { + const result = await this.mediasService.downloadImageAndSave( + image, + 'product', + `medias/products/${data.title.toLowerCase().replaceAll(' ', '-')}`, + ); + newImages.push(result.filename); + } else { + newImages.push(image); + } } if (newImages.length) { @@ -70,7 +104,6 @@ export class ProductsService extends CoreService { } } - // Lưu vào database await this.repo.save(product); return AppResponse.toResponse(product); diff --git a/server/src/modules/users/users.service.ts b/server/src/modules/users/users.service.ts index bdf0bdd..ddbf598 100644 --- a/server/src/modules/users/users.service.ts +++ b/server/src/modules/users/users.service.ts @@ -187,8 +187,9 @@ export class UsersService extends CoreService { if (entity.avatar) { // Nếu đã có avatar cũ, xóa avatar cũ - await this.mediasService.removeAvatar( + await this.mediasService.removeMediasFolder( `${entity.username}/${entity.avatar}` as string, + 'avatars', ); } } @@ -203,8 +204,9 @@ export class UsersService extends CoreService { ): Promise { // Nếu avatar được cập nhật thành null, xóa avatar cũ if (entity.avatar && dataUpdate.avatar === null) { - await this.mediasService.removeAvatar( + await this.mediasService.removeMediasFolder( `${entity.username}/${entity.avatar}` as string, + 'avatars', ); } @@ -324,8 +326,9 @@ export class UsersService extends CoreService { protected async afterDelete(id: number, data: Partial, req?: Request) { // Xóa avatar nếu có if (data.avatar) { - await this.mediasService.removeAvatar( + await this.mediasService.removeMediasFolder( `${data.username}/${data.avatar}` as string, + 'avatars', ); } @@ -340,8 +343,9 @@ export class UsersService extends CoreService { // Xóa avatar của tất cả người dùng bị xóa for (const user of data) { if (user.avatar) { - await this.mediasService.removeAvatar( + await this.mediasService.removeMediasFolder( `${user.username}/${user.avatar}` as string, + 'avatars', ); } }