sm-click-library-ui 0.0.383 → 0.0.384

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.
@@ -18251,19 +18251,20 @@ var es;
18251
18251
  e.UTF8 = "utf8", e.ASCII = "ascii", e.UTF16 = "utf16";
18252
18252
  })(es || (es = {}));
18253
18253
  const kf = sr("Filesystem", {
18254
- web: () => import("./web-DRLxitDq.js").then((e) => new e.FilesystemWeb())
18254
+ web: () => import("./web-Ce0ZGANs.js").then((e) => new e.FilesystemWeb())
18255
18255
  });
18256
18256
  xf();
18257
18257
  const wf = sr("Media", {
18258
- web: () => import("./web-D45SYn4Z.js").then((e) => new e.MediaWeb())
18258
+ web: () => import("./web-DwYJWn6N.js").then((e) => new e.MediaWeb())
18259
18259
  }), Cf = sr("Share", {
18260
- web: () => import("./web-CtyuR8Ay.js").then((e) => new e.ShareWeb())
18260
+ web: () => import("./web-BYsOpl3G.js").then((e) => new e.ShareWeb())
18261
18261
  });
18262
18262
  async function Mf(e = { url, type, title }, t = "", a) {
18263
18263
  try {
18264
18264
  console.log("funcionou");
18265
18265
  const n = await fetch(e.url);
18266
- if (!n.ok) throw new Error("Falha ao buscar o arquivo");
18266
+ if (!n.ok)
18267
+ throw new Error("Falha ao buscar o arquivo", JSON.stringify(n.ok));
18267
18268
  const r = await n.blob(), i = await convertBlobToBase64(r), o = typeof e.type == "string" && e.type.includes("/") ? e.type.split("/")[1] : e.type || "unknown", s = hashString(e.url), u = e.title || `${t === "file" ? `smclick-${o}` : t}-${s}.${o}`, m = await kf.writeFile({
18268
18269
  path: u,
18269
18270
  data: i,
@@ -18297,7 +18298,12 @@ async function Mf(e = { url, type, title }, t = "", a) {
18297
18298
  2e3
18298
18299
  );
18299
18300
  } catch (n) {
18300
- if (console.error(JSON.stringify(n)), n.errorMessage === "Share canceled") return;
18301
+ if (console.error({
18302
+ message: n.message,
18303
+ stack: n.stack,
18304
+ name: n.name,
18305
+ ...n
18306
+ }), console.error(JSON.stringify(n)), n.errorMessage === "Share canceled") return;
18301
18307
  Tr(
18302
18308
  {
18303
18309
  group: "error",
@@ -1,4 +1,4 @@
1
- import { c as s, a as e, d as i, i as r, s as b } from "./index-DNqxu-_s.js";
1
+ import { c as s, a as e, d as i, i as r, s as b } from "./index-1dgik5G_.js";
2
2
  export {
3
3
  s as attLibAttendants,
4
4
  e as attLibDeparts,
@@ -89,7 +89,7 @@
89
89
  <source src="${u}" type="${m}" />
90
90
  Seu navegador não suporta vídeo.
91
91
  </video>
92
- `,caption:c}]):Ye.show([{src:u,type:"image",caption:c}]))};function s(u,m=1){return new Promise((c,f)=>{const h=document.createElement("video");h.src=u,h.crossOrigin="anonymous",h.muted=!0,h.playsInline=!0,h.preload="auto",h.addEventListener("loadeddata",()=>{h.readyState>=2&&(h.currentTime=m)}),h.addEventListener("seeked",()=>{const y=document.createElement("canvas");y.width=h.videoWidth,y.height=h.videoHeight,y.getContext("2d").drawImage(h,0,0,y.width,y.height);const x=y.toDataURL("image/png");c(x)}),h.addEventListener("error",y=>{f("Erro ao carregar vídeo para thumbnail.")})})}const l=u=>typeof u=="string"&&u.startsWith("data:")&&u.includes(";base64,"),d=u=>u?u.startsWith("video/"):void 0,p=u=>{const m=Math.floor(u/60),c=(u%60).toFixed(0),f=m.toString().padStart(2,"0"),h=c.toString().padStart(2,"0");return`${f}:${h}`};return t.onMounted(async()=>{try{n.value=await s(a.base64)}catch(u){console.error(u)}}),(u,m)=>(t.openBlock(),t.createElementBlock("main",{class:t.normalizeClass({main_preview_files_container_message:e.mode==="message",main_preview_files_container_miniature:e.mode==="miniature","main_preview_files_container_preview bg-base-200":e.mode==="preview"})},[e.mimetype==="application/pdf"&&e.mode!=="miniature"?(t.openBlock(),t.createElementBlock("iframe",{key:0,class:"iframe_preview_files",src:e.base64,frameborder:"0"},null,8,a8)):e.mimetype==="application/pdf"&&e.mode==="miniature"?(t.openBlock(),t.createElementBlock("svg",n8,m[6]||(m[6]=[t.createElementVNode("path",{"fill-rule":"evenodd",d:"M9 2.221V7H4.221a2 2 0 0 1 .365-.5L8.5 2.586A2 2 0 0 1 9 2.22ZM11 2v5a2 2 0 0 1-2 2H4a2 2 0 0 0-2 2v7a2 2 0 0 0 2 2 2 2 0 0 0 2 2h12a2 2 0 0 0 2-2 2 2 0 0 0 2-2v-7a2 2 0 0 0-2-2V4a2 2 0 0 0-2-2h-7Zm-6 9a1 1 0 0 0-1 1v5a1 1 0 1 0 2 0v-1h.5a2.5 2.5 0 0 0 0-5H5Zm1.5 3H6v-1h.5a.5.5 0 0 1 0 1Zm4.5-3a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1h1.376A2.626 2.626 0 0 0 15 15.375v-1.75A2.626 2.626 0 0 0 12.375 11H11Zm1 5v-3h.375a.626.626 0 0 1 .625.626v1.748a.625.625 0 0 1-.626.626H12Zm5-5a1 1 0 0 0-1 1v5a1 1 0 1 0 2 0v-1h1a1 1 0 1 0 0-2h-1v-1h1a1 1 0 1 0 0-2h-2Z","clip-rule":"evenodd"},null,-1)]))):e.mimetype==="image/png"||e.mimetype==="image/jpeg"?(t.openBlock(),t.createElementBlock("img",{key:2,onClick:m[0]||(m[0]=c=>i(e.base64,e.mimetype)),class:t.normalizeClass(["preview_img",e.mode]),src:e.base64},null,10,r8)):e.mimetype==="image/svg+xml"?(t.openBlock(),t.createElementBlock("img",{key:3,onClick:m[1]||(m[1]=c=>i(e.base64,e.mimetype)),class:t.normalizeClass(["preview_img",e.mode]),src:l(e.base64)?e.base64:e.base64.replace("+","%2B")},null,10,o8)):d(e.mimetype)&&e.mode==="preview"?(t.openBlock(),t.createElementBlock("video",{key:4,width:"300",height:"150",controls:"",src:e.base64},[t.createElementVNode("source",{src:e.base64,type:e.mimetype},null,8,s8)],8,i8)):d(e.mimetype)&&e.mode==="message"?(t.openBlock(),t.createElementBlock("button",{key:5,onClick:m[2]||(m[2]=c=>i(e.base64,e.mimetype)),class:"video_message_preview_container"},[n.value?(t.openBlock(),t.createElementBlock("section",l8,[t.createElementVNode("div",c8,[m[11]||(m[11]=t.createElementVNode("svg",{class:"size-12 text-white","aria-hidden":"true",xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",fill:"currentColor",viewBox:"0 0 24 24"},[t.createElementVNode("path",{"fill-rule":"evenodd",d:"M8.6 5.2A1 1 0 0 0 7 6v12a1 1 0 0 0 1.6.8l8-6a1 1 0 0 0 0-1.6l-8-6Z","clip-rule":"evenodd"})],-1)),t.createElementVNode("div",d8,[(t.openBlock(),t.createElementBlock("svg",u8,m[7]||(m[7]=[t.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"m19 9-7 7-7-7"},null,-1)]))),(t.openBlock(),t.createElementBlock("svg",m8,m[8]||(m[8]=[t.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"m19 9-7 7-7-7"},null,-1)]))),(t.openBlock(),t.createElementBlock("svg",f8,m[9]||(m[9]=[t.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"m19 9-7 7-7-7"},null,-1)]))),(t.openBlock(),t.createElementBlock("svg",h8,m[10]||(m[10]=[t.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"m19 9-7 7-7-7"},null,-1)])))])]),t.createElementVNode("img",{class:t.normalizeClass(["preview_img",e.mode]),src:n.value},null,10,p8)])):(t.openBlock(),t.createElementBlock("span",g8,"Carregando..."))])):d(e.mimetype)&&e.mode==="miniature"?(t.openBlock(),t.createElementBlock("svg",y8,m[12]||(m[12]=[t.createElementVNode("path",{"fill-rule":"evenodd",d:"M14 7a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V7Zm2 9.387 4.684 1.562A1 1 0 0 0 22 17V7a1 1 0 0 0-1.316-.949L16 7.613v8.774Z","clip-rule":"evenodd"},null,-1)]))):e.mimetype==="audio/mpeg"&&e.mode!=="miniature"||e.mimetype==="application/octet-stream"&&e.mode!=="miniature"?(t.openBlock(),t.createElementBlock("section",k8,[t.createVNode(e1,{avatar:e.avatar,audio:e.base64,onDuration:m[3]||(m[3]=c=>r.value=c),onCurrentTime:m[4]||(m[4]=c=>o.value=c)},null,8,["avatar","audio"])])):e.mimetype==="audio/mpeg"&&e.mode==="miniature"?(t.openBlock(),t.createElementBlock("svg",b8,m[13]||(m[13]=[t.createElementVNode("path",{"fill-rule":"evenodd",d:"M5 8a1 1 0 0 1 1 1v3a4.006 4.006 0 0 0 4 4h4a4.006 4.006 0 0 0 4-4V9a1 1 0 1 1 2 0v3.001A6.006 6.006 0 0 1 14.001 18H13v2h2a1 1 0 1 1 0 2H9a1 1 0 1 1 0-2h2v-2H9.999A6.006 6.006 0 0 1 4 12.001V9a1 1 0 0 1 1-1Z","clip-rule":"evenodd"},null,-1),t.createElementVNode("path",{d:"M7 6a4 4 0 0 1 4-4h2a4 4 0 0 1 4 4v5a4 4 0 0 1-4 4h-2a4 4 0 0 1-4-4V6Z"},null,-1)]))):(t.openBlock(),t.createElementBlock("div",{key:9,class:t.normalizeClass(e.mode==="message"?"generic_files":"")},[m[14]||(m[14]=t.createElementVNode("div",null,[t.createElementVNode("svg",{class:"size-8 text-white","aria-hidden":"true",xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",fill:"currentColor",viewBox:"0 0 24 24"},[t.createElementVNode("path",{"fill-rule":"evenodd",d:"M9 2.221V7H4.221a2 2 0 0 1 .365-.5L8.5 2.586A2 2 0 0 1 9 2.22ZM11 2v5a2 2 0 0 1-2 2H4v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2h-7Z","clip-rule":"evenodd"})])],-1)),e.mode==="message"?(t.openBlock(),t.createElementBlock("span",x8,[t.createElementVNode("p",w8,t.toDisplayString(e.fileName),1),t.createElementVNode("button",{class:"download_btn_generic_files",onClick:m[5]||(m[5]=c=>u.$emit("download"))}," Baixar arquivo ")])):t.createCommentVNode("",!0)],2)),e.mode==="message"?(t.openBlock(),t.createElementBlock("div",v8,[t.renderSlot(u.$slots,"content-message",{},void 0,!0),t.createElementVNode("div",{class:t.normalizeClass([r.value?"justify-between":" justify-end","flex w-full"])},[r.value?(t.openBlock(),t.createElementBlock("p",E8,t.toDisplayString(p(r.value))+" - "+t.toDisplayString(o.value?p(o.value):"00:00"),1)):t.createCommentVNode("",!0),t.renderSlot(u.$slots,"time-message",{},void 0,!0)],2)])):t.createCommentVNode("",!0)],2))}},[["__scopeId","data-v-f8ed200a"]]),C8={props:{audioStream:MediaStream},data(){return{audioContext:null,analyser:null}},mounted(){this.initializeAudio()},methods:{initializeAudio(){this.audioContext=new(window.AudioContext||window.webkitAudioContext),this.analyser=this.audioContext.createAnalyser();const e=this.$refs.canvas,a=e.getContext("2d");this.audioContext.createMediaStreamSource(this.audioStream).connect(this.analyser),this.analyser.fftSize=256;const r=this.analyser.frequencyBinCount,o=new Uint8Array(r),i=()=>{this.analyser.getByteFrequencyData(o),a.clearRect(0,0,e.width,e.height);const s=e.width/r*2.5,l=e.height/2;let d=0;a.strokeStyle="green",a.lineWidth=2,a.beginPath(),a.moveTo(0,l),a.lineTo(e.width,l),a.stroke(),o.forEach(p=>{const u=p;a.fillStyle=`rgb(50, ${u+100}, 50)`,a.fillRect(d,l-u/2,s,u),d+=s+1}),this.audioStream.active&&requestAnimationFrame(i)};i()}}},S8={ref:"canvas",width:"200",height:"40",class:"mx-auto flex items-center rounded"};function M8(e,a,n,r,o,i){return t.openBlock(),t.createElementBlock("div",null,[t.createElementVNode("canvas",S8,null,512)])}const B8=qe(C8,[["render",M8],["__scopeId","data-v-d91f4ade"]]),A8={key:0,class:"flex w-full items-center space-x-3 text-white dark:text-black"},V8=["disabled"],D8=["disabled"],_8={key:0,class:"size-4 hover:text-red-500","aria-hidden":"true",xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",viewBox:"0 0 10 16"},N8={key:1,xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor",class:"w-5 hover:text-emerald-500"},T8={key:5,class:"flex w-full items-center space-x-2"},P8={class:"text-xs"},O8={key:0},F8={key:1,class:"flex items-center px-2 pr-[21px]"},L8=qe({__name:"audioRecorder",props:{canSendMessage:Boolean,sendAudioToAttendant:{type:Function,required:!0},selectedAttendant:{type:Object,required:!0},attendant:{required:!0}},emits:["audio-sent","recording","b64Audio"],setup(e,{emit:a}){const n=e,r=a,o=t.ref(null),i=t.ref(!1),s=t.ref(!1),l=t.ref(0),d=t.ref(0),p=t.ref(null),u=t.ref(null),m=t.ref(null),c=t.ref(null),f=t.ref(0),h=t.ref(0),y=t.ref(null),k=t.ref(!1),x=t.ref(!1),w=G=>{f.value=G},b=G=>{h.value=G},B=G=>{const S=Math.floor(G/60),I=(G%60).toFixed(0),j=S.toString().padStart(2,"0"),U=I.toString().padStart(2,"0");return`${j}:${U}`},A=async()=>{try{u.value=null,c.value=await navigator.mediaDevices.getUserMedia({audio:!0}),o.value=new MediaRecorder(c.value),o.value.ondataavailable=_,o.value.start(),E(),i.value=!0,r("recording",!0)}catch(G){console.error("Erro ao iniciar a gravação:",G)}},_=G=>{G.data.size>0&&!k.value&&(p.value=new Blob([G.data]),y.value=URL.createObjectURL(p.value),T())},E=()=>{let G=Date.now();m.value=setInterval(()=>{l.value=d.value+Math.floor((Date.now()-G)/1e3)},1e3)},C=async()=>{u.value=null,o.value&&i.value&&(s.value?(o.value.resume(),E()):(o.value.pause(),clearInterval(m.value),d.value=l.value),s.value=!s.value)},V=async()=>{o.value&&i.value&&(await o.value.stop(),clearInterval(m.value),i.value=!1,s.value=!1,T()),c.value&&c.value.getTracks().forEach(G=>G.stop()),console.log(u.value)},T=async()=>{if(p.value){const G=new Blob([p.value],{type:"audio/mpeg"}),S=new FileReader;S.onload=()=>{u.value=S.result},S.readAsDataURL(G)}},Y=async()=>{x.value=!0,r("b64Audio",u.value);const S={type:"file",media:{name:"audio",mimetype:(I=>I?I.split(";")[0].split(":")[1]:null)(u.value),data:u.value}};await n.sendAudioToAttendant(n.selectedAttendant.id,S,n.attendant,!0),r("recording",!1),x.value=!1,c.value=null,u.value=null,p.value=null,i.value=!1,s.value=!1,l.value=0},X=async()=>{k.value=!0,i.value=!1,r("recording",!1),await o.value.stop(),c.value&&(c.value.getTracks().forEach(G=>G.stop()),c.value=null),p.value=null,clearInterval(m.value),u.value=null,s.value=!1,l.value=0};return(G,S)=>{var I;return x.value?(t.openBlock(),t.createElementBlock("div",F8,S[9]||(S[9]=[t.createElementVNode("span",{class:"loader-audio-recorder"},null,-1)]))):(t.openBlock(),t.createElementBlock("div",A8,[!i.value&&!u.value?(t.openBlock(),t.createElementBlock("button",{key:0,class:t.normalizeClass(["send-audio-button",{recording:i.value}]),disabled:i.value||!e.canSendMessage,onClick:S[0]||(S[0]=j=>(A(),d.value=0,k.value=!1))},S[3]||(S[3]=[t.createElementVNode("svg",{class:"start-recording-icon","aria-hidden":"true",xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",viewBox:"0 0 16 19"},[t.createElementVNode("path",{d:"M15 5a1 1 0 0 0-1 1v3a4 4 0 0 1-4 4H6a4 4 0 0 1-4-4V6a1 1 0 0 0-2 0v3a6.006 6.006 0 0 0 6 6h1v2H5a1 1 0 0 0 0 2h6a1 1 0 0 0 0-2H9v-2h1a6.006 6.006 0 0 0 6-6V6a1 1 0 0 0-1-1Z"}),t.createElementVNode("path",{d:"M9 0H7a3 3 0 0 0-3 3v5a3 3 0 0 0 3 3h2a3 3 0 0 0 3-3V3a3 3 0 0 0-3-3Z"})],-1)]),10,V8)):t.createCommentVNode("",!0),c.value?(t.openBlock(),t.createElementBlock("button",{key:1,class:"rounded-full bg-red-500 p-1.5 hover:bg-red-600",onClick:S[1]||(S[1]=j=>X())},S[4]||(S[4]=[t.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor",class:"size-4"},[t.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M14.74 9l-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 01-2.244 2.077H8.084a2.25 2.25 0 01-2.244-2.077L4.772 5.79m14.456 0a48.108 48.108 0 00-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 013.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 00-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 00-7.5 0"})],-1)]))):t.createCommentVNode("",!0),i.value?(t.openBlock(),t.createElementBlock("button",{key:2,disabled:!i.value&&!s.value,onClick:C},[s.value?(t.openBlock(),t.createElementBlock("svg",N8,S[6]||(S[6]=[t.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M21 7.5V18M15 7.5V18M3 16.811V8.69c0-.864.933-1.406 1.683-.977l7.108 4.061a1.125 1.125 0 010 1.954l-7.108 4.061A1.125 1.125 0 013 16.811z"},null,-1)]))):(t.openBlock(),t.createElementBlock("svg",_8,S[5]||(S[5]=[t.createElementVNode("path",{"fill-rule":"evenodd",d:"M0 .8C0 .358.32 0 .714 0h1.429c.394 0 .714.358.714.8v14.4c0 .442-.32.8-.714.8H.714a.678.678 0 0 1-.505-.234A.851.851 0 0 1 0 15.2V.8Zm7.143 0c0-.442.32-.8.714-.8h1.429c.19 0 .37.084.505.234.134.15.209.354.209.566v14.4c0 .442-.32.8-.714.8H7.857c-.394 0-.714-.358-.714-.8V.8Z","clip-rule":"evenodd"},null,-1)])))],8,D8)):t.createCommentVNode("",!0),(i.value||p.value)&&!u.value?(t.openBlock(),t.createElementBlock("button",{key:3,class:"rounded-full p-1.5 hover:bg-gray-100 hover:text-light",onClick:V},S[7]||(S[7]=[t.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor",class:"size-4"},[t.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M5.25 7.5A2.25 2.25 0 017.5 5.25h9a2.25 2.25 0 012.25 2.25v9a2.25 2.25 0 01-2.25 2.25h-9a2.25 2.25 0 01-2.25-2.25v-9z"})],-1)]))):t.createCommentVNode("",!0),c.value&&i.value&&!s.value?(t.openBlock(),t.createBlock(B8,{key:4,"audio-stream":c.value},null,8,["audio-stream"])):t.createCommentVNode("",!0),u.value?(t.openBlock(),t.createElementBlock("div",T8,[t.createVNode(e1,{avatar:((I=e.attendant)==null?void 0:I.photo)||null,audio:u.value,onDuration:w,onCurrentTime:b},null,8,["avatar","audio"]),t.createElementVNode("main",P8,[t.createElementVNode("div",null,t.toDisplayString(B(h.value)),1),i.value||p.value?(t.openBlock(),t.createElementBlock("div",O8,t.toDisplayString(B(l.value)),1)):t.createCommentVNode("",!0)])])):t.createCommentVNode("",!0),u.value?(t.openBlock(),t.createElementBlock("button",{key:6,class:"rounded-full p-2 hover:bg-base-100",onClick:S[2]||(S[2]=j=>Y())},S[8]||(S[8]=[t.createElementVNode("svg",{class:"size-5 text-base-200 rotate-90","aria-hidden":"true",xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",fill:"currentColor",viewBox:"0 0 24 24"},[t.createElementVNode("path",{"fill-rule":"evenodd",d:"M12 2a1 1 0 0 1 .932.638l7 18a1 1 0 0 1-1.326 1.281L13 19.517V13a1 1 0 1 0-2 0v6.517l-5.606 2.402a1 1 0 0 1-1.326-1.281l7-18A1 1 0 0 1 12 2Z","clip-rule":"evenodd"})],-1)]))):t.createCommentVNode("",!0)]))}}},[["__scopeId","data-v-db980715"]]);/*! Capacitor: https://capacitorjs.com/ - MIT License */var Ja;(function(e){e.Unimplemented="UNIMPLEMENTED",e.Unavailable="UNAVAILABLE"})(Ja||(Ja={}));class Ho extends Error{constructor(a,n,r){super(a),this.message=a,this.code=n,this.data=r}}const $8=e=>{var a,n;return e!=null&&e.androidBridge?"android":!((n=(a=e==null?void 0:e.webkit)===null||a===void 0?void 0:a.messageHandlers)===null||n===void 0)&&n.bridge?"ios":"web"},H8=e=>{const a=e.CapacitorCustomPlatform||null,n=e.Capacitor||{},r=n.Plugins=n.Plugins||{},o=()=>a!==null?a.name:$8(e),i=()=>o()!=="web",s=m=>{const c=p.get(m);return!!(c!=null&&c.platforms.has(o())||l(m))},l=m=>{var c;return(c=n.PluginHeaders)===null||c===void 0?void 0:c.find(f=>f.name===m)},d=m=>e.console.error(m),p=new Map,u=(m,c={})=>{const f=p.get(m);if(f)return console.warn(`Capacitor plugin "${m}" already registered. Cannot register plugins twice.`),f.proxy;const h=o(),y=l(m);let k;const x=async()=>(!k&&h in c?k=typeof c[h]=="function"?k=await c[h]():k=c[h]:a!==null&&!k&&"web"in c&&(k=typeof c.web=="function"?k=await c.web():k=c.web),k),w=(C,V)=>{var T,Y;if(y){const X=y==null?void 0:y.methods.find(G=>V===G.name);if(X)return X.rtype==="promise"?G=>n.nativePromise(m,V.toString(),G):(G,S)=>n.nativeCallback(m,V.toString(),G,S);if(C)return(T=C[V])===null||T===void 0?void 0:T.bind(C)}else{if(C)return(Y=C[V])===null||Y===void 0?void 0:Y.bind(C);throw new Ho(`"${m}" plugin is not implemented on ${h}`,Ja.Unimplemented)}},b=C=>{let V;const T=(...Y)=>{const X=x().then(G=>{const S=w(G,C);if(S){const I=S(...Y);return V=I==null?void 0:I.remove,I}else throw new Ho(`"${m}.${C}()" is not implemented on ${h}`,Ja.Unimplemented)});return C==="addListener"&&(X.remove=async()=>V()),X};return T.toString=()=>`${C.toString()}() { [capacitor code] }`,Object.defineProperty(T,"name",{value:C,writable:!1,configurable:!1}),T},B=b("addListener"),A=b("removeListener"),_=(C,V)=>{const T=B({eventName:C},V),Y=async()=>{const G=await T;A({eventName:C,callbackId:G},V)},X=new Promise(G=>T.then(()=>G({remove:Y})));return X.remove=async()=>{console.warn("Using addListener() without 'await' is deprecated."),await Y()},X},E=new Proxy({},{get(C,V){switch(V){case"$$typeof":return;case"toJSON":return()=>({});case"addListener":return y?_:B;case"removeListener":return A;default:return b(V)}}});return r[m]=E,p.set(m,{name:m,proxy:E,platforms:new Set([...Object.keys(c),...y?[h]:[]])}),E};return n.convertFileSrc||(n.convertFileSrc=m=>m),n.getPlatform=o,n.handleError=d,n.isNativePlatform=i,n.isPluginAvailable=s,n.registerPlugin=u,n.Exception=Ho,n.DEBUG=!!n.DEBUG,n.isLoggingEnabled=!!n.isLoggingEnabled,n},Ro=(e=>e.Capacitor=H8(e))(typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{}),Cn=Ro.registerPlugin;class Sn{constructor(){this.listeners={},this.retainedEventArguments={},this.windowListeners={}}addListener(a,n){let r=!1;this.listeners[a]||(this.listeners[a]=[],r=!0),this.listeners[a].push(n);const i=this.windowListeners[a];i&&!i.registered&&this.addWindowListener(i),r&&this.sendRetainedArgumentsForEvent(a);const s=async()=>this.removeListener(a,n);return Promise.resolve({remove:s})}async removeAllListeners(){this.listeners={};for(const a in this.windowListeners)this.removeWindowListener(this.windowListeners[a]);this.windowListeners={}}notifyListeners(a,n,r){const o=this.listeners[a];if(!o){if(r){let i=this.retainedEventArguments[a];i||(i=[]),i.push(n),this.retainedEventArguments[a]=i}return}o.forEach(i=>i(n))}hasListeners(a){var n;return!!(!((n=this.listeners[a])===null||n===void 0)&&n.length)}registerWindowListener(a,n){this.windowListeners[n]={registered:!1,windowEventName:a,pluginEventName:n,handler:r=>{this.notifyListeners(n,r)}}}unimplemented(a="not implemented"){return new Ro.Exception(a,Ja.Unimplemented)}unavailable(a="not available"){return new Ro.Exception(a,Ja.Unavailable)}async removeListener(a,n){const r=this.listeners[a];if(!r)return;const o=r.indexOf(n);this.listeners[a].splice(o,1),this.listeners[a].length||this.removeWindowListener(this.windowListeners[a])}addWindowListener(a){window.addEventListener(a.windowEventName,a.handler),a.registered=!0}removeWindowListener(a){a&&(window.removeEventListener(a.windowEventName,a.handler),a.registered=!1)}sendRetainedArgumentsForEvent(a){const n=this.retainedEventArguments[a];n&&(delete this.retainedEventArguments[a],n.forEach(r=>{this.notifyListeners(a,r)}))}}const t1=e=>encodeURIComponent(e).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape),a1=e=>e.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent);class R8 extends Sn{async getCookies(){const a=document.cookie,n={};return a.split(";").forEach(r=>{if(r.length<=0)return;let[o,i]=r.replace(/=/,"CAP_COOKIE").split("CAP_COOKIE");o=a1(o).trim(),i=a1(i).trim(),n[o]=i}),n}async setCookie(a){try{const n=t1(a.key),r=t1(a.value),o=`; expires=${(a.expires||"").replace("expires=","")}`,i=(a.path||"/").replace("path=",""),s=a.url!=null&&a.url.length>0?`domain=${a.url}`:"";document.cookie=`${n}=${r||""}${o}; path=${i}; ${s};`}catch(n){return Promise.reject(n)}}async deleteCookie(a){try{document.cookie=`${a.key}=; Max-Age=0`}catch(n){return Promise.reject(n)}}async clearCookies(){try{const a=document.cookie.split(";")||[];for(const n of a)document.cookie=n.replace(/^ +/,"").replace(/=.*/,`=;expires=${new Date().toUTCString()};path=/`)}catch(a){return Promise.reject(a)}}async clearAllCookies(){try{await this.clearCookies()}catch(a){return Promise.reject(a)}}}Cn("CapacitorCookies",{web:()=>new R8});const z8=async e=>new Promise((a,n)=>{const r=new FileReader;r.onload=()=>{const o=r.result;a(o.indexOf(",")>=0?o.split(",")[1]:o)},r.onerror=o=>n(o),r.readAsDataURL(e)}),I8=(e={})=>{const a=Object.keys(e);return Object.keys(e).map(o=>o.toLocaleLowerCase()).reduce((o,i,s)=>(o[i]=e[a[s]],o),{})},G8=(e,a=!0)=>e?Object.entries(e).reduce((r,o)=>{const[i,s]=o;let l,d;return Array.isArray(s)?(d="",s.forEach(p=>{l=a?encodeURIComponent(p):p,d+=`${i}=${l}&`}),d.slice(0,-1)):(l=a?encodeURIComponent(s):s,d=`${i}=${l}`),`${r}&${d}`},"").substr(1):null,n1=(e,a={})=>{const n=Object.assign({method:e.method||"GET",headers:e.headers},a),o=I8(e.headers)["content-type"]||"";if(typeof e.data=="string")n.body=e.data;else if(o.includes("application/x-www-form-urlencoded")){const i=new URLSearchParams;for(const[s,l]of Object.entries(e.data||{}))i.set(s,l);n.body=i.toString()}else if(o.includes("multipart/form-data")||e.data instanceof FormData){const i=new FormData;if(e.data instanceof FormData)e.data.forEach((l,d)=>{i.append(d,l)});else for(const l of Object.keys(e.data))i.append(l,e.data[l]);n.body=i;const s=new Headers(n.headers);s.delete("content-type"),n.headers=s}else(o.includes("application/json")||typeof e.data=="object")&&(n.body=JSON.stringify(e.data));return n};class j8 extends Sn{async request(a){const n=n1(a,a.webFetchExtra),r=G8(a.params,a.shouldEncodeUrlParams),o=r?`${a.url}?${r}`:a.url,i=await fetch(o,n),s=i.headers.get("content-type")||"";let{responseType:l="text"}=i.ok?a:{};s.includes("application/json")&&(l="json");let d,p;switch(l){case"arraybuffer":case"blob":p=await i.blob(),d=await z8(p);break;case"json":d=await i.json();break;case"document":case"text":default:d=await i.text()}const u={};return i.headers.forEach((m,c)=>{u[c]=m}),{data:d,headers:u,status:i.status,url:i.url}}async get(a){return this.request(Object.assign(Object.assign({},a),{method:"GET"}))}async post(a){return this.request(Object.assign(Object.assign({},a),{method:"POST"}))}async put(a){return this.request(Object.assign(Object.assign({},a),{method:"PUT"}))}async patch(a){return this.request(Object.assign(Object.assign({},a),{method:"PATCH"}))}async delete(a){return this.request(Object.assign(Object.assign({},a),{method:"DELETE"}))}}Cn("CapacitorHttp",{web:()=>new j8});function q8(e){e.CapacitorUtils.Synapse=new Proxy({},{get(a,n){return new Proxy({},{get(r,o){return(i,s,l)=>{const d=e.Capacitor.Plugins[n];if(d===void 0){l(new Error(`Capacitor plugin ${n} not found`));return}if(typeof d[o]!="function"){l(new Error(`Method ${o} not found in Capacitor plugin ${n}`));return}(async()=>{try{const p=await d[o](i);s(p)}catch(p){l(p)}})()}}})}})}function W8(e){e.CapacitorUtils.Synapse=new Proxy({},{get(a,n){return e.cordova.plugins[n]}})}function Y8(e=!1){typeof window>"u"||(window.CapacitorUtils=window.CapacitorUtils||{},window.Capacitor!==void 0&&!e?q8(window):window.cordova!==void 0&&W8(window))}var zo;(function(e){e.Documents="DOCUMENTS",e.Data="DATA",e.Library="LIBRARY",e.Cache="CACHE",e.External="EXTERNAL",e.ExternalStorage="EXTERNAL_STORAGE",e.ExternalCache="EXTERNAL_CACHE",e.LibraryNoCloud="LIBRARY_NO_CLOUD",e.Temporary="TEMPORARY"})(zo||(zo={}));var Io;(function(e){e.UTF8="utf8",e.ASCII="ascii",e.UTF16="utf16"})(Io||(Io={}));const U8=Cn("Filesystem",{web:()=>Promise.resolve().then(()=>Sw).then(e=>new e.FilesystemWeb)});Y8();const X8=Cn("Media",{web:()=>Promise.resolve().then(()=>Bw).then(e=>new e.MediaWeb)}),Z8=Cn("Share",{web:()=>Promise.resolve().then(()=>Vw).then(e=>new e.ShareWeb)});async function Q8(e={url,type,title},a="",n){try{console.log("funcionou");const r=await fetch(e.url);if(!r.ok)throw new Error("Falha ao buscar o arquivo");const o=await r.blob(),i=await convertBlobToBase64(o),s=typeof e.type=="string"&&e.type.includes("/")?e.type.split("/")[1]:e.type||"unknown",l=hashString(e.url),d=e.title||`${a==="file"?`smclick-${s}`:a}-${l}.${s}`,p=await U8.writeFile({path:d,data:i,directory:zo.Documents});if(n==="ios"){if(s==="jpeg")await X8.savePhoto({path:p.uri,album:"MyApp"});else if(["pdf","mpeg"].includes(s)){console.log("share func"),await Z8.share({title:d,url:p.uri});return}}const m={mpeg:"Áudio",jpeg:"Imagem",pdf:"PDF"}[s]||"Arquivo";Zn({group:"success",title:"Sucesso",text:`${m} ${m==="Imagem"?"salva":"salvo"} com sucesso`},2e3)}catch(r){if(console.error(JSON.stringify(r)),r.errorMessage==="Share canceled")return;Zn({group:"error",title:"Erro",text:"Erro ao salvar imagem no dispositivo"},2e3)}}const K8={class:"messages-container bg-base-300"},J8={class:"header-intern bg-base-300"},em={class:"atendente-name"},tm={key:0,class:"date-separator bg-base-100/50"},am={class:"date-separator-text"},nm={key:0,class:"dropdown-container-internal-messages"},rm=["onClick"],om={key:0},im={class:"message-time"},sm={key:1},lm={class:"message-time"},cm={class:"input-area"},r1=qe({__name:"ChatMessages",props:{deviceType:{type:String},selectedAtendente:{type:Object,required:!0},attendant:{required:!0},loadMessagesForAtendente:{type:Function,required:!0},sendMessageToAtendente:{type:Function,required:!0},hasNextPageForAtendente:{type:Function,required:!0}},emits:["send-files","voltar"],setup(e,{emit:a}){const n=e,r=a,o=t.ref(""),i=t.ref(null),s=t.ref(!1),l=t.ref(!1),d=t.ref(!1),p=t.computed(()=>{var E;return((E=n.selectedAtendente)==null?void 0:E.messages)||[]}),u=(E,C)=>{const V=n.deviceType!=="web";console.log(V),V?Q8(E,C,n.deviceType):_(E,C)},m=t.computed(()=>n.hasNextPageForAtendente(n.selectedAtendente.id)),c=E=>{const C=new Date(E),V=C.getHours(),T=C.getMinutes();return`${V.toString().padStart(2,"0")}:${T.toString().padStart(2,"0")}`},f=E=>{const C=new Date(E);return X6(C)?"Hoje":Q6(C)?"Ontem":U6(C)?pl(C,"EEEE",{locale:gl}):pl(C,"dd 'de' MMMM 'de' yyyy",{locale:gl})},h=E=>{if(E===0)return!0;const C=new Date(p.value[E].created_at),V=new Date(p.value[E-1].created_at);return C.toDateString()!==V.toDateString()},y=E=>{E.key==="Enter"&&!E.shiftKey&&(E.preventDefault(),w())},k=()=>{i.value&&i.value.scrollTo({top:i.value.scrollHeight,behavior:"instant"})},x=async E=>{try{if(!m.value){E.complete();return}const C=i.value.scrollHeight,V=i.value.scrollTop;await n.loadMessagesForAtendente(n.selectedAtendente.id),await t.nextTick(),i.value.scrollTop=i.value.scrollHeight-C+V-32,E.loaded()}catch(C){console.error(C),E.complete()}},w=async()=>{if(o.value.trim()!=="")try{const E=JSON.parse(JSON.stringify(o.value));o.value="",await n.sendMessageToAtendente(n.selectedAtendente.id,E,n.attendant),await t.nextTick(),k()}catch(E){console.error("Erro ao enviar mensagem:",E)}},b=()=>{w();const E=document.querySelector(".send-button");E.classList.add("clicked"),setTimeout(()=>{E.classList.remove("clicked")},200)},B=()=>{r("send-files");const E=document.querySelector(".send-files-button");E.classList.add("clicked"),setTimeout(()=>{E.classList.remove("clicked")},200)};t.onMounted(async()=>{console.log(n.deviceType),await t.nextTick(()=>{k(),s.value=!0})}),t.watch(()=>{var E;return(E=p.value)==null?void 0:E.length},(E,C)=>{p.value&&A()&&setTimeout(()=>{i.value.scrollTo({top:i.value.scrollHeight,behavior:"instant"})},100)});function A(){const C=i.value.scrollTop+i.value.clientHeight;return i.value.scrollHeight-C<=80}const _=async(E,C="undefined")=>{const V=E.endsWith("svg+xml");try{const T=await fetch(V?E.replace("+","%2B"):E);if(!T.ok)throw new Error("Erro ao baixar o arquivo");const Y=await T.blob(),X=window.URL.createObjectURL(Y),G=document.createElement("a");G.href=X,G.download=C,document.body.appendChild(G),G.click(),document.body.removeChild(G),window.URL.revokeObjectURL(X)}catch(T){console.error("Erro no download:",T)}};return(E,C)=>{const V=t.resolveComponent("Popper");return t.openBlock(),t.createElementBlock("div",K8,[t.createElementVNode("div",J8,[t.createElementVNode("button",{onClick:C[0]||(C[0]=T=>r("voltar")),class:"back-button"},C[3]||(C[3]=[t.createElementVNode("svg",{class:"w-6 h-6","aria-hidden":"true",xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",viewBox:"0 0 24 24"},[t.createElementVNode("path",{d:"M14.502 7.046h-2.5v-.928a2.122 2.122 0 0 0-1.199-1.954 1.827 1.827 0 0 0-1.984.311L3.71 8.965a2.2 2.2 0 0 0 0 3.24L8.82 16.7a1.829 1.829 0 0 0 1.985.31 2.121 2.121 0 0 0 1.199-1.959v-.928h1a2.025 2.025 0 0 1 1.999 2.047V19a1 1 0 0 0 1.275.961 6.59 6.59 0 0 0 4.662-7.22 6.593 6.593 0 0 0-6.437-5.695Z"})],-1)])),t.createVNode(go,{url:e.selectedAtendente.photo},null,8,["url"]),t.createElementVNode("h3",em,t.toDisplayString(e.selectedAtendente.name),1)]),t.createElementVNode("div",{class:"message-area",ref_key:"chatArea",ref:i},[!d.value&&m.value&&s.value?(t.openBlock(),t.createBlock(t.unref(yo),{key:0,onInfinite:x,distance:30,top:!0,direction:"top",class:"p-3"},{complete:t.withCtx(()=>C[4]||(C[4]=[t.createElementVNode("span",null,null,-1)])),spinner:t.withCtx(()=>C[5]||(C[5]=[t.createElementVNode("div",{class:"loading"},[t.createElementVNode("svg",{class:"spinner",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24"},[t.createElementVNode("circle",{class:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor","stroke-width":"4"}),t.createElementVNode("path",{class:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})])],-1)])),_:1})):t.createCommentVNode("",!0),t.createElementVNode("div",null,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(p.value,(T,Y)=>(t.openBlock(),t.createElementBlock("div",{key:Y},[h(Y)?(t.openBlock(),t.createElementBlock("div",tm,[C[6]||(C[6]=t.createElementVNode("div",{class:"date-separator-line"},null,-1)),t.createElementVNode("div",am,t.toDisplayString(f(T.created_at)),1),C[7]||(C[7]=t.createElementVNode("div",{class:"date-separator-line"},null,-1))])):t.createCommentVNode("",!0),t.createElementVNode("div",{class:t.normalizeClass(["message",{me:T.sender.id===e.attendant.id,"not-me":T.sender.id!==e.attendant.id,"new-message":Y===p.value.length-1}])},[t.createElementVNode("div",{class:t.normalizeClass(["relative",T.sender.id===e.attendant.id?"text-right":"text-left"])},[T.content&&T.content.media&&T.content.media.data?(t.openBlock(),t.createElementBlock("div",nm,[t.createVNode(V,{hover:"",class:"label-popper-internal-messages",placement:"left"},{content:t.withCtx(()=>[t.createElementVNode("button",{class:"download-button-internal-messages",onClick:X=>u(T.content.media.data,T.content.media.name)}," Baixar ",8,rm)]),default:t.withCtx(()=>[C[8]||(C[8]=t.createElementVNode("button",{class:"dropdown-toggle-internal-messages"},[t.createElementVNode("svg",{class:"dropdown-icon-internal-messages","aria-hidden":"true",xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",fill:"none",viewBox:"0 0 24 24"},[t.createElementVNode("path",{stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"m19 9-7 7-7-7"})])],-1))]),_:2,__:[8]},1024)])):t.createCommentVNode("",!0),t.createElementVNode("div",{class:t.normalizeClass(["shadow shadow-gray-900 dark:shadow-gray-500",["message-content",{me:T.sender.id===e.attendant.id,"not-me":T.sender.id!==e.attendant.id}]])},[T.content&&T.content.media&&T.content.media.data?(t.openBlock(),t.createElementBlock("section",om,[t.createVNode($o,{mode:"message",onDownload:X=>u(T.content.media.data,T.content.media.name),avatar:T.sender.id===e.attendant.id?e.attendant.photo:T.sender.photo,fileName:T.content.media.name,base64:T.content.media.data,mimetype:T.content.media.mimetype},{"content-message":t.withCtx(()=>[t.createElementVNode("p",null,t.toDisplayString(T.content.content),1)]),"time-message":t.withCtx(()=>[t.createElementVNode("div",im,t.toDisplayString(c(T.created_at))+" "+t.toDisplayString(e.deviceType),1)]),_:2},1032,["onDownload","avatar","fileName","base64","mimetype"])])):(t.openBlock(),t.createElementBlock("section",sm,[t.createElementVNode("p",null,t.toDisplayString(T.content.content),1),t.createElementVNode("div",lm,t.toDisplayString(c(T.created_at))+" "+t.toDisplayString(e.deviceType),1)]))],2)],2)],2)]))),128))])],512),t.createElementVNode("div",cm,[t.withDirectives(t.createElementVNode("textarea",{type:"text","onUpdate:modelValue":C[1]||(C[1]=T=>o.value=T),class:"message-input bg-base-300 focus:ring-0",placeholder:"Digite sua mensagem...",onKeydown:y},null,544),[[t.vModelText,o.value]]),t.createElementVNode("button",{onClick:B,class:"send-files-button"},C[9]||(C[9]=[t.createElementVNode("svg",{class:"size-5 text-white","aria-hidden":"true",xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",fill:"none",viewBox:"0 0 24 24"},[t.createElementVNode("path",{stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M7 8v8a5 5 0 1 0 10 0V6.5a3.5 3.5 0 1 0-7 0V15a2 2 0 0 0 4 0V8"})],-1)])),o.value.length>0?(t.openBlock(),t.createElementBlock("button",{key:0,onClick:b,class:"send-button"},C[10]||(C[10]=[t.createElementVNode("svg",{class:"size-5 text-white rotate-90","aria-hidden":"true",xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",fill:"currentColor",viewBox:"0 0 24 24"},[t.createElementVNode("path",{"fill-rule":"evenodd",d:"M12 2a1 1 0 0 1 .932.638l7 18a1 1 0 0 1-1.326 1.281L13 19.517V13a1 1 0 1 0-2 0v6.517l-5.606 2.402a1 1 0 0 1-1.326-1.281l7-18A1 1 0 0 1 12 2Z","clip-rule":"evenodd"})],-1)]))):(t.openBlock(),t.createElementBlock("section",{key:1,class:t.normalizeClass(["bg-base-300",["send-audio-button",{recording:l.value}]])},[t.createVNode(L8,{"can-send-message":!0,attendant:e.attendant,selectedAttendant:e.selectedAtendente,sendAudioToAttendant:e.sendMessageToAtendente,onRecording:C[2]||(C[2]=T=>l.value=T)},null,8,["attendant","selectedAttendant","sendAudioToAttendant"])],2))])])}}},[["__scopeId","data-v-2c8ffde2"]]),dm={},um={class:"loading"};function mm(e,a){return t.openBlock(),t.createElementBlock("div",um,a[0]||(a[0]=[t.createElementVNode("svg",{class:"spinner",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24"},[t.createElementVNode("circle",{class:"opacity-30",cx:"12",cy:"12",r:"10",stroke:"currentColor","stroke-width":"4"}),t.createElementVNode("path",{class:"opacity-90",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})],-1)]))}const o1=qe(dm,[["render",mm],["__scopeId","data-v-bd52ddea"]]);/**
92
+ `,caption:c}]):Ye.show([{src:u,type:"image",caption:c}]))};function s(u,m=1){return new Promise((c,f)=>{const h=document.createElement("video");h.src=u,h.crossOrigin="anonymous",h.muted=!0,h.playsInline=!0,h.preload="auto",h.addEventListener("loadeddata",()=>{h.readyState>=2&&(h.currentTime=m)}),h.addEventListener("seeked",()=>{const y=document.createElement("canvas");y.width=h.videoWidth,y.height=h.videoHeight,y.getContext("2d").drawImage(h,0,0,y.width,y.height);const x=y.toDataURL("image/png");c(x)}),h.addEventListener("error",y=>{f("Erro ao carregar vídeo para thumbnail.")})})}const l=u=>typeof u=="string"&&u.startsWith("data:")&&u.includes(";base64,"),d=u=>u?u.startsWith("video/"):void 0,p=u=>{const m=Math.floor(u/60),c=(u%60).toFixed(0),f=m.toString().padStart(2,"0"),h=c.toString().padStart(2,"0");return`${f}:${h}`};return t.onMounted(async()=>{try{n.value=await s(a.base64)}catch(u){console.error(u)}}),(u,m)=>(t.openBlock(),t.createElementBlock("main",{class:t.normalizeClass({main_preview_files_container_message:e.mode==="message",main_preview_files_container_miniature:e.mode==="miniature","main_preview_files_container_preview bg-base-200":e.mode==="preview"})},[e.mimetype==="application/pdf"&&e.mode!=="miniature"?(t.openBlock(),t.createElementBlock("iframe",{key:0,class:"iframe_preview_files",src:e.base64,frameborder:"0"},null,8,a8)):e.mimetype==="application/pdf"&&e.mode==="miniature"?(t.openBlock(),t.createElementBlock("svg",n8,m[6]||(m[6]=[t.createElementVNode("path",{"fill-rule":"evenodd",d:"M9 2.221V7H4.221a2 2 0 0 1 .365-.5L8.5 2.586A2 2 0 0 1 9 2.22ZM11 2v5a2 2 0 0 1-2 2H4a2 2 0 0 0-2 2v7a2 2 0 0 0 2 2 2 2 0 0 0 2 2h12a2 2 0 0 0 2-2 2 2 0 0 0 2-2v-7a2 2 0 0 0-2-2V4a2 2 0 0 0-2-2h-7Zm-6 9a1 1 0 0 0-1 1v5a1 1 0 1 0 2 0v-1h.5a2.5 2.5 0 0 0 0-5H5Zm1.5 3H6v-1h.5a.5.5 0 0 1 0 1Zm4.5-3a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1h1.376A2.626 2.626 0 0 0 15 15.375v-1.75A2.626 2.626 0 0 0 12.375 11H11Zm1 5v-3h.375a.626.626 0 0 1 .625.626v1.748a.625.625 0 0 1-.626.626H12Zm5-5a1 1 0 0 0-1 1v5a1 1 0 1 0 2 0v-1h1a1 1 0 1 0 0-2h-1v-1h1a1 1 0 1 0 0-2h-2Z","clip-rule":"evenodd"},null,-1)]))):e.mimetype==="image/png"||e.mimetype==="image/jpeg"?(t.openBlock(),t.createElementBlock("img",{key:2,onClick:m[0]||(m[0]=c=>i(e.base64,e.mimetype)),class:t.normalizeClass(["preview_img",e.mode]),src:e.base64},null,10,r8)):e.mimetype==="image/svg+xml"?(t.openBlock(),t.createElementBlock("img",{key:3,onClick:m[1]||(m[1]=c=>i(e.base64,e.mimetype)),class:t.normalizeClass(["preview_img",e.mode]),src:l(e.base64)?e.base64:e.base64.replace("+","%2B")},null,10,o8)):d(e.mimetype)&&e.mode==="preview"?(t.openBlock(),t.createElementBlock("video",{key:4,width:"300",height:"150",controls:"",src:e.base64},[t.createElementVNode("source",{src:e.base64,type:e.mimetype},null,8,s8)],8,i8)):d(e.mimetype)&&e.mode==="message"?(t.openBlock(),t.createElementBlock("button",{key:5,onClick:m[2]||(m[2]=c=>i(e.base64,e.mimetype)),class:"video_message_preview_container"},[n.value?(t.openBlock(),t.createElementBlock("section",l8,[t.createElementVNode("div",c8,[m[11]||(m[11]=t.createElementVNode("svg",{class:"size-12 text-white","aria-hidden":"true",xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",fill:"currentColor",viewBox:"0 0 24 24"},[t.createElementVNode("path",{"fill-rule":"evenodd",d:"M8.6 5.2A1 1 0 0 0 7 6v12a1 1 0 0 0 1.6.8l8-6a1 1 0 0 0 0-1.6l-8-6Z","clip-rule":"evenodd"})],-1)),t.createElementVNode("div",d8,[(t.openBlock(),t.createElementBlock("svg",u8,m[7]||(m[7]=[t.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"m19 9-7 7-7-7"},null,-1)]))),(t.openBlock(),t.createElementBlock("svg",m8,m[8]||(m[8]=[t.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"m19 9-7 7-7-7"},null,-1)]))),(t.openBlock(),t.createElementBlock("svg",f8,m[9]||(m[9]=[t.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"m19 9-7 7-7-7"},null,-1)]))),(t.openBlock(),t.createElementBlock("svg",h8,m[10]||(m[10]=[t.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"m19 9-7 7-7-7"},null,-1)])))])]),t.createElementVNode("img",{class:t.normalizeClass(["preview_img",e.mode]),src:n.value},null,10,p8)])):(t.openBlock(),t.createElementBlock("span",g8,"Carregando..."))])):d(e.mimetype)&&e.mode==="miniature"?(t.openBlock(),t.createElementBlock("svg",y8,m[12]||(m[12]=[t.createElementVNode("path",{"fill-rule":"evenodd",d:"M14 7a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V7Zm2 9.387 4.684 1.562A1 1 0 0 0 22 17V7a1 1 0 0 0-1.316-.949L16 7.613v8.774Z","clip-rule":"evenodd"},null,-1)]))):e.mimetype==="audio/mpeg"&&e.mode!=="miniature"||e.mimetype==="application/octet-stream"&&e.mode!=="miniature"?(t.openBlock(),t.createElementBlock("section",k8,[t.createVNode(e1,{avatar:e.avatar,audio:e.base64,onDuration:m[3]||(m[3]=c=>r.value=c),onCurrentTime:m[4]||(m[4]=c=>o.value=c)},null,8,["avatar","audio"])])):e.mimetype==="audio/mpeg"&&e.mode==="miniature"?(t.openBlock(),t.createElementBlock("svg",b8,m[13]||(m[13]=[t.createElementVNode("path",{"fill-rule":"evenodd",d:"M5 8a1 1 0 0 1 1 1v3a4.006 4.006 0 0 0 4 4h4a4.006 4.006 0 0 0 4-4V9a1 1 0 1 1 2 0v3.001A6.006 6.006 0 0 1 14.001 18H13v2h2a1 1 0 1 1 0 2H9a1 1 0 1 1 0-2h2v-2H9.999A6.006 6.006 0 0 1 4 12.001V9a1 1 0 0 1 1-1Z","clip-rule":"evenodd"},null,-1),t.createElementVNode("path",{d:"M7 6a4 4 0 0 1 4-4h2a4 4 0 0 1 4 4v5a4 4 0 0 1-4 4h-2a4 4 0 0 1-4-4V6Z"},null,-1)]))):(t.openBlock(),t.createElementBlock("div",{key:9,class:t.normalizeClass(e.mode==="message"?"generic_files":"")},[m[14]||(m[14]=t.createElementVNode("div",null,[t.createElementVNode("svg",{class:"size-8 text-white","aria-hidden":"true",xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",fill:"currentColor",viewBox:"0 0 24 24"},[t.createElementVNode("path",{"fill-rule":"evenodd",d:"M9 2.221V7H4.221a2 2 0 0 1 .365-.5L8.5 2.586A2 2 0 0 1 9 2.22ZM11 2v5a2 2 0 0 1-2 2H4v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2h-7Z","clip-rule":"evenodd"})])],-1)),e.mode==="message"?(t.openBlock(),t.createElementBlock("span",x8,[t.createElementVNode("p",w8,t.toDisplayString(e.fileName),1),t.createElementVNode("button",{class:"download_btn_generic_files",onClick:m[5]||(m[5]=c=>u.$emit("download"))}," Baixar arquivo ")])):t.createCommentVNode("",!0)],2)),e.mode==="message"?(t.openBlock(),t.createElementBlock("div",v8,[t.renderSlot(u.$slots,"content-message",{},void 0,!0),t.createElementVNode("div",{class:t.normalizeClass([r.value?"justify-between":" justify-end","flex w-full"])},[r.value?(t.openBlock(),t.createElementBlock("p",E8,t.toDisplayString(p(r.value))+" - "+t.toDisplayString(o.value?p(o.value):"00:00"),1)):t.createCommentVNode("",!0),t.renderSlot(u.$slots,"time-message",{},void 0,!0)],2)])):t.createCommentVNode("",!0)],2))}},[["__scopeId","data-v-f8ed200a"]]),C8={props:{audioStream:MediaStream},data(){return{audioContext:null,analyser:null}},mounted(){this.initializeAudio()},methods:{initializeAudio(){this.audioContext=new(window.AudioContext||window.webkitAudioContext),this.analyser=this.audioContext.createAnalyser();const e=this.$refs.canvas,a=e.getContext("2d");this.audioContext.createMediaStreamSource(this.audioStream).connect(this.analyser),this.analyser.fftSize=256;const r=this.analyser.frequencyBinCount,o=new Uint8Array(r),i=()=>{this.analyser.getByteFrequencyData(o),a.clearRect(0,0,e.width,e.height);const s=e.width/r*2.5,l=e.height/2;let d=0;a.strokeStyle="green",a.lineWidth=2,a.beginPath(),a.moveTo(0,l),a.lineTo(e.width,l),a.stroke(),o.forEach(p=>{const u=p;a.fillStyle=`rgb(50, ${u+100}, 50)`,a.fillRect(d,l-u/2,s,u),d+=s+1}),this.audioStream.active&&requestAnimationFrame(i)};i()}}},S8={ref:"canvas",width:"200",height:"40",class:"mx-auto flex items-center rounded"};function M8(e,a,n,r,o,i){return t.openBlock(),t.createElementBlock("div",null,[t.createElementVNode("canvas",S8,null,512)])}const B8=qe(C8,[["render",M8],["__scopeId","data-v-d91f4ade"]]),A8={key:0,class:"flex w-full items-center space-x-3 text-white dark:text-black"},V8=["disabled"],D8=["disabled"],_8={key:0,class:"size-4 hover:text-red-500","aria-hidden":"true",xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",viewBox:"0 0 10 16"},N8={key:1,xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor",class:"w-5 hover:text-emerald-500"},T8={key:5,class:"flex w-full items-center space-x-2"},P8={class:"text-xs"},O8={key:0},F8={key:1,class:"flex items-center px-2 pr-[21px]"},L8=qe({__name:"audioRecorder",props:{canSendMessage:Boolean,sendAudioToAttendant:{type:Function,required:!0},selectedAttendant:{type:Object,required:!0},attendant:{required:!0}},emits:["audio-sent","recording","b64Audio"],setup(e,{emit:a}){const n=e,r=a,o=t.ref(null),i=t.ref(!1),s=t.ref(!1),l=t.ref(0),d=t.ref(0),p=t.ref(null),u=t.ref(null),m=t.ref(null),c=t.ref(null),f=t.ref(0),h=t.ref(0),y=t.ref(null),k=t.ref(!1),x=t.ref(!1),w=G=>{f.value=G},b=G=>{h.value=G},B=G=>{const S=Math.floor(G/60),I=(G%60).toFixed(0),j=S.toString().padStart(2,"0"),U=I.toString().padStart(2,"0");return`${j}:${U}`},A=async()=>{try{u.value=null,c.value=await navigator.mediaDevices.getUserMedia({audio:!0}),o.value=new MediaRecorder(c.value),o.value.ondataavailable=_,o.value.start(),E(),i.value=!0,r("recording",!0)}catch(G){console.error("Erro ao iniciar a gravação:",G)}},_=G=>{G.data.size>0&&!k.value&&(p.value=new Blob([G.data]),y.value=URL.createObjectURL(p.value),T())},E=()=>{let G=Date.now();m.value=setInterval(()=>{l.value=d.value+Math.floor((Date.now()-G)/1e3)},1e3)},C=async()=>{u.value=null,o.value&&i.value&&(s.value?(o.value.resume(),E()):(o.value.pause(),clearInterval(m.value),d.value=l.value),s.value=!s.value)},V=async()=>{o.value&&i.value&&(await o.value.stop(),clearInterval(m.value),i.value=!1,s.value=!1,T()),c.value&&c.value.getTracks().forEach(G=>G.stop()),console.log(u.value)},T=async()=>{if(p.value){const G=new Blob([p.value],{type:"audio/mpeg"}),S=new FileReader;S.onload=()=>{u.value=S.result},S.readAsDataURL(G)}},Y=async()=>{x.value=!0,r("b64Audio",u.value);const S={type:"file",media:{name:"audio",mimetype:(I=>I?I.split(";")[0].split(":")[1]:null)(u.value),data:u.value}};await n.sendAudioToAttendant(n.selectedAttendant.id,S,n.attendant,!0),r("recording",!1),x.value=!1,c.value=null,u.value=null,p.value=null,i.value=!1,s.value=!1,l.value=0},X=async()=>{k.value=!0,i.value=!1,r("recording",!1),await o.value.stop(),c.value&&(c.value.getTracks().forEach(G=>G.stop()),c.value=null),p.value=null,clearInterval(m.value),u.value=null,s.value=!1,l.value=0};return(G,S)=>{var I;return x.value?(t.openBlock(),t.createElementBlock("div",F8,S[9]||(S[9]=[t.createElementVNode("span",{class:"loader-audio-recorder"},null,-1)]))):(t.openBlock(),t.createElementBlock("div",A8,[!i.value&&!u.value?(t.openBlock(),t.createElementBlock("button",{key:0,class:t.normalizeClass(["send-audio-button",{recording:i.value}]),disabled:i.value||!e.canSendMessage,onClick:S[0]||(S[0]=j=>(A(),d.value=0,k.value=!1))},S[3]||(S[3]=[t.createElementVNode("svg",{class:"start-recording-icon","aria-hidden":"true",xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",viewBox:"0 0 16 19"},[t.createElementVNode("path",{d:"M15 5a1 1 0 0 0-1 1v3a4 4 0 0 1-4 4H6a4 4 0 0 1-4-4V6a1 1 0 0 0-2 0v3a6.006 6.006 0 0 0 6 6h1v2H5a1 1 0 0 0 0 2h6a1 1 0 0 0 0-2H9v-2h1a6.006 6.006 0 0 0 6-6V6a1 1 0 0 0-1-1Z"}),t.createElementVNode("path",{d:"M9 0H7a3 3 0 0 0-3 3v5a3 3 0 0 0 3 3h2a3 3 0 0 0 3-3V3a3 3 0 0 0-3-3Z"})],-1)]),10,V8)):t.createCommentVNode("",!0),c.value?(t.openBlock(),t.createElementBlock("button",{key:1,class:"rounded-full bg-red-500 p-1.5 hover:bg-red-600",onClick:S[1]||(S[1]=j=>X())},S[4]||(S[4]=[t.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor",class:"size-4"},[t.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M14.74 9l-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 01-2.244 2.077H8.084a2.25 2.25 0 01-2.244-2.077L4.772 5.79m14.456 0a48.108 48.108 0 00-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 013.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 00-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 00-7.5 0"})],-1)]))):t.createCommentVNode("",!0),i.value?(t.openBlock(),t.createElementBlock("button",{key:2,disabled:!i.value&&!s.value,onClick:C},[s.value?(t.openBlock(),t.createElementBlock("svg",N8,S[6]||(S[6]=[t.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M21 7.5V18M15 7.5V18M3 16.811V8.69c0-.864.933-1.406 1.683-.977l7.108 4.061a1.125 1.125 0 010 1.954l-7.108 4.061A1.125 1.125 0 013 16.811z"},null,-1)]))):(t.openBlock(),t.createElementBlock("svg",_8,S[5]||(S[5]=[t.createElementVNode("path",{"fill-rule":"evenodd",d:"M0 .8C0 .358.32 0 .714 0h1.429c.394 0 .714.358.714.8v14.4c0 .442-.32.8-.714.8H.714a.678.678 0 0 1-.505-.234A.851.851 0 0 1 0 15.2V.8Zm7.143 0c0-.442.32-.8.714-.8h1.429c.19 0 .37.084.505.234.134.15.209.354.209.566v14.4c0 .442-.32.8-.714.8H7.857c-.394 0-.714-.358-.714-.8V.8Z","clip-rule":"evenodd"},null,-1)])))],8,D8)):t.createCommentVNode("",!0),(i.value||p.value)&&!u.value?(t.openBlock(),t.createElementBlock("button",{key:3,class:"rounded-full p-1.5 hover:bg-gray-100 hover:text-light",onClick:V},S[7]||(S[7]=[t.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor",class:"size-4"},[t.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M5.25 7.5A2.25 2.25 0 017.5 5.25h9a2.25 2.25 0 012.25 2.25v9a2.25 2.25 0 01-2.25 2.25h-9a2.25 2.25 0 01-2.25-2.25v-9z"})],-1)]))):t.createCommentVNode("",!0),c.value&&i.value&&!s.value?(t.openBlock(),t.createBlock(B8,{key:4,"audio-stream":c.value},null,8,["audio-stream"])):t.createCommentVNode("",!0),u.value?(t.openBlock(),t.createElementBlock("div",T8,[t.createVNode(e1,{avatar:((I=e.attendant)==null?void 0:I.photo)||null,audio:u.value,onDuration:w,onCurrentTime:b},null,8,["avatar","audio"]),t.createElementVNode("main",P8,[t.createElementVNode("div",null,t.toDisplayString(B(h.value)),1),i.value||p.value?(t.openBlock(),t.createElementBlock("div",O8,t.toDisplayString(B(l.value)),1)):t.createCommentVNode("",!0)])])):t.createCommentVNode("",!0),u.value?(t.openBlock(),t.createElementBlock("button",{key:6,class:"rounded-full p-2 hover:bg-base-100",onClick:S[2]||(S[2]=j=>Y())},S[8]||(S[8]=[t.createElementVNode("svg",{class:"size-5 text-base-200 rotate-90","aria-hidden":"true",xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",fill:"currentColor",viewBox:"0 0 24 24"},[t.createElementVNode("path",{"fill-rule":"evenodd",d:"M12 2a1 1 0 0 1 .932.638l7 18a1 1 0 0 1-1.326 1.281L13 19.517V13a1 1 0 1 0-2 0v6.517l-5.606 2.402a1 1 0 0 1-1.326-1.281l7-18A1 1 0 0 1 12 2Z","clip-rule":"evenodd"})],-1)]))):t.createCommentVNode("",!0)]))}}},[["__scopeId","data-v-db980715"]]);/*! Capacitor: https://capacitorjs.com/ - MIT License */var Ja;(function(e){e.Unimplemented="UNIMPLEMENTED",e.Unavailable="UNAVAILABLE"})(Ja||(Ja={}));class Ho extends Error{constructor(a,n,r){super(a),this.message=a,this.code=n,this.data=r}}const $8=e=>{var a,n;return e!=null&&e.androidBridge?"android":!((n=(a=e==null?void 0:e.webkit)===null||a===void 0?void 0:a.messageHandlers)===null||n===void 0)&&n.bridge?"ios":"web"},H8=e=>{const a=e.CapacitorCustomPlatform||null,n=e.Capacitor||{},r=n.Plugins=n.Plugins||{},o=()=>a!==null?a.name:$8(e),i=()=>o()!=="web",s=m=>{const c=p.get(m);return!!(c!=null&&c.platforms.has(o())||l(m))},l=m=>{var c;return(c=n.PluginHeaders)===null||c===void 0?void 0:c.find(f=>f.name===m)},d=m=>e.console.error(m),p=new Map,u=(m,c={})=>{const f=p.get(m);if(f)return console.warn(`Capacitor plugin "${m}" already registered. Cannot register plugins twice.`),f.proxy;const h=o(),y=l(m);let k;const x=async()=>(!k&&h in c?k=typeof c[h]=="function"?k=await c[h]():k=c[h]:a!==null&&!k&&"web"in c&&(k=typeof c.web=="function"?k=await c.web():k=c.web),k),w=(C,V)=>{var T,Y;if(y){const X=y==null?void 0:y.methods.find(G=>V===G.name);if(X)return X.rtype==="promise"?G=>n.nativePromise(m,V.toString(),G):(G,S)=>n.nativeCallback(m,V.toString(),G,S);if(C)return(T=C[V])===null||T===void 0?void 0:T.bind(C)}else{if(C)return(Y=C[V])===null||Y===void 0?void 0:Y.bind(C);throw new Ho(`"${m}" plugin is not implemented on ${h}`,Ja.Unimplemented)}},b=C=>{let V;const T=(...Y)=>{const X=x().then(G=>{const S=w(G,C);if(S){const I=S(...Y);return V=I==null?void 0:I.remove,I}else throw new Ho(`"${m}.${C}()" is not implemented on ${h}`,Ja.Unimplemented)});return C==="addListener"&&(X.remove=async()=>V()),X};return T.toString=()=>`${C.toString()}() { [capacitor code] }`,Object.defineProperty(T,"name",{value:C,writable:!1,configurable:!1}),T},B=b("addListener"),A=b("removeListener"),_=(C,V)=>{const T=B({eventName:C},V),Y=async()=>{const G=await T;A({eventName:C,callbackId:G},V)},X=new Promise(G=>T.then(()=>G({remove:Y})));return X.remove=async()=>{console.warn("Using addListener() without 'await' is deprecated."),await Y()},X},E=new Proxy({},{get(C,V){switch(V){case"$$typeof":return;case"toJSON":return()=>({});case"addListener":return y?_:B;case"removeListener":return A;default:return b(V)}}});return r[m]=E,p.set(m,{name:m,proxy:E,platforms:new Set([...Object.keys(c),...y?[h]:[]])}),E};return n.convertFileSrc||(n.convertFileSrc=m=>m),n.getPlatform=o,n.handleError=d,n.isNativePlatform=i,n.isPluginAvailable=s,n.registerPlugin=u,n.Exception=Ho,n.DEBUG=!!n.DEBUG,n.isLoggingEnabled=!!n.isLoggingEnabled,n},Ro=(e=>e.Capacitor=H8(e))(typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{}),Cn=Ro.registerPlugin;class Sn{constructor(){this.listeners={},this.retainedEventArguments={},this.windowListeners={}}addListener(a,n){let r=!1;this.listeners[a]||(this.listeners[a]=[],r=!0),this.listeners[a].push(n);const i=this.windowListeners[a];i&&!i.registered&&this.addWindowListener(i),r&&this.sendRetainedArgumentsForEvent(a);const s=async()=>this.removeListener(a,n);return Promise.resolve({remove:s})}async removeAllListeners(){this.listeners={};for(const a in this.windowListeners)this.removeWindowListener(this.windowListeners[a]);this.windowListeners={}}notifyListeners(a,n,r){const o=this.listeners[a];if(!o){if(r){let i=this.retainedEventArguments[a];i||(i=[]),i.push(n),this.retainedEventArguments[a]=i}return}o.forEach(i=>i(n))}hasListeners(a){var n;return!!(!((n=this.listeners[a])===null||n===void 0)&&n.length)}registerWindowListener(a,n){this.windowListeners[n]={registered:!1,windowEventName:a,pluginEventName:n,handler:r=>{this.notifyListeners(n,r)}}}unimplemented(a="not implemented"){return new Ro.Exception(a,Ja.Unimplemented)}unavailable(a="not available"){return new Ro.Exception(a,Ja.Unavailable)}async removeListener(a,n){const r=this.listeners[a];if(!r)return;const o=r.indexOf(n);this.listeners[a].splice(o,1),this.listeners[a].length||this.removeWindowListener(this.windowListeners[a])}addWindowListener(a){window.addEventListener(a.windowEventName,a.handler),a.registered=!0}removeWindowListener(a){a&&(window.removeEventListener(a.windowEventName,a.handler),a.registered=!1)}sendRetainedArgumentsForEvent(a){const n=this.retainedEventArguments[a];n&&(delete this.retainedEventArguments[a],n.forEach(r=>{this.notifyListeners(a,r)}))}}const t1=e=>encodeURIComponent(e).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape),a1=e=>e.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent);class R8 extends Sn{async getCookies(){const a=document.cookie,n={};return a.split(";").forEach(r=>{if(r.length<=0)return;let[o,i]=r.replace(/=/,"CAP_COOKIE").split("CAP_COOKIE");o=a1(o).trim(),i=a1(i).trim(),n[o]=i}),n}async setCookie(a){try{const n=t1(a.key),r=t1(a.value),o=`; expires=${(a.expires||"").replace("expires=","")}`,i=(a.path||"/").replace("path=",""),s=a.url!=null&&a.url.length>0?`domain=${a.url}`:"";document.cookie=`${n}=${r||""}${o}; path=${i}; ${s};`}catch(n){return Promise.reject(n)}}async deleteCookie(a){try{document.cookie=`${a.key}=; Max-Age=0`}catch(n){return Promise.reject(n)}}async clearCookies(){try{const a=document.cookie.split(";")||[];for(const n of a)document.cookie=n.replace(/^ +/,"").replace(/=.*/,`=;expires=${new Date().toUTCString()};path=/`)}catch(a){return Promise.reject(a)}}async clearAllCookies(){try{await this.clearCookies()}catch(a){return Promise.reject(a)}}}Cn("CapacitorCookies",{web:()=>new R8});const z8=async e=>new Promise((a,n)=>{const r=new FileReader;r.onload=()=>{const o=r.result;a(o.indexOf(",")>=0?o.split(",")[1]:o)},r.onerror=o=>n(o),r.readAsDataURL(e)}),I8=(e={})=>{const a=Object.keys(e);return Object.keys(e).map(o=>o.toLocaleLowerCase()).reduce((o,i,s)=>(o[i]=e[a[s]],o),{})},G8=(e,a=!0)=>e?Object.entries(e).reduce((r,o)=>{const[i,s]=o;let l,d;return Array.isArray(s)?(d="",s.forEach(p=>{l=a?encodeURIComponent(p):p,d+=`${i}=${l}&`}),d.slice(0,-1)):(l=a?encodeURIComponent(s):s,d=`${i}=${l}`),`${r}&${d}`},"").substr(1):null,n1=(e,a={})=>{const n=Object.assign({method:e.method||"GET",headers:e.headers},a),o=I8(e.headers)["content-type"]||"";if(typeof e.data=="string")n.body=e.data;else if(o.includes("application/x-www-form-urlencoded")){const i=new URLSearchParams;for(const[s,l]of Object.entries(e.data||{}))i.set(s,l);n.body=i.toString()}else if(o.includes("multipart/form-data")||e.data instanceof FormData){const i=new FormData;if(e.data instanceof FormData)e.data.forEach((l,d)=>{i.append(d,l)});else for(const l of Object.keys(e.data))i.append(l,e.data[l]);n.body=i;const s=new Headers(n.headers);s.delete("content-type"),n.headers=s}else(o.includes("application/json")||typeof e.data=="object")&&(n.body=JSON.stringify(e.data));return n};class j8 extends Sn{async request(a){const n=n1(a,a.webFetchExtra),r=G8(a.params,a.shouldEncodeUrlParams),o=r?`${a.url}?${r}`:a.url,i=await fetch(o,n),s=i.headers.get("content-type")||"";let{responseType:l="text"}=i.ok?a:{};s.includes("application/json")&&(l="json");let d,p;switch(l){case"arraybuffer":case"blob":p=await i.blob(),d=await z8(p);break;case"json":d=await i.json();break;case"document":case"text":default:d=await i.text()}const u={};return i.headers.forEach((m,c)=>{u[c]=m}),{data:d,headers:u,status:i.status,url:i.url}}async get(a){return this.request(Object.assign(Object.assign({},a),{method:"GET"}))}async post(a){return this.request(Object.assign(Object.assign({},a),{method:"POST"}))}async put(a){return this.request(Object.assign(Object.assign({},a),{method:"PUT"}))}async patch(a){return this.request(Object.assign(Object.assign({},a),{method:"PATCH"}))}async delete(a){return this.request(Object.assign(Object.assign({},a),{method:"DELETE"}))}}Cn("CapacitorHttp",{web:()=>new j8});function q8(e){e.CapacitorUtils.Synapse=new Proxy({},{get(a,n){return new Proxy({},{get(r,o){return(i,s,l)=>{const d=e.Capacitor.Plugins[n];if(d===void 0){l(new Error(`Capacitor plugin ${n} not found`));return}if(typeof d[o]!="function"){l(new Error(`Method ${o} not found in Capacitor plugin ${n}`));return}(async()=>{try{const p=await d[o](i);s(p)}catch(p){l(p)}})()}}})}})}function W8(e){e.CapacitorUtils.Synapse=new Proxy({},{get(a,n){return e.cordova.plugins[n]}})}function Y8(e=!1){typeof window>"u"||(window.CapacitorUtils=window.CapacitorUtils||{},window.Capacitor!==void 0&&!e?q8(window):window.cordova!==void 0&&W8(window))}var zo;(function(e){e.Documents="DOCUMENTS",e.Data="DATA",e.Library="LIBRARY",e.Cache="CACHE",e.External="EXTERNAL",e.ExternalStorage="EXTERNAL_STORAGE",e.ExternalCache="EXTERNAL_CACHE",e.LibraryNoCloud="LIBRARY_NO_CLOUD",e.Temporary="TEMPORARY"})(zo||(zo={}));var Io;(function(e){e.UTF8="utf8",e.ASCII="ascii",e.UTF16="utf16"})(Io||(Io={}));const U8=Cn("Filesystem",{web:()=>Promise.resolve().then(()=>Sw).then(e=>new e.FilesystemWeb)});Y8();const X8=Cn("Media",{web:()=>Promise.resolve().then(()=>Bw).then(e=>new e.MediaWeb)}),Z8=Cn("Share",{web:()=>Promise.resolve().then(()=>Vw).then(e=>new e.ShareWeb)});async function Q8(e={url,type,title},a="",n){try{console.log("funcionou");const r=await fetch(e.url);if(!r.ok)throw new Error("Falha ao buscar o arquivo",JSON.stringify(r.ok));const o=await r.blob(),i=await convertBlobToBase64(o),s=typeof e.type=="string"&&e.type.includes("/")?e.type.split("/")[1]:e.type||"unknown",l=hashString(e.url),d=e.title||`${a==="file"?`smclick-${s}`:a}-${l}.${s}`,p=await U8.writeFile({path:d,data:i,directory:zo.Documents});if(n==="ios"){if(s==="jpeg")await X8.savePhoto({path:p.uri,album:"MyApp"});else if(["pdf","mpeg"].includes(s)){console.log("share func"),await Z8.share({title:d,url:p.uri});return}}const m={mpeg:"Áudio",jpeg:"Imagem",pdf:"PDF"}[s]||"Arquivo";Zn({group:"success",title:"Sucesso",text:`${m} ${m==="Imagem"?"salva":"salvo"} com sucesso`},2e3)}catch(r){if(console.error({message:r.message,stack:r.stack,name:r.name,...r}),console.error(JSON.stringify(r)),r.errorMessage==="Share canceled")return;Zn({group:"error",title:"Erro",text:"Erro ao salvar imagem no dispositivo"},2e3)}}const K8={class:"messages-container bg-base-300"},J8={class:"header-intern bg-base-300"},em={class:"atendente-name"},tm={key:0,class:"date-separator bg-base-100/50"},am={class:"date-separator-text"},nm={key:0,class:"dropdown-container-internal-messages"},rm=["onClick"],om={key:0},im={class:"message-time"},sm={key:1},lm={class:"message-time"},cm={class:"input-area"},r1=qe({__name:"ChatMessages",props:{deviceType:{type:String},selectedAtendente:{type:Object,required:!0},attendant:{required:!0},loadMessagesForAtendente:{type:Function,required:!0},sendMessageToAtendente:{type:Function,required:!0},hasNextPageForAtendente:{type:Function,required:!0}},emits:["send-files","voltar"],setup(e,{emit:a}){const n=e,r=a,o=t.ref(""),i=t.ref(null),s=t.ref(!1),l=t.ref(!1),d=t.ref(!1),p=t.computed(()=>{var E;return((E=n.selectedAtendente)==null?void 0:E.messages)||[]}),u=(E,C)=>{const V=n.deviceType!=="web";console.log(V),V?Q8(E,C,n.deviceType):_(E,C)},m=t.computed(()=>n.hasNextPageForAtendente(n.selectedAtendente.id)),c=E=>{const C=new Date(E),V=C.getHours(),T=C.getMinutes();return`${V.toString().padStart(2,"0")}:${T.toString().padStart(2,"0")}`},f=E=>{const C=new Date(E);return X6(C)?"Hoje":Q6(C)?"Ontem":U6(C)?pl(C,"EEEE",{locale:gl}):pl(C,"dd 'de' MMMM 'de' yyyy",{locale:gl})},h=E=>{if(E===0)return!0;const C=new Date(p.value[E].created_at),V=new Date(p.value[E-1].created_at);return C.toDateString()!==V.toDateString()},y=E=>{E.key==="Enter"&&!E.shiftKey&&(E.preventDefault(),w())},k=()=>{i.value&&i.value.scrollTo({top:i.value.scrollHeight,behavior:"instant"})},x=async E=>{try{if(!m.value){E.complete();return}const C=i.value.scrollHeight,V=i.value.scrollTop;await n.loadMessagesForAtendente(n.selectedAtendente.id),await t.nextTick(),i.value.scrollTop=i.value.scrollHeight-C+V-32,E.loaded()}catch(C){console.error(C),E.complete()}},w=async()=>{if(o.value.trim()!=="")try{const E=JSON.parse(JSON.stringify(o.value));o.value="",await n.sendMessageToAtendente(n.selectedAtendente.id,E,n.attendant),await t.nextTick(),k()}catch(E){console.error("Erro ao enviar mensagem:",E)}},b=()=>{w();const E=document.querySelector(".send-button");E.classList.add("clicked"),setTimeout(()=>{E.classList.remove("clicked")},200)},B=()=>{r("send-files");const E=document.querySelector(".send-files-button");E.classList.add("clicked"),setTimeout(()=>{E.classList.remove("clicked")},200)};t.onMounted(async()=>{console.log(n.deviceType),await t.nextTick(()=>{k(),s.value=!0})}),t.watch(()=>{var E;return(E=p.value)==null?void 0:E.length},(E,C)=>{p.value&&A()&&setTimeout(()=>{i.value.scrollTo({top:i.value.scrollHeight,behavior:"instant"})},100)});function A(){const C=i.value.scrollTop+i.value.clientHeight;return i.value.scrollHeight-C<=80}const _=async(E,C="undefined")=>{const V=E.endsWith("svg+xml");try{const T=await fetch(V?E.replace("+","%2B"):E);if(!T.ok)throw new Error("Erro ao baixar o arquivo");const Y=await T.blob(),X=window.URL.createObjectURL(Y),G=document.createElement("a");G.href=X,G.download=C,document.body.appendChild(G),G.click(),document.body.removeChild(G),window.URL.revokeObjectURL(X)}catch(T){console.error("Erro no download:",T)}};return(E,C)=>{const V=t.resolveComponent("Popper");return t.openBlock(),t.createElementBlock("div",K8,[t.createElementVNode("div",J8,[t.createElementVNode("button",{onClick:C[0]||(C[0]=T=>r("voltar")),class:"back-button"},C[3]||(C[3]=[t.createElementVNode("svg",{class:"w-6 h-6","aria-hidden":"true",xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",viewBox:"0 0 24 24"},[t.createElementVNode("path",{d:"M14.502 7.046h-2.5v-.928a2.122 2.122 0 0 0-1.199-1.954 1.827 1.827 0 0 0-1.984.311L3.71 8.965a2.2 2.2 0 0 0 0 3.24L8.82 16.7a1.829 1.829 0 0 0 1.985.31 2.121 2.121 0 0 0 1.199-1.959v-.928h1a2.025 2.025 0 0 1 1.999 2.047V19a1 1 0 0 0 1.275.961 6.59 6.59 0 0 0 4.662-7.22 6.593 6.593 0 0 0-6.437-5.695Z"})],-1)])),t.createVNode(go,{url:e.selectedAtendente.photo},null,8,["url"]),t.createElementVNode("h3",em,t.toDisplayString(e.selectedAtendente.name),1)]),t.createElementVNode("div",{class:"message-area",ref_key:"chatArea",ref:i},[!d.value&&m.value&&s.value?(t.openBlock(),t.createBlock(t.unref(yo),{key:0,onInfinite:x,distance:30,top:!0,direction:"top",class:"p-3"},{complete:t.withCtx(()=>C[4]||(C[4]=[t.createElementVNode("span",null,null,-1)])),spinner:t.withCtx(()=>C[5]||(C[5]=[t.createElementVNode("div",{class:"loading"},[t.createElementVNode("svg",{class:"spinner",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24"},[t.createElementVNode("circle",{class:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor","stroke-width":"4"}),t.createElementVNode("path",{class:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})])],-1)])),_:1})):t.createCommentVNode("",!0),t.createElementVNode("div",null,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(p.value,(T,Y)=>(t.openBlock(),t.createElementBlock("div",{key:Y},[h(Y)?(t.openBlock(),t.createElementBlock("div",tm,[C[6]||(C[6]=t.createElementVNode("div",{class:"date-separator-line"},null,-1)),t.createElementVNode("div",am,t.toDisplayString(f(T.created_at)),1),C[7]||(C[7]=t.createElementVNode("div",{class:"date-separator-line"},null,-1))])):t.createCommentVNode("",!0),t.createElementVNode("div",{class:t.normalizeClass(["message",{me:T.sender.id===e.attendant.id,"not-me":T.sender.id!==e.attendant.id,"new-message":Y===p.value.length-1}])},[t.createElementVNode("div",{class:t.normalizeClass(["relative",T.sender.id===e.attendant.id?"text-right":"text-left"])},[T.content&&T.content.media&&T.content.media.data?(t.openBlock(),t.createElementBlock("div",nm,[t.createVNode(V,{hover:"",class:"label-popper-internal-messages",placement:"left"},{content:t.withCtx(()=>[t.createElementVNode("button",{class:"download-button-internal-messages",onClick:X=>u(T.content.media.data,T.content.media.name)}," Baixar ",8,rm)]),default:t.withCtx(()=>[C[8]||(C[8]=t.createElementVNode("button",{class:"dropdown-toggle-internal-messages"},[t.createElementVNode("svg",{class:"dropdown-icon-internal-messages","aria-hidden":"true",xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",fill:"none",viewBox:"0 0 24 24"},[t.createElementVNode("path",{stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"m19 9-7 7-7-7"})])],-1))]),_:2,__:[8]},1024)])):t.createCommentVNode("",!0),t.createElementVNode("div",{class:t.normalizeClass(["shadow shadow-gray-900 dark:shadow-gray-500",["message-content",{me:T.sender.id===e.attendant.id,"not-me":T.sender.id!==e.attendant.id}]])},[T.content&&T.content.media&&T.content.media.data?(t.openBlock(),t.createElementBlock("section",om,[t.createVNode($o,{mode:"message",onDownload:X=>u(T.content.media.data,T.content.media.name),avatar:T.sender.id===e.attendant.id?e.attendant.photo:T.sender.photo,fileName:T.content.media.name,base64:T.content.media.data,mimetype:T.content.media.mimetype},{"content-message":t.withCtx(()=>[t.createElementVNode("p",null,t.toDisplayString(T.content.content),1)]),"time-message":t.withCtx(()=>[t.createElementVNode("div",im,t.toDisplayString(c(T.created_at))+" "+t.toDisplayString(e.deviceType),1)]),_:2},1032,["onDownload","avatar","fileName","base64","mimetype"])])):(t.openBlock(),t.createElementBlock("section",sm,[t.createElementVNode("p",null,t.toDisplayString(T.content.content),1),t.createElementVNode("div",lm,t.toDisplayString(c(T.created_at))+" "+t.toDisplayString(e.deviceType),1)]))],2)],2)],2)]))),128))])],512),t.createElementVNode("div",cm,[t.withDirectives(t.createElementVNode("textarea",{type:"text","onUpdate:modelValue":C[1]||(C[1]=T=>o.value=T),class:"message-input bg-base-300 focus:ring-0",placeholder:"Digite sua mensagem...",onKeydown:y},null,544),[[t.vModelText,o.value]]),t.createElementVNode("button",{onClick:B,class:"send-files-button"},C[9]||(C[9]=[t.createElementVNode("svg",{class:"size-5 text-white","aria-hidden":"true",xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",fill:"none",viewBox:"0 0 24 24"},[t.createElementVNode("path",{stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M7 8v8a5 5 0 1 0 10 0V6.5a3.5 3.5 0 1 0-7 0V15a2 2 0 0 0 4 0V8"})],-1)])),o.value.length>0?(t.openBlock(),t.createElementBlock("button",{key:0,onClick:b,class:"send-button"},C[10]||(C[10]=[t.createElementVNode("svg",{class:"size-5 text-white rotate-90","aria-hidden":"true",xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",fill:"currentColor",viewBox:"0 0 24 24"},[t.createElementVNode("path",{"fill-rule":"evenodd",d:"M12 2a1 1 0 0 1 .932.638l7 18a1 1 0 0 1-1.326 1.281L13 19.517V13a1 1 0 1 0-2 0v6.517l-5.606 2.402a1 1 0 0 1-1.326-1.281l7-18A1 1 0 0 1 12 2Z","clip-rule":"evenodd"})],-1)]))):(t.openBlock(),t.createElementBlock("section",{key:1,class:t.normalizeClass(["bg-base-300",["send-audio-button",{recording:l.value}]])},[t.createVNode(L8,{"can-send-message":!0,attendant:e.attendant,selectedAttendant:e.selectedAtendente,sendAudioToAttendant:e.sendMessageToAtendente,onRecording:C[2]||(C[2]=T=>l.value=T)},null,8,["attendant","selectedAttendant","sendAudioToAttendant"])],2))])])}}},[["__scopeId","data-v-2c8ffde2"]]),dm={},um={class:"loading"};function mm(e,a){return t.openBlock(),t.createElementBlock("div",um,a[0]||(a[0]=[t.createElementVNode("svg",{class:"spinner",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24"},[t.createElementVNode("circle",{class:"opacity-30",cx:"12",cy:"12",r:"10",stroke:"currentColor","stroke-width":"4"}),t.createElementVNode("path",{class:"opacity-90",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})],-1)]))}const o1=qe(dm,[["render",mm],["__scopeId","data-v-bd52ddea"]]);/**
93
93
  * Vue 3 Carousel 0.16.0
94
94
  * (c) 2025
95
95
  * @license MIT
@@ -1,4 +1,4 @@
1
- import { W as a } from "./index-DNqxu-_s.js";
1
+ import { W as a } from "./index-1dgik5G_.js";
2
2
  class n extends a {
3
3
  async canShare() {
4
4
  return typeof navigator > "u" || !navigator.share ? { value: !1 } : { value: !0 };
@@ -1,4 +1,4 @@
1
- import { W as P, b as x, E } from "./index-DNqxu-_s.js";
1
+ import { W as P, b as x, E } from "./index-1dgik5G_.js";
2
2
  function m(w) {
3
3
  const e = w.split("/").filter((t) => t !== "."), r = [];
4
4
  return e.forEach((t) => {
@@ -1,4 +1,4 @@
1
- import { W as t } from "./index-DNqxu-_s.js";
1
+ import { W as t } from "./index-1dgik5G_.js";
2
2
  class m extends t {
3
3
  getMedias(e) {
4
4
  throw console.log("getMedias", e), this.unimplemented("Not implemented on web.");
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "dist",
6
6
  "src/test-utils"
7
7
  ],
8
- "version": "0.0.383",
8
+ "version": "0.0.384",
9
9
  "main": "dist/sm-click-library-ui.es.js",
10
10
  "module": "dist/sm-click-library-ui.umd.js",
11
11
  "private": false,