import{$ as p}from"./jquery-BJllTr_o.js";import{a as s}from"./helper-DH3MvDof.js";const b=(f,d="image",r=!1)=>{(function(e){e.fn.filemanager=function(t,c){t=t||"file",this.on("click",function(h){const u=c!=null&&c.prefix?c.prefix:`${s()}/filemaneger`,n=e("#"+e(this).data("input")),a=e("#"+e(this).data("preview"));return window.open(u+"?type="+t+"&multiple=0","FileManager","width=900,height=600"),window.SetUrl=function(l){const g=l.map(function(i){return new URL(i.url).pathname}).join(",");n.val("").val(g).trigger("change"),a.html(""),l.forEach(function(i){a.append(e("<img>").css("height","5rem").attr("src",i.url)),a.addClass("mt-4")}),a.trigger("change")},!1})}})(p),p(`#${f}`).filemanager(d,{prefix:`${s()}/filemaneger`})},y=(f,d="image")=>{(function(r){r.fn.filemanager=function(e,t){e="video",this.on("click",function(c){var h=t&&t.prefix?t.prefix:`${s()}/filemaneger`;const u=r(this).closest(".file-manager-container");var n=u.find("input"),a=u.find(".preview");return window.open(h+"?type="+e+"&multiple=0","FileManager","width=1900,height=800"),window.SetUrl=function(l){var g=l.map(function(i){return new URL(i.url).pathname}).join(",");n.val("").val(g).trigger("change"),a.html(""),l.forEach(function(i){a.append(r("<img>").css("height","5rem").attr("src",i.url)),a.addClass("mt-4")}),a.trigger("change")},!1})}})(p),p(`.${f}`).each(function(r,e){p(this).filemanager(d,{prefix:`${s()}/filemaneger`})})},v=(f,d="image")=>{(function(r){r.fn.filemanager=function(e,t){e=e||"file",this.on("click",function(c){var h=t&&t.prefix?t.prefix:`${s()}/filemaneger`,u=r("#"+r(this).data("input")),n=r("#"+r(this).data("preview"));return window.open(h+"?type="+e+"&multiple=1","FileManager","width=900,height=600"),window.SetUrl=function(a){var l=a.map(function(o,m){return{url:new URL(o.url).pathname,id:m}});let g=l,i=u.val();i&&(g=[...JSON.parse(i),...l]);const w=g.map((o,m)=>({url:o.url,id:m}));u.val(JSON.stringify(w)).trigger("change"),n.html(""),w.map(function(o,m){n.append(`<div class="w-full cursor-pointer relative flex items-center justify-center border border-neutral-30 dark:border-neutral-500 p-4 h-[200px] rounded-md">
                                <img src="${o.url}" alt="" class="w-full h-full" />
                                <i data-id="${o.id}" class="remove-file ph ph-trash text-24 text-red-500 absolute top-2 right-2 cursor-pointer"></i>
                            </div>`)}),n.append(`
                    <button id="${f}" data-input="gallery" data-preview="gallery_container" type="button"
                        class="w-full cursor-pointer flex items-center justify-center border border-neutral-30 dark:border-neutral-500 p-4 h-[200px] rounded-md">
                        <i class="ph ph-plus"></i>
                        <span>Add Image</span>
                    </button>
                    `),n.trigger("change"),v(f)},!1})}})(p),p(`#${f}`).filemanager(d,{prefix:`${s()}/filemaneger`,multiple:!0})};export{b as a,v as b,y as f};
