Comparing version 0.0.28 to 0.0.29
@@ -1,1 +0,1 @@ | ||
var x=Object.defineProperty,J=Object.defineProperties,K=Object.getOwnPropertyDescriptor,Q=Object.getOwnPropertyDescriptors,Z=Object.getOwnPropertyNames,j=Object.getOwnPropertySymbols;var E=Object.prototype.hasOwnProperty,ee=Object.prototype.propertyIsEnumerable;var A=(e,t,o)=>t in e?x(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,b=(e,t)=>{for(var o in t||(t={}))E.call(t,o)&&A(e,o,t[o]);if(j)for(var o of j(t))ee.call(t,o)&&A(e,o,t[o]);return e},y=(e,t)=>J(e,Q(t)),te=e=>x(e,"__esModule",{value:!0});var oe=(e,t)=>{for(var o in t)x(e,o,{get:t[o],enumerable:!0})},ne=(e,t,o,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Z(t))!E.call(e,n)&&(o||n!=="default")&&x(e,n,{get:()=>t[n],enumerable:!(r=K(t,n))||r.enumerable});return e};var re=(e=>(t,o)=>e&&e.get(t)||(o=ne(te({}),t,1),e&&e.set(t,o),o))(typeof WeakMap!="undefined"?new WeakMap:0);var ye={};oe(ye,{default:()=>_});function U(){let e=!1,t,o,r=(i,u)=>{e||(e=!0,i(u))},n=new Promise((i,u)=>{t=i,o=u});return n.resolve=i=>r(t,i),n.reject=i=>r(o,i),n}function ie(e){return e&&typeof e=="object"&&!Array.isArray(e)&&!(e instanceof NodeList)&&!(e instanceof Node)&&!(e.el instanceof Node)}function ae(e){return!!e.forEach}function h(e,t,o,r){return e.addEventListener(t,o,r),()=>e.removeEventListener(t,o,r)}function g(e){return c("div",{innerHTML:e}).firstChild}function c(e,...t){let o=e.split("."),r=o[0],n=o.slice(1),i=r==="svg"?document.createElementNS("http://www.w3.org/2000/svg","svg"):document.createElement(r||"div");r==="svg"&&i.setAttribute("xmlns","http://www.w3.org/2000/svg");let u=t[0],l=ie(u)&&u;return n.length&&(i.className=n.join(" ")),ce(l,i),se(l?t.slice(1):t,i),i}function ce(e,t){return t&&e&&Object.keys(e).forEach(o=>{let r=e[o];if(o==="class"||o==="className"){let n=r&&r.split(" ");n&&n.length&&t.classList.add(...n)}else o==="innerHTML"||o==="textContent"||typeof r=="function"||o.startsWith("$")?t[o]=r:r!==!1&&r!==void 0&&r!==null&&t.setAttribute(o,r)}),t}function se(e,t){return t.appendChild(z(e)),t}function z(e,t){return t||(t=document.createDocumentFragment()),e instanceof Node||typeof e=="string"?ue(e,t):(ae(e)&&Array.from(e).forEach(o=>o&&z(o,t)),t)}function ue(e,t){if(!e)return t;let o=typeof e=="string"?document.createTextNode(e):e;return t instanceof Range?(t.insertNode(o),t.collapse()):t instanceof Node&&t.appendChild(o),t}var q=()=>g('<svg fill="currentColor" viewBox="0 0 24 24"><path d="M5 4h-3v-1h3v1zm10.93 0l.812 1.219c.743 1.115 1.987 1.781 3.328 1.781h1.93v13h-20v-13h3.93c1.341 0 2.585-.666 3.328-1.781l.812-1.219h5.86zm1.07-2h-8l-1.406 2.109c-.371.557-.995.891-1.664.891h-5.93v17h24v-17h-3.93c-.669 0-1.293-.334-1.664-.891l-1.406-2.109zm-11 8c0-.552-.447-1-1-1s-1 .448-1 1 .447 1 1 1 1-.448 1-1zm7 0c1.654 0 3 1.346 3 3s-1.346 3-3 3-3-1.346-3-3 1.346-3 3-3zm0-2c-2.761 0-5 2.239-5 5s2.239 5 5 5 5-2.239 5-5-2.239-5-5-5z" /></svg>'),M=()=>g('<svg fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 10l4.553-2.276A1 1 0 0121 8.618v6.764a1 1 0 01-1.447.894L15 14M5 18h8a2 2 0 002-2V8a2 2 0 00-2-2H5a2 2 0 00-2 2v8a2 2 0 002 2z" /></svg>'),C=()=>g('<svg fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 11a7 7 0 01-7 7m0 0a7 7 0 01-7-7m7 7v4m0 0H8m4 0h4m-4-8a3 3 0 01-3-3V5a3 3 0 116 0v6a3 3 0 01-3 3z" /></svg>');(function(){if(window.ImageCapture)return;let t=document.createElement("script");t.src="https://unpkg.com/image-capture@0.4.0/lib/imagecapture.min.js",document.head.appendChild(t)})();function F(e){let t=!!window.MediaRecorder;return{filepicker:!0,takephoto:e.includes("takephoto")&&!!(navigator.mediaDevices&&navigator.mediaDevices.getUserMedia),takevideo:e.includes("takevideo")&&t,takeaudio:e.includes("takeaudio")&&t}}function I(e){let o=(e.video?["video/mp4","video/mpeg","video/webm"]:["audio/mpeg","audio/webm","audio/ogg","audio/wav","audio/mp3","audio/mp4"]).filter(r=>MediaRecorder.isTypeSupported(r))[0];if(!o)throw new Error("No supported mime type found.");return o}function N(e){return e.name=`your${e.type.replace("/",".")}`,e}function O(e){let t=[],o,r;function n(a){a.data.size>0?t.push(a.data):console.error("No data",a)}function i(){return o}function u(){let a=o.getVideoTracks()[0];return new ImageCapture(a).takePhoto().then(N)}function l(){t=[],r=new MediaRecorder(o,{mimeType:I(e)}),r.ondataavailable=n,r.start()}function p(){return new Promise((a,d)=>{r.onstop=()=>{e.isDisposed()&&d(new Error("Disposed."));try{let s=new Blob(t,{type:I(e)});a(N(s))}catch(s){d(s)}},r.stop()})}return setTimeout(function a(){if(e.isDisposed()){r&&r.state!=="inactive"&&r.stop();return}setTimeout(a,1e3)},1e3),navigator.mediaDevices.getUserMedia(e).then(a=>(o=a,{liveSrc:i,capturePhoto:u,beginMediaCapture:l,endMediaCapture:p}))}function R(e){let t=e.onPickFiles,o=e.accept,r=e.sources,n=e.beginCaptureMedia,i=F(r),u=(p,a,d)=>i[p]&&c("button.quik-footer-btn.quik-main-footer-btn",{onclick(s){s.preventDefault(),n(p)}},a(),d),l=c("label.quik-drop-target.quik-content",{ondragover(p){p.preventDefault(),l.classList.add("quik-drop-target-active")},ondragleave(){l.classList.remove("quik-drop-target-active")},ondrop(p){p.preventDefault(),p.stopPropagation();let a=p.dataTransfer.files;!e.multiple&&a.length>1&&(a=[a[0]]),t(a)}},c("input.quik-file-input",{type:"file",accept:o,multiple:e.multiple,onchange(p){t(p.target.files)}}),g('<svg class="quik-icon" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 16a4 4 0 01-.88-7.903A5 5 0 1115.9 6L16 6a5 5 0 011 9.9M15 13l-3-3m0 0l-3 3m3-3v12" /></svg>'),c("h2.quik-header","Upload a file"),c(".quik-instructions",c("span.quik-text","Drag or paste a file here, or choose an option below."),c("footer.quik-footer",c("span.quik-footer-btn.quik-footer-btn-primary",g('<svg fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z" /></svg>'),"Choose File"),u("takephoto",q,"Take Photo"),u("takevideo",M,"Record Video"),u("takeaudio",C,"Record Audio"))));return l}function S(e){let t=e.close;return c(".quikpik",{onmousedown:t,ontouchstart:t},c("div.quik-body",{onmousedown(r){r.stopPropagation()},ontouchstart(r){r.stopPropagation()}},R(e)))}function w(e,t){e.querySelector(".quik-body").firstChild.replaceWith(t)}function W(){return c(".quik-progress",c("span.quik-progress-text",c("span.quik-filename","Uploading..."),c("span.quik-percent","0%")),c("span.quik-progress-bar-wrapper",c("span.quik-progress-bar",{style:"width: 0%"})))}function X(e,t,o){let r=e.querySelector(".quik-progress-bar");e.querySelector(".quik-filename").textContent=`Uploading ${o}`,e.querySelector(".quik-percent").textContent=Math.round(t)+"%",r.style.width=t+"%",t>=100&&r.classList.add("quik-done-bar")}function Y(e,t,o,r){let n=0,i=!1,u=new Image;function l(){let a=o.width;o.width=o.height,o.height=a}function p(a,d,s){if(!d||!i)return;let f=d.getContext("2d");f.translate(d.width/2,d.height/2),f.rotate(s*Math.PI/180),f.drawImage(a,-a.width/2,-a.height/2),f.rotate(-s*Math.PI/180),f.translate(-d.width/2,-d.height/2)}return u.addEventListener("load",()=>{i=!0,o.width=u.width,o.height=u.height,p(u,o,n),r()}),u.addEventListener("error",()=>alert("Failed to load image.")),u.src=e,{save(a="image/png",d=void 0){return n?new Promise(s=>o.toBlob(f=>{f.name=t&&t.name,s(f)},a,d)):Promise.resolve(t)},rotate(){n=(n+90)%360,l(),p(u,o,n)}}}var T=32,P=32;function de(e){let t=e.image,o=e.cropBounds,r=e.scale,n=c("canvas");return n.width=o.width*r,n.height=o.height*r,n.getContext("2d").drawImage(t,o.left*r,o.top*r,o.width*r,o.height*r,0,0,n.width,n.height),new Promise(u=>{n.toBlob(l=>{l.name=t.name,u(l)},"image/png")})}function le(e){let t=e.parentElement,o=c(".quik-crop");return t.appendChild(o),o}function B(e){let t=e.changedTouches&&e.changedTouches[0];return t&&(e.clientX=t.clientX,e.clientY=t.clientY),e}function $(e,t){e=B(e);let o=t.getBoundingClientRect(),r=Math.max(10,Math.floor(o.width/5)),n=Math.max(10,Math.floor(o.height/5)),i=e.clientX<o.left+n,u=e.clientX>o.right-r,l=e.clientY<o.top+n,p=e.clientY>o.bottom-n;return(l?"n":p?"s":"")+(u?"e":i?"w":"")||"move"}function pe(e){let t=e.bounds,o=e.parentBounds,r=Math.max(o.top,t.top+e.deltaY),n=Math.max(o.left,t.left+e.deltaX);return r+t.height>o.bottom&&(r=o.bottom-t.height),n+t.width>o.right&&(n=o.right-t.width),{top:r,left:n}}function fe(e){let t=e.bounds,o=e.parentBounds,r=Math.min(o.right,t.left+t.width+e.deltaX),n=Math.max(P,r-t.left);if(!e.aspectRatio)return{width:n};let i=n*e.aspectRatio;return t.top+i>o.bottom&&(i=o.bottom-t.top,n=i/e.aspectRatio),{width:n,height:i}}function me(e){let t=e.bounds,o=e.parentBounds,r=Math.min(o.bottom,t.top+t.height+e.deltaY),n=Math.max(T,r-t.top);if(!e.aspectRatio)return{height:n};let i=n/e.aspectRatio;return t.left+i>o.right&&(i=o.right-t.left,n=i*e.aspectRatio),{width:i,height:n}}function L(e){let t=e.bounds,o=e.parentBounds,r=Math.max(o.left,t.left+e.deltaX),n=t.right-r;if(n<P&&(r-=P-n,n=P),!e.aspectRatio)return{left:r,width:n};let i=n*e.aspectRatio;return t.top+i>o.bottom&&(i=o.bottom-t.top,n=i/e.aspectRatio,r=t.right-n),{left:r,width:n,height:i}}function he(e){let t=e.bounds,o=e.parentBounds,r=Math.max(o.top,t.top+e.deltaY),n=t.bottom-r;if(n<T&&(r-=T-n,n=T),!e.aspectRatio)return{top:r,height:n};let i=n/e.aspectRatio;return t.left+i>o.right&&(i=o.right-t.left,n=i*e.aspectRatio,r=t.bottom-n),{width:i,height:n,top:r}}function ge(e){let t={};return e.direction==="sw"&&e.aspectRatio?L(e):e.direction==="nw"&&e.aspectRatio?(t=L(e,"n"),t.top=e.bounds.bottom-t.height,t):(e.direction.includes("s")&&(Object.assign(t,me(e)),e.aspectRatio)||e.direction.includes("n")&&(Object.assign(t,he(e)),e.aspectRatio)||(e.direction.includes("w")&&Object.assign(t,L(e)),e.direction.includes("e")&&Object.assign(t,fe(e))),t)}function ke(e,t,o,r,n){let i=t.getBoundingClientRect(),u=e.clientX,l=e.clientY,p={direction:n,aspectRatio:o,parentBounds:i,bounds:r.getBoundingClientRect(),deltaY:0,deltaX:0,applyEvent(a){a=B(a),p.deltaX=a.clientX-u,p.deltaY=a.clientY-l},resize(a){a.top&&(a.top=a.top-i.top),a.left&&(a.left=a.left-i.left),Object.keys(a).forEach(d=>{r.style[d]=Math.round(a[d])+"px"})}};return p}function D(e,t){let o=le(e),r=!1;h(o,"mousedown",n),h(o,"touchstart",n),h(o,"mousemove",i=>{if(!i.buttons){let u=$(i,o);o.style.cursor=u==="move"?"grabbing":u+"-resize"}});function n(i){if(i.preventDefault(),i=B(i),r)return;r=!0;let u=$(i,o),l=ke(i,e,t,o,u),p=[];function a(s){l.applyEvent(s),l.resize(u==="move"?pe(l):ge(l))}function d(){r=!1,p.forEach(s=>s())}p=[h(document,"mousemove",a),h(document,"touchmove",a),h(document,"mouseup",d),h(document,"touchend",d),h(document,"touchcancel",d)]}return{el:o,dispose(){o.remove()},apply(i){return de({image:i,cropBounds:{top:o.offsetTop-e.offsetTop,left:o.offsetLeft-e.offsetLeft,width:o.offsetWidth,height:o.offsetHeight},scale:i.naturalWidth/e.offsetWidth})}}}function ve(e,t){let o=new Image;return new Promise(r=>{o.onload=()=>{r(t(o)),URL.revokeObjectURL(o.src)},o.src=URL.createObjectURL(e)})}function V(e){let t=e.url,o=e.file,r=e.cancelText,n=e.confirmText,i=e.onCancel,u=e.onConfirm,l=e.requireCrop,p=e.cropRatio,a,d=c(".quik-content-wrapper",c(".quik-text","Loading...")),s=c("canvas.quik-confirm-item"),f=c(".quik-content",s),m=Y(t,o,s,()=>{a=l?D(s,p):void 0,d.appendChild(c("footer.quik-footer",c("button.quik-footer-btn",{onclick:i},r),!l&&c("button.quik-footer-btn",{onclick(){a?(a.dispose(),a=void 0):a=D(s,p)}},g('<svg width="24" height="24" viewBox="0 0 24 24" fill="currentColor"><path d="M24 18h-4v-14h-14v-4h-2v4h-4v2h4v14h14v4h2v-4h4v-2zm-18 0v-12h12v12h-12z"/></svg>'),"Crop"),c("button.quik-footer-btn",{onclick:m.rotate},g('<svg viewBox="0 0 24 24" fill="currentColor"><path d="M12 0c3.31 0 6.291 1.353 8.459 3.522l2.48-2.48 1.061 7.341-7.437-.966 2.489-2.489c-1.808-1.807-4.299-2.928-7.052-2.928-5.514 0-10 4.486-10 10s4.486 10 10 10c3.872 0 7.229-2.216 8.89-5.443l1.717 1.046c-2.012 3.803-6.005 6.397-10.607 6.397-6.627 0-12-5.373-12-12s5.373-12 12-12z" /></svg>')," Rotate"),c("button.quik-footer-btn.quik-footer-btn-primary",{onclick(k){k.target.disabled=!0,m.save().then(v=>a?ve(v,a.apply):v).then(v=>{v.name||(v.name=o.name),u(v)})}},n))),d.firstChild.replaceWith(f)});return d}function H(e){let t=e.url,o=e.file,r=e.cancelText,n=e.confirmText,i=e.onCancel,u=e.onConfirm,l=o.type.startsWith("video/")?c("video.quik-vid.quik-content",{src:t,controls:!0}):c("audio",{src:t,controls:!0});return c(".quik-content-wrapper",c(".quik-confirm-item",l),c("footer.quik-footer",c("button.quik-footer-btn",{onclick:i},r),c("button.quik-footer-btn.quik-footer-btn-primary",{onclick(p){p.target.disabled=!0,u(o)}},n)))}var we=10;function be(e){let t=c("video.quik-vid.quik-content");return t.srcObject=e.recorder.liveSrc(),t.muted=!0,t.controls=!1,t.play(),t}function Ce(e,t,o){let r=Date.now(),n=t*60,i=d=>`${Math.floor(d/60)}:${`00${d%60}`.slice(-2)} / ${t}:00`,u,l=c("span.quik-progress-bar",{style:"width: 0%"}),p=c("span.quik-duration",i(0)),a=c(".quik-progress",c("span.quik-progress-text",c("span.quik-filename",e),p),c("span.quik-progress-bar-wrapper",l));return u=setTimeout(function d(){let s=Math.floor((Date.now()-r)/1e3);if(p.textContent=i(s),l.style.width=`${Math.floor(s*100/n)}%`,s>=n){o();return}a.isConnected&&setTimeout(d,1e3)},1e3),a}function G(e){let t=e.onPickFiles,o=e.maxDuration||we,r=e.onCancel;type=e.type;let n,i=c("p.quik-info.quik-content",`Waiting for your ${type==="takeaudio"?"microphone":"camera"}...`),u=c("footer.quik-footer",c("button.quik-footer-btn.quik-footer-btn-secondary",{onclick:r},"Cancel")),l=c(".quik-media",i,u),p=()=>!l.isConnected,a=d=>i.replaceWith(c("p.quik-error",d.toString()));return O({video:type!=="takeaudio",audio:type!=="takephoto",isDisposed:p}).then(d=>{let s=()=>{i.textContent="Generating preview...",n&&n.remove(),(type==="takephoto"?d.capturePhoto():d.endMediaCapture()).then(m=>t([m])).catch(a)};i.textContent=type==="takephoto"?"":`Ready to record. You can record up to ${o} minutes of ${type==="takeaudio"?"audio":"video"}.`,type!=="takeaudio"&&l.insertBefore(be({recorder:d,onPickFiles:t,onError:a}),i),u.appendChild(c("button.quik-footer-btn.quik-footer-btn-primary",{onclick(f){type==="takephoto"||n?(f.target.disabled=!0,s()):(d.beginMediaCapture(),n=Ce("Recording...",o,s),i.textContent="",l.insertBefore(n,u),f.target.innerHTML="",f.target.append(C(),c("span","Stop recording")))}},type==="takephoto"?q():type==="takeaudio"?C():M(),type==="takephoto"?"Take Photo":"Begin Recording"))}).catch(a),l}function xe(e){e=b({sources:["filepicker","takephoto"]},e);let t,o=U(),r=[h(window,"keydown",s=>{(s.key==="Escape"||s.code==="Escape")&&u()}),h(document.body,"paste",s=>{s.clipboardData&&s.clipboardData.files&&s.clipboardData.files.length&&(s.preventDefault(),l(s.clipboardData.files))})],n=y(b({},e),{close:u,uploadFiles:d,onPickFiles:l,beginCaptureMedia:a,promise:o,root:void 0,uploader:void 0});n.root=S(n);function i(){w(n.root,R({onPickFiles:l,beginCaptureMedia:a,accept:n.accept,sources:n.sources}))}function u(){o.resolve(t),n.root.remove(),r.forEach(s=>s()),n.uploader&&(n.uploader.cancel(),n.uploader=void 0)}function l(s){let f=s.length===1?s[0]:void 0;if(f&&f.type!=="image/gif"&&!f.type.startsWith("image/svg")&&f.type.startsWith("image/")){let m=URL.createObjectURL(f);r.push(()=>URL.revokeObjectURL(m)),w(n.root,V(y(b({},e),{url:m,file:f,cancelText:"Cancel",confirmText:"Accept & upload",onCancel:i,onConfirm:k=>d([k])})));return}d(s)}function p(s){let f=s[0],m=URL.createObjectURL(f);r.push(()=>URL.revokeObjectURL(m)),w(n.root,H(y(b({},e),{url:m,file:f,cancelText:"Cancel",confirmText:"Accept & upload",onCancel:i,onConfirm:k=>d([k])})))}function a(s){w(n.root,G({type:s,onPickFiles:s==="takephoto"?l:p,onCancel:i,maxDuration:n.maxDuration}))}function d(s){if(e.customProgress)n.root.remove(),n.uploader=e.upload({files:s,onProgress(){}}),n.uploader.promise.then(f=>o.resolve(f)).catch(o.reject);else{let f=W();w(n.root,f),n.uploader=e.upload({files:s,onProgress(m,k){X(f,m,k)}}),n.uploader.promise.then(m=>{t=m,setTimeout(u,250)}).catch(o.reject)}return n.uploader}return o.cancel=u,n}function _(e={}){let t=xe(e);return document.body.appendChild(t.root),t.promise}module.exports=re(ye); | ||
var x=Object.defineProperty,J=Object.defineProperties,K=Object.getOwnPropertyDescriptor,Q=Object.getOwnPropertyDescriptors,Z=Object.getOwnPropertyNames,j=Object.getOwnPropertySymbols;var A=Object.prototype.hasOwnProperty,ee=Object.prototype.propertyIsEnumerable;var E=(e,t,o)=>t in e?x(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,b=(e,t)=>{for(var o in t||(t={}))A.call(t,o)&&E(e,o,t[o]);if(j)for(var o of j(t))ee.call(t,o)&&E(e,o,t[o]);return e},y=(e,t)=>J(e,Q(t));var te=(e,t)=>{for(var o in t)x(e,o,{get:t[o],enumerable:!0})},oe=(e,t,o,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Z(t))!A.call(e,n)&&n!==o&&x(e,n,{get:()=>t[n],enumerable:!(r=K(t,n))||r.enumerable});return e};var ne=e=>oe(x({},"__esModule",{value:!0}),e);var xe={};te(xe,{default:()=>_});module.exports=ne(xe);function U(){let e=!1,t,o,r=(i,u)=>{e||(e=!0,i(u))},n=new Promise((i,u)=>{t=i,o=u});return n.resolve=i=>r(t,i),n.reject=i=>r(o,i),n}function re(e){return e&&typeof e=="object"&&!Array.isArray(e)&&!(e instanceof NodeList)&&!(e instanceof Node)&&!(e.el instanceof Node)}function ie(e){return!!e.forEach}function h(e,t,o,r){return e.addEventListener(t,o,r),()=>e.removeEventListener(t,o,r)}function g(e){return c("div",{innerHTML:e}).firstChild}function c(e,...t){let o=e.split("."),r=o[0],n=o.slice(1),i=r==="svg"?document.createElementNS("http://www.w3.org/2000/svg","svg"):document.createElement(r||"div");r==="svg"&&i.setAttribute("xmlns","http://www.w3.org/2000/svg");let u=t[0],l=re(u)&&u;return n.length&&(i.className=n.join(" ")),ae(l,i),ce(l?t.slice(1):t,i),i}function ae(e,t){return t&&e&&Object.keys(e).forEach(o=>{let r=e[o];if(o==="class"||o==="className"){let n=r&&r.split(" ");n&&n.length&&t.classList.add(...n)}else o==="innerHTML"||o==="textContent"||typeof r=="function"||o.startsWith("$")?t[o]=r:r!==!1&&r!==void 0&&r!==null&&t.setAttribute(o,r)}),t}function ce(e,t){return t.appendChild(z(e)),t}function z(e,t){return t||(t=document.createDocumentFragment()),e instanceof Node||typeof e=="string"?se(e,t):(ie(e)&&Array.from(e).forEach(o=>o&&z(o,t)),t)}function se(e,t){if(!e)return t;let o=typeof e=="string"?document.createTextNode(e):e;return t instanceof Range?(t.insertNode(o),t.collapse()):t instanceof Node&&t.appendChild(o),t}var q=()=>g('<svg fill="currentColor" viewBox="0 0 24 24"><path d="M5 4h-3v-1h3v1zm10.93 0l.812 1.219c.743 1.115 1.987 1.781 3.328 1.781h1.93v13h-20v-13h3.93c1.341 0 2.585-.666 3.328-1.781l.812-1.219h5.86zm1.07-2h-8l-1.406 2.109c-.371.557-.995.891-1.664.891h-5.93v17h24v-17h-3.93c-.669 0-1.293-.334-1.664-.891l-1.406-2.109zm-11 8c0-.552-.447-1-1-1s-1 .448-1 1 .447 1 1 1 1-.448 1-1zm7 0c1.654 0 3 1.346 3 3s-1.346 3-3 3-3-1.346-3-3 1.346-3 3-3zm0-2c-2.761 0-5 2.239-5 5s2.239 5 5 5 5-2.239 5-5-2.239-5-5-5z" /></svg>'),M=()=>g('<svg fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 10l4.553-2.276A1 1 0 0121 8.618v6.764a1 1 0 01-1.447.894L15 14M5 18h8a2 2 0 002-2V8a2 2 0 00-2-2H5a2 2 0 00-2 2v8a2 2 0 002 2z" /></svg>'),C=()=>g('<svg fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 11a7 7 0 01-7 7m0 0a7 7 0 01-7-7m7 7v4m0 0H8m4 0h4m-4-8a3 3 0 01-3-3V5a3 3 0 116 0v6a3 3 0 01-3 3z" /></svg>');(function(){if(window.ImageCapture)return;let t=document.createElement("script");t.src="https://unpkg.com/image-capture@0.4.0/lib/imagecapture.min.js",document.head.appendChild(t)})();function N(e){let t=!!window.MediaRecorder;return{filepicker:!0,takephoto:e.includes("takephoto")&&!!(navigator.mediaDevices&&navigator.mediaDevices.getUserMedia),takevideo:e.includes("takevideo")&&t,takeaudio:e.includes("takeaudio")&&t}}function F(e){let o=(e.video?["video/mp4","video/mpeg","video/webm"]:["audio/mpeg","audio/webm","audio/ogg","audio/wav","audio/mp3","audio/mp4"]).filter(r=>MediaRecorder.isTypeSupported(r))[0];if(!o)throw new Error("No supported mime type found.");return o}function I(e){return e.name=`your${e.type.replace("/",".")}`,e}function O(e){let t=[],o,r;function n(a){a.data.size>0?t.push(a.data):console.error("No data",a)}function i(){return o}function u(){let a=o.getVideoTracks()[0];return new ImageCapture(a).takePhoto().then(I)}function l(){t=[],r=new MediaRecorder(o,{mimeType:F(e)}),r.ondataavailable=n,r.start()}function p(){return new Promise((a,d)=>{r.onstop=()=>{e.isDisposed()&&d(new Error("Disposed."));try{let s=new Blob(t,{type:F(e)});a(I(s))}catch(s){d(s)}},r.stop()})}return setTimeout(function a(){if(e.isDisposed()){r&&r.state!=="inactive"&&r.stop();return}setTimeout(a,1e3)},1e3),navigator.mediaDevices.getUserMedia(e).then(a=>(o=a,{liveSrc:i,capturePhoto:u,beginMediaCapture:l,endMediaCapture:p}))}function R(e){let t=e.onPickFiles,o=e.accept,r=e.sources,n=e.beginCaptureMedia,i=N(r),u=(p,a,d)=>i[p]&&c("button.quik-footer-btn.quik-main-footer-btn",{onclick(s){s.preventDefault(),n(p)}},a(),d),l=c("label.quik-drop-target.quik-content",{ondragover(p){p.preventDefault(),l.classList.add("quik-drop-target-active")},ondragleave(){l.classList.remove("quik-drop-target-active")},ondrop(p){p.preventDefault(),p.stopPropagation();let a=p.dataTransfer.files;!e.multiple&&a.length>1&&(a=[a[0]]),t(a)}},c("input.quik-file-input",{type:"file",accept:o,multiple:e.multiple,onchange(p){t(p.target.files)}}),g('<svg class="quik-icon" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 16a4 4 0 01-.88-7.903A5 5 0 1115.9 6L16 6a5 5 0 011 9.9M15 13l-3-3m0 0l-3 3m3-3v12" /></svg>'),c("h2.quik-header","Upload a file"),c(".quik-instructions",c("span.quik-text","Drag or paste a file here, or choose an option below."),c("footer.quik-footer",c("span.quik-footer-btn.quik-footer-btn-primary",g('<svg fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z" /></svg>'),"Choose File"),u("takephoto",q,"Take Photo"),u("takevideo",M,"Record Video"),u("takeaudio",C,"Record Audio"))));return l}function S(e){let t=e.close;return c(".quikpik",{onmousedown:t,ontouchstart:t},c("div.quik-body",{onmousedown(r){r.stopPropagation()},ontouchstart(r){r.stopPropagation()}},R(e)))}function w(e,t){e.querySelector(".quik-body").firstChild.replaceWith(t)}function W(){return c(".quik-progress",c("span.quik-progress-text",c("span.quik-filename","Uploading..."),c("span.quik-percent","0%")),c("span.quik-progress-bar-wrapper",c("span.quik-progress-bar",{style:"width: 0%"})))}function X(e,t,o){let r=e.querySelector(".quik-progress-bar");e.querySelector(".quik-filename").textContent=`Uploading ${o}`,e.querySelector(".quik-percent").textContent=Math.round(t)+"%",r.style.width=t+"%",t>=100&&r.classList.add("quik-done-bar")}function Y(e,t,o,r){let n=0,i=!1,u=new Image;function l(){let a=o.width;o.width=o.height,o.height=a}function p(a,d,s){if(!d||!i)return;let f=d.getContext("2d");f.translate(d.width/2,d.height/2),f.rotate(s*Math.PI/180),f.drawImage(a,-a.width/2,-a.height/2),f.rotate(-s*Math.PI/180),f.translate(-d.width/2,-d.height/2)}return u.addEventListener("load",()=>{i=!0,o.width=u.width,o.height=u.height,p(u,o,n),r()}),u.addEventListener("error",()=>alert("Failed to load image.")),u.src=e,{save(a="image/png",d=void 0){return n?new Promise(s=>o.toBlob(f=>{f.name=t&&t.name,s(f)},a,d)):Promise.resolve(t)},rotate(){n=(n+90)%360,l(),p(u,o,n)}}}var T=32,P=32;function ue(e){let t=e.image,o=e.cropBounds,r=e.scale,n=c("canvas");return n.width=o.width*r,n.height=o.height*r,n.getContext("2d").drawImage(t,o.left*r,o.top*r,o.width*r,o.height*r,0,0,n.width,n.height),new Promise(u=>{n.toBlob(l=>{l.name=t.name,u(l)},"image/png")})}function de(e){let t=e.parentElement,o=c(".quik-crop");return t.appendChild(o),o}function L(e){let t=e.changedTouches&&e.changedTouches[0];return t&&(e.clientX=t.clientX,e.clientY=t.clientY),e}function $(e,t){e=L(e);let o=t.getBoundingClientRect(),r=Math.max(10,Math.floor(o.width/5)),n=Math.max(10,Math.floor(o.height/5)),i=e.clientX<o.left+n,u=e.clientX>o.right-r,l=e.clientY<o.top+n,p=e.clientY>o.bottom-n;return(l?"n":p?"s":"")+(u?"e":i?"w":"")||"move"}function le(e){let t=e.bounds,o=e.parentBounds,r=Math.max(o.top,t.top+e.deltaY),n=Math.max(o.left,t.left+e.deltaX);return r+t.height>o.bottom&&(r=o.bottom-t.height),n+t.width>o.right&&(n=o.right-t.width),{top:r,left:n}}function pe(e){let t=e.bounds,o=e.parentBounds,r=Math.min(o.right,t.left+t.width+e.deltaX),n=Math.max(P,r-t.left);if(!e.aspectRatio)return{width:n};let i=n*e.aspectRatio;return t.top+i>o.bottom&&(i=o.bottom-t.top,n=i/e.aspectRatio),{width:n,height:i}}function fe(e){let t=e.bounds,o=e.parentBounds,r=Math.min(o.bottom,t.top+t.height+e.deltaY),n=Math.max(T,r-t.top);if(!e.aspectRatio)return{height:n};let i=n/e.aspectRatio;return t.left+i>o.right&&(i=o.right-t.left,n=i*e.aspectRatio),{width:i,height:n}}function B(e){let t=e.bounds,o=e.parentBounds,r=Math.max(o.left,t.left+e.deltaX),n=t.right-r;if(n<P&&(r-=P-n,n=P),!e.aspectRatio)return{left:r,width:n};let i=n*e.aspectRatio;return t.top+i>o.bottom&&(i=o.bottom-t.top,n=i/e.aspectRatio,r=t.right-n),{left:r,width:n,height:i}}function me(e){let t=e.bounds,o=e.parentBounds,r=Math.max(o.top,t.top+e.deltaY),n=t.bottom-r;if(n<T&&(r-=T-n,n=T),!e.aspectRatio)return{top:r,height:n};let i=n/e.aspectRatio;return t.left+i>o.right&&(i=o.right-t.left,n=i*e.aspectRatio,r=t.bottom-n),{width:i,height:n,top:r}}function he(e){let t={};return e.direction==="sw"&&e.aspectRatio?B(e):e.direction==="nw"&&e.aspectRatio?(t=B(e,"n"),t.top=e.bounds.bottom-t.height,t):(e.direction.includes("s")&&(Object.assign(t,fe(e)),e.aspectRatio)||e.direction.includes("n")&&(Object.assign(t,me(e)),e.aspectRatio)||(e.direction.includes("w")&&Object.assign(t,B(e)),e.direction.includes("e")&&Object.assign(t,pe(e))),t)}function ge(e,t,o,r,n){let i=t.getBoundingClientRect(),u=e.clientX,l=e.clientY,p={direction:n,aspectRatio:o,parentBounds:i,bounds:r.getBoundingClientRect(),deltaY:0,deltaX:0,applyEvent(a){a=L(a),p.deltaX=a.clientX-u,p.deltaY=a.clientY-l},resize(a){a.top&&(a.top=a.top-i.top),a.left&&(a.left=a.left-i.left),Object.keys(a).forEach(d=>{r.style[d]=Math.round(a[d])+"px"})}};return p}function D(e,t){let o=de(e),r=!1;h(o,"mousedown",n),h(o,"touchstart",n),h(o,"mousemove",i=>{if(!i.buttons){let u=$(i,o);o.style.cursor=u==="move"?"grabbing":u+"-resize"}});function n(i){if(i.preventDefault(),i=L(i),r)return;r=!0;let u=$(i,o),l=ge(i,e,t,o,u),p=[];function a(s){l.applyEvent(s),l.resize(u==="move"?le(l):he(l))}function d(){r=!1,p.forEach(s=>s())}p=[h(document,"mousemove",a),h(document,"touchmove",a),h(document,"mouseup",d),h(document,"touchend",d),h(document,"touchcancel",d)]}return{el:o,dispose(){o.remove()},apply(i){return ue({image:i,cropBounds:{top:o.offsetTop-e.offsetTop,left:o.offsetLeft-e.offsetLeft,width:o.offsetWidth,height:o.offsetHeight},scale:i.naturalWidth/e.offsetWidth})}}}function ke(e,t){let o=new Image;return new Promise(r=>{o.onload=()=>{r(t(o)),URL.revokeObjectURL(o.src)},o.src=URL.createObjectURL(e)})}function V(e){let t=e.url,o=e.file,r=e.cancelText,n=e.confirmText,i=e.onCancel,u=e.onConfirm,l=e.requireCrop,p=e.cropRatio,a,d=c(".quik-content-wrapper",c(".quik-text","Loading...")),s=c("canvas.quik-confirm-item"),f=c(".quik-content",s),m=Y(t,o,s,()=>{a=l?D(s,p):void 0,d.appendChild(c("footer.quik-footer",c("button.quik-footer-btn",{onclick:i},r),!l&&c("button.quik-footer-btn",{onclick(){a?(a.dispose(),a=void 0):a=D(s,p)}},g('<svg width="24" height="24" viewBox="0 0 24 24" fill="currentColor"><path d="M24 18h-4v-14h-14v-4h-2v4h-4v2h4v14h14v4h2v-4h4v-2zm-18 0v-12h12v12h-12z"/></svg>'),"Crop"),c("button.quik-footer-btn",{onclick:m.rotate},g('<svg viewBox="0 0 24 24" fill="currentColor"><path d="M12 0c3.31 0 6.291 1.353 8.459 3.522l2.48-2.48 1.061 7.341-7.437-.966 2.489-2.489c-1.808-1.807-4.299-2.928-7.052-2.928-5.514 0-10 4.486-10 10s4.486 10 10 10c3.872 0 7.229-2.216 8.89-5.443l1.717 1.046c-2.012 3.803-6.005 6.397-10.607 6.397-6.627 0-12-5.373-12-12s5.373-12 12-12z" /></svg>')," Rotate"),c("button.quik-footer-btn.quik-footer-btn-primary",{onclick(k){k.target.disabled=!0,m.save().then(v=>a?ke(v,a.apply):v).then(v=>{v.name||(v.name=o.name),u(v)})}},n))),d.firstChild.replaceWith(f)});return d}function H(e){let t=e.url,o=e.file,r=e.cancelText,n=e.confirmText,i=e.onCancel,u=e.onConfirm,l=o.type.startsWith("video/")?c("video.quik-vid.quik-content",{src:t,controls:!0}):c("audio",{src:t,controls:!0});return c(".quik-content-wrapper",c(".quik-confirm-item",l),c("footer.quik-footer",c("button.quik-footer-btn",{onclick:i},r),c("button.quik-footer-btn.quik-footer-btn-primary",{onclick(p){p.target.disabled=!0,u(o)}},n)))}var ve=10;function we(e){let t=c("video.quik-vid.quik-content");return t.srcObject=e.recorder.liveSrc(),t.muted=!0,t.controls=!1,t.play(),t}function be(e,t,o){let r=Date.now(),n=t*60,i=d=>`${Math.floor(d/60)}:${`00${d%60}`.slice(-2)} / ${t}:00`,u,l=c("span.quik-progress-bar",{style:"width: 0%"}),p=c("span.quik-duration",i(0)),a=c(".quik-progress",c("span.quik-progress-text",c("span.quik-filename",e),p),c("span.quik-progress-bar-wrapper",l));return u=setTimeout(function d(){let s=Math.floor((Date.now()-r)/1e3);if(p.textContent=i(s),l.style.width=`${Math.floor(s*100/n)}%`,s>=n){o();return}a.isConnected&&setTimeout(d,1e3)},1e3),a}function G(e){let t=e.onPickFiles,o=e.maxDuration||ve,r=e.onCancel;type=e.type;let n,i=c("p.quik-info.quik-content",`Waiting for your ${type==="takeaudio"?"microphone":"camera"}...`),u=c("footer.quik-footer",c("button.quik-footer-btn.quik-footer-btn-secondary",{onclick:r},"Cancel")),l=c(".quik-media",i,u),p=()=>!l.isConnected,a=d=>i.replaceWith(c("p.quik-error",d.toString()));return O({video:type!=="takeaudio",audio:type!=="takephoto",isDisposed:p}).then(d=>{let s=()=>{i.textContent="Generating preview...",n&&n.remove(),(type==="takephoto"?d.capturePhoto():d.endMediaCapture()).then(m=>t([m])).catch(a)};i.textContent=type==="takephoto"?"":`Ready to record. You can record up to ${o} minutes of ${type==="takeaudio"?"audio":"video"}.`,type!=="takeaudio"&&l.insertBefore(we({recorder:d,onPickFiles:t,onError:a}),i),u.appendChild(c("button.quik-footer-btn.quik-footer-btn-primary",{onclick(f){type==="takephoto"||n?(f.target.disabled=!0,s()):(d.beginMediaCapture(),n=be("Recording...",o,s),i.textContent="",l.insertBefore(n,u),f.target.innerHTML="",f.target.append(C(),c("span","Stop recording")))}},type==="takephoto"?q():type==="takeaudio"?C():M(),type==="takephoto"?"Take Photo":"Begin Recording"))}).catch(a),l}function Ce(e){e=b({sources:["filepicker","takephoto"]},e);let t,o=U(),r=[h(window,"keydown",s=>{(s.key==="Escape"||s.code==="Escape")&&u()}),h(document.body,"paste",s=>{s.clipboardData&&s.clipboardData.files&&s.clipboardData.files.length&&(s.preventDefault(),l(s.clipboardData.files))})],n=y(b({},e),{close:u,uploadFiles:d,onPickFiles:l,beginCaptureMedia:a,promise:o,root:void 0,uploader:void 0});n.root=S(n);function i(){w(n.root,R({onPickFiles:l,beginCaptureMedia:a,accept:n.accept,sources:n.sources}))}function u(){o.resolve(t),n.root.remove(),r.forEach(s=>s()),n.uploader&&(n.uploader.cancel(),n.uploader=void 0)}function l(s){let f=s.length===1?s[0]:void 0;if(f&&f.type!=="image/gif"&&!f.type.startsWith("image/svg")&&f.type.startsWith("image/")){let m=URL.createObjectURL(f);r.push(()=>URL.revokeObjectURL(m)),w(n.root,V(y(b({},e),{url:m,file:f,cancelText:"Cancel",confirmText:"Accept & upload",onCancel:i,onConfirm:k=>d([k])})));return}d(s)}function p(s){let f=s[0],m=URL.createObjectURL(f);r.push(()=>URL.revokeObjectURL(m)),w(n.root,H(y(b({},e),{url:m,file:f,cancelText:"Cancel",confirmText:"Accept & upload",onCancel:i,onConfirm:k=>d([k])})))}function a(s){w(n.root,G({type:s,onPickFiles:s==="takephoto"?l:p,onCancel:i,maxDuration:n.maxDuration}))}function d(s){if(e.customProgress)n.root.remove(),n.uploader=e.upload({files:s,onProgress(){}}),n.uploader.promise.then(f=>o.resolve(f)).catch(o.reject);else{let f=W();w(n.root,f),n.uploader=e.upload({files:s,onProgress(m,k){X(f,m,k)}}),n.uploader.promise.then(m=>{t=m,setTimeout(u,250)}).catch(o.reject)}return n.uploader}return o.cancel=u,n}function _(e={}){let t=Ce(e);return document.body.appendChild(t.root),t.promise} |
@@ -1,1 +0,1 @@ | ||
var quikpik=(()=>{var x=Object.defineProperty,J=Object.defineProperties,K=Object.getOwnPropertyDescriptor,Q=Object.getOwnPropertyDescriptors,Z=Object.getOwnPropertyNames,j=Object.getOwnPropertySymbols;var E=Object.prototype.hasOwnProperty,ee=Object.prototype.propertyIsEnumerable;var A=(e,t,o)=>t in e?x(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,b=(e,t)=>{for(var o in t||(t={}))E.call(t,o)&&A(e,o,t[o]);if(j)for(var o of j(t))ee.call(t,o)&&A(e,o,t[o]);return e},y=(e,t)=>J(e,Q(t)),te=e=>x(e,"__esModule",{value:!0});var oe=(e,t)=>{for(var o in t)x(e,o,{get:t[o],enumerable:!0})},ne=(e,t,o,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Z(t))!E.call(e,n)&&(o||n!=="default")&&x(e,n,{get:()=>t[n],enumerable:!(r=K(t,n))||r.enumerable});return e};var re=(e=>(t,o)=>e&&e.get(t)||(o=ne(te({}),t,1),e&&e.set(t,o),o))(typeof WeakMap!="undefined"?new WeakMap:0);var ye={};oe(ye,{default:()=>_});function U(){let e=!1,t,o,r=(i,u)=>{e||(e=!0,i(u))},n=new Promise((i,u)=>{t=i,o=u});return n.resolve=i=>r(t,i),n.reject=i=>r(o,i),n}function ie(e){return e&&typeof e=="object"&&!Array.isArray(e)&&!(e instanceof NodeList)&&!(e instanceof Node)&&!(e.el instanceof Node)}function ae(e){return!!e.forEach}function h(e,t,o,r){return e.addEventListener(t,o,r),()=>e.removeEventListener(t,o,r)}function g(e){return c("div",{innerHTML:e}).firstChild}function c(e,...t){let o=e.split("."),r=o[0],n=o.slice(1),i=r==="svg"?document.createElementNS("http://www.w3.org/2000/svg","svg"):document.createElement(r||"div");r==="svg"&&i.setAttribute("xmlns","http://www.w3.org/2000/svg");let u=t[0],l=ie(u)&&u;return n.length&&(i.className=n.join(" ")),ce(l,i),se(l?t.slice(1):t,i),i}function ce(e,t){return t&&e&&Object.keys(e).forEach(o=>{let r=e[o];if(o==="class"||o==="className"){let n=r&&r.split(" ");n&&n.length&&t.classList.add(...n)}else o==="innerHTML"||o==="textContent"||typeof r=="function"||o.startsWith("$")?t[o]=r:r!==!1&&r!==void 0&&r!==null&&t.setAttribute(o,r)}),t}function se(e,t){return t.appendChild(z(e)),t}function z(e,t){return t||(t=document.createDocumentFragment()),e instanceof Node||typeof e=="string"?ue(e,t):(ae(e)&&Array.from(e).forEach(o=>o&&z(o,t)),t)}function ue(e,t){if(!e)return t;let o=typeof e=="string"?document.createTextNode(e):e;return t instanceof Range?(t.insertNode(o),t.collapse()):t instanceof Node&&t.appendChild(o),t}var q=()=>g('<svg fill="currentColor" viewBox="0 0 24 24"><path d="M5 4h-3v-1h3v1zm10.93 0l.812 1.219c.743 1.115 1.987 1.781 3.328 1.781h1.93v13h-20v-13h3.93c1.341 0 2.585-.666 3.328-1.781l.812-1.219h5.86zm1.07-2h-8l-1.406 2.109c-.371.557-.995.891-1.664.891h-5.93v17h24v-17h-3.93c-.669 0-1.293-.334-1.664-.891l-1.406-2.109zm-11 8c0-.552-.447-1-1-1s-1 .448-1 1 .447 1 1 1 1-.448 1-1zm7 0c1.654 0 3 1.346 3 3s-1.346 3-3 3-3-1.346-3-3 1.346-3 3-3zm0-2c-2.761 0-5 2.239-5 5s2.239 5 5 5 5-2.239 5-5-2.239-5-5-5z" /></svg>'),M=()=>g('<svg fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 10l4.553-2.276A1 1 0 0121 8.618v6.764a1 1 0 01-1.447.894L15 14M5 18h8a2 2 0 002-2V8a2 2 0 00-2-2H5a2 2 0 00-2 2v8a2 2 0 002 2z" /></svg>'),C=()=>g('<svg fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 11a7 7 0 01-7 7m0 0a7 7 0 01-7-7m7 7v4m0 0H8m4 0h4m-4-8a3 3 0 01-3-3V5a3 3 0 116 0v6a3 3 0 01-3 3z" /></svg>');(function(){if(window.ImageCapture)return;let t=document.createElement("script");t.src="https://unpkg.com/image-capture@0.4.0/lib/imagecapture.min.js",document.head.appendChild(t)})();function F(e){let t=!!window.MediaRecorder;return{filepicker:!0,takephoto:e.includes("takephoto")&&!!(navigator.mediaDevices&&navigator.mediaDevices.getUserMedia),takevideo:e.includes("takevideo")&&t,takeaudio:e.includes("takeaudio")&&t}}function I(e){let o=(e.video?["video/mp4","video/mpeg","video/webm"]:["audio/mpeg","audio/webm","audio/ogg","audio/wav","audio/mp3","audio/mp4"]).filter(r=>MediaRecorder.isTypeSupported(r))[0];if(!o)throw new Error("No supported mime type found.");return o}function N(e){return e.name=`your${e.type.replace("/",".")}`,e}function O(e){let t=[],o,r;function n(a){a.data.size>0?t.push(a.data):console.error("No data",a)}function i(){return o}function u(){let a=o.getVideoTracks()[0];return new ImageCapture(a).takePhoto().then(N)}function l(){t=[],r=new MediaRecorder(o,{mimeType:I(e)}),r.ondataavailable=n,r.start()}function p(){return new Promise((a,d)=>{r.onstop=()=>{e.isDisposed()&&d(new Error("Disposed."));try{let s=new Blob(t,{type:I(e)});a(N(s))}catch(s){d(s)}},r.stop()})}return setTimeout(function a(){if(e.isDisposed()){r&&r.state!=="inactive"&&r.stop();return}setTimeout(a,1e3)},1e3),navigator.mediaDevices.getUserMedia(e).then(a=>(o=a,{liveSrc:i,capturePhoto:u,beginMediaCapture:l,endMediaCapture:p}))}function R(e){let t=e.onPickFiles,o=e.accept,r=e.sources,n=e.beginCaptureMedia,i=F(r),u=(p,a,d)=>i[p]&&c("button.quik-footer-btn.quik-main-footer-btn",{onclick(s){s.preventDefault(),n(p)}},a(),d),l=c("label.quik-drop-target.quik-content",{ondragover(p){p.preventDefault(),l.classList.add("quik-drop-target-active")},ondragleave(){l.classList.remove("quik-drop-target-active")},ondrop(p){p.preventDefault(),p.stopPropagation();let a=p.dataTransfer.files;!e.multiple&&a.length>1&&(a=[a[0]]),t(a)}},c("input.quik-file-input",{type:"file",accept:o,multiple:e.multiple,onchange(p){t(p.target.files)}}),g('<svg class="quik-icon" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 16a4 4 0 01-.88-7.903A5 5 0 1115.9 6L16 6a5 5 0 011 9.9M15 13l-3-3m0 0l-3 3m3-3v12" /></svg>'),c("h2.quik-header","Upload a file"),c(".quik-instructions",c("span.quik-text","Drag or paste a file here, or choose an option below."),c("footer.quik-footer",c("span.quik-footer-btn.quik-footer-btn-primary",g('<svg fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z" /></svg>'),"Choose File"),u("takephoto",q,"Take Photo"),u("takevideo",M,"Record Video"),u("takeaudio",C,"Record Audio"))));return l}function S(e){let t=e.close;return c(".quikpik",{onmousedown:t,ontouchstart:t},c("div.quik-body",{onmousedown(r){r.stopPropagation()},ontouchstart(r){r.stopPropagation()}},R(e)))}function w(e,t){e.querySelector(".quik-body").firstChild.replaceWith(t)}function W(){return c(".quik-progress",c("span.quik-progress-text",c("span.quik-filename","Uploading..."),c("span.quik-percent","0%")),c("span.quik-progress-bar-wrapper",c("span.quik-progress-bar",{style:"width: 0%"})))}function X(e,t,o){let r=e.querySelector(".quik-progress-bar");e.querySelector(".quik-filename").textContent=`Uploading ${o}`,e.querySelector(".quik-percent").textContent=Math.round(t)+"%",r.style.width=t+"%",t>=100&&r.classList.add("quik-done-bar")}function Y(e,t,o,r){let n=0,i=!1,u=new Image;function l(){let a=o.width;o.width=o.height,o.height=a}function p(a,d,s){if(!d||!i)return;let f=d.getContext("2d");f.translate(d.width/2,d.height/2),f.rotate(s*Math.PI/180),f.drawImage(a,-a.width/2,-a.height/2),f.rotate(-s*Math.PI/180),f.translate(-d.width/2,-d.height/2)}return u.addEventListener("load",()=>{i=!0,o.width=u.width,o.height=u.height,p(u,o,n),r()}),u.addEventListener("error",()=>alert("Failed to load image.")),u.src=e,{save(a="image/png",d=void 0){return n?new Promise(s=>o.toBlob(f=>{f.name=t&&t.name,s(f)},a,d)):Promise.resolve(t)},rotate(){n=(n+90)%360,l(),p(u,o,n)}}}var T=32,P=32;function de(e){let t=e.image,o=e.cropBounds,r=e.scale,n=c("canvas");return n.width=o.width*r,n.height=o.height*r,n.getContext("2d").drawImage(t,o.left*r,o.top*r,o.width*r,o.height*r,0,0,n.width,n.height),new Promise(u=>{n.toBlob(l=>{l.name=t.name,u(l)},"image/png")})}function le(e){let t=e.parentElement,o=c(".quik-crop");return t.appendChild(o),o}function B(e){let t=e.changedTouches&&e.changedTouches[0];return t&&(e.clientX=t.clientX,e.clientY=t.clientY),e}function $(e,t){e=B(e);let o=t.getBoundingClientRect(),r=Math.max(10,Math.floor(o.width/5)),n=Math.max(10,Math.floor(o.height/5)),i=e.clientX<o.left+n,u=e.clientX>o.right-r,l=e.clientY<o.top+n,p=e.clientY>o.bottom-n;return(l?"n":p?"s":"")+(u?"e":i?"w":"")||"move"}function pe(e){let t=e.bounds,o=e.parentBounds,r=Math.max(o.top,t.top+e.deltaY),n=Math.max(o.left,t.left+e.deltaX);return r+t.height>o.bottom&&(r=o.bottom-t.height),n+t.width>o.right&&(n=o.right-t.width),{top:r,left:n}}function fe(e){let t=e.bounds,o=e.parentBounds,r=Math.min(o.right,t.left+t.width+e.deltaX),n=Math.max(P,r-t.left);if(!e.aspectRatio)return{width:n};let i=n*e.aspectRatio;return t.top+i>o.bottom&&(i=o.bottom-t.top,n=i/e.aspectRatio),{width:n,height:i}}function me(e){let t=e.bounds,o=e.parentBounds,r=Math.min(o.bottom,t.top+t.height+e.deltaY),n=Math.max(T,r-t.top);if(!e.aspectRatio)return{height:n};let i=n/e.aspectRatio;return t.left+i>o.right&&(i=o.right-t.left,n=i*e.aspectRatio),{width:i,height:n}}function L(e){let t=e.bounds,o=e.parentBounds,r=Math.max(o.left,t.left+e.deltaX),n=t.right-r;if(n<P&&(r-=P-n,n=P),!e.aspectRatio)return{left:r,width:n};let i=n*e.aspectRatio;return t.top+i>o.bottom&&(i=o.bottom-t.top,n=i/e.aspectRatio,r=t.right-n),{left:r,width:n,height:i}}function he(e){let t=e.bounds,o=e.parentBounds,r=Math.max(o.top,t.top+e.deltaY),n=t.bottom-r;if(n<T&&(r-=T-n,n=T),!e.aspectRatio)return{top:r,height:n};let i=n/e.aspectRatio;return t.left+i>o.right&&(i=o.right-t.left,n=i*e.aspectRatio,r=t.bottom-n),{width:i,height:n,top:r}}function ge(e){let t={};return e.direction==="sw"&&e.aspectRatio?L(e):e.direction==="nw"&&e.aspectRatio?(t=L(e,"n"),t.top=e.bounds.bottom-t.height,t):(e.direction.includes("s")&&(Object.assign(t,me(e)),e.aspectRatio)||e.direction.includes("n")&&(Object.assign(t,he(e)),e.aspectRatio)||(e.direction.includes("w")&&Object.assign(t,L(e)),e.direction.includes("e")&&Object.assign(t,fe(e))),t)}function ke(e,t,o,r,n){let i=t.getBoundingClientRect(),u=e.clientX,l=e.clientY,p={direction:n,aspectRatio:o,parentBounds:i,bounds:r.getBoundingClientRect(),deltaY:0,deltaX:0,applyEvent(a){a=B(a),p.deltaX=a.clientX-u,p.deltaY=a.clientY-l},resize(a){a.top&&(a.top=a.top-i.top),a.left&&(a.left=a.left-i.left),Object.keys(a).forEach(d=>{r.style[d]=Math.round(a[d])+"px"})}};return p}function D(e,t){let o=le(e),r=!1;h(o,"mousedown",n),h(o,"touchstart",n),h(o,"mousemove",i=>{if(!i.buttons){let u=$(i,o);o.style.cursor=u==="move"?"grabbing":u+"-resize"}});function n(i){if(i.preventDefault(),i=B(i),r)return;r=!0;let u=$(i,o),l=ke(i,e,t,o,u),p=[];function a(s){l.applyEvent(s),l.resize(u==="move"?pe(l):ge(l))}function d(){r=!1,p.forEach(s=>s())}p=[h(document,"mousemove",a),h(document,"touchmove",a),h(document,"mouseup",d),h(document,"touchend",d),h(document,"touchcancel",d)]}return{el:o,dispose(){o.remove()},apply(i){return de({image:i,cropBounds:{top:o.offsetTop-e.offsetTop,left:o.offsetLeft-e.offsetLeft,width:o.offsetWidth,height:o.offsetHeight},scale:i.naturalWidth/e.offsetWidth})}}}function ve(e,t){let o=new Image;return new Promise(r=>{o.onload=()=>{r(t(o)),URL.revokeObjectURL(o.src)},o.src=URL.createObjectURL(e)})}function V(e){let t=e.url,o=e.file,r=e.cancelText,n=e.confirmText,i=e.onCancel,u=e.onConfirm,l=e.requireCrop,p=e.cropRatio,a,d=c(".quik-content-wrapper",c(".quik-text","Loading...")),s=c("canvas.quik-confirm-item"),f=c(".quik-content",s),m=Y(t,o,s,()=>{a=l?D(s,p):void 0,d.appendChild(c("footer.quik-footer",c("button.quik-footer-btn",{onclick:i},r),!l&&c("button.quik-footer-btn",{onclick(){a?(a.dispose(),a=void 0):a=D(s,p)}},g('<svg width="24" height="24" viewBox="0 0 24 24" fill="currentColor"><path d="M24 18h-4v-14h-14v-4h-2v4h-4v2h4v14h14v4h2v-4h4v-2zm-18 0v-12h12v12h-12z"/></svg>'),"Crop"),c("button.quik-footer-btn",{onclick:m.rotate},g('<svg viewBox="0 0 24 24" fill="currentColor"><path d="M12 0c3.31 0 6.291 1.353 8.459 3.522l2.48-2.48 1.061 7.341-7.437-.966 2.489-2.489c-1.808-1.807-4.299-2.928-7.052-2.928-5.514 0-10 4.486-10 10s4.486 10 10 10c3.872 0 7.229-2.216 8.89-5.443l1.717 1.046c-2.012 3.803-6.005 6.397-10.607 6.397-6.627 0-12-5.373-12-12s5.373-12 12-12z" /></svg>')," Rotate"),c("button.quik-footer-btn.quik-footer-btn-primary",{onclick(k){k.target.disabled=!0,m.save().then(v=>a?ve(v,a.apply):v).then(v=>{v.name||(v.name=o.name),u(v)})}},n))),d.firstChild.replaceWith(f)});return d}function H(e){let t=e.url,o=e.file,r=e.cancelText,n=e.confirmText,i=e.onCancel,u=e.onConfirm,l=o.type.startsWith("video/")?c("video.quik-vid.quik-content",{src:t,controls:!0}):c("audio",{src:t,controls:!0});return c(".quik-content-wrapper",c(".quik-confirm-item",l),c("footer.quik-footer",c("button.quik-footer-btn",{onclick:i},r),c("button.quik-footer-btn.quik-footer-btn-primary",{onclick(p){p.target.disabled=!0,u(o)}},n)))}var we=10;function be(e){let t=c("video.quik-vid.quik-content");return t.srcObject=e.recorder.liveSrc(),t.muted=!0,t.controls=!1,t.play(),t}function Ce(e,t,o){let r=Date.now(),n=t*60,i=d=>`${Math.floor(d/60)}:${`00${d%60}`.slice(-2)} / ${t}:00`,u,l=c("span.quik-progress-bar",{style:"width: 0%"}),p=c("span.quik-duration",i(0)),a=c(".quik-progress",c("span.quik-progress-text",c("span.quik-filename",e),p),c("span.quik-progress-bar-wrapper",l));return u=setTimeout(function d(){let s=Math.floor((Date.now()-r)/1e3);if(p.textContent=i(s),l.style.width=`${Math.floor(s*100/n)}%`,s>=n){o();return}a.isConnected&&setTimeout(d,1e3)},1e3),a}function G(e){let t=e.onPickFiles,o=e.maxDuration||we,r=e.onCancel;type=e.type;let n,i=c("p.quik-info.quik-content",`Waiting for your ${type==="takeaudio"?"microphone":"camera"}...`),u=c("footer.quik-footer",c("button.quik-footer-btn.quik-footer-btn-secondary",{onclick:r},"Cancel")),l=c(".quik-media",i,u),p=()=>!l.isConnected,a=d=>i.replaceWith(c("p.quik-error",d.toString()));return O({video:type!=="takeaudio",audio:type!=="takephoto",isDisposed:p}).then(d=>{let s=()=>{i.textContent="Generating preview...",n&&n.remove(),(type==="takephoto"?d.capturePhoto():d.endMediaCapture()).then(m=>t([m])).catch(a)};i.textContent=type==="takephoto"?"":`Ready to record. You can record up to ${o} minutes of ${type==="takeaudio"?"audio":"video"}.`,type!=="takeaudio"&&l.insertBefore(be({recorder:d,onPickFiles:t,onError:a}),i),u.appendChild(c("button.quik-footer-btn.quik-footer-btn-primary",{onclick(f){type==="takephoto"||n?(f.target.disabled=!0,s()):(d.beginMediaCapture(),n=Ce("Recording...",o,s),i.textContent="",l.insertBefore(n,u),f.target.innerHTML="",f.target.append(C(),c("span","Stop recording")))}},type==="takephoto"?q():type==="takeaudio"?C():M(),type==="takephoto"?"Take Photo":"Begin Recording"))}).catch(a),l}function xe(e){e=b({sources:["filepicker","takephoto"]},e);let t,o=U(),r=[h(window,"keydown",s=>{(s.key==="Escape"||s.code==="Escape")&&u()}),h(document.body,"paste",s=>{s.clipboardData&&s.clipboardData.files&&s.clipboardData.files.length&&(s.preventDefault(),l(s.clipboardData.files))})],n=y(b({},e),{close:u,uploadFiles:d,onPickFiles:l,beginCaptureMedia:a,promise:o,root:void 0,uploader:void 0});n.root=S(n);function i(){w(n.root,R({onPickFiles:l,beginCaptureMedia:a,accept:n.accept,sources:n.sources}))}function u(){o.resolve(t),n.root.remove(),r.forEach(s=>s()),n.uploader&&(n.uploader.cancel(),n.uploader=void 0)}function l(s){let f=s.length===1?s[0]:void 0;if(f&&f.type!=="image/gif"&&!f.type.startsWith("image/svg")&&f.type.startsWith("image/")){let m=URL.createObjectURL(f);r.push(()=>URL.revokeObjectURL(m)),w(n.root,V(y(b({},e),{url:m,file:f,cancelText:"Cancel",confirmText:"Accept & upload",onCancel:i,onConfirm:k=>d([k])})));return}d(s)}function p(s){let f=s[0],m=URL.createObjectURL(f);r.push(()=>URL.revokeObjectURL(m)),w(n.root,H(y(b({},e),{url:m,file:f,cancelText:"Cancel",confirmText:"Accept & upload",onCancel:i,onConfirm:k=>d([k])})))}function a(s){w(n.root,G({type:s,onPickFiles:s==="takephoto"?l:p,onCancel:i,maxDuration:n.maxDuration}))}function d(s){if(e.customProgress)n.root.remove(),n.uploader=e.upload({files:s,onProgress(){}}),n.uploader.promise.then(f=>o.resolve(f)).catch(o.reject);else{let f=W();w(n.root,f),n.uploader=e.upload({files:s,onProgress(m,k){X(f,m,k)}}),n.uploader.promise.then(m=>{t=m,setTimeout(u,250)}).catch(o.reject)}return n.uploader}return o.cancel=u,n}function _(e={}){let t=xe(e);return document.body.appendChild(t.root),t.promise}return re(ye);})(); | ||
var quikpik=(()=>{var x=Object.defineProperty,J=Object.defineProperties,K=Object.getOwnPropertyDescriptor,Q=Object.getOwnPropertyDescriptors,Z=Object.getOwnPropertyNames,j=Object.getOwnPropertySymbols;var A=Object.prototype.hasOwnProperty,ee=Object.prototype.propertyIsEnumerable;var E=(e,t,o)=>t in e?x(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,b=(e,t)=>{for(var o in t||(t={}))A.call(t,o)&&E(e,o,t[o]);if(j)for(var o of j(t))ee.call(t,o)&&E(e,o,t[o]);return e},y=(e,t)=>J(e,Q(t));var te=(e,t)=>{for(var o in t)x(e,o,{get:t[o],enumerable:!0})},oe=(e,t,o,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Z(t))!A.call(e,n)&&n!==o&&x(e,n,{get:()=>t[n],enumerable:!(r=K(t,n))||r.enumerable});return e};var ne=e=>oe(x({},"__esModule",{value:!0}),e);var xe={};te(xe,{default:()=>_});function U(){let e=!1,t,o,r=(i,u)=>{e||(e=!0,i(u))},n=new Promise((i,u)=>{t=i,o=u});return n.resolve=i=>r(t,i),n.reject=i=>r(o,i),n}function re(e){return e&&typeof e=="object"&&!Array.isArray(e)&&!(e instanceof NodeList)&&!(e instanceof Node)&&!(e.el instanceof Node)}function ie(e){return!!e.forEach}function h(e,t,o,r){return e.addEventListener(t,o,r),()=>e.removeEventListener(t,o,r)}function g(e){return c("div",{innerHTML:e}).firstChild}function c(e,...t){let o=e.split("."),r=o[0],n=o.slice(1),i=r==="svg"?document.createElementNS("http://www.w3.org/2000/svg","svg"):document.createElement(r||"div");r==="svg"&&i.setAttribute("xmlns","http://www.w3.org/2000/svg");let u=t[0],l=re(u)&&u;return n.length&&(i.className=n.join(" ")),ae(l,i),ce(l?t.slice(1):t,i),i}function ae(e,t){return t&&e&&Object.keys(e).forEach(o=>{let r=e[o];if(o==="class"||o==="className"){let n=r&&r.split(" ");n&&n.length&&t.classList.add(...n)}else o==="innerHTML"||o==="textContent"||typeof r=="function"||o.startsWith("$")?t[o]=r:r!==!1&&r!==void 0&&r!==null&&t.setAttribute(o,r)}),t}function ce(e,t){return t.appendChild(z(e)),t}function z(e,t){return t||(t=document.createDocumentFragment()),e instanceof Node||typeof e=="string"?se(e,t):(ie(e)&&Array.from(e).forEach(o=>o&&z(o,t)),t)}function se(e,t){if(!e)return t;let o=typeof e=="string"?document.createTextNode(e):e;return t instanceof Range?(t.insertNode(o),t.collapse()):t instanceof Node&&t.appendChild(o),t}var q=()=>g('<svg fill="currentColor" viewBox="0 0 24 24"><path d="M5 4h-3v-1h3v1zm10.93 0l.812 1.219c.743 1.115 1.987 1.781 3.328 1.781h1.93v13h-20v-13h3.93c1.341 0 2.585-.666 3.328-1.781l.812-1.219h5.86zm1.07-2h-8l-1.406 2.109c-.371.557-.995.891-1.664.891h-5.93v17h24v-17h-3.93c-.669 0-1.293-.334-1.664-.891l-1.406-2.109zm-11 8c0-.552-.447-1-1-1s-1 .448-1 1 .447 1 1 1 1-.448 1-1zm7 0c1.654 0 3 1.346 3 3s-1.346 3-3 3-3-1.346-3-3 1.346-3 3-3zm0-2c-2.761 0-5 2.239-5 5s2.239 5 5 5 5-2.239 5-5-2.239-5-5-5z" /></svg>'),M=()=>g('<svg fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 10l4.553-2.276A1 1 0 0121 8.618v6.764a1 1 0 01-1.447.894L15 14M5 18h8a2 2 0 002-2V8a2 2 0 00-2-2H5a2 2 0 00-2 2v8a2 2 0 002 2z" /></svg>'),C=()=>g('<svg fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 11a7 7 0 01-7 7m0 0a7 7 0 01-7-7m7 7v4m0 0H8m4 0h4m-4-8a3 3 0 01-3-3V5a3 3 0 116 0v6a3 3 0 01-3 3z" /></svg>');(function(){if(window.ImageCapture)return;let t=document.createElement("script");t.src="https://unpkg.com/image-capture@0.4.0/lib/imagecapture.min.js",document.head.appendChild(t)})();function N(e){let t=!!window.MediaRecorder;return{filepicker:!0,takephoto:e.includes("takephoto")&&!!(navigator.mediaDevices&&navigator.mediaDevices.getUserMedia),takevideo:e.includes("takevideo")&&t,takeaudio:e.includes("takeaudio")&&t}}function F(e){let o=(e.video?["video/mp4","video/mpeg","video/webm"]:["audio/mpeg","audio/webm","audio/ogg","audio/wav","audio/mp3","audio/mp4"]).filter(r=>MediaRecorder.isTypeSupported(r))[0];if(!o)throw new Error("No supported mime type found.");return o}function I(e){return e.name=`your${e.type.replace("/",".")}`,e}function O(e){let t=[],o,r;function n(a){a.data.size>0?t.push(a.data):console.error("No data",a)}function i(){return o}function u(){let a=o.getVideoTracks()[0];return new ImageCapture(a).takePhoto().then(I)}function l(){t=[],r=new MediaRecorder(o,{mimeType:F(e)}),r.ondataavailable=n,r.start()}function p(){return new Promise((a,d)=>{r.onstop=()=>{e.isDisposed()&&d(new Error("Disposed."));try{let s=new Blob(t,{type:F(e)});a(I(s))}catch(s){d(s)}},r.stop()})}return setTimeout(function a(){if(e.isDisposed()){r&&r.state!=="inactive"&&r.stop();return}setTimeout(a,1e3)},1e3),navigator.mediaDevices.getUserMedia(e).then(a=>(o=a,{liveSrc:i,capturePhoto:u,beginMediaCapture:l,endMediaCapture:p}))}function R(e){let t=e.onPickFiles,o=e.accept,r=e.sources,n=e.beginCaptureMedia,i=N(r),u=(p,a,d)=>i[p]&&c("button.quik-footer-btn.quik-main-footer-btn",{onclick(s){s.preventDefault(),n(p)}},a(),d),l=c("label.quik-drop-target.quik-content",{ondragover(p){p.preventDefault(),l.classList.add("quik-drop-target-active")},ondragleave(){l.classList.remove("quik-drop-target-active")},ondrop(p){p.preventDefault(),p.stopPropagation();let a=p.dataTransfer.files;!e.multiple&&a.length>1&&(a=[a[0]]),t(a)}},c("input.quik-file-input",{type:"file",accept:o,multiple:e.multiple,onchange(p){t(p.target.files)}}),g('<svg class="quik-icon" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 16a4 4 0 01-.88-7.903A5 5 0 1115.9 6L16 6a5 5 0 011 9.9M15 13l-3-3m0 0l-3 3m3-3v12" /></svg>'),c("h2.quik-header","Upload a file"),c(".quik-instructions",c("span.quik-text","Drag or paste a file here, or choose an option below."),c("footer.quik-footer",c("span.quik-footer-btn.quik-footer-btn-primary",g('<svg fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z" /></svg>'),"Choose File"),u("takephoto",q,"Take Photo"),u("takevideo",M,"Record Video"),u("takeaudio",C,"Record Audio"))));return l}function S(e){let t=e.close;return c(".quikpik",{onmousedown:t,ontouchstart:t},c("div.quik-body",{onmousedown(r){r.stopPropagation()},ontouchstart(r){r.stopPropagation()}},R(e)))}function w(e,t){e.querySelector(".quik-body").firstChild.replaceWith(t)}function W(){return c(".quik-progress",c("span.quik-progress-text",c("span.quik-filename","Uploading..."),c("span.quik-percent","0%")),c("span.quik-progress-bar-wrapper",c("span.quik-progress-bar",{style:"width: 0%"})))}function X(e,t,o){let r=e.querySelector(".quik-progress-bar");e.querySelector(".quik-filename").textContent=`Uploading ${o}`,e.querySelector(".quik-percent").textContent=Math.round(t)+"%",r.style.width=t+"%",t>=100&&r.classList.add("quik-done-bar")}function Y(e,t,o,r){let n=0,i=!1,u=new Image;function l(){let a=o.width;o.width=o.height,o.height=a}function p(a,d,s){if(!d||!i)return;let f=d.getContext("2d");f.translate(d.width/2,d.height/2),f.rotate(s*Math.PI/180),f.drawImage(a,-a.width/2,-a.height/2),f.rotate(-s*Math.PI/180),f.translate(-d.width/2,-d.height/2)}return u.addEventListener("load",()=>{i=!0,o.width=u.width,o.height=u.height,p(u,o,n),r()}),u.addEventListener("error",()=>alert("Failed to load image.")),u.src=e,{save(a="image/png",d=void 0){return n?new Promise(s=>o.toBlob(f=>{f.name=t&&t.name,s(f)},a,d)):Promise.resolve(t)},rotate(){n=(n+90)%360,l(),p(u,o,n)}}}var T=32,P=32;function ue(e){let t=e.image,o=e.cropBounds,r=e.scale,n=c("canvas");return n.width=o.width*r,n.height=o.height*r,n.getContext("2d").drawImage(t,o.left*r,o.top*r,o.width*r,o.height*r,0,0,n.width,n.height),new Promise(u=>{n.toBlob(l=>{l.name=t.name,u(l)},"image/png")})}function de(e){let t=e.parentElement,o=c(".quik-crop");return t.appendChild(o),o}function L(e){let t=e.changedTouches&&e.changedTouches[0];return t&&(e.clientX=t.clientX,e.clientY=t.clientY),e}function $(e,t){e=L(e);let o=t.getBoundingClientRect(),r=Math.max(10,Math.floor(o.width/5)),n=Math.max(10,Math.floor(o.height/5)),i=e.clientX<o.left+n,u=e.clientX>o.right-r,l=e.clientY<o.top+n,p=e.clientY>o.bottom-n;return(l?"n":p?"s":"")+(u?"e":i?"w":"")||"move"}function le(e){let t=e.bounds,o=e.parentBounds,r=Math.max(o.top,t.top+e.deltaY),n=Math.max(o.left,t.left+e.deltaX);return r+t.height>o.bottom&&(r=o.bottom-t.height),n+t.width>o.right&&(n=o.right-t.width),{top:r,left:n}}function pe(e){let t=e.bounds,o=e.parentBounds,r=Math.min(o.right,t.left+t.width+e.deltaX),n=Math.max(P,r-t.left);if(!e.aspectRatio)return{width:n};let i=n*e.aspectRatio;return t.top+i>o.bottom&&(i=o.bottom-t.top,n=i/e.aspectRatio),{width:n,height:i}}function fe(e){let t=e.bounds,o=e.parentBounds,r=Math.min(o.bottom,t.top+t.height+e.deltaY),n=Math.max(T,r-t.top);if(!e.aspectRatio)return{height:n};let i=n/e.aspectRatio;return t.left+i>o.right&&(i=o.right-t.left,n=i*e.aspectRatio),{width:i,height:n}}function B(e){let t=e.bounds,o=e.parentBounds,r=Math.max(o.left,t.left+e.deltaX),n=t.right-r;if(n<P&&(r-=P-n,n=P),!e.aspectRatio)return{left:r,width:n};let i=n*e.aspectRatio;return t.top+i>o.bottom&&(i=o.bottom-t.top,n=i/e.aspectRatio,r=t.right-n),{left:r,width:n,height:i}}function me(e){let t=e.bounds,o=e.parentBounds,r=Math.max(o.top,t.top+e.deltaY),n=t.bottom-r;if(n<T&&(r-=T-n,n=T),!e.aspectRatio)return{top:r,height:n};let i=n/e.aspectRatio;return t.left+i>o.right&&(i=o.right-t.left,n=i*e.aspectRatio,r=t.bottom-n),{width:i,height:n,top:r}}function he(e){let t={};return e.direction==="sw"&&e.aspectRatio?B(e):e.direction==="nw"&&e.aspectRatio?(t=B(e,"n"),t.top=e.bounds.bottom-t.height,t):(e.direction.includes("s")&&(Object.assign(t,fe(e)),e.aspectRatio)||e.direction.includes("n")&&(Object.assign(t,me(e)),e.aspectRatio)||(e.direction.includes("w")&&Object.assign(t,B(e)),e.direction.includes("e")&&Object.assign(t,pe(e))),t)}function ge(e,t,o,r,n){let i=t.getBoundingClientRect(),u=e.clientX,l=e.clientY,p={direction:n,aspectRatio:o,parentBounds:i,bounds:r.getBoundingClientRect(),deltaY:0,deltaX:0,applyEvent(a){a=L(a),p.deltaX=a.clientX-u,p.deltaY=a.clientY-l},resize(a){a.top&&(a.top=a.top-i.top),a.left&&(a.left=a.left-i.left),Object.keys(a).forEach(d=>{r.style[d]=Math.round(a[d])+"px"})}};return p}function D(e,t){let o=de(e),r=!1;h(o,"mousedown",n),h(o,"touchstart",n),h(o,"mousemove",i=>{if(!i.buttons){let u=$(i,o);o.style.cursor=u==="move"?"grabbing":u+"-resize"}});function n(i){if(i.preventDefault(),i=L(i),r)return;r=!0;let u=$(i,o),l=ge(i,e,t,o,u),p=[];function a(s){l.applyEvent(s),l.resize(u==="move"?le(l):he(l))}function d(){r=!1,p.forEach(s=>s())}p=[h(document,"mousemove",a),h(document,"touchmove",a),h(document,"mouseup",d),h(document,"touchend",d),h(document,"touchcancel",d)]}return{el:o,dispose(){o.remove()},apply(i){return ue({image:i,cropBounds:{top:o.offsetTop-e.offsetTop,left:o.offsetLeft-e.offsetLeft,width:o.offsetWidth,height:o.offsetHeight},scale:i.naturalWidth/e.offsetWidth})}}}function ke(e,t){let o=new Image;return new Promise(r=>{o.onload=()=>{r(t(o)),URL.revokeObjectURL(o.src)},o.src=URL.createObjectURL(e)})}function V(e){let t=e.url,o=e.file,r=e.cancelText,n=e.confirmText,i=e.onCancel,u=e.onConfirm,l=e.requireCrop,p=e.cropRatio,a,d=c(".quik-content-wrapper",c(".quik-text","Loading...")),s=c("canvas.quik-confirm-item"),f=c(".quik-content",s),m=Y(t,o,s,()=>{a=l?D(s,p):void 0,d.appendChild(c("footer.quik-footer",c("button.quik-footer-btn",{onclick:i},r),!l&&c("button.quik-footer-btn",{onclick(){a?(a.dispose(),a=void 0):a=D(s,p)}},g('<svg width="24" height="24" viewBox="0 0 24 24" fill="currentColor"><path d="M24 18h-4v-14h-14v-4h-2v4h-4v2h4v14h14v4h2v-4h4v-2zm-18 0v-12h12v12h-12z"/></svg>'),"Crop"),c("button.quik-footer-btn",{onclick:m.rotate},g('<svg viewBox="0 0 24 24" fill="currentColor"><path d="M12 0c3.31 0 6.291 1.353 8.459 3.522l2.48-2.48 1.061 7.341-7.437-.966 2.489-2.489c-1.808-1.807-4.299-2.928-7.052-2.928-5.514 0-10 4.486-10 10s4.486 10 10 10c3.872 0 7.229-2.216 8.89-5.443l1.717 1.046c-2.012 3.803-6.005 6.397-10.607 6.397-6.627 0-12-5.373-12-12s5.373-12 12-12z" /></svg>')," Rotate"),c("button.quik-footer-btn.quik-footer-btn-primary",{onclick(k){k.target.disabled=!0,m.save().then(v=>a?ke(v,a.apply):v).then(v=>{v.name||(v.name=o.name),u(v)})}},n))),d.firstChild.replaceWith(f)});return d}function H(e){let t=e.url,o=e.file,r=e.cancelText,n=e.confirmText,i=e.onCancel,u=e.onConfirm,l=o.type.startsWith("video/")?c("video.quik-vid.quik-content",{src:t,controls:!0}):c("audio",{src:t,controls:!0});return c(".quik-content-wrapper",c(".quik-confirm-item",l),c("footer.quik-footer",c("button.quik-footer-btn",{onclick:i},r),c("button.quik-footer-btn.quik-footer-btn-primary",{onclick(p){p.target.disabled=!0,u(o)}},n)))}var ve=10;function we(e){let t=c("video.quik-vid.quik-content");return t.srcObject=e.recorder.liveSrc(),t.muted=!0,t.controls=!1,t.play(),t}function be(e,t,o){let r=Date.now(),n=t*60,i=d=>`${Math.floor(d/60)}:${`00${d%60}`.slice(-2)} / ${t}:00`,u,l=c("span.quik-progress-bar",{style:"width: 0%"}),p=c("span.quik-duration",i(0)),a=c(".quik-progress",c("span.quik-progress-text",c("span.quik-filename",e),p),c("span.quik-progress-bar-wrapper",l));return u=setTimeout(function d(){let s=Math.floor((Date.now()-r)/1e3);if(p.textContent=i(s),l.style.width=`${Math.floor(s*100/n)}%`,s>=n){o();return}a.isConnected&&setTimeout(d,1e3)},1e3),a}function G(e){let t=e.onPickFiles,o=e.maxDuration||ve,r=e.onCancel;type=e.type;let n,i=c("p.quik-info.quik-content",`Waiting for your ${type==="takeaudio"?"microphone":"camera"}...`),u=c("footer.quik-footer",c("button.quik-footer-btn.quik-footer-btn-secondary",{onclick:r},"Cancel")),l=c(".quik-media",i,u),p=()=>!l.isConnected,a=d=>i.replaceWith(c("p.quik-error",d.toString()));return O({video:type!=="takeaudio",audio:type!=="takephoto",isDisposed:p}).then(d=>{let s=()=>{i.textContent="Generating preview...",n&&n.remove(),(type==="takephoto"?d.capturePhoto():d.endMediaCapture()).then(m=>t([m])).catch(a)};i.textContent=type==="takephoto"?"":`Ready to record. You can record up to ${o} minutes of ${type==="takeaudio"?"audio":"video"}.`,type!=="takeaudio"&&l.insertBefore(we({recorder:d,onPickFiles:t,onError:a}),i),u.appendChild(c("button.quik-footer-btn.quik-footer-btn-primary",{onclick(f){type==="takephoto"||n?(f.target.disabled=!0,s()):(d.beginMediaCapture(),n=be("Recording...",o,s),i.textContent="",l.insertBefore(n,u),f.target.innerHTML="",f.target.append(C(),c("span","Stop recording")))}},type==="takephoto"?q():type==="takeaudio"?C():M(),type==="takephoto"?"Take Photo":"Begin Recording"))}).catch(a),l}function Ce(e){e=b({sources:["filepicker","takephoto"]},e);let t,o=U(),r=[h(window,"keydown",s=>{(s.key==="Escape"||s.code==="Escape")&&u()}),h(document.body,"paste",s=>{s.clipboardData&&s.clipboardData.files&&s.clipboardData.files.length&&(s.preventDefault(),l(s.clipboardData.files))})],n=y(b({},e),{close:u,uploadFiles:d,onPickFiles:l,beginCaptureMedia:a,promise:o,root:void 0,uploader:void 0});n.root=S(n);function i(){w(n.root,R({onPickFiles:l,beginCaptureMedia:a,accept:n.accept,sources:n.sources}))}function u(){o.resolve(t),n.root.remove(),r.forEach(s=>s()),n.uploader&&(n.uploader.cancel(),n.uploader=void 0)}function l(s){let f=s.length===1?s[0]:void 0;if(f&&f.type!=="image/gif"&&!f.type.startsWith("image/svg")&&f.type.startsWith("image/")){let m=URL.createObjectURL(f);r.push(()=>URL.revokeObjectURL(m)),w(n.root,V(y(b({},e),{url:m,file:f,cancelText:"Cancel",confirmText:"Accept & upload",onCancel:i,onConfirm:k=>d([k])})));return}d(s)}function p(s){let f=s[0],m=URL.createObjectURL(f);r.push(()=>URL.revokeObjectURL(m)),w(n.root,H(y(b({},e),{url:m,file:f,cancelText:"Cancel",confirmText:"Accept & upload",onCancel:i,onConfirm:k=>d([k])})))}function a(s){w(n.root,G({type:s,onPickFiles:s==="takephoto"?l:p,onCancel:i,maxDuration:n.maxDuration}))}function d(s){if(e.customProgress)n.root.remove(),n.uploader=e.upload({files:s,onProgress(){}}),n.uploader.promise.then(f=>o.resolve(f)).catch(o.reject);else{let f=W();w(n.root,f),n.uploader=e.upload({files:s,onProgress(m,k){X(f,m,k)}}),n.uploader.promise.then(m=>{t=m,setTimeout(u,250)}).catch(o.reject)}return n.uploader}return o.cancel=u,n}function _(e={}){let t=Ce(e);return document.body.appendChild(t.root),t.promise}return ne(xe);})(); |
{ | ||
"name": "quikpik", | ||
"version": "0.0.28", | ||
"version": "0.0.29", | ||
"main": "./dist/quikpik-cjs.js", | ||
@@ -11,2 +11,3 @@ "types": "./types.d.ts", | ||
"build:browser": "NODE_ENV=production esbuild src/index.js --bundle --outfile=dist/quikpik-cjs.js --sourcemap=external --minify --format=cjs --target=chrome58,firefox57,safari11,edge16 --define:process.env.NODE_ENV=\"'production'\"", | ||
"start:bundled": "NODE_ENV=production esbuild public/main.js --global-name=quikpik --bundle --outfile=public/build/bundle.js --sourcemap=external --minify --target=chrome58,firefox57,safari11,edge16 --define:process.env.NODE_ENV=\"'production'\" --servedir=public", | ||
"start": "esbuild public/main.js --outfile=public/build/bundle.js --bundle --servedir=public", | ||
@@ -27,3 +28,3 @@ "test": "" | ||
"devDependencies": { | ||
"esbuild": "0.14.10" | ||
"esbuild": "0.14.34" | ||
}, | ||
@@ -30,0 +31,0 @@ "eslintConfig": { |
Sorry, the diff of this file is not supported yet
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
153013