filepond-plugin-image-preview
Advanced tools
Comparing version 4.6.7 to 4.6.8
/*! | ||
* FilePondPluginImagePreview 4.6.7 | ||
* FilePondPluginImagePreview 4.6.8 | ||
* Licensed under MIT, https://opensource.org/licenses/MIT/ | ||
@@ -966,5 +966,6 @@ * Please visit https://pqina.nl/filepond/ for details. | ||
create: ({ root, props }) => { | ||
let mask = SVG_MASK; | ||
if (document.querySelector('base')) { | ||
const url = window.location.href.replace(window.location.hash, ''); | ||
SVG_MASK = SVG_MASK.replace(/url\(\#/g, 'url(' + url + '#'); | ||
mask = mask.replace(/url\(\#/g, 'url(' + url + '#'); | ||
} | ||
@@ -976,3 +977,3 @@ | ||
); | ||
root.element.innerHTML = SVG_MASK.replace(/__UID__/g, SVGMaskUniqueId); | ||
root.element.innerHTML = mask.replace(/__UID__/g, SVGMaskUniqueId); | ||
}, | ||
@@ -979,0 +980,0 @@ mixins: { |
/*! | ||
* FilePondPluginImagePreview 4.6.7 | ||
* FilePondPluginImagePreview 4.6.8 | ||
* Licensed under MIT, https://opensource.org/licenses/MIT/ | ||
@@ -9,2 +9,2 @@ * Please visit https://pqina.nl/filepond/ for details. | ||
const e=(e,t)=>r(e.x*t,e.y*t),t=(e,t)=>r(e.x+t.x,e.y+t.y),i=(e,t,i)=>{const a=Math.cos(t),o=Math.sin(t),n=r(e.x-i.x,e.y-i.y);return r(i.x+a*n.x-o*n.y,i.y+o*n.x+a*n.y)},r=(e=0,t=0)=>({x:e,y:t}),a=(e,t,i=1,r)=>"string"==typeof e?parseFloat(e)*i:"number"==typeof e?e*(r?t[r]:Math.min(t.width,t.height)):void 0,o=e=>null!=e,n=e=>e.map((e,t)=>`${0===t?"M":"L"} ${e.x} ${e.y}`).join(" "),s=(e,t)=>Object.keys(t).forEach(i=>e.setAttribute(i,t[i])),c=(e,t)=>{const i=document.createElementNS("http://www.w3.org/2000/svg",e);return t&&s(i,t),i},h={contain:"xMidYMid meet",cover:"xMidYMid slice"},l={left:"start",center:"middle",right:"end"},d=e=>t=>c(e,{id:t.id}),g={image:e=>{const t=c("image",{id:e.id,"stroke-linecap":"round","stroke-linejoin":"round",opacity:"0"});return t.onload=(()=>{t.setAttribute("opacity",e.opacity||1)}),t.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",e.src),t},rect:d("rect"),ellipse:d("ellipse"),text:d("text"),path:d("path"),line:e=>{const t=c("g",{id:e.id,"stroke-linecap":"round","stroke-linejoin":"round"}),i=c("line");t.appendChild(i);const r=c("path");t.appendChild(r);const a=c("path");return t.appendChild(a),t}},p={rect:e=>s(e,{...e.rect,...e.styles}),ellipse:e=>{const t=e.rect.x+.5*e.rect.width,i=e.rect.y+.5*e.rect.height,r=.5*e.rect.width,a=.5*e.rect.height;return s(e,{cx:t,cy:i,rx:r,ry:a,...e.styles})},image:(e,t)=>{s(e,{...e.rect,...e.styles,preserveAspectRatio:h[t.fit]||"none"})},text:(e,t,i,r)=>{const o=a(t.fontSize,i,r),n=t.fontFamily||"sans-serif",c=t.fontWeight||"normal",h=l[t.textAlign]||"start";s(e,{...e.rect,...e.styles,"stroke-width":0,"font-weight":c,"font-size":o,"font-family":n,"text-anchor":h}),e.text!==t.text&&(e.text=t.text,e.textContent=t.text.length?t.text:" ")},path:(e,t,i,r)=>{s(e,{...e.styles,fill:"none",d:n(t.points.map(e=>({x:a(e.x,i,r,"width"),y:a(e.y,i,r,"height")})))})},line:(o,n,c,h)=>{s(o,{...o.rect,...o.styles,fill:"none"});const l=o.childNodes[0],d=o.childNodes[1],g=o.childNodes[2],p=o.rect,m={x:o.rect.x+o.rect.width,y:o.rect.y+o.rect.height};if(s(l,{x1:p.x,y1:p.y,x2:m.x,y2:m.y}),!n.lineDecoration)return;d.style.display="none",g.style.display="none";const u=(e=>{const t=Math.sqrt(e.x*e.x+e.y*e.y);return 0===t?{x:0,y:0}:r(e.x/t,e.y/t)})({x:m.x-p.x,y:m.y-p.y}),E=a(.05,c,h);if(-1!==n.lineDecoration.indexOf("arrow-begin")){const r=e(u,E),a=t(p,r),o=i(p,2,a),n=i(p,-2,a);s(d,{style:"display:block;",d:`M${o.x},${o.y} L${p.x},${p.y} L${n.x},${n.y}`})}if(-1!==n.lineDecoration.indexOf("arrow-end")){const r=e(u,-E),a=t(m,r),o=i(m,2,a),n=i(m,-2,a);s(g,{style:"display:block;",d:`M${o.x},${o.y} L${m.x},${m.y} L${n.x},${n.y}`})}}},m=(e,t,i,r,n)=>{"path"!==t&&(e.rect=((e,t,i=1)=>{let r=a(e.x,t,i,"width")||a(e.left,t,i,"width"),n=a(e.y,t,i,"height")||a(e.top,t,i,"height"),s=a(e.width,t,i,"width"),c=a(e.height,t,i,"height"),h=a(e.right,t,i,"width"),l=a(e.bottom,t,i,"height");return o(n)||(n=o(c)&&o(l)?t.height-c-l:l),o(r)||(r=o(s)&&o(h)?t.width-s-h:h),o(s)||(s=o(r)&&o(h)?t.width-r-h:0),o(c)||(c=o(n)&&o(l)?t.height-n-l:0),{x:r||0,y:n||0,width:s||0,height:c||0}})(i,r,n)),e.styles=((e,t,i)=>{const r=e.borderStyle||e.lineStyle||"solid",o=e.backgroundColor||e.fontColor||"transparent",n=e.borderColor||e.lineColor||"transparent",s=a(e.borderWidth||e.lineWidth,t,i);return{"stroke-linecap":e.lineCap||"round","stroke-linejoin":e.lineJoin||"round","stroke-width":s||0,"stroke-dasharray":"string"==typeof r?"":r.map(e=>a(e,t,i)).join(","),stroke:n,fill:o,opacity:e.opacity||1}})(i,r,n),p[t](e,i,r,n)},u=["x","y","left","top","right","bottom","width","height"],E=e=>{const[t,i]=e,r=i.points?{}:u.reduce((e,t)=>(e[t]=(e=>"string"==typeof e&&/%/.test(e)?parseFloat(e)/100:e)(i[t]),e),{});return[t,{zIndex:0,...i,...r}]},f=(e,t)=>e[1].zIndex>t[1].zIndex?1:e[1].zIndex<t[1].zIndex?-1:0,y=e=>e.utils.createView({name:"image-preview-markup",tag:"svg",ignoreRect:!0,mixins:{apis:["width","height","crop","markup","resize","dirty"]},write:({root:e,props:t})=>{if(!t.dirty)return;const{crop:i,resize:r,markup:a}=t,o=t.width,n=t.height;let s=i.width,c=i.height;if(r){const{size:e}=r;let t=e&&e.width,i=e&&e.height;const a=r.mode,o=r.upscale;t&&!i&&(i=t),i&&!t&&(t=i);const n=s<t&&c<i;if(!n||n&&o){let e=t/s,r=i/c;if("force"===a)s=t,c=i;else{let t;"cover"===a?t=Math.max(e,r):"contain"===a&&(t=Math.min(e,r)),s*=t,c*=t}}}const h={width:o,height:n};e.element.setAttribute("width",h.width),e.element.setAttribute("height",h.height);const l=Math.min(o/s,n/c);e.element.innerHTML="";const d=e.query("GET_IMAGE_PREVIEW_MARKUP_FILTER");a.filter(d).map(E).sort(f).forEach(t=>{const[i,r]=t,a=((e,t)=>g[e](t))(i,r);m(a,i,r,h,l),e.element.appendChild(a)})}}),w=(e,t)=>({x:e,y:t}),_=(e,t)=>w(e.x-t.x,e.y-t.y),I=(e,t)=>Math.sqrt(((e,t)=>((e,t)=>e.x*t.x+e.y*t.y)(_(e,t),_(e,t)))(e,t)),M=(e,t)=>{const i=e,r=t,a=1.5707963267948966-t,o=Math.sin(1.5707963267948966),n=Math.sin(r),s=Math.sin(a),c=Math.cos(a),h=i/o;return w(c*(h*n),c*(h*s))},x=(e,t,i,r)=>{const a=r.x>.5?1-r.x:r.x,o=r.y>.5?1-r.y:r.y,n=2*a*e.width,s=2*o*e.height,c=((e,t)=>{const i=e.width,r=e.height,a=M(i,t),o=M(r,t),n=w(e.x+Math.abs(a.x),e.y-Math.abs(a.y)),s=w(e.x+e.width+Math.abs(o.y),e.y+Math.abs(o.x)),c=w(e.x-Math.abs(o.y),e.y+e.height-Math.abs(o.x));return{width:I(n,s),height:I(n,c)}})(t,i);return Math.max(c.width/n,c.height/s)},T=(e,t)=>{let i=e.width,r=i*t;return r>e.height&&(i=(r=e.height)/t),{x:.5*(e.width-i),y:.5*(e.height-r),width:i,height:r}},A=(e,t={})=>{let{zoom:i,rotation:r,center:a,aspectRatio:o}=t;o||(o=e.height/e.width);const n=((e,t,i=1)=>{const r=e.height/e.width;let a=t,o=1,n=r;n>a&&(o=(n=a)/r);const s=Math.max(1/o,a/n),c=e.width/(i*s*o);return{width:c,height:c*t}})(e,o,i),s={x:.5*n.width,y:.5*n.height},c={x:0,y:0,width:n.width,height:n.height,center:s},h=void 0===t.scaleToFit||t.scaleToFit,l=i*x(e,T(c,o),r,h?a:{x:.5,y:.5});return{widthFloat:n.width/l,heightFloat:n.height/l,width:Math.round(n.width/l),height:Math.round(n.height/l)}},R={type:"spring",stiffness:.5,damping:.45,mass:10},C=e=>e.utils.createView({name:"image-clip",tag:"div",ignoreRect:!0,mixins:{apis:["crop","markup","resize","width","height","dirty","background"],styles:["width","height","opacity"],animations:{opacity:{type:"tween",duration:250}}},didWriteView:function({root:e,props:t}){t.background&&(e.element.style.backgroundColor=t.background)},create:({root:t,props:i})=>{t.ref.image=t.appendChildView(t.createChildView((e=>e.utils.createView({name:"image-canvas-wrapper",tag:"div",ignoreRect:!0,mixins:{apis:["crop","width","height"],styles:["originX","originY","translateX","translateY","scaleX","scaleY","rotateZ"],animations:{originX:R,originY:R,scaleX:R,scaleY:R,translateX:R,translateY:R,rotateZ:R}},create:({root:t,props:i})=>{i.width=i.image.width,i.height=i.image.height,t.ref.bitmap=t.appendChildView(t.createChildView((e=>e.utils.createView({name:"image-bitmap",ignoreRect:!0,mixins:{styles:["scaleX","scaleY"]},create:({root:e,props:t})=>{e.appendChild(t.image)}}))(e),{image:i.image}))},write:({root:e,props:t})=>{const{flip:i}=t.crop,{bitmap:r}=e.ref;r.scaleX=i.horizontal?-1:1,r.scaleY=i.vertical?-1:1}}))(e),Object.assign({},i))),t.ref.createMarkup=(()=>{t.ref.markup||(t.ref.markup=t.appendChildView(t.createChildView(y(e),Object.assign({},i))))}),t.ref.destroyMarkup=(()=>{t.ref.markup&&(t.removeChildView(t.ref.markup),t.ref.markup=null)});const r=t.query("GET_IMAGE_PREVIEW_TRANSPARENCY_INDICATOR");null!==r&&(t.element.dataset.transparencyIndicator="grid"===r?r:"color")},write:({root:e,props:t,shouldOptimize:i})=>{const{crop:r,markup:a,resize:o,dirty:n,width:s,height:c}=t;e.ref.image.crop=r;const h={x:0,y:0,width:s,height:c,center:{x:.5*s,y:.5*c}},l={width:e.ref.image.width,height:e.ref.image.height},d={x:r.center.x*l.width,y:r.center.y*l.height},g={x:h.center.x-l.width*r.center.x,y:h.center.y-l.height*r.center.y},p=2*Math.PI+r.rotation%(2*Math.PI),m=r.aspectRatio||l.height/l.width,u=void 0===r.scaleToFit||r.scaleToFit,E=x(l,T(h,m),p,u?r.center:{x:.5,y:.5}),f=r.zoom*E;a&&a.length?(e.ref.createMarkup(),e.ref.markup.width=s,e.ref.markup.height=c,e.ref.markup.resize=o,e.ref.markup.dirty=n,e.ref.markup.markup=a,e.ref.markup.crop=A(l,r)):e.ref.markup&&e.ref.destroyMarkup();const y=e.ref.image;if(i)return y.originX=null,y.originY=null,y.translateX=null,y.translateY=null,y.rotateZ=null,y.scaleX=null,void(y.scaleY=null);y.originX=d.x,y.originY=d.y,y.translateX=g.x,y.translateY=g.y,y.rotateZ=p,y.scaleX=f,y.scaleY=f}});let D='<svg width="500" height="200" viewBox="0 0 500 200" preserveAspectRatio="none">\n <defs>\n <radialGradient id="gradient-__UID__" cx=".5" cy="1.25" r="1.15">\n <stop offset=\'50%\' stop-color=\'#000000\'/>\n <stop offset=\'56%\' stop-color=\'#0a0a0a\'/>\n <stop offset=\'63%\' stop-color=\'#262626\'/>\n <stop offset=\'69%\' stop-color=\'#4f4f4f\'/>\n <stop offset=\'75%\' stop-color=\'#808080\'/>\n <stop offset=\'81%\' stop-color=\'#b1b1b1\'/>\n <stop offset=\'88%\' stop-color=\'#dadada\'/>\n <stop offset=\'94%\' stop-color=\'#f6f6f6\'/>\n <stop offset=\'100%\' stop-color=\'#ffffff\'/>\n </radialGradient>\n <mask id="mask-__UID__">\n <rect x="0" y="0" width="500" height="200" fill="url(#gradient-__UID__)"></rect>\n </mask>\n </defs>\n <rect x="0" width="500" height="200" fill="currentColor" mask="url(#mask-__UID__)"></rect>\n</svg>',G=0;const P=function(){self.onmessage=(e=>{createImageBitmap(e.data.message.file).then(t=>{self.postMessage({id:e.data.id,message:t},[t])})})},v=function(){self.onmessage=(e=>{const t=e.data.message.imageData,i=e.data.message.colorMatrix,r=t.data,a=r.length,o=i[0],n=i[1],s=i[2],c=i[3],h=i[4],l=i[5],d=i[6],g=i[7],p=i[8],m=i[9],u=i[10],E=i[11],f=i[12],y=i[13],w=i[14],_=i[15],I=i[16],M=i[17],x=i[18],T=i[19];let A=0,R=0,C=0,D=0,G=0;for(;A<a;A+=4)R=r[A]/255,C=r[A+1]/255,D=r[A+2]/255,G=r[A+3]/255,r[A]=Math.max(0,Math.min(255*(R*o+C*n+D*s+G*c+h),255)),r[A+1]=Math.max(0,Math.min(255*(R*l+C*d+D*g+G*p+m),255)),r[A+2]=Math.max(0,Math.min(255*(R*u+C*E+D*f+G*y+w),255)),r[A+3]=Math.max(0,Math.min(255*(R*_+C*I+D*M+G*x+T),255));self.postMessage({id:e.data.id,message:t},[t.data.buffer])})},k={1:()=>[1,0,0,1,0,0],2:e=>[-1,0,0,1,e,0],3:(e,t)=>[-1,0,0,-1,e,t],4:(e,t)=>[1,0,0,-1,0,t],5:()=>[0,1,1,0,0,0],6:(e,t)=>[0,1,-1,0,t,0],7:(e,t)=>[0,-1,-1,0,t,e],8:e=>[0,-1,1,0,0,e]},V=(e,t,i,r)=>{t=Math.round(t),i=Math.round(i);const a=document.createElement("canvas");a.width=t,a.height=i;const o=a.getContext("2d");return r>=5&&r<=8&&([t,i]=[i,t]),((e,t,i,r)=>{-1!==r&&e.transform.apply(e,k[r](t,i))})(o,t,i,r),o.drawImage(e,0,0,t,i),a},O=e=>/^image/.test(e.type)&&!/svg/.test(e.type),L=e=>{const t=Math.min(10/e.width,10/e.height),i=document.createElement("canvas"),r=i.getContext("2d"),a=i.width=Math.ceil(e.width*t),o=i.height=Math.ceil(e.height*t);r.drawImage(e,0,0,a,o);let n=null;try{n=r.getImageData(0,0,a,o).data}catch(e){return null}const s=n.length;let c=0,h=0,l=0,d=0;for(;d<s;d+=4)c+=n[d]*n[d],h+=n[d+1]*n[d+1],l+=n[d+2]*n[d+2];return{r:c=S(c,s),g:h=S(h,s),b:l=S(l,s)}},S=(e,t)=>Math.floor(Math.sqrt(e/(t/4))),N=(e,t)=>{return(t=t||document.createElement("canvas")).width=e.width,t.height=e.height,t.getContext("2d").drawImage(e,0,0),t},b=e=>{const t=(e=>e.utils.createView({name:"image-preview-overlay",tag:"div",ignoreRect:!0,create:({root:e,props:t})=>{if(document.querySelector("base")){const e=window.location.href.replace(window.location.hash,"");D=D.replace(/url\(\#/g,"url("+e+"#")}G++,e.element.classList.add(`filepond--image-preview-overlay-${t.status}`),e.element.innerHTML=D.replace(/__UID__/g,G)},mixins:{styles:["opacity"],animations:{opacity:{type:"spring",mass:25}}}}))(e),i=(e=>e.utils.createView({name:"image-preview",tag:"div",ignoreRect:!0,mixins:{apis:["image","crop","markup","resize","dirty","background"],styles:["translateY","scaleX","scaleY","opacity"],animations:{scaleX:R,scaleY:R,translateY:R,opacity:{type:"tween",duration:400}}},create:({root:t,props:i})=>{t.ref.clip=t.appendChildView(t.createChildView(C(e),{id:i.id,image:i.image,crop:i.crop,markup:i.markup,resize:i.resize,dirty:i.dirty,background:i.background}))},write:({root:e,props:t,shouldOptimize:i})=>{const{clip:r}=e.ref,{image:a,crop:o,markup:n,resize:s,dirty:c}=t;if(r.crop=o,r.markup=n,r.resize=s,r.dirty=c,r.opacity=i?0:1,i||e.rect.element.hidden)return;const h=a.height/a.width;let l=o.aspectRatio||h;const d=e.rect.inner.width,g=e.rect.inner.height;let p=e.query("GET_IMAGE_PREVIEW_HEIGHT");const m=e.query("GET_IMAGE_PREVIEW_MIN_HEIGHT"),u=e.query("GET_IMAGE_PREVIEW_MAX_HEIGHT"),E=e.query("GET_PANEL_ASPECT_RATIO"),f=e.query("GET_ALLOW_MULTIPLE");E&&!f&&(p=d*E,l=E);let y=null!==p?p:Math.max(m,Math.min(d*l,u)),w=y/l;w>d&&(y=(w=d)*l),y>g&&(y=g,w=g/l),r.width=w,r.height=y}}))(e),{createWorker:r}=e.utils,a=(e,t,i)=>new Promise(a=>{e.ref.imageData||(e.ref.imageData=i.getContext("2d").getImageData(0,0,i.width,i.height));const o=(e=>{let t;try{t=new ImageData(e.width,e.height)}catch(i){t=document.createElement("canvas").getContext("2d").createImageData(e.width,e.height)}return t.data.set(new Uint8ClampedArray(e.data)),t})(e.ref.imageData);if(!t||20!==t.length)return i.getContext("2d").putImageData(o,0,0),a();const n=r(v);n.post({imageData:o,colorMatrix:t},e=>{i.getContext("2d").putImageData(e,0,0),n.terminate(),a()},[o.data.buffer])}),o=({root:e,props:t,image:r})=>{const a=t.id,o=e.query("GET_ITEM",{id:a});if(!o)return;const n=o.getMetadata("crop")||{center:{x:.5,y:.5},flip:{horizontal:!1,vertical:!1},zoom:1,rotation:0,aspectRatio:null},s=e.query("GET_IMAGE_TRANSFORM_CANVAS_BACKGROUND_COLOR");let c,h,l=!1;e.query("GET_IMAGE_PREVIEW_MARKUP_SHOW")&&(c=o.getMetadata("markup")||[],h=o.getMetadata("resize"),l=!0);const d=e.appendChildView(e.createChildView(i,{id:a,image:r,crop:n,resize:h,markup:c,dirty:l,background:s,opacity:0,scaleX:1.15,scaleY:1.15,translateY:15}),e.childViews.length);e.ref.images.push(d),d.opacity=1,d.scaleX=1,d.scaleY=1,d.translateY=0,setTimeout(()=>{e.dispatch("DID_IMAGE_PREVIEW_SHOW",{id:a})},250)},n=({root:e})=>{e.ref.overlayShadow.opacity=1,e.ref.overlayError.opacity=0,e.ref.overlaySuccess.opacity=0},s=({root:e})=>{e.ref.overlayShadow.opacity=.25,e.ref.overlayError.opacity=1};return e.utils.createView({name:"image-preview-wrapper",create:({root:e})=>{e.ref.images=[],e.ref.imageData=null,e.ref.imageViewBin=[],e.ref.overlayShadow=e.appendChildView(e.createChildView(t,{opacity:0,status:"idle"})),e.ref.overlaySuccess=e.appendChildView(e.createChildView(t,{opacity:0,status:"success"})),e.ref.overlayError=e.appendChildView(e.createChildView(t,{opacity:0,status:"failure"}))},styles:["height"],apis:["height"],destroy:({root:e})=>{e.ref.images.forEach(e=>{e.image.width=1,e.image.height=1})},didWriteView:({root:e})=>{e.ref.images.forEach(e=>{e.dirty=!1})},write:e.utils.createRoute({DID_IMAGE_PREVIEW_DRAW:({root:e})=>{const t=e.ref.images[e.ref.images.length-1];t.translateY=0,t.scaleX=1,t.scaleY=1,t.opacity=1},DID_IMAGE_PREVIEW_CONTAINER_CREATE:({root:e,props:t})=>{const{id:i}=t,r=e.query("GET_ITEM",i);r&&((e,t)=>{let i=new Image;i.onload=(()=>{const e=i.naturalWidth,r=i.naturalHeight;i=null,t(e,r)}),i.src=e})(URL.createObjectURL(r.file),(t,r)=>{e.dispatch("DID_IMAGE_PREVIEW_CALCULATE_SIZE",{id:i,width:t,height:r})})},DID_FINISH_CALCULATE_PREVIEWSIZE:({root:e,props:t})=>{const{id:i}=t,n=e.query("GET_ITEM",i);if(!n)return;const s=URL.createObjectURL(n.file),c=()=>{(e=>new Promise((t,i)=>{const r=new Image;r.crossOrigin="Anonymous",r.onload=(()=>{t(r)}),r.onerror=(e=>{i(e)}),r.src=e}))(s).then(h)},h=i=>{URL.revokeObjectURL(s);const r=(n.getMetadata("exif")||{}).orientation||-1;let{width:c,height:h}=i;if(!c||!h)return;r>=5&&r<=8&&([c,h]=[h,c]);const l=Math.max(1,.75*window.devicePixelRatio),d=e.query("GET_IMAGE_PREVIEW_ZOOM_FACTOR")*l,g=h/c,p=e.rect.element.width,m=e.rect.element.height;let u=p,E=u*g;g>1?E=(u=Math.min(c,p*d))*g:u=(E=Math.min(h,m*d))/g;const f=V(i,u,E,r),y=()=>{const r=e.query("GET_IMAGE_PREVIEW_CALCULATE_AVERAGE_IMAGE_COLOR")?L(data):null;n.setMetadata("color",r,!0),"close"in i&&i.close(),e.ref.overlayShadow.opacity=1,o({root:e,props:t,image:f})},w=n.getMetadata("filter");w?a(e,w,f).then(y):y()};if((e=>{const t=window.navigator.userAgent.match(/Firefox\/([0-9]+)\./);return!((t?parseInt(t[1]):null)<=58)&&"createImageBitmap"in window&&O(e)})(n.file)){const e=r(P);e.post({file:n.file},t=>{e.terminate(),t?h(t):c()})}else c()},DID_UPDATE_ITEM_METADATA:({root:e,props:t,action:i})=>{if(!/crop|filter|markup|resize/.test(i.change.key))return;if(!e.ref.images.length)return;const r=e.query("GET_ITEM",{id:t.id});if(r)if(/filter/.test(i.change.key)){const t=e.ref.images[e.ref.images.length-1];a(e,i.change.value,t.image)}else if(/crop|markup|resize/.test(i.change.key)){const i=r.getMetadata("crop"),a=e.ref.images[e.ref.images.length-1];if(Math.abs(i.aspectRatio-a.crop.aspectRatio)>1e-5){const i=(({root:e})=>{const t=e.ref.images.shift();return t.opacity=0,t.translateY=-15,e.ref.imageViewBin.push(t),t})({root:e});o({root:e,props:t,image:N(i.image)})}else(({root:e,props:t})=>{const i=e.query("GET_ITEM",{id:t.id});if(!i)return;const r=e.ref.images[e.ref.images.length-1];r.crop=i.getMetadata("crop"),r.background=e.query("GET_IMAGE_TRANSFORM_CANVAS_BACKGROUND_COLOR"),e.query("GET_IMAGE_PREVIEW_MARKUP_SHOW")&&(r.dirty=!0,r.resize=i.getMetadata("resize"),r.markup=i.getMetadata("markup"))})({root:e,props:t})}},DID_THROW_ITEM_LOAD_ERROR:s,DID_THROW_ITEM_PROCESSING_ERROR:s,DID_THROW_ITEM_INVALID:s,DID_COMPLETE_ITEM_PROCESSING:({root:e})=>{e.ref.overlayShadow.opacity=.25,e.ref.overlaySuccess.opacity=1},DID_START_ITEM_PROCESSING:n,DID_REVERT_ITEM_PROCESSING:n},({root:e})=>{const t=e.ref.imageViewBin.filter(e=>0===e.opacity);e.ref.imageViewBin=e.ref.imageViewBin.filter(e=>e.opacity>0),t.forEach(t=>((e,t)=>{e.removeChildView(t),t.image.width=1,t.image.height=1,t._destroy()})(e,t)),t.length=0})})},W=e=>{const{addFilter:t,utils:i}=e,{Type:r,createRoute:a,isFile:o}=i,n=b(e);return t("CREATE_VIEW",e=>{const{is:t,view:i,query:r}=e;if(!t("file")||!r("GET_ALLOW_IMAGE_PREVIEW"))return;const s=({root:e})=>{e.ref.shouldRescale=!0};i.registerWriter(a({DID_RESIZE_ROOT:s,DID_STOP_RESIZE:s,DID_LOAD_ITEM:({root:e,props:t})=>{const{id:a}=t,s=r("GET_ITEM",a);if(!s||!o(s.file)||s.archived)return;const c=s.file;if(!(e=>/^image/.test(e.type))(c))return;if(!r("GET_IMAGE_PREVIEW_FILTER_ITEM")(s))return;const h="createImageBitmap"in(window||{}),l=r("GET_IMAGE_PREVIEW_MAX_FILE_SIZE");if(!h&&l&&c.size>l)return;e.ref.imagePreview=i.appendChildView(i.createChildView(n,{id:a}));const d=e.query("GET_IMAGE_PREVIEW_HEIGHT");d&&e.dispatch("DID_UPDATE_PANEL_HEIGHT",{id:s.id,height:d});const g=!h&&c.size>r("GET_IMAGE_PREVIEW_MAX_INSTANT_PREVIEW_FILE_SIZE");e.dispatch("DID_IMAGE_PREVIEW_CONTAINER_CREATE",{id:a},g)},DID_IMAGE_PREVIEW_CALCULATE_SIZE:({root:e,action:t})=>{e.ref.imageWidth=t.width,e.ref.imageHeight=t.height,e.ref.shouldRescale=!0,e.ref.shouldDrawPreview=!0,e.dispatch("KICK")},DID_UPDATE_ITEM_METADATA:({root:e,action:t})=>{"crop"===t.change.key&&(e.ref.shouldRescale=!0)}},({root:e,props:t})=>{e.ref.imagePreview&&(e.rect.element.hidden||(e.ref.shouldRescale&&(((e,t)=>{if(!e.ref.imagePreview)return;let{id:i}=t;const r=e.query("GET_ITEM",{id:i});if(!r)return;const a=e.query("GET_PANEL_ASPECT_RATIO"),o=e.query("GET_ITEM_PANEL_ASPECT_RATIO"),n=e.query("GET_IMAGE_PREVIEW_HEIGHT");if(a||o||n)return;let{imageWidth:s,imageHeight:c}=e.ref;if(!s||!c)return;const h=e.query("GET_IMAGE_PREVIEW_MIN_HEIGHT"),l=e.query("GET_IMAGE_PREVIEW_MAX_HEIGHT"),d=(r.getMetadata("exif")||{}).orientation||-1;if(d>=5&&d<=8&&([s,c]=[c,s]),!O(r.file)||e.query("GET_IMAGE_PREVIEW_UPSCALE")){const e=2048/s;s*=e,c*=e}const g=c/s,p=(r.getMetadata("crop")||{}).aspectRatio||g;let m=Math.max(h,Math.min(c,l));const u=e.rect.element.width,E=Math.min(u*p,m);e.dispatch("DID_UPDATE_PANEL_HEIGHT",{id:r.id,height:E})})(e,t),e.ref.shouldRescale=!1),e.ref.shouldDrawPreview&&(requestAnimationFrame(()=>{e.dispatch("DID_FINISH_CALCULATE_PREVIEWSIZE",{id:t.id})}),e.ref.shouldDrawPreview=!1)))}))}),{options:{allowImagePreview:[!0,r.BOOLEAN],imagePreviewFilterItem:[()=>!0,r.FUNCTION],imagePreviewHeight:[null,r.INT],imagePreviewMinHeight:[44,r.INT],imagePreviewMaxHeight:[256,r.INT],imagePreviewMaxFileSize:[null,r.INT],imagePreviewZoomFactor:[2,r.INT],imagePreviewUpscale:[!1,r.BOOLEAN],imagePreviewMaxInstantPreviewFileSize:[1e6,r.INT],imagePreviewTransparencyIndicator:[null,r.STRING],imagePreviewCalculateAverageImageColor:[!1,r.BOOLEAN],imagePreviewMarkupShow:[!0,r.BOOLEAN],imagePreviewMarkupFilter:[()=>!0,r.FUNCTION]}}};"undefined"!=typeof window&&void 0!==window.document&&document.dispatchEvent(new CustomEvent("FilePond:pluginloaded",{detail:W}));export default W; | ||
const e=(e,t)=>r(e.x*t,e.y*t),t=(e,t)=>r(e.x+t.x,e.y+t.y),i=(e,t,i)=>{const a=Math.cos(t),o=Math.sin(t),n=r(e.x-i.x,e.y-i.y);return r(i.x+a*n.x-o*n.y,i.y+o*n.x+a*n.y)},r=(e=0,t=0)=>({x:e,y:t}),a=(e,t,i=1,r)=>"string"==typeof e?parseFloat(e)*i:"number"==typeof e?e*(r?t[r]:Math.min(t.width,t.height)):void 0,o=e=>null!=e,n=e=>e.map((e,t)=>`${0===t?"M":"L"} ${e.x} ${e.y}`).join(" "),s=(e,t)=>Object.keys(t).forEach(i=>e.setAttribute(i,t[i])),c=(e,t)=>{const i=document.createElementNS("http://www.w3.org/2000/svg",e);return t&&s(i,t),i},h={contain:"xMidYMid meet",cover:"xMidYMid slice"},l={left:"start",center:"middle",right:"end"},d=e=>t=>c(e,{id:t.id}),g={image:e=>{const t=c("image",{id:e.id,"stroke-linecap":"round","stroke-linejoin":"round",opacity:"0"});return t.onload=(()=>{t.setAttribute("opacity",e.opacity||1)}),t.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",e.src),t},rect:d("rect"),ellipse:d("ellipse"),text:d("text"),path:d("path"),line:e=>{const t=c("g",{id:e.id,"stroke-linecap":"round","stroke-linejoin":"round"}),i=c("line");t.appendChild(i);const r=c("path");t.appendChild(r);const a=c("path");return t.appendChild(a),t}},p={rect:e=>s(e,{...e.rect,...e.styles}),ellipse:e=>{const t=e.rect.x+.5*e.rect.width,i=e.rect.y+.5*e.rect.height,r=.5*e.rect.width,a=.5*e.rect.height;return s(e,{cx:t,cy:i,rx:r,ry:a,...e.styles})},image:(e,t)=>{s(e,{...e.rect,...e.styles,preserveAspectRatio:h[t.fit]||"none"})},text:(e,t,i,r)=>{const o=a(t.fontSize,i,r),n=t.fontFamily||"sans-serif",c=t.fontWeight||"normal",h=l[t.textAlign]||"start";s(e,{...e.rect,...e.styles,"stroke-width":0,"font-weight":c,"font-size":o,"font-family":n,"text-anchor":h}),e.text!==t.text&&(e.text=t.text,e.textContent=t.text.length?t.text:" ")},path:(e,t,i,r)=>{s(e,{...e.styles,fill:"none",d:n(t.points.map(e=>({x:a(e.x,i,r,"width"),y:a(e.y,i,r,"height")})))})},line:(o,n,c,h)=>{s(o,{...o.rect,...o.styles,fill:"none"});const l=o.childNodes[0],d=o.childNodes[1],g=o.childNodes[2],p=o.rect,m={x:o.rect.x+o.rect.width,y:o.rect.y+o.rect.height};if(s(l,{x1:p.x,y1:p.y,x2:m.x,y2:m.y}),!n.lineDecoration)return;d.style.display="none",g.style.display="none";const u=(e=>{const t=Math.sqrt(e.x*e.x+e.y*e.y);return 0===t?{x:0,y:0}:r(e.x/t,e.y/t)})({x:m.x-p.x,y:m.y-p.y}),E=a(.05,c,h);if(-1!==n.lineDecoration.indexOf("arrow-begin")){const r=e(u,E),a=t(p,r),o=i(p,2,a),n=i(p,-2,a);s(d,{style:"display:block;",d:`M${o.x},${o.y} L${p.x},${p.y} L${n.x},${n.y}`})}if(-1!==n.lineDecoration.indexOf("arrow-end")){const r=e(u,-E),a=t(m,r),o=i(m,2,a),n=i(m,-2,a);s(g,{style:"display:block;",d:`M${o.x},${o.y} L${m.x},${m.y} L${n.x},${n.y}`})}}},m=(e,t,i,r,n)=>{"path"!==t&&(e.rect=((e,t,i=1)=>{let r=a(e.x,t,i,"width")||a(e.left,t,i,"width"),n=a(e.y,t,i,"height")||a(e.top,t,i,"height"),s=a(e.width,t,i,"width"),c=a(e.height,t,i,"height"),h=a(e.right,t,i,"width"),l=a(e.bottom,t,i,"height");return o(n)||(n=o(c)&&o(l)?t.height-c-l:l),o(r)||(r=o(s)&&o(h)?t.width-s-h:h),o(s)||(s=o(r)&&o(h)?t.width-r-h:0),o(c)||(c=o(n)&&o(l)?t.height-n-l:0),{x:r||0,y:n||0,width:s||0,height:c||0}})(i,r,n)),e.styles=((e,t,i)=>{const r=e.borderStyle||e.lineStyle||"solid",o=e.backgroundColor||e.fontColor||"transparent",n=e.borderColor||e.lineColor||"transparent",s=a(e.borderWidth||e.lineWidth,t,i);return{"stroke-linecap":e.lineCap||"round","stroke-linejoin":e.lineJoin||"round","stroke-width":s||0,"stroke-dasharray":"string"==typeof r?"":r.map(e=>a(e,t,i)).join(","),stroke:n,fill:o,opacity:e.opacity||1}})(i,r,n),p[t](e,i,r,n)},u=["x","y","left","top","right","bottom","width","height"],E=e=>{const[t,i]=e,r=i.points?{}:u.reduce((e,t)=>(e[t]=(e=>"string"==typeof e&&/%/.test(e)?parseFloat(e)/100:e)(i[t]),e),{});return[t,{zIndex:0,...i,...r}]},f=(e,t)=>e[1].zIndex>t[1].zIndex?1:e[1].zIndex<t[1].zIndex?-1:0,y=e=>e.utils.createView({name:"image-preview-markup",tag:"svg",ignoreRect:!0,mixins:{apis:["width","height","crop","markup","resize","dirty"]},write:({root:e,props:t})=>{if(!t.dirty)return;const{crop:i,resize:r,markup:a}=t,o=t.width,n=t.height;let s=i.width,c=i.height;if(r){const{size:e}=r;let t=e&&e.width,i=e&&e.height;const a=r.mode,o=r.upscale;t&&!i&&(i=t),i&&!t&&(t=i);const n=s<t&&c<i;if(!n||n&&o){let e=t/s,r=i/c;if("force"===a)s=t,c=i;else{let t;"cover"===a?t=Math.max(e,r):"contain"===a&&(t=Math.min(e,r)),s*=t,c*=t}}}const h={width:o,height:n};e.element.setAttribute("width",h.width),e.element.setAttribute("height",h.height);const l=Math.min(o/s,n/c);e.element.innerHTML="";const d=e.query("GET_IMAGE_PREVIEW_MARKUP_FILTER");a.filter(d).map(E).sort(f).forEach(t=>{const[i,r]=t,a=((e,t)=>g[e](t))(i,r);m(a,i,r,h,l),e.element.appendChild(a)})}}),w=(e,t)=>({x:e,y:t}),_=(e,t)=>w(e.x-t.x,e.y-t.y),I=(e,t)=>Math.sqrt(((e,t)=>((e,t)=>e.x*t.x+e.y*t.y)(_(e,t),_(e,t)))(e,t)),M=(e,t)=>{const i=e,r=t,a=1.5707963267948966-t,o=Math.sin(1.5707963267948966),n=Math.sin(r),s=Math.sin(a),c=Math.cos(a),h=i/o;return w(c*(h*n),c*(h*s))},x=(e,t,i,r)=>{const a=r.x>.5?1-r.x:r.x,o=r.y>.5?1-r.y:r.y,n=2*a*e.width,s=2*o*e.height,c=((e,t)=>{const i=e.width,r=e.height,a=M(i,t),o=M(r,t),n=w(e.x+Math.abs(a.x),e.y-Math.abs(a.y)),s=w(e.x+e.width+Math.abs(o.y),e.y+Math.abs(o.x)),c=w(e.x-Math.abs(o.y),e.y+e.height-Math.abs(o.x));return{width:I(n,s),height:I(n,c)}})(t,i);return Math.max(c.width/n,c.height/s)},T=(e,t)=>{let i=e.width,r=i*t;return r>e.height&&(i=(r=e.height)/t),{x:.5*(e.width-i),y:.5*(e.height-r),width:i,height:r}},A=(e,t={})=>{let{zoom:i,rotation:r,center:a,aspectRatio:o}=t;o||(o=e.height/e.width);const n=((e,t,i=1)=>{const r=e.height/e.width;let a=t,o=1,n=r;n>a&&(o=(n=a)/r);const s=Math.max(1/o,a/n),c=e.width/(i*s*o);return{width:c,height:c*t}})(e,o,i),s={x:.5*n.width,y:.5*n.height},c={x:0,y:0,width:n.width,height:n.height,center:s},h=void 0===t.scaleToFit||t.scaleToFit,l=i*x(e,T(c,o),r,h?a:{x:.5,y:.5});return{widthFloat:n.width/l,heightFloat:n.height/l,width:Math.round(n.width/l),height:Math.round(n.height/l)}},R={type:"spring",stiffness:.5,damping:.45,mass:10},C=e=>e.utils.createView({name:"image-clip",tag:"div",ignoreRect:!0,mixins:{apis:["crop","markup","resize","width","height","dirty","background"],styles:["width","height","opacity"],animations:{opacity:{type:"tween",duration:250}}},didWriteView:function({root:e,props:t}){t.background&&(e.element.style.backgroundColor=t.background)},create:({root:t,props:i})=>{t.ref.image=t.appendChildView(t.createChildView((e=>e.utils.createView({name:"image-canvas-wrapper",tag:"div",ignoreRect:!0,mixins:{apis:["crop","width","height"],styles:["originX","originY","translateX","translateY","scaleX","scaleY","rotateZ"],animations:{originX:R,originY:R,scaleX:R,scaleY:R,translateX:R,translateY:R,rotateZ:R}},create:({root:t,props:i})=>{i.width=i.image.width,i.height=i.image.height,t.ref.bitmap=t.appendChildView(t.createChildView((e=>e.utils.createView({name:"image-bitmap",ignoreRect:!0,mixins:{styles:["scaleX","scaleY"]},create:({root:e,props:t})=>{e.appendChild(t.image)}}))(e),{image:i.image}))},write:({root:e,props:t})=>{const{flip:i}=t.crop,{bitmap:r}=e.ref;r.scaleX=i.horizontal?-1:1,r.scaleY=i.vertical?-1:1}}))(e),Object.assign({},i))),t.ref.createMarkup=(()=>{t.ref.markup||(t.ref.markup=t.appendChildView(t.createChildView(y(e),Object.assign({},i))))}),t.ref.destroyMarkup=(()=>{t.ref.markup&&(t.removeChildView(t.ref.markup),t.ref.markup=null)});const r=t.query("GET_IMAGE_PREVIEW_TRANSPARENCY_INDICATOR");null!==r&&(t.element.dataset.transparencyIndicator="grid"===r?r:"color")},write:({root:e,props:t,shouldOptimize:i})=>{const{crop:r,markup:a,resize:o,dirty:n,width:s,height:c}=t;e.ref.image.crop=r;const h={x:0,y:0,width:s,height:c,center:{x:.5*s,y:.5*c}},l={width:e.ref.image.width,height:e.ref.image.height},d={x:r.center.x*l.width,y:r.center.y*l.height},g={x:h.center.x-l.width*r.center.x,y:h.center.y-l.height*r.center.y},p=2*Math.PI+r.rotation%(2*Math.PI),m=r.aspectRatio||l.height/l.width,u=void 0===r.scaleToFit||r.scaleToFit,E=x(l,T(h,m),p,u?r.center:{x:.5,y:.5}),f=r.zoom*E;a&&a.length?(e.ref.createMarkup(),e.ref.markup.width=s,e.ref.markup.height=c,e.ref.markup.resize=o,e.ref.markup.dirty=n,e.ref.markup.markup=a,e.ref.markup.crop=A(l,r)):e.ref.markup&&e.ref.destroyMarkup();const y=e.ref.image;if(i)return y.originX=null,y.originY=null,y.translateX=null,y.translateY=null,y.rotateZ=null,y.scaleX=null,void(y.scaleY=null);y.originX=d.x,y.originY=d.y,y.translateX=g.x,y.translateY=g.y,y.rotateZ=p,y.scaleX=f,y.scaleY=f}});let D=0;const G=function(){self.onmessage=(e=>{createImageBitmap(e.data.message.file).then(t=>{self.postMessage({id:e.data.id,message:t},[t])})})},P=function(){self.onmessage=(e=>{const t=e.data.message.imageData,i=e.data.message.colorMatrix,r=t.data,a=r.length,o=i[0],n=i[1],s=i[2],c=i[3],h=i[4],l=i[5],d=i[6],g=i[7],p=i[8],m=i[9],u=i[10],E=i[11],f=i[12],y=i[13],w=i[14],_=i[15],I=i[16],M=i[17],x=i[18],T=i[19];let A=0,R=0,C=0,D=0,G=0;for(;A<a;A+=4)R=r[A]/255,C=r[A+1]/255,D=r[A+2]/255,G=r[A+3]/255,r[A]=Math.max(0,Math.min(255*(R*o+C*n+D*s+G*c+h),255)),r[A+1]=Math.max(0,Math.min(255*(R*l+C*d+D*g+G*p+m),255)),r[A+2]=Math.max(0,Math.min(255*(R*u+C*E+D*f+G*y+w),255)),r[A+3]=Math.max(0,Math.min(255*(R*_+C*I+D*M+G*x+T),255));self.postMessage({id:e.data.id,message:t},[t.data.buffer])})},v={1:()=>[1,0,0,1,0,0],2:e=>[-1,0,0,1,e,0],3:(e,t)=>[-1,0,0,-1,e,t],4:(e,t)=>[1,0,0,-1,0,t],5:()=>[0,1,1,0,0,0],6:(e,t)=>[0,1,-1,0,t,0],7:(e,t)=>[0,-1,-1,0,t,e],8:e=>[0,-1,1,0,0,e]},k=(e,t,i,r)=>{t=Math.round(t),i=Math.round(i);const a=document.createElement("canvas");a.width=t,a.height=i;const o=a.getContext("2d");return r>=5&&r<=8&&([t,i]=[i,t]),((e,t,i,r)=>{-1!==r&&e.transform.apply(e,v[r](t,i))})(o,t,i,r),o.drawImage(e,0,0,t,i),a},V=e=>/^image/.test(e.type)&&!/svg/.test(e.type),O=e=>{const t=Math.min(10/e.width,10/e.height),i=document.createElement("canvas"),r=i.getContext("2d"),a=i.width=Math.ceil(e.width*t),o=i.height=Math.ceil(e.height*t);r.drawImage(e,0,0,a,o);let n=null;try{n=r.getImageData(0,0,a,o).data}catch(e){return null}const s=n.length;let c=0,h=0,l=0,d=0;for(;d<s;d+=4)c+=n[d]*n[d],h+=n[d+1]*n[d+1],l+=n[d+2]*n[d+2];return{r:c=L(c,s),g:h=L(h,s),b:l=L(l,s)}},L=(e,t)=>Math.floor(Math.sqrt(e/(t/4))),S=(e,t)=>{return(t=t||document.createElement("canvas")).width=e.width,t.height=e.height,t.getContext("2d").drawImage(e,0,0),t},N=e=>{const t=(e=>e.utils.createView({name:"image-preview-overlay",tag:"div",ignoreRect:!0,create:({root:e,props:t})=>{let i='<svg width="500" height="200" viewBox="0 0 500 200" preserveAspectRatio="none">\n <defs>\n <radialGradient id="gradient-__UID__" cx=".5" cy="1.25" r="1.15">\n <stop offset=\'50%\' stop-color=\'#000000\'/>\n <stop offset=\'56%\' stop-color=\'#0a0a0a\'/>\n <stop offset=\'63%\' stop-color=\'#262626\'/>\n <stop offset=\'69%\' stop-color=\'#4f4f4f\'/>\n <stop offset=\'75%\' stop-color=\'#808080\'/>\n <stop offset=\'81%\' stop-color=\'#b1b1b1\'/>\n <stop offset=\'88%\' stop-color=\'#dadada\'/>\n <stop offset=\'94%\' stop-color=\'#f6f6f6\'/>\n <stop offset=\'100%\' stop-color=\'#ffffff\'/>\n </radialGradient>\n <mask id="mask-__UID__">\n <rect x="0" y="0" width="500" height="200" fill="url(#gradient-__UID__)"></rect>\n </mask>\n </defs>\n <rect x="0" width="500" height="200" fill="currentColor" mask="url(#mask-__UID__)"></rect>\n</svg>';if(document.querySelector("base")){const e=window.location.href.replace(window.location.hash,"");i=i.replace(/url\(\#/g,"url("+e+"#")}D++,e.element.classList.add(`filepond--image-preview-overlay-${t.status}`),e.element.innerHTML=i.replace(/__UID__/g,D)},mixins:{styles:["opacity"],animations:{opacity:{type:"spring",mass:25}}}}))(e),i=(e=>e.utils.createView({name:"image-preview",tag:"div",ignoreRect:!0,mixins:{apis:["image","crop","markup","resize","dirty","background"],styles:["translateY","scaleX","scaleY","opacity"],animations:{scaleX:R,scaleY:R,translateY:R,opacity:{type:"tween",duration:400}}},create:({root:t,props:i})=>{t.ref.clip=t.appendChildView(t.createChildView(C(e),{id:i.id,image:i.image,crop:i.crop,markup:i.markup,resize:i.resize,dirty:i.dirty,background:i.background}))},write:({root:e,props:t,shouldOptimize:i})=>{const{clip:r}=e.ref,{image:a,crop:o,markup:n,resize:s,dirty:c}=t;if(r.crop=o,r.markup=n,r.resize=s,r.dirty=c,r.opacity=i?0:1,i||e.rect.element.hidden)return;const h=a.height/a.width;let l=o.aspectRatio||h;const d=e.rect.inner.width,g=e.rect.inner.height;let p=e.query("GET_IMAGE_PREVIEW_HEIGHT");const m=e.query("GET_IMAGE_PREVIEW_MIN_HEIGHT"),u=e.query("GET_IMAGE_PREVIEW_MAX_HEIGHT"),E=e.query("GET_PANEL_ASPECT_RATIO"),f=e.query("GET_ALLOW_MULTIPLE");E&&!f&&(p=d*E,l=E);let y=null!==p?p:Math.max(m,Math.min(d*l,u)),w=y/l;w>d&&(y=(w=d)*l),y>g&&(y=g,w=g/l),r.width=w,r.height=y}}))(e),{createWorker:r}=e.utils,a=(e,t,i)=>new Promise(a=>{e.ref.imageData||(e.ref.imageData=i.getContext("2d").getImageData(0,0,i.width,i.height));const o=(e=>{let t;try{t=new ImageData(e.width,e.height)}catch(i){t=document.createElement("canvas").getContext("2d").createImageData(e.width,e.height)}return t.data.set(new Uint8ClampedArray(e.data)),t})(e.ref.imageData);if(!t||20!==t.length)return i.getContext("2d").putImageData(o,0,0),a();const n=r(P);n.post({imageData:o,colorMatrix:t},e=>{i.getContext("2d").putImageData(e,0,0),n.terminate(),a()},[o.data.buffer])}),o=({root:e,props:t,image:r})=>{const a=t.id,o=e.query("GET_ITEM",{id:a});if(!o)return;const n=o.getMetadata("crop")||{center:{x:.5,y:.5},flip:{horizontal:!1,vertical:!1},zoom:1,rotation:0,aspectRatio:null},s=e.query("GET_IMAGE_TRANSFORM_CANVAS_BACKGROUND_COLOR");let c,h,l=!1;e.query("GET_IMAGE_PREVIEW_MARKUP_SHOW")&&(c=o.getMetadata("markup")||[],h=o.getMetadata("resize"),l=!0);const d=e.appendChildView(e.createChildView(i,{id:a,image:r,crop:n,resize:h,markup:c,dirty:l,background:s,opacity:0,scaleX:1.15,scaleY:1.15,translateY:15}),e.childViews.length);e.ref.images.push(d),d.opacity=1,d.scaleX=1,d.scaleY=1,d.translateY=0,setTimeout(()=>{e.dispatch("DID_IMAGE_PREVIEW_SHOW",{id:a})},250)},n=({root:e})=>{e.ref.overlayShadow.opacity=1,e.ref.overlayError.opacity=0,e.ref.overlaySuccess.opacity=0},s=({root:e})=>{e.ref.overlayShadow.opacity=.25,e.ref.overlayError.opacity=1};return e.utils.createView({name:"image-preview-wrapper",create:({root:e})=>{e.ref.images=[],e.ref.imageData=null,e.ref.imageViewBin=[],e.ref.overlayShadow=e.appendChildView(e.createChildView(t,{opacity:0,status:"idle"})),e.ref.overlaySuccess=e.appendChildView(e.createChildView(t,{opacity:0,status:"success"})),e.ref.overlayError=e.appendChildView(e.createChildView(t,{opacity:0,status:"failure"}))},styles:["height"],apis:["height"],destroy:({root:e})=>{e.ref.images.forEach(e=>{e.image.width=1,e.image.height=1})},didWriteView:({root:e})=>{e.ref.images.forEach(e=>{e.dirty=!1})},write:e.utils.createRoute({DID_IMAGE_PREVIEW_DRAW:({root:e})=>{const t=e.ref.images[e.ref.images.length-1];t.translateY=0,t.scaleX=1,t.scaleY=1,t.opacity=1},DID_IMAGE_PREVIEW_CONTAINER_CREATE:({root:e,props:t})=>{const{id:i}=t,r=e.query("GET_ITEM",i);r&&((e,t)=>{let i=new Image;i.onload=(()=>{const e=i.naturalWidth,r=i.naturalHeight;i=null,t(e,r)}),i.src=e})(URL.createObjectURL(r.file),(t,r)=>{e.dispatch("DID_IMAGE_PREVIEW_CALCULATE_SIZE",{id:i,width:t,height:r})})},DID_FINISH_CALCULATE_PREVIEWSIZE:({root:e,props:t})=>{const{id:i}=t,n=e.query("GET_ITEM",i);if(!n)return;const s=URL.createObjectURL(n.file),c=()=>{(e=>new Promise((t,i)=>{const r=new Image;r.crossOrigin="Anonymous",r.onload=(()=>{t(r)}),r.onerror=(e=>{i(e)}),r.src=e}))(s).then(h)},h=i=>{URL.revokeObjectURL(s);const r=(n.getMetadata("exif")||{}).orientation||-1;let{width:c,height:h}=i;if(!c||!h)return;r>=5&&r<=8&&([c,h]=[h,c]);const l=Math.max(1,.75*window.devicePixelRatio),d=e.query("GET_IMAGE_PREVIEW_ZOOM_FACTOR")*l,g=h/c,p=e.rect.element.width,m=e.rect.element.height;let u=p,E=u*g;g>1?E=(u=Math.min(c,p*d))*g:u=(E=Math.min(h,m*d))/g;const f=k(i,u,E,r),y=()=>{const r=e.query("GET_IMAGE_PREVIEW_CALCULATE_AVERAGE_IMAGE_COLOR")?O(data):null;n.setMetadata("color",r,!0),"close"in i&&i.close(),e.ref.overlayShadow.opacity=1,o({root:e,props:t,image:f})},w=n.getMetadata("filter");w?a(e,w,f).then(y):y()};if((e=>{const t=window.navigator.userAgent.match(/Firefox\/([0-9]+)\./);return!((t?parseInt(t[1]):null)<=58)&&"createImageBitmap"in window&&V(e)})(n.file)){const e=r(G);e.post({file:n.file},t=>{e.terminate(),t?h(t):c()})}else c()},DID_UPDATE_ITEM_METADATA:({root:e,props:t,action:i})=>{if(!/crop|filter|markup|resize/.test(i.change.key))return;if(!e.ref.images.length)return;const r=e.query("GET_ITEM",{id:t.id});if(r)if(/filter/.test(i.change.key)){const t=e.ref.images[e.ref.images.length-1];a(e,i.change.value,t.image)}else if(/crop|markup|resize/.test(i.change.key)){const i=r.getMetadata("crop"),a=e.ref.images[e.ref.images.length-1];if(Math.abs(i.aspectRatio-a.crop.aspectRatio)>1e-5){const i=(({root:e})=>{const t=e.ref.images.shift();return t.opacity=0,t.translateY=-15,e.ref.imageViewBin.push(t),t})({root:e});o({root:e,props:t,image:S(i.image)})}else(({root:e,props:t})=>{const i=e.query("GET_ITEM",{id:t.id});if(!i)return;const r=e.ref.images[e.ref.images.length-1];r.crop=i.getMetadata("crop"),r.background=e.query("GET_IMAGE_TRANSFORM_CANVAS_BACKGROUND_COLOR"),e.query("GET_IMAGE_PREVIEW_MARKUP_SHOW")&&(r.dirty=!0,r.resize=i.getMetadata("resize"),r.markup=i.getMetadata("markup"))})({root:e,props:t})}},DID_THROW_ITEM_LOAD_ERROR:s,DID_THROW_ITEM_PROCESSING_ERROR:s,DID_THROW_ITEM_INVALID:s,DID_COMPLETE_ITEM_PROCESSING:({root:e})=>{e.ref.overlayShadow.opacity=.25,e.ref.overlaySuccess.opacity=1},DID_START_ITEM_PROCESSING:n,DID_REVERT_ITEM_PROCESSING:n},({root:e})=>{const t=e.ref.imageViewBin.filter(e=>0===e.opacity);e.ref.imageViewBin=e.ref.imageViewBin.filter(e=>e.opacity>0),t.forEach(t=>((e,t)=>{e.removeChildView(t),t.image.width=1,t.image.height=1,t._destroy()})(e,t)),t.length=0})})},b=e=>{const{addFilter:t,utils:i}=e,{Type:r,createRoute:a,isFile:o}=i,n=N(e);return t("CREATE_VIEW",e=>{const{is:t,view:i,query:r}=e;if(!t("file")||!r("GET_ALLOW_IMAGE_PREVIEW"))return;const s=({root:e})=>{e.ref.shouldRescale=!0};i.registerWriter(a({DID_RESIZE_ROOT:s,DID_STOP_RESIZE:s,DID_LOAD_ITEM:({root:e,props:t})=>{const{id:a}=t,s=r("GET_ITEM",a);if(!s||!o(s.file)||s.archived)return;const c=s.file;if(!(e=>/^image/.test(e.type))(c))return;if(!r("GET_IMAGE_PREVIEW_FILTER_ITEM")(s))return;const h="createImageBitmap"in(window||{}),l=r("GET_IMAGE_PREVIEW_MAX_FILE_SIZE");if(!h&&l&&c.size>l)return;e.ref.imagePreview=i.appendChildView(i.createChildView(n,{id:a}));const d=e.query("GET_IMAGE_PREVIEW_HEIGHT");d&&e.dispatch("DID_UPDATE_PANEL_HEIGHT",{id:s.id,height:d});const g=!h&&c.size>r("GET_IMAGE_PREVIEW_MAX_INSTANT_PREVIEW_FILE_SIZE");e.dispatch("DID_IMAGE_PREVIEW_CONTAINER_CREATE",{id:a},g)},DID_IMAGE_PREVIEW_CALCULATE_SIZE:({root:e,action:t})=>{e.ref.imageWidth=t.width,e.ref.imageHeight=t.height,e.ref.shouldRescale=!0,e.ref.shouldDrawPreview=!0,e.dispatch("KICK")},DID_UPDATE_ITEM_METADATA:({root:e,action:t})=>{"crop"===t.change.key&&(e.ref.shouldRescale=!0)}},({root:e,props:t})=>{e.ref.imagePreview&&(e.rect.element.hidden||(e.ref.shouldRescale&&(((e,t)=>{if(!e.ref.imagePreview)return;let{id:i}=t;const r=e.query("GET_ITEM",{id:i});if(!r)return;const a=e.query("GET_PANEL_ASPECT_RATIO"),o=e.query("GET_ITEM_PANEL_ASPECT_RATIO"),n=e.query("GET_IMAGE_PREVIEW_HEIGHT");if(a||o||n)return;let{imageWidth:s,imageHeight:c}=e.ref;if(!s||!c)return;const h=e.query("GET_IMAGE_PREVIEW_MIN_HEIGHT"),l=e.query("GET_IMAGE_PREVIEW_MAX_HEIGHT"),d=(r.getMetadata("exif")||{}).orientation||-1;if(d>=5&&d<=8&&([s,c]=[c,s]),!V(r.file)||e.query("GET_IMAGE_PREVIEW_UPSCALE")){const e=2048/s;s*=e,c*=e}const g=c/s,p=(r.getMetadata("crop")||{}).aspectRatio||g;let m=Math.max(h,Math.min(c,l));const u=e.rect.element.width,E=Math.min(u*p,m);e.dispatch("DID_UPDATE_PANEL_HEIGHT",{id:r.id,height:E})})(e,t),e.ref.shouldRescale=!1),e.ref.shouldDrawPreview&&(requestAnimationFrame(()=>{e.dispatch("DID_FINISH_CALCULATE_PREVIEWSIZE",{id:t.id})}),e.ref.shouldDrawPreview=!1)))}))}),{options:{allowImagePreview:[!0,r.BOOLEAN],imagePreviewFilterItem:[()=>!0,r.FUNCTION],imagePreviewHeight:[null,r.INT],imagePreviewMinHeight:[44,r.INT],imagePreviewMaxHeight:[256,r.INT],imagePreviewMaxFileSize:[null,r.INT],imagePreviewZoomFactor:[2,r.INT],imagePreviewUpscale:[!1,r.BOOLEAN],imagePreviewMaxInstantPreviewFileSize:[1e6,r.INT],imagePreviewTransparencyIndicator:[null,r.STRING],imagePreviewCalculateAverageImageColor:[!1,r.BOOLEAN],imagePreviewMarkupShow:[!0,r.BOOLEAN],imagePreviewMarkupFilter:[()=>!0,r.FUNCTION]}}};"undefined"!=typeof window&&void 0!==window.document&&document.dispatchEvent(new CustomEvent("FilePond:pluginloaded",{detail:b}));export default b; |
/*! | ||
* FilePondPluginImagePreview 4.6.7 | ||
* FilePondPluginImagePreview 4.6.8 | ||
* Licensed under MIT, https://opensource.org/licenses/MIT/ | ||
@@ -9,2 +9,2 @@ * Please visit https://pqina.nl/filepond/ for details. | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).FilePondPluginImagePreview=t()}(this,function(){"use strict";function e(e){this.wrapped=e}function t(t){var i,r;function a(i,r){try{var o=t[i](r),c=o.value,s=c instanceof e;Promise.resolve(s?c.wrapped:c).then(function(e){s?a("next",e):n(o.done?"return":"normal",e)},function(e){a("throw",e)})}catch(e){n("throw",e)}}function n(e,t){switch(e){case"return":i.resolve({value:t,done:!0});break;case"throw":i.reject(t);break;default:i.resolve({value:t,done:!1})}(i=i.next)?a(i.key,i.arg):r=null}this._invoke=function(e,t){return new Promise(function(n,o){var c={key:e,arg:t,resolve:n,reject:o,next:null};r?r=r.next=c:(i=r=c,a(e,t))})},"function"!=typeof t.return&&(this.return=void 0)}"function"==typeof Symbol&&Symbol.asyncIterator&&(t.prototype[Symbol.asyncIterator]=function(){return this}),t.prototype.next=function(e){return this._invoke("next",e)},t.prototype.throw=function(e){return this._invoke("throw",e)},t.prototype.return=function(e){return this._invoke("return",e)};function i(e,t){return r(e)||function(e,t){var i=[],r=!0,a=!1,n=void 0;try{for(var o,c=e[Symbol.iterator]();!(r=(o=c.next()).done)&&(i.push(o.value),!t||i.length!==t);r=!0);}catch(e){a=!0,n=e}finally{try{r||null==c.return||c.return()}finally{if(a)throw n}}return i}(e,t)||a()}function r(e){if(Array.isArray(e))return e}function a(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}var n=function(e,t){return s(e.x*t,e.y*t)},o=function(e,t){return s(e.x+t.x,e.y+t.y)},c=function(e,t,i){var r=Math.cos(t),a=Math.sin(t),n=s(e.x-i.x,e.y-i.y);return s(i.x+r*n.x-a*n.y,i.y+a*n.x+r*n.y)},s=function(){return{x:arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,y:arguments.length>1&&void 0!==arguments[1]?arguments[1]:0}},h=function(e,t){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,r=arguments.length>3?arguments[3]:void 0;return"string"==typeof e?parseFloat(e)*i:"number"==typeof e?e*(r?t[r]:Math.min(t.width,t.height)):void 0},u=function(e){return null!=e},l=function(e,t){return Object.keys(t).forEach(function(i){return e.setAttribute(i,t[i])})},d=function(e,t){var i=document.createElementNS("http://www.w3.org/2000/svg",e);return t&&l(i,t),i},f={contain:"xMidYMid meet",cover:"xMidYMid slice"},g={left:"start",center:"middle",right:"end"},p=function(e){return function(t){return d(e,{id:t.id})}},m={image:function(e){var t=d("image",{id:e.id,"stroke-linecap":"round","stroke-linejoin":"round",opacity:"0"});return t.onload=function(){t.setAttribute("opacity",e.opacity||1)},t.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",e.src),t},rect:p("rect"),ellipse:p("ellipse"),text:p("text"),path:p("path"),line:function(e){var t=d("g",{id:e.id,"stroke-linecap":"round","stroke-linejoin":"round"}),i=d("line");t.appendChild(i);var r=d("path");t.appendChild(r);var a=d("path");return t.appendChild(a),t}},y={rect:function(e){return l(e,Object.assign({},e.rect,e.styles))},ellipse:function(e){var t=e.rect.x+.5*e.rect.width,i=e.rect.y+.5*e.rect.height,r=.5*e.rect.width,a=.5*e.rect.height;return l(e,Object.assign({cx:t,cy:i,rx:r,ry:a},e.styles))},image:function(e,t){l(e,Object.assign({},e.rect,e.styles,{preserveAspectRatio:f[t.fit]||"none"}))},text:function(e,t,i,r){var a=h(t.fontSize,i,r),n=t.fontFamily||"sans-serif",o=t.fontWeight||"normal",c=g[t.textAlign]||"start";l(e,Object.assign({},e.rect,e.styles,{"stroke-width":0,"font-weight":o,"font-size":a,"font-family":n,"text-anchor":c})),e.text!==t.text&&(e.text=t.text,e.textContent=t.text.length?t.text:" ")},path:function(e,t,i,r){var a;l(e,Object.assign({},e.styles,{fill:"none",d:(a=t.points.map(function(e){return{x:h(e.x,i,r,"width"),y:h(e.y,i,r,"height")}}),a.map(function(e,t){return"".concat(0===t?"M":"L"," ").concat(e.x," ").concat(e.y)}).join(" "))}))},line:function(e,t,i,r){l(e,Object.assign({},e.rect,e.styles,{fill:"none"}));var a=e.childNodes[0],u=e.childNodes[1],d=e.childNodes[2],f=e.rect,g={x:e.rect.x+e.rect.width,y:e.rect.y+e.rect.height};if(l(a,{x1:f.x,y1:f.y,x2:g.x,y2:g.y}),t.lineDecoration){u.style.display="none",d.style.display="none";var p=function(e){var t=Math.sqrt(e.x*e.x+e.y*e.y);return 0===t?{x:0,y:0}:s(e.x/t,e.y/t)}({x:g.x-f.x,y:g.y-f.y}),m=h(.05,i,r);if(-1!==t.lineDecoration.indexOf("arrow-begin")){var y=n(p,m),E=o(f,y),v=c(f,2,E),w=c(f,-2,E);l(u,{style:"display:block;",d:"M".concat(v.x,",").concat(v.y," L").concat(f.x,",").concat(f.y," L").concat(w.x,",").concat(w.y)})}if(-1!==t.lineDecoration.indexOf("arrow-end")){var _=n(p,-m),I=o(g,_),M=c(g,2,I),x=c(g,-2,I);l(d,{style:"display:block;",d:"M".concat(M.x,",").concat(M.y," L").concat(g.x,",").concat(g.y," L").concat(x.x,",").concat(x.y)})}}}},E=function(e,t,i,r,a){"path"!==t&&(e.rect=function(e,t){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,r=h(e.x,t,i,"width")||h(e.left,t,i,"width"),a=h(e.y,t,i,"height")||h(e.top,t,i,"height"),n=h(e.width,t,i,"width"),o=h(e.height,t,i,"height"),c=h(e.right,t,i,"width"),s=h(e.bottom,t,i,"height");return u(a)||(a=u(o)&&u(s)?t.height-o-s:s),u(r)||(r=u(n)&&u(c)?t.width-n-c:c),u(n)||(n=u(r)&&u(c)?t.width-r-c:0),u(o)||(o=u(a)&&u(s)?t.height-a-s:0),{x:r||0,y:a||0,width:n||0,height:o||0}}(i,r,a)),e.styles=function(e,t,i){var r=e.borderStyle||e.lineStyle||"solid",a=e.backgroundColor||e.fontColor||"transparent",n=e.borderColor||e.lineColor||"transparent",o=h(e.borderWidth||e.lineWidth,t,i);return{"stroke-linecap":e.lineCap||"round","stroke-linejoin":e.lineJoin||"round","stroke-width":o||0,"stroke-dasharray":"string"==typeof r?"":r.map(function(e){return h(e,t,i)}).join(","),stroke:n,fill:a,opacity:e.opacity||1}}(i,r,a),y[t](e,i,r,a)},v=["x","y","left","top","right","bottom","width","height"],w=function(e){var t=i(e,2),r=t[0],a=t[1],n=a.points?{}:v.reduce(function(e,t){var i;return e[t]="string"==typeof(i=a[t])&&/%/.test(i)?parseFloat(i)/100:i,e},{});return[r,Object.assign({zIndex:0},a,n)]},_=function(e,t){return e[1].zIndex>t[1].zIndex?1:e[1].zIndex<t[1].zIndex?-1:0},I=function(e){return e.utils.createView({name:"image-preview-markup",tag:"svg",ignoreRect:!0,mixins:{apis:["width","height","crop","markup","resize","dirty"]},write:function(e){var t=e.root,r=e.props;if(r.dirty){var a=r.crop,n=r.resize,o=r.markup,c=r.width,s=r.height,h=a.width,u=a.height;if(n){var l=n.size,d=l&&l.width,f=l&&l.height,g=n.mode,p=n.upscale;d&&!f&&(f=d),f&&!d&&(d=f);var y=h<d&&u<f;if(!y||y&&p){var v,I=d/h,M=f/u;if("force"===g)h=d,u=f;else"cover"===g?v=Math.max(I,M):"contain"===g&&(v=Math.min(I,M)),h*=v,u*=v}}var x={width:c,height:s};t.element.setAttribute("width",x.width),t.element.setAttribute("height",x.height);var T=Math.min(c/h,s/u);t.element.innerHTML="";var A=t.query("GET_IMAGE_PREVIEW_MARKUP_FILTER");o.filter(A).map(w).sort(_).forEach(function(e){var r=i(e,2),a=r[0],n=r[1],o=function(e,t){return m[e](t)}(a,n);E(o,a,n,x,T),t.element.appendChild(o)})}}})},M=function(e,t){return{x:e,y:t}},x=function(e,t){return M(e.x-t.x,e.y-t.y)},T=function(e,t){return Math.sqrt(function(e,t){return function(e,t){return e.x*t.x+e.y*t.y}(x(e,t),x(e,t))}(e,t))},A=function(e,t){var i=e,r=t,a=1.5707963267948966-t,n=Math.sin(1.5707963267948966),o=Math.sin(r),c=Math.sin(a),s=Math.cos(a),h=i/n;return M(s*(h*o),s*(h*c))},R=function(e,t,i,r){var a=r.x>.5?1-r.x:r.x,n=r.y>.5?1-r.y:r.y,o=2*a*e.width,c=2*n*e.height,s=function(e,t){var i=e.width,r=e.height,a=A(i,t),n=A(r,t),o=M(e.x+Math.abs(a.x),e.y-Math.abs(a.y)),c=M(e.x+e.width+Math.abs(n.y),e.y+Math.abs(n.x)),s=M(e.x-Math.abs(n.y),e.y+e.height-Math.abs(n.x));return{width:T(o,c),height:T(o,s)}}(t,i);return Math.max(s.width/o,s.height/c)},P=function(e,t){var i=e.width,r=i*t;return r>e.height&&(i=(r=e.height)/t),{x:.5*(e.width-i),y:.5*(e.height-r),width:i,height:r}},C=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=t.zoom,r=t.rotation,a=t.center,n=t.aspectRatio;n||(n=e.height/e.width);var o=function(e,t){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,r=e.height/e.width,a=t,n=1,o=r;o>a&&(n=(o=a)/r);var c=Math.max(1/n,a/o),s=e.width/(i*c*n);return{width:s,height:s*t}}(e,n,i),c={x:.5*o.width,y:.5*o.height},s={x:0,y:0,width:o.width,height:o.height,center:c},h=void 0===t.scaleToFit||t.scaleToFit,u=i*R(e,P(s,n),r,h?a:{x:.5,y:.5});return{widthFloat:o.width/u,heightFloat:o.height/u,width:Math.round(o.width/u),height:Math.round(o.height/u)}},k={type:"spring",stiffness:.5,damping:.45,mass:10},D=function(e){return e.utils.createView({name:"image-clip",tag:"div",ignoreRect:!0,mixins:{apis:["crop","markup","resize","width","height","dirty","background"],styles:["width","height","opacity"],animations:{opacity:{type:"tween",duration:250}}},didWriteView:function(e){var t=e.root,i=e.props;i.background&&(t.element.style.backgroundColor=i.background)},create:function(t){var i=t.root,r=t.props;i.ref.image=i.appendChildView(i.createChildView(function(e){return e.utils.createView({name:"image-canvas-wrapper",tag:"div",ignoreRect:!0,mixins:{apis:["crop","width","height"],styles:["originX","originY","translateX","translateY","scaleX","scaleY","rotateZ"],animations:{originX:k,originY:k,scaleX:k,scaleY:k,translateX:k,translateY:k,rotateZ:k}},create:function(t){var i=t.root,r=t.props;r.width=r.image.width,r.height=r.image.height,i.ref.bitmap=i.appendChildView(i.createChildView(function(e){return e.utils.createView({name:"image-bitmap",ignoreRect:!0,mixins:{styles:["scaleX","scaleY"]},create:function(e){var t=e.root,i=e.props;t.appendChild(i.image)}})}(e),{image:r.image}))},write:function(e){var t=e.root,i=e.props.crop.flip,r=t.ref.bitmap;r.scaleX=i.horizontal?-1:1,r.scaleY=i.vertical?-1:1}})}(e),Object.assign({},r))),i.ref.createMarkup=function(){i.ref.markup||(i.ref.markup=i.appendChildView(i.createChildView(I(e),Object.assign({},r))))},i.ref.destroyMarkup=function(){i.ref.markup&&(i.removeChildView(i.ref.markup),i.ref.markup=null)};var a=i.query("GET_IMAGE_PREVIEW_TRANSPARENCY_INDICATOR");null!==a&&(i.element.dataset.transparencyIndicator="grid"===a?a:"color")},write:function(e){var t=e.root,i=e.props,r=e.shouldOptimize,a=i.crop,n=i.markup,o=i.resize,c=i.dirty,s=i.width,h=i.height;t.ref.image.crop=a;var u={x:0,y:0,width:s,height:h,center:{x:.5*s,y:.5*h}},l={width:t.ref.image.width,height:t.ref.image.height},d={x:a.center.x*l.width,y:a.center.y*l.height},f={x:u.center.x-l.width*a.center.x,y:u.center.y-l.height*a.center.y},g=2*Math.PI+a.rotation%(2*Math.PI),p=a.aspectRatio||l.height/l.width,m=void 0===a.scaleToFit||a.scaleToFit,y=R(l,P(u,p),g,m?a.center:{x:.5,y:.5}),E=a.zoom*y;n&&n.length?(t.ref.createMarkup(),t.ref.markup.width=s,t.ref.markup.height=h,t.ref.markup.resize=o,t.ref.markup.dirty=c,t.ref.markup.markup=n,t.ref.markup.crop=C(l,a)):t.ref.markup&&t.ref.destroyMarkup();var v=t.ref.image;if(r)return v.originX=null,v.originY=null,v.translateX=null,v.translateY=null,v.rotateZ=null,v.scaleX=null,void(v.scaleY=null);v.originX=d.x,v.originY=d.y,v.translateX=f.x,v.translateY=f.y,v.rotateZ=g,v.scaleX=E,v.scaleY=E}})},G='<svg width="500" height="200" viewBox="0 0 500 200" preserveAspectRatio="none">\n <defs>\n <radialGradient id="gradient-__UID__" cx=".5" cy="1.25" r="1.15">\n <stop offset=\'50%\' stop-color=\'#000000\'/>\n <stop offset=\'56%\' stop-color=\'#0a0a0a\'/>\n <stop offset=\'63%\' stop-color=\'#262626\'/>\n <stop offset=\'69%\' stop-color=\'#4f4f4f\'/>\n <stop offset=\'75%\' stop-color=\'#808080\'/>\n <stop offset=\'81%\' stop-color=\'#b1b1b1\'/>\n <stop offset=\'88%\' stop-color=\'#dadada\'/>\n <stop offset=\'94%\' stop-color=\'#f6f6f6\'/>\n <stop offset=\'100%\' stop-color=\'#ffffff\'/>\n </radialGradient>\n <mask id="mask-__UID__">\n <rect x="0" y="0" width="500" height="200" fill="url(#gradient-__UID__)"></rect>\n </mask>\n </defs>\n <rect x="0" width="500" height="200" fill="currentColor" mask="url(#mask-__UID__)"></rect>\n</svg>',V=0,O=function(){self.onmessage=function(e){createImageBitmap(e.data.message.file).then(function(t){self.postMessage({id:e.data.id,message:t},[t])})}},b=function(){self.onmessage=function(e){for(var t=e.data.message.imageData,i=e.data.message.colorMatrix,r=t.data,a=r.length,n=i[0],o=i[1],c=i[2],s=i[3],h=i[4],u=i[5],l=i[6],d=i[7],f=i[8],g=i[9],p=i[10],m=i[11],y=i[12],E=i[13],v=i[14],w=i[15],_=i[16],I=i[17],M=i[18],x=i[19],T=0,A=0,R=0,P=0,C=0;T<a;T+=4)A=r[T]/255,R=r[T+1]/255,P=r[T+2]/255,C=r[T+3]/255,r[T]=Math.max(0,Math.min(255*(A*n+R*o+P*c+C*s+h),255)),r[T+1]=Math.max(0,Math.min(255*(A*u+R*l+P*d+C*f+g),255)),r[T+2]=Math.max(0,Math.min(255*(A*p+R*m+P*y+C*E+v),255)),r[T+3]=Math.max(0,Math.min(255*(A*w+R*_+P*I+C*M+x),255));self.postMessage({id:e.data.id,message:t},[t.data.buffer])}},S={1:function(){return[1,0,0,1,0,0]},2:function(e){return[-1,0,0,1,e,0]},3:function(e,t){return[-1,0,0,-1,e,t]},4:function(e,t){return[1,0,0,-1,0,t]},5:function(){return[0,1,1,0,0,0]},6:function(e,t){return[0,1,-1,0,t,0]},7:function(e,t){return[0,-1,-1,0,t,e]},8:function(e){return[0,-1,1,0,0,e]}},L=function(e,t,i,r){t=Math.round(t),i=Math.round(i);var a=document.createElement("canvas");a.width=t,a.height=i;var n=a.getContext("2d");if(r>=5&&r<=8){var o=[i,t];t=o[0],i=o[1]}return function(e,t,i,r){-1!==r&&e.transform.apply(e,S[r](t,i))}(n,t,i,r),n.drawImage(e,0,0,t,i),a},N=function(e){return/^image/.test(e.type)&&!/svg/.test(e.type)},W=function(e){var t=Math.min(10/e.width,10/e.height),i=document.createElement("canvas"),r=i.getContext("2d"),a=i.width=Math.ceil(e.width*t),n=i.height=Math.ceil(e.height*t);r.drawImage(e,0,0,a,n);var o=null;try{o=r.getImageData(0,0,a,n).data}catch(e){return null}for(var c=o.length,s=0,h=0,u=0,l=0;l<c;l+=4)s+=o[l]*o[l],h+=o[l+1]*o[l+1],u+=o[l+2]*o[l+2];return{r:s=z(s,c),g:h=z(h,c),b:u=z(u,c)}},z=function(e,t){return Math.floor(Math.sqrt(e/(t/4)))},H=function(e){var t=e.utils.createView({name:"image-preview-overlay",tag:"div",ignoreRect:!0,create:function(e){var t=e.root,i=e.props;if(document.querySelector("base")){var r=window.location.href.replace(window.location.hash,"");G=G.replace(/url\(\#/g,"url("+r+"#")}V++,t.element.classList.add("filepond--image-preview-overlay-".concat(i.status)),t.element.innerHTML=G.replace(/__UID__/g,V)},mixins:{styles:["opacity"],animations:{opacity:{type:"spring",mass:25}}}}),i=function(e){return e.utils.createView({name:"image-preview",tag:"div",ignoreRect:!0,mixins:{apis:["image","crop","markup","resize","dirty","background"],styles:["translateY","scaleX","scaleY","opacity"],animations:{scaleX:k,scaleY:k,translateY:k,opacity:{type:"tween",duration:400}}},create:function(t){var i=t.root,r=t.props;i.ref.clip=i.appendChildView(i.createChildView(D(e),{id:r.id,image:r.image,crop:r.crop,markup:r.markup,resize:r.resize,dirty:r.dirty,background:r.background}))},write:function(e){var t=e.root,i=e.props,r=e.shouldOptimize,a=t.ref.clip,n=i.image,o=i.crop,c=i.markup,s=i.resize,h=i.dirty;if(a.crop=o,a.markup=c,a.resize=s,a.dirty=h,a.opacity=r?0:1,!r&&!t.rect.element.hidden){var u=n.height/n.width,l=o.aspectRatio||u,d=t.rect.inner.width,f=t.rect.inner.height,g=t.query("GET_IMAGE_PREVIEW_HEIGHT"),p=t.query("GET_IMAGE_PREVIEW_MIN_HEIGHT"),m=t.query("GET_IMAGE_PREVIEW_MAX_HEIGHT"),y=t.query("GET_PANEL_ASPECT_RATIO"),E=t.query("GET_ALLOW_MULTIPLE");y&&!E&&(g=d*y,l=y);var v=null!==g?g:Math.max(p,Math.min(d*l,m)),w=v/l;w>d&&(v=(w=d)*l),v>f&&(v=f,w=f/l),a.width=w,a.height=v}}})}(e),r=e.utils.createWorker,a=function(e,t,i){return new Promise(function(a){e.ref.imageData||(e.ref.imageData=i.getContext("2d").getImageData(0,0,i.width,i.height));var n=function(e){var t;try{t=new ImageData(e.width,e.height)}catch(i){t=document.createElement("canvas").getContext("2d").createImageData(e.width,e.height)}return t.data.set(new Uint8ClampedArray(e.data)),t}(e.ref.imageData);if(!t||20!==t.length)return i.getContext("2d").putImageData(n,0,0),a();var o=r(b);o.post({imageData:n,colorMatrix:t},function(e){i.getContext("2d").putImageData(e,0,0),o.terminate(),a()},[n.data.buffer])})},n=function(e){var t=e.root,r=e.props,a=e.image,n=r.id,o=t.query("GET_ITEM",{id:n});if(o){var c,s,h=o.getMetadata("crop")||{center:{x:.5,y:.5},flip:{horizontal:!1,vertical:!1},zoom:1,rotation:0,aspectRatio:null},u=t.query("GET_IMAGE_TRANSFORM_CANVAS_BACKGROUND_COLOR"),l=!1;t.query("GET_IMAGE_PREVIEW_MARKUP_SHOW")&&(c=o.getMetadata("markup")||[],s=o.getMetadata("resize"),l=!0);var d=t.appendChildView(t.createChildView(i,{id:n,image:a,crop:h,resize:s,markup:c,dirty:l,background:u,opacity:0,scaleX:1.15,scaleY:1.15,translateY:15}),t.childViews.length);t.ref.images.push(d),d.opacity=1,d.scaleX=1,d.scaleY=1,d.translateY=0,setTimeout(function(){t.dispatch("DID_IMAGE_PREVIEW_SHOW",{id:n})},250)}},o=function(e){var t=e.root;t.ref.overlayShadow.opacity=1,t.ref.overlayError.opacity=0,t.ref.overlaySuccess.opacity=0},c=function(e){var t=e.root;t.ref.overlayShadow.opacity=.25,t.ref.overlayError.opacity=1};return e.utils.createView({name:"image-preview-wrapper",create:function(e){var i=e.root;i.ref.images=[],i.ref.imageData=null,i.ref.imageViewBin=[],i.ref.overlayShadow=i.appendChildView(i.createChildView(t,{opacity:0,status:"idle"})),i.ref.overlaySuccess=i.appendChildView(i.createChildView(t,{opacity:0,status:"success"})),i.ref.overlayError=i.appendChildView(i.createChildView(t,{opacity:0,status:"failure"}))},styles:["height"],apis:["height"],destroy:function(e){e.root.ref.images.forEach(function(e){e.image.width=1,e.image.height=1})},didWriteView:function(e){e.root.ref.images.forEach(function(e){e.dirty=!1})},write:e.utils.createRoute({DID_IMAGE_PREVIEW_DRAW:function(e){var t=e.root,i=t.ref.images[t.ref.images.length-1];i.translateY=0,i.scaleX=1,i.scaleY=1,i.opacity=1},DID_IMAGE_PREVIEW_CONTAINER_CREATE:function(e){var t=e.root,i=e.props.id,r=t.query("GET_ITEM",i);if(r){var a,n,o,c=URL.createObjectURL(r.file);a=c,n=function(e,r){t.dispatch("DID_IMAGE_PREVIEW_CALCULATE_SIZE",{id:i,width:e,height:r})},(o=new Image).onload=function(){var e=o.naturalWidth,t=o.naturalHeight;o=null,n(e,t)},o.src=a}},DID_FINISH_CALCULATE_PREVIEWSIZE:function(e){var t=e.root,i=e.props,o=i.id,c=t.query("GET_ITEM",o);if(c){var s,h,u=URL.createObjectURL(c.file),l=function(){var e;(e=u,new Promise(function(t,i){var r=new Image;r.crossOrigin="Anonymous",r.onload=function(){t(r)},r.onerror=function(e){i(e)},r.src=e})).then(d)},d=function(e){URL.revokeObjectURL(u);var r=(c.getMetadata("exif")||{}).orientation||-1,o=e.width,s=e.height;if(o&&s){if(r>=5&&r<=8){var h=[s,o];o=h[0],s=h[1]}var l=Math.max(1,.75*window.devicePixelRatio),d=t.query("GET_IMAGE_PREVIEW_ZOOM_FACTOR")*l,f=s/o,g=t.rect.element.width,p=t.rect.element.height,m=g,y=m*f;f>1?y=(m=Math.min(o,g*d))*f:m=(y=Math.min(s,p*d))/f;var E=L(e,m,y,r),v=function(){var r=t.query("GET_IMAGE_PREVIEW_CALCULATE_AVERAGE_IMAGE_COLOR")?W(data):null;c.setMetadata("color",r,!0),"close"in e&&e.close(),t.ref.overlayShadow.opacity=1,n({root:t,props:i,image:E})},w=c.getMetadata("filter");w?a(t,w,E).then(v):v()}};if(s=c.file,!(((h=window.navigator.userAgent.match(/Firefox\/([0-9]+)\./))?parseInt(h[1]):null)<=58)&&"createImageBitmap"in window&&N(s)){var f=r(O);f.post({file:c.file},function(e){f.terminate(),e?d(e):l()})}else l()}},DID_UPDATE_ITEM_METADATA:function(e){var t=e.root,i=e.props,r=e.action;if(/crop|filter|markup|resize/.test(r.change.key)&&t.ref.images.length){var o=t.query("GET_ITEM",{id:i.id});if(o)if(/filter/.test(r.change.key)){var c=t.ref.images[t.ref.images.length-1];a(t,r.change.value,c.image)}else{if(/crop|markup|resize/.test(r.change.key)){var s=o.getMetadata("crop"),h=t.ref.images[t.ref.images.length-1];if(Math.abs(s.aspectRatio-h.crop.aspectRatio)>1e-5){var u=function(e){var t=e.root,i=t.ref.images.shift();return i.opacity=0,i.translateY=-15,t.ref.imageViewBin.push(i),i}({root:t});n({root:t,props:i,image:(l=u.image,(d=d||document.createElement("canvas")).width=l.width,d.height=l.height,d.getContext("2d").drawImage(l,0,0),d)})}else!function(e){var t=e.root,i=e.props,r=t.query("GET_ITEM",{id:i.id});if(r){var a=t.ref.images[t.ref.images.length-1];a.crop=r.getMetadata("crop"),a.background=t.query("GET_IMAGE_TRANSFORM_CANVAS_BACKGROUND_COLOR"),t.query("GET_IMAGE_PREVIEW_MARKUP_SHOW")&&(a.dirty=!0,a.resize=r.getMetadata("resize"),a.markup=r.getMetadata("markup"))}}({root:t,props:i})}var l,d}}},DID_THROW_ITEM_LOAD_ERROR:c,DID_THROW_ITEM_PROCESSING_ERROR:c,DID_THROW_ITEM_INVALID:c,DID_COMPLETE_ITEM_PROCESSING:function(e){var t=e.root;t.ref.overlayShadow.opacity=.25,t.ref.overlaySuccess.opacity=1},DID_START_ITEM_PROCESSING:o,DID_REVERT_ITEM_PROCESSING:o},function(e){var t=e.root,i=t.ref.imageViewBin.filter(function(e){return 0===e.opacity});t.ref.imageViewBin=t.ref.imageViewBin.filter(function(e){return e.opacity>0}),i.forEach(function(e){return function(e,t){e.removeChildView(t),t.image.width=1,t.image.height=1,t._destroy()}(t,e)}),i.length=0})})},q=function(e){var t=e.addFilter,i=e.utils,r=i.Type,a=i.createRoute,n=i.isFile,o=H(e);return t("CREATE_VIEW",function(e){var t=e.is,i=e.view,r=e.query;if(t("file")&&r("GET_ALLOW_IMAGE_PREVIEW")){var c=function(e){e.root.ref.shouldRescale=!0};i.registerWriter(a({DID_RESIZE_ROOT:c,DID_STOP_RESIZE:c,DID_LOAD_ITEM:function(e){var t=e.root,a=e.props.id,c=r("GET_ITEM",a);if(c&&n(c.file)&&!c.archived){var s=c.file;if(function(e){return/^image/.test(e.type)}(s)&&r("GET_IMAGE_PREVIEW_FILTER_ITEM")(c)){var h="createImageBitmap"in(window||{}),u=r("GET_IMAGE_PREVIEW_MAX_FILE_SIZE");if(!(!h&&u&&s.size>u)){t.ref.imagePreview=i.appendChildView(i.createChildView(o,{id:a}));var l=t.query("GET_IMAGE_PREVIEW_HEIGHT");l&&t.dispatch("DID_UPDATE_PANEL_HEIGHT",{id:c.id,height:l});var d=!h&&s.size>r("GET_IMAGE_PREVIEW_MAX_INSTANT_PREVIEW_FILE_SIZE");t.dispatch("DID_IMAGE_PREVIEW_CONTAINER_CREATE",{id:a},d)}}}},DID_IMAGE_PREVIEW_CALCULATE_SIZE:function(e){var t=e.root,i=e.action;t.ref.imageWidth=i.width,t.ref.imageHeight=i.height,t.ref.shouldRescale=!0,t.ref.shouldDrawPreview=!0,t.dispatch("KICK")},DID_UPDATE_ITEM_METADATA:function(e){var t=e.root;"crop"===e.action.change.key&&(t.ref.shouldRescale=!0)}},function(e){var t=e.root,i=e.props;t.ref.imagePreview&&(t.rect.element.hidden||(t.ref.shouldRescale&&(!function(e,t){if(e.ref.imagePreview){var i=t.id,r=e.query("GET_ITEM",{id:i});if(r){var a=e.query("GET_PANEL_ASPECT_RATIO"),n=e.query("GET_ITEM_PANEL_ASPECT_RATIO"),o=e.query("GET_IMAGE_PREVIEW_HEIGHT");if(!(a||n||o)){var c=e.ref,s=c.imageWidth,h=c.imageHeight;if(s&&h){var u=e.query("GET_IMAGE_PREVIEW_MIN_HEIGHT"),l=e.query("GET_IMAGE_PREVIEW_MAX_HEIGHT"),d=(r.getMetadata("exif")||{}).orientation||-1;if(d>=5&&d<=8){var f=[h,s];s=f[0],h=f[1]}if(!N(r.file)||e.query("GET_IMAGE_PREVIEW_UPSCALE")){var g=2048/s;s*=g,h*=g}var p=h/s,m=(r.getMetadata("crop")||{}).aspectRatio||p,y=Math.max(u,Math.min(h,l)),E=e.rect.element.width,v=Math.min(E*m,y);e.dispatch("DID_UPDATE_PANEL_HEIGHT",{id:r.id,height:v})}}}}}(t,i),t.ref.shouldRescale=!1),t.ref.shouldDrawPreview&&(requestAnimationFrame(function(){t.dispatch("DID_FINISH_CALCULATE_PREVIEWSIZE",{id:i.id})}),t.ref.shouldDrawPreview=!1)))}))}}),{options:{allowImagePreview:[!0,r.BOOLEAN],imagePreviewFilterItem:[function(){return!0},r.FUNCTION],imagePreviewHeight:[null,r.INT],imagePreviewMinHeight:[44,r.INT],imagePreviewMaxHeight:[256,r.INT],imagePreviewMaxFileSize:[null,r.INT],imagePreviewZoomFactor:[2,r.INT],imagePreviewUpscale:[!1,r.BOOLEAN],imagePreviewMaxInstantPreviewFileSize:[1e6,r.INT],imagePreviewTransparencyIndicator:[null,r.STRING],imagePreviewCalculateAverageImageColor:[!1,r.BOOLEAN],imagePreviewMarkupShow:[!0,r.BOOLEAN],imagePreviewMarkupFilter:[function(){return!0},r.FUNCTION]}}};return"undefined"!=typeof window&&void 0!==window.document&&document.dispatchEvent(new CustomEvent("FilePond:pluginloaded",{detail:q})),q}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).FilePondPluginImagePreview=t()}(this,function(){"use strict";function e(e){this.wrapped=e}function t(t){var i,r;function a(i,r){try{var o=t[i](r),c=o.value,s=c instanceof e;Promise.resolve(s?c.wrapped:c).then(function(e){s?a("next",e):n(o.done?"return":"normal",e)},function(e){a("throw",e)})}catch(e){n("throw",e)}}function n(e,t){switch(e){case"return":i.resolve({value:t,done:!0});break;case"throw":i.reject(t);break;default:i.resolve({value:t,done:!1})}(i=i.next)?a(i.key,i.arg):r=null}this._invoke=function(e,t){return new Promise(function(n,o){var c={key:e,arg:t,resolve:n,reject:o,next:null};r?r=r.next=c:(i=r=c,a(e,t))})},"function"!=typeof t.return&&(this.return=void 0)}"function"==typeof Symbol&&Symbol.asyncIterator&&(t.prototype[Symbol.asyncIterator]=function(){return this}),t.prototype.next=function(e){return this._invoke("next",e)},t.prototype.throw=function(e){return this._invoke("throw",e)},t.prototype.return=function(e){return this._invoke("return",e)};function i(e,t){return r(e)||function(e,t){var i=[],r=!0,a=!1,n=void 0;try{for(var o,c=e[Symbol.iterator]();!(r=(o=c.next()).done)&&(i.push(o.value),!t||i.length!==t);r=!0);}catch(e){a=!0,n=e}finally{try{r||null==c.return||c.return()}finally{if(a)throw n}}return i}(e,t)||a()}function r(e){if(Array.isArray(e))return e}function a(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}var n=function(e,t){return s(e.x*t,e.y*t)},o=function(e,t){return s(e.x+t.x,e.y+t.y)},c=function(e,t,i){var r=Math.cos(t),a=Math.sin(t),n=s(e.x-i.x,e.y-i.y);return s(i.x+r*n.x-a*n.y,i.y+a*n.x+r*n.y)},s=function(){return{x:arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,y:arguments.length>1&&void 0!==arguments[1]?arguments[1]:0}},h=function(e,t){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,r=arguments.length>3?arguments[3]:void 0;return"string"==typeof e?parseFloat(e)*i:"number"==typeof e?e*(r?t[r]:Math.min(t.width,t.height)):void 0},u=function(e){return null!=e},l=function(e,t){return Object.keys(t).forEach(function(i){return e.setAttribute(i,t[i])})},d=function(e,t){var i=document.createElementNS("http://www.w3.org/2000/svg",e);return t&&l(i,t),i},f={contain:"xMidYMid meet",cover:"xMidYMid slice"},g={left:"start",center:"middle",right:"end"},p=function(e){return function(t){return d(e,{id:t.id})}},m={image:function(e){var t=d("image",{id:e.id,"stroke-linecap":"round","stroke-linejoin":"round",opacity:"0"});return t.onload=function(){t.setAttribute("opacity",e.opacity||1)},t.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",e.src),t},rect:p("rect"),ellipse:p("ellipse"),text:p("text"),path:p("path"),line:function(e){var t=d("g",{id:e.id,"stroke-linecap":"round","stroke-linejoin":"round"}),i=d("line");t.appendChild(i);var r=d("path");t.appendChild(r);var a=d("path");return t.appendChild(a),t}},y={rect:function(e){return l(e,Object.assign({},e.rect,e.styles))},ellipse:function(e){var t=e.rect.x+.5*e.rect.width,i=e.rect.y+.5*e.rect.height,r=.5*e.rect.width,a=.5*e.rect.height;return l(e,Object.assign({cx:t,cy:i,rx:r,ry:a},e.styles))},image:function(e,t){l(e,Object.assign({},e.rect,e.styles,{preserveAspectRatio:f[t.fit]||"none"}))},text:function(e,t,i,r){var a=h(t.fontSize,i,r),n=t.fontFamily||"sans-serif",o=t.fontWeight||"normal",c=g[t.textAlign]||"start";l(e,Object.assign({},e.rect,e.styles,{"stroke-width":0,"font-weight":o,"font-size":a,"font-family":n,"text-anchor":c})),e.text!==t.text&&(e.text=t.text,e.textContent=t.text.length?t.text:" ")},path:function(e,t,i,r){var a;l(e,Object.assign({},e.styles,{fill:"none",d:(a=t.points.map(function(e){return{x:h(e.x,i,r,"width"),y:h(e.y,i,r,"height")}}),a.map(function(e,t){return"".concat(0===t?"M":"L"," ").concat(e.x," ").concat(e.y)}).join(" "))}))},line:function(e,t,i,r){l(e,Object.assign({},e.rect,e.styles,{fill:"none"}));var a=e.childNodes[0],u=e.childNodes[1],d=e.childNodes[2],f=e.rect,g={x:e.rect.x+e.rect.width,y:e.rect.y+e.rect.height};if(l(a,{x1:f.x,y1:f.y,x2:g.x,y2:g.y}),t.lineDecoration){u.style.display="none",d.style.display="none";var p=function(e){var t=Math.sqrt(e.x*e.x+e.y*e.y);return 0===t?{x:0,y:0}:s(e.x/t,e.y/t)}({x:g.x-f.x,y:g.y-f.y}),m=h(.05,i,r);if(-1!==t.lineDecoration.indexOf("arrow-begin")){var y=n(p,m),E=o(f,y),v=c(f,2,E),w=c(f,-2,E);l(u,{style:"display:block;",d:"M".concat(v.x,",").concat(v.y," L").concat(f.x,",").concat(f.y," L").concat(w.x,",").concat(w.y)})}if(-1!==t.lineDecoration.indexOf("arrow-end")){var _=n(p,-m),I=o(g,_),M=c(g,2,I),x=c(g,-2,I);l(d,{style:"display:block;",d:"M".concat(M.x,",").concat(M.y," L").concat(g.x,",").concat(g.y," L").concat(x.x,",").concat(x.y)})}}}},E=function(e,t,i,r,a){"path"!==t&&(e.rect=function(e,t){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,r=h(e.x,t,i,"width")||h(e.left,t,i,"width"),a=h(e.y,t,i,"height")||h(e.top,t,i,"height"),n=h(e.width,t,i,"width"),o=h(e.height,t,i,"height"),c=h(e.right,t,i,"width"),s=h(e.bottom,t,i,"height");return u(a)||(a=u(o)&&u(s)?t.height-o-s:s),u(r)||(r=u(n)&&u(c)?t.width-n-c:c),u(n)||(n=u(r)&&u(c)?t.width-r-c:0),u(o)||(o=u(a)&&u(s)?t.height-a-s:0),{x:r||0,y:a||0,width:n||0,height:o||0}}(i,r,a)),e.styles=function(e,t,i){var r=e.borderStyle||e.lineStyle||"solid",a=e.backgroundColor||e.fontColor||"transparent",n=e.borderColor||e.lineColor||"transparent",o=h(e.borderWidth||e.lineWidth,t,i);return{"stroke-linecap":e.lineCap||"round","stroke-linejoin":e.lineJoin||"round","stroke-width":o||0,"stroke-dasharray":"string"==typeof r?"":r.map(function(e){return h(e,t,i)}).join(","),stroke:n,fill:a,opacity:e.opacity||1}}(i,r,a),y[t](e,i,r,a)},v=["x","y","left","top","right","bottom","width","height"],w=function(e){var t=i(e,2),r=t[0],a=t[1],n=a.points?{}:v.reduce(function(e,t){var i;return e[t]="string"==typeof(i=a[t])&&/%/.test(i)?parseFloat(i)/100:i,e},{});return[r,Object.assign({zIndex:0},a,n)]},_=function(e,t){return e[1].zIndex>t[1].zIndex?1:e[1].zIndex<t[1].zIndex?-1:0},I=function(e){return e.utils.createView({name:"image-preview-markup",tag:"svg",ignoreRect:!0,mixins:{apis:["width","height","crop","markup","resize","dirty"]},write:function(e){var t=e.root,r=e.props;if(r.dirty){var a=r.crop,n=r.resize,o=r.markup,c=r.width,s=r.height,h=a.width,u=a.height;if(n){var l=n.size,d=l&&l.width,f=l&&l.height,g=n.mode,p=n.upscale;d&&!f&&(f=d),f&&!d&&(d=f);var y=h<d&&u<f;if(!y||y&&p){var v,I=d/h,M=f/u;if("force"===g)h=d,u=f;else"cover"===g?v=Math.max(I,M):"contain"===g&&(v=Math.min(I,M)),h*=v,u*=v}}var x={width:c,height:s};t.element.setAttribute("width",x.width),t.element.setAttribute("height",x.height);var T=Math.min(c/h,s/u);t.element.innerHTML="";var A=t.query("GET_IMAGE_PREVIEW_MARKUP_FILTER");o.filter(A).map(w).sort(_).forEach(function(e){var r=i(e,2),a=r[0],n=r[1],o=function(e,t){return m[e](t)}(a,n);E(o,a,n,x,T),t.element.appendChild(o)})}}})},M=function(e,t){return{x:e,y:t}},x=function(e,t){return M(e.x-t.x,e.y-t.y)},T=function(e,t){return Math.sqrt(function(e,t){return function(e,t){return e.x*t.x+e.y*t.y}(x(e,t),x(e,t))}(e,t))},A=function(e,t){var i=e,r=t,a=1.5707963267948966-t,n=Math.sin(1.5707963267948966),o=Math.sin(r),c=Math.sin(a),s=Math.cos(a),h=i/n;return M(s*(h*o),s*(h*c))},R=function(e,t,i,r){var a=r.x>.5?1-r.x:r.x,n=r.y>.5?1-r.y:r.y,o=2*a*e.width,c=2*n*e.height,s=function(e,t){var i=e.width,r=e.height,a=A(i,t),n=A(r,t),o=M(e.x+Math.abs(a.x),e.y-Math.abs(a.y)),c=M(e.x+e.width+Math.abs(n.y),e.y+Math.abs(n.x)),s=M(e.x-Math.abs(n.y),e.y+e.height-Math.abs(n.x));return{width:T(o,c),height:T(o,s)}}(t,i);return Math.max(s.width/o,s.height/c)},P=function(e,t){var i=e.width,r=i*t;return r>e.height&&(i=(r=e.height)/t),{x:.5*(e.width-i),y:.5*(e.height-r),width:i,height:r}},C=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=t.zoom,r=t.rotation,a=t.center,n=t.aspectRatio;n||(n=e.height/e.width);var o=function(e,t){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,r=e.height/e.width,a=t,n=1,o=r;o>a&&(n=(o=a)/r);var c=Math.max(1/n,a/o),s=e.width/(i*c*n);return{width:s,height:s*t}}(e,n,i),c={x:.5*o.width,y:.5*o.height},s={x:0,y:0,width:o.width,height:o.height,center:c},h=void 0===t.scaleToFit||t.scaleToFit,u=i*R(e,P(s,n),r,h?a:{x:.5,y:.5});return{widthFloat:o.width/u,heightFloat:o.height/u,width:Math.round(o.width/u),height:Math.round(o.height/u)}},k={type:"spring",stiffness:.5,damping:.45,mass:10},D=function(e){return e.utils.createView({name:"image-clip",tag:"div",ignoreRect:!0,mixins:{apis:["crop","markup","resize","width","height","dirty","background"],styles:["width","height","opacity"],animations:{opacity:{type:"tween",duration:250}}},didWriteView:function(e){var t=e.root,i=e.props;i.background&&(t.element.style.backgroundColor=i.background)},create:function(t){var i=t.root,r=t.props;i.ref.image=i.appendChildView(i.createChildView(function(e){return e.utils.createView({name:"image-canvas-wrapper",tag:"div",ignoreRect:!0,mixins:{apis:["crop","width","height"],styles:["originX","originY","translateX","translateY","scaleX","scaleY","rotateZ"],animations:{originX:k,originY:k,scaleX:k,scaleY:k,translateX:k,translateY:k,rotateZ:k}},create:function(t){var i=t.root,r=t.props;r.width=r.image.width,r.height=r.image.height,i.ref.bitmap=i.appendChildView(i.createChildView(function(e){return e.utils.createView({name:"image-bitmap",ignoreRect:!0,mixins:{styles:["scaleX","scaleY"]},create:function(e){var t=e.root,i=e.props;t.appendChild(i.image)}})}(e),{image:r.image}))},write:function(e){var t=e.root,i=e.props.crop.flip,r=t.ref.bitmap;r.scaleX=i.horizontal?-1:1,r.scaleY=i.vertical?-1:1}})}(e),Object.assign({},r))),i.ref.createMarkup=function(){i.ref.markup||(i.ref.markup=i.appendChildView(i.createChildView(I(e),Object.assign({},r))))},i.ref.destroyMarkup=function(){i.ref.markup&&(i.removeChildView(i.ref.markup),i.ref.markup=null)};var a=i.query("GET_IMAGE_PREVIEW_TRANSPARENCY_INDICATOR");null!==a&&(i.element.dataset.transparencyIndicator="grid"===a?a:"color")},write:function(e){var t=e.root,i=e.props,r=e.shouldOptimize,a=i.crop,n=i.markup,o=i.resize,c=i.dirty,s=i.width,h=i.height;t.ref.image.crop=a;var u={x:0,y:0,width:s,height:h,center:{x:.5*s,y:.5*h}},l={width:t.ref.image.width,height:t.ref.image.height},d={x:a.center.x*l.width,y:a.center.y*l.height},f={x:u.center.x-l.width*a.center.x,y:u.center.y-l.height*a.center.y},g=2*Math.PI+a.rotation%(2*Math.PI),p=a.aspectRatio||l.height/l.width,m=void 0===a.scaleToFit||a.scaleToFit,y=R(l,P(u,p),g,m?a.center:{x:.5,y:.5}),E=a.zoom*y;n&&n.length?(t.ref.createMarkup(),t.ref.markup.width=s,t.ref.markup.height=h,t.ref.markup.resize=o,t.ref.markup.dirty=c,t.ref.markup.markup=n,t.ref.markup.crop=C(l,a)):t.ref.markup&&t.ref.destroyMarkup();var v=t.ref.image;if(r)return v.originX=null,v.originY=null,v.translateX=null,v.translateY=null,v.rotateZ=null,v.scaleX=null,void(v.scaleY=null);v.originX=d.x,v.originY=d.y,v.translateX=f.x,v.translateY=f.y,v.rotateZ=g,v.scaleX=E,v.scaleY=E}})},G=0,V=function(){self.onmessage=function(e){createImageBitmap(e.data.message.file).then(function(t){self.postMessage({id:e.data.id,message:t},[t])})}},O=function(){self.onmessage=function(e){for(var t=e.data.message.imageData,i=e.data.message.colorMatrix,r=t.data,a=r.length,n=i[0],o=i[1],c=i[2],s=i[3],h=i[4],u=i[5],l=i[6],d=i[7],f=i[8],g=i[9],p=i[10],m=i[11],y=i[12],E=i[13],v=i[14],w=i[15],_=i[16],I=i[17],M=i[18],x=i[19],T=0,A=0,R=0,P=0,C=0;T<a;T+=4)A=r[T]/255,R=r[T+1]/255,P=r[T+2]/255,C=r[T+3]/255,r[T]=Math.max(0,Math.min(255*(A*n+R*o+P*c+C*s+h),255)),r[T+1]=Math.max(0,Math.min(255*(A*u+R*l+P*d+C*f+g),255)),r[T+2]=Math.max(0,Math.min(255*(A*p+R*m+P*y+C*E+v),255)),r[T+3]=Math.max(0,Math.min(255*(A*w+R*_+P*I+C*M+x),255));self.postMessage({id:e.data.id,message:t},[t.data.buffer])}},b={1:function(){return[1,0,0,1,0,0]},2:function(e){return[-1,0,0,1,e,0]},3:function(e,t){return[-1,0,0,-1,e,t]},4:function(e,t){return[1,0,0,-1,0,t]},5:function(){return[0,1,1,0,0,0]},6:function(e,t){return[0,1,-1,0,t,0]},7:function(e,t){return[0,-1,-1,0,t,e]},8:function(e){return[0,-1,1,0,0,e]}},S=function(e,t,i,r){t=Math.round(t),i=Math.round(i);var a=document.createElement("canvas");a.width=t,a.height=i;var n=a.getContext("2d");if(r>=5&&r<=8){var o=[i,t];t=o[0],i=o[1]}return function(e,t,i,r){-1!==r&&e.transform.apply(e,b[r](t,i))}(n,t,i,r),n.drawImage(e,0,0,t,i),a},L=function(e){return/^image/.test(e.type)&&!/svg/.test(e.type)},N=function(e){var t=Math.min(10/e.width,10/e.height),i=document.createElement("canvas"),r=i.getContext("2d"),a=i.width=Math.ceil(e.width*t),n=i.height=Math.ceil(e.height*t);r.drawImage(e,0,0,a,n);var o=null;try{o=r.getImageData(0,0,a,n).data}catch(e){return null}for(var c=o.length,s=0,h=0,u=0,l=0;l<c;l+=4)s+=o[l]*o[l],h+=o[l+1]*o[l+1],u+=o[l+2]*o[l+2];return{r:s=W(s,c),g:h=W(h,c),b:u=W(u,c)}},W=function(e,t){return Math.floor(Math.sqrt(e/(t/4)))},z=function(e){var t=e.utils.createView({name:"image-preview-overlay",tag:"div",ignoreRect:!0,create:function(e){var t=e.root,i=e.props,r='<svg width="500" height="200" viewBox="0 0 500 200" preserveAspectRatio="none">\n <defs>\n <radialGradient id="gradient-__UID__" cx=".5" cy="1.25" r="1.15">\n <stop offset=\'50%\' stop-color=\'#000000\'/>\n <stop offset=\'56%\' stop-color=\'#0a0a0a\'/>\n <stop offset=\'63%\' stop-color=\'#262626\'/>\n <stop offset=\'69%\' stop-color=\'#4f4f4f\'/>\n <stop offset=\'75%\' stop-color=\'#808080\'/>\n <stop offset=\'81%\' stop-color=\'#b1b1b1\'/>\n <stop offset=\'88%\' stop-color=\'#dadada\'/>\n <stop offset=\'94%\' stop-color=\'#f6f6f6\'/>\n <stop offset=\'100%\' stop-color=\'#ffffff\'/>\n </radialGradient>\n <mask id="mask-__UID__">\n <rect x="0" y="0" width="500" height="200" fill="url(#gradient-__UID__)"></rect>\n </mask>\n </defs>\n <rect x="0" width="500" height="200" fill="currentColor" mask="url(#mask-__UID__)"></rect>\n</svg>';if(document.querySelector("base")){var a=window.location.href.replace(window.location.hash,"");r=r.replace(/url\(\#/g,"url("+a+"#")}G++,t.element.classList.add("filepond--image-preview-overlay-".concat(i.status)),t.element.innerHTML=r.replace(/__UID__/g,G)},mixins:{styles:["opacity"],animations:{opacity:{type:"spring",mass:25}}}}),i=function(e){return e.utils.createView({name:"image-preview",tag:"div",ignoreRect:!0,mixins:{apis:["image","crop","markup","resize","dirty","background"],styles:["translateY","scaleX","scaleY","opacity"],animations:{scaleX:k,scaleY:k,translateY:k,opacity:{type:"tween",duration:400}}},create:function(t){var i=t.root,r=t.props;i.ref.clip=i.appendChildView(i.createChildView(D(e),{id:r.id,image:r.image,crop:r.crop,markup:r.markup,resize:r.resize,dirty:r.dirty,background:r.background}))},write:function(e){var t=e.root,i=e.props,r=e.shouldOptimize,a=t.ref.clip,n=i.image,o=i.crop,c=i.markup,s=i.resize,h=i.dirty;if(a.crop=o,a.markup=c,a.resize=s,a.dirty=h,a.opacity=r?0:1,!r&&!t.rect.element.hidden){var u=n.height/n.width,l=o.aspectRatio||u,d=t.rect.inner.width,f=t.rect.inner.height,g=t.query("GET_IMAGE_PREVIEW_HEIGHT"),p=t.query("GET_IMAGE_PREVIEW_MIN_HEIGHT"),m=t.query("GET_IMAGE_PREVIEW_MAX_HEIGHT"),y=t.query("GET_PANEL_ASPECT_RATIO"),E=t.query("GET_ALLOW_MULTIPLE");y&&!E&&(g=d*y,l=y);var v=null!==g?g:Math.max(p,Math.min(d*l,m)),w=v/l;w>d&&(v=(w=d)*l),v>f&&(v=f,w=f/l),a.width=w,a.height=v}}})}(e),r=e.utils.createWorker,a=function(e,t,i){return new Promise(function(a){e.ref.imageData||(e.ref.imageData=i.getContext("2d").getImageData(0,0,i.width,i.height));var n=function(e){var t;try{t=new ImageData(e.width,e.height)}catch(i){t=document.createElement("canvas").getContext("2d").createImageData(e.width,e.height)}return t.data.set(new Uint8ClampedArray(e.data)),t}(e.ref.imageData);if(!t||20!==t.length)return i.getContext("2d").putImageData(n,0,0),a();var o=r(O);o.post({imageData:n,colorMatrix:t},function(e){i.getContext("2d").putImageData(e,0,0),o.terminate(),a()},[n.data.buffer])})},n=function(e){var t=e.root,r=e.props,a=e.image,n=r.id,o=t.query("GET_ITEM",{id:n});if(o){var c,s,h=o.getMetadata("crop")||{center:{x:.5,y:.5},flip:{horizontal:!1,vertical:!1},zoom:1,rotation:0,aspectRatio:null},u=t.query("GET_IMAGE_TRANSFORM_CANVAS_BACKGROUND_COLOR"),l=!1;t.query("GET_IMAGE_PREVIEW_MARKUP_SHOW")&&(c=o.getMetadata("markup")||[],s=o.getMetadata("resize"),l=!0);var d=t.appendChildView(t.createChildView(i,{id:n,image:a,crop:h,resize:s,markup:c,dirty:l,background:u,opacity:0,scaleX:1.15,scaleY:1.15,translateY:15}),t.childViews.length);t.ref.images.push(d),d.opacity=1,d.scaleX=1,d.scaleY=1,d.translateY=0,setTimeout(function(){t.dispatch("DID_IMAGE_PREVIEW_SHOW",{id:n})},250)}},o=function(e){var t=e.root;t.ref.overlayShadow.opacity=1,t.ref.overlayError.opacity=0,t.ref.overlaySuccess.opacity=0},c=function(e){var t=e.root;t.ref.overlayShadow.opacity=.25,t.ref.overlayError.opacity=1};return e.utils.createView({name:"image-preview-wrapper",create:function(e){var i=e.root;i.ref.images=[],i.ref.imageData=null,i.ref.imageViewBin=[],i.ref.overlayShadow=i.appendChildView(i.createChildView(t,{opacity:0,status:"idle"})),i.ref.overlaySuccess=i.appendChildView(i.createChildView(t,{opacity:0,status:"success"})),i.ref.overlayError=i.appendChildView(i.createChildView(t,{opacity:0,status:"failure"}))},styles:["height"],apis:["height"],destroy:function(e){e.root.ref.images.forEach(function(e){e.image.width=1,e.image.height=1})},didWriteView:function(e){e.root.ref.images.forEach(function(e){e.dirty=!1})},write:e.utils.createRoute({DID_IMAGE_PREVIEW_DRAW:function(e){var t=e.root,i=t.ref.images[t.ref.images.length-1];i.translateY=0,i.scaleX=1,i.scaleY=1,i.opacity=1},DID_IMAGE_PREVIEW_CONTAINER_CREATE:function(e){var t=e.root,i=e.props.id,r=t.query("GET_ITEM",i);if(r){var a,n,o,c=URL.createObjectURL(r.file);a=c,n=function(e,r){t.dispatch("DID_IMAGE_PREVIEW_CALCULATE_SIZE",{id:i,width:e,height:r})},(o=new Image).onload=function(){var e=o.naturalWidth,t=o.naturalHeight;o=null,n(e,t)},o.src=a}},DID_FINISH_CALCULATE_PREVIEWSIZE:function(e){var t=e.root,i=e.props,o=i.id,c=t.query("GET_ITEM",o);if(c){var s,h,u=URL.createObjectURL(c.file),l=function(){var e;(e=u,new Promise(function(t,i){var r=new Image;r.crossOrigin="Anonymous",r.onload=function(){t(r)},r.onerror=function(e){i(e)},r.src=e})).then(d)},d=function(e){URL.revokeObjectURL(u);var r=(c.getMetadata("exif")||{}).orientation||-1,o=e.width,s=e.height;if(o&&s){if(r>=5&&r<=8){var h=[s,o];o=h[0],s=h[1]}var l=Math.max(1,.75*window.devicePixelRatio),d=t.query("GET_IMAGE_PREVIEW_ZOOM_FACTOR")*l,f=s/o,g=t.rect.element.width,p=t.rect.element.height,m=g,y=m*f;f>1?y=(m=Math.min(o,g*d))*f:m=(y=Math.min(s,p*d))/f;var E=S(e,m,y,r),v=function(){var r=t.query("GET_IMAGE_PREVIEW_CALCULATE_AVERAGE_IMAGE_COLOR")?N(data):null;c.setMetadata("color",r,!0),"close"in e&&e.close(),t.ref.overlayShadow.opacity=1,n({root:t,props:i,image:E})},w=c.getMetadata("filter");w?a(t,w,E).then(v):v()}};if(s=c.file,!(((h=window.navigator.userAgent.match(/Firefox\/([0-9]+)\./))?parseInt(h[1]):null)<=58)&&"createImageBitmap"in window&&L(s)){var f=r(V);f.post({file:c.file},function(e){f.terminate(),e?d(e):l()})}else l()}},DID_UPDATE_ITEM_METADATA:function(e){var t=e.root,i=e.props,r=e.action;if(/crop|filter|markup|resize/.test(r.change.key)&&t.ref.images.length){var o=t.query("GET_ITEM",{id:i.id});if(o)if(/filter/.test(r.change.key)){var c=t.ref.images[t.ref.images.length-1];a(t,r.change.value,c.image)}else{if(/crop|markup|resize/.test(r.change.key)){var s=o.getMetadata("crop"),h=t.ref.images[t.ref.images.length-1];if(Math.abs(s.aspectRatio-h.crop.aspectRatio)>1e-5){var u=function(e){var t=e.root,i=t.ref.images.shift();return i.opacity=0,i.translateY=-15,t.ref.imageViewBin.push(i),i}({root:t});n({root:t,props:i,image:(l=u.image,(d=d||document.createElement("canvas")).width=l.width,d.height=l.height,d.getContext("2d").drawImage(l,0,0),d)})}else!function(e){var t=e.root,i=e.props,r=t.query("GET_ITEM",{id:i.id});if(r){var a=t.ref.images[t.ref.images.length-1];a.crop=r.getMetadata("crop"),a.background=t.query("GET_IMAGE_TRANSFORM_CANVAS_BACKGROUND_COLOR"),t.query("GET_IMAGE_PREVIEW_MARKUP_SHOW")&&(a.dirty=!0,a.resize=r.getMetadata("resize"),a.markup=r.getMetadata("markup"))}}({root:t,props:i})}var l,d}}},DID_THROW_ITEM_LOAD_ERROR:c,DID_THROW_ITEM_PROCESSING_ERROR:c,DID_THROW_ITEM_INVALID:c,DID_COMPLETE_ITEM_PROCESSING:function(e){var t=e.root;t.ref.overlayShadow.opacity=.25,t.ref.overlaySuccess.opacity=1},DID_START_ITEM_PROCESSING:o,DID_REVERT_ITEM_PROCESSING:o},function(e){var t=e.root,i=t.ref.imageViewBin.filter(function(e){return 0===e.opacity});t.ref.imageViewBin=t.ref.imageViewBin.filter(function(e){return e.opacity>0}),i.forEach(function(e){return function(e,t){e.removeChildView(t),t.image.width=1,t.image.height=1,t._destroy()}(t,e)}),i.length=0})})},H=function(e){var t=e.addFilter,i=e.utils,r=i.Type,a=i.createRoute,n=i.isFile,o=z(e);return t("CREATE_VIEW",function(e){var t=e.is,i=e.view,r=e.query;if(t("file")&&r("GET_ALLOW_IMAGE_PREVIEW")){var c=function(e){e.root.ref.shouldRescale=!0};i.registerWriter(a({DID_RESIZE_ROOT:c,DID_STOP_RESIZE:c,DID_LOAD_ITEM:function(e){var t=e.root,a=e.props.id,c=r("GET_ITEM",a);if(c&&n(c.file)&&!c.archived){var s=c.file;if(function(e){return/^image/.test(e.type)}(s)&&r("GET_IMAGE_PREVIEW_FILTER_ITEM")(c)){var h="createImageBitmap"in(window||{}),u=r("GET_IMAGE_PREVIEW_MAX_FILE_SIZE");if(!(!h&&u&&s.size>u)){t.ref.imagePreview=i.appendChildView(i.createChildView(o,{id:a}));var l=t.query("GET_IMAGE_PREVIEW_HEIGHT");l&&t.dispatch("DID_UPDATE_PANEL_HEIGHT",{id:c.id,height:l});var d=!h&&s.size>r("GET_IMAGE_PREVIEW_MAX_INSTANT_PREVIEW_FILE_SIZE");t.dispatch("DID_IMAGE_PREVIEW_CONTAINER_CREATE",{id:a},d)}}}},DID_IMAGE_PREVIEW_CALCULATE_SIZE:function(e){var t=e.root,i=e.action;t.ref.imageWidth=i.width,t.ref.imageHeight=i.height,t.ref.shouldRescale=!0,t.ref.shouldDrawPreview=!0,t.dispatch("KICK")},DID_UPDATE_ITEM_METADATA:function(e){var t=e.root;"crop"===e.action.change.key&&(t.ref.shouldRescale=!0)}},function(e){var t=e.root,i=e.props;t.ref.imagePreview&&(t.rect.element.hidden||(t.ref.shouldRescale&&(!function(e,t){if(e.ref.imagePreview){var i=t.id,r=e.query("GET_ITEM",{id:i});if(r){var a=e.query("GET_PANEL_ASPECT_RATIO"),n=e.query("GET_ITEM_PANEL_ASPECT_RATIO"),o=e.query("GET_IMAGE_PREVIEW_HEIGHT");if(!(a||n||o)){var c=e.ref,s=c.imageWidth,h=c.imageHeight;if(s&&h){var u=e.query("GET_IMAGE_PREVIEW_MIN_HEIGHT"),l=e.query("GET_IMAGE_PREVIEW_MAX_HEIGHT"),d=(r.getMetadata("exif")||{}).orientation||-1;if(d>=5&&d<=8){var f=[h,s];s=f[0],h=f[1]}if(!L(r.file)||e.query("GET_IMAGE_PREVIEW_UPSCALE")){var g=2048/s;s*=g,h*=g}var p=h/s,m=(r.getMetadata("crop")||{}).aspectRatio||p,y=Math.max(u,Math.min(h,l)),E=e.rect.element.width,v=Math.min(E*m,y);e.dispatch("DID_UPDATE_PANEL_HEIGHT",{id:r.id,height:v})}}}}}(t,i),t.ref.shouldRescale=!1),t.ref.shouldDrawPreview&&(requestAnimationFrame(function(){t.dispatch("DID_FINISH_CALCULATE_PREVIEWSIZE",{id:i.id})}),t.ref.shouldDrawPreview=!1)))}))}}),{options:{allowImagePreview:[!0,r.BOOLEAN],imagePreviewFilterItem:[function(){return!0},r.FUNCTION],imagePreviewHeight:[null,r.INT],imagePreviewMinHeight:[44,r.INT],imagePreviewMaxHeight:[256,r.INT],imagePreviewMaxFileSize:[null,r.INT],imagePreviewZoomFactor:[2,r.INT],imagePreviewUpscale:[!1,r.BOOLEAN],imagePreviewMaxInstantPreviewFileSize:[1e6,r.INT],imagePreviewTransparencyIndicator:[null,r.STRING],imagePreviewCalculateAverageImageColor:[!1,r.BOOLEAN],imagePreviewMarkupShow:[!0,r.BOOLEAN],imagePreviewMarkupFilter:[function(){return!0},r.FUNCTION]}}};return"undefined"!=typeof window&&void 0!==window.document&&document.dispatchEvent(new CustomEvent("FilePond:pluginloaded",{detail:H})),H}); |
{ | ||
"name": "filepond-plugin-image-preview", | ||
"version": "4.6.7", | ||
"version": "4.6.8", | ||
"description": "Image Preview Plugin for FilePond", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
215529
5156