import{k as e}from"./vendor-element-plus.js?ver=3.1.0";import{_ as t,I as o}from"./fc-bits-ui.js?ver=3.1.0";import{r as n,c as a,o as i,L as l,d,F as s,w as p,Q as r,O as u,P as c,n as m}from"./vendor.js?ver=3.1.0";const _={name:"photo_widget",components:{Icons:o},props:{modelValue:{type:String,default:""},value:{type:String,default:""},btn_mode:{type:Boolean,default:()=>!1},btn_text:{type:String,default:()=>"Upload"},btn_type:{type:String,default:()=>"default"},btn_class:{type:String,default:()=>""},hide_upload_icon:{type:Boolean,default:()=>!1},only_icon:{type:Boolean,default:()=>!1}},emits:["update:modelValue","input","changed","update:value"],data:()=>({app_ready:!1}),computed:{displayValue(){return this.modelValue||this.value||""}},methods:{initUploader(){var e;const t=null==(e=null==window?void 0:window.wp)?void 0:e.media,o=null==t?void 0:t.editor;if(!(o&&"function"==typeof o.open&&t&&t.model&&t.view))return console.warn("PhotoWidget: wp.media.editor is not available. Ensure wp_enqueue_media() is called on the page."),!1;const n=o.send.attachment;o.send.attachment=(e,t)=>{if(t&&t.url){const e=t.url;this.$emit("update:modelValue",e),this.$emit("update:value",e),this.$emit("input",e),this.$emit("changed",e)}o.send.attachment=n};const a=window.wpActiveEditor;window.wpActiveEditor="photo_widget",o.open();const i=o.frame;return i&&"function"==typeof i.on?i.on("close",()=>{window.wpActiveEditor=a}):window.wpActiveEditor=a,!1},getThumb:e=>e.url},mounted(){this.app_ready=!0}},y={class:"fluentcrm_photo_card"},f={key:0,class:"fluentcrm_photo_holder"},w=["src"],h={key:0,class:"icon"};const v=t(_,[["render",function(t,o,_,v,g,b){const k=n("Icons"),V=e;return i(),a("div",y,[g.app_ready?(i(),a("div",f,[b.displayValue&&!_.btn_mode?(i(),a("img",{key:0,src:b.displayValue},null,8,w)):l("",!0),d(V,{size:"small",onClick:b.initUploader,type:_.btn_type,class:m(_.btn_class)},{default:p(()=>[!_.hide_upload_icon||_.only_icon?(i(),a("span",h,[d(k,{"icon-name":"simple-upload"})])):l("",!0),_.only_icon?l("",!0):(i(),a(r,{key:1},[u(c(_.btn_text),1)],64))],void 0),_:1},8,["onClick","type","class"]),s(t.$slots,"after")])):l("",!0)])}]]);export{v as P};
