(function(n,t){"use strict";function r(n){var o,r,s,u,f,t,e,h;for(n=n||{},o=n.elements||i.getAllElements(),e=0,h=o.length;e<h;e++)if(r=o[e],s=r.nodeName.toUpperCase(),u=undefined,f=undefined,t=undefined,r[i.ns]||(r[i.ns]={}),n.reevaluate||!r[i.ns].evaluated){if(s==="PICTURE"){if(i.removeVideoShim(r),u=i.getMatch(r),u===!1)continue;t=r.getElementsByTagName("img")[0]}else u=undefined,t=r;t&&(t[i.ns]||(t[i.ns]={}),t.srcset&&(s==="PICTURE"||t.getAttribute("sizes"))&&i.dodgeSrcset(t),u?(f=i.processSourceSet(u),i.applyBestCandidate(f,t)):(f=i.processSourceSet(t),(t.srcset===undefined||t[i.ns].srcset)&&i.applyBestCandidate(f,t)),r[i.ns].evaluated=!0)}}function u(){var i,u;r();i=setInterval(function(){if(r(),/^loaded|^i|^c/.test(t.readyState)){clearInterval(i);return}},250);n.addEventListener&&n.addEventListener("resize",function(){n._picturefillWorking||(n._picturefillWorking=!0,n.clearTimeout(u),u=n.setTimeout(function(){r({reevaluate:!0});n._picturefillWorking=!1},60))},!1)}if(!n.HTMLPictureElement){t.createElement("picture");var i={};i.ns="picturefill";i.srcsetSupported=(new n.Image).srcset!==undefined;i.trim=function(n){return n.trim?n.trim():n.replace(/^\s+|\s+$/g,"")};i.endsWith=function(n,t){return n.endsWith?n.endsWith(t):n.indexOf(t,n.length-t.length)!==-1};i.matchesMedia=function(t){return n.matchMedia&&n.matchMedia(t).matches};i.getDpr=function(){return n.devicePixelRatio||1};i.getWidthFromLength=function(n){return n=n&&parseFloat(n)>0?n:"100vw",n=n.replace("vw","%"),i.lengthEl||(i.lengthEl=t.createElement("div"),t.documentElement.insertBefore(i.lengthEl,t.documentElement.firstChild)),i.lengthEl.style.cssText="position: absolute; left: 0; width: "+n+";",i.lengthEl.offsetWidth};i.types={};i.types["image/jpeg"]=!0;i.types["image/gif"]=!0;i.types["image/png"]=!0;i.types["image/svg+xml"]=t.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#Image","1.1");i.types["image/webp"]=function(){var t=new n.Image,u="image/webp";t.onerror=function(){i.types[u]=!1;r()};t.onload=function(){i.types[u]=t.width===1;r()};t.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAAAAAAfQ//73v/+BiOh/AAA="};i.verifyTypeSupport=function(n){var t=n.getAttribute("type");return t===null||t===""?!0:typeof i.types[t]=="function"?(i.types[t](),"pending"):i.types[t]};i.parseSize=function(n){var t=/(\([^)]+\))?\s*(.+)/g.exec(n);return{media:t&&t[1],length:t&&t[2]}};i.findWidthFromSourceSize=function(n){for(var r=i.trim(n).split(/\s*,\s*/),u,t=0,s=r.length;t<s;t++){var h=r[t],f=i.parseSize(h),e=f.length,o=f.media;if(e&&(!o||i.matchesMedia(o))){u=e;break}}return i.getWidthFromLength(u)};i.parseSrcset=function(n){for(var f=[],r,t,i,e,u;n!=="";)n=n.replace(/^\s+/g,""),r=n.search(/\s/g),i=null,r!==-1?(t=n.slice(0,r),e=t[t.length-1],(e===","||t==="")&&(t=t.replace(/,+$/,""),i=""),n=n.slice(r+1),i===null&&(u=n.indexOf(","),u!==-1?(i=n.slice(0,u),n=n.slice(u+1)):(i=n,n=""))):(t=n,n=""),(t||i)&&f.push({url:t,descriptor:i});return f};i.parseDescriptor=function(n,t){var h=n&&n.replace(/(^\s+|\s+$)/g,""),c=t?i.findWidthFromSourceSize(t):"100%",u,s,e,r,f,o;if(h)for(s=h.split(" "),e=s.length+1;e>=0;e--)r=s[e],f=r&&r.slice(r.length-1),(f==="w"||f==="x")&&(u=r),t&&u?u=parseFloat(parseInt(r,10)/c):(o=r&&parseFloat(r,10),u=o&&!isNaN(o)&&f==="x"||f==="w"?o:1);else u=1;return u};i.getCandidatesFromSourceSet=function(n,t){for(var u,f=i.parseSrcset(n),e=[],r=0,o=f.length;r<o;r++)u=f[r],e.push({url:u.url,resolution:i.parseDescriptor(u.descriptor,t)});return e};i.dodgeSrcset=function(n){n.srcset&&(n[i.ns].srcset=n.srcset,n.removeAttribute("srcset"))};i.processSourceSet=function(n){var t=n.getAttribute("srcset"),u=n.getAttribute("sizes"),r=[];return n.nodeName.toUpperCase()==="IMG"&&n[i.ns]&&n[i.ns].srcset&&(t=n[i.ns].srcset),t&&(r=i.getCandidatesFromSourceSet(t,u)),r};i.applyBestCandidate=function(n,t){var f,e,r,u;for(n.sort(i.ascendingSort),e=n.length,r=n[e-1],u=0;u<e;u++)if(f=n[u],f.resolution>=i.getDpr()){r=f;break}i.endsWith(t.src,r.url)||(t.src=r.url,t.currentSrc=t.src)};i.ascendingSort=function(n,t){return n.resolution-t.resolution};i.removeVideoShim=function(n){var r=n.getElementsByTagName("video"),t,i;if(r.length){for(t=r[0],i=t.getElementsByTagName("source");i.length;)n.insertBefore(i[0],t);t.parentNode.removeChild(t)}};i.getAllElements=function(){for(var r,u=t.getElementsByTagName("picture"),f=[],e=t.getElementsByTagName("img"),n=0,o=u.length+e.length;n<o;n++)n<u.length?f[n]=u[n]:(r=e[n-u.length],r.parentNode.nodeName.toUpperCase()!=="PICTURE"&&(i.srcsetSupported&&r.getAttribute("sizes")||r.getAttribute("srcset")!==null)&&f.push(r));return f};i.getMatch=function(n){for(var t,f,e,o=n.childNodes,r,u=0,s=o.length;u<s;u++)if(t=o[u],t.nodeType===1){if(t.nodeName.toUpperCase()==="IMG")return r;if(t.nodeName.toUpperCase()==="SOURCE"&&(f=t.getAttribute("media"),t.getAttribute("srcset"))&&(!f||i.matchesMedia(f)))if(e=i.verifyTypeSupport(t),e===!0){r=t;break}else if(e==="pending")return!1}return r};u();r._=i;typeof module=="object"&&typeof module.exports=="object"?module.exports=r:typeof define=="function"&&define.amd?define(function(){return r}):typeof n=="object"&&(n.picturefill=r)}})(this,this.document)