polarisrx 0.1.3 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -191,7 +191,7 @@ const gn = [
191
191
  function re() {
192
192
  return mt(Ot);
193
193
  }
194
- const Rn = "http://localhost:8000";
194
+ const Rn = "https://api.polarisrx.com.br";
195
195
  function xn(e) {
196
196
  const { apiKey: t } = re(), [n, r] = ne([]), [s, o] = ne(!1), i = Zt(
197
197
  async (a) => {
@@ -2536,7 +2536,7 @@ const {
2536
2536
  mergeConfig: Ws,
2537
2537
  create: Vs
2538
2538
  } = A, Ie = A.create({
2539
- baseURL: "http://localhost:8000",
2539
+ baseURL: "https://api.polarisrx.com.br",
2540
2540
  headers: {
2541
2541
  "Content-Type": "application/json"
2542
2542
  }
@@ -93,7 +93,7 @@ Error generating stack: `+o.message+`
93
93
  *
94
94
  * This source code is licensed under the ISC license.
95
95
  * See the LICENSE file in the root directory of this source tree.
96
- */const af=Jl("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]),cf=b.createContext({apiKey:""}),Lh=cf.Provider;function Cr(){return b.useContext(cf)}const Ah="http://localhost:8000";function Dh(e){const{apiKey:t}=Cr(),[n,r]=b.useState([]),[l,o]=b.useState(!1),i=b.useCallback(async s=>{if(!e||l)return;const u={id:crypto.randomUUID(),role:"user",content:s};r(d=>[...d,u]),o(!0);const a=crypto.randomUUID();r(d=>[...d,{id:a,role:"assistant",content:""}]);try{const d=await fetch(`${Ah}/widget/sessions/${e}/chat/stream/`,{method:"POST",headers:{"Content-Type":"application/json",...t?{"X-Pharmacy-Key":t}:{}},body:JSON.stringify({question:s})});if(!d.ok||!d.body)throw new Error("Erro ao conectar com o assistente");const m=d.body.getReader(),y=new TextDecoder;let v="";for(;;){const{done:S,value:g}=await m.read();if(S)break;v+=y.decode(g,{stream:!0});const E=v.split(`
96
+ */const af=Jl("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]),cf=b.createContext({apiKey:""}),Lh=cf.Provider;function Cr(){return b.useContext(cf)}const Ah="https://api.polarisrx.com.br";function Dh(e){const{apiKey:t}=Cr(),[n,r]=b.useState([]),[l,o]=b.useState(!1),i=b.useCallback(async s=>{if(!e||l)return;const u={id:crypto.randomUUID(),role:"user",content:s};r(d=>[...d,u]),o(!0);const a=crypto.randomUUID();r(d=>[...d,{id:a,role:"assistant",content:""}]);try{const d=await fetch(`${Ah}/widget/sessions/${e}/chat/stream/`,{method:"POST",headers:{"Content-Type":"application/json",...t?{"X-Pharmacy-Key":t}:{}},body:JSON.stringify({question:s})});if(!d.ok||!d.body)throw new Error("Erro ao conectar com o assistente");const m=d.body.getReader(),y=new TextDecoder;let v="";for(;;){const{done:S,value:g}=await m.read();if(S)break;v+=y.decode(g,{stream:!0});const E=v.split(`
97
97
  `);v=E.pop()??"";for(const f of E){if(!f.startsWith("data: "))continue;const c=f.slice(6).trim();if(c!=="[DONE]")try{const p=JSON.parse(c);p.token&&r(w=>w.map(x=>x.id===a?{...x,content:x.content+p.token}:x))}catch{}}}}catch(d){r(m=>m.map(y=>y.id===a?{...y,content:"Desculpe, ocorreu um erro. Tente novamente."}:y)),console.error(d)}finally{o(!1)}},[e,l,t]);return{messages:n,loading:l,send:i}}function zh({message:e}){const t=e.role==="user";return D.jsxs("div",{className:`flex ${t?"justify-end":"justify-start"} mb-3`,children:[!t&&D.jsx("div",{className:"w-7 h-7 rounded-full bg-emerald-100 flex items-center justify-center text-emerald-700 text-xs font-bold mr-2 mt-0.5 flex-shrink-0",children:"Rx"}),D.jsx("div",{className:`max-w-[80%] rounded-2xl px-4 py-2.5 text-sm leading-relaxed ${t?"bg-emerald-600 text-white rounded-br-sm":"bg-white border border-slate-100 text-slate-700 rounded-bl-sm shadow-sm"}`,children:e.content||D.jsxs("span",{className:"inline-flex gap-1 py-0.5",children:[D.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-slate-300 animate-bounce [animation-delay:0ms]"}),D.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-slate-300 animate-bounce [animation-delay:150ms]"}),D.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-slate-300 animate-bounce [animation-delay:300ms]"})]})})]})}const jh="#059669",Fh="Olá! Sou o assistente da farmácia. Como posso te ajudar hoje?";function Uh({sessionId:e,onClose:t}){const{messages:n,loading:r,send:l}=Dh(e),{primaryColor:o=jh,welcomeMessage:i=Fh}=Cr(),[s,u]=b.useState(""),a=b.useRef(null),d={id:"welcome",role:"assistant",content:i};b.useEffect(()=>{var v;(v=a.current)==null||v.scrollIntoView({behavior:"smooth"})},[n]);async function m(v){v.preventDefault();const S=s.trim();!S||r||(u(""),await l(S))}const y=[d,...n];return D.jsxs("div",{className:"flex flex-col w-[360px] h-[520px] bg-white rounded-2xl shadow-2xl border border-slate-200 overflow-hidden",children:[D.jsxs("div",{style:{backgroundColor:o},className:"flex items-center justify-between px-4 py-3 text-white",children:[D.jsxs("div",{className:"flex items-center gap-2.5",children:[D.jsx("div",{className:"w-8 h-8 rounded-full bg-white/20 flex items-center justify-center text-sm font-bold",children:"Rx"}),D.jsxs("div",{children:[D.jsx("p",{className:"text-sm font-semibold leading-tight",children:"Assistente PolarisRX"}),D.jsxs("p",{className:"text-xs text-white/75 flex items-center gap-1",children:[D.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-white/60 inline-block"}),"Online agora"]})]})]}),D.jsx("button",{onClick:t,className:"w-7 h-7 rounded-full hover:bg-white/20 flex items-center justify-center transition-colors","aria-label":"Fechar",children:D.jsx(af,{className:"w-4 h-4"})})]}),D.jsxs("div",{className:"flex-1 overflow-y-auto px-4 py-4 bg-slate-50 scrollbar-thin",children:[y.map(v=>D.jsx(zh,{message:v},v.id)),D.jsx("div",{ref:a})]}),!e&&D.jsxs("div",{className:"px-4 py-2 bg-amber-50 border-t border-amber-100 flex items-center gap-2 text-xs text-amber-700",children:[D.jsx(Ph,{className:"w-3 h-3 animate-spin"}),"Conectando ao assistente..."]}),D.jsxs("form",{onSubmit:m,className:"flex items-center gap-2 px-3 py-3 border-t border-slate-100 bg-white",children:[D.jsx("input",{type:"text",value:s,onChange:v=>u(v.target.value),disabled:!e||r,placeholder:"Digite sua dúvida...",className:"flex-1 text-sm bg-slate-50 border border-slate-200 rounded-xl px-3 py-2 outline-none focus:border-emerald-400 focus:ring-2 focus:ring-emerald-100 disabled:opacity-50 transition"}),D.jsx("button",{type:"submit",disabled:!e||r||!s.trim(),style:{backgroundColor:o},className:"w-9 h-9 rounded-xl hover:opacity-90 disabled:opacity-40 flex items-center justify-center transition-opacity flex-shrink-0","aria-label":"Enviar",children:D.jsx(Th,{className:"w-4 h-4 text-white"})})]}),D.jsxs("p",{className:"text-center text-[10px] text-slate-300 pb-2",children:["Powered by ",D.jsx("span",{className:"font-medium",style:{color:o},children:"PolarisRX"})]})]})}const Ih="#059669";function Mh(){const{primaryColor:e=Ih}=Cr();return D.jsxs("span",{className:"absolute -top-1 -right-1 flex h-3 w-3",children:[D.jsx("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full opacity-75",style:{backgroundColor:e}}),D.jsx("span",{className:"relative inline-flex rounded-full h-3 w-3",style:{backgroundColor:e}})]})}function ff(e,t){return function(){return e.apply(t,arguments)}}const{toString:Bh}=Object.prototype,{getPrototypeOf:Yl}=Object,{iterator:Gl,toStringTag:df}=Symbol,Zl=(e=>t=>{const n=Bh.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),Ke=e=>(e=e.toLowerCase(),t=>Zl(t)===e),bl=e=>t=>typeof t===e,{isArray:Jt}=Array,Ln=bl("undefined");function An(e){return e!==null&&!Ln(e)&&e.constructor!==null&&!Ln(e.constructor)&&xe(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const pf=Ke("ArrayBuffer");function $h(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&pf(e.buffer),t}const Hh=bl("string"),xe=bl("function"),hf=bl("number"),Rr=e=>e!==null&&typeof e=="object",Vh=e=>e===!0||e===!1,eo=e=>{if(Zl(e)!=="object")return!1;const t=Yl(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(df in e)&&!(Gl in e)},Wh=e=>{if(!Rr(e)||An(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},Qh=Ke("Date"),Kh=Ke("File"),Xh=e=>!!(e&&typeof e.uri<"u"),qh=e=>e&&typeof e.getParts<"u",Jh=Ke("Blob"),Yh=Ke("FileList"),Gh=e=>Rr(e)&&xe(e.pipe);function Zh(){return typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{}}const mf=Zh(),yf=typeof mf.FormData<"u"?mf.FormData:void 0,bh=e=>{if(!e)return!1;if(yf&&e instanceof yf)return!0;const t=Yl(e);if(!t||t===Object.prototype||!xe(e.append))return!1;const n=Zl(e);return n==="formdata"||n==="object"&&xe(e.toString)&&e.toString()==="[object FormData]"},em=Ke("URLSearchParams"),[tm,nm,rm,lm]=["ReadableStream","Request","Response","Headers"].map(Ke),om=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Nr(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let r,l;if(typeof e!="object"&&(e=[e]),Jt(e))for(r=0,l=e.length;r<l;r++)t.call(null,e[r],r,e);else{if(An(e))return;const o=n?Object.getOwnPropertyNames(e):Object.keys(e),i=o.length;let s;for(r=0;r<i;r++)s=o[r],t.call(null,e[s],s,e)}}function gf(e,t){if(An(e))return null;t=t.toLowerCase();const n=Object.keys(e);let r=n.length,l;for(;r-- >0;)if(l=n[r],t===l.toLowerCase())return l;return null}const Yt=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,vf=e=>!Ln(e)&&e!==Yt;function xs(...e){const{caseless:t,skipUndefined:n}=vf(this)&&this||{},r={},l=(o,i)=>{if(i==="__proto__"||i==="constructor"||i==="prototype")return;const s=t&&typeof i=="string"&&gf(r,i)||i,u=_s(r,s)?r[s]:void 0;eo(u)&&eo(o)?r[s]=xs(u,o):eo(o)?r[s]=xs({},o):Jt(o)?r[s]=o.slice():(!n||!Ln(o))&&(r[s]=o)};for(let o=0,i=e.length;o<i;o++){const s=e[o];if(!s||An(s)||(Nr(s,l),typeof s!="object"||Jt(s)))continue;const u=Object.getOwnPropertySymbols(s);for(let a=0;a<u.length;a++){const d=u[a];gm.call(s,d)&&l(s[d],d)}}return r}const im=(e,t,n,{allOwnKeys:r}={})=>(Nr(t,(l,o)=>{n&&xe(l)?Object.defineProperty(e,o,{__proto__:null,value:ff(l,n),writable:!0,enumerable:!0,configurable:!0}):Object.defineProperty(e,o,{__proto__:null,value:l,writable:!0,enumerable:!0,configurable:!0})},{allOwnKeys:r}),e),sm=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),um=(e,t,n,r)=>{e.prototype=Object.create(t.prototype,r),Object.defineProperty(e.prototype,"constructor",{__proto__:null,value:e,writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(e,"super",{__proto__:null,value:t.prototype}),n&&Object.assign(e.prototype,n)},am=(e,t,n,r)=>{let l,o,i;const s={};if(t=t||{},e==null)return t;do{for(l=Object.getOwnPropertyNames(e),o=l.length;o-- >0;)i=l[o],(!r||r(i,e,t))&&!s[i]&&(t[i]=e[i],s[i]=!0);e=n!==!1&&Yl(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},cm=(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},fm=e=>{if(!e)return null;if(Jt(e))return e;let t=e.length;if(!hf(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},dm=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&Yl(Uint8Array)),pm=(e,t)=>{const r=(e&&e[Gl]).call(e);let l;for(;(l=r.next())&&!l.done;){const o=l.value;t.call(e,o[0],o[1])}},hm=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},mm=Ke("HTMLFormElement"),ym=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,l){return r.toUpperCase()+l}),_s=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),{propertyIsEnumerable:gm}=Object.prototype,vm=Ke("RegExp"),wf=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};Nr(n,(l,o)=>{let i;(i=t(l,o,e))!==!1&&(r[o]=i||l)}),Object.defineProperties(e,r)},wm=e=>{wf(e,(t,n)=>{if(xe(e)&&["arguments","caller","callee"].includes(n))return!1;const r=e[n];if(xe(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+"'")})}})},Sm=(e,t)=>{const n={},r=l=>{l.forEach(o=>{n[o]=!0})};return Jt(e)?r(e):r(String(e).split(t)),n},Em=()=>{},km=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function xm(e){return!!(e&&xe(e.append)&&e[df]==="FormData"&&e[Gl])}const _m=e=>{const t=new WeakSet,n=r=>{if(Rr(r)){if(t.has(r))return;if(An(r))return r;if(!("toJSON"in r)){t.add(r);const l=Jt(r)?[]:{};return Nr(r,(o,i)=>{const s=n(o);!Ln(s)&&(l[i]=s)}),t.delete(r),l}}return r};return n(e)},Cm=Ke("AsyncFunction"),Rm=e=>e&&(Rr(e)||xe(e))&&xe(e.then)&&xe(e.catch),Sf=((e,t)=>e?setImmediate:t?((n,r)=>(Yt.addEventListener("message",({source:l,data:o})=>{l===Yt&&o===n&&r.length&&r.shift()()},!1),l=>{r.push(l),Yt.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",xe(Yt.postMessage)),Nm=typeof queueMicrotask<"u"?queueMicrotask.bind(Yt):typeof process<"u"&&process.nextTick||Sf,h={isArray:Jt,isArrayBuffer:pf,isBuffer:An,isFormData:bh,isArrayBufferView:$h,isString:Hh,isNumber:hf,isBoolean:Vh,isObject:Rr,isPlainObject:eo,isEmptyObject:Wh,isReadableStream:tm,isRequest:nm,isResponse:rm,isHeaders:lm,isUndefined:Ln,isDate:Qh,isFile:Kh,isReactNativeBlob:Xh,isReactNative:qh,isBlob:Jh,isRegExp:vm,isFunction:xe,isStream:Gh,isURLSearchParams:em,isTypedArray:dm,isFileList:Yh,forEach:Nr,merge:xs,extend:im,trim:om,stripBOM:sm,inherits:um,toFlatObject:am,kindOf:Zl,kindOfTest:Ke,endsWith:cm,toArray:fm,forEachEntry:pm,matchAll:hm,isHTMLForm:mm,hasOwnProperty:_s,hasOwnProp:_s,reduceDescriptors:wf,freezeMethods:wm,toObjectSet:Sm,toCamelCase:ym,noop:Em,toFiniteNumber:km,findKey:gf,global:Yt,isContextDefined:vf,isSpecCompliantForm:xm,toJSONObject:_m,isAsyncFn:Cm,isThenable:Rm,setImmediate:Sf,asap:Nm,isIterable:e=>e!=null&&xe(e[Gl])},Om=h.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"]),Pm=e=>{const t={};let n,r,l;return e&&e.split(`
98
98
  `).forEach(function(i){l=i.indexOf(":"),n=i.substring(0,l).trim().toLowerCase(),r=i.substring(l+1).trim(),!(!n||t[n]&&Om[n])&&(n==="set-cookie"?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)}),t};function Tm(e){let t=0,n=e.length;for(;t<n;){const r=e.charCodeAt(t);if(r!==9&&r!==32)break;t+=1}for(;n>t;){const r=e.charCodeAt(n-1);if(r!==9&&r!==32)break;n-=1}return t===0&&n===e.length?e:e.slice(t,n)}const Lm=new RegExp("[\\u0000-\\u0008\\u000a-\\u001f\\u007f]+","g"),Am=new RegExp("[^\\u0009\\u0020-\\u007e\\u0080-\\u00ff]+","g");function Cs(e,t){return h.isArray(e)?e.map(n=>Cs(n,t)):Tm(String(e).replace(t,""))}const Dm=e=>Cs(e,Lm),zm=e=>Cs(e,Am);function Ef(e){const t=Object.create(null);return h.forEach(e.toJSON(),(n,r)=>{t[r]=zm(n)}),t}const kf=Symbol("internals");function Or(e){return e&&String(e).trim().toLowerCase()}function to(e){return e===!1||e==null?e:h.isArray(e)?e.map(to):Dm(String(e))}function jm(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 Fm=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function Rs(e,t,n,r,l){if(h.isFunction(r))return r.call(this,t,n);if(l&&(t=n),!!h.isString(t)){if(h.isString(r))return t.indexOf(r)!==-1;if(h.isRegExp(r))return r.test(t)}}function Um(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,n,r)=>n.toUpperCase()+r)}function Im(e,t){const n=h.toCamelCase(" "+t);["get","set","has"].forEach(r=>{Object.defineProperty(e,r+n,{__proto__:null,value:function(l,o,i){return this[r].call(this,t,l,o,i)},configurable:!0})})}let ge=class{constructor(t){t&&this.set(t)}set(t,n,r){const l=this;function o(s,u,a){const d=Or(u);if(!d)return;const m=h.findKey(l,d);(!m||l[m]===void 0||a===!0||a===void 0&&l[m]!==!1)&&(l[m||u]=to(s))}const i=(s,u)=>h.forEach(s,(a,d)=>o(a,d,u));if(h.isPlainObject(t)||t instanceof this.constructor)i(t,n);else if(h.isString(t)&&(t=t.trim())&&!Fm(t))i(Pm(t),n);else if(h.isObject(t)&&h.isIterable(t)){let s={},u,a;for(const d of t){if(!h.isArray(d))throw new TypeError("Object iterator must return a key-value pair");s[a=d[0]]=(u=s[a])?h.isArray(u)?[...u,d[1]]:[u,d[1]]:d[1]}i(s,n)}else t!=null&&o(n,t,r);return this}get(t,n){if(t=Or(t),t){const r=h.findKey(this,t);if(r){const l=this[r];if(!n)return l;if(n===!0)return jm(l);if(h.isFunction(n))return n.call(this,l,r);if(h.isRegExp(n))return n.exec(l);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,n){if(t=Or(t),t){const r=h.findKey(this,t);return!!(r&&this[r]!==void 0&&(!n||Rs(this,this[r],r,n)))}return!1}delete(t,n){const r=this;let l=!1;function o(i){if(i=Or(i),i){const s=h.findKey(r,i);s&&(!n||Rs(r,r[s],s,n))&&(delete r[s],l=!0)}}return h.isArray(t)?t.forEach(o):o(t),l}clear(t){const n=Object.keys(this);let r=n.length,l=!1;for(;r--;){const o=n[r];(!t||Rs(this,this[o],o,t,!0))&&(delete this[o],l=!0)}return l}normalize(t){const n=this,r={};return h.forEach(this,(l,o)=>{const i=h.findKey(r,o);if(i){n[i]=to(l),delete n[o];return}const s=t?Um(o):String(o).trim();s!==o&&delete n[o],n[s]=to(l),r[s]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const n=Object.create(null);return h.forEach(this,(r,l)=>{r!=null&&r!==!1&&(n[l]=t&&h.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(`
99
99
  `)}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(l=>r.set(l)),r}static accessor(t){const r=(this[kf]=this[kf]={accessors:{}}).accessors,l=this.prototype;function o(i){const s=Or(i);r[s]||(Im(l,i),r[s]=!0)}return h.isArray(t)?t.forEach(o):o(t),this}};ge.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),h.reduceDescriptors(ge.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(r){this[n]=r}}}),h.freezeMethods(ge);const Mm="[REDACTED ****]";function Bm(e){if(h.hasOwnProp(e,"toJSON"))return!0;let t=Object.getPrototypeOf(e);for(;t&&t!==Object.prototype;){if(h.hasOwnProp(t,"toJSON"))return!0;t=Object.getPrototypeOf(t)}return!1}function $m(e,t){const n=new Set(t.map(o=>String(o).toLowerCase())),r=[],l=o=>{if(o===null||typeof o!="object"||h.isBuffer(o))return o;if(r.indexOf(o)!==-1)return;o instanceof ge&&(o=o.toJSON()),r.push(o);let i;if(h.isArray(o))i=[],o.forEach((s,u)=>{const a=l(s);h.isUndefined(a)||(i[u]=a)});else{if(!h.isPlainObject(o)&&Bm(o))return r.pop(),o;i=Object.create(null);for(const[s,u]of Object.entries(o)){const a=n.has(s.toLowerCase())?Mm:l(u);h.isUndefined(a)||(i[s]=a)}}return r.pop(),i};return l(e)}let N=class qf extends Error{static from(t,n,r,l,o,i){const s=new qf(t.message,n||t.code,r,l,o);return s.cause=t,s.name=t.name,t.status!=null&&s.status==null&&(s.status=t.status),i&&Object.assign(s,i),s}constructor(t,n,r,l,o){super(t),Object.defineProperty(this,"message",{__proto__:null,value:t,enumerable:!0,writable:!0,configurable:!0}),this.name="AxiosError",this.isAxiosError=!0,n&&(this.code=n),r&&(this.config=r),l&&(this.request=l),o&&(this.response=o,this.status=o.status)}toJSON(){const t=this.config,n=t&&h.hasOwnProp(t,"redact")?t.redact:void 0,r=h.isArray(n)&&n.length>0?$m(t,n):h.toJSONObject(t);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:r,code:this.code,status:this.status}}};N.ERR_BAD_OPTION_VALUE="ERR_BAD_OPTION_VALUE",N.ERR_BAD_OPTION="ERR_BAD_OPTION",N.ECONNABORTED="ECONNABORTED",N.ETIMEDOUT="ETIMEDOUT",N.ECONNREFUSED="ECONNREFUSED",N.ERR_NETWORK="ERR_NETWORK",N.ERR_FR_TOO_MANY_REDIRECTS="ERR_FR_TOO_MANY_REDIRECTS",N.ERR_DEPRECATED="ERR_DEPRECATED",N.ERR_BAD_RESPONSE="ERR_BAD_RESPONSE",N.ERR_BAD_REQUEST="ERR_BAD_REQUEST",N.ERR_CANCELED="ERR_CANCELED",N.ERR_NOT_SUPPORT="ERR_NOT_SUPPORT",N.ERR_INVALID_URL="ERR_INVALID_URL",N.ERR_FORM_DATA_DEPTH_EXCEEDED="ERR_FORM_DATA_DEPTH_EXCEEDED";const Hm=null;function Ns(e){return h.isPlainObject(e)||h.isArray(e)}function xf(e){return h.endsWith(e,"[]")?e.slice(0,-2):e}function Os(e,t,n){return e?e.concat(t).map(function(l,o){return l=xf(l),!n&&o?"["+l+"]":l}).join(n?".":""):t}function Vm(e){return h.isArray(e)&&!e.some(Ns)}const Wm=h.toFlatObject(h,{},null,function(t){return/^is[A-Z]/.test(t)});function no(e,t,n){if(!h.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,n=h.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(E,f){return!h.isUndefined(f[E])});const r=n.metaTokens,l=n.visitor||m,o=n.dots,i=n.indexes,s=n.Blob||typeof Blob<"u"&&Blob,u=n.maxDepth===void 0?100:n.maxDepth,a=s&&h.isSpecCompliantForm(t);if(!h.isFunction(l))throw new TypeError("visitor must be a function");function d(g){if(g===null)return"";if(h.isDate(g))return g.toISOString();if(h.isBoolean(g))return g.toString();if(!a&&h.isBlob(g))throw new N("Blob is not supported. Use a Buffer instead.");return h.isArrayBuffer(g)||h.isTypedArray(g)?a&&typeof Blob=="function"?new Blob([g]):Buffer.from(g):g}function m(g,E,f){let c=g;if(h.isReactNative(t)&&h.isReactNativeBlob(g))return t.append(Os(f,E,o),d(g)),!1;if(g&&!f&&typeof g=="object"){if(h.endsWith(E,"{}"))E=r?E:E.slice(0,-2),g=JSON.stringify(g);else if(h.isArray(g)&&Vm(g)||(h.isFileList(g)||h.endsWith(E,"[]"))&&(c=h.toArray(g)))return E=xf(E),c.forEach(function(w,x){!(h.isUndefined(w)||w===null)&&t.append(i===!0?Os([E],x,o):i===null?E:E+"[]",d(w))}),!1}return Ns(g)?!0:(t.append(Os(f,E,o),d(g)),!1)}const y=[],v=Object.assign(Wm,{defaultVisitor:m,convertValue:d,isVisitable:Ns});function S(g,E,f=0){if(!h.isUndefined(g)){if(f>u)throw new N("Object is too deeply nested ("+f+" levels). Max depth: "+u,N.ERR_FORM_DATA_DEPTH_EXCEEDED);if(y.indexOf(g)!==-1)throw new Error("Circular reference detected in "+E.join("."));y.push(g),h.forEach(g,function(p,w){(!(h.isUndefined(p)||p===null)&&l.call(t,p,h.isString(w)?w.trim():w,E,v))===!0&&S(p,E?E.concat(w):[w],f+1)}),y.pop()}}if(!h.isObject(e))throw new TypeError("data must be an object");return S(e),t}function _f(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"};return encodeURIComponent(e).replace(/[!'()~]|%20/g,function(r){return t[r]})}function Ps(e,t){this._pairs=[],e&&no(e,this,t)}const Cf=Ps.prototype;Cf.append=function(t,n){this._pairs.push([t,n])},Cf.toString=function(t){const n=t?function(r){return t.call(this,r,_f)}:_f;return this._pairs.map(function(l){return n(l[0])+"="+n(l[1])},"").join("&")};function Qm(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function Rf(e,t,n){if(!t)return e;const r=n&&n.encode||Qm,l=h.isFunction(n)?{serialize:n}:n,o=l&&l.serialize;let i;if(o?i=o(t,l):i=h.isURLSearchParams(t)?t.toString():new Ps(t,l).toString(r),i){const s=e.indexOf("#");s!==-1&&(e=e.slice(0,s)),e+=(e.indexOf("?")===-1?"?":"&")+i}return e}class Nf{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){h.forEach(this.handlers,function(r){r!==null&&t(r)})}}const Ts={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1,legacyInterceptorReqResOrdering:!0,advertiseZstdAcceptEncoding:!1},Km={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:Ps,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},Ls=typeof window<"u"&&typeof document<"u",As=typeof navigator=="object"&&navigator||void 0,Xm=Ls&&(!As||["ReactNative","NativeScript","NS"].indexOf(As.product)<0),qm=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",Jm=Ls&&window.location.href||"http://localhost",ue={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Ls,hasStandardBrowserEnv:Xm,hasStandardBrowserWebWorkerEnv:qm,navigator:As,origin:Jm},Symbol.toStringTag,{value:"Module"})),...Km};function Ym(e,t){return no(e,new ue.classes.URLSearchParams,{visitor:function(n,r,l,o){return ue.isNode&&h.isBuffer(n)?(this.append(r,n.toString("base64")),!1):o.defaultVisitor.apply(this,arguments)},...t})}function Gm(e){return h.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function Zm(e){const t={},n=Object.keys(e);let r;const l=n.length;let o;for(r=0;r<l;r++)o=n[r],t[o]=e[o];return t}function Of(e){function t(n,r,l,o){let i=n[o++];if(i==="__proto__")return!0;const s=Number.isFinite(+i),u=o>=n.length;return i=!i&&h.isArray(l)?l.length:i,u?(h.hasOwnProp(l,i)?l[i]=h.isArray(l[i])?l[i].concat(r):[l[i],r]:l[i]=r,!s):((!h.hasOwnProp(l,i)||!h.isObject(l[i]))&&(l[i]=[]),t(n,r,l[i],o)&&h.isArray(l[i])&&(l[i]=Zm(l[i])),!s)}if(h.isFormData(e)&&h.isFunction(e.entries)){const n={};return h.forEachEntry(e,(r,l)=>{t(Gm(r),l,n,0)}),n}return null}const Dn=(e,t)=>e!=null&&h.hasOwnProp(e,t)?e[t]:void 0;function bm(e,t,n){if(h.isString(e))try{return(t||JSON.parse)(e),h.trim(e)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(e)}const Pr={transitional:Ts,adapter:["xhr","http","fetch"],transformRequest:[function(t,n){const r=n.getContentType()||"",l=r.indexOf("application/json")>-1,o=h.isObject(t);if(o&&h.isHTMLForm(t)&&(t=new FormData(t)),h.isFormData(t))return l?JSON.stringify(Of(t)):t;if(h.isArrayBuffer(t)||h.isBuffer(t)||h.isStream(t)||h.isFile(t)||h.isBlob(t)||h.isReadableStream(t))return t;if(h.isArrayBufferView(t))return t.buffer;if(h.isURLSearchParams(t))return n.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let s;if(o){const u=Dn(this,"formSerializer");if(r.indexOf("application/x-www-form-urlencoded")>-1)return Ym(t,u).toString();if((s=h.isFileList(t))||r.indexOf("multipart/form-data")>-1){const a=Dn(this,"env"),d=a&&a.FormData;return no(s?{"files[]":t}:t,d&&new d,u)}}return o||l?(n.setContentType("application/json",!1),bm(t)):t}],transformResponse:[function(t){const n=Dn(this,"transitional")||Pr.transitional,r=n&&n.forcedJSONParsing,l=Dn(this,"responseType"),o=l==="json";if(h.isResponse(t)||h.isReadableStream(t))return t;if(t&&h.isString(t)&&(r&&!l||o)){const s=!(n&&n.silentJSONParsing)&&o;try{return JSON.parse(t,Dn(this,"parseReviver"))}catch(u){if(s)throw u.name==="SyntaxError"?N.from(u,N.ERR_BAD_RESPONSE,this,null,Dn(this,"response")):u}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:ue.classes.FormData,Blob:ue.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};h.forEach(["delete","get","head","post","put","patch","query"],e=>{Pr.headers[e]={}});function Ds(e,t){const n=this||Pr,r=t||n,l=ge.from(r.headers);let o=r.data;return h.forEach(e,function(s){o=s.call(n,o,l.normalize(),t?t.status:void 0)}),l.normalize(),o}function Pf(e){return!!(e&&e.__CANCEL__)}let Tr=class extends N{constructor(t,n,r){super(t??"canceled",N.ERR_CANCELED,n,r),this.name="CanceledError",this.__CANCEL__=!0}};function Tf(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new N("Request failed with status code "+n.status,n.status>=400&&n.status<500?N.ERR_BAD_REQUEST:N.ERR_BAD_RESPONSE,n.config,n.request,n))}function ey(e){const t=/^([-+\w]{1,25}):(?:\/\/)?/.exec(e);return t&&t[1]||""}function ty(e,t){e=e||10;const n=new Array(e),r=new Array(e);let l=0,o=0,i;return t=t!==void 0?t:1e3,function(u){const a=Date.now(),d=r[o];i||(i=a),n[l]=u,r[l]=a;let m=o,y=0;for(;m!==l;)y+=n[m++],m=m%e;if(l=(l+1)%e,l===o&&(o=(o+1)%e),a-i<t)return;const v=d&&a-d;return v?Math.round(y*1e3/v):void 0}}function ny(e,t){let n=0,r=1e3/t,l,o;const i=(a,d=Date.now())=>{n=d,l=null,o&&(clearTimeout(o),o=null),e(...a)};return[(...a)=>{const d=Date.now(),m=d-n;m>=r?i(a,d):(l=a,o||(o=setTimeout(()=>{o=null,i(l)},r-m)))},()=>l&&i(l)]}const ro=(e,t,n=3)=>{let r=0;const l=ty(50,250);return ny(o=>{if(!o||typeof o.loaded!="number")return;const i=o.loaded,s=o.lengthComputable?o.total:void 0,u=s!=null?Math.min(i,s):i,a=Math.max(0,u-r),d=l(a);r=Math.max(r,u);const m={loaded:u,total:s,progress:s?u/s:void 0,bytes:a,rate:d||void 0,estimated:d&&s?(s-u)/d:void 0,event:o,lengthComputable:s!=null,[t?"download":"upload"]:!0};e(m)},n)},Lf=(e,t)=>{const n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},Af=e=>(...t)=>h.asap(()=>e(...t)),ry=ue.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,ue.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(ue.origin),ue.navigator&&/(msie|trident)/i.test(ue.navigator.userAgent)):()=>!0,ly=ue.hasStandardBrowserEnv?{write(e,t,n,r,l,o,i){if(typeof document>"u")return;const s=[`${e}=${encodeURIComponent(t)}`];h.isNumber(n)&&s.push(`expires=${new Date(n).toUTCString()}`),h.isString(r)&&s.push(`path=${r}`),h.isString(l)&&s.push(`domain=${l}`),o===!0&&s.push("secure"),h.isString(i)&&s.push(`SameSite=${i}`),document.cookie=s.join("; ")},read(e){if(typeof document>"u")return null;const t=document.cookie.split(";");for(let n=0;n<t.length;n++){const r=t[n].replace(/^\s+/,""),l=r.indexOf("=");if(l!==-1&&r.slice(0,l)===e)return decodeURIComponent(r.slice(l+1))}return null},remove(e){this.write(e,"",Date.now()-864e5,"/")}}:{write(){},read(){return null},remove(){}};function oy(e){return typeof e!="string"?!1:/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function iy(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function Df(e,t,n){let r=!oy(t);return e&&(r||n===!1)?iy(e,t):t}const zf=e=>e instanceof ge?{...e}:e;function Gt(e,t){t=t||{};const n=Object.create(null);Object.defineProperty(n,"hasOwnProperty",{__proto__:null,value:Object.prototype.hasOwnProperty,enumerable:!1,writable:!0,configurable:!0});function r(a,d,m,y){return h.isPlainObject(a)&&h.isPlainObject(d)?h.merge.call({caseless:y},a,d):h.isPlainObject(d)?h.merge({},d):h.isArray(d)?d.slice():d}function l(a,d,m,y){if(h.isUndefined(d)){if(!h.isUndefined(a))return r(void 0,a,m,y)}else return r(a,d,m,y)}function o(a,d){if(!h.isUndefined(d))return r(void 0,d)}function i(a,d){if(h.isUndefined(d)){if(!h.isUndefined(a))return r(void 0,a)}else return r(void 0,d)}function s(a,d,m){if(h.hasOwnProp(t,m))return r(a,d);if(h.hasOwnProp(e,m))return r(void 0,a)}const u={url:o,method:o,data:o,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,withXSRFToken:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,allowedSocketPaths:i,responseEncoding:i,validateStatus:s,headers:(a,d,m)=>l(zf(a),zf(d),m,!0)};return h.forEach(Object.keys({...e,...t}),function(d){if(d==="__proto__"||d==="constructor"||d==="prototype")return;const m=h.hasOwnProp(u,d)?u[d]:l,y=h.hasOwnProp(e,d)?e[d]:void 0,v=h.hasOwnProp(t,d)?t[d]:void 0,S=m(y,v,d);h.isUndefined(S)&&m!==s||(n[d]=S)}),n}const sy=["content-type","content-length"];function uy(e,t,n){if(n!=="content-only"){e.set(t);return}Object.entries(t).forEach(([r,l])=>{sy.includes(r.toLowerCase())&&e.set(r,l)})}const ay=e=>encodeURIComponent(e).replace(/%([0-9A-F]{2})/gi,(t,n)=>String.fromCharCode(parseInt(n,16)));function jf(e){const t=Gt({},e),n=y=>h.hasOwnProp(t,y)?t[y]:void 0,r=n("data");let l=n("withXSRFToken");const o=n("xsrfHeaderName"),i=n("xsrfCookieName");let s=n("headers");const u=n("auth"),a=n("baseURL"),d=n("allowAbsoluteUrls"),m=n("url");if(t.headers=s=ge.from(s),t.url=Rf(Df(a,m,d),n("params"),n("paramsSerializer")),u&&s.set("Authorization","Basic "+btoa((u.username||"")+":"+(u.password?ay(u.password):""))),h.isFormData(r)&&(ue.hasStandardBrowserEnv||ue.hasStandardBrowserWebWorkerEnv||h.isReactNative(r)?s.setContentType(void 0):h.isFunction(r.getHeaders)&&uy(s,r.getHeaders(),n("formDataHeaderPolicy"))),ue.hasStandardBrowserEnv&&(h.isFunction(l)&&(l=l(t)),l===!0||l==null&&ry(t.url))){const v=o&&i&&ly.read(i);v&&s.set(o,v)}return t}const cy=typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(n,r){const l=jf(e);let o=l.data;const i=ge.from(l.headers).normalize();let{responseType:s,onUploadProgress:u,onDownloadProgress:a}=l,d,m,y,v,S;function g(){v&&v(),S&&S(),l.cancelToken&&l.cancelToken.unsubscribe(d),l.signal&&l.signal.removeEventListener("abort",d)}let E=new XMLHttpRequest;E.open(l.method.toUpperCase(),l.url,!0),E.timeout=l.timeout;function f(){if(!E)return;const p=ge.from("getAllResponseHeaders"in E&&E.getAllResponseHeaders()),x={data:!s||s==="text"||s==="json"?E.responseText:E.response,status:E.status,statusText:E.statusText,headers:p,config:e,request:E};Tf(function(O){n(O),g()},function(O){r(O),g()},x),E=null}"onloadend"in E?E.onloadend=f:E.onreadystatechange=function(){!E||E.readyState!==4||E.status===0&&!(E.responseURL&&E.responseURL.startsWith("file:"))||setTimeout(f)},E.onabort=function(){E&&(r(new N("Request aborted",N.ECONNABORTED,e,E)),g(),E=null)},E.onerror=function(w){const x=w&&w.message?w.message:"Network Error",R=new N(x,N.ERR_NETWORK,e,E);R.event=w||null,r(R),g(),E=null},E.ontimeout=function(){let w=l.timeout?"timeout of "+l.timeout+"ms exceeded":"timeout exceeded";const x=l.transitional||Ts;l.timeoutErrorMessage&&(w=l.timeoutErrorMessage),r(new N(w,x.clarifyTimeoutError?N.ETIMEDOUT:N.ECONNABORTED,e,E)),g(),E=null},o===void 0&&i.setContentType(null),"setRequestHeader"in E&&h.forEach(Ef(i),function(w,x){E.setRequestHeader(x,w)}),h.isUndefined(l.withCredentials)||(E.withCredentials=!!l.withCredentials),s&&s!=="json"&&(E.responseType=l.responseType),a&&([y,S]=ro(a,!0),E.addEventListener("progress",y)),u&&E.upload&&([m,v]=ro(u),E.upload.addEventListener("progress",m),E.upload.addEventListener("loadend",v)),(l.cancelToken||l.signal)&&(d=p=>{E&&(r(!p||p.type?new Tr(null,e,E):p),E.abort(),g(),E=null)},l.cancelToken&&l.cancelToken.subscribe(d),l.signal&&(l.signal.aborted?d():l.signal.addEventListener("abort",d)));const c=ey(l.url);if(c&&!ue.protocols.includes(c)){r(new N("Unsupported protocol "+c+":",N.ERR_BAD_REQUEST,e));return}E.send(o||null)})},fy=(e,t)=>{if(e=e?e.filter(Boolean):[],!t&&!e.length)return;const n=new AbortController;let r=!1;const l=function(u){if(!r){r=!0,i();const a=u instanceof Error?u:this.reason;n.abort(a instanceof N?a:new Tr(a instanceof Error?a.message:a))}};let o=t&&setTimeout(()=>{o=null,l(new N(`timeout of ${t}ms exceeded`,N.ETIMEDOUT))},t);const i=()=>{e&&(o&&clearTimeout(o),o=null,e.forEach(u=>{u.unsubscribe?u.unsubscribe(l):u.removeEventListener("abort",l)}),e=null)};e.forEach(u=>u.addEventListener("abort",l));const{signal:s}=n;return s.unsubscribe=()=>h.asap(i),s},dy=function*(e,t){let n=e.byteLength;if(n<t){yield e;return}let r=0,l;for(;r<n;)l=r+t,yield e.slice(r,l),r=l},py=async function*(e,t){for await(const n of hy(e))yield*dy(n,t)},hy=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}const t=e.getReader();try{for(;;){const{done:n,value:r}=await t.read();if(n)break;yield r}}finally{await t.cancel()}},Ff=(e,t,n,r)=>{const l=py(e,t);let o=0,i,s=u=>{i||(i=!0,r&&r(u))};return new ReadableStream({async pull(u){try{const{done:a,value:d}=await l.next();if(a){s(),u.close();return}let m=d.byteLength;if(n){let y=o+=m;n(y)}u.enqueue(new Uint8Array(d))}catch(a){throw s(a),a}},cancel(u){return s(u),l.return()}},{highWaterMark:2})};function my(e){if(!e||typeof e!="string"||!e.startsWith("data:"))return 0;const t=e.indexOf(",");if(t<0)return 0;const n=e.slice(5,t),r=e.slice(t+1);if(/;base64/i.test(n)){let i=r.length;const s=r.length;for(let v=0;v<s;v++)if(r.charCodeAt(v)===37&&v+2<s){const S=r.charCodeAt(v+1),g=r.charCodeAt(v+2);(S>=48&&S<=57||S>=65&&S<=70||S>=97&&S<=102)&&(g>=48&&g<=57||g>=65&&g<=70||g>=97&&g<=102)&&(i-=2,v+=2)}let u=0,a=s-1;const d=v=>v>=2&&r.charCodeAt(v-2)===37&&r.charCodeAt(v-1)===51&&(r.charCodeAt(v)===68||r.charCodeAt(v)===100);a>=0&&(r.charCodeAt(a)===61?(u++,a--):d(a)&&(u++,a-=3)),u===1&&a>=0&&(r.charCodeAt(a)===61||d(a))&&u++;const y=Math.floor(i/4)*3-(u||0);return y>0?y:0}if(typeof Buffer<"u"&&typeof Buffer.byteLength=="function")return Buffer.byteLength(r,"utf8");let o=0;for(let i=0,s=r.length;i<s;i++){const u=r.charCodeAt(i);if(u<128)o+=1;else if(u<2048)o+=2;else if(u>=55296&&u<=56319&&i+1<s){const a=r.charCodeAt(i+1);a>=56320&&a<=57343?(o+=4,i++):o+=3}else o+=3}return o}const zs="1.17.0",Uf=64*1024,{isFunction:lo}=h,yy=e=>encodeURIComponent(e).replace(/%([0-9A-F]{2})/gi,(t,n)=>String.fromCharCode(parseInt(n,16))),If=e=>{if(!h.isString(e))return e;try{return decodeURIComponent(e)}catch{return e}},Mf=(e,...t)=>{try{return!!e(...t)}catch{return!1}},gy=e=>{const t=e.indexOf("://");let n=e;return t!==-1&&(n=n.slice(t+3)),n.includes("@")||n.includes(":")},vy=e=>{const t=h.global!==void 0&&h.global!==null?h.global:globalThis,{ReadableStream:n,TextEncoder:r}=t;e=h.merge.call({skipUndefined:!0},{Request:t.Request,Response:t.Response},e);const{fetch:l,Request:o,Response:i}=e,s=l?lo(l):typeof fetch=="function",u=lo(o),a=lo(i);if(!s)return!1;const d=s&&lo(n),m=s&&(typeof r=="function"?(f=>c=>f.encode(c))(new r):async f=>new Uint8Array(await new o(f).arrayBuffer())),y=u&&d&&Mf(()=>{let f=!1;const c=new o(ue.origin,{body:new n,method:"POST",get duplex(){return f=!0,"half"}}),p=c.headers.has("Content-Type");return c.body!=null&&c.body.cancel(),f&&!p}),v=a&&d&&Mf(()=>h.isReadableStream(new i("").body)),S={stream:v&&(f=>f.body)};s&&["text","arrayBuffer","blob","formData","stream"].forEach(f=>{!S[f]&&(S[f]=(c,p)=>{let w=c&&c[f];if(w)return w.call(c);throw new N(`Response type '${f}' is not supported`,N.ERR_NOT_SUPPORT,p)})});const g=async f=>{if(f==null)return 0;if(h.isBlob(f))return f.size;if(h.isSpecCompliantForm(f))return(await new o(ue.origin,{method:"POST",body:f}).arrayBuffer()).byteLength;if(h.isArrayBufferView(f)||h.isArrayBuffer(f))return f.byteLength;if(h.isURLSearchParams(f)&&(f=f+""),h.isString(f))return(await m(f)).byteLength},E=async(f,c)=>{const p=h.toFiniteNumber(f.getContentLength());return p??g(c)};return async f=>{let{url:c,method:p,data:w,signal:x,cancelToken:R,timeout:O,onDownloadProgress:P,onUploadProgress:Q,responseType:L,headers:Z,withCredentials:Ze="same-origin",fetchOptions:zt,maxContentLength:Le,maxBodyLength:Lr}=jf(f);const ft=h.isNumber(Le)&&Le>-1,Ar=h.isNumber(Lr)&&Lr>-1,C=I=>h.hasOwnProp(f,I)?f[I]:void 0;let A=l||fetch;L=L?(L+"").toLowerCase():"text";let T=fy([x,R&&R.toAbortSignal()],O),F=null;const $=T&&T.unsubscribe&&(()=>{T.unsubscribe()});let bt;try{let I;const Ae=C("auth");if(Ae){const z=Ae.username||"",et=Ae.password||"";I={username:z,password:et}}if(gy(c)){const z=new URL(c,ue.origin);if(!I&&(z.username||z.password)){const et=If(z.username),zn=If(z.password);I={username:et,password:zn}}(z.username||z.password)&&(z.username="",z.password="",c=z.href)}if(I&&(Z.delete("authorization"),Z.set("Authorization","Basic "+btoa(yy((I.username||"")+":"+(I.password||""))))),ft&&typeof c=="string"&&c.startsWith("data:")&&my(c)>Le)throw new N("maxContentLength size of "+Le+" exceeded",N.ERR_BAD_RESPONSE,f,F);if(Ar&&p!=="get"&&p!=="head"){const z=await E(Z,w);if(typeof z=="number"&&isFinite(z)&&z>Lr)throw new N("Request body larger than maxBodyLength limit",N.ERR_BAD_REQUEST,f,F)}if(Q&&y&&p!=="get"&&p!=="head"&&(bt=await E(Z,w))!==0){let z=new o(c,{method:"POST",body:w,duplex:"half"}),et;if(h.isFormData(w)&&(et=z.headers.get("content-type"))&&Z.setContentType(et),z.body){const[zn,so]=Lf(bt,ro(Af(Q)));w=Ff(z.body,Uf,zn,so)}}h.isString(Ze)||(Ze=Ze?"include":"omit");const dt=u&&"credentials"in o.prototype;if(h.isFormData(w)){const z=Z.getContentType();z&&/^multipart\/form-data/i.test(z)&&!/boundary=/i.test(z)&&Z.delete("content-type")}Z.set("User-Agent","axios/"+zs,!1);const en={...zt,signal:T,method:p.toUpperCase(),headers:Ef(Z.normalize()),body:w,duplex:"half",credentials:dt?Ze:void 0};F=u&&new o(c,en);let be=await(u?A(F,zt):A(c,en));if(ft){const z=h.toFiniteNumber(be.headers.get("content-length"));if(z!=null&&z>Le)throw new N("maxContentLength size of "+Le+" exceeded",N.ERR_BAD_RESPONSE,f,F)}const Ms=v&&(L==="stream"||L==="response");if(v&&be.body&&(P||ft||Ms&&$)){const z={};["status","statusText","headers"].forEach(Dr=>{z[Dr]=be[Dr]});const et=h.toFiniteNumber(be.headers.get("content-length")),[zn,so]=P&&Lf(et,ro(Af(P),!0))||[];let Xf=0;const Ly=Dr=>{if(ft&&(Xf=Dr,Xf>Le))throw new N("maxContentLength size of "+Le+" exceeded",N.ERR_BAD_RESPONSE,f,F);zn&&zn(Dr)};be=new i(Ff(be.body,Uf,Ly,()=>{so&&so(),$&&$()}),z)}L=L||"text";let pt=await S[h.findKey(S,L)||"text"](be,f);if(ft&&!v&&!Ms){let z;if(pt!=null&&(typeof pt.byteLength=="number"?z=pt.byteLength:typeof pt.size=="number"?z=pt.size:typeof pt=="string"&&(z=typeof r=="function"?new r().encode(pt).byteLength:pt.length)),typeof z=="number"&&z>Le)throw new N("maxContentLength size of "+Le+" exceeded",N.ERR_BAD_RESPONSE,f,F)}return!Ms&&$&&$(),await new Promise((z,et)=>{Tf(z,et,{data:pt,headers:ge.from(be.headers),status:be.status,statusText:be.statusText,config:f,request:F})})}catch(I){if($&&$(),T&&T.aborted&&T.reason instanceof N){const Ae=T.reason;throw Ae.config=f,F&&(Ae.request=F),I!==Ae&&(Ae.cause=I),Ae}throw I&&I.name==="TypeError"&&/Load failed|fetch/i.test(I.message)?Object.assign(new N("Network Error",N.ERR_NETWORK,f,F,I&&I.response),{cause:I.cause||I}):N.from(I,I&&I.code,f,F,I&&I.response)}}},wy=new Map,Bf=e=>{let t=e&&e.env||{};const{fetch:n,Request:r,Response:l}=t,o=[r,l,n];let i=o.length,s=i,u,a,d=wy;for(;s--;)u=o[s],a=d.get(u),a===void 0&&d.set(u,a=s?new Map:vy(t)),d=a;return a};Bf();const js={http:Hm,xhr:cy,fetch:{get:Bf}};h.forEach(js,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{__proto__:null,value:t})}catch{}Object.defineProperty(e,"adapterName",{__proto__:null,value:t})}});const $f=e=>`- ${e}`,Sy=e=>h.isFunction(e)||e===null||e===!1;function Ey(e,t){e=h.isArray(e)?e:[e];const{length:n}=e;let r,l;const o={};for(let i=0;i<n;i++){r=e[i];let s;if(l=r,!Sy(r)&&(l=js[(s=String(r)).toLowerCase()],l===void 0))throw new N(`Unknown adapter '${s}'`);if(l&&(h.isFunction(l)||(l=l.get(t))))break;o[s||"#"+i]=l}if(!l){const i=Object.entries(o).map(([u,a])=>`adapter ${u} `+(a===!1?"is not supported by the environment":"is not available in the build"));let s=n?i.length>1?`since :
@@ -102,4 +102,4 @@ Error generating stack: `+o.message+`
102
102
  `);return i===-1?"":l.stack.slice(i+1)})();try{if(!r.stack)r.stack=o;else if(o){const i=o.indexOf(`
103
103
  `),s=i===-1?-1:o.indexOf(`
104
104
  `,i+1),u=s===-1?"":o.slice(s+1);String(r.stack).endsWith(u)||(r.stack+=`
105
- `+o)}}catch{}}throw r}}_request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=Gt(this.defaults,n);const{transitional:r,paramsSerializer:l,headers:o}=n;r!==void 0&&io.assertOptions(r,{silentJSONParsing:_e.transitional(_e.boolean),forcedJSONParsing:_e.transitional(_e.boolean),clarifyTimeoutError:_e.transitional(_e.boolean),legacyInterceptorReqResOrdering:_e.transitional(_e.boolean),advertiseZstdAcceptEncoding:_e.transitional(_e.boolean)},!1),l!=null&&(h.isFunction(l)?n.paramsSerializer={serialize:l}:io.assertOptions(l,{encode:_e.function,serialize:_e.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),io.assertOptions(n,{baseUrl:_e.spelling("baseURL"),withXsrfToken:_e.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let i=o&&h.merge(o.common,o[n.method]);o&&h.forEach(["delete","get","head","post","put","patch","query","common"],S=>{delete o[S]}),n.headers=ge.concat(i,o);const s=[];let u=!0;this.interceptors.request.forEach(function(g){if(typeof g.runWhen=="function"&&g.runWhen(n)===!1)return;u=u&&g.synchronous;const E=n.transitional||Ts;E&&E.legacyInterceptorReqResOrdering?s.unshift(g.fulfilled,g.rejected):s.push(g.fulfilled,g.rejected)});const a=[];this.interceptors.response.forEach(function(g){a.push(g.fulfilled,g.rejected)});let d,m=0,y;if(!u){const S=[Vf.bind(this),void 0];for(S.unshift(...s),S.push(...a),y=S.length,d=Promise.resolve(n);m<y;)d=d.then(S[m++],S[m++]);return d}y=s.length;let v=n;for(;m<y;){const S=s[m++],g=s[m++];try{v=S(v)}catch(E){g.call(this,E);break}}try{d=Vf.call(this,v)}catch(S){return Promise.reject(S)}for(m=0,y=a.length;m<y;)d=d.then(a[m++],a[m++]);return d}getUri(t){t=Gt(this.defaults,t);const n=Df(t.baseURL,t.url,t.allowAbsoluteUrls);return Rf(n,t.params,t.paramsSerializer)}};h.forEach(["delete","get","head","options"],function(t){Zt.prototype[t]=function(n,r){return this.request(Gt(r||{},{method:t,url:n,data:(r||{}).data}))}}),h.forEach(["post","put","patch","query"],function(t){function n(r){return function(o,i,s){return this.request(Gt(s||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:o,data:i}))}}Zt.prototype[t]=n(),t!=="query"&&(Zt.prototype[t+"Form"]=n(!0))});let xy=class Jf{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 r=this;this.promise.then(l=>{if(!r._listeners)return;let o=r._listeners.length;for(;o-- >0;)r._listeners[o](l);r._listeners=null}),this.promise.then=l=>{let o;const i=new Promise(s=>{r.subscribe(s),o=s}).then(l);return i.cancel=function(){r.unsubscribe(o)},i},t(function(o,i,s){r.reason||(r.reason=new Tr(o,i,s),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 Jf(function(l){t=l}),cancel:t}}};function _y(e){return function(n){return e.apply(null,n)}}function Cy(e){return h.isObject(e)&&e.isAxiosError===!0}const Us={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,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(Us).forEach(([e,t])=>{Us[t]=e});function Qf(e){const t=new Zt(e),n=ff(Zt.prototype.request,t);return h.extend(n,Zt.prototype,t,{allOwnKeys:!0}),h.extend(n,t,null,{allOwnKeys:!0}),n.create=function(l){return Qf(Gt(e,l))},n}const G=Qf(Pr);G.Axios=Zt,G.CanceledError=Tr,G.CancelToken=xy,G.isCancel=Pf,G.VERSION=zs,G.toFormData=no,G.AxiosError=N,G.Cancel=G.CanceledError,G.all=function(t){return Promise.all(t)},G.spread=_y,G.isAxiosError=Cy,G.mergeConfig=Gt,G.AxiosHeaders=ge,G.formToJSON=e=>Of(h.isHTMLForm(e)?new FormData(e):e),G.getAdapter=Hf.getAdapter,G.HttpStatusCode=Us,G.default=G;const{Axios:Hy,AxiosError:Vy,CanceledError:Wy,isCancel:Qy,CancelToken:Ky,VERSION:Xy,all:qy,Cancel:Jy,isAxiosError:Yy,spread:Gy,toFormData:Zy,AxiosHeaders:by,HttpStatusCode:eg,formToJSON:tg,getAdapter:ng,mergeConfig:rg,create:lg}=G,Is=G.create({baseURL:"http://localhost:8000",headers:{"Content-Type":"application/json"}});Is.interceptors.response.use(e=>e,e=>{var r,l;const t=(r=e.response)==null?void 0:r.data,n=(l=e.response)==null?void 0:l.status;return console.error(`[PolarisRX] API error ${n}:`,(t==null?void 0:t.detail)??e.message),Promise.reject(e)});const Kf="polarisrx_user_uuid",Ry="polarisrx_session_id";function Ny(){const{apiKey:e}=Cr(),[t,n]=b.useState({sessionId:null,userUuid:null,ready:!1,error:null});return b.useEffect(()=>{let r=!1;const l=e?{"X-Pharmacy-Key":e}:{};async function o(){try{const i=localStorage.getItem(Kf),{data:s}=await Is.post("/widget/users/",i?{user_uuid:i}:{},{headers:l});if(r)return;const u=s.user_uuid;localStorage.setItem(Kf,u);const{data:a}=await Is.post("/widget/sessions/",{user_uuid:u},{headers:l});if(r)return;localStorage.setItem(Ry,a.id),n({sessionId:a.id,userUuid:u,ready:!0,error:null})}catch(i){r||n(s=>({...s,ready:!1,error:String(i)}))}}return o(),()=>{r=!0}},[e]),t}const Oy="#059669";function Py(){const[e,t]=b.useState(!1),{sessionId:n}=Ny(),{position:r="bottom-right",primaryColor:l=Oy}=Cr(),o=r==="bottom-left"?"fixed bottom-5 left-5":"fixed bottom-5 right-5";return D.jsxs("div",{className:`polarisrx-root ${o} z-[9999] flex flex-col items-end gap-3 font-sans`,children:[e&&D.jsx("div",{className:"animate-fadeSlideUp",children:D.jsx(Uh,{sessionId:n,onClose:()=>t(!1)})}),D.jsxs("button",{onClick:()=>t(i=>!i),style:{backgroundColor:l},className:"relative w-14 h-14 rounded-full hover:opacity-90 text-white shadow-lg hover:shadow-xl transition-all duration-200 flex items-center justify-center","aria-label":e?"Fechar chat":"Abrir chat",children:[e?D.jsx(af,{className:"w-6 h-6"}):D.jsx(Oh,{className:"w-6 h-6"}),!e&&D.jsx(Mh,{})]})]})}function Ty(e,t){const n=document.querySelector(e);if(!n)throw new Error(`[PolarisRX] Mount point "${e}" not found`);ho.createRoot(n).render(D.jsx(Lh,{value:t,children:D.jsx(Py,{})}))}typeof window<"u"&&(window.PolarisRXWidget={mount:Ty})});
105
+ `+o)}}catch{}}throw r}}_request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=Gt(this.defaults,n);const{transitional:r,paramsSerializer:l,headers:o}=n;r!==void 0&&io.assertOptions(r,{silentJSONParsing:_e.transitional(_e.boolean),forcedJSONParsing:_e.transitional(_e.boolean),clarifyTimeoutError:_e.transitional(_e.boolean),legacyInterceptorReqResOrdering:_e.transitional(_e.boolean),advertiseZstdAcceptEncoding:_e.transitional(_e.boolean)},!1),l!=null&&(h.isFunction(l)?n.paramsSerializer={serialize:l}:io.assertOptions(l,{encode:_e.function,serialize:_e.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),io.assertOptions(n,{baseUrl:_e.spelling("baseURL"),withXsrfToken:_e.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let i=o&&h.merge(o.common,o[n.method]);o&&h.forEach(["delete","get","head","post","put","patch","query","common"],S=>{delete o[S]}),n.headers=ge.concat(i,o);const s=[];let u=!0;this.interceptors.request.forEach(function(g){if(typeof g.runWhen=="function"&&g.runWhen(n)===!1)return;u=u&&g.synchronous;const E=n.transitional||Ts;E&&E.legacyInterceptorReqResOrdering?s.unshift(g.fulfilled,g.rejected):s.push(g.fulfilled,g.rejected)});const a=[];this.interceptors.response.forEach(function(g){a.push(g.fulfilled,g.rejected)});let d,m=0,y;if(!u){const S=[Vf.bind(this),void 0];for(S.unshift(...s),S.push(...a),y=S.length,d=Promise.resolve(n);m<y;)d=d.then(S[m++],S[m++]);return d}y=s.length;let v=n;for(;m<y;){const S=s[m++],g=s[m++];try{v=S(v)}catch(E){g.call(this,E);break}}try{d=Vf.call(this,v)}catch(S){return Promise.reject(S)}for(m=0,y=a.length;m<y;)d=d.then(a[m++],a[m++]);return d}getUri(t){t=Gt(this.defaults,t);const n=Df(t.baseURL,t.url,t.allowAbsoluteUrls);return Rf(n,t.params,t.paramsSerializer)}};h.forEach(["delete","get","head","options"],function(t){Zt.prototype[t]=function(n,r){return this.request(Gt(r||{},{method:t,url:n,data:(r||{}).data}))}}),h.forEach(["post","put","patch","query"],function(t){function n(r){return function(o,i,s){return this.request(Gt(s||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:o,data:i}))}}Zt.prototype[t]=n(),t!=="query"&&(Zt.prototype[t+"Form"]=n(!0))});let xy=class Jf{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 r=this;this.promise.then(l=>{if(!r._listeners)return;let o=r._listeners.length;for(;o-- >0;)r._listeners[o](l);r._listeners=null}),this.promise.then=l=>{let o;const i=new Promise(s=>{r.subscribe(s),o=s}).then(l);return i.cancel=function(){r.unsubscribe(o)},i},t(function(o,i,s){r.reason||(r.reason=new Tr(o,i,s),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 Jf(function(l){t=l}),cancel:t}}};function _y(e){return function(n){return e.apply(null,n)}}function Cy(e){return h.isObject(e)&&e.isAxiosError===!0}const Us={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,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(Us).forEach(([e,t])=>{Us[t]=e});function Qf(e){const t=new Zt(e),n=ff(Zt.prototype.request,t);return h.extend(n,Zt.prototype,t,{allOwnKeys:!0}),h.extend(n,t,null,{allOwnKeys:!0}),n.create=function(l){return Qf(Gt(e,l))},n}const G=Qf(Pr);G.Axios=Zt,G.CanceledError=Tr,G.CancelToken=xy,G.isCancel=Pf,G.VERSION=zs,G.toFormData=no,G.AxiosError=N,G.Cancel=G.CanceledError,G.all=function(t){return Promise.all(t)},G.spread=_y,G.isAxiosError=Cy,G.mergeConfig=Gt,G.AxiosHeaders=ge,G.formToJSON=e=>Of(h.isHTMLForm(e)?new FormData(e):e),G.getAdapter=Hf.getAdapter,G.HttpStatusCode=Us,G.default=G;const{Axios:Hy,AxiosError:Vy,CanceledError:Wy,isCancel:Qy,CancelToken:Ky,VERSION:Xy,all:qy,Cancel:Jy,isAxiosError:Yy,spread:Gy,toFormData:Zy,AxiosHeaders:by,HttpStatusCode:eg,formToJSON:tg,getAdapter:ng,mergeConfig:rg,create:lg}=G,Is=G.create({baseURL:"https://api.polarisrx.com.br",headers:{"Content-Type":"application/json"}});Is.interceptors.response.use(e=>e,e=>{var r,l;const t=(r=e.response)==null?void 0:r.data,n=(l=e.response)==null?void 0:l.status;return console.error(`[PolarisRX] API error ${n}:`,(t==null?void 0:t.detail)??e.message),Promise.reject(e)});const Kf="polarisrx_user_uuid",Ry="polarisrx_session_id";function Ny(){const{apiKey:e}=Cr(),[t,n]=b.useState({sessionId:null,userUuid:null,ready:!1,error:null});return b.useEffect(()=>{let r=!1;const l=e?{"X-Pharmacy-Key":e}:{};async function o(){try{const i=localStorage.getItem(Kf),{data:s}=await Is.post("/widget/users/",i?{user_uuid:i}:{},{headers:l});if(r)return;const u=s.user_uuid;localStorage.setItem(Kf,u);const{data:a}=await Is.post("/widget/sessions/",{user_uuid:u},{headers:l});if(r)return;localStorage.setItem(Ry,a.id),n({sessionId:a.id,userUuid:u,ready:!0,error:null})}catch(i){r||n(s=>({...s,ready:!1,error:String(i)}))}}return o(),()=>{r=!0}},[e]),t}const Oy="#059669";function Py(){const[e,t]=b.useState(!1),{sessionId:n}=Ny(),{position:r="bottom-right",primaryColor:l=Oy}=Cr(),o=r==="bottom-left"?"fixed bottom-5 left-5":"fixed bottom-5 right-5";return D.jsxs("div",{className:`polarisrx-root ${o} z-[9999] flex flex-col items-end gap-3 font-sans`,children:[e&&D.jsx("div",{className:"animate-fadeSlideUp",children:D.jsx(Uh,{sessionId:n,onClose:()=>t(!1)})}),D.jsxs("button",{onClick:()=>t(i=>!i),style:{backgroundColor:l},className:"relative w-14 h-14 rounded-full hover:opacity-90 text-white shadow-lg hover:shadow-xl transition-all duration-200 flex items-center justify-center","aria-label":e?"Fechar chat":"Abrir chat",children:[e?D.jsx(af,{className:"w-6 h-6"}):D.jsx(Oh,{className:"w-6 h-6"}),!e&&D.jsx(Mh,{})]})]})}function Ty(e,t){const n=document.querySelector(e);if(!n)throw new Error(`[PolarisRX] Mount point "${e}" not found`);ho.createRoot(n).render(D.jsx(Lh,{value:t,children:D.jsx(Py,{})}))}typeof window<"u"&&(window.PolarisRXWidget={mount:Ty})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "polarisrx",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",