listing-facebook/auto-listing-facebook-marke.../auto-listing-facebook-marke.../content.js

7 lines
45 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

function Ne(e,t){return function(){return e.apply(t,arguments)}}const{toString:rt}=Object.prototype,{getPrototypeOf:fe}=Object,{iterator:G,toStringTag:Le}=Symbol,Z=(e=>t=>{const n=rt.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 ot(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 st(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&Be(e.buffer),t}const at=Q("string"),x=Q("function"),Fe=Q("number"),Y=e=>e!==null&&typeof e=="object",dt=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)},ct=P("Date"),lt=P("File"),ut=P("Blob"),ft=P("FileList"),pt=e=>Y(e)&&x(e.pipe),vt=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]"))},ht=P("URLSearchParams"),[mt,wt,yt,bt]=["ReadableStream","Request","Response","Headers"].map(P),Et=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;i<r;i++)t.call(null,e[i],i,e);else{const o=n?Object.getOwnPropertyNames(e):Object.keys(e),s=o.length;let d;for(i=0;i<s;i++)d=o[i],t.call(null,e[d],d,e)}}function Ue(e,t){t=t.toLowerCase();const n=Object.keys(e);let i=n.length,r;for(;i-- >0;)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,De=e=>!M(e)&&e!==F;function se(){const{caseless:e}=De(this)&&this||{},t={},n=(i,r)=>{const o=e&&Ue(t,r)||r;J(t[o])&&J(i)?t[o]=se(t[o],i):J(i)?t[o]=se({},i):j(i)?t[o]=i.slice():t[o]=i};for(let i=0,r=arguments.length;i<r;i++)arguments[i]&&H(arguments[i],n);return t}const gt=(e,t,n,{allOwnKeys:i}={})=>(H(t,(r,o)=>{n&&x(r)?e[o]=Ne(r,n):e[o]=r},{allOwnKeys:i}),e),Rt=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),St=(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)},Tt=(e,t,n,i)=>{let r,o,s;const d={};if(t=t||{},e==null)return t;do{for(r=Object.getOwnPropertyNames(e),o=r.length;o-- >0;)s=r[o],(!i||i(s,e,t))&&!d[s]&&(t[s]=e[s],d[s]=!0);e=n!==!1&&fe(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},At=(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},Ot=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},_t=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&fe(Uint8Array)),xt=(e,t)=>{const i=(e&&e[G]).call(e);let r;for(;(r=i.next())&&!r.done;){const o=r.value;t.call(e,o[0],o[1])}},Ct=(e,t)=>{let n;const i=[];for(;(n=e.exec(t))!==null;)i.push(n);return i},Pt=P("HTMLFormElement"),kt=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,i,r){return i.toUpperCase()+r}),we=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),Nt=P("RegExp"),je=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),i={};H(n,(r,o)=>{let s;(s=t(r,o,e))!==!1&&(i[o]=s||r)}),Object.defineProperties(e,i)},Lt=e=>{je(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+"'")})}})},Bt=(e,t)=>{const n={},i=r=>{r.forEach(o=>{n[o]=!0})};return j(e)?i(e):i(String(e).split(t)),n},Ft=()=>{},Ut=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function Dt(e){return!!(e&&x(e.append)&&e[Le]==="FormData"&&e[G])}const jt=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 o=j(i)?[]:{};return H(i,(s,d)=>{const u=n(s,r+1);!M(u)&&(o[d]=u)}),t[r]=void 0,o}}return i};return n(e,0)},qt=P("AsyncFunction"),It=e=>e&&(Y(e)||x(e))&&x(e.then)&&x(e.catch),qe=((e,t)=>e?setImmediate:t?((n,i)=>(F.addEventListener("message",({source:r,data:o})=>{r===F&&o===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)),Mt=typeof queueMicrotask<"u"?queueMicrotask.bind(F):typeof process<"u"&&process.nextTick||qe,Ht=e=>e!=null&&x(e[G]),a={isArray:j,isArrayBuffer:Be,isBuffer:ot,isFormData:vt,isArrayBufferView:st,isString:at,isNumber:Fe,isBoolean:dt,isObject:Y,isPlainObject:J,isReadableStream:mt,isRequest:wt,isResponse:yt,isHeaders:bt,isUndefined:M,isDate:ct,isFile:lt,isBlob:ut,isRegExp:Nt,isFunction:x,isStream:pt,isURLSearchParams:ht,isTypedArray:_t,isFileList:ft,forEach:H,merge:se,extend:gt,trim:Et,stripBOM:Rt,inherits:St,toFlatObject:Tt,kindOf:Z,kindOfTest:P,endsWith:At,toArray:Ot,forEachEntry:xt,matchAll:Ct,isHTMLForm:Pt,hasOwnProperty:we,hasOwnProp:we,reduceDescriptors:je,freezeMethods:Lt,toObjectSet:Bt,toCamelCase:kt,noop:Ft,toFiniteNumber:Ut,findKey:Ue,global:F,isContextDefined:De,isSpecCompliantForm:Dt,toJSONObject:jt,isAsyncFn:qt,isThenable:It,setImmediate:qe,asap:Mt,isIterable:Ht};function h(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(h,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=h.prototype,Me={};["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=>{Me[e]={value:e}});Object.defineProperties(h,Me);Object.defineProperty(Ie,"isAxiosError",{value:!0});h.from=(e,t,n,i,r,o)=>{const s=Object.create(Ie);return a.toFlatObject(e,s,function(u){return u!==Error.prototype},d=>d!=="isAxiosError"),h.call(s,e.message,t,n,i,r),s.cause=e,s.name=e.name,o&&Object.assign(s,o),s};const $t=null;function ae(e){return a.isPlainObject(e)||a.isArray(e)}function He(e){return a.endsWith(e,"[]")?e.slice(0,-2):e}function ye(e,t,n){return e?e.concat(t).map(function(r,o){return r=He(r),!n&&o?"["+r+"]":r}).join(n?".":""):t}function zt(e){return a.isArray(e)&&!e.some(ae)}const Jt=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,v){return!a.isUndefined(v[m])});const i=n.metaTokens,r=n.visitor||l,o=n.dots,s=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 h("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,v){let E=f;if(f&&!v&&typeof f=="object"){if(a.endsWith(m,"{}"))m=i?m:m.slice(0,-2),f=JSON.stringify(f);else if(a.isArray(f)&&zt(f)||(a.isFileList(f)||a.endsWith(m,"[]"))&&(E=a.toArray(f)))return m=He(m),E.forEach(function(T,N){!(a.isUndefined(T)||T===null)&&t.append(s===!0?ye([m],N,o):s===null?m:m+"[]",c(T))}),!1}return ae(f)?!0:(t.append(ye(v,m,o),c(f)),!1)}const p=[],y=Object.assign(Jt,{defaultVisitor:l,convertValue:c,isVisitable:ae});function R(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(E,S){(!(a.isUndefined(E)||E===null)&&r.call(t,E,a.isString(S)?S.trim():S,m,y))===!0&&R(E,m?m.concat(S):[S])}),p.pop()}}if(!a.isObject(e))throw new TypeError("data must be an object");return R(e),t}function be(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 $e=pe.prototype;$e.append=function(t,n){this._pairs.push([t,n])};$e.toString=function(t){const n=t?function(i){return t.call(this,i,be)}:be;return this._pairs.map(function(r){return n(r[0])+"="+n(r[1])},"").join("&")};function Vt(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function ze(e,t,n){if(!t)return e;const i=n&&n.encode||Vt;a.isFunction(n)&&(n={serialize:n});const r=n&&n.serialize;let o;if(r?o=r(t,n):o=a.isURLSearchParams(t)?t.toString():new pe(t,n).toString(i),o){const s=e.indexOf("#");s!==-1&&(e=e.slice(0,s)),e+=(e.indexOf("?")===-1?"?":"&")+o}return e}class Ee{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 Je={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},Xt=typeof URLSearchParams<"u"?URLSearchParams:pe,Kt=typeof FormData<"u"?FormData:null,Wt=typeof Blob<"u"?Blob:null,Gt={isBrowser:!0,classes:{URLSearchParams:Xt,FormData:Kt,Blob:Wt},protocols:["http","https","file","blob","url","data"]},ve=typeof window<"u"&&typeof document<"u",de=typeof navigator=="object"&&navigator||void 0,Zt=ve&&(!de||["ReactNative","NativeScript","NS"].indexOf(de.product)<0),Qt=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",Yt=ve&&window.location.href||"http://localhost",en=Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:ve,hasStandardBrowserEnv:Zt,hasStandardBrowserWebWorkerEnv:Qt,navigator:de,origin:Yt},Symbol.toStringTag,{value:"Module"})),O={...en,...Gt};function tn(e,t){return ee(e,new O.classes.URLSearchParams,Object.assign({visitor:function(n,i,r,o){return O.isNode&&a.isBuffer(n)?(this.append(i,n.toString("base64")),!1):o.defaultVisitor.apply(this,arguments)}},t))}function nn(e){return a.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function rn(e){const t={},n=Object.keys(e);let i;const r=n.length;let o;for(i=0;i<r;i++)o=n[i],t[o]=e[o];return t}function Ve(e){function t(n,i,r,o){let s=n[o++];if(s==="__proto__")return!0;const d=Number.isFinite(+s),u=o>=n.length;return s=!s&&a.isArray(r)?r.length:s,u?(a.hasOwnProp(r,s)?r[s]=[r[s],i]:r[s]=i,!d):((!r[s]||!a.isObject(r[s]))&&(r[s]=[]),t(n,i,r[s],o)&&a.isArray(r[s])&&(r[s]=rn(r[s])),!d)}if(a.isFormData(e)&&a.isFunction(e.entries)){const n={};return a.forEachEntry(e,(i,r)=>{t(nn(i),r,n,0)}),n}return null}function on(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:Je,adapter:["xhr","http","fetch"],transformRequest:[function(t,n){const i=n.getContentType()||"",r=i.indexOf("application/json")>-1,o=a.isObject(t);if(o&&a.isHTMLForm(t)&&(t=new FormData(t)),a.isFormData(t))return r?JSON.stringify(Ve(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(o){if(i.indexOf("application/x-www-form-urlencoded")>-1)return tn(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 o||r?(n.setContentType("application/json",!1),on(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 s=!(n&&n.silentJSONParsing)&&r;try{return JSON.parse(t)}catch(d){if(s)throw d.name==="SyntaxError"?h.from(d,h.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 sn=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"]),an=e=>{const t={};let n,i,r;return e&&e.split(`
`).forEach(function(s){r=s.indexOf(":"),n=s.substring(0,r).trim().toLowerCase(),i=s.substring(r+1).trim(),!(!n||t[n]&&sn[n])&&(n==="set-cookie"?t[n]?t[n].push(i):t[n]=[i]:t[n]=t[n]?t[n]+", "+i:i)}),t},ge=Symbol("internals");function I(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 dn(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 cn=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 ln(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,n,i)=>n.toUpperCase()+i)}function un(e,t){const n=a.toCamelCase(" "+t);["get","set","has"].forEach(i=>{Object.defineProperty(e,i+n,{value:function(r,o,s){return this[i].call(this,t,r,o,s)},configurable:!0})})}let C=class{constructor(t){t&&this.set(t)}set(t,n,i){const r=this;function o(d,u,c){const l=I(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 s=(d,u)=>a.forEach(d,(c,l)=>o(c,l,u));if(a.isPlainObject(t)||t instanceof this.constructor)s(t,n);else if(a.isString(t)&&(t=t.trim())&&!cn(t))s(an(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]}s(d,n)}else t!=null&&o(n,t,i);return this}get(t,n){if(t=I(t),t){const i=a.findKey(this,t);if(i){const r=this[i];if(!n)return r;if(n===!0)return dn(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=I(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 o(s){if(s=I(s),s){const d=a.findKey(i,s);d&&(!n||ie(i,i[d],d,n))&&(delete i[d],r=!0)}}return a.isArray(t)?t.forEach(o):o(t),r}clear(t){const n=Object.keys(this);let i=n.length,r=!1;for(;i--;){const o=n[i];(!t||ie(this,this[o],o,t,!0))&&(delete this[o],r=!0)}return r}normalize(t){const n=this,i={};return a.forEach(this,(r,o)=>{const s=a.findKey(i,o);if(s){n[s]=V(r),delete n[o];return}const d=t?ln(o):String(o).trim();d!==o&&delete n[o],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[ge]=this[ge]={accessors:{}}).accessors,r=this.prototype;function o(s){const d=I(s);i[d]||(un(r,s),i[d]=!0)}return a.isArray(t)?t.forEach(o):o(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 o=i.data;return a.forEach(e,function(d){o=d.call(n,o,r.normalize(),t?t.status:void 0)}),r.normalize(),o}function Xe(e){return!!(e&&e.__CANCEL__)}function q(e,t,n){h.call(this,e??"canceled",h.ERR_CANCELED,t,n),this.name="CanceledError"}a.inherits(q,h,{__CANCEL__:!0});function Ke(e,t,n){const i=n.config.validateStatus;!n.status||!i||i(n.status)?e(n):t(new h("Request failed with status code "+n.status,[h.ERR_BAD_REQUEST,h.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function fn(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function pn(e,t){e=e||10;const n=new Array(e),i=new Array(e);let r=0,o=0,s;return t=t!==void 0?t:1e3,function(u){const c=Date.now(),l=i[o];s||(s=c),n[r]=u,i[r]=c;let p=o,y=0;for(;p!==r;)y+=n[p++],p=p%e;if(r=(r+1)%e,r===o&&(o=(o+1)%e),c-s<t)return;const R=l&&c-l;return R?Math.round(y*1e3/R):void 0}}function vn(e,t){let n=0,i=1e3/t,r,o;const s=(c,l=Date.now())=>{n=l,r=null,o&&(clearTimeout(o),o=null),e.apply(null,c)};return[(...c)=>{const l=Date.now(),p=l-n;p>=i?s(c,l):(r=c,o||(o=setTimeout(()=>{o=null,s(r)},i-p)))},()=>r&&s(r)]}const K=(e,t,n=3)=>{let i=0;const r=pn(50,250);return vn(o=>{const s=o.loaded,d=o.lengthComputable?o.total:void 0,u=s-i,c=r(u),l=s<=d;i=s;const p={loaded:s,total:d,progress:d?s/d:void 0,bytes:u,rate:c||void 0,estimated:c&&d&&l?(d-s)/c:void 0,event:o,lengthComputable:d!=null,[t?"download":"upload"]:!0};e(p)},n)},Re=(e,t)=>{const n=e!=null;return[i=>t[0]({lengthComputable:n,total:e,loaded:i}),t[1]]},Se=e=>(...t)=>a.asap(()=>e(...t)),hn=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,mn=O.hasStandardBrowserEnv?{write(e,t,n,i,r,o){const s=[e+"="+encodeURIComponent(t)];a.isNumber(n)&&s.push("expires="+new Date(n).toGMTString()),a.isString(i)&&s.push("path="+i),a.isString(r)&&s.push("domain="+r),o===!0&&s.push("secure"),document.cookie=s.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 wn(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function yn(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function We(e,t,n){let i=!wn(t);return e&&(i||n==!1)?yn(e,t):t}const Te=e=>e instanceof C?{...e}:e;function D(e,t){t=t||{};const n={};function i(c,l,p,y){return a.isPlainObject(c)&&a.isPlainObject(l)?a.merge.call({caseless:y},c,l):a.isPlainObject(l)?a.merge({},l):a.isArray(l)?l.slice():l}function r(c,l,p,y){if(a.isUndefined(l)){if(!a.isUndefined(c))return i(void 0,c,p,y)}else return i(c,l,p,y)}function o(c,l){if(!a.isUndefined(l))return i(void 0,l)}function s(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:o,method:o,data:o,baseURL:s,transformRequest:s,transformResponse:s,paramsSerializer:s,timeout:s,timeoutMessage:s,withCredentials:s,withXSRFToken:s,adapter:s,responseType:s,xsrfCookieName:s,xsrfHeaderName:s,onUploadProgress:s,onDownloadProgress:s,decompress:s,maxContentLength:s,maxBodyLength:s,beforeRedirect:s,transport:s,httpAgent:s,httpsAgent:s,cancelToken:s,socketPath:s,responseEncoding:s,validateStatus:d,headers:(c,l,p)=>r(Te(c),Te(l),p,!0)};return a.forEach(Object.keys(Object.assign({},e,t)),function(l){const p=u[l]||r,y=p(e[l],t[l],l);a.isUndefined(y)&&p!==d||(n[l]=y)}),n}const Ge=e=>{const t=D({},e);let{data:n,withXSRFToken:i,xsrfHeaderName:r,xsrfCookieName:o,headers:s,auth:d}=t;t.headers=s=C.from(s),t.url=ze(We(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),d&&s.set("Authorization","Basic "+btoa((d.username||"")+":"+(d.password?unescape(encodeURIComponent(d.password)):"")));let u;if(a.isFormData(n)){if(O.hasStandardBrowserEnv||O.hasStandardBrowserWebWorkerEnv)s.setContentType(void 0);else if((u=s.getContentType())!==!1){const[c,...l]=u?u.split(";").map(p=>p.trim()).filter(Boolean):[];s.setContentType([c||"multipart/form-data",...l].join("; "))}}if(O.hasStandardBrowserEnv&&(i&&a.isFunction(i)&&(i=i(t)),i||i!==!1&&hn(t.url))){const c=r&&o&&mn.read(o);c&&s.set(r,c)}return t},bn=typeof XMLHttpRequest<"u",En=bn&&function(e){return new Promise(function(n,i){const r=Ge(e);let o=r.data;const s=C.from(r.headers).normalize();let{responseType:d,onUploadProgress:u,onDownloadProgress:c}=r,l,p,y,R,f;function m(){R&&R(),f&&f(),r.cancelToken&&r.cancelToken.unsubscribe(l),r.signal&&r.signal.removeEventListener("abort",l)}let v=new XMLHttpRequest;v.open(r.method.toUpperCase(),r.url,!0),v.timeout=r.timeout;function E(){if(!v)return;const T=C.from("getAllResponseHeaders"in v&&v.getAllResponseHeaders()),_={data:!d||d==="text"||d==="json"?v.responseText:v.response,status:v.status,statusText:v.statusText,headers:T,config:e,request:v};Ke(function(B){n(B),m()},function(B){i(B),m()},_),v=null}"onloadend"in v?v.onloadend=E:v.onreadystatechange=function(){!v||v.readyState!==4||v.status===0&&!(v.responseURL&&v.responseURL.indexOf("file:")===0)||setTimeout(E)},v.onabort=function(){v&&(i(new h("Request aborted",h.ECONNABORTED,e,v)),v=null)},v.onerror=function(){i(new h("Network Error",h.ERR_NETWORK,e,v)),v=null},v.ontimeout=function(){let N=r.timeout?"timeout of "+r.timeout+"ms exceeded":"timeout exceeded";const _=r.transitional||Je;r.timeoutErrorMessage&&(N=r.timeoutErrorMessage),i(new h(N,_.clarifyTimeoutError?h.ETIMEDOUT:h.ECONNABORTED,e,v)),v=null},o===void 0&&s.setContentType(null),"setRequestHeader"in v&&a.forEach(s.toJSON(),function(N,_){v.setRequestHeader(_,N)}),a.isUndefined(r.withCredentials)||(v.withCredentials=!!r.withCredentials),d&&d!=="json"&&(v.responseType=r.responseType),c&&([y,f]=K(c,!0),v.addEventListener("progress",y)),u&&v.upload&&([p,R]=K(u),v.upload.addEventListener("progress",p),v.upload.addEventListener("loadend",R)),(r.cancelToken||r.signal)&&(l=T=>{v&&(i(!T||T.type?new q(null,e,v):T),v.abort(),v=null)},r.cancelToken&&r.cancelToken.subscribe(l),r.signal&&(r.signal.aborted?l():r.signal.addEventListener("abort",l)));const S=fn(r.url);if(S&&O.protocols.indexOf(S)===-1){i(new h("Unsupported protocol "+S+":",h.ERR_BAD_REQUEST,e));return}v.send(o||null)})},gn=(e,t)=>{const{length:n}=e=e?e.filter(Boolean):[];if(t||n){let i=new AbortController,r;const o=function(c){if(!r){r=!0,d();const l=c instanceof Error?c:this.reason;i.abort(l instanceof h?l:new q(l instanceof Error?l.message:l))}};let s=t&&setTimeout(()=>{s=null,o(new h(`timeout ${t} of ms exceeded`,h.ETIMEDOUT))},t);const d=()=>{e&&(s&&clearTimeout(s),s=null,e.forEach(c=>{c.unsubscribe?c.unsubscribe(o):c.removeEventListener("abort",o)}),e=null)};e.forEach(c=>c.addEventListener("abort",o));const{signal:u}=i;return u.unsubscribe=()=>a.asap(d),u}},Rn=function*(e,t){let n=e.byteLength;if(n<t){yield e;return}let i=0,r;for(;i<n;)r=i+t,yield e.slice(i,r),i=r},Sn=async function*(e,t){for await(const n of Tn(e))yield*Rn(n,t)},Tn=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}const t=e.getReader();try{for(;;){const{done:n,value:i}=await t.read();if(n)break;yield i}}finally{await t.cancel()}},Ae=(e,t,n,i)=>{const r=Sn(e,t);let o=0,s,d=u=>{s||(s=!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 y=o+=p;n(y)}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",Ze=te&&typeof ReadableStream=="function",An=te&&(typeof TextEncoder=="function"?(e=>t=>e.encode(t))(new TextEncoder):async e=>new Uint8Array(await new Response(e).arrayBuffer())),Qe=(e,...t)=>{try{return!!e(...t)}catch{return!1}},On=Ze&&Qe(()=>{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=Ze&&Qe(()=>a.isReadableStream(new Response("").body)),W={stream:ce&&(e=>e.body)};te&&(e=>{["text","arrayBuffer","blob","formData","stream"].forEach(t=>{!W[t]&&(W[t]=a.isFunction(e[t])?n=>n[t]():(n,i)=>{throw new h(`Response type '${t}' is not supported`,h.ERR_NOT_SUPPORT,i)})})})(new Response);const _n=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 An(e)).byteLength},xn=async(e,t)=>{const n=a.toFiniteNumber(e.getContentLength());return n??_n(t)},Cn=te&&(async e=>{let{url:t,method:n,data:i,signal:r,cancelToken:o,timeout:s,onDownloadProgress:d,onUploadProgress:u,responseType:c,headers:l,withCredentials:p="same-origin",fetchOptions:y}=Ge(e);c=c?(c+"").toLowerCase():"text";let R=gn([r,o&&o.toAbortSignal()],s),f;const m=R&&R.unsubscribe&&(()=>{R.unsubscribe()});let v;try{if(u&&On&&n!=="get"&&n!=="head"&&(v=await xn(l,i))!==0){let _=new Request(t,{method:"POST",body:i,duplex:"half"}),L;if(a.isFormData(i)&&(L=_.headers.get("content-type"))&&l.setContentType(L),_.body){const[B,z]=Re(v,K(Se(u)));i=Ae(_.body,Oe,B,z)}}a.isString(p)||(p=p?"include":"omit");const E="credentials"in Request.prototype;f=new Request(t,{...y,signal:R,method:n.toUpperCase(),headers:l.normalize().toJSON(),body:i,duplex:"half",credentials:E?p:void 0});let S=await fetch(f,y);const T=ce&&(c==="stream"||c==="response");if(ce&&(d||T&&m)){const _={};["status","statusText","headers"].forEach(me=>{_[me]=S[me]});const L=a.toFiniteNumber(S.headers.get("content-length")),[B,z]=d&&Re(L,K(Se(d),!0))||[];S=new Response(Ae(S.body,Oe,B,()=>{z&&z(),m&&m()}),_)}c=c||"text";let N=await W[a.findKey(W,c)||"text"](S,e);return!T&&m&&m(),await new Promise((_,L)=>{Ke(_,L,{data:N,headers:C.from(S.headers),status:S.status,statusText:S.statusText,config:e,request:f})})}catch(E){throw m&&m(),E&&E.name==="TypeError"&&/Load failed|fetch/i.test(E.message)?Object.assign(new h("Network Error",h.ERR_NETWORK,e,f),{cause:E.cause||E}):h.from(E,E&&E.code,e,f)}}),le={http:$t,xhr:En,fetch:Cn};a.forEach(le,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const _e=e=>`- ${e}`,Pn=e=>a.isFunction(e)||e===null||e===!1,Ye={getAdapter:e=>{e=a.isArray(e)?e:[e];const{length:t}=e;let n,i;const r={};for(let o=0;o<t;o++){n=e[o];let s;if(i=n,!Pn(n)&&(i=le[(s=String(n)).toLowerCase()],i===void 0))throw new h(`Unknown adapter '${s}'`);if(i)break;r[s||"#"+o]=i}if(!i){const o=Object.entries(r).map(([d,u])=>`adapter ${d} `+(u===!1?"is not supported by the environment":"is not available in the build"));let s=t?o.length>1?`since :
`+o.map(_e).join(`
`):" "+_e(o[0]):"as no adapter specified";throw new h("There is no suitable adapter to dispatch the request "+s,"ERR_NOT_SUPPORT")}return i},adapters:le};function oe(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new q(null,e)}function xe(e){return oe(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),Ye.getAdapter(e.adapter||$.adapter)(e).then(function(i){return oe(e),i.data=re.call(e,e.transformResponse,i),i.headers=C.from(i.headers),i},function(i){return Xe(i)||(oe(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 et="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 Ce={};ne.transitional=function(t,n,i){function r(o,s){return"[Axios v"+et+"] Transitional option '"+o+"'"+s+(i?". "+i:"")}return(o,s,d)=>{if(t===!1)throw new h(r(s," has been removed"+(n?" in "+n:"")),h.ERR_DEPRECATED);return n&&!Ce[s]&&(Ce[s]=!0,console.warn(r(s," has been deprecated since v"+n+" and will be removed in the near future"))),t?t(o,s,d):!0}};ne.spelling=function(t){return(n,i)=>(console.warn(`${i} is likely a misspelling of ${t}`),!0)};function kn(e,t,n){if(typeof e!="object")throw new h("options must be an object",h.ERR_BAD_OPTION_VALUE);const i=Object.keys(e);let r=i.length;for(;r-- >0;){const o=i[r],s=t[o];if(s){const d=e[o],u=d===void 0||s(d,o,e);if(u!==!0)throw new h("option "+o+" must be "+u,h.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new h("Unknown option "+o,h.ERR_BAD_OPTION)}}const X={assertOptions:kn,validators:ne},k=X.validators;let U=class{constructor(t){this.defaults=t||{},this.interceptors={request:new Ee,response:new Ee}}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 o=r.stack?r.stack.replace(/^.+\n/,""):"";try{i.stack?o&&!String(i.stack).endsWith(o.replace(/^.+\n.+\n/,""))&&(i.stack+=`
`+o):i.stack=o}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:o}=n;i!==void 0&&X.assertOptions(i,{silentJSONParsing:k.transitional(k.boolean),forcedJSONParsing:k.transitional(k.boolean),clarifyTimeoutError:k.transitional(k.boolean)},!1),r!=null&&(a.isFunction(r)?n.paramsSerializer={serialize:r}:X.assertOptions(r,{encode:k.function,serialize:k.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),X.assertOptions(n,{baseUrl:k.spelling("baseURL"),withXsrfToken:k.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let s=o&&a.merge(o.common,o[n.method]);o&&a.forEach(["delete","get","head","post","put","patch","common"],f=>{delete o[f]}),n.headers=C.concat(s,o);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,y;if(!u){const f=[xe.bind(this),void 0];for(f.unshift.apply(f,d),f.push.apply(f,c),y=f.length,l=Promise.resolve(n);p<y;)l=l.then(f[p++],f[p++]);return l}y=d.length;let R=n;for(p=0;p<y;){const f=d[p++],m=d[p++];try{R=f(R)}catch(v){m.call(this,v);break}}try{l=xe.call(this,R)}catch(f){return Promise.reject(f)}for(p=0,y=c.length;p<y;)l=l.then(c[p++],c[p++]);return l}getUri(t){t=D(this.defaults,t);const n=We(t.baseURL,t.url,t.allowAbsoluteUrls);return ze(n,t.params,t.paramsSerializer)}};a.forEach(["delete","get","head","options"],function(t){U.prototype[t]=function(n,i){return this.request(D(i||{},{method:t,url:n,data:(i||{}).data}))}});a.forEach(["post","put","patch"],function(t){function n(i){return function(o,s,d){return this.request(D(d||{},{method:t,headers:i?{"Content-Type":"multipart/form-data"}:{},url:o,data:s}))}}U.prototype[t]=n(),U.prototype[t+"Form"]=n(!0)});let Nn=class tt{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let n;this.promise=new Promise(function(o){n=o});const i=this;this.promise.then(r=>{if(!i._listeners)return;let o=i._listeners.length;for(;o-- >0;)i._listeners[o](r);i._listeners=null}),this.promise.then=r=>{let o;const s=new Promise(d=>{i.subscribe(d),o=d}).then(r);return s.cancel=function(){i.unsubscribe(o)},s},t(function(o,s,d){i.reason||(i.reason=new q(o,s,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 tt(function(r){t=r}),cancel:t}}};function Ln(e){return function(n){return e.apply(null,n)}}function Bn(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 nt(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 nt(D(e,r))},n}const g=nt($);g.Axios=U;g.CanceledError=q;g.CancelToken=Nn;g.isCancel=Xe;g.VERSION=et;g.toFormData=ee;g.AxiosError=h;g.Cancel=g.CanceledError;g.all=function(t){return Promise.all(t)};g.spread=Ln;g.isAxiosError=Bn;g.mergeConfig=D;g.AxiosHeaders=C;g.formToJSON=e=>Ve(a.isHTMLForm(e)?new FormData(e):e);g.getAdapter=Ye.getAdapter;g.HttpStatusCode=ue;g.default=g;const{Axios:Yn,AxiosError:ei,CanceledError:ti,isCancel:ni,CancelToken:ii,VERSION:ri,all:oi,Cancel:si,isAxiosError:ai,spread:di,toFormData:ci,AxiosHeaders:li,HttpStatusCode:ui,formToJSON:fi,getAdapter:pi,mergeConfig:vi}=g,he=g.create({baseURL:"http://localhost:4000/api/v1",headers:{"Content-Type":"application/json"}});class Fn{async sync(t){try{const{data:n}=await he.post("/products/sync",{items:t});return console.log("[NestJS] Response (bulk):",n),n}catch(n){throw console.error("[NestJS] Error (bulk):",n),n}}}const Un=new Fn;function b(e){return new Promise(t=>setTimeout(t,e))}class Dn{base64ToFile(t,n,i){const r=t.includes(",")?t.split(",")[1]:t,o=atob(r),s=new ArrayBuffer(o.length),d=new Uint8Array(s);for(let c=0;c<o.length;c++)d[c]=o.charCodeAt(c);const u=new Blob([s],{type:i});return new File([u],n,{type:i})}clickByPoint(t){const n=t.getBoundingClientRect(),i=n.left+n.width/2,r=n.top+n.height/2,o=document.elementFromPoint(i,r);o&&o.dispatchEvent(new MouseEvent("click",{bubbles:!0,cancelable:!0,view:window}))}async getElementByXPath(t,{retryCount:n=2,delay:i=100,xpathFallback:r}={}){return new Promise(o=>{let s=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){o(c);return}s++,s<n?setTimeout(u,i):!d&&r?(d=!0,s=0,setTimeout(u,i)):o(null)};u()})}async imageUrlToBase64(t){const i=await(await fetch(t)).blob();return new Promise((r,o)=>{const s=new FileReader;s.onloadend=()=>{typeof s.result=="string"?r(s.result.split(",")[1]):o("Không thể đọc dữ liệu ảnh")},s.onerror=o,s.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(o=>o.blob()).then(o=>{const s=new FileReader;s.onloadend=()=>n(s.result),s.onerror=i,s.readAsDataURL(o)}).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 w=new Dn,A={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",publish_btn:"/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",products:"/html/body/div[1]/div/div[1]/div/div[3]/div/div/div[1]/div[1]/div[2]/div/div/div[2]/div[1]/div/div[2]/div/div/span/div/div"},jn=async e=>{const t=new DataTransfer;for(const i of e.images){const r=await w.imageUrlToBase64(i);console.log("Base64:",i.slice(0,50)+"...");const o=w.base64ToFile(r,e.sku,w.getImageExtension(i)||"jpg");t.items.add(o)}const n=document.querySelector(A.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 w.getElementByXPath(t.wraper);if(!n)throw new Error("Wrapper xpath not found");w.scrollToElement(n),w.clickByPoint(n),await b(200);const i=await w.getElementByXPath(t.container);if(!i)throw new Error("Container xpath not found");const r=Array.from(i.children).find(o=>o.textContent?.trim().toLocaleLowerCase().replace(//g,"-").includes(e.toLocaleLowerCase()));if(!r)throw new Error(`No child found with text "${e}"`);w.scrollToElement(r),await b(200),w.clickByPoint(r)},qn=async(e,{input:t,...n})=>{await w.writeToInput(e,t,n.input_fallback),await b(200);const i=await w.getElementByXPath(n.container,{xpathFallback:n.container_fallback});if(!i)throw new Error("Container xpath not found");w.scrollToElement(i);const r=Array.from(i.children).find(o=>o.textContent?.trim().toLocaleLowerCase().includes(e.toLocaleLowerCase()));if(!r)throw new Error(`No child found with text "${e}"`);w.scrollToElement(r),await b(200),w.clickByPoint(r)},In=async(e,t)=>{const n=await w.getElementByXPath(t.input,{xpathFallback:t?.input_falback});if(!n)throw new Error("Input is not found");w.scrollToElement(n),await b(200);for(const i of e)await w.writeToInput(i,t.input,t?.input_falback),await b(200),w.pressEnter(n)},ke=async(e,t)=>{const{data:n}=await he({url:"products/publist-finish/"+e.id,method:"POST",data:t});return n},Mn=async(e,t)=>{const{data:n}=await he({url:"products/delete-finish/"+e.id,method:"POST",data:t});return n},Hn=async()=>{const e=await w.getElementByXPath(A.next_btn);if(!e)throw new Error("Next button is not found");w.clickByPoint(e)},$n=async()=>{const e=await w.getElementByXPath(A.publish_btn);if(!e)throw new Error("Publist button is not found");w.clickByPoint(e)};function zn(e){return Array.from(e.children).map(n=>{const r=n.querySelector('span[dir="auto"], div[dir="auto"]')?.textContent?.trim()||"",s=Array.from(n.querySelectorAll('span[dir="auto"]')).find(u=>/\d/.test(u.textContent||"")&&/[AU$]/.test(u.textContent||""))?.textContent?.match(/\d+(?:\.\d+)?/),d=s?parseFloat(s[0]):0;return{title:r,price:d,el:e}})}const Jn=async e=>(console.log({item:e}),await b(1e3),await jn(e),await b(200),w.writeToInput(e.title,A.title_input),await b(200),w.writeToInput(String(e.price),A.price_input),await b(200),await Pe(e.category,A.category_select),await b(200),await Pe(e.condition,A.condition_select),e.brand&&(await b(200),await w.writeToInput(e.brand,A.brand_input,A.brand_input_fallback)),await b(200),await w.writeToInput(e.description,A.description_input,A.description_input_falback),await b(200),await In(e.tags,A.tags_input),await b(200),await w.writeToInput(e.sku,A.sku_input,A.sku_input_fallback),e?.location&&(await b(200),await qn(e.location,A.location_select)),await b(200),await Hn(),await b(200),await $n(),!0),it=async()=>{const e=await w.getElementByXPath(A.products);return e?zn(e):[]},Vn=async()=>{if(!window.location.href.includes("https://www.facebook.com/marketplace/you/selling"))return;const t=await it();if(!t.length)return;const n=await Un.sync(t.map(i=>({title:i.title,price:i.price})));console.log({response:n})},Xn=async e=>{chrome.runtime.sendMessage({type:"close-tab",payload:e})},Kn=async e=>{const t=await it(),n=t.find(c=>c.title==e.title&&c.price==e.price);if(console.log({payload:e,product:n,products:t}),!n)return;const r=n.el.querySelector(`[aria-label="More options for ${n.title}"]`);if(console.log({optionEl:r}),!r)return;r.click?.(),await b(2e3);const o=Array.from(document.querySelectorAll('[role="menuitem"]'));console.log({items:o}),o.find(c=>c.textContent.toLocaleLowerCase().includes("delete")).click?.(),await b(1e3);const d=await w.getElementByXPath("/html/body/div[1]/div/div[1]/div/div[4]/div/div/div[1]/div/div[2]/div/div/div/div/div/div/div[3]/div/div/div/div/div[1]/div",{xpathFallback:"/html/body/div[1]/div/div[1]/div/div[4]/div/div/div[1]/div/div[2]/div/div/div/div[3]/div[2]/div/div[2]/div[1]"});console.log({btnDelete:d}),d?.click(),(await w.getElementByXPath("/html/body/div[1]/div/div[1]/div/div[4]/div/div/div[1]/div/div[2]/div/div/div/div[2]/div"))?.click(),await Mn(e,{published:!1}),chrome.runtime.sendMessage({type:"delete-done"})},Wn=chrome.runtime.connect();Wn.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 b(500),await Jn(t)}catch(n){await ke(t,{error:n.message,published:!1})}finally{await ke(t,{published:!0}),await b(5e3),await Xn(t)}}});chrome.runtime.onMessage.addListener(e=>{e.type==="DELETE_STREAM_DATA"&&(console.log("Nhận dữ liệu từ background:",e.payload),Kn(e.payload))});async function Gn(){await Vn()}Gn();