You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

1 lines
3.3 KiB

var v=Object.defineProperty;var y=(t,e,o)=>e in t?v(t,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[e]=o;var r=(t,e,o)=>y(t,typeof e!="symbol"?e+"":e,o);import{r as _,C as x,V as w,a as k,_ as C,g as m,x as d,h as f,j as l,i as g,k as D,m as U,s as P,p as u,l as $,F as I}from"./index-BLqts8WY.js";import{P as T}from"./PhotoDialog-Dn3GjI9b.js";var V=Object.defineProperty,B=Object.getOwnPropertyDescriptor,F=(t,e,o,s)=>{for(var a=s>1?void 0:s?B(e,o):e,p=t.length-1,i;p>=0;p--)(i=t[p])&&(a=(s?i(e,o,a):i(a))||a);return s&&a&&V(e,o,a),a};const b=_();let h=class extends w{constructor(){super(...arguments);r(this,"$notify");r(this,"claimType");r(this,"crop",!1);r(this,"imageCallback",()=>{});r(this,"imageUrl");r(this,"visible",!1)}open(o,s,a){this.claimType=s,this.crop=!!a,this.imageCallback=o,this.visible=!0}openPhotoDialog(o,s){this.visible=!1,this.$refs.photoDialog.open(this.imageCallback,this.claimType,this.crop,o,s)}async uploadImageFile(o){this.visible=!1,b.value=o.target.files[0];const s=b.value;if(s!=null){const a=new FileReader;a.onload=async p=>{var c;const i=(c=p.target)==null?void 0:c.result;if(i){const n=new Blob([new Uint8Array(i)],{type:s.type});this.openPhotoDialog(n,s.name)}},a.readAsArrayBuffer(s)}}async acceptUrl(){if(this.visible=!1,this.crop)try{const o=await k.get(this.imageUrl,{responseType:"blob"}),a=new URL(this.imageUrl).pathname.split("/").pop();this.$refs.photoDialog.open(this.imageCallback,this.claimType,this.crop,o.data,a)}catch{this.$notify({group:"alert",type:"danger",title:"Error",text:"There was an error retrieving that image."},5e3)}else this.imageCallback(this.imageUrl)}close(){this.visible=!1}};h=F([x({components:{PhotoDialog:T}})],h);const N={key:0,class:"dialog-overlay z-[60]"},R={class:"dialog relative"},A={class:"text-lg text-center font-light relative z-50"},M={class:"text-center mt-8"},O={class:""},j={class:"mt-4"},z={class:"mt-4"},E={class:"mt-2"},L={class:"ml-2"};function H(t,e,o,s,a,p){const i=m("fa"),c=m("PhotoDialog");return d(),f(I,null,[t.visible?(d(),f("div",N,[l("div",R,[l("div",A,[e[4]||(e[4]=l("div",{id:"ViewHeading",class:"text-center font-bold absolute top-0 left-0 right-0 px-4 py-0.5 bg-black/50 text-white leading-none"}," Add Photo ",-1)),l("div",{class:"text-lg text-center px-2 py-0.5 leading-none absolute right-0 top-0 text-white",onClick:e[0]||(e[0]=n=>t.close())},[g(i,{icon:"xmark",class:"w-[1em]"})])]),l("div",null,[l("div",M,[l("div",O,[g(i,{icon:"camera",class:"bg-gradient-to-b from-blue-400 to-blue-700 shadow-[inset_0_-1px_0_0_rgba(0,0,0,0.5)] text-white px-2 py-2 rounded-md",onClick:e[1]||(e[1]=n=>t.openPhotoDialog())})]),l("div",j,[l("input",{type:"file",onChange:e[2]||(e[2]=(...n)=>t.uploadImageFile&&t.uploadImageFile(...n))},null,32)]),l("div",z,[l("span",E,[e[5]||(e[5]=D(" ... or paste a URL: ")),U(l("input",{type:"text","onUpdate:modelValue":e[3]||(e[3]=n=>t.imageUrl=n),class:"border-2"},null,512),[[P,t.imageUrl]])]),l("span",L,[t.imageUrl?(d(),u(i,{key:0,icon:"check",class:"bg-gradient-to-b from-blue-400 to-blue-700 shadow-[inset_0_-1px_0_0_rgba(0,0,0,0.5)] text-white px-2 py-2 rounded-md cursor-pointer",onClick:t.acceptUrl},null,8,["onClick"])):(d(),u(i,{key:1,icon:"check",class:"text-white bg-white px-2 py-2"}))])])])])])])):$("",!0),g(c,{ref:"photoDialog"},null,512)],64)}const Q=C(h,[["render",H]]);export{Q as I};