1/* 2 * FilePondPluginImagePreview 3.1.4 3 * Licensed under MIT, https://opensource.org/licenses/MIT 4 * Please visit https://pqina.nl/filepond for details. 5 */ 6 7/* eslint-disable */ 8!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.FilePondPluginImagePreview=t()}(this,function(){"use strict";var o={type:"spring",stiffness:.5,damping:.45,mass:10},v=function(e,t){return{x:e,y:t}},c=function(e,t){return v(e.x-t.x,e.y-t.y)},I=function(e,t){return Math.sqrt((r=c(i=e,a=t),n=c(i,a),r.x*n.x+r.y*n.y));var i,a,r,n},_=function(e,t){var i=e,a=t,r=1.5707963267948966-t,n=Math.sin(1.5707963267948966),o=Math.sin(a),c=Math.sin(r),s=Math.cos(r),h=i/n;return v(s*(h*o),s*(h*c))},w=function(e,t,i,a){var r,n,o,c,s,h,l,d,f,p=.5<a.x?1-a.x:a.x,u=.5<a.y?1-a.y:a.y,g=2*p*e.width,E=2*u*e.height,m=(n=i,o=(r=t).width,c=r.height,s=_(o,n),h=_(c,n),l=v(r.x+Math.abs(s.x),r.y-Math.abs(s.y)),d=v(r.x+r.width+Math.abs(h.y),r.y+Math.abs(h.x)),f=v(r.x-Math.abs(h.y),r.y+r.height-Math.abs(h.x)),{width:I(l,d),height:I(l,f)});return Math.max(m.width/g,m.height/E)},s=function(e){return e.utils.createView({name:"image-bitmap",tag:"canvas",ignoreRect:!0,mixins:{styles:["scaleX","scaleY"]},create:function(e){var t,i,a=e.root,r=e.props;t=r.image,(i=(i=a.element)||document.createElement("canvas")).width=t.width,i.height=t.height,i.getContext("2d").drawImage(t,0,0)}})},r=function(n){return n.utils.createView({name:"image-clip",tag:"div",ignoreRect:!0,mixins:{apis:["crop","width","height"],styles:["width","height"]},create:function(e){var a,t=e.root,i=e.props;t.ref.image=t.appendChildView(t.createChildView((a=n).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:o,originY:o,scaleX:o,scaleY:o,translateX:o,translateY:o,rotateZ:o}},create:function(e){var t=e.root,i=e.props;i.width=i.image.width,i.height=i.image.height,t.ref.image=t.appendChildView(t.createChildView(s(a),{image:i.image}))},write:function(e){var t=e.root,i=e.props.crop.flip,a=t.ref.image;a.scaleX=i.horizontal?-1:1,a.scaleY=i.vertical?-1:1}}),Object.assign({},i)));var r=t.query("GET_IMAGE_PREVIEW_TRANSPARENCY_INDICATOR");null!==r&&(t.element.dataset.transparencyIndicator="grid"===r?r:"color")},write:function(e){var t=e.root,i=e.props,a=i.crop,r=i.width,n=i.height;t.ref.image.crop=a;var o,c,s,h,l={x:0,y:0,width:r,height:n,center:{x:.5*r,y:.5*n}},d={width:t.ref.image.width,height:t.ref.image.height},f={x:a.center.x*d.width,y:a.center.y*d.height},p={x:l.center.x-d.width*a.center.x,y:l.center.y-d.height*a.center.y},u=2*Math.PI+a.rotation%(2*Math.PI),g=a.aspectRatio||d.height/d.width,E=w(d,(s=(o=l).width,(h=s*(c=g))>o.height&&(s=(h=o.height)/c),{x:.5*(o.width-s),y:.5*(o.height-h),width:s,height:h}),u,a.center),m=a.zoom*E,v=t.ref.image;v.originX=f.x,v.originY=f.y,v.translateX=p.x,v.translateY=p.y,v.rotateZ=u,v.scaleX=m,v.scaleY=m}})},n="<radialGradient id=\"filepond--image-preview-radial-gradient\" 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\n<mask id=\"filepond--image-preview-masking\">\n<rect x=\"0\" y=\"0\" width=\"500\" height=\"200\" fill=\"url(#filepond--image-preview-radial-gradient)\"></rect>\n</mask>",e=function(){if("interactive"===document.readyState){var e=document.createElementNS("http://www.w3.org/2000/svg","svg");e.style.cssText="position:absolute;width:0;height:0",e.innerHTML=n,document.body.appendChild(e)}},t="undefined"!=typeof navigator;t&&(e(),document.addEventListener("readystatechange",e));var l=!!t&&(document.documentMode||/Edge/.test(navigator.userAgent)),f=function(){self.onmessage=function(t){createImageBitmap(t.data.message.file).then(function(e){self.postMessage({id:t.data.id,message:e},[e])})}},h={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]}
8,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]}},y=function(e,t,i,a){-1!==a&&e.transform.apply(e,function(e){if(Array.isArray(e)){for(var t=0,i=Array(e.length);t<e.length;t++)i[t]=e[t];return i}return Array.from(e)}(h[a](t,i)))},M=function(e){return/^image/.test(e.type)&&!/svg/.test(e.type)},T=function(e,t){return Math.floor(Math.sqrt(e/(t/4)))},d=function(s){var a,i=s.utils.createView({name:"image-preview-overlay",tag:"div",ignoreRect:!0,create:function(e){var t=e.root,i=e.props;t.element.classList.add("filepond--image-preview-overlay-"+i.status),t.element.innerHTML='<svg width="500" height="200" viewBox="0 0 500 200" preserveAspectRatio="none">\n '+(l?"<defs>"+n+"</defs>":"")+'\n <rect x="0" width="500" height="200" fill="currentColor" mask="url(#filepond--image-preview-masking)"></rect>\n </svg>\n '},mixins:{styles:["opacity"],animations:{opacity:{type:"spring",mass:25}}}}),d=[],h=(a=s).utils.createView({name:"image-preview",tag:"div",ignoreRect:!0,mixins:{apis:["crop"],styles:["translateY","scaleX","scaleY","opacity"],animations:{scaleX:o,scaleY:o,translateY:o,opacity:{type:"tween",duration:500}}},create:function(e){var t=e.root,i=e.props;t.ref.clip=t.appendChildView(t.createChildView(r(a),{image:i.image,crop:i.crop}))},write:function(e){var t=e.root,i=e.props,a=t.ref.clip,r=i.crop,n=i.image;a.crop=r;var o=n.height/n.width,c=r.aspectRatio||o,s=t.rect.inner.width,h=s,l=t.query("GET_IMAGE_PREVIEW_HEIGHT"),d=t.query("GET_IMAGE_PREVIEW_MIN_HEIGHT"),f=t.query("GET_IMAGE_PREVIEW_MAX_HEIGHT"),p=t.query("GET_PANEL_ASPECT_RATIO"),u=t.query("GET_ALLOW_MULTIPLE");p&&!u&&(l=s*p,c=p);var g=null!==l?l:Math.max(d,Math.min(s*c,f)),E=g/c;h<E&&(g=(E=h)*c),a.width=E,a.height=g}}),m=function(e){var t=e.root,i=e.props,a=i.id,r=t.query("GET_ITEM",{id:a});if(r){var n=i.preview,o=r.getMetadata("crop")||{center:{x:.5,y:.5},flip:{horizontal:!1,vertical:!1},zoom:1,rotation:0,aspectRatio:null},c=t.appendChildView(t.createChildView(h,{image:n,crop:o,opacity:0,scaleX:1.15,scaleY:1.15,translateY:15}),t.childViews.length);t.ref.images.push(c),c.opacity=1,c.scaleX=1,c.scaleY=1,c.translateY=0,setTimeout(function(){t.dispatch("DID_IMAGE_PREVIEW_SHOW",{id:a})},250)}},e=function(e){var t=e.root;t.ref.overlayShadow.opacity=1,t.ref.overlayError.opacity=0,t.ref.overlaySuccess.opacity=0},t=function(e){var t=e.root;t.ref.overlayShadow.opacity=.25,t.ref.overlayError.opacity=1};return s.utils.createView({name:"image-preview-wrapper",create:function(e){var t=e.root;t.ref.images=[],t.ref.overlayShadow=t.appendChildView(t.createChildView(i,{opacity:0,status:"idle"})),t.ref.overlaySuccess=t.appendChildView(t.createChildView(i,{opacity:0,status:"success"})),t.ref.overlayError=t.appendChildView(t.createChildView(i,{opacity:0,status:"failure"}))},styles:["height"],write:s.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 p=e.root,u=e.props,r=s.utils.createWorker,n=u.id,g=p.query("GET_ITEM",n);if(g){var t,i,a,E=URL.createObjectURL(g.file),o=function(){var a;(a=E,new Promise(function(e,t){var i=new Image;i.crossOrigin="Anonymous",i.onload=function(){e(i)},i.onerror=function(e){t(e)},i.src=a})).then(c)},c=function(e){URL.revokeObjectURL(E);var t=(g.getMetadata("exif")||{}).orientation||-1,i=e.width,a=e.height;if(5<=t&&t<=8){var r=[a,i];i=r[0],a=r[1]}var n=window.devicePixelRatio,o=p.query("GET_IMAGE_PREVIEW_HEIGHT"),c=p.query("GET_IMAGE_PREVIEW_MIN_HEIGHT"),s=p.query("GET_IMAGE_PREVIEW_MAX_HEIGHT"),h=a/i,l=null!==o?o:Math.max(c,Math.min(a,s)),d=l/h;u.preview=function(e,t,i,a){t=Math.round(t),i=Math.round(i);var r=document.createElement("canvas");r.width=t,r.height=i;var n=r.getContext("2d");if(5<=a&&a<=8){var o=[i,t];t=o[0],i=o[1]}return y(n,t,i,a),n.drawImage(e,0,0,t,i),r}(e,Math.min(i,d*n*4),Math.min(a,l*n*4),t);var f=p.query("GET_IMAGE_PREVIEW_CALCULATE_AVERAGE_IMAGE_COLOR")?function(e){var t=Math.min(10/e.width,10/e.height),i=document.createElement("canvas"),a=i.getContext("2d"),r=i.width=Math.ceil(e.width*t),n=i.height=Math.ceil(e.height*t);a.drawImage(e,0,0,r,n);var o=null;try{o=a.getImageData(0,0,r,n).data}catch(e){return null}for(var c=o.length,s=0,h=0,l=0,d=0;d<c;d+=4)s+=o[d]*o[d],h+=o[d+1]*o[d+1],l+=o[d+2]*o[d+2];return{r:s=T(s,c),g:h=T(h,c),b:l=T(l,c)}}(e):null;g.setMetadata("color",f,!0),"close"in e&&e.close(),p.ref.overlaySha
8dow.opacity=1,m({root:p,props:u})};t=E,i=function(e,t){if(p.dispatch("DID_IMAGE_PREVIEW_CALCULATE_SIZE",{id:n,width:e,height:t}),a=g.file,"createImageBitmap"in window&&M(a)){var i=r(f);i.post({file:g.file},function(e){i.terminate(),e?c(e):o()})}else o();var a},(a=new Image).onload=function(){var e=a.naturalWidth,t=a.naturalHeight;a=null,i(e,t)},a.src=t}},DID_UPDATE_ITEM_METADATA:function(e){var t=e.root,i=e.props;if("crop"===e.action.change.key&&t.ref.images.length){var a=t.query("GET_ITEM",{id:i.id});if(a){var r,n,o,c,s,h=a.getMetadata("crop"),l=t.ref.images[t.ref.images.length-1];1e-5<Math.abs(h.aspectRatio-l.crop.aspectRatio)?((s={root:t}.root.ref.images.shift()).opacity=0,s.translateY=-15,d.push(s),m({root:t,props:i})):(n=(r={root:t,props:i}).root,o=r.props,(c=n.query("GET_ITEM",{id:o.id}))&&(n.ref.images[n.ref.images.length-1].crop=c.getMetadata("crop")))}}},DID_THROW_ITEM_LOAD_ERROR:t,DID_THROW_ITEM_PROCESSING_ERROR:t,DID_THROW_ITEM_INVALID:t,DID_COMPLETE_ITEM_PROCESSING:function(e){var t=e.root;t.ref.overlayShadow.opacity=.25,t.ref.overlaySuccess.opacity=1},DID_START_ITEM_PROCESSING:e,DID_REVERT_ITEM_PROCESSING:e},function(e){var i=e.root,t=i.query("GET_PANEL_ASPECT_RATIO");t&&(i.height=t*i.rect.width);var a=d.filter(function(e){return 0===e.opacity});d=d.filter(function(e){return 0<e.opacity}),a.forEach(function(e){return t=e,i.removeChildView(t),void t._destroy();var t}),a.length=0})})},i=function(e){var t=e.addFilter,i=e.utils,a=i.Type,n=i.createRoute,h=i.isFile,l=d(e);return t("CREATE_VIEW",function(e){var t=e.is,c=e.view,s=e.query;if(t("file")&&s("GET_ALLOW_IMAGE_PREVIEW")){var r=function(e,t){if(e.ref.imagePreview){var i=t.id,a=e.query("GET_ITEM",{id:i});if(a){var r=e.ref,n=r.imageWidth,o=r.imageHeight;if(n&&o){var c=(a.getMetadata("exif")||{}).orientation||-1;if(5<=c&&c<=8){var s=[o,n];n=s[0],o=s[1]}var h=e.query("GET_PANEL_ASPECT_RATIO"),l=e.query("GET_ALLOW_MULTIPLE"),d=a.getMetadata("crop")||{center:{x:.5,y:.5},flip:{horizontal:!1,vertical:!1},rotation:0,zoom:1,aspectRatio:o/n},f=!l&&h,p=f?h:d.aspectRatio||o/n,u=e.query("GET_IMAGE_PREVIEW_HEIGHT"),g=e.query("GET_IMAGE_PREVIEW_MIN_HEIGHT"),E=e.query("GET_IMAGE_PREVIEW_MAX_HEIGHT");if(f&&(u=e.rect.element.width*h),!M(a.file)){var m=2048/n;n*=m,o*=m}((n=(o=null!==u?u:Math.max(g,Math.min(o,E)))/p)>e.rect.element.width||f)&&(o=(n=e.rect.element.width)*p),e.ref.imagePreview.element.style.cssText="height:"+Math.round(o)+"px"}}}};c.registerWriter(n({DID_LOAD_ITEM:function(e){var t=e.root,i=e.props.id,a=s("GET_ITEM",i);if(a&&h(a.file)&&!a.archived){var r=a.file;if(/^image/.test(r.type)){var n="createImageBitmap"in(window||{}),o=s("GET_IMAGE_PREVIEW_MAX_FILE_SIZE");!n&&o&&r.size>o||(t.ref.imagePreview=c.appendChildView(c.createChildView(l,{id:i}
8)),t.dispatch("DID_IMAGE_PREVIEW_CONTAINER_CREATE",{id:i}))}}},DID_IMAGE_PREVIEW_CALCULATE_SIZE:function(e){var t=e.root,i=e.props,a=e.action;t.ref.imageWidth=a.width,t.ref.imageHeight=a.height,r(t,i)},DID_UPDATE_ITEM_METADATA:function(e){var t=e.root,i=e.props;"crop"===e.action.change.key&&r(t,i)}}))}}),{options:{allowImagePreview:[!0,a.BOOLEAN],imagePreviewHeight:[null,a.INT],imagePreviewMinHeight:[44,a.INT],imagePreviewMaxHeight:[256,a.INT],imagePreviewMaxFileSize:[null,a.INT],imagePreviewTransparencyIndicator:[null,a.STRING],imagePreviewCalculateAverageImageColor:[!1,a.BOOLEAN]}}};return"undefined"!=typeof window&&void 0!==window.document&&document&&document.dispatchEvent(new CustomEvent("FilePond:pluginloaded",{detail:i})),i});
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.