text: const backup="__doka_webapi__";var getNativeAPIRef=e=>window[backup]?window[backup][e]:window[e],createProgressEvent=(e,t=!0)=>{const o={loaded:100*e,total:100,lengthComputable:t};try{return new(getNativeAPIRef("ProgressEvent"))("progress",o)}catch(e){return{type:"progress",...o}}},noop$1=(...e)=>{};const FileReaderDataFormat={ArrayBuffer:"readAsArrayBuffer"};var readFile=(e,t=noop$1,o={})=>new Promise((n,r)=>{const{dataFormat:a=FileReaderDataFormat.ArrayBuffer}=o,i=new(getNativeAPIRef("FileReader"));i.onload=(()=>n(i.result)),i.onerror=r,i.onprogress=t,i[a](e)});const readExifOrientation$1=(e,t)=>{if(1165519206!==e.getUint32(t+=2,!1))return-1;const o=18761===e.getUint16(t+=6,!1);t+=e.getUint32(t+4,o);const n=e.getUint16(t,o);t+=2;for(let r=0;r<n;r++)if(274===e.getUint16(t+12*r,o))return e.getUint16(t+12*r+8,o)},readData=e=>{const t=new DataView(e);if(65496!=t.getUint16(0,!1))return null;const o=t.byteLength;let n,r=2;for(;r<o;){if(t.getUint16(r+2,!1)<=8)return-1;if(n=t.getUint16(r,!1),r+=2,65505===n)return readExifOrientation$1(t,r);if(65280!=(65280&n))return null;r+=t.getUint16(r,!1)}};var getImageOrientationFromFile=async(e,t=noop$1)=>{t(createProgressEvent(0));const o=await readFile(e.slice(0,262144));return readData(o)||1};let result$b=null;var isBrowser=()=>(null===result$b&&(result$b="undefined"!=typeof window&&void 0!==window.document),result$b);let result$a=null;var canOrientImages=()=>new Promise(e=>{if(null===result$a){const t="data:image/jpg;base64,/9j/4AAQSkZJRgABAQEASABIAAD/4QA6RXhpZgAATU0AKgAAAAgAAwESAAMAAAABAAYAAAEoAAMAAAABAAIAAAITAAMAAAABAAEAAAAAAAD/2wBDAP//////////////////////////////////////////////////////////////////////////////////////wAALCAABAAIBASIA/8QAJgABAAAAAAAAAAAAAAAAAAAAAxABAAAAAAAAAAAAAAAAAAAAAP/aAAgBAQAAPwBH/9k=";let o=isBrowser()?new Image:{};return o.onload=(()=>{result$a=1===o.naturalWidth,o=void 0,e(result$a)}),void(o.src=t)}return e(result$a)}),canvasToImageData=e=>{return e.getContext("2d").getImageData(0,0,e.width,e.height)},h=(e,t,o=[])=>{const n=document.createElement(e),r=Object.getOwnPropertyDescriptors(n.__proto__);for(const e in t)"style"===e?n.style.cssText=t[e]:r[e]&&r[e].set||/textContent|innerHTML/.test(e)||"function"==typeof t[e]?n[e]=t[e]:n.setAttribute(e,t[e]);return o.forEach(e=>n.appendChild(e)),n};const MATRICES={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]};var getImageOrientationMatrix=(e,t,o=-1)=>(-1===o&&(o=1),MATRICES[o](e,t)),releaseCanvas=e=>{e.width=1,e.height=1;const t=e.getContext("2d");t&&t.clearRect(0,0,1,1)},isImageData=e=>"data"in e,imageDataToCanvas=async(e,t=1)=>{const[o,n]=await canOrientImages()||t<5?[e.width,e.height]:[e.height,e.width],r=h("canvas",{width:o,height:n}),a=r.getContext("2d");if(isImageData(e)&&!await canOrientImages()&&t>1){const t=h("canvas",e);t.getContext("2d").putImageData(e,0,0),e=t}return!await canOrientImages()&&t>1&&a.transform.apply(a,getImageOrientationMatrix(e.width,e.height,t)),isImageData(e)?a.putImageData(e,0,0):a.drawImage(e,0,0),e instanceof HTMLCanvasElement&&releaseCanvas(e),r},orientImageData=async(e,t=1)=>1===t?e:await canOrientImages()?e:canvasToImageData(await imageDataToCanvas(e,t)),imageToCanvas=(e,t)=>{let o=e.naturalWidth,n=e.naturalHeight;const r=o*n;if(t&&r>t){const e=Math.sqrt(t)/Math.sqrt(r);o=Math.floor(o*e),n=Math.floor(n*e)}const a=h("canvas");return a.width=o,a.height=n,a.getContext("2d").drawImage(e,0,0,o,n),a},imageToCanvasSafe=(e,t)=>new Promise((o,n)=>{const r=()=>o(imageToCanvas(e,t));e.complete&&e.width?r():(e.onload=r,e.onerror=n)}),blobToCanvas=async(e,t)=>{const o=h("img",{src:URL.createObjectURL(e)}),n=await imageToCanvasSafe(o,t);return URL.revokeObjectURL(o.src),n},canCreateImageBitmap=()=>"createImageBitmap"in window,canCreateOffscreenCanvas=()=>"OffscreenCanvas"in window,isSVGFile=e=>/svg/.test(e.type),getUniqueId=()=>Math.random().toString(36).substr(2,9),functionToBlob=e=>new Blob(["(","function"==typeof e?e.toString():e,")()"],{type:"application/javascript"});const wrapFunction=e=>`function () {self.onmessage = function (message) {(${e.toString()}).apply(null, message.data.content.concat([function (err, response) {\n    response = response || {};\n    const transfer = 'data' in response ? [response.data.buffer] : 'width' in response ? [response] : [];\n    return self.postMessage({ id: message.data.id, content: response, error: err }, transfer);\n}]))}}`,workerPool=new Map;var thread=(e,t,o)=>new Promise((n,r)=>{let a=e.toString(),i=workerPool.get(a);if(!i){const t=wrapFunction(e),o=URL.createObjectURL(functionToBlob(t)),n=new Map,r=new Worker(o);i={url:o,worker:r,messages:n,terminate:()=>{i.worker.terminate(),URL.revokeObjectURL(o)}},r.onmessage=function(e){const{id:t,content:o,error:r}=e.data;if(!n.has(t))return;const a=n.get(t);n.delete(t),null!=r?a.reject(r):a.resolve(o)},workerPool.set(a,i)}const s=getUniqueId();i.messages.set(s,{resolve:n,reject:r}),i.worker.postMessage({id:s,content:t},o)}),blobToImageData=async(e,t)=>{let o;if(canCreateImageBitmap()&&!isSVGFile(e)&&canCreateOffscreenCanvas())try{o=await thread((e,t,o)=>{createImageBitmap(e).then(e=>{let n=e.width,r=e.height;const a=n*r;if(t&&a>t){const e=Math.sqrt(t)/Math.sqrt(a);n=Math.floor(n*e),r=Math.floor(r*e)}const i=new OffscreenCanvas(n,r),s=i.getContext("2d");s.drawImage(e,0,0);const l=s.getImageData(0,0,i.width,i.height);o(null,l)}).catch(e=>{o(e)})},[e,t])}catch(e){}if(!o||!o.width){const n=await blobToCanvas(e,t);o=canvasToImageData(n),releaseCanvas(n)}return o},canvasToBlob=(e,t,o)=>new Promise((n,r)=>{try{e.toBlob(e=>{n(e)},t,o)}catch(e){r(e)}}),imageDataToBlob=async(e,t,o)=>{try{const n=await imageDataToCanvas(e),r=await canvasToBlob(n,t,o);return releaseCanvas(n),r}catch(e){throw e}},blobReadSection=async(e,t=[0,e.size],o)=>await readFile(e.slice(...t),o),blobWriteSection=(e,t,o=[0,e.size])=>t?new Blob([t,e.slice(...o)],{type:e.type}):e,getExtensionFromMimeType=e=>(e.match(/\/([a-z]+)/)||[])[1],getFilenameWithoutExtension=e=>e.substr(0,e.lastIndexOf("."))||e,getExtensionFromFilename=e=>e.split(".").pop();const ImageExtensionsRegex=/avif|bmp|gif|jpg|jpeg|jpe|jif|jfif|png|svg|tiff|webp/;var getMimeTypeFromExtension=e=>ImageExtensionsRegex.test(e)?"image/"+(/jfif|jif|jpe|jpg/.test(e)?"jpeg":"svg"===e?"svg+xml":e):"",getMimeTypeFromFilename=e=>e&&getMimeTypeFromExtension(getExtensionFromFilename(e).toLowerCase()),matchFilenameToMimeType=(e,t)=>{const o=getMimeTypeFromFilename(e);if(o===t)return e;const n=getExtensionFromMimeType(t)||o;return`${getFilenameWithoutExtension(e)}.${n}`},blobToFile=(e,t,o)=>{const n=(new Date).getTime(),r=e.type.length&&!/null|text/.test(e.type),a=r?e.type:o,i=matchFilenameToMimeType(t,a);try{return new(getNativeAPIRef("File"))([e],i,{lastModified:n,type:r?e.type:a})}catch(t){const o=r?e.slice():e.slice(0,e.size,a);return o.lastModified=n,o.name=i,o}},getAspectRatio=(e,t)=>e/t,passthrough=e=>e;const PI=Math.PI,HALF_PI=Math.PI/2,QUART_PI=HALF_PI/2;var isRotatedSideways=e=>{const t=Math.abs(e)%Math.PI;return t>QUART_PI&&t<Math.PI-QUART_PI};const scale=(e,t,o)=>o+(e-o)*t,ellipseCreateFromRect=e=>({x:e.x+.5*e.width,y:e.y+.5*e.height,rx:.5*e.width,ry:.5*e.height}),vectorCreateEmpty=()=>vectorCreate(0,0),vectorCreate=(e,t)=>({x:e,y:t}),vectorCreateFromSize=e=>vectorCreate(e.width,e.height),vectorCreateFromPointerEvent=e=>vectorCreate(e.pageX,e.pageY),vectorCreateFromPointerEventOffset=e=>vectorCreate(e.offsetX,e.offsetY),vectorClone=e=>vectorCreate(e.x,e.y),vectorInvert=e=>(e.x=-e.x,e.y=-e.y,e),vectorPerpendicular=e=>{const t=e.x;return e.x=-e.y,e.y=t,e},vectorRotate=(e,t,o=vectorCreateEmpty())=>{const n=Math.cos(t),r=Math.sin(t),a=e.x-o.x,i=e.y-o.y;return e.x=o.x+n*a-r*i,e.y=o.y+r*a+n*i,e},vectorLength=e=>Math.sqrt(e.x*e.x+e.y*e.y),vectorNormalize=e=>{const t=Math.sqrt(e.x*e.x+e.y*e.y);return 0===t?vectorCreateEmpty():(e.x/=t,e.y/=t,e)},vectorAngle=e=>Math.atan2(e.y,e.x),vectorAngleBetween=(e,t)=>Math.atan2(t.y-e.y,t.x-e.x),vectorEqual=(e,t)=>e.x===t.x&&e.y===t.y,vectorApply=(e,t)=>(e.x=t(e.x),e.y=t(e.y),e),vectorAdd=(e,t)=>(e.x+=t.x,e.y+=t.y,e),vectorSubtract=(e,t)=>(e.x-=t.x,e.y-=t.y,e),vectorMultiply=(e,t)=>(e.x*=t,e.y*=t,e),vectorDot=(e,t)=>e.x*t.x+e.y*t.y,vectorDistanceSquared=(e,t=vectorCreateEmpty())=>{const o=e.x-t.x,n=e.y-t.y;return o*o+n*n},vectorDistance=(e,t=vectorCreateEmpty())=>Math.sqrt(vectorDistanceSquared(e,t)),vectorCenter=e=>{let t=0,o=0;return e.forEach(e=>{t+=e.x,o+=e.y}),vectorCreate(t/e.length,o/e.length)},vectorsFlip=(e,t,o,n,r)=>(e.forEach(e=>{e.x=t?n-(e.x-n):e.x,e.y=o?r-(e.y-r):e.y}),e),vectorsRotate=(e,t,o,n)=>{const r=Math.sin(t),a=Math.cos(t);return e.forEach(e=>{e.x-=o,e.y-=n;const t=e.x*a-e.y*r,i=e.x*r+e.y*a;e.x=o+t,e.y=n+i}),e},toSize=(e,t)=>({width:e,height:t}),sizeClone=e=>toSize(e.width,e.height),sizeCreateFromAny=e=>toSize(e.width,e.height),sizeCreateFromRect=e=>toSize(e.width,e.height),sizeCreateFromArray=e=>toSize(e[0],e[1]),sizeCreate=(e,t)=>toSize(e,t),sizeEqual=(e,t,o=passthrough)=>o(e.width)===o(t.width)&&o(e.height)===o(t.height),sizeScale=(e,t)=>(e.width*=t,e.height*=t,e),sizeCenter=e=>vectorCreate(.5*e.width,.5*e.height),sizeRotate=(e,t)=>{const o=Math.cos(t),n=Math.sin(t),r=o*e.width+n*e.height,a=n*e.width+o*e.height;return e.width=r,e.height=a,e},sizeTurn=(e,t)=>{const o=e.width,n=e.height;return isRotatedSideways(t)&&(e.width=n,e.height=o),e},sizeContains=(e,t)=>e.width>=t.width&&e.height>=t.height,sizeApply=(e,t)=>(e.width=t(e.width),e.height=t(e.height),e),sizeHypotenuse=e=>Math.sqrt(e.width*e.width+e.height*e.height),sizeMin=(e,t)=>sizeCreate(Math.min(e.width,t.width),Math.min(e.height,t.height)),lineCreate=(e,t)=>({start:e,end:t}),lineClone=e=>lineCreate(vectorClone(e.start),vectorClone(e.end)),lineExtend=(e,t)=>{const o=vectorCreate(e.start.x-e.end.x,e.start.y-e.end.y),n=vectorNormalize(o),r=vectorMultiply(n,t);return e.start.x+=r.x,e.start.y+=r.y,e.end.x-=r.x,e.end.y-=r.y,e},lineMultiply=(e,t)=>{const o=vectorCreate(e.start.x-e.end.x,e.start.y-e.end.y),n=vectorNormalize(o),r=vectorMultiply(n,t);return e.end.x+=r.x,e.end.y+=r.y,e},CornerSigns=[vectorCreate(-1,-1),vectorCreate(-1,1),vectorCreate(1,1),vectorCreate(1,-1)],toRect=(e,t,o,n)=>({x:e,y:t,width:o,height:n}),rectClone=e=>toRect(e.x,e.y,e.width,e.height),rectCreateEmpty=()=>toRect(0,0,0,0),rectCreateFromDimensions=(e,t)=>toRect(0,0,e,t),rectCreateFromSize=e=>toRect(0,0,e.width,e.height),rectCreateFromAny=e=>toRect(e.x||0,e.y||0,e.width||0,e.height||0),rectCreateFromPoints=(...e)=>{const t=Array.isArray(e[0])?e[0]:e;let o=t[0].x,n=t[0].x,r=t[0].y,a=t[0].y;return t.forEach(e=>{o=Math.min(o,e.x),n=Math.max(n,e.x),r=Math.min(r,e.y),a=Math.max(a,e.y)}),toRect(o,r,n-o,a-r)},rectCreateFromEllipse=e=>rectCreate(e.x-e.rx,e.y-e.ry,2*e.rx,2*e.ry),rectCreateWithCenter=(e,t)=>toRect(e.x-.5*t.width,e.y-.5*t.height,t.width,t.height),rectCreate=(e,t,o,n)=>toRect(e,t,o,n),rectCenter=e=>vectorCreate(e.x+.5*e.width,e.y+.5*e.height),rectTranslate=(e,t)=>(e.x+=t.x,e.y+=t.y,e),rectScale=(e,t,o)=>(o=o||rectCenter(e),e.x=t*(e.x-o.x)+o.x,e.y=t*(e.y-o.y)+o.y,e.width=t*e.width,e.height=t*e.height,e),rectMultiply=(e,t)=>(e.x*=t,e.y*=t,e.width*=t,e.height*=t,e),rectDivide=(e,t)=>(e.x/=t,e.y/=t,e.width/=t,e.height/=t,e),rectSubtract=(e,t)=>(e.x-=t.x,e.y-=t.y,e.width-=t.width,e.height-=t.height,e),rectAdd=(e,t)=>(e.x+=t.x,e.y+=t.y,e.width+=t.width,e.height+=t.height,e),rectEqual=(e,t,o=passthrough)=>o(e.x)===o(t.x)&&o(e.y)===o(t.y)&&o(e.width)===o(t.width)&&o(e.height)===o(t.height),rectAspectRatio=e=>getAspectRatio(e.width,e.height),rectUpdate=(e,t,o,n,r)=>(e.x=t,e.y=o,e.width=n,e.height=r,e),rectUpdateWithRect=(e,t)=>(e.x=t.x,e.y=t.y,e.width=t.width,e.height=t.height,e),rectRotate=(e,t,o)=>(o||(o=rectCenter(e)),rectGetCorners(e).map(e=>vectorRotate(e,t,o))),rectCenterRect=(e,t)=>toRect(.5*e.width-.5*t.width,.5*e.height-.5*t.height,t.width,t.height),rectContainsPoint=(e,t)=>!(t.x<e.x)&&(!(t.y<e.y)&&(!(t.x>e.x+e.width)&&!(t.y>e.y+e.height))),rectCoverRect=(e,t,o=vectorCreateEmpty())=>{if(0===e.width||0===e.height)return rectCreateEmpty();const n=rectAspectRatio(e);t||(t=n);let r=e.width,a=e.height;return t>n?r=a*t:a=r/t,toRect(o.x+.5*(e.width-r),o.y+.5*(e.height-a),r,a)},rectContainRect=(e,t=rectAspectRatio(e),o=vectorCreateEmpty())=>{if(0===e.width||0===e.height)return rectCreateEmpty();let n=e.width,r=n/t;return r>e.height&&(n=(r=e.height)*t),toRect(o.x+.5*(e.width-n),o.y+.5*(e.height-r),n,r)},rectToBounds=e=>[Math.min(e.y,e.y+e.height),Math.max(e.x,e.x+e.width),Math.max(e.y,e.y+e.height),Math.min(e.x,e.x+e.width)],rectGetCorners=e=>[vectorCreate(e.x,e.y),vectorCreate(e.x+e.width,e.y),vectorCreate(e.x+e.width,e.y+e.height),vectorCreate(e.x,e.y+e.height)],rectApply=(e,t)=>{if(e)return e.x=t(e.x),e.y=t(e.y),e.width=t(e.width),e.height=t(e.height),e},rectApplyPerspective=(e,t,o=rectCenter(e))=>rectGetCorners(e).map((e,n)=>{const r=CornerSigns[n];return vectorCreate(scale(e.x,1+r.x*t.x,o.x),scale(e.y,1+r.y*t.y,o.y))}),rectNormalizeOffset=e=>(e.x=0,e.y=0,e),quadCentroid=e=>{const t=e.map(vectorClone),o=t[0],n=t[t.length-1];o.x==n.x&&o.y==n.y||t.push(o);let r,a,i,s=0,l=0,c=0,p=t.length;for(let e=0,n=p-1;e<p;n=e++)r=t[e],a=t[n],s+=i=(r.y-o.y)*(a.x-o.x)-(a.y-o.y)*(r.x-o.x),l+=(r.x+a.x-2*o.x)*i,c+=(r.y+a.y-2*o.y)*i;return vectorCreate(l/(i=3*s)+o.x,c/i+o.y)},lineLineIntersection=(e,t)=>_lineLineIntersection(e.start,e.end,t.start,t.end),_lineLineIntersection=(e,t,o,n)=>{const r=((n.x-o.x)*(e.y-o.y)-(n.y-o.y)*(e.x-o.x))/((n.y-o.y)*(t.x-e.x)-(n.x-o.x)*(t.y-e.y)),a=((t.x-e.x)*(e.y-o.y)-(t.y-e.y)*(e.x-o.x))/((n.y-o.y)*(t.x-e.x)-(n.x-o.x)*(t.y-e.y));if(r>=0&&r<=1&&a>=0&&a<=1)return vectorCreate(e.x+r*(t.x-e.x),e.y+r*(t.y-e.y))},linePointsIntersection=(e,t)=>{const o=[...t,t[0]],n=o.length,r=[];for(let t=0;t<n-1;t++){const n=_lineLineIntersection(e.start,e.end,vectorCreate(o[t].x,o[t].y),vectorCreate(o[t+1].x,o[t+1].y));n&&r.push(n)}return r.length?r:void 0},polyPointIntersectionConvex=(e,t)=>{let o,n,r,a,i,s,l,c,p,u;const d=t.length;for(o=0;o<d;o++)if(n=t[o],r=t[o+1>d-1?0:o+1],a=n.x-e.x,i=n.y-e.y,s=r.x-e.x,l=r.y-e.y,(u=(c=a-s)*i-(p=i-l)*a)<-1e-5)return!1;return!0},quadLines=e=>{const t=[];for(let o=0;o<e.length;o++){let n=o+1;n===e.length&&(n=0),t.push(lineCreate(vectorClone(e[o]),vectorClone(e[n])))}return t};var getImageTransformedRect=(e,t)=>{const o=rectCreateFromSize(e),n=rectCenter(o),r=rectRotate(o,t,n);return rectNormalizeOffset(rectCreateFromPoints(r))},isElement=(e,t)=>e instanceof HTMLElement&&(!t||new RegExp(`^${t}$`,"i").test(e.nodeName)),isFile=e=>e instanceof File,isString=e=>"string"==typeof e,canvasToFile=async(e,t,o)=>{const n=await canvasToBlob(e,t,o);return blobToFile(n,"canvas")},getFilenameFromURL=e=>e.split("/").pop().split(/\?|\#/).shift();let isSafari=null;var isSafari$1=()=>(null===isSafari&&(isSafari=isSafari=/^((?!chrome|android).)*safari/i.test(navigator.userAgent)),isSafari),getImageElementSize=e=>new Promise((t,o)=>{let n=!1;!e.parentNode&&isSafari$1()&&(n=!0,e.style.cssText="position:absolute;visibility:hidden;pointer-events:none;left:0;top:0;width:0;height:0;",document.body.appendChild(e));const r=()=>{const o=e.naturalWidth,r=e.naturalHeight;o&&r&&(n&&e.parentNode.removeChild(e),clearInterval(a),t({width:o,height:r}))};e.onerror=(e=>{clearInterval(a),o(e)});const a=setInterval(r,1);r()}),getImageSize=async e=>{let t,o=e;o.src||((o=new Image).src=isString(e)?e:URL.createObjectURL(e));try{t=await getImageElementSize(o)}catch(e){throw e}finally{isFile(e)&&URL.revokeObjectURL(o.src)}return t};const awaitComplete=e=>new Promise((t,o)=>{if(e.complete)return t(e);e.onload=(()=>t(e)),e.onerror=o});var imageToFile=async e=>{try{const t=await getImageSize(e),o=await awaitComplete(e),n=document.createElement("canvas");n.width=t.width,n.height=t.height,n.getContext("2d").drawImage(o,0,0);const r=await canvasToBlob(n);return blobToFile(r,getFilenameFromURL(o.src))}catch(e){throw e}},isDataURI=e=>/^data:/.test(e),isUserAgent=e=>isBrowser()?RegExp(e).test(window.navigator.userAgent):void 0;let result$9=null;var isInternetExplorer=()=>(null===result$9&&(result$9=isUserAgent(/MSIE|Trident/)),result$9);const dataURIToBlob=e=>{const t=e.split(","),o=t[0].substr(4),n=atob(t[1]),r=n.length,a=new ArrayBuffer(n.length),i=new Uint8Array(a);for(var s=0;s<r;s++)i[s]=n.charCodeAt(s);return new Blob([a],{type:o})};var dataURIToFile=async(e,t="data-uri",o=noop$1)=>{let n;if(o(createProgressEvent(0)),isInternetExplorer())n=dataURIToBlob(e),o(createProgressEvent(.5));else{const t=await fetch(e);o(createProgressEvent(.33)),n=await t.blob(),o(createProgressEvent(.66))}const r=blobToFile(n,t);return o(createProgressEvent(1)),r},getResponseHeader=(e,t,o=(e=>e))=>e.getAllResponseHeaders().indexOf(t)>=0?o(e.getResponseHeader(t)):void 0,getFilenameFromContentDisposition=e=>{if(!e)return null;const t=e.split(/filename=|filename\*=.+''/).splice(1).map(e=>e.trim().replace(/^["']|[;"']{0,2}$/g,"")).filter(e=>e.length);return t.length?decodeURI(t[t.length-1]):null};const DokaErrorCode={URL_REQUEST:"URL_REQUEST",DOCTYPE_MISSING:"DOCTYPE_MISSING"};class DokaError extends Error{constructor(e,t,o){super(e),this.name="DokaError",this.code=t,this.metadata=o}}var fetchFile=(e,t)=>new Promise((o,n)=>{const r=()=>n(new DokaError("Error fetching image",DokaErrorCode.URL_REQUEST,a)),a=new XMLHttpRequest;a.onprogress=t,a.onerror=r,a.onload=(()=>{if(!a.response||a.status>=300||a.status<200)return r();const t=getResponseHeader(a,"Content-Type"),n=getResponseHeader(a,"Content-Disposition",getFilenameFromContentDisposition)||getFilenameFromURL(e);o(blobToFile(a.response,n,t||getMimeTypeFromFilename(n)))}),a.open("GET",e),a.responseType="blob",a.send()}),urlToFile=(e,t)=>isDataURI(e)?dataURIToFile(e,void 0,t):fetchFile(e,t),isBlob=e=>e instanceof Blob&&!(e instanceof File),srcToFile=async(e,t)=>{if(isFile(e)||isBlob(e))return e;if(isString(e))return await urlToFile(e,t);if(isElement(e,"canvas"))return await canvasToFile(e);if(isElement(e,"img"))return await imageToFile(e);throw new DokaError("Invalid image source","invalid-image-source")},orientImageSize=async(e,t=1)=>await canOrientImages()?e:t<5?e:sizeCreate(e.height,e.width),arrayBufferReadImageHead=e=>{const t=new DataView(e);if(65496!==t.getUint16(0))return null;let o,n,r=2;for(;r<t.byteLength;){if(o=t.getUint16(r,!1),n=t.getUint16(r+2,!1)+2,!(o>=65504&&o<=65519||65534===o))break;if(r+n>t.byteLength)break;r+=n}return e.slice(0,r)};const readExifOrientation=(e,t)=>{if(1165519206!==e.getUint32(t+=2,!1))return-1;const o=18761===e.getUint16(t+=6,!1);t+=e.getUint32(t+4,o);const n=e.getUint16(t,o);t+=2;for(let r=0;r<n;r++)if(274===e.getUint16(t+12*r,o))return e.getUint16(t+12*r+8,o)};var arrayBufferReadExifOrientationTag=e=>{if(!e)return;const t=new DataView(e);if(65496!=t.getUint16(0,!1))return;const o=t.byteLength;let n,r=2;for(;r<o;){if(t.getUint16(r+2,!1)<=8)return;if(n=t.getUint16(r,!1),r+=2,65505===n)return readExifOrientation(t,r);if(65280!=(65280&n))return;r+=t.getUint16(r,!1)}},arrayBufferWriteExifOrientationTag=(e,t=1)=>{if(!e)return!1;const o=new DataView(e);if(65496!==o.getUint16(0))return!1;let n,r,a=2,i=!1;for(;a<o.byteLength;){if(n=o.getUint16(a,!1),r=o.getUint16(a+2,!1)+2,!(n>=65504&&n<=65519||65534===n))break;if(i||(i=writeExifOrientation(o,a,t)),a+r>o.byteLength)break;a+=r}return i};const writeExifOrientation=(e,t,o)=>{if(1165519206!==e.getUint32(t+4,!1))return;t+=4;const n=18761===e.getUint16(t+=6,!1);t+=e.getUint32(t+4,n);const r=e.getUint16(t,n);t+=2;for(let a=0;a<r;a++)if(274===e.getUint16(t+12*a,n))return e.setUint16(t+12*a+8,o,n),!0;return!1};var isJPEG=e=>/jpeg/.test(e.type),isPlainObject=e=>"object"==typeof e&&e.constructor==Object,stringify=e=>isPlainObject(e)?JSON.stringify(e):e,post=(e,t,o)=>new Promise((n,r)=>{const{token:a={},beforeSend:i=noop$1,onprogress:s=noop$1}=o;a.cancel=(()=>l.abort());const l=new XMLHttpRequest;l.upload.onprogress=s,l.onload=(()=>l.status>=200&&l.status<300?n(l):r(l)),l.onerror=(()=>r(l)),l.ontimeout=(()=>r(l)),l.open("POST",encodeURI(e)),i(l),l.send(t.reduce((e,t)=>(e.append(...t.map(stringify)),e),new FormData))}),ctxRotate=(e,t=0,o)=>0===t?e:(e.translate(o.x,o.y),e.rotate(t),e.translate(-o.x,-o.y),e),ctxTranslate=(e,t,o)=>(e.translate(t,o),e),ctxScale=(e,t,o)=>(e.scale(t,o),e),cropImageData=async(e,t={})=>{const{flipX:o,flipY:n,rotation:r,crop:a}=t,i=sizeCreateFromAny(e),s=o||n,l=!!r,c=a&&(a.x||a.y||a.width||a.height),p=c&&rectEqual(a,rectCreateFromSize(i)),u=c&&!p;if(!s&&!l&&!u)return e;let d,m=h("canvas",{width:e.width,height:e.height});if(m.getContext("2d").putImageData(e,0,0),s){const e=h("canvas",{width:m.width,height:m.height}).getContext("2d");ctxScale(e,o?-1:1,n?-1:1),e.drawImage(m,o?-m.width:0,n?-m.height:0),e.restore(),releaseCanvas(m),m=e.canvas}if(l){const e=sizeApply(sizeCreateFromRect(rectCreateFromPoints(rectRotate(rectCreateFromAny(m),r))),Math.floor),t=h("canvas",{width:a.width,height:a.height}).getContext("2d");ctxTranslate(t,-a.x,-a.y),ctxRotate(t,r,sizeCenter(e)),t.drawImage(m,.5*(e.width-m.width),.5*(e.height-m.height)),t.restore(),releaseCanvas(m),m=t.canvas}else if(u){return d=m.getContext("2d").getImageData(a.x,a.y,a.width,a.height),releaseCanvas(m),d}return d=m.getContext("2d").getImageData(0,0,m.width,m.height),releaseCanvas(m),d},resizeTransform=(e,t)=>{const{imageData:o,width:n,height:r}=e,a=o.width,i=o.height,s=Math.round(n),l=Math.round(r),c=o.data,p=new Uint8ClampedArray(s*l*4),u=a/s,d=i/l,h=Math.ceil(.5*u),m=Math.ceil(.5*d);for(let e=0;e<l;e++)for(let t=0;t<s;t++){const o=4*(t+e*s);let n=0,r=0,i=0,l=0,g=0,f=0,_=0;const $=(e+.5)*d;for(let o=Math.floor(e*d);o<(e+1)*d;o++){const e=Math.abs($-(o+.5))/m,s=(t+.5)*u,p=e*e;for(let e=Math.floor(t*u);e<(t+1)*u;e++){let t=Math.abs(s-(e+.5))/h;const u=Math.sqrt(p+t*t);if(u>=-1&&u<=1&&(n=2*u*u*u-3*u*u+1)>0){const s=c[(t=4*(e+o*a))+3];_+=n*s,i+=n,s<255&&(n=n*s/250),l+=n*c[t],g+=n*c[t+1],f+=n*c[t+2],r+=n}}}p[o]=l/r,p[o+1]=g/r,p[o+2]=f/r,p[o+3]=_/i}t(null,{data:p,width:s,height:l})},imageDataObjectToImageData=e=>{if(e instanceof ImageData)return e;let t;try{t=new ImageData(e.width,e.height)}catch(o){t=h("canvas").getContext("2d").createImageData(e.width,e.height)}return t.data.set(e.data),t},resizeImageData=async(e,t={})=>{const{width:o,height:n,fit:r,upscale:a}=t;if(!o&&!n)return e;let i=o,s=n;if(o?n||(s=o):i=n,"force"!==r){let t=i/e.width,o=s/e.height,n=1;if("cover"===r?n=Math.max(t,o):"contain"===r&&(n=Math.min(t,o)),n>1&&!1===a)return e;i=Math.round(e.width*n),s=Math.round(e.height*n)}return e.width===i&&e.height===s?e:(e=await thread(resizeTransform,[{imageData:e,width:i,height:s}],[e.data.buffer]),imageDataObjectToImageData(e))},colorEffect=(e,t)=>{const{imageData:o,matrix:n}=e;if(!n)return t(null,o);const r=new Uint8ClampedArray(o.width*o.height*4),a=o.data,i=a.length,s=n[0],l=n[1],c=n[2],p=n[3],u=n[4],d=n[5],h=n[6],m=n[7],g=n[8],f=n[9],_=n[10],$=n[11],b=n[12],y=n[13],x=n[14],v=n[15],C=n[16],S=n[17],k=n[18],w=n[19];let R=0,T=0,E=0,I=0,A=0,M=0,P=0,D=0,F=0,L=0,z=0,B=0;for(;R<i;R+=4)M=(T=a[R]/255)*s+(E=a[R+1]/255)*l+(I=a[R+2]/255)*c+(A=a[R+3]/255)*p+u,P=T*d+E*h+I*m+A*g+f,D=T*_+E*$+I*b+A*y+x,F=T*v+E*C+I*S+A*k+w,L=Math.max(0,M*F)+(1-F),z=Math.max(0,P*F)+(1-F),B=Math.max(0,D*F)+(1-F),r[R]=255*Math.max(0,Math.min(1,L)),r[R+1]=255*Math.max(0,Math.min(1,z)),r[R+2]=255*Math.max(0,Math.min(1,B)),r[R+3]=255*A;t(null,{data:r,width:o.width,height:o.height})},convolutionEffect=(e,t)=>{const{imageData:o,matrix:n}=e;if(!n)return t(null,o);let r=n.reduce((e,t)=>e+t);const a=o.width,i=o.height,s=o.data;let l=0,c=0,p=0;const u=Math.round(Math.sqrt(n.length)),d=Math.floor(u/2);let h=0,m=0,g=0,f=0,_=0,$=0,b=0,y=0,x=0,v=0;const C=new Uint8ClampedArray(a*i*4);for(p=0;p<i;p++)for(c=0;c<a;c++){for(h=0,m=0,g=0,f=0,$=0;$<u;$++)for(_=0;_<u;_++)y=c+_-d,(b=p+$-d)<0||b>=i||y<0||y>=a||(x=4*(b*a+y),v=n[$*u+_],h+=s[x]*v,m+=s[x+1]*v,g+=s[x+2]*v,f+=s[x+3]*v);C[l]=h/r,C[l+1]=m/r,C[l+2]=g/r,C[l+3]=f/r,l+=4}t(null,{data:C,width:a,height:i})},vignetteEffect=(e,t)=>{const{imageData:o,strength:n}=e;if(!n)return t(null,o);const r=new Uint8ClampedArray(o.width*o.height*4),a=o.width,i=o.height,s=o.data,l=(e,t)=>(c=e-g,p=t-f,Math.sqrt(c*c+p*p));let c,p,u,d=0,h=0,m=0,g=.5*a,f=.5*i,_=l(0,0);for(m=0;m<i;m++)for(h=0;h<a;h++)d=4*(h+m*a),u=l(h,m)*n/_,n>0?(r[d]=s[d]*(1-u),r[d+1]=s[d+1]*(1-u),r[d+2]=s[d+2]*(1-u)):(r[d]=s[d]+u*-(255-s[d]),r[d+1]=s[d+1]+u*-(255-s[d+1]),r[d+2]=s[d+2]+u*-(255-s[d+2])),r[d+3]=s[d+3];t(null,{data:r,width:o.width,height:o.height})},noiseEffect=(e,t)=>{const{imageData:o,level:n,monochrome:r=!1}=e;if(!n)return t(null,o);const a=new Uint8ClampedArray(o.width*o.height*4),i=o.data,s=i.length;let l,c,p,u,d=0;const h=()=>255*(2*Math.random()-1)*n;for(;d<s;d+=4)r?(l=u=h(),c=u,p=u):(l=h(),c=h(),p=h()),a[d]=i[d]+l,a[d+1]=i[d+1]+c,a[d+2]=i[d+2]+p,a[d+3]=i[d+3];t(null,{data:a,width:o.width,height:o.height})},gammaEffect=(e,t)=>{const{imageData:o,level:n}=e;if(!n)return t(null,o);const r=new Uint8ClampedArray(o.width*o.height*4),a=o.data,i=a.length;let s,l,c,p=0;for(;p<i;p+=4)s=a[p]/255,l=a[p+1]/255,c=a[p+2]/255,r[p]=255*Math.pow(s,n),r[p+1]=255*Math.pow(l,n),r[p+2]=255*Math.pow(c,n),r[p+3]=a[p+3];t(null,{data:r,width:o.width,height:o.height})},isIdentityMatrix=e=>{const t=e.length;let o,n=t>=20?6:t>=16?5:3;for(let r=0;r<t;r++){if(1===(o=e[r])&&r%n!=0)return!1;if(0!==o&&1!==o)return!1}return!0},filterImageData=async(e,t={})=>{const{colorMatrix:o,convolutionMatrix:n,gamma:r,noise:a,vignette:i}=t,s=[];if(n&&s.push([convolutionEffect,{matrix:n.clarity}]),r>0&&s.push([gammaEffect,{level:1/r}]),o&&!isIdentityMatrix(o)&&s.push([colorEffect,{matrix:o}]),(a>0||a<0)&&s.push([noiseEffect,{level:a}]),(i>0||i<0)&&s.push([vignetteEffect,{strength:i}]),!s.length)return e;const l=(e,t)=>`(err, imageData) => {\n            (${e[t][0].toString()})(Object.assign({ imageData: imageData }, filterInstructions[${t}]), \n                ${e[t+1]?l(e,t+1):"done"})\n        }`,c=`function (options, done) {\n        const filterInstructions = options.filterInstructions;\n        const imageData = options.imageData;\n        (${l(s,0)})(null, imageData)\n    }`;return e=await thread(c,[{imageData:e,filterInstructions:s.map(e=>e[1])}],[e.data.buffer]),imageDataObjectToImageData(e)},isNumber=e=>"number"==typeof e,isEmoji=e=>isString(e)&&null!==e.match(/(?:[\u2700-\u27bf]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff]|[\u0023-\u0039]\ufe0f?\u20e3|\u3299|\u3297|\u303d|\u3030|\u24c2|\ud83c[\udd70-\udd71]|\ud83c[\udd7e-\udd7f]|\ud83c\udd8e|\ud83c[\udd91-\udd9a]|\ud83c[\udde6-\uddff]|\ud83c[\ude01-\ude02]|\ud83c\ude1a|\ud83c\ude2f|\ud83c[\ude32-\ude3a]|\ud83c[\ude50-\ude51]|\u203c|\u2049|[\u25aa-\u25ab]|\u25b6|\u25c0|[\u25fb-\u25fe]|\u00a9|\u00ae|\u2122|\u2139|\ud83c\udc04|[\u2600-\u26FF]|\u2b05|\u2b06|\u2b07|\u2b1b|\u2b1c|\u2b50|\u2b55|\u231a|\u231b|\u2328|\u23cf|[\u23e9-\u23f3]|[\u23f8-\u23fa]|\ud83c\udccf|\u2934|\u2935|[\u2190-\u21ff])/g),hasProp=(e,t)=>e.hasOwnProperty(t),isObject=e=>"object"==typeof e;const copy=e=>isObject(e)?deepCopy(e):e,deepCopy=e=>{let t;return Array.isArray(e)?(t=[],e.forEach((e,o)=>{t[o]=copy(e)})):(t={},Object.keys(e).forEach(o=>{const n=e[o];t[o]=copy(n)})),t};var isFunction=e=>"function"==typeof e,isArray=e=>Array.isArray(e);let result$8=null;var isMac=()=>(null===result$8&&(result$8=isBrowser()&&/^mac/i.test(navigator.platform)),result$8);let result$7=null;var isIOS=()=>(null===result$7&&(result$7=isBrowser()&&(isUserAgent(/iPhone|iPad|iPod/)||isMac()&&navigator.maxTouchPoints>=1)),result$7),isApple=()=>isIOS()||isMac(),isWindows=()=>/^win/i.test(navigator.platform);let x=64,y=102,fontSize=112,hasSetValues=!1;var getEmojiSVG=(e,t)=>(!hasSetValues&&isBrowser()&&(isWindows()&&(y=103),isApple()&&(x=63.5,y=110,fontSize=123),hasSetValues=!0),`<svg${t?` aria-label="${t}"`:""} width="128" height="128" viewBox="0 0 128 128" preserveAspectRatio="xMinYMin meet" xmlns="http://www.w3.org/2000/svg"><text x="${x}" y="${y}" alignment-baseline="text-top" dominant-baseline="text-top" text-anchor="middle" font-size="${fontSize}px">${e}</text></svg>`),SVGToDataURL=e=>`data:image/svg+xml,${e.replace("<","%3C").replace(">","%3E")}`,isBinary=e=>e instanceof Blob,toPercentage=(e,t)=>`${e/t*100}%`,isRemoteURL=e=>new URL(e,location.href).origin!==location.origin,loadImage=(e,t)=>new Promise((o,n)=>{let r=e,a=!1;const i=()=>{a||(a=!0,isFunction(t)&&Promise.resolve().then(()=>t(sizeCreate(r.naturalWidth,r.naturalHeight))))};if(r.src||(r=new Image,isString(e)&&isRemoteURL(e)&&(r.crossOrigin="anonymous"),r.src=isString(e)?e:URL.createObjectURL(e)),r.complete)return i(),o(r);isFunction(t)&&getImageElementSize(r).then(i).catch(n),r.onload=(()=>{i(),o(r)}),r.onerror=n}),colorArrayToRGBA=e=>`rgba(${Math.round(255*e[0])}, ${Math.round(255*e[1])}, ${Math.round(255*e[2])}, ${isNumber(e[3])?e[3]:1})`;const textPadding=20;let fontOffsetBrowser=void 0;const getBrowserFontOffset=e=>{if(!fontOffsetBrowser){const e=32,t=createSimpleContext(e,e);updateTextContext(t,{fontSize:100,color:"#fff"}),t.fillText("F",0,0);const o=t.getImageData(0,0,e,e).data;let n=0,r=4,a=o.length,i=a-4*e;for(n=i;n<a&&!o[n];n+=r);const s=(n-i)/r;for(r=4*e,n=i=4*(e-1);n<a&&!o[n];n+=r);fontOffsetBrowser=vectorCreate(s,(n-i)/r),releaseCanvas(t.canvas)}return vectorCreate(-fontOffsetBrowser.x*e*.01,-fontOffsetBrowser.y*e*.01)},createSimpleContext=(e=1,t=1)=>{const o=h("canvas").getContext("2d");return o.canvas.width=e,o.canvas.height=t,o},updateTextContext=(e,t)=>{const{fontSize:o=16,fontFamily:n="sans-serif",fontWeight:r="normal",fontVariant:a="normal",fontStyle:i="normal",textAlign:s="left",color:l="#000"}=t;e.font=`${i} ${a} ${r} ${o}px ${n}`,e.textBaseline="top",e.textAlign=s,e.fillStyle=Array.isArray(l)?colorArrayToRGBA(l):l},createSimpleTextContext=e=>{const t=createSimpleContext();return updateTextContext(t,e),t},computeLineHeight=(e,t)=>isFunction(t)?t(e):t,getMeasureVisibleWidth=e=>Math.abs(e.actualBoundingBoxLeft)+Math.abs(e.actualBoundingBoxRight),resizeContextToFitText=(e,t,o)=>{const{width:n,height:r}=measureTextContext(e,t,computeLineHeight(o.fontSize,o.lineHeight));return e.canvas.width=Math.ceil(n),e.canvas.height=Math.ceil(r),e},measureTextContext=(e,t,o)=>{const n=e.textAlign;e.textAlign="left";const r=t.split("\n"),a=r.reduce((t,o)=>{const n=getMeasureVisibleWidth(e.measureText(o));return n>t&&(t=n),t},1);e.textAlign=n;const i=o*r.length;return sizeCreate(Math.ceil(a),Math.ceil(i))},TextSizeCache=new Map,createTextSizeHash=(e,{fontSize:t,fontFamily:o,lineHeight:n,fontWeight:r,fontStyle:a,fontVariant:i})=>`${[e,t,r,a,i,o].join("_")}_${isFunction(n)?n(t):n}`,textSize=(e,t)=>{const o=createSimpleTextContext(t);t.width&&(e=wrapText(o,e,t.width));const n=createTextSizeHash(e,t);let r=TextSizeCache.get(n);return r?{...r}:(r=measureTextContext(o,e,computeLineHeight(t.fontSize,t.lineHeight)),TextSizeCache.set(n,r),{...r})},wrapText=(e,t,o)=>{if(0===t.length)return"";const n=[];let r,a="",i=0;const s=()=>{a.length&&(n[i]||(n[i]=[]),n[i].push(a),a="")},l=t=>{const n=a+t;(r=e.measureText(n).width)<o?a=n:(a.length?(s(),a=t):(a=n,s()),i++)},c=t=>{const n=a.length?a+" "+t:t;(r=e.measureText(n).width)<o?a=n:a.length?(s(),i++,c(t)):t.split("").forEach(l)};return t.split("\n\n").forEach(e=>{e.split("\n").forEach(e=>{e.split(" ").forEach(c),a.length&&s(),i++}),i++}),n.map(e=>e.join(" ")).join("\n")},drawText$1=(e,t="",o={})=>{if(0===t.length)return e;const{x:n=0,y:r=0,lineWidth:a=0,textAlign:i,fontSize:s,lineHeight:l}=o,c=vectorAdd(getBrowserFontOffset(s),vectorCreate(s/12,s/3.75)),p=n+c.x,u=r+c.y,d=isFunction(l)?l(s):l;let h="right"===i?a:"center"===i?.5*a:0;return t.split("\n").forEach((t,o)=>{e.fillText(t,p+h,u+o*d)}),e},shapeContain=(e,t)=>{const o=e.width/e.height,n=rectContainRect(t,o);return(e.width>n.width||e.height>n.height)&&(e.width=n.width,e.height=n.height),e},shapeCenter=(e,t)=>(e.x=t.x-.5*e.width,e.y=t.y-.5*e.height,e),shapeDeepCopy=e=>{const t={...e,backgroundImageElement:void 0},o=deepCopy(t);return e.backgroundImageElement&&(o.backgroundImageElement=e.backgroundImageElement),o},getContextSize=(e,t={})=>{const o=rectAspectRatio(e);let n,r;if(t.width&&t.height)return sizeClone(t);if(t.width||t.height){n=parseFloat(t.width||Number.MAX_SAFE_INTEGER),r=parseFloat(t.height||Number.MAX_SAFE_INTEGER);const e=Math.min(n,r);isString(t.width)||isString(t.height)?(n=`${e}%`,r=`${e*o}%`):(n=e,r=e)}else{const e=10;n=`${e}%`,r=`${e*o}%`}return{width:n,height:r}},shapeCreateFromEmoji=(e,t={})=>({width:void 0,height:void 0,...t,aspectRatio:1,backgroundImage:SVGToDataURL(getEmojiSVG(e))}),shapeCreateFromImage=(e,t,o={})=>{const n={width:void 0,height:void 0,aspectRatio:void 0,backgroundColor:[0,0,0,0],...o,backgroundImage:isString(e)?e:URL.createObjectURL(e)};return shapeLoadResources(n,t)},shapeLoadResources=(e,t=noop$1)=>{if(e.backgroundImage){if(/canvas/.test(e.backgroundImage.nodeName))return e.isComplete=!0,e.isError=!1,e.isLoading=!1,t(e.isError,e),e;if(e.isComplete)return t(e.isError,e),e;if(e.isLoading)return e;e.isComplete=!1,e.isError=!1,e.isLoading=!0;const o=t=>{if(e.backgroundSize)return;const o=t.width/t.height,n=e.width||t.width,r=n/o;e.width=n,e.height=r,e.aspectRatio=t.width/t.height};loadImage(e.backgroundImage,o).then(t=>{e.backgroundImageElement=t}).catch(t=>{e.isError=t}).finally(()=>{e.isLoading=!1,e.isComplete=!0,t(e.isError,e)})}return e},shapeCreateFromPreset=(e,t,o)=>{let n;if(isString(e)||isBinary(e))isEmoji(e)?(n=shapeCreateFromEmoji(e,getContextSize(t)),setTimeout(()=>o(void 0,n),0)):n=shapeCreateFromImage(e,o,{...getContextSize(t)});else if(e.src){const r={...e.shape,...getContextSize(t,e.shape||e)};isEmoji(e.src)?(n=shapeCreateFromEmoji(e.src,r),setTimeout(()=>o(void 0,n),0)):isString(e.src)&&(n=shapeCreateFromImage(e.src,o,r))}else e.shape&&(n=shapeDeepCopy(e.shape));return hasProp(n,"backgroundImage")&&(hasProp(n,"backgroundColor")||(n.backgroundColor=[0,0,0,0]),hasProp(n,"disableStyle")||(n.disableStyle=!0),hasProp(n,"disableFlip")||(n.disableFlip=!0)),t?shapeComputeDisplay(n,t):n},shapeLineGetStartPoint=e=>vectorCreate(e.x1,e.y1),shapeLineGetEndPoint=e=>vectorCreate(e.x2,e.y2),shapeTextUID=({text:e,textAlign:t,fontSize:o,fontFamily:n,lineHeight:r,fontWeight:a,fontStyle:i,fontVariant:s})=>`${[e,t,o,a,i,s,n].join("_")}_${isFunction(r)?r(o):r}`,shapeIsText=e=>hasProp(e,"text"),shapeIsTextLine=e=>shapeIsText(e)&&!(shapeHasRelativeSize(e)||hasProp(e,"width")),shapeIsTextBox=e=>shapeIsText(e)&&(shapeHasRelativeSize(e)||hasProp(e,"width")),shapeIsRect=e=>!shapeIsText(e)&&shapeHasComputedSize(e),shapeIsEllipse=e=>hasProp(e,"rx"),shapeIsLine=e=>hasProp(e,"x1")&&!shapeIsTriangle(e),shapeIsTriangle=e=>hasProp(e,"x3"),shapeIsPath=e=>hasProp(e,"points"),shapeIsTextEmpty=e=>shapeIsText(e)&&!e.text.length,shapeIsTextEditing=e=>shapeIsText(e)&&e.isEditing,shapeIsVisible=e=>!hasProp(e,"opacity")||e.opacity>0,shapeIsSelected=e=>e.isSelected,shapeIsDraft=e=>e.isDraft,shapeHasSize=e=>hasProp(e,"width")&&hasProp(e,"height"),shapeHasNumericStroke=e=>isNumber(e.strokeWidth)&&e.strokeWidth>0,shapeHasRelativePosition=e=>{const t=hasProp(e,"right"),o=hasProp(e,"bottom");return t||o},shapeHasTexture=e=>hasProp(e,"backgroundImage")||hasProp(e,"text"),shapeHasRelativeSize=e=>(hasProp(e,"x")||hasProp(e,"left"))&&hasProp(e,"right")||(hasProp(e,"y")||hasProp(e,"top"))&&hasProp(e,"bottom"),shapeHasComputedSize=e=>shapeHasSize(e)||shapeHasRelativeSize(e),shapeSelect=e=>(e.isSelected=!0,e),shapeMakeDraft=e=>(e.isDraft=!0,e),shapeCanStyle=(e,t)=>!0!==e.disableStyle&&(!isArray(e.disableStyle)||!e.disableStyle.includes(t)),shapeCanErase=e=>!0!==e.disableErase,shapeCanSelect=e=>!0!==e.disableSelect&&!shapeIsPath(e)&&!shapeIsTriangle(e),shapeCanRemove=e=>!0!==e.disableRemove,shapeCanDuplicate=e=>!0!==e.disableDuplicate&&shapeCanMove(e),shapeCanReorder=e=>!0!==e.disableReorder,shapeCanFlip=e=>!e.disableFlip&&(!shapeIsDraft(e)&&!shapeHasRelativePosition(e)&&shapeHasTexture(e)),shapeCanInput=(e,t)=>!!shapeIsText(e)&&(!0!==e.disableInput&&(isFunction(e.disableInput)?e.disableInput(null!=t?t:e.text):t||!0)),shapeCanMove=e=>!0!==e.disableMove&&!shapeIsDraft(e)&&!shapeIsPath(e)&&!shapeHasRelativePosition(e),shapeCanResize=e=>!0!==e.disableResize&&!shapeIsDraft(e)&&(shapeHasSize(e)||shapeIsTextBox(e)||shapeIsEllipse(e)||shapeIsLine(e))&&!shapeHasRelativePosition(e)&&shapeCanMove(e),shapeCanRotate=e=>!0!==e.disableRotate&&!shapeIsDraft(e)&&(shapeHasSize(e)||hasProp(e,"text")||shapeIsEllipse(e))&&!shapeHasRelativePosition(e),shapeDeleteRelativeProps=e=>(delete e.left,delete e.right,delete e.top,delete e.bottom,e),shapeDeleteTransformProps=e=>(delete e.rotation,e),shapeFormatStroke=e=>(e.strokeWidth=e.strokeWidth||1,e.strokeColor=e.strokeColor||[0,0,0],e),shapeFormatFill=e=>(e.backgroundColor=e.backgroundColor?e.backgroundColor:e.strokeWidth||e.backgroundImage?void 0:[0,0,0],e),autoLineHeight=e=>1.2*e,shapeFormatText=e=>(e.fontSize=e.fontSize||16,e.fontFamily=e.fontFamily||"sans-serif",e.fontWeight=e.fontWeight||"normal",e.fontStyle=e.fontStyle||"normal",e.fontVariant=e.fontVariant||"normal",e.lineHeight=isNumber(e.lineHeight)?e.lineHeight:autoLineHeight,e.color=e.color||[0,0,0],shapeIsTextLine(e)?shapeFormatTextLine(e):shapeFormatTextBox(e)),shapeFormatTextLine=e=>(delete e.textAlign,shapeDeleteRelativeProps(e)),shapeFormatTextBox=e=>(e.textAlign=e.textAlign||"left",e),shapeFormatRect=e=>(e.cornerRadius=e.cornerRadius||0,e.strokeWidth=e.strokeWidth||0,e.strokeColor=e.strokeColor||[0,0,0],shapeFormatFill(e)),shapeFormatTriangle=e=>(e.strokeWidth=e.strokeWidth||0,e.strokeColor=e.strokeColor||[0,0,0],shapeFormatFill(e),shapeDeleteRelativeProps(e)),shapeFormatEllipse=e=>(e.strokeWidth=e.strokeWidth||0,e.strokeColor=e.strokeColor||[0,0,0],shapeFormatFill(e)),shapeFormatPath=e=>(shapeFormatStroke(e),shapeDeleteTransformProps(e),shapeDeleteRelativeProps(e)),shapeFormatLine=e=>(shapeFormatStroke(e),e.lineStart=e.lineStart||void 0,e.lineEnd=e.lineEnd||void 0,shapeDeleteTransformProps(e),shapeDeleteRelativeProps(e)),shapeFormatDefaults=e=>{isString(e.id)||(e.id=getUniqueId()),hasProp(e,"rotation")||(e.rotation=0),hasProp(e,"opacity")||(e.opacity=1),hasProp(e,"disableErase")||(e.disableErase=!0)},shapeFormat=e=>(shapeFormatDefaults(e),shapeIsText(e)?shapeFormatText(e):shapeIsRect(e)?shapeFormatRect(e):shapeIsPath(e)?shapeFormatPath(e):shapeIsLine(e)?shapeFormatLine(e):shapeIsEllipse(e)?shapeFormatEllipse(e):shapeIsTriangle(e)&&shapeFormatTriangle(e),shapeLoadResources(e),e),shapeGetDescription=e=>shapeIsText(e)?"text":shapeIsRect(e)?"rectangle":shapeIsPath(e)?"path":shapeIsLine(e)?"line":shapeIsEllipse(e)?"ellipse":shapeIsTriangle(e)?"triangle":void 0,toPixelValue=(e,t)=>parseFloat(e)/100*t,shapeComputeValue=(e,t,{width:o,height:n})=>{if(!hasProp(e,t))return;let r=e[t];if(/points/.test(t)){const r=e[t];if(!isString(r[0].x))return;e[t]=r.map(e=>vectorCreate(toPixelValue(e.x,o),toPixelValue(e.y,n)))}else if(isString(r)){const a=parseFloat(r)/100;/^x|left|width|rx|fontSize|cornerRadius|strokeWidth/.test(t)?e[t]=o*a:/^right/.test(t)?e[t]=o-o*a:/^y|top|height|ry/.test(t)?e[t]=n*a:/^bottom/.test(t)&&(e[t]=n-n*a)}},displayProps=["width","height","left","top","right","bottom","x","y","rx","ry","points","fontSize","strokeWidth","lineHeight","x1","y1","x2","y2","x3","y3"],shapeComputeDisplay=(e,t)=>(displayProps.forEach(o=>shapeComputeValue(e,o,t)),shapeComputeRect(e,t),e),shapeGetPropPixelTotal=(e,t)=>{let o;return/^x|width|rx|fontSize|strokeWidth|cornerRadius/.test(e)?o=t.width:/^y|height|ry/.test(e)&&(o=t.height),o},shapeUpdateProp=(e,t,o,n)=>{if(!isString(e[t]))return e[t]=o;let r=shapeGetPropPixelTotal(t,n);return e[t]=toPercentage(o,r),e},shapeGetPropPixelValue=(e,t,o)=>isString(e[t])?toPixelValue(e[t],shapeGetPropPixelTotal(t,o)):e[t],shapeGetPropsPixelValues=(e,t,o)=>t.reduce((t,n)=>{const r=shapeGetPropPixelValue(e,n,o);return t[n]=r,t},{}),shapeUpdateProps=(e,t,o)=>(Object.keys(t).forEach(n=>shapeUpdateProp(e,n,t[n],o)),e),shapeComputeRect=(e,t)=>{if(hasProp(e,"left")&&(e.x=e.left),hasProp(e,"right")){const o=t.width-e.right;hasProp(e,"left")?(e.x=e.left,e.width=Math.max(0,o-e.left)):hasProp(e,"width")&&(e.x=o-e.width)}if(hasProp(e,"top")&&(e.y=e.top),hasProp(e,"bottom")){const o=t.height-e.bottom;hasProp(e,"top")?(e.y=e.top,e.height=Math.max(0,o-e.top)):hasProp(e,"height")&&(e.y=o-e.height)}return e},shapeComputeTransform=(e,t,o)=>(shapeIsPath(e)&&e.points.filter(e=>isNumber(e.x)).forEach(e=>{e.x*=o,e.y*=o,e.x+=t.x,e.y+=t.y}),shapeIsTriangle(e)&&isNumber(e.x1)&&(e.x1*=o,e.y1*=o,e.x2*=o,e.y2*=o,e.x3*=o,e.y3*=o,e.x1+=t.x,e.y1+=t.y,e.x2+=t.x,e.y2+=t.y,e.x3+=t.x,e.y3+=t.y),shapeIsLine(e)&&isNumber(e.x1)&&(e.x1*=o,e.y1*=o,e.x2*=o,e.y2*=o,e.x1+=t.x,e.y1+=t.y,e.x2+=t.x,e.y2+=t.y),isNumber(e.x)&&isNumber(e.y)&&(e.x*=o,e.y*=o,e.x+=t.x,e.y+=t.y),isNumber(e.width)&&isNumber(e.height)&&(e.width*=o,e.height*=o),isNumber(e.rx)&&isNumber(e.ry)&&(e.rx*=o,e.ry*=o),shapeHasNumericStroke(e)&&(e.strokeWidth*=o),shapeIsText(e)&&isNumber(e.fontSize)&&(e.fontSize*=o,isNumber(e.width)&&(e.width*=o)),hasProp(e,"cornerRadius")&&isNumber(e.cornerRadius)&&(e.cornerRadius*=o),e),shapeGetCenter=e=>{if(shapeIsRect(e))return vectorCreate(e.x+.5*e.width,e.y+.5*e.height);if(shapeIsEllipse(e))return vectorCreate(e.x,e.y);if(shapeIsTextBox(e)){const t=e.height||textSize(e.text,e).height;return vectorCreate(e.x+.5*e.width,e.y+.5*t)}if(shapeIsTextLine(e)){const t=textSize(e.text,e);return vectorCreate(e.x+.5*t.width,e.y+.5*t.height)}return shapeIsPath(e)?vectorCenter(e.points):shapeIsLine(e)?vectorCenter([shapeLineGetStartPoint(e),shapeLineGetEndPoint(e)]):void 0},shapeComputeLineEnd=(e,t,o,n,r)=>{let a={};const i=/solid/.test(n),s=5*t,l=i?s:s-1,c=i?.5*l:Math.ceil(.5*l),p=vectorNormalize(r),u=vectorMultiply(vectorClone(p),c),d=vectorClone(e),h=vectorClone(e);if(/arrow/.test(n)){let n=e.x,r=e.y;const l=vectorMultiply(vectorClone(p),s),d=vectorCreate(n+l.x,r+l.y);if(vectorMultiply(l,.55),i){const e=vectorMultiply(vectorClone(p),.5*c);n-=e.x,r-=e.y,a={points:[vectorCreate(n,r),vectorCreate(d.x-l.y,d.y+l.x),vectorCreate(d.x+l.y,d.y-l.x)],backgroundColor:o},h.x+=u.x,h.y+=u.y}else{const e=vectorMultiply(vectorPerpendicular(vectorClone(p)),.5),i=vectorCreate(n-e.x,r-e.y),s=vectorCreate(n+e.x,r+e.y);a={points:[vectorCreate(d.x+l.y,d.y-l.x),i,vectorCreate(n,r),s,vectorCreate(d.x-l.y,d.y+l.x)],strokeWidth:t,strokeColor:o}}}else/circle/.test(n)?(h.x+=u.x,h.y+=u.y,a={x:d.x,y:d.y,rx:c,ry:c,backgroundColor:i?o:void 0,strokeWidth:i?void 0:t,strokeColor:i?void 0:o}):/square/.test(n)?(h.x+=u.x,h.y+=u.y,a={x:d.x-c,y:d.y-c,width:2*c,height:2*c,rotation:vectorAngle(p),backgroundColor:i?o:void 0,strokeWidth:i?void 0:t,strokeColor:i?void 0:o}):"bar"===n&&(a={points:[vectorCreate(d.x-u.y,d.y+u.x),vectorCreate(d.x+u.y,d.y-u.x)],strokeWidth:t,strokeColor:o});return{position:h,shape:a}};var ctxRoundRect=(e,t,o,n,r,a)=>(n<2*a&&(a=n/2),r<2*a&&(a=r/2),e.beginPath(),e.moveTo(t+a,o),e.arcTo(t+n,o,t+n,o+r,a),e.arcTo(t+n,o+r,t,o+r,a),e.arcTo(t,o+r,t,o,a),e.arcTo(t,o,t+n,o,a),e.closePath(),e);const defineRectShape=(e,t)=>(t.cornerRadius>0?ctxRoundRect(e,t.x,t.y,t.width,t.height,t.cornerRadius):e.rect(t.x,t.y,t.width,t.height),e),fillRectShape=(e,t)=>(t.backgroundColor&&e.fill(),e),strokeRectShape=(e,t)=>(t.strokeWidth&&e.stroke(),e);var drawRect=async(e,t)=>new Promise((o,n)=>{e.lineWidth=t.strokeWidth?t.strokeWidth:1,e.strokeStyle=t.strokeColor?colorArrayToRGBA(t.strokeColor):"none",e.fillStyle=t.backgroundColor?colorArrayToRGBA(t.backgroundColor):"none",e.globalAlpha=t.opacity,t.backgroundImage?shapeLoadResources(t,(t,r)=>{if(t)return n(t);let a=0,i=0,s=r.backgroundImageElement.naturalWidth,l=r.backgroundImageElement.naturalHeight,c=r.x,p=r.y,u=r.width,d=r.height;if("contain"===r.backgroundSize){const e=rectContainRect(r,s/l);u=e.width,d=e.height,c+=e.x,p+=e.y}else if("cover"===r.backgroundSize){const e=rectContainRect(rectCreate(0,0,s,l),u/d);s=e.width,l=e.height,a=e.x,i=e.y}defineRectShape(e,r),fillRectShape(e,r),e.save(),e.clip(),e.drawImage(r.backgroundImageElement,a,i,s,l,c,p,u,d),e.restore(),strokeRectShape(e,r),o([])}):(defineRectShape(e,t),fillRectShape(e,t),strokeRectShape(e,t),o([]))}),drawEllipse=async(e,t)=>new Promise((o,n)=>{e.lineWidth=t.strokeWidth||1,e.strokeStyle=t.strokeColor?colorArrayToRGBA(t.strokeColor):"none",e.fillStyle=t.backgroundColor?colorArrayToRGBA(t.backgroundColor):"none",e.globalAlpha=t.opacity,e.ellipse(t.x,t.y,t.rx,t.ry,0,0,2*Math.PI),t.backgroundColor&&e.fill(),t.backgroundImage?shapeLoadResources(t,(r,a)=>{if(r)return n(r);e.drawImage(a.backgroundImageElement,t.x,t.y,t.width,t.height),t.strokeWidth&&e.stroke(),o([])}):t.strokeWidth&&e.stroke(),o([])}),drawText=async(e,t)=>{const o=t.width&&t.height?sizeCreateFromAny(t):textSize(t.text,t),n={x:t.x,y:t.y,width:t.width||o.width,height:o.height};drawRect(e,{...t,...n}),updateTextContext(e,t);let r=0;return"center"==t.textAlign?r=.5*-textPadding:"right"===t.textAlign&&(r=-textPadding),e.rect(t.x+r,t.y,t.width+2*textPadding,t.height),e.save(),e.clip(),drawText$1(e,t.width?wrapText(e,t.text,t.width):t.text,{x:t.x,y:t.y,fontSize:t.fontSize,textAlign:t.textAlign,lineHeight:t.lineHeight,lineWidth:t.width}),e.restore(),[]};const getLineEndStyle=e=>{if(e&&"none"!==e)return e};var drawLine=async(e,t)=>new Promise(async(o,n)=>{e.lineWidth=t.strokeWidth||1,e.strokeStyle=t.strokeColor?colorArrayToRGBA(t.strokeColor):"none",e.globalAlpha=t.opacity;let r=getLineEndStyle(t.lineStart),a=getLineEndStyle(t.lineEnd),i=shapeLineGetStartPoint(t),s=shapeLineGetEndPoint(t);const l=r&&shapeComputeLineEnd(i,t.strokeWidth,t.strokeColor,r,vectorCreate(s.x-i.x,s.y-i.y)),c=a&&shapeComputeLineEnd(s,t.strokeWidth,t.strokeColor,a,vectorCreate(i.x-s.x,i.y-s.y));i=l?l.position:i,s=c?c.position:s,e.moveTo(i.x,i.y),e.lineTo(s.x,s.y),t.strokeWidth&&e.stroke(),o([l&&l.shape,c&&c.shape].filter(Boolean))}),drawPath=async(e,t)=>new Promise((o,n)=>{e.lineWidth=t.strokeWidth||1,e.strokeStyle=t.strokeColor?colorArrayToRGBA(t.strokeColor):"none",e.fillStyle=t.backgroundColor?colorArrayToRGBA(t.backgroundColor):"none",e.globalAlpha=t.opacity;const{points:r}=t;e.moveTo(r[0].x,r[0].y);const a=r.length;for(let t=1;t<a;t++)e.lineTo(r[t].x,r[t].y);t.strokeWidth&&e.stroke(),t.backgroundColor&&e.fill(),o([])}),ctxFlip=(e,t,o,n)=>t||o?(e.translate(n.x,n.y),e.scale(t?-1:1,o?-1:1),e.translate(-n.x,-n.y),e):e;const drawShape=async(e,t)=>{const o=shapeGetCenter(t);let n;return ctxRotate(e,t.rotation,o),ctxFlip(e,t.flipX,t.flipY,o),shapeIsRect(t)?n=drawRect:shapeIsEllipse(t)?n=drawEllipse:shapeIsLine(t)?n=drawLine:shapeIsPath(t)?n=drawPath:shapeIsText(t)&&(n=drawText),n?[t,...await drawShapes(e,await n(e,t))]:[]};var drawShapes=async(e,t)=>{let o=[];for(const n of t)e.save(),e.beginPath(),o=[...o,...await drawShape(e,n)],e.restore();return o},drawImageData=async(e,t={})=>{const{shapes:o=[],context:n=e,transform:r=noop$1}=t;if(!o.length)return e;let a;const i=h("canvas");i.width=e.width,i.height=e.height;const s=i.getContext("2d");s.putImageData(e,0,0);const l=o.map(shapeDeepCopy).map(e=>shapeComputeDisplay(e,{x:0,y:0,width:n.width,height:n.height}));return r(s),await drawShapes(s,l),a=s.getImageData(0,0,i.width,i.height),releaseCanvas(i),a},fillImageData=async(e,t={})=>{const{backgroundColor:o}=t;if(!o||o&&0===o[3])return e;let n,r=h("canvas");r.width=e.width,r.height=e.height;const a=r.getContext("2d");return a.putImageData(e,0,0),a.globalCompositeOperation="destination-over",a.fillStyle=colorArrayToRGBA(o),a.fillRect(0,0,r.width,r.height),n=a.getImageData(0,0,r.width,r.height),releaseCanvas(r),n},dotColorMatrix=(e,t)=>{const o=new Array(20);return o[0]=e[0]*t[0]+e[1]*t[5]+e[2]*t[10]+e[3]*t[15],o[1]=e[0]*t[1]+e[1]*t[6]+e[2]*t[11]+e[3]*t[16],o[2]=e[0]*t[2]+e[1]*t[7]+e[2]*t[12]+e[3]*t[17],o[3]=e[0]*t[3]+e[1]*t[8]+e[2]*t[13]+e[3]*t[18],o[4]=e[0]*t[4]+e[1]*t[9]+e[2]*t[14]+e[3]*t[19]+e[4],o[5]=e[5]*t[0]+e[6]*t[5]+e[7]*t[10]+e[8]*t[15],o[6]=e[5]*t[1]+e[6]*t[6]+e[7]*t[11]+e[8]*t[16],o[7]=e[5]*t[2]+e[6]*t[7]+e[7]*t[12]+e[8]*t[17],o[8]=e[5]*t[3]+e[6]*t[8]+e[7]*t[13]+e[8]*t[18],o[9]=e[5]*t[4]+e[6]*t[9]+e[7]*t[14]+e[8]*t[19]+e[9],o[10]=e[10]*t[0]+e[11]*t[5]+e[12]*t[10]+e[13]*t[15],o[11]=e[10]*t[1]+e[11]*t[6]+e[12]*t[11]+e[13]*t[16],o[12]=e[10]*t[2]+e[11]*t[7]+e[12]*t[12]+e[13]*t[17],o[13]=e[10]*t[3]+e[11]*t[8]+e[12]*t[13]+e[13]*t[18],o[14]=e[10]*t[4]+e[11]*t[9]+e[12]*t[14]+e[13]*t[19]+e[14],o[15]=e[15]*t[0]+e[16]*t[5]+e[17]*t[10]+e[18]*t[15],o[16]=e[15]*t[1]+e[16]*t[6]+e[17]*t[11]+e[18]*t[16],o[17]=e[15]*t[2]+e[16]*t[7]+e[17]*t[12]+e[18]*t[17],o[18]=e[15]*t[3]+e[16]*t[8]+e[17]*t[13]+e[18]*t[18],o[19]=e[15]*t[4]+e[16]*t[9]+e[17]*t[14]+e[18]*t[19]+e[19],o},getColorMatrixFromColorMatrices=e=>e.length?e.reduce((e,t)=>dotColorMatrix([...e],t),e.shift()):[];const connect=(e,t=((...e)=>e),o)=>async(n,r,a)=>{let i;a(createProgressEvent(0,!1));let s=!1;try{i=await e(...t(n,r,e=>{s=!0,a(e)}))}catch(e){throw e}return o&&o(n,i),s||a(createProgressEvent(1,!1)),n},AnyToFile=({srcProp:e="src",destProp:t="dest"}={})=>[connect(srcToFile,(t,o,n)=>[t[e],n],(e,o)=>e[t]=o),"any-to-file"],BlobReadImageSize=({srcProp:e="src",destProp:t="size"}={})=>[connect(getImageSize,(t,o)=>[t[e]],(e,o)=>e[t]=o),"read-image-size"],ImageSizeMatchOrientation=({srcSize:e="size",srcOrientation:t="orientation",destSize:o="size"}={})=>[connect(orientImageSize,o=>[o[e],o[t]],(e,t)=>e[o]=t),"image-size-match-orientation"],BlobReadImageHead=({srcProp:e="src",destProp:t="head"}={})=>[connect((e,t)=>isJPEG(e)?blobReadSection(e,t):void 0,t=>[t[e],[0,65536],onprogress],(e,o)=>e[t]=o),"read-image-head"],ImageHeadReadExifOrientationTag=({srcProp:e="head",destProp:t="orientation"}={})=>[connect(arrayBufferReadExifOrientationTag,t=>[t[e]],(e,o)=>e[t]=o),"read-exif-orientation-tag"],ImageHeadClearExifOrientationTag=({srcProp:e="head"}={})=>[connect(arrayBufferWriteExifOrientationTag,t=>[t[e],1]),"clear-exif-orientation-tag"],ApplyCanvasScalar=({srcImageSize:e="size",srcCanvasSize:t="imageData",srcImageState:o="imageState",destImageSize:n="size",destScalar:r="scalar"}={})=>[connect((e,t,o)=>{const n=Math.min(t.width/e.width,t.height/e.height);if(1!==n){const{crop:e,annotation:t,decoration:r}=o,a=vectorCreateEmpty();e&&(o.crop=rectScale(e,n,a));const i=vectorCreateEmpty();o.annotation=t.map(e=>shapeComputeTransform(e,i,n)),o.decoration=r.map(e=>shapeComputeTransform(e,i,n))}return[n,sizeCreateFromAny(t)]},n=>[n[e],n[t],n[o]],(e,[t,o])=>{e[r]=t,e[n]=o}),"calculate-canvas-scalar"],BlobToImageData=({srcProp:e="src",destProp:t="imageData",canvasMemoryLimit:o})=>[connect(blobToImageData,t=>[t[e],o],(e,o)=>e[t]=o),"blob-to-image-data"],ImageDataMatchOrientation=({srcImageData:e="imageData",srcOrientation:t="orientation"}={})=>[connect(orientImageData,o=>[o[e],o[t]],(e,t)=>e.imageData=t),"image-data-match-orientation"],ImageDataFill=({srcImageData:e="imageData",srcImageState:t="imageState"}={})=>[connect(fillImageData,o=>[o[e],{backgroundColor:o[t].backgroundColor}],(e,t)=>e.imageData=t),"image-data-fill"],ImageDataCrop=({srcImageData:e="imageData",srcImageState:t="imageState"}={})=>[connect(cropImageData,o=>[o[e],{crop:o[t].crop,rotation:o[t].rotation,flipX:o[t].flipX,flipY:o[t].flipY}],(e,t)=>e.imageData=t),"image-data-crop"],ImageDataResize=({resize:e={width:void 0,height:void 0,fit:void 0,upscale:void 0},srcProp:t="imageData",srcImageState:o="imageState",destImageScaledSize:n="imageScaledSize"})=>[connect(resizeImageData,n=>[n[t],{width:Math.min(e.width||Number.MAX_SAFE_INTEGER,n[o].targetSize&&n[o].targetSize.width||Number.MAX_SAFE_INTEGER),height:Math.min(e.height||Number.MAX_SAFE_INTEGER,n[o].targetSize&&n[o].targetSize.height||Number.MAX_SAFE_INTEGER),fit:e.fit||"contain",upscale:e.upscale||!1}],(e,t)=>{sizeEqual(e.imageData,t)||(e[n]=sizeCreateFromAny(t)),e.imageData=t}),"image-data-resize"],ImageDataFilter=({srcImageData:e="imageData",srcImageState:t="imageState",destImageData:o="imageData"}={})=>[connect(filterImageData,o=>{const{colorMatrix:n}=o[t],r=n&&Object.keys(n).map(e=>n[e]).filter(Boolean);return[o[e],{colorMatrix:r&&getColorMatrixFromColorMatrices(r),convolutionMatrix:o[t].convolutionMatrix,gamma:o[t].gamma,noise:o[t].noise,vignette:o[t].vignette}]},(e,t)=>e[o]=t),"image-data-filter"],ImageDataAnnotate=({srcImageData:e="imageData",srcSize:t="size",srcImageState:o="imageState",destImageData:n="imageData",destImageScaledSize:r="imageScaledSize"}={})=>[connect(drawImageData,n=>[n[e],{shapes:n[o].annotation,context:n[t],transform:e=>{const a=n[t],{crop:i=rectCreateFromSize(a),rotation:s=0,flipX:l,flipY:c}=n[o],p=getImageTransformedRect(a,s),u=p.width,d=p.height,h=n[r],m=h?Math.min(h.width/i.width,h.height/i.height):1,g=.5*a.width-.5*u,f=.5*a.height-.5*d,_=sizeCenter(a);e.scale(m,m),e.translate(-g,-f),e.translate(-i.x,-i.y),e.translate(_.x,_.y),e.rotate(s),e.translate(-_.x,-_.y),e.scale(l?-1:1,c?-1:1),e.translate(l?-a.width:0,c?-a.height:0),e.rect(0,0,a.width,a.height),e.clip()}}],(e,t)=>e[n]=t),"image-data-annotate"],ImageDataDecorate=({srcImageData:e="imageData",srcImageState:t="imageState",destImageData:o="imageData",destImageScaledSize:n="imageScaledSize"}={})=>[connect(drawImageData,o=>[o[e],{shapes:o[t].decoration,context:o[t].crop,transform:e=>{const{crop:t}=o.imageState,r=o[n],a=r?Math.min(r.width/t.width,r.height/t.height):1;e.scale(a,a)}}],(e,t)=>e[o]=t),"image-data-decorate"],ImageDataToBlob=({mimeType:e,quality:t,srcImageData:o="imageData",srcFile:n="src",destBlob:r="blob"}={})=>[connect(imageDataToBlob,r=>[r[o],e||getMimeTypeFromFilename(r[n].name)||r[n].type,t],(e,t)=>e[r]=t),"image-data-to-blob"],BlobWriteImageHead=(e="blob",t="head",o="blob")=>[connect((e,t)=>isJPEG(e)&&t?blobWriteSection(e,arrayBufferReadImageHead(t),[20]):e,o=>[o[e],o[t]],(e,t)=>e[o]=t),"blob-write-image-head"],BlobToFile=({renameFile:e,srcBlob:t="blob",srcFile:o="src",destFile:n="dest",defaultFilename:r}={})=>[connect(blobToFile,n=>[n[t],e?e(n[o]):n[o].name||`${r}.${getExtensionFromMimeType(n[t].type)}`],(e,t)=>e[n]=t),"blob-to-file"],Store=({url:e="./",dataset:t=(e=>[["dest",e.dest,e.dest.name],["imageState",e.imageState]]),destStore:o="store"})=>[connect(async(t,o)=>{try{return await post(e,t,{onprogress:o})}catch(e){throw e}},(e,o,n)=>[t(e),n],(e,t)=>e[o]=t),"store"],PropFilter=e=>[connect(t=>e&&e.length?(Object.keys(t).forEach(o=>{e.includes(o)||delete t[o]}),t):t),"prop-filter"],createDefaultImageReader=(e={})=>{const{orientImage:t=!0,outputProps:o=["src","dest","size"],preprocessImageFile:n}=e;return[AnyToFile(),n&&[connect(n,(e,t,o)=>[e.dest,t,o],(e,t)=>e.dest=t),"preprocess-image-file"],BlobReadImageSize({srcProp:"dest"}),t&&BlobReadImageHead({srcProp:"dest"}),t&&ImageHeadReadExifOrientationTag(),t&&ImageSizeMatchOrientation(),PropFilter(o)].filter(Boolean)},createDefaultImageWriter=(e={})=>{const{canvasMemoryLimit:t=(isIOS()?16777216:1/0),orientImage:o=!0,copyImageHead:n=!0,mimeType:r,quality:a,renameFile:i,targetSize:s,store:l,outputProps:c=["src","dest","imageState","store"],preprocessImageState:p,postprocessImageData:u}=e;return[(o||n)&&BlobReadImageHead(),o&&ImageHeadReadExifOrientationTag(),BlobReadImageSize(),p&&[connect(p,(e,t,o)=>[e.imageState,t,o],(e,t)=>e.imageState=t),"preprocess-image-state"],BlobToImageData({canvasMemoryLimit:t}),ApplyCanvasScalar(),o&&ImageSizeMatchOrientation(),o&&ImageDataMatchOrientation(),ImageDataCrop(),ImageDataResize({resize:s}),ImageDataFilter(),ImageDataFill(),ImageDataAnnotate(),ImageDataDecorate(),u&&[connect(u,(e,t,o)=>[e.imageData,t,o],(e,t)=>e.imageData=t),"postprocess-image-data"],ImageDataToBlob({mimeType:r,quality:a}),o&&ImageHeadClearExifOrientationTag(),n&&BlobWriteImageHead(),BlobToFile({defaultFilename:"image",renameFile:i}),l&&(isString(l)?Store({url:l}):isFunction(l)?[l,"store"]:Store(l)),PropFilter(c)].filter(Boolean)};function noop(){}const identity=e=>e;function assign(e,t){for(const o in t)e[o]=t[o];return e}function run(e){return e()}function blank_object(){return Object.create(null)}function run_all(e){e.forEach(run)}function is_function(e){return"function"==typeof e}function safe_not_equal(e,t){return e!=e?t==t:e!==t||e&&"object"==typeof e||"function"==typeof e}function is_empty(e){return 0===Object.keys(e).length}function subscribe(e,...t){if(null==e)return noop;const o=e.subscribe(...t);return o.unsubscribe?()=>o.unsubscribe():o}function get_store_value(e){let t;return subscribe(e,e=>t=e)(),t}function component_subscribe(e,t,o){e.$$.on_destroy.push(subscribe(t,o))}function create_slot(e,t,o,n){if(e){const r=get_slot_context(e,t,o,n);return e[0](r)}}function get_slot_context(e,t,o,n){return e[1]&&n?assign(o.ctx.slice(),e[1](n(t))):o.ctx}function get_slot_changes(e,t,o,n){if(e[2]&&n){const r=e[2](n(o));if(void 0===t.dirty)return r;if("object"==typeof r){const e=[],o=Math.max(t.dirty.length,r.length);for(let n=0;n<o;n+=1)e[n]=t.dirty[n]|r[n];return e}return t.dirty|r}return t.dirty}function update_slot(e,t,o,n,r,a,i){const s=get_slot_changes(t,n,r,a);if(s){const r=get_slot_context(t,o,n,i);e.p(r,s)}}function exclude_internal_props(e){const t={};for(const o in e)"$"!==o[0]&&(t[o]=e[o]);return t}function set_store_value(e,t,o=t){return e.set(o),t}function action_destroyer(e){return e&&is_function(e.destroy)?e.destroy:noop}const is_client="undefined"!=typeof window;let now=is_client?()=>window.performance.now():()=>Date.now(),raf=is_client?e=>requestAnimationFrame(e):noop;const tasks=new Set;function run_tasks(e){tasks.forEach(t=>{t.c(e)||(tasks.delete(t),t.f())}),0!==tasks.size&&raf(run_tasks)}function loop(e){let t;return 0===tasks.size&&raf(run_tasks),{promise:new Promise(o=>{tasks.add(t={c:e,f:o})}),abort(){tasks.delete(t)}}}function append(e,t){e.appendChild(t)}function insert(e,t,o){e.insertBefore(t,o||null)}function detach(e){e.parentNode.removeChild(e)}function element(e){return document.createElement(e)}function svg_element(e){return document.createElementNS("http://www.w3.org/2000/svg",e)}function text(e){return document.createTextNode(e)}function space(){return text(" ")}function empty(){return text("")}function listen(e,t,o,n){return e.addEventListener(t,o,n),()=>e.removeEventListener(t,o,n)}function prevent_default(e){return function(t){return t.preventDefault(),e.call(this,t)}}function stop_propagation(e){return function(t){return t.stopPropagation(),e.call(this,t)}}function attr(e,t,o){null==o?e.removeAttribute(t):e.getAttribute(t)!==o&&e.setAttribute(t,o)}function set_attributes(e,t){const o=Object.getOwnPropertyDescriptors(e.__proto__);for(const n in t)null==t[n]?e.removeAttribute(n):"style"===n?e.style.cssText=t[n]:"__value"===n?e.value=e[n]=t[n]:o[n]&&o[n].set?e[n]=t[n]:attr(e,n,t[n])}function children(e){return Array.from(e.childNodes)}function set_data(e,t){t=""+t,e.wholeText!==t&&(e.data=t)}function set_input_value(e,t){e.value=null==t?"":t}function set_style(e,t,o,n){e.style.setProperty(t,o,n?"important":"")}function custom_event(e,t){const o=document.createEvent("CustomEvent");return o.initCustomEvent(e,!1,!1,t),o}const active_docs=new Set;let current_component,active=0;function hash(e){let t=5381,o=e.length;for(;o--;)t=(t<<5)-t^e.charCodeAt(o);return t>>>0}function create_rule(e,t,o,n,r,a,i,s=0){const l=16.666/n;let c="{\n";for(let e=0;e<=1;e+=l){const n=t+(o-t)*a(e);c+=100*e+`%{${i(n,1-n)}}\n`}const p=c+`100% {${i(o,1-o)}}\n}`,u=`__svelte_${hash(p)}_${s}`,d=e.ownerDocument;active_docs.add(d);const h=d.__svelte_stylesheet||(d.__svelte_stylesheet=d.head.appendChild(element("style")).sheet),m=d.__svelte_rules||(d.__svelte_rules={});m[u]||(m[u]=!0,h.insertRule(`@keyframes ${u} ${p}`,h.cssRules.length));const g=e.style.animation||"";return e.style.animation=`${g?`${g}, `:""}${u} ${n}ms linear ${r}ms 1 both`,active+=1,u}function delete_rule(e,t){const o=(e.style.animation||"").split(", "),n=o.filter(t?e=>e.indexOf(t)<0:e=>-1===e.indexOf("__svelte")),r=o.length-n.length;r&&(e.style.animation=n.join(", "),(active-=r)||clear_rules())}function clear_rules(){raf(()=>{active||(active_docs.forEach(e=>{const t=e.__svelte_stylesheet;let o=t.cssRules.length;for(;o--;)t.deleteRule(o);e.__svelte_rules={}}),active_docs.clear())})}function set_current_component(e){current_component=e}function get_current_component(){if(!current_component)throw new Error("Function called outside component initialization");return current_component}function onMount(e){get_current_component().$$.on_mount.push(e)}function afterUpdate(e){get_current_component().$$.after_update.push(e)}function onDestroy(e){get_current_component().$$.on_destroy.push(e)}function createEventDispatcher(){const e=get_current_component();return(t,o)=>{const n=e.$$.callbacks[t];if(n){const r=custom_event(t,o);n.slice().forEach(t=>{t.call(e,r)})}}}function setContext(e,t){get_current_component().$$.context.set(e,t)}function getContext(e){return get_current_component().$$.context.get(e)}function bubble(e,t){const o=e.$$.callbacks[t.type];o&&o.slice().forEach(e=>e(t))}const dirty_components=[],binding_callbacks=[],render_callbacks=[],flush_callbacks=[],resolved_promise=Promise.resolve();let update_scheduled=!1;function schedule_update(){update_scheduled||(update_scheduled=!0,resolved_promise.then(flush))}function add_render_callback(e){render_callbacks.push(e)}function add_flush_callback(e){flush_callbacks.push(e)}let flushing=!1;const seen_callbacks=new Set;function flush(){if(!flushing){flushing=!0;do{for(let e=0;e<dirty_components.length;e+=1){const t=dirty_components[e];set_current_component(t),update(t.$$)}for(set_current_component(null),dirty_components.length=0;binding_callbacks.length;)binding_callbacks.pop()();for(let e=0;e<render_callbacks.length;e+=1){const t=render_callbacks[e];seen_callbacks.has(t)||(seen_callbacks.add(t),t())}render_callbacks.length=0}while(dirty_components.length);for(;flush_callbacks.length;)flush_callbacks.pop()();update_scheduled=!1,flushing=!1,seen_callbacks.clear()}}function update(e){if(null!==e.fragment){e.update(),run_all(e.before_update);const t=e.dirty;e.dirty=[-1],e.fragment&&e.fragment.p(e.ctx,t),e.after_update.forEach(add_render_callback)}}let promise;function wait(){return promise||(promise=Promise.resolve()).then(()=>{promise=null}),promise}function dispatch(e,t,o){e.dispatchEvent(custom_event(`${t?"intro":"outro"}${o}`))}const outroing=new Set;let outros;function group_outros(){outros={r:0,c:[],p:outros}}function check_outros(){outros.r||run_all(outros.c),outros=outros.p}function transition_in(e,t){e&&e.i&&(outroing.delete(e),e.i(t))}function transition_out(e,t,o,n){if(e&&e.o){if(outroing.has(e))return;outroing.add(e),outros.c.push(()=>{outroing.delete(e),n&&(o&&e.d(1),n())}),e.o(t)}}const null_transition={duration:0};function create_bidirectional_transition(e,t,o,n){let r=t(e,o),a=n?0:1,i=null,s=null,l=null;function c(){l&&delete_rule(e,l)}function p(e,t){const o=e.b-a;return t*=Math.abs(o),{a:a,b:e.b,d:o,duration:t,start:e.start,end:e.start+t,group:e.group}}function u(t){const{delay:o=0,duration:n=300,easing:u=identity,tick:d=noop,css:h}=r||null_transition,m={start:now()+o,b:t};t||(m.group=outros,outros.r+=1),i||s?s=m:(h&&(c(),l=create_rule(e,a,t,n,o,u,h)),t&&d(0,1),i=p(m,n),add_render_callback(()=>dispatch(e,t,"start")),loop(t=>{if(s&&t>s.start&&(i=p(s,n),s=null,dispatch(e,i.b,"start"),h&&(c(),l=create_rule(e,a,i.b,i.duration,0,u,r.css))),i)if(t>=i.end)d(a=i.b,1-a),dispatch(e,i.b,"end"),s||(i.b?c():--i.group.r||run_all(i.group.c)),i=null;else if(t>=i.start){const e=t-i.start;a=i.a+i.d*u(e/i.duration),d(a,1-a)}return!(!i&&!s)}))}return{run(e){is_function(r)?wait().then(()=>{r=r(),u(e)}):u(e)},end(){c(),i=s=null}}}const globals="undefined"!=typeof window?window:"undefined"!=typeof globalThis?globalThis:global;function destroy_block(e,t){e.d(1),t.delete(e.key)}function outro_and_destroy_block(e,t){transition_out(e,1,1,()=>{t.delete(e.key)})}function update_keyed_each(e,t,o,n,r,a,i,s,l,c,p,u){let d=e.length,h=a.length,m=d;const g={};for(;m--;)g[e[m].key]=m;const f=[],_=new Map,$=new Map;for(m=h;m--;){const e=u(r,a,m),s=o(e);let l=i.get(s);l?n&&l.p(e,t):(l=c(s,e)).c(),_.set(s,f[m]=l),s in g&&$.set(s,Math.abs(m-g[s]))}const b=new Set,y=new Set;function x(e){transition_in(e,1),e.m(s,p),i.set(e.key,e),p=e.first,h--}for(;d&&h;){const t=f[h-1],o=e[d-1],n=t.key,r=o.key;t===o?(p=t.first,d--,h--):_.has(r)?!i.has(n)||b.has(n)?x(t):y.has(r)?d--:$.get(n)>$.get(r)?(y.add(n),x(t)):(b.add(r),d--):(l(o,i),d--)}for(;d--;){const t=e[d];_.has(t.key)||l(t,i)}for(;h;)x(f[h-1]);return f}function get_spread_update(e,t){const o={},n={},r={$$scope:1};let a=e.length;for(;a--;){const i=e[a],s=t[a];if(s){for(const e in i)e in s||(n[e]=1);for(const e in s)r[e]||(o[e]=s[e],r[e]=1);e[a]=s}else for(const e in i)r[e]=1}for(const e in n)e in o||(o[e]=void 0);return o}function get_spread_object(e){return"object"==typeof e&&null!==e?e:{}}function bind(e,t,o){const n=e.$$.props[t];void 0!==n&&(e.$$.bound[n]=o,o(e.$$.ctx[n]))}function create_component(e){e&&e.c()}function mount_component(e,t,o,n){const{fragment:r,on_mount:a,on_destroy:i,after_update:s}=e.$$;r&&r.m(t,o),n||add_render_callback(()=>{const t=a.map(run).filter(is_function);i?i.push(...t):run_all(t),e.$$.on_mount=[]}),s.forEach(add_render_callback)}function destroy_component(e,t){const o=e.$$;null!==o.fragment&&(run_all(o.on_destroy),o.fragment&&o.fragment.d(t),o.on_destroy=o.fragment=null,o.ctx=[])}function make_dirty(e,t){-1===e.$$.dirty[0]&&(dirty_components.push(e),schedule_update(),e.$$.dirty.fill(0)),e.$$.dirty[t/31|0]|=1<<t%31}function init(e,t,o,n,r,a,i=[-1]){const s=current_component;set_current_component(e);const l=e.$$={fragment:null,ctx:null,props:a,update:noop,not_equal:r,bound:blank_object(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(s?s.$$.context:t.context||[]),callbacks:blank_object(),dirty:i,skip_bound:!1};let c=!1;if(l.ctx=o?o(e,t.props||{},(t,o,...n)=>{const a=n.length?n[0]:o;return l.ctx&&r(l.ctx[t],l.ctx[t]=a)&&(!l.skip_bound&&l.bound[t]&&l.bound[t](a),c&&make_dirty(e,t)),o}):[],l.update(),c=!0,run_all(l.before_update),l.fragment=!!n&&n(l.ctx),t.target){if(t.hydrate){const e=children(t.target);l.fragment&&l.fragment.l(e),e.forEach(detach)}else l.fragment&&l.fragment.c();t.intro&&transition_in(e.$$.fragment),mount_component(e,t.target,t.anchor,t.customElement),flush()}set_current_component(s)}class SvelteComponent{$destroy(){destroy_component(this,1),this.$destroy=noop}$on(e,t){const o=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return o.push(t),()=>{const e=o.indexOf(t);-1!==e&&o.splice(e,1)}}$set(e){this.$$set&&!is_empty(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}const subscriber_queue=[];function readable(e,t){return{subscribe:writable(e,t).subscribe}}function writable(e,t=noop){let o;const n=[];function r(t){if(safe_not_equal(e,t)&&(e=t,o)){const t=!subscriber_queue.length;for(let t=0;t<n.length;t+=1){const o=n[t];o[1](),subscriber_queue.push(o,e)}if(t){for(let e=0;e<subscriber_queue.length;e+=2)subscriber_queue[e][0](subscriber_queue[e+1]);subscriber_queue.length=0}}}return{set:r,update:function(t){r(t(e))},subscribe:function(a,i=noop){const s=[a,i];return n.push(s),1===n.length&&(o=t(r)||noop),a(e),()=>{const e=n.indexOf(s);-1!==e&&n.splice(e,1),0===n.length&&(o(),o=null)}}}}function derived(e,t,o){const n=!Array.isArray(e),r=n?[e]:e,a=t.length<2;return readable(o,e=>{let o=!1;const i=[];let s=0,l=noop;const c=()=>{if(s)return;l();const o=t(n?i[0]:i,e);a?e(o):l=is_function(o)?o:noop},p=r.map((e,t)=>subscribe(e,e=>{i[t]=e,s&=~(1<<t),o&&c()},()=>{s|=1<<t}));return o=!0,c(),function(){run_all(p),l()}})}var mergeObjects=e=>e.reduce((e,t)=>Object.assign(e,t),{});const UPDATE_VALUE=e=>({updateValue:e}),DEFAULT_VALUE=e=>({defaultValue:e}),CUSTOM_STORE=e=>({store:e}),DERIVED_STORE=e=>({store:(t,o)=>derived(...e(o))}),UNIQUE_DERIVED_STORE=e=>({store:(t,o)=>{const[n,r,a=(()=>!1)]=e(o);let i,s=!0;return derived(n,(e,t)=>{r(e,e=>{!s&&a(i,e)||(i=e,s=!1,t(e))})})}}),MAP_STORE=e=>({store:(t,o)=>{const[n,r={}]=e(o);let a=[],i={};const s=e=>n(e,i),l=e=>{(a.length||e.length)&&(a=e,c())},c=()=>{const e=a.map(s);a=e,u(e)};Object.keys(r).forEach(e=>{r[e].subscribe(t=>{i[e]=t,t&&c()})});const{subscribe:p,set:u}=writable(t);return{set:l,update:e=>l(e(null)),subscribe:p}}}),createStore=(e,t,o)=>{const{store:n=(e=>writable(e)),defaultValue:r=noop$1,updateValue:a}=o,i=n(r(),t,e),{subscribe:s,update:l=noop$1}=i;let c;const p=e=>{let t=!0;c&&c(),c=s(o=>{if(t)return t=!1;e(o),c(),c=void 0})},u=a?a(e):passthrough;return i.set=(e=>l(t=>u(e,t,p))),i.defaultValue=r,i};var createStores=e=>{const t={},o={};return e.forEach(([e,...n])=>{const r=mergeObjects(n),a=t[e]=createStore(o,t,r),i={get:()=>get_store_value(a),set:a.set};Object.defineProperty(o,e,i)}),{stores:t,accessors:o}},props=[["src"],["imageReader"],["imageWriter"],["images",DEFAULT_VALUE(()=>[])]],pubsub=()=>{let e=[];return{sub:(t,o)=>(e.push({event:t,callback:o}),()=>e=e.filter(e=>e.event!==t||e.callback!==o)),pub:(t,o)=>{e.filter(e=>e.event===t).forEach(e=>e.callback(o))}}},capitalizeFirstLetter=e=>e.charAt(0).toUpperCase()+e.slice(1),defineMethods=(e,t)=>{Object.keys(t).forEach(o=>{const n=isFunction(t[o])?{value:t[o],writable:!1}:t[o];Object.defineProperty(e,o,n)})},fixPrecision=(e,t=12)=>parseFloat(e.toFixed(t));const scalar=1e4;var offsetRectToFitPolygon=(e,t)=>{const o=quadLines(t),n=vectorCreateEmpty();rectGetCorners(e).forEach(e=>{vectorAdd(e,n),polyPointIntersectionConvex(e,t)||o.forEach(t=>{const o=Math.atan2(t.start.y-t.end.y,t.start.x-t.end.x),r=1e4*Math.sin(Math.PI-o),a=1e4*Math.cos(Math.PI-o),i=vectorCreate(e.x+r,e.y+a),s=lineExtend(lineClone(t),1e4),l=lineLineIntersection(lineCreate(e,i),s);l&&vectorAdd(n,vectorSubtract(vectorClone(l),e))})});const r=rectClone(e);return vectorAdd(r,n),!!rectGetCorners(r).every(e=>polyPointIntersectionConvex(e,t))&&(rectUpdateWithRect(e,r),!0)},limitCropRectToImage=(e,t)=>{const o=rectGetCorners(e),n=quadLines(t).map(e=>lineExtend(e,5)),r=rectCenter(e),a=[];o.forEach(e=>{const t=lineMultiply(lineCreate(vectorClone(r),vectorClone(e)),1e6);let o=!1;n.map(lineClone).forEach(e=>{const n=lineLineIntersection(t,e);n&&!o&&(a.push(n),o=!0)})});const i=vectorDistance(a[0],a[2])<vectorDistance(a[1],a[3])?[a[0],a[2]]:[a[1],a[3]],s=rectCreateFromPoints(i);return s.width<e.width&&(rectUpdateWithRect(e,s),!0)},getImagePolygon=(e,t,o={x:0,y:0})=>{const n=rectCreateFromSize(e),r=rectCenter(n),a=rectApplyPerspective(n,o,r).map(e=>vectorRotate(e,t,r)),i=rectCreateFromPoints(a);return a.map(e=>vectorSubtract(e,i))},getMaxSizeInRect=(e,t=0,o=rectAspectRatio(e))=>{let n,r;if(0!==t){const a=Math.atan2(1,o),i=Math.sign(t)*t,s=i%Math.PI,l=i%HALF_PI;let c,p;p=s>QUART_PI&&s<HALF_PI+QUART_PI?l>QUART_PI?i:HALF_PI-l:l>QUART_PI?HALF_PI-l:i,c=Math.min(Math.abs(e.height/Math.sin(a+p)),Math.abs(e.width/Math.cos(a-p))),r=(n=Math.cos(a)*c)/o}else(r=(n=e.width)/o)>e.height&&(n=(r=e.height)*o);return sizeCreate(n,r)},limitRectToImage=(e,t,o=0,n=vectorCreateEmpty(),r)=>{if(isNumber(o)&&0!==o||n.x||n.y){const r=rectAspectRatio(e),a=getImagePolygon(t,o,n),i=getMaxSizeInRect(t,o,r);if(!(e.width<i.width&&e.height<i.height)){const t=.5*e.width-.5*i.width,o=.5*e.height-.5*i.height;e.width>i.width&&(e.width=i.width,e.x+=t),e.height>i.height&&(e.height=i.height,e.y+=o)}offsetRectToFitPolygon(e,a),limitCropRectToImage(e,a)&&offsetRectToFitPolygon(e,a)}else{let o=rectAspectRatio(e);e.width=Math.min(e.width,t.width),e.height=Math.min(e.height,t.height),e.x=Math.max(e.x,0),e.x+e.width>t.width&&(e.x-=e.x+e.width-t.width),e.y=Math.max(e.y,0),e.y+e.height>t.height&&(e.y-=e.y+e.height-t.height);const n=rectCenter(e),a=rectContainRect(e,o);a.width=Math.max(r.width,a.width),a.height=Math.max(r.height,a.height),a.x=n.x-.5*a.width,a.y=n.y-.5*a.height,rectUpdateWithRect(e,a)}},applyCropRectAction=(e,t,o,n,r,a,i,s)=>{const l=sizeClone(i),c=sizeClone(s),p=fixPrecision(Math.max(t.width/c.width,t.height/c.height)),u=fixPrecision(Math.min(t.width/l.width,t.height/l.height)),d=rectClone(t);if(u<1||p>1){const o=rectCenter(e),n=rectCenter(t),r=u<1?u:p,a=(n.x+o.x)/2,i=(n.y+o.y)/2,s=d.width/r,l=d.height/r;rectUpdate(d,a-.5*s,i-.5*l,s,l)}return a?(limitRectToImage(d,o,n,r,l),{crop:d}):{crop:d}},getBaseCropRect=(e,t,o,n={x:0,y:0})=>{const r=rectCreateFromSize(e),a=rectCenter(r),i=rectRotate(r,o,a),s=rectCenter(rectNormalizeOffset(rectCreateFromPoints(i))),l=rectCenter(t),c=vectorRotate(l,-o,s),p=vectorSubtract(c,s),u=vectorApply(vectorAdd(a,p),fixPrecision);return rectCreate(u.x-.5*t.width,u.y-.5*t.height,t.width,t.height)},clamp=(e,t,o)=>Math.max(t,Math.min(e,o)),applyRotationAction=(e,t,o,n,r,a,i,s,l,c)=>{const p=sizeClone(l);let u=sizeClone(c);i&&(u.width=Math.min(c.width,r.width),u.height=Math.min(c.height,r.height));let d=!1;const h=(t,o)=>{const l=getBaseCropRect(r,n,t,null),c=rectCreateFromSize(r),m=rectCenter(c),g=rectApplyPerspective(c,a,m),f=vectorSubtract(vectorClone(m),quadCentroid(g)),_=vectorRotate(rectCenter(l),o,m),$=vectorSubtract(vectorClone(m),_);g.forEach(e=>vectorRotate(e,o,m));const b=rectCreateFromPoints(g),y=quadCentroid(g),x=vectorAdd(vectorSubtract(vectorSubtract(y,$),b),f),v=rectCreate(x.x-.5*l.width,x.y-.5*l.height,l.width,l.height);if(s&&rectScale(v,s.width/v.width),i){const e=getImagePolygon(r,o,a);limitCropRectToImage(v,e)}const C=fixPrecision(Math.min(v.width/p.width,v.height/p.height),8),S=fixPrecision(Math.max(v.width/u.width,v.height/u.height),8);if(C<1||S>1){if(fixPrecision(Math.abs(o-t))===fixPrecision(Math.PI/2)&&!d)return d=!0,h(e,e+Math.sign(o-t)*Math.PI)}return{rotation:o,crop:rectApply(v,e=>fixPrecision(e,8))}},m=Math.sign(t)*Math.round(Math.abs(t)/HALF_PI)*HALF_PI,g=clamp(t,m+o[0],m+o[1]);return h(e,g)};const ORDERED_STATE_PROPS=["cropLimitToImage","cropMinSize","cropMaxSize","cropAspectRatio","flipX","flipY","rotation","crop","colorMatrix","convolutionMatrix","gamma","vignette","annotation","decoration","backgroundColor","targetSize"],clone=e=>isArray(e)?e.map(clone):isObject(e)?{...e}:e,excludedShapeProps=["isDraft","isFormatted","isComplete","isError","isLoading","isEditing","isSelected"],isSerializeAble=e=>!isElement(e),filterShapeState=e=>e.map(e=>Object.keys(e).reduce((t,o)=>excludedShapeProps.includes(o)||!isSerializeAble(e[o])?t:(t[o]=e[o],t),{}));var stateStore=(e,t,o)=>{const n=ORDERED_STATE_PROPS.map(e=>t[e]),{subscribe:r}=derived(n,(e,t)=>{const o=ORDERED_STATE_PROPS.reduce((t,o,n)=>(t[o]=clone(e[n]),t),{});o.crop&&rectApply(o.crop,Math.round),o.annotation=o.annotation&&filterShapeState(o.annotation),o.decoration=o.decoration&&filterShapeState(o.decoration),t(o)}),a=e=>{e&&(o.cropOrigin=void 0,ORDERED_STATE_PROPS.filter(t=>e.hasOwnProperty(t)).forEach(t=>{o[t]=clone(e[t])}))};return{set:a,update:e=>a(e(null)),subscribe:r}},toNumericAspectRatio=e=>{if(e){if(/:/.test(e)){const[t,o]=e.split(":");return t/o}return parseFloat(e)}},arrayEqual=(e,t)=>{if(e.length!==t.length)return!1;for(let o=0;o<e.length;o++)if(e[o]!==t[o])return!1;return!0};let result$6=null;var isAndroid=()=>(null===result$6&&(result$6=isUserAgent(/Android/)),result$6);let result$5=null;var isFirefox=()=>(null===result$5&&(result$5=isUserAgent(/Firefox/)),result$5);let result$4=null;var isEdge=()=>(null===result$4&&(result$4=isUserAgent(/Edge/)),result$4);let vendor;var getBrowserVendor=()=>vendor||(vendor=isIOS()?"ios":isAndroid()?"android":isFirefox()?"firefox":isInternetExplorer()?"ie":isEdge()?"edge":"chrome");let maxCanvasSze;var getMaxCanvasSize=()=>{if(!maxCanvasSze){const e={android:[14188,14188],ios:[4096,4096],chrome:[16384,16384],firefox:[11180,11180],edge:[16384,16384],ie:[16384,16384]};maxCanvasSze=e[getBrowserVendor()]||e.chrome}const[e,t]=maxCanvasSze;return{width:e,height:t}},padColorArray=(e=[0,0,0,0],t=1)=>4===e.length?e:[...e,t];const MIN_ROTATION=-QUART_PI,MAX_ROTATION=QUART_PI,isCropCentered=(e,t,o)=>{const n=vectorApply(rectCenter(e),e=>fixPrecision(e,8)),r=rectCreateFromSize(t),a=rectCenter(r),i=rectRotate(r,o,a),s=vectorApply(sizeCenter(rectCreateFromPoints(i)),e=>fixPrecision(e,8)),l=Math.abs(s.x-n.x),c=Math.abs(s.y-n.y);return l<1&&c<1},isCropMaxSize=(e,t,o)=>{const n=getMaxSizeInRect(t,o,rectAspectRatio(e));return sizeEqual(sizeApply(n,Math.round),sizeApply(sizeClone(e),Math.round))},updateCropRect=e=>(t,o=t)=>{const{loadState:n,size:r,cropMinSize:a,cropMaxSize:i,cropLimitToImage:s,rotation:l,perspective:c}=e;if(!t||!n||!n.beforeComplete)return t;const p=applyCropRectAction(o,t,r,l,c,s,a,i);return rectApply(p.crop,e=>fixPrecision(e,8))},updateCropAspectRatio=e=>t=>{const{loadState:o,crop:n,size:r,rotation:a}=e,i=toNumericAspectRatio(t);if(i){if(!o||!o.beforeComplete)return i;if(isCropCentered(n,r,a)){const o=sizeTurn(sizeClone(r),a);e.crop=rectApply(rectContainRect(rectCreateFromSize(o),t),fixPrecision)}else{const t={width:n.height*i,height:n.height},o=.5*(n.width-t.width),r=.5*(n.height-t.height);e.crop=rectApply(rectCreate(n.x+o,n.y+r,t.width,t.height),fixPrecision)}return i}},updateCropLimitToImage=e=>(t,o,n)=>(!o&&t&&n(()=>e.crop=rectClone(e.crop)),t),updateRotation=e=>(t,o,n)=>{if(t===o)return t;const{loadState:r,size:a,rotationRange:i,cropMinSize:s,cropMaxSize:l,crop:c,perspective:p,cropLimitToImage:u,cropOrigin:d}=e;if(!r||!r.beforeComplete)return t;const h=isCropMaxSize(c,a,o),m=isCropCentered(c,a,o),g=applyRotationAction(o,t,i,c,a,p,u,d,s,l);if(h&&m){const e=getMaxSizeInRect(a,t,rectAspectRatio(g.crop));g.crop.x+=.5*g.crop.width,g.crop.y+=.5*g.crop.height,g.crop.x-=.5*e.width,g.crop.y-=.5*e.height,g.crop.width=e.width,g.crop.height=e.height}return n(()=>{e.crop=rectApply(g.crop,e=>fixPrecision(e,8))}),g.rotation},updateRotationRange=(e,t,o,n)=>{const r=Math.max(o.width/n.width,o.height/n.height),a=sizeCreate(n.width*r,n.height*r),i=sizeHypotenuse(a);if(i<Math.min(e.width,e.height))return[MIN_ROTATION,MAX_ROTATION];const s=t?e.height:e.width,l=t?e.width:e.height,c=Math.acos(a.height/i),p=c-Math.acos(l/i),u=Math.asin(s/i)-c;if(Number.isNaN(p)&&Number.isNaN(u))return[MIN_ROTATION,MAX_ROTATION];const d=Number.isNaN(p)?u:Number.isNaN(u)?p:Math.min(p,u);return[Math.max(-d,MIN_ROTATION),Math.min(d,MAX_ROTATION)]},updateCropRange=(e,t,o,n,r,a)=>{let i=sizeClone(n),s=sizeClone(r);return a?[i,sizeApply(getMaxSizeInRect(e,t,o),Math.round)]:[i,s]},prepareShape=(e,t)=>(e.isFormatted||((e=shapeFormat(e)).isFormatted=!0),e.isDraft||!shapeHasRelativeSize(e)||e.context&&rectEqual(t.context,e.context)||((e=shapeComputeRect(e,t.context)).context={...t.context}),e);var imageProps=[["file"],["size"],["loadState"],["processState"],["aspectRatio",DERIVED_STORE(({size:e})=>[e,e=>e?rectAspectRatio(e):void 0])],["perspectiveX",DEFAULT_VALUE(()=>0)],["perspectiveY",DEFAULT_VALUE(()=>0)],["perspective",DERIVED_STORE(({perspectiveX:e,perspectiveY:t})=>[[e,t],([e,t])=>({x:e,y:t})])],["rotation",DEFAULT_VALUE(()=>0),UPDATE_VALUE(updateRotation)],["flipX",DEFAULT_VALUE(()=>!1)],["flipY",DEFAULT_VALUE(()=>!1)],["flip",DERIVED_STORE(({flipX:e,flipY:t})=>[[e,t],([e,t])=>({x:e,y:t})])],["isRotatedSideways",UNIQUE_DERIVED_STORE(({rotation:e})=>[[e],([e],t)=>t(isRotatedSideways(e)),(e,t)=>e!==t])],["crop",UPDATE_VALUE(updateCropRect)],["cropAspectRatio",UPDATE_VALUE(updateCropAspectRatio)],["cropOrigin"],["cropMinSize",DEFAULT_VALUE(()=>({width:1,height:1}))],["cropMaxSize",DEFAULT_VALUE(()=>sizeClone(getMaxCanvasSize()))],["cropLimitToImage",DEFAULT_VALUE(()=>!0),UPDATE_VALUE(updateCropLimitToImage)],["cropSize",UNIQUE_DERIVED_STORE(({crop:e})=>[[e],([e],t)=>{e&&t(sizeCreate(e.width,e.height))},(e,t)=>sizeEqual(e,t)])],["cropRectAspectRatio",DERIVED_STORE(({cropSize:e})=>[[e],([e],t)=>{e&&t(fixPrecision(rectAspectRatio(e),5))}])],["cropRange",UNIQUE_DERIVED_STORE(({size:e,rotation:t,cropRectAspectRatio:o,cropMinSize:n,cropMaxSize:r,cropLimitToImage:a})=>[[e,t,o,n,r,a],([e,t,o,n,r,a],i)=>{if(!e)return;i(updateCropRange(e,t,o,n,r,a))},(e,t)=>arrayEqual(e,t)])],["rotationRange",UNIQUE_DERIVED_STORE(({size:e,isRotatedSideways:t,cropMinSize:o,cropSize:n})=>[[e,t,o,n],([e,t,o,n],r)=>{if(!e||!n)return;r(updateRotationRange(e,t,o,n))},(e,t)=>arrayEqual(e,t)])],["backgroundColor",UPDATE_VALUE(()=>e=>padColorArray(e))],["targetSize"],["colorMatrix"],["convolutionMatrix"],["gamma"],["noise"],["vignette"],["annotation",MAP_STORE(({size:e})=>[prepareShape,{context:e}]),DEFAULT_VALUE(()=>[])],["decoration",MAP_STORE(({crop:e})=>[prepareShape,{context:e}]),DEFAULT_VALUE(()=>[])],["state",CUSTOM_STORE(stateStore)]],process=async(e,t,o={},n)=>{const{ontaskstart:r,ontaskprogress:a,ontaskend:i,token:s}=n;let l=!1;s.cancel=(()=>{l=!0});for(const[n,s]of t.entries()){if(l)return;const[t,c]=s;r(n,c);try{e=await t(e,{...o},e=>a(n,c,e))}catch(e){throw l=!0,e}i(n,c)}return e},createImage=({minSize:e={width:1,height:1}}={})=>{const{stores:t,accessors:o}=createStores(imageProps),{pub:n,sub:r}=pubsub(),a=(e,t)=>{const r=()=>o[e]||{},a=t=>o[e]={...r(),...t,timeStamp:Date.now()},i=()=>r().error,s=e=>{i()||(a({error:e}),n(`${t}error`,{...r()}))};return{start(){n(`${t}start`)},onabort(){n(`${t}abort`)},ontaskstart(e,o){i()||(a({index:e,task:o,taskProgress:void 0,taskLengthComputable:void 0}),n(`${t}taskstart`,{...r()}))},ontaskprogress(e,o,s){i()||(a({index:e,task:o,taskProgress:s.loaded/s.total,taskLengthComputable:s.lengthComputable}),n(`${t}taskprogress`,{...r()}),n(`${t}progress`,{...r()}))},ontaskend(e,o){i()||(a({index:e,task:o}),n(`${t}taskend`,{...r()}))},ontaskerror(e){s(e)},error(e){s(e)},beforeComplete(e){i()||(a({beforeComplete:!0}),n(`before${t}`,e))},complete(e){i()||(a({complete:!0}),n(t,e))}}};return defineMethods(o,{read:(t,{reader:n})=>{if(!n)return;Object.assign(o,{file:void 0,size:void 0,loadState:void 0});let r={cancel:noop$1},i=!1;const s=a("loadState","load"),l={token:r,...s},c={src:t,size:void 0,dest:void 0},p={};return(async()=>{try{s.start();const t=await process(c,n,p,l);if(i)return s.onabort();const{size:a,dest:u}=t||{};if(!a||!a.width||!a.height)throw new DokaError("Image size missing","IMAGE_SIZE_MISSING",t);if(a.width<e.width||a.height<e.height)throw new DokaError("Image too small","IMAGE_TOO_SMALL",{...t,minWidth:e.width,minHeight:e.height});Object.assign(o,{size:a,file:u}),o.crop||(o.crop=rectContainRect(rectCreateFromSize(a),o.cropAspectRatio)),o.state=o.state,s.beforeComplete(t),s.complete(t)}catch(e){s.error(e)}finally{r=void 0}})(),()=>{i=!0,r&&r.cancel()}},write:e=>{if(!o.loadState.complete)return;o.processState=void 0;const t=a("processState","process"),n={src:o.file,imageState:o.state,dest:void 0};if(!e)return t.start(),void t.complete(n);let r={cancel:noop$1};const i={},s={token:r,...t};return(async()=>{t.start();try{const o=await process(n,e,i,s);t.complete(o)}catch(e){t.error(e)}finally{r=void 0}})(),()=>r&&r.cancel()},on:r}),{accessors:o,stores:t}};const editorEventsToBubble=["loadstart","loadabort","loaderror","loadprogress","load","processstart","processabort","processerror","processprogress","process"],imagePrivateProps=["flip","cropOrigin","isRotatedSideways","perspective","perspectiveX","perspectiveY","cropRange"],editorPrivateProps=["images"],getImagePropGroupedName=e=>`image${capitalizeFirstLetter(e)}`,getEditorProps$1=()=>{const e=getImagePublicPropNames(imageProps).map(getImagePropGroupedName),t=props.map(([e])=>e).filter(e=>!editorPrivateProps.includes(e));return e.concat(t)},getImagePublicPropNames=e=>e.map(([e])=>e).filter(e=>!imagePrivateProps.includes(e));var createImageEditor=()=>{const{stores:e,accessors:t}=createStores(props),{sub:o,pub:n}=pubsub(),r=()=>t.images?t.images[0]:{};let a={};getImagePublicPropNames(imageProps).forEach(e=>{Object.defineProperty(t,getImagePropGroupedName(e),{get:()=>{const t=r();if(t)return t.accessors[e]},set:t=>{const o=r();o?o.accessors[e]=t:a[e]=t}})});const i=e.src.subscribe(e=>e?t.imageReader?t.images.length?void u(e).catch(()=>{}):l(e):void 0:t.images=[]),s=e.imageReader.subscribe(e=>{e&&(t.images.length||t.src&&l(t.src).catch(()=>{}))}),l=e=>Promise.resolve().then(()=>u(e,a)),c=()=>t.images&&t.images[0];let p;const u=(e,o={})=>new Promise((r,i)=>{let s=c();const l=o.cropMinSize||s&&s.accessors.cropMinSize;s&&h(),s=createImage({minSize:l}),editorEventsToBubble.map(e=>s.accessors.on(e,(e=>t=>n(e,t))(e)));const u=()=>{a={},d(),m()},d=s.accessors.on("loaderror",e=>{u(),i(e)});s.accessors.on("beforeload",()=>{const e=getImagePublicPropNames(imageProps).reduce((e,t)=>{if(t in o)return e[t]=o[t],e;{const n=getImagePropGroupedName(t);n in o&&(e[t]=o[n])}return e},{});["cropLimitToImage","crop","cropAspectRatio","rotation"].forEach(t=>{t in e&&(s.accessors[t]=e[t],delete e[t])}),Object.assign(s.accessors,e)});const m=s.accessors.on("load",e=>{p=void 0,u(),r(e)});t.images=[s],o.imageReader&&(t.imageReader=o.imageReader),o.imageWriter&&(t.imageWriter=o.imageWriter),p=s.accessors.read(e,{reader:t.imageReader})});let d;const h=()=>{const e=c();e&&(p&&p(),e.accessors.loadState=void 0,t.images=[])};return Object.defineProperty(t,"stores",{get:()=>e}),defineMethods(t,{on:o,loadImage:u,abortLoadImage:()=>{t.images=[]},editImage:(e,o)=>new Promise((n,r)=>{u(e,o).then(()=>{const{images:e}=t,o=e[0],a=()=>{i(),s()},i=o.accessors.on("processerror",e=>{a(),r(e)}),s=o.accessors.on("process",e=>{a(),n(e)})}).catch(r)}),removeImage:h,processImage:(e,o)=>new Promise(async(n,r)=>{e&&await u(e,o);const a=c();if(!a)return r("no image");const i=()=>{d=void 0,s(),l()},s=a.accessors.on("processerror",e=>{i(),r(e)}),l=a.accessors.on("process",e=>{i(),n(e)});d=a.accessors.write(t.imageWriter)}),abortProcessImage:()=>{const e=c();e&&(d&&d(),e.accessors.processState=void 0)},destroy:()=>{i(),s()}}),t},getComponentExportedProps=e=>{const t=Object.getOwnPropertyDescriptors(e.prototype);return Object.keys(t).filter(e=>!!t[e].get)};function circOut(e){return Math.sqrt(1- --e*e)}function is_date(e){return"[object Date]"===Object.prototype.toString.call(e)}function get_interpolator(e,t){if(e===t||e!=e)return()=>e;const o=typeof e;if(o!==typeof t||Array.isArray(e)!==Array.isArray(t))throw new Error("Cannot interpolate values of different type");if(Array.isArray(e)){const o=t.map((t,o)=>get_interpolator(e[o],t));return e=>o.map(t=>t(e))}if("object"===o){if(!e||!t)throw new Error("Object cannot be null");if(is_date(e)&&is_date(t)){e=e.getTime();const o=(t=t.getTime())-e;return t=>new Date(e+t*o)}const o=Object.keys(t),n={};return o.forEach(o=>{n[o]=get_interpolator(e[o],t[o])}),e=>{const t={};return o.forEach(o=>{t[o]=n[o](e)}),t}}if("number"===o){const o=t-e;return t=>e+t*o}throw new Error(`Cannot interpolate ${o} values`)}function tweened(e,t={}){const o=writable(e);let n,r=e;function a(a,i){if(null==e)return o.set(e=a),Promise.resolve();r=a;let s=n,l=!1,{delay:c=0,duration:p=400,easing:u=identity,interpolate:d=get_interpolator}=assign(assign({},t),i);if(0===p)return s&&(s.abort(),s=null),o.set(e=r),Promise.resolve();const h=now()+c;let m;return(n=loop(t=>{if(t<h)return!0;l||(m=d(e,a),"function"==typeof p&&(p=p(e,a)),l=!0),s&&(s.abort(),s=null);const n=t-h;return n>p?(o.set(e=a),!1):(o.set(e=m(u(n/p))),!0)})).promise}return{set:a,update:(t,o)=>a(t(r,e),o),subscribe:o.subscribe}}function tick_spring(e,t,o,n){if("number"==typeof o){const r=n-o,a=(o-t)/(e.dt||1/60),i=(a+(e.opts.stiffness*r-e.opts.damping*a)*e.inv_mass)*e.dt;return Math.abs(i)<e.opts.precision&&Math.abs(r)<e.opts.precision?n:(e.settled=!1,o+i)}if(isArray(o))return o.map((r,a)=>tick_spring(e,t[a],o[a],n[a]));if("object"==typeof o){const r={};for(const a in o)r[a]=tick_spring(e,t[a],o[a],n[a]);return r}throw new Error(`Cannot spring ${typeof o} values`)}function spring(e,t={}){const o=writable(e),{stiffness:n=.15,damping:r=.8,precision:a=.01}=t;let i,s,l,c=e,p=e,u=1,d=0,h=!1;function m(t,n={}){p=t;const r=l={};if(null==e||n.hard||g.stiffness>=1&&g.damping>=1)return h=!0,i=null,c=t,o.set(e=p),Promise.resolve();if(n.soft){const e=!0===n.soft?.5:+n.soft;d=1/(60*e),u=0}if(!s){i=null,h=!1;const t={inv_mass:void 0,opts:g,settled:!0,dt:void 0};s=loop(n=>{if(null===i&&(i=n),h)return h=!1,s=null,!1;u=Math.min(u+d,1),t.inv_mass=u,t.opts=g,t.settled=!0,t.dt=60*(n-i)/1e3;const r=tick_spring(t,c,e,p);return i=n,c=e,o.set(e=r),t.settled&&(s=null),!t.settled})}return new Promise(e=>{s.promise.then(()=>{r===l&&e()})})}const g={set:m,update:(t,o)=>m(t(p,e),o),subscribe:o.subscribe,stiffness:n,damping:r,precision:a};return g}var prefersReducedMotion=readable(!1,e=>{const t=window.matchMedia("(prefers-reduced-motion:reduce)");e(t.matches),t.onchange=(()=>e(t.matches))}),hasResizeObserver=()=>"ResizeObserver"in window;const rectNext=rectCreateEmpty(),updateNodeRect=(e,t,o,n,r)=>{e.rect||(e.rect=rectCreateEmpty());const a=e.rect;rectUpdate(rectNext,t,o,n,r),rectEqual(a,rectNext)||(rectUpdateWithRect(a,rectNext),e.dispatchEvent(new CustomEvent("measure",{detail:a})))},r=Math.round,measureViewRect=e=>{const t=e.getBoundingClientRect();updateNodeRect(e,r(t.x),r(t.y),r(t.width),r(t.height))},measureOffset=e=>updateNodeRect(e,e.offsetLeft,e.offsetTop,e.offsetWidth,e.offsetHeight),elements=[];let observer,frame=null;function tick(){elements.length?(elements.forEach(e=>e.measure(e)),frame=requestAnimationFrame(tick)):frame=null}var measurable=(e,t={})=>{const{observePosition:o=!1,observeViewRect:n=!1,once:r=!1,disabled:a=!1}=t;if(!a)return!hasResizeObserver()||o||n?(e.measure=n?measureViewRect:measureOffset,elements.push(e),frame||(frame=requestAnimationFrame(tick)),e.measure(e),{destroy(){const t=elements.indexOf(e);elements.splice(t,1)}}):(observer||(observer=new ResizeObserver(e=>{e.forEach(e=>measureOffset(e.target))})),observer.observe(e),measureOffset(e),r&&observer.unobserve(e),{destroy(){r||observer.unobserve(e)}})},focusvisible=e=>{let t=!1;const o={pointerdown:()=>{t=!1},keydown:()=>{t=!0},keyup:()=>{t=!1},focus:e=>{t&&(e.target.dataset.focusVisible="")},blur:e=>{delete e.target.dataset.focusVisible}};return Object.keys(o).forEach(t=>e.addEventListener(t,o[t],!0)),{destroy(){Object.keys(o).forEach(t=>e.removeEventListener(t,o[t],!0))}}},isImage=e=>/^image/.test(e.type);const getFilesFromEvent=e=>{const{items:t,files:o}=e.dataTransfer;return t?Array.from(t).filter(e=>"file"===e.kind).map(e=>e.getAsFile()):Array.from(o)||[]};var dropable=e=>{const t=e=>{e.preventDefault()},o=t=>{t.preventDefault(),t.stopPropagation(),e.dispatchEvent(new CustomEvent("dropfiles",{detail:{event:t,files:getFilesFromEvent(t).filter(e=>isImage(e))}}))};return e.addEventListener("drop",o),e.addEventListener("dragover",t),{destroy(){e.removeEventListener("drop",o),e.removeEventListener("dragover",t)}}};let result$3=null;var supportsWebGL2=()=>{if(null===result$3)if("WebGL2RenderingContext"in window){let e;try{e=h("canvas"),result$3=!!e.getContext("webgl2")}catch(e){result$3=!1}e&&releaseCanvas(e)}else result$3=!1;return result$3},isPowerOf2=e=>0==(e&e-1),stringReplace=(e,t={},o="",n="")=>Object.keys(t).filter(e=>!isObject(t[e])).reduce((e,r)=>e.replace(new RegExp(o+r+n),t[r]),e),SHADER_FRAG_HEAD="#version 300 es\nprecision highp float;\n\nout vec4 fragColor;",SHADER_FRAG_INIT="\nfloat a=1.0;vec4 fillColor=uColor;vec4 textureColor=texture(uTexture,vTexCoord);textureColor*=(1.0-step(1.0,vTexCoord.y))*step(0.0,vTexCoord.y)*(1.0-step(1.0,vTexCoord.x))*step(0.0,vTexCoord.x);",SHADER_FRAG_MASK="\nuniform float uMaskFeather[8];uniform float uMaskBounds[4];uniform float uMaskOpacity;float mask(float x,float y,float bounds[4],float opacity){return 1.0-(1.0-(smoothstep(bounds[3],bounds[3]+1.0,x)*(1.0-smoothstep(bounds[1]-1.0,bounds[1],x))*(1.0-step(bounds[0],y))*step(bounds[2],y)))*(1.0-opacity);}",SHADER_FRAG_MASK_APPLY="\nfloat m=mask(gl_FragCoord.x,gl_FragCoord.y,uMaskBounds,uMaskOpacity);",SHADER_FRAG_MASK_FEATHER_APPLY="\nfloat leftFeatherOpacity=step(uMaskFeather[1],gl_FragCoord.x)*uMaskFeather[0]+((1.0-uMaskFeather[0])*smoothstep(uMaskFeather[1],uMaskFeather[3],gl_FragCoord.x));float rightFeatherOpacity=(1.0-step(uMaskFeather[7],gl_FragCoord.x))*uMaskFeather[4]+((1.0-uMaskFeather[4])*smoothstep(uMaskFeather[7],uMaskFeather[5],gl_FragCoord.x));a*=leftFeatherOpacity*rightFeatherOpacity;",SHADER_FRAG_RECT_AA="\nvec2 scaledPoint=vec2(vRectCoord.x*uSize.x,vRectCoord.y*uSize.y);a*=smoothstep(0.0,1.0,uSize.x-scaledPoint.x);a*=smoothstep(0.0,1.0,uSize.y-scaledPoint.y);a*=smoothstep(0.0,1.0,scaledPoint.x);a*=smoothstep(0.0,1.0,scaledPoint.y);",SHADER_FRAG_CORNER_RADIUS="\nvec2 s=(uSize-2.0)*.5;vec2 r=(vRectCoord*uSize);vec2 p=r-(uSize*.5);float cornerRadius=uCornerRadius[0];bool left=r.x<s.x;bool top=r.y<s.x;if(!left&&top){cornerRadius=uCornerRadius[1];}if(!left&&!top){cornerRadius=uCornerRadius[3];}if(left&&!top){cornerRadius=uCornerRadius[2];}a*=1.0-clamp(length(max(abs(p)-(s-cornerRadius),0.0))-cornerRadius,0.0,1.0);",SHADER_FRAG_SHAPE_BLEND_COLOR="\nfillColor.a*=a;fillColor.rgb*=fillColor.a;fillColor.rgb*=m;fillColor.rgb+=(1.0-m)*(uCanvasColor.rgb*fillColor.a);textureColor*=uTextureOpacity;textureColor.a*=a;textureColor.rgb*=m*a;textureColor.rgb+=(1.0-m)*(uCanvasColor.rgb*textureColor.a);fragColor=textureColor+(fillColor*(1.0-textureColor.a));",SHADER_FRAG_TEXTURE_COLORIZE="\nif(uTextureColor.a!=0.0&&textureColor.a>0.0){vec3 colorFlattened=textureColor.rgb/textureColor.a;if(colorFlattened.r>.999999&&colorFlattened.g==0.0&&colorFlattened.b>.999999){textureColor.rgb=uTextureColor.rgb*textureColor.a;}textureColor*=uTextureColor.a;}",SHADER_VERT_HEAD="#version 300 es\n\nin vec4 aPosition;uniform mat4 uMatrix;",SHADER_VERT_MULTIPLY_MATRUX="\ngl_Position=uMatrix*vec4(aPosition.x,aPosition.y,0,1);",SHADER_VERT_TEXTURE="\nin vec2 aTexCoord;out vec2 vTexCoord;";const SHADER_VERT_SNIPPETS={head:SHADER_VERT_HEAD,text:SHADER_VERT_TEXTURE,matrix:SHADER_VERT_MULTIPLY_MATRUX},SHADER_FRAG_SNIPPETS={head:SHADER_FRAG_HEAD,mask:SHADER_FRAG_MASK,init:SHADER_FRAG_INIT,colorize:SHADER_FRAG_TEXTURE_COLORIZE,maskapply:SHADER_FRAG_MASK_APPLY,maskfeatherapply:SHADER_FRAG_MASK_FEATHER_APPLY,edgeaa:SHADER_FRAG_RECT_AA,cornerradius:SHADER_FRAG_CORNER_RADIUS,fragcolor:SHADER_FRAG_SHAPE_BLEND_COLOR},transpileShader=(e,t,o)=>(t=stringReplace(t,o===e.VERTEX_SHADER?SHADER_VERT_SNIPPETS:SHADER_FRAG_SNIPPETS,"##").trim(),supportsWebGL2()?t:(t=(t=t.replace(/#version.+/gm,"").trim()).replace(/^\/\/\#/gm,"#"),o===e.VERTEX_SHADER&&(t=t.replace(/in /gm,"attribute ").replace(/out /g,"varying ")),o===e.FRAGMENT_SHADER&&(t=t.replace(/in /gm,"varying ").replace(/out.*?;/gm,"").replace(/texture\(/g,"texture2D(").replace(/fragColor/g,"gl_FragColor")),`${t}`)),compileShader=(e,t,o)=>{const n=e.createShader(o),r=transpileShader(e,t,o);return e.shaderSource(n,r),e.compileShader(n),e.getShaderParameter(n,e.COMPILE_STATUS)||console.error(e.getShaderInfoLog(n)),n},createShader=(e,t,o,n,r)=>{const a=e.createProgram();e.attachShader(a,compileShader(e,t,e.VERTEX_SHADER)),e.attachShader(a,compileShader(e,o,e.FRAGMENT_SHADER)),e.linkProgram(a);const i={};return n.forEach(t=>{i[t]=e.getAttribLocation(a,t)}),r.forEach(t=>{i[t]=e.getUniformLocation(a,t)}),{program:a,locations:i}},canMipMap=e=>!!supportsWebGL2()||isPowerOf2(e.width)&&isPowerOf2(e.height),applyTextureProperties=(e,t)=>{e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,canMipMap(t)?e.LINEAR_MIPMAP_LINEAR:e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),canMipMap(t)&&e.generateMipmap(e.TEXTURE_2D)},createTexture=(e,t)=>{const o=e.createTexture();return e.bindTexture(e.TEXTURE_2D,o),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,t),applyTextureProperties(e,t),e.bindTexture(e.TEXTURE_2D,null),o},applyOpacity=(e,t=1)=>e?[e[0],e[1],e[2],isNumber(e[3])?t*e[3]:t]:[0,0,0,0],mat4Create=()=>{const e=new Float32Array(16);return e[0]=1,e[5]=1,e[10]=1,e[15]=1,e},mat4Perspective=(e,t,o,n,r)=>{const a=1/Math.tan(t/2),i=1/(n-r);e[0]=a/o,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=a,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=(r+n)*i,e[11]=-1,e[12]=0,e[13]=0,e[14]=2*r*n*i,e[15]=0},mat4Ortho=(e,t,o,n,r,a,i)=>{const s=1/(t-o),l=1/(n-r),c=1/(a-i);e[0]=-2*s,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*l,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=2*c,e[11]=0,e[12]=(t+o)*s,e[13]=(r+n)*l,e[14]=(i+a)*c,e[15]=1},mat4Translate=(e,t,o,n)=>{e[12]=e[0]*t+e[4]*o+e[8]*n+e[12],e[13]=e[1]*t+e[5]*o+e[9]*n+e[13],e[14]=e[2]*t+e[6]*o+e[10]*n+e[14],e[15]=e[3]*t+e[7]*o+e[11]*n+e[15]},mat4Scale=(e,t)=>{e[0]=e[0]*t,e[1]=e[1]*t,e[2]=e[2]*t,e[3]=e[3]*t,e[4]=e[4]*t,e[5]=e[5]*t,e[6]=e[6]*t,e[7]=e[7]*t,e[8]=e[8]*t,e[9]=e[9]*t,e[10]=e[10]*t,e[11]=e[11]*t},mat4ScaleX=(e,t)=>{e[0]=e[0]*t,e[1]=e[1]*t,e[2]=e[2]*t,e[3]=e[3]*t},mat4ScaleY=(e,t)=>{e[4]=e[4]*t,e[5]=e[5]*t,e[6]=e[6]*t,e[7]=e[7]*t},mat4RotateX=(e,t)=>{const o=Math.sin(t),n=Math.cos(t),r=e[4],a=e[5],i=e[6],s=e[7],l=e[8],c=e[9],p=e[10],u=e[11];e[4]=r*n+l*o,e[5]=a*n+c*o,e[6]=i*n+p*o,e[7]=s*n+u*o,e[8]=l*n-r*o,e[9]=c*n-a*o,e[10]=p*n-i*o,e[11]=u*n-s*o},mat4RotateY=(e,t)=>{const o=Math.sin(t),n=Math.cos(t),r=e[0],a=e[1],i=e[2],s=e[3],l=e[8],c=e[9],p=e[10],u=e[11];e[0]=r*n-l*o,e[1]=a*n-c*o,e[2]=i*n-p*o,e[3]=s*n-u*o,e[8]=r*o+l*n,e[9]=a*o+c*n,e[10]=i*o+p*n,e[11]=s*o+u*n},mat4RotateZ=(e,t)=>{const o=Math.sin(t),n=Math.cos(t),r=e[0],a=e[1],i=e[2],s=e[3],l=e[4],c=e[5],p=e[6],u=e[7];e[0]=r*n+l*o,e[1]=a*n+c*o,e[2]=i*n+p*o,e[3]=s*n+u*o,e[4]=l*n-r*o,e[5]=c*n-a*o,e[6]=p*n-i*o,e[7]=u*n-s*o};var degToRad=e=>e*Math.PI/180,previewFragmentShader="\n##head\nin vec2 vTexCoord;uniform sampler2D uTexture;uniform sampler2D uTextureMarkup;uniform vec2 uTextureSize;uniform float uOpacity;uniform vec4 uFillColor;uniform vec4 uOverlayColor;uniform mat4 uColorMatrix;uniform vec4 uColorOffset;uniform float uClarityKernel[9];uniform float uClarityKernelWeight;uniform float uColorGamma;uniform float uColorVignette;uniform float uMaskClip;uniform float uMaskOpacity;uniform float uMaskBounds[4];uniform float uMaskCornerRadius[4];uniform float uMaskFeather[8];vec4 applyGamma(vec4 c,float g){c.r=pow(c.r,g);c.g=pow(c.g,g);c.b=pow(c.b,g);return c;}vec4 applyColorMatrix(vec4 c,mat4 m,vec4 o){vec4 cM=(c*m)+o;cM*=cM.a;return cM;}vec4 applyConvolutionMatrix(vec4 c,float k0,float k1,float k2,float k3,float k4,float k5,float k6,float k7,float k8,float w){if(w<=0.0)return c;vec2 pixel=vec2(1)/uTextureSize;vec4 colorSum=texture(uTexture,vTexCoord+pixel*vec2(-1.0,-1.0))*k0+texture(uTexture,vTexCoord+pixel*vec2(0.0,-1.0))*k1+texture(uTexture,vTexCoord+pixel*vec2(1.0,-1.0))*k2+texture(uTexture,vTexCoord+pixel*vec2(-1.0,0.0))*k3+texture(uTexture,vTexCoord+pixel*vec2(0.0,0.0))*k4+texture(uTexture,vTexCoord+pixel*vec2(1.0,0.0))*k5+texture(uTexture,vTexCoord+pixel*vec2(-1.0,1.0))*k6+texture(uTexture,vTexCoord+pixel*vec2(0.0,1.0))*k7+texture(uTexture,vTexCoord+pixel*vec2(1.0,1.0))*k8;vec4 color=vec4((colorSum/w).rgb,c.a);color.rgb=clamp(color.rgb,0.0,1.0);return color;}vec4 applyVignette(vec4 c,vec2 pos,vec2 center,float v){float d=distance(pos,center)/length(center);float f=1.0-(d*abs(v));if(v>0.0){c.rgb*=f;}else if(v<0.0){c.rgb+=(1.0-f)*(1.0-c.rgb);}return c;}vec4 blendPremultipliedAlpha(vec4 back,vec4 front){return front+(back*(1.0-front.a));}void main(){float x=gl_FragCoord.x;float y=gl_FragCoord.y;float a=1.0;float maskTop=uMaskBounds[0];float maskRight=uMaskBounds[1];float maskBottom=uMaskBounds[2];float maskLeft=uMaskBounds[3];float leftFeatherOpacity=step(uMaskFeather[1],x)*uMaskFeather[0]+((1.0-uMaskFeather[0])*smoothstep(uMaskFeather[1],uMaskFeather[3],x));float rightFeatherOpacity=(1.0-step(uMaskFeather[7],x))*uMaskFeather[4]+((1.0-uMaskFeather[4])*smoothstep(uMaskFeather[7],uMaskFeather[5],x));a*=leftFeatherOpacity*rightFeatherOpacity;float overlayColorAlpha=(smoothstep(maskLeft,maskLeft+1.0,x)*(1.0-smoothstep(maskRight-1.0,maskRight,x))*(1.0-step(maskTop,y))*step(maskBottom,y));if(uOverlayColor.a==0.0){a*=overlayColorAlpha;}vec2 offset=vec2(maskLeft,maskBottom);vec2 size=vec2(maskRight-maskLeft,maskTop-maskBottom)*.5;vec2 center=offset.xy+size.xy;int pixelX=int(step(center.x,x));int pixelY=int(step(y,center.y));float cornerRadius=0.0;if(pixelX==0&&pixelY==0)cornerRadius=uMaskCornerRadius[0];if(pixelX==1&&pixelY==0)cornerRadius=uMaskCornerRadius[1];if(pixelX==0&&pixelY==1)cornerRadius=uMaskCornerRadius[2];if(pixelX==1&&pixelY==1)cornerRadius=uMaskCornerRadius[3];float cornerOffset=sign(cornerRadius)*length(max(abs(gl_FragCoord.xy-size-offset)-size+cornerRadius,0.0))-cornerRadius;float cornerOpacity=1.0-smoothstep(0.0,1.0,cornerOffset);a*=cornerOpacity;vec2 scaledPoint=vec2(vTexCoord.x*uTextureSize.x,vTexCoord.y*uTextureSize.y);a*=smoothstep(0.0,1.0,uTextureSize.x-scaledPoint.x);a*=smoothstep(0.0,1.0,uTextureSize.y-scaledPoint.y);a*=smoothstep(0.0,1.0,scaledPoint.x);a*=smoothstep(0.0,1.0,scaledPoint.y);vec4 color=texture(uTexture,vTexCoord);color=applyConvolutionMatrix(color,uClarityKernel[0],uClarityKernel[1],uClarityKernel[2],uClarityKernel[3],uClarityKernel[4],uClarityKernel[5],uClarityKernel[6],uClarityKernel[7],uClarityKernel[8],uClarityKernelWeight);color=applyGamma(color,uColorGamma);color=applyColorMatrix(color,uColorMatrix,uColorOffset);color=blendPremultipliedAlpha(uFillColor,color);color*=a;color=blendPremultipliedAlpha(color,texture(uTextureMarkup,vTexCoord));if(uColorVignette!=0.0){vec2 pos=gl_FragCoord.xy-offset;color=applyVignette(color,pos,center-offset,uColorVignette);}vec4 overlayColor=uOverlayColor*(1.0-overlayColorAlpha);overlayColor.rgb*=overlayColor.a;color=blendPremultipliedAlpha(color,overlayColor);if(uOverlayColor.a>0.0&&color.a<1.0&&uFillColor.a>0.0){color=blendPremultipliedAlpha(uFillColor,overlayColor);}color*=uOpacity;fragColor=color;}",previewVertexShader="\n##head\n##text\nvoid main(){vTexCoord=aTexCoord;gl_Position=uMatrix*aPosition;}",pathVertexShader="#version 300 es\n\nin vec4 aPosition;in vec2 aNormal;in float aMiter;out vec2 vNormal;out float vMiter;uniform float uWidth;uniform mat4 uMatrix;void main(){vMiter=aMiter;vNormal=aNormal;float w=uWidth;gl_Position=uMatrix*vec4(aPosition.x+(aNormal.x*w*.5*aMiter),aPosition.y+(aNormal.y*w*.5*aMiter),0,1);}",pathFragmentShader="\n##head\n##mask\nin vec2 vNormal;in float vMiter;uniform float uWidth;uniform vec4 uColor;uniform vec4 uCanvasColor;void main(){vec4 fillColor=uColor;float w=(uWidth-1.0)*.5;float d=1.0-abs(vMiter);float m=mask(gl_FragCoord.x,gl_FragCoord.y,uMaskBounds,uMaskOpacity);fillColor.a*=clamp(smoothstep(0.25,1.0,d*w),0.0,1.0);fillColor.rgb*=fillColor.a;fillColor.rgb*=m;fillColor.rgb+=(1.0-m)*(uCanvasColor.rgb*fillColor.a);fragColor=fillColor;}",rectVertexShader="\n##head\n##text\nin vec2 aRectCoord;out vec2 vRectCoord;void main(){vTexCoord=aTexCoord;vRectCoord=aRectCoord;\n##matrix\n}",rectFragmentShader="\n##head\n##mask\nin vec2 vTexCoord;in vec2 vRectCoord;uniform sampler2D uTexture;uniform vec4 uTextureColor;uniform float uTextureOpacity;uniform vec4 uColor;uniform float uCornerRadius[4];uniform vec2 uSize;uniform vec2 uPosition;uniform vec4 uCanvasColor;void main(){\n##init\n##colorize\n##edgeaa\n##cornerradius\n##maskfeatherapply\n##maskapply\n##fragcolor\n}",ellipseVertexShader="\n##head\n##text\nvoid main(){vTexCoord=vec2(aTexCoord.x*2.0-1.0,aTexCoord.y*2.0-1.0);\n##matrix\n}",ellipseFragmentShader="\n##head\n##mask\nin vec2 vTexCoord;uniform sampler2D uTexture;uniform float uTextureOpacity;uniform vec2 uRadius;uniform vec4 uColor;uniform int uInverted;uniform vec4 uCanvasColor;void main(){\n##init\nfloat ar=uRadius.x/uRadius.y;vec2 rAA=vec2(uRadius.x-1.0,uRadius.y-(1.0/ar));vec2 scaledPointSq=vec2((vTexCoord.x*uRadius.x)*(vTexCoord.x*uRadius.x),(vTexCoord.y*uRadius.y)*(vTexCoord.y*uRadius.y));float p=(scaledPointSq.x/(uRadius.x*uRadius.x))+(scaledPointSq.y/(uRadius.y*uRadius.y));float pAA=(scaledPointSq.x/(rAA.x*rAA.x))+(scaledPointSq.y/(rAA.y*rAA.y));a=smoothstep(1.0,p/pAA,p);if(uInverted==1)a=1.0-a;\n##maskapply\n##fragcolor\n}",triangleVertexShader="\n##head\nvoid main(){\n##matrix\n}",triangleFragmentShader="\n##head\n##mask\nuniform vec4 uColor;uniform vec4 uCanvasColor;void main(){vec4 fillColor=uColor;\n##maskapply\nfillColor.rgb*=fillColor.a;fillColor.rgb*=m;fillColor.rgb+=(1.0-m)*(uCanvasColor.rgb*fillColor.a);fragColor=fillColor;}";const createPathSegment=(e,t,o,n,r)=>{let a,i;a=vectorNormalize(vectorCreate(n.x-o.x,n.y-o.y)),i=vectorNormalize(vectorCreate(r.x-n.x,r.y-n.y));const s=vectorNormalize(vectorCreate(a.x+i.x,a.y+i.y)),l=vectorCreate(-s.y,s.x),c=vectorCreate(-a.y,a.x),p=1/vectorDot(l,c);e[t]=n.x,e[t+1]=n.y,e[t+2]=l.x,e[t+3]=l.y,e[t+4]=-p,e[t+5]=n.x,e[t+6]=n.y,e[t+7]=l.x,e[t+8]=l.y,e[t+9]=p},createPathVertices=(e,t)=>{let o,n,r,a=0;const i=e.length,s=new Float32Array(10*(t?i+1:i)),l=e[0],c=e[i-1];for(a=0;a<i;a++)o=e[a-1],n=e[a],r=e[a+1],o||(o=t?c:vectorCreate(n.x+(n.x-r.x),n.y+(n.y-r.y))),r||(r=t?l:vectorCreate(n.x+(n.x-o.x),n.y+(n.y-o.y))),createPathSegment(s,10*a,o,n,r);return t&&createPathSegment(s,10*i,c,l,e[1]),s},rectPointsToVertices=e=>{const t=new Float32Array(8);return t[0]=e[3].x,t[1]=e[3].y,t[2]=e[0].x,t[3]=e[0].y,t[4]=e[2].x,t[5]=e[2].y,t[6]=e[1].x,t[7]=e[1].y,t},trianglePointToVertices=e=>{const t=new Float32Array(6);return t[0]=e[0].x,t[1]=e[0].y,t[2]=e[1].x,t[3]=e[1].y,t[4]=e[2].x,t[5]=e[2].y,t},createRectPoints=(e,t=0,o,n)=>{const r=rectGetCorners(e),a=e.x+.5*e.width,i=e.y+.5*e.height;return(o||n)&&vectorsFlip(r,o,n,a,i),0!==t&&vectorsRotate(r,t,a,i),r},createEllipseOutline=(e,t,o,n,r,a,i)=>{const s=[],l=Math.abs(o)+Math.abs(n),c=Math.max(20,Math.round(l/6)),p=.5*o,u=.5*n,d=e+p,h=t+u;for(let e=0;e<c;e++)s.push(vectorCreate(d+p*Math.cos(e*(2*Math.PI)/c),h+u*Math.sin(e*(2*Math.PI)/c)));return(a||i)&&vectorsFlip(s,a,i,d,h),r&&vectorsRotate(s,r,d,h),s},createRectOutline=(e,t,o,n,r,a,i,s)=>{const l=[];if(a.every(e=>0===e))l.push(vectorCreate(e,t),vectorCreate(e+o,t),vectorCreate(e+o,t+n),vectorCreate(e,t+n));else{const[r,i,s,c]=a,p=e,u=e+o,d=t,h=t+n;l.push(vectorCreate(p+r,d)),pushRectCornerPoints(l,u-i,d+i,i,-1),l.push(vectorCreate(u,d+i)),pushRectCornerPoints(l,u-c,h-c,c,0),l.push(vectorCreate(u-c,h)),pushRectCornerPoints(l,p+s,h-s,s,1),l.push(vectorCreate(p,h-s)),pushRectCornerPoints(l,p+r,d+r,r,2)}return(i||s)&&vectorsFlip(l,i,s,e+.5*o,t+.5*n),r&&vectorsRotate(l,r,e+.5*o,t+.5*n),l},pushRectCornerPoints=(e,t,o,n,r)=>{const a=Math.min(20,Math.max(4,Math.round(n/2)));let i=0,s=0,l=0,c=0,p=0;for(;p<a;p++)s=r*HALF_PI+(i=p/a)*HALF_PI,l=n*Math.cos(s),c=n*Math.sin(s),e.push(vectorCreate(t+l,o+c))};var getWebGLContext=(e,t)=>e.getContext("webgl2",t)||e.getContext("webgl",t)||e.getContext("experimental-webgl",t);const rectUV=new Float32Array([0,1,0,0,1,1,1,0]);var createGLImageDrawer=(e,t,o,n)=>{let r,a,i,s,l,c,p,u,d,h,m,g,f,_={width:0,height:0},$={width:0,height:0},b=[0,0,0];const y=[],x=(e,t,o)=>{const n=y[e];return n&&w.deleteTexture(n.texture),y[e]={texture:t,source:o,textureAspectRatio:o?getAspectRatio(o.width,o.height):void 0},e},v=()=>{const e=y.findIndex(e=>void 0===e);return e<4?y.length:e},C=(e,t)=>{x(e,createTexture(w,t),t)},S=degToRad(30),k=Math.tan(S/2),w=getWebGLContext(e,{antialias:!1,alpha:!1,premultipliedAlpha:!0});if(!w)return;w.getExtension("OES_standard_derivatives"),w.disable(w.DEPTH_TEST),w.enable(w.BLEND),w.blendFunc(w.ONE,w.ONE_MINUS_SRC_ALPHA),w.pixelStorei(w.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0);const R=w.createTexture();w.bindTexture(w.TEXTURE_2D,R),w.texImage2D(w.TEXTURE_2D,0,w.RGBA,1,1,0,w.RGBA,w.UNSIGNED_BYTE,new Uint8Array([255,255,255,255])),x(0,R);const T=w.createTexture();w.bindTexture(w.TEXTURE_2D,T),w.texImage2D(w.TEXTURE_2D,0,w.RGBA,1,1,0,w.RGBA,w.UNSIGNED_BYTE,new Uint8Array([0,0,0,0])),x(1,T);const E=w.createTexture();x(2,E);const I=w.createFramebuffer();C(3,t);const A=w.createBuffer(),M=w.createBuffer();w.bindBuffer(w.ARRAY_BUFFER,M),w.bufferData(w.ARRAY_BUFFER,rectUV,w.STATIC_DRAW);const P=createShader(w,previewVertexShader,previewFragmentShader,["aPosition","aTexCoord"],["uMatrix","uTexture","uTextureMarkup","uTextureSize","uColorGamma","uColorVignette","uColorOffset","uColorMatrix","uClarityKernel","uClarityKernelWeight","uOpacity","uMaskOpacity","uMaskBounds","uMaskCornerRadius","uMaskFeather","uFillColor","uOverlayColor"]);let D;w.useProgram(P.program);const F=createShader(w,pathVertexShader,pathFragmentShader,["aPosition","aNormal","aMiter"],["uColor","uCanvasColor","uMatrix","uWidth","uMaskBounds","uMaskOpacity"]),L=w.createBuffer(),z=(e,t,o,n)=>{const{program:r,locations:a}=F;w.useProgram(r),w.enableVertexAttribArray(a.aPosition),w.enableVertexAttribArray(a.aNormal),w.enableVertexAttribArray(a.aMiter);const i=createPathVertices(e,n),s=5*Float32Array.BYTES_PER_ELEMENT,l=2*Float32Array.BYTES_PER_ELEMENT,p=4*Float32Array.BYTES_PER_ELEMENT;w.uniform1f(a.uWidth,t+2),w.uniform4fv(a.uColor,o),w.uniformMatrix4fv(a.uMatrix,!1,c),w.uniform4f(a.uCanvasColor,b[0],b[1],b[2],1),w.uniform1fv(a.uMaskBounds,f),w.uniform1f(a.uMaskOpacity,g),w.bindBuffer(w.ARRAY_BUFFER,L),w.bufferData(w.ARRAY_BUFFER,i,w.STATIC_DRAW),w.vertexAttribPointer(a.aPosition,2,w.FLOAT,!1,s,0),w.vertexAttribPointer(a.aNormal,2,w.FLOAT,!1,s,l),w.vertexAttribPointer(a.aMiter,1,w.FLOAT,!1,s,p),w.drawArrays(w.TRIANGLE_STRIP,0,i.length/5),w.disableVertexAttribArray(a.aPosition),w.disableVertexAttribArray(a.aNormal),w.disableVertexAttribArray(a.aMiter)},B=createShader(w,triangleVertexShader,triangleFragmentShader,["aPosition"],["uColor","uCanvasColor","uMatrix","uMaskBounds","uMaskOpacity"]),O=w.createBuffer(),U=createShader(w,rectVertexShader,rectFragmentShader,["aPosition","aTexCoord","aRectCoord"],["uTexture","uColor","uMatrix","uCanvasColor","uTextureColor","uTextureOpacity","uPosition","uSize","uMaskBounds","uMaskOpacity","uMaskFeather","uCornerRadius"]),N=w.createBuffer(),V=w.createBuffer(),H=w.createBuffer(),W=[0,0,0,0],G=createShader(w,ellipseVertexShader,ellipseFragmentShader,["aPosition","aTexCoord"],["uTexture","uTextureOpacity","uColor","uCanvasColor","uMatrix","uRadius","uInverted","uMaskBounds","uMaskOpacity"]),j=w.createBuffer(),q=w.createBuffer();return{drawPath:(e,t,o,r)=>{e.length<2||z(e.map(e=>({x:e.x*n,y:e.y*n})),t*n,applyOpacity(o,r),!1)},drawTriangle:(e,t=0,o=!1,r=!1,a,i)=>{if(!a)return;const s=e.map(e=>({x:e.x*n,y:e.y*n})),l=quadCentroid(s);(o||r)&&vectorsFlip(s,o,r,l.x,l.y),vectorsRotate(s,t,l.x,l.y),((e,t)=>{const{program:o,locations:n}=B;w.useProgram(o),w.enableVertexAttribArray(n.aPosition),w.uniform4fv(n.uColor,t),w.uniformMatrix4fv(n.uMatrix,!1,c),w.uniform1fv(n.uMaskBounds,f),w.uniform1f(n.uMaskOpacity,g),w.uniform4f(n.uCanvasColor,b[0],b[1],b[2],1),w.bindBuffer(w.ARRAY_BUFFER,O),w.bufferData(w.ARRAY_BUFFER,e,w.STATIC_DRAW),w.vertexAttribPointer(n.aPosition,2,w.FLOAT,!1,0,0),w.drawArrays(w.TRIANGLE_STRIP,0,e.length/2),w.disableVertexAttribArray(n.aPosition)})(trianglePointToVertices(s),applyOpacity(a,i))},drawRect:(e,o=0,r=!1,i=!1,s,l,p,u,d,h,m,$,x,v)=>{let C=rectMultiply(rectClone(e),n);const S=s.map(t=>((e,t)=>Math.floor(clamp(e,0,Math.min(.5*(t.width-1),.5*(t.height-1)))))(t||0,e)).map(e=>e*a);if(l||p){const e=rectClone(C);e.x-=.5,e.y-=.5,e.width+=1,e.height+=1;const a=createRectPoints(e,o,r,i),s=rectPointsToVertices(a);let h;v&&0===(h=applyOpacity(v))[3]&&(h[3]=.001),((e,o,r,a,i,s,l=1,p=W,u=rectUV,d=[1,0,1,0,1,Math.max(_.width,t.width),1,Math.max(_.width,t.width)])=>{const{program:h,locations:m}=U;w.useProgram(h),w.enableVertexAttribArray(m.aPosition),w.enableVertexAttribArray(m.aTexCoord),w.enableVertexAttribArray(m.aRectCoord),w.uniform4fv(m.uColor,i),w.uniform4fv(m.uTextureColor,p),w.uniform1f(m.uTextureOpacity,l),w.uniform2fv(m.uSize,[o,r]),w.uniform2fv(m.uPosition,[e[2],e[3]]),w.uniform1fv(m.uCornerRadius,a),w.uniform4f(m.uCanvasColor,b[0],b[1],b[2],1),w.uniform1fv(m.uMaskFeather,d.map((e,t)=>t%2==0?e:e*n)),w.uniform1fv(m.uMaskBounds,f),w.uniform1f(m.uMaskOpacity,g),w.uniformMatrix4fv(m.uMatrix,!1,c);const $=y[s]&&y[s].texture?s:1;w.uniform1i(m.uTexture,$),w.activeTexture(w.TEXTURE0+$),w.bindTexture(w.TEXTURE_2D,y[$].texture),w.bindBuffer(w.ARRAY_BUFFER,V),w.bufferData(w.ARRAY_BUFFER,u,w.STATIC_DRAW),w.vertexAttribPointer(m.aTexCoord,2,w.FLOAT,!1,0,0),w.bindBuffer(w.ARRAY_BUFFER,H),w.bufferData(w.ARRAY_BUFFER,rectUV,w.STATIC_DRAW),w.vertexAttribPointer(m.aRectCoord,2,w.FLOAT,!1,0,0),w.bindBuffer(w.ARRAY_BUFFER,N),w.bufferData(w.ARRAY_BUFFER,e,w.STATIC_DRAW),w.vertexAttribPointer(m.aPosition,2,w.FLOAT,!1,0,0),w.drawArrays(w.TRIANGLE_STRIP,0,e.length/2),w.disableVertexAttribArray(m.aPosition),w.disableVertexAttribArray(m.aTexCoord),w.disableVertexAttribArray(m.aRectCoord)})(s,e.width,e.height,S,applyOpacity(l,$),p,$,h,((e,t,o,r)=>{if(!o&&!r)return rectUV;let a=r.x/o.width,i=r.y/o.height,s=e/o.width/n,l=t/o.height/n;return s-=a,l-=i,new Float32Array([-a,l,-a,-i,s,l,s,-i])})(e.width,e.height,u,d),x)}h&&(h=Math.min(h,C.width,C.height),z(createRectOutline(C.x,C.y,C.width,C.height,o,S,r,i),h*n,applyOpacity(m,$),!0))},drawEllipse:(e,t,o,r,a,i,s,l,p,u,d,h)=>{let m=rectMultiply(rectCreate(e.x-t,e.y-o,2*t,2*o),n);if(s||l){const e=rectClone(m);e.x-=.5,e.y-=.5,e.width+=1,e.height+=1;const t=createRectPoints(e,r,a,i);((e,t,o,n,r=1,a=1,i=!1)=>{const{program:s,locations:l}=G;w.useProgram(s),w.enableVertexAttribArray(l.aPosition),w.enableVertexAttribArray(l.aTexCoord),w.uniform2fv(l.uRadius,[.5*t,.5*o]),w.uniform1i(l.uInverted,i?1:0),w.uniform4fv(l.uColor,n),w.uniformMatrix4fv(l.uMatrix,!1,c),w.uniform4f(l.uCanvasColor,b[0],b[1],b[2],1),w.uniform1fv(l.uMaskBounds,f),w.uniform1f(l.uMaskOpacity,g),w.uniform1i(l.uTexture,r),w.uniform1f(l.uTextureOpacity,a),w.activeTexture(w.TEXTURE0+r),w.bindTexture(w.TEXTURE_2D,y[r].texture),w.bindBuffer(w.ARRAY_BUFFER,q),w.bufferData(w.ARRAY_BUFFER,rectUV,w.STATIC_DRAW),w.vertexAttribPointer(l.aTexCoord,2,w.FLOAT,!1,0,0),w.bindBuffer(w.ARRAY_BUFFER,j),w.bufferData(w.ARRAY_BUFFER,e,w.STATIC_DRAW),w.vertexAttribPointer(l.aPosition,2,w.FLOAT,!1,0,0),w.drawArrays(w.TRIANGLE_STRIP,0,e.length/2),w.disableVertexAttribArray(l.aPosition),w.disableVertexAttribArray(l.aTexCoord)})(rectPointsToVertices(t),e.width,e.height,applyOpacity(s,d),l,d,h)}p&&z(createEllipseOutline(m.x,m.y,m.width,m.height,r,a,i),p*n,applyOpacity(u,d),!0)},drawPreviewImage:(e,o,s,l,c,p,u,d,h,m=1,_,b=1,x=0,v=[1,0,1,0,1,$.width,1,$.width],C=[0,0,0,0],k=[0,0,0,0],R=[0,0,0,0],T=!0)=>{const{program:E,locations:I}=P;s*=a,l*=a,e*=a,o*=a,D=mat4Create(),mat4Perspective(D,S,r,1,2*-i),mat4Translate(D,s,-l,i),mat4Translate(D,e,-o,0),mat4RotateZ(D,-u),mat4Scale(D,d),mat4Translate(D,-e,o,0),mat4RotateY(D,p),mat4RotateX(D,c),w.useProgram(E),w.enableVertexAttribArray(I.aPosition),w.enableVertexAttribArray(I.aTexCoord);const F=y[3];w.uniform1i(I.uTexture,3),w.uniform2f(I.uTextureSize,t.width,t.height),w.activeTexture(w.TEXTURE0+3),w.bindTexture(w.TEXTURE_2D,F.texture);const L=T?2:1,z=y[L];let B;w.uniform1i(I.uTextureMarkup,L),w.activeTexture(w.TEXTURE0+L),w.bindTexture(w.TEXTURE_2D,z.texture),w.bindBuffer(w.ARRAY_BUFFER,A),w.vertexAttribPointer(I.aPosition,3,w.FLOAT,!1,0,0),w.bindBuffer(w.ARRAY_BUFFER,M),w.vertexAttribPointer(I.aTexCoord,2,w.FLOAT,!1,0,0),w.uniformMatrix4fv(I.uMatrix,!1,D),w.uniform4fv(I.uOverlayColor,R),w.uniform4fv(I.uFillColor,k),_?B=(B=_.reduce((e,t)=>e+t,0))<=0?1:B:(_=[0,0,0,0,1,0,0,0,0],B=-1),w.uniform1fv(I.uClarityKernel,_),w.uniform1f(I.uClarityKernelWeight,B),w.uniform1f(I.uColorGamma,1/b),w.uniform1f(I.uColorVignette,x),w.uniform4f(I.uColorOffset,h[4],h[9],h[14],h[19]),w.uniformMatrix4fv(I.uColorMatrix,!1,[h[0],h[1],h[2],h[3],h[5],h[6],h[7],h[8],h[10],h[11],h[12],h[13],h[15],h[16],h[17],h[18]]),w.uniform1f(I.uOpacity,m),w.uniform1f(I.uMaskOpacity,g),w.uniform1fv(I.uMaskBounds,f),w.uniform1fv(I.uMaskCornerRadius,C.map(e=>e*n)),w.uniform1fv(I.uMaskFeather,v.map((e,t)=>t%2==0?e:e*n)),w.drawArrays(w.TRIANGLE_STRIP,0,4),w.disableVertexAttribArray(I.aPosition),w.disableVertexAttribArray(I.aTexCoord)},setCanvasColor(e){b=e},drawToCanvas(){w.bindFramebuffer(w.FRAMEBUFFER,null),c=s,w.viewport(0,0,w.drawingBufferWidth,w.drawingBufferHeight),w.colorMask(!0,!0,!0,!1),w.clearColor(b[0],b[1],b[2],1),w.clear(w.COLOR_BUFFER_BIT)},drawToFramebuffer(){w.bindFramebuffer(w.FRAMEBUFFER,I),c=l,w.viewport(0,0,t.width,t.height),w.colorMask(!0,!0,!0,!0),w.clearColor(0,0,0,0),w.clear(w.COLOR_BUFFER_BIT)},addTexture:e=>((e,t)=>x(v(),e,t))(createTexture(w,e),e),setTexture:C,reserveTexture:e=>{y[e]={}},removeTexture:e=>{const t=y[e];w.deleteTexture(t.texture),t.source instanceof HTMLCanvasElement&&releaseCanvas(t.source),y[e]=void 0},getTextureSize:e=>{const t=y[e].source;return t&&{width:t.width,height:t.height}},getAvailableTextureIndex:v,enableMask(e,t){const o=e.x*a,n=e.y*a,r=e.width*a,i=e.height*a;d=(m=o)+r,u=_.height-n,h=_.height-(n+i),g=1-t,f=[u,d,h,m]},disableMask(){m=0,d=_.width,u=_.height,g=1,f=[u,d,h=0,m]},resize:(n,c,u)=>{a=u,$.width=n,$.height=c,_.width=n*u,_.height=c*u,r=getAspectRatio(_.width,_.height),e.width=_.width,e.height=_.height,s=mat4Create(),mat4Ortho(s,0,_.width,_.height,0,-1,1),l=mat4Create();const d=t.width*u,h=t.height*u;mat4Ortho(l,0,d,h,0,-1,1),mat4Translate(l,0,h,0),mat4ScaleX(l,1),mat4ScaleY(l,-1),w.bindTexture(w.TEXTURE_2D,y[2].texture),w.texImage2D(w.TEXTURE_2D,0,w.RGBA,t.width,t.height,0,w.RGBA,w.UNSIGNED_BYTE,null),w.texParameteri(w.TEXTURE_2D,w.TEXTURE_MIN_FILTER,w.LINEAR),w.texParameteri(w.TEXTURE_2D,w.TEXTURE_WRAP_S,w.CLAMP_TO_EDGE),w.texParameteri(w.TEXTURE_2D,w.TEXTURE_WRAP_T,w.CLAMP_TO_EDGE),w.bindFramebuffer(w.FRAMEBUFFER,I),w.framebufferTexture2D(w.FRAMEBUFFER,w.COLOR_ATTACHMENT0,w.TEXTURE_2D,y[2].texture,0);const m=o.width*u,g=o.height*u,f=-.5*m,b=.5*g,x=.5*m,v=-.5*g;p=new Float32Array([f,v,0,f,b,0,x,v,0,x,b,0]),w.bindBuffer(w.ARRAY_BUFFER,A),w.bufferData(w.ARRAY_BUFFER,p,w.STATIC_DRAW),i=o.height/2/k*(_.height/o.height)*-1},release(){e.width=1,e.height=1}}};function create_fragment$H(e){let t,o,n,r;return{c(){t=element("div"),o=element("canvas"),attr(t,"class","DokaCanvas")},m(a,i){insert(a,t,i),append(t,o),e[20](o),n||(r=[listen(o,"measure",e[4]),action_destroyer(measurable.call(null,o))],n=!0)},p:noop,i:noop,o:noop,d(o){o&&detach(t),e[20](null),n=!1,run_all(r)}}}function instance$H(e,t,o){let n,r,a,i,s,l;const c=createEventDispatcher(),p=[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0];let{animate:u}=t,{imageData:d}=t,{imageSize:h}=t,{imageProps:m}=t,{imagePreviews:g=[]}=t,{maskRect:f}=t,{pixelRatio:_=1}=t,{willRender:$=passthrough}=t,{loadImageData:b=passthrough}=t,{backgroundColor:y}=t;const x=(e,t)=>e.set(t,{hard:!u}),v=(e,t)=>{const[o,n,r]=e,[a,i,s,l]=t;return[a*l+o*(1-l),i*l+n*(1-l),s*l+r*(1-l),1]},C={precision:1e-4},S={precision:.01*C.precision},k=tweened(void 0,{duration:250});component_subscribe(e,k,e=>o(22,s=e));const w=spring(void 0,C),R=spring(void 0,S),T=spring(void 0,C),E=spring(void 0,S),I=spring(void 0,S),A=spring(void 0,S),M=spring(void 0,S),P=spring([...p],C),D=writable(void 0),F=spring(0,S),L=spring(1,S),z=writable();component_subscribe(e,z,e=>o(24,l=e));const B=writable(),O=derived([T,w,E,R,I,F,P,z,L,D,A,M,B,k],([e,t,o,n,r,a,i,s,l,c,p,u,d,h],g)=>{if(!m||!h)return g(void 0);const f=clamp(l,0,1);g({origin:e,translation:t,perspective:o,rotation:n,scale:r,colorMatrix:i,opacity:clamp(a,0,1),clarity:c,gamma:p,vignette:u,mask:s,maskOpacity:f,overlayColor:[h[0],h[1],h[2],f],backgroundColor:d})});let U;component_subscribe(e,O,e=>o(19,i=e));let N=null,V=null,H=null;const W=({origin:e,translation:t,rotation:o,scale:n,colorMatrix:r,opacity:a,clarity:i,gamma:l,vignette:c,offset:u,maskFeather:d,maskCornerRadius:h,backgroundColor:m,overlayColor:g,enableShapes:f})=>{let _=t.x,$=t.y;u&&(_+=u.x-.5*V,$+=u.y-.5*H),m[3]<1&&m[3]>0&&(m=v(s,m)),N.drawPreviewImage(e.x,e.y,_,$,o.x,o.y,o.z,n,r||p,a,i,l,c,d,h,m,g,f)},G=new Map([]),j=createSimpleContext(),q=e=>{let t;if(e.backgroundImage)t=(({backgroundImage:e})=>{let t=G.get(e);return t||(t=N.getAvailableTextureIndex(),N.reserveTexture(t),G.set(e,t),b(e).then(e=>{N.setTexture(t,e),requestAnimationFrame(a)}).catch(e=>{console.error(e)}),t)})(e);else if(isString(e.text)){if(e.width&&e.width<1||e.height&&e.height<1)return;t=(e=>{let{text:t,textAlign:o,fontFamily:n,fontSize:r,fontWeight:a,fontVariant:i,fontStyle:s,lineHeight:l,width:c}=e;updateTextContext(j,{fontSize:r,fontFamily:n,fontWeight:a,fontVariant:i,fontStyle:s,textAlign:o});const p=c?wrapText(j,t,c):t,u=shapeTextUID({...e,text:p});let d=G.get(u);if(d)return d;const h=createSimpleContext();updateTextContext(h,{fontSize:r,fontFamily:n,fontWeight:a,fontVariant:i,fontStyle:s,textAlign:o}),resizeContextToFitText(h,p,{fontSize:r,fontFamily:n,fontWeight:a,fontVariant:i,fontStyle:s,textAlign:o,lineHeight:l});const m=h.canvas.width;return h.canvas.width+=textPadding,updateTextContext(h,{fontSize:r,fontFamily:n,fontWeight:a,fontVariant:i,fontStyle:s,textAlign:o,color:[1,0,1]}),drawText$1(h,p,{fontSize:r,textAlign:o,lineHeight:l,lineWidth:m}),d=N.addTexture(h.canvas),G.set(u,d),d})(e)}return t},X=(e=[])=>e.map(e=>{let t=q(e);if(isArray(e.points))3===e.points.length&&e.backgroundColor?N.drawTriangle(e.points,e.rotation,e.flipX,e.flipY,e.backgroundColor,e.strokeWidth,e.strokeColor,e.opacity):N.drawPath(e.points,e.strokeWidth,e.strokeColor,e.opacity);else if(isNumber(e.rx))N.drawEllipse(e,e.rx,e.ry,e.rotation,e.flipX,e.flipY,e.backgroundColor,t,e.strokeWidth,e.strokeColor,e.opacity,e.inverted);else if(isString(e.text)&&t||e.width){const o=t&&N.getTextureSize(t);let n,r,a,i=void 0,s=[e.cornerRadius,e.cornerRadius,e.cornerRadius,e.cornerRadius];if(n=e.width?e:{x:e.x,y:e.y,...o},o){if(e.backgroundImage&&e.backgroundSize){const t=getAspectRatio(o.width,o.height);if("contain"===e.backgroundSize){const o=rectContainRect(e,t,n);r=sizeCreateFromRect(o),a=vectorCreate(.5*(e.width-r.width),.5*(e.height-r.height))}else if("cover"===e.backgroundSize){const o=rectCoverRect(e,t,n);r=sizeCreateFromRect(o),a=vectorCreate(o.x,o.y),a=vectorCreate(.5*(e.width-r.width),.5*(e.height-r.height))}}else e.text&&e.width?(r=o,a=vectorCreate(0,0),e.height||(e.height=o.height),e.x-=textPadding,e.width+=2*textPadding,"left"===e.textAlign&&(a.x=textPadding),"center"===e.textAlign&&(a.x=.5*textPadding+.5*(e.width-o.width)),"right"===e.textAlign&&(a.x=e.width-o.width)):e.text&&(a=vectorCreate(0,0),r={width:n.width,height:n.height},n.width-=textPadding);e.text&&(i=e.color)}N.drawRect(n,e.rotation,e.flipX,e.flipY,s,e.backgroundColor,t,r,a,e.strokeWidth,e.strokeColor,e.opacity,void 0,i)}return t?[e.id,t]:void 0}).filter(Boolean),Y=()=>{const e=$({opacity:i.opacity,rotation:i.rotation,scale:i.scale,size:n,backgroundColor:[...s]});e.backgroundColor=[...s],e.image=i,e.imageMask=i.mask,e.imageMaskOpacity=i.maskOpacity,e.imagePreviews=g;const t=e.annotationShapes.length>0,o=i.backgroundColor[3]>0,r=[];if(i.maskOpacity<1&&o){const t=e.backgroundColor[0],o=e.backgroundColor[1],n=e.backgroundColor[2],r=1-i.maskOpacity,a=i.backgroundColor[0]*r,s=i.backgroundColor[1]*r,l=i.backgroundColor[2]*r,c=1-r;e.backgroundColor=[a+t*c,s+o*c,l+n*c,1]}N.setCanvasColor(e.backgroundColor),t&&(N.disableMask(),N.drawToFramebuffer(),r.push(...X(e.annotationShapes))),N.drawToCanvas(),N.enableMask(e.imageMask,e.imageMaskOpacity),o&&N.drawRect(l,0,!1,!1,[0,0,0,0],v(s,i.backgroundColor)),e.image.enableShapes=t,W(e.image),r.push(...X(e.decorationShapes)),N.disableMask(),r.push(...X(e.interfaceShapes)),e.imagePreviews.forEach(e=>{N.enableMask(e.mask,e.maskOpacity),o&&N.drawRect(e.mask,0,!1,!1,e.maskCornerRadius,i.backgroundColor,void 0,void 0,void 0,void 0,void 0,e.opacity,e.maskFeather),W({...e,backgroundColor:i.backgroundColor,overlayColor:[0,0,0,0],enableShapes:!1})}),N.disableMask(),G.forEach((e,t,o)=>{!!r.find(([t,o])=>o===e)||(G.delete(t),N.removeTexture(e))})};return afterUpdate(()=>a()),onMount(()=>o(15,N=createGLImageDrawer(U,d,h,_))),onDestroy(()=>{N&&(N.release(),releaseCanvas(j.canvas))}),e.$$set=(e=>{"animate"in e&&o(5,u=e.animate),"imageData"in e&&o(6,d=e.imageData),"imageSize"in e&&o(7,h=e.imageSize),"imageProps"in e&&o(8,m=e.imageProps),"imagePreviews"in e&&o(9,g=e.imagePreviews),"maskRect"in e&&o(10,f=e.maskRect),"pixelRatio"in e&&o(11,_=e.pixelRatio),"willRender"in e&&o(12,$=e.willRender),"loadImageData"in e&&o(13,b=e.loadImageData),"backgroundColor"in e&&o(14,y=e.backgroundColor)}),e.$$.update=(()=>{16384&e.$$.dirty[0]&&y&&x(k,y),256&e.$$.dirty[0]&&m&&x(T,m.origin),256&e.$$.dirty[0]&&m&&x(w,m.translation),256&e.$$.dirty[0]&&m&&x(E,m.perspective),256&e.$$.dirty[0]&&m&&x(R,m.rotation),256&e.$$.dirty[0]&&m&&x(I,m.scale),256&e.$$.dirty[0]&&m&&x(P,m.colorMatrix||[...p]),256&e.$$.dirty[0]&&m&&x(M,m.vignette||0),256&e.$$.dirty[0]&&m&&x(A,m.gamma||1),256&e.$$.dirty[0]&&m&&D.set(m.convolutionMatrix&&m.convolutionMatrix.clarity||void 0),256&e.$$.dirty[0]&&m&&x(F,1),256&e.$$.dirty[0]&&m&&x(L,isNumber(m.maskOpacity)?m.maskOpacity:1),1024&e.$$.dirty[0]&&f&&z.set(f),256&e.$$.dirty[0]&&m&&B.set(m.backgroundColor),196608&e.$$.dirty[0]&&(n={width:V,height:H}),753664&e.$$.dirty[0]&&o(18,r=N&&V&&H&&i),231424&e.$$.dirty[0]&&V&&H&&N&&N.resize(V,H,_),262144&e.$$.dirty[0]&&(a=r?Y:noop$1)}),[U,k,z,O,e=>{o(16,V=e.detail.width),o(17,H=e.detail.height),c("measure",{width:V,height:H})},u,d,h,m,g,f,_,$,b,y,N,V,H,r,i,function(e){binding_callbacks[e?"unshift":"push"](()=>{o(0,U=e)})}]}class Canvas extends SvelteComponent{constructor(e){super(),init(this,e,instance$H,create_fragment$H,safe_not_equal,{animate:5,imageData:6,imageSize:7,imageProps:8,imagePreviews:9,maskRect:10,pixelRatio:11,willRender:12,loadImageData:13,backgroundColor:14},[-1,-1])}}var arrayJoin=(e,t=Boolean,o=" ")=>e.filter(t).join(o);function get_each_context$9(e,t,o){const n=e.slice();return n[17]=t[o],n}const get_default_slot_changes$1=e=>({tab:4&e}),get_default_slot_context$1=e=>({tab:e[17]});function create_if_block$d(e){let t,o,n,r=[],a=new Map,i=e[2];const s=e=>e[17].id;for(let t=0;t<i.length;t+=1){let o=get_each_context$9(e,i,t),n=s(o);a.set(n,r[t]=create_each_block$9(n,o))}return{c(){t=element("ul");for(let e=0;e<r.length;e+=1)r[e].c();attr(t,"class",o=arrayJoin(["DokaTabList",e[0]])),attr(t,"role","tablist"),attr(t,"data-layout",e[1])},m(o,a){insert(o,t,a);for(let e=0;e<r.length;e+=1)r[e].m(t,null);e[14](t),n=!0},p(e,l){1124&l&&(i=e[2],group_outros(),r=update_keyed_each(r,l,s,1,e,i,a,t,outro_and_destroy_block,create_each_block$9,null,get_each_context$9),check_outros()),(!n||1&l&&o!==(o=arrayJoin(["DokaTabList",e[0]])))&&attr(t,"class",o),(!n||2&l)&&attr(t,"data-layout",e[1])},i(e){if(!n){for(let e=0;e<i.length;e+=1)transition_in(r[e]);n=!0}},o(e){for(let e=0;e<r.length;e+=1)transition_out(r[e]);n=!1},d(o){o&&detach(t);for(let e=0;e<r.length;e+=1)r[e].d();e[14](null)}}}function create_each_block$9(e,t){let o,n,r,a,i,s,l,c,p,u;const d=t[11].default,h=create_slot(d,t,t[10],get_default_slot_context$1);function m(...e){return t[12](t[17],...e)}function g(...e){return t[13](t[17],...e)}return{key:e,first:null,c(){o=element("li"),n=element("button"),h&&h.c(),a=space(),n.disabled=r=t[17].disabled,attr(o,"role","tab"),attr(o,"aria-controls",i=t[17].href.substr(1)),attr(o,"id",s=t[17].tabId),attr(o,"aria-selected",l=t[17].selected),this.first=o},m(e,t){insert(e,o,t),append(o,n),h&&h.m(n,null),append(o,a),c=!0,p||(u=[listen(n,"keydown",m),listen(n,"click",g)],p=!0)},p(e,a){t=e,h&&h.p&&1028&a&&update_slot(h,d,t,t[10],a,get_default_slot_changes$1,get_default_slot_context$1),(!c||4&a&&r!==(r=t[17].disabled))&&(n.disabled=r),(!c||4&a&&i!==(i=t[17].href.substr(1)))&&attr(o,"aria-controls",i),(!c||4&a&&s!==(s=t[17].tabId))&&attr(o,"id",s),(!c||4&a&&l!==(l=t[17].selected))&&attr(o,"aria-selected",l)},i(e){c||(transition_in(h,e),c=!0)},o(e){transition_out(h,e),c=!1},d(e){e&&detach(o),h&&h.d(e),p=!1,run_all(u)}}}function create_fragment$G(e){let t,o,n=e[4]&&create_if_block$d(e);return{c(){n&&n.c(),t=empty()},m(e,r){n&&n.m(e,r),insert(e,t,r),o=!0},p(e,[o]){e[4]?n?(n.p(e,o),16&o&&transition_in(n,1)):((n=create_if_block$d(e)).c(),transition_in(n,1),n.m(t.parentNode,t)):n&&(group_outros(),transition_out(n,1,1,()=>{n=null}),check_outros())},i(e){o||(transition_in(n),o=!0)},o(e){transition_out(n),o=!1},d(e){n&&n.d(e),e&&detach(t)}}}function instance$G(e,t,o){let n,r,a,{$$slots:i={},$$scope:s}=t,{class:l}=t,{name:c}=t,{selected:p}=t,{tabs:u=[]}=t,{layout:d}=t;const h=createEventDispatcher(),m=e=>{const t=a.querySelectorAll('[role="tab"] button')[e];t&&t.focus()},g=(e,t)=>{e.preventDefault(),e.stopPropagation(),h("select",t)},f=({key:e},t)=>{if(!/arrow/i.test(e))return;const o=u.findIndex(e=>e.id===t);return/right|down/i.test(e)?m(o<u.length-1?o+1:0):/left|up/i.test(e)?m(o>0?o-1:u.length-1):void 0};return e.$$set=(e=>{"class"in e&&o(0,l=e.class),"name"in e&&o(7,c=e.name),"selected"in e&&o(8,p=e.selected),"tabs"in e&&o(9,u=e.tabs),"layout"in e&&o(1,d=e.layout),"$$scope"in e&&o(10,s=e.$$scope)}),e.$$.update=(()=>{896&e.$$.dirty&&o(2,n=u.map(e=>{const t=e.id===p;return{...e,tabId:`doka-tab-${c}-${e.id}`,href:`#doka-${c}-${e.id}`,selected:t}})),4&e.$$.dirty&&o(4,r=n.length>1)}),[l,d,n,a,r,g,f,c,p,u,s,i,(e,t)=>f(t,e.id),(e,t)=>g(t,e.id),function(e){binding_callbacks[e?"unshift":"push"](()=>{o(3,a=e)})}]}class TabList extends SvelteComponent{constructor(e){super(),init(this,e,instance$G,create_fragment$G,safe_not_equal,{class:0,name:7,selected:8,tabs:9,layout:1})}}const get_default_slot_changes_1=e=>({panel:16&e}),get_default_slot_context_1=e=>({panel:e[4][0].id,panelIsActive:!0});function get_each_context$8(e,t,o){const n=e.slice();return n[14]=t[o].id,n[15]=t[o].draw,n[16]=t[o].panelId,n[17]=t[o].tabindex,n[18]=t[o].labelledBy,n[19]=t[o].hidden,n[3]=t[o].visible,n}const get_default_slot_changes=e=>({panel:16&e,panelIsActive:16&e}),get_default_slot_context=e=>({panel:e[14],panelIsActive:!e[19]});function create_else_block$5(e){let t,o,n,r,a,i;const s=e[11].default,l=create_slot(s,e,e[10],get_default_slot_context_1);return{c(){t=element("div"),o=element("div"),l&&l.c(),attr(o,"class",n=arrayJoin([e[1]])),attr(t,"class",e[0]),attr(t,"style",e[2])},m(n,s){insert(n,t,s),append(t,o),l&&l.m(o,null),r=!0,a||(i=[listen(t,"measure",e[13]),action_destroyer(measurable.call(null,t))],a=!0)},p(e,a){l&&l.p&&1040&a&&update_slot(l,s,e,e[10],a,get_default_slot_changes_1,get_default_slot_context_1),(!r||2&a&&n!==(n=arrayJoin([e[1]])))&&attr(o,"class",n),(!r||1&a)&&attr(t,"class",e[0]),(!r||4&a)&&attr(t,"style",e[2])},i(e){r||(transition_in(l,e),r=!0)},o(e){transition_out(l,e),r=!1},d(e){e&&detach(t),l&&l.d(e),a=!1,run_all(i)}}}function create_if_block$c(e){let t,o,n,r,a,i=[],s=new Map,l=e[4];const c=e=>e[14];for(let t=0;t<l.length;t+=1){let o=get_each_context$8(e,l,t),n=c(o);s.set(n,i[t]=create_each_block$8(n,o))}return{c(){t=element("div");for(let e=0;e<i.length;e+=1)i[e].c();attr(t,"class",o=arrayJoin(["DokaTabPanels",e[0]])),attr(t,"style",e[2])},m(o,s){insert(o,t,s);for(let e=0;e<i.length;e+=1)i[e].m(t,null);n=!0,r||(a=[listen(t,"measure",e[12]),action_destroyer(measurable.call(null,t))],r=!0)},p(e,r){1042&r&&(l=e[4],group_outros(),i=update_keyed_each(i,r,c,1,e,l,s,t,outro_and_destroy_block,create_each_block$8,null,get_each_context$8),check_outros()),(!n||1&r&&o!==(o=arrayJoin(["DokaTabPanels",e[0]])))&&attr(t,"class",o),(!n||4&r)&&attr(t,"style",e[2])},i(e){if(!n){for(let e=0;e<l.length;e+=1)transition_in(i[e]);n=!0}},o(e){for(let e=0;e<i.length;e+=1)transition_out(i[e]);n=!1},d(e){e&&detach(t);for(let e=0;e<i.length;e+=1)i[e].d();r=!1,run_all(a)}}}function create_if_block_1$d(e){let t;const o=e[11].default,n=create_slot(o,e,e[10],get_default_slot_context);return{c(){n&&n.c()},m(e,o){n&&n.m(e,o),t=!0},p(e,t){n&&n.p&&1040&t&&update_slot(n,o,e,e[10],t,get_default_slot_changes,get_default_slot_context)},i(e){t||(transition_in(n,e),t=!0)},o(e){transition_out(n,e),t=!1},d(e){n&&n.d(e)}}}function create_each_block$8(e,t){let o,n,r,a,i,s,l,c,p,u=t[15]&&create_if_block_1$d(t);return{key:e,first:null,c(){o=element("div"),u&&u.c(),n=space(),attr(o,"class",r=arrayJoin(["DokaTabPanel",t[1]])),o.hidden=a=t[19],attr(o,"id",i=t[16]),attr(o,"tabindex",s=t[17]),attr(o,"aria-labelledby",l=t[18]),attr(o,"data-inert",c=!t[3]),this.first=o},m(e,t){insert(e,o,t),u&&u.m(o,null),append(o,n),p=!0},p(e,d){(t=e)[15]?u?(u.p(t,d),16&d&&transition_in(u,1)):((u=create_if_block_1$d(t)).c(),transition_in(u,1),u.m(o,n)):u&&(group_outros(),transition_out(u,1,1,()=>{u=null}),check_outros()),(!p||2&d&&r!==(r=arrayJoin(["DokaTabPanel",t[1]])))&&attr(o,"class",r),(!p||16&d&&a!==(a=t[19]))&&(o.hidden=a),(!p||16&d&&i!==(i=t[16]))&&attr(o,"id",i),(!p||16&d&&s!==(s=t[17]))&&attr(o,"tabindex",s),(!p||16&d&&l!==(l=t[18]))&&attr(o,"aria-labelledby",l),(!p||16&d&&c!==(c=!t[3]))&&attr(o,"data-inert",c)},i(e){p||(transition_in(u),p=!0)},o(e){transition_out(u),p=!1},d(e){e&&detach(o),u&&u.d()}}}function create_fragment$F(e){let t,o,n,r;const a=[create_if_block$c,create_else_block$5],i=[];function s(e,t){return e[5]?0:1}return t=s(e),o=i[t]=a[t](e),{c(){o.c(),n=empty()},m(e,o){i[t].m(e,o),insert(e,n,o),r=!0},p(e,[r]){let l=t;(t=s(e))===l?i[t].p(e,r):(group_outros(),transition_out(i[l],1,1,()=>{i[l]=null}),check_outros(),(o=i[t])?o.p(e,r):(o=i[t]=a[t](e)).c(),transition_in(o,1),o.m(n.parentNode,n))},i(e){r||(transition_in(o),r=!0)},o(e){transition_out(o),r=!1},d(e){i[t].d(e),e&&detach(n)}}}function instance$F(e,t,o){let n,r,{$$slots:a={},$$scope:i}=t,{class:s}=t,{name:l}=t,{selected:c}=t,{visible:p}=t,{panelClass:u}=t,{panels:d=[]}=t,{style:h}=t;const m={};return e.$$set=(e=>{"class"in e&&o(0,s=e.class),"name"in e&&o(6,l=e.name),"selected"in e&&o(7,c=e.selected),"visible"in e&&o(3,p=e.visible),"panelClass"in e&&o(1,u=e.panelClass),"panels"in e&&o(8,d=e.panels),"style"in e&&o(2,h=e.style),"$$scope"in e&&o(10,i=e.$$scope)}),e.$$.update=(()=>{968&e.$$.dirty&&o(4,n=d.map(e=>{const t=e===c,n=!p||-1!==p.indexOf(e);return t&&o(9,m[e]=!0,m),{id:e,panelId:`doka-${l}-${e}`,labelledBy:`doka-tab-${l}-${e}`,hidden:!t,visible:n,tabindex:t?0:-1,draw:t||m[e]}})),16&e.$$.dirty&&o(5,r=n.length>1)}),[s,u,h,p,n,r,l,c,d,m,i,a,function(t){bubble(e,t)},function(t){bubble(e,t)}]}class TabPanels extends SvelteComponent{constructor(e){super(),init(this,e,instance$F,create_fragment$F,safe_not_equal,{class:0,name:6,selected:7,visible:3,panelClass:1,panels:8,style:2})}}function create_fragment$E(e){let t,o,n,r,a;const i=[e[6]];function s(t){e[19](t)}var l=e[10];function c(e){let t={};for(let e=0;e<i.length;e+=1)t=assign(t,i[e]);return void 0!==e[4]&&(t.name=e[4]),{props:t}}return l&&(o=new l(c(e)),binding_callbacks.push(()=>bind(o,"name",s)),e[20](o),o.$on("measure",e[21])),{c(){t=element("div"),o&&create_component(o.$$.fragment),attr(t,"data-util",e[4]),attr(t,"class",r=arrayJoin(["DokaPanel",e[1]])),attr(t,"style",e[5])},m(e,n){insert(e,t,n),o&&mount_component(o,t,null),a=!0},p(e,[p]){const u=64&p?get_spread_update(i,[get_spread_object(e[6])]):{};if(!n&&16&p&&(n=!0,u.name=e[4],add_flush_callback(()=>n=!1)),l!==(l=e[10])){if(o){group_outros();const e=o;transition_out(e.$$.fragment,1,0,()=>{destroy_component(e,1)}),check_outros()}l?(o=new l(c(e)),binding_callbacks.push(()=>bind(o,"name",s)),e[20](o),o.$on("measure",e[21]),create_component(o.$$.fragment),transition_in(o.$$.fragment,1),mount_component(o,t,null)):o=null}else l&&o.$set(u);(!a||16&p)&&attr(t,"data-util",e[4]),(!a||2&p&&r!==(r=arrayJoin(["DokaPanel",e[1]])))&&attr(t,"class",r),(!a||32&p)&&attr(t,"style",e[5])},i(e){a||(o&&transition_in(o.$$.fragment,e),a=!0)},o(e){o&&transition_out(o.$$.fragment,e),a=!1},d(n){n&&detach(t),e[20](null),o&&destroy_component(o)}}}function instance$E(e,t,o){let n,r,a,i;const s=createEventDispatcher();let l,{isActive:c=!0}=t,{isAnimated:p=!0}=t,{stores:u}=t,{content:d}=t,{component:h}=t,{locale:m}=t,{class:g}=t;const f=spring(0),_=derived(f,e=>clamp(e,0,1));component_subscribe(e,_,e=>o(18,a=e));let $=!c;const b=writable(c);component_subscribe(e,b,e=>o(22,i=e));const y={isActive:derived(b,e=>e),isActiveFraction:derived(_,e=>e),isVisible:derived(_,e=>e>0)},x=d.view,v=getComponentExportedProps(x),C=Object.keys(d.props||{}).reduce((e,t)=>v.includes(t)?(e[t]=d.props[t],e):e,{}),S=Object.keys(y).reduce((e,t)=>v.includes(t)?(e[t]=y[t],e):e,{});let k,w=!1;onMount(()=>{o(3,w=!0)});return e.$$set=(e=>{"isActive"in e&&o(11,c=e.isActive),"isAnimated"in e&&o(12,p=e.isAnimated),"stores"in e&&o(13,u=e.stores),"content"in e&&o(14,d=e.content),"component"in e&&o(0,h=e.component),"locale"in e&&o(15,m=e.locale),"class"in e&&o(1,g=e.class)}),e.$$.update=(()=>{2053&e.$$.dirty&&l&&c&&h&&s("measure",l),6144&e.$$.dirty&&f.set(c?1:0,{hard:!p}),393216&e.$$.dirty&&(a<=0&&!$?o(17,$=!0):a>0&&$&&o(17,$=!1)),131080&e.$$.dirty&&w&&s($?"hide":"show"),262144&e.$$.dirty&&s("fade",a),262144&e.$$.dirty&&o(5,n=a<1?`opacity: ${a}`:void 0),2048&e.$$.dirty&&set_store_value(b,i=c,i),40960&e.$$.dirty&&o(6,r={...C,...S,stores:u,locale:m})}),[h,g,l,w,k,n,r,s,_,b,x,c,p,u,d,m,f,$,a,function(e){o(4,k=e)},function(e){binding_callbacks[e?"unshift":"push"](()=>{o(0,h=e)})},e=>{w&&(o(2,l=e.detail),s("measure",{...l}))}]}class Panel extends SvelteComponent{constructor(e){super(),init(this,e,instance$E,create_fragment$E,safe_not_equal,{isActive:11,isAnimated:12,stores:13,content:14,component:0,locale:15,class:1,opacity:16})}get opacity(){return this.$$.ctx[16]}}function create_fragment$D(e){let t,o,n;const r=e[5].default,a=create_slot(r,e,e[4],null);return{c(){t=svg_element("svg"),a&&a.c(),attr(t,"class",e[3]),attr(t,"style",e[2]),attr(t,"width",e[0]),attr(t,"height",e[1]),attr(t,"viewBox",o="0 0 "+e[0]+"\n    "+e[1]),attr(t,"xmlns","http://www.w3.org/2000/svg"),attr(t,"aria-hidden","true"),attr(t,"focusable","false"),attr(t,"stroke-linecap","round"),attr(t,"stroke-linejoin","round")},m(e,o){insert(e,t,o),a&&a.m(t,null),n=!0},p(e,[i]){a&&a.p&&16&i&&update_slot(a,r,e,e[4],i,null,null),(!n||8&i)&&attr(t,"class",e[3]),(!n||4&i)&&attr(t,"style",e[2]),(!n||1&i)&&attr(t,"width",e[0]),(!n||2&i)&&attr(t,"height",e[1]),(!n||3&i&&o!==(o="0 0 "+e[0]+"\n    "+e[1]))&&attr(t,"viewBox",o)},i(e){n||(transition_in(a,e),n=!0)},o(e){transition_out(a,e),n=!1},d(e){e&&detach(t),a&&a.d(e)}}}function instance$D(e,t,o){let{$$slots:n={},$$scope:r}=t,{width:a=24}=t,{height:i=24}=t,{style:s}=t,{class:l}=t;return e.$$set=(e=>{"width"in e&&o(0,a=e.width),"height"in e&&o(1,i=e.height),"style"in e&&o(2,s=e.style),"class"in e&&o(3,l=e.class),"$$scope"in e&&o(4,r=e.$$scope)}),[a,i,s,l,r,n]}class Icon extends SvelteComponent{constructor(e){super(),init(this,e,instance$D,create_fragment$D,safe_not_equal,{width:0,height:1,style:2,class:3})}}var isEventTarget=(e,t)=>t===e.target||t.contains(e.target);function create_if_block_1$c(e){let t,o;return t=new Icon({props:{class:"DokaButtonIcon",$$slots:{default:[create_default_slot$d]},$$scope:{ctx:e}}}),{c(){create_component(t.$$.fragment)},m(e,n){mount_component(t,e,n),o=!0},p(e,o){const n={};1048578&o&&(n.$$scope={dirty:o,ctx:e}),t.$set(n)},i(e){o||(transition_in(t.$$.fragment,e),o=!0)},o(e){transition_out(t.$$.fragment,e),o=!1},d(e){destroy_component(t,e)}}}function create_default_slot$d(e){let t;return{c(){t=svg_element("g")},m(o,n){insert(o,t,n),t.innerHTML=e[1]},p(e,o){2&o&&(t.innerHTML=e[1])},d(e){e&&detach(t)}}}function create_if_block$b(e){let t,o;return{c(){t=element("span"),o=text(e[0]),attr(t,"class",e[11])},m(e,n){insert(e,t,n),append(t,o)},p(e,n){1&n&&set_data(o,e[0]),2048&n&&attr(t,"class",e[11])},d(e){e&&detach(t)}}}function fallback_block$2(e){let t,o,n,r=e[1]&&create_if_block_1$c(e),a=e[0]&&create_if_block$b(e);return{c(){t=element("span"),r&&r.c(),o=space(),a&&a.c(),attr(t,"class",e[9])},m(e,i){insert(e,t,i),r&&r.m(t,null),append(t,o),a&&a.m(t,null),n=!0},p(e,i){e[1]?r?(r.p(e,i),2&i&&transition_in(r,1)):((r=create_if_block_1$c(e)).c(),transition_in(r,1),r.m(t,o)):r&&(group_outros(),transition_out(r,1,1,()=>{r=null}),check_outros()),e[0]?a?a.p(e,i):((a=create_if_block$b(e)).c(),a.m(t,null)):a&&(a.d(1),a=null),(!n||512&i)&&attr(t,"class",e[9])},i(e){n||(transition_in(r),n=!0)},o(e){transition_out(r),n=!1},d(e){e&&detach(t),r&&r.d(),a&&a.d()}}}function create_fragment$C(e){let t,o,n,r;const a=e[18].default,i=create_slot(a,e,e[20],null),s=i||fallback_block$2(e);return{c(){t=element("button"),s&&s.c(),attr(t,"type",e[4]),attr(t,"style",e[2]),t.disabled=e[3],attr(t,"class",e[10]),attr(t,"title",e[0])},m(a,i){insert(a,t,i),s&&s.m(t,null),e[19](t),o=!0,n||(r=[listen(t,"keydown",function(){is_function(e[6])&&e[6].apply(this,arguments)}),listen(t,"click",function(){is_function(e[5])&&e[5].apply(this,arguments)}),action_destroyer(e[7].call(null,t))],n=!0)},p(n,[r]){e=n,i?i.p&&1048576&r&&update_slot(i,a,e,e[20],r,null,null):s&&s.p&&2563&r&&s.p(e,r),(!o||16&r)&&attr(t,"type",e[4]),(!o||4&r)&&attr(t,"style",e[2]),(!o||8&r)&&(t.disabled=e[3]),(!o||1024&r)&&attr(t,"class",e[10]),(!o||1&r)&&attr(t,"title",e[0])},i(e){o||(transition_in(s,e),o=!0)},o(e){transition_out(s,e),o=!1},d(o){o&&detach(t),s&&s.d(o),e[19](null),n=!1,run_all(r)}}}function instance$C(e,t,o){let n,r,a,i,{$$slots:s={},$$scope:l}=t,{class:c}=t,{label:p}=t,{labelClass:u}=t,{innerClass:d}=t,{hideLabel:h=!1}=t,{icon:m}=t,{style:g}=t,{disabled:f}=t,{type:_="button"}=t,{onclick:$}=t,{onkeydown:b}=t,{action:y=(()=>{})}=t;return e.$$set=(e=>{"class"in e&&o(12,c=e.class),"label"in e&&o(0,p=e.label),"labelClass"in e&&o(13,u=e.labelClass),"innerClass"in e&&o(14,d=e.innerClass),"hideLabel"in e&&o(15,h=e.hideLabel),"icon"in e&&o(1,m=e.icon),"style"in e&&o(2,g=e.style),"disabled"in e&&o(3,f=e.disabled),"type"in e&&o(4,_=e.type),"onclick"in e&&o(5,$=e.onclick),"onkeydown"in e&&o(6,b=e.onkeydown),"action"in e&&o(7,y=e.action),"$$scope"in e&&o(20,l=e.$$scope)}),e.$$.update=(()=>{16384&e.$$.dirty&&o(9,n=arrayJoin(["DokaButtonInner",d])),36864&e.$$.dirty&&o(10,r=arrayJoin(["DokaButton",h&&"DokaButtonIconOnly",c])),40960&e.$$.dirty&&o(11,a=arrayJoin([h?"implicit":"DokaButtonLabel",u]))}),[p,m,g,f,_,$,b,y,i,n,r,a,c,u,d,h,e=>isEventTarget(e,i),()=>i,s,function(e){binding_callbacks[e?"unshift":"push"](()=>{o(8,i=e)})},l]}class Button extends SvelteComponent{constructor(e){super(),init(this,e,instance$C,create_fragment$C,safe_not_equal,{class:12,label:0,labelClass:13,innerClass:14,hideLabel:15,icon:1,style:2,disabled:3,type:4,onclick:5,onkeydown:6,action:7,isEventTarget:16,getElement:17})}get isEventTarget(){return this.$$.ctx[16]}get getElement(){return this.$$.ctx[17]}}var arrayRemove=(e,t)=>{const o=e.findIndex(t);if(o>=0)return e.splice(o,1)};const INERTIA_THRESHOLD=.25,INERTIA_DISTANCE_MULTIPLIER=50,INERTIA_DURATION_MULTIPLIER=80,TAP_DURATION_MAX=300,TAP_DISTANCE_MAX=64,DOUBLE_TAP_DURATION_MAX=700,DOUBLE_TAP_DISTANCE_MAX=128,isContextMenuAction=e=>isNumber(e.button)&&0!==e.button,getPinchScalar=(e,t)=>(t-e)/e;var interactable=(e,t={})=>{const{inertia:o=!1,matchTarget:n=!1,pinch:r=!1,getEventPosition:a=(e=>vectorCreate(e.clientX,e.clientY))}=t;function i(t,o){e.dispatchEvent(new CustomEvent(t,{detail:o}))}function s(){$&&$(),$=void 0}const l=[],c=e=>{const t={timeStamp:e.timeStamp,timeStampInitial:e.timeStamp,position:a(e),origin:a(e),velocity:vectorCreateEmpty(),translation:vectorCreateEmpty(),interactionState:void 0,event:e};l.push(t),t.interactionState=f(l)},p=e=>{const t=arrayRemove(l,t=>t.event.pointerId===e.pointerId);if(t)return t[0]},u=e=>{e.origin.x=e.position.x,e.origin.y=e.position.y,e.translation.x=0,e.translation.y=0},d=e=>{const t=h(e);if(!t)return;const{timeStamp:o}=e,n=a(e),r=Math.max(1,o-t.timeStamp);t.velocity.x=(n.x-t.position.x)/r,t.velocity.y=(n.y-t.position.y)/r,t.translation.x=n.x-t.origin.x,t.translation.y=n.y-t.origin.y,t.timeStamp=o,t.position.x=n.x,t.position.y=n.y,t.event=e},h=e=>{const t=(e=>l.findIndex(t=>t.event.pointerId===e.pointerId))(e);if(!(t<0))return l[t]},m=()=>1===l.length,g=()=>2===l.length,f=e=>{const t=vectorCenter(e.map(e=>e.position));return{center:t,distance:((e,t)=>{return e.reduce((e,o)=>e+=vectorDistance(t,o.position),0)/e.length})(e,t),velocity:vectorCenter(e.map(e=>e.velocity)),translation:vectorCenter(e.map(e=>e.translation))}};let _,$,b,y,x,v,C=0,S=void 0;function k(t){g()||isContextMenuAction(t)||n&&t.target!==e||(s(),c(t),m()?(document.documentElement.addEventListener("pointermove",w),document.documentElement.addEventListener("pointerup",R),document.documentElement.addEventListener("pointercancel",R),v=!1,x=0,y=vectorCreateEmpty(),b=void 0,i("interactionstart",{origin:vectorClone(h(t).origin)})):r&&(v=!0,b=vectorDistance(l[0].position,l[1].position),y.x+=l[0].translation.x,y.y+=l[0].translation.y,u(l[0])))}function w(e){e.preventDefault(),d(e);let t=x,o=vectorClone(l[0].translation);if(r&&g()){o.x+=l[1].translation.x,o.y+=l[1].translation.y;const e=vectorDistance(l[0].position,l[1].position);t+=getPinchScalar(b,e)}o.x+=y.x,o.y+=y.y,i("interactionupdate",{translation:o,scalar:r?t:void 0})}function R(e){const t=p(e);if(r&&m()){const e=vectorDistance(l[0].position,t.position);x=(x||0)+getPinchScalar(b,e),y.x+=l[0].translation.x+t.translation.x,y.y+=l[0].translation.y+t.translation.y,u(l[0])}let n=!1,a=!1;if(!v){const e=performance.now(),o=e-t.timeStampInitial,r=vectorDistanceSquared(t.translation);n=r<TAP_DISTANCE_MAX&&o<TAP_DURATION_MAX,a=!!(S&&n&&e-C<DOUBLE_TAP_DURATION_MAX&&vectorDistanceSquared(S,t.position)<DOUBLE_TAP_DISTANCE_MAX),n&&(S=vectorClone(t.position),C=e)}if(l.length>0)return;document.documentElement.removeEventListener("pointermove",w),document.documentElement.removeEventListener("pointerup",R),document.documentElement.removeEventListener("pointercancel",R);const s=vectorClone(t.translation),c=vectorClone(t.velocity);let d=!1;i("interactionrelease",{isTap:n,isDoubleTap:a,translation:s,scalar:x,preventInertia:()=>d=!0});const h=vectorDistance(c);if(d||!o||h<INERTIA_THRESHOLD)return E(s,{isTap:n,isDoubleTap:a});(_=tweened(vectorClone(s),{easing:circOut,duration:h*INERTIA_DURATION_MULTIPLIER})).set({x:s.x+c.x*INERTIA_DISTANCE_MULTIPLIER,y:s.y+c.y*INERTIA_DISTANCE_MULTIPLIER}).then(()=>{$&&E(get_store_value(_),{isTap:n,isDoubleTap:a})}),$=_.subscribe(T)}function T(e){e&&i("interactionupdate",{translation:e,scalar:r?x:void 0})}function E(e,t){s(),i("interactionend",{...t,translation:e,scalar:r?x:void 0})}return e.addEventListener("pointerdown",k),{destroy(){s(),e.removeEventListener("pointerdown",k)}}},nudgeable=(e,t={})=>{const{direction:o,shiftMultiplier:n=10,bubbles:r=!1,stopKeydownPropagation:a=!0}=t,i="horizontal"===o,s="vertical"===o,l=t=>{const{key:o}=t,l=t.shiftKey,c=/up|down/i.test(o),p=/left|right/i.test(o);if(!c&&!p)return;if(i&&p)return;if(s&&c)return;const u=l?n:1;a&&t.stopPropagation(),e.dispatchEvent(new CustomEvent("nudge",{bubbles:r,detail:vectorCreate((/left/i.test(o)?-1:/right/i.test(o)?1:0)*u,(/up/i.test(o)?-1:/down/i.test(o)?1:0)*u)}))};return e.addEventListener("keydown",l),{destroy(){e.removeEventListener("keydown",l)}}};function elastify(e,t){return t*Math.sign(e)*Math.log10(1+Math.abs(e)/t)}const elastifyRects=(e,t,o)=>{if(!t)return rectClone(e);const n=e.x+elastify(t.x-e.x,o),r=e.x+e.width+elastify(t.x+t.width-(e.x+e.width),o),a=e.y+elastify(t.y-e.y,o);return{x:n,y:a,width:r-n,height:e.y+e.height+elastify(t.y+t.height-(e.y+e.height),o)-a}};var unitToPixels=(e,t)=>{if(e)return/em/.test(e)?16*parseInt(e,10):/px/.test(e)?parseInt(e,10):void 0},getWheelDelta=e=>{let t=e.detail||0;const{deltaX:o,deltaY:n,wheelDelta:r,wheelDeltaX:a,wheelDeltaY:i}=e;return isNumber(a)&&Math.abs(a)>Math.abs(i)?t=a/-120:isNumber(o)&&Math.abs(o)>Math.abs(n)?t=o/20:(r||i)&&(t=(r||i)/-120),t||(t=n/20),t};function create_fragment$B(e){let t,o,n,r,a,i,s;const l=e[37].default,c=create_slot(l,e,e[36],null);return{c(){t=element("div"),o=element("div"),c&&c.c(),attr(o,"style",e[6]),attr(t,"class",n=arrayJoin(["DokaScrollable",e[0]])),attr(t,"style",e[4]),attr(t,"data-direction",e[1]),attr(t,"data-state",e[5])},m(n,l){insert(n,t,l),append(t,o),c&&c.m(o,null),e[39](t),a=!0,i||(s=[listen(o,"interactionstart",e[9]),listen(o,"interactionupdate",e[11]),listen(o,"interactionend",e[12]),listen(o,"interactionrelease",e[10]),action_destroyer(interactable.call(null,o,{inertia:!0})),listen(o,"measure",e[38]),action_destroyer(measurable.call(null,o)),listen(t,"wheel",e[14],{passive:!1}),listen(t,"scroll",e[16]),listen(t,"focusin",e[15]),listen(t,"nudge",e[17]),listen(t,"measure",e[13]),action_destroyer(measurable.call(null,t,{observePosition:!0})),action_destroyer(r=nudgeable.call(null,t,{direction:"x"===e[1]?"horizontal":"vertical",stopKeydownPropagation:!1}))],i=!0)},p(e,i){c&&c.p&&32&i[1]&&update_slot(c,l,e,e[36],i,null,null),(!a||64&i[0])&&attr(o,"style",e[6]),(!a||1&i[0]&&n!==(n=arrayJoin(["DokaScrollable",e[0]])))&&attr(t,"class",n),(!a||16&i[0])&&attr(t,"style",e[4]),(!a||2&i[0])&&attr(t,"data-direction",e[1]),(!a||32&i[0])&&attr(t,"data-state",e[5]),r&&is_function(r.update)&&2&i[0]&&r.update.call(null,{direction:"x"===e[1]?"horizontal":"vertical",stopKeydownPropagation:!1})},i(e){a||(transition_in(c,e),a=!0)},o(e){transition_out(c,e),a=!1},d(o){o&&detach(t),c&&c.d(o),e[39](null),i=!1,run_all(s)}}}function instance$B(e,t,o){let n,r,a,i,s,l,c,p,u,{$$slots:d={},$$scope:h}=t;const m=createEventDispatcher(),g=getContext("keysPressed");component_subscribe(e,g,e=>o(46,u=e));let f,_,$,b,y="idle",x=spring(0);component_subscribe(e,x,e=>o(34,p=e));let v,{class:C}=t,{scrollBlockInteractionDist:S=5}=t,{scrollStep:k=10}=t,{scrollFocusMargin:w=64}=t,{scrollDirection:R="x"}=t,{scrollAutoCancel:T=!1}=t,{elasticity:E=0}=t,{onscroll:I=noop$1}=t,{maskFeatherSize:A}=t,{maskFeatherStartOpacity:M}=t,{maskFeatherEndOpacity:P}=t,{scroll:D}=t,F="",L=!0;x.subscribe(e=>{const t=vectorCreateEmpty();t[R]=e,I(t)});const z=e=>Math.max(Math.min(0,e),$[n]-_[n]);let B,O,U;const N=(e,t={})=>{const{elastic:n=!1,animate:r=!1}=t;Math.abs(e)>S&&"idle"===y&&!b&&o(28,y="scrolling");const a=z(e),i=n&&E&&!b?a+elastify(e-a,E):a;let s=!0;r?s=!1:L||(s=!b),L=!1,x.set(i,{hard:s}).then(e=>{b&&(L=!0)})};return e.$$set=(e=>{"class"in e&&o(0,C=e.class),"scrollBlockInteractionDist"in e&&o(21,S=e.scrollBlockInteractionDist),"scrollStep"in e&&o(22,k=e.scrollStep),"scrollFocusMargin"in e&&o(23,w=e.scrollFocusMargin),"scrollDirection"in e&&o(1,R=e.scrollDirection),"scrollAutoCancel"in e&&o(24,T=e.scrollAutoCancel),"elasticity"in e&&o(25,E=e.elasticity),"onscroll"in e&&o(26,I=e.onscroll),"maskFeatherSize"in e&&o(20,A=e.maskFeatherSize),"maskFeatherStartOpacity"in e&&o(18,M=e.maskFeatherStartOpacity),"maskFeatherEndOpacity"in e&&o(19,P=e.maskFeatherEndOpacity),"scroll"in e&&o(27,D=e.scroll),"$$scope"in e&&o(36,h=e.$$scope)}),e.$$.update=(()=>{if(2&e.$$.dirty[0]&&o(30,n="x"===R?"width":"height"),2&e.$$.dirty[0]&&o(31,r=R.toUpperCase()),8&e.$$.dirty[0]&&o(32,a=v&&getComputedStyle(v)),8&e.$$.dirty[0]|2&e.$$.dirty[1]&&o(33,i=a&&unitToPixels(a.getPropertyValue("--scrollable-feather-size"))),1611399172&e.$$.dirty[0]|12&e.$$.dirty[1]&&null!=p&&$&&null!=i&&_){const e=-p/i,t=-($[n]-_[n]-p)/i;o(18,M=clamp(1-e,0,1)),o(19,P=clamp(1-t,0,1)),o(20,A=i),o(4,F=`--scrollable-feather-start-opacity: ${M};--scrollable-feather-end-opacity: ${P}`)}134217736&e.$$.dirty[0]&&v&&void 0!==D&&(isNumber(D)?N(D):N(D.scrollOffset,D)),1610612740&e.$$.dirty[0]&&o(35,s=$&&_?_[n]>$[n]:void 0),268435456&e.$$.dirty[0]|16&e.$$.dirty[1]&&o(5,l=arrayJoin([y,s?"overflows":void 0])),25&e.$$.dirty[1]&&o(6,c=s?`transform: translate${r}(${p}px)`:void 0)}),[C,R,_,v,F,l,c,g,x,()=>{s&&(O=!1,B=!0,U=vectorCreate(0,0),b=!1,o(28,y="idle"),f=get_store_value(x))},({detail:e})=>{s&&(b=!0,o(28,y="idle"))},({detail:e})=>{s&&(O||B&&(B=!1,vectorDistanceSquared(e.translation)<.1)||(!T||"x"!==R||(e=>{const t=vectorApply(vectorCreate(e.x-U.x,e.y-U.y),Math.abs);U=vectorClone(e);const o=vectorDistanceSquared(t),n=t.x-t.y;return!(o>1&&n<-.5)})(e.translation)?N(f+e.translation[R],{elastic:!0}):O=!0))},({detail:e})=>{if(!s)return;if(O)return;const t=f+e.translation[R],o=z(t);L=!1,x.set(o).then(e=>{b&&(L=!0)})},({detail:e})=>{o(29,$=e),m("measure",{x:e.x,y:e.y,width:e.width,height:e.height})},e=>{if(!s)return;e.preventDefault(),e.stopPropagation();const t=getWheelDelta(e),o=get_store_value(x);N(o+t*k,{animate:!0})},e=>{if(!s)return;if(!b&&!u.length)return;let t=e.target;e.target.classList.contains("implicit")&&(t=t.parentNode);const o=t["x"===R?"offsetLeft":"offsetTop"],r=o+t["x"===R?"offsetWidth":"offsetHeight"],a=get_store_value(x),i=w+A;a+o<i?N(-o+i):a+r>$[n]-i&&N($[n]-r-i,{animate:!0})},()=>{o(3,v["x"===R?"scrollLeft":"scrollTop"]=0,v)},({detail:e})=>{const t=-2*e[R],o=get_store_value(x);N(o+t*k,{animate:!0})},M,P,A,S,k,w,T,E,I,D,y,$,n,r,a,i,p,s,h,d,e=>o(2,_=e.detail),function(e){binding_callbacks[e?"unshift":"push"](()=>{o(3,v=e)})}]}class Scrollable extends SvelteComponent{constructor(e){super(),init(this,e,instance$B,create_fragment$B,safe_not_equal,{class:0,scrollBlockInteractionDist:21,scrollStep:22,scrollFocusMargin:23,scrollDirection:1,scrollAutoCancel:24,elasticity:25,onscroll:26,maskFeatherSize:20,maskFeatherStartOpacity:18,maskFeatherEndOpacity:19,scroll:27},[-1,-1])}}function fade$1(e,{delay:t=0,duration:o=400,easing:n=identity}={}){const r=+getComputedStyle(e).opacity;return{delay:t,duration:o,easing:n,css:e=>`opacity: ${e*r}`}}function create_fragment$A(e){let t,o,n,r,a,i;return{c(){t=element("span"),o=text(e[0]),attr(t,"class","DokaStatusMessage")},m(n,s){insert(n,t,s),append(t,o),r=!0,a||(i=[listen(t,"measure",function(){is_function(e[1])&&e[1].apply(this,arguments)}),action_destroyer(measurable.call(null,t))],a=!0)},p(t,[n]){e=t,(!r||1&n)&&set_data(o,e[0])},i(e){r||(add_render_callback(()=>{n||(n=create_bidirectional_transition(t,fade$1,{},!0)),n.run(1)}),r=!0)},o(e){n||(n=create_bidirectional_transition(t,fade$1,{},!1)),n.run(0),r=!1},d(e){e&&detach(t),e&&n&&n.end(),a=!1,run_all(i)}}}function instance$A(e,t,o){let{text:n}=t,{onmeasure:r=noop$1}=t;return e.$$set=(e=>{"text"in e&&o(0,n=e.text),"onmeasure"in e&&o(1,r=e.onmeasure)}),[n,r]}class StatusMessage extends SvelteComponent{constructor(e){super(),init(this,e,instance$A,create_fragment$A,safe_not_equal,{text:0,onmeasure:1})}}function create_fragment$z(e){let t,o,n,r,a,i,s,l;return{c(){t=element("span"),o=svg_element("svg"),n=svg_element("g"),r=svg_element("circle"),a=svg_element("circle"),i=space(),s=element("span"),l=text(e[0]),attr(r,"class","DokaProgressIndicatorBar"),attr(r,"r","8.5"),attr(r,"cx","10"),attr(r,"cy","10"),attr(r,"stroke-linecap","round"),attr(r,"opacity",".25"),attr(a,"class","DokaProgressIndicatorFill"),attr(a,"r","8.5"),attr(a,"stroke-dasharray",e[1]),attr(a,"cx","10"),attr(a,"cy","10"),attr(a,"transform","rotate(-90) translate(-20)"),attr(n,"fill","none"),attr(n,"stroke","currentColor"),attr(n,"stroke-width","2.5"),attr(n,"stroke-linecap","round"),attr(n,"opacity",e[2]),attr(o,"width","20"),attr(o,"height","20"),attr(o,"viewBox","0 0 20 20"),attr(o,"xmlns","http://www.w3.org/2000/svg"),attr(o,"aria-hidden","true"),attr(o,"focusable","false"),attr(s,"class","implicit"),attr(t,"class","DokaProgressIndicator"),attr(t,"data-status",e[3])},m(e,c){insert(e,t,c),append(t,o),append(o,n),append(n,r),append(n,a),append(t,i),append(t,s),append(s,l)},p(e,[o]){2&o&&attr(a,"stroke-dasharray",e[1]),4&o&&attr(n,"opacity",e[2]),1&o&&set_data(l,e[0]),8&o&&attr(t,"data-status",e[3])},i:noop,o:noop,d(e){e&&detach(t)}}}function instance$z(e,t,o){let n,r,a,i,s;const l=createEventDispatcher();let{progress:c}=t,{min:p=0}=t,{max:u=100}=t,{labelBusy:d="Busy"}=t;const h=spring(0,{precision:.01}),m=derived([h],e=>clamp(e,p,u));return component_subscribe(e,m,e=>o(9,s=e)),m.subscribe(e=>{1===c&&Math.round(e)>=100&&l("complete")}),e.$$set=(e=>{"progress"in e&&o(5,c=e.progress),"min"in e&&o(6,p=e.min),"max"in e&&o(7,u=e.max),"labelBusy"in e&&o(8,d=e.labelBusy)}),e.$$.update=(()=>{32&e.$$.dirty&&c&&c!==1/0&&h.set(100*c),800&e.$$.dirty&&o(0,n=c===1/0?d:`${Math.round(s)}%`),544&e.$$.dirty&&o(1,r=c===1/0?"26.5 53":`${s/100*53} 53`),544&e.$$.dirty&&o(2,a=Math.min(1,c===1/0?1:s/10)),32&e.$$.dirty&&o(3,i=c===1/0?"busy":"loading")}),[n,r,a,i,m,c,p,u,d,s]}class ProgressIndicator extends SvelteComponent{constructor(e){super(),init(this,e,instance$z,create_fragment$z,safe_not_equal,{progress:5,min:6,max:7,labelBusy:8})}}function create_fragment$y(e){let t,o,n;return(o=new ProgressIndicator({props:{progress:e[0]}})).$on("complete",function(){is_function(e[1])&&e[1].apply(this,arguments)}),{c(){t=element("span"),create_component(o.$$.fragment),attr(t,"class","DokaStatusProgress"),attr(t,"style",e[2])},m(e,r){insert(e,t,r),mount_component(o,t,null),n=!0},p(r,[a]){e=r;const i={};1&a&&(i.progress=e[0]),o.$set(i),(!n||4&a)&&attr(t,"style",e[2])},i(e){n||(transition_in(o.$$.fragment,e),n=!0)},o(e){transition_out(o.$$.fragment,e),n=!1},d(e){e&&detach(t),destroy_component(o)}}}function instance$y(e,t,o){let n,{offset:r=0}=t,{visible:a=!0}=t,{progress:i}=t,{oncomplete:s=noop$1}=t;return e.$$set=(e=>{"offset"in e&&o(3,r=e.offset),"visible"in e&&o(4,a=e.visible),"progress"in e&&o(0,i=e.progress),"oncomplete"in e&&o(1,s=e.oncomplete)}),e.$$.update=(()=>{24&e.$$.dirty&&o(2,n=`transform: translateX(${r}px); opacity: ${a?1:0}`)}),[i,s,n,r,a]}class StatusProgress extends SvelteComponent{constructor(e){super(),init(this,e,instance$y,create_fragment$y,safe_not_equal,{offset:3,visible:4,progress:0,oncomplete:1})}}function get_each_context$7(e,t,o){const n=e.slice();return n[4]=t[o][0],n[5]=t[o][1],n[6]=t[o][2],n[0]=t[o][3],n}function create_else_block$4(e){let t,o,n;const r=[e[6]];var a=e[4];function i(e){let t={};for(let e=0;e<r.length;e+=1)t=assign(t,r[e]);return{props:t}}return a&&(t=new a(i())),{c(){t&&create_component(t.$$.fragment),o=empty()},m(e,r){t&&mount_component(t,e,r),insert(e,o,r),n=!0},p(e,n){const s=1&n?get_spread_update(r,[get_spread_object(e[6])]):{};if(a!==(a=e[4])){if(t){group_outros();const e=t;transition_out(e.$$.fragment,1,0,()=>{destroy_component(e,1)}),check_outros()}a?(create_component((t=new a(i())).$$.fragment),transition_in(t.$$.fragment,1),mount_component(t,o.parentNode,o)):t=null}else a&&t.$set(s)},i(e){n||(t&&transition_in(t.$$.fragment,e),n=!0)},o(e){t&&transition_out(t.$$.fragment,e),n=!1},d(e){e&&detach(o),t&&destroy_component(t,e)}}}function create_if_block$a(e){let t,o,n;o=new DynamicComponentTree_1({props:{items:e[0],discardEmptyItems:!0}});let r=[e[6]],a={};for(let e=0;e<r.length;e+=1)a=assign(a,r[e]);return{c(){t=element("div"),create_component(o.$$.fragment),set_attributes(t,a)},m(e,r){insert(e,t,r),mount_component(o,t,null),n=!0},p(e,n){const i={};1&n&&(i.items=e[0]),o.$set(i),set_attributes(t,a=get_spread_update(r,[1&n&&e[6]]))},i(e){n||(transition_in(o.$$.fragment,e),n=!0)},o(e){transition_out(o.$$.fragment,e),n=!1},d(e){e&&detach(t),destroy_component(o)}}}function create_each_block$7(e,t){let o,n,r,a,i,s;const l=[create_if_block$a,create_else_block$4],c=[];function p(e,t){return 1&t&&(n=!!isString(e[4])),n?0:1}return r=p(t,-1),a=c[r]=l[r](t),{key:e,first:null,c(){o=empty(),a.c(),i=empty(),this.first=o},m(e,t){insert(e,o,t),c[r].m(e,t),insert(e,i,t),s=!0},p(e,o){let n=r;(r=p(t=e,o))===n?c[r].p(t,o):(group_outros(),transition_out(c[n],1,1,()=>{c[n]=null}),check_outros(),(a=c[r])?a.p(t,o):(a=c[r]=l[r](t)).c(),transition_in(a,1),a.m(i.parentNode,i))},i(e){s||(transition_in(a),s=!0)},o(e){transition_out(a),s=!1},d(e){e&&detach(o),c[r].d(e),e&&detach(i)}}}function create_fragment$x(e){let t,o,n=[],r=new Map,a=e[0];const i=e=>e[5];for(let t=0;t<a.length;t+=1){let o=get_each_context$7(e,a,t),s=i(o);r.set(s,n[t]=create_each_block$7(s,o))}return{c(){for(let e=0;e<n.length;e+=1)n[e].c();t=empty()},m(e,r){for(let t=0;t<n.length;t+=1)n[t].m(e,r);insert(e,t,r),o=!0},p(e,[o]){1&o&&(a=e[0],group_outros(),n=update_keyed_each(n,o,i,1,e,a,r,t.parentNode,outro_and_destroy_block,create_each_block$7,t,get_each_context$7),check_outros())},i(e){if(!o){for(let e=0;e<a.length;e+=1)transition_in(n[e]);o=!0}},o(e){for(let e=0;e<n.length;e+=1)transition_out(n[e]);o=!1},d(e){for(let t=0;t<n.length;t+=1)n[t].d(e);e&&detach(t)}}}function instance$x(e,t,o){let n,{items:r}=t,{discardEmptyItems:a=!0}=t;const i=e=>{if(!e)return!1;const[t,,,o]=e;return!isString(t)||o.some(i)};return e.$$set=(e=>{"items"in e&&o(1,r=e.items),"discardEmptyItems"in e&&o(2,a=e.discardEmptyItems)}),e.$$.update=(()=>{6&e.$$.dirty&&o(0,n=(r&&a?r.filter(i):r)||[])}),[n,r,a]}class DynamicComponentTree_1 extends SvelteComponent{constructor(e){super(),init(this,e,instance$x,create_fragment$x,safe_not_equal,{items:1,discardEmptyItems:2})}}const ImageStoreProps=["file","size","loadState","processState","cropAspectRatio","cropLimitToImage","crop","cropMinSize","cropMaxSize","cropRange","cropOrigin","cropRectAspectRatio","rotation","rotationRange","targetSize","flipX","flipY","perspectiveX","perspectiveY","perspective","colorMatrix","convolutionMatrix","gamma","vignette","noise","decoration","annotation","backgroundColor","state"],proxy=function(e,t,o){let n=[];return{set:t,update:o,publish:e=>{n.forEach(t=>t(e))},subscribe:t=>(n.push(t),e(t),()=>{n=n.filter(e=>e!==t)})}};var createImageProxy=()=>{let e,t;const o=ImageStoreProps.reduce((e,o)=>(e[o]=proxy(e=>{if(!t)return e();t.stores[o].subscribe(e)()},e=>{t&&t.stores[o].set(e)},e=>{t&&t.stores[o].update(e)}),e),{});return{update:n=>{if(t=n,e&&(e.forEach(e=>e()),e=void 0),!n)return o.file.publish(void 0),void o.loadState.publish(void 0);e=ImageStoreProps.map(e=>n.stores[e].subscribe(t=>{o[e].publish(t)}))},stores:o}},createPingRouter=(e,t=!0)=>o=>{"ping"===o.type&&(t&&o.stopPropagation(),e(o.detail.type,o.detail.data))},isTextarea=e=>/textarea/i.test(e.nodeName),isTextInput=e=>/date|email|number|search|text|url/.test(e.type),isTextField=e=>isTextarea(e)||isTextInput(e),toKebabCase=(e,t)=>(t?stringReplace(e,t):e).replace(/([a-z])([A-Z])/g,"$1-$2").replace(/\s+/g,"-").toLowerCase(),matchMedia$1=(e,t)=>{const o=matchMedia(e);return o.addListener(t),t(o),{get matches(){return o.matches},destroy:()=>o.removeListener(t)}},mediaQueryStore=(e,t=passthrough)=>{const{subscribe:o,set:n}=writable(void 0);return{subscribe:o,unsubscribe:matchMedia$1(e,({matches:e})=>n(t(e))).destroy}},canPreventNavSwipe=()=>{if(!isIOS())return!1;const e=navigator.userAgent.match(/OS (\d+)_(\d+)_?(\d+)?/i)||[],[,t,o]=e.map(e=>parseInt(e,10)||0);return t>13||13===t&&o>=4},calculateImageTransforms=(e,t,o,n,r,a,i,s,l,c,p)=>{if(!(e&&t&&o&&n&&a))return;const u=rectNormalizeOffset(rectClone(t)),d=rectCenter(u),h=rectCenter(e),m=rectCreateFromSize(o),g=rectCenter(m),f=vectorCreate(i,s),_=getBaseCropRect(o,n,l,f),$=rectCenter(_),b=vectorSubtract(vectorClone(g),$),y=vectorSubtract(vectorClone(h),d);b.x+=y.x,b.y+=y.y;const x=vectorInvert(vectorClone(b));x.x+=y.x,x.y+=y.y;const v=rectCenter(rectTranslate(rectClone(r),e)),C=vectorSubtract(v,h);return vectorAdd(b,C),{origin:x,translation:b,rotation:{x:p?Math.PI:0,y:c?Math.PI:0,z:l},perspective:f,scale:a}},historyCreate=(e,t)=>{const{sub:o,pub:n}=pubsub();let r;const a=[],i=writable(-1),s=[],l=()=>s.forEach(e=>e({index:get_store_value(i),length:a.length})),c={get index(){return get_store_value(i)},set index(e){e=Number.isInteger(e)?e:-1,e=clamp(e,-1,a.length-1),i.set(e),t(a[c.index]||r),l()},get state(){return a[a.length-1]||r},length:()=>a.length,undo(){const e=c.index--;return n("undo",e),e},redo(){const e=c.index++;return n("redo",c.index),e},revert(){a.length=0,c.index=-1,n("revert")},write(){a.length=c.index+1,a.push(e()),i.set(a.length-1),l()},set(e={}){r=e},subscribe:e=>(s.push(e),e({index:c.index,length:a.length}),()=>s.splice(s.indexOf(e),1)),on:o};return c},isChrome=()=>isBrowser()&&!!window.chrome,imageBitmapToImageData=async e=>canvasToImageData(await imageDataToCanvas(e)),blobToImageBitmap=(e,t,o)=>new Promise(async(n,r)=>{const a=await t.read(e),i=e=>blobToImageData(e,o).then(e=>t.apply(e,a)).then(n).catch(r);if(!canCreateImageBitmap()||isSVGFile(e))return i(e);let s;try{s=await thread((e,t)=>createImageBitmap(e).then(e=>t(null,e)).catch(t),[e])}catch(e){}return s&&s.width?await canOrientImages()?isChrome()&&a>1?n(await imageBitmapToImageData(s)):void n(s):n(t.apply(s,a)):i(e)}),imageDataContain=(e,t)=>new Promise(async o=>{if(e.width<t.width&&e.height<t.height)return o(e);const n=Math.min(t.width/e.width,t.height/e.height),r=n*e.width,a=n*e.height,i=h("canvas",{width:r,height:a}),s=i.getContext("2d"),l=isImageData(e)?await imageDataToCanvas(e):e;s.drawImage(l,0,0,r,a),o(canvasToImageData(i))});let limit=null;var getWebGLTextureSizeLimit=()=>{if(null!==limit)return limit;const e=h("canvas"),t=getWebGLContext(e);return limit=t?t.getParameter(t.MAX_TEXTURE_SIZE):void 0,releaseCanvas(e),limit},getDevicePixelRatio=()=>isBrowser()&&window.devicePixelRatio||1,hexToRGB=e=>{const[,t,o,n]=e.split("");e=4===e.length?`#${t}${t}${o}${o}${n}${n}`:e;const[,r,a,i]=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);return[r,a,i].map(e=>parseInt(e,16)/255)},colorStringToColorArray=e=>(e=e.trim(),/^rgba/.test(e)?e.substr(5).split(",").map(parseFloat).map((e,t)=>e/(3===t?1:255)):/^rgb/.test(e)?e.substr(4).split(",").map(parseFloat).map(e=>e/255):/^#/.test(e)?hexToRGB(e):void 0),isDarkColor=e=>e[0]<.25&&e[1]<.25&&e[2]<.25;let result$2=null;var supportsWebGL=()=>{if(null===result$2){const e=h("canvas");result$2=!!getWebGLContext(e),releaseCanvas(e)}return result$2};function create_if_block$9(e){let t,o,n,r=e[47]&&create_if_block_5$3(e),a=e[25]&&!e[20]&&create_if_block_1$b(e);return{c(){r&&r.c(),t=space(),a&&a.c(),o=empty()},m(e,i){r&&r.m(e,i),insert(e,t,i),a&&a.m(e,i),insert(e,o,i),n=!0},p(e,n){e[47]?r?(r.p(e,n),65536&n[1]&&transition_in(r,1)):((r=create_if_block_5$3(e)).c(),transition_in(r,1),r.m(t.parentNode,t)):r&&(group_outros(),transition_out(r,1,1,()=>{r=null}),check_outros()),e[25]&&!e[20]?a?(a.p(e,n),34603008&n[0]&&transition_in(a,1)):((a=create_if_block_1$b(e)).c(),transition_in(a,1),a.m(o.parentNode,o)):a&&(group_outros(),transition_out(a,1,1,()=>{a=null}),check_outros())},i(e){n||(transition_in(r),transition_in(a),n=!0)},o(e){transition_out(r),transition_out(a),n=!1},d(e){r&&r.d(e),e&&detach(t),a&&a.d(e),e&&detach(o)}}}function create_if_block_5$3(e){let t,o,n,r,a,i,s;const l=[create_if_block_6$2,create_if_block_7$1,create_if_block_9],c=[];function p(e,t){return e[20]?0:e[22]||e[21]||e[23]||e[24]?1:e[26]&&e[43]?2:-1}return~(n=p(e))&&(r=c[n]=l[n](e)),{c(){t=element("div"),o=element("p"),r&&r.c(),attr(o,"style",a=`transform: translateX(${e[48]}px)`),attr(t,"class","DokaStatus"),attr(t,"style",i=`opacity: ${e[27]}`)},m(e,r){insert(e,t,r),append(t,o),~n&&c[n].m(o,null),s=!0},p(e,u){let d=n;(n=p(e))===d?~n&&c[n].p(e,u):(r&&(group_outros(),transition_out(c[d],1,1,()=>{c[d]=null}),check_outros()),~n?((r=c[n])?r.p(e,u):(r=c[n]=l[n](e)).c(),transition_in(r,1),r.m(o,null)):r=null),(!s||131072&u[1]&&a!==(a=`transform: translateX(${e[48]}px)`))&&attr(o,"style",a),(!s||134217728&u[0]&&i!==(i=`opacity: ${e[27]}`))&&attr(t,"style",i)},i(e){s||(transition_in(r),s=!0)},o(e){transition_out(r),s=!1},d(e){e&&detach(t),~n&&c[n].d()}}}function create_if_block_9(e){let t,o,n,r,a,i;t=new StatusMessage({props:{text:e[43],onmeasure:e[109]}}),n=new StatusProgress({props:{offset:e[49],visible:e[45],progress:e[44]}});let s=e[46]&&create_if_block_10(e);return{c(){create_component(t.$$.fragment),o=space(),create_component(n.$$.fragment),r=space(),s&&s.c(),a=empty()},m(e,l){mount_component(t,e,l),insert(e,o,l),mount_component(n,e,l),insert(e,r,l),s&&s.m(e,l),insert(e,a,l),i=!0},p(e,o){const r={};4096&o[1]&&(r.text=e[43]),t.$set(r);const i={};262144&o[1]&&(i.offset=e[49]),16384&o[1]&&(i.visible=e[45]),8192&o[1]&&(i.progress=e[44]),n.$set(i),e[46]?s?(s.p(e,o),32768&o[1]&&transition_in(s,1)):((s=create_if_block_10(e)).c(),transition_in(s,1),s.m(a.parentNode,a)):s&&(group_outros(),transition_out(s,1,1,()=>{s=null}),check_outros())},i(e){i||(transition_in(t.$$.fragment,e),transition_in(n.$$.fragment,e),transition_in(s),i=!0)},o(e){transition_out(t.$$.fragment,e),transition_out(n.$$.fragment,e),transition_out(s),i=!1},d(e){destroy_component(t,e),e&&detach(o),destroy_component(n,e),e&&detach(r),s&&s.d(e),e&&detach(a)}}}function create_if_block_7$1(e){let t,o,n,r,a,i;t=new StatusMessage({props:{text:e[42],onmeasure:e[109]}}),n=new StatusProgress({props:{offset:e[49],visible:e[41],progress:e[40]}});let s=e[21]&&create_if_block_8(e);return{c(){create_component(t.$$.fragment),o=space(),create_component(n.$$.fragment),r=space(),s&&s.c(),a=empty()},m(e,l){mount_component(t,e,l),insert(e,o,l),mount_component(n,e,l),insert(e,r,l),s&&s.m(e,l),insert(e,a,l),i=!0},p(e,o){const r={};2048&o[1]&&(r.text=e[42]),t.$set(r);const i={};262144&o[1]&&(i.offset=e[49]),1024&o[1]&&(i.visible=e[41]),512&o[1]&&(i.progress=e[40]),n.$set(i),e[21]?s?(s.p(e,o),2097152&o[0]&&transition_in(s,1)):((s=create_if_block_8(e)).c(),transition_in(s,1),s.m(a.parentNode,a)):s&&(group_outros(),transition_out(s,1,1,()=>{s=null}),check_outros())},i(e){i||(transition_in(t.$$.fragment,e),transition_in(n.$$.fragment,e),transition_in(s),i=!0)},o(e){transition_out(t.$$.fragment,e),transition_out(n.$$.fragment,e),transition_out(s),i=!1},d(e){destroy_component(t,e),e&&detach(o),destroy_component(n,e),e&&detach(r),s&&s.d(e),e&&detach(a)}}}function create_if_block_6$2(e){let t,o,n,r,a,i;return t=new StatusMessage({props:{text:e[20],onmeasure:e[109]}}),r=new Icon({props:{$$slots:{default:[create_default_slot_4$1]},$$scope:{ctx:e}}}),{c(){create_component(t.$$.fragment),o=space(),n=element("span"),create_component(r.$$.fragment),attr(n,"class","DokaStatusIcon"),attr(n,"style",a=`transform: translateX(${e[49]}px)`)},m(e,a){mount_component(t,e,a),insert(e,o,a),insert(e,n,a),mount_component(r,n,null),i=!0},p(e,o){const s={};1048576&o[0]&&(s.text=e[20]),t.$set(s);const l={};4&o[0]|2097152&o[8]&&(l.$$scope={dirty:o,ctx:e}),r.$set(l),(!i||262144&o[1]&&a!==(a=`transform: translateX(${e[49]}px)`))&&attr(n,"style",a)},i(e){i||(transition_in(t.$$.fragment,e),transition_in(r.$$.fragment,e),i=!0)},o(e){transition_out(t.$$.fragment,e),transition_out(r.$$.fragment,e),i=!1},d(e){destroy_component(t,e),e&&detach(o),e&&detach(n),destroy_component(r)}}}function create_if_block_10(e){let t,o,n,r;return o=new Button({props:{onclick:e[111],label:e[2].statusLabelButtonClose,icon:e[2].statusIconButtonClose,hideLabel:!0}}),{c(){t=element("span"),create_component(o.$$.fragment),attr(t,"class","DokaStatusButton"),attr(t,"style",n=`transform: translateX(${e[49]}px)`)},m(e,n){insert(e,t,n),mount_component(o,t,null),r=!0},p(e,a){const i={};4&a[0]&&(i.label=e[2].statusLabelButtonClose),4&a[0]&&(i.icon=e[2].statusIconButtonClose),o.$set(i),(!r||262144&a[1]&&n!==(n=`transform: translateX(${e[49]}px)`))&&attr(t,"style",n)},i(e){r||(transition_in(o.$$.fragment,e),r=!0)},o(e){transition_out(o.$$.fragment,e),r=!1},d(e){e&&detach(t),destroy_component(o)}}}function create_if_block_8(e){let t,o,n,r;return o=new Button({props:{onclick:e[110],label:e[2].statusLabelButtonClose,icon:e[2].statusIconButtonClose,hideLabel:!0}}),{c(){t=element("span"),create_component(o.$$.fragment),attr(t,"class","DokaStatusButton"),attr(t,"style",n=`transform: translateX(${e[49]}px)`)},m(e,n){insert(e,t,n),mount_component(o,t,null),r=!0},p(e,a){const i={};4&a[0]&&(i.label=e[2].statusLabelButtonClose),4&a[0]&&(i.icon=e[2].statusIconButtonClose),o.$set(i),(!r||262144&a[1]&&n!==(n=`transform: translateX(${e[49]}px)`))&&attr(t,"style",n)},i(e){r||(transition_in(o.$$.fragment,e),r=!0)},o(e){transition_out(o.$$.fragment,e),r=!1},d(e){e&&detach(t),destroy_component(o)}}}function create_default_slot_4$1(e){let t,o=e[2].iconSupportError+"";return{c(){t=svg_element("g")},m(e,n){insert(e,t,n),t.innerHTML=o},p(e,n){4&n[0]&&o!==(o=e[2].iconSupportError+"")&&(t.innerHTML=o)},d(e){e&&detach(t)}}}function create_if_block_1$b(e){let t,o,n,r,a,i,s,l,c,p=e[6]&&create_if_block_4$5(e),u=e[19]&&e[13]&&create_if_block_3$5(e);const d=[create_if_block_2$7,create_else_block$3],h=[];function m(e,t){return e[19]?0:1}return n=m(e),r=h[n]=d[n](e),i=new Canvas({props:{animate:e[15],pixelRatio:e[56],backgroundColor:e[36],maskRect:e[39],imageSize:e[29],imageData:e[25],imageProps:e[38],imagePreviews:e[57],loadImageData:e[8],willRender:e[199]}}),{c(){p&&p.c(),t=space(),u&&u.c(),o=space(),r.c(),a=space(),create_component(i.$$.fragment),s=space(),attr(l=element("div"),"class","DokaRootPortal")},m(r,d){p&&p.m(r,d),insert(r,t,d),u&&u.m(r,d),insert(r,o,d),h[n].m(r,d),insert(r,a,d),mount_component(i,r,d),insert(r,s,d),insert(r,l,d),e[200](l),c=!0},p(e,s){e[6]?p?(p.p(e,s),64&s[0]&&transition_in(p,1)):((p=create_if_block_4$5(e)).c(),transition_in(p,1),p.m(t.parentNode,t)):p&&(group_outros(),transition_out(p,1,1,()=>{p=null}),check_outros()),e[19]&&e[13]?u?(u.p(e,s),532480&s[0]&&transition_in(u,1)):((u=create_if_block_3$5(e)).c(),transition_in(u,1),u.m(o.parentNode,o)):u&&(group_outros(),transition_out(u,1,1,()=>{u=null}),check_outros());let l=n;(n=m(e))===l?h[n].p(e,s):(group_outros(),transition_out(h[l],1,1,()=>{h[l]=null}),check_outros(),(r=h[n])?r.p(e,s):(r=h[n]=d[n](e)).c(),transition_in(r,1),r.m(a.parentNode,a));const c={};32768&s[0]&&(c.animate=e[15]),33554432&s[1]&&(c.pixelRatio=e[56]),32&s[1]&&(c.backgroundColor=e[36]),256&s[1]&&(c.maskRect=e[39]),536870912&s[0]&&(c.imageSize=e[29]),33554432&s[0]&&(c.imageData=e[25]),128&s[1]&&(c.imageProps=e[38]),67108864&s[1]&&(c.imagePreviews=e[57]),256&s[0]&&(c.loadImageData=e[8]),32&s[0]|939524096&s[1]&&(c.willRender=e[199]),i.$set(c)},i(e){c||(transition_in(p),transition_in(u),transition_in(r),transition_in(i.$$.fragment,e),c=!0)},o(e){transition_out(p),transition_out(u),transition_out(r),transition_out(i.$$.fragment,e),c=!1},d(r){p&&p.d(r),r&&detach(t),u&&u.d(r),r&&detach(o),h[n].d(r),r&&detach(a),destroy_component(i,r),r&&detach(s),r&&detach(l),e[200](null)}}}function create_if_block_4$5(e){let t,o,n,r,a;return o=new DynamicComponentTree_1({props:{items:e[51]}}),{c(){t=element("div"),create_component(o.$$.fragment),attr(t,"class","DokaNav DokaNavTools")},m(i,s){insert(i,t,s),mount_component(o,t,null),n=!0,r||(a=[listen(t,"measure",e[184]),action_destroyer(measurable.call(null,t))],r=!0)},p(e,t){const n={};1048576&t[1]&&(n.items=e[51]),o.$set(n)},i(e){n||(transition_in(o.$$.fragment,e),n=!0)},o(e){transition_out(o.$$.fragment,e),n=!1},d(e){e&&detach(t),destroy_component(o),r=!1,run_all(a)}}}function create_if_block_3$5(e){let t,o,n;return o=new Scrollable({props:{elasticity:e[4]*scrollElasticity,scrollDirection:e[35]?"y":"x",$$slots:{default:[create_default_slot_1$7]},$$scope:{ctx:e}}}),{c(){t=element("div"),create_component(o.$$.fragment),attr(t,"class","DokaNav DokaNavMain")},m(e,r){insert(e,t,r),mount_component(o,t,null),n=!0},p(e,t){const n={};16&t[0]&&(n.elasticity=e[4]*scrollElasticity),16&t[1]&&(n.scrollDirection=e[35]?"y":"x"),65536&t[0]|3&t[1]|2097152&t[8]&&(n.$$scope={dirty:t,ctx:e}),o.$set(n)},i(e){n||(transition_in(o.$$.fragment,e),n=!0)},o(e){transition_out(o.$$.fragment,e),n=!1},d(e){e&&detach(t),destroy_component(o)}}}function create_default_slot_3$2(e){let t,o=e[268].icon+"";return{c(){t=svg_element("g")},m(e,n){insert(e,t,n),t.innerHTML=o},p(e,n){1048576&n[8]&&o!==(o=e[268].icon+"")&&(t.innerHTML=o)},d(e){e&&detach(t)}}}function create_default_slot_2$4(e){let t,o,n,r,a,i=e[268].label+"";return t=new Icon({props:{$$slots:{default:[create_default_slot_3$2]},$$scope:{ctx:e}}}),{c(){create_component(t.$$.fragment),o=space(),n=element("span"),r=text(i)},m(e,i){mount_component(t,e,i),insert(e,o,i),insert(e,n,i),append(n,r),a=!0},p(e,o){const n={};3145728&o[8]&&(n.$$scope={dirty:o,ctx:e}),t.$set(n),(!a||1048576&o[8])&&i!==(i=e[268].label+"")&&set_data(r,i)},i(e){a||(transition_in(t.$$.fragment,e),a=!0)},o(e){transition_out(t.$$.fragment,e),a=!1},d(e){destroy_component(t,e),e&&detach(o),e&&detach(n)}}}function create_default_slot_1$7(e){let t,o;const n=[e[31],{tabs:e[32]}];let r={$$slots:{default:[create_default_slot_2$4,({tab:e})=>({268:e}),({tab:e})=>[0,0,0,0,0,0,0,0,e?1048576:0]]},$$scope:{ctx:e}};for(let e=0;e<n.length;e+=1)r=assign(r,n[e]);return(t=new TabList({props:r})).$on("select",e[185]),{c(){create_component(t.$$.fragment)},m(e,n){mount_component(t,e,n),o=!0},p(e,o){const r=3&o[1]?get_spread_update(n,[1&o[1]&&get_spread_object(e[31]),2&o[1]&&{tabs:e[32]}]):{};3145728&o[8]&&(r.$$scope={dirty:o,ctx:e}),t.$set(r)},i(e){o||(transition_in(t.$$.fragment,e),o=!0)},o(e){transition_out(t.$$.fragment,e),o=!1},d(e){destroy_component(t,e)}}}function create_else_block$3(e){let t,o,n;function r(t){e[194](t)}let a={class:"DokaMain",content:{...e[17].find(e[193]),props:e[7][e[16]]},locale:e[2],isAnimated:e[15],stores:e[104]};return void 0!==e[0][e[16]]&&(a.component=e[0][e[16]]),t=new Panel({props:a}),binding_callbacks.push(()=>bind(t,"component",r)),t.$on("measure",e[195]),t.$on("show",e[196]),t.$on("hide",e[197]),t.$on("fade",e[198]),{c(){create_component(t.$$.fragment)},m(e,o){mount_component(t,e,o),n=!0},p(e,n){const r={};196736&n[0]&&(r.content={...e[17].find(e[193]),props:e[7][e[16]]}),4&n[0]&&(r.locale=e[2]),32768&n[0]&&(r.isAnimated=e[15]),!o&&65537&n[0]&&(o=!0,r.component=e[0][e[16]],add_flush_callback(()=>o=!1)),t.$set(r)},i(e){n||(transition_in(t.$$.fragment,e),n=!0)},o(e){transition_out(t.$$.fragment,e),n=!1},d(e){destroy_component(t,e)}}}function create_if_block_2$7(e){let t,o;const n=[{class:"DokaMain"},{visible:e[28]},e[31],{panels:e[33]}];let r={$$slots:{default:[create_default_slot$c,({panel:e})=>({267:e}),({panel:e})=>[0,0,0,0,0,0,0,0,e?524288:0]]},$$scope:{ctx:e}};for(let e=0;e<n.length;e+=1)r=assign(r,n[e]);return(t=new TabPanels({props:r})).$on("measure",e[192]),{c(){create_component(t.$$.fragment)},m(e,n){mount_component(t,e,n),o=!0},p(e,o){const r=268435456&o[0]|5&o[1]?get_spread_update(n,[n[0],268435456&o[0]&&{visible:e[28]},1&o[1]&&get_spread_object(e[31]),4&o[1]&&{panels:e[33]}]):{};268927109&o[0]|16777216&o[1]|2621440&o[8]&&(r.$$scope={dirty:o,ctx:e}),t.$set(r)},i(e){o||(transition_in(t.$$.fragment,e),o=!0)},o(e){transition_out(t.$$.fragment,e),o=!1},d(e){destroy_component(t,e)}}}function create_default_slot$c(e){let t,o,n;function r(...t){return e[186](e[267],...t)}function a(t){e[187](t,e[267])}let i={content:{...e[17].find(r),props:e[7][e[267]]},locale:e[2],isActive:e[267]===e[16],isAnimated:e[15],stores:e[104]};return void 0!==e[0][e[267]]&&(i.component=e[0][e[267]]),t=new Panel({props:i}),binding_callbacks.push(()=>bind(t,"component",a)),t.$on("measure",e[188]),t.$on("show",function(){return e[189](e[267])}),t.$on("hide",function(){return e[190](e[267])}),t.$on("fade",function(...t){return e[191](e[267],...t)}),{c(){create_component(t.$$.fragment)},m(e,o){mount_component(t,e,o),n=!0},p(n,a){e=n;const i={};131200&a[0]|524288&a[8]&&(i.content={...e[17].find(r),props:e[7][e[267]]}),4&a[0]&&(i.locale=e[2]),65536&a[0]|524288&a[8]&&(i.isActive=e[267]===e[16]),32768&a[0]&&(i.isAnimated=e[15]),!o&&1&a[0]|524288&a[8]&&(o=!0,i.component=e[0][e[267]],add_flush_callback(()=>o=!1)),t.$set(i)},i(e){n||(transition_in(t.$$.fragment,e),n=!0)},o(e){transition_out(t.$$.fragment,e),n=!1},d(e){destroy_component(t,e)}}}function create_fragment$w(e){let t,o,n,r;add_render_callback(e[183]);let a=e[52]&&create_if_block$9(e);return{c(){t=element("div"),a&&a.c(),attr(t,"id",e[3]),attr(t,"class",e[34]),attr(t,"data-env",e[37])},m(i,s){insert(i,t,s),a&&a.m(t,null),e[201](t),o=!0,n||(r=[listen(window,"keydown",e[113]),listen(window,"keyup",e[114]),listen(window,"blur",e[115]),listen(window,"resize",e[183]),listen(t,"ping",function(){is_function(e[53])&&e[53].apply(this,arguments)}),listen(t,"contextmenu",e[116]),listen(t,"touchstart",function(){is_function(e[50])&&e[50].apply(this,arguments)},{passive:!1}),listen(t,"transitionend",e[105]),listen(t,"dropfiles",e[117]),listen(t,"measure",e[202]),action_destroyer(measurable.call(null,t,{observeViewRect:!0})),action_destroyer(focusvisible.call(null,t)),action_destroyer(dropable.call(null,t))],n=!0)},p(n,r){(e=n)[52]?a?(a.p(e,r),2097152&r[1]&&transition_in(a,1)):((a=create_if_block$9(e)).c(),transition_in(a,1),a.m(t,null)):a&&(group_outros(),transition_out(a,1,1,()=>{a=null}),check_outros()),(!o||8&r[0])&&attr(t,"id",e[3]),(!o||8&r[1])&&attr(t,"class",e[34]),(!o||64&r[1])&&attr(t,"data-env",e[37])},i(e){o||(transition_in(a),o=!0)},o(e){transition_out(a),o=!1},d(o){o&&detach(t),a&&a.d(),e[201](null),n=!1,run_all(r)}}}const imageCropRectElasticity=5,imageSelectionRectElasticity=1,scrollElasticity=10,rangeInputElasticity=5;function instance$w(e,t,o){let n,r,a,i,s,l,c,p,u,d,h,m,g,f,_,$,b,y,x,v,C,S,k,w,R,T,E,I,A,M,P,D,F,L,z,B,O,U,N,V,H,W,G,j,q,X,Y,K,Z,J,Q,ee,te,oe,ne,re,ae,ie,se,le,ce,pe,ue,de,he,me,ge,fe,_e,$e,be,ye,xe,ve,Ce,Se,ke,we,Re,Te,Ee,Ie,Ae,Me,Pe,De,Fe,Le,ze,Be,Oe,Ue,Ne,Ve,He,We,Ge,je,qe,Xe,Ye,Ke,Ze,Je,Qe=noop;component_subscribe(e,prefersReducedMotion,e=>o(151,Se=e)),e.$$.on_destroy.push(()=>Qe());const et=pubsub(),tt=createEventDispatcher();let{class:ot}=t,{layout:nt}=t,{stores:rt}=t,{locale:at}=t,{id:it}=t,{util:st}=t,{utils:lt}=t,{animations:ct="auto"}=t,{previewUpscale:pt=!1}=t,{elasticityMultiplier:ut=10}=t,{willRevert:dt=(()=>Promise.resolve(!0))}=t,{willRenderCanvas:ht=passthrough}=t,{willRenderToolbar:mt=passthrough}=t,{enableButtonExport:gt=!0}=t,{enableButtonRevert:ft=!0}=t,{enableNavigateHistory:_t=!0}=t,{enableToolbar:$t=!0}=t,{enableUtils:bt=!0}=t,{enableButtonClose:yt=!1}=t,{previewImageDataMaxSize:xt}=t,{enableDropImage:vt=!1}=t,{imageOrienter:Ct={read:()=>1,apply:e=>e}}=t,{pluginComponents:St}=t,{pluginOptions:kt={}}=t;const wt=et.sub,Rt={};let{root:Tt}=t,Et=[];const It=getWebGLTextureSizeLimit()||1024,At=sizeCreate(It,It),Mt=isIOS()?16777216:1/0;let{imageSourceToImageData:Pt=(e=>isString(e)?fetch(e).then(e=>e.blob()).then(e=>blobToImageBitmap(e,Ct,Mt)).then(e=>imageDataContain(e,a)):isElement(e)?new Promise(t=>t(canvasToImageData(e))):blobToImageBitmap(e,Ct,Mt).then(e=>imageDataContain(e,a)))}=t;const Dt=createImageProxy(),{file:Ft,size:Lt,loadState:zt,processState:Bt,cropAspectRatio:Ot,cropLimitToImage:Ut,crop:Nt,cropMinSize:Vt,cropMaxSize:Ht,cropRange:Wt,cropOrigin:Gt,cropRectAspectRatio:jt,rotation:qt,rotationRange:Xt,targetSize:Yt,flipX:Kt,flipY:Zt,backgroundColor:Jt,colorMatrix:Qt,convolutionMatrix:eo,gamma:to,vignette:oo,noise:no,decoration:ro,annotation:ao,state:io}=Dt.stores;component_subscribe(e,Ft,e=>o(148,Ce=e)),component_subscribe(e,Lt,e=>o(29,ye=e)),component_subscribe(e,zt,e=>o(144,le=e)),component_subscribe(e,Bt,e=>o(181,Ue=e)),component_subscribe(e,Nt,e=>o(146,de=e)),component_subscribe(e,Yt,e=>o(213,$e=e)),component_subscribe(e,Jt,e=>o(178,Le=e)),component_subscribe(e,ro,e=>o(58,Ke=e)),component_subscribe(e,ao,e=>o(59,Ze=e)),component_subscribe(e,io,e=>o(206,se=e));const{images:so,imageReader:lo}=rt;component_subscribe(e,so,e=>o(142,re=e));const co=writable([0,0,0]);component_subscribe(e,co,e=>o(36,Ee=e));const po=writable();component_subscribe(e,po,e=>o(217,Te=e));const uo=writable();component_subscribe(e,uo,e=>o(14,ae=e));const ho=writable();component_subscribe(e,ho,e=>o(143,ie=e));const mo=writable(rectCreateEmpty());component_subscribe(e,mo,e=>o(30,ke=e));const go=writable(rectCreateEmpty());component_subscribe(e,go,e=>o(54,je=e));const fo=writable();component_subscribe(e,fo,e=>o(55,qe=e));const _o=derived([fo,mo,go],([e,t,o],r)=>{if(!e)return r(void 0);let a=0;1!==p.length||n||(a=o.y+o.height),r(rectCreate(e.x+t.x,e.y+t.y+a,e.width,e.height))});component_subscribe(e,_o,e=>o(212,_e=e));const $o=mediaQueryStore("(pointer: fine)",e=>e?"pointer-fine":"pointer-coarse");component_subscribe(e,$o,e=>o(173,Ae=e));const bo=mediaQueryStore("(hover: hover)",e=>e?"pointer-hover":"pointer-no-hover");component_subscribe(e,bo,e=>o(174,Me=e));const yo=writable(!1);component_subscribe(e,yo,e=>o(147,he=e));const xo=readable(void 0,e=>{const t=spring(0),o=[yo.subscribe(e=>{t.set(e?1:0)}),t.subscribe(e)];return()=>o.forEach(e=>e())});component_subscribe(e,xo,e=>o(219,Ge=e));const vo=writable(pt);component_subscribe(e,vo,e=>o(209,ue=e));const Co=derived([_o,Nt],([e,t],o)=>{if(!e||!t||!(!ce&&!pe))return;const n=Math.min(e.width/t.width,e.height/t.height);o(ue?n:Math.min(1,n))});component_subscribe(e,Co,e=>o(214,be=e));const So=writable();component_subscribe(e,So,e=>o(207,ce=e));const ko=writable();component_subscribe(e,ko,e=>o(208,pe=e));const wo=readable(void 0,e=>{const t=spring(void 0,{precision:1e-4}),o=[Nt.subscribe(()=>{if(!de)return;const e=void 0===pe||he,o=elastifyRects(de,pe,imageCropRectElasticity*ut);t.set(o,{hard:e})}),t.subscribe(e)];return()=>o.forEach(e=>e())}),Ro=writable();component_subscribe(e,Ro,e=>o(210,me=e));const To=writable();component_subscribe(e,To,e=>o(216,ve=e));const Eo=writable(void 0);component_subscribe(e,Eo,e=>o(211,fe=e));const Io=readable(void 0,e=>{const t=spring(void 0,{precision:1e-4}),o=()=>{if(!me)return;const e=he||!ge,o=elastifyRects(me,fe,imageSelectionRectElasticity*ut);if(o.width<0&&(o.width=0,o.x=me.x),o.height<0&&(o.height=0,o.y=me.y),rectTranslate(o,_e),"resize"===m&&de){const e=$e||de;rectScale(o,e.width/me.width||e.height/me.height)}t.set(o,{hard:e})},n=[_o.subscribe(o),Ro.subscribe(o),Yt.subscribe(o),t.subscribe(e)];return()=>n.forEach(e=>e())});let Ao;component_subscribe(e,Io,e=>o(39,ze=e)),_o.subscribe(()=>{if(!_e||!de)return;const e=de.width<=_e.width&&de.height<=_e.height?rectCenterRect(_e,rectMultiply(rectClone(de),be||1)):rectContainRect(_e,rectAspectRatio(de||ye));Ro.set(e)}),To.subscribe(e=>{if(!e)return Ao=void 0,void set_store_value(So,ce=void 0,ce);Ao=xe;const t=rectClone(de);So.set(t)}),Ro.subscribe(e=>{if(!e||!ve)return;const t=rectSubtract(rectClone(e),ve);rectDivide(t,Ao);const o=rectAdd(rectClone(ce),t);Nt.set(o)}),Nt.subscribe(e=>{if(he||ve||pe)return;if(!e||!me)return;const t=rectAspectRatio(me),o=rectAspectRatio(e);if(fixPrecision(t,6)===fixPrecision(o,6))return;const n=Math.min(_e.width/de.width,_e.height/de.height),r=sizeCreate(e.width*n,e.height*n),a=.5*(me.width-r.width),i=.5*(me.height-r.height),s=rectCreate(me.x+a,me.y+i,r.width,r.height);Ro.set(s)});const Mo=derived([Co,Nt,Ro],([e,t,o],n)=>{if(!e||!t||!o)return;const r=o.width/t.width,a=o.height/t.height;n(Math.max(r,a)/e)}),Po=derived([Co,Mo],([e,t],o)=>{if(!t)return;o(e*t)});component_subscribe(e,Po,e=>o(215,xe=e));const Do=derived([po,Io],([e,t],o)=>{if(!t||n)return o([]);const{x:r,y:a,width:i,height:s}=t;o([{points:[vectorCreate(r,a),vectorCreate(r+i,a),vectorCreate(r+i,a+s),vectorCreate(r,a+s),vectorCreate(r,a)],strokeWidth:1,strokeColor:e}])}),Fo=writable([]),Lo=derived([Do,Fo],([e,t],o)=>{o([...e,...t])});component_subscribe(e,Lo,e=>o(60,Je=e));const zo=writable(!1);let Bo;component_subscribe(e,zo,e=>o(180,Be=e));const Oo=derived([zo,Ft],([e,t],o)=>{if(Bo&&Bo.cancel(),!e||!t)return o(void 0);((e,t)=>new Promise((o,n)=>{let r,a=!1;t.cancel=(()=>a=!0);const i=Date.now();Pt(e).then(e=>{const t=Date.now()-i;clearTimeout(r),r=setTimeout(()=>{a||o(e)},Math.max(0,1e3-t))}).catch(n)}))(t,Bo={cancel:noop$1}).then(o).catch(e=>set_store_value(zt,le.error=e,le))});component_subscribe(e,Oo,e=>o(25,Oe=e));const Uo=writable({});component_subscribe(e,Uo,e=>o(176,De=e));const No=writable([]);component_subscribe(e,No,e=>o(57,Ye=e));const Vo=derived([_o,ho,Lt,wo,Ro,Po,qt,Kt,Zt,Yt],([e,t,o,n,r,a,i,s,l,c],p)=>{if(e&&"resize"===m){const e=c||n;a=e.width/n.width||e.height/n.height}p(calculateImageTransforms(e,t,o,n,r,a,0,0,i,s,l))});component_subscribe(e,Vo,e=>o(175,Pe=e));const Ho=derived([Qt,eo,to,oo,no],([e,t,o,n,r],a)=>{const i=e&&Object.keys(e).map(t=>e[t]).filter(Boolean);a({gamma:o||void 0,vignette:n||void 0,noise:r||void 0,convolutionMatrix:t||void 0,colorMatrix:i&&i.length&&getColorMatrixFromColorMatrices(i)})});let Wo,Go;component_subscribe(e,Ho,e=>o(177,Fe=e));const jo=canPreventNavSwipe(),qo=writable({});component_subscribe(e,qo,e=>o(172,Ie=e));const Xo=getDevicePixelRatio(),Yo=readable(Xo,e=>{const t=()=>e(getDevicePixelRatio()),o=matchMedia(`(resolution: ${Xo}dppx)`);return o.addListener(t),()=>o.removeListener(t)});component_subscribe(e,Yo,e=>o(56,Xe=e));const Ko=writable();component_subscribe(e,Ko,e=>o(15,ge=e));const Zo=historyCreate(()=>se,e=>{set_store_value(io,se=e,se),mo.set(ke)});(()=>(Qe(),Qe=subscribe(Zo,e=>o(153,we=e)),Zo))(),zt.subscribe(({complete:e}={})=>{e&&Zo.set(se)});const Jo=()=>dt().then(e=>e&&Zo.revert()),Qo=writable(!1);component_subscribe(e,Qo,e=>o(155,Re=e));const en=()=>{set_store_value(Qo,Re=!0,Re);const e=pn.subscribe(t=>{1===t&&(e(),tt("processImage"))})};Bt.subscribe(e=>{if(!e)return;set_store_value(Qo,Re=!0,Re);const{complete:t}=e;t&&set_store_value(Qo,Re=!1,Re)});const tn={...rt,imageFile:Ft,imageSize:Lt,imageCropAspectRatio:Ot,imageCropMinSize:Vt,imageCropMaxSize:Ht,imageCropLimitToImage:Ut,imageCropRect:Nt,imageCropRectOrigin:Gt,imageCropRectSnapshot:So,imageCropRectAspectRatio:jt,imageCropRange:Wt,imageRotation:qt,imageRotationRange:Xt,imageFlipX:Kt,imageFlipY:Zt,imageOutputSize:Yt,imageColorMatrix:Qt,imageConvolutionMatrix:eo,imageGamma:to,imageVignette:oo,imageNoise:no,imageDecoration:ro,imageAnnotation:ao,imagePreview:Oo,imageTransforms:Vo,imagePreviewModifiers:Uo,history:Zo,animation:Ko,pixelRatio:Yo,elasticityMultiplier:ut,scrollElasticity:scrollElasticity,rangeInputElasticity:rangeInputElasticity,pointerAccuracy:$o,pointerHoverable:bo,env:qo,rootRect:ho,stageRect:_o,stageScalar:Co,utilRect:fo,presentationScalar:Po,rootBackgroundColor:co,rootLineColor:po,imageOverlayMarkup:Fo,imagePreviews:No,isInteracting:yo,isInteractingFraction:xo,imageCropRectIntent:ko,imageCropRectPresentation:wo,imageSelectionRect:Ro,imageSelectionRectIntent:Eo,imageSelectionRectPresentation:Io,imageSelectionRectSnapshot:To,imageScalar:Mo};delete tn.image;const on=`util-${getUniqueId()}`;let nn=[],rn=isIOS();const an=e=>{const t=F.getPropertyValue(e);return colorStringToColorArray(t)},sn=()=>{(()=>{const e=an("background-color");0!==e[3]&&(e.length=3,set_store_value(co,Ee=e,Ee))})(),(()=>{const e=an("--preview-border-color");set_store_value(po,Te=e||(isDarkColor(Ee)?[1,1,1]:[0,0,0]),Te)})()},ln=e=>{const t=[];return e.forEach(e=>t.push(...cn(e))),t.filter(Boolean)},cn=e=>{const t=[e];if(shapeIsLine(e)){let o=vectorCreate(e.x1,e.y1),n=vectorCreate(e.x2,e.y2);if(e.lineStart){const r=shapeComputeLineEnd(o,e.strokeWidth,e.strokeColor,e.lineStart,vectorCreate(n.x-o.x,n.y-o.y));o=r.position||o,t.push(r.shape)}if(e.lineEnd){const r=shapeComputeLineEnd(n,e.strokeWidth,e.strokeColor,e.lineEnd,vectorCreate(o.x-n.x,o.y-n.y));n=r.position||o,t.push(r.shape)}e.points=[o,n]}else shapeIsTriangle(e)?e.points=[vectorCreate(e.x1,e.y1),vectorCreate(e.x2,e.y2),vectorCreate(e.x3,e.y3)]:shapeIsTextEmpty(e)&&(shapeIsTextLine(e)&&(e.width=5,e.height=isFunction(e.lineHeight)?e.lineHeight(e.fontSize):e.lineHeight),e.strokeWidth=1,e.strokeColor=[1,1,1,.5],e.backgroundColor=[0,0,0,.1]);return t},pn=tweened(void 0,{duration:500});let un;component_subscribe(e,pn,e=>o(27,Ne=e));const dn=spring(void 0,{stiffness:.02,damping:.5,precision:.25});component_subscribe(e,dn,e=>o(48,Ve=e));const hn=spring(void 0,{stiffness:.03,damping:.4,precision:.25});component_subscribe(e,hn,e=>o(49,He=e));const mn=Button,gn=writable([]);component_subscribe(e,gn,e=>o(218,We=e)),setContext("keysPressed",gn);const fn=()=>({utilVisibility:{...f},isInteracting:he,isInteractingFraction:Ge,rootRect:rectClone(ie),stageRect:rectClone(_e),selectionRect:rectClone(ze)}),_n=(e,t,o,n)=>({annotationShapes:ln(t.filter(shapeIsVisible).map(shapeDeepCopy).map(e=>shapeComputeDisplay(e,ye))),decorationShapes:ln(o.filter(shapeIsVisible).map(shapeDeepCopy).map(t=>((e,t)=>shapeComputeDisplay(e,{x:ze.x/t.scale,y:ze.y/t.scale,width:ze.width/t.scale,height:ze.height/t.scale}))(t,e)).map(t=>((e,t)=>(shapeComputeTransform(e,ze,t.scale,t.size),e))(t,e))),interfaceShapes:ln(n.filter(shapeIsVisible))});let $n;const bn=writable();setContext("rootPortal",bn),setContext("rootRect",ho);return e.$$set=(e=>{"class"in e&&o(120,ot=e.class),"layout"in e&&o(121,nt=e.layout),"stores"in e&&o(122,rt=e.stores),"locale"in e&&o(2,at=e.locale),"id"in e&&o(3,it=e.id),"util"in e&&o(123,st=e.util),"utils"in e&&o(124,lt=e.utils),"animations"in e&&o(125,ct=e.animations),"previewUpscale"in e&&o(126,pt=e.previewUpscale),"elasticityMultiplier"in e&&o(4,ut=e.elasticityMultiplier),"willRevert"in e&&o(127,dt=e.willRevert),"willRenderCanvas"in e&&o(5,ht=e.willRenderCanvas),"willRenderToolbar"in e&&o(128,mt=e.willRenderToolbar),"enableButtonExport"in e&&o(129,gt=e.enableButtonExport),"enableButtonRevert"in e&&o(130,ft=e.enableButtonRevert),"enableNavigateHistory"in e&&o(131,_t=e.enableNavigateHistory),"enableToolbar"in e&&o(6,$t=e.enableToolbar),"enableUtils"in e&&o(132,bt=e.enableUtils),"enableButtonClose"in e&&o(133,yt=e.enableButtonClose),"previewImageDataMaxSize"in e&&o(134,xt=e.previewImageDataMaxSize),"enableDropImage"in e&&o(135,vt=e.enableDropImage),"imageOrienter"in e&&o(136,Ct=e.imageOrienter),"pluginComponents"in e&&o(137,St=e.pluginComponents),"pluginOptions"in e&&o(7,kt=e.pluginOptions),"root"in e&&o(1,Tt=e.root),"imageSourceToImageData"in e&&o(8,Pt=e.imageSourceToImageData)}),e.$$.update=(()=>{if(268435456&e.$$.dirty[3]&&o(141,n="overlay"===nt),131328&e.$$.dirty[4]&&o(13,r=bt&&!n),129&e.$$.dirty[0]&&kt&&Object.keys(kt).forEach(e=>{Object.keys(kt[e]).forEach(t=>{Rt[e]&&o(0,Rt[e][t]=kt[e][t],Rt)})}),1&e.$$.dirty[0]|8192&e.$$.dirty[4]){let e=!1;St.forEach(([t])=>{Rt[t]||(o(0,Rt[t]={},Rt),e=!0)}),e&&o(139,Et=[...St])}1024&e.$$.dirty[4]&&(a=xt?sizeMin(xt,At):At),262144&e.$$.dirty[4]&&Dt.update(re[0]),16384&e.$$.dirty[0]&&ae&&ho.set(rectCreate(ae.x,ae.y,ae.width,ae.height)),1703936&e.$$.dirty[4]&&ie&&n&&le&&le.complete&&(Ot.set(rectAspectRatio(ie)),Zo.set(se)),131076&e.$$.dirty[4]&&vo.set(pt||n),16777216&e.$$.dirty[4]&&Ce&&(()=>No.set([]))(),8388608&e.$$.dirty[4]&&o(149,i=!he),134217728&e.$$.dirty[4]&&o(150,s=!Se),100663298&e.$$.dirty[4]&&set_store_value(Ko,ge="always"===ct?i:"never"!==ct&&(i&&s),ge),536870912&e.$$.dirty[4]&&o(152,l=we.index>-1),536870912&e.$$.dirty[4]&&o(154,c=we.index<we.length-1),4&e.$$.dirty[0]|32769&e.$$.dirty[4]&&o(145,p=at&&Et.length?lt||Et.map(([e])=>e):[]),2129920&e.$$.dirty[4]&&o(156,u=Et.filter(([e])=>p.includes(e))),2&e.$$.dirty[5]&&o(157,d=u.length),4&e.$$.dirty[0]|2097152&e.$$.dirty[4]|2&e.$$.dirty[5]&&o(17,h=p.map(e=>{const t=u.find(([t])=>e===t);if(t)return{id:e,view:t[1],tabIcon:at[`${e}Icon`],tabLabel:at[`${e}Label`]}}).filter(Boolean)||[]),1073741824&e.$$.dirty[3]|2097152&e.$$.dirty[4]|4&e.$$.dirty[5]&&o(16,m=st&&"string"==typeof st&&p.includes(st)?st:d>0?p[0]:void 0),65537&e.$$.dirty[0]&&o(158,g=m&&Rt[m].tools||[]),393216&e.$$.dirty[0]&&o(18,f=h.reduce((e,t)=>(e[t.id]=f&&f[t.id]||0,e),{})),65536&e.$$.dirty[0]&&o(31,_={name:on,selected:m}),131072&e.$$.dirty[0]&&o(32,$=h.map(e=>({id:e.id,icon:e.tabIcon,label:e.tabLabel}))),131072&e.$$.dirty[0]&&o(33,b=h.map(e=>e.id)),2097152&e.$$.dirty[4]&&o(19,y=p.length>1),134217728&e.$$.dirty[3]&&o(34,x=arrayJoin(["DokaRoot","DokaRootComponent",ot])),524288&e.$$.dirty[4]&&o(159,v=ie&&(ie.width>ie.height?"landscape":"portrait")),16&e.$$.dirty[5]&&o(35,C="landscape"===v),524288&e.$$.dirty[4]&&o(160,S=ie&&(ie.width>1e3?"wide":ie.width<600?"narrow":void 0)),524288&e.$$.dirty[4]&&o(161,k=ie&&(ie.width<=320||ie.height<=460)),524288&e.$$.dirty[4]&&o(162,w=ie&&(ie.height>1e3?"tall":ie.height<600?"short":void 0)),2&e.$$.dirty[0]&&o(163,R=Tt&&Tt.parentNode&&Tt.parentNode.classList.contains("DokaModal")),1024&e.$$.dirty[0]|524288&e.$$.dirty[4]|256&e.$$.dirty[5]&&o(164,T=R&&ie&&Wo>ie.width),2048&e.$$.dirty[0]|524288&e.$$.dirty[4]|256&e.$$.dirty[5]&&o(165,E=R&&ie&&Go>ie.height),1536&e.$$.dirty[5]&&o(166,I=T&&E),32&e.$$.dirty[5]&&o(167,A="narrow"===S),4224&e.$$.dirty[5]&&o(168,M=A||"short"===w),1024&e.$$.dirty[0]|524288&e.$$.dirty[4]&&o(169,P=rn&&ie&&Wo===ie.width&&!jo),136&e.$$.dirty[5]&&o(170,D=g.length&&"short"===w),2&e.$$.dirty[0]&&o(171,F=Tt&&getComputedStyle(Tt)),65536&e.$$.dirty[5]&&F&&sn(),565312&e.$$.dirty[0]|268435456&e.$$.dirty[3]|946160&e.$$.dirty[5]&&qo.set({...Ie,layoutMode:nt,orientation:v,horizontalSpace:S,verticalSpace:w,isModal:R,isCentered:I,isCenteredHorizontally:T,isCenteredVertically:E,isAnimated:ge,pointerAccuracy:Ae,pointerHoverable:Me,isCompact:M,hasSwipeNavigation:P,hasLimitedSpace:k,hasToolbar:$t,hasNavigation:y&&r,isIOS:rn}),131072&e.$$.dirty[5]&&o(37,L=Object.keys(Ie).map(e=>/^is|has/.test(e)?Ie[e]?toKebabCase(e):void 0:Ie[e]).filter(Boolean).join(" ")),4194304&e.$$.dirty[4]|15728640&e.$$.dirty[5]&&o(38,z=Pe?{...Object.keys(De).filter(e=>null!=De[e]).reduce((e,t)=>e={...e,...De[t]},{}),...Pe,...Fe,backgroundColor:Le,size:sizeCreateFromRect(de)}:void 0),4&e.$$.dirty[0]|16777216&e.$$.dirty[5]&&o(20,O=at&&B.length&&at.labelSupportError(B)),1048576&e.$$.dirty[4]&&o(21,U=le&&!!le.error),1048576&e.$$.dirty[4]&&o(22,N=!le||!le.complete&&void 0===le.task),1048576&e.$$.dirty[4]&&o(40,V=le&&(le.taskLengthComputable?le.taskProgress:1/0)),1114112&e.$$.dirty[4]&&(le&&le.complete?(clearTimeout(un),o(140,un=setTimeout(()=>{set_store_value(zo,Be=!0,Be)},500))):le||set_store_value(zo,Be=!1,Be)),6291456&e.$$.dirty[0]|1048576&e.$$.dirty[4]|33554432&e.$$.dirty[5]&&o(23,H=le&&!U&&!N&&!Be),33554432&e.$$.dirty[0]|16777216&e.$$.dirty[4]&&o(24,W=!(!Ce||Oe)),67108865&e.$$.dirty[5]&&o(26,G=Re||Ue&&void 0!==Ue.progress&&!Ue.complete),4194304&e.$$.dirty[0]|1048576&e.$$.dirty[4]&&o(41,j=le&&!(le.error||N)),4&e.$$.dirty[0]|1048576&e.$$.dirty[4]&&o(42,q=at&&(le?le.complete?at.statusLabelLoadImage({progress:1/0,task:"blob-to-bitmap"}):stringReplace(at.statusLabelLoadImage(le),le.error&&le.error.metadata,"{","}"):at.statusLabelLoadImage(le))),4&e.$$.dirty[0]|67108864&e.$$.dirty[5]&&o(43,X=Ue&&at&&at.statusLabelProcessImage(Ue)),67108864&e.$$.dirty[5]&&o(44,Y=Ue&&(Ue.taskLengthComputable?Ue.taskProgress:1/0)),67108864&e.$$.dirty[5]&&o(45,K=Ue&&!Ue.error),67108864&e.$$.dirty[5]&&o(46,Z=Ue&&Ue.error),99614720&e.$$.dirty[0]&&set_store_value(pn,Ne=O||N||U||H||W||G?1:0,Ne),134217728&e.$$.dirty[0]&&o(47,J=Ne>0),134217728&e.$$.dirty[0]&&Ne<=0&&(dn.set(void 0,{hard:!0}),hn.set(void 0,{hard:!0})),1024&e.$$.dirty[0]&&o(50,Q=jo&&(e=>{const t=e.touches?e.touches[0]:e;t.pageX>10&&t.pageX<Wo-10||e.preventDefault()})),4&e.$$.dirty[0]|1342178032&e.$$.dirty[4]|167944&e.$$.dirty[5]&&o(51,ee=at&&mt([["div","alpha",{class:"DokaNavGroup"},[["div","alpha-set",{class:"DokaNavSet"},[yt&&[mn,"close",{label:at.labelClose,icon:at.iconButtonClose,onclick:()=>tt("close"),hideLabel:!0}],ft&&[mn,"revert",{label:at.labelButtonRevert,icon:at.iconButtonRevert,disabled:!l,onclick:Jo,hideLabel:!0}]]]]],["div","beta",{class:"DokaNavGroup DokaNavGroupFloat"},[_t&&["div","history",{class:"DokaNavSet"},[[mn,"undo",{label:at.labelButtonUndo,icon:at.iconButtonUndo,disabled:!l,onclick:Zo.undo,hideLabel:!0}],[mn,"redo",{label:at.labelButtonRedo,icon:at.iconButtonRedo,disabled:!c,onclick:Zo.redo,hideLabel:!0}]]],D&&["div","plugin-tools",{class:"DokaNavSet"},g.filter(Boolean).map(([e,t,o])=>[e,t,{...o,hideLabel:!0}])]]],["div","gamma",{class:"DokaNavGroup"},[gt&&[mn,"export",{label:at.labelButtonExport,icon:A&&at.iconButtonExport,class:"DokaButtonExport",onclick:en,hideLabel:A}]]]],{...Ie})),16384&e.$$.dirty[0]&&o(182,te=ae&&ae.width>0&&ae.height>0),4&e.$$.dirty[0]|134217732&e.$$.dirty[5]&&o(52,oe=te&&at&&d),4096&e.$$.dirty[0]&&$n&&bn.set($n)}),o(179,B=[!supportsWebGL()&&"WebGL"].filter(Boolean)),o(53,ne=createPingRouter(et.pub)),[Rt,Tt,at,it,ut,ht,$t,kt,Pt,Zo,Wo,Go,$n,r,ae,ge,m,h,f,y,O,U,N,H,W,Oe,G,Ne,nn,ye,ke,_,$,b,x,C,Ee,L,z,ze,V,j,q,X,Y,K,Z,J,Ve,He,Q,ee,oe,ne,je,qe,Xe,Ye,Ke,Ze,Je,Ft,Lt,zt,Bt,Nt,Yt,Jt,ro,ao,io,so,co,po,uo,ho,mo,go,fo,_o,$o,bo,yo,xo,vo,Co,So,ko,Ro,To,Eo,Io,Po,Lo,zo,Oo,Uo,No,Vo,Ho,qo,Yo,Ko,Qo,tn,({target:e,propertyName:t})=>{e===Tt&&"background-color"===t&&sn()},pn,dn,hn,e=>{set_store_value(dn,Ve=Math.round(.5*-e.detail.width)-16,Ve),set_store_value(hn,He=e.detail.width,He)},()=>{tt("abortLoadImage")},()=>{tt("abortProcessImage"),set_store_value(Qo,Re=!1,Re)},gn,e=>{const{keyCode:t}=e;if(229===t)return;const o=new Set([...We,t]);gn.set(Array.from(o))},({keyCode:e})=>{gn.set(We.filter(t=>t!==e))},()=>{gn.set([])},e=>{isTextField(e.target)||e.preventDefault()},e=>{vt&&e.detail.files.length&&tt("loadImage",e.detail.files[0])},fn,_n,ot,nt,rt,st,lt,ct,pt,dt,mt,gt,ft,_t,bt,yt,xt,vt,Ct,St,wt,Et,un,n,re,ie,le,p,de,he,Ce,i,s,Se,l,we,c,Re,u,d,g,v,S,k,w,R,T,E,I,A,M,P,D,F,Ie,Ae,Me,Pe,De,Fe,Le,B,Be,Ue,te,function(){o(10,Wo=window.innerWidth),o(11,Go=window.innerHeight)},e=>set_store_value(go,je=e.detail,je),({detail:e})=>o(16,m=e),(e,t)=>t.id===e,function(t,n){e.$$.not_equal(Rt[n],t)&&(Rt[n]=t,o(0,Rt),o(7,kt),o(137,St))},e=>set_store_value(fo,qe=e.detail,qe),e=>o(28,nn=nn.concat(e)),e=>o(28,nn=nn.filter(t=>t!==e)),(e,{detail:t})=>o(18,f[e]=t,f),e=>set_store_value(mo,ke=e.detail,ke),e=>e.id===m,function(t){e.$$.not_equal(Rt[m],t)&&(Rt[m]=t,o(0,Rt),o(7,kt),o(137,St))},e=>set_store_value(fo,qe=e.detail,qe),()=>o(28,nn=nn.concat(m)),()=>o(28,nn=nn.filter(e=>e!==m)),({detail:e})=>o(18,f[m]=e,f),e=>{const t={...e,...fn()},{annotationShapes:o,decorationShapes:n,interfaceShapes:r}=ht({decorationShapes:Ke,annotationShapes:Ze,interfaceShapes:Je},t);return _n(t,o,n,r)},function(e){binding_callbacks[e?"unshift":"push"](()=>{o(12,$n=e)})},function(e){binding_callbacks[e?"unshift":"push"](()=>{o(1,Tt=e)})},e=>set_store_value(uo,ae=e.detail,ae)]}class Ui extends SvelteComponent{constructor(e){super(),init(this,e,instance$w,create_fragment$w,safe_not_equal,{class:120,layout:121,stores:122,locale:2,id:3,util:123,utils:124,animations:125,previewUpscale:126,elasticityMultiplier:4,willRevert:127,willRenderCanvas:5,willRenderToolbar:128,enableButtonExport:129,enableButtonRevert:130,enableNavigateHistory:131,enableToolbar:6,enableUtils:132,enableButtonClose:133,previewImageDataMaxSize:134,enableDropImage:135,imageOrienter:136,pluginComponents:137,pluginOptions:7,sub:138,pluginInterface:0,root:1,imageSourceToImageData:8,history:9},[-1,-1,-1,-1,-1,-1,-1,-1,-1])}get class(){return this.$$.ctx[120]}set class(e){this.$set({class:e}),flush()}get layout(){return this.$$.ctx[121]}set layout(e){this.$set({layout:e}),flush()}get stores(){return this.$$.ctx[122]}set stores(e){this.$set({stores:e}),flush()}get locale(){return this.$$.ctx[2]}set locale(e){this.$set({locale:e}),flush()}get id(){return this.$$.ctx[3]}set id(e){this.$set({id:e}),flush()}get util(){return this.$$.ctx[123]}set util(e){this.$set({util:e}),flush()}get utils(){return this.$$.ctx[124]}set utils(e){this.$set({utils:e}),flush()}get animations(){return this.$$.ctx[125]}set animations(e){this.$set({animations:e}),flush()}get previewUpscale(){return this.$$.ctx[126]}set previewUpscale(e){this.$set({previewUpscale:e}),flush()}get elasticityMultiplier(){return this.$$.ctx[4]}set elasticityMultiplier(e){this.$set({elasticityMultiplier:e}),flush()}get willRevert(){return this.$$.ctx[127]}set willRevert(e){this.$set({willRevert:e}),flush()}get willRenderCanvas(){return this.$$.ctx[5]}set willRenderCanvas(e){this.$set({willRenderCanvas:e}),flush()}get willRenderToolbar(){return this.$$.ctx[128]}set willRenderToolbar(e){this.$set({willRenderToolbar:e}),flush()}get enableButtonExport(){return this.$$.ctx[129]}set enableButtonExport(e){this.$set({enableButtonExport:e}),flush()}get enableButtonRevert(){return this.$$.ctx[130]}set enableButtonRevert(e){this.$set({enableButtonRevert:e}),flush()}get enableNavigateHistory(){return this.$$.ctx[131]}set enableNavigateHistory(e){this.$set({enableNavigateHistory:e}),flush()}get enableToolbar(){return this.$$.ctx[6]}set enableToolbar(e){this.$set({enableToolbar:e}),flush()}get enableUtils(){return this.$$.ctx[132]}set enableUtils(e){this.$set({enableUtils:e}),flush()}get enableButtonClose(){return this.$$.ctx[133]}set enableButtonClose(e){this.$set({enableButtonClose:e}),flush()}get previewImageDataMaxSize(){return this.$$.ctx[134]}set previewImageDataMaxSize(e){this.$set({previewImageDataMaxSize:e}),flush()}get enableDropImage(){return this.$$.ctx[135]}set enableDropImage(e){this.$set({enableDropImage:e}),flush()}get imageOrienter(){return this.$$.ctx[136]}set imageOrienter(e){this.$set({imageOrienter:e}),flush()}get pluginComponents(){return this.$$.ctx[137]}set pluginComponents(e){this.$set({pluginComponents:e}),flush()}get pluginOptions(){return this.$$.ctx[7]}set pluginOptions(e){this.$set({pluginOptions:e}),flush()}get sub(){return this.$$.ctx[138]}get pluginInterface(){return this.$$.ctx[0]}get root(){return this.$$.ctx[1]}set root(e){this.$set({root:e}),flush()}get imageSourceToImageData(){return this.$$.ctx[8]}set imageSourceToImageData(e){this.$set({imageSourceToImageData:e}),flush()}get history(){return this.$$.ctx[9]}}const utilPrivateProps=["klass","stores","isVisible","isActive","isActiveFraction","locale"],viewPrivateProps=["history","klass","stores","navButtons","pluginComponents","pluginInterface","pluginOptions","sub"];let editorProps;const pluginProps=new Set([]),propPluginRef={},pluginComponents=new Map,setEditorViewPlugins=(...e)=>{e.forEach(e=>{const[t,o]=e.util;pluginComponents.set(t,o),getComponentExportedProps(o).filter(e=>!utilPrivateProps.includes(e)).forEach(e=>{pluginProps.add(e),propPluginRef[e]?propPluginRef[e].push(t):propPluginRef[e]=[t]})})},getEditorViewProps=()=>[...editorProps=new Set(getComponentExportedProps(Ui).filter(e=>!viewPrivateProps.includes(e))),...pluginProps],attachEditorView=(e,t)=>{const o={},n=new Ui({target:e,props:{stores:t,pluginComponents:Array.from(pluginComponents)}});editorProps||(editorProps=new Set(getComponentExportedProps(Ui).filter(e=>!viewPrivateProps.includes(e)))),editorProps.forEach(e=>{Object.defineProperty(o,e,{get:()=>n.prop,set:t=>n[e]=t})}),pluginProps.forEach(e=>{const t=propPluginRef[e],r=t[0];Object.defineProperty(o,e,{get:()=>n.pluginInterface[r][e],set:o=>{const r=t.reduce((t,r)=>(t[r]={...n.pluginOptions[r],[e]:o},t),{});n.pluginOptions={...n.pluginOptions,...r}}})}),Object.defineProperty(o,"element",{get:()=>n.root,set:()=>void 0});const r=n.history;return defineMethods(o,{on:(e,t)=>{if(/undo|redo|revert/.test(e))return r.on(e,t);const o=[n.sub(e,t),n.$on(e,e=>t(e instanceof CustomEvent&&!e.detail?void 0:e))].filter(Boolean);return()=>o.forEach(e=>e())},close:()=>n.pub("close"),destroy:()=>n.$destroy(),undo:()=>r.undo(),redo:()=>r.redo(),revert:()=>r.revert()}),Object.defineProperty(o,"history",{get:()=>({undo:()=>r.undo(),redo:()=>r.redo(),revert:()=>r.revert(),get length(){return r.length()}})}),isBrowser()&&window.addEventListener("pagehide",()=>n&&n.$destroy()),o};var linkAccessors=(e,t)=>{const o=Object.getOwnPropertyDescriptors(e);Object.keys(o).forEach(n=>{o[n].get?Object.defineProperty(t,n,{get:()=>e[n],set:t=>e[n]=t}):t[n]=e[n]})},editorEvents=[...editorEventsToBubble,"undo","redo","revert","destroy","show","hide","close","selectshape","updateshape","addshape","removeshape"],hasDoctype=()=>isBrowser()&&null!==document.doctype,initEditorView=e=>{const t={},{sub:o,pub:n}=pubsub();hasDoctype()||console.warn("Missing Document Type Declaration");const r=createImageEditor();linkAccessors(r,t);const a=attachEditorView(e,r.stores);linkAccessors(a,t);const i=["loadImage","processImage","abortProcessImage","abortLoadImage"].map(e=>a.on(e,t=>r[e](t&&t.detail))),s=(e,t)=>{const n=o(e,t),i=r.on(e,t),s=a.on(e,t);return()=>{n(),i(),s()}};t.handleEvent=noop$1;const l=editorEvents.map(e=>s(e,o=>t.handleEvent(e,o)));return defineMethods(t,{on:s,close:()=>{n("close")},destroy:()=>{[...i,...l].forEach(e=>e()),a.destroy(),r.destroy(),n("destroy")}}),t},appendEditor=(e,t={})=>{const o=isString(e)?document.querySelector(e):e;if(!o)return;t.class=t.class?`doka-image-editor ${t.class}`:"doka-image-editor";const n=initEditorView(o);return Object.assign(n,t)},appendEditors=(e,t={})=>{return(isString(e)?Array.from(document.querySelectorAll(e)):e).filter(Boolean).map(e=>appendEditor(e,deepCopy(t)))};const{document:document_1}=globals;function create_fragment$v(e){let t,o,n,r;return add_render_callback(e[18]),{c(){t=space(),attr(o=element("div"),"class","doka-image-editor DokaModal"),attr(o,"style",e[4])},m(a,i){insert(a,t,i),insert(a,o,i),e[19](o),n||(r=[listen(window,"keydown",e[9]),listen(window,"orientationchange",e[10]),listen(window,"resize",e[18]),listen(document_1.body,"focusin",function(){is_function(!e[3]&&e[6])&&(!e[3]&&e[6]).apply(this,arguments)}),listen(document_1.body,"focusout",function(){is_function(e[1]&&e[7])&&(e[1]&&e[7]).apply(this,arguments)}),listen(o,"wheel",e[8],{passive:!1})],n=!0)},p(t,n){e=t,16&n[0]&&attr(o,"style",e[4])},i:noop,o:noop,d(a){a&&detach(t),a&&detach(o),e[19](null),n=!1,run_all(r)}}}function instance$v(e,t,o){let n,r,a,i;const s=createEventDispatcher();let{root:l}=t,{preventZoomViewport:c=!0}=t,p=!0,u=!1,d=!1;const m=spring(0,{precision:.001,damping:.5});component_subscribe(e,m,e=>o(16,i=e));const g=m.subscribe(e=>{d&&e>=1?(d=!1,o(3,p=!1),s("show")):u&&e<=0&&(u=!1,o(3,p=!0),s("hide"))});onDestroy(()=>g());let f=!1,_=void 0,$=void 0;const b=()=>document.querySelector("meta[name=viewport]"),y=()=>{if(u||p)return;clearTimeout($),u=!0;const e=b();_?e.setAttribute("content",_):document.head.removeChild(e),set_store_value(m,i=0,i)};let x;const v=(e,t)=>{const o=()=>{e()?t():requestAnimationFrame(o)};requestAnimationFrame(o)};let C,S,k=0,w=void 0;const R=()=>{S||(S=h("div",{style:"position:fixed;height:100vh;top:0"}),document.body.appendChild(S))};return onMount(()=>{isIOS()&&R()}),afterUpdate(()=>{S&&(o(15,w=S.offsetHeight),S.parentNode.removeChild(S),S=void 0)}),e.$$set=(e=>{"root"in e&&o(0,l=e.root),"preventZoomViewport"in e&&o(11,c=e.preventZoomViewport)}),e.$$.update=(()=>{2048&e.$$.dirty[0]&&(n="width=device-width,height=device-height,initial-scale=1"+(c?",maximum-scale=1,user-scalable=0":"")),6&e.$$.dirty[0]&&(f||o(14,C=k)),32772&e.$$.dirty[0]&&o(17,r=isIOS()?`--viewport-pad-footer:${w>k?0:1}`:""),212992&e.$$.dirty[0]&&o(4,a=`height:${C}px;opacity:${i};--editor-modal:1;${r}`)}),[l,f,k,p,a,m,e=>{/textarea/i.test(e.target)&&(o(1,f=!0),x=k)},e=>{if(/textarea/i.test(e.target))if(clearTimeout(void 0),x===k)o(1,f=!1);else{const e=k;v(()=>k!==e,()=>o(1,f=!1))}},e=>e.preventDefault(),e=>{const{key:t}=e;if(!/escape/i.test(t))return;const o=e.target;o&&/input|textarea/i.test(o.nodeName)||y()},R,c,()=>{if(d||!p)return;d=!0;const e=b()||h("meta",{name:"viewport"});_=!_&&e.getAttribute("content"),e.setAttribute("content",n+(/cover/.test(_)?",viewport-fit=cover":"")),e.parentNode||document.head.appendChild(e),clearTimeout($),$=setTimeout(()=>set_store_value(m,i=1,i),250)},y,C,w,i,r,function(){o(2,k=window.innerHeight)},function(e){binding_callbacks[e?"unshift":"push"](()=>{o(0,l=e)})}]}class Modal extends SvelteComponent{constructor(e){super(),init(this,e,instance$v,create_fragment$v,safe_not_equal,{root:0,preventZoomViewport:11,show:12,hide:13},[-1,-1])}get root(){return this.$$.ctx[0]}set root(e){this.$set({root:e}),flush()}get preventZoomViewport(){return this.$$.ctx[11]}set preventZoomViewport(e){this.$set({preventZoomViewport:e}),flush()}get show(){return this.$$.ctx[12]}get hide(){return this.$$.ctx[13]}}var createModal=(e={},t)=>new Modal({target:t||document.body,props:{preventZoomViewport:e.preventZoomViewport}}),openEditor=(e={},t)=>{const{sub:o,pub:n}=pubsub(),r={},a=createModal(e,t),i=()=>{a.hide()},s=()=>{a.show()},l=initEditorView(a.root);linkAccessors(l,r),r.handleEvent=noop$1,l.handleEvent=((e,t)=>r.handleEvent(e,t)),l.on("close",i);const c=(e,t)=>/show|hide/.test(e)?o(e,t):l.on(e,t),p=["show","hide"].map(e=>c(e,t=>r.handleEvent(e,t))),u=()=>{p.forEach(e=>e()),i(),a.$destroy(),l.destroy()};return defineMethods(r,{on:c,destroy:u,hide:i,show:s}),Object.defineProperty(r,"modal",{get:()=>a.root,set:()=>void 0}),a.$on("show",()=>n("show")),a.$on("hide",()=>{n("hide"),u()}),l.on("process",i),l.on("loadstart",s),!1!==e.enableButtonClose&&(e.enableButtonClose=!0),Object.assign(r,e),r},overlayEditor=(e,t)=>{return appendEditor(e,{...t,layout:"overlay"})};const dispatchElementEvent=(e,t,o)=>e.dispatchEvent(new CustomEvent(t,{detail:o,bubbles:!0,cancelable:!0}));var dispatchEditorEvents=(e,t,o={})=>{const{prefix:n="doka:"}=o;return editorEvents.map(o=>e.on(o,e=>isElement(t)?dispatchElementEvent(t,`${n}${o}`,e):t(o,e)))};const TAG="doka-image-editor";var customElement=()=>new Promise(e=>{if(!DokaImageEditorElement)return e([]);customElements.define(TAG,DokaImageEditorElement),customElements.whenDefined(TAG).then(()=>e(document.querySelectorAll(TAG)))});const DokaImageEditorElement=isBrowser()&&class extends HTMLElement{constructor(){super(),this._editor=void 0,this._unsubs=void 0}static get observedAttributes(){return["src"]}attributeChangedCallback(e,t,o){this[e]=o}connectedCallback(){this._editor=initEditorView(this),linkAccessors(this._editor,this),this._editor.src=this.getAttribute("src"),this._unsubs=dispatchEditorEvents(this._editor,this)}disconnectedCallback(){this._editor.destroy(),this._unsubs.forEach(e=>e())}};var arrayInsert=(e,t,o)=>(e.splice(t,0,o),e);const isNode=e=>isString(e[0]),isNodeList=e=>!isNode(e),getNodeId=e=>e[1],getNodeChildren=e=>e[3]||[],createNode=(e,t,o={},n=[])=>[e,t,o,n],insertNode=(e,t,o,n=(e=>e))=>{const r=findNodeList(t,o),a=r.findIndex(e=>getNodeId(e)===t);arrayInsert(r,n(a),e)},insertNodeBefore=(e,t,o)=>insertNode(e,t,o),insertNodeAfter=(e,t,o)=>insertNode(e,t,o,e=>e+1),appendNode=(e,t,o)=>{const n=findNode(t,o);return getNodeChildren(n).push(e),n},removeNode=(e,t)=>{const o=findNodeList(e,t);return arrayRemove(o,t=>getNodeId(t)===e),o},findNode=(e,t)=>isNode(t)?getNodeId(t)===e?t:findNode(e,getNodeChildren(t)):t.find(t=>findNode(e,t)),findNodeList=(e,t)=>isNodeList(t)?t.find(t=>getNodeId(t)===e)?t:t.find(t=>findNodeList(e,getNodeChildren(t))):findNodeList(e,getNodeChildren(t)),propertyMap={borderColor:"strokeColor",borderWidth:"strokeWidth",lineWidth:"strokeWidth",fontColor:"color",lineColor:"strokeColor",src:"backgroundImage",fit:"backgroundSize"},convertValue=e=>0===e?0:"0%"===e?0:"0px"===e?0:/px$/.test(e)?parseInt(e,10):/\%$/.test(e)?e:e<=1?`${100*e}%`:void 0,addValues=(e,t)=>{let o,n;return/%$/.test(e)?`${(o=parseFloat(e))+(n=parseFloat(t))}%`:/px$/.test(e)?`${(o=parseInt(e,10))+(n=parseInt(t,10))}px`:void 0},shapeFromLegacyMarkup=(e,t,o)=>{const n=Object.keys(o).reduce((e,t)=>{let n=o[t];return t=propertyMap[t]||t,/px$/.test(n)?n=convertValue(n):/^(?:x|y|left|right|top|bottom|width|height|fontSize|strokeWidth)$/.test(t)&&"number"==typeof n&&(/strokeWidth/.test(t)&&(n*=2),n=convertValue(n)),/color/i.test(t)&&(n=colorStringToColorArray(n)),null===n&&(n=void 0),e[t]=n,e},{});if("line"===t&&(1===n.lineDecoration.length&&(n.lineEnd="arrow"),2===n.lineDecoration.length&&(n.lineStart="arrow"),n.x1=n.x,n.y1=n.y,n.x2=addValues(n.x,n.width),n.y2=addValues(n.y,n.height),delete n.x,delete n.y,delete n.width,delete n.height,delete n.lineDecoration,delete n.lineStyle),"text"===t&&(n.y=addValues(n.y,"-"+n.fontSize),delete n.width,delete n.height,delete n.borderStyle),"ellipse"===t){let t,o;if(/%$/.test(n.width)){t=parseFloat(n.width)/100,o=parseFloat(n.height)/100;const r=t*e.width,a=o*e.height;t=r/e.width*100,o=a/e.height*100}else t=n.width,o=n.height;n.rx=.5*t,n.ry=.5*o,/%$/.test(n.width)&&(n.rx+="%",n.ry+="%"),n.x=addValues(n.x,n.rx),n.y=addValues(n.y,n.ry),delete n.width,delete n.height,delete n.borderStyle}return"rect"===t&&delete n.borderStyle,"path"===t&&(n.points=n.points.map(e=>({x:convertValue(e.x),y:convertValue(e.y)}))),n},getOffsetPointOnEdge=(e,t)=>{const o=e,n=t,r=1.5707963267948966-t,a=Math.sin(1.5707963267948966),i=Math.sin(n),s=Math.sin(r),l=Math.cos(r),c=o/a;return vectorCreate(l*(c*i),l*(c*s))},getRotatedRectSize=(e,t)=>{const o=e.width,n=e.height,r=getOffsetPointOnEdge(o,t),a=getOffsetPointOnEdge(n,t),i=vectorCreate(e.x+Math.abs(r.x),e.y-Math.abs(r.y)),s=vectorCreate(e.x+e.width+Math.abs(a.y),e.y+Math.abs(a.x)),l=vectorCreate(e.x-Math.abs(a.y),e.y+e.height-Math.abs(a.x));return{width:vectorDistance(i,s),height:vectorDistance(i,l)}},getBoundsAroundCenter=(e,t)=>{const o=t.x>.5?1-t.x:t.x,n=t.y>.5?1-t.y:t.y;return sizeCreate(2*o*e.width,2*n*e.height)},getCanvasSize=(e,t,o=1)=>{const n=e.height/e.width;let r=t,a=1,i=n;i>r&&(a=(i=r)/n);const s=Math.max(1/a,r/i),l=e.width/(o*s*a);return{width:l,height:l*t}},getCenteredCropRect=(e,t)=>{let o=e.width,n=o*t;n>e.height&&(o=(n=e.height)/t);const r=.5*(e.width-o),a=.5*(e.height-n);return rectCreate(r,a,o,n)},getCorrectedLegacyAspectRatio=(e,t)=>null!=t?1/t:e.width/e.height,imagePropertiesFromLegacyCrop=(e,{flip:t,aspectRatio:o,rotation:n,center:r,zoom:a,scaleToFit:i})=>{const s={},l=!r||r&&.5===r.x&&.5===r.y;t&&t.horizontal&&(s.flipHorizontal=t.horizontal),t&&t.vertical&&(s.flipVertical=t.vertical);const c=getCorrectedLegacyAspectRatio(e,o),p=!(!1===i),u=getCanvasSize(e,o,a),d=l?e:getBoundsAroundCenter(e,p?r:{x:.5,y:.5}),h=getCenteredCropRect(e,o);if((o||!l||a)&&(s.crop=rectContainRect(rectCreateFromSize(d),c)),"number"==typeof n&&null!==n){null!=n&&(s.rotation=n);const t=getRotatedRectSize(h,n),o=Math.max(t.width/d.width,t.height/d.height),a=vectorCreate(r.x*e.width,r.y*e.height),i=getImageTransformedRect(e,n),l=sizeCenter(i),c=vectorCreate(.5*(i.width-e.width),.5*(i.height-e.height)),p=rectRotate({x:c.x+a.x-u.width/o*.5,y:c.y+a.y-u.height/o*.5,width:u.width/o,height:u.height/o},n),m=vectorsRotate(p.map(vectorClone),n,l.x,l.y),g=rectCenter(rectCreateFromPoints(m)),f=vectorsRotate(m.map(vectorClone),-2*n,g.x,g.y);s.crop=rectCreateFromPoints(f)}else null!=a&&rectScale(s.crop,1/a);return p||(s.cropLimitToImage=!1),s},isLegacyData=(e={})=>{if("markup"in e||"color"in e||"filter"in e)return!0;const{crop:t}=e;return!(!t||!("flip"in t||"center"in t||"aspectRatio"in t||"rotation"in t))};var legacyDataToImageState=(e,t,o={})=>{const n={};if(!isLegacyData(o))return o;if(o.crop&&Object.assign(n,imagePropertiesFromLegacyCrop(t,o.crop)),o.markup){let e=Array.isArray(o.markup)?o.markup:Object.values(o.markup);n.decoration=e.map(e=>shapeFromLegacyMarkup(n.crop||t,e[0],e[1])).sort((e,t)=>e.zIndex<t.zIndex?-1:e.zIndex>t.zIndex?1:0).map(e=>(delete e.zIndex,e))}return o.color&&Object.keys(o.color).filter(e=>o.color[e]).map(e=>[e,Array.isArray(o.color[e].matrix)?o.color[e].matrix:Object.values(o.color[e].matrix)]).forEach(([e,t])=>{n.colorMatrix||(n.colorMatrix={}),n.colorMatrix[e]=t}),o.filter&&(n.colorMatrix||(n.colorMatrix={}),n.colorMatrix.filter="string"==typeof o.filter&&e.filterFunctions[o.filter]?e.filterFunctions[o.filter]():o.filter.matrix),n};const isOperaMini=()=>"[object OperaMini]"===Object.prototype.toString.call(window.operamini),hasPromises=()=>"Promise"in window,hasCreateObjectURL=()=>"URL"in window&&"createObjectURL"in window.URL,hasVisibility=()=>"visibilityState"in document,hasTiming=()=>"performance"in window,hasFileConstructor=()=>"File"in window;let result$1=null;var isModernBrowser=()=>(null===result$1&&(result$1=isBrowser()&&!isOperaMini()&&hasVisibility()&&hasPromises()&&hasFileConstructor()&&hasCreateObjectURL()&&hasTiming()),result$1);const toPercentageNumber=e=>Math.round(100*e),brightness={base:0,min:-.25,max:.25,getLabel:e=>toPercentageNumber(e/.25),getStore:({imageColorMatrix:e})=>e,getValue:e=>{if(e.brightness)return e.brightness[4]},setValue:(e,t)=>e.update(e=>({...e,brightness:[1,0,0,0,t,0,1,0,0,t,0,0,1,0,t,0,0,0,1,0]}))},contrast={base:1,min:.5,max:1.5,getLabel:e=>toPercentageNumber(2*(e-.5)-1),getStore:({imageColorMatrix:e})=>e,getValue:e=>{if(e.contrast)return e.contrast[0]},setValue:(e,t)=>e.update(e=>({...e,contrast:[t,0,0,0,.5*(1-t),0,t,0,0,.5*(1-t),0,0,t,0,.5*(1-t),0,0,0,1,0]}))},saturation={base:1,min:0,max:2,getLabel:e=>toPercentageNumber(e-1),getStore:({imageColorMatrix:e})=>e,getValue:e=>{if(e.saturation)return(e.saturation[0]-.213)/.787},setValue:(e,t)=>e.update(e=>({...e,saturation:[.213+.787*t,.715-.715*t,.072-.072*t,0,0,.213-.213*t,.715+.285*t,.072-.072*t,0,0,.213-.213*t,.715-.715*t,.072+.928*t,0,0,0,0,0,1,0]}))},exposure={base:1,min:.5,max:1.5,getLabel:e=>toPercentageNumber(2*(e-.5)-1),getStore:({imageColorMatrix:e})=>e,getValue:e=>{if(e.exposure)return e.exposure[0]},setValue:(e,t)=>e.update(e=>({...e,exposure:[t,0,0,0,0,0,t,0,0,0,0,0,t,0,0,0,0,0,1,0]}))},gamma={base:1,min:.15,max:4,getLabel:e=>toPercentageNumber(e<1?(e-.15)/.85-1:(e-1)/3),getStore:({imageGamma:e})=>e},vignette={base:0,min:-1,max:1,getStore:({imageVignette:e})=>e},clarity={base:0,min:-1,max:1,getStore:({imageConvolutionMatrix:e})=>e,getValue:e=>{if(e.clarity)return 0===e.clarity[0]?e.clarity[1]/-1:e.clarity[1]/-2},setValue:(e,t)=>{e.update(e=>({...e,clarity:t>=0?[0,-1*t,0,-1*t,1+4*t,-1*t,0,-1*t,0]:[-1*t,-2*t,-1*t,-2*t,1+-3*t,-2*t,-1*t,-2*t,-1*t]}))}},temperature={base:0,min:-1,max:1,getStore:({imageColorMatrix:e})=>e,getValue:e=>{if(!e.temperature)return;const t=e.temperature[0];return t>=1?(t-1)/.1:(1-t)/-.15},setValue:(e,t)=>e.update(e=>({...e,temperature:t>0?[1+.1*t,0,0,0,0,0,1,0,0,0,0,0,1+.1*-t,0,0,0,0,0,1,0]:[1+.15*t,0,0,0,0,0,1+.05*t,0,0,0,0,0,1+.15*-t,0,0,0,0,0,1,0]}))},finetuneControlConfigurationDefault={gamma:gamma,brightness:brightness,contrast:contrast,saturation:saturation,exposure:exposure,temperature:temperature,clarity:clarity,vignette:vignette},finetuneOptionsDefault=[["brightness",e=>e.finetuneLabelBrightness],["contrast",e=>e.finetuneLabelContrast],["saturation",e=>e.finetuneLabelSaturation],["exposure",e=>e.finetuneLabelExposure],["temperature",e=>e.finetuneLabelTemperature],["gamma",e=>e.finetuneLabelGamma],["clarity",e=>e.finetuneLabelClarity],["vignette",e=>e.finetuneLabelVignette]];var defaults$2={finetuneControlConfiguration:finetuneControlConfigurationDefault,finetuneOptions:finetuneOptionsDefault};const pastel=()=>[.75,.25,.25,0,0,.25,.75,.25,0,0,.25,.25,.75,0,0,0,0,0,1,0],chrome=()=>[1.398,-.316,.065,-.273,.201,-.051,1.278,-.08,-.273,.201,-.051,.119,1.151,-.29,.215,0,0,0,1,0],fade=()=>[1.073,-.015,.092,-.115,-.017,.107,.859,.184,-.115,-.017,.015,.077,1.104,-.115,-.017,0,0,0,1,0],warm=()=>[1.06,0,0,0,0,0,1.01,0,0,0,0,0,.93,0,0,0,0,0,1,0],cold=()=>[1.1,0,0,0,-.1,0,1.1,0,0,-.1,0,0,1.2,0,-.1,0,0,0,1,0],invert=()=>[-1,0,0,1,0,0,-1,0,1,0,0,0,-1,1,0,0,0,0,1,0],monoDefault=()=>[.212,.715,.114,0,0,.212,.715,.114,0,0,.212,.715,.114,0,0,0,0,0,1,0],monoNoir=()=>[.15,1.3,-.25,.1,-.2,.15,1.3,-.25,.1,-.2,.15,1.3,-.25,.1,-.2,0,0,0,1,0],monoWash=()=>[.163,.518,.084,-.01,.208,.163,.529,.082,-.02,.21,.171,.529,.084,0,.214,0,0,0,1,0],monoStark=()=>[.338,.991,.117,.093,-.196,.302,1.049,.096,.078,-.196,.286,1.016,.146,.101,-.196,0,0,0,1,0],sepiaDefault=()=>[.393,.768,.188,0,0,.349,.685,.167,0,0,.272,.533,.13,0,0,0,0,0,1,0],sepiaBlues=()=>[.289,.62,.185,0,.077,.257,.566,.163,0,.115,.2,.43,.128,0,.188,0,0,0,1,0],sepiaRust=()=>[.269,.764,.172,.05,.1,.239,.527,.152,0,.176,.186,.4,.119,0,.159,0,0,0,1,0],sepiaColor=()=>[.547,.764,.134,0,-.147,.281,.925,.12,0,-.135,.225,.558,.33,0,-.113,0,0,0,1,0],filterFunctionsDefault={chrome:chrome,fade:fade,pastel:pastel,cold:cold,warm:warm,monoDefault:monoDefault,monoWash:monoWash,monoNoir:monoNoir,monoStark:monoStark,sepiaDefault:sepiaDefault,sepiaRust:sepiaRust,sepiaBlues:sepiaBlues,sepiaColor:sepiaColor},filterOptionsDefault=[["Default",[[void 0,e=>e.labelDefault]]],["Classic",[["chrome",e=>e.filterLabelChrome],["fade",e=>e.filterLabelFade],["cold",e=>e.filterLabelCold],["warm",e=>e.filterLabelWarm],["pastel",e=>e.filterLabelPastel]]],["Monochrome",[["monoDefault",e=>e.filterLabelMonoDefault],["monoNoir",e=>e.filterLabelMonoNoir],["monoStark",e=>e.filterLabelMonoStark],["monoWash",e=>e.filterLabelMonoWash]]],["Sepia",[["sepiaDefault",e=>e.filterLabelSepiaDefault],["sepiaRust",e=>e.filterLabelSepiaRust],["sepiaBlues",e=>e.filterLabelSepiaBlues],["sepiaColor",e=>e.filterLabelSepiaColor]]]];var defaults$1={filterFunctions:filterFunctionsDefault,filterOptions:filterOptionsDefault};let fn=null;var snapToPixel=e=>(null===fn&&(fn=1===getDevicePixelRatio()?e=>Math.round(e):e=>e),fn(e));const get_details_slot_changes=e=>({}),get_details_slot_context=e=>({}),get_label_slot_changes=e=>({}),get_label_slot_context=e=>({});function create_default_slot$b(e){let t;const o=e[30].label,n=create_slot(o,e,e[34],get_label_slot_context);return{c(){n&&n.c()},m(e,o){n&&n.m(e,o),t=!0},p(e,t){n&&n.p&&8&t[1]&&update_slot(n,o,e,e[34],t,get_label_slot_changes,get_label_slot_context)},i(e){t||(transition_in(n,e),t=!0)},o(e){transition_out(n,e),t=!1},d(e){n&&n.d(e)}}}function create_if_block_1$a(e){let t,o,n,r,a;const i=e[30].details,s=create_slot(i,e,e[34],get_details_slot_context);return{c(){t=element("div"),s&&s.c(),attr(t,"class",o=arrayJoin(["DokaDetailsPanel",e[1]])),attr(t,"tabindex","-1"),attr(t,"style",e[6])},m(o,i){insert(o,t,i),s&&s.m(t,null),e[32](t),n=!0,r||(a=[listen(t,"keydown",e[16]),listen(t,"measure",e[33]),action_destroyer(measurable.call(null,t))],r=!0)},p(e,r){s&&s.p&&8&r[1]&&update_slot(s,i,e,e[34],r,get_details_slot_changes,get_details_slot_context),(!n||2&r[0]&&o!==(o=arrayJoin(["DokaDetailsPanel",e[1]])))&&attr(t,"class",o),(!n||64&r[0])&&attr(t,"style",e[6])},i(e){n||(transition_in(s,e),n=!0)},o(e){transition_out(s,e),n=!1},d(o){o&&detach(t),s&&s.d(o),e[32](null),r=!1,run_all(a)}}}function create_fragment$u(e){let t,o,n,r,a,i,s,l,c={class:arrayJoin(["DokaDetailsButton",e[0]]),onkeydown:e[15],onclick:e[14],$$slots:{default:[create_default_slot$b]},$$scope:{ctx:e}};o=new Button({props:c}),e[31](o);let p=e[5]&&create_if_block_1$a(e);return{c(){t=space(),create_component(o.$$.fragment),n=space(),p&&p.c(),r=space(),a=empty()},m(c,u){insert(c,t,u),mount_component(o,c,u),insert(c,n,u),p&&p.m(c,u),insert(c,r,u),insert(c,a,u),i=!0,s||(l=[listen(document.body,"pointerdown",function(){is_function(e[7])&&e[7].apply(this,arguments)}),listen(document.body,"pointerup",function(){is_function(e[8])&&e[8].apply(this,arguments)})],s=!0)},p(t,n){e=t;const a={};1&n[0]&&(a.class=arrayJoin(["DokaDetailsButton",e[0]])),8&n[1]&&(a.$$scope={dirty:n,ctx:e}),o.$set(a),e[5]?p?(p.p(e,n),32&n[0]&&transition_in(p,1)):((p=create_if_block_1$a(e)).c(),transition_in(p,1),p.m(r.parentNode,r)):p&&(group_outros(),transition_out(p,1,1,()=>{p=null}),check_outros())},i(e){i||(transition_in(o.$$.fragment,e),transition_in(p),transition_in(!1),i=!0)},o(e){transition_out(o.$$.fragment,e),transition_out(p),transition_out(!1),i=!1},d(i){i&&detach(t),e[31](null),destroy_component(o,i),i&&detach(n),p&&p.d(i),i&&detach(r),i&&detach(a),s=!1,run_all(l)}}}let panelMargin=12;function instance$u(e,t,o){let n,r,a,i,s,l,c,p,u,d,h,m,{$$slots:g={},$$scope:f}=t,{buttonClass:_}=t,{panelClass:$}=t,{isActive:b=!1}=t,{onshow:y=(({panel:e})=>e.focus())}=t;const x=getContext("rootPortal");component_subscribe(e,x,e=>o(29,m=e));const v=getContext("rootRect");let C,S,k;component_subscribe(e,v,e=>o(23,p=e));let w=vectorCreateEmpty(),R=spring(0);component_subscribe(e,R,e=>o(25,d=e));const T=writable({x:0,y:0});component_subscribe(e,T,e=>o(24,u=e));const E=spring(-5);component_subscribe(e,E,e=>o(28,h=e));const I=e=>isEventTarget(e,m)||S.isEventTarget(e);let A,M,P=!1;onDestroy(()=>{m&&A&&m.removeChild(A)});return e.$$set=(e=>{"buttonClass"in e&&o(0,_=e.buttonClass),"panelClass"in e&&o(1,$=e.panelClass),"isActive"in e&&o(17,b=e.isActive),"onshow"in e&&o(18,y=e.onshow),"$$scope"in e&&o(34,f=e.$$scope)}),e.$$.update=(()=>{if(8&e.$$.dirty[0]&&(n=S&&S.getElement()),2228224&e.$$.dirty[0]&&o(8,c=b?e=>{P&&(o(21,P=!1),I(e)||o(17,b=!1))}:void 0),131072&e.$$.dirty[0]&&R.set(b?1:0),131072&e.$$.dirty[0]&&E.set(b?0:-5),8912900&e.$$.dirty[0]&&p&&C&&k){let e=k.x-p.x+.5*k.width-.5*C.width,t=k.y-p.y+k.height;const n=panelMargin,r=panelMargin,a=p.width-panelMargin,i=p.height-panelMargin,s=e,l=t,c=s+C.width,d=l+C.height;if(s<n&&(e=n),c>a&&(e=a-C.width),d>i){o(20,w.y=-1,w),t-=r<t-C.height-k.height?C.height+k.height:d-i}else o(20,w.y=1,w);set_store_value(T,u=vectorApply(vectorCreate(e,t),snapToPixel),u)}33554432&e.$$.dirty[0]&&o(5,r=d>0),33554432&e.$$.dirty[0]&&o(26,a=d<1),286261248&e.$$.dirty[0]&&o(27,i=`translateX(${u.x+w.x*panelMargin}px) translateY(${u.y+w.y*panelMargin+w.y*h}px)`),234881024&e.$$.dirty[0]&&o(6,s=a?`opacity: ${d}; pointer-events: ${d<1?"none":"all"}; transform: ${i};`:`transform: ${i}`),131072&e.$$.dirty[0]&&o(7,l=b?e=>{I(e)||o(21,P=!0)}:void 0),536870960&e.$$.dirty[0]&&r&&m&&A&&A.parentNode!==m&&m.appendChild(A),131072&e.$$.dirty[0]&&(b||o(22,M=void 0)),4456496&e.$$.dirty[0]&&r&&A&&y({e:M,panel:A})}),[_,$,C,S,A,r,s,l,c,x,v,R,T,E,e=>{b||o(19,k=n.getBoundingClientRect()),o(22,M=e),o(17,b=!b)},e=>{/down/i.test(e.key)&&(o(17,b=!0),o(22,M=e))},e=>{/esc/i.test(e.key)&&(o(17,b=!1),n.focus())},b,y,k,w,P,M,p,u,d,a,i,h,m,g,function(e){binding_callbacks[e?"unshift":"push"](()=>{o(3,S=e)})},function(e){binding_callbacks[e?"unshift":"push"](()=>{o(4,A=e)})},e=>o(2,C=sizeCreateFromAny(e.detail)),f]}class Details extends SvelteComponent{constructor(e){super(),init(this,e,instance$u,create_fragment$u,safe_not_equal,{buttonClass:0,panelClass:1,isActive:17,onshow:18},[-1,-1])}}function create_fragment$t(e){let t,o,n,r,a,i,s,l;const c=e[14].default,p=create_slot(c,e,e[13],null);return{c(){t=element("li"),o=element("input"),n=space(),r=element("label"),p&&p.c(),attr(o,"type","radio"),attr(o,"class","implicit"),attr(o,"id",e[6]),attr(o,"name",e[0]),o.value=e[3],o.disabled=e[5],o.checked=e[4],attr(r,"for",e[6]),attr(r,"title",e[2]),attr(t,"class",a=arrayJoin(["DokaRadioGroupOption",e[1]])),attr(t,"data-disabled",e[5]),attr(t,"data-selected",e[4])},m(a,c){insert(a,t,c),append(t,o),append(t,n),append(t,r),p&&p.m(r,null),i=!0,s||(l=[listen(o,"change",stop_propagation(e[15])),listen(o,"keydown",e[8]),listen(o,"click",e[9])],s=!0)},p(e,[n]){(!i||64&n)&&attr(o,"id",e[6]),(!i||1&n)&&attr(o,"name",e[0]),(!i||8&n)&&(o.value=e[3]),(!i||32&n)&&(o.disabled=e[5]),(!i||16&n)&&(o.checked=e[4]),p&&p.p&&8192&n&&update_slot(p,c,e,e[13],n,null,null),(!i||64&n)&&attr(r,"for",e[6]),(!i||4&n)&&attr(r,"title",e[2]),(!i||2&n&&a!==(a=arrayJoin(["DokaRadioGroupOption",e[1]])))&&attr(t,"class",a),(!i||32&n)&&attr(t,"data-disabled",e[5]),(!i||16&n)&&attr(t,"data-selected",e[4])},i(e){i||(transition_in(p,e),i=!0)},o(e){transition_out(p,e),i=!1},d(e){e&&detach(t),p&&p.d(e),s=!1,run_all(l)}}}function instance$t(e,t,o){let n,r,{$$slots:a={},$$scope:i}=t,{name:s}=t,{class:l}=t,{label:c}=t,{id:p}=t,{value:u}=t,{checked:d}=t,{onkeydown:h}=t,{onclick:m}=t,{disabled:g=!1}=t;const f=getContext("keysPressed");component_subscribe(e,f,e=>o(16,r=e));return e.$$set=(e=>{"name"in e&&o(0,s=e.name),"class"in e&&o(1,l=e.class),"label"in e&&o(2,c=e.label),"id"in e&&o(10,p=e.id),"value"in e&&o(3,u=e.value),"checked"in e&&o(4,d=e.checked),"onkeydown"in e&&o(11,h=e.onkeydown),"onclick"in e&&o(12,m=e.onclick),"disabled"in e&&o(5,g=e.disabled),"$$scope"in e&&o(13,i=e.$$scope)}),e.$$.update=(()=>{1025&e.$$.dirty&&o(6,n=`${s}-${p}`)}),[s,l,c,u,d,g,n,f,e=>{h(e)},e=>{r.length||m(e)},p,h,m,i,a,function(t){bubble(e,t)}]}class RadioItem extends SvelteComponent{constructor(e){super(),init(this,e,instance$t,create_fragment$t,safe_not_equal,{name:0,class:1,label:2,id:10,value:3,checked:4,onkeydown:11,onclick:12,disabled:5})}}var flattenOptions=(e=[])=>e.reduce((e,t)=>{return(isArray(t)?isArray(t[1]):!!t.options)?e.concat(isArray(t)?t[1]:t.options):(e.push(t),e)},[]);const mapOption=(e,t,o)=>{let n;return isArray(e)?n={id:t,value:e[0],label:e[1],...e[2]||{}}:(n=e).id=null!=n.id?n.id:t,o?o(n):n};var mapOptions=(e=[],t)=>{let o=0;return e.map(e=>(o++,isArray(e)?isArray(e[1])?{id:o,label:e[0],options:e[1].map(e=>mapOption(e,++o,t))}:mapOption(e,o,t):e.options?{id:e.id||o,label:e.label,options:e.options.map(e=>mapOption(e,++o,t))}:mapOption(e,o,t)))},opop=(e,...t)=>e&&e(...t),localize=(e,t,o)=>isFunction(e)?e(t,o):e;const localizeOptions=(e,t)=>e.map(([e,o,n])=>{if(isArray(o))return[localize(e,t),localizeOptions(o,t)];{const r=[e,localize(o,t)];if(n){let e={...n};n.icon&&(e.icon=localize(n.icon,t)),r.push(e)}return r}});var localizeOptions$1=(e,t)=>localizeOptions(e,t);function get_each_context$6(e,t,o){const n=e.slice();return n[27]=t[o],n}const get_option_slot_changes_1=e=>({option:2048&e[0]}),get_option_slot_context_1=e=>({option:e[27]});function get_each_context_1(e,t,o){const n=e.slice();return n[27]=t[o],n}const get_option_slot_changes=e=>({option:2048&e[0]}),get_option_slot_context=e=>({option:e[27]}),get_group_slot_changes=e=>({option:2048&e[0]}),get_group_slot_context=e=>({option:e[27]});function create_if_block_1$9(e){let t,o,n,r,a,i=[],s=new Map,l=e[1]&&create_if_block_7(e),c=e[11];const p=e=>e[27].id;for(let t=0;t<c.length;t+=1){let o=get_each_context$6(e,c,t),n=p(o);s.set(n,i[t]=create_each_block$6(n,o))}return{c(){t=element("fieldset"),l&&l.c(),o=space(),n=element("ul");for(let e=0;e<i.length;e+=1)i[e].c();attr(n,"class","DokaRadioGroupOptions"),attr(t,"class",r=arrayJoin(["DokaRadioGroup",e[3]])),attr(t,"data-layout",e[5]),attr(t,"title",e[7])},m(e,r){insert(e,t,r),l&&l.m(t,null),append(t,o),append(t,n);for(let e=0;e<i.length;e+=1)i[e].m(n,null);a=!0},p(e,u){e[1]?l?l.p(e,u):((l=create_if_block_7(e)).c(),l.m(t,o)):l&&(l.d(1),l=null),8420177&u[0]&&(c=e[11],group_outros(),i=update_keyed_each(i,u,p,1,e,c,s,n,outro_and_destroy_block,create_each_block$6,null,get_each_context$6),check_outros()),(!a||8&u[0]&&r!==(r=arrayJoin(["DokaRadioGroup",e[3]])))&&attr(t,"class",r),(!a||32&u[0])&&attr(t,"data-layout",e[5]),(!a||128&u[0])&&attr(t,"title",e[7])},i(e){if(!a){for(let e=0;e<c.length;e+=1)transition_in(i[e]);a=!0}},o(e){for(let e=0;e<i.length;e+=1)transition_out(i[e]);a=!1},d(e){e&&detach(t),l&&l.d();for(let e=0;e<i.length;e+=1)i[e].d()}}}function create_if_block_7(e){let t,o,n;return{c(){t=element("legend"),o=text(e[1]),attr(t,"class",n=e[2]&&"implicit")},m(e,n){insert(e,t,n),append(t,o)},p(e,r){2&r[0]&&set_data(o,e[1]),4&r[0]&&n!==(n=e[2]&&"implicit")&&attr(t,"class",n)},d(e){e&&detach(t)}}}function create_else_block$2(e){let t,o;return t=new RadioItem({props:{name:e[4],label:e[27].label,id:e[27].id,value:e[27].value,disabled:e[27].disabled,class:e[8],checked:e[12](e[27])===e[0],onkeydown:e[13](e[27]),onclick:e[14](e[27]),$$slots:{default:[create_default_slot_2$3]},$$scope:{ctx:e}}}),{c(){create_component(t.$$.fragment)},m(e,n){mount_component(t,e,n),o=!0},p(e,o){const n={};16&o[0]&&(n.name=e[4]),2048&o[0]&&(n.label=e[27].label),2048&o[0]&&(n.id=e[27].id),2048&o[0]&&(n.value=e[27].value),2048&o[0]&&(n.disabled=e[27].disabled),256&o[0]&&(n.class=e[8]),2049&o[0]&&(n.checked=e[12](e[27])===e[0]),2048&o[0]&&(n.onkeydown=e[13](e[27])),2048&o[0]&&(n.onclick=e[14](e[27])),8390720&o[0]&&(n.$$scope={dirty:o,ctx:e}),t.$set(n)},i(e){o||(transition_in(t.$$.fragment,e),o=!0)},o(e){transition_out(t.$$.fragment,e),o=!1},d(e){destroy_component(t,e)}}}function create_if_block_2$6(e){let t,o,n,r,a,i,s=[],l=new Map;const c=e[22].group,p=create_slot(c,e,e[23],get_group_slot_context),u=p||fallback_block_1(e);let d=e[27].options;const h=e=>e[27].id;for(let t=0;t<d.length;t+=1){let o=get_each_context_1(e,d,t),n=h(o);l.set(n,s[t]=create_each_block_1(n,o))}return{c(){t=element("li"),u&&u.c(),o=space(),n=element("ul");for(let e=0;e<s.length;e+=1)s[e].c();r=space(),attr(n,"class","DokaRadioGroupOptions"),attr(t,"class",a=arrayJoin(["DokaRadioGroupOptionGroup",e[9]]))},m(e,a){insert(e,t,a),u&&u.m(t,null),append(t,o),append(t,n);for(let e=0;e<s.length;e+=1)s[e].m(n,null);append(t,r),i=!0},p(e,o){p?p.p&&8390656&o[0]&&update_slot(p,c,e,e[23],o,get_group_slot_changes,get_group_slot_context):u&&u.p&&2048&o[0]&&u.p(e,o),8419665&o[0]&&(d=e[27].options,group_outros(),s=update_keyed_each(s,o,h,1,e,d,l,n,outro_and_destroy_block,create_each_block_1,null,get_each_context_1),check_outros()),(!i||512&o[0]&&a!==(a=arrayJoin(["DokaRadioGroupOptionGroup",e[9]])))&&attr(t,"class",a)},i(e){if(!i){transition_in(u,e);for(let e=0;e<d.length;e+=1)transition_in(s[e]);i=!0}},o(e){transition_out(u,e);for(let e=0;e<s.length;e+=1)transition_out(s[e]);i=!1},d(e){e&&detach(t),u&&u.d(e);for(let e=0;e<s.length;e+=1)s[e].d()}}}function create_if_block_6$1(e){let t,o;return t=new Icon({props:{$$slots:{default:[create_default_slot_3$1]},$$scope:{ctx:e}}}),{c(){create_component(t.$$.fragment)},m(e,n){mount_component(t,e,n),o=!0},p(e,o){const n={};8390656&o[0]&&(n.$$scope={dirty:o,ctx:e}),t.$set(n)},i(e){o||(transition_in(t.$$.fragment,e),o=!0)},o(e){transition_out(t.$$.fragment,e),o=!1},d(e){destroy_component(t,e)}}}function create_default_slot_3$1(e){let t,o=e[27].icon+"";return{c(){t=svg_element("g")},m(e,n){insert(e,t,n),t.innerHTML=o},p(e,n){2048&n[0]&&o!==(o=e[27].icon+"")&&(t.innerHTML=o)},d(e){e&&detach(t)}}}function create_if_block_5$2(e){let t,o,n=e[27].label+"";return{c(){t=element("span"),o=text(n),attr(t,"class",e[6])},m(e,n){insert(e,t,n),append(t,o)},p(e,r){2048&r[0]&&n!==(n=e[27].label+"")&&set_data(o,n),64&r[0]&&attr(t,"class",e[6])},d(e){e&&detach(t)}}}function fallback_block_2(e){let t,o,n,r=e[27].icon&&create_if_block_6$1(e),a=!e[27].hideLabel&&create_if_block_5$2(e);return{c(){r&&r.c(),t=space(),a&&a.c(),o=space()},m(e,i){r&&r.m(e,i),insert(e,t,i),a&&a.m(e,i),insert(e,o,i),n=!0},p(e,n){e[27].icon?r?(r.p(e,n),2048&n[0]&&transition_in(r,1)):((r=create_if_block_6$1(e)).c(),transition_in(r,1),r.m(t.parentNode,t)):r&&(group_outros(),transition_out(r,1,1,()=>{r=null}),check_outros()),e[27].hideLabel?a&&(a.d(1),a=null):a?a.p(e,n):((a=create_if_block_5$2(e)).c(),a.m(o.parentNode,o))},i(e){n||(transition_in(r),n=!0)},o(e){transition_out(r),n=!1},d(e){r&&r.d(e),e&&detach(t),a&&a.d(e),e&&detach(o)}}}function create_default_slot_2$3(e){let t;const o=e[22].option,n=create_slot(o,e,e[23],get_option_slot_context_1),r=n||fallback_block_2(e);return{c(){r&&r.c()},m(e,o){r&&r.m(e,o),t=!0},p(e,t){n?n.p&&8390656&t[0]&&update_slot(n,o,e,e[23],t,get_option_slot_changes_1,get_option_slot_context_1):r&&r.p&&2112&t[0]&&r.p(e,t)},i(e){t||(transition_in(r,e),t=!0)},o(e){transition_out(r,e),t=!1},d(e){r&&r.d(e)}}}function fallback_block_1(e){let t,o,n=e[27].label+"";return{c(){t=element("span"),o=text(n),attr(t,"class","DokaRadioGroupOptionGroupLabel")},m(e,n){insert(e,t,n),append(t,o)},p(e,t){2048&t[0]&&n!==(n=e[27].label+"")&&set_data(o,n)},d(e){e&&detach(t)}}}function create_if_block_4$4(e){let t,o;return t=new Icon({props:{$$slots:{default:[create_default_slot_1$6]},$$scope:{ctx:e}}}),{c(){create_component(t.$$.fragment)},m(e,n){mount_component(t,e,n),o=!0},p(e,o){const n={};8390656&o[0]&&(n.$$scope={dirty:o,ctx:e}),t.$set(n)},i(e){o||(transition_in(t.$$.fragment,e),o=!0)},o(e){transition_out(t.$$.fragment,e),o=!1},d(e){destroy_component(t,e)}}}function create_default_slot_1$6(e){let t,o=e[27].icon+"";return{c(){t=svg_element("g")},m(e,n){insert(e,t,n),t.innerHTML=o},p(e,n){2048&n[0]&&o!==(o=e[27].icon+"")&&(t.innerHTML=o)},d(e){e&&detach(t)}}}function create_if_block_3$4(e){let t,o,n=e[27].label+"";return{c(){t=element("span"),o=text(n),attr(t,"class",e[6])},m(e,n){insert(e,t,n),append(t,o)},p(e,r){2048&r[0]&&n!==(n=e[27].label+"")&&set_data(o,n),64&r[0]&&attr(t,"class",e[6])},d(e){e&&detach(t)}}}function fallback_block$1(e){let t,o,n,r=e[27].icon&&create_if_block_4$4(e),a=!e[27].hideLabel&&create_if_block_3$4(e);return{c(){r&&r.c(),t=space(),a&&a.c(),o=space()},m(e,i){r&&r.m(e,i),insert(e,t,i),a&&a.m(e,i),insert(e,o,i),n=!0},p(e,n){e[27].icon?r?(r.p(e,n),2048&n[0]&&transition_in(r,1)):((r=create_if_block_4$4(e)).c(),transition_in(r,1),r.m(t.parentNode,t)):r&&(group_outros(),transition_out(r,1,1,()=>{r=null}),check_outros()),e[27].hideLabel?a&&(a.d(1),a=null):a?a.p(e,n):((a=create_if_block_3$4(e)).c(),a.m(o.parentNode,o))},i(e){n||(transition_in(r),n=!0)},o(e){transition_out(r),n=!1},d(e){r&&r.d(e),e&&detach(t),a&&a.d(e),e&&detach(o)}}}function create_default_slot$a(e){let t;const o=e[22].option,n=create_slot(o,e,e[23],get_option_slot_context),r=n||fallback_block$1(e);return{c(){r&&r.c()},m(e,o){r&&r.m(e,o),t=!0},p(e,t){n?n.p&&8390656&t[0]&&update_slot(n,o,e,e[23],t,get_option_slot_changes,get_option_slot_context):r&&r.p&&2112&t[0]&&r.p(e,t)},i(e){t||(transition_in(r,e),t=!0)},o(e){transition_out(r,e),t=!1},d(e){r&&r.d(e)}}}function create_each_block_1(e,t){let o,n,r;return n=new RadioItem({props:{name:t[4],label:t[27].label,id:t[27].id,value:t[27].value,disabled:t[27].disabled,class:t[8],checked:t[12](t[27])===t[0],onkeydown:t[13](t[27]),onclick:t[14](t[27]),$$slots:{default:[create_default_slot$a]},$$scope:{ctx:t}}}),{key:e,first:null,c(){o=empty(),create_component(n.$$.fragment),this.first=o},m(e,t){insert(e,o,t),mount_component(n,e,t),r=!0},p(e,o){t=e;const r={};16&o[0]&&(r.name=t[4]),2048&o[0]&&(r.label=t[27].label),2048&o[0]&&(r.id=t[27].id),2048&o[0]&&(r.value=t[27].value),2048&o[0]&&(r.disabled=t[27].disabled),256&o[0]&&(r.class=t[8]),2049&o[0]&&(r.checked=t[12](t[27])===t[0]),2048&o[0]&&(r.onkeydown=t[13](t[27])),2048&o[0]&&(r.onclick=t[14](t[27])),8390720&o[0]&&(r.$$scope={dirty:o,ctx:t}),n.$set(r)},i(e){r||(transition_in(n.$$.fragment,e),r=!0)},o(e){transition_out(n.$$.fragment,e),r=!1},d(e){e&&detach(o),destroy_component(n,e)}}}function create_each_block$6(e,t){let o,n,r,a,i;const s=[create_if_block_2$6,create_else_block$2],l=[];function c(e,t){return e[27].options?0:1}return n=c(t),r=l[n]=s[n](t),{key:e,first:null,c(){o=empty(),r.c(),a=empty(),this.first=o},m(e,t){insert(e,o,t),l[n].m(e,t),insert(e,a,t),i=!0},p(e,o){let i=n;(n=c(t=e))===i?l[n].p(t,o):(group_outros(),transition_out(l[i],1,1,()=>{l[i]=null}),check_outros(),(r=l[n])?r.p(t,o):(r=l[n]=s[n](t)).c(),transition_in(r,1),r.m(a.parentNode,a))},i(e){i||(transition_in(r),i=!0)},o(e){transition_out(r),i=!1},d(e){e&&detach(o),l[n].d(e),e&&detach(a)}}}function create_fragment$s(e){let t,o,n,r=e[10].length&&create_if_block_1$9(e);return{c(){r&&r.c(),t=space(),o=empty()},m(e,a){r&&r.m(e,a),insert(e,t,a),insert(e,o,a),n=!0},p(e,o){e[10].length?r?(r.p(e,o),1024&o[0]&&transition_in(r,1)):((r=create_if_block_1$9(e)).c(),transition_in(r,1),r.m(t.parentNode,t)):r&&(group_outros(),transition_out(r,1,1,()=>{r=null}),check_outros())},i(e){n||(transition_in(r),transition_in(!1),n=!0)},o(e){transition_out(r),transition_out(!1),n=!1},d(e){r&&r.d(e),e&&detach(t),e&&detach(o)}}}function instance$s(e,t,o){let n,r,a,{$$slots:i={},$$scope:s}=t;const l=createEventDispatcher();let{label:c}=t,{hideLabel:p=!0}=t,{class:u}=t,{name:d=`doka-radio-group-${getUniqueId()}`}=t,{selectedIndex:h=-1}=t,{options:m=[]}=t,{onchange:g}=t,{layout:f}=t,{optionMapper:_}=t,{optionFilter:$}=t,{value:b}=t,{optionLabelClass:y}=t,{title:x}=t,{locale:v}=t,{optionClass:C}=t,{optionGroupClass:S}=t;const k=e=>a.findIndex(t=>t.id===e.id),w=e=>{o(0,h=k(e));const t={index:h,...e};opop(g,t),l("change",t)};return e.$$set=(e=>{"label"in e&&o(1,c=e.label),"hideLabel"in e&&o(2,p=e.hideLabel),"class"in e&&o(3,u=e.class),"name"in e&&o(4,d=e.name),"selectedIndex"in e&&o(0,h=e.selectedIndex),"options"in e&&o(15,m=e.options),"onchange"in e&&o(16,g=e.onchange),"layout"in e&&o(5,f=e.layout),"optionMapper"in e&&o(17,_=e.optionMapper),"optionFilter"in e&&o(18,$=e.optionFilter),"value"in e&&o(19,b=e.value),"optionLabelClass"in e&&o(6,y=e.optionLabelClass),"title"in e&&o(7,x=e.title),"locale"in e&&o(20,v=e.locale),"optionClass"in e&&o(8,C=e.optionClass),"optionGroupClass"in e&&o(9,S=e.optionGroupClass),"$$scope"in e&&o(23,s=e.$$scope)}),e.$$.update=(()=>{1343488&e.$$.dirty[0]&&o(10,n=localizeOptions$1($?m.filter($):m,v)),132096&e.$$.dirty[0]&&o(11,r=mapOptions(n,_)),2048&e.$$.dirty[0]&&o(21,a=flattenOptions(r)),2621441&e.$$.dirty[0]&&b&&h<0&&o(0,h=a.findIndex(e=>e.value===b))}),[h,c,p,u,d,f,y,x,C,S,n,r,k,e=>t=>{(e=>/enter| /i.test(e))(t.key)&&w(e)},e=>t=>{w(e)},m,g,_,$,b,v,a,i,s]}class RadioGroup extends SvelteComponent{constructor(e){super(),init(this,e,instance$s,create_fragment$s,safe_not_equal,{label:1,hideLabel:2,class:3,name:4,selectedIndex:0,options:15,onchange:16,layout:5,optionMapper:17,optionFilter:18,value:19,optionLabelClass:6,title:7,locale:20,optionClass:8,optionGroupClass:9},[-1,-1])}}var isDeepEqual=(e,t)=>Array.isArray(e)&&Array.isArray(t)?arrayEqual(e,t):e===t;function create_if_block_1$8(e){let t,o;return t=new Icon({props:{$$slots:{default:[create_default_slot_1$5]},$$scope:{ctx:e}}}),{c(){create_component(t.$$.fragment)},m(e,n){mount_component(t,e,n),o=!0},p(e,o){const n={};134217792&o&&(n.$$scope={dirty:o,ctx:e}),t.$set(n)},i(e){o||(transition_in(t.$$.fragment,e),o=!0)},o(e){transition_out(t.$$.fragment,e),o=!1},d(e){destroy_component(t,e)}}}function create_default_slot_1$5(e){let t;return{c(){t=svg_element("g")},m(o,n){insert(o,t,n),t.innerHTML=e[6]},p(e,o){64&o&&(t.innerHTML=e[6])},d(e){e&&detach(t)}}}function create_label_slot$1(e){let t,o,n,r,a,i,s,l,c=(e[2]||e[18])+"",p=e[6]&&create_if_block_1$8(e);return{c(){t=element("span"),p&&p.c(),o=space(),n=element("span"),r=text(c),attr(n,"class",a=arrayJoin(["DokaButtonLabel",e[3],e[5]&&"implicit"])),attr(t,"slot","label"),attr(t,"title",i=localize(e[1],e[15])),attr(t,"class",s=arrayJoin(["DokaButtonInner",e[4]]))},m(e,a){insert(e,t,a),p&&p.m(t,null),append(t,o),append(t,n),append(n,r),l=!0},p(e,u){e[6]?p?(p.p(e,u),64&u&&transition_in(p,1)):((p=create_if_block_1$8(e)).c(),transition_in(p,1),p.m(t,o)):p&&(group_outros(),transition_out(p,1,1,()=>{p=null}),check_outros()),(!l||262148&u)&&c!==(c=(e[2]||e[18])+"")&&set_data(r,c),(!l||40&u&&a!==(a=arrayJoin(["DokaButtonLabel",e[3],e[5]&&"implicit"])))&&attr(n,"class",a),(!l||32770&u&&i!==(i=localize(e[1],e[15])))&&attr(t,"title",i),(!l||16&u&&s!==(s=arrayJoin(["DokaButtonInner",e[4]])))&&attr(t,"class",s)},i(e){l||(transition_in(p),l=!0)},o(e){transition_out(p),l=!1},d(e){e&&detach(t),p&&p.d()}}}function create_group_slot$1(e){let t,o,n=e[26].label+"";return{c(){t=element("span"),o=text(n),attr(t,"slot","group")},m(e,n){insert(e,t,n),append(t,o)},p(e,t){67108864&t&&n!==(n=e[26].label+"")&&set_data(o,n)},d(e){e&&detach(t)}}}function create_if_block$8(e){let t,o;return t=new Icon({props:{style:isFunction(e[13])?e[13](e[26].value):e[13],$$slots:{default:[create_default_slot$9]},$$scope:{ctx:e}}}),{c(){create_component(t.$$.fragment)},m(e,n){mount_component(t,e,n),o=!0},p(e,o){const n={};67117056&o&&(n.style=isFunction(e[13])?e[13](e[26].value):e[13]),201326592&o&&(n.$$scope={dirty:o,ctx:e}),t.$set(n)},i(e){o||(transition_in(t.$$.fragment,e),o=!0)},o(e){transition_out(t.$$.fragment,e),o=!1},d(e){destroy_component(t,e)}}}function create_default_slot$9(e){let t,o=e[26].icon+"";return{c(){t=svg_element("g")},m(e,n){insert(e,t,n),t.innerHTML=o},p(e,n){67108864&n&&o!==(o=e[26].icon+"")&&(t.innerHTML=o)},d(e){e&&detach(t)}}}function create_option_slot$3(e){let t,o,n,r,a,i,s,l=e[26].label+"",c=e[26].icon&&create_if_block$8(e);return{c(){t=element("span"),c&&c.c(),o=space(),n=element("span"),r=text(l),attr(n,"style",a=isFunction(e[14])?e[14](e[26].value):e[14]),attr(n,"class",i=arrayJoin(["DokaDropdownOptionLabel",e[10]])),attr(t,"slot","option")},m(e,a){insert(e,t,a),c&&c.m(t,null),append(t,o),append(t,n),append(n,r),s=!0},p(e,p){e[26].icon?c?(c.p(e,p),67108864&p&&transition_in(c,1)):((c=create_if_block$8(e)).c(),transition_in(c,1),c.m(t,o)):c&&(group_outros(),transition_out(c,1,1,()=>{c=null}),check_outros()),(!s||67108864&p)&&l!==(l=e[26].label+"")&&set_data(r,l),(!s||67125248&p&&a!==(a=isFunction(e[14])?e[14](e[26].value):e[14]))&&attr(n,"style",a),(!s||1024&p&&i!==(i=arrayJoin(["DokaDropdownOptionLabel",e[10]])))&&attr(n,"class",i)},i(e){s||(transition_in(c),s=!0)},o(e){transition_out(c),s=!1},d(e){e&&detach(t),c&&c.d()}}}function create_details_slot$1(e){let t,o,n,r,a;return o=new RadioGroup({props:{name:e[7],value:e[9],selectedIndex:e[8],optionFilter:e[11],optionMapper:e[12],optionLabelClass:arrayJoin(["DokaDropdownOptionLabel",e[10]]),optionGroupClass:"DokaDropdownOptionGroup",optionClass:"DokaDropdownOption",options:e[16],onchange:e[19],$$slots:{option:[create_option_slot$3,({option:e})=>({26:e}),({option:e})=>e?67108864:0],group:[create_group_slot$1,({option:e})=>({26:e}),({option:e})=>e?67108864:0]},$$scope:{ctx:e}}}),{c(){t=element("div"),create_component(o.$$.fragment),attr(t,"class","DokaDropdownPanel"),attr(t,"slot","details")},m(i,s){insert(i,t,s),mount_component(o,t,null),n=!0,r||(a=listen(t,"keydown",e[21]),r=!0)},p(e,t){const n={};128&t&&(n.name=e[7]),512&t&&(n.value=e[9]),256&t&&(n.selectedIndex=e[8]),2048&t&&(n.optionFilter=e[11]),4096&t&&(n.optionMapper=e[12]),1024&t&&(n.optionLabelClass=arrayJoin(["DokaDropdownOptionLabel",e[10]])),65536&t&&(n.options=e[16]),201352192&t&&(n.$$scope={dirty:t,ctx:e}),o.$set(n)},i(e){n||(transition_in(o.$$.fragment,e),n=!0)},o(e){transition_out(o.$$.fragment,e),n=!1},d(e){e&&detach(t),destroy_component(o),r=!1,a()}}}function create_fragment$r(e){let t,o,n;function r(t){e[24](t)}let a={onshow:e[20],buttonClass:arrayJoin(["DokaDropdownButton",e[0],e[5]&&"DokaDropdownIconOnly"]),$$slots:{details:[create_details_slot$1],label:[create_label_slot$1]},$$scope:{ctx:e}};return void 0!==e[17]&&(a.isActive=e[17]),t=new Details({props:a}),binding_callbacks.push(()=>bind(t,"isActive",r)),{c(){create_component(t.$$.fragment)},m(e,o){mount_component(t,e,o),n=!0},p(e,[n]){const r={};33&n&&(r.buttonClass=arrayJoin(["DokaDropdownButton",e[0],e[5]&&"DokaDropdownIconOnly"])),134610942&n&&(r.$$scope={dirty:n,ctx:e}),!o&&131072&n&&(o=!0,r.isActive=e[17],add_flush_callback(()=>o=!1)),t.$set(r)},i(e){n||(transition_in(t.$$.fragment,e),n=!0)},o(e){transition_out(t.$$.fragment,e),n=!1},d(e){destroy_component(t,e)}}}function instance$r(e,t,o){let n,r,{class:a}=t,{title:i}=t,{label:s}=t,{labelClass:l}=t,{innerClass:c}=t,{hideLabel:p=!1}=t,{icon:u}=t,{name:d}=t,{options:h=[]}=t,{selectedIndex:m=-1}=t,{value:g}=t,{optionLabelClass:f}=t,{optionFilter:_}=t,{optionMapper:$}=t,{optionIconStyle:b}=t,{optionLabelStyle:y}=t,{onchange:x}=t,{locale:v}=t;let C;return e.$$set=(e=>{"class"in e&&o(0,a=e.class),"title"in e&&o(1,i=e.title),"label"in e&&o(2,s=e.label),"labelClass"in e&&o(3,l=e.labelClass),"innerClass"in e&&o(4,c=e.innerClass),"hideLabel"in e&&o(5,p=e.hideLabel),"icon"in e&&o(6,u=e.icon),"name"in e&&o(7,d=e.name),"options"in e&&o(22,h=e.options),"selectedIndex"in e&&o(8,m=e.selectedIndex),"value"in e&&o(9,g=e.value),"optionLabelClass"in e&&o(10,f=e.optionLabelClass),"optionFilter"in e&&o(11,_=e.optionFilter),"optionMapper"in e&&o(12,$=e.optionMapper),"optionIconStyle"in e&&o(13,b=e.optionIconStyle),"optionLabelStyle"in e&&o(14,y=e.optionLabelStyle),"onchange"in e&&o(23,x=e.onchange),"locale"in e&&o(15,v=e.locale)}),e.$$.update=(()=>{4227072&e.$$.dirty&&o(16,n=localizeOptions$1(h,v)),66048&e.$$.dirty&&o(18,r=n.reduce((e,t)=>{if(e)return e;const[o,n]=t;return isDeepEqual(o,g)?n:void 0},void 0)||(e=>{const t=n.find(e=>void 0===e[0]);if(t)return t[1]})())}),[a,i,s,l,c,p,u,d,m,g,f,_,$,b,y,v,n,C,r,e=>{o(18,r=e.value),x(e),o(17,C=!1)},({e:e,panel:t})=>{if(e&&e.key&&/up|down/i.test(e.key))return t.querySelector("input:not([disabled])").focus();t.querySelector("fieldset").focus()},e=>{/tab/i.test(e.key)&&e.preventDefault()},h,x,function(e){o(17,C=e)}]}class Dropdown extends SvelteComponent{constructor(e){super(),init(this,e,instance$r,create_fragment$r,safe_not_equal,{class:0,title:1,label:2,labelClass:3,innerClass:4,hideLabel:5,icon:6,name:7,options:22,selectedIndex:8,value:9,optionLabelClass:10,optionFilter:11,optionMapper:12,optionIconStyle:13,optionLabelStyle:14,onchange:23,locale:15})}}function create_fragment$q(e){let t,o,n,r,a,i,s,l,c,p,u;return{c(){t=element("div"),o=element("input"),n=space(),r=element("div"),a=space(),i=element("div"),s=element("div"),attr(o,"type","range"),attr(o,"id",e[4]),attr(o,"min",e[1]),attr(o,"max",e[2]),attr(o,"step",e[3]),o.value=e[0],attr(r,"class","DokaSliderTrack"),attr(r,"style",e[5]),attr(s,"class","DokaSliderKnob"),attr(s,"style",e[6]),attr(i,"class","DokaSliderKnobController"),attr(i,"style",l=`transform: translateX(${e[9]}%)`),attr(t,"class",c=arrayJoin(["DokaSlider",e[7]]))},m(l,c){insert(l,t,c),append(t,o),e[15](o),append(t,n),append(t,r),append(t,a),append(t,i),append(i,s),p||(u=[listen(o,"pointerdown",e[12]),listen(o,"input",e[10]),listen(o,"nudge",e[11]),action_destroyer(nudgeable.call(null,o))],p=!0)},p(e,[n]){16&n&&attr(o,"id",e[4]),2&n&&attr(o,"min",e[1]),4&n&&attr(o,"max",e[2]),8&n&&attr(o,"step",e[3]),1&n&&(o.value=e[0]),32&n&&attr(r,"style",e[5]),64&n&&attr(s,"style",e[6]),512&n&&l!==(l=`transform: translateX(${e[9]}%)`)&&attr(i,"style",l),128&n&&c!==(c=arrayJoin(["DokaSlider",e[7]]))&&attr(t,"class",c)},i:noop,o:noop,d(o){o&&detach(t),e[15](null),p=!1,run_all(u)}}}function instance$q(e,t,o){let n,r,a,i,s,l,{min:c=0}=t,{max:p=100}=t,{step:u=1}=t,{id:d}=t,{value:h=0}=t,{trackStyle:m}=t,{knobStyle:g}=t,{onchange:f}=t,{class:_}=t;const $=(e,t)=>{o(0,h=clamp(c+e/t*n,c,p)),f(h)},b=e=>{const t=e.pageX-l;$(s+t,i)},y=e=>{i=void 0,document.documentElement.removeEventListener("pointermove",b),document.documentElement.removeEventListener("pointerup",y),f(h)};return e.$$set=(e=>{"min"in e&&o(1,c=e.min),"max"in e&&o(2,p=e.max),"step"in e&&o(3,u=e.step),"id"in e&&o(4,d=e.id),"value"in e&&o(0,h=e.value),"trackStyle"in e&&o(5,m=e.trackStyle),"knobStyle"in e&&o(6,g=e.knobStyle),"onchange"in e&&o(13,f=e.onchange),"class"in e&&o(7,_=e.class)}),e.$$.update=(()=>{6&e.$$.dirty&&o(14,n=p-c),16385&e.$$.dirty&&o(9,r=h/n*100)}),[h,c,p,u,d,m,g,_,a,r,e=>{i||(o(0,h=parseFloat(e.target.value)),f(h))},e=>{const t=a.offsetWidth;$(h/n*t+e.detail.x,t)},e=>{e.stopPropagation(),i=a.offsetWidth,s=e.offsetX,l=e.pageX,$(s,i),document.documentElement.addEventListener("pointermove",b),document.documentElement.addEventListener("pointerup",y)},f,n,function(e){binding_callbacks[e?"unshift":"push"](()=>{o(8,a=e)})}]}class Slider extends SvelteComponent{constructor(e){super(),init(this,e,instance$q,create_fragment$q,safe_not_equal,{min:1,max:2,step:3,id:4,value:0,trackStyle:5,knobStyle:6,onchange:13,class:7})}}var RGBToHSV=(e,t,o)=>{let n=Math.max(e,t,o),r=n-Math.min(e,t,o),a=r&&(n==e?(t-o)/r:n==t?2+(o-e)/r:4+(e-t)/r);return[60*(a<0?a+6:a)/360,n&&r/n,n]},HSVToRGB=(e,t,o)=>{let n,r,a;const i=Math.floor(6*e),s=6*e-i,l=o*(1-t),c=o*(1-s*t),p=o*(1-(1-s)*t);switch(i%6){case 0:n=o,r=p,a=l;break;case 1:n=c,r=o,a=l;break;case 2:n=l,r=o,a=p;break;case 3:n=l,r=c,a=o;break;case 4:n=p,r=l,a=o;break;case 5:n=o,r=l,a=c}return[n,r,a]};function create_fragment$p(e){let t,o,n;return{c(){t=element("div"),o=element("span"),attr(t,"class","DokaColorPreview"),attr(t,"title",e[0]),attr(t,"style",n=`--color:${e[1]}`)},m(e,n){insert(e,t,n),append(t,o)},p(e,[o]){1&o&&attr(t,"title",e[0]),2&o&&n!==(n=`--color:${e[1]}`)&&attr(t,"style",n)},i:noop,o:noop,d(e){e&&detach(t)}}}function instance$p(e,t,o){let n,{color:r}=t,{title:a}=t;return e.$$set=(e=>{"color"in e&&o(2,r=e.color),"title"in e&&o(0,a=e.title)}),e.$$.update=(()=>{4&e.$$.dirty&&o(1,n=r?colorArrayToRGBA(r):"transparent")}),[a,n,r]}class ColorPreview extends SvelteComponent{constructor(e){super(),init(this,e,instance$p,create_fragment$p,safe_not_equal,{color:2,title:0})}}function create_if_block_4$3(e){let t,o;return{c(){t=element("span"),o=text(e[0])},m(e,n){insert(e,t,n),append(t,o)},p(e,t){1&t[0]&&set_data(o,e[0])},d(e){e&&detach(t)}}}function create_label_slot(e){let t,o,n,r;o=new ColorPreview({props:{color:e[4],title:localize(e[8],e[10])}});let a=!e[9]&&create_if_block_4$3(e);return{c(){t=element("span"),create_component(o.$$.fragment),n=space(),a&&a.c(),attr(t,"slot","label"),attr(t,"class","DokaButtonLabel")},m(e,i){insert(e,t,i),mount_component(o,t,null),append(t,n),a&&a.m(t,null),r=!0},p(e,n){const r={};16&n[0]&&(r.color=e[4]),1280&n[0]&&(r.title=localize(e[8],e[10])),o.$set(r),e[9]?a&&(a.d(1),a=null):a?a.p(e,n):((a=create_if_block_4$3(e)).c(),a.m(t,null))},i(e){r||(transition_in(o.$$.fragment,e),r=!0)},o(e){transition_out(o.$$.fragment,e),r=!1},d(e){e&&detach(t),destroy_component(o),a&&a.d()}}}function create_if_block_2$5(e){let t,o,n,r,a,i,s,l,c,p,u,d,h;c=new Slider({props:{class:"DokaHuePicker",knobStyle:`background-color:${e[19]}`,onchange:e[24],value:e[14],min:0,max:1,step:.001}});let m=e[11]&&create_if_block_3$3(e);return{c(){t=element("div"),o=element("div"),n=element("div"),r=element("div"),l=space(),create_component(c.$$.fragment),p=space(),m&&m.c(),attr(r,"role","button"),attr(r,"aria-label","Saturation slider"),attr(r,"class","DokaPickerKnob"),attr(r,"tabindex","0"),attr(r,"style",a=`background-color:${e[18]};`),attr(n,"class","DokaPickerKnobController"),attr(n,"style",i=`transform:translate(${e[21]}%,${e[22]}%)`),attr(o,"class","DokaSaturationPicker"),attr(o,"style",s=`background-color: ${e[19]}`),attr(t,"class","DokaPicker")},m(a,i){insert(a,t,i),append(t,o),append(o,n),append(n,r),e[31](o),append(t,l),mount_component(c,t,null),append(t,p),m&&m.m(t,null),u=!0,d||(h=[listen(r,"nudge",e[27]),action_destroyer(nudgeable.call(null,r)),listen(o,"pointerdown",e[26])],d=!0)},p(e,l){(!u||262144&l[0]&&a!==(a=`background-color:${e[18]};`))&&attr(r,"style",a),(!u||6291456&l[0]&&i!==(i=`transform:translate(${e[21]}%,${e[22]}%)`))&&attr(n,"style",i),(!u||524288&l[0]&&s!==(s=`background-color: ${e[19]}`))&&attr(o,"style",s);const p={};524288&l[0]&&(p.knobStyle=`background-color:${e[19]}`),16384&l[0]&&(p.value=e[14]),c.$set(p),e[11]?m?(m.p(e,l),2048&l[0]&&transition_in(m,1)):((m=create_if_block_3$3(e)).c(),transition_in(m,1),m.m(t,null)):m&&(group_outros(),transition_out(m,1,1,()=>{m=null}),check_outros())},i(e){u||(transition_in(c.$$.fragment,e),transition_in(m),u=!0)},o(e){transition_out(c.$$.fragment,e),transition_out(m),u=!1},d(o){o&&detach(t),e[31](null),destroy_component(c),m&&m.d(),d=!1,run_all(h)}}}function create_if_block_3$3(e){let t,o;return t=new Slider({props:{class:"DokaOpacityPicker",knobStyle:`background-color: ${e[16]}`,trackStyle:`background-image: linear-gradient(to right, ${e[17]}, ${e[18]})`,onchange:e[25],value:e[15],min:0,max:1,step:.001}}),{c(){create_component(t.$$.fragment)},m(e,n){mount_component(t,e,n),o=!0},p(e,o){const n={};65536&o[0]&&(n.knobStyle=`background-color: ${e[16]}`),393216&o[0]&&(n.trackStyle=`background-image: linear-gradient(to right, ${e[17]}, ${e[18]})`),32768&o[0]&&(n.value=e[15]),t.$set(n)},i(e){o||(transition_in(t.$$.fragment,e),o=!0)},o(e){transition_out(t.$$.fragment,e),o=!1},d(e){destroy_component(t,e)}}}function create_if_block$7(e){let t,o;return t=new RadioGroup({props:{label:"Presets",class:arrayJoin(["DokaColorPresets",e[9]?"DokaColorPresetsGrid":"DokaColorPresetsList"]),hideLabel:!1,name:e[1],value:e[4],optionGroupClass:"DokaDropdownOptionGroup",optionClass:"DokaDropdownOption",options:e[2].map(e[32]),selectedIndex:e[3],optionMapper:e[7],optionLabelClass:e[6],onchange:e[33],$$slots:{option:[create_option_slot$2,({option:e})=>({44:e}),({option:e})=>[0,e?8192:0]],group:[create_group_slot,({option:e})=>({44:e}),({option:e})=>[0,e?8192:0]]},$$scope:{ctx:e}}}),{c(){create_component(t.$$.fragment)},m(e,n){mount_component(t,e,n),o=!0},p(e,o){const n={};512&o[0]&&(n.class=arrayJoin(["DokaColorPresets",e[9]?"DokaColorPresetsGrid":"DokaColorPresetsList"])),2&o[0]&&(n.name=e[1]),16&o[0]&&(n.value=e[4]),1028&o[0]&&(n.options=e[2].map(e[32])),8&o[0]&&(n.selectedIndex=e[3]),128&o[0]&&(n.optionMapper=e[7]),64&o[0]&&(n.optionLabelClass=e[6]),512&o[0]|24576&o[1]&&(n.$$scope={dirty:o,ctx:e}),t.$set(n)},i(e){o||(transition_in(t.$$.fragment,e),o=!0)},o(e){transition_out(t.$$.fragment,e),o=!1},d(e){destroy_component(t,e)}}}function create_group_slot(e){let t,o,n=e[44].label+"";return{c(){t=element("span"),o=text(n),attr(t,"slot","group")},m(e,n){insert(e,t,n),append(t,o)},p(e,t){8192&t[1]&&n!==(n=e[44].label+"")&&set_data(o,n)},d(e){e&&detach(t)}}}function create_if_block_1$7(e){let t,o,n=e[44].label+"";return{c(){t=element("span"),o=text(n),attr(t,"class","DokaButtonLabel")},m(e,n){insert(e,t,n),append(t,o)},p(e,t){8192&t[1]&&n!==(n=e[44].label+"")&&set_data(o,n)},d(e){e&&detach(t)}}}function create_option_slot$2(e){let t,o,n,r;o=new ColorPreview({props:{title:e[44].label,color:e[44].value}});let a=!e[9]&&create_if_block_1$7(e);return{c(){t=element("span"),create_component(o.$$.fragment),n=space(),a&&a.c(),attr(t,"slot","option")},m(e,i){insert(e,t,i),mount_component(o,t,null),append(t,n),a&&a.m(t,null),r=!0},p(e,n){const r={};8192&n[1]&&(r.title=e[44].label),8192&n[1]&&(r.color=e[44].value),o.$set(r),e[9]?a&&(a.d(1),a=null):a?a.p(e,n):((a=create_if_block_1$7(e)).c(),a.m(t,null))},i(e){r||(transition_in(o.$$.fragment,e),r=!0)},o(e){transition_out(o.$$.fragment,e),r=!1},d(e){e&&detach(t),destroy_component(o),a&&a.d()}}}function create_details_slot(e){let t,o,n,r=e[13]&&create_if_block_2$5(e),a=e[12]&&create_if_block$7(e);return{c(){t=element("div"),r&&r.c(),o=space(),a&&a.c(),attr(t,"slot","details"),attr(t,"class","DokaColorPickerPanel")},m(e,i){insert(e,t,i),r&&r.m(t,null),append(t,o),a&&a.m(t,null),n=!0},p(e,n){e[13]?r?(r.p(e,n),8192&n[0]&&transition_in(r,1)):((r=create_if_block_2$5(e)).c(),transition_in(r,1),r.m(t,o)):r&&(group_outros(),transition_out(r,1,1,()=>{r=null}),check_outros()),e[12]?a?(a.p(e,n),4096&n[0]&&transition_in(a,1)):((a=create_if_block$7(e)).c(),transition_in(a,1),a.m(t,null)):a&&(group_outros(),transition_out(a,1,1,()=>{a=null}),check_outros())},i(e){n||(transition_in(r),transition_in(a),n=!0)},o(e){transition_out(r),transition_out(a),n=!1},d(e){e&&detach(t),r&&r.d(),a&&a.d()}}}function create_fragment$o(e){let t,o;return t=new Details({props:{buttonClass:arrayJoin(["DokaColorPickerButton",e[5]]),$$slots:{details:[create_details_slot],label:[create_label_slot]},$$scope:{ctx:e}}}),{c(){create_component(t.$$.fragment)},m(e,n){mount_component(t,e,n),o=!0},p(e,o){const n={};32&o[0]&&(n.buttonClass=arrayJoin(["DokaColorPickerButton",e[5]])),8388575&o[0]|16384&o[1]&&(n.$$scope={dirty:o,ctx:e}),t.$set(n)},i(e){o||(transition_in(t.$$.fragment,e),o=!0)},o(e){transition_out(t.$$.fragment,e),o=!1},d(e){destroy_component(t,e)}}}function instance$o(e,t,o){let n,r,a,i,s,l,c,p,u,d,h,{label:m}=t,{name:g}=t,{options:f=[]}=t,{selectedIndex:_=-1}=t,{value:$}=t,{buttonClass:b}=t,{optionLabelClass:y}=t,{optionMapper:x}=t,{onchange:v}=t,{title:C}=t,{hidePresetLabel:S=!0}=t,{locale:k}=t,{enableOpacity:w=!0}=t,{enablePresets:R=!0}=t,{enablePicker:T=!0}=t;const E=(e,t)=>{if(c=[e[0],e[1],e[2]],t){let t=RGBToHSV(...c);o(14,a=t[0]),o(29,i=t[1]),o(30,s=t[2]),o(15,l=isNumber(e[3])?e[3]:1)}o(16,p=colorArrayToRGBA(e)),o(17,u=colorArrayToRGBA([...c,0])),o(18,d=colorArrayToRGBA([...c,1])),o(19,h=colorArrayToRGBA(HSVToRGB(a,1,1)))};$&&E($,!0);const I=()=>{const e=[...HSVToRGB(a,i,s),l];E(e),v(e)},A=e=>{const t=3===e.length?[...e,1]:e;E(t,!0),v(t)},M=(e,t)=>{const n=clamp(e.x/t.width,0,1),r=clamp(e.y/t.height,0,1);P=1-r,o(29,i=n),o(30,s=P),0===l&&o(15,l=1),I()};var P;let D,F,L,z;const B=e=>{const t=vectorSubtract(vectorCreateFromPointerEvent(e),z);M(vectorAdd(vectorClone(L),t),F)},O=e=>{F=void 0,document.documentElement.removeEventListener("pointermove",B),document.documentElement.removeEventListener("pointerup",O)};return e.$$set=(e=>{"label"in e&&o(0,m=e.label),"name"in e&&o(1,g=e.name),"options"in e&&o(2,f=e.options),"selectedIndex"in e&&o(3,_=e.selectedIndex),"value"in e&&o(4,$=e.value),"buttonClass"in e&&o(5,b=e.buttonClass),"optionLabelClass"in e&&o(6,y=e.optionLabelClass),"optionMapper"in e&&o(7,x=e.optionMapper),"onchange"in e&&o(28,v=e.onchange),"title"in e&&o(8,C=e.title),"hidePresetLabel"in e&&o(9,S=e.hidePresetLabel),"locale"in e&&o(10,k=e.locale),"enableOpacity"in e&&o(11,w=e.enableOpacity),"enablePresets"in e&&o(12,R=e.enablePresets),"enablePicker"in e&&o(13,T=e.enablePicker)}),e.$$.update=(()=>{536870912&e.$$.dirty[0]&&o(21,n=100*i),1073741824&e.$$.dirty[0]&&o(22,r=100-100*s)}),[m,g,f,_,$,b,y,x,C,S,k,w,R,T,a,l,p,u,d,h,D,n,r,A,e=>{o(14,a=e),0===l&&o(15,l=1),I()},e=>{o(15,l=e),I()},e=>{e.stopPropagation(),F=sizeCreate(D.offsetWidth,D.offsetHeight),L=vectorCreateFromPointerEventOffset(e),z=vectorCreateFromPointerEvent(e),M(L,F),document.documentElement.addEventListener("pointermove",B),document.documentElement.addEventListener("pointerup",O)},e=>{F=sizeCreate(D.offsetWidth,D.offsetHeight);const t=n/100*F.width,o=r/100*F.height;M({x:t+e.detail.x,y:o+e.detail.y},F)},v,i,s,function(e){binding_callbacks[e?"unshift":"push"](()=>{o(20,D=e)})},([e,t])=>[e,isFunction(t)?t(k):t],e=>A(e.value)]}class ColorPicker extends SvelteComponent{constructor(e){super(),init(this,e,instance$o,create_fragment$o,safe_not_equal,{label:0,name:1,options:2,selectedIndex:3,value:4,buttonClass:5,optionLabelClass:6,optionMapper:7,onchange:28,title:8,hidePresetLabel:9,locale:10,enableOpacity:11,enablePresets:12,enablePicker:13},[-1,-1])}}var upperCaseFirstLetter=e=>e.charAt(0).toUpperCase()+e.slice(1);const toLocaleFn=(e,t)=>o=>o[t?`${t}${upperCaseFirstLetter(e)}`:e],mapToSizeOption=e=>[e,`${e}`],createLocaleMapper=(e,t)=>o=>[e[o],toLocaleFn(o,t)],toolColorDefault=[1,.2549,.2118],toolStrokeColorDefault=[1,1,1,0],toolShapeDefaults={path:()=>({points:[],disableErase:!1}),line:()=>({x1:0,y1:0,x2:0,y2:0,disableErase:!1}),rectangle:()=>({x:0,y:0,width:0,height:0}),ellipse:()=>({x:0,y:0,rx:0,ry:0}),text:()=>({x:0,y:0,text:"Text"})},createToolStyle=(e,t={},o={position:"relative"})=>{if(!toolShapeDefaults[e])return;return[{...toolShapeDefaults[e](),...t},o]},createToolStyles=e=>({sharpie:createToolStyle("path",{strokeWidth:"0.5%",strokeColor:[...toolColorDefault]}),line:createToolStyle("line",{strokeColor:[...toolColorDefault],strokeWidth:"0.5%"}),arrow:createToolStyle("line",{lineStart:"none",lineEnd:"arrow-solid",strokeColor:[...toolColorDefault],strokeWidth:"0.5%"}),rectangle:createToolStyle("rectangle",{strokeColor:[...toolStrokeColorDefault],backgroundColor:[...toolColorDefault]}),ellipse:createToolStyle("ellipse",{strokeColor:[...toolStrokeColorDefault],backgroundColor:[...toolColorDefault]}),text:createToolStyle("text",{color:[...toolColorDefault],fontSize:"2%"}),...e}),createToolbarItem=(e,t,o)=>[e,t||toLocaleFn(e,"shapeLabelTool"),{icon:toLocaleFn(e,"shapeIconTool"),...o}],createToolbar=(e=["sharpie","eraser","line","arrow","rectangle","ellipse","text","preset"])=>e.map(e=>isString(e)?createToolbarItem(e):Array.isArray(e)?isObject(e[1])?createToolbarItem(e[0],void 0,e[1]):createToolbarItem(e[0],e[1],e[2]):void 0).filter(Boolean),createDefaultColorOptions=()=>({transparent:[1,1,1,0],white:[1,1,1],silver:[.8667,.8667,.8667],gray:[.6667,.6667,.6667],black:[0,0,0],navy:[0,.1216,.2471],blue:[0,.4549,.851],aqua:[.498,.8588,1],teal:[.2235,.8,.8],olive:[.2392,.6,.4392],green:[.1804,.8,.251],yellow:[1,.8627,0],orange:[1,.5216,.1059],red:[1,.2549,.2118],maroon:[.5216,.0784,.2941],fuchsia:[.9412,.0706,.7451],purple:[.6941,.051,.7882]}),createDefaultFontSizeOptions=()=>[16,18,20,24,30,36,48,64,72,96,144],createDefaultFontScaleOptions=()=>({extraSmall:"2%",small:"4%",mediumSmall:"8%",medium:"10%",mediumLarge:"15%",large:"20%",extraLarge:"25%"}),createDefaultStrokeWidthOptions=()=>[1,2,3,4,6,8,12,16,20,24,32,48],createDefaultStrokeScaleOptions=()=>({extraSmall:"0.25%",small:"0.5%",mediumSmall:"1%",medium:"1.75%",mediumLarge:"2.5%",large:"3.5%",extraLarge:"5%"}),createDefaultLineEndStyleOptions=()=>["bar","arrow","arrowSolid","circle","circleSolid","square","squareSolid"],createDefaultFontFamilyOptions=()=>[["Helvetica, Arial, Verdana, 'Droid Sans', sans-serif","Sans Serif"],["'Arial Black', 'Avenir-Black', 'Arial Bold'","Black"],["'Arial Narrow', 'Futura-CondensedMedium'","Narrow"],["'Trebuchet MS'","Humanist"],["Georgia, 'Avenir-Black', 'Times New Roman', 'Droid Serif', serif","Serif"],["Palatino","Old-Style"],["'Times New Roman', 'TimesNewRomanPSMT'","Transitional"],["Menlo, Monaco, 'Lucida Console', monospace","Monospaced"],["'Courier New', monospace","Slab Serif"]],createDefaultTextAlignOptions=()=>["left","center","right"],createDefaultFontStyleOptions=()=>[["normal","bold"],["italic","normal"],["italic","bold"]],createColorOptions=e=>Object.keys(e).map(createLocaleMapper(e,"shapeTitleColor")),createFontSizeOptions=e=>e.map(mapToSizeOption),createFontScaleOptions=e=>Object.keys(e).map(createLocaleMapper(e,"labelSize")),createStrokeWidthOptions=e=>e.map(mapToSizeOption),createStrokeScaleOptions=e=>Object.keys(e).map(createLocaleMapper(e,"labelSize")),createFontFamilyOptions=e=>[...e],createFontStyleOptions=e=>e.map(e=>[e,t=>t[`shapeLabelFontStyle${e.filter(e=>"normal"!==e).map(upperCaseFirstLetter).join("")}`]]),createLineEndStyleOptions=e=>e.map(e=>[toKebabCase(e),t=>t[`shapeTitleLineDecoration${upperCaseFirstLetter(e)}`],{icon:t=>t[`shapeIconLineDecoration${upperCaseFirstLetter(e)}`]}]),createTextAlignOptions=e=>e.map(e=>[e,t=>t[`shapeTitleTextAlign${upperCaseFirstLetter(e)}`],{hideLabel:!0,icon:t=>t[`shapeIconTextAlign${upperCaseFirstLetter(e)}`]}]),createControlOptions=(e,t)=>{const{defaultKey:o,defaultOptions:n}=t||{};let r=[];return o&&(r[0]=[void 0,e=>e[o],{...n}]),[...r,...e]},createFontFamilyControl=e=>[Dropdown,{title:e=>e.shapeTitleFontFamily,optionLabelStyle:e=>`font-family: ${e}`,options:createControlOptions(e,{defaultKey:"labelDefault"}),optionFilter:e=>{if(!isBrowser())return!0;const[t]=e;return!t||t.split(",").map(e=>e.trim()).some(e=>document.fonts.check(`16px ${e}`))}}],createBackgroundColorControl=e=>[ColorPicker,{title:e=>e.shapeTitleBackgroundColor,options:createControlOptions(e)}],createStrokeColorControl=(e,t={})=>[ColorPicker,{title:e=>e.shapeTitleStrokeColor,options:createControlOptions(e),buttonClass:"DokaColorPickerButtonStroke",onchange:(e,o)=>{let n=o.strokeWidth;(isNumber(n)||isString(n)?parseFloat(n):0)>0||(o.strokeWidth=t&&t.defaultStrokeWidth||"0.5%")}}],createStrokeWidthControl=e=>[Dropdown,{title:e=>e.shapeTitleStrokeWidth,options:t=>hasProp(t,"backgroundColor")?createControlOptions(e,{defaultKey:"shapeLabelStrokeNone"}):createControlOptions(e)}],createLineControl=(e,t,o)=>[Dropdown,{title:e=>e[t],options:createControlOptions(e,{defaultKey:"labelNone",defaultOptions:{icon:'<g stroke="currentColor" stroke-linecap="round" stroke-width=".125em"><path d="M5,12 H14"/></g>'}}),optionIconStyle:o}],createLineStartStyleControl=e=>createLineControl(e,"shapeTitleLineStart","transform: scaleX(-1)"),createLineEndStyleControl=e=>createLineControl(e,"shapeTitleLineEnd"),createFontColorControl=e=>[ColorPicker,{title:e=>e.shapeTitleTextColor,options:createControlOptions(e)}],createFontStyleControl=e=>[Dropdown,{title:e=>e.shapeTitleFontStyle,optionLabelStyle:e=>e&&`font-style:${e[0]};font-weight:${e[1]}`,options:createControlOptions(e,{defaultKey:"shapeLabelFontStyleNormal"})}],createFontSizeControl=e=>[Dropdown,{title:e=>e.shapeTitleFontSize,options:createControlOptions(e,{defaultKey:"labelDefault"})}],createTextAlignControl=e=>[RadioGroup,{title:e=>e.shapeTitleTextAlign,options:createControlOptions(e)}],createLineHeightControl=e=>[Dropdown,{title:e=>e.shapeTitleLineHeight,options:createControlOptions(e,{defaultKey:"labelAuto"})}],createShapeStyleControls=(e={})=>{const{colorOptions:t=createColorOptions(createDefaultColorOptions()),strokeWidthOptions:o=createStrokeScaleOptions(createDefaultStrokeScaleOptions()),lineEndStyleOptions:n=createLineEndStyleOptions(createDefaultLineEndStyleOptions()),fontFamilyOptions:r=createFontFamilyOptions(createDefaultFontFamilyOptions()),fontStyleOptions:a=createFontStyleOptions(createDefaultFontStyleOptions()),fontSizeOptions:i=createFontScaleOptions(createDefaultFontScaleOptions()),textAlignOptions:s=createTextAlignOptions(createDefaultTextAlignOptions())}=e;return{backgroundColor:t&&createBackgroundColorControl(t),strokeColor:t&&createStrokeColorControl(t),strokeWidth:o&&createStrokeWidthControl(o),lineStart:n&&createLineStartStyleControl(n),lineEnd:n&&createLineEndStyleControl(n),color:t&&createFontColorControl(t),fontFamily:r&&createFontFamilyControl(r),fontStyle_fontWeight:a&&createFontStyleControl(a),fontSize:i&&createFontSizeControl(i),textAlign:s&&createTextAlignControl(s)}};function create_fragment$n(e){let t,o,n,r;const a=e[3].default,i=create_slot(a,e,e[2],null);return{c(){t=element("div"),i&&i.c(),attr(t,"class",e[0])},m(a,s){insert(a,t,s),i&&i.m(t,null),o=!0,n||(r=[listen(t,"measure",e[1]),action_destroyer(measurable.call(null,t))],n=!0)},p(e,[n]){i&&i.p&&4&n&&update_slot(i,a,e,e[2],n,null,null),(!o||1&n)&&attr(t,"class",e[0])},i(e){o||(transition_in(i,e),o=!0)},o(e){transition_out(i,e),o=!1},d(e){e&&detach(t),i&&i.d(e),n=!1,run_all(r)}}}function instance$n(e,t,o){let{$$slots:n={},$$scope:r}=t;const a=createEventDispatcher();let{class:i=null}=t;return e.$$set=(e=>{"class"in e&&o(0,i=e.class),"$$scope"in e&&o(2,r=e.$$scope)}),[i,({detail:e})=>a("measure",e),r,n]}class Measure extends SvelteComponent{constructor(e){super(),init(this,e,instance$n,create_fragment$n,safe_not_equal,{class:0})}}const get_footer_slot_changes=e=>({}),get_footer_slot_context=e=>({}),get_main_slot_changes=e=>({}),get_main_slot_context=e=>({}),get_header_slot_changes=e=>({}),get_header_slot_context=e=>({});function create_if_block_2$4(e){let t,o;const n=e[4].header,r=create_slot(n,e,e[3],get_header_slot_context);return{c(){t=element("div"),r&&r.c(),attr(t,"class","DokaUtilHeader")},m(e,n){insert(e,t,n),r&&r.m(t,null),o=!0},p(e,t){r&&r.p&&8&t&&update_slot(r,n,e,e[3],t,get_header_slot_changes,get_header_slot_context)},i(e){o||(transition_in(r,e),o=!0)},o(e){transition_out(r,e),o=!1},d(e){e&&detach(t),r&&r.d(e)}}}function fallback_block(e){let t,o;return(t=new Measure({props:{class:"DokaStage"}})).$on("measure",e[5]),{c(){create_component(t.$$.fragment)},m(e,n){mount_component(t,e,n),o=!0},p:noop,i(e){o||(transition_in(t.$$.fragment,e),o=!0)},o(e){transition_out(t.$$.fragment,e),o=!1},d(e){destroy_component(t,e)}}}function create_if_block_1$6(e){let t,o;const n=e[4].footer,r=create_slot(n,e,e[3],get_footer_slot_context);return{c(){t=element("div"),r&&r.c(),attr(t,"class","DokaUtilFooter")},m(e,n){insert(e,t,n),r&&r.m(t,null),o=!0},p(e,t){r&&r.p&&8&t&&update_slot(r,n,e,e[3],t,get_footer_slot_changes,get_footer_slot_context)},i(e){o||(transition_in(r,e),o=!0)},o(e){transition_out(r,e),o=!1},d(e){e&&detach(t),r&&r.d(e)}}}function create_fragment$m(e){let t,o,n,r,a,i,s=e[1]&&create_if_block_2$4(e);const l=e[4].main,c=create_slot(l,e,e[3],get_main_slot_context),p=c||fallback_block(e);let u=e[2]&&create_if_block_1$6(e);return{c(){s&&s.c(),t=space(),o=element("div"),p&&p.c(),n=space(),u&&u.c(),r=space(),a=empty(),attr(o,"class","DokaUtilMain")},m(l,c){s&&s.m(l,c),insert(l,t,c),insert(l,o,c),p&&p.m(o,null),e[6](o),insert(l,n,c),u&&u.m(l,c),insert(l,r,c),insert(l,a,c),i=!0},p(e,[o]){e[1]?s?(s.p(e,o),2&o&&transition_in(s,1)):((s=create_if_block_2$4(e)).c(),transition_in(s,1),s.m(t.parentNode,t)):s&&(group_outros(),transition_out(s,1,1,()=>{s=null}),check_outros()),c&&c.p&&8&o&&update_slot(c,l,e,e[3],o,get_main_slot_changes,get_main_slot_context),e[2]?u?(u.p(e,o),4&o&&transition_in(u,1)):((u=create_if_block_1$6(e)).c(),transition_in(u,1),u.m(r.parentNode,r)):u&&(group_outros(),transition_out(u,1,1,()=>{u=null}),check_outros())},i(e){i||(transition_in(s),transition_in(p,e),transition_in(u),transition_in(!1),i=!0)},o(e){transition_out(s),transition_out(p,e),transition_out(u),transition_out(!1),i=!1},d(i){s&&s.d(i),i&&detach(t),i&&detach(o),p&&p.d(i),e[6](null),i&&detach(n),u&&u.d(i),i&&detach(r),i&&detach(a)}}}function instance$m(e,t,o){let{$$slots:n={},$$scope:r}=t,{hasHeader:a=!!t.$$slots.header}=t,{hasFooter:i=!!t.$$slots.footer}=t,{root:s}=t;return e.$$set=(e=>{o(7,t=assign(assign({},t),exclude_internal_props(e))),"hasHeader"in e&&o(1,a=e.hasHeader),"hasFooter"in e&&o(2,i=e.hasFooter),"root"in e&&o(0,s=e.root),"$$scope"in e&&o(3,r=e.$$scope)}),t=exclude_internal_props(t),[s,a,i,r,n,function(t){bubble(e,t)},function(e){binding_callbacks[e?"unshift":"push"](()=>{o(0,s=e)})}]}class Util extends SvelteComponent{constructor(e){super(),init(this,e,instance$m,create_fragment$m,safe_not_equal,{hasHeader:1,hasFooter:2,root:0})}}var toFraction=(e,t,o)=>(e-t)/(o-t);function create_if_block$6(e){let t,o;return{c(){attr(t=element("div"),"class","DokaRangeInputMeter"),attr(t,"style",o=`transform: translateX(${e[9].x-e[10].x}px) translateY(${e[9].y-e[10].y}px)`)},m(o,n){insert(o,t,n),t.innerHTML=e[7]},p(e,n){128&n[0]&&(t.innerHTML=e[7]),512&n[0]&&o!==(o=`transform: translateX(${e[9].x-e[10].x}px) translateY(${e[9].y-e[10].y}px)`)&&attr(t,"style",o)},d(e){e&&detach(t)}}}function create_fragment$l(e){let t,o,n,r,a,i,s,l,c,p,u,d,h=e[9]&&create_if_block$6(e);return{c(){t=element("div"),o=element("span"),n=text(e[4]),r=space(),a=element("button"),i=text(e[1]),l=space(),c=element("div"),h&&h.c(),attr(o,"class","DokaRangeInputValue"),attr(a,"class","DokaRangeInputReset"),attr(a,"type","button"),a.disabled=s=e[0]===e[3],attr(c,"class","DokaRangeInputInner"),attr(c,"style",e[8]),attr(c,"data-value-limited",e[6]),attr(t,"class","DokaRangeInput"),attr(t,"tabindex","0")},m(s,m){insert(s,t,m),append(t,o),append(o,n),append(t,r),append(t,a),append(a,i),append(t,l),append(t,c),h&&h.m(c,null),u||(d=[listen(a,"click",e[15]),listen(c,"interactionstart",e[11]),listen(c,"interactionupdate",e[13]),listen(c,"interactionend",e[14]),listen(c,"interactionrelease",e[12]),action_destroyer(interactable.call(null,c,{inertia:!0})),listen(c,"measure",e[32]),action_destroyer(measurable.call(null,c)),listen(t,"wheel",e[17],{passive:!1}),listen(t,"nudge",e[18]),action_destroyer(p=nudgeable.call(null,t,e[2]="horizontal"))],u=!0)},p(e,t){16&t[0]&&set_data(n,e[4]),2&t[0]&&set_data(i,e[1]),9&t[0]&&s!==(s=e[0]===e[3])&&(a.disabled=s),e[9]?h?h.p(e,t):((h=create_if_block$6(e)).c(),h.m(c,null)):h&&(h.d(1),h=null),256&t[0]&&attr(c,"style",e[8]),64&t[0]&&attr(c,"data-value-limited",e[6]),p&&is_function(p.update)&&4&t[0]&&p.update.call(null,e[2]="horizontal")},i:noop,o:noop,d(e){e&&detach(t),h&&h.d(),u=!1,run_all(d)}}}const radiusBig=2,radiusSmall=.75,indicatorSpacing=10,indicatorInterval=5,indicatorCount=40;function instance$l(e,t,o){let n,r,a,i,s,l,c,p,{labelReset:u="Reset"}=t,{direction:d="x"}=t,{min:h=0}=t,{max:m=1}=t,{base:g=h}=t,{value:f=0}=t,{valueLabel:_=0}=t,{valueMin:$}=t,{valueMax:b}=t,{oninputstart:y=noop$1}=t,{oninputmove:x=noop$1}=t,{oninputend:v=noop$1}=t,{elasticity:C=0}=t;const S=(e,t,o)=>Math.ceil((e-o)/t)*t+o;let k,w,R;const T={x:2,y:0},E=(e,t,o)=>`M ${e-o} ${t} a ${o} ${o} 0 1 0 0 -1`;let I,A=void 0,M=!1,P={snap:!1,elastic:!1};const D=(e,t,o)=>{const n=e[d]+t[d],r=clamp(n,I[1][d],I[0][d]),a=C?r+elastify(n-r,C):r,i=o.elastic?a:r,s=vectorCreate(0,0);return s[d]=i,F.set(s,{hard:o.snap}),clamp(z(s,d),h,m)},F=spring();component_subscribe(e,F,e=>o(9,p=e));const L=(e,t)=>{const o=.5*(k[t]-i[t])-(toFraction(e,h,m)*i[t]-.5*i[t]);return{x:"x"===t?o:0,y:"y"===t?o:0}},z=(e,t)=>{const o=-(e[t]-.5*k[t])/i[t];return h+o*n};F.subscribe(e=>{e&&A&&x(clamp(z(e,d),h,m))});const B=e=>{const t=[L(null!=$?$:h,d),L(null!=b?b:m,d)],o={x:"x"===d?p.x+e:0,y:"y"===d?p.y+e:0},n=clamp(o[d],t[1][d],t[0][d]),r={...p,[d]:n};set_store_value(F,p=r,p);const a=clamp(z(r,d),h,m);y(),x(a),v(a)};return e.$$set=(e=>{"labelReset"in e&&o(1,u=e.labelReset),"direction"in e&&o(2,d=e.direction),"min"in e&&o(19,h=e.min),"max"in e&&o(20,m=e.max),"base"in e&&o(3,g=e.base),"value"in e&&o(0,f=e.value),"valueLabel"in e&&o(4,_=e.valueLabel),"valueMin"in e&&o(21,$=e.valueMin),"valueMax"in e&&o(22,b=e.valueMax),"oninputstart"in e&&o(23,y=e.oninputstart),"oninputmove"in e&&o(24,x=e.oninputmove),"oninputend"in e&&o(25,v=e.oninputend),"elasticity"in e&&o(26,C=e.elasticity)}),e.$$.update=(()=>{if(1572864&e.$$.dirty[0]&&o(28,n=m-h),2621440&e.$$.dirty[0]&&o(29,r=null!=$?Math.max($,h):h),5242880&e.$$.dirty[0]&&o(30,a=null!=b?Math.min(b,m):m),1572872&e.$$.dirty[0]&&o(31,s=toFraction(g,h,m)),32&e.$$.dirty[0]|1&e.$$.dirty[1]&&k){const e=.5*k.y;let t,n=indicatorCount*s,r="",a=k.y,i="";for(let o=0;o<=indicatorCount;o++){const a=T.x+o*indicatorSpacing,s=e;r+=E(a,s,o%indicatorInterval==0?radiusBig:radiusSmall)+" ",t=a+T.x,o===n&&(i=`<path d="M${a} ${s-4} l2 3 l-2 -1 l-2 1 z"/>`)}o(7,w=`<svg width="${t}" height="${a}" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${t} ${a}" aria-hidden="true" focusable="false">\n        ${i}\n        <rect rx="4" ry="4" y="${e-4}"" height="8"/>\n        <path fill-rule="evenodd" d="${r.trim()}"/></svg>`),o(27,R={x:t-2*T.x,y:a})}134217760&e.$$.dirty[0]&&(i=k&&R),1612185600&e.$$.dirty[0]&&o(6,l=r!==h||a!==m),1610612800&e.$$.dirty[0]&&o(8,c=l?function(e,t){const o=1/indicatorCount,n=toFraction(e,h,m),r=toFraction(t,h,m);return`--range-mask-from:${100*fixPrecision(S(n,o,0)-.5*o)}%;--range-mask-to:${100*fixPrecision(S(r,o,0)-.5*o)}%`}(r,a):""),268435493&e.$$.dirty[0]&&n&&k&&k.x&&k.y&&F.set(L(f,d))}),[f,u,d,g,_,k,l,w,c,p,T,()=>{M=!1,A=get_store_value(F),I=[L(null!=$?$:h,d),L(null!=b?b:m,d)],y()},()=>{M=!0},({detail:e})=>{P.snap=!M,P.elastic=!M,D(A,e.translation,P)},({detail:e})=>{P.snap=!1,P.elastic=!1;const t=D(A,e.translation,P);if(A=void 0,I=void 0,Math.abs(t-g)<.01)return v(g);v(t)},()=>{o(0,f=clamp(g,r,a)),y(),v(f)},F,e=>{e.preventDefault(),e.stopPropagation();const t=8*getWheelDelta(e);B(t)},({detail:e})=>{B(8*e[d])},h,m,$,b,y,x,v,C,R,n,r,a,s,e=>o(5,k=vectorCreateFromSize(e.detail))]}class RangeInput extends SvelteComponent{constructor(e){super(),init(this,e,instance$l,create_fragment$l,safe_not_equal,{labelReset:1,direction:2,min:19,max:20,base:3,value:0,valueLabel:4,valueMin:21,valueMax:22,oninputstart:23,oninputmove:24,oninputend:25,elasticity:26},[-1,-1])}}function create_fragment$k(e){let t,o,n,r,a;const i=e[7].default,s=create_slot(i,e,e[6],null);return{c(){t=element("div"),o=element("div"),s&&s.c(),attr(o,"class","DokaToolbarInner"),attr(t,"class","DokaToolbar"),attr(t,"data-layout",e[1]),attr(t,"data-overflow",e[0])},m(i,l){insert(i,t,l),append(t,o),s&&s.m(o,null),n=!0,r||(a=[listen(o,"measure",e[3]),action_destroyer(measurable.call(null,o)),listen(t,"measure",e[2]),action_destroyer(measurable.call(null,t))],r=!0)},p(e,[o]){s&&s.p&&64&o&&update_slot(s,i,e,e[6],o,null,null),(!n||2&o)&&attr(t,"data-layout",e[1]),(!n||1&o)&&attr(t,"data-overflow",e[0])},i(e){n||(transition_in(s,e),n=!0)},o(e){transition_out(s,e),n=!1},d(e){e&&detach(t),s&&s.d(e),r=!1,run_all(a)}}}function instance$k(e,t,o){let n,r,{$$slots:a={},$$scope:i}=t,s=0,l=0,c=0;const p=()=>{o(0,r="compact"===n&&s>c?"overflow":void 0)};return e.$$set=(e=>{"$$scope"in e&&o(6,i=e.$$scope)}),e.$$.update=(()=>{48&e.$$.dirty&&o(1,n=l>c?"compact":"default")}),[r,n,({detail:e})=>{const{width:t,height:n}=e;o(5,c=t),p()},({detail:e})=>{const{width:t,height:n}=e;t>l&&o(4,l=t),s=t,r||p()},l,c,i,a]}class Toolbar extends SvelteComponent{constructor(e){super(),init(this,e,instance$k,create_fragment$k,safe_not_equal,{})}}const Direction={Top:"t",Right:"r",Bottom:"b",Left:"l",TopLeft:"tl",TopRight:"tr",BottomRight:"br",BottomLeft:"bl"},{Top:Top,Right:Right,Bottom:Bottom,Left:Left,TopLeft:TopLeft,TopRight:TopRight,BottomRight:BottomRight,BottomLeft:BottomLeft}=Direction;var DirectionRectMap={[Top]:e=>({x:e.x,y:e.y}),[TopRight]:e=>({x:e.x+e.width,y:e.y}),[Right]:e=>({x:e.x+e.width,y:e.y}),[BottomRight]:e=>({x:e.x+e.width,y:e.y+e.height}),[Bottom]:e=>({x:e.x,y:e.y+e.height}),[BottomLeft]:e=>({x:e.x,y:e.y+e.height}),[Left]:e=>({x:e.x,y:e.y}),[TopLeft]:e=>({x:e.x,y:e.y})};function get_each_context$5(e,t,o){const n=e.slice();return n[11]=t[o].key,n[12]=t[o].translate,n[13]=t[o].scale,n[14]=t[o].type,n[15]=t[o].opacity,n}function create_each_block$5(e,t){let o,n,r,a,i,s,l,c;return{key:e,first:null,c(){attr(o=element("div"),"role","button"),attr(o,"aria-label",n=`Drag ${t[14]} ${t[11]}`),attr(o,"tabindex",r="edge"===t[14]?-1:0),attr(o,"class","DokaRectManipulator"),attr(o,"data-direction",a=t[11]),attr(o,"data-shape",i=`${"edge"===t[14]?"edge":`${t[0]}`}`),attr(o,"style",s=`transform: translate3d(${t[12].x}px, ${t[12].y}px, 0) scale(${t[13].x}, ${t[13].y}); opacity: ${t[15]}`),this.first=o},m(e,n){insert(e,o,n),l||(c=[listen(o,"nudge",function(){is_function(t[5](t[11]))&&t[5](t[11]).apply(this,arguments)}),action_destroyer(nudgeable.call(null,o)),listen(o,"interactionstart",function(){is_function(t[4]("resizestart",t[11]))&&t[4]("resizestart",t[11]).apply(this,arguments)}),listen(o,"interactionupdate",function(){is_function(t[4]("resizemove",t[11]))&&t[4]("resizemove",t[11]).apply(this,arguments)}),listen(o,"interactionend",function(){is_function(t[4]("resizeend",t[11]))&&t[4]("resizeend",t[11]).apply(this,arguments)}),action_destroyer(interactable.call(null,o))],l=!0)},p(e,l){t=e,2&l&&n!==(n=`Drag ${t[14]} ${t[11]}`)&&attr(o,"aria-label",n),2&l&&r!==(r="edge"===t[14]?-1:0)&&attr(o,"tabindex",r),2&l&&a!==(a=t[11])&&attr(o,"data-direction",a),3&l&&i!==(i=`${"edge"===t[14]?"edge":`${t[0]}`}`)&&attr(o,"data-shape",i),2&l&&s!==(s=`transform: translate3d(${t[12].x}px, ${t[12].y}px, 0) scale(${t[13].x}, ${t[13].y}); opacity: ${t[15]}`)&&attr(o,"style",s)},d(e){e&&detach(o),l=!1,run_all(c)}}}function create_fragment$j(e){let t,o=[],n=new Map,r=e[1];const a=e=>e[11];for(let t=0;t<r.length;t+=1){let i=get_each_context$5(e,r,t),s=a(i);n.set(s,o[t]=create_each_block$5(s,i))}return{c(){for(let e=0;e<o.length;e+=1)o[e].c();t=empty()},m(e,n){for(let t=0;t<o.length;t+=1)o[t].m(e,n);insert(e,t,n)},p(e,[i]){51&i&&(r=e[1],o=update_keyed_each(o,i,a,1,e,r,n,t.parentNode,destroy_block,create_each_block$5,t,get_each_context$5))},i:noop,o:noop,d(e){for(let t=0;t<o.length;t+=1)o[t].d(e);e&&detach(t)}}}function instance$j(e,t,o){let n,r,a,{rect:i=null}=t,{visible:s=!1}=t,{style:l}=t;const c=spring(void 0,{precision:1e-4,stiffness:.2,damping:.4});component_subscribe(e,c,e=>o(8,r=e));const p=spring(0,{precision:.001});component_subscribe(e,p,e=>o(9,a=e));const u=createEventDispatcher();return e.$$set=(e=>{"rect"in e&&o(6,i=e.rect),"visible"in e&&o(7,s=e.visible),"style"in e&&o(0,l=e.style)}),e.$$.update=(()=>{128&e.$$.dirty&&c.set(s?1:.5),128&e.$$.dirty&&p.set(s?1:0),832&e.$$.dirty&&o(1,n=Object.keys(Direction).map((e,t)=>{const o=Direction[e],n=DirectionRectMap[o](i),s=1===o.length?"edge":"corner",l="corner"===s;return{key:o,type:s,scale:{x:/^(t|b)$/.test(o)?i.width:l?clamp(r,.5,1.25):1,y:/^(r|l)$/.test(o)?i.height:l?clamp(r,.5,1.25):1},translate:{x:n.x,y:n.y},opacity:a}}))}),[l,n,c,p,(e,t)=>({detail:o})=>u(e,{direction:t,translation:o&&o.translation}),e=>({detail:t})=>{u("resizestart",{direction:e,translation:{x:0,y:0}}),u("resizemove",{direction:e,translation:t}),u("resizeend",{direction:e,translation:{x:0,y:0}})},i,s,r,a]}class RectManipulator extends SvelteComponent{constructor(e){super(),init(this,e,instance$j,create_fragment$j,safe_not_equal,{rect:6,visible:7,style:0})}}var gesturable=e=>{function t(t,o){e.dispatchEvent(new CustomEvent(t,{detail:o}))}const o=o=>{o.preventDefault(),e.addEventListener("gesturechange",n),e.addEventListener("gestureend",r),t("gesturedown")},n=e=>{e.preventDefault(),t("gestureupdate",e.scale)},r=e=>{t("gestureup",e.scale),e.preventDefault(),a()},a=()=>{e.removeEventListener("gesturechange",n),e.removeEventListener("gestureend",r)};return e.addEventListener("gesturestart",o),{destroy:()=>{a(),e.removeEventListener("gesturestart",o)}}},getEventPositionInViewport=e=>vectorCreate(e.clientX,e.clientY),getEventPositionInStage=(e,t,o)=>{const n=getEventPositionInViewport(e);return vectorSubtract(vectorSubtract(n,t),o)},DirectionInversionTable={[Top]:Bottom,[Right]:Left,[Bottom]:Top,[Left]:Right,[TopLeft]:BottomRight,[TopRight]:BottomLeft,[BottomRight]:TopLeft,[BottomLeft]:TopRight},DirectionCoordinateTable={[Top]:[.5,0],[Right]:[1,.5],[Bottom]:[.5,1],[Left]:[0,.5],[TopLeft]:[0,0],[TopRight]:[1,0],[BottomRight]:[1,1],[BottomLeft]:[0,1]},getTranslationInfo=e=>{const t=e===Left||e===Right,o=e===Top||e===Bottom;return[e===Right||e===TopRight||e===BottomRight,e===Left||e===BottomLeft||e===TopLeft,e===Top||e===TopRight||e===TopLeft,e===Bottom||e===BottomRight||e===BottomLeft,t,o,t||o]},limitRectDirectionTranslation=(e,t,o,n={})=>{const{target:r,translate:a}=t,{aspectRatio:i,minSize:s,maxSize:l}=n,c=DirectionInversionTable[r],p=DirectionCoordinateTable[c],u=vectorAdd(vectorCreate(e.x,e.y),vectorCreate(p[0]*e.width,p[1]*e.height)),d=DirectionCoordinateTable[r],h=vectorAdd(rectClone(e),vectorCreate(d[0]*e.width,d[1]*e.height)),[m,g,f,_,$,b,y]=getTranslationInfo(r);let x=a.x,v=a.y;$?v=0:b&&(x=0);const C=getInteractionBounds(u,r,o,{aspectRatio:i,minSize:s,maxSize:l});let[S,k,w,R]=rectToBounds(e);if(m?R=u.x:g&&(k=u.x),_?S=u.y:f&&(w=u.y),m){const e=C.inner.x+C.inner.width,t=C.outer.x+C.outer.width;k=clamp(h.x+x,e,t)}else if(g){const e=C.outer.x,t=C.inner.x;R=clamp(h.x+x,e,t)}if(_){const e=C.inner.y+C.inner.height,t=C.outer.y+C.outer.height;w=clamp(h.y+v,e,t)}else if(f){const e=C.outer.y,t=C.inner.y;S=clamp(h.y+v,e,t)}if(i)if(y){let e=k-R,t=w-S;$?(t=e/i,S=u.y-.5*t,w=u.y+.5*t):b&&(e=t*i,R=u.x-.5*e,k=u.x+.5*e)}else{const e=vectorCreate(h.x+x-u.x,h.y+v-u.y);r===TopRight?(e.x=Math.max(0,e.x),e.y=Math.min(0,e.y)):r===BottomRight?(e.x=Math.max(0,e.x),e.y=Math.max(0,e.y)):r===BottomLeft?(e.x=Math.min(0,e.x),e.y=Math.max(0,e.y)):r===TopLeft&&(e.x=Math.min(0,e.x),e.y=Math.min(0,e.y));const t=vectorLength(e),o=vectorLength(vectorCreate(C.inner.width,C.inner.height)),n=vectorLength(vectorCreate(C.outer.width,C.outer.height)),a=clamp(t,o,n),s=vectorCreate(i,1),l=vectorMultiply(vectorNormalize(s),a);r===TopRight?(k=u.x+l.x,S=u.y-l.y):r===BottomRight?(k=u.x+l.x,w=u.y+l.y):r===BottomLeft?(R=u.x-l.x,w=u.y+l.y):r===TopLeft&&(R=u.x-l.x,S=u.y-l.y)}return rectCreate(R,S,k-R,w-S)};const getInteractionBounds=(e,t,o,n)=>{const{aspectRatio:r,minSize:a,maxSize:i}=n,s=t===Right||t===TopRight||t===BottomRight,l=t===Left||t===BottomLeft||t===TopLeft,c=t===Top||t===TopRight||t===TopLeft,p=t===Bottom||t===BottomRight||t===BottomLeft,u=t===Left||t===Right,d=t===Top||t===Bottom,h=rectClone(o);s?(h.x=e.x,h.width-=e.x):l&&(h.width=e.x),p?(h.y=e.y,h.height-=e.y):c&&(h.height=e.y);const m=rectCreateFromDimensions(Math.min(h.width,i.width),Math.min(h.height,i.height));if(r)if(u){const t=Math.min(e.y,o.height-e.y);m.height=Math.min(2*t,m.height)}else if(d){const t=Math.min(e.x,o.width-e.x);m.width=Math.min(2*t,m.width)}const g=r?sizeCreateFromRect(rectContainRect(m,r)):m,f=r?sizeCreateFromRect(rectCoverRect(rectCreateFromSize(a),r)):a;let _,$,b,y;s?_=e.x:l&&($=e.x),p?b=e.y:c&&(y=e.y),s?$=_+f.width:l&&(_=$-f.width),p?y=b+f.height:c&&(b=y-f.height),u?(b=e.y-.5*f.height,y=e.y+.5*f.height):d&&(_=e.x-.5*f.width,$=e.x+.5*f.width);const x=rectCreateFromPoints(vectorCreate(_,b),vectorCreate($,y));return s?$=_+g.width:l&&(_=$-g.width),p?y=b+g.height:c&&(b=y-g.height),u?(b=e.y-.5*g.height,y=e.y+.5*g.height):d&&(_=e.x-.5*g.width,$=e.x+.5*g.width),{inner:x,outer:rectCreateFromPoints(vectorCreate(_,b),vectorCreate($,y))}};var applyRectDirectionTranslation=(e,t,o={})=>{const{target:n,translate:r}=t,{aspectRatio:a}=o,i=DirectionInversionTable[n],s=DirectionCoordinateTable[i],l=vectorAdd(rectClone(e),vectorCreate(s[0]*e.width,s[1]*e.height)),c=DirectionCoordinateTable[n],p=vectorAdd(rectClone(e),vectorCreate(c[0]*e.width,c[1]*e.height)),[u,d,h,m,g,f,_]=getTranslationInfo(n);let $=r.x,b=r.y;g?b=0:f&&($=0);let[y,x,v,C]=rectToBounds(e);if(u?C=l.x:d&&(x=l.x),m?y=l.y:h&&(v=l.y),u?x=p.x+$:d&&(C=p.x+$),m?v=p.y+b:h&&(y=p.y+b),a)if(_){let e=x-C,t=v-y;g?(t=e/a,y=l.y-.5*t,v=l.y+.5*t):f&&(e=t*a,C=l.x-.5*e,x=l.x+.5*e)}else{const e=vectorCreate(p.x+$-l.x,p.y+b-l.y);n===TopRight?(e.x=Math.max(0,e.x),e.y=Math.min(0,e.y)):n===BottomRight?(e.x=Math.max(0,e.x),e.y=Math.max(0,e.y)):n===BottomLeft?(e.x=Math.min(0,e.x),e.y=Math.max(0,e.y)):n===TopLeft&&(e.x=Math.min(0,e.x),e.y=Math.min(0,e.y));const t=vectorLength(e),o=vectorCreate(a,1),r=vectorMultiply(vectorNormalize(o),t);n===TopRight?(x=l.x+r.x,y=l.y-r.y):n===BottomRight?(x=l.x+r.x,v=l.y+r.y):n===BottomLeft?(C=l.x-r.x,v=l.y+r.y):n===TopLeft&&(C=l.x-r.x,y=l.y-r.y)}return rectCreate(C,y,x-C,v-y)},radToDeg=e=>180*e/Math.PI;function create_fragment$i(e){let t,o,n;return o=new RangeInput({props:{elasticity:e[5],min:e[7],max:e[8],value:e[12],valueMin:e[0],valueMax:e[1],labelReset:e[6],base:e[11],valueLabel:`${Math.round(radToDeg(e[12]))}°`,oninputstart:e[2],oninputmove:e[14],oninputend:e[15]}}),{c(){t=element("div"),create_component(o.$$.fragment),attr(t,"class","DokaImageRotator")},m(e,r){insert(e,t,r),mount_component(o,t,null),n=!0},p(e,[t]){const n={};32&t&&(n.elasticity=e[5]),128&t&&(n.min=e[7]),256&t&&(n.max=e[8]),4096&t&&(n.value=e[12]),1&t&&(n.valueMin=e[0]),2&t&&(n.valueMax=e[1]),64&t&&(n.labelReset=e[6]),2048&t&&(n.base=e[11]),4096&t&&(n.valueLabel=`${Math.round(radToDeg(e[12]))}°`),4&t&&(n.oninputstart=e[2]),1544&t&&(n.oninputmove=e[14]),1552&t&&(n.oninputend=e[15]),o.$set(n)},i(e){n||(transition_in(o.$$.fragment,e),n=!0)},o(e){transition_out(o.$$.fragment,e),n=!1},d(e){e&&detach(t),destroy_component(o)}}}const MARGIN=1e-9;function instance$i(e,t,o){let n,r,a,i,s,l;const c=Math.PI/2,p=Math.PI/4;let{rotation:u}=t,{valueMin:d}=t,{valueMax:h}=t,{oninputstart:m=noop$1}=t,{oninputmove:g=noop$1}=t,{oninputend:f=noop$1}=t,{elasticity:_=0}=t,{labelReset:$}=t;return e.$$set=(e=>{"rotation"in e&&o(13,u=e.rotation),"valueMin"in e&&o(0,d=e.valueMin),"valueMax"in e&&o(1,h=e.valueMax),"oninputstart"in e&&o(2,m=e.oninputstart),"oninputmove"in e&&o(3,g=e.oninputmove),"oninputend"in e&&o(4,f=e.oninputend),"elasticity"in e&&o(5,_=e.elasticity),"labelReset"in e&&o(6,$=e.labelReset)}),e.$$.update=(()=>{384&e.$$.dirty&&o(11,a=n+.5*(r-n)),8192&e.$$.dirty&&o(9,i=Math.sign(u)),8192&e.$$.dirty&&o(10,s=Math.round(Math.abs(u)/c)*c),9728&e.$$.dirty&&o(12,l=u-i*s)}),o(7,n=-p+MARGIN),o(8,r=p-MARGIN),[d,h,m,g,f,_,$,n,r,i,s,a,l,u,e=>g(i*s+e),e=>f(i*s+e)]}class ImageRotator extends SvelteComponent{constructor(e){super(),init(this,e,instance$i,create_fragment$i,safe_not_equal,{rotation:13,valueMin:0,valueMax:1,oninputstart:2,oninputmove:3,oninputend:4,elasticity:5,labelReset:6})}}function create_fragment$h(e){let t,o,n,r,a;return{c(){t=element("div"),o=element("p"),n=text(e[0]),r=text(" × "),a=text(e[1]),attr(t,"class","DokaImageInfo")},m(e,i){insert(e,t,i),append(t,o),append(o,n),append(o,r),append(o,a)},p(e,[t]){1&t&&set_data(n,e[0]),2&t&&set_data(a,e[1])},i:noop,o:noop,d(e){e&&detach(t)}}}function instance$h(e,t,o){let{width:n}=t,{height:r}=t;return e.$$set=(e=>{"width"in e&&o(0,n=e.width),"height"in e&&o(1,r=e.height)}),[n,r]}class ImageInfo extends SvelteComponent{constructor(e){super(),init(this,e,instance$h,create_fragment$h,safe_not_equal,{width:0,height:1})}}var getSelectionPresetOptionIcon=(e,t={})=>{const{width:o=24,height:n=24,bounds:r=16,radius:a=3}=t;let i,s,l,c,p=isArray(e)?getAspectRatio(e[0],e[1]):e,u=!!p;return c=(l=(p=u?p:1)>1?r:p*r)/p,i=Math.round(.5*(o-l)),s=Math.round(.5*(n-c)),`<rect fill="${u?"currentColor":"none"}" stroke="${u?"none":"currentColor"}" stroke-width="${o/16}" stroke-dasharray="${[o/12,o/6].join(" ")}" x="${i}" y="${s}" width="${l}" height="${c}" rx="${a}"/>`};function create_default_slot_2$2(e){let t,o;return t=new DynamicComponentTree_1({props:{items:e[0]}}),{c(){create_component(t.$$.fragment)},m(e,n){mount_component(t,e,n),o=!0},p(e,o){const n={};1&o[0]&&(n.items=e[0]),t.$set(n)},i(e){o||(transition_in(t.$$.fragment,e),o=!0)},o(e){transition_out(t.$$.fragment,e),o=!1},d(e){destroy_component(t,e)}}}function create_header_slot(e){let t,o,n;return o=new Toolbar({props:{$$slots:{default:[create_default_slot_2$2]},$$scope:{ctx:e}}}),{c(){t=element("div"),create_component(o.$$.fragment),attr(t,"slot","header")},m(e,r){insert(e,t,r),mount_component(o,t,null),n=!0},p(e,t){const n={};1&t[0]|1&t[6]&&(n.$$scope={dirty:t,ctx:e}),o.$set(n)},i(e){n||(transition_in(o.$$.fragment,e),n=!0)},o(e){transition_out(o.$$.fragment,e),n=!1},d(e){e&&detach(t),destroy_component(o)}}}function create_if_block_5$1(e){let t,o;return t=new Button({props:{onclick:e[79],label:e[4].cropLabelButtonRecenter,icon:e[4].cropIconButtonRecenter,class:"DokaButtonCenter",disabled:!e[9],hideLabel:!0,style:`opacity: ${e[27]}; transform: translate3d(${e[28].x}px, ${e[28].y}px, 0)`}}),{c(){create_component(t.$$.fragment)},m(e,n){mount_component(t,e,n),o=!0},p(e,o){const n={};16&o[0]&&(n.label=e[4].cropLabelButtonRecenter),16&o[0]&&(n.icon=e[4].cropIconButtonRecenter),512&o[0]&&(n.disabled=!e[9]),402653184&o[0]&&(n.style=`opacity: ${e[27]}; transform: translate3d(${e[28].x}px, ${e[28].y}px, 0)`),t.$set(n)},i(e){o||(transition_in(t.$$.fragment,e),o=!0)},o(e){transition_out(t.$$.fragment,e),o=!1},d(e){destroy_component(t,e)}}}function create_if_block_4$2(e){let t,o;return(t=new RectManipulator({props:{rect:e[10],visible:e[11],style:e[2]}})).$on("resizestart",e[59]),t.$on("resizemove",e[60]),t.$on("resizeend",e[61]),{c(){create_component(t.$$.fragment)},m(e,n){mount_component(t,e,n),o=!0},p(e,o){const n={};1024&o[0]&&(n.rect=e[10]),2048&o[0]&&(n.visible=e[11]),4&o[0]&&(n.style=e[2]),t.$set(n)},i(e){o||(transition_in(t.$$.fragment,e),o=!0)},o(e){transition_out(t.$$.fragment,e),o=!1},d(e){destroy_component(t,e)}}}function create_if_block_3$2(e){let t,o;return t=new ImageInfo({props:{width:Math.round(e[7].width),height:Math.round(e[7].height)}}),{c(){create_component(t.$$.fragment)},m(e,n){mount_component(t,e,n),o=!0},p(e,o){const n={};128&o[0]&&(n.width=Math.round(e[7].width)),128&o[0]&&(n.height=Math.round(e[7].height)),t.$set(n)},i(e){o||(transition_in(t.$$.fragment,e),o=!0)},o(e){transition_out(t.$$.fragment,e),o=!1},d(e){destroy_component(t,e)}}}function create_main_slot$1(e){let t,o,n,r,a,i,s,l,c=e[17]&&e[18]&&create_if_block_5$1(e),p=e[17]&&create_if_block_4$2(e),u=e[16]&&create_if_block_3$2(e);return{c(){t=element("div"),o=element("div"),c&&c.c(),n=space(),p&&p.c(),a=space(),u&&u.c(),attr(o,"class","DokaStage"),attr(t,"slot","main")},m(d,h){insert(d,t,h),append(t,o),c&&c.m(o,null),append(o,n),p&&p.m(o,null),e[139](o),append(t,a),u&&u.m(t,null),i=!0,s||(l=[listen(o,"measure",e[137]),action_destroyer(measurable.call(null,o)),listen(o,"wheel",function(){is_function(e[3]&&e[78])&&(e[3]&&e[78]).apply(this,arguments)},{passive:!1}),listen(o,"interactionstart",e[65]),listen(o,"interactionupdate",e[66]),listen(o,"interactionrelease",e[68]),listen(o,"interactionend",e[67]),action_destroyer(r=interactable.call(null,o,{drag:!0,pinch:e[3],inertia:!0,matchTarget:!0,getEventPosition:e[140]})),listen(o,"gesturedown",e[75]),listen(o,"gestureupdate",e[76]),listen(o,"gestureup",e[77]),action_destroyer(gesturable.call(null,o))],s=!0)},p(a,i){(e=a)[17]&&e[18]?c?(c.p(e,i),393216&i[0]&&transition_in(c,1)):((c=create_if_block_5$1(e)).c(),transition_in(c,1),c.m(o,n)):c&&(group_outros(),transition_out(c,1,1,()=>{c=null}),check_outros()),e[17]?p?(p.p(e,i),131072&i[0]&&transition_in(p,1)):((p=create_if_block_4$2(e)).c(),transition_in(p,1),p.m(o,null)):p&&(group_outros(),transition_out(p,1,1,()=>{p=null}),check_outros()),r&&is_function(r.update)&&32776&i[0]&&r.update.call(null,{drag:!0,pinch:e[3],inertia:!0,matchTarget:!0,getEventPosition:e[140]}),e[16]?u?(u.p(e,i),65536&i[0]&&transition_in(u,1)):((u=create_if_block_3$2(e)).c(),transition_in(u,1),u.m(t,null)):u&&(group_outros(),transition_out(u,1,1,()=>{u=null}),check_outros())},i(e){i||(transition_in(c),transition_in(p),transition_in(u),i=!0)},o(e){transition_out(c),transition_out(p),transition_out(u),i=!1},d(o){o&&detach(t),c&&c.d(),p&&p.d(),e[139](null),u&&u.d(),s=!1,run_all(l)}}}function create_if_block$5(e){let t,o,n,r;const a=[{class:"DokaControlList"},{tabs:e[12]},e[21]];let i={$$slots:{default:[create_default_slot_1$4,({tab:e})=>({185:e}),({tab:e})=>[0,0,0,0,0,e?1073741824:0]]},$$scope:{ctx:e}};for(let e=0;e<a.length;e+=1)i=assign(i,a[e]);(t=new TabList({props:i})).$on("select",e[138]);const s=[{class:"DokaControlPanels"},{panelClass:"DokaControlPanel"},{panels:e[22]},e[21]];let l={$$slots:{default:[create_default_slot$8,({panel:e})=>({184:e}),({panel:e})=>[0,0,0,0,0,e?536870912:0]]},$$scope:{ctx:e}};for(let e=0;e<s.length;e+=1)l=assign(l,s[e]);return n=new TabPanels({props:l}),{c(){create_component(t.$$.fragment),o=space(),create_component(n.$$.fragment)},m(e,a){mount_component(t,e,a),insert(e,o,a),mount_component(n,e,a),r=!0},p(e,o){const r=2101248&o[0]?get_spread_update(a,[a[0],4096&o[0]&&{tabs:e[12]},2097152&o[0]&&get_spread_object(e[21])]):{};1073741824&o[5]|1&o[6]&&(r.$$scope={dirty:o,ctx:e}),t.$set(r);const i=6291456&o[0]?get_spread_update(s,[s[0],s[1],4194304&o[0]&&{panels:e[22]},2097152&o[0]&&get_spread_object(e[21])]):{};117461264&o[0]|536870912&o[5]|1&o[6]&&(i.$$scope={dirty:o,ctx:e}),n.$set(i)},i(e){r||(transition_in(t.$$.fragment,e),transition_in(n.$$.fragment,e),r=!0)},o(e){transition_out(t.$$.fragment,e),transition_out(n.$$.fragment,e),r=!1},d(e){destroy_component(t,e),e&&detach(o),destroy_component(n,e)}}}function create_default_slot_1$4(e){let t,o,n=e[185].label+"";return{c(){t=element("span"),o=text(n)},m(e,n){insert(e,t,n),append(t,o)},p(e,t){1073741824&t[5]&&n!==(n=e[185].label+"")&&set_data(o,n)},d(e){e&&detach(t)}}}function create_if_block_2$3(e){let t,o;return t=new RangeInput({props:{elasticity:e[35]*e[36],base:imageZoomLevelBase,min:e[14],max:imageZoomLevelMax,valueMin:e[25][0],valueMax:e[25][1],value:e[26],labelReset:e[4].labelReset,valueLabel:`${Math.round(100*e[26])}%`,oninputstart:e[72],oninputmove:e[73],oninputend:e[74]}}),{c(){create_component(t.$$.fragment)},m(e,n){mount_component(t,e,n),o=!0},p(e,o){const n={};16384&o[0]&&(n.min=e[14]),33554432&o[0]&&(n.valueMin=e[25][0]),33554432&o[0]&&(n.valueMax=e[25][1]),67108864&o[0]&&(n.value=e[26]),16&o[0]&&(n.labelReset=e[4].labelReset),67108864&o[0]&&(n.valueLabel=`${Math.round(100*e[26])}%`),t.$set(n)},i(e){o||(transition_in(t.$$.fragment,e),o=!0)},o(e){transition_out(t.$$.fragment,e),o=!1},d(e){destroy_component(t,e)}}}function create_if_block_1$5(e){let t,o;return t=new ImageRotator({props:{elasticity:e[35]*e[36],rotation:e[8],labelReset:e[4].labelReset,valueMin:e[24][0],valueMax:e[24][1],oninputstart:e[62],oninputmove:e[63],oninputend:e[64]}}),{c(){create_component(t.$$.fragment)},m(e,n){mount_component(t,e,n),o=!0},p(e,o){const n={};256&o[0]&&(n.rotation=e[8]),16&o[0]&&(n.labelReset=e[4].labelReset),16777216&o[0]&&(n.valueMin=e[24][0]),16777216&o[0]&&(n.valueMax=e[24][1]),t.$set(n)},i(e){o||(transition_in(t.$$.fragment,e),o=!0)},o(e){transition_out(t.$$.fragment,e),o=!1},d(e){destroy_component(t,e)}}}function create_default_slot$8(e){let t,o,n,r;const a=[create_if_block_1$5,create_if_block_2$3],i=[];function s(e,t){return e[184]===e[12][0].id?0:e[184]===e[12][1].id?1:-1}return~(t=s(e))&&(o=i[t]=a[t](e)),{c(){o&&o.c(),n=empty()},m(e,o){~t&&i[t].m(e,o),insert(e,n,o),r=!0},p(e,r){let l=t;(t=s(e))===l?~t&&i[t].p(e,r):(o&&(group_outros(),transition_out(i[l],1,1,()=>{i[l]=null}),check_outros()),~t?((o=i[t])?o.p(e,r):(o=i[t]=a[t](e)).c(),transition_in(o,1),o.m(n.parentNode,n)):o=null)},i(e){r||(transition_in(o),r=!0)},o(e){transition_out(o),r=!1},d(e){~t&&i[t].d(e),e&&detach(n)}}}function create_footer_slot$4(e){let t,o,n=e[20]&&create_if_block$5(e);return{c(){t=element("div"),n&&n.c(),attr(t,"slot","footer"),attr(t,"style",e[23])},m(e,r){insert(e,t,r),n&&n.m(t,null),o=!0},p(e,r){e[20]?n?(n.p(e,r),1048576&r[0]&&transition_in(n,1)):((n=create_if_block$5(e)).c(),transition_in(n,1),n.m(t,null)):n&&(group_outros(),transition_out(n,1,1,()=>{n=null}),check_outros()),(!o||8388608&r[0])&&attr(t,"style",e[23])},i(e){o||(transition_in(n),o=!0)},o(e){transition_out(n),o=!1},d(e){e&&detach(t),n&&n.d()}}}function create_fragment$g(e){let t,o,n;function r(t){e[141](t)}let a={hasHeader:e[19],$$slots:{footer:[create_footer_slot$4],main:[create_main_slot$1],header:[create_header_slot]},$$scope:{ctx:e}};return void 0!==e[13]&&(a.root=e[13]),t=new Util({props:a}),binding_callbacks.push(()=>bind(t,"root",r)),t.$on("measure",e[142]),{c(){create_component(t.$$.fragment)},m(e,o){mount_component(t,e,o),n=!0},p(e,n){const r={};524288&n[0]&&(r.hasHeader=e[19]),536338429&n[0]|1&n[6]&&(r.$$scope={dirty:n,ctx:e}),!o&&8192&n[0]&&(o=!0,r.root=e[13],add_flush_callback(()=>o=!1)),t.$set(r)},i(e){n||(transition_in(t.$$.fragment,e),n=!0)},o(e){transition_out(t.$$.fragment,e),n=!1},d(e){destroy_component(t,e)}}}const imageZoomLevelMax=1,imageZoomLevelBase=0;function instance$g(e,t,o){let n,r,a,i,s,l,c,p,u,d,h,m,g,f,_,$,b,y,x,v,C,S,k,w,R,T,E,I,A,M,P,D,F,L,z,B,O,U,N,V,H,W,G,j,q,X,Y,K,Z,J,Q,ee,te,oe,ne,re,ae,ie,se,le,ce,pe=noop,ue=()=>(pe(),pe=subscribe(de,e=>o(11,Q=e)),de);e.$$.on_destroy.push(()=>pe());let{isActive:de}=t;ue();let{stores:he}=t,{cropImageSelectionCornerStyle:me="circle"}=t,{cropWillRenderImageSelectionGuides:ge=((e,t)=>{const o="rotate"==e;return{rows:o?5:3,cols:o?5:3,opacity:.25*t}})}=t,{cropAutoCenterImageSelectionTimeout:fe}=t,{cropEnableZoomMatchImageAspectRatio:_e=!0}=t,{cropEnableRotateMatchImageAspectRatio:$e="never"}=t,{cropEnableRotationInput:be=!0}=t,{cropEnableZoom:ye=!0}=t,{cropEnableZoomInput:xe=!0}=t,{cropEnableImageSelection:ve=!0}=t,{cropEnableInfoIndicator:Ce=!1}=t,{cropEnableZoomTowardsWheelPosition:Se=!0}=t,{cropEnableLimitWheelInputToCropSelection:ke=!0}=t,{cropEnableCenterImageSelection:we=!0}=t,{cropEnableButtonRotateLeft:Re=!0}=t,{cropEnableButtonRotateRight:Te=!1}=t,{cropEnableButtonFlipHorizontal:Ee=!0}=t,{cropEnableButtonFlipVertical:Ie=!1}=t,{cropSelectPresetOptions:Ae}=t,{cropEnableSelectPreset:Me=!0}=t,{cropEnableButtonToggleCropLimit:Pe=!1}=t,{locale:De={}}=t,{tools:Fe=[]}=t,Le="idle";const ze=()=>void 0===R,Be=(e,t,o)=>isRotatedSideways(o)?t.width===Math.round(e.height)||t.height===Math.round(e.width):t.width===Math.round(e.width)||t.height===Math.round(e.height),Oe=()=>(ze()||"always"===$e&&(()=>{if(1===R)return!1;const e=(e=>1/e)(R);return!!Ae&&!!flattenOptions(Ae).find(([t])=>t===e)})())&&((e,t,o)=>{const n=sizeApply(sizeRotate(sizeClone(t),o),e=>Math.abs(Math.round(e))),r=sizeCenter(n),a=rectCenter(e);return vectorEqual(r,a)})(T,E,I)&&Be(T,E,I),Ue=e=>{if("never"!==$e&&Oe()){set_store_value(nt,I+=e,I);const t=isRotatedSideways(I),o=t?E.height:E.width,n=t?E.width:E.height;set_store_value(dt,T=rectCreate(0,0,o,n),T),ze()||set_store_value(ft,R=getAspectRatio(o,n),R)}else set_store_value(nt,I+=e,I)},Ne=Button,{history:Ve,env:He,isInteracting:We,isInteractingFraction:Ge,rootRect:je,stageRect:qe,utilRect:Xe,rootLineColor:Ye,animation:Ke,elasticityMultiplier:Ze,rangeInputElasticity:Je,presentationScalar:Qe,imagePreviewModifiers:et,imageFlipX:tt,imageFlipY:ot,imageRotation:nt,imageRotationRange:rt,imageOutputSize:at,imageSelectionRect:it,imageSelectionRectSnapshot:st,imageSelectionRectIntent:lt,imageSelectionRectPresentation:ct,imageCropRectIntent:pt,imageCropRectOrigin:ut,imageCropRect:dt,imageCropMinSize:ht,imageCropMaxSize:mt,imageCropRange:gt,imageCropAspectRatio:ft,imageCropRectAspectRatio:_t,imageCropLimitToImage:$t,imageSize:bt,imageScalar:yt,imageOverlayMarkup:xt}=he;let vt,Ct,St;component_subscribe(e,He,e=>o(128,Z=e)),component_subscribe(e,We,e=>o(114,z=e)),component_subscribe(e,je,e=>o(15,q=e)),component_subscribe(e,qe,e=>o(119,X=e)),component_subscribe(e,Xe,e=>o(118,H=e)),component_subscribe(e,Ke,e=>o(135,ne=e)),component_subscribe(e,Qe,e=>o(117,U=e)),component_subscribe(e,et,e=>o(131,ee=e)),component_subscribe(e,tt,e=>o(108,M=e)),component_subscribe(e,ot,e=>o(107,A=e)),component_subscribe(e,nt,e=>o(8,I=e)),component_subscribe(e,rt,e=>o(24,ae=e)),component_subscribe(e,at,e=>o(152,D=e)),component_subscribe(e,it,e=>o(116,O=e)),component_subscribe(e,st,e=>o(115,B=e)),component_subscribe(e,lt,e=>o(154,V=e)),component_subscribe(e,ct,e=>o(122,K=e)),component_subscribe(e,pt,e=>o(156,G=e)),component_subscribe(e,ut,e=>o(155,W=e)),component_subscribe(e,dt,e=>o(7,T=e)),component_subscribe(e,ht,e=>o(112,F=e)),component_subscribe(e,mt,e=>o(153,N=e)),component_subscribe(e,gt,e=>o(157,j=e)),component_subscribe(e,ft,e=>o(151,R=e)),component_subscribe(e,$t,e=>o(113,L=e)),component_subscribe(e,bt,e=>o(106,E=e)),component_subscribe(e,yt,e=>o(130,J=e)),component_subscribe(e,xt,e=>o(159,te=e));const kt=(e,t)=>{const o={target:e,translate:t};let n,r=applyRectDirectionTranslation(B,o,{aspectRatio:R});const a=sizeCreateFromRect(rectDivide(rectClone(r),U)),i=getImagePolygon(E,I);if(quadCentroid(i),a.width<F.width||a.height<F.height){const o=t.y<0,r=t.x>0,i=t.x<0,s=t.y>0,l="t"===e&&o||"r"===e&&r||"b"===e&&s||"l"===e&&i||"tr"===e&&(r||o)||"tl"===e&&(i||o)||"br"===e&&(r||s)||"bl"===e&&(i||s),c=rectAspectRatio(a),p=getMaxSizeInRect(E,I,c);if(l&&(p.width<F.width||p.height<F.height)){if(0!==I){const e=Math.sign(I),t=Math.round(Math.abs(I)/HALF_PI)*HALF_PI,o=I-e*t,n=t/HALF_PI%2==1,r=n?E.height:E.width,i=n?E.width:E.height,s=Math.abs(o),l=Math.sin(s),c=Math.cos(s);if(a.width<F.width){a.width=F.width;const e=r-(c*a.width+l*a.height),t=i-(l*a.width+c*a.height);e<t?a.height=(r-c*a.width)/l:t<e&&(a.height=(i-l*a.width)/c)}if(a.height<F.height){a.height=F.height;const e=r-(c*a.width+l*a.height),t=i-(l*a.width+c*a.height);e<t?a.width=(r-l*a.height)/c:t<e&&(a.width=(i-c*a.height)/l)}}else a.width<F.width&&(a.width=F.width,a.height=E.height),a.height<F.height&&(a.height=F.height,a.width=E.width);n=rectAspectRatio(a)}}return n&&(r=applyRectDirectionTranslation(B,o,{aspectRatio:n||R})),{boundsLimited:limitRectDirectionTranslation(B,o,H,{aspectRatio:R||n,minSize:Ct,maxSize:St}),boundsIntent:r}};let wt=void 0,Rt=void 0;const Tt=({translation:e,scalar:t})=>{const o=Math.min(O.width/T.width,O.height/T.height),n=vectorMultiply(vectorClone(e),1/o);let r;if(Rt){const t=vectorSubtract(vectorClone(Rt),e);Rt=e,r=rectTranslate(rectClone(T),t)}else r=rectTranslate(rectClone(wt),vectorInvert(vectorClone(n))),void 0!==t&&rectScale(r,1-t);set_store_value(pt,G=r,G),set_store_value(dt,T=r,T)},Et=derived([gt,dt],([e,t],o)=>{if(!t)return;const[n,r]=e,a=rectAspectRatio(t);o([sizeCreateFromRect(rectApply(rectCoverRect(n,a),fixPrecision)),sizeCreateFromRect(rectApply(rectContainRect(r,a),fixPrecision))])});component_subscribe(e,Et,e=>o(158,Y=e));const It=derived([bt,$t,ht,mt,gt,nt],([e,t,o,n,r,a],i)=>{if(!e)return;const s=r[0],l=r[1];let c,p;t?(c=((e,t,o)=>isRotatedSideways(o)?1-1/Math.min(e.height/t.width,e.width/t.height):1-1/Math.min(e.width/t.width,e.height/t.height))(e,l,a),p=Math.min(s.width/o.width,s.height/o.height)):(p=1,c=-1),i([fixPrecision(c),fixPrecision(p)])});component_subscribe(e,It,e=>o(25,ie=e));const At=derived([bt,dt,gt,nt],([e,t,o,n],r)=>{if(!e||!t)return r(0);let a;const i=o[0],s=o[1],l=t.width,c=t.height,p=rectAspectRatio(t),u=isRotatedSideways(n)?sizeCreate(e.height,e.width):e,d=rectContainRect(u,p);if(l<=d.width||c<=d.height){const e=d.width-i.width,t=d.height-i.height;a=0===e||0===t?1:1-Math.min((l-i.width)/e,(c-i.height)/t)}else{const e=s.width-d.width,t=s.height-d.height,o=rectContainRect({width:e,height:t},p);a=-Math.min((l-d.width)/o.width,(c-d.height)/o.height)}r(a)});component_subscribe(e,At,e=>o(26,se=e));const Mt=e=>{const t=rectAspectRatio(wt);let o,n,r;const a=isRotatedSideways(I)?sizeCreate(E.height,E.width):E,i=rectContainRect(a,t);if(e>=0){const a=i.width-j[0].width,s=i.height-j[0].height;o=i.width-a*e,n=i.height-s*e,r=rectCoverRect({width:o,height:n},t)}else{const a=j[1].width-i.width,s=j[1].height-i.height;o=i.width+a*-e,n=i.height+s*-e,r=rectContainRect({width:o,height:n},t)}o=r.width,n=r.height;const s=wt.x+.5*wt.width-.5*o,l=wt.y+.5*wt.height-.5*n;set_store_value(dt,T={x:s,y:l,width:o,height:n},T)};let Pt;const Dt=e=>{const t=rectScale(rectClone(Pt),1/e);set_store_value(pt,G=t,G),set_store_value(dt,T=t,T)};let Ft;const Lt=createEventDispatcher(),zt=()=>{Lt("measure",rectClone(H))};let Bt;const Ot=spring(0,{precision:1e-4});component_subscribe(e,Ot,e=>o(27,le=e));const Ut=spring();component_subscribe(e,Ut,e=>o(28,ce=e));const Nt=derived([ft,at],([e,t],o)=>{if(!Ae)return;const n=flattenOptions(Ae),r=[...n].map(e=>e[0]).sort((e,t)=>isArray(e[0])&&!isArray(t[0])?1:-1).find(o=>{if(isArray(o)&&t){const[n,r]=o,a=t.width===n&&t.height===r,i=e===getAspectRatio(n,r);return a&&i}return o===e});o(n.map(e=>e[0]).findIndex(e=>isArray(e)?arrayEqual(e,r):e===r))});component_subscribe(e,Nt,e=>o(110,P=e));const Vt=derived([Ye,ct,Ge],([e,t,o],n)=>{const{rows:r,cols:a,opacity:i}=ge(Le,o);if(!t||i<=0)return n([]);const{x:s,y:l,width:c,height:p}=t,u=c/a,d=p/r,h=[];for(let t=1;t<=r-1;t++){const o=l+d*t;h.push({id:`image-selection-guide-row-${t}`,points:[vectorCreate(s,o),vectorCreate(s+c,o)],opacity:i,strokeWidth:1,strokeColor:e})}for(let t=1;t<=a-1;t++){const o=s+u*t;h.push({id:`image-selection-guide-col-${t}`,points:[vectorCreate(o,l),vectorCreate(o,l+p)],opacity:i,strokeWidth:1,strokeColor:e})}n(h)});component_subscribe(e,Vt,e=>o(132,oe=e));const Ht=`crop-${getUniqueId()}`;let Wt,Gt=Ht+"-"+(be?"rotation":"zoom"),jt=Gt,qt=void 0;const Xt=spring(ne?20:0);component_subscribe(e,Xt,e=>o(136,re=e));return e.$$set=(e=>{"isActive"in e&&ue(o(1,de=e.isActive)),"stores"in e&&o(86,he=e.stores),"cropImageSelectionCornerStyle"in e&&o(2,me=e.cropImageSelectionCornerStyle),"cropWillRenderImageSelectionGuides"in e&&o(87,ge=e.cropWillRenderImageSelectionGuides),"cropAutoCenterImageSelectionTimeout"in e&&o(88,fe=e.cropAutoCenterImageSelectionTimeout),"cropEnableZoomMatchImageAspectRatio"in e&&o(89,_e=e.cropEnableZoomMatchImageAspectRatio),"cropEnableRotateMatchImageAspectRatio"in e&&o(90,$e=e.cropEnableRotateMatchImageAspectRatio),"cropEnableRotationInput"in e&&o(91,be=e.cropEnableRotationInput),"cropEnableZoom"in e&&o(3,ye=e.cropEnableZoom),"cropEnableZoomInput"in e&&o(92,xe=e.cropEnableZoomInput),"cropEnableImageSelection"in e&&o(93,ve=e.cropEnableImageSelection),"cropEnableInfoIndicator"in e&&o(94,Ce=e.cropEnableInfoIndicator),"cropEnableZoomTowardsWheelPosition"in e&&o(95,Se=e.cropEnableZoomTowardsWheelPosition),"cropEnableLimitWheelInputToCropSelection"in e&&o(96,ke=e.cropEnableLimitWheelInputToCropSelection),"cropEnableCenterImageSelection"in e&&o(97,we=e.cropEnableCenterImageSelection),"cropEnableButtonRotateLeft"in e&&o(98,Re=e.cropEnableButtonRotateLeft),"cropEnableButtonRotateRight"in e&&o(99,Te=e.cropEnableButtonRotateRight),"cropEnableButtonFlipHorizontal"in e&&o(100,Ee=e.cropEnableButtonFlipHorizontal),"cropEnableButtonFlipVertical"in e&&o(101,Ie=e.cropEnableButtonFlipVertical),"cropSelectPresetOptions"in e&&o(102,Ae=e.cropSelectPresetOptions),"cropEnableSelectPreset"in e&&o(103,Me=e.cropEnableSelectPreset),"cropEnableButtonToggleCropLimit"in e&&o(104,Pe=e.cropEnableButtonToggleCropLimit),"locale"in e&&o(4,De=e.locale),"tools"in e&&o(0,Fe=e.tools)}),e.$$.update=(()=>{16&e.$$.dirty[4]&&o(127,u="overlay"===Z.layoutMode),1024&e.$$.dirty[3]|8&e.$$.dirty[4]&&o(109,$=Me&&!u),41943040&e.$$.dirty[3]&&o(123,i=H&&O&&rectCenterRect(H,O)),1082130432&e.$$.dirty[3]&&o(124,s=!(!O||!i)),1082130432&e.$$.dirty[3]|1&e.$$.dirty[4]&&o(111,l=s&&rectEqual(O,i,e=>fixPrecision(e,5))),272&e.$$.dirty[0]|2092e3&e.$$.dirty[3]&&o(0,Fe=[Re&&[Ne,"rotate-left",{label:De.cropLabelButtonRotateLeft,labelClass:"DokaToolbarContentWide",icon:De.cropIconButtonRotateLeft,onclick:()=>{Ue(-Math.PI/2),Ve.write()}}],Te&&[Ne,"rotate-right",{label:De.cropLabelButtonRotateRight,labelClass:"DokaToolbarContentWide",icon:De.cropIconButtonRotateRight,onclick:()=>{Ue(Math.PI/2),Ve.write()}}],Ee&&[Ne,"flip-horizontal",{label:De.cropLabelButtonFlipHorizontal,labelClass:"DokaToolbarContentWide",icon:De.cropIconButtonFlipHorizontal,onclick:()=>{isRotatedSideways(I)?set_store_value(ot,A=!A,A):set_store_value(tt,M=!M,M),Ve.write()}}],Ie&&[Ne,"flip-vertical",{label:De.cropLabelButtonFlipVertical,labelClass:"DokaToolbarContentWide",icon:De.cropIconButtonFlipVertical,onclick:()=>{isRotatedSideways(I)?set_store_value(tt,M=!M,M):set_store_value(ot,A=!A,A),Ve.write()}}],$&&Ae&&[Dropdown,"select-preset",{icon:localize(De.cropIconSelectPreset,De,(e=>{if(!Ae)return;const t=flattenOptions(Ae)[e][0];return t?isArray(t)?getAspectRatio(t[0],t[1]):t:void 0})(P)),label:De.cropLabelSelectPreset,labelClass:"DokaToolbarContentWide",options:Ae,selectedIndex:P,onchange:({value:e})=>{isArray(e)?(set_store_value(ft,R=getAspectRatio(e[0],e[1]),R),set_store_value(at,D=sizeCreateFromArray(e),D)):set_store_value(ft,R=e,R),l&&zt(),Ve.write()},optionMapper:e=>{let t=!1;const o=isArray(e.value)?e.value[0]/e.value[1]:e.value;if(o){const e=getMaxSizeInRect(E,I,o);t=e.width<F.width||e.height<F.height}return e.icon=getSelectionPresetOptionIcon(e.value,{bounds:14}),{...e,disabled:t}}}],Pe&&[Dropdown,"select-crop-limit",{icon:localize(De.cropIconCropBoundary,De,L),label:De.cropLabelCropBoundary,labelClass:"DokaToolbarContentWide",onchange:({value:e})=>{set_store_value($t,L=e,L),Ve.write()},options:[[!0,De.cropLabelCropBoundaryEdge,{icon:localize(De.cropIconCropBoundary,De,!0)}],[!1,De.cropLabelCropBoundaryNone,{icon:localize(De.cropIconCropBoundary,De,!1)}]]}]]),1048576&e.$$.dirty[3]&&o(14,n=L?0:-1),100663296&e.$$.dirty[3]&&o(120,r=H&&vectorCreate(-(X.x-H.x),-(X.y-H.y))),671088640&e.$$.dirty[3]&&o(121,a=K&&vectorCreate(snapToPixel(K.x+.5*K.width+r.x),snapToPixel(K.y+.5*K.height+r.y))),4194304&e.$$.dirty[3]&&o(125,c=null!=B),1107296256&e.$$.dirty[3]&&o(126,p=H&&i&&(i.height===H.height||i.width===H.width)),16777216&e.$$.dirty[3]|68&e.$$.dirty[4]&&o(129,d=!p&&U<1&&J<1),262144&e.$$.dirty[3]|35&e.$$.dirty[4]&&o(9,h=s&&!c&&(!l||d)),128&e.$$.dirty[0]|2&e.$$.dirty[3]|8&e.$$.dirty[4]&&o(16,m=Ce&&!!T&&!u),671088640&e.$$.dirty[3]&&o(10,_=K&&r&&{x:K.x+r.x,y:K.y+r.y,width:K.width,height:K.height}),1024&e.$$.dirty[0]|1&e.$$.dirty[3]|8&e.$$.dirty[4]&&o(17,g=ve&&!!_&&!u),67108864&e.$$.dirty[2]|268435472&e.$$.dirty[3]&&o(18,f=we&&!!a&&!fe),512&e.$$.dirty[0]|67108864&e.$$.dirty[2]|2101248&e.$$.dirty[3]&&h&&fe&&!z&&(clearTimeout(Bt),o(105,Bt=setTimeout(zt,fe))),2101248&e.$$.dirty[3]&&z&&clearTimeout(Bt),512&e.$$.dirty[0]&&Ot.set(h?1:0),268435456&e.$$.dirty[3]&&Ut.set(a),2048&e.$$.dirty[0]|128&e.$$.dirty[4]&&(Q?set_store_value(et,ee.crop={maskOpacity:.85,maskMarkupOpacity:.85},ee):delete ee.crop),256&e.$$.dirty[4]&&oe&&(()=>{const e=te.filter(e=>!/^image\-selection\-guide/.test(e.id));set_store_value(xt,te=Q?[...e,...oe]:e,te)})(),24&e.$$.dirty[4]&&o(133,b=!u&&"short"!==Z.verticalSpace),512&e.$$.dirty[4]&&o(19,y=b),8&e.$$.dirty[0]|1073741824&e.$$.dirty[2]|512&e.$$.dirty[4]&&o(134,x=ye&&xe&&b),536870912&e.$$.dirty[2]|1024&e.$$.dirty[4]&&o(20,v=be||x),1024&e.$$.dirty[4]&&(x||o(5,jt=Gt)),32&e.$$.dirty[0]&&o(21,C={name:Ht,selected:jt}),16&e.$$.dirty[0]|536870912&e.$$.dirty[2]|1024&e.$$.dirty[4]&&o(12,S=[be&&{id:Ht+"-rotation",label:De.cropLabelTabRotation},x&&{id:Ht+"-zoom",label:De.cropLabelTabZoom}].filter(Boolean)),4096&e.$$.dirty[0]&&o(22,k=S.map(e=>e.id)),64&e.$$.dirty[0]|8&e.$$.dirty[4]&&Wt&&!Wt.children.length&&u&&Wt.dispatchEvent(new CustomEvent("measure",{detail:Wt.rect})),2048&e.$$.dirty[0]|2048&e.$$.dirty[4]&&ne&&Xt.set(Q?0:20),4096&e.$$.dirty[4]&&o(23,w=re?`transform: translateY(${re}px)`:void 0)}),[Fe,de,me,ye,De,jt,Wt,T,I,h,_,Q,S,qt,n,q,m,g,f,y,v,C,k,w,ae,ie,se,le,ce,He,We,je,qe,Xe,Ke,Ze,Je,Qe,et,tt,ot,nt,rt,at,it,st,lt,ct,pt,ut,dt,ht,mt,gt,ft,$t,bt,yt,xt,()=>{Le="select",set_store_value(We,z=!0,z),set_store_value(st,B=rectClone(O),B),vt=U,Ct=sizeScale(sizeClone(F),vt),St=sizeScale(sizeClone(N),vt)},({detail:e})=>{const{boundsLimited:t,boundsIntent:o}=kt(e.direction,e.translation);set_store_value(lt,V=o,V),set_store_value(it,O=t,O)},({detail:e})=>{const{boundsLimited:t}=kt(e.direction,e.translation);set_store_value(We,z=!1,z),set_store_value(lt,V=void 0,V),vectorLength(e.translation)&&(set_store_value(it,O=t,O),Ve.write()),set_store_value(st,B=void 0,B)},()=>{Le="rotate",set_store_value(We,z=!0,z),set_store_value(ut,W=rectClone(T),W)},e=>{set_store_value(nt,I=e,I)},e=>{set_store_value(We,z=!1,z),set_store_value(nt,I=e,I),Ve.write(),set_store_value(ut,W=void 0,W)},()=>{Le="pan",Rt=void 0,set_store_value(We,z=!0,z),wt=rectClone(T)},({detail:e})=>Tt(e),({detail:e})=>{set_store_value(We,z=!1,z),(vectorLength(e.translation)>0||0!==e.scalar)&&(Tt(e),Ve.write()),set_store_value(pt,G=void 0,G),wt=void 0},({detail:e})=>{Rt=e.translation,set_store_value(We,z=!1,z)},Et,It,At,()=>{Le="zoom",set_store_value(We,z=!0,z),wt=rectClone(T)},e=>{Mt(e)},e=>{Mt(e),Ve.write(),set_store_value(We,z=!1,z),wt=void 0},()=>{Le="zoom",wt||(Pt=rectClone(T),set_store_value(We,z=!0,z))},({detail:e})=>{Pt&&Dt(e)},({detail:e})=>{Pt&&(set_store_value(We,z=!1,z),Dt(e),set_store_value(pt,G=void 0,G),Pt=void 0,Ve.write())},e=>{const t=getEventPositionInStage(e,q,X);if(ke&&!rectContainsPoint(O,t))return;Le="zoom",set_store_value(We,z=!0,z),e.preventDefault(),e.stopPropagation();const o=getWheelDelta(e),n=1+o/100,r=rectClone(T),a=1===Math.min(T.width/F.width,T.height/F.height);if(_e&&L){const e=Be(T,E,I);if(ze()&&e&&o>0&&l){set_store_value(We,z=!1,z);const e=isRotatedSideways(I)?rectCreateFromSize({height:E.width,width:E.height}):rectCreateFromSize(E);if(rectEqual(r,e))return;if(clearTimeout(Ft),rectEqual(Ve.state.crop,e))return;return set_store_value(dt,T=e,T),void Ve.write()}}let i=rectCenter(T);if(Se&&o<0&&!a){const e=vectorSubtract(vectorClone(t),O),o=Math.min(O.width/T.width,O.height/T.height),n=rectScale(rectClone(O),1.1);i=rectContainsPoint(n,t)?vectorAdd(rectClone(T),vectorMultiply(e,1/o)):i}let s=rectScale(rectClone(T),n,i);sizeContains(Y[1],s)||(s=rectCreateWithCenter(rectCenter(s),Y[1])),sizeContains(s,Y[0])||(s=rectCreateWithCenter(rectCenter(s),Y[0])),rectEqual(r,s,fixPrecision)?set_store_value(We,z=!1,z):(set_store_value(dt,T=rectApply(s,e=>fixPrecision(e,5)),T),set_store_value(We,z=!1,z),clearTimeout(Ft),Ft=setTimeout(()=>{Ve.write()},500))},zt,Ot,Ut,Nt,Vt,Xt,"crop",he,ge,fe,_e,$e,be,xe,ve,Ce,Se,ke,we,Re,Te,Ee,Ie,Ae,Me,Pe,Bt,E,A,M,$,P,l,F,L,z,B,O,U,H,X,r,a,K,i,s,c,p,u,Z,d,J,ee,oe,b,x,ne,re,function(t){bubble(e,t)},({detail:e})=>o(5,jt=e),function(e){binding_callbacks[e?"unshift":"push"](()=>{o(6,Wt=e)})},e=>getEventPositionInViewport(e),function(e){o(13,qt=e)},function(t){bubble(e,t)}]}class Crop extends SvelteComponent{constructor(e){super(),init(this,e,instance$g,create_fragment$g,safe_not_equal,{name:85,isActive:1,stores:86,cropImageSelectionCornerStyle:2,cropWillRenderImageSelectionGuides:87,cropAutoCenterImageSelectionTimeout:88,cropEnableZoomMatchImageAspectRatio:89,cropEnableRotateMatchImageAspectRatio:90,cropEnableRotationInput:91,cropEnableZoom:3,cropEnableZoomInput:92,cropEnableImageSelection:93,cropEnableInfoIndicator:94,cropEnableZoomTowardsWheelPosition:95,cropEnableLimitWheelInputToCropSelection:96,cropEnableCenterImageSelection:97,cropEnableButtonRotateLeft:98,cropEnableButtonRotateRight:99,cropEnableButtonFlipHorizontal:100,cropEnableButtonFlipVertical:101,cropSelectPresetOptions:102,cropEnableSelectPreset:103,cropEnableButtonToggleCropLimit:104,locale:4,tools:0},[-1,-1,-1,-1,-1,-1,-1])}get name(){return this.$$.ctx[85]}get isActive(){return this.$$.ctx[1]}set isActive(e){this.$set({isActive:e}),flush()}get stores(){return this.$$.ctx[86]}set stores(e){this.$set({stores:e}),flush()}get cropImageSelectionCornerStyle(){return this.$$.ctx[2]}set cropImageSelectionCornerStyle(e){this.$set({cropImageSelectionCornerStyle:e}),flush()}get cropWillRenderImageSelectionGuides(){return this.$$.ctx[87]}set cropWillRenderImageSelectionGuides(e){this.$set({cropWillRenderImageSelectionGuides:e}),flush()}get cropAutoCenterImageSelectionTimeout(){return this.$$.ctx[88]}set cropAutoCenterImageSelectionTimeout(e){this.$set({cropAutoCenterImageSelectionTimeout:e}),flush()}get cropEnableZoomMatchImageAspectRatio(){return this.$$.ctx[89]}set cropEnableZoomMatchImageAspectRatio(e){this.$set({cropEnableZoomMatchImageAspectRatio:e}),flush()}get cropEnableRotateMatchImageAspectRatio(){return this.$$.ctx[90]}set cropEnableRotateMatchImageAspectRatio(e){this.$set({cropEnableRotateMatchImageAspectRatio:e}),flush()}get cropEnableRotationInput(){return this.$$.ctx[91]}set cropEnableRotationInput(e){this.$set({cropEnableRotationInput:e}),flush()}get cropEnableZoom(){return this.$$.ctx[3]}set cropEnableZoom(e){this.$set({cropEnableZoom:e}),flush()}get cropEnableZoomInput(){return this.$$.ctx[92]}set cropEnableZoomInput(e){this.$set({cropEnableZoomInput:e}),flush()}get cropEnableImageSelection(){return this.$$.ctx[93]}set cropEnableImageSelection(e){this.$set({cropEnableImageSelection:e}),flush()}get cropEnableInfoIndicator(){return this.$$.ctx[94]}set cropEnableInfoIndicator(e){this.$set({cropEnableInfoIndicator:e}),flush()}get cropEnableZoomTowardsWheelPosition(){return this.$$.ctx[95]}set cropEnableZoomTowardsWheelPosition(e){this.$set({cropEnableZoomTowardsWheelPosition:e}),flush()}get cropEnableLimitWheelInputToCropSelection(){return this.$$.ctx[96]}set cropEnableLimitWheelInputToCropSelection(e){this.$set({cropEnableLimitWheelInputToCropSelection:e}),flush()}get cropEnableCenterImageSelection(){return this.$$.ctx[97]}set cropEnableCenterImageSelection(e){this.$set({cropEnableCenterImageSelection:e}),flush()}get cropEnableButtonRotateLeft(){return this.$$.ctx[98]}set cropEnableButtonRotateLeft(e){this.$set({cropEnableButtonRotateLeft:e}),flush()}get cropEnableButtonRotateRight(){return this.$$.ctx[99]}set cropEnableButtonRotateRight(e){this.$set({cropEnableButtonRotateRight:e}),flush()}get cropEnableButtonFlipHorizontal(){return this.$$.ctx[100]}set cropEnableButtonFlipHorizontal(e){this.$set({cropEnableButtonFlipHorizontal:e}),flush()}get cropEnableButtonFlipVertical(){return this.$$.ctx[101]}set cropEnableButtonFlipVertical(e){this.$set({cropEnableButtonFlipVertical:e}),flush()}get cropSelectPresetOptions(){return this.$$.ctx[102]}set cropSelectPresetOptions(e){this.$set({cropSelectPresetOptions:e}),flush()}get cropEnableSelectPreset(){return this.$$.ctx[103]}set cropEnableSelectPreset(e){this.$set({cropEnableSelectPreset:e}),flush()}get cropEnableButtonToggleCropLimit(){return this.$$.ctx[104]}set cropEnableButtonToggleCropLimit(e){this.$set({cropEnableButtonToggleCropLimit:e}),flush()}get locale(){return this.$$.ctx[4]}set locale(e){this.$set({locale:e}),flush()}get tools(){return this.$$.ctx[0]}set tools(e){this.$set({tools:e}),flush()}}var index$6={util:["crop",Crop]};function create_option_slot$1(e){let t,o,n,r,a,i,s,l=e[63],c=(isFunction(e[63].label)?e[63].label(e[2]):e[63].label)+"";function p(...t){return e[44](e[63],...t)}const u=()=>e[45](o,l),d=()=>e[45](null,l);return{c(){t=element("div"),o=element("div"),n=space(),r=element("span"),a=text(c),attr(o,"class",FILTER_PREVIEW_CLASS_NAME),attr(t,"slot","option"),attr(t,"class","DokaFilterOption")},m(e,l){insert(e,t,l),append(t,o),u(),append(t,n),append(t,r),append(r,a),i||(s=[listen(o,"measure",p),action_destroyer(measurable.call(null,o))],i=!0)},p(t,o){l!==(e=t)[63]&&(d(),l=e[63],u()),4&o[0]|2&o[2]&&c!==(c=(isFunction(e[63].label)?e[63].label(e[2]):e[63].label)+"")&&set_data(a,c)},d(e){e&&detach(t),d(),i=!1,run_all(s)}}}function create_default_slot$7(e){let t,o;return t=new RadioGroup({props:{locale:e[2],layout:"row",options:e[3],selectedIndex:e[10],onchange:e[26],$$slots:{option:[create_option_slot$1,({option:e})=>({63:e}),({option:e})=>[0,0,e?2:0]]},$$scope:{ctx:e}}}),{c(){create_component(t.$$.fragment)},m(e,n){mount_component(t,e,n),o=!0},p(e,o){const n={};4&o[0]&&(n.locale=e[2]),8&o[0]&&(n.options=e[3]),1024&o[0]&&(n.selectedIndex=e[10]),516&o[0]|6&o[2]&&(n.$$scope={dirty:o,ctx:e}),t.$set(n)},i(e){o||(transition_in(t.$$.fragment,e),o=!0)},o(e){transition_out(t.$$.fragment,e),o=!1},d(e){destroy_component(t,e)}}}function create_footer_slot$3(e){let t,o,n,r,a,i,s,l;function c(t){e[47](t)}function p(t){e[48](t)}function u(t){e[49](t)}let d={elasticity:e[15]*e[16],onscroll:e[46],$$slots:{default:[create_default_slot$7]},$$scope:{ctx:e}};return void 0!==e[4]&&(d.maskFeatherStartOpacity=e[4]),void 0!==e[5]&&(d.maskFeatherEndOpacity=e[5]),void 0!==e[6]&&(d.maskFeatherSize=e[6]),o=new Scrollable({props:d}),binding_callbacks.push(()=>bind(o,"maskFeatherStartOpacity",c)),binding_callbacks.push(()=>bind(o,"maskFeatherEndOpacity",p)),binding_callbacks.push(()=>bind(o,"maskFeatherSize",u)),o.$on("measure",e[50]),{c(){t=element("div"),create_component(o.$$.fragment),attr(t,"slot","footer"),attr(t,"style",e[11])},m(n,r){insert(n,t,r),mount_component(o,t,null),i=!0,s||(l=listen(t,"transitionend",e[24]),s=!0)},p(e,s){const l={};128&s[0]&&(l.onscroll=e[46]),1548&s[0]|4&s[2]&&(l.$$scope={dirty:s,ctx:e}),!n&&16&s[0]&&(n=!0,l.maskFeatherStartOpacity=e[4],add_flush_callback(()=>n=!1)),!r&&32&s[0]&&(r=!0,l.maskFeatherEndOpacity=e[5],add_flush_callback(()=>r=!1)),!a&&64&s[0]&&(a=!0,l.maskFeatherSize=e[6],add_flush_callback(()=>a=!1)),o.$set(l),(!i||2048&s[0])&&attr(t,"style",e[11])},i(e){i||(transition_in(o.$$.fragment,e),i=!0)},o(e){transition_out(o.$$.fragment,e),i=!1},d(e){e&&detach(t),destroy_component(o),s=!1,l()}}}function create_fragment$f(e){let t,o;return(t=new Util({props:{$$slots:{footer:[create_footer_slot$3]},$$scope:{ctx:e}}})).$on("measure",e[51]),{c(){create_component(t.$$.fragment)},m(e,n){mount_component(t,e,n),o=!0},p(e,o){const n={};4092&o[0]|4&o[2]&&(n.$$scope={dirty:o,ctx:e}),t.$set(n)},i(e){o||(transition_in(t.$$.fragment,e),o=!0)},o(e){transition_out(t.$$.fragment,e),o=!1},d(e){destroy_component(t,e)}}}let FILTER_PREVIEW_CLASS_NAME="DokaFilterPreview";function instance$f(e,t,o){let n,r,a,i,s,l,c,p,u,d,h,m,g,f,_,$=noop,b=()=>($(),$=subscribe(v,e=>o(37,u=e)),v),y=noop,x=()=>(y(),y=subscribe(C,e=>o(41,g=e)),C);e.$$.on_destroy.push(()=>$()),e.$$.on_destroy.push(()=>y());let{isActive:v}=t;b();let{isActiveFraction:C}=t;x();let{stores:S}=t,{locale:k}=t,{filterFunctions:w}=t,{filterOptions:R}=t;const{history:T,imagePreviews:E,stageRect:I,utilRect:A,animation:M,elasticityMultiplier:P,scrollElasticity:D,imageCropRect:F,imageSize:L,imageRotation:z,imageFlipX:B,imageFlipY:O,imageGamma:U,imageColorMatrix:N}=S;component_subscribe(e,I,e=>o(39,h=e)),component_subscribe(e,A,e=>o(38,d=e)),component_subscribe(e,M,e=>o(36,p=e)),component_subscribe(e,U,e=>o(40,m=e)),component_subscribe(e,N,e=>o(33,i=e));const V=writable({});component_subscribe(e,V,e=>o(34,s=e));const H=(e,t)=>set_store_value(V,s[e.value]=t,s),W=derived(V,e=>{if(!e[void 0])return;const t=e[void 0];return l&&sizeEqual(l,t)?l:sizeClone(t)});component_subscribe(e,W,e=>o(52,l=e));const G=derived([v,W,F,L,z,B,O],([e,t,o,n,r,a,i],s)=>{if(!e||!t||!n)return c;const l=rectCreateFromSize(n),p=rectCenter(l),u=getBaseCropRect(n,o,r),d=rectCenter(u),h=vectorSubtract(vectorClone(p),d),m=vectorInvert(vectorClone(h)),g=Math.max(t.width/o.width,t.height/o.height);s({origin:m,translation:h,rotation:{x:i?Math.PI:0,y:a?Math.PI:0,z:r},perspective:vectorCreateEmpty(),scale:g})});component_subscribe(e,G,e=>o(35,c=e));const j=spring(p?20:0);let q;component_subscribe(e,j,e=>o(42,f=e));const X={};let Y,K,Z,J,Q,ee={x:0,y:0};const te=writable([]);component_subscribe(e,te,e=>o(43,_=e));const oe=e=>{const t={...e,offset:{...e.offset},mask:{...e.mask}};return t.opacity=g,t.offset.y+=f,t.mask.y+=f,t};return e.$$set=(e=>{"isActive"in e&&b(o(0,v=e.isActive)),"isActiveFraction"in e&&x(o(1,C=e.isActiveFraction)),"stores"in e&&o(28,S=e.stores),"locale"in e&&o(2,k=e.locale),"filterFunctions"in e&&o(29,w=e.filterFunctions),"filterOptions"in e&&o(3,R=e.filterOptions)}),e.$$.update=(()=>{if(8&e.$$.dirty[0]&&o(32,n=flattenOptions(R)),6&e.$$.dirty[1]&&o(10,r=((e,t)=>{if(!e||!e.filter||!t)return 0;const o=e.filter;return t.findIndex(([e])=>{if(!w[e])return!1;const t=w[e]();return arrayEqual(t,o)})})(i,n)),96&e.$$.dirty[1]&&p&&j.set(u?0:20),448&e.$$.dirty[1]&&u&&d&&h){const e=h.y+h.height+d.y;o(31,Q={x:h.x-d.x,y:e})}if(1610613232&e.$$.dirty[0]|543&e.$$.dirty[1]&&c&&Q&&ee&&J&&q){const e=Q.x+J.x+ee.x,t=Q.y,o=J.x+Q.x,r=o+J.width;te.set(n.map(([n],a)=>{const l=s[n],p=ee.x+l.x,u=p+l.width;if(u<0||p>J.width)return!1;const d=e+l.x,h=t+l.y,g=(e=>({origin:vectorClone(e.origin),translation:vectorClone(e.translation),rotation:{...e.rotation},perspective:vectorClone(e.perspective),scale:e.scale}))(c);g.offset=vectorCreate(.5*l.width+d,.5*l.height+h);g.maskOpacity=1,g.mask=rectCreate(d+0,h,l.width+0,l.height),g.maskFeather=[1,0,1,0,1,r,1,r],p<Z&&Y<1&&(g.maskFeather[0]=Y,g.maskFeather[1]=o,g.maskFeather[2]=1,g.maskFeather[3]=o+Z),u>J.width-Z&&K<1&&(g.maskFeather[4]=K,g.maskFeather[5]=r-Z,g.maskFeather[6]=1,g.maskFeather[7]=r),g.maskCornerRadius=q[n];let f=i&&Object.keys(i).filter(e=>"filter"!=e).map(e=>i[e])||[];return isFunction(w[n])&&f.push(w[n]()),g.colorMatrix=f.length?getColorMatrixFromColorMatrices(f):void 0,g.gamma=m,g}).filter(Boolean))}7232&e.$$.dirty[1]&&(u&&_?E.set(_.map(oe)):E.set([])),2048&e.$$.dirty[1]&&o(11,a=f?`transform: translateY(${f}px)`:void 0)}),[v,C,k,R,Y,K,Z,ee,J,X,r,a,I,A,M,P,D,U,N,V,H,W,G,j,e=>{e.target.className===FILTER_PREVIEW_CLASS_NAME&&o(30,q=Object.keys(X).reduce((e,t)=>{const o=X[t],n=getComputedStyle(o),r=["top-left","top-right","bottom-left","bottom-right"].map(e=>n.getPropertyValue(`border-${e}-radius`)).map(unitToPixels).map(e=>1.25*e);return e[t]=r,e},{}))},te,({value:e})=>{set_store_value(N,i={...i,filter:isFunction(w[e])?w[e]():void 0},i),T.write()},"filter",S,w,q,Q,n,i,s,c,p,u,d,h,m,g,f,_,(e,t)=>H(e,t.detail),function(e,t){binding_callbacks[e?"unshift":"push"](()=>{X[t.value]=e,o(9,X)})},e=>o(7,ee=e),function(e){o(4,Y=e)},function(e){o(5,K=e)},function(e){o(6,Z=e)},e=>o(8,J=e.detail),function(t){bubble(e,t)}]}class Filter extends SvelteComponent{constructor(e){super(),init(this,e,instance$f,create_fragment$f,safe_not_equal,{name:27,isActive:0,isActiveFraction:1,stores:28,locale:2,filterFunctions:29,filterOptions:3},[-1,-1,-1])}get name(){return this.$$.ctx[27]}get isActive(){return this.$$.ctx[0]}set isActive(e){this.$set({isActive:e}),flush()}get isActiveFraction(){return this.$$.ctx[1]}set isActiveFraction(e){this.$set({isActiveFraction:e}),flush()}get stores(){return this.$$.ctx[28]}set stores(e){this.$set({stores:e}),flush()}get locale(){return this.$$.ctx[2]}set locale(e){this.$set({locale:e}),flush()}get filterFunctions(){return this.$$.ctx[29]}set filterFunctions(e){this.$set({filterFunctions:e}),flush()}get filterOptions(){return this.$$.ctx[3]}set filterOptions(e){this.$set({filterOptions:e}),flush()}}var index$5={util:["filter",Filter]};function create_default_slot_2$1(e){let t,o,n=e[37].label+"";return{c(){t=element("span"),o=text(n)},m(e,n){insert(e,t,n),append(t,o)},p(e,t){64&t[1]&&n!==(n=e[37].label+"")&&set_data(o,n)},d(e){e&&detach(t)}}}function create_default_slot_1$3(e){let t,o;const n=[{class:"DokaControlList"},{tabs:e[1]},e[3]];let r={$$slots:{default:[create_default_slot_2$1,({tab:e})=>({37:e}),({tab:e})=>[0,e?64:0]]},$$scope:{ctx:e}};for(let e=0;e<n.length;e+=1)r=assign(r,n[e]);return(t=new TabList({props:r})).$on("select",e[22]),{c(){create_component(t.$$.fragment)},m(e,n){mount_component(t,e,n),o=!0},p(e,o){const r=10&o[0]?get_spread_update(n,[n[0],2&o[0]&&{tabs:e[1]},8&o[0]&&get_spread_object(e[3])]):{};192&o[1]&&(r.$$scope={dirty:o,ctx:e}),t.$set(r)},i(e){o||(transition_in(t.$$.fragment,e),o=!0)},o(e){transition_out(t.$$.fragment,e),o=!1},d(e){destroy_component(t,e)}}}function create_default_slot$6(e){let t,o;const n=[e[5][e[36]]];let r={};for(let e=0;e<n.length;e+=1)r=assign(r,n[e]);return t=new RangeInput({props:r}),{c(){create_component(t.$$.fragment)},m(e,n){mount_component(t,e,n),o=!0},p(e,o){const r=32&o[0]|32&o[1]?get_spread_update(n,[get_spread_object(e[5][e[36]])]):{};t.$set(r)},i(e){o||(transition_in(t.$$.fragment,e),o=!0)},o(e){transition_out(t.$$.fragment,e),o=!1},d(e){destroy_component(t,e)}}}function create_footer_slot$2(e){let t,o,n,r,a;o=new Scrollable({props:{elasticity:e[9]*e[8],class:"DokaControlListScroller",$$slots:{default:[create_default_slot_1$3]},$$scope:{ctx:e}}});const i=[{class:"DokaControlPanels"},{panelClass:"DokaControlPanel"},{panels:e[4]},e[3]];let s={$$slots:{default:[create_default_slot$6,({panel:e})=>({36:e}),({panel:e})=>[0,e?32:0]]},$$scope:{ctx:e}};for(let e=0;e<i.length;e+=1)s=assign(s,i[e]);return r=new TabPanels({props:s}),{c(){t=element("div"),create_component(o.$$.fragment),n=space(),create_component(r.$$.fragment),attr(t,"slot","footer"),attr(t,"style",e[6])},m(e,i){insert(e,t,i),mount_component(o,t,null),append(t,n),mount_component(r,t,null),a=!0},p(e,n){const s={};14&n[0]|128&n[1]&&(s.$$scope={dirty:n,ctx:e}),o.$set(s);const l=24&n[0]?get_spread_update(i,[i[0],i[1],16&n[0]&&{panels:e[4]},8&n[0]&&get_spread_object(e[3])]):{};32&n[0]|160&n[1]&&(l.$$scope={dirty:n,ctx:e}),r.$set(l),(!a||64&n[0])&&attr(t,"style",e[6])},i(e){a||(transition_in(o.$$.fragment,e),transition_in(r.$$.fragment,e),a=!0)},o(e){transition_out(o.$$.fragment,e),transition_out(r.$$.fragment,e),a=!1},d(e){e&&detach(t),destroy_component(o),destroy_component(r)}}}function create_fragment$e(e){let t,o;return(t=new Util({props:{$$slots:{footer:[create_footer_slot$2]},$$scope:{ctx:e}}})).$on("measure",e[23]),{c(){create_component(t.$$.fragment)},m(e,n){mount_component(t,e,n),o=!0},p(e,o){const n={};126&o[0]|128&o[1]&&(n.$$scope={dirty:o,ctx:e}),t.$set(n)},i(e){o||(transition_in(t.$$.fragment,e),o=!0)},o(e){transition_out(t.$$.fragment,e),o=!1},d(e){destroy_component(t,e)}}}function instance$e(e,t,o){let n,r,a,i,s,l,c,p,u,d,h=noop,m=()=>(h(),h=subscribe(f,e=>o(20,u=e)),f);e.$$.on_destroy.push(()=>h());let{stores:g}=t,{isActive:f}=t;m();let{locale:_={}}=t,{finetuneControlConfiguration:$}=t,{finetuneOptions:b}=t;const{history:y,animation:x,scrollElasticity:v,elasticityMultiplier:C,rangeInputElasticity:S,imageColorMatrix:k,imageConvolutionMatrix:w,imageGamma:R,imageVignette:T,imageNoise:E}=g;component_subscribe(e,x,e=>o(19,p=e));const I={imageColorMatrix:k,imageConvolutionMatrix:w,imageGamma:R,imageVignette:T,imageNoise:E},A=`doka-finetune-${getUniqueId()}`,M=writable({});component_subscribe(e,M,e=>o(18,c=e));const P=writable({});component_subscribe(e,P,e=>o(5,l=e));let D=[];const F=spring(p?20:0);component_subscribe(e,F,e=>o(21,d=e));var L;return e.$$set=(e=>{"stores"in e&&o(14,g=e.stores),"isActive"in e&&m(o(0,f=e.isActive)),"locale"in e&&o(15,_=e.locale),"finetuneControlConfiguration"in e&&o(16,$=e.finetuneControlConfiguration),"finetuneOptions"in e&&o(17,b=e.finetuneOptions)}),e.$$.update=(()=>{163840&e.$$.dirty[0]&&o(1,n=b?b.map(([e,t])=>({id:e,label:isFunction(t)?t(_):t})):[]),2&e.$$.dirty[0]&&o(2,r=n.length&&n[0].id),4&e.$$.dirty[0]&&o(3,a={name:A,selected:r}),2&e.$$.dirty[0]&&o(4,i=n.map(e=>e.id)),65536&e.$$.dirty[0]&&$&&(L=$,D&&D.forEach(e=>e()),D=i.map(e=>{const{getStore:t,getValue:o=passthrough}=L[e];return t(I).subscribe(t=>{const n=null!=t?o(t):t;set_store_value(M,c={...c,[e]:n},c)})})),327680&e.$$.dirty[0]&&$&&c&&set_store_value(P,l=Object.keys(c).reduce((e,t)=>{const{base:o,min:n,max:r,getLabel:a,getStore:i,setValue:s=((e,t)=>e.set(t))}=$[t],l=i(I),p=null!=c[t]?c[t]:o;return e[t]={base:o,min:n,max:r,value:p,valueLabel:a?a(p,n,r,r-n):Math.round(100*p),oninputmove:e=>{s(l,e)},oninputend:e=>{s(l,e),y.write()},elasticity:C*S,labelReset:_.labelReset},e},{}),l),1572864&e.$$.dirty[0]&&p&&F.set(u?0:20),2097152&e.$$.dirty[0]&&o(6,s=d?`transform: translateY(${d}px)`:void 0)}),[f,n,r,a,i,l,s,x,v,C,M,P,F,"finetune",g,_,$,b,c,p,u,d,({detail:e})=>o(2,r=e),function(t){bubble(e,t)}]}class Finetune extends SvelteComponent{constructor(e){super(),init(this,e,instance$e,create_fragment$e,safe_not_equal,{name:13,stores:14,isActive:0,locale:15,finetuneControlConfiguration:16,finetuneOptions:17},[-1,-1])}get name(){return this.$$.ctx[13]}get stores(){return this.$$.ctx[14]}set stores(e){this.$set({stores:e}),flush()}get isActive(){return this.$$.ctx[0]}set isActive(e){this.$set({isActive:e}),flush()}get locale(){return this.$$.ctx[15]}set locale(e){this.$set({locale:e}),flush()}get finetuneControlConfiguration(){return this.$$.ctx[16]}set finetuneControlConfiguration(e){this.$set({finetuneControlConfiguration:e}),flush()}get finetuneOptions(){return this.$$.ctx[17]}set finetuneOptions(e){this.$set({finetuneOptions:e}),flush()}}var index$4={util:["finetune",Finetune]};function get_each_context$4(e,t,o){const n=e.slice();return n[47]=t[o].key,n[48]=t[o].index,n[49]=t[o].translate,n[50]=t[o].scale,n[14]=t[o].rotate,n[51]=t[o].dir,n[52]=t[o].center,n[53]=t[o].type,n}function create_if_block_1$4(e){let t,o;return{c(){attr(t=element("div"),"class","DokaShapeManipulator"),attr(t,"data-control","point"),attr(t,"style",o=`pointer-events:none;transform: translate3d(${e[52].x}px, ${e[52].y}px, 0) scale(${e[5]}, ${e[5]}); opacity: ${e[6]}`)},m(e,o){insert(e,t,o)},p(e,n){104&n[0]&&o!==(o=`pointer-events:none;transform: translate3d(${e[52].x}px, ${e[52].y}px, 0) scale(${e[5]}, ${e[5]}); opacity: ${e[6]}`)&&attr(t,"style",o)},d(e){e&&detach(t)}}}function create_each_block$4(e,t){let o,n,r,a,i,s,l,c,p;function u(...e){return t[18](t[48],...e)}let d="edge"===t[53]&&"both"!==t[2]&&create_if_block_1$4(t);return{key:e,first:null,c(){o=element("div"),s=space(),d&&d.c(),l=empty(),attr(o,"role","button"),attr(o,"aria-label",n=`Drag ${t[53]} ${t[47]}`),attr(o,"tabindex",r="edge"===t[53]?-1:0),attr(o,"class","DokaShapeManipulator"),attr(o,"data-control",a=t[53]),attr(o,"style",i=`cursor: ${t[51]?t[51]+"-resize":"move"}; transform: translate3d(${t[49].x}px, ${t[49].y}px, 0) rotate(${t[14]}rad) scale(${"point"===t[53]?t[5]:t[50].x}, ${"point"===t[53]?t[5]:t[50].y}); opacity: ${t[6]}`),this.first=o},m(e,n){insert(e,o,n),insert(e,s,n),d&&d.m(e,n),insert(e,l,n),c||(p=[listen(o,"keydown",t[7]),listen(o,"keyup",t[8]),listen(o,"nudge",u),action_destroyer(nudgeable.call(null,o)),listen(o,"interactionstart",function(){is_function(t[11]("start",t[48]))&&t[11]("start",t[48]).apply(this,arguments)}),listen(o,"interactionupdate",function(){is_function(t[11]("move",t[48]))&&t[11]("move",t[48]).apply(this,arguments)}),listen(o,"interactionend",function(){is_function(t[11]("end",t[48]))&&t[11]("end",t[48]).apply(this,arguments)}),action_destroyer(interactable.call(null,o))],c=!0)},p(e,s){t=e,8&s[0]&&n!==(n=`Drag ${t[53]} ${t[47]}`)&&attr(o,"aria-label",n),8&s[0]&&r!==(r="edge"===t[53]?-1:0)&&attr(o,"tabindex",r),8&s[0]&&a!==(a=t[53])&&attr(o,"data-control",a),104&s[0]&&i!==(i=`cursor: ${t[51]?t[51]+"-resize":"move"}; transform: translate3d(${t[49].x}px, ${t[49].y}px, 0) rotate(${t[14]}rad) scale(${"point"===t[53]?t[5]:t[50].x}, ${"point"===t[53]?t[5]:t[50].y}); opacity: ${t[6]}`)&&attr(o,"style",i),"edge"===t[53]&&"both"!==t[2]?d?d.p(t,s):((d=create_if_block_1$4(t)).c(),d.m(l.parentNode,l)):d&&(d.d(1),d=null)},d(e){e&&detach(o),e&&detach(s),d&&d.d(e),e&&detach(l),c=!1,run_all(p)}}}function create_if_block$4(e){let t,o,n,r;return{c(){attr(t=element("div"),"role","button"),attr(t,"aria-label","Drag rotator"),attr(t,"tabindex","0"),attr(t,"class","DokaShapeManipulator"),attr(t,"data-control","rotate"),attr(t,"style",o=`transform: translate3d(${e[0].x}px, ${e[0].y}px, 0) scale(${e[5]}, ${e[5]}); opacity: ${e[6]}`)},m(o,a){insert(o,t,a),n||(r=[listen(t,"keydown",e[7]),listen(t,"keyup",e[8]),listen(t,"nudge",e[13]),action_destroyer(nudgeable.call(null,t)),listen(t,"interactionstart",e[14]("start")),listen(t,"interactionupdate",e[14]("move")),listen(t,"interactionend",e[14]("end")),action_destroyer(interactable.call(null,t))],n=!0)},p(e,n){97&n[0]&&o!==(o=`transform: translate3d(${e[0].x}px, ${e[0].y}px, 0) scale(${e[5]}, ${e[5]}); opacity: ${e[6]}`)&&attr(t,"style",o)},d(e){e&&detach(t),n=!1,run_all(r)}}}function create_fragment$d(e){let t,o,n=[],r=new Map,a=e[3];const i=e=>e[47];for(let t=0;t<a.length;t+=1){let o=get_each_context$4(e,a,t),s=i(o);r.set(s,n[t]=create_each_block$4(s,o))}let s=e[1]&&e[4]&&create_if_block$4(e);return{c(){for(let e=0;e<n.length;e+=1)n[e].c();t=space(),s&&s.c(),o=empty()},m(e,r){for(let t=0;t<n.length;t+=1)n[t].m(e,r);insert(e,t,r),s&&s.m(e,r),insert(e,o,r)},p(e,l){6636&l[0]&&(a=e[3],n=update_keyed_each(n,l,i,1,e,a,r,t.parentNode,destroy_block,create_each_block$4,t,get_each_context$4)),e[1]&&e[4]?s?s.p(e,l):((s=create_if_block$4(e)).c(),s.m(o.parentNode,o)):s&&(s.d(1),s=null)},i:noop,o:noop,d(e){for(let t=0;t<n.length;t+=1)n[t].d(e);e&&detach(t),s&&s.d(e),e&&detach(o)}}}function instance$d(e,t,o){let n,r,a,i,s;const l=createEventDispatcher(),c=.5*QUART_PI,p=HALF_PI-c,u=HALF_PI+c,d=-HALF_PI,h=d-c,m=d+c,g=PI-c,f=-PI+c,_=c,$=-c,b=HALF_PI-QUART_PI,y=b-c,x=b+c,v=PI-QUART_PI,C=v-c,S=v+c,k=d-QUART_PI,w=k+c,R=k-c,T=d+QUART_PI,E=T+c,I=T-c;let{points:A=[]}=t,{rotatorPoint:M}=t,{visible:P=!1}=t,{enableResizing:D=!0}=t,{enableRotating:F=!0}=t,L=!1;const z=spring(.5,{precision:1e-4,stiffness:.3,damping:.7});component_subscribe(e,z,e=>o(5,i=e));const B=spring(0,{precision:.001});component_subscribe(e,B,e=>o(6,s=e));const O=e=>{let t="";return(e<=u&&e>=p||e>=h&&e<=m)&&(t="ns"),(e<=f||e>=g||e>=$&&e<=_)&&(t="ew"),(e>=C&&e<=S||e<=E&&e>=I)&&(t="nesw"),(e>=y&&e<=x||e<=w&&e>=R)&&(t="nwse"),t},U=(e,t)=>{l("resizestart",{indexes:e,translation:vectorCreateEmpty()}),l("resizemove",{indexes:e,translation:t}),l("resizeend",{indexes:e,translation:vectorCreateEmpty()})};return e.$$set=(e=>{"points"in e&&o(15,A=e.points),"rotatorPoint"in e&&o(0,M=e.rotatorPoint),"visible"in e&&o(16,P=e.visible),"enableResizing"in e&&o(17,D=e.enableResizing),"enableRotating"in e&&o(1,F=e.enableRotating)}),e.$$.update=(()=>{65536&e.$$.dirty[0]&&z.set(P?1:.5),65536&e.$$.dirty[0]&&B.set(P?1:0),131072&e.$$.dirty[0]&&o(2,n=!!D&&(isString(D)?D:"both")),32772&e.$$.dirty[0]&&o(3,r=n&&((e,t)=>{let o=0;const n=vectorCenter(e),r=[],a=e.length,i=2===a,s="both"!==t;for(;o<a;o++){const l=e[o-1]||e[e.length-1],c=e[o],p=e[o+1]||e[0],u=Math.atan2(p.y-c.y,p.x-c.x);if(!s){const e=vectorNormalize(vectorCreate(l.x-c.x,l.y-c.y)),t=vectorNormalize(vectorCreate(p.x-c.x,p.y-c.y)),n=vectorCreate(e.x+t.x,e.y+t.y);r.push({index:[o],key:`point-${o}`,type:"point",scale:{x:1,y:1},translate:{x:c.x,y:c.y},angle:void 0,rotate:i?0:u,center:c,dir:i?void 0:O(Math.atan2(n.y,n.x))})}if(i)continue;const d=vectorCreate(c.x+.5*(p.x-c.x),c.y+.5*(p.y-c.y));"horizontal"===t&&o%2==0||"vertical"===t&&o%2!=0||r.push({index:[o,o+1===a?0:o+1],key:`edge-${o}`,type:"edge",scale:{x:vectorDistance(c,p),y:1},translate:{x:c.x,y:c.y},angle:u,rotate:u,center:d,dir:O(Math.atan2(n.y-d.y,n.x-d.x))})}return r})(A,n)||[]),32768&e.$$.dirty[0]&&o(4,a=A.length>2)}),[M,F,n,r,a,i,s,e=>L=e.shiftKey,e=>L=!1,z,B,(e,t)=>({detail:o})=>{const n=o&&o.translation?o.translation:vectorCreate(0,0);l(`resize${e}`,{indexes:t,translation:n,shiftKey:L})},U,({detail:e})=>{l("rotatestart",{translation:vectorCreateEmpty()}),l("rotatemove",{translation:e}),l("rotateend",{translation:vectorCreateEmpty()})},e=>({detail:t})=>{const o=t&&t.translation?t.translation:vectorCreate(0,0);l(`rotate${e}`,{translation:o,shiftKey:L})},A,P,D,(e,{detail:t})=>U(e,t)]}class ShapeManipulator extends SvelteComponent{constructor(e){super(),init(this,e,instance$d,create_fragment$d,safe_not_equal,{points:15,rotatorPoint:0,visible:16,enableResizing:17,enableRotating:1},[-1,-1])}}var getEventPositionInEditor=(e,t)=>{const o=getEventPositionInViewport(e);return vectorSubtract(o,t)},cursorMoveToEnd=e=>e.selectionStart=e.selectionEnd=e.value.length;let result=null;var supportsVisualViewport=()=>(null===result&&(result=isBrowser()&&"visualViewport"in window),result),createSoftKeyboardObserver=e=>{if(!supportsVisualViewport())return!1;const t=visualViewport.height,o=()=>{e(visualViewport.height<t?"visible":"hidden")};return visualViewport.addEventListener("resize",o),()=>visualViewport.removeEventListener("resize",o)};function create_fragment$c(e){let t,o,n,r,a,i,s,l,c,p;n=new Button({props:{onclick:e[1],label:e[5],icon:e[7],hideLabel:!e[6]}});const u=e[20].default,d=create_slot(u,e,e[19],null);return s=new Button({props:{onclick:e[0],label:e[2],icon:e[4],hideLabel:!e[3],class:"DokaInputFormButtonConfirm"}}),{c(){t=element("div"),o=element("div"),create_component(n.$$.fragment),r=space(),a=element("div"),d&&d.c(),i=space(),create_component(s.$$.fragment),attr(a,"class","DokaInputFormFields"),attr(o,"class","DokaInputFormInner"),attr(t,"class","DokaInputForm"),attr(t,"style",e[9])},m(u,h){insert(u,t,h),append(t,o),mount_component(n,o,null),append(o,r),append(o,a),d&&d.m(a,null),append(o,i),mount_component(s,o,null),e[21](t),l=!0,c||(p=[listen(t,"focusin",e[10]),listen(t,"focusout",e[11]),listen(t,"measure",e[12]),action_destroyer(measurable.call(null,t))],c=!0)},p(e,o){const r={};2&o[0]&&(r.onclick=e[1]),32&o[0]&&(r.label=e[5]),128&o[0]&&(r.icon=e[7]),64&o[0]&&(r.hideLabel=!e[6]),n.$set(r),d&&d.p&&524288&o[0]&&update_slot(d,u,e,e[19],o,null,null);const a={};1&o[0]&&(a.onclick=e[0]),4&o[0]&&(a.label=e[2]),16&o[0]&&(a.icon=e[4]),8&o[0]&&(a.hideLabel=!e[3]),s.$set(a),(!l||512&o[0])&&attr(t,"style",e[9])},i(e){l||(transition_in(n.$$.fragment,e),transition_in(d,e),transition_in(s.$$.fragment,e),l=!0)},o(e){transition_out(n.$$.fragment,e),transition_out(d,e),transition_out(s.$$.fragment,e),l=!1},d(o){o&&detach(t),destroy_component(n),d&&d.d(o),destroy_component(s),e[21](null),c=!1,run_all(p)}}}const panelDelay=200;function instance$c(e,t,o){let n,r,a,i,{$$slots:s={},$$scope:l}=t,{onconfirm:c}=t,{oncancel:p}=t,{autoFocus:u=!0}=t,{autoPositionCursor:d=!0}=t,{labelConfirm:h}=t,{labelConfirmShow:m=!0}=t,{iconConfirm:g}=t,{labelCancel:f}=t,{labelCancelShow:_=!1}=t,{iconCancel:$}=t,{panelOffset:b=vectorCreateEmpty()}=t,y=!1,x=void 0,v=void 0,C="",S=0;const k=()=>{i.querySelector("input, textarea").focus()},w=()=>{y=!0,T||!isIOS()&&!isAndroid()||o(16,C="top:1em;bottom:auto;"),isIOS()&&(e=>{let t;const o=e=>t=e.touches[0].screenY,n=e=>{const o=e.touches[0].screenY,n=e.target;/textarea/i.test(n.nodeName)?(o>t?0==n.scrollTop&&e.preventDefault():o<t?n.scrollTop+n.offsetHeight==n.scrollHeight&&e.preventDefault():e.preventDefault(),t=o):e.preventDefault()};e.addEventListener("touchstart",o),e.addEventListener("touchmove",n)})(i),o(17,S=1)};let R;const T=createSoftKeyboardObserver(e=>{r&&("hidden"!==e||y?(clearTimeout(v),v=void 0,o(16,C=`top:${visualViewport.height-x-b.y}px`),"visible"===e?(o(8,i.dataset.layout="stick",i),k(),w()):(y=!1,o(17,S=0))):k())});return onMount(()=>{u&&k()}),onDestroy(()=>{T&&T()}),e.$$set=(e=>{"onconfirm"in e&&o(0,c=e.onconfirm),"oncancel"in e&&o(1,p=e.oncancel),"autoFocus"in e&&o(13,u=e.autoFocus),"autoPositionCursor"in e&&o(14,d=e.autoPositionCursor),"labelConfirm"in e&&o(2,h=e.labelConfirm),"labelConfirmShow"in e&&o(3,m=e.labelConfirmShow),"iconConfirm"in e&&o(4,g=e.iconConfirm),"labelCancel"in e&&o(5,f=e.labelCancel),"labelCancelShow"in e&&o(6,_=e.labelCancelShow),"iconCancel"in e&&o(7,$=e.iconCancel),"panelOffset"in e&&o(15,b=e.panelOffset),"$$scope"in e&&o(19,l=e.$$scope)}),e.$$.update=(()=>{256&e.$$.dirty[0]&&o(18,n=i&&getComputedStyle(i)),262144&e.$$.dirty[0]&&(r=n&&"1"===n.getPropertyValue("--editor-modal")),196608&e.$$.dirty[0]&&o(9,a=`opacity:${S};${C}`)}),[c,p,h,m,g,f,_,$,i,a,e=>{(e=>/textarea/i.test(e))(e.target)&&(R=Date.now(),d&&cursorMoveToEnd(e.target),clearTimeout(v),v=setTimeout(w,panelDelay))},e=>{Date.now()-R>50||(e.stopPropagation(),k())},({detail:e})=>{x=e.height},u,d,b,C,S,n,l,s,function(e){binding_callbacks[e?"unshift":"push"](()=>{o(8,i=e)})}]}class InputForm extends SvelteComponent{constructor(e){super(),init(this,e,instance$c,create_fragment$c,safe_not_equal,{onconfirm:0,oncancel:1,autoFocus:13,autoPositionCursor:14,labelConfirm:2,labelConfirmShow:3,iconConfirm:4,labelCancel:5,labelCancelShow:6,iconCancel:7,panelOffset:15},[-1,-1])}}function get_each_context$3(e,t,o){const n=e.slice();return n[149]=t[o],n[151]=o,n}function create_each_block$3(e,t){let o,n,r,a,i,s,l,c,p,u,d,h=t[149].name+"";function m(...e){return t[113](t[151],...e)}return r=new ColorPreview({props:{color:t[149].color}}),{key:e,first:null,c(){o=element("li"),n=element("button"),create_component(r.$$.fragment),a=space(),i=element("span"),s=text(h),c=space(),attr(n,"class","DokaShapeListItem"),attr(n,"type","button"),attr(n,"aria-label",l="Select shape "+t[149].name),this.first=o},m(e,t){insert(e,o,t),append(o,n),mount_component(r,n,null),append(n,a),append(n,i),append(i,s),append(o,c),p=!0,u||(d=listen(n,"click",m),u=!0)},p(e,o){t=e;const a={};524288&o[0]&&(a.color=t[149].color),r.$set(a),(!p||524288&o[0])&&h!==(h=t[149].name+"")&&set_data(s,h),(!p||524288&o[0]&&l!==(l="Select shape "+t[149].name))&&attr(n,"aria-label",l)},i(e){p||(transition_in(r.$$.fragment,e),p=!0)},o(e){transition_out(r.$$.fragment,e),p=!1},d(e){e&&detach(o),destroy_component(r),u=!1,d()}}}function create_if_block_2$2(e){let t,o;return(t=new ShapeManipulator({props:{visible:!0,points:e[8],rotatorPoint:e[14],enableResizing:e[13],enableRotating:e[6]}})).$on("resizestart",e[25]),t.$on("resizemove",e[26]),t.$on("resizeend",e[27]),t.$on("rotatestart",e[28]),t.$on("rotatemove",e[29]),t.$on("rotateend",e[30]),{c(){create_component(t.$$.fragment)},m(e,n){mount_component(t,e,n),o=!0},p(e,o){const n={};256&o[0]&&(n.points=e[8]),16384&o[0]&&(n.rotatorPoint=e[14]),8192&o[0]&&(n.enableResizing=e[13]),64&o[0]&&(n.enableRotating=e[6]),t.$set(n)},i(e){o||(transition_in(t.$$.fragment,e),o=!0)},o(e){transition_out(t.$$.fragment,e),o=!1},d(e){destroy_component(t,e)}}}function create_if_block_1$3(e){let t,o;return t=new InputForm({props:{panelOffset:e[1],onconfirm:e[36],oncancel:e[37],labelCancel:e[3].shapeLabelInputCancel,iconCancel:e[3].shapeIconInputCancel,labelConfirm:e[3].shapeLabelInputConfirm,iconConfirm:e[3].shapeIconInputConfirm,$$slots:{default:[create_default_slot$5]},$$scope:{ctx:e}}}),{c(){create_component(t.$$.fragment)},m(e,n){mount_component(t,e,n),o=!0},p(e,o){const n={};2&o[0]&&(n.panelOffset=e[1]),8&o[0]&&(n.labelCancel=e[3].shapeLabelInputCancel),8&o[0]&&(n.iconCancel=e[3].shapeIconInputCancel),8&o[0]&&(n.labelConfirm=e[3].shapeLabelInputConfirm),8&o[0]&&(n.iconConfirm=e[3].shapeIconInputConfirm),100352&o[0]|268435456&o[4]&&(n.$$scope={dirty:o,ctx:e}),t.$set(n)},i(e){o||(transition_in(t.$$.fragment,e),o=!0)},o(e){transition_out(t.$$.fragment,e),o=!1},d(e){destroy_component(t,e)}}}function create_default_slot$5(e){let t,o,n;return{c(){attr(t=element("textarea"),"style",e[16]),attr(t,"spellcheck","false"),attr(t,"autocorrect","off"),attr(t,"autocapitalize","off"),t.value=e[15]},m(r,a){insert(r,t,a),e[114](t),o||(n=[listen(t,"keydown",e[34]),listen(t,"keypress",e[33]),listen(t,"keyup",e[35]),listen(t,"input",e[32])],o=!0)},p(e,o){65536&o[0]&&attr(t,"style",e[16]),32768&o[0]&&(t.value=e[15])},d(r){r&&detach(t),e[114](null),o=!1,run_all(n)}}}function create_if_block$3(e){let t,o,n,r,a;return o=new DynamicComponentTree_1({props:{items:e[18]}}),{c(){t=element("div"),create_component(o.$$.fragment),attr(t,"class","DokaShapeControls"),attr(t,"style",e[17])},m(i,s){insert(i,t,s),mount_component(o,t,null),n=!0,r||(a=[listen(t,"measure",e[115]),action_destroyer(measurable.call(null,t))],r=!0)},p(e,r){const a={};262144&r[0]&&(a.items=e[18]),o.$set(a),(!n||131072&r[0])&&attr(t,"style",e[17])},i(e){n||(transition_in(o.$$.fragment,e),n=!0)},o(e){transition_out(o.$$.fragment,e),n=!1},d(e){e&&detach(t),destroy_component(o),r=!1,run_all(a)}}}function create_fragment$b(e){let t,o,n,r,a,i,s,l,c,p,u=[],d=new Map,h=e[19];const m=e=>e[149].id;for(let t=0;t<h.length;t+=1){let o=get_each_context$3(e,h,t),n=m(o);d.set(n,u[t]=create_each_block$3(n,o))}let g=e[7]&&create_if_block_2$2(e),f=e[9]&&create_if_block_1$3(e),_=e[10]>0&&create_if_block$3(e);return{c(){t=element("div"),o=element("nav"),n=element("ul");for(let e=0;e<u.length;e+=1)u[e].c();r=space(),g&&g.c(),a=space(),f&&f.c(),i=space(),_&&_.c(),attr(o,"class","DokaShapeList"),attr(o,"data-visible",e[12]),attr(t,"class","DokaShapeEditor"),attr(t,"tabindex","0")},m(d,h){insert(d,t,h),append(t,o),append(o,n);for(let e=0;e<u.length;e+=1)u[e].m(n,null);append(t,r),g&&g.m(t,null),append(t,a),f&&f.m(t,null),append(t,i),_&&_.m(t,null),l=!0,c||(p=[listen(o,"focusin",e[40]),listen(o,"focusout",e[41]),listen(t,"keydown",e[31]),listen(t,"nudge",e[39]),listen(t,"measure",e[112]),action_destroyer(measurable.call(null,t)),action_destroyer(nudgeable.call(null,t)),listen(t,"interactionstart",e[21]),listen(t,"interactionupdate",e[22]),listen(t,"interactionrelease",e[23]),listen(t,"interactionend",e[24]),action_destroyer(s=interactable.call(null,t,{drag:!0,pinch:!0,inertia:!0,matchTarget:!0,getEventPosition:e[116]}))],c=!0)},p(e,r){524305&r[0]&&(h=e[19],group_outros(),u=update_keyed_each(u,r,m,1,e,h,d,n,outro_and_destroy_block,create_each_block$3,null,get_each_context$3),check_outros()),(!l||4096&r[0])&&attr(o,"data-visible",e[12]),e[7]?g?(g.p(e,r),128&r[0]&&transition_in(g,1)):((g=create_if_block_2$2(e)).c(),transition_in(g,1),g.m(t,a)):g&&(group_outros(),transition_out(g,1,1,()=>{g=null}),check_outros()),e[9]?f?(f.p(e,r),512&r[0]&&transition_in(f,1)):((f=create_if_block_1$3(e)).c(),transition_in(f,1),f.m(t,i)):f&&(group_outros(),transition_out(f,1,1,()=>{f=null}),check_outros()),e[10]>0?_?(_.p(e,r),1024&r[0]&&transition_in(_,1)):((_=create_if_block$3(e)).c(),transition_in(_,1),_.m(t,null)):_&&(group_outros(),transition_out(_,1,1,()=>{_=null}),check_outros()),s&&is_function(s.update)&&4&r[0]&&s.update.call(null,{drag:!0,pinch:!0,inertia:!0,matchTarget:!0,getEventPosition:e[116]})},i(e){if(!l){for(let e=0;e<h.length;e+=1)transition_in(u[e]);transition_in(g),transition_in(f),transition_in(_),l=!0}},o(e){for(let e=0;e<u.length;e+=1)transition_out(u[e]);transition_out(g),transition_out(f),transition_out(_),l=!1},d(e){e&&detach(t);for(let e=0;e<u.length;e+=1)u[e].d();g&&g.d(),f&&f.d(),_&&_.d(),c=!1,run_all(p)}}}const ROTATION_CONTROL_OFFSET=20,MIN_TEXT_MARKUP_WIDTH=10,shapeControlDist=16;function instance$b(e,t,o){let n,r,a,i,s,l,c,p,u,d,h,m,g,f,_,$,b,y,x,v,C,S,k,w,R,T,E,I,A,M,P,D,F,L,z,{markup:B}=t,{offset:O}=t,{rotation:U=0}=t,{scale:N}=t,{ui:V}=t,{opacity:H=1}=t,{parentRect:W}=t,{rootRect:G}=t,{utilRect:j}=t,{oninteractionstart:q=noop$1}=t,{oninteractionupdate:X=noop$1}=t,{oninteractionrelease:Y=noop$1}=t,{oninteractionend:K=noop$1}=t,{onaddshape:Z=noop$1}=t,{onupdateshape:J=noop$1}=t,{onselectshape:Q=noop$1}=t,{onremoveshape:ee=noop$1}=t,{beforeSelectShape:te=(()=>!0)}=t,{beforeDeselectShape:oe=(()=>!0)}=t,{beforeRemoveShape:ne=(()=>!0)}=t,{beforeUpdateShape:re=((e,t)=>t)}=t,{willRenderShapeControls:ae=passthrough}=t,{mapEditorPointToImagePoint:ie}=t,{mapImagePointToEditorPoint:se}=t,{enableButtonFlipVertical:le=!1}=t,{locale:ce}=t;const pe=(e,t,o)=>{let n=re({...e},t,{...o});shapeUpdateProps(e,n,o)},ue=(e,t,o,n)=>{if(o)return!!polyPointIntersectionConvex(e,rectRotate(t,o,n||rectCenter(t)));const[r,a,i,s]=rectToBounds(t);return e.x>=s&&e.x<=a&&e.y>=r&&e.y<=i},de=getContext("keysPressed");component_subscribe(e,de,e=>o(123,L=e));const he=(e,t)=>{const o=se(e);return ie(vectorAdd(o,t))},me=(e,t,o)=>{if(shapeIsLine(e)){const n=he(shapeLineGetStartPoint(t),o),r=he(shapeLineGetEndPoint(t),o);pe(e,{x1:n.x,y1:n.y,x2:r.x,y2:r.y},W)}else if(shapeIsRect(e)||shapeIsText(e)||shapeIsEllipse(e)){const n=he(t,o);pe(e,n,W)}ye()};let ge;const fe=()=>{if(!B.length)return;const e=B[B.length-1];return e.isDraft?e:void 0},_e=(e,t=!0)=>{if(!fe())return e=Object.assign(e,{isDraft:!0}),xe(e,t)},$e=()=>{const e=fe();if(e)return Ce(e,"isDraft",!1),e},be=()=>{fe()&&o(0,B=B.slice(0,-1))},ye=()=>o(0,B),xe=(e,t=!0)=>(B.push(e),t&&ye(),e),ve=(e,t,o=!0)=>{e=Object.assign(e,t),o&&ye()},Ce=(e,t,o,n=!0)=>{e[t]=o,n&&ye()},Se=(e,t=!0)=>{B.forEach(t=>ve(t,e,!1)),t&&ye()},ke=()=>[...B].reverse().find(shapeIsSelected),we=()=>!!ke(),Re=(e,t=!0)=>{if(!ne(e))return!1;const n=B.filter(t=>t!==e);ee(e),t&&o(0,B=n)},Te=()=>{const e=ke();if(!e)return;const t=B.filter(e=>shapeCanRemove(e)&&shapeCanSelect(e)),o=t.findIndex(t=>t===e);if(!1===Re(e))return;if(Ee=e,t.length-1==0)return Ie();const n=o-1<0?t.length-1:o-1;Me(t[n])};let Ee=void 0;const Ie=()=>{Ee=Ae(),Se({isSelected:!1,isEditing:!1})},Ae=()=>B.find(shapeIsSelected),Me=(e,t=!0)=>{if(e.isDraft)return;const o=Ae()||Ee;Ee=void 0,te(o,e)&&(Ie(),shapeSelect(e),Q(e),t&&ye())},Pe=e=>{ve(e,{isSelected:!1,isEditing:!1})},De=e=>{ve(e,{isSelected:!0,isEditing:!0})},Fe=e=>{ve(e,{isSelected:!0,isEditing:!1})},Le=e=>{const t=e.filter(ne);return o(0,B=B.filter(e=>!t.includes(e))),t},ze=e=>{const t=textSize(e.text,e);return rectCreate(e.x,e.y,e.width?Math.min(e.width,t.width):t.width,e.height?Math.min(e.height,t.height):t.height)},Be=e=>{if(shapeHasSize(e))return rectCreateFromAny(e);if(shapeIsEllipse(e))return rectCreateFromEllipse(e);const t=ze(e);return t.width=Math.max(MIN_TEXT_MARKUP_WIDTH,e.width||t.width),t},Oe=e=>[...B].reverse().map(e=>({shape:e,priority:1})).filter(e=>shapeCanSelect(e.shape)).filter(t=>{const{shape:o}=t,n=shapeComputeDisplay(shapeDeepCopy(o),W);if(shapeIsRect(n))return ue(e,n,o.rotation);if(shapeIsText(n)){const r=Be(n),a=ue(e,r,o.rotation);let i=!1;if(a&&!shapeIsSelected(o)){const a=ze(n);"right"!==o.textAlign||o.flipX||(a.x=r.x+r.width-a.width),"center"===o.textAlign&&(a.x=r.x+.5*r.width-.5*a.width),(i=ue(e,a,o.rotation,rectCenter(r)))||(t.priority=-1)}return a}return shapeIsEllipse(n)?((e,t,o)=>{const n=t.rx,r=t.ry,a=t.x,i=t.y,s=o||0,l=Math.cos(s),c=Math.sin(s),p=n*n,u=r*r,d=l*(e.x-a)+c*(e.y-i),h=c*(e.x-a)-l*(e.y-i);return d*d/p+h*h/u<=1})(e,n,o.rotation):!!shapeIsLine(n)&&((e,t,o,n)=>{const r=Math.atan2(e.y-t.y,e.x-t.x),a=Math.atan2(e.y-o.y,e.x-o.x);if(r>0&&a>0||r<0&&a<0)return!1;const i=n*n,s=vectorCreate(o.x-t.x,o.y-t.y),l=vectorCreate(t.x-e.x,t.y-e.y),c=vectorDot(s,s),p=2*vectorDot(l,s);return p*p-4*c*(vectorDot(l,l)-i)>=0})(e,shapeLineGetStartPoint(n),shapeLineGetEndPoint(n),16)}).sort((e,t)=>e.priority<t.priority?1:e.priority>t.priority?-1:0),Ue=(e,t)=>{const o=lineCreate(e,t);return B.filter(shapeCanErase).filter(e=>!!linePointsIntersection(o,je(shapeComputeDisplay(shapeDeepCopy(e),W))))};let Ne=void 0,Ve=void 0,He=void 0,We=void 0,Ge=!1;const je=e=>{let t,o;if(shapeIsRect(e))t=rectCenter(e),o=rectGetCorners(e),(e.flipX||e.flipY)&&vectorsFlip(o,e.flipX,e.flipY,t.x,t.y),o=vectorsRotate(o,e.rotation,t.x,t.y);else if(shapeIsEllipse(e))t=e,o=rectGetCorners(rectCreateFromEllipse(e)),(e.flipX||e.flipY)&&vectorsFlip(o,e.flipX,e.flipY,t.x,t.y),o=vectorsRotate(o,e.rotation,t.x,t.y);else if(shapeIsLine(e))o=[shapeLineGetStartPoint(e),shapeLineGetEndPoint(e)],t=vectorCenter(o);else if(shapeIsPath(e))o=[...e.points],t=vectorCenter(o);else if(shapeIsText(e)){const n=Be(e);n.width=Math.max(MIN_TEXT_MARKUP_WIDTH,n.width),t=rectCenter(n),o=rectGetCorners(n),(e.flipX||e.flipY)&&vectorsFlip(o,e.flipX,e.flipY,t.x,t.y),o=vectorsRotate(o,e.rotation,t.x,t.y)}return o},qe=e=>{const t=je(e);let o,n;return e.flipY?(o=vectorCenter([t[0],t[1]]),n=vectorNormalize(vectorCreate(t[1].x-t[2].x,t[1].y-t[2].y))):(o=vectorCenter([t[2],t[3]]),n=vectorNormalize(vectorCreate(t[2].x-t[1].x,t[2].y-t[1].y))),vectorMultiply(n,ROTATION_CONTROL_OFFSET/N),{origin:o,dir:n}};onDestroy(()=>{o(42,V=V.filter(e=>"markup-manipulator-segment"!==e.id))});let Xe;const Ye=()=>{const e=shapeIsTextLine(n)?Ze(Xe.value):Xe.value,t=shapeCanInput(n,e),o=!0===t?e:t;let r=y.x,a=y.y;if(!n.height&&0!==n.rotation){const e=textSize(o,n),t=rectCreate(y.x,y.y,e.width,e.height),[i]=rectRotate(t,y.rotation),[s]=rectRotate(v,y.rotation);r+=s.x-i.x,a+=s.y-i.y}ve(n,{x:r,y:a,text:o})},Ke=()=>De(n),Ze=e=>e.split(/[\n\r]/g).map(e=>e.trim()).filter(e=>e.length).join(" "),Je=()=>{let e=n.isDraft;n.isDraft&&$e(),Ye(),Fe(n),e?Z(n):J(n)},Qe=()=>{ve(n,{text:y.text,x:y.x,y:y.y}),n.isDraft&&be(),Fe(n)},et=e=>{e.stopPropagation();const t=n.flipX||!1;Ce(n,"flipX",!t),J(n)},tt=e=>{e.stopPropagation();const t=n.flipY||!1;Ce(n,"flipY",!t),J(n)},ot=e=>{e.stopPropagation(),e.target.blur(),Te()},nt=e=>{e.stopPropagation(),B.findIndex(e=>e===n)!==B.length-1&&(o(0,B=B.filter(e=>e!==n).concat([n])),J(n))},rt=e=>{e.stopPropagation();const t=shapeDeepCopy(n);t.id=getUniqueId();const o=vectorCreate(50,-50);if(shapeIsLine(t)){const e=shapeGetPropsPixelValues(t,["x1","y1","x2","y2"],W);e.x1+=o.x,e.y1+=o.y,e.x2+=o.x,e.y2+=o.y,shapeUpdateProps(t,e,W)}else{const e=shapeGetPropsPixelValues(t,["x","y"],W);e.x+=50,e.y-=50,shapeUpdateProps(t,e,W)}B.push(t),Z(t),Me(t)},at=spring(0,{stiffness:.2,damping:.7});let it;component_subscribe(e,at,e=>o(10,z=e));let st=!1;return e.$$set=(e=>{"markup"in e&&o(0,B=e.markup),"offset"in e&&o(1,O=e.offset),"rotation"in e&&o(43,U=e.rotation),"scale"in e&&o(44,N=e.scale),"ui"in e&&o(42,V=e.ui),"opacity"in e&&o(45,H=e.opacity),"parentRect"in e&&o(46,W=e.parentRect),"rootRect"in e&&o(2,G=e.rootRect),"utilRect"in e&&o(47,j=e.utilRect),"oninteractionstart"in e&&o(48,q=e.oninteractionstart),"oninteractionupdate"in e&&o(49,X=e.oninteractionupdate),"oninteractionrelease"in e&&o(50,Y=e.oninteractionrelease),"oninteractionend"in e&&o(51,K=e.oninteractionend),"onaddshape"in e&&o(52,Z=e.onaddshape),"onupdateshape"in e&&o(53,J=e.onupdateshape),"onselectshape"in e&&o(54,Q=e.onselectshape),"onremoveshape"in e&&o(55,ee=e.onremoveshape),"beforeSelectShape"in e&&o(56,te=e.beforeSelectShape),"beforeDeselectShape"in e&&o(57,oe=e.beforeDeselectShape),"beforeRemoveShape"in e&&o(58,ne=e.beforeRemoveShape),"beforeUpdateShape"in e&&o(59,re=e.beforeUpdateShape),"willRenderShapeControls"in e&&o(60,ae=e.willRenderShapeControls),"mapEditorPointToImagePoint"in e&&o(61,ie=e.mapEditorPointToImagePoint),"mapImagePointToEditorPoint"in e&&o(62,se=e.mapImagePointToEditorPoint),"enableButtonFlipVertical"in e&&o(63,le=e.enableButtonFlipVertical),"locale"in e&&o(3,ce=e.locale)}),e.$$.update=(()=>{if(1&e.$$.dirty[0]&&o(91,n=B&&(fe()||ke())),536870912&e.$$.dirty[2]&&o(92,r=n&&!shapeIsDraft(n)?n.id:void 0),32768&e.$$.dirty[1]|536870912&e.$$.dirty[2]&&o(93,a=n&&shapeComputeDisplay(shapeDeepCopy(n),W)),536870912&e.$$.dirty[2]&&o(94,i=!(!n||!shapeIsDraft(n))),536870912&e.$$.dirty[2]&&o(95,s=n||void 0),536870912&e.$$.dirty[2]|1&e.$$.dirty[3]&&o(96,l=n&&!shapeIsPath(a)&&je(a)||[]),536870912&e.$$.dirty[2]&&o(97,c=n&&shapeCanResize(n)&&!shapeIsTextEditing(n)),536870912&e.$$.dirty[2]&&o(6,p=n&&shapeCanRotate(n)&&!shapeIsTextEditing(n)),536870912&e.$$.dirty[2]|16&e.$$.dirty[3]&&o(13,u=c&&hasProp(n,"text")&&!n.height?"horizontal":c),536870912&e.$$.dirty[2]|8&e.$$.dirty[3]&&o(7,d=n&&l.length>1),1&e.$$.dirty[2]|8&e.$$.dirty[3]&&o(98,h=l.map(se)),2&e.$$.dirty[0]|32&e.$$.dirty[3]&&o(8,m=h.map(e=>vectorCreate(e.x-O.x,e.y-O.y))),192&e.$$.dirty[0]|1&e.$$.dirty[3]&&o(99,g=d&&p&&(e=>{const t=qe(e),o=se({x:t.origin.x+t.dir.x,y:t.origin.y+t.dir.y});return{origin:se(t.origin),position:o}})(a)),2&e.$$.dirty[0]|64&e.$$.dirty[3]&&o(14,f=g&&vectorCreate(g.position.x-O.x,g.position.y-O.y)),16384&e.$$.dirty[1]&&o(100,_=H),256&e.$$.dirty[0]|18432&e.$$.dirty[1]|224&e.$$.dirty[3])if(H>0&&m.length>2){const e=[...h,h[0]],t=e.length,n=[],r=[1,1,1,_],a=1;for(let o=0;o<t-1;o++)n[o]={id:"markup-manipulator-segment",points:[e[o],e[o+1]],opacity:1,strokeColor:r,strokeWidth:a};g&&(n[n.length]={id:"markup-manipulator-segment",opacity:1,points:[{x:g.origin.x,y:g.origin.y},{x:g.position.x,y:g.position.y}],strokeColor:r,strokeWidth:a}),o(42,V=[...V.filter(e=>"markup-manipulator-segment"!==e.id),...n])}else o(42,V=V.filter(e=>"markup-manipulator-segment"!==e.id));536870912&e.$$.dirty[2]&&o(101,$=n&&shapeIsText(n)),536870912&e.$$.dirty[2]|256&e.$$.dirty[3]&&o(9,b=$&&!1!==shapeCanInput(n)&&n.isEditing),512&e.$$.dirty[0]&&o(102,y=b?(()=>({...n}))():void 0),512&e.$$.dirty[3]&&o(103,x=y&&textSize(y.text,y)),1536&e.$$.dirty[3]&&(v=y&&rectCreate(y.x,y.y,x.width,x.height)),512&e.$$.dirty[0]|536870912&e.$$.dirty[2]&&o(15,C=b?n.text:""),512&e.$$.dirty[0]|4&e.$$.dirty[3]&&o(16,S=b&&`\n    text-align: ${s.textAlign||"left"};\n    font-family: ${s.fontFamily||"sans-serif"};\n`),536870912&e.$$.dirty[2]|2050&e.$$.dirty[3]&&o(104,k=n&&!i?n:k),2048&e.$$.dirty[3]&&o(105,w=k&&shapeCanFlip(k)),2048&e.$$.dirty[3]&&o(106,R=k&&shapeCanDuplicate(k)),2048&e.$$.dirty[3]&&o(107,T=k&&shapeCanRemove(k)),2048&e.$$.dirty[3]&&o(108,E=k&&shapeCanReorder(k)),2048&e.$$.dirty[3]&&o(109,I=k&&!1!==shapeCanInput(k)),512&e.$$.dirty[0]|805306368&e.$$.dirty[2]|2&e.$$.dirty[3]&&at.set(!n||i||Ge||b?0:1),256&e.$$.dirty[0]|536870912&e.$$.dirty[2]|131074&e.$$.dirty[3]&&o(110,A=n&&!i?(e=>vectorApply(vectorCreate(e.x+.5*e.width,e.y),snapToPixel))(rectCreateFromPoints(m)):A),32&e.$$.dirty[0]|65536&e.$$.dirty[1]|131072&e.$$.dirty[3]&&o(111,M=A&&it&&j&&(e=>{const t=j.x,o=j.y,n=t+j.width;let r=Math.max(e.x-.5*it.width,t),a=Math.max(e.y-it.height-shapeControlDist,o);return r+it.width>n&&(r=n-it.width),vectorCreate(r,a)})(A)),1024&e.$$.dirty[0]|262144&e.$$.dirty[3]&&o(17,P=M&&`transform: translate(${M.x}px, ${M.y}px);opacity:${z}`),8&e.$$.dirty[0]|536870912&e.$$.dirty[1]|1073741826&e.$$.dirty[2]|126976&e.$$.dirty[3]&&o(18,D=r&&ae([["div","alpha",{class:"DokaShapeControlsGroup"},[w&&[Button,"flip-horizontal",{onclick:et,label:ce.shapeTitleButtonFlipHorizontal,icon:ce.shapeIconButtonFlipHorizontal,hideLabel:!0}],w&&le&&[Button,"flip-vertical",{onclick:tt,label:ce.shapeTitleButtonFlipVertical,icon:ce.shapeIconButtonFlipVertical,hideLabel:!0}],E&&[Button,"to-front",{onclick:nt,label:ce.shapeTitleButtonMoveToFront,icon:ce.shapeIconButtonMoveToFront,hideLabel:!0}],R&&[Button,"duplicate",{onclick:rt,label:ce.shapeTitleButtonDuplicate,icon:ce.shapeIconButtonDuplicate,hideLabel:!0}],T&&[Button,"remove",{onclick:ot,label:ce.shapeTitleButtonRemove,icon:ce.shapeIconButtonRemove,hideLabel:!0}]]],I&&["div","beta",{class:"DokaShapeControlsGroup"},[[Button,"edit-text",{label:ce.shapeLabelInputText,onclick:Ke}]]]],r)),4&e.$$.dirty[0]&&G&&($||Ie()),9&e.$$.dirty[0]&&o(19,F=B.filter(shapeCanSelect).filter(e=>!shapeIsDraft(e)).map(e=>({id:e.id,color:shapeIsText(e)?e.color:shapeIsLine(e)?e.strokeColor:e.backgroundColor,name:e.name||ce[`shapeLabelTool${capitalizeFirstLetter(shapeGetDescription(e))}`]})))}),[B,O,G,ce,Me,it,p,d,m,b,z,Xe,st,u,f,C,S,P,D,F,de,e=>{const{origin:t}=e.detail;He=void 0,We=void 0,Ve=void 0,clearTimeout(Ne),Ne=setTimeout(()=>o(90,Ge=!0),250);const n=ie(vectorClone(t)),r=Oe(n),a=r.length&&r.shift().shape;a&&shapeIsSelected(a)?We=shapeComputeDisplay(shapeDeepCopy(He=a),W):(Ve=a,q(e))},e=>{if(He){if(!shapeCanMove(He))return;if(shapeIsTextEditing(He))return;return me(He,We,e.detail.translation)}X(e)},e=>{clearTimeout(Ne),o(90,Ge=!1),He?He.isEditing?Qe():e.detail.isDoubleTap&&shapeIsText(He)&&!1!==shapeCanInput(He)&&De(He):Y(e)},e=>{if(He)return J(He),void(He=void 0);const t=Ae(),o=Ve&&e.detail.isTap,n=!t||oe(t,Ve);n&&Ie(),K(e),n&&o&&Me(Ve)},e=>{o(90,Ge=!0),He=n,We=a},e=>{const{translation:t,indexes:o,shiftKey:n}=e.detail;((e,t,o,n,r)=>{if(shapeIsLine(e)){const[r]=o,a=L.includes(16)?(e,t)=>{const o=vectorDistance(e,t),n=vectorAngleBetween(e,t),r=Math.PI/4,a=r*Math.round(n/r)-U%r;t.x=e.x+o*Math.cos(a),t.y=e.y+o*Math.sin(a)}:(e,t)=>t;if(0===r){const o=he(shapeLineGetStartPoint(t),n);a(vectorCreate(t.x2,t.y2),o),pe(e,{x1:o.x,y1:o.y},W)}else if(1===r){const o=he(shapeLineGetEndPoint(t),n);a(vectorCreate(t.x1,t.y1),o),pe(e,{x2:o.x,y2:o.y},W)}}else if(shapeHasSize(e)||shapeIsEllipse(e)||shapeIsTextBox(e)){let a,i,s=!1;if(shapeIsEllipse(e))a=rectCreateFromEllipse(t);else if(shapeHasSize(e))a=rectCreateFromAny(t);else{s=!0,a=rectCreateFromAny(t);const e=textSize(t.text,t);a.height=e.height}e.aspectRatio?i=e.aspectRatio:r.shiftKey&&!s&&(i=a.width/a.height);const l=rectCreateFromAny(a),c=rectCenter(l),p=e.rotation,u=rectGetCorners(l),d=rectRotate(l,p);if(1===o.length){let t=o[0];const[r,a,s,l]=u,h=se(d[t]);vectorAdd(h,n);const m=ie(h),g=vectorCreate(m.x-d[t].x,m.y-d[t].y);e.flipX&&(g.x=-g.x),e.flipY&&(g.y=-g.y);const f=vectorRotate(vectorClone(g),-p),_=vectorCreate(u[t].x+f.x,u[t].y+f.y);let $;0===t&&($=s),1===t&&($=l),2===t&&($=r),3===t&&($=a);const b=rectCreateFromPoints($,_);if(i){const{width:e,height:t}=rectContainRect(b,i),[o,n,r,a]=rectToBounds(b);b.width=e,b.height=t,_.y<$.y&&(b.y=r-t),_.x<$.x&&(b.x=n-e)}const y=rectRotate(b,p,c),x=vectorCenter(y),v=vectorRotate(y[0],-p,x),C=vectorRotate(y[2],-p,x);(e.flipX||e.flipY)&&vectorsFlip([v,C],e.flipX,e.flipY,c.x,c.y);const S=rectCreateFromPoints(v,C);pe(e,shapeIsEllipse(e)?ellipseCreateFromRect(S):S,W)}else{const[t,r]=o.map(e=>d[e]),a={x:t.x+.5*(r.x-t.x),y:t.y+.5*(r.y-t.y)},[l,h]=o.map(e=>u[e]),[m,g]=o.map(e=>{const t=e+2;return t<4?u[t]:u[t-4]});l.x,h.x,l.x,l.y,h.y,l.y;const f={x:m.x+.5*(g.x-m.x),y:m.y+.5*(g.y-m.y)},_=se(a);vectorAdd(_,n);const $=ie(_),b=vectorCreate($.x-a.x,$.y-a.y);e.flipX&&(b.x=-b.x),e.flipY&&(b.y=-b.y);const y=vectorRotate(vectorClone(b),-p),x=vectorSubtract(vectorClone(l),h),v=vectorApply(x,e=>1-Math.abs(Math.sign(e))),C=vectorCreate(y.x*v.x,y.y*v.y);vectorAdd(l,C),vectorAdd(h,C);const S=rectCreateFromPoints(u);if(i){let e=S.width,t=S.height;0===v.y?t=e/i:e=t*i,S.width=e,S.height=t,0===v.y?S.y=f.y-.5*t:S.x=f.x-.5*e}const k=rectRotate(S,p,c),w=vectorCenter(k),R=vectorRotate(k[0],-p,w),T=vectorRotate(k[2],-p,w);(e.flipX||e.flipY)&&vectorsFlip([R,T],e.flipX,e.flipY,c.x,c.y);const E=rectCreateFromPoints(R,T);let I;shapeIsEllipse(e)?I=ellipseCreateFromRect(E):shapeHasSize(e)?I=E:s&&(I={x:E.x,y:E.y,width:E.width}),pe(e,I,W)}}ye()})(He,We,o,t,{shiftKey:n})},e=>{Me(He),He=void 0,o(90,Ge=!1),J(n)},e=>{ge=qe(a).origin,o(90,Ge=!0),He=n,We=a},e=>{const{translation:t,shiftKey:o}=e.detail;((e,t,o,n)=>{const r=Be(shapeComputeDisplay(shapeDeepCopy(e),W)),a=rectCenter(r),i=he(ge,o);let s=vectorAngleBetween(i,a)+Math.PI/2;if(n.shiftKey){const e=Math.PI/16;s=e*Math.round(s/e)-U%e}pe(e,{rotation:s},W),ye()})(He,0,t,{shiftKey:o})},()=>{Me(He),He=void 0,o(90,Ge=!1),J(n)},e=>{if(!we())return;const{key:t}=e;if(/escape/i.test(t))return Pe(n);/backspace/i.test(t)&&!/input|textarea/i.test(e.target.nodeName)&&(e.preventDefault(),Te())},Ye,e=>{const t=e.target.value,o=e.target.selectionStart,r=e.target.selectionEnd,a=t.substring(0,o),i=t.substring(r),s=a+e.key+i;if(shapeCanInput(n,s)!==s)return e.preventDefault()},e=>shapeIsTextLine(n)&&/enter/i.test(e.code)?e.preventDefault():/arrow/i.test(e.code)?e.stopPropagation():/escape/i.test(e.key)?Qe():void 0,e=>{const{key:t,ctrlKey:o,altKey:n}=e;if(/enter/i.test(t)&&o|n)return Je()},Je,Qe,at,e=>{const t=ke();t&&shapeCanMove(t)&&(We=shapeComputeDisplay(shapeDeepCopy(He=t),W),me(He,We,e.detail))},e=>{o(12,st=!0)},({relatedTarget:e})=>{e.classList.contains("shape-selector__button")||o(12,st=!1)},V,U,N,H,W,j,q,X,Y,K,Z,J,Q,ee,te,oe,ne,re,ae,ie,se,le,(e,t={})=>{let o,n,r,a=shapeIsEllipse(e),i=shapeIsText(e),s="relative"===t.position;return shapeIsPath(e)?{start:t=>{const{origin:a}=t.detail;n=4,o=vectorClone(a),r=vectorClone(a);const i=ie(a);s&&(i.x=s?toPercentage(i.x,W.width):i.x,i.y=s?toPercentage(i.y,W.height):i.y),_e({...e,points:[i]})},update:e=>{const t=fe(),{translation:a}=e.detail,i=vectorCreate(o.x+a.x,o.y+a.y),l=vectorDistance(r,i);if(fixPrecision(l,5)<=n)return;const c=vectorAngleBetween(i,r),p=n-l;r.x+=p*Math.cos(c),r.y+=p*Math.sin(c);const u=ie(r);u&&(u.x=s?toPercentage(u.x,W.width):u.x,u.y=s?toPercentage(u.y,W.height):u.y),t.points=t.points.concat(u),ye()},release:e=>e.detail.preventInertia(),end:e=>{if(e.detail.isTap)return be();const t=$e();Z(t)}}:a||i||shapeIsRect(e)?{start:t=>{const{origin:n}=t.detail;o=vectorClone(n);const r=ie(o),i={...e,rotation:-U,x:s?toPercentage(r.x,W.width):r.x,y:s?toPercentage(r.y,W.height):r.y};delete i.position,i.opacity=0,a?(i.rx=s?toPercentage(0):0,i.ry=s?toPercentage(0):0):(i.width=s?toPercentage(0):0,i.height=s?toPercentage(0):0),_e(i)},update:e=>{const t=fe();t.opacity=1;const{aspectRatio:n}=t;let{translation:r}=e.detail;if(n){const e=Math.abs(r.x)*n;r.x=r.x,r.y=e*Math.sign(r.y)}const i=vectorCreate(o.x+r.x,o.y+r.y),s=ie(o),l=ie(i),c={x:s.x+.5*(l.x-s.x),y:s.y+.5*(l.y-s.y)};vectorRotate(s,U,c),vectorRotate(l,U,c);const p=Math.min(s.x,l.x),u=Math.min(s.y,l.y);let d=Math.max(s.x,l.x)-p,h=Math.max(s.y,l.y)-u,m={};a?(m.x=p+.5*d,m.y=u+.5*h,m.rx=.5*d,m.ry=.5*h):(m.x=p,m.y=u,m.width=d,m.height=h),pe(t,m,W),ye()},release:e=>{e.detail.preventInertia()},end:e=>{const t=fe();if(e.detail.isTap)return be();if(t.opacity=1,!shapeIsText(t)){const e=$e();Z(e)}Me(t),shapeIsText(t)&&De(t)}}:shapeIsLine(e)?{start:t=>{const{origin:n}=t.detail,r=ie(n),a=vectorApply(r,snapToPixel);o=vectorClone(n),_e({...e,x1:s?toPercentage(a.x,W.width):a.x,y1:s?toPercentage(a.y,W.height):a.y,x2:s?toPercentage(a.x,W.width):a.x,y2:s?toPercentage(a.y,W.height):a.y,opacity:0})},update:e=>{const t=fe(),{translation:n}=e.detail,r=vectorAdd(vectorClone(o),n);if(L.includes(16)){const e=vectorDistance(o,r),t=vectorAngleBetween(o,r),n=Math.PI/4,a=n*Math.round(t/n);r.x=o.x+e*Math.cos(a),r.y=o.y+e*Math.sin(a)}const a=ie(r);ve(t,{x2:s?toPercentage(a.x,W.width):a.x,y2:s?toPercentage(a.y,W.height):a.y,opacity:1}),ye()},release:e=>e.detail.preventInertia(),end:e=>{const t=fe();if(e.detail.isTap)return be();t.opacity=1;const o=$e();Z(o),Me(o)}}:void 0},()=>{let e,t;return{start:o=>{e=o.detail.origin,t=e},update:o=>{const{translation:n}=o.detail,r=vectorCreate(e.x+n.x,e.y+n.y),a=Ue(ie(t),ie(r));Le(a).forEach(ee),t=vectorClone(r)},release:e=>e.detail.preventInertia(),end:()=>{}}},fe,_e,$e,be,(e={})=>({id:getUniqueId(),...e}),ye,xe,ve,Ce,(e,t,o=!0)=>{B.forEach(o=>Ce(o,e,t,!1)),o&&ye()},Se,ke,we,Re,Te,Ie,Pe,De,Fe,Le,ze,Be,Oe,Ue,Ge,n,r,a,i,s,l,c,h,g,_,$,y,x,k,w,R,T,E,I,A,M,function(t){bubble(e,t)},(e,t)=>Me(B[e]),function(e){binding_callbacks[e?"unshift":"push"](()=>{o(11,Xe=e)})},e=>o(5,it=e.detail),e=>getEventPositionInEditor(e,G)]}class ShapeLayoutEditor extends SvelteComponent{constructor(e){super(),init(this,e,instance$b,create_fragment$b,safe_not_equal,{markup:0,offset:1,rotation:43,scale:44,ui:42,opacity:45,parentRect:46,rootRect:2,utilRect:47,oninteractionstart:48,oninteractionupdate:49,oninteractionrelease:50,oninteractionend:51,onaddshape:52,onupdateshape:53,onselectshape:54,onremoveshape:55,beforeSelectShape:56,beforeDeselectShape:57,beforeRemoveShape:58,beforeUpdateShape:59,willRenderShapeControls:60,mapEditorPointToImagePoint:61,mapImagePointToEditorPoint:62,enableButtonFlipVertical:63,locale:3,createShape:64,eraseShape:65,getMarkupItemDraft:66,addMarkupItemDraft:67,confirmMarkupItemDraft:68,discardMarkupItemDraft:69,createMarkupItem:70,syncShapes:71,addShape:72,updateMarkupShape:73,updateMarkupShapeProperty:74,updateMarkupItemsShapeProperty:75,updateMarkupShapeItems:76,getActiveMarkupItem:77,hasActiveMarkupItem:78,removeShape:79,removeActiveMarkupItem:80,blurShapes:81,selectShape:4,deselectMarkupItem:82,editMarkupItem:83,finishEditMarkupItem:84,removeMarkupItems:85,getTextShapeRect:86,getMarkupShapeRect:87,getShapesAtPosition:88,getMarkupBetweenPoints:89},[-1,-1,-1,-1,-1])}get createShape(){return this.$$.ctx[64]}get eraseShape(){return this.$$.ctx[65]}get getMarkupItemDraft(){return this.$$.ctx[66]}get addMarkupItemDraft(){return this.$$.ctx[67]}get confirmMarkupItemDraft(){return this.$$.ctx[68]}get discardMarkupItemDraft(){return this.$$.ctx[69]}get createMarkupItem(){return this.$$.ctx[70]}get syncShapes(){return this.$$.ctx[71]}get addShape(){return this.$$.ctx[72]}get updateMarkupShape(){return this.$$.ctx[73]}get updateMarkupShapeProperty(){return this.$$.ctx[74]}get updateMarkupItemsShapeProperty(){return this.$$.ctx[75]}get updateMarkupShapeItems(){return this.$$.ctx[76]}get getActiveMarkupItem(){return this.$$.ctx[77]}get hasActiveMarkupItem(){return this.$$.ctx[78]}get removeShape(){return this.$$.ctx[79]}get removeActiveMarkupItem(){return this.$$.ctx[80]}get blurShapes(){return this.$$.ctx[81]}get selectShape(){return this.$$.ctx[4]}get deselectMarkupItem(){return this.$$.ctx[82]}get editMarkupItem(){return this.$$.ctx[83]}get finishEditMarkupItem(){return this.$$.ctx[84]}get removeMarkupItems(){return this.$$.ctx[85]}get getTextShapeRect(){return this.$$.ctx[86]}get getMarkupShapeRect(){return this.$$.ctx[87]}get getShapesAtPosition(){return this.$$.ctx[88]}get getMarkupBetweenPoints(){return this.$$.ctx[89]}}function get_each_context$2(e,t,o){const n=e.slice();return n[7]=t[o],n}function create_each_block$2(e,t){let o,n,r,a,i,s,l,c=localize(t[7].componentProps.title,t[1])+"";const p=[t[7].componentProps];var u=t[7].component;function d(e){let t={};for(let e=0;e<p.length;e+=1)t=assign(t,p[e]);return{props:t}}return u&&(i=new u(d())),{key:e,first:null,c(){o=element("li"),n=element("span"),r=text(c),a=space(),i&&create_component(i.$$.fragment),s=space(),attr(n,"class","DokaShapeStyleLabel"),attr(o,"class","DokaShapeStyle"),this.first=o},m(e,t){insert(e,o,t),append(o,n),append(n,r),append(o,a),i&&mount_component(i,o,null),append(o,s),l=!0},p(e,n){t=e,(!l||3&n)&&c!==(c=localize(t[7].componentProps.title,t[1])+"")&&set_data(r,c);const a=1&n?get_spread_update(p,[get_spread_object(t[7].componentProps)]):{};if(u!==(u=t[7].component)){if(i){group_outros();const e=i;transition_out(e.$$.fragment,1,0,()=>{destroy_component(e,1)}),check_outros()}u?(create_component((i=new u(d())).$$.fragment),transition_in(i.$$.fragment,1),mount_component(i,o,s)):i=null}else u&&i.$set(a)},i(e){l||(i&&transition_in(i.$$.fragment,e),l=!0)},o(e){i&&transition_out(i.$$.fragment,e),l=!1},d(e){e&&detach(o),i&&destroy_component(i)}}}function create_default_slot$4(e){let t,o,n=[],r=new Map,a=e[0];const i=e=>e[7].id;for(let t=0;t<a.length;t+=1){let o=get_each_context$2(e,a,t),s=i(o);r.set(s,n[t]=create_each_block$2(s,o))}return{c(){t=element("ul");for(let e=0;e<n.length;e+=1)n[e].c();attr(t,"class","DokaShapeStyleList")},m(e,r){insert(e,t,r);for(let e=0;e<n.length;e+=1)n[e].m(t,null);o=!0},p(e,o){3&o&&(a=e[0],group_outros(),n=update_keyed_each(n,o,i,1,e,a,r,t,outro_and_destroy_block,create_each_block$2,null,get_each_context$2),check_outros())},i(e){if(!o){for(let e=0;e<a.length;e+=1)transition_in(n[e]);o=!0}},o(e){for(let e=0;e<n.length;e+=1)transition_out(n[e]);o=!1},d(e){e&&detach(t);for(let e=0;e<n.length;e+=1)n[e].d()}}}function create_fragment$a(e){let t,o,n;return o=new Scrollable({props:{class:"DokaShapeStyles",elasticity:e[2],$$slots:{default:[create_default_slot$4]},$$scope:{ctx:e}}}),{c(){t=element("div"),create_component(o.$$.fragment),attr(t,"style",e[3])},m(e,r){insert(e,t,r),mount_component(o,t,null),n=!0},p(e,[r]){const a={};4&r&&(a.elasticity=e[2]),1027&r&&(a.$$scope={dirty:r,ctx:e}),o.$set(a),(!n||8&r)&&attr(t,"style",e[3])},i(e){n||(transition_in(o.$$.fragment,e),n=!0)},o(e){transition_out(o.$$.fragment,e),n=!1},d(e){e&&detach(t),destroy_component(o)}}}function instance$a(e,t,o){let n,r,{isActive:a=!1}=t,{controls:i=[]}=t,{locale:s}=t,{scrollElasticity:l}=t;const c=spring(0);return component_subscribe(e,c,e=>o(6,r=e)),e.$$set=(e=>{"isActive"in e&&o(5,a=e.isActive),"controls"in e&&o(0,i=e.controls),"locale"in e&&o(1,s=e.locale),"scrollElasticity"in e&&o(2,l=e.scrollElasticity)}),e.$$.update=(()=>{32&e.$$.dirty&&c.set(a?1:0),96&e.$$.dirty&&o(3,n=`opacity:${r};${!a&&"pointer-events:none;"}${r<=0&&"visibility:hidden"}`)}),[i,s,l,n,c,a,r]}class ShapeStyleControls extends SvelteComponent{constructor(e){super(),init(this,e,instance$a,create_fragment$a,safe_not_equal,{isActive:5,controls:0,locale:1,scrollElasticity:2})}}function get_each_context$1(e,t,o){const n=e.slice();return n[11]=t[o].key,n[2]=t[o].controls,n[12]=t[o].isActive,n}function create_each_block$1(e,t){let o,n,r;return n=new ShapeStyleControls({props:{isActive:t[12],controls:t[2],locale:t[0],scrollElasticity:t[1]}}),{key:e,first:null,c(){o=empty(),create_component(n.$$.fragment),this.first=o},m(e,t){insert(e,o,t),mount_component(n,e,t),r=!0},p(e,o){t=e;const r={};8&o&&(r.isActive=t[12]),8&o&&(r.controls=t[2]),1&o&&(r.locale=t[0]),2&o&&(r.scrollElasticity=t[1]),n.$set(r)},i(e){r||(transition_in(n.$$.fragment,e),r=!0)},o(e){transition_out(n.$$.fragment,e),r=!1},d(e){e&&detach(o),destroy_component(n,e)}}}function create_fragment$9(e){let t,o,n=[],r=new Map,a=e[3];const i=e=>e[11];for(let t=0;t<a.length;t+=1){let o=get_each_context$1(e,a,t),s=i(o);r.set(s,n[t]=create_each_block$1(s,o))}return{c(){t=element("div");for(let e=0;e<n.length;e+=1)n[e].c();attr(t,"class","DokaShapeStyleEditor")},m(e,r){insert(e,t,r);for(let e=0;e<n.length;e+=1)n[e].m(t,null);o=!0},p(e,[o]){11&o&&(a=e[3],group_outros(),n=update_keyed_each(n,o,i,1,e,a,r,t,outro_and_destroy_block,create_each_block$1,null,get_each_context$1),check_outros())},i(e){if(!o){for(let e=0;e<a.length;e+=1)transition_in(n[e]);o=!0}},o(e){for(let e=0;e<n.length;e+=1)transition_out(n[e]);o=!1},d(e){e&&detach(t);for(let e=0;e<n.length;e+=1)n[e].d()}}}function instance$9(e,t,o){let n,r,a,{controls:i={}}=t,{shape:s}=t,{onchange:l}=t,{locale:c}=t,{scrollElasticity:p}=t;const u=[];return e.$$set=(e=>{"controls"in e&&o(2,i=e.controls),"shape"in e&&o(4,s=e.shape),"onchange"in e&&o(5,l=e.onchange),"locale"in e&&o(0,c=e.locale),"scrollElasticity"in e&&o(1,p=e.scrollElasticity)}),e.$$.update=(()=>{4&e.$$.dirty&&o(6,n=Object.keys(i).filter(e=>i[e])),80&e.$$.dirty&&o(7,r=s&&n&&shapeCanStyle(s)?(e=>{const t=e.id||"tool";return n.filter(t=>t.split("_").every(t=>e.hasOwnProperty(t)&&shapeCanStyle(e,t))).map(o=>{const n=o.split("_"),r=n.length>1?n.map(t=>e[t]):e[o],[a,s]=i[o],p=isFunction(s.options)?s.options(e):s.options;return{id:`${t}_${o}`,component:a,componentProps:{...s,options:p,locale:c,value:r,optionLabelClass:"DokaButtonLabel",onchange:t=>{const r=isObject(t)&&!isArray(t)?t.value:t;s.onchange&&s.onchange(r,e);const a=n.length>1?n.reduce((e,t,o)=>({...e,[t]:Array.isArray(r)?r[o]:r}),{}):{[o]:r};l(a)}}}})})(s):[]),144&e.$$.dirty&&o(3,a=((e,t)=>{let o=u.find(t=>t.key===e);return o||(o={key:e,controls:t},u.push(o)),u.forEach(e=>e.isActive=!1),o.controls=t,o.isActive=!0,u})(Object.keys(s).join("_"),r))}),[c,p,i,a,s,l,n,r]}class ShapeStyleEditor extends SvelteComponent{constructor(e){super(),init(this,e,instance$9,create_fragment$9,safe_not_equal,{controls:2,shape:4,onchange:5,locale:0,scrollElasticity:1})}}function create_if_block_1$2(e){let t,o;return t=new Icon({props:{width:16,height:16,$$slots:{default:[create_default_slot$3]},$$scope:{ctx:e}}}),{c(){create_component(t.$$.fragment)},m(e,n){mount_component(t,e,n),o=!0},p(e,o){const n={};65&o&&(n.$$scope={dirty:o,ctx:e}),t.$set(n)},i(e){o||(transition_in(t.$$.fragment,e),o=!0)},o(e){transition_out(t.$$.fragment,e),o=!1},d(e){destroy_component(t,e)}}}function create_default_slot$3(e){let t,o=e[0].shapeIconButtonSelectSticker+"";return{c(){t=svg_element("g")},m(e,n){insert(e,t,n),t.innerHTML=o},p(e,n){1&n&&o!==(o=e[0].shapeIconButtonSelectSticker+"")&&(t.innerHTML=o)},d(e){e&&detach(t)}}}function create_if_block$2(e){let t,o,n=e[0].shapeLabelButtonSelectSticker+"";return{c(){t=element("span"),o=text(n)},m(e,n){insert(e,t,n),append(t,o)},p(e,t){1&t&&n!==(n=e[0].shapeLabelButtonSelectSticker+"")&&set_data(o,n)},d(e){e&&detach(t)}}}function create_fragment$8(e){let t,o,n,r,a,i,s,l,c=e[0].shapeIconButtonSelectSticker&&create_if_block_1$2(e),p=e[0].shapeLabelButtonSelectSticker&&create_if_block$2(e);return{c(){t=element("form"),o=element("input"),n=space(),r=element("label"),c&&c.c(),a=space(),p&&p.c(),attr(o,"id",e[2]),attr(o,"type","file"),attr(o,"accept","image/*"),attr(r,"for",e[2]),attr(t,"class","DokaShapePresetSelect")},m(u,d){insert(u,t,d),append(t,o),append(t,n),append(t,r),c&&c.m(r,null),append(r,a),p&&p.m(r,null),e[5](t),i=!0,s||(l=listen(o,"input",e[3]),s=!0)},p(e,[t]){e[0].shapeIconButtonSelectSticker?c?(c.p(e,t),1&t&&transition_in(c,1)):((c=create_if_block_1$2(e)).c(),transition_in(c,1),c.m(r,a)):c&&(group_outros(),transition_out(c,1,1,()=>{c=null}),check_outros()),e[0].shapeLabelButtonSelectSticker?p?p.p(e,t):((p=create_if_block$2(e)).c(),p.m(r,null)):p&&(p.d(1),p=null)},i(e){i||(transition_in(c),i=!0)},o(e){transition_out(c),i=!1},d(o){o&&detach(t),c&&c.d(),p&&p.d(),e[5](null),s=!1,l()}}}function instance$8(e,t,o){let{locale:n}=t,{oninput:r}=t;const a=`doka-preset-select-${getUniqueId()}`;let i;return e.$$set=(e=>{"locale"in e&&o(0,n=e.locale),"oninput"in e&&o(4,r=e.oninput)}),[n,i,a,e=>{Array.from(e.target.files).filter(isImage).forEach(r),i.reset()},r,function(e){binding_callbacks[e?"unshift":"push"](()=>{o(1,i=e)})}]}class ShapePresetSelect extends SvelteComponent{constructor(e){super(),init(this,e,instance$8,create_fragment$8,safe_not_equal,{locale:0,oninput:4})}}function create_fragment$7(e){let t,o,n;return{c(){attr(t=element("button"),"class","DokaDragButton"),attr(t,"title",e[1]),t.disabled=e[2]},m(r,a){insert(r,t,a),t.innerHTML=e[0],e[9](t),o||(n=listen(t,"pointerdown",e[4]),o=!0)},p(e,[o]){1&o&&(t.innerHTML=e[0]),2&o&&attr(t,"title",e[1]),4&o&&(t.disabled=e[2])},i:noop,o:noop,d(r){r&&detach(t),e[9](null),o=!1,n()}}}function instance$7(e,t,o){let n,{html:r}=t,{title:a}=t,{onclick:i}=t,{disabled:s=!1}=t,{ongrab:l=noop$1}=t,{ondrag:c=noop$1}=t,{ondrop:p=noop$1}=t;const u=e=>vectorDistanceSquared(d,vectorCreate(e.pageX,e.pageY))<256;let d;const h=e=>{document.documentElement.removeEventListener("pointermove",m),document.documentElement.removeEventListener("pointerup",h);const t=vectorCreate(e.pageX,e.pageY);if(vectorDistanceSquared(d,t)<32)return i(e);u(e)||p(e)},m=e=>{u(e)||c(e)};return e.$$set=(e=>{"html"in e&&o(0,r=e.html),"title"in e&&o(1,a=e.title),"onclick"in e&&o(5,i=e.onclick),"disabled"in e&&o(2,s=e.disabled),"ongrab"in e&&o(6,l=e.ongrab),"ondrag"in e&&o(7,c=e.ondrag),"ondrop"in e&&o(8,p=e.ondrop)}),[r,a,s,n,e=>{d=vectorCreate(e.pageX,e.pageY),l(e),document.documentElement.addEventListener("pointermove",m),document.documentElement.addEventListener("pointerup",h)},i,l,c,p,function(e){binding_callbacks[e?"unshift":"push"](()=>{o(3,n=e)})}]}class DragButton extends SvelteComponent{constructor(e){super(),init(this,e,instance$7,create_fragment$7,safe_not_equal,{html:0,title:1,onclick:5,disabled:2,ongrab:6,ondrag:7,ondrop:8})}}function get_each_context(e,t,o){const n=e.slice();return n[14]=t[o],n}function create_each_block(e,t){let o,n,r,a,i,s,l;function c(){return t[10](t[14])}function p(...e){return t[11](t[14],...e)}function u(...e){return t[12](t[14],...e)}function d(...e){return t[13](t[14],...e)}return n=new DragButton({props:{onclick:c,ongrab:p,ondrag:u,ondrop:d,disabled:t[1]||t[14].disabled,title:t[14].title,html:t[14].thumb}}),{key:e,first:null,c(){o=element("li"),create_component(n.$$.fragment),r=space(),attr(o,"class","DokaShapePreset"),attr(o,"style",t[6]),this.first=o},m(e,c){insert(e,o,c),mount_component(n,o,null),append(o,r),i=!0,s||(l=action_destroyer(a=t[8].call(null,o,t[14])),s=!0)},p(e,r){t=e;const s={};5&r&&(s.onclick=c),9&r&&(s.ongrab=p),17&r&&(s.ondrag=u),33&r&&(s.ondrop=d),3&r&&(s.disabled=t[1]||t[14].disabled),1&r&&(s.title=t[14].title),1&r&&(s.html=t[14].thumb),n.$set(s),(!i||64&r)&&attr(o,"style",t[6]),a&&is_function(a.update)&&1&r&&a.update.call(null,t[14])},i(e){i||(transition_in(n.$$.fragment,e),i=!0)},o(e){transition_out(n.$$.fragment,e),i=!1},d(e){e&&detach(o),destroy_component(n),s=!1,l()}}}function create_fragment$6(e){let t,o,n=[],r=new Map,a=e[0];const i=e=>e[14].id;for(let t=0;t<a.length;t+=1){let o=get_each_context(e,a,t),s=i(o);r.set(s,n[t]=create_each_block(s,o))}return{c(){t=element("ul");for(let e=0;e<n.length;e+=1)n[e].c();attr(t,"class","DokaShapePresetsList")},m(e,r){insert(e,t,r);for(let e=0;e<n.length;e+=1)n[e].m(t,null);o=!0},p(e,[o]){127&o&&(a=e[0],group_outros(),n=update_keyed_each(n,o,i,1,e,a,r,t,outro_and_destroy_block,create_each_block,null,get_each_context),check_outros())},i(e){if(!o){for(let e=0;e<a.length;e+=1)transition_in(n[e]);o=!0}},o(e){for(let e=0;e<n.length;e+=1)transition_out(n[e]);o=!1},d(e){e&&detach(t);for(let e=0;e<n.length;e+=1)n[e].d()}}}function instance$6(e,t,o){let n,r,{presets:a}=t,{disabled:i}=t,{onclickpreset:s}=t,{ongrabpreset:l}=t,{ondragpreset:c}=t,{ondroppreset:p}=t;const u=tweened(0,{duration:300});component_subscribe(e,u,e=>o(9,r=e));onMount(()=>u.set(1));return e.$$set=(e=>{"presets"in e&&o(0,a=e.presets),"disabled"in e&&o(1,i=e.disabled),"onclickpreset"in e&&o(2,s=e.onclickpreset),"ongrabpreset"in e&&o(3,l=e.ongrabpreset),"ondragpreset"in e&&o(4,c=e.ondragpreset),"ondroppreset"in e&&o(5,p=e.ondroppreset)}),e.$$.update=(()=>{512&e.$$.dirty&&o(6,n=`opacity:${r}`)}),[a,i,s,l,c,p,n,u,(e,t)=>t.mount&&t.mount(e.firstChild,t),r,e=>s(e.id),(e,t)=>l(e.id,t),(e,t)=>c(e.id,t),(e,t)=>p(e.id,t)]}class ShapePresetsList extends SvelteComponent{constructor(e){super(),init(this,e,instance$6,create_fragment$6,safe_not_equal,{presets:0,disabled:1,onclickpreset:2,ongrabpreset:3,ondragpreset:4,ondroppreset:5})}}var isSVGMarkup=e=>/<svg /.test(e);function create_if_block_6(e){let t,o;return t=new ShapePresetSelect({props:{locale:e[0],oninput:e[3]}}),{c(){create_component(t.$$.fragment)},m(e,n){mount_component(t,e,n),o=!0},p(e,o){const n={};1&o&&(n.locale=e[0]),8&o&&(n.oninput=e[3]),t.$set(n)},i(e){o||(transition_in(t.$$.fragment,e),o=!0)},o(e){transition_out(t.$$.fragment,e),o=!1},d(e){destroy_component(t,e)}}}function create_if_block$1(e){let t,o,n,r;const a=[create_if_block_1$1,create_else_block$1],i=[];function s(e,t){return e[9]?0:1}return t=s(e),o=i[t]=a[t](e),{c(){o.c(),n=empty()},m(e,o){i[t].m(e,o),insert(e,n,o),r=!0},p(e,r){let l=t;(t=s(e))===l?i[t].p(e,r):(group_outros(),transition_out(i[l],1,1,()=>{i[l]=null}),check_outros(),(o=i[t])?o.p(e,r):(o=i[t]=a[t](e)).c(),transition_in(o,1),o.m(n.parentNode,n))},i(e){r||(transition_in(o),r=!0)},o(e){transition_out(o),r=!1},d(e){i[t].d(e),e&&detach(n)}}}function create_else_block$1(e){let t,o,n,r,a=e[2]&&create_if_block_5(e);return n=new Scrollable({props:{scrollAutoCancel:e[8],elasticity:e[1],$$slots:{default:[create_default_slot_4]},$$scope:{ctx:e}}}),{c(){t=element("div"),a&&a.c(),o=space(),create_component(n.$$.fragment),attr(t,"class","DokaShapePresetsFlat")},m(e,i){insert(e,t,i),a&&a.m(t,null),append(t,o),mount_component(n,t,null),r=!0},p(e,r){e[2]?a?(a.p(e,r),4&r&&transition_in(a,1)):((a=create_if_block_5(e)).c(),transition_in(a,1),a.m(t,o)):a&&(group_outros(),transition_out(a,1,1,()=>{a=null}),check_outros());const i={};256&r&&(i.scrollAutoCancel=e[8]),2&r&&(i.elasticity=e[1]),268435704&r&&(i.$$scope={dirty:r,ctx:e}),n.$set(i)},i(e){r||(transition_in(a),transition_in(n.$$.fragment,e),r=!0)},o(e){transition_out(a),transition_out(n.$$.fragment,e),r=!1},d(e){e&&detach(t),a&&a.d(),destroy_component(n)}}}function create_if_block_1$1(e){let t,o,n,r,a,i,s,l=e[2]&&create_if_block_4$1(e);const c=[{class:"DokaControlList"},{tabs:e[10]},e[13],{layout:"compact"}];let p={$$slots:{default:[create_default_slot_2,({tab:e})=>({27:e}),({tab:e})=>e?134217728:0]},$$scope:{ctx:e}};for(let e=0;e<c.length;e+=1)p=assign(p,c[e]);(r=new TabList({props:p})).$on("select",e[16]);const u=[{class:"DokaControlPanels"},{panelClass:"DokaControlPanel"},{panels:e[14]},e[13]];let d={$$slots:{default:[create_default_slot$2,({panel:e,panelIsActive:t})=>({25:e,26:t}),({panel:e,panelIsActive:t})=>(e?33554432:0)|(t?67108864:0)]},$$scope:{ctx:e}};for(let e=0;e<u.length;e+=1)d=assign(d,u[e]);return i=new TabPanels({props:d}),{c(){t=element("div"),o=element("div"),l&&l.c(),n=space(),create_component(r.$$.fragment),a=space(),create_component(i.$$.fragment),attr(o,"class","DokaShapePresetsGroups"),attr(t,"class","DokaShapePresetsGrouped")},m(e,c){insert(e,t,c),append(t,o),l&&l.m(o,null),append(o,n),mount_component(r,o,null),append(t,a),mount_component(i,t,null),s=!0},p(e,t){e[2]?l?(l.p(e,t),4&t&&transition_in(l,1)):((l=create_if_block_4$1(e)).c(),transition_in(l,1),l.m(o,n)):l&&(group_outros(),transition_out(l,1,1,()=>{l=null}),check_outros());const a=9216&t?get_spread_update(c,[c[0],1024&t&&{tabs:e[10]},8192&t&&get_spread_object(e[13]),c[3]]):{};402653184&t&&(a.$$scope={dirty:t,ctx:e}),r.$set(a);const s=24576&t?get_spread_update(u,[u[0],u[1],16384&t&&{panels:e[14]},8192&t&&get_spread_object(e[13])]):{};369103226&t&&(s.$$scope={dirty:t,ctx:e}),i.$set(s)},i(e){s||(transition_in(l),transition_in(r.$$.fragment,e),transition_in(i.$$.fragment,e),s=!0)},o(e){transition_out(l),transition_out(r.$$.fragment,e),transition_out(i.$$.fragment,e),s=!1},d(e){e&&detach(t),l&&l.d(),destroy_component(r),destroy_component(i)}}}function create_if_block_5(e){let t,o;return t=new ShapePresetSelect({props:{locale:e[0],oninput:e[3]}}),{c(){create_component(t.$$.fragment)},m(e,n){mount_component(t,e,n),o=!0},p(e,o){const n={};1&o&&(n.locale=e[0]),8&o&&(n.oninput=e[3]),t.$set(n)},i(e){o||(transition_in(t.$$.fragment,e),o=!0)},o(e){transition_out(t.$$.fragment,e),o=!1},d(e){destroy_component(t,e)}}}function create_default_slot_4(e){let t,o;return t=new ShapePresetsList({props:{presets:e[7],onclickpreset:e[3],ongrabpreset:e[4],ondragpreset:e[5],ondroppreset:e[6]}}),{c(){create_component(t.$$.fragment)},m(e,n){mount_component(t,e,n),o=!0},p(e,o){const n={};128&o&&(n.presets=e[7]),8&o&&(n.onclickpreset=e[3]),16&o&&(n.ongrabpreset=e[4]),32&o&&(n.ondragpreset=e[5]),64&o&&(n.ondroppreset=e[6]),t.$set(n)},i(e){o||(transition_in(t.$$.fragment,e),o=!0)},o(e){transition_out(t.$$.fragment,e),o=!1},d(e){destroy_component(t,e)}}}function create_if_block_4$1(e){let t,o;return t=new ShapePresetSelect({props:{locale:e[0],oninput:e[3]}}),{c(){create_component(t.$$.fragment)},m(e,n){mount_component(t,e,n),o=!0},p(e,o){const n={};1&o&&(n.locale=e[0]),8&o&&(n.oninput=e[3]),t.$set(n)},i(e){o||(transition_in(t.$$.fragment,e),o=!0)},o(e){transition_out(t.$$.fragment,e),o=!1},d(e){destroy_component(t,e)}}}function create_if_block_3$1(e){let t,o;return t=new Icon({props:{$$slots:{default:[create_default_slot_3]},$$scope:{ctx:e}}}),{c(){create_component(t.$$.fragment)},m(e,n){mount_component(t,e,n),o=!0},p(e,o){const n={};402653184&o&&(n.$$scope={dirty:o,ctx:e}),t.$set(n)},i(e){o||(transition_in(t.$$.fragment,e),o=!0)},o(e){transition_out(t.$$.fragment,e),o=!1},d(e){destroy_component(t,e)}}}function create_default_slot_3(e){let t,o=e[27].icon+"";return{c(){t=svg_element("g")},m(e,n){insert(e,t,n),t.innerHTML=o},p(e,n){134217728&n&&o!==(o=e[27].icon+"")&&(t.innerHTML=o)},d(e){e&&detach(t)}}}function create_if_block_2$1(e){let t,o,n=e[27].label+"";return{c(){t=element("span"),o=text(n)},m(e,n){insert(e,t,n),append(t,o)},p(e,t){134217728&t&&n!==(n=e[27].label+"")&&set_data(o,n)},d(e){e&&detach(t)}}}function create_default_slot_2(e){let t,o,n,r=e[27].icon&&create_if_block_3$1(e),a=!e[27].hideLabel&&create_if_block_2$1(e);return{c(){r&&r.c(),t=space(),a&&a.c(),o=empty()},m(e,i){r&&r.m(e,i),insert(e,t,i),a&&a.m(e,i),insert(e,o,i),n=!0},p(e,n){e[27].icon?r?(r.p(e,n),134217728&n&&transition_in(r,1)):((r=create_if_block_3$1(e)).c(),transition_in(r,1),r.m(t.parentNode,t)):r&&(group_outros(),transition_out(r,1,1,()=>{r=null}),check_outros()),e[27].hideLabel?a&&(a.d(1),a=null):a?a.p(e,n):((a=create_if_block_2$1(e)).c(),a.m(o.parentNode,o))},i(e){n||(transition_in(r),n=!0)},o(e){transition_out(r),n=!1},d(e){r&&r.d(e),e&&detach(t),a&&a.d(e),e&&detach(o)}}}function create_default_slot_1$2(e){let t,o;return t=new ShapePresetsList({props:{presets:e[12][e[25]].items,disabled:e[12][e[25]].disabled,onclickpreset:e[3],ongrabpreset:e[4],ondragpreset:e[5],ondroppreset:e[6]}}),{c(){create_component(t.$$.fragment)},m(e,n){mount_component(t,e,n),o=!0},p(e,o){const n={};33558528&o&&(n.presets=e[12][e[25]].items),33558528&o&&(n.disabled=e[12][e[25]].disabled),8&o&&(n.onclickpreset=e[3]),16&o&&(n.ongrabpreset=e[4]),32&o&&(n.ondragpreset=e[5]),64&o&&(n.ondroppreset=e[6]),t.$set(n)},i(e){o||(transition_in(t.$$.fragment,e),o=!0)},o(e){transition_out(t.$$.fragment,e),o=!1},d(e){destroy_component(t,e)}}}function create_default_slot$2(e){let t,o;return t=new Scrollable({props:{scroll:e[26]?{scrollOffset:0,animate:!1}:void 0,scrollAutoCancel:e[8],elasticity:e[1],$$slots:{default:[create_default_slot_1$2]},$$scope:{ctx:e}}}),{c(){create_component(t.$$.fragment)},m(e,n){mount_component(t,e,n),o=!0},p(e,o){const n={};67108864&o&&(n.scroll=e[26]?{scrollOffset:0,animate:!1}:void 0),256&o&&(n.scrollAutoCancel=e[8]),2&o&&(n.elasticity=e[1]),301994104&o&&(n.$$scope={dirty:o,ctx:e}),t.$set(n)},i(e){o||(transition_in(t.$$.fragment,e),o=!0)},o(e){transition_out(t.$$.fragment,e),o=!1},d(e){destroy_component(t,e)}}}function create_fragment$5(e){let t,o,n,r;const a=[create_if_block$1,create_if_block_6],i=[];function s(e,t){return e[8]?0:e[2]?1:-1}return~(o=s(e))&&(n=i[o]=a[o](e)),{c(){t=element("div"),n&&n.c(),attr(t,"class","DokaShapePresetsPalette")},m(e,n){insert(e,t,n),~o&&i[o].m(t,null),r=!0},p(e,[r]){let l=o;(o=s(e))===l?~o&&i[o].p(e,r):(n&&(group_outros(),transition_out(i[l],1,1,()=>{i[l]=null}),check_outros()),~o?((n=i[o])?n.p(e,r):(n=i[o]=a[o](e)).c(),transition_in(n,1),n.m(t,null)):n=null)},i(e){r||(transition_in(n),r=!0)},o(e){transition_out(n),r=!1},d(e){e&&detach(t),~o&&i[o].d()}}}function instance$5(e,t,o){let n,r,a,i,s,l,c,p,{locale:u}=t,{presets:d}=t,{scrollElasticity:h}=t,{enableSelectImage:m=!0}=t,{onaddpreset:g=noop$1}=t,{ongrabpreset:f=noop$1}=t,{ondragpreset:_=noop$1}=t,{ondroppreset:$=noop$1}=t;const b=`doka-presets-${getUniqueId()}`,y=(e,t="")=>isSVGMarkup(e)?e:isEmoji(e)?getEmojiSVG(e,t):`<img src="${e}" alt="${t}"/>`,x=e=>getFilenameWithoutExtension(getFilenameFromURL(e)),v=["src","alt","thumb","shape","id","mount","disabled"],C=e=>e.map(e=>(e=>isArray(e)&&isString(e[0])&&isArray(e[1]))(e)?{...e[2],id:`${b}-${e[0].toLowerCase()}`,label:e[0],items:C(e[1])}:(e=>{let t,o,n,r,a,i,s,l=e;return isString(e)?isEmoji(e)?r=y(t=e,a=e):(a=x(t=e),r=y(t,a)):(t=e.src,a=e.alt||(isString(t)?x(t):isString(e.thumb)?x(e.thumb):void 0),r=y(e.thumb||t,a),o=e.shape,i=e.mount,s=e.disabled,n=Object.keys(e).reduce((t,o)=>v.includes(o)?t:(t[o]=e[o],t),{})),{id:l,src:t,thumb:r,shape:o,shapeProps:n,alt:a,title:a,mount:i,disabled:s}})(e));return e.$$set=(e=>{"locale"in e&&o(0,u=e.locale),"presets"in e&&o(15,d=e.presets),"scrollElasticity"in e&&o(1,h=e.scrollElasticity),"enableSelectImage"in e&&o(2,m=e.enableSelectImage),"onaddpreset"in e&&o(3,g=e.onaddpreset),"ongrabpreset"in e&&o(4,f=e.ongrabpreset),"ondragpreset"in e&&o(5,_=e.ondragpreset),"ondroppreset"in e&&o(6,$=e.ondroppreset)}),e.$$.update=(()=>{32768&e.$$.dirty&&o(7,n=C(d)),128&e.$$.dirty&&o(8,r=n.length),384&e.$$.dirty&&o(9,a=r&&n.some(e=>!!e.items)),640&e.$$.dirty&&o(10,i=a&&n),640&e.$$.dirty&&o(12,s=a&&n.reduce((e,t)=>(e[t.id]=t,e),{})),3072&e.$$.dirty&&o(11,l=l||i&&(i.find(e=>!e.disabled)||{}).id),2048&e.$$.dirty&&o(13,c={name:b,selected:l}),1024&e.$$.dirty&&o(14,p=i&&i.map(e=>e.id))}),[u,h,m,g,f,_,$,n,r,a,i,l,s,c,p,d,({detail:e})=>o(11,l=e)]}class ShapePresetsPalette extends SvelteComponent{constructor(e){super(),init(this,e,instance$5,create_fragment$5,safe_not_equal,{locale:0,presets:15,scrollElasticity:1,enableSelectImage:2,onaddpreset:3,ongrabpreset:4,ondragpreset:5,ondroppreset:6})}}var createPingDispatcher=e=>(t,o)=>{e.dispatchEvent(new CustomEvent("ping",{detail:{type:t,data:o},cancelable:!0,bubbles:!0}))};function create_if_block_4(e){let t,o,n,r;const a=[{locale:e[4]},{parentRect:e[25]},{rootRect:e[20]},{utilRect:e[16]},{offset:e[22]},{scale:e[31]},{rotation:e[12]},{opacity:e[18]},{enableButtonFlipVertical:e[7]},{mapEditorPointToImagePoint:e[10]},{mapImagePointToEditorPoint:e[11]},{oninteractionstart:e[41]},{oninteractionupdate:e[42]},{oninteractionrelease:e[43]},{oninteractionend:e[44]},{onaddshape:e[72]},{onselectshape:e[73]},{onupdateshape:e[74]},{onremoveshape:e[75]},e[28]];function i(t){e[77](t)}function s(t){e[78](t)}let l={};for(let e=0;e<a.length;e+=1)l=assign(l,a[e]);return void 0!==e[17]&&(l.markup=e[17]),void 0!==e[30]&&(l.ui=e[30]),t=new ShapeLayoutEditor({props:l}),e[76](t),binding_callbacks.push(()=>bind(t,"markup",i)),binding_callbacks.push(()=>bind(t,"ui",s)),t.$on("measure",e[79]),{c(){create_component(t.$$.fragment)},m(e,o){mount_component(t,e,o),r=!0},p(e,r){const i=374676624&r[0]|1063937&r[1]?get_spread_update(a,[16&r[0]&&{locale:e[4]},33554432&r[0]&&{parentRect:e[25]},1048576&r[0]&&{rootRect:e[20]},65536&r[0]&&{utilRect:e[16]},4194304&r[0]&&{offset:e[22]},1&r[1]&&{scale:e[31]},4096&r[0]&&{rotation:e[12]},262144&r[0]&&{opacity:e[18]},128&r[0]&&{enableButtonFlipVertical:e[7]},1024&r[0]&&{mapEditorPointToImagePoint:e[10]},2048&r[0]&&{mapImagePointToEditorPoint:e[11]},1024&r[1]&&{oninteractionstart:e[41]},2048&r[1]&&{oninteractionupdate:e[42]},4096&r[1]&&{oninteractionrelease:e[43]},8192&r[1]&&{oninteractionend:e[44]},67108864&r[0]|1048576&r[1]&&{onaddshape:e[72]},67108864&r[0]&&{onselectshape:e[73]},67108864&r[0]|1048576&r[1]&&{onupdateshape:e[74]},67108864&r[0]|1048576&r[1]&&{onremoveshape:e[75]},268435456&r[0]&&get_spread_object(e[28])]):{};!o&&131072&r[0]&&(o=!0,i.markup=e[17],add_flush_callback(()=>o=!1)),!n&&1073741824&r[0]&&(n=!0,i.ui=e[30],add_flush_callback(()=>n=!1)),t.$set(i)},i(e){r||(transition_in(t.$$.fragment,e),r=!0)},o(e){transition_out(t.$$.fragment,e),r=!1},d(o){e[76](null),destroy_component(t,o)}}}function create_main_slot(e){let t,o,n,r,a=e[21]&&create_if_block_4(e);return{c(){t=element("div"),a&&a.c(),attr(t,"slot","main"),set_style(t,"cursor","crosshair")},m(i,s){insert(i,t,s),a&&a.m(t,null),e[80](t),o=!0,n||(r=[action_destroyer(dropable.call(null,t)),listen(t,"dropfiles",e[50])],n=!0)},p(e,o){e[21]?a?(a.p(e,o),2097152&o[0]&&transition_in(a,1)):((a=create_if_block_4(e)).c(),transition_in(a,1),a.m(t,null)):a&&(group_outros(),transition_out(a,1,1,()=>{a=null}),check_outros())},i(e){o||(transition_in(a),o=!0)},o(e){transition_out(a),o=!1},d(o){o&&detach(t),a&&a.d(),e[80](null),n=!1,run_all(r)}}}function create_if_block_3(e){let t,o;return t=new ShapePresetsPalette({props:{locale:e[4],presets:e[9],enableSelectImage:e[8],onaddpreset:e[49],ongrabpreset:e[46],ondragpreset:e[47],ondroppreset:e[48],scrollElasticity:e[27]}}),{c(){create_component(t.$$.fragment)},m(e,n){mount_component(t,e,n),o=!0},p(e,o){const n={};16&o[0]&&(n.locale=e[4]),512&o[0]&&(n.presets=e[9]),256&o[0]&&(n.enableSelectImage=e[8]),134217728&o[0]&&(n.scrollElasticity=e[27]),t.$set(n)},i(e){o||(transition_in(t.$$.fragment,e),o=!0)},o(e){transition_out(t.$$.fragment,e),o=!1},d(e){destroy_component(t,e)}}}function create_if_block(e){let t,o,n,r,a,i;const s=[create_if_block_2,create_else_block],l=[];function c(e,t){return e[24]?0:1}return o=c(e),n=l[o]=s[o](e),a=new Scrollable({props:{class:"DokaControlListScroller",elasticity:e[27],$$slots:{default:[create_default_slot$1]},$$scope:{ctx:e}}}),{c(){t=element("div"),n.c(),r=space(),create_component(a.$$.fragment),attr(t,"class","DokaControlPanels")},m(e,n){insert(e,t,n),l[o].m(t,null),insert(e,r,n),mount_component(a,e,n),i=!0},p(e,r){let i=o;(o=c(e))===i?l[o].p(e,r):(group_outros(),transition_out(l[i],1,1,()=>{l[i]=null}),check_outros(),(n=l[o])?n.p(e,r):(n=l[o]=s[o](e)).c(),transition_in(n,1),n.m(t,null));const p={};134217728&r[0]&&(p.elasticity=e[27]),524305&r[0]|1&r[3]&&(p.$$scope={dirty:r,ctx:e}),a.$set(p)},i(e){i||(transition_in(n),transition_in(a.$$.fragment,e),i=!0)},o(e){transition_out(n),transition_out(a.$$.fragment,e),i=!1},d(e){e&&detach(t),l[o].d(),e&&detach(r),destroy_component(a,e)}}}function create_else_block(e){let t,o,n;return o=new ShapeStyleEditor({props:{locale:e[4],shape:e[23],onchange:e[45],controls:e[6],scrollElasticity:e[27]}}),{c(){t=element("div"),create_component(o.$$.fragment),attr(t,"class","DokaControlPanel")},m(e,r){insert(e,t,r),mount_component(o,t,null),n=!0},p(e,t){const n={};16&t[0]&&(n.locale=e[4]),8388608&t[0]&&(n.shape=e[23]),64&t[0]&&(n.controls=e[6]),134217728&t[0]&&(n.scrollElasticity=e[27]),o.$set(n)},i(e){n||(transition_in(o.$$.fragment,e),n=!0)},o(e){transition_out(o.$$.fragment,e),n=!1},d(e){e&&detach(t),destroy_component(o)}}}function create_if_block_2(e){let t,o,n;return o=new ShapePresetsPalette({props:{locale:e[4],presets:e[9],enableSelectImage:e[8],onaddpreset:e[49],ongrabpreset:e[46],ondragpreset:e[47],ondroppreset:e[48],scrollElasticity:e[27]}}),{c(){t=element("div"),create_component(o.$$.fragment),attr(t,"class","DokaControlPanel")},m(e,r){insert(e,t,r),mount_component(o,t,null),n=!0},p(e,t){const n={};16&t[0]&&(n.locale=e[4]),512&t[0]&&(n.presets=e[9]),256&t[0]&&(n.enableSelectImage=e[8]),134217728&t[0]&&(n.scrollElasticity=e[27]),o.$set(n)},i(e){n||(transition_in(o.$$.fragment,e),n=!0)},o(e){transition_out(o.$$.fragment,e),n=!1},d(e){e&&detach(t),destroy_component(o)}}}function create_if_block_1(e){let t,o;return t=new Icon({props:{$$slots:{default:[create_default_slot_1$1]},$$scope:{ctx:e}}}),{c(){create_component(t.$$.fragment)},m(e,n){mount_component(t,e,n),o=!0},p(e,o){const n={};16&o[0]|1073741824&o[2]|1&o[3]&&(n.$$scope={dirty:o,ctx:e}),t.$set(n)},i(e){o||(transition_in(t.$$.fragment,e),o=!0)},o(e){transition_out(t.$$.fragment,e),o=!1},d(e){destroy_component(t,e)}}}function create_default_slot_1$1(e){let t,o=(isFunction(e[92].icon)?e[92].icon(e[4]):e[92].icon)+"";return{c(){t=svg_element("g")},m(e,n){insert(e,t,n),t.innerHTML=o},p(e,n){16&n[0]|1073741824&n[2]&&o!==(o=(isFunction(e[92].icon)?e[92].icon(e[4]):e[92].icon)+"")&&(t.innerHTML=o)},d(e){e&&detach(t)}}}function create_option_slot(e){let t,o,n,r,a,i=(isFunction(e[92].label)?e[92].label(e[4]):e[92].label)+"",s=e[92].icon&&create_if_block_1(e);return{c(){t=element("div"),s&&s.c(),o=space(),n=element("span"),r=text(i),attr(t,"slot","option")},m(e,i){insert(e,t,i),s&&s.m(t,null),append(t,o),append(t,n),append(n,r),a=!0},p(e,n){e[92].icon?s?(s.p(e,n),1073741824&n[2]&&transition_in(s,1)):((s=create_if_block_1(e)).c(),transition_in(s,1),s.m(t,o)):s&&(group_outros(),transition_out(s,1,1,()=>{s=null}),check_outros()),(!a||16&n[0]|1073741824&n[2])&&i!==(i=(isFunction(e[92].label)?e[92].label(e[4]):e[92].label)+"")&&set_data(r,i)},i(e){a||(transition_in(s),a=!0)},o(e){transition_out(s),a=!1},d(e){e&&detach(t),s&&s.d()}}}function create_default_slot$1(e){let t,o;return t=new RadioGroup({props:{locale:e[4],class:"DokaControlList",optionClass:"DokaControlListOption",layout:"row",options:e[19],selectedIndex:e[19].findIndex(e[71]),onchange:e[40],$$slots:{option:[create_option_slot,({option:e})=>({92:e}),({option:e})=>[0,0,e?1073741824:0]]},$$scope:{ctx:e}}}),{c(){create_component(t.$$.fragment)},m(e,n){mount_component(t,e,n),o=!0},p(e,o){const n={};16&o[0]&&(n.locale=e[4]),524288&o[0]&&(n.options=e[19]),524289&o[0]&&(n.selectedIndex=e[19].findIndex(e[71])),16&o[0]|1073741824&o[2]|1&o[3]&&(n.$$scope={dirty:o,ctx:e}),t.$set(n)},i(e){o||(transition_in(t.$$.fragment,e),o=!0)},o(e){transition_out(t.$$.fragment,e),o=!1},d(e){destroy_component(t,e)}}}function create_footer_slot$1(e){let t,o,n,r;const a=[create_if_block,create_if_block_3],i=[];function s(e,t){return e[19].length?0:e[24]?1:-1}return~(o=s(e))&&(n=i[o]=a[o](e)),{c(){t=element("div"),n&&n.c(),attr(t,"slot","footer"),attr(t,"style",e[29])},m(e,n){insert(e,t,n),~o&&i[o].m(t,null),r=!0},p(e,l){let c=o;(o=s(e))===c?~o&&i[o].p(e,l):(n&&(group_outros(),transition_out(i[c],1,1,()=>{i[c]=null}),check_outros()),~o?((n=i[o])?n.p(e,l):(n=i[o]=a[o](e)).c(),transition_in(n,1),n.m(t,null)):n=null),(!r||536870912&l[0])&&attr(t,"style",e[29])},i(e){r||(transition_in(n),r=!0)},o(e){transition_out(n),r=!1},d(e){e&&detach(t),~o&&i[o].d()}}}function create_fragment$4(e){let t,o;return(t=new Util({props:{$$slots:{footer:[create_footer_slot$1],main:[create_main_slot]},$$scope:{ctx:e}}})).$on("measure",e[81]),{c(){create_component(t.$$.fragment)},m(e,n){mount_component(t,e,n),o=!0},p(e,o){const n={};2147475409&o[0]|1&o[1]|1&o[3]&&(n.$$scope={dirty:o,ctx:e}),t.$set(n)},i(e){o||(transition_in(t.$$.fragment,e),o=!0)},o(e){transition_out(t.$$.fragment,e),o=!1},d(e){destroy_component(t,e)}}}function instance$4(e,t,o){let n,r,a,i,s,l,c,p,u,d,h,m,g,f,_,$,b,y,x,v,C,S,k,w,R,T,E,I=noop,A=()=>(I(),I=subscribe(U,e=>o(61,_=e)),U),M=noop,P=()=>(M(),M=subscribe(V,e=>o(64,b=e)),V),D=noop,F=()=>(D(),D=subscribe(G,e=>o(17,v=e)),G),L=noop,z=()=>(L(),L=subscribe(N,e=>o(18,C=e)),N),B=noop,O=()=>(B(),B=subscribe(ae,e=>o(25,k=e)),ae);e.$$.on_destroy.push(()=>I()),e.$$.on_destroy.push(()=>M()),e.$$.on_destroy.push(()=>D()),e.$$.on_destroy.push(()=>L()),e.$$.on_destroy.push(()=>B());let{isActive:U}=t;A();let{isActiveFraction:N}=t;z();let{isVisible:V}=t;P();let{stores:H}=t,{locale:W={}}=t,{shapes:G=[]}=t;F();let{tools:j=[]}=t,{toolShapes:q=[]}=t,{toolActive:X="sharpie"}=t,{shapeControls:Y=[]}=t,{enableButtonFlipVertical:K=!1}=t,{enablePresetSelectImage:Z=!0}=t,{shapePresets:J=[]}=t,{utilKey:Q}=t,{mapScreenPointToImagePoint:ee}=t,{mapImagePointToScreenPoint:te}=t,{imageRotation:oe=0}=t,{imageFlipX:ne=!1}=t,{imageFlipY:re=!1}=t,{parentRect:ae}=t;O();let{hooks:ie={}}=t;const{animation:se,history:le,rootRect:ce,stageRect:pe,utilRect:ue,elasticityMultiplier:de,scrollElasticity:he,imageOverlayMarkup:me,imagePreviewModifiers:ge,imageCropRect:fe,presentationScalar:_e}=H;component_subscribe(e,se,e=>o(69,w=e)),component_subscribe(e,ce,e=>o(20,f=e)),component_subscribe(e,pe,e=>o(65,x=e)),component_subscribe(e,ue,e=>o(16,y=e)),component_subscribe(e,me,e=>o(30,T=e)),component_subscribe(e,ge,e=>o(62,$=e)),component_subscribe(e,fe,e=>o(84,S=e)),component_subscribe(e,_e,e=>o(31,E=e));const $e=e=>ee(getEventPositionInEditor(e,f));let be,ye,xe={};const ve=(e,t)=>{let o=!1;if(t||(o=!0,t=rectCenter(S)),t.x-=k.x||0,t.y-=k.y||0,0!==oe){const e={width:k.width,height:k.height};sizeRotate(e,oe);const o=.5*(k.width-Math.abs(e.width)),n=.5*(k.height-Math.abs(e.height));t.x+=o,t.y+=n}const n=shapeCreateFromPreset(e,S,(e,o)=>{if(v.find(e=>e.id===o.id)){if(e)return be.removeShape(o),console.error(e);shapeContain(o,S),shapeCenter(o,t),v[v.length-1]===o&&be.selectShape(o)}});n.flipX=ne,n.flipY=re,n.rotation=0!==oe?-oe:0;const r=be.getShapesAtPosition(t),a=S.width,i=S.height;if(o&&r.length&&n.width<a&&n.height<i){const e=.1*Math.min(a,i);t.x+=Math.round(-e+Math.random()*e*2),t.y+=Math.round(-e+Math.random()*e*2)}return n.width&&n.height&&(shapeContain(n,S),shapeCenter(n,t)),n},Ce=(e,t)=>{const{beforeAddShape:o=(()=>!0)}=ie,n=ve(e,t);if(o(n))return be.addShape(n),le.write(),n};let Se=!1;const ke=()=>le.write();let we;const Re=spring(w?20:0);component_subscribe(e,Re,e=>o(70,R=e));return e.$$set=(e=>{"isActive"in e&&A(o(1,U=e.isActive)),"isActiveFraction"in e&&z(o(2,N=e.isActiveFraction)),"isVisible"in e&&P(o(3,V=e.isVisible)),"stores"in e&&o(53,H=e.stores),"locale"in e&&o(4,W=e.locale),"shapes"in e&&F(o(5,G=e.shapes)),"tools"in e&&o(54,j=e.tools),"toolShapes"in e&&o(55,q=e.toolShapes),"toolActive"in e&&o(0,X=e.toolActive),"shapeControls"in e&&o(6,Y=e.shapeControls),"enableButtonFlipVertical"in e&&o(7,K=e.enableButtonFlipVertical),"enablePresetSelectImage"in e&&o(8,Z=e.enablePresetSelectImage),"shapePresets"in e&&o(9,J=e.shapePresets),"utilKey"in e&&o(56,Q=e.utilKey),"mapScreenPointToImagePoint"in e&&o(10,ee=e.mapScreenPointToImagePoint),"mapImagePointToScreenPoint"in e&&o(11,te=e.mapImagePointToScreenPoint),"imageRotation"in e&&o(12,oe=e.imageRotation),"imageFlipX"in e&&o(57,ne=e.imageFlipX),"imageFlipY"in e&&o(58,re=e.imageFlipY),"parentRect"in e&&O(o(13,ae=e.parentRect)),"hooks"in e&&o(59,ie=e.hooks)}),e.$$.update=(()=>{512&e.$$.dirty[0]|8388608&e.$$.dirty[1]&&o(19,n=0===J.length?j.filter(e=>"preset"!==e[0]):j),1107296256&e.$$.dirty[1]|1&e.$$.dirty[2]&&(_?set_store_value(ge,$[Q]={maskMarkupOpacity:.85},$):delete $[Q]),4&e.$$.dirty[2]&&o(21,r=b),65536&e.$$.dirty[0]|8&e.$$.dirty[2]&&o(22,a=y&&vectorCreate(x.x-y.x,x.y-y.y)),16385&e.$$.dirty[0]&&X&&be&&be.blurShapes(),64&e.$$.dirty[0]&&o(66,i=Object.keys(Y)),131072&e.$$.dirty[0]&&o(67,s=(v.filter(shapeIsSelected)||[])[0]),1&e.$$.dirty[0]|1090519040&e.$$.dirty[1]&&o(68,l=_&&(q[X]?shapeFormat(shapeDeepCopy(q[X][0])):{})),536870912&e.$$.dirty[1]|80&e.$$.dirty[2]&&o(63,c=l&&Object.keys(l).reduce((e,t)=>{const o="disableStyle"===t,n=i.find(e=>e.split("_").includes(t));return o||n?void 0===l[t]?e:(e[t]=xe[t]||l[t],e):e},{})),34&e.$$.dirty[2]&&o(23,p=s||c),262913&e.$$.dirty[0]&&o(24,u=C>0&&"preset"===X&&(J.length>0||Z)),32768&e.$$.dirty[0]&&o(26,d=we&&createPingDispatcher(we)),268435456&e.$$.dirty[1]&&o(28,m=Object.keys(ie).reduce((e,t)=>"beforeAddShape"===t?e:(e[t]=ie[t],e),{})),1073741824&e.$$.dirty[1]|128&e.$$.dirty[2]&&w&&Re.set(_?0:20),256&e.$$.dirty[2]&&o(29,g=R?`transform: translateY(${R}px)`:void 0)}),o(27,h=de*he),[X,U,N,V,W,G,Y,K,Z,J,ee,te,oe,ae,be,we,y,v,C,n,f,r,a,p,u,k,d,h,m,g,T,E,se,ce,pe,ue,me,ge,fe,_e,({value:e})=>o(0,X=e),e=>{if(q[X]){const[e,t]=q[X];ye=be.createShape({...e,...c},t)}else ye="eraser"===X?be.eraseShape():void 0;ye&&ye.start(e)},e=>{ye&&ye.update(e)},e=>{ye&&ye.release(e)},e=>{ye&&(ye.end(e),ye=void 0)},function(e){Object.keys(e).forEach(t=>o(60,xe[t]=e[t],xe)),s&&(be.updateMarkupShape(s,e),ke())},(e,t)=>{Se=!1},(e,t)=>{if(Se)return;const{beforeAddShape:o=(()=>!0)}=ie,n=$e(t),r=be.getMarkupItemDraft(),a=rectContainsPoint(S,{x:n.x+(k.x||0),y:n.y+(k.y||0)});if(r&&!a&&be.discardMarkupItemDraft(),a){if(!r){const r=ve(e,n);return o(r)?(shapeMakeDraft(r),void be.addShape(r)):(Se=!0,void t.preventDefault())}be.updateMarkupShape(r,{x:n.x-.5*r.width,y:n.y-.5*r.height})}},(e,t)=>{if(Se)return;const o=$e(t);if(rectContainsPoint(S,{x:o.x+(k.x||0),y:o.y+(k.y||0)})){const e=be.confirmMarkupItemDraft();be.selectShape(e),le.write()}else be.discardMarkupItemDraft()},e=>Ce(e),e=>((e,t)=>e.forEach(e=>Ce(e,t)))(e.detail.files,$e(e.detail.event)),ke,Re,H,j,q,Q,ne,re,ie,xe,_,$,c,b,x,i,s,l,w,R,e=>e[0]===X,e=>{d("addshape",e),ke()},e=>{d("selectshape",e)},e=>{d("updateshape",e),ke()},e=>{d("removeshape",e),ke()},function(e){binding_callbacks[e?"unshift":"push"](()=>{o(14,be=e)})},function(e){v=e,G.set(v)},function(e){T=e,me.set(T)},function(t){bubble(e,t)},function(e){binding_callbacks[e?"unshift":"push"](()=>{o(15,we=e)})},function(t){bubble(e,t)}]}class ShapeUtil extends SvelteComponent{constructor(e){super(),init(this,e,instance$4,create_fragment$4,safe_not_equal,{isActive:1,isActiveFraction:2,isVisible:3,stores:53,locale:4,shapes:5,tools:54,toolShapes:55,toolActive:0,shapeControls:6,enableButtonFlipVertical:7,enablePresetSelectImage:8,shapePresets:9,utilKey:56,mapScreenPointToImagePoint:10,mapImagePointToScreenPoint:11,imageRotation:12,imageFlipX:57,imageFlipY:58,parentRect:13,hooks:59},[-1,-1,-1,-1])}get isActive(){return this.$$.ctx[1]}set isActive(e){this.$set({isActive:e}),flush()}get isActiveFraction(){return this.$$.ctx[2]}set isActiveFraction(e){this.$set({isActiveFraction:e}),flush()}get isVisible(){return this.$$.ctx[3]}set isVisible(e){this.$set({isVisible:e}),flush()}get stores(){return this.$$.ctx[53]}set stores(e){this.$set({stores:e}),flush()}get locale(){return this.$$.ctx[4]}set locale(e){this.$set({locale:e}),flush()}get shapes(){return this.$$.ctx[5]}set shapes(e){this.$set({shapes:e}),flush()}get tools(){return this.$$.ctx[54]}set tools(e){this.$set({tools:e}),flush()}get toolShapes(){return this.$$.ctx[55]}set toolShapes(e){this.$set({toolShapes:e}),flush()}get toolActive(){return this.$$.ctx[0]}set toolActive(e){this.$set({toolActive:e}),flush()}get shapeControls(){return this.$$.ctx[6]}set shapeControls(e){this.$set({shapeControls:e}),flush()}get enableButtonFlipVertical(){return this.$$.ctx[7]}set enableButtonFlipVertical(e){this.$set({enableButtonFlipVertical:e}),flush()}get enablePresetSelectImage(){return this.$$.ctx[8]}set enablePresetSelectImage(e){this.$set({enablePresetSelectImage:e}),flush()}get shapePresets(){return this.$$.ctx[9]}set shapePresets(e){this.$set({shapePresets:e}),flush()}get utilKey(){return this.$$.ctx[56]}set utilKey(e){this.$set({utilKey:e}),flush()}get mapScreenPointToImagePoint(){return this.$$.ctx[10]}set mapScreenPointToImagePoint(e){this.$set({mapScreenPointToImagePoint:e}),flush()}get mapImagePointToScreenPoint(){return this.$$.ctx[11]}set mapImagePointToScreenPoint(e){this.$set({mapImagePointToScreenPoint:e}),flush()}get imageRotation(){return this.$$.ctx[12]}set imageRotation(e){this.$set({imageRotation:e}),flush()}get imageFlipX(){return this.$$.ctx[57]}set imageFlipX(e){this.$set({imageFlipX:e}),flush()}get imageFlipY(){return this.$$.ctx[58]}set imageFlipY(e){this.$set({imageFlipY:e}),flush()}get parentRect(){return this.$$.ctx[13]}set parentRect(e){this.$set({parentRect:e}),flush()}get hooks(){return this.$$.ctx[59]}set hooks(e){this.$set({hooks:e}),flush()}}var _mapImagePointToScreenPoint=(e,t,o,n,r,a,i,s,l)=>{const c=vectorClone(e),p=.5*o.width,u=.5*o.height,d=.5*t.width,h=.5*t.height,m=r.x+n.x,g=r.y+n.y;s&&(c.x=o.width-c.x),l&&(c.y=o.height-c.y);const f=Math.cos(a),_=Math.sin(a);c.x-=p,c.y-=u;const $=c.x*f-c.y*_,b=c.x*_+c.y*f;c.x=p+$,c.y=u+b,c.x*=i,c.y*=i,c.x+=d,c.y+=h,c.x+=m,c.y+=g,c.x-=p*i,c.y-=u*i;const y=(r.x-m)*i,x=(r.y-g)*i,v=y*f-x*_,C=y*_+x*f;return c.x+=v,c.y+=C,c},_mapScreenPointToImagePoint=(e,t,o,n,r,a,i,s,l)=>{const c=vectorClone(e),p=sizeCenter(o),u=sizeCenter(t),d=vectorCreate(r.x+n.x,r.y+n.y),h=Math.cos(a),m=Math.sin(a);c.x-=u.x,c.y-=u.y;const g=(r.x-d.x)*i,f=(r.y-d.y)*i,_=g*h-f*m,$=g*m+f*h;c.x-=_,c.y-=$,c.x-=d.x,c.y-=d.y,c.x/=i,c.y/=i;const b=c.x*h+c.y*m,y=c.x*m-c.y*h;return c.x=b,c.y=-y,c.x+=p.x,c.y+=p.y,s&&(c.x=o.width-c.x),l&&(c.y=o.height-c.y),c};function create_fragment$3(e){let t,o;return(t=new ShapeUtil({props:{stores:e[3],locale:e[4],isActive:e[0],isActiveFraction:e[1],isVisible:e[2],mapScreenPointToImagePoint:e[31],mapImagePointToScreenPoint:e[32],utilKey:"annotate",imageRotation:e[23],imageFlipX:e[21],imageFlipY:e[22],shapes:e[25],tools:e[8]||e[5],toolShapes:e[9]||e[6],toolActive:e[11],shapeControls:e[10]||e[7],shapePresets:e[14],enableButtonFlipVertical:e[12],parentRect:e[26],enablePresetSelectImage:e[13],hooks:{willRenderShapeControls:e[15],beforeAddShape:e[16],beforeRemoveShape:e[17],beforeDeselectShape:e[18],beforeSelectShape:e[19],beforeUpdateShape:e[20]}}})).$on("measure",e[34]),{c(){create_component(t.$$.fragment)},m(e,n){mount_component(t,e,n),o=!0},p(e,o){const n={};8&o[0]&&(n.stores=e[3]),16&o[0]&&(n.locale=e[4]),1&o[0]&&(n.isActive=e[0]),2&o[0]&&(n.isActiveFraction=e[1]),4&o[0]&&(n.isVisible=e[2]),8388608&o[0]&&(n.imageRotation=e[23]),2097152&o[0]&&(n.imageFlipX=e[21]),4194304&o[0]&&(n.imageFlipY=e[22]),288&o[0]&&(n.tools=e[8]||e[5]),576&o[0]&&(n.toolShapes=e[9]||e[6]),2048&o[0]&&(n.toolActive=e[11]),1152&o[0]&&(n.shapeControls=e[10]||e[7]),16384&o[0]&&(n.shapePresets=e[14]),4096&o[0]&&(n.enableButtonFlipVertical=e[12]),8192&o[0]&&(n.enablePresetSelectImage=e[13]),2064384&o[0]&&(n.hooks={willRenderShapeControls:e[15],beforeAddShape:e[16],beforeRemoveShape:e[17],beforeDeselectShape:e[18],beforeSelectShape:e[19],beforeUpdateShape:e[20]}),t.$set(n)},i(e){o||(transition_in(t.$$.fragment,e),o=!0)},o(e){transition_out(t.$$.fragment,e),o=!1},d(e){destroy_component(t,e)}}}function instance$3(e,t,o){let n,r,a,i,s,l;let{isActive:c}=t,{isActiveFraction:p}=t,{isVisible:u}=t,{stores:d}=t,{locale:h={}}=t,{markupEditorToolbar:m}=t,{markupEditorToolStyles:g}=t,{markupEditorShapeStyleControls:f}=t,{annotateTools:_}=t,{annotateToolShapes:$}=t,{annotateShapeControls:b}=t,{annotateActiveTool:y="sharpie"}=t,{annotateEnableButtonFlipVertical:x=!1}=t,{annotateEnableSelectImagePreset:v=!1}=t,{annotatePresets:C=[]}=t,{willRenderShapeControls:S}=t,{beforeAddShape:k}=t,{beforeRemoveShape:w}=t,{beforeDeselectShape:R}=t,{beforeSelectShape:T}=t,{beforeUpdateShape:E}=t;const{rootRect:I,imageAnnotation:A,imageSize:M,imageTransforms:P,imageRotation:D,imageFlipX:F,imageFlipY:L}=d;component_subscribe(e,I,e=>o(35,n=e)),component_subscribe(e,M,e=>o(36,r=e)),component_subscribe(e,P,e=>o(37,a=e)),component_subscribe(e,D,e=>o(23,l=e)),component_subscribe(e,F,e=>o(21,i=e)),component_subscribe(e,L,e=>o(22,s=e));return e.$$set=(e=>{"isActive"in e&&o(0,c=e.isActive),"isActiveFraction"in e&&o(1,p=e.isActiveFraction),"isVisible"in e&&o(2,u=e.isVisible),"stores"in e&&o(3,d=e.stores),"locale"in e&&o(4,h=e.locale),"markupEditorToolbar"in e&&o(5,m=e.markupEditorToolbar),"markupEditorToolStyles"in e&&o(6,g=e.markupEditorToolStyles),"markupEditorShapeStyleControls"in e&&o(7,f=e.markupEditorShapeStyleControls),"annotateTools"in e&&o(8,_=e.annotateTools),"annotateToolShapes"in e&&o(9,$=e.annotateToolShapes),"annotateShapeControls"in e&&o(10,b=e.annotateShapeControls),"annotateActiveTool"in e&&o(11,y=e.annotateActiveTool),"annotateEnableButtonFlipVertical"in e&&o(12,x=e.annotateEnableButtonFlipVertical),"annotateEnableSelectImagePreset"in e&&o(13,v=e.annotateEnableSelectImagePreset),"annotatePresets"in e&&o(14,C=e.annotatePresets),"willRenderShapeControls"in e&&o(15,S=e.willRenderShapeControls),"beforeAddShape"in e&&o(16,k=e.beforeAddShape),"beforeRemoveShape"in e&&o(17,w=e.beforeRemoveShape),"beforeDeselectShape"in e&&o(18,R=e.beforeDeselectShape),"beforeSelectShape"in e&&o(19,T=e.beforeSelectShape),"beforeUpdateShape"in e&&o(20,E=e.beforeUpdateShape)}),[c,p,u,d,h,m,g,f,_,$,b,y,x,v,C,S,k,w,R,T,E,i,s,l,I,A,M,P,D,F,L,e=>_mapScreenPointToImagePoint(e,n,r,a.origin,a.translation,a.rotation.z,a.scale,i,s),e=>_mapImagePointToScreenPoint(e,n,r,a.origin,a.translation,a.rotation.z,a.scale,i,s),"annotate",function(t){bubble(e,t)}]}class Annotate extends SvelteComponent{constructor(e){super(),init(this,e,instance$3,create_fragment$3,safe_not_equal,{name:33,isActive:0,isActiveFraction:1,isVisible:2,stores:3,locale:4,markupEditorToolbar:5,markupEditorToolStyles:6,markupEditorShapeStyleControls:7,annotateTools:8,annotateToolShapes:9,annotateShapeControls:10,annotateActiveTool:11,annotateEnableButtonFlipVertical:12,annotateEnableSelectImagePreset:13,annotatePresets:14,willRenderShapeControls:15,beforeAddShape:16,beforeRemoveShape:17,beforeDeselectShape:18,beforeSelectShape:19,beforeUpdateShape:20},[-1,-1])}get name(){return this.$$.ctx[33]}get isActive(){return this.$$.ctx[0]}set isActive(e){this.$set({isActive:e}),flush()}get isActiveFraction(){return this.$$.ctx[1]}set isActiveFraction(e){this.$set({isActiveFraction:e}),flush()}get isVisible(){return this.$$.ctx[2]}set isVisible(e){this.$set({isVisible:e}),flush()}get stores(){return this.$$.ctx[3]}set stores(e){this.$set({stores:e}),flush()}get locale(){return this.$$.ctx[4]}set locale(e){this.$set({locale:e}),flush()}get markupEditorToolbar(){return this.$$.ctx[5]}set markupEditorToolbar(e){this.$set({markupEditorToolbar:e}),flush()}get markupEditorToolStyles(){return this.$$.ctx[6]}set markupEditorToolStyles(e){this.$set({markupEditorToolStyles:e}),flush()}get markupEditorShapeStyleControls(){return this.$$.ctx[7]}set markupEditorShapeStyleControls(e){this.$set({markupEditorShapeStyleControls:e}),flush()}get annotateTools(){return this.$$.ctx[8]}set annotateTools(e){this.$set({annotateTools:e}),flush()}get annotateToolShapes(){return this.$$.ctx[9]}set annotateToolShapes(e){this.$set({annotateToolShapes:e}),flush()}get annotateShapeControls(){return this.$$.ctx[10]}set annotateShapeControls(e){this.$set({annotateShapeControls:e}),flush()}get annotateActiveTool(){return this.$$.ctx[11]}set annotateActiveTool(e){this.$set({annotateActiveTool:e}),flush()}get annotateEnableButtonFlipVertical(){return this.$$.ctx[12]}set annotateEnableButtonFlipVertical(e){this.$set({annotateEnableButtonFlipVertical:e}),flush()}get annotateEnableSelectImagePreset(){return this.$$.ctx[13]}set annotateEnableSelectImagePreset(e){this.$set({annotateEnableSelectImagePreset:e}),flush()}get annotatePresets(){return this.$$.ctx[14]}set annotatePresets(e){this.$set({annotatePresets:e}),flush()}get willRenderShapeControls(){return this.$$.ctx[15]}set willRenderShapeControls(e){this.$set({willRenderShapeControls:e}),flush()}get beforeAddShape(){return this.$$.ctx[16]}set beforeAddShape(e){this.$set({beforeAddShape:e}),flush()}get beforeRemoveShape(){return this.$$.ctx[17]}set beforeRemoveShape(e){this.$set({beforeRemoveShape:e}),flush()}get beforeDeselectShape(){return this.$$.ctx[18]}set beforeDeselectShape(e){this.$set({beforeDeselectShape:e}),flush()}get beforeSelectShape(){return this.$$.ctx[19]}set beforeSelectShape(e){this.$set({beforeSelectShape:e}),flush()}get beforeUpdateShape(){return this.$$.ctx[20]}set beforeUpdateShape(e){this.$set({beforeUpdateShape:e}),flush()}}var index$3={util:["annotate",Annotate]};function create_fragment$2(e){let t,o;return(t=new ShapeUtil({props:{stores:e[3],locale:e[4],isActive:e[0],isActiveFraction:e[1],isVisible:e[2],mapScreenPointToImagePoint:e[25],mapImagePointToScreenPoint:e[26],utilKey:"decorate",shapes:e[22],tools:e[8]||e[5],toolShapes:e[9]||e[6],toolActive:e[11],shapeControls:e[10]||e[7],shapePresets:e[14],enablePresetSelectImage:e[13],enableButtonFlipVertical:e[12],parentRect:e[21],hooks:{willRenderShapeControls:e[15],beforeAddShape:e[16],beforeRemoveShape:e[17],beforeDeselectShape:e[18],beforeSelectShape:e[19],beforeUpdateShape:e[20]}}})).$on("measure",e[28]),{c(){create_component(t.$$.fragment)},m(e,n){mount_component(t,e,n),o=!0},p(e,[o]){const n={};8&o&&(n.stores=e[3]),16&o&&(n.locale=e[4]),1&o&&(n.isActive=e[0]),2&o&&(n.isActiveFraction=e[1]),4&o&&(n.isVisible=e[2]),288&o&&(n.tools=e[8]||e[5]),576&o&&(n.toolShapes=e[9]||e[6]),2048&o&&(n.toolActive=e[11]),1152&o&&(n.shapeControls=e[10]||e[7]),16384&o&&(n.shapePresets=e[14]),8192&o&&(n.enablePresetSelectImage=e[13]),4096&o&&(n.enableButtonFlipVertical=e[12]),2064384&o&&(n.hooks={willRenderShapeControls:e[15],beforeAddShape:e[16],beforeRemoveShape:e[17],beforeDeselectShape:e[18],beforeSelectShape:e[19],beforeUpdateShape:e[20]}),t.$set(n)},i(e){o||(transition_in(t.$$.fragment,e),o=!0)},o(e){transition_out(t.$$.fragment,e),o=!1},d(e){destroy_component(t,e)}}}function instance$2(e,t,o){let n,r;let{isActive:a}=t,{isActiveFraction:i}=t,{isVisible:s}=t,{stores:l}=t,{locale:c={}}=t,{markupEditorToolbar:p}=t,{markupEditorToolStyles:u}=t,{markupEditorShapeStyleControls:d}=t,{decorateTools:h}=t,{decorateToolShapes:m}=t,{decorateShapeControls:g}=t,{decorateActiveTool:f="sharpie"}=t,{decorateEnableButtonFlipVertical:_=!1}=t,{decorateEnableSelectImagePreset:$=!1}=t,{decoratePresets:b=[]}=t,{willRenderShapeControls:y}=t,{beforeAddShape:x}=t,{beforeRemoveShape:v}=t,{beforeDeselectShape:C}=t,{beforeSelectShape:S}=t,{beforeUpdateShape:k}=t;const{imageCropRect:w,imageDecoration:R,imageSelectionRectPresentation:T,presentationScalar:E}=l;component_subscribe(e,T,e=>o(29,n=e)),component_subscribe(e,E,e=>o(30,r=e));return e.$$set=(e=>{"isActive"in e&&o(0,a=e.isActive),"isActiveFraction"in e&&o(1,i=e.isActiveFraction),"isVisible"in e&&o(2,s=e.isVisible),"stores"in e&&o(3,l=e.stores),"locale"in e&&o(4,c=e.locale),"markupEditorToolbar"in e&&o(5,p=e.markupEditorToolbar),"markupEditorToolStyles"in e&&o(6,u=e.markupEditorToolStyles),"markupEditorShapeStyleControls"in e&&o(7,d=e.markupEditorShapeStyleControls),"decorateTools"in e&&o(8,h=e.decorateTools),"decorateToolShapes"in e&&o(9,m=e.decorateToolShapes),"decorateShapeControls"in e&&o(10,g=e.decorateShapeControls),"decorateActiveTool"in e&&o(11,f=e.decorateActiveTool),"decorateEnableButtonFlipVertical"in e&&o(12,_=e.decorateEnableButtonFlipVertical),"decorateEnableSelectImagePreset"in e&&o(13,$=e.decorateEnableSelectImagePreset),"decoratePresets"in e&&o(14,b=e.decoratePresets),"willRenderShapeControls"in e&&o(15,y=e.willRenderShapeControls),"beforeAddShape"in e&&o(16,x=e.beforeAddShape),"beforeRemoveShape"in e&&o(17,v=e.beforeRemoveShape),"beforeDeselectShape"in e&&o(18,C=e.beforeDeselectShape),"beforeSelectShape"in e&&o(19,S=e.beforeSelectShape),"beforeUpdateShape"in e&&o(20,k=e.beforeUpdateShape)}),[a,i,s,l,c,p,u,d,h,m,g,f,_,$,b,y,x,v,C,S,k,w,R,T,E,e=>{const t=vectorClone(e);return t.x-=n.x,t.y-=n.y,t.x/=r,t.y/=r,t},e=>{const t=vectorClone(e);return t.x*=r,t.y*=r,t.x+=n.x,t.y+=n.y,t},"decorate",function(t){bubble(e,t)}]}class Decorate extends SvelteComponent{constructor(e){super(),init(this,e,instance$2,create_fragment$2,safe_not_equal,{name:27,isActive:0,isActiveFraction:1,isVisible:2,stores:3,locale:4,markupEditorToolbar:5,markupEditorToolStyles:6,markupEditorShapeStyleControls:7,decorateTools:8,decorateToolShapes:9,decorateShapeControls:10,decorateActiveTool:11,decorateEnableButtonFlipVertical:12,decorateEnableSelectImagePreset:13,decoratePresets:14,willRenderShapeControls:15,beforeAddShape:16,beforeRemoveShape:17,beforeDeselectShape:18,beforeSelectShape:19,beforeUpdateShape:20})}get name(){return this.$$.ctx[27]}get isActive(){return this.$$.ctx[0]}set isActive(e){this.$set({isActive:e}),flush()}get isActiveFraction(){return this.$$.ctx[1]}set isActiveFraction(e){this.$set({isActiveFraction:e}),flush()}get isVisible(){return this.$$.ctx[2]}set isVisible(e){this.$set({isVisible:e}),flush()}get stores(){return this.$$.ctx[3]}set stores(e){this.$set({stores:e}),flush()}get locale(){return this.$$.ctx[4]}set locale(e){this.$set({locale:e}),flush()}get markupEditorToolbar(){return this.$$.ctx[5]}set markupEditorToolbar(e){this.$set({markupEditorToolbar:e}),flush()}get markupEditorToolStyles(){return this.$$.ctx[6]}set markupEditorToolStyles(e){this.$set({markupEditorToolStyles:e}),flush()}get markupEditorShapeStyleControls(){return this.$$.ctx[7]}set markupEditorShapeStyleControls(e){this.$set({markupEditorShapeStyleControls:e}),flush()}get decorateTools(){return this.$$.ctx[8]}set decorateTools(e){this.$set({decorateTools:e}),flush()}get decorateToolShapes(){return this.$$.ctx[9]}set decorateToolShapes(e){this.$set({decorateToolShapes:e}),flush()}get decorateShapeControls(){return this.$$.ctx[10]}set decorateShapeControls(e){this.$set({decorateShapeControls:e}),flush()}get decorateActiveTool(){return this.$$.ctx[11]}set decorateActiveTool(e){this.$set({decorateActiveTool:e}),flush()}get decorateEnableButtonFlipVertical(){return this.$$.ctx[12]}set decorateEnableButtonFlipVertical(e){this.$set({decorateEnableButtonFlipVertical:e}),flush()}get decorateEnableSelectImagePreset(){return this.$$.ctx[13]}set decorateEnableSelectImagePreset(e){this.$set({decorateEnableSelectImagePreset:e}),flush()}get decoratePresets(){return this.$$.ctx[14]}set decoratePresets(e){this.$set({decoratePresets:e}),flush()}get willRenderShapeControls(){return this.$$.ctx[15]}set willRenderShapeControls(e){this.$set({willRenderShapeControls:e}),flush()}get beforeAddShape(){return this.$$.ctx[16]}set beforeAddShape(e){this.$set({beforeAddShape:e}),flush()}get beforeRemoveShape(){return this.$$.ctx[17]}set beforeRemoveShape(e){this.$set({beforeRemoveShape:e}),flush()}get beforeDeselectShape(){return this.$$.ctx[18]}set beforeDeselectShape(e){this.$set({beforeDeselectShape:e}),flush()}get beforeSelectShape(){return this.$$.ctx[19]}set beforeSelectShape(e){this.$set({beforeSelectShape:e}),flush()}get beforeUpdateShape(){return this.$$.ctx[20]}set beforeUpdateShape(e){this.$set({beforeUpdateShape:e}),flush()}}var index$2={util:["decorate",Decorate]};function create_fragment$1(e){let t,o;return(t=new ShapeUtil({props:{stores:e[3],locale:e[4],isActive:e[0],isActiveFraction:e[1],isVisible:e[2],mapScreenPointToImagePoint:e[29],mapImagePointToScreenPoint:e[30],utilKey:"sticker",shapePresets:e[5],shapes:e[6]?e[22]:e[23],toolActive:"preset",imageFlipX:!!e[6]&&e[15],imageFlipY:!!e[6]&&e[16],imageRotation:e[6]?e[17]:0,parentRect:e[6]?e[24]:e[20],enablePresetSelectImage:e[7],enableButtonFlipVertical:e[8],hooks:{willRenderShapeControls:e[9],beforeAddShape:e[10],beforeRemoveShape:e[11],beforeDeselectShape:e[12],beforeSelectShape:e[13],beforeUpdateShape:e[14]}}})).$on("measure",e[32]),{c(){create_component(t.$$.fragment)},m(e,n){mount_component(t,e,n),o=!0},p(e,o){const n={};8&o[0]&&(n.stores=e[3]),16&o[0]&&(n.locale=e[4]),1&o[0]&&(n.isActive=e[0]),2&o[0]&&(n.isActiveFraction=e[1]),4&o[0]&&(n.isVisible=e[2]),32&o[0]&&(n.shapePresets=e[5]),64&o[0]&&(n.shapes=e[6]?e[22]:e[23]),32832&o[0]&&(n.imageFlipX=!!e[6]&&e[15]),65600&o[0]&&(n.imageFlipY=!!e[6]&&e[16]),131136&o[0]&&(n.imageRotation=e[6]?e[17]:0),64&o[0]&&(n.parentRect=e[6]?e[24]:e[20]),128&o[0]&&(n.enablePresetSelectImage=e[7]),256&o[0]&&(n.enableButtonFlipVertical=e[8]),32256&o[0]&&(n.hooks={willRenderShapeControls:e[9],beforeAddShape:e[10],beforeRemoveShape:e[11],beforeDeselectShape:e[12],beforeSelectShape:e[13],beforeUpdateShape:e[14]}),t.$set(n)},i(e){o||(transition_in(t.$$.fragment,e),o=!0)},o(e){transition_out(t.$$.fragment,e),o=!1},d(e){destroy_component(t,e)}}}function instance$1(e,t,o){let n,r,a,i,s,l,c,p;let{isActive:u}=t,{isActiveFraction:d}=t,{isVisible:h}=t,{stores:m}=t,{locale:g={}}=t,{stickers:f=[]}=t,{stickerStickToImage:_=!1}=t,{stickerEnableSelectImage:$=!0}=t,{stickersEnableButtonFlipVertical:b=!1}=t,{willRenderShapeControls:y}=t,{beforeAddShape:x}=t,{beforeRemoveShape:v}=t,{beforeDeselectShape:C}=t,{beforeSelectShape:S}=t,{beforeUpdateShape:k}=t;const{presentationScalar:w,rootRect:R,imageCropRect:T,imageSelectionRectPresentation:E,imageAnnotation:I,imageDecoration:A,imageSize:M,imageTransforms:P,imageRotation:D,imageFlipX:F,imageFlipY:L}=m;component_subscribe(e,w,e=>o(37,c=e)),component_subscribe(e,R,e=>o(33,n=e)),component_subscribe(e,E,e=>o(36,l=e)),component_subscribe(e,M,e=>o(34,r=e)),component_subscribe(e,P,e=>o(35,a=e)),component_subscribe(e,D,e=>o(17,p=e)),component_subscribe(e,F,e=>o(15,i=e)),component_subscribe(e,L,e=>o(16,s=e));const z=_?e=>_mapScreenPointToImagePoint(e,n,r,a.origin,a.translation,a.rotation.z,a.scale,i,s):e=>{const t=vectorClone(e);return t.x-=l.x,t.y-=l.y,t.x/=c,t.y/=c,t},B=_?e=>_mapImagePointToScreenPoint(e,n,r,a.origin,a.translation,a.rotation.z,a.scale,i,s):e=>{const t=vectorClone(e);return t.x*=c,t.y*=c,t.x+=l.x,t.y+=l.y,t};return e.$$set=(e=>{"isActive"in e&&o(0,u=e.isActive),"isActiveFraction"in e&&o(1,d=e.isActiveFraction),"isVisible"in e&&o(2,h=e.isVisible),"stores"in e&&o(3,m=e.stores),"locale"in e&&o(4,g=e.locale),"stickers"in e&&o(5,f=e.stickers),"stickerStickToImage"in e&&o(6,_=e.stickerStickToImage),"stickerEnableSelectImage"in e&&o(7,$=e.stickerEnableSelectImage),"stickersEnableButtonFlipVertical"in e&&o(8,b=e.stickersEnableButtonFlipVertical),"willRenderShapeControls"in e&&o(9,y=e.willRenderShapeControls),"beforeAddShape"in e&&o(10,x=e.beforeAddShape),"beforeRemoveShape"in e&&o(11,v=e.beforeRemoveShape),"beforeDeselectShape"in e&&o(12,C=e.beforeDeselectShape),"beforeSelectShape"in e&&o(13,S=e.beforeSelectShape),"beforeUpdateShape"in e&&o(14,k=e.beforeUpdateShape)}),[u,d,h,m,g,f,_,$,b,y,x,v,C,S,k,i,s,p,w,R,T,E,I,A,M,P,D,F,L,z,B,"sticker",function(t){bubble(e,t)}]}class Sticker extends SvelteComponent{constructor(e){super(),init(this,e,instance$1,create_fragment$1,safe_not_equal,{name:31,isActive:0,isActiveFraction:1,isVisible:2,stores:3,locale:4,stickers:5,stickerStickToImage:6,stickerEnableSelectImage:7,stickersEnableButtonFlipVertical:8,willRenderShapeControls:9,beforeAddShape:10,beforeRemoveShape:11,beforeDeselectShape:12,beforeSelectShape:13,beforeUpdateShape:14},[-1,-1])}get name(){return this.$$.ctx[31]}get isActive(){return this.$$.ctx[0]}set isActive(e){this.$set({isActive:e}),flush()}get isActiveFraction(){return this.$$.ctx[1]}set isActiveFraction(e){this.$set({isActiveFraction:e}),flush()}get isVisible(){return this.$$.ctx[2]}set isVisible(e){this.$set({isVisible:e}),flush()}get stores(){return this.$$.ctx[3]}set stores(e){this.$set({stores:e}),flush()}get locale(){return this.$$.ctx[4]}set locale(e){this.$set({locale:e}),flush()}get stickers(){return this.$$.ctx[5]}set stickers(e){this.$set({stickers:e}),flush()}get stickerStickToImage(){return this.$$.ctx[6]}set stickerStickToImage(e){this.$set({stickerStickToImage:e}),flush()}get stickerEnableSelectImage(){return this.$$.ctx[7]}set stickerEnableSelectImage(e){this.$set({stickerEnableSelectImage:e}),flush()}get stickersEnableButtonFlipVertical(){return this.$$.ctx[8]}set stickersEnableButtonFlipVertical(e){this.$set({stickersEnableButtonFlipVertical:e}),flush()}get willRenderShapeControls(){return this.$$.ctx[9]}set willRenderShapeControls(e){this.$set({willRenderShapeControls:e}),flush()}get beforeAddShape(){return this.$$.ctx[10]}set beforeAddShape(e){this.$set({beforeAddShape:e}),flush()}get beforeRemoveShape(){return this.$$.ctx[11]}set beforeRemoveShape(e){this.$set({beforeRemoveShape:e}),flush()}get beforeDeselectShape(){return this.$$.ctx[12]}set beforeDeselectShape(e){this.$set({beforeDeselectShape:e}),flush()}get beforeSelectShape(){return this.$$.ctx[13]}set beforeSelectShape(e){this.$set({beforeSelectShape:e}),flush()}get beforeUpdateShape(){return this.$$.ctx[14]}set beforeUpdateShape(e){this.$set({beforeUpdateShape:e}),flush()}}var index$1={util:["sticker",Sticker]},smoothstep=(e,t,o,n=(e=>e*e*(3-2*e)))=>n(Math.max(0,Math.min(1,(o-e)/(t-e))));function create_default_slot_1(e){let t,o=(isString(e[2].resizeIconButtonMaintainAspectRatio)?e[2].resizeIconButtonMaintainAspectRatio:e[2].resizeIconButtonMaintainAspectRatio(e[3],e[12]))+"";return{c(){t=svg_element("g")},m(e,n){insert(e,t,n),t.innerHTML=o},p(e,n){4108&n[0]&&o!==(o=(isString(e[2].resizeIconButtonMaintainAspectRatio)?e[2].resizeIconButtonMaintainAspectRatio:e[2].resizeIconButtonMaintainAspectRatio(e[3],e[12]))+"")&&(t.innerHTML=o)},d(e){e&&detach(t)}}}function create_default_slot(e){let t;return{c(){t=text("Save")},m(e,o){insert(e,t,o)},d(e){e&&detach(t)}}}function create_footer_slot(e){let t,o,n,r,a,i,s,l,c,p,u,d,h,m,g,f,_,$,b,y,x,v,C,S,k,w,R,T,E,I,A,M,P,D,F=e[2].resizeLabelFormCaption+"",L=e[2].resizeLabelInputWidth+"",z=e[2].resizeLabelInputHeight+"";return y=new Icon({props:{$$slots:{default:[create_default_slot_1]},$$scope:{ctx:e}}}),A=new Button({props:{type:"submit",class:"implicit",$$slots:{default:[create_default_slot]},$$scope:{ctx:e}}}),{c(){t=element("form"),o=element("div"),n=element("fieldset"),r=element("legend"),a=text(F),i=space(),s=element("div"),l=element("div"),c=element("label"),p=text(L),h=space(),m=element("input"),g=space(),f=element("div"),_=element("input"),$=space(),b=element("label"),create_component(y.$$.fragment),v=space(),C=element("div"),S=element("label"),k=text(z),T=space(),E=element("input"),I=space(),create_component(A.$$.fragment),attr(r,"class","implicit"),attr(c,"for","doka-width-"+e[24]),attr(c,"title",u=e[2].resizeTitleInputWidth),attr(c,"aria-label",d=e[2].resizeTitleInputWidth),attr(m,"id","doka-width-"+e[24]),attr(m,"type","text"),attr(m,"inputmode","numeric"),attr(m,"pattern","[0-9]*"),attr(m,"data-state",e[9]),attr(m,"autocomplete","off"),attr(m,"placeholder",e[7]),attr(l,"class","DokaInputDimension"),attr(_,"class","implicit"),attr(_,"id","doka-maintainAspectRatio-"+e[24]),attr(_,"type","checkbox"),attr(b,"for","doka-maintainAspectRatio-"+e[24]),attr(b,"title",x=e[2].resizeTitleButtonMaintainAspectRatio),attr(S,"for","doka-height-"+e[24]),attr(S,"title",w=e[2].resizeTitleInputHeight),attr(S,"aria-label",R=e[2].resizeTitleInputHeight),attr(E,"id","doka-height-"+e[24]),attr(E,"type","text"),attr(E,"inputmode","numeric"),attr(E,"pattern","[0-9]*"),attr(E,"autocomplete","off"),attr(E,"data-state",e[10]),attr(E,"placeholder",e[8]),attr(C,"class","DokaInputDimension"),attr(s,"class","DokaFieldsetInner"),attr(o,"class","DokaFormInner"),attr(t,"slot","footer"),attr(t,"style",e[11])},m(u,d){insert(u,t,d),append(t,o),append(o,n),append(n,r),append(r,a),append(n,i),append(n,s),append(s,l),append(l,c),append(c,p),append(l,h),append(l,m),set_input_value(m,e[4]),append(s,g),append(s,f),append(f,_),_.checked=e[3],append(f,$),append(f,b),mount_component(y,b,null),append(s,v),append(s,C),append(C,S),append(S,k),append(C,T),append(C,E),set_input_value(E,e[5]),e[63](s),append(o,I),mount_component(A,o,null),M=!0,P||(D=[listen(m,"input",e[60]),listen(_,"change",e[61]),listen(E,"input",e[62]),listen(s,"focusin",e[25]),listen(s,"focusout",e[26]),listen(t,"submit",prevent_default(e[27]))],P=!0)},p(e,o){(!M||4&o[0])&&F!==(F=e[2].resizeLabelFormCaption+"")&&set_data(a,F),(!M||4&o[0])&&L!==(L=e[2].resizeLabelInputWidth+"")&&set_data(p,L),(!M||4&o[0]&&u!==(u=e[2].resizeTitleInputWidth))&&attr(c,"title",u),(!M||4&o[0]&&d!==(d=e[2].resizeTitleInputWidth))&&attr(c,"aria-label",d),(!M||512&o[0])&&attr(m,"data-state",e[9]),(!M||128&o[0])&&attr(m,"placeholder",e[7]),16&o[0]&&m.value!==e[4]&&set_input_value(m,e[4]),8&o[0]&&(_.checked=e[3]);const n={};4108&o[0]|8192&o[2]&&(n.$$scope={dirty:o,ctx:e}),y.$set(n),(!M||4&o[0]&&x!==(x=e[2].resizeTitleButtonMaintainAspectRatio))&&attr(b,"title",x),(!M||4&o[0])&&z!==(z=e[2].resizeLabelInputHeight+"")&&set_data(k,z),(!M||4&o[0]&&w!==(w=e[2].resizeTitleInputHeight))&&attr(S,"title",w),(!M||4&o[0]&&R!==(R=e[2].resizeTitleInputHeight))&&attr(S,"aria-label",R),(!M||1024&o[0])&&attr(E,"data-state",e[10]),(!M||256&o[0])&&attr(E,"placeholder",e[8]),32&o[0]&&E.value!==e[5]&&set_input_value(E,e[5]);const r={};8192&o[2]&&(r.$$scope={dirty:o,ctx:e}),A.$set(r),(!M||2048&o[0])&&attr(t,"style",e[11])},i(e){M||(transition_in(y.$$.fragment,e),transition_in(A.$$.fragment,e),M=!0)},o(e){transition_out(y.$$.fragment,e),transition_out(A.$$.fragment,e),M=!1},d(o){o&&detach(t),destroy_component(y),e[63](null),destroy_component(A),P=!1,run_all(D)}}}function create_fragment(e){let t,o;return(t=new Util({props:{$$slots:{footer:[create_footer_slot]},$$scope:{ctx:e}}})).$on("measure",e[64]),{c(){create_component(t.$$.fragment)},m(e,n){mount_component(t,e,n),o=!0},p(e,o){const n={};8188&o[0]|8192&o[2]&&(n.$$scope={dirty:o,ctx:e}),t.$set(n)},i(e){o||(transition_in(t.$$.fragment,e),o=!0)},o(e){transition_out(t.$$.fragment,e),o=!1},d(e){destroy_component(t,e)}}}const id="resize-overlay",maxOpacity=.85,size=180,inset=40,margin=0;function instance(e,t,o){let n,r,a,i,s,l,c,p,u,d,h,m,g,f,_,$,b,y,x,v,C,S,k,w,R,T,E,I=noop,A=()=>(I(),I=subscribe(F,e=>o(42,b=e)),F),M=noop,P=()=>(M(),M=subscribe(L,e=>o(50,C=e)),L);e.$$.on_destroy.push(()=>I()),e.$$.on_destroy.push(()=>M());const D=(e,t=0,o=9999)=>{if(isString(e)&&!(e=e.replace(/\D/g,"")).length)return;const n=Math.round(e);return Number.isNaN(n)?void 0:clamp(n,t,o)};let{isActive:F}=t;A();let{isActiveFraction:L}=t;P();let{stores:z}=t,{locale:B={}}=t,{resizeMinSize:O=sizeCreate(1,1)}=t,{resizeMaxSize:U=sizeCreate(9999,9999)}=t;const N=spring(0,{stiffness:.15,damping:.3});component_subscribe(e,N,e=>o(12,E=e));const{env:V,animation:H,utilRect:W,rootRect:G,rootBackgroundColor:j,imageSize:q,imageCropRect:X,imageCropRectAspectRatio:Y,imageCropAspectRatio:K,imageOutputSize:Z,imageOverlayMarkup:J,history:Q}=z;component_subscribe(e,H,e=>o(58,R=e)),component_subscribe(e,W,e=>o(47,x=e)),component_subscribe(e,G,e=>o(49,v=e)),component_subscribe(e,j,e=>o(43,y=e)),component_subscribe(e,q,e=>o(67,$=e)),component_subscribe(e,X,e=>o(40,g=e)),component_subscribe(e,Y,e=>o(39,m=e)),component_subscribe(e,K,e=>o(66,_=e)),component_subscribe(e,Z,e=>o(41,f=e)),component_subscribe(e,J,e=>o(57,w=e));const ee=getUniqueId();let te,oe,ne,re,ae,ie,se,le,ce,pe=!1;const ue=e=>{let t=D(oe),n=D(ne),r=t,a=n,i=r&&a,s=e||m;if(!r&&!a)return;r&&!a?a=Math.round(r/s):a&&!r&&(r=Math.round(a*s)),s=e||i?getAspectRatio(r,a):m;let l=sizeCreate(r,a);sizeContains(U,l)||(l=rectContainRect(U,s)),sizeContains(l,O)||(l=rectCoverRect(O,s)),o(4,oe=null!=t?Math.round(l.width):void 0),o(5,ne=null!=n?Math.round(l.height):void 0)},de=()=>{ue();const{width:e,height:t}=f||{};e===oe&&t===ne||(oe||ne?(oe&&ne&&set_store_value(K,_=oe/ne,_),set_store_value(Z,f=sizeCreate(oe,ne),f)):(set_store_value(K,_=$.width/$.height,_),set_store_value(K,_=void 0,_),set_store_value(Z,f=void 0,f)),Q.write())};Z.subscribe(e=>{if(!e)return o(4,oe=void 0),void o(5,ne=void 0);o(4,oe=e.width),o(5,ne=e.height),ue()}),K.subscribe(e=>{(oe||ne)&&e&&(oe&&ne&&getAspectRatio(oe,ne)!==e?(o(5,ne=oe/e),ue(e)):ue())});const he=(e,t,o)=>{const n=document.createElement("canvas").getContext("2d");n.canvas.width=Math.max(1,e),n.canvas.height=Math.max(1,t);const r=n.createLinearGradient(0,0,e,t);return[[0,0],[.013,.081],[.049,.155],[.104,.225],[.175,.29],[.259,.353],[.352,.412],[.45,.471],[.55,.529],[.648,.588],[.741,.647],[.825,.71],[.896,.775],[.951,.845],[.987,.919],[1,1]].forEach(([e,t])=>r.addColorStop(t,`rgba(${255*o[0]}, ${255*o[1]}, ${255*o[2]}, ${e})`)),n.fillStyle=r,n.fillRect(0,0,n.canvas.width,n.canvas.height),document.body.appendChild(n.canvas),n.canvas},me=spring(0);component_subscribe(e,me,e=>o(54,k=e));const ge=spring(0);let fe;component_subscribe(e,ge,e=>o(51,S=e));const _e=spring(R?20:0);return component_subscribe(e,_e,e=>o(59,T=e)),e.$$set=(e=>{"isActive"in e&&A(o(0,F=e.isActive)),"isActiveFraction"in e&&P(o(1,L=e.isActiveFraction)),"stores"in e&&o(32,z=e.stores),"locale"in e&&o(2,B=e.locale),"resizeMinSize"in e&&o(33,O=e.resizeMinSize),"resizeMaxSize"in e&&o(34,U=e.resizeMaxSize)}),e.$$.update=(()=>{if(8&e.$$.dirty[0]&&N.set(pe?1:0),64&e.$$.dirty[1]&&le&&(ce=le),16&e.$$.dirty[0]&&o(35,re=D(oe)),32&e.$$.dirty[0]&&o(36,ae=D(ne)),92&e.$$.dirty[1]&&o(9,n=null!=re&&"width"!==le?re>=O.width&&re<=U.width?"valid":"invalid":"undetermined"),108&e.$$.dirty[1]&&o(10,r=null!=ae&&"height"!==le?ae>=O.height&&ae<=U.height?"valid":"invalid":"undetermined"),800&e.$$.dirty[1]&&o(7,ie=Math.round(null!=ae?ae*m:g.width)),784&e.$$.dirty[1]&&o(8,se=Math.round(null!=re?re/m:g.height)),56&e.$$.dirty[0]&&pe&&oe&&ne&&("width"===le?o(5,ne=Math.round(oe/m)):"height"===le?o(4,oe=Math.round(ne*m)):("width"===ce?o(5,ne=Math.round(oe/m)):"height"===ce&&o(4,oe=Math.round(ne*m)),ue())),6272&e.$$.dirty[1]&&(!b||!y||fe&&arrayEqual(fe,y)||o(38,fe=y)),128&e.$$.dirty[1]&&o(44,a=fe&&he(16,0,fe)),128&e.$$.dirty[1]&&o(45,i=fe&&he(0,16,fe)),1536&e.$$.dirty[1]&&o(46,s=((e,t)=>{let{width:o,height:n}=e;const r=rectAspectRatio(t);return o&&n?e:(o&&!n&&(n=o/r),n&&!o&&(o=n*r),o||n||(o=t.width,n=t.height),sizeApply(sizeCreate(o,n),Math.round))})(f||{},g)),98304&e.$$.dirty[1]&&x&&me.set(smoothstep(x.width,x.width+inset,s.width)),98304&e.$$.dirty[1]&&x&&ge.set(smoothstep(x.height,x.height+inset,s.height)),1851392&e.$$.dirty[1]&&o(48,l={id:id,x:0,y:-margin,width:v.width,height:size,rotation:Math.PI,opacity:C*maxOpacity*S,backgroundImage:i}),1851392&e.$$.dirty[1]&&o(52,c={id:id,x:0,y:v.height-size+margin,width:v.width,height:size,opacity:C*maxOpacity*S,backgroundImage:i}),9183232&e.$$.dirty[1]&&o(53,p={id:id,x:-margin,y:0,height:v.height,width:size,rotation:Math.PI,opacity:C*maxOpacity*k,backgroundImage:a}),9183232&e.$$.dirty[1]&&o(55,u={id:id,x:v.width-size+margin,y:0,height:v.height,width:size,opacity:C*maxOpacity*k,backgroundImage:a}),23199744&e.$$.dirty[1]&&o(56,d=[l,u,c,p]),101318656&e.$$.dirty[1]&&l){const e=w.filter(e=>e.id!==id);set_store_value(J,w=C>0?[...e,...d]:e,w)}134219776&e.$$.dirty[1]&&R&&_e.set(b?0:20),268435456&e.$$.dirty[1]&&o(11,h=T?`transform: translateY(${T}px)`:void 0)}),[F,L,B,pe,oe,ne,te,ie,se,n,r,h,E,N,H,W,G,j,q,X,Y,K,Z,J,ee,e=>{const t=e.target.id;/width/.test(t)?o(37,le="width"):/height/.test(t)?o(37,le="height"):/aspectRatio/i.test(t)?o(37,le="lock"):o(37,le=void 0)},e=>{te.contains(e.relatedTarget)||de(),o(37,le=void 0)},de,me,ge,_e,"resize",z,O,U,re,ae,le,fe,m,g,f,b,y,a,i,s,x,l,v,C,S,c,p,k,u,d,w,R,T,function(){oe=this.value,o(4,oe)},function(){pe=this.checked,o(3,pe)},function(){ne=this.value,o(5,ne)},function(e){binding_callbacks[e?"unshift":"push"](()=>{o(6,te=e)})},function(t){bubble(e,t)}]}class Resize extends SvelteComponent{constructor(e){super(),init(this,e,instance,create_fragment,safe_not_equal,{name:31,isActive:0,isActiveFraction:1,stores:32,locale:2,resizeMinSize:33,resizeMaxSize:34},[-1,-1,-1])}get name(){return this.$$.ctx[31]}get isActive(){return this.$$.ctx[0]}set isActive(e){this.$set({isActive:e}),flush()}get isActiveFraction(){return this.$$.ctx[1]}set isActiveFraction(e){this.$set({isActiveFraction:e}),flush()}get stores(){return this.$$.ctx[32]}set stores(e){this.$set({stores:e}),flush()}get locale(){return this.$$.ctx[2]}set locale(e){this.$set({locale:e}),flush()}get resizeMinSize(){return this.$$.ctx[33]}set resizeMinSize(e){this.$set({resizeMinSize:e}),flush()}get resizeMaxSize(){return this.$$.ctx[34]}set resizeMaxSize(e){this.$set({resizeMaxSize:e}),flush()}}var index={util:["resize",Resize]};const cropSelectPresetOptionsDefault=[["Crop",[[void 0,"Custom"],[1,"Square"],[4/3,"Landscape"],[.75,"Portrait"]]],["Size",[[[180,180],"Profile Picture"],[[1200,600],"Header Image"],[[800,400],"Timeline Photo"]]]];var defaults={cropSelectPresetOptions:cropSelectPresetOptionsDefault};const IconCross='<g fill="none" fill-rule="evenodd" stroke-linecap="round" stroke-linejoin="round" stroke="currentColor" stroke-width=".125em"><path d="M18 6L6 18M6 6l12 12"></path></path></g>';var en_gb$7={labelReset:"Reset",labelDefault:"Default",labelAuto:"Auto",labelNone:"None",labelEdit:"Edit",labelClose:"Close",labelSupportError:e=>`${e.join(", ")} not supported on this browser`,labelSizeExtraSmall:"Extra small",labelSizeSmall:"Small",labelSizeMediumSmall:"Medium small",labelSizeMedium:"Medium",labelSizeMediumLarge:"Medium large",labelSizeLarge:"Large",labelSizeExtraLarge:"Extra large",labelButtonRevert:"Revert",labelButtonCancel:"Cancel",labelButtonUndo:"Undo",labelButtonRedo:"Redo",labelButtonExport:"Done",iconSupportError:'<g fill="none" stroke="currentColor" stroke-width="2"><path d="M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"/><g><line x1="12" y1="9" x2="12" y2="13"/><line x1="12" y1="17" x2="12.01" y2="17"/></g>',iconButtonClose:IconCross,iconButtonRevert:'<g fill="none" fill-rule="evenodd" stroke-linecap="round" stroke-linejoin="round" stroke="currentColor" stroke-width=".125em"><path d="M7.388 18.538a8 8 0 10-2.992-9.03"/><path fill="currentColor" d="M2.794 11.696L2.37 6.714l5.088 3.18z"/><path d="M12 8v4M12 12l4 2"/></g>',iconButtonUndo:'<g fill="none" fill-rule="evenodd" stroke-linecap="round" stroke-linejoin="round" stroke="currentColor" stroke-width=".125em"><path d="M10 8h4c2.485 0 5 2 5 5s-2.515 5-5 5h-4"/><path fill="currentColor" d="M5 8l4-3v6z"/></g>',iconButtonRedo:'<g fill="none" fill-rule="evenodd" stroke-linecap="round" stroke-linejoin="round" stroke="currentColor" stroke-width=".125em"><path d="M14 8h-4c-2.485 0-5 2-5 5s2.515 5 5 5h4"/><path fill="currentColor" d="M19 8l-4-3v6z"/></g>',iconButtonExport:'<polyline points="20 6 9 17 4 12" fill="none" stroke="currentColor" stroke-width=".125em"></polyline>',statusLabelButtonClose:"Close",statusIconButtonClose:IconCross,statusLabelLoadImage:e=>e&&e.task?e.error?"IMAGE_TOO_SMALL"===e.error.code?"Minimum image size is {minWidth} × {minHeight}":"Error loading image":"blob-to-bitmap"===e.task?"Creating preview…":"Loading image…":"Waiting for image",statusLabelProcessImage:e=>{if(e&&e.task)return"store"===e.task?e.error?"Error uploading image":"Uploading image…":e.error?"Error processing image":"Processing image…"}};const MarkupEditor={shapeLabelButtonSelectSticker:"Select image",shapeIconButtonSelectSticker:'<g><circle fill="currentColor" cx="5" cy="6" r="1.333"/><g fill="none" stroke="currentColor" stroke-width="0.0625em" stroke-linecap="round" stroke-linejoin="round"><rect x="1" y="1" width="14" height="14" rx="2"/><path d="M15 13l-5-6-5 8"/></g></g>',shapeIconButtonFlipHorizontal:'<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg"><g stroke="#FFF" stroke-width="2" fill="none" fill-rule="evenodd"><path d="M6 6.5h5v11H6z"/><path fill="#FFF" d="M15 6.5h3v11h-3z"/><path d="M11 4v16" fill="#fff"/></g></svg>',shapeIconButtonFlipVertical:'<g stroke="currentColor" stroke-width=".125em"><rect x="7" y="8" width="11" height="5" fill="none"/><rect x="7" y="17" width="11" height="2" fill="currentColor"/><line x1="5" y1="13" x2="20" y2="13"/></g>',shapeIconButtonRemove:'<g fill="none" fill-rule="evenodd"><path stroke="#FFF" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" d="M7.5 7h9z"/><path d="M7.916 9h8.168a1 1 0 01.99 1.14l-.972 6.862a2 2 0 01-1.473 1.653c-.877.23-1.753.345-2.629.345-.876 0-1.752-.115-2.628-.345a2 2 0 01-1.473-1.653l-.973-6.862A1 1 0 017.916 9z" fill="#FFF"/><rect fill="#FFF" x="10" y="5" width="4" height="3" rx="1"/></g>',shapeIconButtonDuplicate:'<g fill="none" fill-rule="evenodd"><path d="M15 13.994V16a2 2 0 01-2 2H8a2 2 0 01-2-2v-5a2 2 0 012-2h2.142" stroke="currentColor" stroke-width=".125em"/><path d="M15 9V8a1 1 0 00-2 0v1h-1a1 1 0 000 2h1v1a1 1 0 002 0v-1h1a1 1 0 000-2h-1zm-4-4h6a2 2 0 012 2v6a2 2 0 01-2 2h-6a2 2 0 01-2-2V7a2 2 0 012-2z" fill="currentColor"/></g>',shapeIconButtonMoveToFront:'<g fill="none" fill-rule="evenodd"><rect fill="currentColor" x="11" y="13" width="8" height="2" rx="1"/><rect fill="currentColor" x="9" y="17" width="10" height="2" rx="1"/><path d="M11.364 8H10a5 5 0 000 10M12 6.5L14.5 8 12 9.5z" stroke="currentColor" stroke-width=".125em" stroke-linecap="round"/></g>',shapeTitleButtonFlipHorizontal:"Flip Horizontal",shapeTitleButtonFlipVertical:"Flip Vertical",shapeTitleButtonRemove:"Remove",shapeTitleButtonDuplicate:"Duplicate",shapeTitleButtonMoveToFront:"Move to front",shapeLabelInputText:"Edit text",shapeIconInputCancel:'<g fill="none" fill-rule="evenodd" stroke-linecap="round" stroke-linejoin="round" stroke="currentColor" stroke-width=".125em"><path d="M18 6L6 18M6 6l12 12"/></g>',shapeIconInputConfirm:'<g fill="none" fill-rule="evenodd" stroke-linecap="round" stroke-linejoin="round" stroke="currentColor" stroke-width=".125em"><polyline points="20 6 9 17 4 12"/></g>',shapeLabelInputCancel:"Cancel",shapeLabelInputConfirm:"Confirm",shapeLabelStrokeNone:"No outline",shapeLabelFontStyleNormal:"Normal",shapeLabelFontStyleBold:"Bold",shapeLabelFontStyleItalic:"Italic",shapeLabelFontStyleItalicBold:"Italic Bold",shapeTitleBackgroundColor:"Fill color",shapeTitleFontFamily:"Font",shapeTitleFontSize:"Font size",shapeTitleFontStyle:"Font style",shapeTitleLineHeight:"Leading",shapeTitleLineStart:"Start",shapeTitleLineEnd:"End",shapeTitleStrokeWidth:"Line width",shapeTitleStrokeColor:"Line color",shapeTitleLineDecorationBar:"Bar",shapeTitleLineDecorationCircle:"Circle",shapeTitleLineDecorationSquare:"Square",shapeTitleLineDecorationArrow:"Arrow",shapeTitleLineDecorationCircleSolid:"Circle solid",shapeTitleLineDecorationSquareSolid:"Square solid",shapeTitleLineDecorationArrowSolid:"Arrow solid",shapeIconLineDecorationBar:'<g stroke="currentColor" stroke-linecap="round" stroke-width=".125em"><path d="M5,12 H16"/><path d="M16,8 V16"/></g>',shapeIconLineDecorationCircle:'<g stroke="currentColor" stroke-linecap="round"><path stroke-width=".125em" d="M5,12 H12"/><circle fill="none" stroke-width=".125em" cx="16" cy="12" r="4"/></g>',shapeIconLineDecorationSquare:'<g stroke="currentColor" stroke-linecap="round" stroke-width=".125em"><path d="M5,12 H16"/><path d="M13,7 l6,5 l-6,5z" fill="currentColor"/></g>',shapeIconLineDecorationArrow:'<g stroke="currentColor" stroke-linecap="round" stroke-width=".125em"><path d="M5,12 H16 M13,7 l6,5 l-6,5" fill="none"/></g>',shapeIconLineDecorationCircleSolid:'<g stroke="currentColor" stroke-linecap="round"><path stroke-width=".125em" d="M5,12 H12"/><circle fill="currentColor" cx="16" cy="12" r="4"/></g>',shapeIconLineDecorationSquareSolid:'<g stroke="currentColor" stroke-linecap="round"><path stroke-width=".125em" d="M5,12 H12"/><rect fill="currentColor" x="12" y="8" width="8" height="8"/></g>',shapeIconLineDecorationArrowSolid:'<g stroke="currentColor" stroke-linecap="round" stroke-width=".125em"><path d="M5,12 H16"/><path d="M13,7 l6,5 l-6,5z" fill="currentColor"/></g>',shapeTitleColorTransparent:"Transparent",shapeTitleColorWhite:"White",shapeTitleColorSilver:"Silver",shapeTitleColorGray:"Gray",shapeTitleColorBlack:"Black",shapeTitleColorNavy:"Navy",shapeTitleColorBlue:"Blue",shapeTitleColorAqua:"Aqua",shapeTitleColorTeal:"Teal",shapeTitleColorOlive:"Olive",shapeTitleColorGreen:"Green",shapeTitleColorYellow:"Yellow",shapeTitleColorOrange:"Orange",shapeTitleColorRed:"Red",shapeTitleColorMaroon:"Maroon",shapeTitleColorFuchsia:"Fuchsia",shapeTitleColorPurple:"Purple",shapeTitleTextColor:"Font color",shapeTitleTextAlign:"Text align",shapeTitleTextAlignLeft:"Left align text",shapeTitleTextAlignCenter:"Center align text",shapeTitleTextAlignRight:"Right align text",shapeIconTextAlignLeft:'<g stroke-width=".125em" stroke="currentColor"><line x1="5" y1="8" x2="15" y2="8"/><line x1="5" y1="12" x2="19" y2="12"/><line x1="5" y1="16" x2="14" y2="16"/></g>',shapeIconTextAlignCenter:'<g stroke-width=".125em" stroke="currentColor"><line x1="7" y1="8" x2="17" y2="8"/><line x1="5" y1="12" x2="19" y2="12"/><line x1="8" y1="16" x2="16" y2="16"/></g>',shapeIconTextAlignRight:'<g stroke-width=".125em" stroke="currentColor"><line x1="9" y1="8" x2="19" y2="8"/><line x1="5" y1="12" x2="19" y2="12"/><line x1="11" y1="16" x2="19" y2="16"/></g>',shapeLabelToolSharpie:"Sharpie",shapeLabelToolEraser:"Eraser",shapeLabelToolRectangle:"Rectangle",shapeLabelToolEllipse:"Ellipse",shapeLabelToolArrow:"Arrow",shapeLabelToolLine:"Line",shapeLabelToolText:"Text",shapeLabelToolPreset:"Stickers",shapeIconToolSharpie:'<g stroke-width=".125em" stroke="currentColor" fill="none"><path d="M2.025 5c5.616-2.732 8.833-3.857 9.65-3.374C12.903 2.351.518 12.666 2.026 14 3.534 15.334 16.536.566 17.73 2.566 18.924 4.566 3.98 17.187 4.831 18c.851.813 9.848-6 11.643-6 1.087 0-2.53 5.11-2.92 7-.086.41 3.323-1.498 4.773-1 .494.17.64 2.317 1.319 3 .439.443 1.332.776 2.679 1" stroke="currentColor" stroke-width=".125em" fill="none" fill-rule="evenodd" stroke-linejoin="round"/></g>',shapeIconToolEraser:'<g stroke-width=".125em" stroke="currentColor" stroke-linecap="round" fill="none"><g transform="translate(3, 15) rotate(-45)"><rect x="0" y="0" width="18" height="10" rx="3"/></g><line x1="11" y1="21" x2="18" y2="21"/><line x1="20" y1="21" x2="22" y2="21"/></g>',shapeIconToolRectangle:'<g stroke-width=".125em" stroke="currentColor" fill="none"><rect x="2" y="2" width="20" height="20" rx="3"/></g>',shapeIconToolEllipse:'<g stroke-width=".125em" stroke="currentColor" fill="none"><circle cx="12" cy="12" r="11"/></g>',shapeIconToolArrow:'<g stroke-width=".125em" stroke="currentColor" fill="none"><line x1="20" y1="3" x2="6" y2="21"/><path d="m10 5 L22 1 L21 13" fill="currentColor" stroke="none"/></g>',shapeIconToolLine:'<g stroke-width=".125em" stroke="currentColor" fill="none"><line x1="20" y1="3" x2="6" y2="21"/></g>',shapeIconToolText:'<g stroke="none" fill="currentColor" transform="translate(6,0)"><path d="M8.14 20.085c.459 0 .901-.034 1.329-.102a8.597 8.597 0 001.015-.21v1.984c-.281.135-.695.247-1.242.336a9.328 9.328 0 01-1.477.133c-3.312 0-4.968-1.745-4.968-5.235V6.804H.344v-1.25l2.453-1.078L3.89.819h1.5v3.97h4.97v2.015H5.39v10.078c0 1.031.245 1.823.735 2.375s1.161.828 2.015.828z"/>',shapeIconToolPreset:'<g fill="none" stroke-linecap="round" stroke-linejoin="round" stroke="currentColor" stroke-width=".125em"><path d="M12 22c2.773 0 1.189-5.177 3-7 1.796-1.808 7-.25 7-3 0-5.523-4.477-10-10-10S2 6.477 2 12s4.477 10 10 10z"></path><path d="M20 17c-3 3-5 5-8 5"></path></g>'};var en_gb$6={cropLabel:"Crop",cropIcon:'<g stroke-width=".125em" stroke="currentColor" fill="none"><path d="M23 17H9a2 2 0 0 1-2-2v-5m0-3V1 M1 7h14a2 2 0 0 1 2 2v7m0 4v3"/></g>',cropIconButtonRecenter:'<path stroke="currentColor" fill="none" stroke-width="2" stroke-linejoin="bevel" d="M1.5 7.5v-6h6M1.5 16.5v6h6M22.5 16.5v6h-6M22.5 7.5v-6h-6"/><circle cx="12" cy="12" r="3.5" fill="currentColor" stroke="none"/>',cropIconButtonRotateLeft:'<g stroke="none" fill="currentColor"><path fill="none" d="M-1-1h582v402H-1z"/><rect x="3" rx="1" height="12" width="12" y="9"/><path d="M15 5h-1a5 5 0 015 5 1 1 0 002 0 7 7 0 00-7-7h-1.374l.747-.747A1 1 0 0011.958.84L9.603 3.194a1 1 0 000 1.415l2.355 2.355a1 1 0 001.415-1.414l-.55-.55H15z"/></g>',cropIconButtonRotateRight:'<g stroke="none" fill="currentColor"><path fill="none" d="M-1-1h582v402H-1z"/><path d="M11.177 5H10a5 5 0 00-5 5 1 1 0 01-2 0 7 7 0 017-7h1.374l-.747-.747A1 1 0 0112.042.84l2.355 2.355a1 1 0 010 1.415l-2.355 2.354a1 1 0 01-1.415-1.414l.55-.55z"/><rect rx="1" height="12" width="12" y="9" x="9"/></g>',cropIconButtonFlipVertical:'<g stroke="none" fill="currentColor"><path d="M19.993 12.143H7a1 1 0 0 1-1-1V5.994a1 1 0 0 1 1.368-.93l12.993 5.15a1 1 0 0 1-.368 1.93z"/><path d="M19.993 14a1 1 0 0 1 .368 1.93L7.368 21.078A1 1 0 0 1 6 20.148V15a1 1 0 0 1 1-1h12.993z" opacity=".6"/></g>',cropIconButtonFlipHorizontal:'<g stroke="none" fill="currentColor"><path d="M11.93 7.007V20a1 1 0 0 1-1 1H5.78a1 1 0 0 1-.93-1.368l5.15-12.993a1 1 0 0 1 1.929.368z"/><path d="M14 7.007V20a1 1 0 0 0 1 1h5.149a1 1 0 0 0 .93-1.368l-5.15-12.993A1 1 0 0 0 14 7.007z" opacity=".6"/></g>',cropIconSelectPreset:(e,t)=>{const[o,n,r]=t?[t<1?1:.3,1===t?.85:.5,t>1?1:.3]:[.2,.3,.4];return`<g fill="currentColor">\n            <rect opacity="${o}" x="2" y="4" width="10" height="18" rx="1"/>\n            <rect opacity="${n}" x="4" y="8" width="14" height="14" rx="1"/>\n            <rect opacity="${r}" x="6" y="12" width="17" height="10" rx="1"/>\n        </g>`},cropIconCropBoundary:(e,t)=>{const[o,n,r,a]=t?[.3,1,0,0]:[0,0,.3,1];return`<g fill="currentColor">\n            <rect opacity="${o}" x="2" y="3" width="20" height="20" rx="1"/>\n            <rect opacity="${n}" x="7" y="8" width="10" height="10" rx="1"/>\n            <rect opacity="${r}" x="4" y="8" width="14" height="14" rx="1"/>\n            <rect opacity="${a}" x="12" y="4" width="10" height="10" rx="1"/>\n        </g>`},cropLabelButtonRecenter:"Recenter",cropLabelButtonRotateLeft:"Rotate left",cropLabelButtonRotateRight:"Rotate right",cropLabelButtonFlipHorizontal:"Flip horizontal",cropLabelButtonFlipVertical:"Flip vertical",cropLabelSelectPreset:"Crop shape",cropLabelCropBoundary:"Crop boundary",cropLabelCropBoundaryEdge:"Edge of image",cropLabelCropBoundaryNone:"None",cropLabelTabRotation:"Rotation",cropLabelTabZoom:"Zoom"},en_gb$5={filterLabel:"Filter",filterIcon:'<g stroke-width=".125em" stroke="currentColor" fill="none"><path d="M18.347 9.907a6.5 6.5 0 1 0-1.872 3.306M3.26 11.574a6.5 6.5 0 1 0 2.815-1.417 M10.15 17.897A6.503 6.503 0 0 0 16.5 23a6.5 6.5 0 1 0-6.183-8.51"/></g>',filterLabelChrome:"Chrome",filterLabelFade:"Fade",filterLabelCold:"Cold",filterLabelWarm:"Warm",filterLabelPastel:"Pastel",filterLabelMonoDefault:"Mono",filterLabelMonoNoir:"Noir",filterLabelMonoWash:"Wash",filterLabelMonoStark:"Stark",filterLabelSepiaDefault:"Sepia",filterLabelSepiaBlues:"Blues",filterLabelSepiaRust:"Rust",filterLabelSepiaColor:"Color"},en_gb$4={finetuneLabel:"Finetune",finetuneIcon:'<g stroke-width=".125em" stroke="currentColor" fill="none"><path d="M4 1v5.5m0 3.503V23M12 1v10.5m0 3.5v8M20 1v15.5m0 3.5v3M2 7h4M10 12h4M18 17h4"/></g>',finetuneLabelBrightness:"Brightness",finetuneLabelContrast:"Contrast",finetuneLabelSaturation:"Saturation",finetuneLabelExposure:"Exposure",finetuneLabelTemperature:"Temperature",finetuneLabelGamma:"Gamma",finetuneLabelClarity:"Clarity",finetuneLabelVignette:"Vignette"},en_gb$3={resizeLabel:"Resize",resizeIcon:'<g stroke-width=".125em" stroke="currentColor" fill="none"><rect x="2" y="12" width="10" height="10" rx="2"/><path d="M4 11.5V4a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-5.5"/><path d="M14 10l3.365-3.365M14 6h4v4"/></g>',resizeLabelFormCaption:"Image output size",resizeLabelInputWidth:"w",resizeTitleInputWidth:"Width",resizeLabelInputHeight:"h",resizeTitleInputHeight:"Height",resizeTitleButtonMaintainAspectRatio:"Maintain aspectratio",resizeIconButtonMaintainAspectRatio:(e,t)=>`\n        <defs>\n            <mask id="mask1" x="0" y="0" width="24" height="24" >\n                <rect x="0" y="0" width="24" height="10" fill="#fff" stroke="none"/>\n            </mask>\n        </defs>\n        <g fill="none" fill-rule="evenodd">\n            <g  mask="url(#mask1)">\n                <path transform="translate(0 ${3*(t-1)})" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" d="M9.401 10.205v-.804a2.599 2.599 0 0 1 5.198 0V17"/>\n            </g>\n            <rect fill="currentColor" x="7" y="10" width="10" height="7" rx="1.5"/>\n        </g>\n    `},en_gb$2={decorateLabel:"Decorate",decorateIcon:'<g fill="none" fill-rule="evenodd"><path stroke="currentColor" stroke-width=".125em" stroke-linecap="round" stroke-linejoin="round" d="M12 18.5l-6.466 3.4 1.235-7.2-5.23-5.1 7.228-1.05L12 2l3.233 6.55 7.229 1.05-5.231 5.1 1.235 7.2z"/></g>'},en_gb$1={annotateLabel:"Annotate",annotateIcon:'<g stroke-width=".125em" stroke="currentColor" fill="none"><path d="M17.086 2.914a2.828 2.828 0 1 1 4 4l-14.5 14.5-5.5 1.5 1.5-5.5 14.5-14.5z"/></g>'},en_gb={stickerLabel:"Sticker",stickerIcon:'<g fill="none" stroke-linecap="round" stroke-linejoin="round" stroke="currentColor" stroke-width=".125em"><path d="M12 22c2.773 0 1.189-5.177 3-7 1.796-1.808 7-.25 7-3 0-5.523-4.477-10-10-10S2 6.477 2 12s4.477 10 10 10z"/><path d="M20 17c-3 3-5 5-8 5"/></g>'};const imageOrienter={read:getImageOrientationFromFile,apply:orientImageData},createDefaultImageOrienter=()=>({read:getImageOrientationFromFile,apply:orientImageData}),createEditor=createImageEditor,getEditorProps=()=>getEditorProps$1().concat(getEditorViewProps()),processImage=(e,t)=>{const{processImage:o}=createImageEditor();return o(e,t)},createMarkupEditorToolbar=createToolbar,createMarkupEditorToolStyles=createToolStyles,createMarkupEditorShapeStyleControls=createShapeStyleControls,markup_editor_defaults={markupEditorToolbar:createToolbar(),markupEditorToolStyles:createToolStyles(),markupEditorShapeStyleControls:createShapeStyleControls()},plugin_annotate_defaults={...markup_editor_defaults,annotateTools:createToolbar(),annotateToolShapes:createToolStyles(),annotateShapeControls:createShapeStyleControls()},plugin_decorate_defaults={...markup_editor_defaults,decorateTools:createToolbar(),decorateToolShapes:createToolStyles(),decorateShapeControls:createShapeStyleControls()},plugin_resize_defaults={},plugin_sticker_defaults={};export{appendEditor,appendEditors,appendNode,blobToFile,colorStringToColorArray,MarkupEditor as component_shape_editor_locale_en_gb,createDefaultColorOptions,createDefaultFontFamilyOptions,createDefaultFontScaleOptions,createDefaultFontSizeOptions,createDefaultFontStyleOptions,createDefaultImageOrienter,createDefaultImageReader,createDefaultImageWriter,createDefaultLineEndStyleOptions,createDefaultStrokeScaleOptions,createDefaultStrokeWidthOptions,createDefaultTextAlignOptions,createEditor,createBackgroundColorControl as createMarkupEditorBackgroundColorControl,createColorOptions as createMarkupEditorColorOptions,createFontColorControl as createMarkupEditorFontColorControl,createFontFamilyControl as createMarkupEditorFontFamilyControl,createFontFamilyOptions as createMarkupEditorFontFamilyOptions,createFontScaleOptions as createMarkupEditorFontScaleOptions,createFontSizeControl as createMarkupEditorFontSizeControl,createFontSizeOptions as createMarkupEditorFontSizeOptions,createFontStyleControl as createMarkupEditorFontStyleControl,createFontStyleOptions as createMarkupEditorFontStyleOptions,createLineEndStyleControl as createMarkupEditorLineEndStyleControl,createLineEndStyleOptions as createMarkupEditorLineEndStyleOptions,createLineHeightControl as createMarkupEditorLineHeightControl,createLineStartStyleControl as createMarkupEditorLineStartStyleControl,createMarkupEditorShapeStyleControls,createStrokeColorControl as createMarkupEditorStrokeColorControl,createStrokeScaleOptions as createMarkupEditorStrokeScaleOptions,createStrokeWidthControl as createMarkupEditorStrokeWidthControl,createStrokeWidthOptions as createMarkupEditorStrokeWidthOptions,createTextAlignControl as createMarkupEditorTextAlignControl,createToolStyle as createMarkupEditorToolStyle,createMarkupEditorToolStyles,createMarkupEditorToolbar,createNode,customElement as defineCustomElements,degToRad,dispatchEditorEvents,brightness as effectBrightness,clarity as effectClarity,contrast as effectContrast,exposure as effectExposure,gamma as effectGamma,saturation as effectSaturation,temperature as effectTemperature,vignette as effectVignette,chrome as filterChrome,cold as filterCold,fade as filterFade,invert as filterInvert,monoDefault as filterMonoDefault,monoNoir as filterMonoNoir,monoStark as filterMonoStark,monoWash as filterMonoWash,pastel as filterPastel,sepiaBlues as filterSepiaBlues,sepiaColor as filterSepiaColor,sepiaDefault as filterSepiaDefault,sepiaRust as filterSepiaRust,warm as filterWarm,findNode,getEditorProps,imageOrienter,insertNodeAfter,insertNodeBefore,isModernBrowser as isSupported,legacyDataToImageState,en_gb$7 as locale_en_gb,markup_editor_defaults,MarkupEditor as markup_editor_locale_en_gb,openEditor,overlayEditor,index$3 as plugin_annotate,plugin_annotate_defaults,en_gb$1 as plugin_annotate_locale_en_gb,index$6 as plugin_crop,defaults as plugin_crop_defaults,en_gb$6 as plugin_crop_locale_en_gb,index$2 as plugin_decorate,plugin_decorate_defaults,en_gb$2 as plugin_decorate_locale_en_gb,index$5 as plugin_filter,defaults$1 as plugin_filter_defaults,en_gb$5 as plugin_filter_locale_en_gb,index$4 as plugin_finetune,defaults$2 as plugin_finetune_defaults,en_gb$4 as plugin_finetune_locale_en_gb,index as plugin_resize,plugin_resize_defaults,en_gb$3 as plugin_resize_locale_en_gb,index$1 as plugin_sticker,plugin_sticker_defaults,en_gb as plugin_sticker_locale_en_gb,processImage,removeNode,setEditorViewPlugins as setPlugins,supportsWebGL};