@templatical/media-library 0.0.1 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ @import"https://fonts.bunny.net/css?family=geist:400,500,600";.vue-advanced-cropper{text-align:center;position:relative;user-select:none;max-height:100%;max-width:100%;direction:ltr}.vue-advanced-cropper__stretcher{pointer-events:none;position:relative;max-width:100%;max-height:100%}.vue-advanced-cropper__image{user-select:none;position:absolute;transform-origin:center;max-width:none!important}.vue-advanced-cropper__background,.vue-advanced-cropper__foreground{opacity:1;background:#000;transform:translate(-50%,-50%);position:absolute;top:50%;left:50%}.vue-advanced-cropper__foreground{opacity:.5}.vue-advanced-cropper__boundaries{opacity:1;transform:translate(-50%,-50%);position:absolute;left:50%;top:50%}.vue-advanced-cropper__cropper-wrapper{width:100%;height:100%}.vue-advanced-cropper__image-wrapper{overflow:hidden;position:absolute;width:100%;height:100%}.vue-advanced-cropper__stencil-wrapper{position:absolute}.vue-simple-handler{display:block;background:#fff;height:10px;width:10px}.vue-handler-wrapper{position:absolute;transform:translate(-50%,-50%);width:30px;height:30px}.vue-handler-wrapper__draggable{width:100%;height:100%;display:flex;align-items:center;justify-content:center}.vue-handler-wrapper--west-north{cursor:nw-resize}.vue-handler-wrapper--north{cursor:n-resize}.vue-handler-wrapper--east-north{cursor:ne-resize}.vue-handler-wrapper--east{cursor:e-resize}.vue-handler-wrapper--east-south{cursor:se-resize}.vue-handler-wrapper--south{cursor:s-resize}.vue-handler-wrapper--west-south{cursor:sw-resize}.vue-handler-wrapper--west{cursor:w-resize}.vue-handler-wrapper--disabled{cursor:auto}.vue-line-wrapper{background:none;position:absolute;display:flex;align-items:center;justify-content:center}.vue-line-wrapper--north,.vue-line-wrapper--south{height:12px;width:100%;left:0;transform:translateY(-50%)}.vue-line-wrapper--north{top:0;cursor:n-resize}.vue-line-wrapper--south{top:100%;cursor:s-resize}.vue-line-wrapper--east,.vue-line-wrapper--west{width:12px;height:100%;transform:translate(-50%);top:0}.vue-line-wrapper--east{left:100%;cursor:e-resize}.vue-line-wrapper--west{left:0;cursor:w-resize}.vue-line-wrapper--disabled{cursor:auto}.vue-bounding-box{position:relative;height:100%;width:100%}.vue-bounding-box__handler{position:absolute}.vue-bounding-box__handler--west-north{left:0;top:0}.vue-bounding-box__handler--north{left:50%;top:0}.vue-bounding-box__handler--east-north{left:100%;top:0}.vue-bounding-box__handler--east{left:100%;top:50%}.vue-bounding-box__handler--east-south{left:100%;top:100%}.vue-bounding-box__handler--south{left:50%;top:100%}.vue-bounding-box__handler--west-south{left:0;top:100%}.vue-bounding-box__handler--west{left:0;top:50%}.vue-draggable-area{position:relative}.vue-preview-result{overflow:hidden;box-sizing:border-box;position:absolute;height:100%;width:100%}.vue-preview-result__wrapper{position:absolute}.vue-preview-result__image{pointer-events:none;position:relative;user-select:none;transform-origin:center;max-width:none!important}.vue-rectangle-stencil{position:absolute;height:100%;width:100%;box-sizing:border-box}.vue-rectangle-stencil__preview{position:absolute;width:100%;height:100%}.vue-rectangle-stencil--movable{cursor:move}.vue-circle-stencil{position:absolute;height:100%;width:100%;box-sizing:content-box;cursor:move}.vue-circle-stencil__preview{border-radius:50%;position:absolute;width:100%;height:100%}.vue-circle-stencil--movable{cursor:move}.vue-preview{overflow:hidden;box-sizing:border-box;position:relative}.vue-preview--fill{width:100%;height:100%;position:absolute}.vue-preview__wrapper{position:absolute;height:100%;width:100%}.vue-preview__image{pointer-events:none;position:absolute;user-select:none;transform-origin:center;max-width:none!important}.vue-simple-line{background:none;transition:border .5s;border-color:#ffffff4d;border-width:0;border-style:solid}.vue-simple-line--south,.vue-simple-line--north{height:0;width:100%}.vue-simple-line--east,.vue-simple-line--west{height:100%;width:0}.vue-simple-line--east{border-right-width:1px}.vue-simple-line--west{border-left-width:1px}.vue-simple-line--south{border-bottom-width:1px}.vue-simple-line--north{border-top-width:1px}.vue-simple-line--hover{opacity:1;border-color:#fff}[data-v-bd5f2e31] .tpl-cropper-background{background-color:var(--tpl-bg)!important}[data-v-bd5f2e31] .vue-advanced-cropper{background-color:transparent!important}[data-v-bd5f2e31] .vue-advanced-cropper__background{background-color:var(--tpl-bg)!important}[data-v-bd5f2e31] .vue-advanced-cropper__foreground{background-color:var(--tpl-overlay)!important}.tpl-media-item[data-v-9db961d1]:not(.tpl-media-item--selected):hover{border-color:var(--tpl-border)!important}.tpl-media-list-item[data-v-9db961d1]:hover{background-color:var(--tpl-bg-hover)!important}.tpl-list-icon[data-v-9db961d1]{transform:scale(.35);transform-origin:center}.tpl-preview-icon[data-v-060e36cd]{transform:scale(.45);transform-origin:center}@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-translate-x:0;--tw-translate-y:0;--tw-translate-z:0;--tw-space-y-reverse:0;--tw-border-style:solid;--tw-font-weight:initial;--tw-tracking:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000;--tw-duration:initial;--tw-ease:initial;--tw-leading:initial}}}@layer theme{:root,:host{--tpl-radius-sm:.25rem;--tpl-radius-lg:.5rem;--tpl-shadow-xl:0 20px 25px -5px #0000001a, 0 8px 10px -6px #0000001a}}.tpl\:invisible{visibility:hidden}.tpl\:absolute{position:absolute}.tpl\:fixed{position:fixed}.tpl\:relative{position:relative}.tpl\:inset-0{inset:0}.tpl\:-top-1{top:-.25rem}.tpl\:top-1\.5{top:.375rem}.tpl\:top-1\/2{top:50%}.tpl\:top-full{top:100%}.tpl\:right-1\.5{right:.375rem}.tpl\:right-2\.5{right:.625rem}.tpl\:bottom-full{bottom:100%}.tpl\:left-0{left:0}.tpl\:left-1\.5{left:.375rem}.tpl\:left-1\/2{left:50%}.tpl\:left-2\.5{left:.625rem}.tpl\:z-10{z-index:10}.tpl\:z-50{z-index:50}.tpl\:z-\[9999\]{z-index:9999}.tpl\:z-\[10000\]{z-index:10000}.tpl\:mx-4{margin-inline:1rem}.tpl\:mt-0\.5{margin-top:.125rem}.tpl\:mt-1{margin-top:.25rem}.tpl\:mt-2{margin-top:.5rem}.tpl\:mb-1{margin-bottom:.25rem}.tpl\:mb-1\.5{margin-bottom:.375rem}.tpl\:mb-2{margin-bottom:.5rem}.tpl\:mb-3{margin-bottom:.75rem}.tpl\:mb-4{margin-bottom:1rem}.tpl\:mb-px{margin-bottom:1px}.tpl\:-ml-48{margin-left:-12rem}.tpl\:ml-0{margin-left:0}.tpl\:block{display:block}.tpl\:flex{display:flex}.tpl\:grid{display:grid}.tpl\:inline{display:inline}.tpl\:inline-flex{display:inline-flex}.tpl\:aspect-square{aspect-ratio:1}.tpl\:size-2{width:.5rem;height:.5rem}.tpl\:size-4{width:1rem;height:1rem}.tpl\:size-5{width:1.25rem;height:1.25rem}.tpl\:size-6{width:1.5rem;height:1.5rem}.tpl\:size-7{width:1.75rem;height:1.75rem}.tpl\:size-10{width:2.5rem;height:2.5rem}.tpl\:size-full{width:100%;height:100%}.tpl\:h-4{height:1rem}.tpl\:h-12{height:3rem}.tpl\:h-full{height:100%}.tpl\:max-h-32{max-height:8rem}.tpl\:max-h-56{max-height:14rem}.tpl\:max-h-\[90vh\]{max-height:90vh}.tpl\:min-h-0{min-height:0}.tpl\:w-48{width:12rem}.tpl\:w-52{width:13rem}.tpl\:w-56{width:14rem}.tpl\:w-full{width:100%}.tpl\:max-w-2xl{max-width:42rem}.tpl\:max-w-sm{max-width:24rem}.tpl\:min-w-0{min-width:0}.tpl\:flex-1{flex:1}.tpl\:shrink-0{flex-shrink:0}.tpl\:-translate-x-1\/2{--tw-translate-x: -50% ;translate:var(--tw-translate-x) var(--tw-translate-y)}.tpl\:-translate-y-1\/2{--tw-translate-y: -50% ;translate:var(--tw-translate-x) var(--tw-translate-y)}.tpl\:translate-y-0{--tw-translate-y: 0rem ;translate:var(--tw-translate-x) var(--tw-translate-y)}.tpl\:translate-y-1{--tw-translate-y: .25rem ;translate:var(--tw-translate-x) var(--tw-translate-y)}.tpl\:-rotate-90{rotate:-90deg}.tpl\:rotate-45{rotate:45deg}.tpl\:rotate-90{rotate:90deg}.tpl\:animate-spin{animation:1s linear infinite spin}.tpl\:cursor-help{cursor:help}.tpl\:cursor-not-allowed{cursor:not-allowed}.tpl\:cursor-pointer{cursor:pointer}.tpl\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.tpl\:flex-col{flex-direction:column}.tpl\:flex-wrap{flex-wrap:wrap}.tpl\:items-center{align-items:center}.tpl\:justify-between{justify-content:space-between}.tpl\:justify-center{justify-content:center}.tpl\:justify-end{justify-content:flex-end}.tpl\:gap-0\.5{gap:.125rem}.tpl\:gap-1{gap:.25rem}.tpl\:gap-1\.5{gap:.375rem}.tpl\:gap-2{gap:.5rem}.tpl\:gap-3{gap:.75rem}.tpl\:gap-5{gap:1.25rem}:where(.tpl\:space-y-3>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(.75rem * var(--tw-space-y-reverse));margin-block-end:calc(.75rem * calc(1 - var(--tw-space-y-reverse)))}.tpl\:truncate{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.tpl\:overflow-hidden{overflow:hidden}.tpl\:overflow-y-auto{overflow-y:auto}.tpl\:rounded{border-radius:.25rem}.tpl\:rounded-\[var\(--tpl-radius-lg\)\]{border-radius:var(--tpl-radius-lg)}.tpl\:rounded-full{border-radius:3.40282e38px}.tpl\:rounded-lg{border-radius:.5rem}.tpl\:rounded-md{border-radius:.375rem}.tpl\:border{border-style:var(--tw-border-style);border-width:1px}.tpl\:border-2{border-style:var(--tw-border-style);border-width:2px}.tpl\:border-t{border-top-style:var(--tw-border-style);border-top-width:1px}.tpl\:border-r{border-right-style:var(--tw-border-style);border-right-width:1px}.tpl\:border-b{border-bottom-style:var(--tw-border-style);border-bottom-width:1px}.tpl\:border-dashed{--tw-border-style:dashed;border-style:dashed}.tpl\:object-cover{object-fit:cover}.tpl\:p-0\.5{padding:.125rem}.tpl\:p-2{padding:.5rem}.tpl\:p-4{padding:1rem}.tpl\:p-5{padding:1.25rem}.tpl\:px-1\.5{padding-inline:.375rem}.tpl\:px-2{padding-inline:.5rem}.tpl\:px-2\.5{padding-inline:.625rem}.tpl\:px-3{padding-inline:.75rem}.tpl\:px-4{padding-inline:1rem}.tpl\:px-5{padding-inline:1.25rem}.tpl\:py-0\.5{padding-block:.125rem}.tpl\:py-1{padding-block:.25rem}.tpl\:py-1\.5{padding-block:.375rem}.tpl\:py-2{padding-block:.5rem}.tpl\:py-2\.5{padding-block:.625rem}.tpl\:py-3{padding-block:.75rem}.tpl\:py-3\.5{padding-block:.875rem}.tpl\:py-4{padding-block:1rem}.tpl\:py-16{padding-block:4rem}.tpl\:pt-3{padding-top:.75rem}.tpl\:pt-4{padding-top:1rem}.tpl\:pr-2{padding-right:.5rem}.tpl\:pr-3{padding-right:.75rem}.tpl\:pr-6{padding-right:1.5rem}.tpl\:pr-7{padding-right:1.75rem}.tpl\:pr-8{padding-right:2rem}.tpl\:pb-4{padding-bottom:1rem}.tpl\:pl-2{padding-left:.5rem}.tpl\:pl-2\.5{padding-left:.625rem}.tpl\:pl-3{padding-left:.75rem}.tpl\:pl-8{padding-left:2rem}.tpl\:text-center{text-align:center}.tpl\:text-left{text-align:left}.tpl\:text-sm{font-size:.875rem;line-height:var(--tw-leading,calc(1.25 / .875))}.tpl\:text-xs{font-size:.75rem;line-height:var(--tw-leading,calc(1 / .75))}.tpl\:text-\[9px\]{font-size:9px}.tpl\:text-\[10px\]{font-size:10px}.tpl\:font-bold{--tw-font-weight:700;font-weight:700}.tpl\:font-medium{--tw-font-weight:500;font-weight:500}.tpl\:font-normal{--tw-font-weight:400;font-weight:400}.tpl\:font-semibold{--tw-font-weight:600;font-weight:600}.tpl\:tracking-wider{--tw-tracking:.05em;letter-spacing:.05em}.tpl\:whitespace-nowrap{white-space:nowrap}.tpl\:text-white{color:#fff}.tpl\:italic{font-style:italic}.tpl\:opacity-0{opacity:0}.tpl\:opacity-50{opacity:.5}.tpl\:opacity-60{opacity:.6}.tpl\:opacity-100{opacity:1}.tpl\:shadow-lg{--tw-shadow:0 10px 15px -3px var(--tw-shadow-color,#0000001a), 0 4px 6px -4px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.tpl\:shadow-xl{--tw-shadow:0 20px 25px -5px var(--tw-shadow-color,#0000001a), 0 8px 10px -6px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.tpl\:shadow-xs{--tw-shadow:0 1px 2px 0 var(--tw-shadow-color,#0000000d);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.tpl\:transition{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to,opacity,box-shadow,transform,translate,scale,rotate,filter,-webkit-backdrop-filter,backdrop-filter,display,content-visibility,overlay,pointer-events;transition-timing-function:var(--tw-ease,cubic-bezier(.4, 0, .2, 1));transition-duration:var(--tw-duration,.15s)}.tpl\:transition-all{transition-property:all;transition-timing-function:var(--tw-ease,cubic-bezier(.4, 0, .2, 1));transition-duration:var(--tw-duration,.15s)}.tpl\:transition-colors{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to;transition-timing-function:var(--tw-ease,cubic-bezier(.4, 0, .2, 1));transition-duration:var(--tw-duration,.15s)}.tpl\:transition-opacity{transition-property:opacity;transition-timing-function:var(--tw-ease,cubic-bezier(.4, 0, .2, 1));transition-duration:var(--tw-duration,.15s)}.tpl\:transition-transform{transition-property:transform,translate,scale,rotate;transition-timing-function:var(--tw-ease,cubic-bezier(.4, 0, .2, 1));transition-duration:var(--tw-duration,.15s)}.tpl\:duration-100{--tw-duration:.1s;transition-duration:.1s}.tpl\:duration-150{--tw-duration:.15s;transition-duration:.15s}.tpl\:duration-200{--tw-duration:.2s;transition-duration:.2s}.tpl\:duration-300{--tw-duration:.3s;transition-duration:.3s}.tpl\:ease-in{--tw-ease:cubic-bezier(.4, 0, 1, 1);transition-timing-function:cubic-bezier(.4,0,1,1)}.tpl\:ease-out{--tw-ease:cubic-bezier(0, 0, .2, 1);transition-timing-function:cubic-bezier(0,0,.2,1)}.tpl\:outline-none{--tw-outline-style:none;outline-style:none}@media(hover:hover){.tpl\:group-hover\:opacity-100:is(:where(.tpl\:group):hover *){opacity:1}.tpl\:hover\:underline:hover{text-decoration-line:underline}.tpl\:hover\:opacity-90:hover{opacity:.9}}.tpl\:focus\:shadow-\[var\(--tpl-ring\)\]:focus{--tw-shadow:var(--tpl-ring);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.tpl\:disabled\:cursor-not-allowed:disabled{cursor:not-allowed}.tpl\:disabled\:opacity-50:disabled{opacity:.5}@layer base,components;.tpl{--tpl-bg:oklch(99.5% .002 60);--tpl-bg-elevated:oklch(98% .004 60);--tpl-bg-hover:oklch(96% .006 60);--tpl-bg-active:oklch(93.5% .008 60);--tpl-border:oklch(92% .006 60);--tpl-border-light:oklch(86% .01 60);--tpl-text:oklch(18% .01 60);--tpl-text-muted:oklch(50% .015 60);--tpl-text-dim:oklch(68% .012 60);--tpl-primary:oklch(70% .16 55);--tpl-primary-hover:oklch(63% .17 55);--tpl-primary-light:oklch(95% .04 55);--tpl-secondary:oklch(60% .118 184.71);--tpl-secondary-hover:oklch(53.2% .105 186.39);--tpl-secondary-light:oklch(93.8% .03 186.82);--tpl-success:oklch(62.8% .194 155.1);--tpl-success-light:oklch(93.6% .043 163.51);--tpl-warning:oklch(76.9% .168 70.08);--tpl-warning-light:oklch(95% .038 73.59);--tpl-danger:oklch(63.7% .237 25.33);--tpl-danger-light:oklch(93.6% .032 17.72);--tpl-radius:10px;--tpl-radius-sm:7px;--tpl-radius-lg:14px;--tpl-font-family:"Geist", ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";--tpl-shadow:0 1px 2px #0000000a, 0 1px 3px #00000008;--tpl-shadow-md:0 2px 8px #0000000f, 0 1px 3px #0000000a;--tpl-shadow-lg:0 4px 16px #00000014, 0 2px 6px #0000000a;--tpl-shadow-xl:0 8px 32px #0000001a, 0 4px 12px #0000000f;--tpl-ring:0 0 0 3px var(--tpl-primary-light);--tpl-transition:.12s cubic-bezier(.16, 1, .3, 1)}.tpl[data-tpl-theme=dark]{--tpl-bg:oklch(16% .005 60);--tpl-bg-elevated:oklch(21% .006 60);--tpl-bg-hover:oklch(26% .007 60);--tpl-bg-active:oklch(30% .008 60);--tpl-border:oklch(30% .006 60);--tpl-border-light:oklch(38% .008 60);--tpl-text:oklch(93% .005 60);--tpl-text-muted:oklch(65% .01 60);--tpl-text-dim:oklch(50% .008 60);--tpl-primary:oklch(73% .15 55);--tpl-primary-hover:oklch(78% .14 55);--tpl-primary-light:oklch(28% .05 55);--tpl-secondary:oklch(63% .11 184.71);--tpl-secondary-hover:oklch(68% .1 186.39);--tpl-secondary-light:oklch(25% .03 186.82);--tpl-success:oklch(65% .18 155.1);--tpl-success-light:oklch(25% .04 163.51);--tpl-warning:oklch(78% .16 70.08);--tpl-warning-light:oklch(28% .04 73.59);--tpl-danger:oklch(65% .22 25.33);--tpl-danger-light:oklch(25% .04 17.72);--tpl-shadow:0 1px 2px #0000004d, 0 1px 3px #0003;--tpl-shadow-md:0 2px 8px #00000059, 0 1px 3px #00000040;--tpl-shadow-lg:0 4px 16px #0006, 0 2px 6px #0000004d;--tpl-shadow-xl:0 8px 32px #00000080, 0 4px 12px #00000059;--tpl-ring:0 0 0 3px var(--tpl-primary-light)}.tpl{font-family:Geist,ui-sans-serif,system-ui,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;font-size:.875rem;line-height:var(--tw-leading,calc(1.25 / .875));--tw-leading:1.5;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;background-color:var(--tpl-bg);color:var(--tpl-text);line-height:1.5;font-family:var(--tpl-font-family)}.tpl button,.tpl input,.tpl select,.tpl textarea{font-family:inherit}.tpl button{cursor:pointer;background:0 0;border:none;outline:none}.tpl ::-webkit-scrollbar{width:6px;height:6px}.tpl ::-webkit-scrollbar-track{background:0 0}.tpl ::-webkit-scrollbar-thumb{background-color:var(--tpl-border-light)}@supports (color:color-mix(in lab,red,red)){.tpl ::-webkit-scrollbar-thumb{background-color:color-mix(in srgb,var(--tpl-border-light) 60%,transparent)}}.tpl ::-webkit-scrollbar-thumb{border-radius:.25rem}.tpl ::-webkit-scrollbar-thumb:hover{background-color:var(--tpl-border-light)}@keyframes tpl-pulse{0%,to{opacity:1}50%{opacity:.5}}@keyframes tpl-spin{0%{transform:rotate(0)}to{transform:rotate(360deg)}}@keyframes tpl-scale-in{0%{opacity:0;transform:scale(.97)}to{opacity:1;transform:scale(1)}}.tpl-pulse{animation:2s infinite tpl-pulse}.tpl-spinner{animation:1s linear infinite tpl-spin}.tpl-scale-in{animation:.15s cubic-bezier(.16,1,.3,1) tpl-scale-in}@property --tw-translate-x{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-y{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-z{syntax:"*";inherits:false;initial-value:0}@property --tw-space-y-reverse{syntax:"*";inherits:false;initial-value:0}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-font-weight{syntax:"*";inherits:false}@property --tw-tracking{syntax:"*";inherits:false}@property --tw-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-shadow-color{syntax:"*";inherits:false}@property --tw-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-inset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-shadow-color{syntax:"*";inherits:false}@property --tw-inset-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-ring-color{syntax:"*";inherits:false}@property --tw-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-ring-color{syntax:"*";inherits:false}@property --tw-inset-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-ring-inset{syntax:"*";inherits:false}@property --tw-ring-offset-width{syntax:"<length>";inherits:false;initial-value:0}@property --tw-ring-offset-color{syntax:"*";inherits:false;initial-value:#fff}@property --tw-ring-offset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-duration{syntax:"*";inherits:false}@property --tw-ease{syntax:"*";inherits:false}@property --tw-leading{syntax:"*";inherits:false}@keyframes spin{to{transform:rotate(360deg)}}
@@ -0,0 +1,17 @@
1
+ import{$ as e,A as t,B as n,C as r,D as i,E as a,F as o,G as s,H as c,I as l,J as u,K as d,L as f,M as p,N as m,O as h,P as g,Q as _,R as v,S as y,T as b,U as x,V as S,W as C,X as w,Y as T,Z as E,_ as D,a as O,at as k,b as ee,c as A,d as te,et as ne,f as re,g as ie,h as ae,i as oe,it as j,j as M,k as N,l as se,m as ce,n as le,nt as ue,o as de,ot as P,p as fe,q as F,r as pe,rt as I,s as me,st as L,t as he,tt as ge,u as _e,v as ve,w as R,x as ye,y as be,z}from"./chunks/icons-Ccy3Ecl_.js";var xe=class extends Error{constructor(e,t){super(e),this.statusCode=t,this.name=`SdkError`}get isNotFound(){return this.statusCode===404}get isUnauthorized(){return this.statusCode===401}get isServerError(){return this.statusCode!==void 0&&this.statusCode>=500}},Se=class e{static DEFAULT_BASE_URL=`https://templatical.com`;accessToken=null;expiresAt=null;_projectId=null;_tenantId=null;_tenantSlug=null;_testEmailConfig=null;_userConfig=null;url;baseUrl;requestOptions;onError;refreshPromise=null;static REFRESH_THRESHOLD_MS=60*1e3;constructor(t){this.url=t.url,this.baseUrl=(t.baseUrl??e.DEFAULT_BASE_URL).replace(/\/$/,``),this.requestOptions=t.requestOptions??{},this.onError=t.onError}resolveUrl(e){if(e.startsWith(`http://`)||e.startsWith(`https://`))return e;let t=e.startsWith(`/`)?e:`/${e}`;return`${this.baseUrl}${t}`}get projectId(){if(!this._projectId)throw Error(`Project ID not available. Call initialize() first.`);return this._projectId}get tenantId(){if(!this._tenantId)throw Error(`Tenant ID not available. Call initialize() first.`);return this._tenantId}get tenantSlug(){if(!this._tenantSlug)throw Error(`Tenant slug not available. Call initialize() first.`);return this._tenantSlug}get testEmailConfig(){return this._testEmailConfig}get userConfig(){return this._userConfig}get accessTokenValue(){return this.accessToken}async initialize(){await this.ensureToken()}async ensureToken(){return this.accessToken&&!this.isTokenExpiringSoon()?this.accessToken:this.refreshToken()}isTokenExpiringSoon(){return this.expiresAt?this.expiresAt.getTime()-Date.now()<e.REFRESH_THRESHOLD_MS:!0}async refreshToken(){if(this.refreshPromise)return this.refreshPromise;this.refreshPromise=this.performRefresh();try{return await this.refreshPromise}finally{this.refreshPromise=null}}async performRefresh(){try{let e=this.requestOptions.method??`POST`,t={Accept:`application/json`,...this.requestOptions.headers},n={method:e,headers:t,credentials:this.requestOptions.credentials??`include`};e===`POST`&&this.requestOptions.body&&(t[`Content-Type`]=`application/json`,n.body=JSON.stringify(this.requestOptions.body));let r=await fetch(this.url,n);if(!r.ok)throw new xe(`Token refresh failed: ${r.status}`,r.status);let i=await r.json();if(!i.token||!i.expires_at||!i.project_id||!i.tenant)throw Error(`Invalid token response: missing token, expires_at, project_id, or tenant`);return this.accessToken=i.token,this.expiresAt=new Date(i.expires_at*1e3),this._projectId=i.project_id,this._tenantSlug=i.tenant,i.test_email?.allowed_emails&&i.test_email?.signature?this._testEmailConfig={allowedEmails:i.test_email.allowed_emails,signature:i.test_email.signature}:this._testEmailConfig=null,i.user?.id&&i.user?.name&&i.user?.signature?this._userConfig={id:i.user.id,name:i.user.name,signature:i.user.signature}:this._userConfig=null,this.accessToken}catch(e){let t=e instanceof Error?e:Error(`Token refresh failed`,{cause:e});throw this.onError?.(t),t}}async authenticatedFetch(e,t={}){let n=await this.ensureToken(),r=this.resolveUrl(e),i=async e=>fetch(r,{...t,headers:{...t.headers,Authorization:`Bearer ${e}`}}),a=await i(n);return a.status===401&&(a=await i(await this.refreshToken())),a}};function Ce(e,t){return e.mode===`direct`?new Se({url:`${(e.baseUrl??`https://templatical.com`).replace(/\/$/,``)}/api/v1/auth/token`,baseUrl:e.baseUrl,requestOptions:{method:`POST`,headers:{"Content-Type":`application/json`},body:{client_id:e.clientId,client_secret:e.clientSecret,tenant:e.tenant,client_type:`sdk`}},onError:t}):new Se({url:e.url,baseUrl:e.baseUrl,requestOptions:e.requestOptions,onError:t})}function B(e,t){return e.replace(/\{(\w+)\}/g,(e,n)=>encodeURIComponent(t[n]??``))}var we=`/api/v1/projects/{project}/tenants/{tenant}`,V=`${we}/templates/{template}`,Te=`${V}/ai`,Ee=`${we}/media`,De=`${Ee}/folders`,Oe=`${we}/saved-modules`,H={health:`/api/v1/health`,"projects.config":`${we}/config`,"broadcasting.auth":`${we}/broadcasting/auth`,"templates.store":`${we}/templates`,"templates.show":`${V}`,"templates.update":`${V}`,"templates.destroy":`${V}`,"templates.export":`${V}/export`,"templates.importFromBeefree":`${we}/templates/import/from-beefree`,"templates.sendTestEmail":`${V}/send-test-email`,"snapshots.index":`${V}/snapshots`,"snapshots.store":`${V}/snapshots`,"snapshots.show":`${V}/snapshots/{snapshot}`,"snapshots.restore":`${V}/snapshots/{snapshot}/restore`,"comments.index":`${V}/comments`,"comments.store":`${V}/comments`,"comments.update":`${V}/comments/{comment}`,"comments.destroy":`${V}/comments/{comment}`,"comments.resolve":`${V}/comments/{comment}/resolve`,"ai.generate":`${Te}/generate`,"ai.conversationMessages":`${Te}/conversation-messages`,"ai.suggestions":`${Te}/suggestions`,"ai.rewriteText":`${Te}/rewrite-text`,"ai.score":`${Te}/score`,"ai.fixFinding":`${Te}/fix-finding`,"ai.generateFromDesign":`${Te}/generate-from-design`,"media.upload":`${Ee}/upload`,"media.browse":`${Ee}/browse`,"media.delete":`${Ee}/delete`,"media.move":`${Ee}/move`,"media.update":`${Ee}/{media}`,"media.replace":`${Ee}/{media}/replace`,"media.checkUsage":`${Ee}/check-usage`,"media.frequentlyUsed":`${Ee}/frequently-used`,"media.importFromUrl":`${Ee}/import-from-url`,"folders.index":`${De}`,"folders.store":`${De}`,"folders.update":`${De}/{mediaFolder}`,"folders.destroy":`${De}/{mediaFolder}`,"savedModules.index":`${Oe}`,"savedModules.store":`${Oe}`,"savedModules.update":`${Oe}/{savedModule}`,"savedModules.destroy":`${Oe}/{savedModule}`},ke=class{constructor(e){this.authManager=e}get projectId(){return this.authManager.projectId}get tenantSlug(){return this.authManager.tenantSlug}get baseParams(){return{project:this.projectId,tenant:this.tenantSlug}}async request(e,t={}){let n=await this.authManager.authenticatedFetch(e,{...t,headers:{"Content-Type":`application/json`,Accept:`application/json`,...t.headers}});if(!n.ok){let e=await n.json().catch(()=>({message:`HTTP error ${n.status}`}));throw new xe(this.extractFirstValidationError(e),n.status)}if(n.status!==204)return(await n.json()).data}extractFirstValidationError(e){if(e.errors){let t=Object.keys(e.errors)[0];if(t&&e.errors[t]?.length>0)return e.errors[t][0]}return e.message}async createTemplate(e){return this.request(B(H[`templates.store`],this.baseParams),{method:`POST`,body:JSON.stringify({content:e})})}async getTemplate(e){return this.request(B(H[`templates.show`],{...this.baseParams,template:e}))}async updateTemplate(e,t){return this.request(B(H[`templates.update`],{...this.baseParams,template:e}),{method:`PUT`,body:JSON.stringify({content:t})})}async createSnapshot(e,t){return this.request(B(H[`snapshots.store`],{...this.baseParams,template:e}),{method:`POST`,body:JSON.stringify({content:t})})}async deleteTemplate(e){return this.request(B(H[`templates.destroy`],{...this.baseParams,template:e}),{method:`DELETE`})}async getSnapshots(e){return this.request(B(H[`snapshots.index`],{...this.baseParams,template:e}))}async restoreSnapshot(e,t){return this.request(B(H[`snapshots.restore`],{...this.baseParams,template:e,snapshot:t}),{method:`POST`})}async exportTemplate(e,t){let n=t?JSON.stringify({custom_fonts:t.customFonts,default_fallback:t.defaultFallback}):void 0;return this.request(B(H[`templates.export`],{...this.baseParams,template:e}),{method:`POST`,body:n})}async sendTestEmail(e,t){await this.request(B(H[`templates.sendTestEmail`],{...this.baseParams,template:e}),{method:`POST`,body:JSON.stringify(t)})}commentsUrl(e,t){return t?B(H[`comments.update`],{...this.baseParams,template:e,comment:t}):B(H[`comments.index`],{...this.baseParams,template:e})}async getComments(e){return this.request(this.commentsUrl(e))}async createComment(e,t,n){return this.request(this.commentsUrl(e),{method:`POST`,body:JSON.stringify(t),headers:n})}async updateComment(e,t,n,r){return this.request(this.commentsUrl(e,t),{method:`PUT`,body:JSON.stringify(n),headers:r})}async deleteComment(e,t,n,r){return this.request(this.commentsUrl(e,t),{method:`DELETE`,body:JSON.stringify(n),headers:r})}async resolveComment(e,t,n,r){return this.request(B(H[`comments.resolve`],{...this.baseParams,template:e,comment:t}),{method:`POST`,body:JSON.stringify(n),headers:r})}async fetchConfig(){return this.request(B(H[`projects.config`],this.baseParams))}async listModules(e){let t=B(H[`savedModules.index`],this.baseParams),n=e?`?search=${encodeURIComponent(e)}`:``;return this.request(`${t}${n}`)}async createModule(e){return this.request(B(H[`savedModules.store`],this.baseParams),{method:`POST`,body:JSON.stringify(e)})}async updateModule(e,t){return this.request(B(H[`savedModules.update`],{...this.baseParams,savedModule:e}),{method:`PUT`,body:JSON.stringify(t)})}async deleteModule(e){return this.request(B(H[`savedModules.destroy`],{...this.baseParams,savedModule:e}),{method:`DELETE`})}},Ae=`modulepreload`,je=function(e){return`/`+e},Me={},Ne=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}r=o(t.map(t=>{if(t=je(t,n),t in Me)return;Me[t]=!0;let r=t.endsWith(`.css`),i=r?`[rel="stylesheet"]`:``;if(n)for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}else if(document.querySelector(`link[href="${t}"]${i}`))return;let o=document.createElement(`link`);if(o.rel=r?`stylesheet`:Ae,r||(o.as=`script`),o.crossOrigin=``,o.href=t,a&&o.setAttribute(`nonce`,a),document.head.appendChild(o),r)return new Promise((e,n)=>{o.addEventListener(`load`,e),o.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})};function Pe(e){let t=e??l(`translations`),n=w(t)?t.value:t;function r(e,t){return e.replace(/\{(\w+)\}/g,(e,n)=>n in t?String(t[n]):`{${n}}`)}return{t:n,format:r}}var Fe={key:0,class:`tpl:flex tpl:items-center tpl:gap-1 tpl:text-xs`,style:{color:`var(--tpl-text-muted)`}},Ie=[`onClick`],Le={key:1,style:{color:`var(--tpl-text)`}},Re=m({__name:`MediaBreadcrumb`,props:{folders:{},currentFolderId:{}},emits:[`navigate`],setup(e,{emit:n}){let r=e,o=n,{t:s}=Pe(),c=a(()=>{if(!r.currentFolderId)return[];let e=[];return l(r.folders,r.currentFolderId,e),e});function l(e,t,n){for(let r of e){if(r.id===t)return n.push(r),!0;if(r.children&&l(r.children,t,n))return n.unshift(r),!0}return!1}return(e,n)=>c.value.length>0?(z(),t(`div`,Fe,[i(`button`,{class:`tpl:transition-colors tpl:duration-150 tpl:hover:underline`,style:{color:`var(--tpl-primary)`},onClick:n[0]||=e=>o(`navigate`,null)},L(j(s).mediaLibrary.allFiles),1),(z(!0),t(R,null,S(c.value,(e,n)=>(z(),t(R,{key:e.id},[p(j(ie),{size:12,"stroke-width":2}),n<c.value.length-1?(z(),t(`button`,{key:0,class:`tpl:transition-colors tpl:duration-150 tpl:hover:underline`,style:{color:`var(--tpl-primary)`},onClick:t=>o(`navigate`,e.id)},L(e.name),9,Ie)):(z(),t(`span`,Le,L(e.name),1))],64))),128))])):N(``,!0)}});function ze(){let e=l(`planConfig`),t=a(()=>e.config.value?.media??null),n=a(()=>t.value?.use_media_library??!0),r=a(()=>t.value?.categories??null),i=a(()=>r.value?Object.values(r.value).flatMap(e=>e.mime_types):[]),o=a(()=>i.value.join(`,`)),s=a(()=>t.value?.max_file_size??0);function c(e,t){return r.value?!t||t.length===0?i.value.includes(e):t.some(t=>r.value[t]?.mime_types.includes(e)):!1}function u(e){return r.value?r.value.images?.mime_types.includes(e)??!1:!1}function d(e){if(!r.value)return null;for(let[t,n]of Object.entries(r.value))if(n.mime_types.includes(e))return t;return null}return{isMediaLibraryEnabled:n,allAcceptedMimeTypes:i,allAcceptedInputString:o,maxFileSize:s,availableCategories:a(()=>r.value?Object.keys(r.value):[]),isAcceptedMimeType:c,isImageMimeType:u,getCategoryForMimeType:d}}var Be={free:void 0,square:1,landscape43:4/3,landscape169:16/9,original:void 0};function Ve(e){return e===`image/png`||e===`image/gif`?{mimeType:`image/png`,quality:1}:e===`image/webp`?{mimeType:`image/webp`,quality:.92}:{mimeType:`image/jpeg`,quality:.92}}function He(e,t,n){let r=e.width,i=e.height;if(!t&&!n)return e;let a=r,o=i;if(t&&r>t&&(a=t,o=Math.round(t/r*i)),n&&o>n&&(o=n,a=Math.round(a*(n/(i*(t?t/r:1))))),a===r&&o===i)return e;let s=document.createElement(`canvas`);s.width=a,s.height=o;let c=s.getContext(`2d`);return c&&(c.imageSmoothingEnabled=!0,c.imageSmoothingQuality=`high`,c.drawImage(e,0,0,a,o)),s}function Ue(e,t,n){return new Promise((r,i)=>{e.toBlob(e=>{if(!e){i(Error(`Failed to create blob from canvas`));return}let a=n.mimeType.split(`/`)[1],o=`${t.replace(/\.[^.]+$/,``)}.${a}`;r(new File([e],o,{type:n.mimeType}))},n.mimeType,n.quality)})}function We(e,t,n,r){let i=e,a=t;if(n&&i>n){let e=n/i;i=n,a=Math.round(a*e)}if(r&&a>r){let e=r/a;a=r,i=Math.round(i*e)}return{width:i,height:a}}function Ge(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function U(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Ge(Object(n),!0).forEach((function(t){W(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ge(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function W(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Ke(e,t){if(e==null)return{};var n,r,i=function(e,t){if(e==null)return{};var n,r,i={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(i[n]=e[n]);return i}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function qe(e){return function(e){if(Array.isArray(e))return Je(e)}(e)||function(e){if(typeof Symbol<`u`&&e[Symbol.iterator]!=null||e[`@@iterator`]!=null)return Array.from(e)}(e)||function(e,t){if(e){if(typeof e==`string`)return Je(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`)return Array.from(e);if(n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Je(e,t)}}(e)||function(){throw TypeError(`Invalid attempt to spread non-iterable instance.
2
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function Je(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}var Ye,Xe,Ze,G=(Ye=function(e){(function(){var t={}.hasOwnProperty;function n(){for(var e=[],r=0;r<arguments.length;r++){var i=arguments[r];if(i){var a=typeof i;if(a===`string`||a===`number`)e.push(i);else if(Array.isArray(i)){if(i.length){var o=n.apply(null,i);o&&e.push(o)}}else if(a===`object`)if(i.toString===Object.prototype.toString)for(var s in i)t.call(i,s)&&i[s]&&e.push(s);else e.push(i.toString())}}return e.join(` `)}e.exports?(n.default=n,e.exports=n):window.classNames=n})()},Ye(Ze={path:Xe,exports:{},require:function(e,t){return function(){throw Error(`Dynamic requires are not currently supported by @rollup/plugin-commonjs`)}(t==null&&Ze.path)}},Ze.exports),Ze.exports),K=function(e){return function(t,n){if(!t)return e;var r;typeof t==`string`?r=t:n=t;var i=e;return r&&(i+=`__`+r),i+(n?Object.keys(n).reduce((function(e,t){var r=n[t];return r&&(e+=` `+(typeof r==`boolean`?i+`--`+t:i+`--`+t+`_`+r)),e}),``):``)}};function Qe(e,t,n){var r,i,a,o,s;function c(){var l=Date.now()-o;l<t&&l>=0?r=setTimeout(c,t-l):(r=null,n||(s=e.apply(a,i),a=i=null))}t??=100;var l=function(){a=this,i=arguments,o=Date.now();var l=n&&!r;return r||=setTimeout(c,t),l&&(s=e.apply(a,i),a=i=null),s};return l.clear=function(){r&&=(clearTimeout(r),null)},l.flush=function(){r&&=(s=e.apply(a,i),a=i=null,clearTimeout(r),null)},l}Qe.debounce=Qe;var $e=Qe,q=function(){return q=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},q.apply(this,arguments)};function et(e,t){var n,r;return e&&t?(n=``+e+t[0].toUpperCase()+t.slice(1),r=e+`-`+t):(n=e||t,r=e||t),{name:n,classname:r}}function tt(e){return/^blob:/.test(e)}function nt(e){return tt(e)||function(e){return/^data:/.test(e)}(e)}function rt(e){return!!(e&&e.constructor&&e.call&&e.apply)}function J(e){return e===void 0}function it(e){return typeof e==`object`&&!!e}function at(e,t,n){var r={};return it(e)?(Object.keys(t).forEach((function(i){J(e[i])?r[i]=t[i]:it(t[i])?it(e[i])?r[i]=at(e[i],t[i],n[i]):r[i]=e[i]?t[i]:n[i]:!0===t[i]||!1===t[i]?r[i]=!!e[i]:r[i]=e[i]})),r):e?t:n}function ot(e){var t=Number(e);return Number.isNaN(t)?e:t}function st(e){return typeof(e==`number`||function(e){return typeof e==`object`&&!!e}(e)&&toString.call(e)==`[object Number]`)&&!ct(e)}function ct(e){return e!=e}function lt(e,t){return Math.sqrt((e.x-t.x)**2+(e.y-t.y)**2)}var ut=function(e,t){e===void 0&&(e={}),t===void 0&&(t={}),this.type=`manipulateImage`,this.move=e,this.scale=t},dt=function(e,t){t===void 0&&(t={}),this.type=`resize`,this.directions=e,this.params=t},ft=function(e){this.type=`move`,this.directions=e},pt=function(){function e(e,t,n,r,i){this.type=`drag`,this.nativeEvent=e,this.position=n,this.previousPosition=r,this.element=t,this.anchor=i}return e.prototype.shift=function(){var e=this,t=e.element,n=e.anchor,r=e.position;if(t){var i=t.getBoundingClientRect(),a=i.left,o=i.top;return{left:r.left-a-n.left,top:r.top-o-n.top}}return{left:0,top:0}},e}(),mt={name:`DraggableElement`,props:{classname:{type:String}},beforeMount:function(){window.addEventListener(`mouseup`,this.onMouseUp,{passive:!1}),window.addEventListener(`mousemove`,this.onMouseMove,{passive:!1}),window.addEventListener(`touchmove`,this.onTouchMove,{passive:!1}),window.addEventListener(`touchend`,this.onTouchEnd,{passive:!1})},beforeUnmount:function(){window.removeEventListener(`mouseup`,this.onMouseUp),window.removeEventListener(`mousemove`,this.onMouseMove),window.removeEventListener(`touchmove`,this.onTouchMove),window.removeEventListener(`touchend`,this.onTouchEnd)},mounted:function(){if(!this.$refs.draggable)throw Error(`You should add ref "draggable" to your root element to use draggable mixin`);this.touches=[],this.hovered=!1},methods:{onMouseOver:function(){this.hovered||(this.hovered=!0,this.$emit(`enter`))},onMouseLeave:function(){this.hovered&&!this.touches.length&&(this.hovered=!1,this.$emit(`leave`))},onTouchStart:function(e){e.cancelable&&!this.disabled&&e.touches.length===1&&(this.touches=qe(e.touches),this.hovered||=(this.$emit(`enter`),!0),e.touches.length&&this.initAnchor(this.touches.reduce((function(t,n){return{clientX:t.clientX+n.clientX/e.touches.length,clientY:t.clientY+n.clientY/e.touches.length}}),{clientX:0,clientY:0})),e.preventDefault&&e.preventDefault(),e.stopPropagation())},onTouchEnd:function(){this.processEnd()},onTouchMove:function(e){this.touches.length&&(this.processMove(e,e.touches),e.preventDefault&&e.preventDefault(),e.stopPropagation&&e.stopPropagation())},onMouseDown:function(e){if(!this.disabled){var t={fake:!0,clientX:e.clientX,clientY:e.clientY};this.touches=[t],this.initAnchor(t),e.stopPropagation()}},onMouseMove:function(e){this.touches.length&&(this.processMove(e,[{fake:!0,clientX:e.clientX,clientY:e.clientY}]),e.preventDefault&&e.preventDefault())},onMouseUp:function(){this.processEnd()},initAnchor:function(e){var t=this.$refs.draggable.getBoundingClientRect(),n=t.left,r=t.right,i=t.bottom,a=t.top;this.anchor={left:e.clientX-n,top:e.clientY-a,bottom:i-e.clientY,right:r-e.clientX}},processMove:function(e,t){var n=qe(t);if(this.touches.length){if(this.touches.length===1&&n.length===1){var r=this.$refs.draggable;this.$emit(`drag`,new pt(e,r,{left:n[0].clientX,top:n[0].clientY},{left:this.touches[0].clientX,top:this.touches[0].clientY},this.anchor))}this.touches=n}},processEnd:function(){this.touches.length&&this.$emit(`drag-end`),this.hovered&&=(this.$emit(`leave`),!1),this.touches=[]}},emits:[`drag`,`drag-end`,`leave`,`enter`]};mt.render=function(e,t,n,r,i,a){return z(),h(`div`,{ref:`draggable`,class:n.classname,onTouchstart:t[1]||=function(){return a.onTouchStart&&a.onTouchStart.apply(a,arguments)},onMousedown:t[2]||=function(){return a.onMouseDown&&a.onMouseDown.apply(a,arguments)},onMouseover:t[3]||=function(){return a.onMouseOver&&a.onMouseOver.apply(a,arguments)},onMouseleave:t[4]||=function(){return a.onMouseLeave&&a.onMouseLeave.apply(a,arguments)}},[c(e.$slots,`default`)],34)};var ht=K(`vue-handler-wrapper`),gt={name:`HandlerWrapper`,components:{DraggableElement:mt},props:{horizontalPosition:{type:String},verticalPosition:{type:String},disabled:{type:Boolean,default:!1}},computed:{classes:function(){var e;if(this.horizontalPosition||this.verticalPosition){var t,n=et(this.horizontalPosition,this.verticalPosition);e=ht((W(t={},n.classname,!0),W(t,`disabled`,this.disabled),t))}else e=ht({disabled:this.disabled});return{root:e,draggable:ht(`draggable`)}}},emits:[`leave`,`enter`,`drag`,`drag-end`]};gt.render=function(e,t,n,r,i,a){var o=x(`DraggableElement`);return z(),h(`div`,{class:a.classes.root},[p(o,{class:a.classes.draggable,onDrag:t[1]||=function(t){return e.$emit(`drag`,t)},onDragEnd:t[2]||=function(t){return e.$emit(`drag-end`)},onLeave:t[3]||=function(t){return e.$emit(`leave`)},onEnter:t[4]||=function(t){return e.$emit(`enter`)}},{default:F((function(){return[c(e.$slots,`default`)]})),_:3},8,[`class`])],2)};var _t=K(`vue-line-wrapper`),vt={name:`LineWrapper`,components:{DraggableElement:mt},props:{position:{type:String,required:!0},disabled:{type:Boolean,default:!1}},computed:{classname:function(){var e;return _t((W(e={},this.position,!0),W(e,`disabled`,this.disabled),e))}},emits:[`leave`,`enter`,`drag`,`drag-end`]};vt.render=function(e,t,n,r,i,a){var o=x(`DraggableElement`);return z(),h(o,{class:a.classname,onDrag:t[1]||=function(t){return e.$emit(`drag`,t)},onDragEnd:t[2]||=function(t){return e.$emit(`drag-end`)},onLeave:t[3]||=function(t){return e.$emit(`leave`)},onEnter:t[4]||=function(t){return e.$emit(`enter`)}},{default:F((function(){return[c(e.$slots,`default`)]})),_:3},8,[`class`])};var yt=[`left`,`right`,`top`,`bottom`],bt=[`left`,`right`],xt=[`top`,`bottom`],St=[`left`,`top`],Ct=[`fill-area`,`fit-area`,`stencil`,`none`],wt={left:0,top:0,width:0,height:0};function Tt(e,t,n){return!(n||=[`width`,`height`,`left`,`top`]).some((function(n){return e[n]!==t[n]}))}function Et(e){return{left:e.left,top:e.top,right:e.left+e.width,bottom:e.top+e.height}}function Dt(e,t){return{left:e.left-t.left,top:e.top-t.top}}function Y(e){return{left:e.left+e.width/2,top:e.top+e.height/2}}function Ot(e,t){var n={left:0,top:0,right:0,bottom:0};return yt.forEach((function(r){var i=t[r],a=Et(e)[r];n[r]=i!==void 0&&a!==void 0?r===`left`||r===`top`?Math.max(0,i-a):Math.max(0,a-i):0})),n}function kt(e,t){return{left:e.left-t.left,top:e.top-t.top,width:e.width+t.left+t.right,height:e.height+t.top+t.bottom}}function At(e){return{left:-e.left,top:-e.top}}function X(e,t){return q(q({},e),{left:e.left+t.left,top:e.top+t.top})}function Z(e,t,n,r){if(t!==1){if(n){var i=Y(e);return{width:e.width*t,height:e.height*t,left:e.left+e.width*(1-t)/2+(n.left-i.left)*(r||1-t),top:e.top+e.height*(1-t)/2+(n.top-i.top)*(r||1-t)}}return{width:e.width*t,height:e.height*t,left:e.left+e.width*(1-t)/2,top:e.top+e.height*(1-t)/2}}return e}function Q(e){return e.width/e.height}function jt(e,t){return Math.min(t.right!==void 0&&t.left!==void 0?(t.right-t.left)/e.width:1/0,t.bottom!==void 0&&t.top!==void 0?(t.bottom-t.top)/e.height:1/0)}function Mt(e,t){var n={left:0,top:0},r=Ot(e,t);return r.left&&r.left>0?n.left=r.left:r.right&&r.right>0&&(n.left=-r.right),r.top&&r.top>0?n.top=r.top:r.bottom&&r.bottom>0&&(n.top=-r.bottom),n}function Nt(e,t){var n;return t.minimum&&e<t.minimum?n=t.minimum:t.maximum&&e>t.maximum&&(n=t.maximum),n}function Pt(e,t){var n=Q(e),r=Q(t);return t.width<1/0&&t.height<1/0?n>r?{width:t.width,height:t.width/n}:{width:t.height*n,height:t.height}:t.width<1/0?{width:t.width,height:t.width/n}:t.height<1/0?{width:t.height*n,height:t.height}:e}function Ft(e,t){var n=t*Math.PI/180;return{width:Math.abs(e.width*Math.cos(n))+Math.abs(e.height*Math.sin(n)),height:Math.abs(e.width*Math.sin(n))+Math.abs(e.height*Math.cos(n))}}function It(e,t){var n=t*Math.PI/180;return{left:e.left*Math.cos(n)-e.top*Math.sin(n),top:e.left*Math.sin(n)+e.top*Math.cos(n)}}function Lt(e,t){var n=Ot($(e,t),t);return n.left+n.right+n.top+n.bottom?n.left+n.right>n.top+n.bottom?Math.min((e.width+n.left+n.right)/e.width,jt(e,t)):Math.min((e.height+n.top+n.bottom)/e.height,jt(e,t)):1}function $(e,t,n){n===void 0&&(n=!1);var r=Mt(e,t);return X(e,n?At(r):r)}function Rt(e){return{width:e.right!==void 0&&e.left!==void 0?e.right-e.left:1/0,height:e.bottom!==void 0&&e.top!==void 0?e.bottom-e.top:1/0}}function zt(e,t){return q(q({},e),{minWidth:Math.min(t.width,e.minWidth),minHeight:Math.min(t.height,e.minHeight),maxWidth:Math.min(t.width,e.maxWidth),maxHeight:Math.min(t.height,e.maxHeight)})}function Bt(e,t,n){n===void 0&&(n=!0);var r={};return yt.forEach((function(i){var a=e[i],o=t[i];a!==void 0&&o!==void 0?r[i]=i===`left`||i===`top`?n?Math.max(a,o):Math.min(a,o):n?Math.min(a,o):Math.max(a,o):o===void 0?a!==void 0&&(r[i]=a):r[i]=o})),r}function Vt(e,t){return Bt(e,t,!0)}function Ht(e){var t=e.size,n=e.aspectRatio,r=e.ignoreMinimum,i=e.sizeRestrictions;return!!((t.correctRatio||Q(t)>=n.minimum&&Q(t)<=n.maximum)&&t.height<=i.maxHeight&&t.width<=i.maxWidth&&t.width&&t.height&&(r||t.height>=i.minHeight&&t.width>=i.minWidth))}function Ut(e,t){return(e.width-t.width)**2+(e.height-t.height)**2}function Wt(e){var t=e.width,n=e.height,r=e.sizeRestrictions,i={minimum:e.aspectRatio&&e.aspectRatio.minimum||0,maximum:e.aspectRatio&&e.aspectRatio.maximum||1/0},a={width:Math.max(r.minWidth,Math.min(r.maxWidth,t)),height:Math.max(r.minHeight,Math.min(r.maxHeight,n))};function o(e,a){return a===void 0&&(a=!1),e.reduce((function(e,o){return Ht({size:o,aspectRatio:i,sizeRestrictions:r,ignoreMinimum:a})&&(!e||Ut(o,{width:t,height:n})<Ut(e,{width:t,height:n}))?o:e}),null)}var s=[];i&&[i.minimum,i.maximum].forEach((function(e){e&&s.push({width:a.width,height:a.width/e,correctRatio:!0},{width:a.height*e,height:a.height,correctRatio:!0})})),Ht({size:a,aspectRatio:i,sizeRestrictions:r})&&s.push(a);var c=o(s)||o(s,!0);return c&&{width:c.width,height:c.height}}function Gt(e){var t=e.event,n=e.coordinates,r=e.positionRestrictions,i=r===void 0?{}:r,a=X(n,t.directions);return X(a,Mt(a,i))}function Kt(e){var t=e.coordinates,n=e.transform,r=e.imageSize,i=e.sizeRestrictions,a=e.positionRestrictions,o=e.aspectRatio,s=e.visibleArea,c=function(e,t){return Gt({coordinates:e,positionRestrictions:a,event:new ft({left:t.left-e.left,top:t.top-e.top})})},l=q({},t);return(Array.isArray(n)?n:[n]).forEach((function(e){var t={};J((t=typeof e==`function`?e({coordinates:l,imageSize:r,visibleArea:s}):e).width)&&J(t.height)||(l=function(e,t){return c(q(q(q({},e),Wt({width:t.width,height:t.height,sizeRestrictions:i,aspectRatio:o})),{left:0,top:0}),{left:e.left,top:e.top})}(l,q(q({},l),t))),J(t.left)&&J(t.top)||(l=c(l,q(q({},l),t)))})),l}function qt(e){var t=e.getAreaRestrictions,n=e.boundaries,r=e.coordinates,i=e.visibleArea,a=e.stencilSize,o=e.sizeRestrictions,s=e.positionRestrictions,c,l,u,d=q({},r),f=q({},i),p=q({},a);c=Q(p),l=Q(d),u===void 0&&(u=.001),(c===0||l===0?Math.abs(l-c)<u:Math.abs(l/c)<1+u&&Math.abs(l/c)>1-u)||(d=q(q({},d),Wt({sizeRestrictions:o,width:d.width,height:d.height,aspectRatio:{minimum:Q(p),maximum:Q(p)}})));var m=Lt(f=Z(f,d.width*n.width/(f.width*p.width)),t({visibleArea:f,type:`resize`}));return m!==1&&(f=Z(f,m),d=Z(d,m)),f=$(f=X(f,Dt(Y(d),Y(f))),t({visibleArea:f,type:`move`})),{coordinates:d=$(d,Vt(Et(f),s)),visibleArea:f}}function Jt(e){var t=e.event,n=e.getAreaRestrictions,r=e.boundaries,i=e.coordinates,a=e.visibleArea,o=e.positionRestrictions,s=q({},i),c=q({},a);if(i&&a&&t.type!==`manipulateImage`){var l={width:0,height:0};Q(r)>Q(s)?(l.height=.8*r.height,l.width=l.height*Q(s)):(l.width=.8*r.width,l.height=l.width*Q(s));var u=Lt(c=Z(c,s.width*r.width/(c.width*l.width)),n({visibleArea:c,type:`resize`}));c=Z(c,u),u!==1&&(l.height/=u,l.width/=u),c=$(c=X(c,Dt(Y(s),Y(c))),n({visibleArea:c,type:`move`})),s=$(s,Vt(Et(c),o))}return{coordinates:s,visibleArea:c}}function Yt(e){var t=e.event,n=e.coordinates,r=e.visibleArea,i=e.getAreaRestrictions,a=q({},r),o=q({},n);if(t.type===`setCoordinates`){var s=Math.max(0,o.width-a.width),c=Math.max(0,o.height-a.height);s>c?a=Z(a,Math.min(o.width/a.width,jt(a,i({visibleArea:a,type:`resize`})))):c>s&&(a=Z(a,Math.min(o.height/a.height,jt(a,i({visibleArea:a,type:`resize`}))))),a=$(a=X(a,At(Mt(o,Et(a)))),i({visibleArea:a,type:`move`}))}return{visibleArea:a,coordinates:o}}function Xt(e){var t=e.imageSize,n=e.visibleArea,r=e.coordinates,i=n||t;return{left:(n?n.left:0)+i.width/2-r.width/2,top:(n?n.top:0)+i.height/2-r.height/2}}function Zt(e){var t=e.imageSize,n=e.visibleArea,r=e.aspectRatio,i=e.sizeRestrictions,a=n||t,o=Math.min(r.maximum||1/0,Math.max(r.minimum||0,Q(a))),s=a.width<a.height?{width:.8*a.width,height:.8*a.width/o}:{height:.8*a.height,width:.8*a.height*o};return Wt(q(q({},s),{aspectRatio:r,sizeRestrictions:i}))}function Qt(e){var t,n,r=e.imageSize,i=e.visibleArea,a=e.boundaries,o=e.aspectRatio,s=e.sizeRestrictions,c=e.stencilSize,l=i||r;return Q(l)>Q(a)?n=(t=c.height*l.height/a.height)*Q(c):t=(n=c.width*l.width/a.width)/Q(c),Wt({width:n,height:t,aspectRatio:o,sizeRestrictions:s})}function $t(e){var t=e.getAreaRestrictions,n=e.coordinates,r=e.imageSize,i=Q(e.boundaries);if(n){var a={height:Math.max(n.height,r.height),width:Math.max(n.width,r.width)},o=Pt({width:Q(a)>i?a.width:a.height*i,height:Q(a)>i?a.width/i:a.height},Rt(t())),s={left:n.left+n.width/2-o.width/2,top:n.top+n.height/2-o.height/2,width:o.width,height:o.height},c=Ot(n,Et(q({left:0,top:0},r))),l={};return!c.left&&!c.right&&s.width<=r.width&&(l.left=0,l.right=r.width),!c.top&&!c.bottom&&s.height<=r.height&&(l.top=0,l.bottom=r.height),$(s,l)}var u=Q(r);return o={height:u>i?r.height:r.width/i,width:u>i?r.height*i:r.width},{left:r.width/2-o.width/2,top:r.height/2-o.height/2,width:o.width,height:o.height}}function en(e,t){return Bt(e,Et(t))}function tn(e){var t=e.event,n=e.coordinates,r=e.visibleArea,i=e.sizeRestrictions,a=e.getAreaRestrictions,o=e.positionRestrictions,s=e.adjustStencil,c=t.scale,l=t.move,u=q({},r),d=q({},n),f=1,p=1,m=c.factor&&Math.abs(c.factor-1)>.001;u=X(u,{left:l.left||0,top:l.top||0});var h={stencil:{minimum:Math.max(i.minWidth?i.minWidth/d.width:0,i.minHeight?i.minHeight/d.height:0),maximum:Math.min(i.maxWidth?i.maxWidth/d.width:1/0,i.maxHeight?i.maxHeight/d.height:1/0,jt(d,o))},area:{maximum:jt(u,a({visibleArea:u,type:`resize`}))}};c.factor&&m&&(c.factor<1?(p=Math.max(c.factor,h.stencil.minimum))>1&&(p=1):c.factor>1&&(p=Math.min(c.factor,Math.min(h.area.maximum,h.stencil.maximum)))<1&&(p=1)),p&&(u=Z(u,p,c.center));var g=n.left-r.left,_=r.width+r.left-(n.width+n.left),v=n.top-r.top,y=r.height+r.top-(n.height+n.top);return u=$(u=X(u,Mt(u,{left:o.left===void 0?void 0:o.left-g*p,top:o.top===void 0?void 0:o.top-v*p,bottom:o.bottom===void 0?void 0:o.bottom+y*p,right:o.right===void 0?void 0:o.right+_*p})),a({visibleArea:u,type:`move`})),d.width*=p,d.height*=p,d.left=u.left+g*p,d.top=u.top+v*p,d=$(d,Vt(Et(u),o)),c.factor&&m&&s&&(c.factor>1?f=Math.min(h.area.maximum,c.factor)/p:c.factor<1&&(f=Math.max(d.height/u.height,d.width/u.width,c.factor/p)),f!==1&&(u=X(u=$(u=Z(u,f,c.factor>1?c.center:Y(d)),a({visibleArea:u,type:`move`})),At(Mt(d,Et(u)))))),{coordinates:d,visibleArea:u}}function nn(e){var t=e.aspectRatio,n=e.getAreaRestrictions,r=e.coordinates,i=e.visibleArea,a=e.sizeRestrictions,o=e.positionRestrictions,s=e.imageSize,c=e.previousImageSize,l=e.angle,u=q({},r),d=q({},i),f=It(Y(q({left:0,top:0},c)),l);return(u=q(q({},Wt({sizeRestrictions:a,aspectRatio:t,width:u.width,height:u.height})),It(Y(u),l))).left-=f.left-s.width/2+u.width/2,u.top-=f.top-s.height/2+u.height/2,d=Z(d,Lt(d,n({visibleArea:d,type:`resize`}))),{coordinates:u=$(u,o),visibleArea:d=$(d=X(d,Dt(Y(u),Y(r))),n({visibleArea:d,type:`move`}))}}function rn(e){var t=e.flip,n=e.previousFlip,r=e.rotate,i=e.getAreaRestrictions,a=e.coordinates,o=e.visibleArea,s=e.imageSize,c=q({},a),l=q({},o),u=n.horizontal!==t.horizontal,d=n.vertical!==t.vertical;if(u||d){var f=It({left:s.width/2,top:s.height/2},-r),p=It(Y(c),-r),m=It({left:u?f.left-(p.left-f.left):p.left,top:d?f.top-(p.top-f.top):p.top},r);c=X(c,Dt(m,Y(c))),p=It(Y(l),-r),l=$(l=X(l,Dt(m=It({left:u?f.left-(p.left-f.left):p.left,top:d?f.top-(p.top-f.top):p.top},r),Y(l))),i({visibleArea:l,type:`move`}))}return{coordinates:c,visibleArea:l}}function an(e){var t=e.directions,n=e.coordinates,r=e.positionRestrictions,i=r===void 0?{}:r,a=e.sizeRestrictions,o=e.preserveRatio,s=e.compensate,c=q({},t),l=kt(n,c).width,u=kt(n,c).height;l<0&&(c.left<0&&c.right<0?(c.left=-(n.width-a.minWidth)/(c.left/c.right),c.right=-(n.width-a.minWidth)/(c.right/c.left)):c.left<0?c.left=-(n.width-a.minWidth):c.right<0&&(c.right=-(n.width-a.minWidth))),u<0&&(c.top<0&&c.bottom<0?(c.top=-(n.height-a.minHeight)/(c.top/c.bottom),c.bottom=-(n.height-a.minHeight)/(c.bottom/c.top)):c.top<0?c.top=-(n.height-a.minHeight):c.bottom<0&&(c.bottom=-(n.height-a.minHeight)));var d=Ot(kt(n,c),i);s&&(d.left&&d.left>0&&d.right===0?(c.right+=d.left,c.left-=d.left):d.right&&d.right>0&&d.left===0&&(c.left+=d.right,c.right-=d.right),d.top&&d.top>0&&d.bottom===0?(c.bottom+=d.top,c.top-=d.top):d.bottom&&d.bottom>0&&d.top===0&&(c.top+=d.bottom,c.bottom-=d.bottom),d=Ot(kt(n,c),i));var f={width:1/0,height:1/0,left:1/0,right:1/0,top:1/0,bottom:1/0};if(yt.forEach((function(e){var t=d[e];t&&c[e]&&(f[e]=Math.max(0,1-t/c[e]))})),o){var p=Math.min.apply(null,yt.map((function(e){return f[e]})));p!==1/0&&yt.forEach((function(e){c[e]*=p}))}else yt.forEach((function(e){f[e]!==1/0&&(c[e]*=f[e])}));if(l=kt(n,c).width,u=kt(n,c).height,c.right+c.left&&(l>a.maxWidth?f.width=(a.maxWidth-n.width)/(c.right+c.left):l<a.minWidth&&(f.width=(a.minWidth-n.width)/(c.right+c.left))),c.bottom+c.top&&(u>a.maxHeight?f.height=(a.maxHeight-n.height)/(c.bottom+c.top):u<a.minHeight&&(f.height=(a.minHeight-n.height)/(c.bottom+c.top))),o){var m=Math.min(f.width,f.height);m!==1/0&&yt.forEach((function(e){c[e]*=m}))}else f.width!==1/0&&bt.forEach((function(e){c[e]*=f.width})),f.height!==1/0&&xt.forEach((function(e){c[e]*=f.height}));return c}function on(e,t,n){return t==0&&n==0?e/2:t==0?0:n==0?e:e*Math.abs(t/(t+n))}var sn=K(`vue-simple-handler`),cn=K(`vue-simple-handler-wrapper`),ln={name:`SimpleHandler`,components:{HandlerWrapper:gt},props:{defaultClass:{type:String},hoverClass:{type:String},wrapperClass:{type:String},horizontalPosition:{type:String},verticalPosition:{type:String},disabled:{type:Boolean,default:!1}},data:function(){return{hover:!1}},computed:{classes:function(){var e,t=(W(e={},this.horizontalPosition,!!this.horizontalPosition),W(e,this.verticalPosition,!!this.verticalPosition),W(e,`${this.horizontalPosition}-${this.verticalPosition}`,!!(this.verticalPosition&&this.horizontalPosition)),W(e,`hover`,this.hover),e);return{default:G(sn(t),this.defaultClass,this.hover&&this.hoverClass),wrapper:G(cn(t),this.wrapperClass)}}},methods:{onDrag:function(e){this.$emit(`drag`,e)},onEnter:function(){this.hover=!0},onLeave:function(){this.hover=!1},onDragEnd:function(){this.$emit(`drag-end`)}},emits:[`drag`,`drag-end`]};ln.render=function(e,t,n,r,i,a){var o=x(`HandlerWrapper`);return z(),h(o,{class:a.classes.wrapper,"vertical-position":n.verticalPosition,"horizontal-position":n.horizontalPosition,disabled:n.disabled,onDrag:a.onDrag,onDragEnd:a.onDragEnd,onEnter:a.onEnter,onLeave:a.onLeave},{default:F((function(){return[p(`div`,{class:a.classes.default},null,2)]})),_:1},8,[`class`,`vertical-position`,`horizontal-position`,`disabled`,`onDrag`,`onDragEnd`,`onEnter`,`onLeave`])};var un=K(`vue-simple-line`),dn=K(`vue-simple-line-wrapper`),fn={name:`SimpleLine`,components:{LineWrapper:vt},props:{defaultClass:{type:String},hoverClass:{type:String},wrapperClass:{type:String},position:{type:String},disabled:{type:Boolean,default:!1}},data:function(){return{hover:!1}},computed:{classes:function(){return{root:G(un(W({},this.position,!0)),this.defaultClass,this.hover&&this.hoverClass),wrapper:G(dn(W({},this.position,!0)),this.wrapperClass)}}},methods:{onDrag:function(e){this.$emit(`drag`,e)},onEnter:function(){this.hover=!0},onLeave:function(){this.hover=!1},onDragEnd:function(){this.$emit(`drag-end`)}},emits:[`drag`,`drag-end`]};fn.render=function(e,t,n,r,i,a){var o=x(`LineWrapper`);return z(),h(o,{class:a.classes.wrapper,position:n.position,disabled:n.disabled,onDrag:a.onDrag,onDragEnd:a.onDragEnd,onEnter:a.onEnter,onLeave:a.onLeave},{default:F((function(){return[p(`div`,{class:a.classes.root},null,2)]})),_:1},8,[`class`,`position`,`disabled`,`onDrag`,`onDragEnd`,`onEnter`,`onLeave`])};var pn=K(`vue-bounding-box`),mn=[`east`,`west`,null],hn=[`south`,`north`,null],gn={name:`BoundingBox`,props:{width:{type:Number},height:{type:Number},transitions:{type:Object},handlers:{type:Object,default:function(){return{eastNorth:!0,north:!0,westNorth:!0,west:!0,westSouth:!0,south:!0,eastSouth:!0,east:!0}}},handlersComponent:{type:[Object,String],default:function(){return ln}},handlersClasses:{type:Object,default:function(){return{}}},handlersWrappersClasses:{type:Object,default:function(){return{}}},lines:{type:Object,default:function(){return{west:!0,north:!0,east:!0,south:!0}}},linesComponent:{type:[Object,String],default:function(){return fn}},linesClasses:{type:Object,default:function(){return{}}},linesWrappersClasses:{type:Object,default:function(){return{}}},resizable:{type:Boolean,default:!0}},data:function(){var e=[];return mn.forEach((function(t){hn.forEach((function(n){if(t!==n){var r=et(t,n);e.push({name:r.name,classname:r.classname,verticalDirection:n,horizontalDirection:t})}}))})),{points:e}},computed:{style:function(){var e={};return this.width&&this.height&&(e.width=`${this.width}px`,e.height=`${this.height}px`,this.transitions&&this.transitions.enabled&&(e.transition=`${this.transitions.time}ms ${this.transitions.timingFunction}`)),e},classes:function(){var e=this.handlersClasses,t=this.handlersWrappersClasses,n=this.linesClasses,r=this.linesWrappersClasses;return{root:pn(),handlers:e,handlersWrappers:t,lines:n,linesWrappers:r}},lineNodes:function(){var e=this,t=[];return this.points.forEach((function(n){n.horizontalDirection&&n.verticalDirection||!e.lines[n.name]||t.push({name:n.name,component:e.linesComponent,class:G(e.classes.lines.default,e.classes.lines[n.name],!e.resizable&&e.classes.lines.disabled),wrapperClass:G(e.classes.linesWrappers.default,e.classes.linesWrappers[n.name],!e.resizable&&e.classes.linesWrappers.disabled),hoverClass:e.classes.lines.hover,verticalDirection:n.verticalDirection,horizontalDirection:n.horizontalDirection,disabled:!e.resizable})})),t},handlerNodes:function(){var e=this,t=[],n=this.width,r=this.height;return this.points.forEach((function(i){if(e.handlers[i.name]){var a={name:i.name,component:e.handlersComponent,class:G(e.classes.handlers.default,e.classes.handlers[i.name]),wrapperClass:G(e.classes.handlersWrappers.default,e.classes.handlersWrappers[i.name]),hoverClass:e.classes.handlers.hover,verticalDirection:i.verticalDirection,horizontalDirection:i.horizontalDirection,disabled:!e.resizable};if(n&&r){var o=i.horizontalDirection,s=i.verticalDirection,c=o===`east`?n:o===`west`?0:n/2,l=s===`south`?r:s===`north`?0:r/2;a.wrapperClass=pn(`handler`),a.wrapperStyle={transform:`translate(${c}px, ${l}px)`},e.transitions&&e.transitions.enabled&&(a.wrapperStyle.transition=`${e.transitions.time}ms ${e.transitions.timingFunction}`)}else a.wrapperClass=pn(`handler`,W({},i.classname,!0));t.push(a)}})),t}},beforeMount:function(){window.addEventListener(`mouseup`,this.onMouseUp,{passive:!1}),window.addEventListener(`mousemove`,this.onMouseMove,{passive:!1}),window.addEventListener(`touchmove`,this.onTouchMove,{passive:!1}),window.addEventListener(`touchend`,this.onTouchEnd,{passive:!1})},beforeUnmount:function(){window.removeEventListener(`mouseup`,this.onMouseUp),window.removeEventListener(`mousemove`,this.onMouseMove),window.removeEventListener(`touchmove`,this.onTouchMove),window.removeEventListener(`touchend`,this.onTouchEnd)},mounted:function(){this.touches=[]},methods:{onEnd:function(){this.$emit(`resize-end`)},onHandlerDrag:function(e,t,n){var r,i=e.shift(),a=i.left,o=i.top,s={left:0,right:0,top:0,bottom:0};t===`west`?s.left-=a:t===`east`&&(s.right+=a),n===`north`?s.top-=o:n===`south`&&(s.bottom+=o),!n&&t?r=`width`:n&&!t&&(r=`height`),this.resizable&&this.$emit(`resize`,new dt(s,{allowedDirections:{left:t===`west`||!t,right:t===`east`||!t,bottom:n===`south`||!n,top:n===`north`||!n},preserveAspectRatio:e.nativeEvent&&e.nativeEvent.shiftKey,respectDirection:r}))}},emits:[`resize`,`resize-end`]};gn.render=function(e,t,n,r,i,a){return z(),h(`div`,{ref:`box`,class:a.classes.root,style:a.style},[c(e.$slots,`default`),p(`div`,null,[(z(!0),h(R,null,S(a.lineNodes,(function(e){return z(),h(C(e.component),{key:e.name,"default-class":e.class,"hover-class":e.hoverClass,"wrapper-class":e.wrapperClass,position:e.name,disabled:e.disabled,onDrag:function(t){return a.onHandlerDrag(t,e.horizontalDirection,e.verticalDirection)},onDragEnd:t[1]||=function(e){return a.onEnd()}},null,8,[`default-class`,`hover-class`,`wrapper-class`,`position`,`disabled`,`onDrag`])})),128))]),(z(!0),h(R,null,S(a.handlerNodes,(function(e){return z(),h(`div`,{key:e.name,style:e.wrapperStyle,class:e.wrapperClass},[(z(),h(C(e.component),{"default-class":e.class,"hover-class":e.hoverClass,"wrapper-class":e.wrapperClass,"horizontal-position":e.horizontalDirection,"vertical-position":e.verticalDirection,disabled:e.disabled,onDrag:function(t){return a.onHandlerDrag(t,e.horizontalDirection,e.verticalDirection)},onDragEnd:t[2]||=function(e){return a.onEnd()}},null,8,[`default-class`,`hover-class`,`wrapper-class`,`horizontal-position`,`vertical-position`,`disabled`,`onDrag`]))],6)})),128))],6)};var _n=K(`vue-draggable-area`),vn={name:`DraggableArea`,props:{movable:{type:Boolean,default:!0},activationDistance:{type:Number,default:20}},computed:{classnames:function(){return{default:_n()}}},beforeMount:function(){window.addEventListener(`mouseup`,this.onMouseUp,{passive:!1}),window.addEventListener(`mousemove`,this.onMouseMove,{passive:!1}),window.addEventListener(`touchmove`,this.onTouchMove,{passive:!1}),window.addEventListener(`touchend`,this.onTouchEnd,{passive:!1})},beforeUnmount:function(){window.removeEventListener(`mouseup`,this.onMouseUp),window.removeEventListener(`mousemove`,this.onMouseMove),window.removeEventListener(`touchmove`,this.onTouchMove),window.removeEventListener(`touchend`,this.onTouchEnd)},mounted:function(){this.touches=[],this.touchStarted=!1},methods:{onTouchStart:function(e){if(e.cancelable){var t=this.movable&&e.touches.length===1;t&&(this.touches=qe(e.touches)),(this.touchStarted||t)&&(e.preventDefault(),e.stopPropagation())}},onTouchEnd:function(){this.touchStarted=!1,this.processEnd()},onTouchMove:function(e){this.touches.length>=1&&(this.touchStarted?(this.processMove(e,e.touches),e.preventDefault(),e.stopPropagation()):lt({x:this.touches[0].clientX,y:this.touches[0].clientY},{x:e.touches[0].clientX,y:e.touches[0].clientY})>this.activationDistance&&(this.initAnchor({clientX:e.touches[0].clientX,clientY:e.touches[0].clientY}),this.touchStarted=!0))},onMouseDown:function(e){if(this.movable&&e.button===0){var t={fake:!0,clientX:e.clientX,clientY:e.clientY};this.touches=[t],this.initAnchor(t),e.stopPropagation()}},onMouseMove:function(e){this.touches.length&&(this.processMove(e,[{fake:!0,clientX:e.clientX,clientY:e.clientY}]),e.preventDefault&&e.cancelable&&e.preventDefault(),e.stopPropagation())},onMouseUp:function(){this.processEnd()},initAnchor:function(e){var t=this.$refs.container.getBoundingClientRect(),n=t.left,r=t.top;this.anchor={x:e.clientX-n,y:e.clientY-r}},processMove:function(e,t){var n=qe(t);if(this.touches.length){var r=this.$refs.container.getBoundingClientRect(),i=r.left,a=r.top;this.touches.length===1&&n.length===1&&this.$emit(`move`,new ft({left:n[0].clientX-(i+this.anchor.x),top:n[0].clientY-(a+this.anchor.y)}))}},processEnd:function(){this.touches.length&&this.$emit(`move-end`),this.touches=[]}},emits:[`move`,`move-end`]};vn.render=function(e,t,n,r,i,a){return z(),h(`div`,{ref:`container`,onTouchstart:t[1]||=function(){return a.onTouchStart&&a.onTouchStart.apply(a,arguments)},onMousedown:t[2]||=function(){return a.onMouseDown&&a.onMouseDown.apply(a,arguments)}},[c(e.$slots,`default`)],544)};function yn(e){return{rotate:e.rotate||0,flip:{horizontal:e?.flip?.horizontal||!1,vertical:e?.flip?.vertical||!1}}}function bn(e){return new Promise((function(t,n){try{if(e)if(/^data:/i.test(e))t(function(e){e=e.replace(/^data:([^;]+);base64,/gim,``);for(var t=atob(e),n=t.length,r=new ArrayBuffer(n),i=new Uint8Array(r),a=0;a<n;a++)i[a]=t.charCodeAt(a);return r}(e));else if(/^blob:/i.test(e)){var r=new FileReader;r.onload=function(e){t(e.target.result)},a=e,o=function(e){r.readAsArrayBuffer(e)},(s=new XMLHttpRequest).open(`GET`,a,!0),s.responseType=`blob`,s.onload=function(){this.status!=200&&this.status!==0||o(this.response)},s.send()}else{var i=new XMLHttpRequest;i.onreadystatechange=function(){i.readyState===4&&(i.status===200||i.status===0?t(i.response):n(`Warning: could not load an image to parse its orientation`),i=null)},i.onprogress=function(){i.getResponseHeader(`content-type`)!==`image/jpeg`&&i.abort()},i.withCredentials=!1,i.open(`GET`,e,!0),i.responseType=`arraybuffer`,i.send(null)}else n(`Error: the image is empty`)}catch(e){n(e)}var a,o,s}))}function xn(e){var t=e.rotate,n=e.flip,r=e.scaleX,i=e.scaleY,a=``;return a+=` rotate(`+t+`deg) `,a+=` scaleX(`+r*(n.horizontal?-1:1)+`) `,a+=` scaleY(`+i*(n.vertical?-1:1)+`) `}function Sn(e){try{var t,n=new DataView(e),r=void 0,i=void 0,a=void 0,o=void 0;if(n.getUint8(0)===255&&n.getUint8(1)===216)for(var s=n.byteLength,c=2;c+1<s;){if(n.getUint8(c)===255&&n.getUint8(c+1)===225){a=c;break}c++}if(a&&(r=a+10,function(e,t,n){var r,i=``;for(r=t,n+=t;r<n;r++)i+=String.fromCharCode(e.getUint8(r));return i}(n,a+4,4)===`Exif`)){var l=n.getUint16(r);if(((i=l===18761)||l===19789)&&n.getUint16(r+2,i)===42){var u=n.getUint32(r+4,i);u>=8&&(o=r+u)}}if(o){for(var d=n.getUint16(o,i),f=0;f<d;f++)if(c=o+12*f+2,n.getUint16(c,i)===274){c+=8,t=n.getUint16(c,i),n.setUint16(c,1,i);break}}return t}catch{return null}}var Cn=K(`vue-preview-result`),wn={name:`PreviewResult`,props:{image:{type:Object},transitions:{type:Object},stencilCoordinates:{type:Object,default:function(){return{width:0,height:0,left:0,top:0}}},imageClass:{type:String}},computed:{classes:function(){return{root:Cn(),wrapper:Cn(`wrapper`),imageWrapper:Cn(`image-wrapper`),image:G(Cn(`image`),this.imageClass)}},wrapperStyle:function(){var e={width:`${this.stencilCoordinates.width}px`,height:`${this.stencilCoordinates.height}px`,left:`calc(50% - ${this.stencilCoordinates.width/2}px)`,top:`calc(50% - ${this.stencilCoordinates.height/2}px)`};return this.transitions&&this.transitions.enabled&&(e.transition=`${this.transitions.time}ms ${this.transitions.timingFunction}`),e},imageStyle:function(){var e=this.image.transforms,t=Ft({width:this.image.width,height:this.image.height},e.rotate),n={width:`${this.image.width}px`,height:`${this.image.height}px`,left:`0px`,top:`0px`},r={left:(this.image.width-t.width)*e.scaleX/2,top:(this.image.height-t.height)*e.scaleY/2},i={left:(1-e.scaleX)*this.image.width/2,top:(1-e.scaleY)*this.image.height/2};return n.transform=`translate(
3
+ ${-this.stencilCoordinates.left-e.translateX-r.left-i.left}px,${-this.stencilCoordinates.top-e.translateY-r.top-i.top}px) `+xn(e),this.transitions&&this.transitions.enabled&&(n.transition=`${this.transitions.time}ms ${this.transitions.timingFunction}`),n}}};function Tn(e,t){var n=t.getBoundingClientRect(),r=n.left,i=n.top,a={left:0,top:0},o=0;return e.forEach((function(t){a.left+=(t.clientX-r)/e.length,a.top+=(t.clientY-i)/e.length})),e.forEach((function(e){o+=lt({x:a.left,y:a.top},{x:e.clientX-r,y:e.clientY-i})})),{centerMass:a,spread:o,count:e.length}}wn.render=function(e,t,n,r,i,a){return z(),h(`div`,{class:a.classes.root},[p(`div`,{ref:`wrapper`,class:a.classes.wrapper,style:a.wrapperStyle},[p(`img`,{ref:`image`,src:n.image.src,class:a.classes.image,style:a.imageStyle},null,14,[`src`])],6)],2)};var En={props:{touchMove:{type:Boolean,required:!0},mouseMove:{type:Boolean,required:!0},touchResize:{type:Boolean,required:!0},wheelResize:{type:[Boolean,Object],required:!0},eventsFilter:{type:Function,required:!1}},beforeMount:function(){window.addEventListener(`mouseup`,this.onMouseUp,{passive:!1}),window.addEventListener(`mousemove`,this.onMouseMove,{passive:!1}),window.addEventListener(`touchmove`,this.onTouchMove,{passive:!1}),window.addEventListener(`touchend`,this.onTouchEnd,{passive:!1})},beforeUnmount:function(){window.removeEventListener(`mouseup`,this.onMouseUp),window.removeEventListener(`mousemove`,this.onMouseMove),window.removeEventListener(`touchmove`,this.onTouchMove),window.removeEventListener(`touchend`,this.onTouchEnd)},created:function(){this.transforming=!1,this.debouncedProcessEnd=$e(this.processEnd),this.touches=[]},methods:{processMove:function(e,t){if(this.touches.length){if(this.touches.length===1&&t.length===1)this.$emit(`move`,new ut({left:this.touches[0].clientX-t[0].clientX,top:this.touches[0].clientY-t[0].clientY}));else if(this.touches.length>1&&this.touchResize){var n=Tn(t,this.$refs.container),r=this.oldGeometricProperties;r.count===n.count&&r.count>1&&this.$emit(`resize`,new ut({left:r.centerMass.left-n.centerMass.left,top:r.centerMass.top-n.centerMass.top},{factor:r.spread/n.spread,center:n.centerMass})),this.oldGeometricProperties=n}this.touches=t}},processEnd:function(){this.transforming&&(this.transforming=!1,this.$emit(`transform-end`))},processStart:function(){this.transforming=!0,this.debouncedProcessEnd.clear()},processEvent:function(e){return this.eventsFilter?!1!==this.eventsFilter(e,this.transforming):(e.preventDefault(),e.stopPropagation(),!0)},onTouchStart:function(e){if(e.cancelable&&(this.touchMove||this.touchResize&&e.touches.length>1)&&this.processEvent(e)){var t=this.$refs.container,n=t.getBoundingClientRect(),r=n.left,i=n.top,a=n.bottom,o=n.right;this.touches=qe(e.touches).filter((function(e){return e.clientX>r&&e.clientX<o&&e.clientY>i&&e.clientY<a})),this.oldGeometricProperties=Tn(this.touches,t)}},onTouchEnd:function(e){e.touches.length===0&&(this.touches=[],this.processEnd())},onTouchMove:function(e){var t=this;if(this.touches.length){var n=qe(e.touches).filter((function(e){return!e.identifier||t.touches.find((function(t){return t.identifier===e.identifier}))}));this.processEvent(e)&&(this.processMove(e,n),this.processStart())}},onMouseDown:function(e){this.mouseMove&&`buttons`in e&&e.buttons===1&&this.processEvent(e)&&(this.touches=[{fake:!0,clientX:e.clientX,clientY:e.clientY}],this.processStart())},onMouseMove:function(e){this.touches.length&&this.processEvent(e)&&this.processMove(e,[{clientX:e.clientX,clientY:e.clientY}])},onMouseUp:function(){this.touches=[],this.processEnd()},onWheel:function(e){if(this.wheelResize&&this.processEvent(e)){var t=this.$refs.container.getBoundingClientRect(),n=t.left,r=t.top,i=1+this.wheelResize.ratio*(o=e.deltaY||e.detail||e.wheelDelta,(s=+o)==0||ct(s)?s:s>0?1:-1),a={left:e.clientX-n,top:e.clientY-r};this.$emit(`resize`,new ut({},{factor:i,center:a})),this.touches.length||this.debouncedProcessEnd()}var o,s}},emits:[`resize`,`move`,`transform-end`]};En.render=function(e,t,n,r,i,a){return z(),h(`div`,{ref:`container`,onTouchstart:t[1]||=function(){return a.onTouchStart&&a.onTouchStart.apply(a,arguments)},onMousedown:t[2]||=function(){return a.onMouseDown&&a.onMouseDown.apply(a,arguments)},onWheel:t[3]||=function(){return a.onWheel&&a.onWheel.apply(a,arguments)}},[c(e.$slots,`default`)],544)};var Dn={components:{TransformableImage:En},props:{touchMove:{type:Boolean,required:!0},mouseMove:{type:Boolean,required:!0},touchResize:{type:Boolean,required:!0},wheelResize:{type:[Boolean,Object],required:!0}},emits:[`resize`,`move`]};Dn.render=function(e,t,n,r,i,a){var o=x(`transformable-image`);return z(),h(o,{"touch-move":n.touchMove,"touch-resize":n.touchResize,"mouse-move":n.mouseMove,"wheel-resize":n.wheelResize,onMove:t[1]||=function(t){return e.$emit(`move`,t)},onResize:t[2]||=function(t){return e.$emit(`resize`,t)}},{default:F((function(){return[c(e.$slots,`default`)]})),_:3},8,[`touch-move`,`touch-resize`,`mouse-move`,`wheel-resize`])};var On=K(`vue-preview`),kn={props:{coordinates:{type:Object},transitions:{type:Object},image:{type:Object,default:function(){return{}}},imageClass:{type:String},width:{type:Number},height:{type:Number},fill:{type:Boolean}},data:function(){return{calculatedImageSize:{width:0,height:0},calculatedSize:{width:0,height:0}}},computed:{classes:function(){return{root:On({fill:this.fill}),wrapper:On(`wrapper`),imageWrapper:On(`image-wrapper`),image:G(On(`image`),this.imageClass)}},style:function(){if(this.fill)return{};var e={};return this.width&&(e.width=`${this.size.width}px`),this.height&&(e.height=`${this.size.height}px`),this.transitions&&this.transitions.enabled&&(e.transition=`${this.transitions.time}ms ${this.transitions.timingFunction}`),e},wrapperStyle:function(){var e={width:`${this.size.width}px`,height:`${this.size.height}px`,left:`calc(50% - ${this.size.width/2}px)`,top:`calc(50% - ${this.size.height/2}px)`};return this.transitions&&this.transitions.enabled&&(e.transition=`${this.transitions.time}ms ${this.transitions.timingFunction}`),e},imageStyle:function(){if(this.coordinates&&this.image){var e=this.coordinates.width/this.size.width,t=U(U({rotate:0,flip:{horizontal:!1,vertical:!1}},this.image.transforms),{},{scaleX:1/e,scaleY:1/e}),n=this.imageSize.width,r=this.imageSize.height,i=Ft({width:n,height:r},t.rotate),a={width:`${n}px`,height:`${r}px`,left:`0px`,top:`0px`},o={rotate:{left:(n-i.width)*t.scaleX/2,top:(r-i.height)*t.scaleY/2},scale:{left:(1-t.scaleX)*n/2,top:(1-t.scaleY)*r/2}};return a.transform=`translate(
4
+ ${-this.coordinates.left/e-o.rotate.left-o.scale.left}px,${-this.coordinates.top/e-o.rotate.top-o.scale.top}px) `+xn(t),this.transitions&&this.transitions.enabled&&(a.transition=`${this.transitions.time}ms ${this.transitions.timingFunction}`),a}return{}},size:function(){return{width:this.width||this.calculatedSize.width,height:this.height||this.calculatedSize.height}},imageSize:function(){return{width:this.image.width||this.calculatedImageSize.width,height:this.image.height||this.calculatedImageSize.height}}},watch:{image:function(e){(e.width||e.height)&&this.onChangeImage()}},mounted:function(){var e=this;this.onChangeImage(),this.$refs.image.addEventListener(`load`,(function(){e.refreshImage()})),window.addEventListener(`resize`,this.refresh),window.addEventListener(`orientationchange`,this.refresh)},unmounted:function(){window.removeEventListener(`resize`,this.refresh),window.removeEventListener(`orientationchange`,this.refresh)},methods:{refreshImage:function(){var e=this.$refs.image;this.calculatedImageSize.height=e.naturalHeight,this.calculatedImageSize.width=e.naturalWidth},refresh:function(){var e=this.$refs.root;this.width||(this.calculatedSize.width=e.clientWidth),this.height||(this.calculatedSize.height=e.clientHeight)},onChangeImage:function(){var e=this.$refs.image;e&&e.complete&&this.refreshImage(),this.refresh()}}};kn.render=function(e,t,n,r,i,a){return z(),h(`div`,{ref:`root`,class:a.classes.root,style:a.style},[p(`div`,{ref:`wrapper`,class:a.classes.wrapper,style:a.wrapperStyle},[u(p(`img`,{ref:`image`,src:n.image&&n.image.src,class:a.classes.image,style:a.imageStyle},null,14,[`src`]),[[ye,n.image&&n.image.src]])],6)],6)};var An={components:{Preview:kn},inheritAttrs:!1};An.render=function(e,t,n,r,i,a){var o=x(`preview`);return z(),h(o,f(e.$attrs,{fill:!0}),null,16)};var jn=K(`vue-rectangle-stencil`),Mn={name:`RectangleStencil`,components:{StencilPreview:An,BoundingBox:gn,DraggableArea:vn},props:{image:{type:Object},coordinates:{type:Object},stencilCoordinates:{type:Object},handlers:{type:Object},handlersComponent:{type:[Object,String],default:function(){return ln}},lines:{type:Object},linesComponent:{type:[Object,String],default:function(){return fn}},aspectRatio:{type:[Number,String]},minAspectRatio:{type:[Number,String]},maxAspectRatio:{type:[Number,String]},movable:{type:Boolean,default:!0},resizable:{type:Boolean,default:!0},transitions:{type:Object},movingClass:{type:String},resizingClass:{type:String},previewClass:{type:String},boundingBoxClass:{type:String},linesClasses:{type:Object,default:function(){return{}}},linesWrappersClasses:{type:Object,default:function(){return{}}},handlersClasses:{type:Object,default:function(){return{}}},handlersWrappersClasses:{type:Object,default:function(){return{}}}},data:function(){return{moving:!1,resizing:!1}},computed:{classes:function(){return{stencil:G(jn({movable:this.movable,moving:this.moving,resizing:this.resizing}),this.moving&&this.movingClass,this.resizing&&this.resizingClass),preview:G(jn(`preview`),this.previewClass),boundingBox:G(jn(`bounding-box`),this.boundingBoxClass)}},style:function(){var e=this.stencilCoordinates,t=e.height,n=e.width,r=e.left,i=e.top,a={width:`${n}px`,height:`${t}px`,transform:`translate(${r}px, ${i}px)`};return this.transitions&&this.transitions.enabled&&(a.transition=`${this.transitions.time}ms ${this.transitions.timingFunction}`),a}},methods:{onMove:function(e){this.$emit(`move`,e),this.moving=!0},onMoveEnd:function(){this.$emit(`move-end`),this.moving=!1},onResize:function(e){this.$emit(`resize`,e),this.resizing=!0},onResizeEnd:function(){this.$emit(`resize-end`),this.resizing=!1},aspectRatios:function(){return{minimum:this.aspectRatio||this.minAspectRatio,maximum:this.aspectRatio||this.maxAspectRatio}}},emits:[`resize`,`resize-end`,`move`,`move-end`]};Mn.render=function(e,t,n,r,i,a){var o=x(`stencil-preview`),s=x(`draggable-area`),c=x(`bounding-box`);return z(),h(`div`,{class:a.classes.stencil,style:a.style},[p(c,{width:n.stencilCoordinates.width,height:n.stencilCoordinates.height,transitions:n.transitions,class:a.classes.boundingBox,handlers:n.handlers,"handlers-component":n.handlersComponent,"handlers-classes":n.handlersClasses,"handlers-wrappers-classes":n.handlersWrappersClasses,lines:n.lines,"lines-component":n.linesComponent,"lines-classes":n.linesClasses,"lines-wrappers-classes":n.linesWrappersClasses,resizable:n.resizable,onResize:a.onResize,onResizeEnd:a.onResizeEnd},{default:F((function(){return[p(s,{movable:n.movable,onMove:a.onMove,onMoveEnd:a.onMoveEnd},{default:F((function(){return[p(o,{image:n.image,coordinates:n.coordinates,width:n.stencilCoordinates.width,height:n.stencilCoordinates.height,class:a.classes.preview,transitions:n.transitions},null,8,[`image`,`coordinates`,`width`,`height`,`class`,`transitions`])]})),_:1},8,[`movable`,`onMove`,`onMoveEnd`])]})),_:1},8,[`width`,`height`,`transitions`,`class`,`handlers`,`handlers-component`,`handlers-classes`,`handlers-wrappers-classes`,`lines`,`lines-component`,`lines-classes`,`lines-wrappers-classes`,`resizable`,`onResize`,`onResizeEnd`])],6)};var Nn=K(`vue-circle-stencil`),Pn={components:{StencilPreview:An,BoundingBox:gn,DraggableArea:vn},props:{image:{type:Object},coordinates:{type:Object},stencilCoordinates:{type:Object},handlers:{type:Object,default:function(){return{eastNorth:!0,westNorth:!0,westSouth:!0,eastSouth:!0}}},handlersComponent:{type:[Object,String],default:function(){return ln}},handlersClasses:{type:Object,default:function(){return{}}},handlersWrappersClasses:{type:Object,default:function(){return{}}},lines:{type:Object},linesComponent:{type:[Object,String],default:function(){return fn}},linesClasses:{type:Object,default:function(){return{}}},linesWrappersClasses:{type:Object,default:function(){return{}}},movable:{type:Boolean,default:!0},resizable:{type:Boolean,default:!0},transitions:{type:Object},movingClass:{type:String},resizingClass:{type:String},previewClass:{type:String},boundingBoxClass:{type:String}},data:function(){return{moving:!1,resizing:!1}},computed:{classes:function(){return{stencil:G(Nn({movable:this.movable,moving:this.moving,resizing:this.resizing}),this.moving&&this.movingClass,this.resizing&&this.resizingClass),preview:G(Nn(`preview`),this.previewClass),boundingBox:G(Nn(`bounding-box`),this.boundingBoxClass)}},style:function(){var e=this.stencilCoordinates,t=e.height,n=e.width,r=e.left,i=e.top,a={width:`${n}px`,height:`${t}px`,transform:`translate(${r}px, ${i}px)`};return this.transitions&&this.transitions.enabled&&(a.transition=`${this.transitions.time}ms ${this.transitions.timingFunction}`),a}},methods:{onMove:function(e){this.$emit(`move`,e),this.moving=!0},onMoveEnd:function(){this.$emit(`move-end`),this.moving=!1},onResize:function(e){this.$emit(`resize`,e),this.resizing=!0},onResizeEnd:function(){this.$emit(`resize-end`),this.resizing=!1},aspectRatios:function(){return{minimum:1,maximum:1}}},emits:[`resize`,`resize-end`,`move`,`move-end`]};Pn.render=function(e,t,n,r,i,a){var o=x(`stencil-preview`),s=x(`draggable-area`),c=x(`bounding-box`);return z(),h(`div`,{class:a.classes.stencil,style:a.style},[p(c,{width:n.stencilCoordinates.width,height:n.stencilCoordinates.height,transitions:n.transitions,class:a.classes.boundingBox,handlers:n.handlers,"handlers-component":n.handlersComponent,"handlers-classes":n.handlersClasses,"handlers-wrappers-classes":n.handlersWrappersClasses,lines:n.lines,"lines-component":n.linesComponent,"lines-classes":n.linesClasses,"lines-wrappers-classes":n.linesWrappersClasses,resizable:n.resizable,onResize:a.onResize,onResizeEnd:a.onResizeEnd},{default:F((function(){return[p(s,{movable:n.movable,onMove:a.onMove,onMoveEnd:a.onMoveEnd},{default:F((function(){return[p(o,{image:n.image,coordinates:n.coordinates,width:n.stencilCoordinates.width,height:n.stencilCoordinates.height,class:a.classes.preview,transitions:n.transitions},null,8,[`image`,`coordinates`,`width`,`height`,`class`,`transitions`])]})),_:1},8,[`movable`,`onMove`,`onMoveEnd`])]})),_:1},8,[`width`,`height`,`transitions`,`class`,`handlers`,`handlers-component`,`handlers-classes`,`handlers-wrappers-classes`,`lines`,`lines-component`,`lines-classes`,`lines-wrappers-classes`,`resizable`,`onResize`,`onResizeEnd`])],6)};var Fn=[`transitions`],In=K(`vue-advanced-cropper`),Ln={name:`Cropper`,components:{BackgroundWrapper:Dn},props:{src:{type:String,default:null},stencilComponent:{type:[Object,String],default:function(){return Mn}},backgroundWrapperComponent:{type:[Object,String],default:function(){return Dn}},stencilProps:{type:Object,default:function(){return{}}},autoZoom:{type:Boolean,default:!1},imageClass:{type:String},boundariesClass:{type:String},backgroundClass:{type:String},foregroundClass:{type:String},minWidth:{type:[Number,String]},minHeight:{type:[Number,String]},maxWidth:{type:[Number,String]},maxHeight:{type:[Number,String]},debounce:{type:[Boolean,Number],default:500},transitions:{type:Boolean,default:!0},checkOrientation:{type:Boolean,default:!0},canvas:{type:[Object,Boolean],default:!0},crossOrigin:{type:[Boolean,String],default:void 0},transitionTime:{type:Number,default:300},imageRestriction:{type:String,default:`fit-area`,validator:function(e){return Ct.indexOf(e)!==-1}},roundResult:{type:Boolean,default:!0},defaultSize:{type:[Function,Object]},defaultPosition:{type:[Function,Object]},defaultVisibleArea:{type:[Function,Object]},defaultTransforms:{type:[Function,Object]},defaultBoundaries:{type:[Function,String],validator:function(e){return!(typeof e==`string`&&e!==`fill`&&e!==`fit`)}},priority:{type:String,default:`coordinates`},stencilSize:{type:[Object,Function]},resizeImage:{type:[Boolean,Object],default:!0},moveImage:{type:[Boolean,Object],default:!0},autoZoomAlgorithm:{type:Function},resizeAlgorithm:{type:Function,default:function(e){var t=e.event,n=e.coordinates,r=e.aspectRatio,i=e.positionRestrictions,a=e.sizeRestrictions,o=q(q({},n),{right:n.left+n.width,bottom:n.top+n.height}),s=t.params||{},c=q({},t.directions),l=s.allowedDirections||{left:!0,right:!0,bottom:!0,top:!0};a.widthFrozen&&(c.left=0,c.right=0),a.heightFrozen&&(c.top=0,c.bottom=0),yt.forEach((function(e){l[e]||(c[e]=0)}));var u=kt(o,c=an({coordinates:o,directions:c,sizeRestrictions:a,positionRestrictions:i})).width,d=kt(o,c).height,f=s.preserveRatio?Q(o):Nt(u/d,r);if(f){var p=s.respectDirection;if(p||=o.width>=o.height||f===1?`width`:`height`,p===`width`){var m=u/f-o.height;if(l.top&&l.bottom){var h=c.top,g=c.bottom;c.bottom=on(m,g,h),c.top=on(m,h,g)}else l.bottom?c.bottom=m:l.top?c.top=m:l.right?c.right=0:l.left&&(c.left=0)}else if(p===`height`){var _=o.width-d*f;if(l.left&&l.right){var v=c.left,y=c.right;c.left=-on(_,v,y),c.right=-on(_,y,v)}else l.left?c.left=-_:l.right?c.right=-_:l.top?c.top=0:l.bottom&&(c.bottom=0)}c=an({directions:c,coordinates:o,sizeRestrictions:a,positionRestrictions:i,preserveRatio:!0,compensate:s.compensate})}return u=kt(o,c).width,d=kt(o,c).height,(f=s.preserveRatio?Q(o):Nt(u/d,r))&&Math.abs(f-u/d)>.001&&yt.forEach((function(e){l[e]||(c[e]=0)})),Gt({event:new ft({left:-c.left,top:-c.top}),coordinates:{width:n.width+c.right+c.left,height:n.height+c.top+c.bottom,left:n.left,top:n.top},positionRestrictions:i})}},moveAlgorithm:{type:Function,default:Gt},initStretcher:{type:Function,default:function(e){var t=e.stretcher,n=e.imageSize,r=Q(n);t.style.width=n.width+`px`,t.style.height=t.clientWidth/r+`px`,t.style.width=t.clientWidth+`px`}},fitCoordinates:{type:Function,default:function(e){var t=e.visibleArea,n=e.coordinates,r=e.aspectRatio,i=e.sizeRestrictions,a=e.positionRestrictions,o=q(q({},n),Wt({width:n.width,height:n.height,aspectRatio:r,sizeRestrictions:{maxWidth:t.width,maxHeight:t.height,minHeight:Math.min(t.height,i.minHeight),minWidth:Math.min(t.width,i.minWidth)}}));return o=$(o=X(o,Dt(Y(n),Y(o))),Vt(Et(t),a))}},fitVisibleArea:{type:Function,default:function(e){var t=e.visibleArea,n=e.boundaries,r=e.getAreaRestrictions,i=e.coordinates,a=q({},t);a.height=a.width/Q(n),a.top+=(t.height-a.height)/2,(i.height-a.height>0||i.width-a.width>0)&&(a=Z(a,Math.max(i.height/a.height,i.width/a.width)));var o=At(Mt(i,Et(a=Z(a,Lt(a,r({visibleArea:a,type:`resize`}))))));return a.width<i.width&&(o.left=0),a.height<i.height&&(o.top=0),a=$(a=X(a,o),r({visibleArea:a,type:`move`}))}},areaRestrictionsAlgorithm:{type:Function,default:function(e){var t=e.visibleArea,n=e.boundaries,r=e.imageSize,i=e.imageRestriction,a=e.type,o={};return i===`fill-area`?o={left:0,top:0,right:r.width,bottom:r.height}:i===`fit-area`&&(Q(n)>Q(r)?(o={top:0,bottom:r.height},t&&a===`move`&&(t.width>r.width?(o.left=-(t.width-r.width)/2,o.right=r.width-o.left):(o.left=0,o.right=r.width))):(o={left:0,right:r.width},t&&a===`move`&&(t.height>r.height?(o.top=-(t.height-r.height)/2,o.bottom=r.height-o.top):(o.top=0,o.bottom=r.height)))),o}},sizeRestrictionsAlgorithm:{type:Function,default:function(e){return{minWidth:e.minWidth,minHeight:e.minHeight,maxWidth:e.maxWidth,maxHeight:e.maxHeight}}},positionRestrictionsAlgorithm:{type:Function,default:function(e){var t=e.imageSize,n={};return e.imageRestriction!==`none`&&(n={left:0,top:0,right:t.width,bottom:t.height}),n}}},data:function(){return{transitionsActive:!1,imageLoaded:!1,imageAttributes:{width:null,height:null,crossOrigin:null,src:null},defaultImageTransforms:{rotate:0,flip:{horizontal:!1,vertical:!1}},appliedImageTransforms:{rotate:0,flip:{horizontal:!1,vertical:!1}},boundaries:{width:0,height:0},visibleArea:null,coordinates:U({},wt)}},computed:{image:function(){return{src:this.imageAttributes.src,width:this.imageAttributes.width,height:this.imageAttributes.height,transforms:this.imageTransforms}},imageTransforms:function(){return{rotate:this.appliedImageTransforms.rotate,flip:{horizontal:this.appliedImageTransforms.flip.horizontal,vertical:this.appliedImageTransforms.flip.vertical},translateX:this.visibleArea?this.visibleArea.left/this.coefficient:0,translateY:this.visibleArea?this.visibleArea.top/this.coefficient:0,scaleX:1/this.coefficient,scaleY:1/this.coefficient}},imageSize:function(){var e=function(e){return e*Math.PI/180}(this.imageTransforms.rotate);return{width:Math.abs(this.imageAttributes.width*Math.cos(e))+Math.abs(this.imageAttributes.height*Math.sin(e)),height:Math.abs(this.imageAttributes.width*Math.sin(e))+Math.abs(this.imageAttributes.height*Math.cos(e))}},initialized:function(){return!!(this.visibleArea&&this.imageLoaded)},settings:function(){var e=at(this.resizeImage,{touch:!0,wheel:{ratio:.1},adjustStencil:!0},{touch:!1,wheel:!1,adjustStencil:!1});return{moveImage:at(this.moveImage,{touch:!0,mouse:!0},{touch:!1,mouse:!1}),resizeImage:e}},coefficient:function(){return this.visibleArea?this.visibleArea.width/this.boundaries.width:0},areaRestrictions:function(){return this.imageLoaded?this.areaRestrictionsAlgorithm({imageSize:this.imageSize,imageRestriction:this.imageRestriction,boundaries:this.boundaries}):{}},transitionsOptions:function(){return{enabled:this.transitionsActive,timingFunction:`ease-in-out`,time:350}},sizeRestrictions:function(){if(this.boundaries.width&&this.boundaries.height&&this.imageSize.width&&this.imageSize.height){var e=this.sizeRestrictionsAlgorithm({imageSize:this.imageSize,minWidth:J(this.minWidth)?0:ot(this.minWidth),minHeight:J(this.minHeight)?0:ot(this.minHeight),maxWidth:J(this.maxWidth)?1/0:ot(this.maxWidth),maxHeight:J(this.maxHeight)?1/0:ot(this.maxHeight)});if(e=function(e){var t=e.areaRestrictions,n=e.sizeRestrictions,r=e.boundaries,i=e.positionRestrictions,a=q(q({},n),{minWidth:n.minWidth===void 0?0:n.minWidth,minHeight:n.minHeight===void 0?0:n.minHeight,maxWidth:n.maxWidth===void 0?1/0:n.maxWidth,maxHeight:n.maxHeight===void 0?1/0:n.maxHeight});i.left!==void 0&&i.right!==void 0&&(a.maxWidth=Math.min(a.maxWidth,i.right-i.left)),i.bottom!==void 0&&i.top!==void 0&&(a.maxHeight=Math.min(a.maxHeight,i.bottom-i.top));var o=Rt(t),s=Pt(r,o);return o.width<1/0&&(!a.maxWidth||a.maxWidth>s.width)&&(a.maxWidth=Math.min(a.maxWidth,s.width)),o.height<1/0&&(!a.maxHeight||a.maxHeight>s.height)&&(a.maxHeight=Math.min(a.maxHeight,s.height)),a.minWidth>a.maxWidth&&(a.minWidth=a.maxWidth,a.widthFrozen=!0),a.minHeight>a.maxHeight&&(a.minHeight=a.maxHeight,a.heightFrozen=!0),a}({sizeRestrictions:e,areaRestrictions:this.getAreaRestrictions({visibleArea:this.visibleArea,type:`resize`}),imageSize:this.imageSize,boundaries:this.boundaries,positionRestrictions:this.positionRestrictions,imageRestriction:this.imageRestriction,visibleArea:this.visibleArea,stencilSize:this.getStencilSize()}),this.visibleArea&&this.stencilSize){var t=this.getStencilSize(),n=Rt(this.getAreaRestrictions({visibleArea:this.visibleArea,type:`resize`}));e.maxWidth=Math.min(e.maxWidth,n.width*t.width/this.boundaries.width),e.maxHeight=Math.min(e.maxHeight,n.height*t.height/this.boundaries.height),e.maxWidth<e.minWidth&&(e.minWidth=e.maxWidth),e.maxHeight<e.minHeight&&(e.minHeight=e.maxHeight)}return e}return{minWidth:0,minHeight:0,maxWidth:0,maxHeight:0}},positionRestrictions:function(){return this.positionRestrictionsAlgorithm({imageSize:this.imageSize,imageRestriction:this.imageRestriction})},classes:function(){return{cropper:In(),image:G(In(`image`),this.imageClass),stencil:In(`stencil`),boundaries:G(In(`boundaries`),this.boundariesClass),stretcher:G(In(`stretcher`)),background:G(In(`background`),this.backgroundClass),foreground:G(In(`foreground`),this.foregroundClass),imageWrapper:G(In(`image-wrapper`)),cropperWrapper:G(In(`cropper-wrapper`))}},stencilCoordinates:function(){if(this.initialized){var e=this.coordinates,t=e.width,n=e.height,r=e.left,i=e.top;return{width:t/this.coefficient,height:n/this.coefficient,left:(r-this.visibleArea.left)/this.coefficient,top:(i-this.visibleArea.top)/this.coefficient}}return this.defaultCoordinates()},boundariesStyle:function(){var e={width:this.boundaries.width?`${Math.round(this.boundaries.width)}px`:`auto`,height:this.boundaries.height?`${Math.round(this.boundaries.height)}px`:`auto`,transition:`opacity ${this.transitionTime}ms`,pointerEvents:this.imageLoaded?`all`:`none`};return this.imageLoaded||(e.opacity=`0`),e},imageStyle:function(){var e=this.imageAttributes.width>this.imageAttributes.height?{width:Math.min(1024,this.imageAttributes.width),height:Math.min(1024,this.imageAttributes.width)/(this.imageAttributes.width/this.imageAttributes.height)}:{height:Math.min(1024,this.imageAttributes.height),width:this.imageAttributes.width/this.imageAttributes.height*Math.min(1024,this.imageAttributes.height)},t={left:(e.width-this.imageSize.width)/(2*this.coefficient),top:(e.height-this.imageSize.height)/(2*this.coefficient)},n={left:(1-1/this.coefficient)*e.width/2,top:(1-1/this.coefficient)*e.height/2},r=U(U({},this.imageTransforms),{},{scaleX:this.imageAttributes.width/e.width*this.imageTransforms.scaleX,scaleY:this.imageAttributes.height/e.height*this.imageTransforms.scaleY}),i={width:`${e.width}px`,height:`${e.height}px`,left:`0px`,top:`0px`,transform:`translate(${-t.left-n.left-this.imageTransforms.translateX}px, ${-t.top-n.top-this.imageTransforms.translateY}px)`+xn(r)};return this.transitionsOptions.enabled&&(i.transition=`${this.transitionsOptions.time}ms ${this.transitionsOptions.timingFunction}`),i}},watch:{src:function(){this.onChangeImage()},stencilComponent:function(){var e=this;this.$nextTick((function(){e.resetCoordinates(),e.runAutoZoom(`setCoordinates`),e.onChange()}))},minWidth:function(){this.onPropsChange()},maxWidth:function(){this.onPropsChange()},minHeight:function(){this.onPropsChange()},maxHeight:function(){this.onPropsChange()},imageRestriction:function(){this.reset()},stencilProps:function(e,t){[`aspectRatio`,`minAspectRatio`,`maxAspectRatio`].find((function(n){return e[n]!==t[n]}))&&this.$nextTick(this.onPropsChange)}},created:function(){this.debouncedUpdate=$e(this.update,this.debounce),this.debouncedDisableTransitions=$e(this.disableTransitions,this.transitionsOptions.time),this.awaiting=!1},mounted:function(){this.$refs.image.addEventListener(`load`,this.onSuccessLoadImage),this.$refs.image.addEventListener(`error`,this.onFailLoadImage),this.onChangeImage(),window.addEventListener(`resize`,this.refresh),window.addEventListener(`orientationchange`,this.refresh)},unmounted:function(){window.removeEventListener(`resize`,this.refresh),window.removeEventListener(`orientationchange`,this.refresh),this.imageAttributes.revoke&&this.imageAttributes.src&&URL.revokeObjectURL(this.imageAttributes.src),this.debouncedUpdate.clear(),this.debouncedDisableTransitions.clear()},methods:{getResult:function(){var e=this.initialized?this.prepareResult(U({},this.coordinates)):this.defaultCoordinates(),t={rotate:this.imageTransforms.rotate%360,flip:U({},this.imageTransforms.flip)};if(this.src&&this.imageLoaded){var n=this;return{image:this.image,coordinates:e,visibleArea:this.visibleArea?U({},this.visibleArea):null,imageTransforms:t,get canvas(){return n.canvas?n.getCanvas():void 0}}}return{image:this.image,coordinates:e,visibleArea:this.visibleArea?U({},this.visibleArea):null,canvas:void 0,imageTransforms:t}},zoom:function(e,t){var n=(arguments.length>2&&arguments[2]!==void 0?arguments[2]:{}).transitions,r=n===void 0||n;this.onManipulateImage(new ut({},{factor:1/e,center:t}),{normalize:!1,transitions:r})},move:function(e,t){var n=(arguments.length>2&&arguments[2]!==void 0?arguments[2]:{}).transitions,r=n===void 0||n;this.onManipulateImage(new ut({left:e||0,top:t||0}),{normalize:!1,transitions:r})},setCoordinates:function(e){var t=this,n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r=n.autoZoom,i=r===void 0||r,a=n.transitions,o=a===void 0||a;this.$nextTick((function(){t.imageLoaded?(t.transitionsActive||(o&&t.enableTransitions(),t.coordinates=t.applyTransform(e),i&&t.runAutoZoom(`setCoordinates`),o&&t.debouncedDisableTransitions()),t.onChange()):t.delayedTransforms=e}))},refresh:function(){var e=this;if(this.src&&this.$refs.image)return this.initialized?this.updateVisibleArea().then((function(){e.onChange()})):this.resetVisibleArea().then((function(){e.onChange()}))},reset:function(){var e=this;return this.resetVisibleArea().then((function(){e.onChange(!1)}))},awaitRender:function(e){var t=this;this.awaiting||(this.awaiting=!0,this.$nextTick((function(){e(),t.awaiting=!1})))},prepareResult:function(e){return this.roundResult?function(e){var t=e.coordinates,n=e.sizeRestrictions,r=e.positionRestrictions,i={width:Math.round(t.width),height:Math.round(t.height),left:Math.round(t.left),top:Math.round(t.top)};return i.width>n.maxWidth?i.width=Math.floor(t.width):i.width<n.minWidth&&(i.width=Math.ceil(t.width)),i.height>n.maxHeight?i.height=Math.floor(t.height):i.height<n.minHeight&&(i.height=Math.ceil(t.height)),$(i,r)}(U(U({},this.getPublicProperties()),{},{positionRestrictions:en(this.positionRestrictions,this.visibleArea),coordinates:e})):e},processAutoZoom:function(e,t,n,r){var i=this.autoZoomAlgorithm;i||=this.stencilSize?qt:this.autoZoom?Jt:Yt;var a=i({event:{type:e,params:r},visibleArea:t,coordinates:n,boundaries:this.boundaries,aspectRatio:this.getAspectRatio(),positionRestrictions:this.positionRestrictions,getAreaRestrictions:this.getAreaRestrictions,sizeRestrictions:this.sizeRestrictions,stencilSize:this.getStencilSize()});return U(U({},a),{},{changed:!Tt(a.visibleArea,t)||!Tt(a.coordinates,n)})},runAutoZoom:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=t.transitions,r=n!==void 0&&n,i=Ke(t,Fn),a=this.processAutoZoom(e,this.visibleArea,this.coordinates,i),o=a.visibleArea,s=a.coordinates,c=a.changed;r&&c&&this.enableTransitions(),this.visibleArea=o,this.coordinates=s,r&&c&&this.debouncedDisableTransitions()},normalizeEvent:function(e){return function(e){var t=e.event,n=e.visibleArea,r=e.coefficient;if(t.type===`manipulateImage`)return q(q({},t),{move:{left:t.move&&t.move.left?r*t.move.left:0,top:t.move&&t.move.top?r*t.move.top:0},scale:{factor:t.scale&&t.scale.factor?t.scale.factor:1,center:t.scale&&t.scale.center?{left:t.scale.center.left*r+n.left,top:t.scale.center.top*r+n.top}:null}});if(t.type===`resize`){var i=q(q({},t),{directions:q({},t.directions)});return yt.forEach((function(e){i.directions[e]*=r})),i}if(t.type===`move`){var a=q(q({},t),{directions:q({},t.directions)});return St.forEach((function(e){a.directions[e]*=r})),a}return t}(U(U({},this.getPublicProperties()),{},{event:e}))},getCanvas:function(){if(this.$refs.canvas){var e=this.$refs.canvas,t=this.$refs.image,n=this.imageTransforms.rotate!==0||this.imageTransforms.flip.horizontal||this.imageTransforms.flip.vertical?function(e,t,n){var r=n.rotate,i=n.flip,a={width:t.naturalWidth,height:t.naturalHeight},o=Ft(a,r),s=e.getContext(`2d`);e.height=o.height,e.width=o.width,s.save();var c=It(Y(q({left:0,top:0},a)),r);return s.translate(-(c.left-o.width/2),-(c.top-o.height/2)),s.rotate(r*Math.PI/180),s.translate(i.horizontal?a.width:0,i.vertical?a.height:0),s.scale(i.horizontal?-1:1,i.vertical?-1:1),s.drawImage(t,0,0,a.width,a.height),s.restore(),e}(this.$refs.sourceCanvas,t,this.imageTransforms):t,r=U({minWidth:0,minHeight:0,maxWidth:1/0,maxHeight:1/0,maxArea:this.maxCanvasSize,imageSmoothingEnabled:!0,imageSmoothingQuality:`high`,fillColor:`transparent`},this.canvas),i=function(e){return e.find((function(e){return t=e,!Number.isNaN(parseFloat(t))&&isFinite(t);var t}))},a=Wt({sizeRestrictions:{minWidth:i([r.width,r.minWidth])||0,minHeight:i([r.height,r.minHeight])||0,maxWidth:i([r.width,r.maxWidth])||1/0,maxHeight:i([r.height,r.maxHeight])||1/0},width:this.coordinates.width,height:this.coordinates.height,aspectRatio:{minimum:this.coordinates.width/this.coordinates.height,maximum:this.coordinates.width/this.coordinates.height}});if(r.maxArea&&a.width*a.height>r.maxArea){var o=Math.sqrt(r.maxArea/(a.width*a.height));a={width:Math.round(o*a.width),height:Math.round(o*a.height)}}return function(e,t,n,r,i){e.width=r?r.width:n.width,e.height=r?r.height:n.height;var a=e.getContext(`2d`);a.clearRect(0,0,e.width,e.height),i&&(i.imageSmoothingEnabled&&(a.imageSmoothingEnabled=i.imageSmoothingEnabled),i.imageSmoothingQuality&&(a.imageSmoothingQuality=i.imageSmoothingQuality),i.fillColor&&(a.fillStyle=i.fillColor,a.fillRect(0,0,e.width,e.height),a.save()));var o=n.left<0?-n.left:0,s=n.top<0?-n.top:0;a.drawImage(t,n.left+o,n.top+s,n.width,n.height,e.width/n.width*o,e.height/n.height*s,e.width,e.height)}(e,n,this.coordinates,a,r),e}},update:function(){this.$emit(`change`,this.getResult())},applyTransform:function(e){var t=arguments.length>1&&arguments[1]!==void 0&&arguments[1],n=this.visibleArea&&t?zt(this.sizeRestrictions,this.visibleArea):this.sizeRestrictions,r=this.visibleArea&&t?en(this.positionRestrictions,this.visibleArea):this.positionRestrictions;return Kt({transform:e,coordinates:this.coordinates,imageSize:this.imageSize,sizeRestrictions:n,positionRestrictions:r,aspectRatio:this.getAspectRatio(),visibleArea:this.visibleArea})},resetCoordinates:function(){var e=this;if(this.$refs.image){var t=this.defaultSize;t||=this.stencilSize?Qt:Zt;var n=rt(t)?t({boundaries:this.boundaries,imageSize:this.imageSize,aspectRatio:this.getAspectRatio(),sizeRestrictions:this.sizeRestrictions,stencilSize:this.getStencilSize(),visibleArea:this.visibleArea}):t,r=this.defaultPosition||Xt,i=[n,function(t){var n=t.coordinates;return U({},rt(r)?r({coordinates:n,imageSize:e.imageSize,visibleArea:e.visibleArea}):e.defaultPosition)}];this.delayedTransforms&&i.push.apply(i,qe(Array.isArray(this.delayedTransforms)?this.delayedTransforms:[this.delayedTransforms])),this.coordinates=this.applyTransform(i,!0),this.delayedTransforms=null}},clearImage:function(){var e=this;this.imageLoaded=!1,setTimeout((function(){var t=e.$refs.stretcher;t&&(t.style.height=`auto`,t.style.width=`auto`),e.coordinates=e.defaultCoordinates(),e.boundaries={width:0,height:0}}),this.transitionTime)},enableTransitions:function(){this.transitions&&(this.transitionsActive=!0)},disableTransitions:function(){this.transitionsActive=!1},updateBoundaries:function(){var e=this,t=this.$refs.stretcher,n=this.$refs.cropper;return this.initStretcher({cropper:n,stretcher:t,imageSize:this.imageSize}),this.$nextTick().then((function(){var t={cropper:n,imageSize:e.imageSize};if(rt(e.defaultBoundaries)?e.boundaries=e.defaultBoundaries(t):e.defaultBoundaries===`fit`?e.boundaries=function(e){var t=e.cropper,n=e.imageSize,r=t.clientHeight,i=t.clientWidth,a=r,o=n.width*r/n.height;return o>i&&(o=i,a=n.height*i/n.width),{width:o,height:a}}(t):e.boundaries=function(e){var t=e.cropper;return{width:t.clientWidth,height:t.clientHeight}}(t),!e.boundaries.width||!e.boundaries.height)throw Error(`It's impossible to fit the cropper in the current container`)}))},resetVisibleArea:function(){var e=this;return this.appliedImageTransforms=U(U({},this.defaultImageTransforms),{},{flip:U({},this.defaultImageTransforms.flip)}),this.updateBoundaries().then((function(){e.priority!==`visible-area`&&(e.visibleArea=null,e.resetCoordinates());var t,n,r,i,a,o,s=e.defaultVisibleArea||$t;e.visibleArea=rt(s)?s({imageSize:e.imageSize,boundaries:e.boundaries,coordinates:e.priority===`visible-area`?null:e.coordinates,getAreaRestrictions:e.getAreaRestrictions,stencilSize:e.getStencilSize()}):e.defaultVisibleArea,e.visibleArea=(t={visibleArea:e.visibleArea,boundaries:e.boundaries,getAreaRestrictions:e.getAreaRestrictions},n=t.visibleArea,r=t.boundaries,i=t.getAreaRestrictions,a=q({},n),o=Q(r),a.width/a.height!==o&&(a.height=a.width/o),$(a,i({visibleArea:a,type:`move`}))),e.priority===`visible-area`?e.resetCoordinates():e.coordinates=e.fitCoordinates({visibleArea:e.visibleArea,coordinates:e.coordinates,aspectRatio:e.getAspectRatio(),positionRestrictions:e.positionRestrictions,sizeRestrictions:e.sizeRestrictions}),e.runAutoZoom(`resetVisibleArea`)})).catch((function(){e.visibleArea=null}))},updateVisibleArea:function(){var e=this;return this.updateBoundaries().then((function(){e.visibleArea=e.fitVisibleArea({imageSize:e.imageSize,boundaries:e.boundaries,visibleArea:e.visibleArea,coordinates:e.coordinates,getAreaRestrictions:e.getAreaRestrictions}),e.coordinates=e.fitCoordinates({visibleArea:e.visibleArea,coordinates:e.coordinates,aspectRatio:e.getAspectRatio(),positionRestrictions:e.positionRestrictions,sizeRestrictions:e.sizeRestrictions}),e.runAutoZoom(`updateVisibleArea`)})).catch((function(){e.visibleArea=null}))},onChange:function(){(!(arguments.length>0&&arguments[0]!==void 0)||arguments[0])&&this.debounce?this.debouncedUpdate():this.update()},onChangeImage:function(){var e,t=this;if(this.imageLoaded=!1,this.delayedTransforms=null,this.src){if(function(e){if(nt(e))return!1;var t=window.location,n=/(\w+:)?(?:\/\/)([\w.-]+)?(?::(\d+))?\/?/.exec(e)||[],r={protocol:n[1]||``,host:n[2]||``,port:n[3]||``},i=function(e){return e.port||((e.protocol||t.protocol)===`http`?80:433)};return!(!r.protocol&&!r.host&&!r.port||r.protocol&&r.protocol==t.protocol&&r.host&&r.host==t.host&&r.host&&i(r)==i(t))}(this.src)){var n=J(this.crossOrigin)?this.canvas:this.crossOrigin;!0===n&&(n=`anonymous`),this.imageAttributes.crossOrigin=n||null}if(this.checkOrientation){var r=(e=this.src,new Promise((function(t){bn(e).then((function(n){var r=Sn(n);t(n?{source:e,arrayBuffer:n,orientation:r}:{source:e,arrayBuffer:null,orientation:null})})).catch((function(n){console.warn(n),t({source:e,arrayBuffer:null,orientation:null})}))})));setTimeout((function(){r.then(t.onParseImage)}),this.transitionTime)}else setTimeout((function(){t.onParseImage({source:t.src})}),this.transitionTime)}else this.clearImage()},onFailLoadImage:function(){this.imageAttributes.src&&(this.clearImage(),this.$emit(`error`))},onSuccessLoadImage:function(){var e=this,t=this.$refs.image;t&&!this.imageLoaded&&(this.imageAttributes.height=t.naturalHeight,this.imageAttributes.width=t.naturalWidth,this.imageLoaded=!0,this.resetVisibleArea().then((function(){e.$emit(`ready`),e.onChange(!1)})))},onParseImage:function(e){var t=this,n=e.source,r=e.arrayBuffer,i=e.orientation;this.imageAttributes.revoke&&this.imageAttributes.src&&URL.revokeObjectURL(this.imageAttributes.src),this.imageAttributes.revoke=!1,r&&i&&i>1?tt(n)||!nt(n)?(this.imageAttributes.src=URL.createObjectURL(new Blob([r])),this.imageAttributes.revoke=!0):this.imageAttributes.src=function(e){for(var t=[],n=new Uint8Array(e);n.length>0;){var r=n.subarray(0,8192);t.push(String.fromCharCode.apply(null,Array.from?Array.from(r):r.slice())),n=n.subarray(8192)}return`data:image/jpeg;base64,`+btoa(t.join(``))}(r):this.imageAttributes.src=n,rt(this.defaultTransforms)?this.appliedImageTransforms=yn(this.defaultTransforms()):it(this.defaultTransforms)?this.appliedImageTransforms=yn(this.defaultTransforms):this.appliedImageTransforms=function(e){var t=yn({});if(e)switch(e){case 2:t.flip.horizontal=!0;break;case 3:t.rotate=-180;break;case 4:t.flip.vertical=!0;break;case 5:t.rotate=90,t.flip.vertical=!0;break;case 6:t.rotate=90;break;case 7:t.rotate=90,t.flip.horizontal=!0;break;case 8:t.rotate=-90}return t}(i),this.defaultImageTransforms=U(U({},this.appliedImageTransforms),{},{flip:U({},this.appliedImageTransforms.flip)}),this.$nextTick((function(){var e=t.$refs.image;e&&e.complete&&(function(e){return!!e.naturalWidth}(e)?t.onSuccessLoadImage():t.onFailLoadImage())}))},onResizeEnd:function(){this.runAutoZoom(`resize`,{transitions:!0})},onMoveEnd:function(){this.runAutoZoom(`move`,{transitions:!0})},onMove:function(e){var t=this;this.transitionsOptions.enabled||this.awaitRender((function(){t.coordinates=t.moveAlgorithm(U(U({},t.getPublicProperties()),{},{positionRestrictions:en(t.positionRestrictions,t.visibleArea),coordinates:t.coordinates,event:t.normalizeEvent(e)})),t.onChange()}))},onResize:function(e){var t=this;this.transitionsOptions.enabled||this.stencilSize&&!this.autoZoom||this.awaitRender((function(){var n=t.sizeRestrictions,r=Math.min(t.coordinates.width,t.coordinates.height,20*t.coefficient);t.coordinates=t.resizeAlgorithm(U(U({},t.getPublicProperties()),{},{positionRestrictions:en(t.positionRestrictions,t.visibleArea),sizeRestrictions:{maxWidth:Math.min(n.maxWidth,t.visibleArea.width),maxHeight:Math.min(n.maxHeight,t.visibleArea.height),minWidth:Math.max(n.minWidth,r),minHeight:Math.max(n.minHeight,r)},event:t.normalizeEvent(e)})),t.onChange(),t.ticking=!1}))},onManipulateImage:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!this.transitionsOptions.enabled){var n=t.transitions,r=n!==void 0&&n,i=t.normalize,a=i===void 0||i;r&&this.enableTransitions();var o=tn(U(U({},this.getPublicProperties()),{},{event:a?this.normalizeEvent(e):e,getAreaRestrictions:this.getAreaRestrictions,imageRestriction:this.imageRestriction,adjustStencil:!this.stencilSize&&this.settings.resizeImage.adjustStencil})),s=o.visibleArea,c=o.coordinates;this.visibleArea=s,this.coordinates=c,this.runAutoZoom(`manipulateImage`),this.onChange(),r&&this.debouncedDisableTransitions()}},onPropsChange:function(){this.coordinates=this.applyTransform(this.coordinates,!0),this.onChange(!1)},getAreaRestrictions:function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=e.visibleArea,n=e.type;return this.areaRestrictionsAlgorithm({boundaries:this.boundaries,imageSize:this.imageSize,imageRestriction:this.imageRestriction,visibleArea:t,type:n===void 0?`move`:n})},getAspectRatio:function(e){var t,n,r=this.stencilProps,i=r.aspectRatio,a=r.minAspectRatio,o=r.maxAspectRatio;if(this.$refs.stencil&&this.$refs.stencil.aspectRatios){var s=this.$refs.stencil.aspectRatios();t=s.minimum,n=s.maximum}if(J(t)&&(t=J(i)?a:i),J(n)&&(n=J(i)?o:i),!e&&(J(t)||J(n))){var c=this.getStencilSize(),l=c?Q(c):null;J(t)&&(t=st(l)?l:void 0),J(n)&&(n=st(l)?l:void 0)}return{minimum:t,maximum:n}},getStencilSize:function(){if(this.stencilSize)return e={currentStencilSize:{width:this.stencilCoordinates.width,height:this.stencilCoordinates.height},stencilSize:this.stencilSize,boundaries:this.boundaries,coefficient:this.coefficient,coordinates:this.coordinates,aspectRatio:this.getAspectRatio(!0)},t=e.boundaries,n=e.stencilSize,r=e.aspectRatio,Nt(Q(i=rt(n)?n({boundaries:t,aspectRatio:r}):n),r)&&(i=Wt({sizeRestrictions:{maxWidth:t.width,maxHeight:t.height,minWidth:0,minHeight:0},width:i.width,height:i.height,aspectRatio:{minimum:r.minimum,maximum:r.maximum}})),(i.width>t.width||i.height>t.height)&&(i=Wt({sizeRestrictions:{maxWidth:t.width,maxHeight:t.height,minWidth:0,minHeight:0},width:i.width,height:i.height,aspectRatio:{minimum:Q(i),maximum:Q(i)}})),i;var e,t,n,r,i},getPublicProperties:function(){return{coefficient:this.coefficient,visibleArea:this.visibleArea,coordinates:this.coordinates,boundaries:this.boundaries,sizeRestrictions:this.sizeRestrictions,positionRestrictions:this.positionRestrictions,aspectRatio:this.getAspectRatio(),imageRestriction:this.imageRestriction}},defaultCoordinates:function(){return U({},wt)},flip:function(e,t){var n=(arguments.length>2&&arguments[2]!==void 0?arguments[2]:{}).transitions,r=n===void 0||n;if(!this.transitionsActive){r&&this.enableTransitions();var i=U({},this.imageTransforms.flip),a=rn({flip:{horizontal:e?!i.horizontal:i.horizontal,vertical:t?!i.vertical:i.vertical},previousFlip:i,rotate:this.imageTransforms.rotate,visibleArea:this.visibleArea,coordinates:this.coordinates,imageSize:this.imageSize,positionRestrictions:this.positionRestrictions,sizeRestrictions:this.sizeRestrictions,getAreaRestrictions:this.getAreaRestrictions,aspectRatio:this.getAspectRatio()}),o=a.visibleArea,s=a.coordinates;e&&(this.appliedImageTransforms.flip.horizontal=!this.appliedImageTransforms.flip.horizontal),t&&(this.appliedImageTransforms.flip.vertical=!this.appliedImageTransforms.flip.vertical),this.visibleArea=o,this.coordinates=s,this.onChange(),r&&this.debouncedDisableTransitions()}},rotate:function(e){var t=(arguments.length>1&&arguments[1]!==void 0?arguments[1]:{}).transitions,n=t===void 0||t;if(!this.transitionsActive){n&&this.enableTransitions();var r=U({},this.imageSize);this.appliedImageTransforms.rotate+=e;var i=nn({visibleArea:this.visibleArea,coordinates:this.coordinates,previousImageSize:r,imageSize:this.imageSize,angle:e,positionRestrictions:this.positionRestrictions,sizeRestrictions:this.sizeRestrictions,getAreaRestrictions:this.getAreaRestrictions,aspectRatio:this.getAspectRatio()}),a=i.visibleArea,o=i.coordinates,s=this.processAutoZoom(`rotateImage`,a,o);a=s.visibleArea,o=s.coordinates,this.visibleArea=a,this.coordinates=o,this.onChange(),n&&this.debouncedDisableTransitions()}}},emits:[`change`,`error`,`ready`]},Rn={key:0,ref:`canvas`,style:{display:`none`}},zn={key:1,ref:`sourceCanvas`,style:{display:`none`}};Ln.render=function(e,t,n,i,a,o){return z(),h(`div`,{ref:`cropper`,class:o.classes.cropper},[p(`div`,{ref:`stretcher`,class:o.classes.stretcher},null,2),p(`div`,{class:o.classes.boundaries,style:o.boundariesStyle},[(z(),h(C(n.backgroundWrapperComponent),{class:o.classes.cropperWrapper,"wheel-resize":o.settings.resizeImage.wheel,"touch-resize":o.settings.resizeImage.touch,"touch-move":o.settings.moveImage.touch,"mouse-move":o.settings.moveImage.mouse,onMove:o.onManipulateImage,onResize:o.onManipulateImage},{default:F((function(){return[p(`div`,{class:o.classes.background,style:o.boundariesStyle},null,6),p(`div`,{class:o.classes.imageWrapper},[p(`img`,{ref:`image`,crossorigin:a.imageAttributes.crossOrigin,src:a.imageAttributes.src,class:o.classes.image,style:o.imageStyle,onMousedown:t[1]||=r((function(){}),[`prevent`])},null,46,[`crossorigin`,`src`])],2),p(`div`,{class:o.classes.foreground,style:o.boundariesStyle},null,6),u((z(),h(C(n.stencilComponent),f({ref:`stencil`,image:o.image,coordinates:a.coordinates,"stencil-coordinates":o.stencilCoordinates,transitions:o.transitionsOptions},n.stencilProps,{onResize:o.onResize,onResizeEnd:o.onResizeEnd,onMove:o.onMove,onMoveEnd:o.onMoveEnd}),null,16,[`image`,`coordinates`,`stencil-coordinates`,`transitions`,`onResize`,`onResizeEnd`,`onMove`,`onMoveEnd`])),[[ye,a.imageLoaded]]),n.canvas?(z(),h(`canvas`,Rn,null,512)):N(``,!0),n.canvas?(z(),h(`canvas`,zn,null,512)):N(``,!0)]})),_:1},8,[`class`,`wheel-resize`,`touch-resize`,`touch-move`,`mouse-move`,`onMove`,`onResize`]))],6)],2)};var Bn=[`data-tpl-theme`],Vn={class:`tpl:shrink-0 tpl:p-5 tpl:pb-4`},Hn={class:`tpl:text-sm tpl:font-semibold`,style:{color:`var(--tpl-text)`}},Un={class:`tpl:min-h-0 tpl:flex-1 tpl:overflow-y-auto tpl:px-5`},Wn={key:0,class:`tpl:mb-4`},Gn={class:`tpl:relative tpl:mb-3 tpl:overflow-hidden tpl:rounded-md tpl:border`,style:{"border-color":`var(--tpl-border)`,height:`300px`,"background-color":`var(--tpl-bg)`}},Kn={class:`tpl:space-y-3`},qn={class:`tpl:mb-1.5 tpl:block tpl:text-xs tpl:font-medium`,style:{color:`var(--tpl-text-muted)`}},Jn={class:`tpl:flex tpl:flex-wrap tpl:gap-1.5`},Yn=[`onClick`],Xn={class:`tpl:flex tpl:gap-3`},Zn={class:`tpl:flex-1`},Qn={class:`tpl:mb-1 tpl:block tpl:text-xs tpl:font-medium`,style:{color:`var(--tpl-text-muted)`}},$n={class:`tpl:font-normal`,style:{color:`var(--tpl-text-dim)`}},er={class:`tpl:relative`},tr=[`value`,`placeholder`],nr={class:`tpl:absolute tpl:top-1/2 tpl:right-2.5 tpl:-translate-y-1/2 tpl:text-xs`,style:{color:`var(--tpl-text-dim)`}},rr={class:`tpl:flex-1`},ir={class:`tpl:mb-1 tpl:block tpl:text-xs tpl:font-medium`,style:{color:`var(--tpl-text-muted)`}},ar={class:`tpl:font-normal`,style:{color:`var(--tpl-text-dim)`}},or={class:`tpl:relative`},sr=[`value`,`placeholder`],cr={class:`tpl:absolute tpl:top-1/2 tpl:right-2.5 tpl:-translate-y-1/2 tpl:text-xs`,style:{color:`var(--tpl-text-dim)`}},lr={key:0,class:`tpl:flex tpl:items-center tpl:gap-1 tpl:text-xs`,style:{color:`var(--tpl-text-muted)`}},ur={class:`tpl:font-medium`,style:{color:`var(--tpl-text)`}},dr={class:`tpl:mb-3`},fr={class:`tpl:mb-1 tpl:block tpl:text-xs tpl:font-medium`,style:{color:`var(--tpl-text-muted)`}},pr=[`autofocus`],mr={key:1,class:`tpl:mb-4`},hr={class:`tpl:mb-1 tpl:block tpl:text-xs tpl:font-medium`,style:{color:`var(--tpl-text-muted)`}},gr=[`placeholder`],_r={class:`tpl:flex tpl:shrink-0 tpl:justify-end tpl:gap-2 tpl:p-5 tpl:pt-4`},vr=[`disabled`],yr=m({__name:`MediaEditModal`,props:{visible:{type:Boolean},item:{}},emits:[`save`,`close`],setup(n,{emit:o}){let c=n,d=o,{t:f}=Pe(),m=l(`tplUiTheme`),g=f.mediaLibrary,{isImageMimeType:_}=ze(),v=e(``),y=e(``),x=e(null),C=e(`free`),w=e(void 0),T=e(void 0),E=e(``),D=e(``),O=e(void 0),A=e(null),te=e(!1),ne=e(!1),re=e(!1),ie=a(()=>c.item?[`image/jpeg`,`image/png`,`image/webp`,`image/gif`].includes(c.item.mime_type):!1),ae=a(()=>C.value===`original`?O.value:Be[C.value]),oe=a(()=>A.value?We(A.value.width,A.value.height,w.value,T.value):null);s(()=>c.visible,e=>{e&&c.item&&(v.value=c.item.filename,y.value=c.item.alt_text||``,C.value=`free`,w.value=void 0,T.value=void 0,E.value=``,D.value=``,O.value=void 0,A.value=null,te.value=!1,re.value=!1,c.item.width&&c.item.height&&(O.value=c.item.width/c.item.height))});function se(e){e.coordinates&&(A.value={width:Math.round(e.coordinates.width),height:Math.round(e.coordinates.height)},re.value=!0)}function ce(){te.value=!0,!O.value&&c.item?.width&&c.item?.height&&(O.value=c.item.width/c.item.height)}function le(e){let t=e.target.value;E.value=t,w.value=t&&parseInt(t,10)||void 0}function ue(e){let t=e.target.value;D.value=t,T.value=t&&parseInt(t,10)||void 0}async function de(){let e=v.value.trim();if(!e||!c.item||ne.value)return;let t=_(c.item.mime_type),n;if(ie.value&&x.value&&re.value){ne.value=!0;try{let{canvas:e}=x.value.getResult();if(e){let t=He(e,w.value,T.value),r=Ve(c.item.mime_type);n={file:await Ue(t,c.item.filename,r)}}}catch{ne.value=!1;return}ne.value=!1}d(`save`,c.item.id,e,t?y.value:void 0,n),d(`close`)}function fe(e){e.key===`Enter`&&!ne.value&&(e.preventDefault(),de()),e.key===`Escape`&&d(`close`)}return(e,a)=>(z(),h(b,{to:`body`},[p(ve,{"enter-active-class":`tpl:transition tpl:ease-out tpl:duration-150`,"enter-from-class":`tpl:opacity-0`,"enter-to-class":`tpl:opacity-100`,"leave-active-class":`tpl:transition tpl:ease-in tpl:duration-100`,"leave-from-class":`tpl:opacity-100`,"leave-to-class":`tpl:opacity-0`},{default:F(()=>[n.visible&&n.item?(z(),t(`div`,{key:0,"data-tpl-theme":j(m),class:`tpl tpl:fixed tpl:inset-0 tpl:z-[10000] tpl:flex tpl:items-center tpl:justify-center`,style:{"background-color":`var(--tpl-overlay)`},onClick:a[3]||=r(e=>d(`close`),[`self`]),onKeydown:fe},[i(`div`,{class:k([`tpl:mx-4 tpl:flex tpl:max-h-[90vh] tpl:w-full tpl:flex-col tpl:overflow-hidden tpl:rounded-lg tpl:shadow-xl`,ie.value?`tpl:max-w-2xl`:`tpl:max-w-sm`]),style:{"background-color":`var(--tpl-bg-elevated)`}},[i(`div`,Vn,[i(`h3`,Hn,L(j(f).mediaLibrary.editFile),1)]),i(`div`,Un,[ie.value?(z(),t(`div`,Wn,[i(`div`,Gn,[p(j(Ln),{ref_key:`cropperRef`,ref:x,src:n.item.url,"stencil-props":{aspectRatio:ae.value},class:`tpl:h-full tpl:w-full`,"background-class":`tpl-cropper-background`,onChange:se,onReady:ce},null,8,[`src`,`stencil-props`])]),i(`div`,Kn,[i(`div`,null,[i(`label`,qn,L(j(f).mediaLibrary.cropAspectRatio),1),i(`div`,Jn,[(z(),t(R,null,S([`free`,`square`,`landscape43`,`landscape169`,`original`],e=>i(`button`,{key:e,type:`button`,class:`tpl:cursor-pointer tpl:rounded-md tpl:border tpl:px-2.5 tpl:py-1 tpl:text-xs tpl:font-medium tpl:transition-all tpl:duration-150`,style:P({borderColor:C.value===e?`var(--tpl-primary)`:`var(--tpl-border)`,backgroundColor:C.value===e?`var(--tpl-primary-light)`:`var(--tpl-bg)`,color:C.value===e?`var(--tpl-primary)`:`var(--tpl-text)`}),onClick:t=>C.value=e},L(j(g)[`crop${e.charAt(0).toUpperCase()}${e.slice(1)}`]),13,Yn)),64))])]),i(`div`,Xn,[i(`div`,Zn,[i(`label`,Qn,[M(L(j(f).mediaLibrary.cropMaxWidth)+` `,1),i(`span`,$n,L(j(f).mediaLibrary.cropOptional),1)]),i(`div`,er,[i(`input`,{value:E.value,type:`number`,min:`1`,class:`tpl:w-full tpl:rounded-md tpl:border tpl:py-1.5 tpl:pr-8 tpl:pl-3 tpl:text-xs tpl:outline-none`,style:{"border-color":`var(--tpl-border)`,"background-color":`var(--tpl-bg)`,color:`var(--tpl-text)`},placeholder:A.value?.width?.toString()||``,onInput:le},null,40,tr),i(`span`,nr,L(j(f).mediaLibrary.cropPixels),1)])]),i(`div`,rr,[i(`label`,ir,[M(L(j(f).mediaLibrary.cropMaxHeight)+` `,1),i(`span`,ar,L(j(f).mediaLibrary.cropOptional),1)]),i(`div`,or,[i(`input`,{value:D.value,type:`number`,min:`1`,class:`tpl:w-full tpl:rounded-md tpl:border tpl:py-1.5 tpl:pr-8 tpl:pl-3 tpl:text-xs tpl:outline-none`,style:{"border-color":`var(--tpl-border)`,"background-color":`var(--tpl-bg)`,color:`var(--tpl-text)`},placeholder:A.value?.height?.toString()||``,onInput:ue},null,40,sr),i(`span`,cr,L(j(f).mediaLibrary.cropPixels),1)])])]),oe.value?(z(),t(`div`,lr,[i(`span`,null,L(j(f).mediaLibrary.cropOutputSize)+`: `,1),i(`span`,ur,L(oe.value.width)+` x `+L(oe.value.height)+` `+L(j(f).mediaLibrary.cropPixels),1)])):N(``,!0)])])):N(``,!0),i(`div`,dr,[i(`label`,fr,L(j(f).mediaLibrary.fileName),1),u(i(`input`,{"onUpdate:modelValue":a[0]||=e=>v.value=e,type:`text`,class:`tpl:w-full tpl:rounded-md tpl:border tpl:px-3 tpl:py-1.5 tpl:text-xs tpl:outline-none`,style:{"border-color":`var(--tpl-border)`,"background-color":`var(--tpl-bg)`,color:`var(--tpl-text)`},autofocus:!ie.value},null,8,pr),[[ee,v.value]])]),j(_)(n.item.mime_type)?(z(),t(`div`,mr,[i(`label`,hr,L(j(f).mediaLibrary.altText),1),u(i(`input`,{"onUpdate:modelValue":a[1]||=e=>y.value=e,type:`text`,class:`tpl:w-full tpl:rounded-md tpl:border tpl:px-3 tpl:py-1.5 tpl:text-xs tpl:outline-none`,style:{"border-color":`var(--tpl-border)`,"background-color":`var(--tpl-bg)`,color:`var(--tpl-text)`},placeholder:j(f).mediaLibrary.altTextPlaceholder},null,8,gr),[[ee,y.value]])])):N(``,!0)]),i(`div`,_r,[i(`button`,{class:`tpl:cursor-pointer tpl:rounded-md tpl:border tpl:px-3 tpl:py-1.5 tpl:text-xs tpl:font-medium tpl:transition-all tpl:duration-150`,style:{"border-color":`var(--tpl-border)`,color:`var(--tpl-text)`,"background-color":`var(--tpl-bg)`},onClick:a[2]||=e=>d(`close`)},L(j(f).mediaLibrary.cancel),1),i(`button`,{class:`tpl:cursor-pointer tpl:rounded-md tpl:px-3 tpl:py-1.5 tpl:text-xs tpl:font-medium tpl:text-white tpl:transition-all tpl:duration-150 tpl:disabled:cursor-not-allowed tpl:disabled:opacity-50`,style:{background:`linear-gradient(
5
+ 135deg,
6
+ var(--tpl-primary),
7
+ var(--tpl-primary-hover)
8
+ )`},disabled:ne.value,onClick:de},L(ne.value?j(f).mediaLibrary.saving:j(f).mediaLibrary.saveChanges),9,vr)])],2)],40,Bn)):N(``,!0)]),_:1})]))}}),br=(e,t)=>{let n=e.__vccOpts||e;for(let[e,r]of t)n[e]=r;return n},xr=br(yr,[[`__scopeId`,`data-v-bd5f2e31`]]),Sr={key:1,class:`tpl:size-4 tpl:shrink-0`},Cr={key:0,class:`tpl:truncate`},wr={key:3,class:`tpl:flex tpl:shrink-0 tpl:items-center tpl:gap-0.5 tpl:opacity-0 tpl:transition-opacity tpl:group-hover:opacity-100`},Tr=[`title`],Er=[`title`],Dr={key:0},Or=[`placeholder`],kr=5,Ar=m({__name:`MediaFolderTreeNode`,props:{folder:{},currentFolderId:{},depth:{}},emits:[`navigate`,`createFolder`,`renameFolder`,`deleteFolder`],setup(n,{emit:o}){let s=n,c=o,{t:l}=Pe(),d=e(!1),f=e(!1),m=e(``),g=e(!1),_=e(``),v=a(()=>(s.folder.children?.length??0)>0),b=a(()=>s.depth<kr-1),C=a(()=>s.currentFolderId===s.folder.id),w=a(()=>!s.currentFolderId||!s.folder.children?!1:E(s.folder.children,s.currentFolderId)),T=a(()=>d.value||w.value);function E(e,t){for(let n of e)if(n.id===t||n.children&&E(n.children,t))return!0;return!1}function D(){d.value=!d.value}function O(){f.value=!0,m.value=s.folder.name}function A(){let e=m.value.trim();e&&e!==s.folder.name&&c(`renameFolder`,s.folder.id,e),f.value=!1,m.value=``}function te(){f.value=!1,m.value=``}function ne(){g.value=!0,_.value=``,d.value=!0}function re(){_.value.trim()&&c(`createFolder`,_.value.trim(),s.folder.id),g.value=!1,_.value=``}function ae(){g.value=!1,_.value=``}return(e,a)=>{let o=x(`MediaFolderTreeNode`,!0);return z(),t(`div`,null,[i(`div`,{class:`tpl:group tpl:flex tpl:w-full tpl:items-center tpl:gap-1 tpl:py-1.5 tpl:pr-2 tpl:text-left tpl:text-xs tpl:transition-all tpl:duration-150`,style:P({paddingLeft:`${n.depth*16+8}px`,backgroundColor:C.value?`var(--tpl-bg-active)`:`transparent`,color:C.value?`var(--tpl-primary)`:`var(--tpl-text)`})},[v.value||g.value?(z(),t(`button`,{key:0,class:`tpl:flex tpl:size-4 tpl:shrink-0 tpl:items-center tpl:justify-center tpl:rounded tpl:transition-colors`,onClick:r(D,[`stop`])},[p(j(ie),{class:k([`tpl:transition-transform tpl:duration-150`,{"tpl:rotate-90":T.value}]),size:10,"stroke-width":2},null,8,[`class`])])):(z(),t(`span`,Sr)),i(`button`,{class:`tpl:flex tpl:min-w-0 tpl:flex-1 tpl:items-center tpl:gap-1.5`,onClick:a[0]||=e=>c(`navigate`,n.folder.id)},[p(j(fe),{class:`tpl:shrink-0`,size:14,"stroke-width":1.5}),f.value?N(``,!0):(z(),t(`span`,Cr,L(n.folder.name),1))]),f.value?u((z(),t(`input`,{key:2,"onUpdate:modelValue":a[1]||=e=>m.value=e,type:`text`,class:`tpl:min-w-0 tpl:flex-1 tpl:rounded tpl:border tpl:px-1.5 tpl:py-0.5 tpl:text-xs tpl:outline-none`,style:{"border-color":`var(--tpl-primary)`,"background-color":`var(--tpl-bg)`,color:`var(--tpl-text)`},autofocus:``,onKeydown:[y(A,[`enter`]),y(te,[`escape`])],onBlur:A,onClick:a[2]||=r(()=>{},[`stop`])},null,544)),[[ee,m.value]]):N(``,!0),f.value?N(``,!0):(z(),t(`span`,wr,[b.value?(z(),t(`button`,{key:0,class:`tpl:flex tpl:size-6 tpl:items-center tpl:justify-center tpl:rounded tpl:transition-colors`,title:j(l).mediaLibrary.addSubfolder,onClick:r(ne,[`stop`])},[p(j(de),{size:12,"stroke-width":2})],8,Tr)):N(``,!0),i(`button`,{class:`tpl:flex tpl:size-6 tpl:items-center tpl:justify-center tpl:rounded tpl:transition-colors`,title:j(l).mediaLibrary.renameFolder,onClick:r(O,[`stop`])},[p(j(me),{size:12,"stroke-width":2})],8,Er),i(`button`,{class:`tpl:flex tpl:size-6 tpl:items-center tpl:justify-center tpl:rounded tpl:transition-colors`,onClick:a[3]||=r(e=>c(`deleteFolder`,n.folder.id),[`stop`])},[p(j(le),{size:12,"stroke-width":2,style:{color:`var(--tpl-danger)`}})])]))],4),T.value?(z(),t(`div`,Dr,[(z(!0),t(R,null,S(n.folder.children,e=>(z(),h(o,{key:e.id,folder:e,"current-folder-id":n.currentFolderId,depth:n.depth+1,onNavigate:a[4]||=e=>c(`navigate`,e),onCreateFolder:a[5]||=(e,t)=>c(`createFolder`,e,t),onRenameFolder:a[6]||=(e,t)=>c(`renameFolder`,e,t),onDeleteFolder:a[7]||=e=>c(`deleteFolder`,e)},null,8,[`folder`,`current-folder-id`,`depth`]))),128)),g.value?(z(),t(`div`,{key:0,style:P({paddingLeft:`${(n.depth+1)*16+8}px`}),class:`tpl:py-1.5 tpl:pr-2`},[u(i(`input`,{"onUpdate:modelValue":a[8]||=e=>_.value=e,type:`text`,class:`tpl:w-full tpl:rounded tpl:border tpl:px-2 tpl:py-1 tpl:text-xs tpl:outline-none`,style:{"border-color":`var(--tpl-primary)`,"background-color":`var(--tpl-bg)`,color:`var(--tpl-text)`},placeholder:j(l).mediaLibrary.subfolderName,autofocus:``,onKeydown:[y(re,[`enter`]),y(ae,[`escape`])],onBlur:re},null,40,Or),[[ee,_.value]])],4)):N(``,!0)])):N(``,!0)])}}}),jr={class:`tpl:flex tpl:h-full tpl:flex-col tpl:overflow-y-auto`},Mr={key:0,class:`tpl:px-3 tpl:py-2`},Nr=[`placeholder`],Pr=m({__name:`MediaFolderTree`,props:{folders:{},currentFolderId:{},viewMode:{},hasFrequentlyUsed:{type:Boolean}},emits:[`navigate`,`createFolder`,`renameFolder`,`deleteFolder`,`showFrequentlyUsed`],setup(n,{emit:r}){let a=r,{t:o}=Pe(),s=e(!1),c=e(``);function l(){s.value=!0,c.value=``}function d(){c.value.trim()&&a(`createFolder`,c.value.trim()),s.value=!1,c.value=``}function f(){s.value=!1,c.value=``}return(e,r)=>(z(),t(`div`,jr,[i(`button`,{class:`tpl:flex tpl:w-full tpl:items-center tpl:gap-2 tpl:px-3 tpl:py-2 tpl:text-left tpl:text-xs tpl:font-medium tpl:transition-all tpl:duration-150`,style:P({backgroundColor:n.viewMode===`files`&&n.currentFolderId===null?`var(--tpl-bg-active)`:`transparent`,color:n.viewMode===`files`&&n.currentFolderId===null?`var(--tpl-primary)`:`var(--tpl-text)`}),onClick:r[0]||=e=>a(`navigate`,null)},[p(j(ce),{size:14,"stroke-width":1.5}),M(` `+L(j(o).mediaLibrary.allFiles),1)],4),(z(!0),t(R,null,S(n.folders,e=>(z(),h(Ar,{key:e.id,folder:e,"current-folder-id":n.currentFolderId,depth:0,onNavigate:r[1]||=e=>a(`navigate`,e),onCreateFolder:r[2]||=(e,t)=>a(`createFolder`,e,t),onRenameFolder:r[3]||=(e,t)=>a(`renameFolder`,e,t),onDeleteFolder:r[4]||=e=>a(`deleteFolder`,e)},null,8,[`folder`,`current-folder-id`]))),128)),s.value?(z(),t(`div`,Mr,[u(i(`input`,{"onUpdate:modelValue":r[5]||=e=>c.value=e,type:`text`,class:`tpl:w-full tpl:rounded tpl:border tpl:px-2 tpl:py-1 tpl:text-xs tpl:outline-none`,style:{"border-color":`var(--tpl-primary)`,"background-color":`var(--tpl-bg)`,color:`var(--tpl-text)`},placeholder:j(o).mediaLibrary.folderName,autofocus:``,onKeydown:[y(d,[`enter`]),y(f,[`escape`])],onBlur:d},null,40,Nr),[[ee,c.value]])])):N(``,!0),s.value?N(``,!0):(z(),t(`button`,{key:1,class:`tpl:flex tpl:w-full tpl:items-center tpl:gap-2 tpl:px-3 tpl:py-2 tpl:text-left tpl:text-xs tpl:transition-all tpl:duration-150`,style:{color:`var(--tpl-text-muted)`},onClick:l},[p(j(de),{size:14,"stroke-width":1.5}),M(` `+L(j(o).mediaLibrary.newFolder),1)])),r[7]||=i(`div`,{class:`tpl:flex-1`},null,-1),n.hasFrequentlyUsed?(z(),t(`button`,{key:2,class:`tpl:flex tpl:w-full tpl:items-center tpl:gap-2 tpl:border-t tpl:px-3 tpl:py-2 tpl:text-left tpl:text-xs tpl:font-medium tpl:transition-all tpl:duration-150`,style:P({borderColor:`var(--tpl-border)`,backgroundColor:n.viewMode===`frequently-used`?`var(--tpl-bg-active)`:`transparent`,color:n.viewMode===`frequently-used`?`var(--tpl-primary)`:`var(--tpl-text)`}),onClick:r[6]||=e=>a(`showFrequentlyUsed`)},[p(j(pe),{size:14,"stroke-width":1.5}),M(` `+L(j(o).mediaLibrary.frequentlyUsed),1)],4)):N(``,!0)]))}}),Fr={class:`tpl:flex tpl:aspect-square tpl:flex-col tpl:items-center tpl:justify-center tpl:gap-2`},Ir=m({__name:`MediaFileIcon`,props:{mimeType:{}},setup(e){let n=e,r={"application/pdf":{label:`PDF`,color:`#dc2626`,bgColor:`#fef2f2`,icon:`document`},"application/vnd.openxmlformats-officedocument.wordprocessingml.document":{label:`DOC`,color:`#2563eb`,bgColor:`#eff6ff`,icon:`document`},"application/msword":{label:`DOC`,color:`#2563eb`,bgColor:`#eff6ff`,icon:`document`},"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":{label:`XLS`,color:`#16a34a`,bgColor:`#f0fdf4`,icon:`document`},"application/vnd.ms-excel":{label:`XLS`,color:`#16a34a`,bgColor:`#f0fdf4`,icon:`document`},"application/vnd.openxmlformats-officedocument.presentationml.presentation":{label:`PPT`,color:`#ea580c`,bgColor:`#fff7ed`,icon:`document`},"application/vnd.ms-powerpoint":{label:`PPT`,color:`#ea580c`,bgColor:`#fff7ed`,icon:`document`},"text/csv":{label:`CSV`,color:`#16a34a`,bgColor:`#f0fdf4`,icon:`document`},"text/plain":{label:`TXT`,color:`#6b7280`,bgColor:`#f9fafb`,icon:`document`},"video/mp4":{label:`MP4`,color:`#9333ea`,bgColor:`#faf5ff`,icon:`video`},"video/quicktime":{label:`MOV`,color:`#9333ea`,bgColor:`#faf5ff`,icon:`video`},"video/webm":{label:`WEBM`,color:`#9333ea`,bgColor:`#faf5ff`,icon:`video`},"audio/mpeg":{label:`MP3`,color:`#0d9488`,bgColor:`#f0fdfa`,icon:`audio`},"audio/wav":{label:`WAV`,color:`#0d9488`,bgColor:`#f0fdfa`,icon:`audio`},"audio/ogg":{label:`OGG`,color:`#0d9488`,bgColor:`#f0fdfa`,icon:`audio`}},o={label:`FILE`,color:`#6b7280`,bgColor:`#f9fafb`,icon:`document`},s=a(()=>r[n.mimeType]??o);return(e,n)=>(z(),t(`div`,Fr,[s.value.icon===`document`?(z(),t(`svg`,{key:0,width:`60`,height:`60`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`1.5`,style:P({color:s.value.color})},[...n[0]||=[i(`path`,{d:`M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z`},null,-1),i(`polyline`,{points:`14 2 14 8 20 8`},null,-1),i(`line`,{x1:`8`,y1:`13`,x2:`16`,y2:`13`},null,-1),i(`line`,{x1:`8`,y1:`17`,x2:`12`,y2:`17`},null,-1)]],4)):s.value.icon===`video`?(z(),t(`svg`,{key:1,width:`40`,height:`40`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`1.5`,style:P({color:s.value.color})},[...n[1]||=[i(`rect`,{x:`2`,y:`4`,width:`20`,height:`16`,rx:`2`},null,-1),i(`polygon`,{points:`10,8 16,12 10,16`,fill:`currentColor`,stroke:`none`},null,-1)]],4)):(z(),t(`svg`,{key:2,width:`40`,height:`40`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`1.5`,style:P({color:s.value.color})},[...n[2]||=[i(`path`,{d:`M9 18V5l12-2v13`},null,-1),i(`circle`,{cx:`6`,cy:`18`,r:`3`},null,-1),i(`circle`,{cx:`18`,cy:`16`,r:`3`},null,-1)]],4)),i(`span`,{class:`tpl:text-xs tpl:font-bold tpl:tracking-wider`,style:P({color:s.value.color})},L(s.value.label),5)]))}});function Lr(e,t){return T()?(E(e,t),!0):!1}function Rr(){let e=new Set,t=t=>{e.delete(t)};return{on:n=>{e.add(n);let r=()=>t(n);return Lr(r),{off:r}},off:t,trigger:(...t)=>Promise.all(Array.from(e).map(e=>e(...t))),clear:()=>{e.clear()}}}var zr=typeof window<`u`&&typeof document<`u`;typeof WorkerGlobalScope<`u`&&globalThis instanceof WorkerGlobalScope;var Br=e=>e!=null,Vr=Object.prototype.toString,Hr=e=>Vr.call(e)===`[object Object]`,Ur=()=>{},Wr=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),Gr=Kr();function Kr(){var e,t;return zr&&!!(!((e=window)==null||(e=e.navigator)==null)&&e.userAgent)&&(/iP(?:ad|hone|od)/.test(window.navigator.userAgent)||((t=window)==null||(t=t.navigator)==null?void 0:t.maxTouchPoints)>2&&/iPad|Macintosh/.test(window?.navigator.userAgent))}function qr(e,t){function n(...n){return new Promise((r,i)=>{Promise.resolve(e(()=>t.apply(this,n),{fn:t,thisArg:this,args:n})).then(r).catch(i)})}return n}function Jr(e,t={}){let n,r,i=Ur,a=e=>{clearTimeout(e),i(),i=Ur},o;return s=>{let c=I(e),l=I(t.maxWait);return n&&a(n),c<=0||l!==void 0&&l<=0?(r&&=(a(r),void 0),Promise.resolve(s())):new Promise((e,u)=>{i=t.rejectOnCancel?u:e,o=s,l&&!r&&(r=setTimeout(()=>{n&&a(n),r=void 0,e(o())},l)),n=setTimeout(()=>{r&&a(r),r=void 0,e(s())},c)})}}function Yr(e){let t;function n(){return t||=e(),t}return n.reset=async()=>{let e=t;t=void 0,e&&await e},n}function Xr(e){return Array.isArray(e)?e:[e]}function Zr(e,t=200,n={}){return qr(Jr(t,n),e)}function Qr(e,t,n={}){let{immediate:r=!0,immediateCallback:i=!1}=n,a=ge(!1),o;function s(){o&&=(clearTimeout(o),void 0)}function c(){a.value=!1,s()}function l(...n){i&&e(),s(),a.value=!0,o=setTimeout(()=>{a.value=!1,o=void 0,e(...n)},I(t))}return r&&(a.value=!0,zr&&l()),Lr(c),{isPending:ne(a),start:l,stop:c}}function $r(e,t,n){return s(e,t,{...n,immediate:!0})}var ei=zr?window:void 0,ti=zr?window.document:void 0,ni=zr?window.navigator:void 0;function ri(e){let t=I(e);return t?.$el??t}function ii(...e){let t=(e,t,n,r)=>(e.addEventListener(t,n,r),()=>e.removeEventListener(t,n,r)),n=a(()=>{let t=Xr(I(e[0])).filter(e=>e!=null);return t.every(e=>typeof e!=`string`)?t:void 0});return $r(()=>[n.value?.map(e=>ri(e))??[ei].filter(e=>e!=null),Xr(I(n.value?e[1]:e[0])),Xr(j(n.value?e[2]:e[1])),I(n.value?e[3]:e[2])],([e,n,r,i],a,o)=>{if(!e?.length||!n?.length||!r?.length)return;let s=Hr(i)?{...i}:i,c=e.flatMap(e=>n.flatMap(n=>r.map(r=>t(e,n,r,s))));o(()=>{c.forEach(e=>e())})},{flush:`post`})}var ai=!1;function oi(e,t,n={}){let{window:r=ei,ignore:i=[],capture:a=!0,detectIframe:o=!1,controls:s=!1}=n;if(!r)return s?{stop:Ur,cancel:Ur,trigger:Ur}:Ur;if(Gr&&!ai){ai=!0;let e={passive:!0};Array.from(r.document.body.children).forEach(t=>t.addEventListener(`click`,Ur,e)),r.document.documentElement.addEventListener(`click`,Ur,e)}let c=!0,l=e=>I(i).some(t=>{if(typeof t==`string`)return Array.from(r.document.querySelectorAll(t)).some(t=>t===e.target||e.composedPath().includes(t));{let n=ri(t);return n&&(e.target===n||e.composedPath().includes(n))}});function u(e){let t=I(e);return t&&t.$.subTree.shapeFlag===16}function d(e,t){let n=I(e),r=n.$.subTree&&n.$.subTree.children;return r==null||!Array.isArray(r)?!1:r.some(e=>e.el===t.target||t.composedPath().includes(e.el))}let f=n=>{let r=ri(e);if(n.target!=null&&!(!(r instanceof Element)&&u(e)&&d(e,n))&&!(!r||r===n.target||n.composedPath().includes(r))){if(`detail`in n&&n.detail===0&&(c=!l(n)),!c){c=!0;return}t(n)}},p=!1,m=[ii(r,`click`,e=>{p||(p=!0,setTimeout(()=>{p=!1},0),f(e))},{passive:!0,capture:a}),ii(r,`pointerdown`,t=>{let n=ri(e);c=!l(t)&&!!(n&&!t.composedPath().includes(n))},{passive:!0}),o&&ii(r,`blur`,n=>{setTimeout(()=>{let i=ri(e);r.document.activeElement?.tagName===`IFRAME`&&!i?.contains(r.document.activeElement)&&t(n)},0)},{passive:!0})].filter(Boolean),h=()=>m.forEach(e=>e());return s?{stop:h,cancel:()=>{c=!1},trigger:e=>{c=!0,f(e),c=!1}}:h}function si(){let e=ge(!1),t=g();return t&&v(()=>{e.value=!0},t),e}function ci(e){return si(),a(()=>!!e())}function li(e,t={}){let{controls:n=!1,navigator:r=ni}=t,i=ci(()=>r&&`permissions`in r),a=ge(),o=typeof e==`string`?{name:e}:e,s=ge(),c=()=>{s.value=a.value?.state??`prompt`};ii(a,`change`,c,{passive:!0});let l=Yr(async()=>{if(i.value){if(!a.value)try{a.value=await r.permissions.query(o)}catch{a.value=void 0}finally{c()}if(n)return ue(a.value)}});return l(),n?{state:s,isSupported:i,query:l}:s}function ui(e={}){let{navigator:t=ni,read:n=!1,source:r,copiedDuring:i=1500,legacy:o=!1}=e,s=ci(()=>t&&`clipboard`in t),c=li(`clipboard-read`),l=li(`clipboard-write`),u=a(()=>s.value||o),d=ge(``),f=ge(!1),p=Qr(()=>f.value=!1,i,{immediate:!1});async function m(){let e=!(s.value&&y(c.value));if(!e)try{d.value=await t.clipboard.readText()}catch{e=!0}e&&(d.value=v())}u.value&&n&&ii([`copy`,`cut`],m,{passive:!0});async function h(e=I(r)){if(u.value&&e!=null){let n=!(s.value&&y(l.value));if(!n)try{await t.clipboard.writeText(e)}catch{n=!0}n&&g(e),d.value=e,f.value=!0,p.start()}}function g(e){let t=document.createElement(`textarea`);t.value=e,t.style.position=`absolute`,t.style.opacity=`0`,t.setAttribute(`readonly`,``),document.body.appendChild(t),t.select(),document.execCommand(`copy`),t.remove()}function v(){var e,t;return((e=document)==null||(t=e.getSelection)==null||(t=t.call(e))==null?void 0:t.toString())??``}function y(e){return e===`granted`||e===`prompt`}return{isSupported:u,text:_(d),copied:_(f),copy:h}}function di(e,t={}){let n=ge(!1),r=ge(null),i=0,a=!0;if(zr){let o=typeof t==`function`?{onDrop:t}:t,s=o.multiple??!0,c=o.preventDefaultForUnhandled??!1,l=e=>{let t=Array.from(e.dataTransfer?.files??[]);return t.length===0?null:s?t:[t[0]]},u=e=>{let t=j(o.dataTypes);return typeof t==`function`?t(e):t?.length?e.length===0?!1:e.every(e=>t.some(t=>e.includes(t))):!0},d=e=>o.checkValidity?o.checkValidity(e):u(Array.from(e??[]).map(e=>e.type))&&(s||e.length<=1),f=()=>/^(?:(?!chrome|android).)*safari/i.test(navigator.userAgent)&&!(`chrome`in window),p=(e,t)=>{let s=e.dataTransfer?.items;if(a=(s&&d(s))??!1,c&&e.preventDefault(),!f()&&!a){e.dataTransfer&&(e.dataTransfer.dropEffect=`none`);return}e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect=`copy`);let u=l(e);switch(t){case`enter`:var p;i+=1,n.value=!0,(p=o.onEnter)==null||p.call(o,null,e);break;case`over`:var m;(m=o.onOver)==null||m.call(o,null,e);break;case`leave`:var h;--i,i===0&&(n.value=!1),(h=o.onLeave)==null||h.call(o,null,e);break;case`drop`:if(i=0,n.value=!1,a){var g;r.value=u,(g=o.onDrop)==null||g.call(o,u,e)}break}};ii(e,`dragenter`,e=>p(e,`enter`)),ii(e,`dragover`,e=>p(e,`over`)),ii(e,`dragleave`,e=>p(e,`leave`)),ii(e,`drop`,e=>p(e,`drop`))}return{files:r,isOverDropZone:n}}function fi(e,t,n={}){let{root:r,rootMargin:i,threshold:o=0,window:c=ei,immediate:l=!0}=n,u=ci(()=>c&&`IntersectionObserver`in c),d=a(()=>Xr(I(e)).map(ri).filter(Br)),f=Ur,p=ge(l),m=u.value?s(()=>[d.value,ri(r),I(i),p.value],([e,n,r])=>{if(f(),!p.value||!e.length)return;let i=new IntersectionObserver(t,{root:ri(n),rootMargin:r,threshold:o});e.forEach(e=>e&&i.observe(e)),f=()=>{i.disconnect(),f=Ur}},{immediate:l,flush:`post`}):Ur,h=()=>{f(),m(),p.value=!1};return Lr(h),{isSupported:u,isActive:p,pause(){f(),p.value=!1},resume(){p.value=!0},stop:h}}var pi={multiple:!0,accept:`*`,reset:!1,directory:!1};function mi(e){if(!e)return null;if(e instanceof FileList)return e;let t=new DataTransfer;for(let n of e)t.items.add(n);return t.files}function hi(t={}){let{document:n=ti}=t,r=e(mi(t.initialFiles)),{on:i,trigger:o}=Rr(),{on:s,trigger:c}=Rr(),l=a(()=>{let e=ri(t.input)??(n?n.createElement(`input`):void 0);return e&&(e.type=`file`,e.onchange=e=>{r.value=e.target.files,o(r.value)},e.oncancel=()=>{c()}),e}),u=()=>{r.value=null,l.value&&l.value.value&&(l.value.value=``,o(null))},f=e=>{let t=l.value;t&&(t.multiple=I(e.multiple),t.accept=I(e.accept),t.webkitdirectory=I(e.directory),Wr(e,`capture`)&&(t.capture=I(e.capture)))};return d(()=>{f(t)}),{files:_(r),open:e=>{let n=l.value;if(!n)return;let r={...pi,...t,...e};f(r),I(r.reset)&&u(),n.click()},reset:u,onCancel:s,onChange:i}}var gi={class:`tpl:p-4`},_i={key:1,class:`tpl:flex tpl:flex-col tpl:items-center tpl:justify-center tpl:py-16`},vi={class:`tpl:text-xs`,style:{color:`var(--tpl-text-muted)`}},yi={key:2,class:`tpl:grid tpl:grid-cols-4 tpl:gap-3`},bi=[`onClick`],xi={class:`tpl:aspect-square`},Si=[`src`,`alt`],Ci={class:`tpl:px-2 tpl:py-1.5`},wi={class:`tpl:truncate tpl:text-[10px] tpl:font-medium`,style:{color:`var(--tpl-text)`}},Ti={class:`tpl:flex tpl:justify-between tpl:text-[9px]`,style:{color:`var(--tpl-text-muted)`}},Ei={key:0},Di={class:`tpl:absolute tpl:top-1.5 tpl:left-1.5 tpl:flex tpl:gap-1 tpl:opacity-0 tpl:transition-opacity tpl:duration-150 tpl:group-hover:opacity-100`},Oi=[`title`,`onClick`],ki=[`title`,`onClick`],Ai={key:0,class:`tpl:absolute tpl:top-1.5 tpl:right-1.5 tpl:flex tpl:size-5 tpl:items-center tpl:justify-center tpl:rounded-full tpl:text-white`,style:{"background-color":`var(--tpl-primary)`}},ji={key:3,class:`tpl:flex tpl:flex-col tpl:gap-1`},Mi=[`onClick`],Ni={class:`tpl:size-10 tpl:shrink-0 tpl:overflow-hidden tpl:rounded`,style:{"background-color":`var(--tpl-bg-hover)`}},Pi=[`src`,`alt`],Fi={key:1,class:`tpl-list-icon tpl:size-full`},Ii={class:`tpl:min-w-0 tpl:flex-1`},Li={class:`tpl:truncate tpl:text-xs tpl:font-medium`,style:{color:`var(--tpl-text)`}},Ri={class:`tpl:text-[10px]`,style:{color:`var(--tpl-text-muted)`}},zi={class:`tpl:flex tpl:gap-1 tpl:opacity-0 tpl:transition-opacity tpl:duration-150 tpl:group-hover:opacity-100`},Bi=[`title`,`onClick`],Vi=[`title`,`onClick`],Hi={key:0,class:`tpl:flex tpl:size-5 tpl:shrink-0 tpl:items-center tpl:justify-center tpl:rounded-full tpl:text-white`,style:{"background-color":`var(--tpl-primary)`}},Ui={key:4,class:`tpl:flex tpl:justify-center tpl:py-4`},Wi=br(m({__name:`MediaGrid`,props:{items:{},selectedIds:{},isLoading:{type:Boolean},hasMore:{type:Boolean},accept:{},layout:{}},emits:[`select`,`toggle`,`loadMore`,`edit`,`replace`],setup(n,{emit:a}){let o=n,s=a,{isAcceptedMimeType:c,isImageMimeType:l}=ze();function u(e){return!o.accept||o.accept.length===0?!0:c(e.mime_type,o.accept)}function d(e){s(`select`,e)}let{t:f}=Pe(),m=e(null);fi(m,([{isIntersecting:e}])=>{e&&o.hasMore&&!o.isLoading&&s(`loadMore`)},{threshold:.1});function g(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function _(e){return new Date(e).toLocaleDateString(void 0,{year:`numeric`,month:`short`,day:`numeric`})}return(e,a)=>(z(),t(`div`,gi,[n.isLoading&&n.items.length===0?(z(),t(`div`,{key:0,class:k(n.layout===`list`?`tpl:flex tpl:flex-col tpl:gap-1`:`tpl:grid tpl:grid-cols-4 tpl:gap-3`)},[(z(),t(R,null,S(8,e=>i(`div`,{key:e,class:k([`tpl-pulse tpl:rounded-lg`,n.layout===`list`?`tpl:h-12`:`tpl:aspect-square`]),style:{"background-color":`var(--tpl-bg-hover)`}},null,2)),64))],2)):n.items.length===0?(z(),t(`div`,_i,[p(j(ce),{class:`tpl:mb-3`,size:40,"stroke-width":1,style:{color:`var(--tpl-text-dim)`}}),i(`p`,vi,L(j(f).mediaLibrary.noFiles),1)])):n.layout===`list`?(z(),t(`div`,ji,[(z(!0),t(R,null,S(n.items,e=>(z(),t(`div`,{key:e.id,class:k([`tpl-media-list-item tpl:group tpl:flex tpl:cursor-pointer tpl:items-center tpl:gap-3 tpl:rounded-lg tpl:px-3 tpl:py-2 tpl:transition-all tpl:duration-150`,[!u(e)&&!n.selectedIds.has(e.id)?`tpl:opacity-60`:``]]),style:P({backgroundColor:n.selectedIds.has(e.id)?`var(--tpl-bg-hover)`:`transparent`}),onClick:t=>d(e)},[i(`div`,Ni,[j(l)(e.mime_type)?(z(),t(`img`,{key:0,src:e.small_url||e.url,alt:e.filename,class:`tpl:size-full tpl:object-cover`,loading:`lazy`},null,8,Pi)):(z(),t(`div`,Fi,[p(Ir,{"mime-type":e.mime_type},null,8,[`mime-type`])]))]),i(`div`,Ii,[i(`p`,Li,L(e.filename),1),i(`p`,Ri,[M(L(g(e.size))+` · `+L(_(e.created_at))+` `,1),j(l)(e.mime_type)&&e.width&&e.height?(z(),t(R,{key:0},[M(` · `+L(e.width)+`×`+L(e.height),1)],64)):N(``,!0)])]),i(`div`,zi,[i(`button`,{class:`tpl:flex tpl:size-6 tpl:shrink-0 tpl:cursor-pointer tpl:items-center tpl:justify-center tpl:rounded`,style:{color:`var(--tpl-text-muted)`},title:j(f).mediaLibrary.editFile,onClick:r(t=>s(`edit`,e),[`stop`])},[p(j(me),{size:12,"stroke-width":2})],8,Bi),i(`button`,{class:`tpl:flex tpl:size-6 tpl:shrink-0 tpl:cursor-pointer tpl:items-center tpl:justify-center tpl:rounded`,style:{color:`var(--tpl-text-muted)`},title:j(f).mediaLibrary.replaceFile,onClick:r(t=>s(`replace`,e),[`stop`])},[p(j(O),{size:12,"stroke-width":2})],8,Vi)]),n.selectedIds.has(e.id)?(z(),t(`div`,Hi,[p(j(D),{size:12,"stroke-width":3})])):N(``,!0)],14,Mi))),128))])):(z(),t(`div`,yi,[(z(!0),t(R,null,S(n.items,e=>(z(),t(`div`,{key:e.id,class:k([`tpl-media-item tpl:group tpl:relative tpl:overflow-hidden tpl:rounded-lg tpl:border-2 tpl:transition-all tpl:duration-150`,[`tpl:cursor-pointer`,!u(e)&&!n.selectedIds.has(e.id)?`tpl:opacity-60`:``,n.selectedIds.has(e.id)?`tpl-media-item--selected`:``]]),style:P({borderColor:n.selectedIds.has(e.id)?`var(--tpl-primary)`:`transparent`,backgroundColor:!u(e)&&!n.selectedIds.has(e.id)?`var(--tpl-bg)`:`var(--tpl-bg-hover)`}),onClick:t=>d(e)},[i(`div`,xi,[j(l)(e.mime_type)?(z(),t(`img`,{key:0,src:e.small_url||e.url,alt:e.filename,class:`tpl:size-full tpl:object-cover`,loading:`lazy`},null,8,Si)):(z(),h(Ir,{key:1,"mime-type":e.mime_type},null,8,[`mime-type`]))]),i(`div`,Ci,[i(`p`,wi,L(e.filename),1),i(`p`,Ti,[i(`span`,null,L(g(e.size)),1),j(l)(e.mime_type)&&e.width&&e.height?(z(),t(`span`,Ei,L(e.width)+`×`+L(e.height),1)):N(``,!0)])]),i(`div`,Di,[i(`button`,{class:`tpl:flex tpl:size-6 tpl:items-center tpl:justify-center tpl:rounded-full tpl:text-white`,style:{"background-color":`rgba(0, 0, 0, 0.6)`},title:j(f).mediaLibrary.editFile,onClick:r(t=>s(`edit`,e),[`stop`])},[p(j(me),{size:11,"stroke-width":2})],8,Oi),i(`button`,{class:`tpl:flex tpl:size-6 tpl:items-center tpl:justify-center tpl:rounded-full tpl:text-white`,style:{"background-color":`rgba(0, 0, 0, 0.6)`},title:j(f).mediaLibrary.replaceFile,onClick:r(t=>s(`replace`,e),[`stop`])},[p(j(O),{size:11,"stroke-width":2})],8,ki)]),n.selectedIds.has(e.id)?(z(),t(`div`,Ai,[p(j(D),{size:12,"stroke-width":3})])):N(``,!0)],14,bi))),128))])),i(`div`,{ref_key:`sentinelRef`,ref:m,class:`tpl:h-4`},null,512),n.isLoading&&n.items.length>0?(z(),t(`div`,Ui,[p(j(se),{class:`tpl-spinner`,size:20,"stroke-width":2,style:{color:`var(--tpl-primary)`}})])):N(``,!0)]))}}),[[`__scopeId`,`data-v-9db961d1`]]),Gi=[`data-tpl-theme`],Ki={class:`tpl:mx-4 tpl:w-full tpl:max-w-sm tpl:rounded-lg tpl:p-5 tpl:shadow-xl`,style:{"background-color":`var(--tpl-bg-elevated)`}},qi={class:`tpl:mb-4 tpl:text-sm tpl:font-semibold`,style:{color:`var(--tpl-text)`}},Ji={class:`tpl:mb-3`},Yi=[`placeholder`,`disabled`],Xi={key:0,class:`tpl:mb-3 tpl:text-xs`,style:{color:`var(--tpl-danger)`}},Zi={class:`tpl:flex tpl:justify-end tpl:gap-2`},Qi=[`disabled`],$i=[`disabled`],ea={key:0,class:`tpl:flex tpl:items-center tpl:gap-1.5`},ta={key:1},na=m({__name:`MediaImportUrlModal`,props:{visible:{type:Boolean},isImporting:{type:Boolean},error:{}},emits:[`import`,`close`],setup(n,{emit:a}){let o=n,c=a,{t:d}=Pe(),f=l(`tplUiTheme`),m=e(``);s(()=>o.visible,e=>{e&&(m.value=``)});function g(){let e=m.value.trim();!e||o.isImporting||c(`import`,e)}function _(){o.isImporting||c(`close`)}function v(e){e.key===`Enter`&&(e.preventDefault(),g()),e.key===`Escape`&&_()}return(e,a)=>(z(),h(b,{to:`body`},[p(ve,{"enter-active-class":`tpl:transition tpl:ease-out tpl:duration-150`,"enter-from-class":`tpl:opacity-0`,"enter-to-class":`tpl:opacity-100`,"leave-active-class":`tpl:transition tpl:ease-in tpl:duration-100`,"leave-from-class":`tpl:opacity-100`,"leave-to-class":`tpl:opacity-0`},{default:F(()=>[n.visible?(z(),t(`div`,{key:0,"data-tpl-theme":j(f),class:`tpl tpl:fixed tpl:inset-0 tpl:z-[10000] tpl:flex tpl:items-center tpl:justify-center`,style:{"background-color":`var(--tpl-overlay)`},onClick:r(_,[`self`]),onKeydown:v},[i(`div`,Ki,[i(`h3`,qi,L(j(d).mediaLibrary.importFromUrl),1),i(`div`,Ji,[u(i(`input`,{"onUpdate:modelValue":a[0]||=e=>m.value=e,type:`url`,class:`tpl:w-full tpl:rounded-md tpl:border tpl:px-3 tpl:py-1.5 tpl:text-xs tpl:outline-none`,style:{"border-color":`var(--tpl-border)`,"background-color":`var(--tpl-bg)`,color:`var(--tpl-text)`},placeholder:j(d).mediaLibrary.importUrlPlaceholder,disabled:n.isImporting,autofocus:``},null,8,Yi),[[ee,m.value]])]),n.error?(z(),t(`p`,Xi,L(n.error),1)):N(``,!0),i(`div`,Zi,[i(`button`,{class:k([`tpl:cursor-pointer tpl:rounded-md tpl:border tpl:px-3 tpl:py-1.5 tpl:text-xs tpl:font-medium tpl:transition-all tpl:duration-150`,{"tpl:cursor-not-allowed tpl:opacity-50":n.isImporting}]),style:{"border-color":`var(--tpl-border)`,color:`var(--tpl-text)`,"background-color":`var(--tpl-bg)`},disabled:n.isImporting,onClick:_},L(j(d).mediaLibrary.cancel),11,Qi),i(`button`,{class:`tpl:cursor-pointer tpl:rounded-md tpl:px-3 tpl:py-1.5 tpl:text-xs tpl:font-medium tpl:text-white tpl:transition-all tpl:duration-150 tpl:disabled:cursor-not-allowed tpl:disabled:opacity-50`,style:{background:`linear-gradient(
9
+ 135deg,
10
+ var(--tpl-primary),
11
+ var(--tpl-primary-hover)
12
+ )`},disabled:!m.value.trim()||n.isImporting,onClick:g},[n.isImporting?(z(),t(`span`,ea,[p(j(se),{class:`tpl:animate-spin`,size:12,"stroke-width":2}),M(` `+L(j(d).mediaLibrary.importing),1)])):(z(),t(`span`,ta,L(j(d).mediaLibrary.import),1))],8,$i)])])],40,Gi)):N(``,!0)]),_:1})]))}}),ra={class:`tpl:max-h-56 tpl:overflow-y-auto tpl:py-1`},ia=[`disabled`,`onClick`],aa={class:`tpl:truncate`},oa={key:0,class:`tpl:shrink-0`,style:{color:`var(--tpl-text-dim)`}},sa=m({__name:`MediaMovePicker`,props:{folders:{},currentFolderId:{}},emits:[`select`,`close`],setup(n,{emit:r}){let a=r,{t:o}=Pe(),s=e(null);function c(e,t=0){let n=[];for(let r of e)n.push({id:r.id,name:r.name,depth:t}),r.children?.length&&n.push(...c(r.children,t+1));return n}return oi(s,()=>{a(`close`)}),(e,r)=>(z(),t(`div`,{ref_key:`pickerRef`,ref:s,class:`tpl:absolute tpl:bottom-full tpl:left-0 tpl:z-10 tpl:mb-2 tpl:w-56 tpl:overflow-hidden tpl:rounded-lg tpl:border tpl:shadow-lg`,style:{"border-color":`var(--tpl-border)`,"background-color":`var(--tpl-bg-elevated)`}},[i(`div`,ra,[n.currentFolderId===null?N(``,!0):(z(),t(`button`,{key:0,class:`tpl:flex tpl:w-full tpl:items-center tpl:gap-1.5 tpl:px-3 tpl:py-1.5 tpl:text-left tpl:text-xs tpl:transition-colors tpl:duration-100`,style:{color:`var(--tpl-text)`},onClick:r[0]||=e=>a(`select`,null)},[p(j(ce),{class:`tpl:shrink-0`,size:14,"stroke-width":1.5}),M(` `+L(j(o).mediaLibrary.moveToRoot),1)])),(z(!0),t(R,null,S(c(n.folders),e=>(z(),t(`button`,{key:e.id,class:`tpl:flex tpl:w-full tpl:items-center tpl:gap-1.5 tpl:py-1.5 tpl:pr-3 tpl:text-left tpl:text-xs tpl:transition-colors tpl:duration-100`,style:P({paddingLeft:`${e.depth*16+12}px`,color:e.id===n.currentFolderId?`var(--tpl-text-dim)`:`var(--tpl-text)`,opacity:e.id===n.currentFolderId?.5:1}),disabled:e.id===n.currentFolderId,onClick:t=>a(`select`,e.id)},[p(j(fe),{class:`tpl:shrink-0`,size:14,"stroke-width":1.5}),i(`span`,aa,L(e.name),1),e.id===n.currentFolderId?(z(),t(`span`,oa,L(j(o).mediaLibrary.currentFolder),1)):N(``,!0)],12,ia))),128))])],512))}}),ca={class:`tpl:flex tpl:items-center tpl:gap-3`},la=[`src`,`alt`],ua={key:1,class:`tpl:flex tpl:size-10 tpl:shrink-0 tpl:items-center tpl:justify-center tpl:overflow-hidden tpl:rounded`,style:{border:`1px solid var(--tpl-border)`}},da={class:`tpl:min-w-0 tpl:flex-1`},fa={class:`tpl:truncate tpl:text-xs tpl:font-medium`,style:{color:`var(--tpl-text)`}},pa={class:`tpl:mt-0.5 tpl:text-[10px]`,style:{color:`var(--tpl-text-muted)`}},ma={key:2,class:`tpl:shrink-0`},ha={class:`tpl:block tpl:text-[10px]`,style:{color:`var(--tpl-text-muted)`}},ga=[`value`],_a=[`value`],va=br(m({__name:`MediaPreviewPanel`,props:{item:{},folders:{},selectedConversion:{}},emits:[`update:selectedConversion`],setup(e,{emit:n}){let r=e,o=n,{t:s}=Pe(),{isImageMimeType:c}=ze(),l=a(()=>{if(!g.value||!r.item.conversions_generated)return[];let e=[];return r.item.small_url&&e.push({value:`small`,label:s.mediaLibrary.conversionSmall,url:r.item.small_url}),r.item.medium_url&&e.push({value:`medium`,label:s.mediaLibrary.conversionMedium,url:r.item.medium_url}),r.item.large_url&&e.push({value:`large`,label:s.mediaLibrary.conversionLarge,url:r.item.large_url}),e.push({value:`original`,label:s.mediaLibrary.conversionOriginal,url:r.item.url}),e}),u=a(()=>g.value&&l.value.length>1),d=a(()=>{if(!g.value)return null;switch(r.selectedConversion){case`small`:return r.item.small_url||r.item.url;case`medium`:return r.item.medium_url||r.item.url;case`large`:return r.item.large_url||r.item.url;default:return r.item.url}});function f(e){let t=e.target;o(`update:selectedConversion`,t.value)}function m(e,t,n=[]){for(let r of e){let e=[...n,r.name];if(r.id===t)return e;if(r.children){let n=m(r.children,t,e);if(n)return n}}return null}let h=a(()=>{if(!r.item.folder_id||!r.folders)return null;let e=m(r.folders,r.item.folder_id);return e?e.join(`/`):null}),g=a(()=>c(r.item.mime_type));function _(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function v(e){return new Date(e).toLocaleDateString(void 0,{year:`numeric`,month:`short`,day:`numeric`})}return(n,r)=>(z(),t(`div`,ca,[g.value?(z(),t(`img`,{key:0,src:d.value??void 0,alt:e.item.alt_text||e.item.filename,class:`tpl:size-10 tpl:shrink-0 tpl:rounded tpl:object-cover`,style:{border:`1px solid var(--tpl-border)`}},null,8,la)):(z(),t(`div`,ua,[p(Ir,{"mime-type":e.item.mime_type,class:`tpl-preview-icon`},null,8,[`mime-type`])])),i(`div`,da,[i(`p`,fa,L(e.item.filename),1),i(`p`,pa,[M(L(_(e.item.size))+` · `+L(v(e.item.created_at))+` `,1),g.value&&e.item.width&&e.item.height?(z(),t(R,{key:0},[M(` · `+L(e.item.width)+`×`+L(e.item.height)+`px `,1)],64)):N(``,!0),h.value?(z(),t(R,{key:1},[r[0]||=M(` · `,-1),p(j(fe),{class:`tpl:mb-px tpl:inline`,size:9,"stroke-width":2}),M(` `+L(h.value),1)],64)):N(``,!0)]),g.value?(z(),t(`p`,{key:0,class:k([`tpl:mt-0.5 tpl:truncate tpl:text-[10px] tpl:italic`,{"tpl:invisible":!e.item.alt_text}]),style:{color:`var(--tpl-text-dim)`}},L(e.item.alt_text||`\xA0`),3)):N(``,!0)]),u.value?(z(),t(`div`,ma,[i(`label`,ha,L(j(s).mediaLibrary.conversionLabel),1),i(`select`,{class:`tpl:mt-0.5 tpl:rounded-md tpl:border tpl:py-1 tpl:pr-6 tpl:pl-2 tpl:text-xs tpl:outline-none`,style:{"border-color":`var(--tpl-border)`,"background-color":`var(--tpl-bg)`,color:`var(--tpl-text)`},value:e.selectedConversion,onChange:f},[(z(!0),t(R,null,S(l.value,e=>(z(),t(`option`,{key:e.value,value:e.value},L(e.label),9,_a))),128))],40,ga)])):N(``,!0)]))}}),[[`__scopeId`,`data-v-060e36cd`]]),ya=[`data-tpl-theme`],ba={class:`tpl:mx-4 tpl:w-full tpl:max-w-sm tpl:rounded-lg tpl:p-5 tpl:shadow-xl`,style:{"background-color":`var(--tpl-bg-elevated)`}},xa={class:`tpl:mb-2 tpl:text-sm tpl:font-semibold`,style:{color:`var(--tpl-text)`}},Sa={class:`tpl:mb-2 tpl:text-xs`,style:{color:`var(--tpl-text-muted)`}},Ca={key:0,class:`tpl:mb-3 tpl:text-xs`,style:{color:`var(--tpl-warning)`}},wa={class:`tpl:mb-3 tpl:rounded tpl:border tpl:p-2`,style:{"border-color":`var(--tpl-border)`}},Ta={class:`tpl:truncate tpl:text-xs tpl:font-medium`,style:{color:`var(--tpl-text)`}},Ea={class:`tpl:mb-4`},Da={class:`tpl:mb-1 tpl:block tpl:text-xs tpl:font-medium`,style:{color:`var(--tpl-text-muted)`}},Oa=[`accept`],ka={key:1,class:`tpl:mb-3 tpl:text-xs`,style:{color:`var(--tpl-danger)`}},Aa={class:`tpl:flex tpl:justify-end tpl:gap-2`},ja=[`disabled`],Ma=[`disabled`],Na=m({__name:`MediaReplaceModal`,props:{visible:{type:Boolean},item:{},usageInfo:{},isReplacing:{type:Boolean},error:{}},emits:[`replace`,`close`],setup(n,{emit:o}){let c=n,u=o,{t:d}=Pe(),f=l(`tplUiTheme`),m=e(null),g=e(null),_=a(()=>{if(!c.item)return``;let e=c.item.filename.split(`.`);return e.length>1?e[e.length-1].toLowerCase():``}),v=a(()=>_.value?`.${_.value}`:`*`),y=a(()=>(c.usageInfo?.template_count??0)>0);s(()=>c.visible,e=>{e||(g.value=null,m.value&&(m.value.value=``))});function x(e){let t=e.target;t.files&&t.files.length>0&&(g.value=t.files[0])}function S(){g.value&&u(`replace`,g.value)}function C(e){e.key===`Escape`&&u(`close`)}return(e,a)=>(z(),h(b,{to:`body`},[p(ve,{"enter-active-class":`tpl:transition tpl:ease-out tpl:duration-150`,"enter-from-class":`tpl:opacity-0`,"enter-to-class":`tpl:opacity-100`,"leave-active-class":`tpl:transition tpl:ease-in tpl:duration-100`,"leave-from-class":`tpl:opacity-100`,"leave-to-class":`tpl:opacity-0`},{default:F(()=>[n.visible&&n.item?(z(),t(`div`,{key:0,"data-tpl-theme":j(f),class:`tpl tpl:fixed tpl:inset-0 tpl:z-[10000] tpl:flex tpl:items-center tpl:justify-center`,style:{"background-color":`var(--tpl-overlay)`},onClick:a[1]||=r(e=>u(`close`),[`self`]),onKeydown:C},[i(`div`,ba,[i(`h3`,xa,L(j(d).mediaLibrary.replaceWarningTitle),1),i(`p`,Sa,L(j(d).mediaLibrary.replaceWarningMessage.replace(`{extension}`,`.${_.value}`)),1),y.value?(z(),t(`p`,Ca,L(j(d).mediaLibrary.replaceWarningUsageNote.replace(`{count}`,n.usageInfo.template_count.toString())),1)):N(``,!0),i(`div`,wa,[i(`p`,Ta,L(n.item.filename),1)]),i(`div`,Ea,[i(`label`,Da,L(j(d).mediaLibrary.replaceSelectFile),1),i(`input`,{ref_key:`fileInputRef`,ref:m,type:`file`,accept:v.value,class:`tpl:w-full tpl:rounded-md tpl:border tpl:px-3 tpl:py-1.5 tpl:text-xs`,style:{"border-color":`var(--tpl-border)`,"background-color":`var(--tpl-bg)`,color:`var(--tpl-text)`},onChange:x},null,40,Oa)]),n.error?(z(),t(`p`,ka,L(n.error),1)):N(``,!0),i(`div`,Aa,[i(`button`,{class:`tpl:cursor-pointer tpl:rounded-md tpl:border tpl:px-3 tpl:py-1.5 tpl:text-xs tpl:font-medium tpl:transition-all tpl:duration-150`,style:{"border-color":`var(--tpl-border)`,color:`var(--tpl-text)`,"background-color":`var(--tpl-bg)`},disabled:n.isReplacing,onClick:a[0]||=e=>u(`close`)},L(j(d).mediaLibrary.cancel),9,ja),i(`button`,{class:`tpl:cursor-pointer tpl:rounded-md tpl:px-3 tpl:py-1.5 tpl:text-xs tpl:font-medium tpl:text-white tpl:transition-all tpl:duration-150 tpl:disabled:cursor-not-allowed tpl:disabled:opacity-50`,style:{background:`linear-gradient(
13
+ 135deg,
14
+ var(--tpl-primary),
15
+ var(--tpl-primary-hover)
16
+ )`},disabled:!g.value||n.isReplacing,onClick:S},L(n.isReplacing?j(d).mediaLibrary.replacing:j(d).mediaLibrary.replace),9,Ma)])])],40,ya)):N(``,!0)]),_:1})]))}}),Pa={key:0,class:`tpl:flex tpl:items-center tpl:gap-2`},Fa={class:`tpl:text-xs`,style:{color:`var(--tpl-text-muted)`}},Ia={class:`tpl:text-xs`,style:{color:`var(--tpl-text-muted)`}},La={class:`tpl:mt-1 tpl:text-[10px]`,style:{color:`var(--tpl-text-dim)`}},Ra=m({__name:`MediaUploadZone`,props:{isUploading:{type:Boolean},uploadProgress:{}},emits:[`upload`],setup(n,{emit:r}){let a=r,{t:o,format:s}=Pe(),{allAcceptedMimeTypes:c,allAcceptedInputString:l,maxFileSize:u}=ze(),d=e();function f(e){let t=[];for(let n of Array.from(e))c.value.includes(n.type)&&n.size<=u.value&&t.push(n);return t}function m(e){let t=f(e);t.length&&a(`upload`,t)}let{isOverDropZone:h}=di(d,{onDrop:e=>{e?.length&&m(e)}}),{open:g,onChange:_}=hi({accept:l.value,multiple:!0});return _(e=>{e?.length&&m(e)}),(e,r)=>(z(),t(`div`,{ref_key:`dropZoneRef`,ref:d,class:k([`tpl-upload-zone tpl:flex tpl:cursor-pointer tpl:flex-col tpl:items-center tpl:justify-center tpl:rounded-lg tpl:border-2 tpl:border-dashed tpl:p-5 tpl:text-center tpl:transition-all tpl:duration-150`,j(h)?`tpl-upload-zone-active`:``]),style:{"border-color":`var(--tpl-border-light)`,"background-color":`var(--tpl-bg)`},onClick:r[0]||=e=>j(g)()},[n.isUploading?(z(),t(`div`,Pa,[p(j(se),{class:`tpl-spinner`,size:20,"stroke-width":2,style:{color:`var(--tpl-primary)`}}),i(`span`,Fa,L(n.uploadProgress&&n.uploadProgress.total>1?j(s)(j(o).mediaLibrary.uploadingProgress,{current:n.uploadProgress.current,total:n.uploadProgress.total}):j(o).mediaLibrary.uploading),1)])):(z(),t(R,{key:1},[p(j(he),{class:`tpl:mb-2`,size:24,"stroke-width":1.5,style:{color:`var(--tpl-text-dim)`}}),i(`p`,Ia,L(j(o).mediaLibrary.dropOrClick),1),i(`p`,La,L(j(o).mediaLibrary.acceptedFormats),1)],64))],2))}}),za=[`width`,`height`,`viewBox`],Ba=[`cx`,`cy`,`r`,`stroke-width`],Va=[`cx`,`cy`,`r`,`stroke-width`,`stroke`,`stroke-dasharray`,`stroke-dashoffset`],Ha={key:0,class:`tpl:absolute tpl:top-full tpl:left-1/2 tpl:z-50 tpl:mt-2 tpl:-translate-x-1/2 tpl:rounded-md tpl:px-2.5 tpl:py-1.5 tpl:text-xs tpl:whitespace-nowrap tpl:shadow-lg`,style:{"background-color":`var(--tpl-text)`,color:`var(--tpl-bg-elevated)`}},Ua=m({__name:`StorageProgressRing`,props:{usedBytes:{},limitBytes:{},size:{}},setup(n){let r=n,{t:o,format:s}=Pe(),c=e(!1),l=a(()=>r.size??24),u=a(()=>Math.max(2,l.value/8)),d=a(()=>(l.value-u.value)/2),f=a(()=>2*Math.PI*d.value),m=a(()=>r.limitBytes<=0?0:Math.min(100,r.usedBytes/r.limitBytes*100)),h=a(()=>f.value-m.value/100*f.value),g=a(()=>m.value>=95?`var(--tpl-danger)`:m.value>=75?`var(--tpl-warning, #f59e0b)`:`var(--tpl-primary)`);function _(e){if(e===0)return`0 B`;let t=1024,n=[`B`,`KB`,`MB`,`GB`],r=Math.floor(Math.log(e)/Math.log(t));return`${(e/t**+r).toFixed(+(r>=2))} ${n[r]}`}let v=a(()=>_(r.usedBytes)),y=a(()=>_(r.limitBytes)),b=a(()=>Math.max(0,r.limitBytes-r.usedBytes)),x=a(()=>_(b.value)),S=a(()=>s(o.mediaLibrary.storageTooltip,{used:v.value,total:y.value,remaining:x.value}));return(e,n)=>(z(),t(`div`,{class:`tpl:relative tpl:inline-flex tpl:cursor-help tpl:items-center tpl:justify-center`,onMouseenter:n[0]||=e=>c.value=!0,onMouseleave:n[1]||=e=>c.value=!1},[(z(),t(`svg`,{width:l.value,height:l.value,class:`tpl:-rotate-90`,viewBox:`0 0 ${l.value} ${l.value}`},[i(`circle`,{cx:l.value/2,cy:l.value/2,r:d.value,fill:`none`,"stroke-width":u.value,style:{stroke:`var(--tpl-border)`}},null,8,Ba),i(`circle`,{cx:l.value/2,cy:l.value/2,r:d.value,fill:`none`,"stroke-width":u.value,stroke:g.value,"stroke-linecap":`round`,"stroke-dasharray":f.value,"stroke-dashoffset":h.value,class:`tpl:transition-all tpl:duration-300 tpl:ease-out`},null,8,Va)],8,za)),p(ve,{"enter-active-class":`tpl:transition tpl:ease-out tpl:duration-150`,"enter-from-class":`tpl:opacity-0 tpl:translate-y-1`,"enter-to-class":`tpl:opacity-100 tpl:translate-y-0`,"leave-active-class":`tpl:transition tpl:ease-in tpl:duration-100`,"leave-from-class":`tpl:opacity-100 tpl:translate-y-0`,"leave-to-class":`tpl:opacity-0 tpl:translate-y-1`},{default:F(()=>[c.value?(z(),t(`div`,Ha,[M(L(S.value)+` `,1),n[2]||=i(`div`,{class:`tpl:absolute tpl:-top-1 tpl:left-1/2 tpl:size-2 tpl:-translate-x-1/2 tpl:rotate-45`,style:{"background-color":`var(--tpl-text)`}},null,-1)])):N(``,!0)]),_:1})],32))}}),Wa=class{constructor(e){this.authManager=e}get projectId(){return this.authManager.projectId}get tenantSlug(){return this.authManager.tenantSlug}get baseParams(){return{project:this.projectId,tenant:this.tenantSlug}}async request(e,t={}){let n=await this.authManager.authenticatedFetch(e,{...t,headers:{"Content-Type":`application/json`,Accept:`application/json`,...t.headers}});if(!n.ok){let e=await n.json().catch(()=>({message:`HTTP error ${n.status}`}));throw Error(e.message,{cause:e})}if(n.status!==204)return(await n.json()).data}async browseMedia(e){let t=new URLSearchParams;e.folder_id&&t.set(`folder_id`,e.folder_id),e.search&&t.set(`search`,e.search),e.category&&t.set(`category`,e.category),e.sort&&t.set(`sort`,e.sort),e.cursor&&t.set(`cursor`,e.cursor);let n=t.toString(),r=`${B(H[`media.browse`],this.baseParams)}${n?`?${n}`:``}`,i=await this.authManager.authenticatedFetch(r,{headers:{Accept:`application/json`}});if(!i.ok){let e=await i.json().catch(()=>({message:`HTTP error ${i.status}`}));throw Error(e.message,{cause:e})}return i.json()}async uploadMedia(e,t){let n=new FormData;n.append(`file`,e),t&&n.append(`folder_id`,t);let r=B(H[`media.upload`],this.baseParams),i=await this.authManager.authenticatedFetch(r,{method:`POST`,headers:{Accept:`application/json`},body:n});if(!i.ok){let e=await i.json().catch(()=>({message:`HTTP error ${i.status}`}));throw Error(e.message,{cause:e})}return(await i.json()).data}async updateMedia(e,t,n){return this.request(B(H[`media.update`],{...this.baseParams,media:e}),{method:`PUT`,body:JSON.stringify({filename:t,alt_text:n})})}async deleteMedia(e){return this.request(B(H[`media.delete`],this.baseParams),{method:`POST`,body:JSON.stringify({ids:e})})}async moveMedia(e,t){return this.request(B(H[`media.move`],this.baseParams),{method:`POST`,body:JSON.stringify({ids:e,folder_id:t})})}async getMediaFolders(){return this.request(B(H[`folders.index`],this.baseParams))}async createMediaFolder(e,t){return this.request(B(H[`folders.store`],this.baseParams),{method:`POST`,body:JSON.stringify({name:e,parent_id:t??null})})}async renameMediaFolder(e,t){return this.request(B(H[`folders.update`],{...this.baseParams,mediaFolder:e}),{method:`PUT`,body:JSON.stringify({name:t})})}async deleteMediaFolder(e){return this.request(B(H[`folders.destroy`],{...this.baseParams,mediaFolder:e}),{method:`DELETE`})}async checkMediaUsage(e){let t=await this.authManager.authenticatedFetch(B(H[`media.checkUsage`],this.baseParams),{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({ids:e})});if(!t.ok){let e=await t.json().catch(()=>({message:`HTTP error ${t.status}`}));throw Error(e.message,{cause:e})}return t.json()}async getFrequentlyUsed(){return this.request(B(H[`media.frequentlyUsed`],this.baseParams))}async importFromUrl(e,t){return this.request(B(H[`media.importFromUrl`],this.baseParams),{method:`POST`,body:JSON.stringify({url:e,folder_id:t??null})})}async replaceMedia(e,t){let n=new FormData;n.append(`file`,t);let r=B(H[`media.replace`],{...this.baseParams,media:e}),i=await this.authManager.authenticatedFetch(r,{method:`POST`,headers:{Accept:`application/json`},body:n});if(!i.ok){let e=await i.json().catch(()=>({message:`HTTP error ${i.status}`}));throw Error(e.message,{cause:e})}return(await i.json()).data}};function Ga(t){if(!t.projectId)throw Error(`projectId is required for useMediaLibrary`);let n=new Wa(t.authManager),r=e([]),i=e([]),a=e(null),o=e(`files`),s=e(``),c=e(null),l=e(`newest`),u=e(!1),d=e(!1),f=e(!1),p=e(null),m=e(null),h=e(new Set),g=e(null),_=e([]),v=e({}),y=e(!1),b=e([]),x=e(!1),S=e(null),C=e(!1),w=e(null),T=e(!1),E=e(null),D=e(null);async function O(){u.value=!0;try{let e=await n.browseMedia({folder_id:s.value?void 0:a.value,search:s.value||void 0,category:c.value||void 0,sort:l.value===`newest`?void 0:l.value});r.value=e.data,p.value=e.meta.next_cursor,f.value=!!e.meta.next_cursor}catch(e){t.onError?.(e)}finally{u.value=!1}}async function k(){if(!(!f.value||!p.value||u.value)){u.value=!0;try{let e=await n.browseMedia({folder_id:s.value?void 0:a.value,search:s.value||void 0,category:c.value||void 0,sort:l.value===`newest`?void 0:l.value,cursor:p.value});r.value=[...r.value,...e.data],p.value=e.meta.next_cursor,f.value=!!e.meta.next_cursor}catch(e){t.onError?.(e)}finally{u.value=!1}}}async function ee(e){s.value=e,await O()}async function A(e){c.value=e,await O()}async function te(e){l.value=e,await O()}async function ne(e){o.value=`files`,a.value=e,s.value=``,h.value=new Set,g.value=null,await O()}async function re(){o.value=`frequently-used`,a.value=null,s.value=``,h.value=new Set,g.value=null,await N()}async function ie(e){d.value=!0;try{let t=await n.uploadMedia(e,a.value);return r.value=[t,...r.value],t}catch(e){return t.onError?.(e),null}finally{d.value=!1}}async function ae(e){d.value=!0,m.value={current:0,total:e.length};try{for(let i=0;i<e.length;i++){m.value={current:i+1,total:e.length};try{r.value=[await n.uploadMedia(e[i],a.value),...r.value]}catch(e){t.onError?.(e)}}}finally{d.value=!1,m.value=null}}async function oe(e){if(h.value.size!==0)try{let t=await n.moveMedia([...h.value],e);if(a.value===null){let e=new Map(t.map(e=>[e.id,e]));r.value=r.value.map(t=>e.get(t.id)??t)}else r.value=r.value.filter(e=>!h.value.has(e.id));h.value=new Set,g.value=null}catch(e){t.onError?.(e)}}async function j(e,i,a){try{let t=await n.updateMedia(e,i,a);r.value=r.value.map(n=>n.id===e?t:n),g.value?.id===e&&(g.value=t)}catch(e){t.onError?.(e)}}async function M(){if(h.value.size!==0)try{await n.deleteMedia([...h.value]),r.value=r.value.filter(e=>!h.value.has(e.id)),_.value=_.value.filter(e=>!h.value.has(e.id)),h.value=new Set,g.value=null}catch(e){t.onError?.(e)}}async function N(){try{_.value=await n.getFrequentlyUsed()}catch(e){t.onError?.(e)}}async function se(){if(h.value.size===0)return!1;b.value=[...h.value];try{let e=await n.checkMediaUsage(b.value);v.value=e.data;let t=Object.values(e.data).some(e=>e.template_count>0);return y.value=!0,t}catch(e){return t.onError?.(e),!1}}async function ce(){if(y.value=!1,b.value.length!==0)try{await n.deleteMedia(b.value),r.value=r.value.filter(e=>!b.value.includes(e.id)),_.value=_.value.filter(e=>!b.value.includes(e.id)),h.value=new Set,g.value=null,b.value=[],v.value={}}catch(e){t.onError?.(e)}}function le(){y.value=!1,b.value=[],v.value={}}async function ue(e){x.value=!0,S.value=null;try{let t=await n.importFromUrl(e,a.value);return r.value=[t,...r.value],t}catch(e){return S.value=e instanceof Error?e.message:`Import failed`,t.onError?.(e),null}finally{x.value=!1}}function de(e){let t=new Set(h.value);t.has(e)?t.delete(e):t.add(e),h.value=t}function P(){h.value=new Set,g.value=null}function fe(e){g.value=e,h.value=new Set([e.id])}async function F(){try{i.value=await n.getMediaFolders()}catch(e){t.onError?.(e)}}async function pe(e,r){try{let t=await n.createMediaFolder(e,r);return await F(),t}catch(e){return t.onError?.(e),null}}function I(e,t){for(let n of e){if(n.id===t)return n;if(n.children){let e=I(n.children,t);if(e)return e}}return null}async function me(e,r){try{await n.renameMediaFolder(e,r),await F()}catch(e){t.onError?.(e)}}async function L(e){try{let t=I(i.value,e)?.parent_id??null;await n.deleteMediaFolder(e),a.value===e&&(a.value=t),await F(),await O()}catch(e){t.onError?.(e)}}async function he(e){E.value=e,w.value=null;try{D.value=(await n.checkMediaUsage([e.id])).data[e.id]??null,T.value=!0}catch(e){t.onError?.(e)}}function ge(){T.value=!1,E.value=null,D.value=null,w.value=null}async function _e(e){if(!E.value)return null;C.value=!0,w.value=null;try{let t=await n.replaceMedia(E.value.id,e);return r.value=r.value.map(e=>e.id===t.id?t:e),_.value=_.value.map(e=>e.id===t.id?t:e),g.value?.id===t.id&&(g.value=t),T.value=!1,E.value=null,D.value=null,t}catch(e){return w.value=e instanceof Error?e.message:`Replace failed`,t.onError?.(e),null}finally{C.value=!1}}async function ve(e,i){try{let t=await n.replaceMedia(e,i);return r.value=r.value.map(e=>e.id===t.id?t:e),_.value=_.value.map(e=>e.id===t.id?t:e),g.value?.id===t.id&&(g.value=t),t}catch(e){return t.onError?.(e),null}}return{items:r,folders:i,currentFolderId:a,viewMode:o,searchQuery:s,categoryFilter:c,sortOption:l,isLoading:u,isUploading:d,uploadProgress:m,hasMore:f,selectedItems:h,previewItem:g,frequentlyUsedItems:_,deleteUsageInfo:v,showDeleteWarning:y,loadItems:O,loadMore:k,search:ee,filterByCategory:A,sortBy:te,navigateToFolder:ne,showFrequentlyUsed:re,uploadFile:ie,uploadFiles:ae,moveSelected:oe,updateFile:j,deleteSelected:M,isImportingFromUrl:x,importFromUrlError:S,importFromUrl:ue,toggleSelection:de,clearSelection:P,selectItem:fe,loadFolders:F,createFolder:pe,renameFolder:me,deleteFolder:L,findFolderInTree:I,loadFrequentlyUsed:N,checkUsageBeforeDelete:se,confirmDelete:ce,cancelDelete:le,isReplacing:C,replaceError:w,showReplaceWarning:T,pendingReplaceItem:E,replaceUsageInfo:D,checkUsageBeforeReplace:he,cancelReplace:ge,replaceFile:_e,replaceMediaDirectly:ve}}function Ka(t){let{library:n,canUseMediaFolders:r,translations:i}=t;function o(){return`value`in i&&typeof i.value==`object`?i.value:i}let c=e(`grid`),l=e(!1),u=e(``),d=e(`original`),f=e(null),p=e(!1),m=e(!1),h=a(()=>{let e=n.previewItem.value;if(!e)return null;switch(d.value){case`small`:return e.small_url||e.url;case`medium`:return e.medium_url||e.url;case`large`:return e.large_url||e.url;default:return e.url}}),g=a(()=>n.frequentlyUsedItems.value.length>0),_=a(()=>n.viewMode.value===`frequently-used`?n.frequentlyUsedItems.value:n.items.value),v=a(()=>Object.values(n.deleteUsageInfo.value).some(e=>e.template_count>0)),y={images:()=>o().mediaLibrary.filterImages,documents:()=>o().mediaLibrary.filterDocuments,videos:()=>o().mediaLibrary.filterVideos,audio:()=>o().mediaLibrary.filterAudio};function b(e){return y[e]?.()??e}s(l,e=>{e&&r.value&&n.loadFolders()}),s(()=>n.previewItem.value?.id,()=>{d.value=`original`});let x=Zr(e=>{n.search(e)},300);function S(e){u.value=e,x(e)}let{copy:C,copied:w}=ui({copiedDuring:2e3,legacy:!0});async function T(e){await n.uploadFiles(e)}function E(e){n.selectItem(e)}async function D(e,t){await n.createFolder(e,t)}async function O(e,t){await n.renameFolder(e,t)}async function k(e){await n.deleteFolder(e)}function ee(e){f.value=e}async function A(e,t,r,i){i&&await n.replaceMediaDirectly(e,i.file),await n.updateFile(e,t,r),f.value=null}async function te(e){await n.importFromUrl(e)&&(p.value=!1)}async function ne(e){m.value=!1,await n.moveSelected(e)}async function re(){await n.checkUsageBeforeDelete()}function ie(e){n.checkUsageBeforeReplace(e)}async function ae(e){await n.replaceFile(e)}function oe(){n.clearSelection(),n.cancelDelete(),n.cancelReplace(),u.value=``,n.categoryFilter.value=null,n.sortOption.value=`newest`,n.viewMode.value=`files`,f.value=null,p.value=!1,d.value=`original`}return{layoutMode:c,showSidebar:l,searchInput:u,selectedConversion:d,editingItem:f,showImportUrlModal:p,showMovePicker:m,selectedUrl:h,hasFrequentlyUsed:g,displayItems:_,hasUsedFiles:v,copy:C,copied:w,getCategoryLabel:b,handleSearchInput:S,handleUpload:T,handleSelect:E,handleCreateFolder:D,handleRenameFolder:O,handleDeleteFolder:k,handleEditItem:ee,handleEditSave:A,handleImportFromUrl:te,handleMoveToFolder:ne,handleDeleteClick:re,handleReplaceItem:ie,handleReplaceFile:ae,resetUI:oe}}var qa={class:`tpl tpl:flex tpl:flex-col tpl:overflow-hidden tpl:rounded-[var(--tpl-radius-lg)]`,style:{width:`100%`,height:`100%`,"background-color":`var(--tpl-bg-elevated)`,border:`1px solid var(--tpl-border)`}},Ja={class:`tpl:flex tpl:shrink-0 tpl:items-center tpl:justify-between tpl:border-b tpl:px-5 tpl:py-3.5`,style:{"border-color":`var(--tpl-border)`}},Ya={class:`tpl:text-sm tpl:font-semibold`,style:{color:`var(--tpl-text)`}},Xa={class:`tpl:flex tpl:items-center tpl:gap-3`},Za={class:`tpl:relative`},Qa=[`value`,`placeholder`],$a={class:`tpl:flex tpl:min-h-0 tpl:flex-1 tpl:overflow-hidden`},eo={key:0,class:`tpl:flex tpl:w-48 tpl:shrink-0 tpl:flex-col tpl:border-r`,style:{"border-color":`var(--tpl-border)`,"background-color":`var(--tpl-bg)`}},to={class:`tpl:flex tpl:min-w-0 tpl:flex-1 tpl:flex-col`},no={class:`tpl:flex tpl:shrink-0 tpl:items-center tpl:justify-between tpl:border-b tpl:px-4 tpl:py-2.5`,style:{"border-color":`var(--tpl-border)`}},ro={class:`tpl:flex tpl:items-center tpl:gap-2`},io=[`title`],ao={key:1,class:`tpl:text-xs tpl:font-medium`,style:{color:`var(--tpl-text)`}},oo={class:`tpl:flex tpl:rounded-md tpl:p-0.5`,style:{border:`1px solid var(--tpl-border)`,"background-color":`var(--tpl-bg)`}},so=[`title`],co=[`title`],lo={class:`tpl:flex tpl:items-center tpl:gap-2`},uo=[`value`],fo={value:``},po=[`value`],mo=[`value`],ho={value:`newest`},go={value:`oldest`},_o={value:`name_asc`},vo={value:`name_desc`},yo={value:`size_asc`},bo={value:`size_desc`},xo={class:`tpl:min-h-0 tpl:flex-1 tpl:overflow-y-auto`},So={key:0,class:`tpl:px-4 tpl:pt-3`},Co={class:`tpl-scale-in tpl:mx-4 tpl:w-full tpl:max-w-sm tpl:rounded-[var(--tpl-radius-lg)] tpl:p-5`,style:{"background-color":`var(--tpl-bg-elevated)`,"box-shadow":`var(--tpl-shadow-xl)`}},wo={class:`tpl:mb-2 tpl:text-sm tpl:font-semibold`,style:{color:`var(--tpl-text)`}},To={key:0,class:`tpl:mb-4 tpl:text-xs`,style:{color:`var(--tpl-text-muted)`}},Eo={key:1,class:`tpl:mb-4 tpl:max-h-32 tpl:overflow-y-auto tpl:rounded tpl:border tpl:p-2`,style:{"border-color":`var(--tpl-border)`}},Do={class:`tpl:font-medium`},Oo={style:{color:`var(--tpl-text-muted)`}},ko={class:`tpl:flex tpl:justify-end tpl:gap-2`},Ao={class:`tpl:flex tpl:shrink-0 tpl:items-center tpl:justify-between tpl:border-t tpl:px-5 tpl:py-3`,style:{"border-color":`var(--tpl-border)`}},jo={class:`tpl:flex tpl:min-w-0 tpl:flex-1 tpl:items-center tpl:gap-3`},Mo={class:`tpl:flex tpl:items-center tpl:gap-5`},No={key:0,class:`tpl:flex tpl:items-center tpl:gap-2`},Po={key:1,class:`tpl:relative`},Fo={class:`tpl:flex tpl:items-center tpl:gap-2`},Io=[`disabled`],Lo=m({__name:`MediaLibrary`,props:{authManager:{},projectId:{},planConfig:{},translations:{},onSelect:{type:Function},onError:{type:Function}},emits:[`ready`],setup(o,{emit:s}){let c=o,l=s,u=a(()=>c.translations);n(`translations`,c.translations),n(`authManager`,c.authManager),n(`projectId`,a(()=>c.projectId)),n(`planConfig`,{config:e(c.planConfig),isLoading:e(!1),hasFeature:e=>c.planConfig.features[e]??!1,features:a(()=>c.planConfig.features),fetchConfig:async()=>{}});let d=a(()=>c.planConfig.features.media_folders??!1),f=a(()=>c.planConfig.features.import_from_url??!1),m=a(()=>c.planConfig.storage.used_bytes??0),g=a(()=>c.planConfig.storage.limit_bytes??0),{availableCategories:_}=ze(),y=Ga({projectId:c.projectId,authManager:c.authManager,onError:c.onError}),b=Ka({library:y,canUseMediaFolders:d,translations:u});function x(){if(!y.previewItem.value)return;let e=y.previewItem.value;c.onSelect?.({...e,url:b.selectedUrl.value||e.url})}return v(()=>{y.loadItems(),y.loadFrequentlyUsed(),l(`ready`)}),(e,n)=>(z(),t(`div`,qa,[i(`div`,Ja,[i(`h2`,Ya,L(u.value.mediaLibrary.title),1),i(`div`,Xa,[p(Ua,{"used-bytes":m.value,"limit-bytes":g.value,size:22},null,8,[`used-bytes`,`limit-bytes`]),i(`div`,Za,[i(`input`,{value:j(b).searchInput.value,type:`text`,class:`tpl:w-52 tpl:rounded-md tpl:border tpl:py-1.5 tpl:pr-3 tpl:pl-8 tpl:text-xs tpl:shadow-xs tpl:transition-all tpl:duration-150 tpl:outline-none tpl:focus:shadow-[var(--tpl-ring)]`,style:{"border-color":`var(--tpl-border)`,"background-color":`var(--tpl-bg)`,color:`var(--tpl-text)`},placeholder:u.value.mediaLibrary.searchPlaceholder,onInput:n[0]||=e=>j(b).handleSearchInput(e.target.value)},null,40,Qa),p(j(oe),{class:`tpl:absolute tpl:top-1/2 tpl:left-2.5 tpl:-translate-y-1/2`,size:13,"stroke-width":2,style:{color:`var(--tpl-text-dim)`}})])])]),i(`div`,$a,[p(ve,{"enter-active-class":`tpl:transition-all tpl:duration-200 tpl:ease-out`,"enter-from-class":`tpl:-ml-48 tpl:opacity-0`,"enter-to-class":`tpl:ml-0 tpl:opacity-100`,"leave-active-class":`tpl:transition-all tpl:duration-150 tpl:ease-in`,"leave-from-class":`tpl:ml-0 tpl:opacity-100`,"leave-to-class":`tpl:-ml-48 tpl:opacity-0`},{default:F(()=>[d.value&&j(b).showSidebar.value?(z(),t(`div`,eo,[p(Pr,{folders:j(y).folders.value,"current-folder-id":j(y).currentFolderId.value,"view-mode":j(y).viewMode.value,"has-frequently-used":j(b).hasFrequentlyUsed.value,onNavigate:j(y).navigateToFolder,onCreateFolder:j(b).handleCreateFolder,onRenameFolder:j(b).handleRenameFolder,onDeleteFolder:j(b).handleDeleteFolder,onShowFrequentlyUsed:j(y).showFrequentlyUsed},null,8,[`folders`,`current-folder-id`,`view-mode`,`has-frequently-used`,`onNavigate`,`onCreateFolder`,`onRenameFolder`,`onDeleteFolder`,`onShowFrequentlyUsed`])])):N(``,!0)]),_:1}),i(`div`,to,[i(`div`,no,[i(`div`,ro,[d.value?(z(),t(`button`,{key:0,class:`tpl:flex tpl:size-7 tpl:cursor-pointer tpl:items-center tpl:justify-center tpl:rounded-md tpl:transition-all tpl:duration-150`,style:P({color:j(b).showSidebar.value?`var(--tpl-primary)`:`var(--tpl-text-muted)`,backgroundColor:j(b).showSidebar.value?`var(--tpl-bg)`:`transparent`,border:j(b).showSidebar.value?`1px solid var(--tpl-border)`:`1px solid transparent`}),title:j(b).showSidebar.value?u.value.mediaLibrary.hideFolders:u.value.mediaLibrary.showFolders,onClick:n[1]||=e=>j(b).showSidebar.value=!j(b).showSidebar.value},[p(j(A),{size:16,"stroke-width":2})],12,io)):N(``,!0),j(y).viewMode.value===`frequently-used`?(z(),t(`span`,ao,L(u.value.mediaLibrary.frequentlyUsed),1)):(z(),h(Re,{key:2,folders:j(y).folders.value,"current-folder-id":j(y).currentFolderId.value,onNavigate:j(y).navigateToFolder},null,8,[`folders`,`current-folder-id`,`onNavigate`])),i(`div`,oo,[i(`button`,{class:`tpl:flex tpl:size-6 tpl:cursor-pointer tpl:items-center tpl:justify-center tpl:rounded tpl:transition-all tpl:duration-150`,style:P({color:j(b).layoutMode.value===`grid`?`var(--tpl-primary)`:`var(--tpl-text-muted)`,backgroundColor:j(b).layoutMode.value===`grid`?`var(--tpl-bg-elevated)`:`transparent`}),title:u.value.mediaLibrary.viewGrid,onClick:n[2]||=e=>j(b).layoutMode.value=`grid`},[p(j(re),{size:14,"stroke-width":2})],12,so),i(`button`,{class:`tpl:flex tpl:size-6 tpl:cursor-pointer tpl:items-center tpl:justify-center tpl:rounded tpl:transition-all tpl:duration-150`,style:P({color:j(b).layoutMode.value===`list`?`var(--tpl-primary)`:`var(--tpl-text-muted)`,backgroundColor:j(b).layoutMode.value===`list`?`var(--tpl-bg-elevated)`:`transparent`}),title:u.value.mediaLibrary.viewList,onClick:n[3]||=e=>j(b).layoutMode.value=`list`},[p(j(_e),{size:14,"stroke-width":2})],12,co)])]),i(`div`,lo,[j(_).length>1?(z(),t(`select`,{key:0,class:`tpl:rounded-md tpl:border tpl:py-1.5 tpl:pr-7 tpl:pl-2.5 tpl:text-xs tpl:transition-all tpl:duration-150 tpl:outline-none`,style:{"border-color":`var(--tpl-border)`,"background-color":`var(--tpl-bg)`,color:`var(--tpl-text)`},value:j(y).categoryFilter.value??``,onChange:n[4]||=e=>j(y).filterByCategory(e.target.value||null)},[i(`option`,fo,L(u.value.mediaLibrary.filterAll),1),(z(!0),t(R,null,S(j(_),e=>(z(),t(`option`,{key:e,value:e},L(j(b).getCategoryLabel(e)),9,po))),128))],40,uo)):N(``,!0),i(`select`,{class:`tpl:rounded-md tpl:border tpl:py-1.5 tpl:pr-7 tpl:pl-2.5 tpl:text-xs tpl:transition-all tpl:duration-150 tpl:outline-none`,style:{"border-color":`var(--tpl-border)`,"background-color":`var(--tpl-bg)`,color:`var(--tpl-text)`},value:j(y).sortOption.value,onChange:n[5]||=e=>j(y).sortBy(e.target.value)},[i(`option`,ho,L(u.value.mediaLibrary.sortNewest),1),i(`option`,go,L(u.value.mediaLibrary.sortOldest),1),i(`option`,_o,L(u.value.mediaLibrary.sortNameAsc),1),i(`option`,vo,L(u.value.mediaLibrary.sortNameDesc),1),i(`option`,yo,L(u.value.mediaLibrary.sortSizeAsc),1),i(`option`,bo,L(u.value.mediaLibrary.sortSizeDesc),1)],40,mo)])]),i(`div`,xo,[j(y).viewMode.value===`files`?(z(),t(`div`,So,[p(Ra,{"is-uploading":j(y).isUploading.value,"upload-progress":j(y).uploadProgress.value,onUpload:j(b).handleUpload},null,8,[`is-uploading`,`upload-progress`,`onUpload`]),f.value?(z(),t(`button`,{key:0,class:`tpl:mt-2 tpl:flex tpl:w-full tpl:cursor-pointer tpl:items-center tpl:justify-center tpl:gap-1.5 tpl:rounded-md tpl:border tpl:border-dashed tpl:px-3 tpl:py-1.5 tpl:text-xs tpl:font-medium tpl:transition-all tpl:duration-150`,style:{"border-color":`var(--tpl-border)`,color:`var(--tpl-text-muted)`,"background-color":`var(--tpl-bg)`},onClick:n[6]||=e=>j(b).showImportUrlModal.value=!0},[p(j(te),{size:14,"stroke-width":2}),M(` `+L(u.value.mediaLibrary.importFromUrl),1)])):N(``,!0)])):N(``,!0),p(Wi,{items:j(b).displayItems.value,"selected-ids":j(y).selectedItems.value,"is-loading":j(y).isLoading.value,"has-more":j(y).viewMode.value===`files`&&j(y).hasMore.value,layout:j(b).layoutMode.value,onSelect:j(b).handleSelect,onToggle:j(y).toggleSelection,onLoadMore:j(y).loadMore,onEdit:j(b).handleEditItem,onReplace:j(b).handleReplaceItem},null,8,[`items`,`selected-ids`,`is-loading`,`has-more`,`layout`,`onSelect`,`onToggle`,`onLoadMore`,`onEdit`,`onReplace`])])])]),p(na,{visible:j(b).showImportUrlModal.value,"is-importing":j(y).isImportingFromUrl.value,error:j(y).importFromUrlError.value,onImport:j(b).handleImportFromUrl,onClose:n[7]||=e=>j(b).showImportUrlModal.value=!1},null,8,[`visible`,`is-importing`,`error`,`onImport`]),p(xr,{visible:!!j(b).editingItem.value,item:j(b).editingItem.value,onSave:j(b).handleEditSave,onClose:n[8]||=e=>j(b).editingItem.value=null},null,8,[`visible`,`item`,`onSave`]),p(Na,{visible:j(y).showReplaceWarning.value,item:j(y).pendingReplaceItem.value,"usage-info":j(y).replaceUsageInfo.value,"is-replacing":j(y).isReplacing.value,error:j(y).replaceError.value,onReplace:j(b).handleReplaceFile,onClose:j(y).cancelReplace},null,8,[`visible`,`item`,`usage-info`,`is-replacing`,`error`,`onReplace`,`onClose`]),p(ve,{"enter-active-class":`tpl:transition tpl:ease-out tpl:duration-150`,"enter-from-class":`tpl:opacity-0`,"enter-to-class":`tpl:opacity-100`,"leave-active-class":`tpl:transition tpl:ease-in tpl:duration-100`,"leave-from-class":`tpl:opacity-100`,"leave-to-class":`tpl:opacity-0`},{default:F(()=>[j(y).showDeleteWarning.value?(z(),t(`div`,{key:0,class:`tpl:absolute tpl:inset-0 tpl:z-10 tpl:flex tpl:items-center tpl:justify-center tpl:rounded-[var(--tpl-radius-lg)]`,style:{"background-color":`rgba(0, 0, 0, 0.5)`,"backdrop-filter":`blur(8px)`,"-webkit-backdrop-filter":`blur(8px)`},onClick:n[11]||=r((...e)=>j(y).cancelDelete&&j(y).cancelDelete(...e),[`self`])},[i(`div`,Co,[i(`h3`,wo,L(u.value.mediaLibrary.deleteWarningTitle),1),i(`p`,{class:k([`tpl:text-xs`,j(b).hasUsedFiles.value?`tpl:mb-2`:`tpl:mb-4`]),style:{color:`var(--tpl-text-muted)`}},L(u.value.mediaLibrary.deleteWarningMessage),3),j(b).hasUsedFiles.value?(z(),t(`p`,To,L(u.value.mediaLibrary.deleteWarningUsageNote),1)):N(``,!0),j(b).hasUsedFiles.value?(z(),t(`div`,Eo,[(z(!0),t(R,null,S(j(y).deleteUsageInfo.value,(e,n)=>(z(),t(`div`,{key:n,class:`tpl:text-xs`,style:{color:`var(--tpl-text)`}},[e.template_count>0?(z(),t(R,{key:0},[i(`span`,Do,L(j(b).displayItems.value.find(e=>e.id===n)?.filename||n),1),i(`span`,Oo,` - `+L(u.value.mediaLibrary.usedInTemplates.replace(`{count}`,e.template_count.toString())),1)],64)):N(``,!0)]))),128))])):N(``,!0),i(`div`,ko,[i(`button`,{class:`tpl:cursor-pointer tpl:rounded-md tpl:border tpl:px-3 tpl:py-1.5 tpl:text-xs tpl:font-medium tpl:transition-all tpl:duration-150`,style:{"border-color":`var(--tpl-border)`,color:`var(--tpl-text)`,"background-color":`var(--tpl-bg)`},onClick:n[9]||=(...e)=>j(y).cancelDelete&&j(y).cancelDelete(...e)},L(u.value.mediaLibrary.cancel),1),i(`button`,{class:`tpl:cursor-pointer tpl:rounded-md tpl:border tpl:px-3 tpl:py-1.5 tpl:text-xs tpl:font-medium tpl:transition-all tpl:duration-150`,style:{"border-color":`var(--tpl-danger)`,color:`var(--tpl-danger)`,"background-color":`var(--tpl-danger-light)`},onClick:n[10]||=(...e)=>j(y).confirmDelete&&j(y).confirmDelete(...e)},L(j(b).hasUsedFiles.value?u.value.mediaLibrary.deleteAnyway:u.value.mediaLibrary.confirmDelete),1)])])])):N(``,!0)]),_:1}),i(`div`,Ao,[i(`div`,jo,[j(y).previewItem.value?(z(),h(va,{key:0,"selected-conversion":j(b).selectedConversion.value,"onUpdate:selectedConversion":n[12]||=e=>j(b).selectedConversion.value=e,item:j(y).previewItem.value,folders:j(y).folders.value},null,8,[`selected-conversion`,`item`,`folders`])):N(``,!0)]),i(`div`,Mo,[j(y).selectedItems.value.size>0?(z(),t(`div`,No,[j(y).previewItem.value?(z(),t(`button`,{key:0,class:`tpl:flex tpl:cursor-pointer tpl:items-center tpl:gap-1 tpl:rounded-md tpl:border tpl:px-3 tpl:py-1.5 tpl:text-xs tpl:font-medium tpl:transition-all tpl:duration-150`,style:P({borderColor:j(b).copied.value?`var(--tpl-success)`:`var(--tpl-border)`,color:j(b).copied.value?`var(--tpl-success)`:`var(--tpl-text)`,backgroundColor:`var(--tpl-bg)`}),onClick:n[13]||=e=>j(b).copy(j(b).selectedUrl.value)},[j(b).copied.value?(z(),h(j(D),{key:1,size:12,"stroke-width":2})):(z(),h(j(ae),{key:0,size:12,"stroke-width":2})),M(` `+L(j(b).copied.value?u.value.mediaLibrary.copied:u.value.mediaLibrary.copyUrl),1)],4)):N(``,!0),d.value?(z(),t(`div`,Po,[i(`button`,{class:`tpl:cursor-pointer tpl:rounded-md tpl:border tpl:px-3 tpl:py-1.5 tpl:text-xs tpl:font-medium tpl:transition-all tpl:duration-150`,style:{"border-color":`var(--tpl-border)`,color:`var(--tpl-text)`,"background-color":`var(--tpl-bg)`},onClick:n[14]||=e=>j(b).showMovePicker.value=!j(b).showMovePicker.value},L(u.value.mediaLibrary.moveSelected),1),j(b).showMovePicker.value?(z(),h(sa,{key:0,folders:j(y).folders.value,"current-folder-id":j(y).currentFolderId.value,onSelect:j(b).handleMoveToFolder,onClose:n[15]||=e=>j(b).showMovePicker.value=!1},null,8,[`folders`,`current-folder-id`,`onSelect`])):N(``,!0)])):N(``,!0)])):N(``,!0),i(`div`,Fo,[j(y).selectedItems.value.size>0?(z(),t(`button`,{key:0,class:`tpl:cursor-pointer tpl:rounded-md tpl:border tpl:px-3 tpl:py-1.5 tpl:text-xs tpl:font-medium tpl:transition-all tpl:duration-150`,style:{"border-color":`var(--tpl-danger)`,color:`var(--tpl-danger)`,"background-color":`var(--tpl-danger-light)`},onClick:n[16]||=(...e)=>j(b).handleDeleteClick&&j(b).handleDeleteClick(...e)},L(u.value.mediaLibrary.deleteSelected),1)):N(``,!0),o.onSelect?(z(),t(`button`,{key:1,class:`tpl:cursor-pointer tpl:rounded-md tpl:px-4 tpl:py-1.5 tpl:text-sm tpl:font-medium tpl:shadow-xs tpl:transition-all tpl:duration-150 tpl:hover:opacity-90 tpl:disabled:cursor-not-allowed tpl:disabled:opacity-50`,style:{"background-color":`var(--tpl-primary)`,color:`var(--tpl-bg)`},disabled:!j(y).previewItem.value,onClick:x},L(u.value.mediaLibrary.selectFile),9,Io)):N(``,!0)])])])]))}}),Ro=(e,t,n)=>{let r=t.lastIndexOf(`?`),i=e[r===-1||r<t.lastIndexOf(`/`)?t:t.slice(0,r)];return i?typeof i==`function`?i():Promise.resolve(i):new Promise((e,r)=>{(typeof queueMicrotask==`function`?queueMicrotask:setTimeout)(r.bind(null,Error(`Unknown variable dynamic import: `+t+(t.split(`/`).length===n?``:`. Note that variables only represent file names one level deep.`))))})},zo=[`en`,`de`];function Bo(e){return e.split(`-`)[0].toLowerCase()}async function Vo(e){let t=Bo(e),n=zo.includes(t)?t:`en`;return(await Ro(Object.assign({"./locales/de.ts":()=>Ne(()=>import(`./chunks/de-DfD_hnV5.js`),[]),"./locales/en.ts":()=>Ne(()=>import(`./chunks/en-DJUYNOeL.js`),[])}),`./locales/${n}.ts`,3)).default}var Ho=null,Uo=e(null);async function Wo(e){let t=typeof e.container==`string`?document.querySelector(e.container):e.container;if(!t)throw Error(`Container element not found: ${e.container}`);Ho&&Go();let n=Ce(e.auth,e.onError);await n.initialize();let r=await new ke(n).fetchConfig(),i=await Vo(e.locale??`en`);return Ko(t,e.theme),new Promise((a,s)=>{try{Ho=be({setup(){let s=()=>{a({setTheme:e=>Ko(t,e),unmount:Go})};return()=>o(Lo,{authManager:n,projectId:n.projectId,planConfig:r,translations:i,onSelect:e.onSelect,onError:e.onError,ref:Uo,onReady:s})}}),Ho.mount(t)}catch(e){s(e)}})}function Go(){Ho&&(Ho.unmount(),Ho=null,Uo.value=null)}function Ko(e,t){t&&(t.primaryColor&&e.style.setProperty(`--tpl-primary`,t.primaryColor),t.borderRadius!==void 0&&(e.style.setProperty(`--tpl-radius`,`${t.borderRadius}px`),e.style.setProperty(`--tpl-radius-sm`,`${Math.max(0,t.borderRadius-3)}px`),e.style.setProperty(`--tpl-radius-lg`,`${t.borderRadius+4}px`)))}typeof window<`u`&&(window.TemplaticalMedia={init:Wo,unmount:Go});
17
+ //# sourceMappingURL=media-library.js.map