1import{az as F,a as j,r as c,R as C,D as f,j as t,o as D}from"./wordpress-bundle.js";const N=".png?",S="image/png",L="application/pdf",b=(e="")=>new URL(e).pathname.replace(/^\//,""),O=e=>/([23])[0-9]{2}/g.test(e),R=async(e,i=S,a=N,r="",o={})=>{const{isDownload:u=!1}=o,{url:m}=await _(i,r),d=b(m),{status:g}=await k(e,m,i,{isDownload:u,filepath:d});return O(g)?d:null};async function k(e,i,a=S,r){const{isDownload:o=!1,filepath:u=""}=r||{};return await fetch(i,{method:"PUT",body:e,headers:{"Content-Type":a,...o&&u?{"Content-Disposition":`attachment;filename=${u.split("/").slice(-1)};`}:{}}})}async function _(e=S,i=""){e==="video/x-ms-wmv"&&(e="video/x-ms-asf");const a=F();return(await fetch(`undefined/upload/pre-signed-for-guest?nameFile=${a}`,{method:"GET",headers:{"Content-Type":e}})).json()}function T({title:e="Upload",placeHolder:i="Upload your photo",fileType:a=".jpg, .jpeg, .png",aiPrefix:r="ai-photo-editor?image=",componentId:o="upload-photo-popup"}){const u=j(s=>s.isClient),[m,d]=c.useState(null),[g,h]=c.useState(0),[E,v]=c.useState(""),x=c.useRef(null),[A,U]=c.useState(""),w=c.useCallback(async s=>{const n=s.target.files?s.target.files[0]:null;if(d(n),n){v("UPLOADING"),h(80);const l=await R(n,a===".pdf"?L:void 0);U(l||""),h(100);const P=`${r}${l}`;window.location.href=`/${P}`,v("DONE")}},[r,a]);C.useEffect(()=>{function s(n){x.current&&!x.current.contains(n.target)&&document.dispatchEvent(new CustomEvent(f.PREFESH_UPLOAD,{detail:{key:o}}))}return j.getState().isMobile||document.addEventListener("mousedown",s),()=>{document.removeEventListener("mousedown",s)}},[o,a]),c.useEffect(()=>{function s(n){const p=n.detail?.key;if(!p||p!==o)return;d(null),h(0),v("");const l=document.querySelector(`#${o}`);l&&l.offsetWidth>0&&(l.style.cssText+="display:none")}return document.addEventListener(f.PREFESH_UPLOAD,s),()=>document.removeEventListener(f.PREFESH_UPLOAD,s)},[o]);const y=c.useCallback(s=>{const n=s.target,p=n.closest(".upload-file-element"),l=n.closest(".upload-file");if(!l)return;if(p){l.querySelector("input")?.click();return}if(n.closest(".close-button")){document.dispatchEvent(new CustomEvent(f.PREFESH_UPLOAD));return}},[]);return u?t.jsxs("div",{ref:x,onClick:y,id:o,className:"upload-file",children:[t.jsxs("div",{className:"upload-file-top",children:[t.jsx("span",{children:e}),t.jsx("span",{className:"close-button",children:t.jsx("img",{src:D("close.svg"),alt:"close-button"})})]}),t.jsxs("div",{className:"upload-file-body",children:[t.jsxs("div",{className:"upload-file-element",children:[E===""&&t.jsxs(C.Fragment,{children:[t.jsx("img",{src:D("upload.svg"),alt:"upload file"}),t.jsx("span",{children:i})]}),t.jsx("div",{className:"upload-progress",style:{opacity:["UPLOADING","DONE"].includes(E)?1:0,zIndex:["UPLOADING","DONE"].includes(E)?"unset":"-1"},children:t.jsx("div",{className:"progress-bar",style:{width:`${g}%`}})})]}),t.jsx("input",{type:"file",accept:a,onChange:w})]})]}):null}export{T as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.